a2dWidgetButton Class Reference
[a2dCanvasObject related objects]

a2dWidgetButton is a a2dCanvasObject based button in a canvas More...

#include <canwidget.h>

Inheritance diagram for a2dWidgetButton:

Inheritance graph
[legend]
Collaboration diagram for a2dWidgetButton:

Collaboration graph
[legend]

List of all members.

Public Types

enum  WidgetMode { Boundingbox, BoundingboxSize, ScaledContent, ScaledContentKeepAspect }

Public Member Functions

 a2dWidgetButton (a2dCanvasObject *parent, int buttonId, double x, double y, double w, double h, WidgetMode mode=Boundingbox)
 Standard constructor.
 a2dWidgetButton (const a2dWidgetButton &other, CloneOptions options)
 ~a2dWidgetButton ()
 destructor
virtual a2dObjectClone (CloneOptions options) const
 Clone this object and return a pointer to the new object.
virtual void SetParent (a2dCanvasObject *parent)
 set parent object of the pin or some other objects that needs a parent
virtual a2dEvtHandlerGetParentEvtHandler ()
 get parent object if available
void SetContentObject (a2dCanvasObject *content)
 Set the content object.
a2dCanvasObjectGetContentObject ()
 Get the content object,.
void SetContentBorder (double contentBorder)
 Set the border width around the content.
double GetContentBorder ()
 Get the border width around the content.
void SetSelectedStroke (const a2dStroke &selectedStroke)
 Set the selected stroke style for the button.
void SetSelectedFill (const a2dFill &selectedFill)
 Set the selected fill style for the button.
void SetHighLightStroke (const a2dStroke &highLightStroke)
 Set the selected stroke style for the button.
void SetHighLightFill (const a2dFill &highLightFill)
 Set the selected fill style for the button.
int GetButtonId ()
 id used for button event.

Protected Member Functions

void DoWalker (wxObject *parent, a2dWalkerIOHandler &handler)
 iterate over this object and its children
virtual void DrawHighLighted (a2dIterC &ic)
 called by Render() if m_flags.m_HighLight is set
virtual void Render (a2dIterC &ic, OVERLAP clipparent)
 Render this object to the active a2dCanvasView.
