UpdateCanvas Class Reference

Class for painting outside a WM_PAINT message. More...

Inherits Canvas.

List of all members.

Public Member Functions

int drawText (const SmartUtil::tstring &text, const SmartWin::Rectangle &rect, unsigned format)
 Draws given string within given Rectangle.
void ellipse (const SmartWin::Rectangle &rect)
 Draws an ellipse in the Device Context.
void ellipse (int left, int top, int right, int bottom)
 Draws an ellipse in the Device Context.
bool extFloodFill (int x, int y, COLORREF color, bool fillTilColorFound)
 parameter.
void extTextOut (const SmartUtil::tstring &text, unsigned x, unsigned y)
 Draws given text inside given Rectangle.
void fillRectangle (const SmartWin::Rectangle &rect, Brush &brush)
 Fills a Rectangle in the Device Context with the given brush.
void fillRectangle (int left, int top, int right, int bottom, Brush &brush)
 Fills a Rectangle in the Device Context with the given brush.
COLORREF getBkColor ()
 Gets the background color for the this Canvas.
HDC getDc ()
 Returns the Device Context for the Canvas.
int getDeviceCaps (int nIndex)
 Gets the device capabilities.
COLORREF getPixel (const Point &coord)
 Returns the pixel's color at given point.
COLORREF getPixel (int x, int y)
 Returns the pixel's color at (x,y).
COLORREF getSysColor (int index)
 Gets the color for an system display object.
void line (const SmartWin::Rectangle &rect)
 Draws a line around a Rectangle without filling it.
void line (const Point &start, const Point &end)
 Draws a line from Start to End in the Device Context.
void line (int xStart, int yStart, int xEnd, int yEnd)
 Draws a line in the Device Context.
void lineTo (const Point &coord)
 Draws a line from the current position to a specific Point.
void lineTo (int x, int y)
 Draws a line from the current position to a X,Y point.
void moveTo (const Point &coord)
 Moves to a specific Point. (But does not draw).
void moveTo (int x, int y)
 Moves to a X,Y point. (But does not draw).
void polygon (POINT points[], unsigned count)
 Fills a polygon defined by vertices.
void polygon (const Point points[], unsigned count)
 Fills a polygon defined by vertices.
void rectangle (const SmartWin::Rectangle &rect)
 Draws a Rectangle in the Device Context.
void rectangle (int left, int top, int right, int bottom)
 Draws a Rectangle in the Device Context.
void selectFont (FontPtr font)
 Selects the given font.
COLORREF setBkColor (COLORREF crColor)
 Sets the background color for the this Canvas.
bool setBkMode (bool transparent=false)
 Sets the background mode.
COLORREF setPixel (int x, int y, COLORREF pixcolor)
 Sets the pixel at (x,y) to be pixcolor. Returns the old pixel color.
unsigned setTextAlign (unsigned fMode)
 Sets the alignment mode for text operations.
COLORREF setTextColor (COLORREF crColor)
 Sets the TextColor of the this Canvas.
 UpdateCanvas (Widget *widget)
 Constructor, automatically calls GetDC.
 UpdateCanvas (HWND hWnd)
 Constructor, automatically calls GetDC.
virtual ~UpdateCanvas ()
 DTOR, automatically calls ReleaseDC.

Protected Attributes

HWND itsHandle
 Handle to the window of the object.
HDC itsHdc
 Handle to the Device Context of the object.


Detailed Description

Class for painting outside a WM_PAINT message.

Helper class for securing that GetDC and ReleaseDC is called in Constructor and DTOR.
Instantiate an object if this type where ever you want except within a WM_PAINT event handler (where you
should rather use PaintCanvas) to get access to draw objects within a window.
Then when Widget is invalidated or updated your "painting" will show.
Related classes


Constructor & Destructor Documentation

UpdateCanvas ( HWND  hWnd  )  [explicit]

Constructor, automatically calls GetDC.

Takes the handle to the window we're supposed to paint.

UpdateCanvas ( Widget widget  ) 

Constructor, automatically calls GetDC.

Takes a pointer to the Widget we're supposed to paint.

~UpdateCanvas (  )  [virtual]

DTOR, automatically calls ReleaseDC.

Automtaically releases the Device Context


Member Function Documentation

int drawText ( const SmartUtil::tstring &  text,
const SmartWin::Rectangle rect,
unsigned  format 
) [inherited]

Draws given string within given Rectangle.

Draw text within a rectangle according to given format.
The format can be any combination of:

Google for or look at MSDN what their different meaning are.

void ellipse ( const SmartWin::Rectangle rect  )  [inherited]

Draws an ellipse in the Device Context.

Draws an ellipse within the given rectangle.

void ellipse ( int  left,
int  top,
int  right,
int  bottom 
) [inherited]

Draws an ellipse in the Device Context.

Draws an ellipse from (left, top) to (right, bottom).

bool extFloodFill ( int  x,
int  y,
COLORREF  color,
bool  fillTilColorFound 
) [inherited]

parameter.

If fillTilColorFound is true filling continues outwards from (x,y) until we find the given color and stops there.
If it is false it will fill AS LONG as it finds the given color and stop when it finds another color.
Function returns true if any filling was done, if no filling was done at all it'll return false.

