00001 #pragma ident "$Id: TextStyle.hpp 1644 2009-01-27 19:26:14Z ckiesch $"
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef VDRAW_TEXTSTYLE_H
00028 #define VDRAW_TEXTSTYLE_H
00029
00030 #include <string>
00031 #include <iostream>
00032 #include "Color.hpp"
00033
00034 namespace vdraw
00035 {
00038
00050 class TextStyle {
00051
00052
00053
00054 public:
00055
00056
00057
00060 static const short NORMAL = 0;
00061
00063 static const short BOLD = 1;
00064
00066 static const short ITALIC = 2;
00067
00069 static const short UNDERLINE = 4;
00070
00072 static const short STRIKE = 8;
00073
00075 enum Font{MONOSPACE, SANSSERIF, SERIF};
00076
00077
00078
00079
00080
00084 TextStyle(void);
00085
00092 TextStyle(double ips, short istyle=0);
00093
00102 TextStyle(double ips, short istyle, const Color& icolor, Font ifont=MONOSPACE);
00103
00111 TextStyle(double ips, const Color& icolor, Font ifont=MONOSPACE);
00112
00113
00114
00115
00116
00125 static short style(const char* str);
00126
00134 void setStyle(short istyle);
00135
00137 inline void setColor(const Color &c) { color = c; }
00138
00140 inline void setPointSize(double s) { pointSize = s; }
00141
00142
00143
00144
00145
00147 inline Color getColor(void) const { return color; }
00148
00150 inline double getPointSize(void) const { return pointSize; }
00151
00153 inline bool isBold(void) const { return bold; }
00154
00156 inline bool isItalic(void) const { return italic; }
00157
00159 inline bool isUnderline(void) const { return underline; }
00160
00162 inline bool isStrike(void) const { return strike; }
00163
00165 inline bool isMonospace(void) const { return font == MONOSPACE; }
00166
00168 inline bool isSansSerif(void) const { return font == SANSSERIF; }
00169
00171 inline bool isSerif(void) const { return font == SERIF; }
00172
00174 inline short getStyle(void) const
00175 { return (bold?BOLD:0) & (italic?ITALIC:0) & (underline?UNDERLINE:0) & (strike?STRIKE:0); }
00176
00178 inline Font getFont(void) const { return font; }
00179
00181 inline bool equals(const TextStyle& other) const
00182 {
00183 return (pointSize == other.getPointSize())
00184 && (getStyle() == other.getStyle())
00185 && (font == other.getFont());
00186 }
00187
00189 bool operator==(const TextStyle& rhs) const {return this->equals(rhs);};
00190
00192 bool operator!=(const TextStyle& rhs) const {return !this->equals(rhs);};
00193
00194
00195
00196
00197 protected:
00198
00199
00200
00201
00202
00203 private:
00204
00206 Font font;
00207
00209 Color color;
00210
00212 double pointSize;
00213
00215 bool bold;
00216
00218 bool italic;
00219
00221 bool underline;
00222
00224 bool strike;
00225
00226 };
00227
00229
00230 }
00231 #endif //VDRAW_TEXTSTYLE_H
00232