wxShapeFramework  1.13.0 beta
wxSFShapeCanvas Class Reference

Class encapsulating a Shape canvas. The shape canvas is window control which extends the wxScrolledWindow and is responsible for displaying of shapes diagrams. It also supports clipboard and drag&drop operations, undo/redo operations, and graphics exporting functions. More...

#include <ShapeCanvas.h>

Inheritance diagram for wxSFShapeCanvas:
Collaboration diagram for wxSFShapeCanvas:

Public Types

enum  MODE {
  modeREADY = 0 , modeHANDLEMOVE , modeMULTIHANDLEMOVE , modeSHAPEMOVE ,
  modeMULTISELECTION , modeCREATECONNECTION , modeDND
}
 Working modes. More...
 
enum  SELECTIONMODE { selectNORMAL , selectADD , selectREMOVE }
 Selection modes. More...
 
enum  SEARCHMODE { searchSELECTED , searchUNSELECTED , searchBOTH }
 Search mode flags for GetShapeAtPosition function. More...
 
enum  VALIGN { valignNONE , valignTOP , valignMIDDLE , valignBOTTOM }
 Flags for AlignSelected function. More...
 
enum  HALIGN { halignNONE , halignLEFT , halignCENTER , halignRIGHT }
 Flags for AlignSelected function. More...
 
enum  STYLE {
  sfsMULTI_SELECTION = 1 , sfsMULTI_SIZE_CHANGE = 2 , sfsGRID_SHOW = 4 , sfsGRID_USE = 8 ,
  sfsDND = 16 , sfsUNDOREDO = 32 , sfsCLIPBOARD = 64 , sfsHOVERING = 128 ,
  sfsHIGHLIGHTING = 256 , sfsGRADIENT_BACKGROUND = 512 , sfsPRINT_BACKGROUND = 1024 , sfsPROCESS_MOUSEWHEEL = 2048 ,
  sfsDEFAULT_CANVAS_STYLE = sfsMULTI_SELECTION | sfsMULTI_SIZE_CHANGE | sfsDND | sfsUNDOREDO | sfsCLIPBOARD | sfsHOVERING | sfsHIGHLIGHTING
}
 Style flags. More...
 
enum  SHADOWMODE { shadowTOPMOST , shadowALL }
 Flags for ShowShadow function. More...
 
enum  PRINTMODE {
  prnFIT_TO_PAPER , prnFIT_TO_PAGE , prnFIT_TO_MARGINS , prnMAP_TO_PAPER ,
  prnMAP_TO_PAGE , prnMAP_TO_MARGINS , prnMAP_TO_DEVICE
}
 Printing modes used by SetPrintMode() function. More...
 
enum  PRECONNECTIONFINISHEDSTATE { pfsOK , pfsFAILED_AND_CANCEL_LINE , pfsFAILED_AND_CONTINUE_EDIT }
 

Public Member Functions

 wxSFShapeCanvas ()
 Default constructor. More...
 
 wxSFShapeCanvas (wxSFDiagramManager *manager, wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHSCROLL|wxVSCROLL)
 Constructor. More...
 
 ~wxSFShapeCanvas (void)
 Destructor. More...
 
virtual bool Create (wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHSCROLL|wxVSCROLL, const wxString &name=wxT("scrolledWindow"))
 Creates the window in two-step construction mode. SetDiagramManager() function must be also called to complete the canvas initialization. More...
 
wxSFDiagramManagerGetDiagramManager ()
 Get diagram manager associated with this instance of shape canvas. More...
 
void SetDiagramManager (wxSFDiagramManager *manager)
 Set diagram manager for this shape canvas. More...
 
void LoadCanvas (const wxString &file)
 Load serialized canvas content (diagrams) from given file. More...
 
void SaveCanvas (const wxString &file)
 Save canvas content (diagrams) to given file. More...
 
void SaveCanvasToBMP (const wxString &file)
 Export canvas content to BMP file. DEPRECATED: use SaveCanvasToImage() instead. More...
 
void SaveCanvasToImage (const wxString &file, wxBitmapType type=wxBITMAP_TYPE_BMP, bool background=true, double scale=-1)
 Export canvas content to image file. More...
 
void StartInteractiveConnection (wxClassInfo *shapeInfo, const wxPoint &pos, wxSF::ERRCODE *err=NULL)
 Start interactive connection creation. More...
 
void StartInteractiveConnection (wxSFLineShape *shape, const wxPoint &pos, wxSF::ERRCODE *err=NULL)
 Start interactive connection creation from existing line object. More...
 
void StartInteractiveConnection (wxSFLineShape *shape, wxSFConnectionPoint *connectionPoint, const wxPoint &pos, wxSF::ERRCODE *err=NULL)
 Start interactive connection creation from existing line object. More...
 
void AbortInteractiveConnection ()
 Abort interactive connection creation process. More...
 
void SelectAll ()
 Select all shapes in the canvas. More...
 
void DeselectAll ()
 Deselect all shapes. More...
 
void HideAllHandles ()
 Hide handles of all shapes. More...
 
void RefreshCanvas (bool erase, const wxRect &rct)
 Repaint the shape canvas. More...
 
void InvalidateRect (const wxRect &rct)
 Mark given rectangle as an invalidated one, i.e. as a rectangle which should be refreshed (by using wxSFShapeCanvas::RefreshInvalidatedRect()). More...
 
void InvalidateVisibleRect ()
 Mark whole visible canvas portion as an invalidated rectangle. More...
 
void RefreshInvalidatedRect ()
 Refresh all canvas rectangles marked as invalidated. More...
 
void ShowShadows (bool show, SHADOWMODE style)
 Show shapes shadows (only current digram shapes are affected). More...
 
wxDragResult DoDragDrop (ShapeList &shapes, const wxPoint &start=wxPoint(-1, -1))
 Start Drag&Drop operation with shapes included in the given list. More...
 
void Copy ()
 Copy selected shapes to the clipboard. More...
 
void Cut ()
 Copy selected shapes to the clipboard and remove them from the canvas. More...
 
void Paste ()
 Paste shapes stored in the clipboard to the canvas. More...
 
void Undo ()
 Perform Undo operation (if available) More...
 
void Redo ()
 Perform Redo operation (if available) More...
 
bool CanCopy ()
 Function returns TRUE if some shapes can be copied to the clipboard (it means they are selected) More...
 
bool CanCut ()
 Function returns TRUE if some shapes can be cutted to the clipboard (it means they are selected) More...
 
bool CanPaste ()
 Function returns TRUE if some shapes can be copied from the clipboard to the canvas (it means the clipboard contains stored shapes) More...
 
bool CanUndo ()
 Function returns TRUE if Undo operation can be done. More...
 
bool CanRedo ()
 Function returns TRUE if Redo operation can be done. More...
 
bool CanAlignSelected ()
 Function returns TRUE if AlignSelected function can be invoked (if more than one shape is selected) More...
 
void SaveCanvasState ()
 Save current canvas state (for Undo/Redo operations) More...
 
void ClearCanvasHistory ()
 Clear all stored canvas states (no Undo/Redo operations will be available) More...
 
void Print (bool prompt=sfPROMPT)
 Print current canvas content. More...
 
void Print (wxSFPrintout *printout, bool prompt=sfPROMPT)
 Print current canvas content using user-defined printout class. More...
 
void PrintPreview ()
 Show print preview. More...
 
void PrintPreview (wxSFPrintout *preview, wxSFPrintout *printout=NULL)
 
void PageSetup ()
 Show page setup dialog for printing. More...
 
wxPoint DP2LP (const wxPoint &pos) const
 Show page margins setup dialog (available only for MAC). *‍/ void PageMargins(); #endif. More...
 
wxRect DP2LP (const wxRect &rct) const
 
wxPoint LP2DP (const wxPoint &pos) const
 Convert logical position to device position. More...
 
wxRect LP2DP (const wxRect &rct) const
 
void UpdateShapeUnderCursorCache (const wxPoint &pos)
 
wxSFShapeBaseGetShapeUnderCursor (SEARCHMODE mode=searchBOTH)
 Get shape under current mouse cursor position (fast implementation - use everywhere it is possible instead of much slower GetShapeAtPosition()). More...
 
wxSFShapeBaseGetShapeAtPosition (const wxPoint &pos, int zorder=1, SEARCHMODE mode=searchBOTH)
 Get shape at given logical position. More...
 
wxSFShapeHandleGetTopmostHandleAtPosition (const wxPoint &pos)
 Get topmost handle at given position. More...
 
