File: ShapeCanvas.h

package info (click to toggle)
codelite 17.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 136,204 kB
  • sloc: cpp: 491,547; ansic: 280,393; php: 10,259; sh: 8,930; lisp: 7,664; vhdl: 6,518; python: 6,020; lex: 4,920; yacc: 3,123; perl: 2,385; javascript: 1,715; cs: 1,193; xml: 1,110; makefile: 804; cobol: 741; sql: 709; ruby: 620; f90: 566; ada: 534; asm: 464; fortran: 350; objc: 289; tcl: 258; java: 157; erlang: 61; pascal: 51; ml: 49; awk: 44; haskell: 36
file content (1264 lines) | stat: -rw-r--r-- 48,280 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
/***************************************************************
 * Name:      ShapeCanvas.h
 * Purpose:   Defines shape canvas class
 * Author:    Michal Bližňák (michal.bliznak@tiscali.cz)
 * Created:   2007-07-22
 * Copyright: Michal Bližňák
 * License:   wxWidgets license (www.wxwidgets.org)
 * Notes:
 **************************************************************/

#ifndef _WXSFSHAPECANVAS_H
#define _WXSFSHAPECANVAS_H

#include <wx/dataobj.h>
#include <wx/dnd.h>
#include <wx/hashmap.h>

#include <wx/wxsf/ShapeBase.h>
#include <wx/wxsf/DiagramManager.h>
#include <wx/wxsf/MultiSelRect.h>
#include <wx/wxsf/CanvasHistory.h>
#include <wx/wxsf/LineShape.h>
#include <wx/wxsf/EditTextShape.h>
#include <wx/wxsf/Printout.h>
#include <wx/wxsf/CommonFcn.h>

#ifdef __WXMAC__ 
#include <wx/printdlg.h> 
#endif 

WX_DECLARE_HASH_MAP( wxUIntPtr, wxRealPoint*, wxIntegerHash, wxIntegerEqual, PositionMap );

/*! \brief XPM (mono-)bitmap which can be used in shape's shadow brush */
extern const char* wxSFShadowBrush_xpm[];

/*! \brief Global page setup data */
extern wxPageSetupDialogData* g_pageSetupData;

/*! \brief Global print data, to remember settings during the session */
extern wxPrintData *g_printData;

#define sfDEFAULT_ME_OFFSET 5
#define sfSAVE_STATE true
#define sfDONT_SAVE_STATE false
#define sfFROM_PAINT true
#define sfNOT_FROM_PAINT false
#define sfTOPMOST_SHAPES true
#define sfALL_SHAPES false
#define sfPROMPT true
#define sfNO_PROMPT false
#define sfWITH_BACKGROUND true
#define sfWITHOUT_BACKGROUND false

// default values
/*! \brief Default value of wxSFCanvasSettings::m_nBackgroundColor data member */
#define sfdvSHAPECANVAS_BACKGROUNDCOLOR wxColour(240, 240, 240)
/*! \brief Default value of wxSFCanvasSettings::m_nGridSize data member */
#define sfdvSHAPECANVAS_GRIDSIZE wxSize(10, 10)
/*! \brief Default value of wxSFCanvasSettings::m_nGridLineMult data member */
#define sfdvSHAPECANVAS_GRIDLINEMULT 1
/*! \brief Default value of wxSFCanvasSettings::m_nGridColor data member */
#define sfdvSHAPECANVAS_GRIDCOLOR wxColour(200, 200, 200)
/*! \brief Default value of wxSFCanvasSettings::m_nGridStyle data member */
#define sfdvSHAPECANVAS_GRIDSTYLE wxSOLID
/*! \brief Default value of wxSFCanvasSettings::m_CommnonHoverColor data member */
#define sfdvSHAPECANVAS_HOVERCOLOR wxColor(120, 120, 255)
/*! \brief Default value of wxSFCanvasSettings::m_nGradientFrom data member */
#define sfdvSHAPECANVAS_GRADIENT_FROM wxColour(240, 240, 240)
/*! \brief Default value of wxSFCanvasSettings::m_nGradientTo data member */
#define sfdvSHAPECANVAS_GRADIENT_TO wxColour(200, 200, 255)
/*! \brief Default value of wxSFCanvasSettings::m_nStyle data member */
#define sfdvSHAPECANVAS_STYLE wxSFShapeCanvas::sfsDEFAULT_CANVAS_STYLE
/*! \brief Default value of wxSFCanvasSettings::m_nShadowOffset data member */
#define sfdvSHAPECANVAS_SHADOWOFFSET wxRealPoint(4, 4)
/*! \brief Default shadow colour */
#define sfdvSHAPECANVAS_SHADOWCOLOR wxColour(150, 150, 150, 128)
/*! \brief Default value of wxSFCanvasSettings::m_ShadowFill data member */
#define sfdvSHAPECANVAS_SHADOWBRUSH wxBrush(sfdvSHAPECANVAS_SHADOWCOLOR, wxBRUSHSTYLE_SOLID)
/*! \brief Default value of wxSFCanvasSettings::m_nPrintHAlign data member */
#define sfdvSHAPECANVAS_PRINT_HALIGN wxSFShapeCanvas::halignCENTER
/*! \brief Default value of wxSFCanvasSettings::m_nPrintVAlign data member */
#define sfdvSHAPECANVAS_PRINT_VALIGN wxSFShapeCanvas::valignMIDDLE
/*! \brief Default value of wxSFCanvasSettings::m_nPrintMode data member */
#define sfdvSHAPECANVAS_PRINT_MODE wxSFShapeCanvas::prnFIT_TO_MARGINS
/*! \brief Default value of wxSFCanvasSettings::m_nMinScale data member */
#define sfdvSHAPECANVAS_SCALE_MIN 0.1
/*! \brief Default value of wxSFCanvasSettings::m_nMaxScale data member */
#define sfdvSHAPECANVAS_SCALE_MAX 5