virtual bool DoUpdate (UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
 Update derived Object specific things ( mainly boundingbox).
virtual a2dBoundingBox DoGetUnTransformedBbox (a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
virtual void DoRender (a2dIterC &ic, OVERLAP clipparent)
 render derived object
bool DoIsHitWorld (a2dIterC &ic, a2dHitEvent &hitEvent)
 Does hit test on the object (exclusif child objects).
void OnEnterObject (a2dCanvasObjectMouseEvent &event)
 handler for A2D_EVT_CANVASOBJECT_ENTER_EVENT
void OnLeaveObject (a2dCanvasObjectMouseEvent &event)
 handler for A2D_EVT_CANVASOBJECT_LEAVE_EVENT
void OnCanvasObjectMouseEvent (a2dCanvasObjectMouseEvent &event)
 handler for A2D_EVT_CANVASOBJECT_MOUSE_EVENT

Protected Attributes

a2dStroke m_selectedStroke
a2dFill m_selectedFill
a2dStroke m_highLightStroke
a2dFill m_highLightFill
int m_buttonId
 event id used when sending events
WidgetMode m_mode
 type of button rendering of the m_content object.
double m_contentBorder
 here a border between the button and the content can be given
a2dCanvasObjectPtr m_content
 the button its graphics, which will be scaled in WidgetMode::ScaleChildren
a2dCanvasObjectm_parent
 events are sent from the button to this object, if not handled by the button itself.
a2dAffineMatrix m_contentWorld
 for scaling/translating the m_content


Detailed Description

a2dWidgetButton is a a2dCanvasObject based button in a canvas

a2dWidgetButton implements a a2dCanvasObject based button. This is usefull for selecting objects from a a2dCanvas that is used as a palette of objects, styles or tools. If the object is selected, it is drawn with the styles set by SetSelectedStroke and SetSelectedFill. Otherwise it is drawn by the usual style for this object. The default selected style is a one pixel black line and white fill. The default non-selected style is transparent stroke and fill.

a2dWidgetButton does not need a tool. It processes Mouse events.

Definition at line 41 of file canwidget.h.


Member Enumeration Documentation

Enumerator:
Boundingbox  The width and height is the boundingbox of the m_content ORed with the button and children.
BoundingboxSize  Like Boundingbox, but objects with negative extend are shifted positive.
ScaledContent  The width and height button, m_content are scaled to fit in.
ScaledContentKeepAspect  like ScaledContent, but keep aspect ratio.

Definition at line 46 of file canwidget.h.


Member Function Documentation

virtual a2dEvtHandler* a2dWidgetButton::GetParentEvtHandler (  )  [inline, virtual]

get parent object if available

A wxCommandEvent is sent to a parent when available.

Reimplemented from a2dEvtHandler.

Definition at line 67 of file canwidget.h.

void a2dWidgetButton::SetContentObject ( a2dCanvasObject content  )  [inline]

Set the content object.

child objects can be added to a button, but they will always be drawn unscaled, independent of WidgetMode. Therefore one can not fit the children inside of the boundingbox of the button. It is important to be able to split normalized content from child objects, for example when object tips that are added to the button. Such an object tip should never be scaled, when the button itself is resized. So the prefered manner of setting the drawing for a button is using SetContentObject(). Children should be used for decorating the button itself, not for fitting/scaling the inside drawing of tyhe button.

Definition at line 79 of file canwidget.h.

a2dCanvasObject* a2dWidgetButton::GetContentObject (  )  [inline]

Get the content object,.

See also:
SetContentObject()

Definition at line 82 of file canwidget.h.

void a2dWidgetButton::DoWalker ( wxObject *  parent,
a2dWalkerIOHandler handler 
) [protected, virtual]

iterate over this object and its children

This function allows you to extend the functionality of all a2dCanvasObject classes in a a2dCanvasDocument, without adding extra members to these objects.

Default functions are called on the a2dWalkerIOHandler, which redirect the calls to other functions based on this object its classname. On can register classes to a2dWalkerIOHandler or derived classes. This way for each unique object in the document there can be a function in a2dWalkerIOHandler.

Returns:
false if some object did not have a function attached via a2dWalkerIOHandler.
See a2dWalkerIOHandler for more.

Reimplemented from a2dCanvasObject.

Definition at line 84 of file canwidget.cpp.

void a2dWidgetButton::DrawHighLighted ( a2dIterC ic  )  [protected, virtual]

called by Render() if m_flags.m_HighLight is set

Parameters:
ic iteration context (has a2dCanvasView accumulative matrix to calculate absolute position of the object)

Reimplemented from a2dCanvasObject.

Definition at line 95 of file canwidget.cpp.

void a2dWidgetButton::Render ( a2dIterC ic,
OVERLAP  clipparent 
) [protected, virtual]

Render this object to the active a2dCanvasView.

This function is called via the a2dCanvasDocument class or its nested children. The active a2dCanvasView which is set for the document is used to draw to (either on its buffer or directly on the device) All rendering goes through this function to be able to render specific things in the base class first (like a2dCanvasObject its properties.) Somewhere internal DoRender will be called to really render the derived object itself. Next to that nested a2dCanvasObject's will be rendered too.

If wanted only the canvas objects with a certain mask set, will be rendered. Mask example: Checking visible and selected

use: mask=(a2dCANOBJ_VISIBLE | a2dCANOBJ_SELECTED)

Remarks:
Do not use directly from outside the containing document of this object. Normally only used directly in derived classes
See also:
a2dCanvasDocument
Remarks:
The active clipping rectangle is set within the active drawer. It can be used to decide which parts of the object need to be re-drawn or not. This may speed up drawing in sepcial cases, but in general the active a2dCanvasView, simply clips all that is drawn on it to active clipping rectangle. The fact that the object is called to redrawn itself, is not decided here, instead it is part of the pending object mechanism. Which uses the object its boundingbox to request redrawing.

Normally an object will be rendered if the given layer is equal to the object its layer.

wxLAYER_ALL has a special meaning. If the given input layer is wxLAYER_ALL, then the m_layer of objects is not tested. So the child objects their own layer settings are ignored/not checked in that case. All child objects are drawn at once, still the style of the layers settings is used when needed.

If the flag "m_flags.m_childrenOnSameLayer" is set, a new iteration over layers will take place. The effect is that all children will be drawn at once ( not only objects on the given layer ), but the order of the layers will be taken into account to draw the children. If the flag "m_flags.m_childrenOnSameLayer" is NOT set, a new iteration on layers is NOT done, and only the objects on the given layer will be drawn.

Remarks:
ic.GetPerLayerMode() is true, then only ic.GetLayer() is rendered, which can not be wxLAYER_ALL.
Parameters:
ic iteration context (has a2dCanvasView accumulative matrix to calculate absolute position of the object)
clipparent this must be the clip status of parent object, it is used to optimize drawing speed. e.g If parent is completely within the current clipping rectangle of the a2dCanvasView, there is no need to check child objects.

Reimplemented from a2dCanvasObject.

Definition at line 131 of file canwidget.cpp.

bool a2dWidgetButton::DoUpdate ( UpdateMode  mode,
const a2dBoundingBox childbox,
const a2dBoundingBox clipbox,
const a2dBoundingBox propbox 
) [protected, virtual]

Update derived Object specific things ( mainly boundingbox).

Calculates the boundingbox of the object (exclusif base class child objects but with other nested objects).

Parameters:
mode way to update the objects
childbox size of children boundingbox
clipbox clip to this
propbox size of properties boundingbox
Remarks:
in a derived class this function can also be used to update object specific cache data.

force may or may not have direct influence on the object itself, if this function is called directly for some reason (e.g from derived objects), you must invalidate the boudingbox yourself. GetDrawerBox()->SetValid( false );

Reimplemented from a2dWindowMM.

Definition at line 138 of file canwidget.cpp.

void a2dWidgetButton::DoRender ( a2dIterC ic,
OVERLAP  clipparent 
) [protected, virtual]

render derived object

if the object has sub objects (apart from the childobject which are handled here), those subobject most rendered by iterating on layer when needed/wanted, simular to child objects. We do not iterate here, since that is only needed if indeed there or subobjects. This will be know in a "wxDerivedCanvasObject DoRender".

SO parent objects that call this function, must:

  • 1- clip object against area to redraw.
  • 2- iterate on layers when needed.
A a2dCanvasObject is rendered as a + (plus sign) when there or no children.

Reimplemented from a2dWindowMM.

Definition at line 246 of file canwidget.cpp.

bool a2dWidgetButton::DoIsHitWorld ( a2dIterC ic,
a2dHitEvent hitEvent 
) [protected, virtual]

Does hit test on the object (exclusif child objects).

DoIsHitWorld() should return the way the object is hit by filling a2dHitEvent::m_how with the correct info.

Parameters:
ic iterative context ( e.g. current transform WITH the local transform applied )
hitEvent stores hit information
Returns:
true if hit

Reimplemented from a2dRectMM.

Definition at line 313 of file canwidget.cpp.


Member Data Documentation

See also:
SetSelectedStroke

Definition at line 135 of file canwidget.h.

See also:
SetSelectedFill

Definition at line 138 of file canwidget.h.

See also:
SetSelectedStroke

Definition at line 141 of file canwidget.h.

See also:
SetSelectedFill

Definition at line 144 of file canwidget.h.


The documentation for this class was generated from the following files:
a2dWidgetButton Class Reference -- Tue Aug 31 18:38:11 2010 -- 31 Aug 2010 -- 1.5.5 -- wxArt2D -- . -- Main Page Reference Documentation