void GetShapesAtPosition (const wxPoint &pos, ShapeList &shapes)
 Get list of all shapes located at given position. More...
 
void GetShapesInside (const wxRect &rct, ShapeList &shapes)
 Get list of shapes located inside given rectangle. More...
 
void GetSelectedShapes (ShapeList &selection)
 Get list of selected shapes. More...
 
wxRect GetTotalBoundingBox () const
 Get box bounding all shapes in the canvas. More...
 
wxRect GetSelectionBB ()
 Get bounding box of all selected shapes. More...
 
void AlignSelected (HALIGN halign, VALIGN valign)
 Align selected shapes in given directions. More...
 
void SetStyle (long style)
 Set canvas style. More...
 
long GetStyle () const
 Get current canvas style. More...
 
void AddStyle (STYLE style)
 Add new style flag. More...
 
void RemoveStyle (STYLE style)
 Remove given style flag. More...
 
bool ContainsStyle (STYLE style) const
 Check whether given style flag is used. More...
 
void SetCanvasColour (const wxColour &col)
 Set canvas background color. More...
 
wxColour GetCanvasColour () const
 Get canvas background color. More...
 
void SetGradientFrom (const wxColour &col)
 Set starting gradient color. More...
 
wxColour GetGradientFrom () const
 Get starting gradient color. More...
 
void SetGradientTo (const wxColour &col)
 Set ending gradient color. More...
 
wxColour GetGradientTo () const
 Get ending gradient color. More...
 
wxSize GetGrid () const
 Get grid size. More...
 
void SetGrid (wxSize grid)
 Set grid size. More...
 
void SetGridLineMult (int multiple)
 Set grid line multiple. More...
 
int GetGrigLineMult () const
 Get grid line multiple. More...
 
void SetGridColour (const wxColour &col)
 Set grid color. More...
 
wxColour GetGridColour () const
 Get grid color. More...
 
void SetGridStyle (int style)
 Set grid line style. More...
 
int GetGridStyle () const
 Get grid line style. More...
 
void SetShadowOffset (const wxRealPoint &offset)
 Set shadow offset. More...
 
wxRealPoint GetShadowOffset () const
 Get shadow offset. More...
 
void SetShadowFill (const wxBrush &brush)
 Set shadow fill (used for shadows of non-text shapes only). More...
 
wxBrush GetShadowFill () const
 Get shadow fill. More...
 
void SetPrintHAlign (HALIGN val)
 Set horizontal align of printed drawing. More...
 
HALIGN GetPrintHAlign () const
 Get horizontal align of printed drawing. More...
 
void SetPrintVAlign (VALIGN val)
 Set vertical align of printed drawing. More...
 
VALIGN GetPrintVAlign () const
 Get vertical align of printed drawing. More...
 
void SetPrintMode (PRINTMODE mode)
 Set printing mode for this canvas. More...
 
PRINTMODE GetPrintMode () const
 Get printing mode for this canvas. More...
 
void SetScale (double scale)
 Set canvas scale. More...
 
void SetMinScale (double scale)
 Set minimal allowed scale (for mouse wheel scale change). More...
 
double GetMinScale ()
 Get minimal allowed scale (for mouse wheel scale change). More...
 
void SetMaxScale (double scale)
 Set maximal allowed scale (for mouse wheel scale change). More...
 
double GetMaxScale ()
 Set maximal allowed scale (for mouse wheel scale change). More...
 
double GetScale () const
 Get the canvas scale. More...
 
void SetScaleToViewAll ()
 Set the canvas scale so a whole diagram is visible. More...
 
void ScrollToShape (wxSFShapeBase *shape)
 Scroll the shape canvas so the given shape will be located in its center. More...
 
MODE GetMode () const
 Get canvas workind mode. More...
 
void SetHoverColour (const wxColour &col)
 Set default hover color. More...
 
wxColour GetHoverColour () const
 Get default hover color. More...
 
wxSFCanvasHistoryGetHistoryManager ()
 Get canvas hostory manager. More...
 
wxPoint FitPositionToGrid (const wxPoint &pos)
 Update given position so it will fit canvas grid (if enabled). More...
 
void UpdateMultieditSize ()
 Update size of multi selection rectangle. More...
 
void UpdateVirtualSize ()
 Update scroll window virtual size so it can display all shape canvas. More...
 
void MoveShapesFromNegatives ()
 Move all shapes so none of it will be located in negative position. More...
 
void CenterShapes ()
 Center diagram in accordance to the shape canvas extent. More...
 
void ValidateSelection (ShapeList &selection)
 Validate selection (remove redundantly selected shapes etc...). More...
 
virtual void DrawContent (wxDC &dc, bool fromPaint)
 Function responsible for drawing of the canvas's content to given DC. The default implementation draws actual objects managed by assigned diagram manager. More...
 
virtual void DrawBackground (wxDC &dc, bool fromPaint)
 Function responsible for drawing of the canvas's background to given DC. The default implementation draws canvas background and grid. More...
 
virtual void DrawForeground (wxDC &dc, bool fromPaint)
 Function responsible for drawing of the canvas's foreground to given DC. The default do nothing. More...
 
wxSFMultiSelRectGetMultiselectionBox ()
 Get reference to multiselection box. More...
 
void DeleteAllTextCtrls ()
 Close and delete all opened text editing controls actualy used by editable text shapes. More...
 
virtual void OnLeftDown (wxMouseEvent &event)
 Event handler called when the canvas is clicked by the left mouse button. The function can be overrided if necessary. More...
 
virtual void OnLeftDoubleClick (wxMouseEvent &event)
 Event handler called when the canvas is double-clicked by the left mouse button. The function can be overrided if necessary. More...
 
virtual void OnLeftUp (wxMouseEvent &event)
 Event handler called when the left mouse button is released. The function can be overrided if necessary. More...
 
virtual void OnRightDown (wxMouseEvent &event)
 Event handler called when the canvas is clicked by the right mouse button. The function can be overrided if necessary. More...
 
virtual void OnRightDoubleClick (wxMouseEvent &event)
 Event handler called when the canvas is double-clicked by the right mouse button. The function can be overrided if necessary. More...
 
virtual void OnRightUp (wxMouseEvent &event)
 Event handler called when the right mouse button is released. The function can be overrided if necessary. More...
 
virtual void OnMouseMove (wxMouseEvent &event)
 Event handler called when the mouse pointer is moved. The function can be overrided if necessary. More...
 
virtual void OnMouseWheel (wxMouseEvent &event)
 Event handler called when the mouse wheel position is changed. The function can be overrided if necessary. More...
 
virtual void OnKeyDown (wxKeyEvent &event)
 Event handler called when any key is pressed. The function can be overrided if necessary. More...
 
virtual void OnTextChange (wxSFEditTextShape *shape)
 Event handler called when any editable text shape is changed. The function can be overrided if necessary. The function is called by the framework and its default implementation generates wxEVT_SF_TEXT_CHANGE event. More...
 
virtual void OnConnectionFinished (wxSFLineShape *connection)
 
virtual PRECONNECTIONFINISHEDSTATE OnPreConnectionFinished (wxSFLineShape *connection)
 
virtual void OnDrop (wxCoord x, wxCoord y, wxDragResult def, const ShapeList &dropped)
 
virtual void OnPaste (const ShapeList &pasted)
 
virtual void OnUpdateVirtualSize (wxRect &virtrct)
 Event handler called if canvas virtual size is going to be updated. The default implementation does nothing but the function can be overrided by a user to modify calculated virtual canvas size. More...
 

Static Public Member Functions

static void EnableGC (bool enab)
 Enable usage of wxGraphicsContext for drawing (if supported). More...
 
static bool IsGCEnabled ()
 Function returns information whether the wxGraphicsContext is enabled (if supported). More...
 

Protected Attributes

MODE m_nWorkingMode
 
SELECTIONMODE m_nSelectionMode
 
wxSFCanvasSettings m_Settings
 

Static Protected Attributes

static bool m_fEnableGC
 

Private Member Functions

void ValidateSelectionForClipboard (ShapeList &selection, bool storeprevpos)
 Validate selection so the shapes in the given list can be processed by the clipboard functions. More...
 
void AppendAssignedConnections (wxSFShapeBase *shape, ShapeList &selection, bool childrenonly)
 Append connections assigned to shapes in given list to this list as well. More...
 
void InitializePrinting ()
 Initialize printing framework. More...
 
void DeinitializePrinting ()
 Deinitialize prnting framework. More...
 
void RemoveFromTemporaries (wxSFShapeBase *shape)
 Remove given shape for temporary containers. More...
 