class wxSFCanvasDropTarget;

/*!
 * \brief Auxiliary class encapsulating shape drop target.
 */
class wxSFCanvasDropTarget : public wxDropTarget
{
	friend class wxSFShapeCanvas;

protected:
	wxSFCanvasDropTarget(wxDataObject *data, wxSFShapeCanvas *parent);
	virtual ~wxSFCanvasDropTarget();

	virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);

	wxSFShapeCanvas *m_pParentCanvas;
};

/*!
 * \brief Auxiliary serializable class encapsulating the canvas properties.
 */
class wxSFCanvasSettings : public xsSerializable
{
public:
    DECLARE_DYNAMIC_CLASS(wxSFCanvasSettings);

    wxSFCanvasSettings();

    wxColour m_nBackgroundColor;
    wxColour m_nCommonHoverColor;

	wxColour m_nGradientFrom;
	wxColour m_nGradientTo;

    wxSize m_nGridSize;
	int m_nGridLineMult;
    wxColour m_nGridColor;
	int m_nGridStyle;

    wxRealPoint m_nShadowOffset;
    wxBrush m_ShadowFill;

    wxArrayString m_arrAcceptedShapes;

    double m_nScale;
	double m_nMinScale;
	double m_nMaxScale;

	long m_nStyle;

	int m_nPrintHAlign;
	int m_nPrintVAlign;
	int m_nPrintMode;
};

/*!
 * \brief 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.
 * \sa wxSFDiagramManager
 */
class WXDLLIMPEXP_SF wxSFShapeCanvas : public wxScrolledWindow
{
public:

    friend class wxSFDiagramManager;
	friend class wxSFCanvasDropTarget;

    /*!
     * \brief Default constructor
     */
    wxSFShapeCanvas();
    /*!
     * \brief Constructor
     * \param manager Pointer to shape manager
     * \param parent Parent window
     * \param id Window ID
     * \param pos Initial position
     * \param size Initial size
     * \param style Window style
     */
	wxSFShapeCanvas(wxSFDiagramManager* manager, wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxHSCROLL | wxVSCROLL);
	/*! \brief Destructor */
	~wxSFShapeCanvas(void);

    /*!
     * \brief Creates the window in two-step construction mode. SetDiagramManager() function must be also called to complete the canvas initialization.
     * \param parent Parent window
     * \param id Window ID
     * \param pos Initial position
     * \param size Initial size
     * \param style Window style
     * \param name Window name
     */
    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"));

    /*! \brief Working modes */
	enum MODE
	{
	    /*! \brief The shape canvas is in ready state (no operation is pending) */
		modeREADY = 0,
        /*! \brief Some shape handle is dragged */
		modeHANDLEMOVE,
		/*! \brief Handle of multiselection tool is dragged */
		modeMULTIHANDLEMOVE,
		/*! \brief Some shape/s is/are dragged */
		modeSHAPEMOVE,
		/*! \brief Multiple shape selection is in progess */
		modeMULTISELECTION,
		/*! \brief Interactive connection creation is in progress */
		modeCREATECONNECTION,
		/*! \brief Canvas is in the Drag&Drop mode */
		modeDND
	};

	/*! \brief Selection modes */
	enum SELECTIONMODE
	{
		selectNORMAL,
		selectADD,
		selectREMOVE,
	};

    /*! \brief Search mode flags for GetShapeAtPosition function */
	enum SEARCHMODE
	{
	    /*! \brief Search for selected shapes only*/
		searchSELECTED,
		/*! \brief Search for unselected shapes only */
		searchUNSELECTED,
		/*! \brief Search for both selected and unselected shapes */
		searchBOTH
	};

    /*! \brief Flags for AlignSelected function */
	enum VALIGN
	{
	    valignNONE,
	    valignTOP,
	    valignMIDDLE,
	    valignBOTTOM
	};

    /*! \brief Flags for AlignSelected function */
	enum HALIGN
	{
	    halignNONE,
	    halignLEFT,
	    halignCENTER,
	    halignRIGHT
	};

	/*! \brief Style flags */
	enum STYLE
	{
		/*! \brief Allow multiselection box. */
		sfsMULTI_SELECTION = 1,
		/*! \brief Allow shapes' size change done via the multiselection box. */
		sfsMULTI_SIZE_CHANGE = 2,
		/*! \brief Show grid. */
		sfsGRID_SHOW = 4,
		/*! \brief Use grid. */
		sfsGRID_USE = 8,
		/*! \brief Enable Drag & Drop operations. */
		sfsDND = 16,
		/*! \brief Enable Undo/Redo operations. */
		sfsUNDOREDO = 32,
		/*! \brief Enable the clipboard. */
		sfsCLIPBOARD = 64,
		/*! \brief Enable mouse hovering */
		sfsHOVERING = 128,
		/*! \brief Enable highligting of shapes able to accept dragged shape(s). */
		sfsHIGHLIGHTING = 256,
		/*! \brief Use gradient color for the canvas background. */
		sfsGRADIENT_BACKGROUND = 512,
		/*! \brief Print also canvas background. */
		sfsPRINT_BACKGROUND = 1024,
		/*! \brief Process mouse wheel by the canvas (canvas scale will be changed). */
		sfsPROCESS_MOUSEWHEEL = 2048,
		/*! \brief Default canvas style. */
		sfsDEFAULT_CANVAS_STYLE = sfsMULTI_SELECTION | sfsMULTI_SIZE_CHANGE | sfsDND | sfsUNDOREDO | sfsCLIPBOARD | sfsHOVERING | sfsHIGHLIGHTING
	};

