]>
Commit | Line | Data |
---|---|---|
457814b5 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dlghndlr.h | |
3 | // Purpose: Dialog handler | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _DLGHNDLR_H_ | |
13 | #define _DLGHNDLR_H_ | |
14 | ||
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 | |
c0e66542 | 22 | #define wxDRAG_TYPE_BOUNDING_BOX 200 |
457814b5 JS |
23 | |
24 | #define wxKEY_SHIFT 1 | |
25 | #define wxKEY_CTRL 2 | |
26 | ||
27 | class wxResourceEditorDialogHandler: public wxEvtHandler | |
28 | { | |
f6bcfd97 BP |
29 | DECLARE_CLASS(wxResourceEditorDialogHandler) |
30 | public: | |
31 | wxResourceManager *resourceManager; | |
32 | wxPanel *handlerDialog; | |
33 | wxItemResource *handlerResource; | |
34 | wxEvtHandler *handlerOldHandler; | |
35 | ||
36 | wxControl *dragItem; | |
37 | int dragMode; | |
38 | int dragType; | |
39 | int dragTolerance; | |
40 | bool checkTolerance; | |
41 | int firstDragX; | |
42 | int firstDragY; | |
43 | int oldDragX; | |
44 | int oldDragY; | |
45 | bool m_mouseCaptured; | |
46 | // long m_treeItem; | |
47 | ||
48 | wxResourceEditorDialogHandler(wxPanel *dialog, wxItemResource *resource, wxEvtHandler *oldHandler, | |
49 | wxResourceManager *manager); | |
50 | ~wxResourceEditorDialogHandler(void); | |
51 | ||
52 | void OnPaint(wxPaintEvent& event); | |
53 | void OnMouseEvent(wxMouseEvent& event); | |
54 | void OnSize(wxSizeEvent& event); | |
55 | ||
56 | virtual void OnItemEvent(wxControl *win, wxMouseEvent& event); | |
57 | virtual void OnLeftClick(int x, int y, int keys); | |
58 | virtual void OnRightClick(int x, int y, int keys); | |
59 | virtual void OnItemLeftClick(wxControl *item, int x, int y, int keys); | |
60 | virtual void OnItemRightClick(wxControl *item, int x, int y, int keys); | |
61 | virtual void OnItemSelect(wxControl *item, bool select); | |
62 | virtual void OnItemMove( | |
63 | wxControl *WXUNUSED(item), int WXUNUSED(x), int WXUNUSED(y) ) {}; | |
64 | virtual void OnItemSize( | |
65 | wxControl *WXUNUSED(item), int WXUNUSED(w), int WXUNUSED(h) ) {}; | |
66 | ||
67 | void AddChildHandlers(void); | |
68 | void PaintSelectionHandles(wxDC& dc); | |
69 | void ProcessItemEvent(wxControl *item, wxMouseEvent& event, int selectionHandle); | |
c0e66542 GT |
70 | |
71 | virtual void DrawBoundingBox(wxDC& dc, int x, int y, int w, int h); | |
72 | virtual void OnDragBegin(int x, int y, int keys, wxDC& dc, int selectionHandle); | |
73 | virtual void OnDragContinue(bool paintIt, int x, int y, int keys, wxDC& dc, int selectionHandle); | |
74 | virtual void OnDragEnd(int x, int y, int keys, wxDC& dc, int selectionHandle); | |
75 | ||
f6bcfd97 BP |
76 | // Accessors |
77 | /* | |
78 | inline long GetTreeItem() const { return m_treeItem; } | |
79 | inline void SetTreeItem(long item) { m_treeItem = item; } | |
80 | */ | |
81 | ||
82 | DECLARE_EVENT_TABLE() | |
457814b5 JS |
83 | }; |
84 | ||
85 | class wxResourceEditorControlHandler: public wxEvtHandler | |
86 | { | |
f6bcfd97 BP |
87 | DECLARE_CLASS(wxResourceEditorControlHandler) |
88 | public: | |
89 | // wxResourceManager *resourceManager; | |
90 | wxControl *handlerControl; | |
91 | // wxItemResource *handlerResource; | |
92 | wxEvtHandler *handlerOldHandler; | |
93 | ||
94 | bool isSelected; | |
95 | int handleSize; // selection handle size | |
96 | int handleMargin; // Distance between item edge and handle edge | |
97 | long m_treeItem; | |
98 | static int dragOffsetX; // Distance between pointer at start of drag and | |
99 | static int dragOffsetY; // top-left of item | |
100 | ||
101 | wxResourceEditorControlHandler(wxControl *control, wxEvtHandler *oldHandler); | |
102 | ~wxResourceEditorControlHandler(void); | |
103 | ||
104 | void OnMouseEvent(wxMouseEvent& event); | |
105 | ||
106 | // Manipulation and drawing of items in Edit Mode | |
107 | ||
108 | // Calculate position of the 8 handles | |
109 | virtual void CalcSelectionHandles(int *hx, int *hy); | |
110 | virtual void DrawSelectionHandles(wxDC& dc, bool erase = FALSE); | |
111 | virtual void DrawBoundingBox(wxDC& dc, int x, int y, int w, int h); | |
112 | virtual void SelectItem(bool select); | |
113 | virtual inline bool IsSelected(void) { return isSelected; } | |
114 | ||
115 | // Returns TRUE or FALSE | |
116 | virtual bool HitTest(int x, int y); | |
117 | ||
118 | // Returns 0 (no hit), 1 - 8 for which selection handle | |
119 | // (clockwise from top middle) | |
120 | virtual int SelectionHandleHitTest(int x, int y); | |
121 | ||
122 | // If selectionHandle is zero, not dragging the selection handle. | |
123 | virtual void OnDragBegin(int x, int y, int keys, wxDC& dc, int selectionHandle); | |
124 | virtual void OnDragContinue(bool paintIt, int x, int y, int keys, wxDC& dc, int selectionHandle); | |
125 | virtual void OnDragEnd(int x, int y, int keys, wxDC& dc, int selectionHandle); | |
126 | ||
127 | // These functions call panel functions | |
128 | // by default. | |
129 | virtual void OldOnMove(int x, int y); | |
130 | virtual void OldOnSize(int w, int h); | |
131 | virtual void OnLeftClick(int x, int y, int keys); | |
132 | virtual void OnRightClick(int x, int y, int keys); | |
133 | virtual void OnSelect(bool select); | |
134 | ||
135 | // Accessors | |
136 | /* | |
137 | inline long GetTreeItem() const { return m_treeItem; } | |
138 | inline void SetTreeItem(long item) { m_treeItem = item; } | |
139 | */ | |
140 | ||
141 | DECLARE_EVENT_TABLE() | |
142 | }; | |
ae8351fc | 143 | |
f6bcfd97 BP |
144 | // This dialog, for testing dialogs, has to intercept commands before |
145 | // they go up the hierarchy and accidentally set off arbitrary | |
146 | // Dialog Editor functionality | |
147 | class ResourceEditorDialogTester: public wxDialog | |
148 | { | |
149 | public: | |
150 | ResourceEditorDialogTester() {} | |
151 | ||
152 | bool ProcessEvent(wxEvent& event); | |
457814b5 JS |
153 | }; |
154 | ||
155 | #endif | |
156 |