00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _ufont_hpp_
00026 #define _ufont_hpp_
00027
00028 #include <ubit/uprop.hpp>
00029
00030
00033 class UFont : public UProp {
00034 public:
00035 static const int MIN_LSIZE = 1;
00036 static const int MEDIUM_LSIZE = 8;
00037 static const int MAX_LSIZE = 23;
00039
00040 static const int FONTMAP_SIZE = 4 * (UFont::MAX_LSIZE + 1);
00042
00043 struct FontSize {
00044 int logsize;
00045 int ptsize;
00046 const char *natspec;
00047 };
00049
00050 enum FontStyle {
00051 BOLD = 1<<0,
00052 ITALIC = 1<<1,
00053 FILL = 1<<2,
00054 UNDERLINE = 1<<3,
00055 OVERLINE = 1<<4,
00056 STRIKETHROUGH = 1<<5
00057 };
00059
00060
00061
00062 static UFont normal, bold, italic, fill, underline, overline, strikethrough;
00063 static UFont _bold, _italic, _fill, _underline, _overline, _strikethrough;
00070 static UFont xx_small, x_small, small, medium, large, x_large, xx_large;
00074 static UFont standard, inherit, helvetica, courier, times, fixed;
00079
00080
00081 UFont(const class UFontFamily& family, int style = 0, int lsize = 0, u_modes = 0);
00091 UFont(const UFont& = UFont::standard);
00093
00094 friend UFont& ufont(const UFont& _f) {return *new UFont(_f);}
00096
00097
00098
00099 UFont& operator=(const UFont&);
00101
00102 virtual void set(const UFont&);
00104
00105 virtual void merge(const UFont&);
00109
00110
00111 virtual bool equals(const UFont&) const;
00113
00114 bool isBold() const;
00115 bool isItalic() const;
00117
00118 bool isFilled() const;
00119 bool isUnderlined() const;
00120 bool isOverlined() const;
00121 bool isStrikethrough() const;
00122
00123
00124
00125 void setFamily(const UFont&);
00126 void setFamily(const class UFontFamily&);
00128
00129 const class UFontFamily* getFamily() const;
00131
00132 void setStyle(const UFont&);
00133 void setStyle(signed int font_styles, bool update);
00140 void setSize(const UFont &f);
00142
00143 int getLsize() const;
00145
00146 void setLsize(int logical_size, bool update = true);
00148
00149 int getPointSize() const;
00150 int getPtsize() const;
00152
00153 void setPointSize(int point_size, bool update = true);
00154 void setPtsize(int point_size, bool update = true);
00156
00157
00158
00159 virtual void update();
00161
00162 bool realize(class UDisp*);
00169 #ifndef NO_DOC
00170
00171
00172
00173 friend class UDisp;
00174 friend class UNatDisp;
00175 friend class UFontDesc;
00176
00177 void setImpl(const UFontDesc*, bool update);
00178 virtual void putProp(class UContext*, class UCtrl*);
00179
00180 private:
00181 const class UFontFamily *family;
00182 short lsize;
00183 short onStyles, offStyles;
00184 #endif
00185 };
00186
00187
00188
00189
00194 class UFontFamily {
00195 public:
00202 static UFontFamily standard, any, helvetica, times, courier, fixed;
00203
00204 void init(const char *name,
00205 const char *normal_weight = "medium",
00206 const char *bold_weight = "bold",
00207 const char *slant = "o",
00208 const char *compression = "normal",
00209 const char *encoding = "1",
00210 const UFont::FontSize *font_sizes = null);
00218 int lsizeToPtsize(int logical_size) const;
00219 int ptsizeToLsize(int point_size) const;
00221
00222 static float getXYScale(short lscale);
00224
00225 static const UFont::FontSize* getFontSizes();
00227
00228 #ifndef NO_DOC
00229
00230
00231
00232 friend class UDisp;
00233 friend class UNatDisp;
00234 friend class UFont;
00235 private:
00236 static const UFont::FontSize *FONT_SIZES;
00237 static int family_count;
00238 unsigned long index;
00239 const char *name;
00240 const char *normal_weight, *bold_weight, *slant, *compression, *encoding;
00241 const UFont::FontSize *font_sizes;
00242 #endif
00243 };
00244
00245
00246
00247
00251 struct UFontDesc {
00252 const class UFontFamily* family;
00253 short font_ix, lsize, styles;
00254
00255 UFontDesc() {}
00256 UFontDesc(const UFont&);
00257
00258 void set(const UFont&);
00259 void set(const UFont&, int delta_scale);
00260
00261
00262 void merge(const UFont&, int delta_scale);
00263
00264
00265 void incrScale(int delta_scale);
00266 };
00267
00268 #endif
00269
00270
00271