    /*! \brief Flags for ShowShadow function. */
	enum SHADOWMODE
	{
	    /*! \brief Show/hide shadow under topmost shapes only. */
	    shadowTOPMOST,
	    /*! \brief Show/hide shadow under all shapes in the diagram. */
	    shadowALL
	};

	/*! \brief Printing modes used by SetPrintMode() function. */
	enum PRINTMODE
	{
	    /*! \brief 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_PAPER,
        /*! \brief 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_PAGE,
        /*! \brief 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. */
	    prnFIT_TO_MARGINS,
	    /*! \brief 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_PAPER,
	    /*! \brief 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_PAGE,
	    /*! \brief 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_MARGINS,
	     /*! \brief 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. */
	    prnMAP_TO_DEVICE
	};

	enum PRECONNECTIONFINISHEDSTATE
	{
		/*! \brief Finish line connection. */
		pfsOK,
		/*! \brief Cancel line connection and abort the interactive connection. */
		pfsFAILED_AND_CANCEL_LINE,
		/*! \brief Cancel line connection and continue with the interactive connection. */
		pfsFAILED_AND_CONTINUE_EDIT,
	};

	// public functions

    /*!
     * \brief Get diagram manager associated with this instance of shape canvas
     * \return Pointer to diagram manager
     * \sa wxSFDiagramManager
     */
    inline wxSFDiagramManager* GetDiagramManager() { return m_pManager; }
    /*!
     * \brief Set diagram manager for this shape canvas
     * \param manager Pointer to diagram manager instance
     * \sa wxSFDiagramManager
     */
    void SetDiagramManager(wxSFDiagramManager* manager);

    /*!
     * \brief Load serialized canvas content (diagrams) from given file.
     * \param file Full file name
     */
	void LoadCanvas(const wxString& file);
    /*!
     * \brief Save  canvas content (diagrams) to given file.
     * \param file Full file name
     */
	void SaveCanvas(const wxString& file);
    /*!
     * \brief Export canvas content to BMP file.
	 * DEPRECATED: use SaveCanvasToImage() instead.
     * \param file Full file name
     */
	void SaveCanvasToBMP(const wxString& file);
	/*!
	 * \brief Export canvas content to image file.
	 * \param file Full file name
	 * \param type Image type. See wxBitmapType for more details. Default type is
	 * wxBITMAP_TYPE_BMP.
	 * \param background Export also diagram background
	 * \param scale Image scale. If -1 then current canvas scale id used.
	 */
	void SaveCanvasToImage(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_BMP, bool background = true, double scale = -1);

    /*!
     * \brief 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.
     * \param shapeInfo Connection type
     * \param pos Position where to start
	 * \param err Pointer to variable where operation result will be stored. Can be NULL.
     * \sa CreateConnection
     */
    void StartInteractiveConnection(wxClassInfo* shapeInfo, const wxPoint& pos, wxSF::ERRCODE *err = NULL);
	 /*!
     * \brief 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.
     * \param shape Pointer to existing line shape object which will be used as a connection.
     * \param pos Position where to start
	 * \param err Pointer to variable where operation result will be stored. Can be NULL.
     * \sa CreateConnection
     */
	void StartInteractiveConnection(wxSFLineShape* shape, const wxPoint& pos, wxSF::ERRCODE *err = NULL);
	 /*!
     * \brief 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.
     * \param shape Pointer to existing line shape object which will be used as a connection.
	 * \param connectionPoint Initial connection point
     * \param pos Position where to start
	 * \param err Pointer to variable where operation result will be stored. Can be NULL.
     * \sa CreateConnection
     */
	void StartInteractiveConnection(wxSFLineShape* shape, wxSFConnectionPoint* connectionPoint, const wxPoint& pos, wxSF::ERRCODE *err = NULL);
	
    /*! \brief Abort interactive connection creation process */
	void AbortInteractiveConnection();

    /*! \brief Select all shapes in the canvas */
	void SelectAll();
	/*! \brief Deselect all shapes */
	void DeselectAll();
	/*! \brief Hide handles of all shapes */
	void HideAllHandles();
	/*!
	 * \brief Repaint the shape canvas.
	 * \param erase TRUE if the canvas should be erased before repainting
	 * \param rct Refreshed region (rectangle)
	 */
	void RefreshCanvas(bool erase, const wxRect& rct);
	
	/*!
	 * \brief Mark given rectangle as an invalidated one, i.e. as a rectangle which should
	 * be refreshed (by using wxSFShapeCanvas::RefreshInvalidatedRect()).
	 * \param rct Rectangle to be invalidated
	 */
	void InvalidateRect(const wxRect& rct);
	
	/*!
	 * \brief Mark whole visible canvas portion as an invalidated rectangle.
	 */
	void InvalidateVisibleRect();
	/*!
	 * \brief Refresh all canvas rectangles marked as invalidated.
	 * \sa wxSFShapeCanvas::InvalidateRect()
	 */
	void RefreshInvalidatedRect();
	
