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

VCF::Win32ControlContext Class Reference

implementation of the peer for Win32 of the GraphicsContext More...

#include <Win32ControlContext.h>

Inheritance diagram for VCF::Win32ControlContext:

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

Public Member Functions

 Win32ControlContext (ControlPeer *controlPeer)
virtual ~Win32ControlContext ()
virtual void setContext (GraphicsContext *context)
 sets the Graphics context to be currently used for Graphics operations.
ControlgetOwningControl ()
 gets the control to which is associated the Graphics context to be currently used for Graphics operations.
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.

Protected Attributes

ControlGraphicsContextowningControlCtx_
 the Graphics Context associated to the control that is owning the Graphics Context we need.

Detailed Description

implementation of the peer for Win32 of the GraphicsContext

To paint inside a mouse move event it is necessary to use the HDC (device context handle) given by getDC( hwnd ) where hwnd is the HWND of the control.

To paint inside a WM_PAINT message it is necessary to use the HDC given by the system with the message itself.

We CANNOT count on the HDC that we get from WM_PAINT being the same as the HDC we get from GetDC.

All of this is done automatically by checkHandle()/releaseHandle() members of this class, that by doing:

 HDC dc = (HDC) getContext()->getPeer()->getContextID();
make us confident that we alwyas have the HDC we need.

During a paint operation it is necessary to use the HDC given by the system with the message itself, so before the paint it is necessary to modify the instance of this class so that getOwningControl() returns NULL and then checkHandle() and releaseHandle() become no-op functions.

See also:
AbstractWin32Component::doControlPaint


Constructor & Destructor Documentation

VCF::Win32ControlContext::Win32ControlContext ControlPeer controlPeer  ) 
 

virtual VCF::Win32ControlContext::~Win32ControlContext  )  [virtual]
 


Member Function Documentation

virtual void VCF::Win32ControlContext::checkHandle  )  [virtual]
 

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

If the owningControl of the Graphics context is not NULL, it gets the device context from its HWND. It hte control is lightWeight it is also necessary to set the viewport correctly and this too is done here.

See also:
releaseHandle()

Reimplemented from VCF::Win32Context.

Control* VCF::Win32ControlContext::getOwningControl  ) 
 

gets the control to which is associated the Graphics context to be currently used for Graphics operations.

Returns:
Control*, the control owning the Graphics context.

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

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

restores the previous HDC if it has been changed by checkHandle().

See also:
checkHandle()

Reimplemented from VCF::Win32Context.

virtual void VCF::Win32ControlContext::setContext GraphicsContext context  )  [virtual]
 

sets the Graphics context to be currently used for Graphics operations.

Reimplemented from VCF::Win32Context.


Member Data Documentation

ControlGraphicsContext* VCF::Win32ControlContext::owningControlCtx_ [protected]
 

the Graphics Context associated to the control that is owning the Graphics Context we need.

When doing any Graphics operation the suited HDC changes according to the operation to perform. If the Graphics operation needs to be extracted from the HWND of a control, then the owningControl of this Graphics Context is not NULL and we need to get the HDC from it.


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information