1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Dialog handler
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
15 #define wxDRAG_MODE_NONE 0
16 #define wxDRAG_MODE_START_LEFT 1
17 #define wxDRAG_MODE_CONTINUE_LEFT 2
18 #define wxDRAG_MODE_START_RIGHT 3
19 #define wxDRAG_MODE_CONTINUE_RIGHT 4
20 #define wxDRAG_TYPE_NONE 0
21 #define wxDRAG_TYPE_ITEM 100
26 class wxResourceEditorDialogHandler
: public wxEvtHandler
28 DECLARE_CLASS(wxResourceEditorDialogHandler
)
30 wxResourceManager
*resourceManager
;
31 wxPanel
*handlerDialog
;
32 wxItemResource
*handlerResource
;
33 wxEvtHandler
*handlerOldHandler
;
47 wxResourceEditorDialogHandler(wxPanel
*dialog
, wxItemResource
*resource
, wxEvtHandler
*oldHandler
,
48 wxResourceManager
*manager
);
49 ~wxResourceEditorDialogHandler(void);
51 void OnPaint(wxPaintEvent
& event
);
52 void OnMouseEvent(wxMouseEvent
& event
);
54 virtual void OnItemEvent(wxControl
*win
, wxMouseEvent
& event
);
55 virtual void OnLeftClick(int x
, int y
, int keys
);
56 virtual void OnRightClick(int x
, int y
, int keys
);
57 virtual void OnItemLeftClick(wxControl
*item
, int x
, int y
, int keys
);
58 virtual void OnItemRightClick(wxControl
*item
, int x
, int y
, int keys
);
59 virtual void OnItemSelect(wxControl
*item
, bool select
);
60 virtual void OnItemMove(wxControl
*item
, int x
, int y
) {};
61 virtual void OnItemSize(wxControl
*item
, int w
, int h
) {};
63 void AddChildHandlers(void);
64 void PaintSelectionHandles(wxDC
& dc
);
65 void ProcessItemEvent(wxControl
*item
, wxMouseEvent
& event
, int selectionHandle
);
69 inline long GetTreeItem() const { return m_treeItem; }
70 inline void SetTreeItem(long item) { m_treeItem = item; }
76 class wxResourceEditorControlHandler
: public wxEvtHandler
78 DECLARE_CLASS(wxResourceEditorControlHandler
)
80 // wxResourceManager *resourceManager;
81 wxControl
*handlerControl
;
82 // wxItemResource *handlerResource;
83 wxEvtHandler
*handlerOldHandler
;
86 int handleSize
; // selection handle size
87 int handleMargin
; // Distance between item edge and handle edge
89 static int dragOffsetX
; // Distance between pointer at start of drag and
90 static int dragOffsetY
; // top-left of item
92 wxResourceEditorControlHandler(wxControl
*control
, wxEvtHandler
*oldHandler
);
93 ~wxResourceEditorControlHandler(void);
95 void OnMouseEvent(wxMouseEvent
& event
);
97 // Manipulation and drawing of items in Edit Mode
99 // Calculate position of the 8 handles
100 virtual void CalcSelectionHandles(int *hx
, int *hy
);
101 virtual void DrawSelectionHandles(wxDC
& dc
, bool erase
= FALSE
);
102 virtual void DrawBoundingBox(wxDC
& dc
, int x
, int y
, int w
, int h
);
103 virtual void SelectItem(bool select
);
104 virtual inline bool IsSelected(void) { return isSelected
; }
106 // Returns TRUE or FALSE
107 virtual bool HitTest(int x
, int y
);
109 // Returns 0 (no hit), 1 - 8 for which selection handle
110 // (clockwise from top middle)
111 virtual int SelectionHandleHitTest(int x
, int y
);
113 // If selectionHandle is zero, not dragging the selection handle.
114 virtual void OnDragBegin(int x
, int y
, int keys
, wxDC
& dc
, int selectionHandle
);
115 virtual void OnDragContinue(bool paintIt
, int x
, int y
, int keys
, wxDC
& dc
, int selectionHandle
);
116 virtual void OnDragEnd(int x
, int y
, int keys
, wxDC
& dc
, int selectionHandle
);
118 // These functions call panel functions
120 virtual void OldOnMove(int x
, int y
);
121 virtual void OldOnSize(int w
, int h
);
122 virtual void OnLeftClick(int x
, int y
, int keys
);
123 virtual void OnRightClick(int x
, int y
, int keys
);
124 virtual void OnSelect(bool select
);
128 inline long GetTreeItem() const { return m_treeItem; }
129 inline void SetTreeItem(long item) { m_treeItem = item; }
132 DECLARE_EVENT_TABLE()