	/*!
	 * \brief Show shapes shadows (only current digram shapes are affected).
	 *
	 * The functions sets/unsets sfsSHOW_SHADOW flag for all shapes currently included in the diagram.
	 * \param show TRUE if the shadow shoud be shown, otherwise FALSE
	 * \param style Shadow style
	 * \sa SHADOWMODE
	 */
	void ShowShadows(bool show, SHADOWMODE style);

	/*!
	 * \brief Start Drag&Drop operation with shapes included in the given list.
	 * \param shapes List of shapes which should be dragged
	 * \param start A point where the dragging operation has started
	 * \return rct Drag result
	 */
	wxDragResult DoDragDrop(ShapeList &shapes, const wxPoint& start = wxPoint(-1, -1));
    /*! \brief Copy selected shapes to the clipboard */
	void Copy();
	/*! \brief Copy selected shapes to the clipboard and remove them from the canvas */
	void Cut();
	/*! \brief Paste shapes stored in the clipboard to the canvas */
	void Paste();
	/*! \brief Perform Undo operation (if available) */
	void Undo();
	/*! \brief Perform Redo operation (if available) */
	void Redo();
	/*! \brief Function returns TRUE if some shapes can be copied to the clipboard (it means they are selected) */
	bool CanCopy();
	/*! \brief Function returns TRUE if some shapes can be cutted to the clipboard (it means they are selected) */
	bool CanCut();
	/*! \brief Function returns TRUE if some shapes can be copied from the clipboard to the canvas
	 * (it means the clipboard contains stored shapes) */
	bool CanPaste();
	/*! \brief Function returns TRUE if Undo operation can be done */
	bool CanUndo();
	/*! \brief Function returns TRUE if Redo operation can be done */
	bool CanRedo();
	/*! \brief Function returns TRUE if AlignSelected function can be invoked (if more than
	 * one shape is selected) */
	bool CanAlignSelected();

    /*! \brief Save current canvas state (for Undo/Redo operations) */
	void SaveCanvasState();
	/*! \brief Clear all stored canvas states (no Undo/Redo operations will be available) */
	void ClearCanvasHistory();

	/*!
	 * \brief Print current canvas content.
	 * \param prompt If TRUE (sfPROMT) then the the native print dialog will be displayed before printing
	 */
	void Print(bool prompt = sfPROMPT);
	/*!
	 * \brief Print current canvas content using user-defined printout class.
	 * \param printout Pointer to user-defined printout object (inherited from wxSFPrintout class). Do not delete this object explicitly.
	 * \param prompt If TRUE (sfPROMT) then the native print dialog will be displayed before printing
	 * \sa wxSFPrintout
	 */
	void Print(wxSFPrintout *printout, bool prompt = sfPROMPT);
	/*! \brief Show print preview. */
	void PrintPreview();
	/*!
	 * \brief Show print preview using user-defined printout classes.
     * \param preview Pointer to user-defined printout object (inherited from wxSFPrintout class) used for print preview.
     * Do not delete this object explicitly.
     * \param printout Pointer 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).
     * \sa wxSFPrintout
	 */
	void PrintPreview(wxSFPrintout *preview, wxSFPrintout *printout = NULL);
	/*! \brief Show page setup dialog for printing. */
	void PageSetup();
	// #ifdef __WXMAC__
	// /*! \brief 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
     */
	wxPoint DP2LP(const wxPoint& pos) const;
	wxRect DP2LP(const wxRect& rct) const;
    /*!
     * \brief Convert logical position to device position.
     *
     * The function returns scrolled scaled canvas position.
     * \param pos Logical position (for example shape position)
     * \return Device position
     */
	wxPoint LP2DP(const wxPoint& pos) const;
	wxRect LP2DP(const wxRect& rct) const;

	/*!
	*/
	void UpdateShapeUnderCursorCache(const wxPoint& pos);

	/*!
	 * \brief Get shape under current mouse cursor position (fast implementation - use everywhere
	 * it is possible instead of much slower GetShapeAtPosition()).
	 * \param mode Search mode
	 * \return Pointer to shape if found, otherwise NULL
	 * \sa SEARCHMODE, wxSFShapeCanvas::DP2LP, wxSFShapeCanvas::GetShapeAtPosition
	 */
	wxSFShapeBase* GetShapeUnderCursor(SEARCHMODE mode = searchBOTH);
	/*!
	 * \brief Get shape at given logical position
	 * \param pos Logical position
	 * \param zorder Z-order of searched shape (usefull if several shapes are located
	 * at the given position)
	 * \param mode Search mode
	 * \return Pointer to shape if found, otherwise NULL
	 * \sa SEARCHMODE, wxSFShapeCanvas::DP2LP,, wxSFShapeCanvas::GetShapeUnderCursor
	 */
	wxSFShapeBase* GetShapeAtPosition(const wxPoint& pos, int zorder = 1, SEARCHMODE mode = searchBOTH);
    /*!
     * \brief Get topmost handle at given position
     * \param pos Logical position
     * \return Pointer to shape handle object if found, otherwise NULL
     * \sa wxSFShapeCanvas::DP2LP
     */
	wxSFShapeHandle* GetTopmostHandleAtPosition(const wxPoint& pos);
	/*!
	 * \brief Get list of all shapes located at given position
	 * \param pos Logical position
	 * \param shapes Reference to shape list where pointers to all found shapes will be stored
	 * \sa wxSFShapeCanvas::DP2LP
	 */
	void GetShapesAtPosition(const wxPoint& pos, ShapeList& shapes);
	/*!
	 * \brief Get list of shapes located inside given rectangle
	 * \param rct Examined rectangle
	 * \param shapes Reference to shape list where pointers to all found shapes will be stored
	 */
	void GetShapesInside(const wxRect& rct, ShapeList& shapes);
	/*!
	 * \brief Get list of selected shapes.
	 * \param selection Reference to shape list where pointers to all selected shapes will be stored
	 */
	void GetSelectedShapes(ShapeList& selection);
    /*!
	 * \brief Get box bounding all shapes in the canvas.
	 * \return Total bounding box
	 */
	wxRect GetTotalBoundingBox() const;
    /*!
     * \brief Get bounding box of all selected shapes.
     * \return Selection bounding box
     */
	wxRect GetSelectionBB();

