]> git.saurik.com Git - wxWidgets.git/blob - utils/dialoged/src/dlghndlr.h
aced1272c7d657e19d77f1a08c2096adc3baf544
[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
23 #define wxKEY_SHIFT 1
24 #define wxKEY_CTRL 2
25
26 class wxResourceEditorDialogHandler: public wxEvtHandler
27 {
28 DECLARE_CLASS(wxResourceEditorDialogHandler)
29 public:
30 wxResourceManager *resourceManager;
31 wxPanel *handlerDialog;
32 wxItemResource *handlerResource;
33 wxEvtHandler *handlerOldHandler;
34
35 wxControl *dragItem;
36 int dragMode;
37 int dragType;
38 int dragTolerance;
39 bool checkTolerance;
40 int firstDragX;
41 int firstDragY;
42 int oldDragX;
43 int oldDragY;
44
45 wxResourceEditorDialogHandler(wxPanel *dialog, wxItemResource *resource, wxEvtHandler *oldHandler,
46 wxResourceManager *manager);
47 ~wxResourceEditorDialogHandler(void) {}
48
49 bool OnClose(void);
50
51 void OnPaint(wxPaintEvent& event);
52 void OnMouseEvent(wxMouseEvent& event);
53
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) {};
62
63 void AddChildHandlers(void);
64 void PaintSelectionHandles(wxDC& dc);
65 void ProcessItemEvent(wxControl *item, wxMouseEvent& event, int selectionHandle);
66
67 DECLARE_EVENT_TABLE()
68 };
69
70 class wxResourceEditorControlHandler: public wxEvtHandler
71 {
72 DECLARE_CLASS(wxResourceEditorControlHandler)
73 public:
74 // wxResourceManager *resourceManager;
75 wxControl *handlerControl;
76 // wxItemResource *handlerResource;
77 wxEvtHandler *handlerOldHandler;
78
79 bool isSelected;
80 int handleSize; // selection handle size
81 int handleMargin; // Distance between item edge and handle edge
82 static int dragOffsetX; // Distance between pointer at start of drag and
83 static int dragOffsetY; // top-left of item
84
85 wxResourceEditorControlHandler(wxControl *control, wxEvtHandler *oldHandler);
86 ~wxResourceEditorControlHandler(void) {}
87
88 void OnMouseEvent(wxMouseEvent& event);
89
90 // Manipulation and drawing of items in Edit Mode
91
92 // Calculate position of the 8 handles
93 virtual void CalcSelectionHandles(int *hx, int *hy);
94 virtual void DrawSelectionHandles(wxDC& dc, bool erase = FALSE);
95 virtual void DrawBoundingBox(wxDC& dc, int x, int y, int w, int h);
96 virtual void SelectItem(bool select);
97 virtual inline bool IsSelected(void) { return isSelected; }
98
99 // Returns TRUE or FALSE
100 virtual bool HitTest(int x, int y);
101
102 // Returns 0 (no hit), 1 - 8 for which selection handle
103 // (clockwise from top middle)
104 virtual int SelectionHandleHitTest(int x, int y);
105
106 // If selectionHandle is zero, not dragging the selection handle.
107 virtual void OnDragBegin(int x, int y, int keys, wxDC& dc, int selectionHandle);
108 virtual void OnDragContinue(bool paintIt, int x, int y, int keys, wxDC& dc, int selectionHandle);
109 virtual void OnDragEnd(int x, int y, int keys, wxDC& dc, int selectionHandle);
110
111 // These functions call panel functions
112 // by default.
113 virtual void OldOnMove(int x, int y);
114 virtual void OldOnSize(int w, int h);
115 virtual void OnLeftClick(int x, int y, int keys);
116 virtual void OnRightClick(int x, int y, int keys);
117 virtual void OnSelect(bool select);
118
119 DECLARE_EVENT_TABLE()
120 };
121
122 #endif
123