00001 #pragma ident "$Id: Text.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
00028 #ifndef VDRAW_TEXT_H
00029 #define VDRAW_TEXT_H
00030
00031 #include <string>
00032 #include <stdio.h>
00033
00034 #include "VDrawException.hpp"
00035 #include "TextStyle.hpp"
00036
00037 namespace vdraw
00038 {
00041
00042
00046 class Text {
00047
00048 public:
00049
00051 double x;
00052
00054 double y;
00055
00059 enum ALIGNMENT {LEFT, CENTER, RIGHT};
00060
00071 Text(const char* str, double ix, double iy, ALIGNMENT align=LEFT, int angle=0);
00072
00084 Text(const char* str, double ix, double iy, const TextStyle& its, ALIGNMENT align=LEFT, int angle=0);
00085
00096 Text(int num, double ix, double iy, ALIGNMENT align=LEFT, int angle=0);
00097
00109 Text(int num, double ix, double iy, const TextStyle& its, ALIGNMENT align=LEFT, int angle=0);
00110
00111
00116 inline void setText(const std::string& str) { textString = str; }
00117
00122 inline void setStyle(TextStyle& its) { hasOwnStyle = true; textStyle = its; }
00123
00127 inline void removeStyle() { hasOwnStyle = false; }
00128
00134 inline void setPosition(double ix, double iy) { x = ix; y = iy; }
00135
00141 inline void setAlignment(ALIGNMENT align) { textAlign = align; }
00142
00148 inline void setAngle(int angle) { textAngle = angle; }
00149
00150
00151
00152
00153
00154
00156 inline std::string getString(void) const { return textString; }
00157
00159 inline bool hasOwnTextStyle(void) const { return hasOwnStyle; }
00160
00162 inline TextStyle getStyle(void) const { return textStyle; }
00163
00165 inline bool isCenter(void) const { return textAlign == CENTER; }
00166
00168 inline bool isLeft(void) const { return textAlign == LEFT; }
00169
00171 inline bool isRight(void) const { return textAlign == RIGHT; }
00172
00174 inline int getAngle(void) const { return textAngle; }
00175
00176 protected:
00177
00178 private:
00179
00180 std::string textString;
00181 bool hasOwnStyle;
00182 TextStyle textStyle;
00183 ALIGNMENT textAlign;
00184 int textAngle;
00185
00186 };
00187
00189
00190 }
00191
00192 #endif //VDRAW_TEXT_H
00193