Generic 'canvas' control supporting drawing and simple user input. More...
#include <mgui/canvas.h>

Generic 'canvas' control supporting drawing and simple user input.
| typedef fastdelegate::FastDelegate<bool(MGUI::POINT,MGUI::KEYCODE,MGUI::KEYSTATE)> MGUI::CANVAS::DELEGATE_ONKEY |
| typedef fastdelegate::FastDelegate<void(MGD::CONTEXT*) MGUI::CANVAS::DELEGATE_ONPAINT) |
| typedef fastdelegate::FastDelegate<bool(MGUI::POINT,MGUI::POINTERBUTTON,MGUI::KEYSTATE)> MGUI::CANVAS::DELEGATE_ONPOINTER |
| typedef fastdelegate::FastDelegate<bool(MGUI::POINT,MGUI::POINTERBUTTON,MGUI::KEYSTATE,bool)> MGUI::CANVAS::DELEGATE_ONPOINTERMOVE |
| typedef fastdelegate::FastDelegate<void(const LRECT2D&)> MGUI::CANVAS::DELEGATE_ONUPDATERECT |
| typedef fastdelegate::FastDelegate<void(INT32)> MGUI::CANVAS::DELEGATE_ONWHEEL |
| enum MGUI::CANVAS::STYLE |
Reimplemented in MGUI::CTRL_ANGLE, and MGUI::CTRL_MAGNIFIER.
| MGUI::CANVAS::CANVAS | ( | STYLE | style = STYLE_Default |
) |
Constructor.
| virtual MGUI::CANVAS::~CANVAS | ( | ) | [virtual] |
Destructor.
| void MGUI::CANVAS::AddDelegateOnPointerButtonDown | ( | POINTERBUTTON | buttons, | |
| DELEGATE_ONPOINTER | delegate | |||
| ) |
Add delegate to call when pointer button pressed.
The delegate gets passed the same parameters as v_OnPointerButtonDown(). Delegate must return 'true' if it processed the message, false to continue processing.
| buttons | Button(s) for which to call delegate | |
| delegate | Delegate to call |
| void MGUI::CANVAS::AddDelegateOnPointerButtonUp | ( | POINTERBUTTON | buttons, | |
| DELEGATE_ONPOINTER | delegate | |||
| ) |
Add delegate to call when pointer button released.
The delegate gets passed the same parameters as v_OnPointerButtonUp(). Delegate must return 'true' if it processed the message, false to continue processing.
| buttons | Button(s) for which to call delegate | |
| delegate | Delegate to call |
| void MGUI::CANVAS::Create | ( | LAYOUT_PANE_BASE & | ParentPane, | |
| int | width, | |||
| int | height, | |||
| LAYOUT_SIZEALIGN | sizealign, | |||
| CANVAS::STYLE | style = STYLE_Default | |||
| ) |
Create canvas control.
| ParentPane | Parent pane | |
| width | Desired width in pixels | |
| height | Desired height in pixels | |
| sizealign | Sizing and alignment options |
| void MGUI::CANVAS::CursorSetVisible | ( | bool | visible | ) |
Set cursor visibility.
| visible | Whether visible or not |
| void MGUI::CANVAS::Erase | ( | const COLOR & | color | ) |
Erase canvas to specified color.
| color | Color to erase to |
| CURSORID MGUI::CANVAS::GetCursor | ( | ) | const |
Get current cursor ID.
| MDLGPARENT MGUI::CANVAS::GetDlgParent | ( | ) | const |
Get suitable parent for dialog launched from canvas.
Reimplemented from MGUI::CTRL.
| MGD::CONTEXT* MGUI::CANVAS::GetDrawingContext | ( | DEVICETYPE | DeviceType, | |
| STEREOVIEW | StereoView = STEREOVIEW_None | |||
| ) | const |
Get shared drawing context.
| StereoView | Stereo view, ignored unless stereo enabled |
| MGD::DEVICE* MGUI::CANVAS::GetDrawingDevice | ( | DEVICETYPE | DeviceType, | |
| bool | AllowStereo | |||
| ) |
Get drawing device for buffer or direct display with control over whether to allow stereo.
Do not delete the returned DEVICE as it is internal to the CANVAS.
| DeviceType | Drawing device type | |
| AllowStereo | Whether to allow stereo left/right frames (if supported) |
| MGD::DEVICE* MGUI::CANVAS::GetDrawingDevice | ( | DEVICETYPE | DeviceType = DEVICETYPE_Memory |
) |
Get drawing device for buffer or direct display.
Do not delete the returned DEVICE as it is internal to the CANVAS.
| DeviceType | Drawing device type |
| INT16 MGUI::CANVAS::GetHeight | ( | ) | const |
Get height of canvas in pixels.
| bool MGUI::CANVAS::GetPointerLocation | ( | MGUI::POINT & | ptCanvas | ) | const |
Get current pointer location relative to canvas.
| ptCanvas | Location relative to canvas returned |
Get dimensions of canvas.
| width | Width in pixels returned | |
| height | Height in pixels returned |
| STYLE MGUI::CANVAS::GetStyle | ( | ) | const |
Get canvas style flags.
| INT16 MGUI::CANVAS::GetWidth | ( | ) | const |
Get width of canvas in pixels.
| bool MGUI::CANVAS::IsPointerCaptured | ( | ) | const |
Determine if pointer is "captured" by this canvas.
Pan view by specified amount by copying from background buffer.
Will update screen display.
| dx | X offset in pixels | |
| dy | Y offset in pixels | |
| pColorBG | Color to fill portions where no data available to copy |
| void MGUI::CANVAS::ReleaseCapture | ( | ) |
Release capture on pointer.
Use with care, typically used if buttonpress pops up a menu.
Resize canvas.
| width | New width requested | |
| height | New height requested |
| void MGUI::CANVAS::RestoreFromBuffer | ( | DEVICETYPE | devtype, | |
| const LRECT2D & | rect, | |||
| bool | UpdateNow = false | |||
| ) |
Restore portion of canvas from specific off-screen buffer.
Will generate OnPaint notifications if STYLE_NotifyExpose was specified in constructor or Create. Note that if DEVICETYPE_Stereo is specified the actual area(s) restored may differ from the specified rectangle.
| devtype | Buffer device type | |
| rect | Portion of canvas to restore | |
| UpdateNow | Perform immediate update before returning |
| void MGUI::CANVAS::RestoreFromBuffer | ( | DEVICETYPE | devtype, | |
| bool | UpdateNow = false | |||
| ) |
Restore entire canvas from specific off-screen buffer.
Will generate OnPaint notifications if STYLE_NotifyExpose was specified in constructor or Create.
| devtype | Buffer device type | |
| UpdateNow | Perform immediate update before returning |
| void MGUI::CANVAS::SetCursor | ( | CURSORID | cursorid | ) |
Set pointer cursor to show while in canvas.
| void MGUI::CANVAS::SetDelegateOnKey | ( | DELEGATE_ONKEY | delegate | ) |
Set delegate to call when key "pressed".
Delegate should
| void MGUI::CANVAS::SetDelegateOnPaint | ( | DELEGATE_ONPAINT | delegate | ) |
Set delegate to call when canvas needs to be redrawn.
This delegate is called after the buffer is updated to the screen. If no overlay and not unbuffered then this delegate does not need to be set. The delegate gets passed the same parameters as v_OnPaint()
| void MGUI::CANVAS::SetDelegateOnPointerDoubleClick | ( | DELEGATE_ONPOINTER | delegate | ) |
Set delegate to call for double-click on any button.
| void MGUI::CANVAS::SetDelegateOnPointerEnter | ( | DELEGATE_VOID_NOPARMS | delegate | ) |
Set delegate to call when pointer enters canvas area.
| void MGUI::CANVAS::SetDelegateOnPointerLeave | ( | DELEGATE_VOID_NOPARMS | delegate | ) |
Set delegate to call when pointer leaves canvas area.
| void MGUI::CANVAS::SetDelegateOnPointerMove | ( | DELEGATE_ONPOINTERMOVE | delegate | ) |
Set delegate to call when pointer is moved.
The delegate gets passed the same parameters as v_OnPointerMove()
| void MGUI::CANVAS::SetDelegateOnPointerWheel | ( | DELEGATE_ONWHEEL | delegate | ) |
Set delegate to call when the user scrolls the pointer wheel.
The delegate is passed an integer parameter which will be positive if the wheel was scrolled up and negative if scrolled down.
| void MGUI::CANVAS::SetDelegateOnSize | ( | DELEGATE_ONSIZE | delegate | ) |
Set delegate to call when canvas size changes.
Note, this is NOT called repeatedly while the user resizes the window, but instead will be called after the user releases the pointer or pauses for a nominal period of time (.5 second). The delegate gets passed the same parameters as v_OnSize()
| void MGUI::CANVAS::SetDelegateOnUpdatePixmap | ( | DELEGATE_ONUPDATERECT | delegate | ) |
Set delegate to call when Pixmap updated from Memory buffer.
Only applies if both STYLE_UsePixmap and STYLE_UseMemory specified in construction/creation.
| void MGUI::CANVAS::StereoDisable | ( | ) |
Disable stereo buffering.
| void MGUI::CANVAS::StereoDrawCursor | ( | MGUI::POINT | ptCanvasL, | |
| MGUI::POINT | ptCanvasR, | |||
| LRECT2D & | CursorRectL, | |||
| LRECT2D & | CursorRectR | |||
| ) |
Draw stereo cursor using specified left/right points.
| ptCanvasL | Left canvas coordinate | |
| ptCanvasR | Right canvas coordinate | |
| CursorRectL | Left rectangle returned | |
| CursorRectR | Right rectangle returned |
| void MGUI::CANVAS::StereoEnable | ( | const STEREODEVICE & | StereoDevice | ) |
Enable stereo buffering.
| StereoDevice | Stereo device hardware description |
| const STEREODEVICE* MGUI::CANVAS::StereoGetDeviceHW | ( | ) | const |
Get stereo device hardware description.
| bool MGUI::CANVAS::StereoIsEnabled | ( | ) | const |
Determine if stereo buffering is enabled.
| void MGUI::CANVAS::StereoUpdateFromBuffer | ( | ) |
Update buffer/screen from stereo buffer if enabled and available.
| void MGUI::CANVAS::UpdateFromBuffer | ( | DEVICETYPE | DevTarget, | |
| DEVICETYPE | DevSource, | |||
| const LRECT2D * | pRectSource = 0 | |||
| ) |
Update specified target device buffer from specified source buffer.
| DevTarget | Target device type to update to | |
| DevSource | Source device type to update from | |
| pRectSource | Rectangle in source buffer, NULL for entire extent |
| virtual void MGUI::CANVAS::v_OnCaptureChanged | ( | ) | [protected, virtual] |
Called when cursor "capture" is changed (lost).
Default implementation calls the delegate.
Reimplemented in MGUI::TOOLCANVAS.
| virtual bool MGUI::CANVAS::v_OnKey | ( | MGUI::POINT | point, | |
| MGUI::KEYCODE | keycode, | |||
| MGUI::KEYSTATE | keystate | |||
| ) | [protected, virtual] |
Called when key "pressed".
Override must call base for proper behavior if does not handle key itself.
| point | Point in canvas coordinates where button event occurred | |
| keycode | Processed key code, equivalent to MIUNICODE for alphanumeric keys. | |
| keystate | Modifier key state |
Reimplemented in MGUI::TOOLCANVAS.
| virtual void MGUI::CANVAS::v_OnPaint | ( | MGD::CONTEXT * | gc | ) | [protected, virtual] |
Called when canvas needs to be redrawn, do not call directly except from derived implementation.
Override must call base for proper behavior. This is called after the buffer is updated to the screen. If no overlay and not unbuffered then this method does not need to be overridden. Default implementation calls the delegate.
| gc | Drawing context for unbuffered/overlay. |
Reimplemented in MGUI::TOOLCANVAS.
| virtual void MGUI::CANVAS::v_OnPointerButtonDown | ( | MGUI::POINT | point, | |
| POINTERBUTTON | button, | |||
| KEYSTATE | keystate | |||
| ) | [protected, virtual] |
Called when pointer button pressed.
Override must call base for proper behavior if it does not handle the button itself. Default implementation calls the delegate(s) associated with the button.
| point | Point in canvas coordinates where button event occurred | |
| button | Button that was pressed | |
| keystate | Modifier key state at time of event |
Reimplemented in MGUI::TOOLCANVAS.
| virtual void MGUI::CANVAS::v_OnPointerButtonUp | ( | MGUI::POINT | point, | |
| POINTERBUTTON | button, | |||
| KEYSTATE | keystate | |||
| ) | [protected, virtual] |
Called when pointer button released.
Return 'true' if it processed the message, false to continue processing. Default implementation calls the delegate(s) associated with the button.
| point | Point in canvas coordinates where button event occurred | |
| button | Button that was released | |
| keystate | Modifier key state at time of original button press |
Reimplemented in MGUI::TOOLCANVAS.
| virtual void MGUI::CANVAS::v_OnPointerEnter | ( | ) | [protected, virtual] |
Called when pointer enters canvas area.
Override must call base for proper behavior. Default implementation calls the delegate.
Reimplemented in MGUI::TOOLCANVAS.
| virtual void MGUI::CANVAS::v_OnPointerLeave | ( | ) | [protected, virtual] |
Called when pointer leaves canvas area.
Override must call base for proper behavior. Default implementation calls the delegate.
Reimplemented in MGUI::TOOLCANVAS.
| virtual void MGUI::CANVAS::v_OnPointerMove | ( | MGUI::POINT | point, | |
| POINTERBUTTON | button, | |||
| KEYSTATE | keystate, | |||
| bool | hasmore | |||
| ) | [protected, virtual] |
Called when pointer cursor is moved.
Override must call base for proper behavior. Default implementation calls the delegate.
| point | Point in canvas coordinates where button event occurred | |
| button | Current button state | |
| keystate | Modifier key state at time of event | |
| hasmore | Indicates whether more "move" events follow with same button/key state |
Reimplemented in MGUI::TOOLCANVAS.
| virtual void MGUI::CANVAS::v_OnPointerWheel | ( | INT32 | direction | ) | [protected, virtual] |
Called when the user scrolls the pointer wheel Override must call base for proper behavior.
Default implementation calls the delegate.
| direction | positive for up, negative for down |
| virtual void MGUI::CANVAS::v_OnSize | ( | int | width, | |
| int | height | |||
| ) | [protected, virtual] |
Called when canvas size changes.
Override must call base for proper behavior. Note, this is NOT called repeatedly while the user resizes the window, but instead will be called after the user releases the pointer or pauses for a nominal period of time (.5 second). Default implementation calls the delegate.
| width | New canvas width in pixels | |
| height | New canvas height in pixels |
Reimplemented in MGUI::TOOLCANVAS.
| virtual void MGUI::CANVAS::v_OnUpdatePixmap | ( | const LRECT2D & | rect | ) | [private, virtual] |
Called when Pixmap updated from Memory buffer.
Only used if both STYLE_UsePixmap and STYLE_UseMemory specified in construction/creation. Default implementation does nothing.
| rect | Rectangle that was updated |
1.6.1