Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

arspaint.h

Go to the documentation of this file.
00001 #if !defined( __ARSPAINT_H__ )
00002 #define __ARSPAINT_H__
00003 
00004 namespace Ars
00005 {
00006 class HPaint {
00007 public:
00010         enum EPaintMode {
00011                 PAINT_IGNORE = 0,  
00012                 PAINT_REPLACE,  
00013                 PAINT_NORMAL,  
00014                 PAINT_OR,  
00015                 PAINT_AND,  
00016                 PAINT_XOR  
00017         };
00018 protected:
00019 
00020         friend class View;
00021 
00022         SDL_Surface *&m_pSurface;  
00023 
00024         EPaintMode m_PaintMode;  
00025 
00026         FontEngine *m_pFontEngine;  
00027 
00028         mutable XPoint m_CachedBoundedDimensions;  
00029         mutable XPoint m_OriginOffset;  
00030         mutable std::vector<XRect> m_CachedCharacterRects;  
00031         mutable bool m_bCachedMetricsValid;  
00032         char m_MaskChar; 
00033         int m_MaxFontHeight; 
00034         XPoint  textSize;
00035 
00036 private:
00037 
00038         unsigned long   states; 
00039 
00040 public:
00041 
00042         static SDL_Surface *NoSurface;
00043 
00044         HPaint( void );
00045 
00046         HPaint( SDL_Surface *&surface );
00047 
00048         const EPaintMode SetMode( const EPaintMode aNewMode )
00049         {
00050                 EPaintMode      ans = m_PaintMode;
00051                 m_PaintMode = aNewMode;
00052                 return ans;
00053         }
00054 
00055         FontEngine *SetFont( FontEngine *aFontEngine )  
00056         {
00057                 FontEngine *ans = m_pFontEngine;
00058                 m_pFontEngine = aFontEngine;
00059                 m_bCachedMetricsValid = false;
00060                 return ans;
00061         }
00062         FontEngine *GetFont( void )     {       return m_pFontEngine;   }
00063 
00064         const int       GetFontSize( void ) const       {       return m_pFontEngine->GetFontSize();    }
00065 
00068         XPoint GetTextSize( const string &str );
00069 
00074         void GetMetrics( const string &str , XPoint* pBoundedDimensions, XPoint* pOriginOffset, std::vector<XRect>* pCharacterRects = 0) const;
00075 
00076         void SetTextAlign( const int vAlign , const int hAlign = -1 )
00077         {       
00078                 if( vAlign != -1 )
00079                 {
00080                         states &= ~VALIGN_MASK;
00081                         states |= vAlign;
00082                 }
00083                 if( hAlign != -1 )
00084                 {
00085                         states &= ~HALIGN_MASK;
00086                         states |= vAlign;
00087                 }
00088         }
00089         virtual const unsigned long GetStates( void ) const     {       return states;  }
00090 
00093         unsigned int GetMaxFontHeight( void );
00094 
00099         virtual void TextOutStr( const XRect &BoundingRect, const std::string &str , const RGBColor &FontColor );
00100 
00103         void SetMaskChar( const char MaskChar ) { m_MaskChar = MaskChar; }
00104 
00105         void _TextOut( XRect &drawRect , XPoint &OriginPoint , const std::string &str , const RGBColor &FontColor );
00106 
00108         void SetGDI( SDL_Surface *&surface )    {       m_pSurface = surface;   }
00109 
00111         SDL_Surface *&GetGDI( void ) const      {       return m_pSurface;      }
00112 
00118         void DrawHLine( const int xStart, const int xEnd, const int y, const RGBColor& LineColor );
00119 
00125         void DrawVLine( const int yStart, const int yEnd, const int x, const RGBColor& LineColor );
00126 
00132         void DrawRect( const XRect& Rect, const bool bFilled, const RGBColor& BorderColor , const RGBColor& FillColor );
00133 
00138         void DrawLine( const XPoint& StartPoint, const XPoint& EndPoint, const RGBColor& LineColor );
00139 
00143         void DrawPoint(const XPoint& Point, const RGBColor& PointColor );
00144         void DrawPoint( SDL_Surface *s , const XPoint& Point, const RGBColor& PointColor );
00145 
00149         RGBColor ReadPoint(const XPoint& Point);
00150         RGBColor ReadPoint( SDL_Surface *s , const XPoint &Point);
00151 
00155         void ReplaceColor(const RGBColor& NewColor, const RGBColor& OldColor);
00156 
00159         void TransparentColor(const RGBColor& TransparentColor);
00160 
00161 
00162 protected:
00164         void LockSurface(void);
00165 
00167         void UnlockSurface(void);
00168 
00173         RGBColor MixColor(const RGBColor& ColorBase, const RGBColor& ColorAdd);
00174 };
00175 
00177 class Painter : public HPaint , public Thing    {
00178 public:
00179 
00183         Painter( void );
00184 
00186         virtual ~Painter( void ) { }
00187 
00192         virtual void Init( icstring &aStr );
00193 
00194         void SetTextAlign( const int vAlign , const int hAlign = -1 )
00195         {       
00196                 if( vAlign != -1 )
00197                 {
00198                         ResetState( VALIGN_MASK );
00199                         SetState( vAlign );
00200                 }
00201                 if( hAlign != -1 )
00202                 {
00203                         ResetState( HALIGN_MASK );
00204                         SetState( hAlign );
00205                 }
00206         }
00207         virtual const unsigned long GetStates( void ) const     {       return Thing::GetStates();      }
00208 };
00209 }
00210 
00211 #endif

Generated on Fri Dec 5 04:05:59 2003 for Borqueror by doxygen 1.3.3