void extTextOut ( const SmartUtil::tstring &  text,
unsigned  x,
unsigned  y 
) [inherited]

Draws given text inside given Rectangle.

Draw text within coordinates of given Rectangle according to
setTextColor, setTextAlign, SetTextJustification

void fillRectangle ( const SmartWin::Rectangle rect,
Brush brush 
) [inherited]

Fills a Rectangle in the Device Context with the given brush.

Fills a Rectangle within the given Rectangle.

void fillRectangle ( int  left,
int  top,
int  right,
int  bottom,
Brush brush 
) [inherited]

Fills a Rectangle in the Device Context with the given brush.

Fills a Rectangle from (left, top) to (right, bottom).

COLORREF getBkColor (  )  [inherited]

Gets the background color for the this Canvas.

Gets the background color for extTextOut() calls. Returns the current background color.

HDC getDc (  )  [inherited]

Returns the Device Context for the Canvas.

Can be used to construct e.g. a Pen object or a HdcModeSetter object

int getDeviceCaps ( int  nIndex  )  [inherited]

Gets the device capabilities.

HORZRES, VERTRES give pixels

COLORREF getPixel ( const Point coord  )  [inherited]

Returns the pixel's color at given point.

Returns the pixel's color at coord in the Device Context of the object.

COLORREF getPixel ( int  x,
int  y 
) [inherited]

Returns the pixel's color at (x,y).

Returns the pixel's color at (x,y) in the Device Context of the object.

COLORREF getSysColor ( int  index  )  [inherited]

Gets the color for an system display object.

Example: getSysColor( COLOR_WINDOW )

void line ( const SmartWin::Rectangle rect  )  [inherited]

Draws a line around a Rectangle without filling it.

Draws a line from rect.pos to rect.pos + rect.size
(Use Rectangle if you want to fill it.)

void line ( const Point start,
const Point end 
) [inherited]

Draws a line from Start to End in the Device Context.

Draws a line from Start to End.
An alternate for line( int xStart, int yStart, int xEnd, int yEnd )

void line ( int  xStart,
int  yStart,
int  xEnd,
int  yEnd 
) [inherited]

Draws a line in the Device Context.

Draws a line from (xStart, yStart) to (xEnd, yEnd).

void lineTo ( const Point coord  )  [inherited]

Draws a line from the current position to a specific Point.

Draws to Point in the Device Context of the object. Use line (below) if you know two coordinates.

void lineTo ( int  x,
int  y 
) [inherited]

Draws a line from the current position to a X,Y point.

Draws to x,y in the Device Context of the object. Use line (below) if you know two coordinates.

void moveTo ( const Point coord  )  [inherited]

Moves to a specific Point. (But does not draw).

Moves to Point in the Device Context of the object.

void moveTo ( int  x,
int  y 
) [inherited]

Moves to a X,Y point. (But does not draw).

Moves to x,y in the Device Context of the object.

void polygon ( POINT  points[],
unsigned  count 
) [inherited]

Fills a polygon defined by vertices.

Fills a polygon defined by vertices.

void polygon ( const Point  points[],
unsigned  count 
) [inherited]

Fills a polygon defined by vertices.

Fills a polygon defined by vertices.

void rectangle ( const SmartWin::Rectangle rect  )  [inherited]

Draws a Rectangle in the Device Context.

Draws a Rectangle from (pos) to ( pos + size ). Uses the current Pen to outline, and the current Brush to fill it.

void rectangle ( int  left,
int  top,
int  right,
int  bottom 
) [inherited]

Draws a Rectangle in the Device Context.

Draws a Rectangle from (left, top) to (right, bottom). Uses the current Pen to outline, and the current Brush to fill it.

void selectFont ( FontPtr  font  )  [inherited]

Selects the given font.

Selects the given font for later text operations

COLORREF setBkColor ( COLORREF  crColor  )  [inherited]

Sets the background color for the this Canvas.

Sets the background color for extTextOut() calls. Returns the previous background color

bool setBkMode ( bool  transparent = false  )  [inherited]

Sets the background mode.

Can either be transparent (true) or opaque (false). Returns true if the previous background mode was transparent, false if it was opaque

COLORREF setPixel ( int  x,
int  y,
COLORREF  pixcolor 
) [inherited]

Sets the pixel at (x,y) to be pixcolor. Returns the old pixel color.

Sets the pixel at (x,y) to be pixcol

unsigned setTextAlign ( unsigned  fMode  )  [inherited]

Sets the alignment mode for text operations.

Returns the previous alignement mode and changes the current mode of text operations. Possible values can be any combination of these:

COLORREF setTextColor ( COLORREF  crColor  )  [inherited]

Sets the TextColor of the this Canvas.

Sets the TextColor for future TextOut() calls. Returns the previous color.


Member Data Documentation

HWND itsHandle [protected, inherited]

Handle to the window of the object.

Handle of the window that the Canvas is for

HDC itsHdc [protected, inherited]

Handle to the Device Context of the object.

Derived classes needs access to this to e.g. call BeginPaint and EndPaint

Back to SmartWin website
SourceForge.net Logo