	/*!
	 * \brief Align selected shapes in given directions.
	 *
	 * Shapes will be aligned according to most far shape in appropriate direction.
	 * \param halign Horizontal alignment
	 * \param valign Vertical alignment
	 */
	void AlignSelected(HALIGN halign, VALIGN valign);

    /*!
     * \brief Set canvas style.
	 *
	 * Default value is sfsMULTI_SELECTION | sfsMULTI_SIZE_CHANGE | sfsDND | sfsUNDOREDO | sfsCLIPBOARD | sfsHOVERING | sfsHIGHLIGHTING
     * \param style Combination of the canvas styles
     * \sa STYLE
     */
    inline void SetStyle(long style) { m_Settings.m_nStyle = style; }
    /*! \brief Get current canvas style. */
    inline long GetStyle() const { return m_Settings.m_nStyle; }
	/*! \brief Add new style flag. */
    inline void AddStyle(STYLE style) { m_Settings.m_nStyle |= style; }
	/*! \brief Remove given style flag. */
    inline void RemoveStyle(STYLE style) { m_Settings.m_nStyle &= ~style; }
	/*! \brief Check whether given style flag is used. */
    inline bool ContainsStyle(STYLE style) const { return (m_Settings.m_nStyle & style) != 0; }

	// public members accessors
	/*!
	 * \brief Set canvas background color.
	 * \param col Background color
	 */
	inline void SetCanvasColour(const wxColour& col) { m_Settings.m_nBackgroundColor = col; }
	/*!
	 * \brief Get canvas background color.
	 * \return Background color
	 */
	inline wxColour GetCanvasColour() const { return m_Settings.m_nBackgroundColor; }
	/*!
	 * \brief Set starting gradient color.
	 * \param col Color
	 */
	inline void SetGradientFrom(const wxColour& col) { m_Settings.m_nGradientFrom = col; }
	/*!
	 * \brief Get starting gradient color.
	 * \return Color
	 */
	inline wxColour GetGradientFrom() const { return m_Settings.m_nGradientFrom; }
	/*!
	 * \brief Set ending gradient color.
	 * \param col Color
	 */
	inline void SetGradientTo(const wxColour& col) { m_Settings.m_nGradientTo = col; }
	/*!
	 * \brief Get ending gradient color.
	 * \return Color
	 */
	inline wxColour GetGradientTo() const { return m_Settings.m_nGradientTo; }
	/*!
	 * \brief Get grid size.
	 * \return Grid size
	 */
	inline wxSize GetGrid() const { return m_Settings.m_nGridSize; }
	/*!
	 * \brief Set grid size.
	 * \param grid Grid size
	 */
	inline void SetGrid(wxSize grid) { m_Settings.m_nGridSize = grid; }
	/*!
	 * \brief Set grid line multiple.
	 * 
	 * Grid lines will be drawn in a distance calculated as grid size multiplicated by this value.
	 * Default value is 1.
	 * \param multiple Multiple value
	 */
	inline void SetGridLineMult(int multiple) { m_Settings.m_nGridLineMult = multiple; }
	/**
	 * \brief Get grid line multiple.
	 * \return Value by which a grid size will be multiplicated to determine grid lines distance
	 */
	inline int GetGrigLineMult() const { return m_Settings.m_nGridLineMult; }
	/*!
	 * \brief Set grid color.
	 * \param col Grid color
	 */
	inline void SetGridColour(const wxColour& col) { m_Settings.m_nGridColor = col; }
	/*!
	 * \brief Get grid color.
	 * \return Grid color
	 */
	inline wxColour GetGridColour() const { return m_Settings.m_nGridColor; }
	/*!
	 * \brief Set grid line style.
	 * \param style Line style
	 */
	inline void SetGridStyle(int style) { m_Settings.m_nGridStyle = style; }
	/*!
	 * \brief Get grid line style.
	 * \return Line style
	 */
	inline int GetGridStyle() const {return m_Settings.m_nGridStyle; }
	/*!
	 * \brief Set shadow offset.
	 * \param offset Shadow offset
	 */
	inline void SetShadowOffset(const wxRealPoint& offset) { m_Settings.m_nShadowOffset = offset; }
	/*!
	 * \brief Get shadow offset.
	 * \return Shadow offset
	 */
	inline wxRealPoint GetShadowOffset() const { return m_Settings.m_nShadowOffset; }
	/*!
	 * \brief Set shadow fill (used for shadows of non-text shapes only).
	 * \param brush Reference to brush object
	 */
	inline void SetShadowFill(const wxBrush& brush) { m_Settings.m_ShadowFill = brush; }
	/*!
	 * \brief Get shadow fill.
	 * \return Current shadow brush
	 */
	inline wxBrush GetShadowFill() const { return m_Settings.m_ShadowFill; }
	/*!
	 * \brief Set horizontal align of printed drawing.
	 * \param val Horizontal align
	 * \sa HALIGN
	 */
	inline void SetPrintHAlign(HALIGN val) { m_Settings.m_nPrintHAlign = (int)val; }
	/*!
	 * \brief Get horizontal align of printed drawing.
	 * \return Current horizontal align
	 * \sa HALIGN
	 */
	inline HALIGN GetPrintHAlign() const { return (HALIGN)m_Settings.m_nPrintHAlign; }
	/*!
	 * \brief Set vertical align of printed drawing.
	 * \param val Verical align
	 * \sa VALIGN
	 */
	inline void SetPrintVAlign(VALIGN val) { m_Settings.m_nPrintVAlign = (int)val; }
	/*!
	 * \brief Get vertical align of printed drawing.
	 * \return Current vertical align
	 * \sa VALIGN
	 */
	inline VALIGN GetPrintVAlign() const { return (VALIGN)m_Settings.m_nPrintVAlign; }
	/*!
	 * \brief Set printing mode for this canvas.
	 * \param mode Printing mode
	 * \sa PRINTMODE
	 */
	inline void SetPrintMode(PRINTMODE mode) { m_Settings.m_nPrintMode = (int)mode; }
	/*!
	 * \brief Get printing mode for this canvas.
	 * \return Current printing mode
	 * \sa PRINTMODE
	 */
	inline PRINTMODE GetPrintMode() const { return (PRINTMODE)m_Settings.m_nPrintMode; }
	/*!
	 * \brief Set canvas scale.
	 * \param scale Scale value
	 */
	void SetScale(double scale);
	/*!
	 * \brief Set minimal allowed scale (for mouse wheel scale change).
	 * \param scale Minimal scale
	 */
	void SetMinScale(double scale) { m_Settings.m_nMinScale = scale; }
	/*!
	 * \brief Get minimal allowed scale (for mouse wheel scale change).
	 * \return Minimal scale
	 */
	double GetMinScale() { return m_Settings.m_nMinScale; }
	/*!
	 * \brief Set maximal allowed scale (for mouse wheel scale change).
	 * \param scale Maximal scale
	 */
	void SetMaxScale(double scale) { m_Settings.m_nMaxScale = scale; }
	/*!
	 * \brief Set maximal allowed scale (for mouse wheel scale change).
	 * \return Maximal scale
	 */
	double GetMaxScale() { return m_Settings.m_nMaxScale; }
	/*!
	 * \brief Get the canvas scale.
	 * \return Canvas scale
	 */
	inline double GetScale() const { return m_Settings.m_nScale; }
	/*!
	 * \brief Set the canvas scale so a whole diagram is visible.
	 */
	void SetScaleToViewAll();
	/**
	 * \brief Scroll the shape canvas so the given shape will be located in its center.
	 * \param shape Pointer to focused shape
	 */
	void ScrollToShape(wxSFShapeBase* shape);
	/*!
	 * \brief Enable usage of wxGraphicsContext for drawing (if supported).
	 * \param enab If TRUE then the wxGraphicsContext will be used
	 */
    static void EnableGC(bool enab);
	/*!
	 * \brief Function returns information whether the wxGraphicsContext is enabled (if supported).
	 * \return TRUE if the wxGraphicsContext is enabled
	 */
    static bool IsGCEnabled() { return m_fEnableGC; }

