Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::Win32Context Class Reference

A Context provides the lowest level graphics interface to the native systems 2D drawing operations. More...

#include <Win32Context.h>

Inheritance diagram for VCF::Win32Context:

VCF::Object VCF::ContextPeer VCF::Win32ControlContext List of all members.

Public Member Functions

 Win32Context ()
 Win32Context (const uint32 &width, const uint32 &height)
 creates a new HDC from scratch
 Win32Context (OSHandleID contextID)
virtual ~Win32Context ()
virtual void setContext (GraphicsContext *context)
virtual GraphicsContextgetContext ()
virtual OSHandleID getContextID ()
virtual void setContextID (OSHandleID handle)
void init ()
virtual void setOrigin (const double &x, const double &y)
virtual Point getOrigin ()
virtual bool isAntiAliasingOn ()
 Turns the XOR mode on or off.
virtual void setAntiAliasingOn (bool antiAliasingOn)
virtual bool prepareForDrawing (int32 drawingOperation)
 this method is called for the peer to initialize any graphics resources before calling the following methods:
virtual void finishedDrawing (int32 drawingOperation)
virtual bool isMemoryContext ()
 is this context Peer in memory or does it associated with a component ?
virtual void copyContext (const Rect &sourceRect, const Rect &destRect, ContextPeer *sourceContext)
virtual void textAt (const Rect &bounds, const String &text, const int32 &drawOptions=0)
virtual double getTextWidth (const String &text)
virtual double getTextHeight (const String &text)
virtual void lineTo (const double &x, const double &y)
virtual void moveTo (const double &x, const double &y)
virtual void closePath ()
virtual void rectangle (const double &x1, const double &y1, const double &x2, const double &y2)
virtual void roundRect (const double &x1, const double &y1, const double &x2, const double &y2, const double &xc, const double &yc)
virtual void ellipse (const double &x1, const double &y1, const double &x2, const double &y2)
virtual void arc (const double &x1, const double &y1, const double &x2, const double &y2, const double &x3, const double &y3, const double &x4, const double &y4)
virtual void polyline (const std::vector< Point > &pts)
virtual void curve (const double &x1, const double &y1, const double &x2, const double &y2, const double &x3, const double &y3, const double &x4, const double &y4)
virtual void drawImage (const double &x, const double &y, Rect *imageBounds, Image *image, int compositeMode)
virtual void bitBlit (const double &x, const double &y, Rect *imageBounds, Image *image)
 "Blits" the image to the underlying graphics context.
void copyToImage (Win32Image *image)
virtual void checkHandle ()
 make sure we always have the HDC ( device context handle ) we need.
virtual void releaseHandle ()
 Does the opposite operation of checkHandle(), i.e.
virtual void setTextAlignment (const bool &alignTobaseline)
 this is used to determine how to align text when the windowing systems draws it.
virtual bool isTextAlignedToBaseline ()
virtual void setClippingPath (Path *clippingPath)
 sets the current clipping path to be used for the duration of the Contexts lifetime or until it has been changed
virtual void setClippingRect (Rect *clipRect)
virtual void drawThemeSelectionRect (Rect *rect, DrawUIState &state)
virtual void drawThemeFocusRect (Rect *rect, DrawUIState &state)
 Draws a focus rect, which is an inverted gray dotted line around the rect.
virtual void drawThemeButtonRect (Rect *rect, ButtonState &state, Rect *captionRect=NULL)
 Draws a button's background, the border, and its caption.
virtual void drawThemeButtonFocusRect (Rect *rect)
 Similar to drawThemeFocusRect, but dimension of the focus rect is chosen by the peer.
virtual void drawThemeCheckboxRect (Rect *rect, ButtonState &state)
virtual void drawThemeRadioButtonRect (Rect *rect, ButtonState &state)
virtual void drawThemeComboboxRect (Rect *rect, ButtonState &state)
virtual void drawThemeScrollButtonRect (Rect *rect, ScrollBarState &state)
virtual void drawThemeDisclosureButton (Rect *rect, DisclosureButtonState &state)
 Draws a button that is used to open up more details, for example the button that opens up a tree node to reveal it's children, that is compliant with the native windowing systems default look and feel.
