MGUI::TOOL_BASE Class Reference

Base class for graphic tools. More...

#include <mgui/toolbase.h>

Inheritance diagram for MGUI::TOOL_BASE:

Inheritance graph
[legend]
List of all members.

Public Types

enum  ADJUSTFLAGS { ADJUST_Default = 0x00, ADJUST_Absolute = 0x01, ADJUST_ScreenCoords = 0x02, ADJUST_Notify = 0x80 }
enum  CHANGESEQ {
  CHANGESEQ_None = 0, CHANGESEQ_Begin = 1, CHANGESEQ_Continue = 2, CHANGESEQ_End = 3,
  CHANGESEQ_Cancel = 4
}
enum  CHANGETYPE {
  CHANGETYPE_None = 0, CHANGETYPE_Shift = 1, CHANGETYPE_Resize = 2, CHANGETYPE_Rotate = 3,
  CHANGETYPE_Shear = 4, CHANGETYPE_Edit = 5, CHANGETYPE_Create = 6, CHANGETYPE_Clear = 7
}
enum  CTRLOPT {
  CTRLOPT_Default = 0x00, CTRLOPT_Manual = 0x01, CTRLOPT_GPS = 0x02, CTRLOPT_SnapGrid = 0x04,
  CTRLOPT_NoManualProj = 0x08
}
enum  MARKER {
  MARKER_X = 0, MARKER_Plus = 1, MARKER_ArrowIn = 2, MARKER_ArrowOut = 3,
  MARKER_None = 4, MARKER_Circle = 5, MARKER_Flat = 6, MARKER_Square = 7
}
enum  PENCOLOR { PENCOLOR_Primary, PENCOLOR_Inactive, PENCOLOR_Highlight, PENCOLOR_COUNT }

Public Member Functions

void Activate ()
void ClearPosition ()
MGUI::FORMCreateControlForm (MGUI::LAYOUT_PANE_BASE &ParentPane, CTRLOPT ctrlopt)
MGUI::FORMCreateManualForm (MGUI::LAYOUT_PANE_BASE &ParentPane, CTRLOPT ctrlopt)
void Deactivate ()
ERRVALUE GenerateRegion (REGION2D &region) const
const DPOINT2DGetArrowKeyDeltas () const
TOOLCANVASGetCanvas () const
void GetCanvasExtents (DRECT2D &extents) const
CTRLOPT GetControlOptions () const
const TRANS2D_AFFINEGetTransToWindow () const
bool HasControls () const
bool HasManualControls () const
bool HasPosition () const
bool IsActive () const
bool IsResizable () const
bool IsRotatable () const
bool IsSuspended () const
void Move (double dx, double dy, ADJUSTFLAGS flags)
void Resize (double dx, double dy, ADJUSTFLAGS flags)
void Resume ()
void SetArrowKeyDeltas (double dx, double dy)
void SetCanStartNew (bool canstartnew)
void SetControlOptions (CTRLOPT ctrlopt)
void SetResizable (bool resizable)
void SetRotatable (bool rotatable)
void SetTransToWindow (const TRANS2D_AFFINE &trans)
const SNAPGRIDSnapGridGet () const
bool SnapGridIsActive () const
void SnapGridSet (SNAPGRID &parms)
void SnapGridSetActive (bool active)
void Suspend ()
virtual ~TOOL_BASE ()=0

Static Public Member Functions

UINT32 GetPenColorRef (PENCOLOR pencolor=PENCOLOR_Primary)
void SetPenColorRef (PENCOLOR pencolor, UINT32 ColorRef)

Protected Types

enum  CONTROLNEED { CONTROLNEED_None, CONTROLNEED_Optional, CONTROLNEED_Required }

Protected Member Functions