	/*!
	 * \brief Get canvas workind mode.
	 * \return Working mode
	 * \sa MODE
	 */
	inline MODE GetMode() const { return m_nWorkingMode; }
	/*!
	 * \brief Set default hover color.
	 * \param col Hover color.
	 */
	void SetHoverColour(const wxColour& col);
	/*!
	 * \brief Get default hover color.
	 * \return Hover color
	 */
	inline wxColour GetHoverColour() const { return m_Settings.m_nCommonHoverColor; }
	/*!
	 * \brief Get canvas hostory manager.
	 * \return Reference to the canvas history manager
	 * \sa wxSFCanvasHistory
	 */
	inline wxSFCanvasHistory& GetHistoryManager() { return m_CanvasHistory; }

	/*!
	 * \brief Update given position so it will fit canvas grid (if enabled).
	 * \param pos Position which should be updated
	 * \return Updated position
	 */
	wxPoint FitPositionToGrid(const wxPoint& pos);
	/*! \brief Update size of multi selection rectangle */
	void UpdateMultieditSize();
	/*! \brief Update scroll window virtual size so it can display all shape canvas */
	void UpdateVirtualSize();
	/*! \brief Move all shapes so none of it will be located in negative position */
	void MoveShapesFromNegatives();
	/*! \brief Center diagram in accordance to the shape canvas extent. */
	void CenterShapes();
    /*!
     * \brief Validate selection (remove redundantly selected shapes etc...).
     * \param selection List of selected shapes that should be validated
     */
	void ValidateSelection(ShapeList& selection);

