wg_painter.h

00001 // wg_painter.h
00002 //
00003 // CPainter class which provides useful graphics routines
00004 //
00005 //
00006 // Copyright (c) 2002-2004 Rob Wiskow
00007 // rob-dev@boxedchaos.com
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 //
00014 // This library 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 GNU
00017 // 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 this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022 //
00023 
00024 
00025 #ifndef _WG_GRAPHICS_H_
00026 #define _WG_GRAPHICS_H_
00027 
00028 #include "wg_rect.h"
00029 #include "wg_color.h"
00030 #include "wg_point.h"
00031 #include "wg_window.h"
00032 #include "SDL.h"
00033 
00034 
00035 namespace wGui
00036 {
00037 
00039 
00040 class CPainter
00041 {
00042 public:
00045      enum EPaintMode {
00046           PAINT_IGNORE = 0,  
00047           PAINT_REPLACE,  
00048           PAINT_NORMAL,  
00049           PAINT_OR,  
00050           PAINT_AND,  
00051           PAINT_XOR,  
00052           PAINT_ADDITIVE  
00053      };
00054 
00058      CPainter(SDL_Surface* pSurface, EPaintMode ePaintMode = PAINT_NORMAL);
00059 
00063      CPainter(CWindow* pWindow, EPaintMode ePaintMode = PAINT_NORMAL);
00064 
00066      virtual ~CPainter(void) { }
00067 
00068 
00074      void DrawHLine(int xStart, int xEnd, int y, const CRGBColor& LineColor = DEFAULT_LINE_COLOR);
00075 
00081      void DrawVLine(int yStart, int yEnd, int x, const CRGBColor& LineColor = DEFAULT_LINE_COLOR);
00082 
00088      void DrawRect(const CRect& Rect, bool bFilled, const CRGBColor& BorderColor = DEFAULT_LINE_COLOR,
00089           const CRGBColor& FillColor = DEFAULT_FOREGROUND_COLOR);
00090 
00095      void DrawLine(const CPoint& StartPoint, const CPoint& EndPoint, const CRGBColor& LineColor = DEFAULT_LINE_COLOR);
00096 
00100      void DrawPoint(const CPoint& Point, const CRGBColor& PointColor = DEFAULT_LINE_COLOR);
00101 
00105      CRGBColor ReadPoint(const CPoint& Point);
00106 
00110      void ReplaceColor(const CRGBColor& NewColor, const CRGBColor& OldColor);
00111 
00114      void TransparentColor(const CRGBColor& TransparentColor);
00115 
00116 
00117 protected:
00119      void LockSurface(void);
00120 
00122      void UnlockSurface(void);
00123 
00128      CRGBColor MixColor(const CRGBColor& ColorBase, const CRGBColor& ColorAdd);
00129 
00130      SDL_Surface* m_pSurface;  
00131      CWindow* m_pWindow;  
00132      EPaintMode m_PaintMode;  
00133 };
00134 
00135 
00136 }
00137 
00138 #endif // _WG_GRAPHICS_H_
00139 

Generated on Wed May 16 23:11:26 2007 for wGui by  doxygen 1.5.1