void AdjustBegin (CHANGETYPE changetype, bool redraw=true)
void AdjustEnd (bool releasecapture=true, bool cancel=false)
void ApplyMoveDeltas (DPOINT2D &point, double dx, double dy, ADJUSTFLAGS flags) const
void ApplySnap (DPOINT2D &point) const
bool CanStartNew () const
int CheckBounds (const DRECT2D &, DRECT2D *) const
void DrawMarker (MGD::CONTEXT *dc, const LPOINT2D &centerpoint, const LPOINT2D &dirpoint, MARKER marker, UINT16 size) const
bool GetArrowDeltas (KEYCODE, double *, double *)
CHANGETYPE GetChangeType () const
MGD::CONTEXTGetDrawingContext ()
bool IsMouseCaptured () const
void NotifyChange (CHANGESEQ changeseq, CHANGETYPE changetype)
void RestoreBackground (const LRECT2D &rect, bool AddLineWidth=true) const
void RestoreBackground () const
void RestoreDrawingContext ()
void SetCursor (CURSORID cursorid) const
void SetHasPosition (bool HasPosition=true)
 TOOL_BASE (TOOLCANVAS *canvas, CONTROLNEED ControlNeed, bool HasManualControls)
LPOINT2D TransToolToWindow (const DPOINT2D &point) const
DPOINT2D TransWindowToTool (const LPOINT2D &point) const
DPOINT2D TransWindowToTool (MGUI::POINT point) const

Private Member Functions

virtual MGUI::FORMv_CreateControlForm (MGUI::LAYOUT_PANE_BASE &ParentPane, CTRLOPT ctrlopt)
virtual MGUI::FORMv_CreateManualForm (MGUI::LAYOUT_PANE_BASE &ParentPane, CTRLOPT ctrlopt)
virtual void v_DoDraw (MGD::CONTEXT *)=0
virtual void v_DoMove (double x, double y, ADJUSTFLAGS)
virtual void v_DoSize (double x, double y, ADJUSTFLAGS)
virtual int v_GenerateRegion (REGION2D &region) const
virtual MISTRING v_GetDialogTitle () const
virtual void v_OnActivate ()
virtual void v_OnClear ()
virtual void v_OnDeactivate ()
virtual bool v_OnKey (MGUI::POINT point, MGUI::KEYCODE, KEYSTATE)
virtual void v_OnLButtonDown (MGUI::POINT point, KEYSTATE keystate)=0
virtual void v_OnLButtonUp (MGUI::POINT point, KEYSTATE keystate)
virtual void v_OnMouseMove (MGUI::POINT point, KEYSTATE keystate)=0
virtual void v_OnNotifyChange (CHANGESEQ changeseq, CHANGETYPE changetype)
virtual void v_OnRButtonDown (MGUI::POINT point, KEYSTATE keystate)
virtual void v_OnRButtonUp (MGUI::POINT point, KEYSTATE keystate)
virtual void v_OnResume ()
virtual void v_OnSetTransToWindow ()
virtual void v_OnSizeCanvas ()

Detailed Description

Base class for graphic tools.

Derived tool clients should only override the v_OnNotifyChange virtual method to receive tool change notifications. Tool implementations should NOT override the v_OnNotifyChange virtual methods (but may define new v_OnNotify... methods) as this avoids the need for derived tool client classes to call base methods.

Definition at line 62 of file toolbase.h.


Member Enumeration Documentation

enum MGUI::TOOL_BASE::ADJUSTFLAGS
 

Adjustment flags for Move() and Resize() methods.

Enumeration values:
ADJUST_Default  Values are relative tool coordinates.
ADJUST_Absolute  Adjustment values are absolute.
ADJUST_ScreenCoords  Adjustment values are in screen pixels.
ADJUST_Notify  Send notification message.

Definition at line 66 of file toolbase.h.

enum MGUI::TOOL_BASE::CHANGESEQ
 

sequence

Enumeration values:
CHANGESEQ_None 
CHANGESEQ_Begin 
CHANGESEQ_Continue 
CHANGESEQ_End 
CHANGESEQ_Cancel 

Definition at line 83 of file toolbase.h.

enum MGUI::TOOL_BASE::CHANGETYPE
 

Enumeration values:
CHANGETYPE_None 
CHANGETYPE_Shift 
CHANGETYPE_Resize 
CHANGETYPE_Rotate 
CHANGETYPE_Shear 
CHANGETYPE_Edit 
CHANGETYPE_Create 
CHANGETYPE_Clear 