virtual void drawThemeTab (Rect *rect, TabState &state)
 Draws a tab, the part of the TabbedPages control that acts like a little button to activate a page, that is compliant with the native windowing systems default look and feel.
virtual void drawThemeTabPage (Rect *rect, DrawUIState &state)
 Draws a tab page - the page on which other controls for the page are parented to, that is compliant with the native windowing systems default look and feel.
virtual void drawThemeTabContent (Rect *rect, DrawUIState &state)
virtual void drawThemeTabs (Rect *rect, DrawUIState &paneState, TabState &selectedTabState, TabState &otherTabs, const std::vector< String > &tabNames, int selectedTabIndex)
virtual void drawThemeTickMarks (Rect *rect, SliderState &state)
 Draws a tick mark, like that used for a slider control, that is compliant with the native windowing systems default look and feel.
virtual void drawThemeSlider (Rect *rect, SliderState &state)
 Draws a slider control, like that used for a slider control, that is compliant with the native windowing systems default look and feel.
virtual void drawThemeProgress (Rect *rect, ProgressState &state)
 Draws a progress bar control, that is compliant with the native windowing systems default look and feel.
virtual void drawThemeImage (Rect *rect, Image *image, DrawUIState &state)
virtual void drawThemeHeader (Rect *rect, ButtonState &state)
 Draws a header control that is compliant with the native windowing systems default look and feel.
virtual void drawThemeEdge (Rect *rect, DrawUIState &state, const int32 &edgeSides, const int32 &edgeStyle)
 draws edges, useful for separators, that is compliant with the native windowing systems default look and feel.
virtual void drawThemeBorder (Rect *rect, DrawUIState &state)
virtual void drawThemeSizeGripper (Rect *rect, DrawUIState &state)
 Draws a size gripper for resizing a control/window that is compliant with the native windowing systems default look and feel.
virtual void drawThemeBackground (Rect *rect, BackgroundState &state)
 Draws a them compliant background.
virtual void drawThemeMenuItem (Rect *rect, MenuState &state)
 Draws the background appropriate for a menu item that is compliant with the native windowing systems default look and feel.
virtual void drawThemeMenuItemText (Rect *rect, MenuState &state)
virtual void drawThemeText (Rect *rect, TextState &state)

Protected Member Functions

void drawImageAGG (const double &x, const double &y, Rect *imageBounds, Image *image)
void drawGrayScaleImage (const double &x, const double &y, Rect *imageBounds, Image *image)
void prepareDCWithContextFont (HFONT &fontHandle)
HDC getDC ()

Static Protected Member Functions

static void drawTransparentBitmap (HDC hdc, HBITMAP hBitmap, int32 xStart, int32 yStart, COLORREF cTransparentColor)
 Utility function to draw a transparent bitmap.

Protected Attributes

HRGN clipRGN_
bool pathStarted_
Point oldOrigin_
Point origin_
bool inFillPath_
HDC dc_
HBITMAP memBitmap_
HBITMAP originalBitmap_
HBRUSH currentHBrush_
HPEN currentHPen_
HFONT currentHFont_
int currentDCState_
bool isMemoryCtx_
GraphicsContextcontext_
bool alignToBaseline_

Detailed Description

A Context provides the lowest level graphics interface to the native systems 2D drawing operations.

Based loosely on PostScript, a Context takes a series of of drawing operations, or commands (lineTo, moveTo, etc), and then executes them by either filling or strokeing the path(s) that result from the commands. Thus calling ellipse() will not draw anything till the strokePath() or fillPath() methods have been called. All path commands should add their information to a stack of some sort that is then looped through and executed using the appropriate native graphics calls. At each path command a test should be made as to whether the buffer should be cleared. The buffer should be cleared only after the stroke of fill methods have been called. For example:

	ellipse(23,23,45,67) //added to buffer
	moveTo(89,100) //add to buffer
	lineTo(300,40) //add to buffer
	strokePath()
	fillPath()
	rectangle(200,300,400,400)//buffer cleared, then add to buffer


Constructor & Destructor Documentation

VCF::Win32Context::Win32Context  ) 
 

VCF::Win32Context::Win32Context const uint32 width,
const uint32 height
 

creates a new HDC from scratch

VCF::Win32Context::Win32Context OSHandleID  contextID  ) 
 