	/*!
	 * \brief Function responsible for drawing of the canvas's content to given DC. The default
	 * implementation draws actual objects managed by assigned diagram manager.
	 * \param dc Reference to device context where the shapes will be drawn to
	 * \param fromPaint Set 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)
	 */
	virtual void DrawContent(wxDC& dc, bool fromPaint);
	/*!
	 * \brief Function responsible for drawing of the canvas's background to given DC. The default
	 * implementation draws canvas background and grid.
	 * \param dc Reference to device context where the shapes will be drawn to
	 * \param fromPaint Set 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)
	 */
	virtual void DrawBackground(wxDC& dc, bool fromPaint);
	/*!
	 * \brief Function responsible for drawing of the canvas's foreground to given DC. The default
	 * do nothing.
	 * \param dc Reference to device context where the shapes will be drawn to
	 * \param fromPaint Set 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)
	 */
	virtual void DrawForeground(wxDC& dc, bool fromPaint);

    /*!
     * \brief Get reference to multiselection box
     * \return Reference to multiselection box object
     */
    inline wxSFMultiSelRect& GetMultiselectionBox() { return m_shpMultiEdit; }

	/*! \brief Close and delete all opened text editing controls actualy used by editable text shapes */
	void DeleteAllTextCtrls();

	// public virtual event handlers
    /*!
     * \brief 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.
     * \param event Mouse event
     * \sa _OnLeftDown()
     */
	virtual void OnLeftDown(wxMouseEvent& event);
    /*!
     * \brief 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.
     * \param event Mouse event
     * \sa _OnLeftDoubleClick()
     */
	virtual void OnLeftDoubleClick(wxMouseEvent& event);
    /*!
     * \brief 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.
     * \param event Mouse event
     * \sa _OnLeftUp()
     */
	virtual void OnLeftUp(wxMouseEvent& event);
    /*!
     * \brief 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.
     * \param event Mouse event
     * \sa _OnRightDown()
     */
	virtual void OnRightDown(wxMouseEvent& event);
    /*!
     * \brief 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.
     * \param event Mouse event
     * \sa _OnRightDoubleClick()
     */
	virtual void OnRightDoubleClick(wxMouseEvent& event);
    /*!
     * \brief 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.
     * \param event Mouse event
     * \sa _OnRightUp()
     */
	virtual void OnRightUp(wxMouseEvent& event);
    /*!
     * \brief 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.
     * \param event Mouse event
     * \sa _OnMouseMove()
     */
	virtual void OnMouseMove(wxMouseEvent& event);
	/*!
     * \brief 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.
     * \param event Mouse event
     * \sa _OnMouseWheel()
     */
	virtual void OnMouseWheel(wxMouseEvent& event);
    /*!
     * \brief 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.
     * \param event Keyboard event
     * \sa _OnKeyDown()
     */
	virtual void OnKeyDown(wxKeyEvent& event);

    /*!
     * \brief 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.
     * \param shape Changed wxSFEditTextShape object
	 * \sa wxSFEditTextShape::EditLabel(), wxSFShapeTextEvent
     */
	virtual void OnTextChange(wxSFEditTextShape* shape);
	/*!
	 * \brief Event handler called after successfull conection creation. The function
	 * can be overrided if necessary. The default implementation
     * generates wxEVT_SF_LINE_DONE event.
	 * \param connection Pointer to new connection object
	 * \sa StartInteractiveConnection(), wxSFShapeEvent
	 */
	virtual void OnConnectionFinished(wxSFLineShape* connection);
	
	/*!
	 * \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.
	 * \param connection Pointer to new connection object
	 * \sa StartInteractiveConnection(), wxSFShapeEvent
	 * \return false if the generated event has been vetoed in this case,
	 * the connection creation is cancelled
	 */
	virtual PRECONNECTIONFINISHEDSTATE OnPreConnectionFinished(wxSFLineShape* connection);

	/*!
	 * \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.
	 * \param x X-coordinate of a position the data was dropped to
	 * \param y Y-coordinate of a position the data was dropped to
	 * \param def Drag result
	 * \param dropped Reference to a list containing the dropped data
	 * \sa wxSFCanvasDropTarget, wxSFShapeDropEvent
	 */
	virtual void OnDrop(wxCoord x, wxCoord y, wxDragResult def, const ShapeList& dropped);

	/*!
	 * \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.
	 * \param pasted Reference to a list containing the pasted data
	 * \sa wxSFShapeCanvas::Paste(), wxSFShapePasteEvent
	 */
	virtual void OnPaste(const ShapeList& pasted);
	
	/*!
	 * \brief 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.
	 * \param virtrct Calculated canvas virtual size
	 */
	virtual void OnUpdateVirtualSize(wxRect &virtrct);


protected:

	// protected data members
	MODE m_nWorkingMode;
    SELECTIONMODE m_nSelectionMode;
	wxSFCanvasSettings m_Settings;
	static bool m_fEnableGC;

	// protected functions

private:

	// private data members

	wxRealPoint m_selectionStart;
    wxSFMultiSelRect m_shpSelection;
	wxSFMultiSelRect m_shpMultiEdit;
	static wxBitmap m_OutBMP;

	bool m_fCanSaveStateOnMouseUp;
	static int m_nRefCounter;

	/*! \brief Flag used for determination whether the D&D operation has started and ended in one canvas instance */
	bool m_fDnDStartedHere;
	/*! \brief Started position of current D&D operation */
	wxPoint m_nDnDStartedAt;
	/*! \brief Custom data format object (used for the clipboard and D&D operations */
	wxDataFormat m_formatShapes;

	wxPoint m_nPrevMousePos;
	PositionMap m_mapPrevPositions;
	
	wxRect m_nInvalidateRect;