Definition at line 91 of file toolbase.h.

enum MGUI::TOOL_BASE::CONTROLNEED [protected]
 

Enumeration values:
CONTROLNEED_None 
CONTROLNEED_Optional 
CONTROLNEED_Required 

Definition at line 345 of file toolbase.h.

enum MGUI::TOOL_BASE::CTRLOPT
 

Options for standard and manual control forms.

Enumeration values:
CTRLOPT_Default 
CTRLOPT_Manual  Include "manual" controls if available.
CTRLOPT_GPS  Include "gps" controls if supported.
CTRLOPT_SnapGrid  Include "snap to grid" toggle if supported.
CTRLOPT_NoManualProj  Don't allow manual projection / distance controls.

Definition at line 74 of file toolbase.h.

enum MGUI::TOOL_BASE::MARKER
 

Marker types, not all types are supported by all tools.

Enumeration values:
MARKER_X  Diagonal cross.
MARKER_Plus  Orthogonal cross.
MARKER_ArrowIn  Arrow pointing in for line endpoint.
MARKER_ArrowOut  Arrow pointing out for line endpoint.
MARKER_None  No marker.
MARKER_Circle  Circle.
MARKER_Flat  Flat line endpoint.
MARKER_Square  Square.

Definition at line 103 of file toolbase.h.

enum MGUI::TOOL_BASE::PENCOLOR
 

Enumeration values:
PENCOLOR_Primary  Primary tool drawing color.
PENCOLOR_Inactive  Color for inactive elements (eg in POLYLINE tool).
PENCOLOR_Highlight  Color for highlighting.
PENCOLOR_COUNT  Number of pens, always last.

Definition at line 114 of file toolbase.h.


Constructor & Destructor Documentation

virtual MGUI::TOOL_BASE::~TOOL_BASE  )  [pure virtual]
 

Destructor.

MGUI::TOOL_BASE::TOOL_BASE TOOLCANVAS canvas,
CONTROLNEED  ControlNeed,
bool  HasManualControls
[explicit, protected]
 

Constructor.

Parameters:
ControlNeed  Need for control dialog or form
HasManualControls  Optional manual controls available


Member Function Documentation

void MGUI::TOOL_BASE::Activate  ) 
 

Activate the tool.

If another tool is currently active on the canvas it will be automatically deactivated.

void MGUI::TOOL_BASE::AdjustBegin CHANGETYPE  changetype,
bool  redraw = true
[protected]
 

Utility methods for use by tool implementation.

void MGUI::TOOL_BASE::AdjustEnd bool  releasecapture = true,
bool  cancel = false
[protected]
 

void MGUI::TOOL_BASE::ApplyMoveDeltas DPOINT2D point,
double  dx,
double  dy,
ADJUSTFLAGS  flags
const [protected]
 

void MGUI::TOOL_BASE::ApplySnap DPOINT2D point  )  const [protected]
 

Snap point to current snap grid, if no snapping enabled point unchanged.

Parameters:
point  Point to adjust

bool MGUI::TOOL_BASE::CanStartNew  )  const [inline, protected]
 

Definition at line 376 of file toolbase.h.

int MGUI::TOOL_BASE::CheckBounds const DRECT2D ,
DRECT2D
const [protected]
 

Check rectangle against tool limits.

void MGUI::TOOL_BASE::ClearPosition  ) 
 

Clear current tool position, erasing all graphics.

MGUI::FORM* MGUI::TOOL_BASE::CreateControlForm MGUI::LAYOUT_PANE_BASE ParentPane,
CTRLOPT  ctrlopt
[inline]
 

Create "form" with tool-specific controls.

Returns:
Pointer to FORM or NULL if tool has no "control" form.
Parameters:
ParentPane  Parent pane
ctrlopt  Control options

Definition at line 200 of file toolbase.h.

MGUI::FORM* MGUI::TOOL_BASE::CreateManualForm MGUI::LAYOUT_PANE_BASE ParentPane,
CTRLOPT  ctrlopt
[inline]
 

Create "form" with tool-specific manual-entry controls.

