Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

ufont.hpp

00001 /* ==================================================== ======== ======= * 00002 * 00003 * ufont.hpp 00004 * Ubit Project [Elc][2003] 00005 * Author: Eric Lecolinet 00006 * 00007 * Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs 00008 * 00009 * (C) 1999-2003 Eric Lecolinet @ ENST Paris 00010 * WWW: http://www.enst.fr/~elc/ubit Email: elc@enst.fr (subject: ubit) 00011 * 00012 * *********************************************************************** 00013 * COPYRIGHT NOTICE : 00014 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 00015 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 00016 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 00017 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 00018 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION. 00019 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS. 00020 * *********************************************************************** 00021 * 00022 * ==================================================== [Elc:03] ======= * 00023 * ==================================================== ======== ======= */ 00024 00025 #ifndef _ufont_hpp_ 00026 #define _ufont_hpp_ 00027 //pragma ident "@(#)ufont.hpp ubit:03.06.02" 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; // logical size 00045 int ptsize; // point size 00046 const char *natspec; // native point spec 00047 }; 00049 00050 enum FontStyle { 00051 BOLD = 1<<0, // DON'T CHANGE VALUE! 00052 ITALIC = 1<<1, // DON'T CHANGE VALUE! 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 // implementation 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; // logical font size of this UFont 00183 short onStyles, offStyles; // activated and disactivated styles 00184 #endif 00185 }; 00186 00187 /* ==================================================== [Elc:03] ======= */ 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", // may be "i" 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 // implementation 00231 00232 friend class UDisp; 00233 friend class UNatDisp; 00234 friend class UFont; 00235 private: 00236 static const UFont::FontSize *FONT_SIZES; // array of MAX_LSIZE 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; // array of MAX_LSIZE 00242 #endif 00243 }; 00244 00245 /* ==================================================== [Elc:03] ======= */ 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 // merge only sets NON default values (and combines styles) 00262 void merge(const UFont&, int delta_scale); 00263 00264 // note: decrements if the value is negative 00265 void incrScale(int delta_scale); 00266 }; 00267 00268 #endif 00269 /* ==================================================== [TheEnd] ======= */ 00270 /* ==================================================== [Elc:03] ======= */ 00271

Generated on Wed Aug 18 07:38:55 2004 for Ubit[Eric.Lecolinet@enst.fr] by doxygen 1.3.7