	/*! \brief Canvas history manager */
	wxSFCanvasHistory m_CanvasHistory;

	/*! \brief Pointer to parent data (shapes) manager */
    wxSFDiagramManager* m_pManager;

	/*! \brief Pointer to currently selected shape handle */
	wxSFShapeHandle* m_pSelectedHandle;
	/*! \brief Pointer to new line shape under constuction */
	wxSFLineShape* m_pNewLineShape;
	/*! \brief Pointer to topmost unselected shape under the mouse cursor */
	wxSFShapeBase *m_pUnselectedShapeUnderCursor;
	/*! \brief Pointer to topmost selected shape under the mouse cursor */
	wxSFShapeBase *m_pSelectedShapeUnderCursor;
	/*! \brief Pointer to topmost shape under the mouse cursor */
	wxSFShapeBase *m_pTopmostShapeUnderCursor;

	/*! \brief Current list of all shapes in the canvas updated during mouse movement */
	ShapeList m_lstCurrentShapes;

	// private functions

	/*! \brief Validate selection so the shapes in the given list can be processed by the clipboard functions */
	void ValidateSelectionForClipboard(ShapeList& selection, bool storeprevpos);
	/*! \brief Append connections assigned to shapes in given list to this list as well */
	void AppendAssignedConnections(wxSFShapeBase *shape, ShapeList& selection, bool childrenonly);
	/*! \brief Initialize printing framework */
	void InitializePrinting();
	/*! \brief Deinitialize prnting framework */
	void DeinitializePrinting();
	/*! \brief Remove given shape for temporary containers */
	void RemoveFromTemporaries(wxSFShapeBase *shape);
	/*! \brief Clear all temporary containers */
	void ClearTemporaries();
	/*! \brief Assign give shape to parent at given location (if exists) */
	void ReparentShape(wxSFShapeBase *shape, const wxPoint& parentpos);
	
	/*! \brief Store previous shape's position modified in ValidateSelectionForClipboard() function */
	inline void StorePrevPosition(const wxSFShapeBase *shape);
	/*! \brief Restore previously stored shapes' positions and clear the storage */
	void RestorePrevPositions();

	// private event handlers
	/*!
	 * \brief Event handler called when the canvas should be repainted.
	 * \param event Paint event
	 */
	void _OnPaint(wxPaintEvent& event);
	/*!
	 * \brief Event handler called when the canvas should be erased.
	 * \param event Erase event
	 */
	void _OnEraseBackground(wxEraseEvent& event);
	/*!
	 * \brief Event handler called when the mouse pointer leaves the canvas window.
	 * \param event Mouse event
	 */
	void _OnLeaveWindow(wxMouseEvent& event);
	/*!
	 * \brief Event handler called when the mouse pointer enters the canvas window.
	 * \param event Mouse event
	 */
	void _OnEnterWindow(wxMouseEvent& event);
	/*!
	 * \brief Event handler called when the canvas size has changed.
	 * \param event Size event
	 */
	void _OnResize(wxSizeEvent& event);
	
	// original private event handlers
	/*!
	 * \brief 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.
	 * \param event Mouse event
	 * \sa wxSFShapeCanvas::OnLeftDown
	 */
	void _OnLeftDown(wxMouseEvent& event);
	/*!
	 * \brief 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.
	 * \param event Mouse event
	 * \sa wxSFShapeCanvas::OnLeftDoubleClick
	 */
	void _OnLeftDoubleClick(wxMouseEvent& event);
	/*!
	 * \brief 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.
	 * \param event Mouse event
	 * \sa wxSFShapeCanvas::OnLeftUp
	 */
	void _OnLeftUp(wxMouseEvent& event);
	/*!
	 * \brief 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.
	 * \param event Mouse event
	 * \sa wxSFShapeCanvas::OnRightDown
	 */
	void _OnRightDown(wxMouseEvent& event);
	/*!
	 * \brief 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.
	 * \param event Mouse event
	 * \sa wxSFShapeCanvas::OnRightDoubleClick
	 */
	void _OnRightDoubleClick(wxMouseEvent& event);
	/*!
	 * \brief 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.
	 * \param event Mouse event
	 * \sa wxSFShapeCanvas::OnRightUp
	 */
	void _OnRightUp(wxMouseEvent& event);
	/*!
	 * \brief 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.
	 * \param event Mouse event
	 * \sa wxSFShapeCanvas::OnMouseMove
	 */
	void _OnMouseMove(wxMouseEvent& event);
	/*!
	 * \brief 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.
	 * \param event Mouse event
	 * \sa wxSFShapeCanvas::OnMouseWheel
	 */
	void _OnMouseWheel(wxMouseEvent& event);
	/*!
	 * \brief 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.
	 * \param event Keyboard event
	 * \sa wxSFShapeCanvas::OnKeyDown
	 */
	void _OnKeyDown(wxKeyEvent& event);

	/*!
	 * \brief Function is called by associated wxSFCanvasDropTarget after any dragged shapes
	 * are dropped to the canvas.
	 * \param x X-coordinate of a position the data was dropped to
	 * \param y Y-coordinate of a position the data was dropped to
	 * \param def Drag result
	 * \param data Pointer to a data object encapsulating dropped data
	 * \sa wxSFCanvasDropTarget
	 */
	void _OnDrop(wxCoord x, wxCoord y, wxDragResult def, wxDataObject *data);
	

	DECLARE_EVENT_TABLE();
};

#endif //_WXSFSHAPECANVAS_H