Returns:
Pointer to FORM or NULL if tool has no "manual entry" form.
Parameters:
ParentPane  Parent pane
ctrlopt  Control options

Definition at line 207 of file toolbase.h.

void MGUI::TOOL_BASE::Deactivate  ) 
 

Deactivate this tool.

void MGUI::TOOL_BASE::DrawMarker MGD::CONTEXT dc,
const LPOINT2D centerpoint,
const LPOINT2D dirpoint,
MARKER  marker,
UINT16  size
const [protected]
 

Draw a marker (MARKER...) in the position and size specified.

ERRVALUE MGUI::TOOL_BASE::GenerateRegion REGION2D region  )  const [inline]
 

Generate region from tool.

Parameters:
region  Region in 'tool' coordinates returned

Definition at line 217 of file toolbase.h.

bool MGUI::TOOL_BASE::GetArrowDeltas KEYCODE  ,
double *  ,
double * 
[protected]
 

const DPOINT2D& MGUI::TOOL_BASE::GetArrowKeyDeltas  )  const [inline]
 

Get movement values associated with arrow keys.

Returns:
Values in "tool" coordinates.

Definition at line 223 of file toolbase.h.

TOOLCANVAS* MGUI::TOOL_BASE::GetCanvas  )  const [inline]
 

Get "canvas" associated with tool.

Definition at line 235 of file toolbase.h.

void MGUI::TOOL_BASE::GetCanvasExtents DRECT2D extents  )  const
 

Get extents of canvas.

CHANGETYPE MGUI::TOOL_BASE::GetChangeType  )  const [inline, protected]
 

Definition at line 392 of file toolbase.h.

CTRLOPT MGUI::TOOL_BASE::GetControlOptions  )  const [inline]
 

Get current control options settings.

Definition at line 227 of file toolbase.h.

MGD::CONTEXT* MGUI::TOOL_BASE::GetDrawingContext  )  [protected]
 

Get drawing context.

Will set PixelFunction to Invert if modifying, Copy if not.

UINT32 MGUI::TOOL_BASE::GetPenColorRef PENCOLOR  pencolor = PENCOLOR_Primary  )  [static]
 

Get global tool pen color reference.

Returns:
Color reference.

const TRANS2D_AFFINE& MGUI::TOOL_BASE::GetTransToWindow  )  const [inline]
 

Get transformation between "tool" and "window" coordinates.

Definition at line 231 of file toolbase.h.

bool MGUI::TOOL_BASE::HasControls  )  const [inline]
 

Determine if tool controls available.

Definition at line 244 of file toolbase.h.

bool MGUI::TOOL_BASE::HasManualControls  )  const [inline]
 

Determine if has manual data entry controls.

Definition at line 248 of file toolbase.h.

bool MGUI::TOOL_BASE::HasPosition  )  const [inline]
 

Check if tool has a valid position set.

Definition at line 268 of file toolbase.h.

bool MGUI::TOOL_BASE::IsActive  )  const [inline]
 

Check if tool is currently "active".

Definition at line 252 of file toolbase.h.

bool MGUI::TOOL_BASE::IsMouseCaptured  )  const [protected]
 

Determine if tool's canvas has the mouse "captured".

bool MGUI::TOOL_BASE::IsResizable  )  const [inline]
 

Determine if tool is "resizable".

Definition at line 256 of file toolbase.h.

bool MGUI::TOOL_BASE::IsRotatable  )  const [inline]
 

Determine if tool is "rotatable".

Definition at line 260 of file toolbase.h.

bool MGUI::TOOL_BASE::IsSuspended  )  const [inline]
 

Check if tool is "suspended".

Definition at line 264 of file toolbase.h.

void MGUI::TOOL_BASE::Move double  dx,
double  dy,
ADJUSTFLAGS  flags
 

Move the tool by the specified amount.

void MGUI::TOOL_BASE::NotifyChange CHANGESEQ  changeseq,
CHANGETYPE  changetype
[inline, protected]
 

Send notification that "change" action has or will occur.

Parameters:
changeseq  Sequence
changetype  Type

Definition at line 400 of file toolbase.h.

void MGUI::TOOL_BASE::Resize double  dx,
double  dy,
ADJUSTFLAGS  flags
 