virtual VCF::Win32Context::~Win32Context  )  [virtual]
 


Member Function Documentation

virtual void VCF::Win32Context::arc const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
const double &  x3,
const double &  y3,
const double &  x4,
const double &  y4
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::bitBlit const double &  x,
const double &  y,
Rect imageBounds,
Image image
[virtual]
 

"Blits" the image to the underlying graphics context.

No attempt is made to transform the image. The image is blitted to the coordinates specified by the x and y arguments, and the image's width and height are used to determine the bounds.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::checkHandle  )  [inline, virtual]
 

make sure we always have the HDC ( device context handle ) we need.

Normally the paint function already receives the correct handle so this is a no-op (does nothing). In the case of a control we may need to get a different HDC, for example when painting under a mouse move event or getting other informations depending on the device context.

See also:
releaseHandle()

Reimplemented in VCF::Win32ControlContext.

virtual void VCF::Win32Context::closePath  )  [virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::copyContext const Rect sourceRect,
const Rect destRect,
ContextPeer sourceContext
[virtual]
 

Implements VCF::ContextPeer.

void VCF::Win32Context::copyToImage Win32Image image  ) 
 

virtual void VCF::Win32Context::curve const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
const double &  x3,
const double &  y3,
const double &  x4,
const double &  y4
[virtual]
 

Implements VCF::ContextPeer.

void VCF::Win32Context::drawGrayScaleImage const double &  x,
const double &  y,
Rect imageBounds,
Image image
[protected]
 

virtual void VCF::Win32Context::drawImage const double &  x,
const double &  y,
Rect imageBounds,
Image image,
int  compositeMode
[virtual]
 

Implements VCF::ContextPeer.

void VCF::Win32Context::drawImageAGG const double &  x,
const double &  y,
Rect imageBounds,
Image image
[protected]
 

virtual void VCF::Win32Context::drawThemeBackground Rect rect,
BackgroundState state
[virtual]
 

Draws a them compliant background.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeBorder Rect rect,
DrawUIState state
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeButtonFocusRect Rect rect  )  [virtual]
 

Similar to drawThemeFocusRect, but dimension of the focus rect is chosen by the peer.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeButtonRect Rect rect,
ButtonState state,
Rect captionRect = NULL
[virtual]
 

Draws a button's background, the border, and its caption.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeCheckboxRect Rect rect,
ButtonState state
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeComboboxRect Rect rect,
ButtonState state
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeDisclosureButton Rect rect,
DisclosureButtonState state
[virtual]
 

Draws a button that is used to open up more details, for example the button that opens up a tree node to reveal it's children, that is compliant with the native windowing systems default look and feel.

On Win32 this is usually represented by the "+" and "-" look as found on the tree controls, while on OSX it is the little triangles

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeEdge Rect rect,
DrawUIState state,
const int32 edgeSides,
const int32 edgeStyle
[virtual]
 

draws edges, useful for separators, that is compliant with the native windowing systems default look and feel.

use a mask or 1 or more values of type ContextPeer::EdgeType to indicate which sides of the rect to draw an edge on

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeFocusRect Rect rect,
DrawUIState state
[virtual]
 

Draws a focus rect, which is an inverted gray dotted line around the rect.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeHeader Rect rect,
ButtonState state
[virtual]
 

Draws a header control that is compliant with the native windowing systems default look and feel.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeImage Rect rect,
Image image,
DrawUIState state
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeMenuItem Rect rect,
MenuState state
[virtual]
 

Draws the background appropriate for a menu item that is compliant with the native windowing systems default look and feel.

This is typically called first by a menu item to give it a standard look and feel in it's background before drawing any thing else

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeMenuItemText Rect rect,
MenuState state
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeProgress Rect rect,
ProgressState state
[virtual]
 

Draws a progress bar control, that is compliant with the native windowing systems default look and feel.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeRadioButtonRect Rect rect,
ButtonState state
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeScrollButtonRect Rect rect,
ScrollBarState state
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeSelectionRect Rect rect,
DrawUIState state
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeSizeGripper Rect rect,
DrawUIState state
[virtual]
 

Draws a size gripper for resizing a control/window that is compliant with the native windowing systems default look and feel.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeSlider Rect rect,
SliderState state
[virtual]
 