void ClearTemporaries ()
 Clear all temporary containers. More...
 
void ReparentShape (wxSFShapeBase *shape, const wxPoint &parentpos)
 Assign give shape to parent at given location (if exists) More...
 
void StorePrevPosition (const wxSFShapeBase *shape)
 Store previous shape's position modified in ValidateSelectionForClipboard() function. More...
 
void RestorePrevPositions ()
 Restore previously stored shapes' positions and clear the storage. More...
 
void _OnPaint (wxPaintEvent &event)
 Event handler called when the canvas should be repainted. More...
 
void _OnEraseBackground (wxEraseEvent &event)
 Event handler called when the canvas should be erased. More...
 
void _OnLeaveWindow (wxMouseEvent &event)
 Event handler called when the mouse pointer leaves the canvas window. More...
 
void _OnEnterWindow (wxMouseEvent &event)
 Event handler called when the mouse pointer enters the canvas window. More...
 
void _OnResize (wxSizeEvent &event)
 Event handler called when the canvas size has changed. More...
 
void _OnLeftDown (wxMouseEvent &event)
 Original private event handler called when the canvas is clicked by left mouse button. The handler calls user-overridable event handler function and skips the event for next possible processing. More...
 
void _OnLeftDoubleClick (wxMouseEvent &event)
 Original private event handler called when the canvas is double-clicked by left mouse button. The handler calls user-overridable event handler function and skips the event for next possible processing. More...
 
void _OnLeftUp (wxMouseEvent &event)
 Original private event handler called when the left mouse button is release above the canvas. The handler calls user-overridable event handler function and skips the event for next possible processing. More...
 
void _OnRightDown (wxMouseEvent &event)
 Original private event handler called when the canvas is clicked by right mouse button. The handler calls user-overridable event handler function and skips the event for next possible processing. More...
 
void _OnRightDoubleClick (wxMouseEvent &event)
 Original private event handler called when the canvas is double-clicked by right mouse button. The handler calls user-overridable event handler function and skips the event for next possible processing. More...
 
void _OnRightUp (wxMouseEvent &event)
 Original private event handler called when the right mouse button is release above the canvas. The handler calls user-overridable event handler function and skips the event for next possible processing. More...
 
void _OnMouseMove (wxMouseEvent &event)
 Original private event handler called when the mouse pointer is moving above the canvas. The handler calls user-overridable event handler function and skips the event for next possible processing. More...
 
void _OnMouseWheel (wxMouseEvent &event)
 Original private event handler called when the mouse wheel pocition is changed. The handler calls user-overridable event handler function and skips the event for next possible processing. More...
 
void _OnKeyDown (wxKeyEvent &event)
 Original private event handler called when any key is pressed. The handler calls user-overridable event handler function and skips the event for next possible processing. More...
 
void _OnDrop (wxCoord x, wxCoord y, wxDragResult def, wxDataObject *data)
 Function is called by associated wxSFCanvasDropTarget after any dragged shapes are dropped to the canvas. More...
 
 DECLARE_EVENT_TABLE ()
 

Private Attributes

wxRealPoint m_selectionStart
 
wxSFMultiSelRect m_shpSelection
 
wxSFMultiSelRect m_shpMultiEdit
 
bool m_fCanSaveStateOnMouseUp
 
bool m_fDnDStartedHere
 Flag used for determination whether the D&D operation has started and ended in one canvas instance. More...
 
wxPoint m_nDnDStartedAt
 Started position of current D&D operation. More...
 