Resize the tool.

void MGUI::TOOL_BASE::RestoreBackground const LRECT2D rect,
bool  AddLineWidth = true
const [protected]
 

Restore background for specified rectangle.

Parameters:
rect  Rectangle in 'canvas' coordinates to restore
AddLineWidth  Expand rectangle by 'LineWidth+1' to allow for wide lines

void MGUI::TOOL_BASE::RestoreBackground  )  const [protected]
 

Restore background for entire tool canvas window.

void MGUI::TOOL_BASE::RestoreDrawingContext  )  [protected]
 

void MGUI::TOOL_BASE::Resume  ) 
 

Resume the tool after performing drawing operation on the canvas.

void MGUI::TOOL_BASE::SetArrowKeyDeltas double  dx,
double  dy
 

Set movement amounts associated with arrow keys.

void MGUI::TOOL_BASE::SetCanStartNew bool  canstartnew  )  [inline]
 

Set whether user can start drawing a "new" tool.

Definition at line 296 of file toolbase.h.

void MGUI::TOOL_BASE::SetControlOptions CTRLOPT  ctrlopt  )  [inline]
 

Set controls to appear on dialog when shown.

If used, this must be called before tool is first activated.

Parameters:
ctrlopt  Control settings

Definition at line 302 of file toolbase.h.

void MGUI::TOOL_BASE::SetCursor CURSORID  cursorid  )  const [inline, protected]
 

Set mouse cursor.

Definition at line 419 of file toolbase.h.

void MGUI::TOOL_BASE::SetHasPosition bool  HasPosition = true  )  [inline, protected]
 

Definition at line 423 of file toolbase.h.

void MGUI::TOOL_BASE::SetPenColorRef PENCOLOR  pencolor,
UINT32  ColorRef
[static]
 

Set global tool pen color.

Parameters:
ColorRef  Color reference

void MGUI::TOOL_BASE::SetResizable bool  resizable  )  [inline]
 

Set whether tool is resizable.

Definition at line 307 of file toolbase.h.

void MGUI::TOOL_BASE::SetRotatable bool  rotatable  )  [inline]
 

Set whether tool is rotatable.

Definition at line 312 of file toolbase.h.

void MGUI::TOOL_BASE::SetTransToWindow const TRANS2D_AFFINE trans  ) 
 

Set transformation between "tool" and "window" coordinates.

const SNAPGRID& MGUI::TOOL_BASE::SnapGridGet  )  const [inline]
 

Get snap grid settings.

Definition at line 326 of file toolbase.h.

bool MGUI::TOOL_BASE::SnapGridIsActive  )  const [inline]
 

Determine if snap grid is currently in use.

Definition at line 322 of file toolbase.h.

void MGUI::TOOL_BASE::SnapGridSet SNAPGRID parms  ) 
 

Set snap grid parameters.

void MGUI::TOOL_BASE::SnapGridSetActive bool  active  )  [inline]
 

Set whether to use snap grid or not.

Definition at line 335 of file toolbase.h.

void MGUI::TOOL_BASE::Suspend  ) 
 

Suspend tool prior to performing a drawing operation on the canvas.

LPOINT2D MGUI::TOOL_BASE::TransToolToWindow const DPOINT2D point  )  const [protected]
 

Transform DPOINT2D from "tool" to "window" coordinates.

DPOINT2D MGUI::TOOL_BASE::TransWindowToTool const LPOINT2D point  )  const [inline, protected]
 

Transform LPOINT2D point in "window" to "tool" coordinates.

Definition at line 438 of file toolbase.h.

DPOINT2D MGUI::TOOL_BASE::TransWindowToTool MGUI::POINT  point  )  const [inline, protected]
 

Transform MGUI::POINT point in "window" to "tool" coordinates.

Definition at line 433 of file toolbase.h.

virtual MGUI::FORM* MGUI::TOOL_BASE::v_CreateControlForm MGUI::LAYOUT_PANE_BASE ParentPane,
CTRLOPT  ctrlopt
[private, virtual]
 

Create "form" with tool-specific controls.

