wGui::CPainter Class Reference

Painter objects take care of all the actual drawing functions needed to draw to an SDL surface. More...

#include <wg_painter.h>

Public Types

Public Member Functions

Protected Member Functions

Protected Attributes


Detailed Description

Painter objects take care of all the actual drawing functions needed to draw to an SDL surface.

Definition at line 40 of file wg_painter.h.


Member Enumeration Documentation

enum wGui::CPainter::EPaintMode

A mode for painting the surface can be specified currently this does not work for the DrawHLine, DrawVLine, or DrawRect methods

Enumerator:
PAINT_IGNORE  Don't actually draw anything.
PAINT_REPLACE  Replace the pixel with the new pixel.
PAINT_NORMAL  Do normal color mixing (uses the alpha channel).
PAINT_OR  OR the new color in.
PAINT_AND  AND the new color in.
PAINT_XOR  XOR the new color in.
PAINT_ADDITIVE  Use Additive color mixing.

Definition at line 45 of file wg_painter.h.


Constructor & Destructor Documentation

wGui::CPainter::CPainter ( SDL_Surface *  pSurface,
EPaintMode  ePaintMode = PAINT_NORMAL 
)

Construct a new Painter object

Parameters:
pSurface A pointer to the SDL surface to draw to
ePaintMode The painting mode to use, defaults to PAINT_NORMAL

Definition at line 35 of file wg_painter.cpp.

References m_pSurface.

wGui::CPainter::CPainter ( CWindow pWindow,
EPaintMode  ePaintMode = PAINT_NORMAL 
)

Construct a new Painter object

Parameters:
pWindow A pointer to the CWindow to draw to, this will only allow drawing to the window's client area
ePaintMode The painting mode to use, defaults to PAINT_NORMAL

Definition at line 47 of file wg_painter.cpp.

References wGui::CWindow::GetSDLSurface(), m_pSurface, and m_pWindow.


Member Function Documentation

void wGui::CPainter::DrawHLine ( int  xStart,
int  xEnd,
int  y,
const CRGBColor LineColor = DEFAULT_LINE_COLOR 
)

Draw a horizontal line

Parameters:
xStart The start position of the line
xEnd The end position of the line
y The vertical location of the line
LineColor The color of the line

Definition at line 64 of file wg_painter.cpp.

References wGui::CWindow::GetClientRect(), m_pSurface, m_pWindow, wGui::CRGBColor::SDLColor(), wGui::CRect::TopLeft(), wGui::CPoint::XPos(), and wGui::CPoint::YPos().

Referenced by wGui::CScrollBar::Draw(), wGui::CProgress::Draw(), wGui::CPopupMenu::Draw(), wGui::CFrame::Draw(), wGui::CCheckBox::Draw(), wGui::CPictureButton::Draw(), wGui::CButton::Draw(), and DrawRect().

void wGui::CPainter::DrawVLine ( int  yStart,
int  yEnd,
int  x,
const CRGBColor LineColor = DEFAULT_LINE_COLOR 
)

Draw a vertical line

Parameters:
yStart The start position of the line
yEnd The end position of the line
x The horizontal location of the line
LineColor The color of the line

Definition at line 82 of file wg_painter.cpp.

References wGui::CWindow::GetClientRect(), m_pSurface, m_pWindow, wGui::CRGBColor::SDLColor(), wGui::CRect::TopLeft(), wGui::CPoint::XPos(), and wGui::CPoint::YPos().

Referenced by wGui::CTextBox::Draw(), wGui::CScrollBar::Draw(), wGui::CProgress::Draw(), wGui::CPopupMenu::Draw(), wGui::CMenu::Draw(), wGui::CFrame::Draw(), wGui::CEditBox::Draw(), wGui::CCheckBox::Draw(), wGui::CPictureButton::Draw(), wGui::CButton::Draw(), DrawLine(), and DrawRect().

void wGui::CPainter::DrawRect ( const CRect Rect,
bool  bFilled,
const CRGBColor BorderColor = DEFAULT_LINE_COLOR,
const CRGBColor FillColor = DEFAULT_FOREGROUND_COLOR 
)

Draw a rectangle (this has been optimized to work much faster for filled rects in PAINT_REPLACE mode)

Parameters:
Rect A CRect that describes the rectangle
bFilled If true, rectangle will be filled with the FillColor, otherwise only the border is drawn
BorderColor The color for the border
FillColor The color to fill the rectangle with

