TextStyle.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: TextStyle.hpp 1644 2009-01-27 19:26:14Z ckiesch $"
00002 
00004 
00005 //============================================================================
00006 //
00007 //  This file is part of GPSTk, the GPS Toolkit.
00008 //
00009 //  The GPSTk is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU Lesser General Public License as published
00011 //  by the Free Software Foundation; either version 2.1 of the License, or
00012 //  any later version.
00013 //
00014 //  The GPSTk is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 //  GNU Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with GPSTk; if not, write to the Free Software Foundation,
00021 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //  
00023 //  Copyright 2004, The University of Texas at Austin
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      * Public stuff
00053      */
00054     public:
00055       /*
00056        * Fields
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        * Constructors
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        * Modifiers
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        * Accessor Methods
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        * Protected stuff
00196        */
00197     protected:
00198 
00199 
00200       /*
00201        * Private stuff
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 

Generated on Wed Feb 8 03:31:03 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1