Returns:
Pointer to FORM or NULL if tool has no "control" form.
Parameters:
ParentPane  Parent pane
ctrlopt  Control options

virtual MGUI::FORM* MGUI::TOOL_BASE::v_CreateManualForm MGUI::LAYOUT_PANE_BASE ParentPane,
CTRLOPT  ctrlopt
[private, virtual]
 

Create "form" with tool-specific manual-entry controls.

Returns:
Pointer to FORM or NULL if tool has no "manual entry" form.
Parameters:
ParentPane  Parent pane
ctrlopt  Control options

virtual void MGUI::TOOL_BASE::v_DoDraw MGD::CONTEXT  )  [private, pure virtual]
 

Do actual drawing of tool graphic.

virtual void MGUI::TOOL_BASE::v_DoMove double  x,
double  y,
ADJUSTFLAGS 
[private, virtual]
 

Move the tool.

virtual void MGUI::TOOL_BASE::v_DoSize double  x,
double  y,
ADJUSTFLAGS 
[private, virtual]
 

Size the tool.

virtual int MGUI::TOOL_BASE::v_GenerateRegion REGION2D region  )  const [private, virtual]
 

Generate region from tool.

Returns:
TRUE if region generated, FALSE if not, < 0 if error.
Parameters:
region  Generated region in 'tool' coordinates returned

virtual MISTRING MGUI::TOOL_BASE::v_GetDialogTitle  )  const [private, virtual]
 

Called to get title of tool control dialog.

virtual void MGUI::TOOL_BASE::v_OnActivate  )  [private, virtual]
 

Called when tool is "activated".

Reimplemented in MGUI::TOOL_LIMITED.

virtual void MGUI::TOOL_BASE::v_OnClear  )  [private, virtual]
 

Called when tool is cleared.

virtual void MGUI::TOOL_BASE::v_OnDeactivate  )  [private, virtual]
 

Called when tool is deactivated.

virtual bool MGUI::TOOL_BASE::v_OnKey MGUI::POINT  point,
MGUI::KEYCODE  ,
KEYSTATE 
[private, virtual]
 

Called when key pressed/released.

Returns:
'true' if key handled, 'false' if not. Should not be called directly, called by OnKey.

virtual void MGUI::TOOL_BASE::v_OnLButtonDown MGUI::POINT  point,
KEYSTATE  keystate
[private, pure virtual]
 

Called when left mouse button pressed.

virtual void MGUI::TOOL_BASE::v_OnLButtonUp MGUI::POINT  point,
KEYSTATE  keystate
[private, virtual]
 

Called when left mouse button released.

virtual void MGUI::TOOL_BASE::v_OnMouseMove MGUI::POINT  point,
KEYSTATE  keystate
[private, pure virtual]
 

Called when mouse cursor is moved.

virtual void MGUI::TOOL_BASE::v_OnNotifyChange CHANGESEQ  changeseq,
CHANGETYPE  changetype
[private, virtual]
 

Called when change made to tool position, shape, size, etc.

Parameters:
changeseq  Sequence
changetype  Type

virtual void MGUI::TOOL_BASE::v_OnRButtonDown MGUI::POINT  point,
KEYSTATE  keystate
[private, virtual]
 

Called when right mouse button pressed.

Often overridden to show a popup menu.

virtual void MGUI::TOOL_BASE::v_OnRButtonUp MGUI::POINT  point,
KEYSTATE  keystate
[private, virtual]
 

Called when right mouse button released.

Often overridden to perform an 'apply' action.

virtual void MGUI::TOOL_BASE::v_OnResume  )  [private, virtual]
 

Called when tool is "resumed" after being suspended.

virtual void MGUI::TOOL_BASE::v_OnSetTransToWindow  )  [private, virtual]
 

Called when tool to window transformation is set.

Reimplemented in MGUI::TOOL_LIMITED.

virtual void MGUI::TOOL_BASE::v_OnSizeCanvas  )  [private, virtual]
 

Called when canvas is resized.


The documentation for this class was generated from the following file:
Generated on Tue Dec 14 13:21:01 2004 for TNTsdk by  doxygen 1.3.8-20040913