Draws a slider control, like that used for a slider control, that is compliant with the native windowing systems default look and feel.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeTab Rect rect,
TabState state
[virtual]
 

Draws a tab, the part of the TabbedPages control that acts like a little button to activate a page, that is compliant with the native windowing systems default look and feel.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeTabContent Rect rect,
DrawUIState state
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeTabPage Rect rect,
DrawUIState state
[virtual]
 

Draws a tab page - the page on which other controls for the page are parented to, that is compliant with the native windowing systems default look and feel.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeTabs Rect rect,
DrawUIState paneState,
TabState selectedTabState,
TabState otherTabs,
const std::vector< String > &  tabNames,
int  selectedTabIndex
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeText Rect rect,
TextState state
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::drawThemeTickMarks Rect rect,
SliderState state
[virtual]
 

Draws a tick mark, like that used for a slider control, that is compliant with the native windowing systems default look and feel.

Implements VCF::ContextPeer.

static void VCF::Win32Context::drawTransparentBitmap HDC  hdc,
HBITMAP  hBitmap,
int32  xStart,
int32  yStart,
COLORREF  cTransparentColor
[static, protected]
 

Utility function to draw a transparent bitmap.

virtual void VCF::Win32Context::ellipse const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::finishedDrawing int32  drawingOperation  )  [virtual]
 

Implements VCF::ContextPeer.

virtual GraphicsContext* VCF::Win32Context::getContext  )  [virtual]
 

Implements VCF::ContextPeer.

virtual OSHandleID VCF::Win32Context::getContextID  )  [virtual]
 

Implements VCF::ContextPeer.

HDC VCF::Win32Context::getDC  )  [protected]
 

virtual Point VCF::Win32Context::getOrigin  )  [virtual]
 

Implements VCF::ContextPeer.

virtual double VCF::Win32Context::getTextHeight const String text  )  [virtual]
 

Implements VCF::ContextPeer.

virtual double VCF::Win32Context::getTextWidth const String text  )  [virtual]
 

Implements VCF::ContextPeer.

void VCF::Win32Context::init  ) 
 

virtual bool VCF::Win32Context::isAntiAliasingOn  )  [inline, virtual]
 

Turns the XOR mode on or off.

Parameters:
bool XORModeOn, if true then turns the XORMode on otherwise if it's false it turns it off.

Implements VCF::ContextPeer.

virtual bool VCF::Win32Context::isMemoryContext  )  [virtual]
 

is this context Peer in memory or does it associated with a component ?

Returns:
bool true if the context is on memory, otherwise false

Implements VCF::ContextPeer.

virtual bool VCF::Win32Context::isTextAlignedToBaseline  )  [virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::lineTo const double &  x,
const double &  y
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::moveTo const double &  x,
const double &  y
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::polyline const std::vector< Point > &  pts  )  [virtual]
 

Implements VCF::ContextPeer.

void VCF::Win32Context::prepareDCWithContextFont HFONT &  fontHandle  )  [protected]
 

virtual bool VCF::Win32Context::prepareForDrawing int32  drawingOperation  )  [virtual]
 

this method is called for the peer to initialize any graphics resources before calling the following methods:

  • textAt
  • getTextWidth
  • getTextHeight
  • rectangle
  • ellipse
  • arc
  • polyline
  • curve
  • moveTo
  • lineTo
Since the drawing primitives like (rectangle, moveTo, etc) are executed as a series of operations by the GraphicsContext, this means that prepareForDrawing() will get called as part of the GraphicsContext::fillPath(), GraphicsContext::strokePath(), or GraphicsContext::textAtXXX() methods. prepareForDrawing() will be called prior to any of the drawing primitive functions in the above list, allowing the peer to initialize whatever graphics resources need to be as specified by the GraphicsContext.

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::rectangle const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2
[virtual]
 

Implements VCF::ContextPeer.

virtual void VCF::Win32Context::releaseHandle  )  [virtual]
 

Does the opposite operation of checkHandle(), i.e.

restores the previous HDC if it has been changed by checkHandle(). Normally the paint function already receives the correct handle in checkHandle() so this one too is a no-op.

See also:
checkHandle()

Reimplemented in VCF::Win32ControlContext.

virtual void VCF::Win32Context::roundRect const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
const double &  xc,
const double &  yc