00001
00002 #ifndef ZFONT_H
00003 #define ZFONT_H
00004
00005 #include <qimage.h>
00006 #include <qpixmap.h>
00007 #include <qstring.h>
00008 #include <qdirectpainter_qws.h>
00009 #include <qgfx_qws.h>
00010 #include <qstring.h>
00011 #include "ZSurface.h"
00012
00013
00014
00016
00042 class ZFont: public ZSurface
00043 {
00044
00045
00046 public:
00050 ZFont();
00055 ZFont(const QImage &,QColor backColor);
00060 ZFont(const QPixmap &,QColor backColor);
00066 ZFont(const QFont &,QColor foreCol, QColor backCol);
00067
00072 ZFont(const ZFont &);
00076 ZFont & operator=(const ZFont &f);
00077
00081 ~ZFont();
00082
00088 bool create(const QImage &, QColor backColor);
00094 bool create(const QPixmap &,QColor backColor);
00100 bool create(const QFont &, QColor foreColor, QColor backCol);
00101
00105 inline int charWidth(char c) const
00106 {
00107 return iWidth[(int)c-32];
00108 }
00112 inline int x(char c) const
00113 {
00114 return iOffset[(int)c-32];
00115 }
00116
00117
00118
00119
00120
00121
00126 inline int height() const
00127 {
00128 return iHeight;
00129 }
00133 inline int y() const
00134 {
00135 return skipTop;
00136 }
00141 inline void setSpacing(int s)
00142 {
00143 iSpacing=s;
00144 }
00149 inline int spacing() const
00150 {
00151 return iSpacing;
00152 }
00153
00157 int stringWidth(const QString &s) const;
00158
00159
00163 QColor backgroundColor() const
00164 {
00165 return iBackColor;
00166 }
00167
00168 private:
00169
00170 void initGeneric();
00171 void initFromCustomImage(QColor c);
00172 bool initFromCustomFont(const QFont &f, QColor fc, QColor bc);
00173
00174 void copyFont(const ZFont &);
00175
00176 int iOffset[256-32];
00177 int iWidth[256-32];
00178 int iHeight;
00179
00180 int skipTop;
00181 int iSpacing;
00182 QColor iBackColor;
00183
00184 };
00185
00186 #endif // INPUT_DIALOG_H
00187