wxDataFormat m_formatShapes
 Custom data format object (used for the clipboard and D&D operations. More...
 
wxPoint m_nPrevMousePos
 
PositionMap m_mapPrevPositions
 
wxRect m_nInvalidateRect
 
wxSFCanvasHistory m_CanvasHistory
 Canvas history manager. More...
 
wxSFDiagramManagerm_pManager
 Pointer to parent data (shapes) manager. More...
 
wxSFShapeHandlem_pSelectedHandle
 Pointer to currently selected shape handle. More...
 
wxSFLineShapem_pNewLineShape
 Pointer to new line shape under constuction. More...
 
wxSFShapeBasem_pUnselectedShapeUnderCursor
 Pointer to topmost unselected shape under the mouse cursor. More...
 
wxSFShapeBasem_pSelectedShapeUnderCursor
 Pointer to topmost selected shape under the mouse cursor. More...
 
wxSFShapeBasem_pTopmostShapeUnderCursor
 Pointer to topmost shape under the mouse cursor. More...
 
ShapeList m_lstCurrentShapes
 Current list of all shapes in the canvas updated during mouse movement. More...
 

Static Private Attributes

static wxBitmap m_OutBMP
 
static int m_nRefCounter
 

Friends

class wxSFDiagramManager
 
class wxSFCanvasDropTarget
 

Detailed Description

Class encapsulating a Shape canvas. The shape canvas is window control which extends the wxScrolledWindow and is responsible for displaying of shapes diagrams. It also supports clipboard and drag&drop operations, undo/redo operations, and graphics exporting functions.

This class is a core framework class and provides many member functions suitable for adding, removing, moving, resizing and drawing of shape objects. It can be used as it is or as a base class if necessary. In that case, the default class functionality can be enhaced by overriding of its virtual functions or by manual events handling. In both cases the user is responsible for invoking of default event handlers/virtual functions otherwise the built in functionality wont be available.

See also
wxSFDiagramManager

Member Enumeration Documentation

◆ HALIGN

Flags for AlignSelected function.

Enumerator
halignNONE 
halignLEFT 
halignCENTER 
halignRIGHT 

◆ MODE

Working modes.

Enumerator
modeREADY 

The shape canvas is in ready state (no operation is pending)

modeHANDLEMOVE 

Some shape handle is dragged.

modeMULTIHANDLEMOVE 

Handle of multiselection tool is dragged.

modeSHAPEMOVE 

Some shape/s is/are dragged.

modeMULTISELECTION 

Multiple shape selection is in progess.

modeCREATECONNECTION 

Interactive connection creation is in progress.

modeDND 

Canvas is in the Drag&Drop mode.

◆ PRECONNECTIONFINISHEDSTATE

Enumerator
pfsOK 

Finish line connection.

pfsFAILED_AND_CANCEL_LINE 

Cancel line connection and abort the interactive connection.

pfsFAILED_AND_CONTINUE_EDIT 

Cancel line connection and continue with the interactive connection.

◆ PRINTMODE

Printing modes used by SetPrintMode() function.

Enumerator
prnFIT_TO_PAPER 

This sets the user scale and origin of the DC so that the image fits within the paper rectangle (but the edges could be cut off by printers that can't print to the edges of the paper – which is most of them. Use this if your image already has its own margins.

prnFIT_TO_PAGE 

This sets the user scale and origin of the DC so that the image fits within the page rectangle, which is the printable area on Mac and MSW and is the entire page on other platforms.

prnFIT_TO_MARGINS 

This sets the user scale and origin of the DC so that the image fits within the page margins as specified by g_PageSetupData, which you can change (on some platforms, at least) in the Page Setup dialog. Note that on Mac, the native Page Setup dialog doesn't let you change the margins of a wxPageSetupDialogData object, so you'll have to write your own dialog or use the Mac-only wxMacPageMarginsDialog, as we do in this program.

prnMAP_TO_PAPER 

This sets the user scale and origin of the DC so that you could map the screen image to the entire paper at the same size as it appears on screen.

prnMAP_TO_PAGE 

This sets the user scale and origin of the DC so that the image appears on the paper at the same size that it appears on screen (i.e., 10-point type on screen is 10-point on the printed page).

prnMAP_TO_MARGINS 

This sets the user scale and origin of the DC so that you could map the screen image to the page margins specified by the native Page Setup dialog at the same size as it appears on screen.

prnMAP_TO_DEVICE 

This sets the user scale and origin of the DC so that you can to do you own scaling in order to draw objects at full native device resolution.

◆ SEARCHMODE

Search mode flags for GetShapeAtPosition function.

Enumerator
searchSELECTED 

Search for selected shapes only.

searchUNSELECTED 

Search for unselected shapes only.

searchBOTH 

Search for both selected and unselected shapes.

◆ SELECTIONMODE

Selection modes.

Enumerator
selectNORMAL 
selectADD 
selectREMOVE 

◆ SHADOWMODE

Flags for ShowShadow function.

Enumerator
shadowTOPMOST 

Show/hide shadow under topmost shapes only.

shadowALL 

Show/hide shadow under all shapes in the diagram.

◆ STYLE

Style flags.

Enumerator
sfsMULTI_SELECTION 

Allow multiselection box.

sfsMULTI_SIZE_CHANGE 

Allow shapes' size change done via the multiselection box.

sfsGRID_SHOW 

Show grid.

sfsGRID_USE 

Use grid.

sfsDND 

Enable Drag & Drop operations.

sfsUNDOREDO 

Enable Undo/Redo operations.

sfsCLIPBOARD 

Enable the clipboard.

sfsHOVERING 

Enable mouse hovering.

sfsHIGHLIGHTING 

Enable highligting of shapes able to accept dragged shape(s).

sfsGRADIENT_BACKGROUND 

Use gradient color for the canvas background.

sfsPRINT_BACKGROUND 

Print also canvas background.

sfsPROCESS_MOUSEWHEEL 

Process mouse wheel by the canvas (canvas scale will be changed).

sfsDEFAULT_CANVAS_STYLE 

Default canvas style.

◆ VALIGN

Flags for AlignSelected function.

Enumerator
valignNONE 
valignTOP 
valignMIDDLE 
valignBOTTOM 

Constructor & Destructor Documentation

◆ wxSFShapeCanvas() [1/2]

wxSFShapeCanvas::wxSFShapeCanvas ( )

Default constructor.

◆ wxSFShapeCanvas() [2/2]

wxSFShapeCanvas::wxSFShapeCanvas ( wxSFDiagramManager manager,
wxWindow *  parent,
wxWindowID  id = -1,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxHSCROLL|wxVSCROLL 
)

Constructor.

Parameters
managerPointer to shape manager
parentParent window
idWindow ID
posInitial position
sizeInitial size
styleWindow style

◆ ~wxSFShapeCanvas()

wxSFShapeCanvas::~wxSFShapeCanvas ( void  )

Destructor.

Member Function Documentation

◆ _OnDrop()

void wxSFShapeCanvas::_OnDrop ( wxCoord  x,
wxCoord  y,
wxDragResult  def,
wxDataObject *  data 
)
private

Function is called by associated wxSFCanvasDropTarget after any dragged shapes are dropped to the canvas.

Parameters
xX-coordinate of a position the data was dropped to
yY-coordinate of a position the data was dropped to
defDrag result
dataPointer to a data object encapsulating dropped data
See also
wxSFCanvasDropTarget

◆ _OnEnterWindow()

void wxSFShapeCanvas::_OnEnterWindow ( wxMouseEvent &  event)
private

Event handler called when the mouse pointer enters the canvas window.

Parameters
eventMouse event

◆ _OnEraseBackground()

void wxSFShapeCanvas::_OnEraseBackground ( wxEraseEvent &  event)
private

Event handler called when the canvas should be erased.

Parameters
eventErase event

◆ _OnKeyDown()

void wxSFShapeCanvas::_OnKeyDown ( wxKeyEvent &  event)
private

Original private event handler called when any key is pressed. The handler calls user-overridable event handler function and skips the event for next possible processing.

Parameters
eventKeyboard event
See also
wxSFShapeCanvas::OnKeyDown

◆ _OnLeaveWindow()

void wxSFShapeCanvas::_OnLeaveWindow ( wxMouseEvent &  event)
private

Event handler called when the mouse pointer leaves the canvas window.

Parameters
eventMouse event

◆ _OnLeftDoubleClick()

void wxSFShapeCanvas::_OnLeftDoubleClick ( wxMouseEvent &  event)
private

Original private event handler called when the canvas is double-clicked by left mouse button. The handler calls user-overridable event handler function and skips the event for next possible processing.

Parameters
eventMouse event
See also
wxSFShapeCanvas::OnLeftDoubleClick

◆ _OnLeftDown()

void wxSFShapeCanvas::_OnLeftDown ( wxMouseEvent &  event)
private

Original private event handler called when the canvas is clicked by left mouse button. The handler calls user-overridable event handler function and skips the event for next possible processing.

Parameters
eventMouse event
See also
wxSFShapeCanvas::OnLeftDown

◆ _OnLeftUp()

void wxSFShapeCanvas::_OnLeftUp ( wxMouseEvent &  event)
private

Original private event handler called when the left mouse button is release above the canvas. The handler calls user-overridable event handler function and skips the event for next possible processing.

Parameters
eventMouse event
See also
wxSFShapeCanvas::OnLeftUp

◆ _OnMouseMove()

void wxSFShapeCanvas::_OnMouseMove ( wxMouseEvent &  event)
private

Original private event handler called when the mouse pointer is moving above the canvas. The handler calls user-overridable event handler function and skips the event for next possible processing.

Parameters
eventMouse event
See also
wxSFShapeCanvas::OnMouseMove

◆ _OnMouseWheel()

void wxSFShapeCanvas::_OnMouseWheel ( wxMouseEvent &  event)
private

Original private event handler called when the mouse wheel pocition is changed. The handler calls user-overridable event handler function and skips the event for next possible processing.

Parameters
eventMouse event
See also
wxSFShapeCanvas::OnMouseWheel

◆ _OnPaint()

void wxSFShapeCanvas::_OnPaint ( wxPaintEvent &  event)
private

Event handler called when the canvas should be repainted.

Parameters
eventPaint event

◆ _OnResize()

void wxSFShapeCanvas::_OnResize ( wxSizeEvent &  event)
private

Event handler called when the canvas size has changed.

Parameters
eventSize event

◆ _OnRightDoubleClick()

void wxSFShapeCanvas::_OnRightDoubleClick ( wxMouseEvent &  event)
private

Original private event handler called when the canvas is double-clicked by right mouse button. The handler calls user-overridable event handler function and skips the event for next possible processing.

Parameters
eventMouse event
See also
wxSFShapeCanvas::OnRightDoubleClick

◆ _OnRightDown()

void wxSFShapeCanvas::_OnRightDown ( wxMouseEvent &  event)
private

Original private event handler called when the canvas is clicked by right mouse button. The handler calls user-overridable event handler function and skips the event for next possible processing.

Parameters
eventMouse event
See also
wxSFShapeCanvas::OnRightDown

◆ _OnRightUp()

void wxSFShapeCanvas::_OnRightUp ( wxMouseEvent &  event)
private

Original private event handler called when the right mouse button is release above the canvas. The handler calls user-overridable event handler function and skips the event for next possible processing.

Parameters
eventMouse event
See also
wxSFShapeCanvas::OnRightUp

◆ AbortInteractiveConnection()

void wxSFShapeCanvas::AbortInteractiveConnection ( )

Abort interactive connection creation process.

◆ AddStyle()

void wxSFShapeCanvas::AddStyle ( STYLE  style)
inline

Add new style flag.

◆ AlignSelected()

void wxSFShapeCanvas::AlignSelected ( HALIGN  halign,
VALIGN  valign 
)

Align selected shapes in given directions.

Shapes will be aligned according to most far shape in appropriate direction.

Parameters
halignHorizontal alignment
valignVertical alignment

◆ AppendAssignedConnections()

void wxSFShapeCanvas::AppendAssignedConnections ( wxSFShapeBase shape,
ShapeList &  selection,
bool  childrenonly 
)
private

Append connections assigned to shapes in given list to this list as well.

◆ CanAlignSelected()

bool wxSFShapeCanvas::CanAlignSelected ( )

Function returns TRUE if AlignSelected function can be invoked (if more than one shape is selected)

◆ CanCopy()

bool wxSFShapeCanvas::CanCopy ( )

Function returns TRUE if some shapes can be copied to the clipboard (it means they are selected)

◆ CanCut()

bool wxSFShapeCanvas::CanCut ( )

Function returns TRUE if some shapes can be cutted to the clipboard (it means they are selected)

◆ CanPaste()

bool wxSFShapeCanvas::CanPaste ( )

Function returns TRUE if some shapes can be copied from the clipboard to the canvas (it means the clipboard contains stored shapes)

◆ CanRedo()

bool wxSFShapeCanvas::CanRedo ( )

Function returns TRUE if Redo operation can be done.

◆ CanUndo()

bool wxSFShapeCanvas::CanUndo ( )

Function returns TRUE if Undo operation can be done.

◆ CenterShapes()

void wxSFShapeCanvas::CenterShapes ( )

Center diagram in accordance to the shape canvas extent.

◆ ClearCanvasHistory()

void wxSFShapeCanvas::ClearCanvasHistory ( )

Clear all stored canvas states (no Undo/Redo operations will be available)

◆ ClearTemporaries()

void wxSFShapeCanvas::ClearTemporaries ( )
private

Clear all temporary containers.

◆ ContainsStyle()

bool wxSFShapeCanvas::ContainsStyle ( STYLE  style) const
inline

Check whether given style flag is used.

◆ Copy()

void wxSFShapeCanvas::Copy ( )

Copy selected shapes to the clipboard.

◆ Create()

virtual bool wxSFShapeCanvas::Create ( wxWindow *  parent,
wxWindowID  id = -1,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxHSCROLL|wxVSCROLL,
const wxString &  name = wxT("scrolledWindow") 
)
virtual

Creates the window in two-step construction mode. SetDiagramManager() function must be also called to complete the canvas initialization.

Parameters
parentParent window
idWindow ID
posInitial position
sizeInitial size
styleWindow style
nameWindow name

◆ Cut()

void wxSFShapeCanvas::Cut ( )

Copy selected shapes to the clipboard and remove them from the canvas.

◆ DECLARE_EVENT_TABLE()

wxSFShapeCanvas::DECLARE_EVENT_TABLE ( )
private

◆ DeinitializePrinting()

void wxSFShapeCanvas::DeinitializePrinting ( )
private

Deinitialize prnting framework.

◆ DeleteAllTextCtrls()

void wxSFShapeCanvas::DeleteAllTextCtrls ( )

Close and delete all opened text editing controls actualy used by editable text shapes.

◆ DeselectAll()

void wxSFShapeCanvas::DeselectAll ( )

Deselect all shapes.

◆ DoDragDrop()

wxDragResult wxSFShapeCanvas::DoDragDrop ( ShapeList &  shapes,
const wxPoint &  start = wxPoint(-1, -1) 
)

Start Drag&Drop operation with shapes included in the given list.

Parameters
shapesList of shapes which should be dragged
startA point where the dragging operation has started
Returns
rct Drag result

◆ DP2LP() [1/2]

wxPoint wxSFShapeCanvas::DP2LP ( const wxPoint &  pos) const

Show page margins setup dialog (available only for MAC). *‍/ void PageMargins(); #endif.

/*!
   \brief Convert device position to logical position.

   The function returns unscrolled unscaled canvas position.
   \param pos Device position (for example mouse position)
   \return Logical position

◆ DP2LP() [2/2]

wxRect wxSFShapeCanvas::DP2LP ( const wxRect &  rct) const

◆ DrawBackground()

virtual void wxSFShapeCanvas::DrawBackground ( wxDC &  dc,
bool  fromPaint 
)
virtual

Function responsible for drawing of the canvas's background to given DC. The default implementation draws canvas background and grid.

Parameters
dcReference to device context where the shapes will be drawn to
fromPaintSet the argument to TRUE if the dc argument refers to the wxPaintDC instance or derived classes (i.e. the function is called as a response to wxEVT_PAINT event)

◆ DrawContent()

virtual void wxSFShapeCanvas::DrawContent ( wxDC &  dc,
bool  fromPaint 
)
virtual

Function responsible for drawing of the canvas's content to given DC. The default implementation draws actual objects managed by assigned diagram manager.

Parameters
dcReference to device context where the shapes will be drawn to
fromPaintSet the argument to TRUE if the dc argument refers to the wxPaintDC instance or derived classes (i.e. the function is called as a response to wxEVT_PAINT event)

◆ DrawForeground()

virtual void wxSFShapeCanvas::DrawForeground ( wxDC &  dc,
bool  fromPaint 
)
virtual

Function responsible for drawing of the canvas's foreground to given DC. The default do nothing.

Parameters
dcReference to device context where the shapes will be drawn to
fromPaintSet the argument to TRUE if the dc argument refers to the wxPaintDC instance or derived classes (i.e. the function is called as a response to wxEVT_PAINT event)

◆ EnableGC()

static void wxSFShapeCanvas::EnableGC ( bool  enab)
static

Enable usage of wxGraphicsContext for drawing (if supported).

Parameters
enabIf TRUE then the wxGraphicsContext will be used

◆ FitPositionToGrid()

wxPoint wxSFShapeCanvas::FitPositionToGrid ( const wxPoint &  pos)

Update given position so it will fit canvas grid (if enabled).

Parameters
posPosition which should be updated
Returns
Updated position

◆ GetCanvasColour()

wxColour wxSFShapeCanvas::GetCanvasColour ( ) const
inline

Get canvas background color.

Returns
Background color

◆ GetDiagramManager()

wxSFDiagramManager* wxSFShapeCanvas::GetDiagramManager ( )
inline

Get diagram manager associated with this instance of shape canvas.

Returns
Pointer to diagram manager
See also
wxSFDiagramManager

◆ GetGradientFrom()

wxColour wxSFShapeCanvas::GetGradientFrom ( ) const
inline

Get starting gradient color.

Returns
Color

◆ GetGradientTo()

wxColour wxSFShapeCanvas::GetGradientTo ( ) const
inline

Get ending gradient color.

Returns
Color

◆ GetGrid()

wxSize wxSFShapeCanvas::GetGrid ( ) const
inline

Get grid size.

Returns
Grid size

◆ GetGridColour()

wxColour wxSFShapeCanvas::GetGridColour ( ) const
inline

Get grid color.

Returns
Grid color

◆ GetGridStyle()

int wxSFShapeCanvas::GetGridStyle ( ) const
inline

Get grid line style.

Returns
Line style

◆ GetGrigLineMult()

int wxSFShapeCanvas::GetGrigLineMult ( ) const
inline

Get grid line multiple.

Returns
Value by which a grid size will be multiplicated to determine grid lines distance

◆ GetHistoryManager()

wxSFCanvasHistory& wxSFShapeCanvas::GetHistoryManager ( )
inline

Get canvas hostory manager.

Returns
Reference to the canvas history manager
See also
wxSFCanvasHistory

◆ GetHoverColour()

wxColour wxSFShapeCanvas::GetHoverColour ( ) const
inline

Get default hover color.

Returns
Hover color

◆ GetMaxScale()

double wxSFShapeCanvas::GetMaxScale ( )
inline

Set maximal allowed scale (for mouse wheel scale change).

Returns
Maximal scale

◆ GetMinScale()

double wxSFShapeCanvas::GetMinScale ( )
inline

Get minimal allowed scale (for mouse wheel scale change).

Returns
Minimal scale

◆ GetMode()

MODE wxSFShapeCanvas::GetMode ( ) const
inline

Get canvas workind mode.

Returns
Working mode
See also
MODE

◆ GetMultiselectionBox()

wxSFMultiSelRect& wxSFShapeCanvas::GetMultiselectionBox ( )
inline

Get reference to multiselection box.

Returns
Reference to multiselection box object

◆ GetPrintHAlign()

HALIGN wxSFShapeCanvas::GetPrintHAlign ( ) const
inline

Get horizontal align of printed drawing.

Returns
Current horizontal align
See also
HALIGN

◆ GetPrintMode()

PRINTMODE wxSFShapeCanvas::GetPrintMode ( ) const
inline

Get printing mode for this canvas.

Returns
Current printing mode
See also
PRINTMODE

◆ GetPrintVAlign()

VALIGN wxSFShapeCanvas::GetPrintVAlign ( ) const
inline

Get vertical align of printed drawing.

Returns
Current vertical align
See also
VALIGN

◆ GetScale()

double wxSFShapeCanvas::GetScale ( ) const
inline

Get the canvas scale.

Returns
Canvas scale

◆ GetSelectedShapes()

void wxSFShapeCanvas::GetSelectedShapes ( ShapeList &  selection)

Get list of selected shapes.

Parameters
selectionReference to shape list where pointers to all selected shapes will be stored

◆ GetSelectionBB()

wxRect wxSFShapeCanvas::GetSelectionBB ( )

Get bounding box of all selected shapes.

Returns
Selection bounding box

◆ GetShadowFill()

wxBrush wxSFShapeCanvas::GetShadowFill ( ) const
inline

Get shadow fill.

Returns
Current shadow brush

◆ GetShadowOffset()

wxRealPoint wxSFShapeCanvas::GetShadowOffset ( ) const
inline

Get shadow offset.

Returns
Shadow offset

◆ GetShapeAtPosition()

wxSFShapeBase* wxSFShapeCanvas::GetShapeAtPosition ( const wxPoint &  pos,
int  zorder = 1,
SEARCHMODE  mode = searchBOTH 
)

Get shape at given logical position.

Parameters
posLogical position
zorderZ-order of searched shape (usefull if several shapes are located at the given position)
modeSearch mode
Returns
Pointer to shape if found, otherwise NULL
See also
SEARCHMODE, wxSFShapeCanvas::DP2LP,, wxSFShapeCanvas::GetShapeUnderCursor

◆ GetShapesAtPosition()

void wxSFShapeCanvas::GetShapesAtPosition ( const wxPoint &  pos,
ShapeList &  shapes 
)

Get list of all shapes located at given position.

Parameters
posLogical position
shapesReference to shape list where pointers to all found shapes will be stored
See also
wxSFShapeCanvas::DP2LP

◆ GetShapesInside()

void wxSFShapeCanvas::GetShapesInside ( const wxRect &  rct,
ShapeList &  shapes 
)

Get list of shapes located inside given rectangle.

Parameters
rctExamined rectangle
shapesReference to shape list where pointers to all found shapes will be stored

◆ GetShapeUnderCursor()

wxSFShapeBase* wxSFShapeCanvas::GetShapeUnderCursor ( SEARCHMODE  mode = searchBOTH)

Get shape under current mouse cursor position (fast implementation - use everywhere it is possible instead of much slower GetShapeAtPosition()).

Parameters
modeSearch mode
Returns
Pointer to shape if found, otherwise NULL
See also
SEARCHMODE, wxSFShapeCanvas::DP2LP, wxSFShapeCanvas::GetShapeAtPosition

◆ GetStyle()

long wxSFShapeCanvas::GetStyle ( ) const
inline

Get current canvas style.

◆ GetTopmostHandleAtPosition()

wxSFShapeHandle* wxSFShapeCanvas::GetTopmostHandleAtPosition ( const wxPoint &  pos)

Get topmost handle at given position.

Parameters
posLogical position
Returns
Pointer to shape handle object if found, otherwise NULL
See also
wxSFShapeCanvas::DP2LP

◆ GetTotalBoundingBox()

wxRect wxSFShapeCanvas::GetTotalBoundingBox ( ) const

Get box bounding all shapes in the canvas.

Returns
Total bounding box

◆ HideAllHandles()

void wxSFShapeCanvas::HideAllHandles ( )

Hide handles of all shapes.

◆ InitializePrinting()

void wxSFShapeCanvas::InitializePrinting ( )
private

Initialize printing framework.

◆ InvalidateRect()

void wxSFShapeCanvas::InvalidateRect ( const wxRect &  rct)

Mark given rectangle as an invalidated one, i.e. as a rectangle which should be refreshed (by using wxSFShapeCanvas::RefreshInvalidatedRect()).

Parameters
rctRectangle to be invalidated

◆ InvalidateVisibleRect()

void wxSFShapeCanvas::InvalidateVisibleRect ( )

Mark whole visible canvas portion as an invalidated rectangle.

◆ IsGCEnabled()

static bool wxSFShapeCanvas::IsGCEnabled ( )
inlinestatic

Function returns information whether the wxGraphicsContext is enabled (if supported).

Returns
TRUE if the wxGraphicsContext is enabled

◆ LoadCanvas()

void wxSFShapeCanvas::LoadCanvas ( const wxString &  file)

Load serialized canvas content (diagrams) from given file.

Parameters
fileFull file name

◆ LP2DP() [1/2]

wxPoint wxSFShapeCanvas::LP2DP ( const wxPoint &  pos) const

Convert logical position to device position.

The function returns scrolled scaled canvas position.

Parameters
posLogical position (for example shape position)
Returns
Device position

◆ LP2DP() [2/2]

wxRect wxSFShapeCanvas::LP2DP ( const wxRect &  rct) const

◆ MoveShapesFromNegatives()

void wxSFShapeCanvas::MoveShapesFromNegatives ( )

Move all shapes so none of it will be located in negative position.

◆ OnConnectionFinished()

virtual void wxSFShapeCanvas::OnConnectionFinished ( wxSFLineShape connection)
virtual
\brief Event handler called after successfull conection creation. The function
can be overrided if necessary. The default implementation

generates wxEVT_SF_LINE_DONE event.

Parameters
connectionPointer to new connection object
See also
StartInteractiveConnection(), wxSFShapeEvent

◆ OnDrop()

virtual void wxSFShapeCanvas::OnDrop ( wxCoord  x,
wxCoord  y,
wxDragResult  def,
const ShapeList &  dropped 
)
virtual
\brief Event handler called by the framework after any dragged shapes
are dropped to the canvas. The default implementation

generates wxEVT_SF_ON_DROP event.

Parameters
xX-coordinate of a position the data was dropped to
yY-coordinate of a position the data was dropped to
defDrag result
droppedReference to a list containing the dropped data
See also
wxSFCanvasDropTarget, wxSFShapeDropEvent

◆ OnKeyDown()

virtual void wxSFShapeCanvas::OnKeyDown ( wxKeyEvent &  event)
virtual

Event handler called when any key is pressed. The function can be overrided if necessary.

The function is called by the framework and provides basic functionality needed for proper management of displayed shape. It is necessary to call this function from overrided methods if the default canvas behaviour should be preserved.

Parameters
eventKeyboard event
See also
_OnKeyDown()

◆ OnLeftDoubleClick()

virtual void wxSFShapeCanvas::OnLeftDoubleClick ( wxMouseEvent &  event)
virtual

Event handler called when the canvas is double-clicked by the left mouse button. The function can be overrided if necessary.

The function is called by the framework and provides basic functionality needed for proper management of displayed shape. It is necessary to call this function from overrided methods if the default canvas behaviour should be preserved.

Parameters
eventMouse event
See also
_OnLeftDoubleClick()

◆ OnLeftDown()

virtual void wxSFShapeCanvas::OnLeftDown ( wxMouseEvent &  event)
virtual

Event handler called when the canvas is clicked by the left mouse button. The function can be overrided if necessary.

The function is called by the framework and provides basic functionality needed for proper management of displayed shape. It is necessary to call this function from overrided methods if the default canvas behaviour should be preserved.

Parameters
eventMouse event
See also
_OnLeftDown()

◆ OnLeftUp()

virtual void wxSFShapeCanvas::OnLeftUp ( wxMouseEvent &  event)
virtual

Event handler called when the left mouse button is released. The function can be overrided if necessary.

The function is called by the framework and provides basic functionality needed for proper management of displayed shape. It is necessary to call this function from overrided methods if the default canvas behaviour should be preserved.

Parameters
eventMouse event
See also
_OnLeftUp()

◆ OnMouseMove()

virtual void wxSFShapeCanvas::OnMouseMove ( wxMouseEvent &  event)
virtual

Event handler called when the mouse pointer is moved. The function can be overrided if necessary.

The function is called by the framework and provides basic functionality needed for proper management of displayed shape. It is necessary to call this function from overrided methods if the default canvas behaviour should be preserved.

Parameters
eventMouse event
See also
_OnMouseMove()

◆ OnMouseWheel()

virtual void wxSFShapeCanvas::OnMouseWheel ( wxMouseEvent &  event)
virtual

Event handler called when the mouse wheel position is changed. The function can be overrided if necessary.

The function is called by the framework and provides basic functionality needed for proper management of displayed shape. It is necessary to call this function from overrided methods if the default canvas behaviour should be preserved.

Parameters
eventMouse event
See also
_OnMouseWheel()

◆ OnPaste()

virtual void wxSFShapeCanvas::OnPaste ( const ShapeList &  pasted)
virtual
\brief Event handler called by the framework after pasting of shapes
from the clipboard to the canvas. The default implementation

generates wxEVT_SF_ON_PASTE event.

Parameters
pastedReference to a list containing the pasted data
See also
wxSFShapeCanvas::Paste(), wxSFShapePasteEvent

◆ OnPreConnectionFinished()

virtual PRECONNECTIONFINISHEDSTATE wxSFShapeCanvas::OnPreConnectionFinished ( wxSFLineShape connection)
virtual
\brief Event handler called after successfull conection creation in
order to alow developper to perform some kind of checks
before the connection is really added to the diagram. The function
can be overrided if necessary. The default implementation

generates wxEVT_SF_LINE_DONE event.

Parameters
connectionPointer to new connection object
See also
StartInteractiveConnection(), wxSFShapeEvent
Returns
false if the generated event has been vetoed in this case, the connection creation is cancelled

◆ OnRightDoubleClick()

virtual void wxSFShapeCanvas::OnRightDoubleClick ( wxMouseEvent &  event)
virtual

Event handler called when the canvas is double-clicked by the right mouse button. The function can be overrided if necessary.

The function is called by the framework and provides basic functionality needed for proper management of displayed shape. It is necessary to call this function from overrided methods if the default canvas behaviour should be preserved.

Parameters
eventMouse event
See also
_OnRightDoubleClick()

◆ OnRightDown()

virtual void wxSFShapeCanvas::OnRightDown ( wxMouseEvent &  event)
virtual

Event handler called when the canvas is clicked by the right mouse button. The function can be overrided if necessary.

The function is called by the framework and provides basic functionality needed for proper management of displayed shape. It is necessary to call this function from overrided methods if the default canvas behaviour should be preserved.

Parameters
eventMouse event
See also
_OnRightDown()

◆ OnRightUp()

virtual void wxSFShapeCanvas::OnRightUp ( wxMouseEvent &  event)
virtual

Event handler called when the right mouse button is released. The function can be overrided if necessary.

The function is called by the framework and provides basic functionality needed for proper management of displayed shape. It is necessary to call this function from overrided methods if the default canvas behaviour should be preserved.

Parameters
eventMouse event
See also
_OnRightUp()

◆ OnTextChange()

virtual void wxSFShapeCanvas::OnTextChange ( wxSFEditTextShape shape)
virtual

Event handler called when any editable text shape is changed. The function can be overrided if necessary. The function is called by the framework and its default implementation generates wxEVT_SF_TEXT_CHANGE event.

Parameters
shapeChanged wxSFEditTextShape object
See also
wxSFEditTextShape::EditLabel(), wxSFShapeTextEvent

◆ OnUpdateVirtualSize()

virtual void wxSFShapeCanvas::OnUpdateVirtualSize ( wxRect &  virtrct)
virtual

Event handler called if canvas virtual size is going to be updated. The default implementation does nothing but the function can be overrided by a user to modify calculated virtual canvas size.

Parameters
virtrctCalculated canvas virtual size

◆ PageSetup()

void wxSFShapeCanvas::PageSetup ( )

Show page setup dialog for printing.

◆ Paste()

void wxSFShapeCanvas::Paste ( )

Paste shapes stored in the clipboard to the canvas.

◆ Print() [1/2]

void wxSFShapeCanvas::Print ( bool  prompt = sfPROMPT)

Print current canvas content.

Parameters
promptIf TRUE (sfPROMT) then the the native print dialog will be displayed before printing

◆ Print() [2/2]

void wxSFShapeCanvas::Print ( wxSFPrintout printout,
bool  prompt = sfPROMPT 
)

Print current canvas content using user-defined printout class.

Parameters
printoutPointer to user-defined printout object (inherited from wxSFPrintout class). Do not delete this object explicitly.
promptIf TRUE (sfPROMT) then the native print dialog will be displayed before printing
See also
wxSFPrintout

◆ PrintPreview() [1/2]

void wxSFShapeCanvas::PrintPreview ( )

Show print preview.

◆ PrintPreview() [2/2]

void wxSFShapeCanvas::PrintPreview ( wxSFPrintout preview,
wxSFPrintout printout = NULL 
)
\brief Show print preview using user-defined printout classes.
Parameters
previewPointer to user-defined printout object (inherited from wxSFPrintout class) used for print preview. Do not delete this object explicitly.
printoutPointer to user-defined printout class (inherited from wxSFPrintout class) used for printing. Do not delete this object explicitly. This parameter can be NULL (in this case a print button will not be available in the print preview window).
See also
wxSFPrintout

◆ Redo()

void wxSFShapeCanvas::Redo ( )

Perform Redo operation (if available)

◆ RefreshCanvas()

void wxSFShapeCanvas::RefreshCanvas ( bool  erase,
const wxRect &  rct 
)

Repaint the shape canvas.

Parameters
eraseTRUE if the canvas should be erased before repainting
rctRefreshed region (rectangle)

◆ RefreshInvalidatedRect()

void wxSFShapeCanvas::RefreshInvalidatedRect ( )

Refresh all canvas rectangles marked as invalidated.

See also
wxSFShapeCanvas::InvalidateRect()

◆ RemoveFromTemporaries()

void wxSFShapeCanvas::RemoveFromTemporaries ( wxSFShapeBase shape)
private

Remove given shape for temporary containers.

◆ RemoveStyle()

void wxSFShapeCanvas::RemoveStyle ( STYLE  style)
inline

Remove given style flag.

◆ ReparentShape()

void wxSFShapeCanvas::ReparentShape ( wxSFShapeBase shape,
const wxPoint &  parentpos 
)
private

Assign give shape to parent at given location (if exists)

◆ RestorePrevPositions()

void wxSFShapeCanvas::RestorePrevPositions ( )
private

Restore previously stored shapes' positions and clear the storage.

◆ SaveCanvas()

void wxSFShapeCanvas::SaveCanvas ( const wxString &  file)

Save canvas content (diagrams) to given file.

Parameters
fileFull file name

◆ SaveCanvasState()

void wxSFShapeCanvas::SaveCanvasState ( )

Save current canvas state (for Undo/Redo operations)

◆ SaveCanvasToBMP()

void wxSFShapeCanvas::SaveCanvasToBMP ( const wxString &  file)

Export canvas content to BMP file. DEPRECATED: use SaveCanvasToImage() instead.

Parameters
fileFull file name

◆ SaveCanvasToImage()

void wxSFShapeCanvas::SaveCanvasToImage ( const wxString &  file,
wxBitmapType  type = wxBITMAP_TYPE_BMP,
bool  background = true,
double  scale = -1 
)

Export canvas content to image file.

Parameters
fileFull file name
typeImage type. See wxBitmapType for more details. Default type is wxBITMAP_TYPE_BMP.
backgroundExport also diagram background
scaleImage scale. If -1 then current canvas scale id used.

◆ ScrollToShape()

void wxSFShapeCanvas::ScrollToShape ( wxSFShapeBase shape)

Scroll the shape canvas so the given shape will be located in its center.

Parameters
shapePointer to focused shape

◆ SelectAll()

void wxSFShapeCanvas::SelectAll ( )

Select all shapes in the canvas.

◆ SetCanvasColour()

void wxSFShapeCanvas::SetCanvasColour ( const wxColour &  col)
inline

Set canvas background color.

Parameters
colBackground color

◆ SetDiagramManager()

void wxSFShapeCanvas::SetDiagramManager ( wxSFDiagramManager manager)

Set diagram manager for this shape canvas.

Parameters
managerPointer to diagram manager instance
See also
wxSFDiagramManager

◆ SetGradientFrom()

void wxSFShapeCanvas::SetGradientFrom ( const wxColour &  col)
inline

Set starting gradient color.

Parameters
colColor

◆ SetGradientTo()

void wxSFShapeCanvas::SetGradientTo ( const wxColour &  col)
inline

Set ending gradient color.

Parameters
colColor

◆ SetGrid()

void wxSFShapeCanvas::SetGrid ( wxSize  grid)
inline

Set grid size.

Parameters
gridGrid size

◆ SetGridColour()

void wxSFShapeCanvas::SetGridColour ( const wxColour &  col)
inline

Set grid color.

Parameters
colGrid color

◆ SetGridLineMult()

void wxSFShapeCanvas::SetGridLineMult ( int  multiple)
inline

Set grid line multiple.

Grid lines will be drawn in a distance calculated as grid size multiplicated by this value. Default value is 1.

Parameters
multipleMultiple value

◆ SetGridStyle()

void wxSFShapeCanvas::SetGridStyle ( int  style)
inline

Set grid line style.

Parameters
styleLine style

◆ SetHoverColour()

void wxSFShapeCanvas::SetHoverColour ( const wxColour &  col)

Set default hover color.

Parameters
colHover color.

◆ SetMaxScale()

void wxSFShapeCanvas::SetMaxScale ( double  scale)
inline

Set maximal allowed scale (for mouse wheel scale change).

Parameters
scaleMaximal scale

◆ SetMinScale()

void wxSFShapeCanvas::SetMinScale ( double  scale)
inline

Set minimal allowed scale (for mouse wheel scale change).

Parameters
scaleMinimal scale

◆ SetPrintHAlign()

void wxSFShapeCanvas::SetPrintHAlign ( HALIGN  val)
inline

Set horizontal align of printed drawing.

Parameters
valHorizontal align
See also
HALIGN

◆ SetPrintMode()

void wxSFShapeCanvas::SetPrintMode ( PRINTMODE  mode)
inline

Set printing mode for this canvas.

Parameters
modePrinting mode
See also
PRINTMODE

◆ SetPrintVAlign()

void wxSFShapeCanvas::SetPrintVAlign ( VALIGN  val)
inline

Set vertical align of printed drawing.

Parameters
valVerical align
See also
VALIGN

◆ SetScale()

void wxSFShapeCanvas::SetScale ( double  scale)

Set canvas scale.

Parameters
scaleScale value

◆ SetScaleToViewAll()

void wxSFShapeCanvas::SetScaleToViewAll ( )

Set the canvas scale so a whole diagram is visible.

◆ SetShadowFill()

void wxSFShapeCanvas::SetShadowFill ( const wxBrush &  brush)
inline

Set shadow fill (used for shadows of non-text shapes only).

Parameters
brushReference to brush object

◆ SetShadowOffset()

void wxSFShapeCanvas::SetShadowOffset ( const wxRealPoint &  offset)
inline

Set shadow offset.

Parameters
offsetShadow offset

◆ SetStyle()

void wxSFShapeCanvas::SetStyle ( long  style)
inline

Set canvas style.

Default value is sfsMULTI_SELECTION | sfsMULTI_SIZE_CHANGE | sfsDND | sfsUNDOREDO | sfsCLIPBOARD | sfsHOVERING | sfsHIGHLIGHTING
Parameters
styleCombination of the canvas styles
See also
STYLE

◆ ShowShadows()

void wxSFShapeCanvas::ShowShadows ( bool  show,
SHADOWMODE  style 
)

Show shapes shadows (only current digram shapes are affected).

The functions sets/unsets sfsSHOW_SHADOW flag for all shapes currently included in the diagram.

Parameters
showTRUE if the shadow shoud be shown, otherwise FALSE
styleShadow style
See also
SHADOWMODE

◆ StartInteractiveConnection() [1/3]

void wxSFShapeCanvas::StartInteractiveConnection ( wxClassInfo *  shapeInfo,
const wxPoint &  pos,
wxSF::ERRCODE err = NULL 
)

Start interactive connection creation.

This function switch the canvas to a mode in which a new shape connection can be created interactively (by mouse operations). Every connection must start and finish in some shape object or another connection. At the end of the process the OnConnectionFinished event handler is invoked so the user can set needed connection properties immediately.

Function must be called from mouse event handler and the event must be passed to the function.

Parameters
shapeInfoConnection type
posPosition where to start
errPointer to variable where operation result will be stored. Can be NULL.
See also
CreateConnection

◆ StartInteractiveConnection() [2/3]

void wxSFShapeCanvas::StartInteractiveConnection ( wxSFLineShape shape,
const wxPoint &  pos,
wxSF::ERRCODE err = NULL 
)

Start interactive connection creation from existing line object.

This function switch the canvas to a mode in which a new shape connection can be created interactively (by mouse operations). Every connection must start and finish in some shape object or another connection. At the end of the process the OnConnectionFinished event handler is invoked so the user can set needed connection properties immediately.

Function must be called from mouse event handler and the event must be passed to the function.

Parameters
shapePointer to existing line shape object which will be used as a connection.
posPosition where to start
errPointer to variable where operation result will be stored. Can be NULL.
See also
CreateConnection

◆ StartInteractiveConnection() [3/3]

void wxSFShapeCanvas::StartInteractiveConnection ( wxSFLineShape shape,
wxSFConnectionPoint connectionPoint,
const wxPoint &  pos,
wxSF::ERRCODE err = NULL 
)

Start interactive connection creation from existing line object.

This function switch the canvas to a mode in which a new shape connection can be created interactively (by mouse operations). Every connection must start and finish in some shape object or another connection. At the end of the process the OnConnectionFinished event handler is invoked so the user can set needed connection properties immediately.

Function must be called from mouse event handler and the event must be passed to the function.

Parameters
shapePointer to existing line shape object which will be used as a connection.
connectionPointInitial connection point
posPosition where to start
errPointer to variable where operation result will be stored. Can be NULL.
See also
CreateConnection

◆ StorePrevPosition()

void wxSFShapeCanvas::StorePrevPosition ( const wxSFShapeBase shape)
inlineprivate

Store previous shape's position modified in ValidateSelectionForClipboard() function.

◆ Undo()

void wxSFShapeCanvas::Undo ( )

Perform Undo operation (if available)

◆ UpdateMultieditSize()

void wxSFShapeCanvas::UpdateMultieditSize ( )

Update size of multi selection rectangle.

◆ UpdateShapeUnderCursorCache()

void wxSFShapeCanvas::UpdateShapeUnderCursorCache ( const wxPoint &  pos)

◆ UpdateVirtualSize()

void wxSFShapeCanvas::UpdateVirtualSize ( )

Update scroll window virtual size so it can display all shape canvas.

◆ ValidateSelection()

void wxSFShapeCanvas::ValidateSelection ( ShapeList &  selection)

Validate selection (remove redundantly selected shapes etc...).

Parameters
selectionList of selected shapes that should be validated

◆ ValidateSelectionForClipboard()

void wxSFShapeCanvas::ValidateSelectionForClipboard ( ShapeList &  selection,
bool  storeprevpos 
)
private

Validate selection so the shapes in the given list can be processed by the clipboard functions.

Friends And Related Function Documentation

◆ wxSFCanvasDropTarget

friend class wxSFCanvasDropTarget
friend

◆ wxSFDiagramManager

friend class wxSFDiagramManager
friend

Member Data Documentation

◆ m_CanvasHistory

wxSFCanvasHistory wxSFShapeCanvas::m_CanvasHistory
private

Canvas history manager.

◆ m_fCanSaveStateOnMouseUp

bool wxSFShapeCanvas::m_fCanSaveStateOnMouseUp
private

◆ m_fDnDStartedHere

bool wxSFShapeCanvas::m_fDnDStartedHere
private

Flag used for determination whether the D&D operation has started and ended in one canvas instance.

◆ m_fEnableGC

bool wxSFShapeCanvas::m_fEnableGC
staticprotected

◆ m_formatShapes

wxDataFormat wxSFShapeCanvas::m_formatShapes
private

Custom data format object (used for the clipboard and D&D operations.

◆ m_lstCurrentShapes

ShapeList wxSFShapeCanvas::m_lstCurrentShapes
private

Current list of all shapes in the canvas updated during mouse movement.

◆ m_mapPrevPositions

PositionMap wxSFShapeCanvas::m_mapPrevPositions
private

◆ m_nDnDStartedAt

wxPoint wxSFShapeCanvas::m_nDnDStartedAt
private

Started position of current D&D operation.

◆ m_nInvalidateRect

wxRect wxSFShapeCanvas::m_nInvalidateRect
private

◆ m_nPrevMousePos

wxPoint wxSFShapeCanvas::m_nPrevMousePos
private

◆ m_nRefCounter

int wxSFShapeCanvas::m_nRefCounter
staticprivate

◆ m_nSelectionMode

SELECTIONMODE wxSFShapeCanvas::m_nSelectionMode
protected

◆ m_nWorkingMode

MODE wxSFShapeCanvas::m_nWorkingMode
protected

◆ m_OutBMP

wxBitmap wxSFShapeCanvas::m_OutBMP
staticprivate

◆ m_pManager

wxSFDiagramManager* wxSFShapeCanvas::m_pManager
private

Pointer to parent data (shapes) manager.

◆ m_pNewLineShape

wxSFLineShape* wxSFShapeCanvas::m_pNewLineShape
private

Pointer to new line shape under constuction.

◆ m_pSelectedHandle

wxSFShapeHandle* wxSFShapeCanvas::m_pSelectedHandle
private

Pointer to currently selected shape handle.

◆ m_pSelectedShapeUnderCursor

wxSFShapeBase* wxSFShapeCanvas::m_pSelectedShapeUnderCursor
private

Pointer to topmost selected shape under the mouse cursor.

◆ m_pTopmostShapeUnderCursor

wxSFShapeBase* wxSFShapeCanvas::m_pTopmostShapeUnderCursor
private

Pointer to topmost shape under the mouse cursor.

◆ m_pUnselectedShapeUnderCursor

wxSFShapeBase* wxSFShapeCanvas::m_pUnselectedShapeUnderCursor
private

Pointer to topmost unselected shape under the mouse cursor.

◆ m_selectionStart

wxRealPoint wxSFShapeCanvas::m_selectionStart
private

◆ m_Settings

wxSFCanvasSettings wxSFShapeCanvas::m_Settings
protected

◆ m_shpMultiEdit

wxSFMultiSelRect wxSFShapeCanvas::m_shpMultiEdit
private

◆ m_shpSelection

wxSFMultiSelRect wxSFShapeCanvas::m_shpSelection
private

The documentation for this class was generated from the following file: