]> git.saurik.com Git - wxWidgets.git/blob - utils/dialoged/src/dlghndlr.h
new template-based more flexible and hopefully more efficient raw bitmap implementation
[wxWidgets.git] / utils / dialoged / src / dlghndlr.h
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
22 #define wxDRAG_TYPE_BOUNDING_BOX 200
23
24 #define wxKEY_SHIFT 1
25 #define wxKEY_CTRL 2
26
27 class wxResourceEditorDialogHandler: public wxEvtHandler
28 {
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 void OnObjectEdit(wxCommandEvent& event);
56 void OnObjectDelete(wxCommandEvent& event);
57
58 virtual void OnItemEvent(wxControl *win, wxMouseEvent& event);
59 virtual void OnLeftClick(int x, int y, int keys);
60 virtual void OnRightClick(int x, int y, int keys);
61 virtual void OnItemLeftClick(wxControl *item, int x, int y, int keys);
62 virtual void OnItemRightClick(wxControl *item, int x, int y, int keys);
63 virtual void OnItemSelect(wxControl *item, bool select);
64 virtual void OnItemMove(
65 wxControl *WXUNUSED(item), int WXUNUSED(x), int WXUNUSED(y) ) {};
66 virtual void OnItemSize(
67 wxControl *WXUNUSED(item), int WXUNUSED(w), int WXUNUSED(h) ) {};
68
69 void AddChildHandlers(void);
70 void PaintSelectionHandles(wxDC& dc);
71 void ProcessItemEvent(wxControl *item, wxMouseEvent& event, int selectionHandle);
72
73 virtual void DrawBoundingBox(wxDC& dc, int x, int y, int w, int h);
74 virtual void OnDragBegin(int x, int y, int keys, wxDC& dc, int selectionHandle);
75 virtual void OnDragContinue(bool paintIt, int x, int y, int keys, wxDC& dc, int selectionHandle);
76 virtual void OnDragEnd(int x, int y, int keys, wxDC& dc, int selectionHandle);
77
78 // Accessors
79 /*
80 inline long GetTreeItem() const { return m_treeItem; }
81 inline void SetTreeItem(long item) { m_treeItem = item; }
82 */
83
84 DECLARE_EVENT_TABLE()
85 };
86
87 class wxResourceEditorControlHandler: public wxEvtHandler
88 {
89 DECLARE_CLASS(wxResourceEditorControlHandler)
90 public:
91 // wxResourceManager *resourceManager;
92 wxControl *handlerControl;
93 // wxItemResource *handlerResource;
94 wxEvtHandler *handlerOldHandler;
95
96 bool isSelected;
97 int handleSize; // selection handle size
98 int handleMargin; // Distance between item edge and handle edge
99 long m_treeItem;
100 static int dragOffsetX; // Distance between pointer at start of drag and
101 static int dragOffsetY; // top-left of item
102
103 wxResourceEditorControlHandler(wxControl *control, wxEvtHandler *oldHandler);
104 ~wxResourceEditorControlHandler(void);
105
106 void OnMouseEvent(wxMouseEvent& event);
107
108 // Manipulation and drawing of items in Edit Mode
109
110 // Calculate position of the 8 handles
111 virtual void CalcSelectionHandles(int *hx, int *hy);
112 virtual void DrawSelectionHandles(wxDC& dc, bool erase = FALSE);
113 virtual void DrawBoundingBox(wxDC& dc, int x, int y, int w, int h);
114 virtual void SelectItem(bool select);
115 virtual inline bool IsSelected(void) { return isSelected; }
116
117 // Returns TRUE or FALSE
118 virtual bool HitTest(int x, int y);
119
120 // Returns 0 (no hit), 1 - 8 for which selection handle
121 // (clockwise from top middle)
122 virtual int SelectionHandleHitTest(int x, int y);
123
124 // If selectionHandle is zero, not dragging the selection handle.
125 virtual void OnDragBegin(int x, int y, int keys, wxDC& dc, int selectionHandle);
126 virtual void OnDragContinue(bool paintIt, int x, int y, int keys, wxDC& dc, int selectionHandle);
127 virtual void OnDragEnd(int x, int y, int keys, wxDC& dc, int selectionHandle);
128
129 // These functions call panel functions
130 // by default.
131 virtual void OldOnMove(int x, int y);
132 virtual void OldOnSize(int w, int h);
133 virtual void OnLeftClick(int x, int y, int keys);
134 virtual void OnRightClick(int x, int y, int keys);
135 virtual void OnSelect(bool select);
136
137 // Accessors
138 /*
139 inline long GetTreeItem() const { return m_treeItem; }
140 inline void SetTreeItem(long item) { m_treeItem = item; }
141 */
142
143 DECLARE_EVENT_TABLE()
144 };
145
146 // This dialog, for testing dialogs, has to intercept commands before
147 // they go up the hierarchy and accidentally set off arbitrary
148 // Dialog Editor functionality
149 class ResourceEditorDialogTester: public wxDialog
150 {
151 public:
152 ResourceEditorDialogTester() {}
153
154 bool ProcessEvent(wxEvent& event);
155 };
156
157 #endif
158