Definition at line 100 of file wg_painter.cpp.

References wGui::CRect::Bottom(), wGui::CRect::ClipTo(), DrawHLine(), DrawPoint(), DrawVLine(), wGui::CWindow::GetClientRect(), wGui::CRect::Grow(), wGui::CRect::Left(), m_PaintMode, m_pSurface, m_pWindow, PAINT_REPLACE, wGui::CRect::Right(), wGui::CRGBColor::SDLColor(), wGui::CRect::SDLRect(), wGui::CRect::Top(), and wGui::CRect::TopLeft().

Referenced by wGui::CWindow::Draw(), wGui::CToolTip::Draw(), wGui::CTextBox::Draw(), wGui::CScrollBar::Draw(), wGui::CProgress::Draw(), wGui::CPopupMenu::Draw(), wGui::CMenu::Draw(), wGui::CListBox::Draw(), wGui::CGroupBox::Draw(), wGui::CFrame::Draw(), wGui::CEditBox::Draw(), wGui::CCheckBox::Draw(), wGui::CPictureButton::Draw(), and wGui::CButton::Draw().

void wGui::CPainter::DrawLine ( const CPoint StartPoint,
const CPoint EndPoint,
const CRGBColor LineColor = DEFAULT_LINE_COLOR 
)

Draw a line between two points

Parameters:
StartPoint The beginning point of the line
EndPoint The end point of the line
LineColor The color to use for drawing the line

Definition at line 138 of file wg_painter.cpp.

References DrawPoint(), DrawVLine(), wGui::CPoint::XPos(), and wGui::CPoint::YPos().

Referenced by wGui::CCheckBox::Draw().

void wGui::CPainter::DrawPoint ( const CPoint Point,
const CRGBColor PointColor = DEFAULT_LINE_COLOR 
)

Draw a pixel

Parameters:
Point The location of the pixel to set
PointColor The color to set the pixel to

Definition at line 169 of file wg_painter.cpp.

References wGui::CWindow::GetClientRect(), LockSurface(), m_pSurface, m_pWindow, MixColor(), ReadPoint(), wGui::CRect::RELPOS_INSIDE, wGui::CRGBColor::SDLColor(), wGui::CRect::TopLeft(), UnlockSurface(), wGui::CPoint::XPos(), and wGui::CPoint::YPos().

Referenced by wGui::CRenderedString::Draw(), DrawLine(), DrawRect(), and ReplaceColor().

CRGBColor wGui::CPainter::ReadPoint ( const CPoint Point  ) 

Get the color of the pixel at the given point

Parameters:
Point The location of the pixel to read
Returns:
A CRGBColor object representing the color of the pixel

Definition at line 207 of file wg_painter.cpp.

References wGui::CWindow::GetClientRect(), m_pSurface, m_pWindow, wGui::CRect::RELPOS_INSIDE, wGui::CRect::TopLeft(), wGui::CPoint::XPos(), and wGui::CPoint::YPos().

Referenced by DrawPoint(), and ReplaceColor().

void wGui::CPainter::ReplaceColor ( const CRGBColor NewColor,
const CRGBColor OldColor 
)

Replace all pixels of a certain color with a new color

Parameters:
NewColor The color value to replace the pixels with
OldColor The color of the pixels to be replaced

Definition at line 301 of file wg_painter.cpp.

References DrawPoint(), m_pSurface, and ReadPoint().

void wGui::CPainter::TransparentColor ( const CRGBColor TransparentColor  ) 

Sets the transparent pixel

Parameters:
TransparentColor The pixel color to be treated as transparent

Definition at line 317 of file wg_painter.cpp.

References m_pSurface.

CRGBColor wGui::CPainter::MixColor ( const CRGBColor ColorBase,
const CRGBColor ColorAdd 
) [protected]

Mixes thje two colors based on the painting mode

Parameters:
ColorBase The color to use as the base
ColorAdd The color to add to the base
Returns:
A CRGBColor object representing the mixed colors

Definition at line 269 of file wg_painter.cpp.

References wGui::COLOR_TRANSPARENT, m_PaintMode, wGui::CRGBColor::MixNormal(), PAINT_ADDITIVE, PAINT_AND, PAINT_IGNORE, PAINT_NORMAL, PAINT_OR, PAINT_REPLACE, and PAINT_XOR.

Referenced by DrawPoint().


The documentation for this class was generated from the following files:
Generated on Wed May 16 23:11:27 2007 for wGui by  doxygen 1.5.1