/
FXMDIChild.i
242 lines (213 loc) · 9.16 KB
/
FXMDIChild.i
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
/***********************************************************************
* FXRuby -- the Ruby language bindings for the FOX GUI toolkit.
* Copyright (c) 2001-2009 by Lyle Johnson. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For further information please contact the author by e-mail
* at "lyle@lylejohnson.name".
***********************************************************************/
class FXMDIClient;
class FXMenuButton;
class FXButton;
class FXFont;
/// MDI Child Window styles
enum {
MDI_NORMAL = 0, /// Normal display mode
MDI_MAXIMIZED = 0x00001000, /// Window appears maximized
MDI_MINIMIZED = 0x00002000, /// Window is iconified or minimized
MDI_TRACKING = 0x00004000 /// Track continuously during dragging
};
/**
* The MDI child window contains the application work area in a Multiple Document
* Interface application. GUI Controls are connected to the MDI child via delegation
* through the MDI client, which forwards messages it receives to the active MDI child.
* The MDI child itself tries to further delegate messages to its single content window,
* and if not handled there, to its target object.
* When the MDI child is maximized, it sends a SEL_MAXIMIZE message; when the MDI
* child is minimized, it sends a SEL_MINIMIZE message. When it is restored, it
* sends a SEL_RESTORE message to its target. The MDI child also notifies its
* target when it becomes the active MDI child, via the SEL_SELECTED message.
* The void* in the SEL_SELECTED message refers to the previously active MDI child,
* if any. When an MDI child ceases to be the active one, a SEL_DESELECTED message
* is sent. The void* in the SEL_DESELECTED message refers to the newly activated
* MDI child, if any. Thus, interception of SEL_SELECTED and SEL_DESELECTED allows
* the target object to determine whether the user switched between MDI windows of
* the same document (target) or between MDI windows belonging to the same document.
* When the MDI child is closed, it sends a SEL_CLOSE message to its target.
* The target has an opportunity to object to the closing; if the MDI child should
* not be closed, it should return 1 (objection). If the MDI child should be closed,
* the target can either just return 0 or simply not handle the SEL_CLOSE message.
* The SEL_UPDATE message can be used to modify the MDI child's title (via
* ID_SETSTRINGVALUE), and window icon (via ID_SETICONVALUE).
*/
class FXMDIChild : public FXComposite {
protected:
FXString title; // Window title
FXMenuButton *windowbtn; // Window button
FXButton *minimizebtn; // Minimize button
FXButton *restorebtn; // Restore button
FXButton *maximizebtn; // Maximize buton
FXButton *deletebtn; // Close button
FXFont *font; // Title font
FXColor baseColor; // Colors
FXColor hiliteColor;
FXColor shadowColor;
FXColor borderColor;
FXColor titleColor;
FXColor titleBackColor;
FXint iconPosX; // Saved icon position
FXint iconPosY;
FXint iconWidth;
FXint iconHeight;
FXint normalPosX; // Saved normal position
FXint normalPosY;
FXint normalWidth;
FXint normalHeight;
FXint spotx; // Grab-spot of mouse on window
FXint spoty;
FXint xoff; // Mouse offset to add
FXint newx; // New location of window
FXint newy;
FXint neww;
FXint newh;
FXuchar mode; // Dragging mode
protected:
FXMDIChild();
void drawRubberBox(FXint x,FXint y,FXint w,FXint h);
void animateRectangles(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh);
FXuchar where(FXint x,FXint y);
void changeCursor(FXint x,FXint y);
void revertCursor();
protected:
enum {
DRAG_NONE = 0,
DRAG_TOP = 1,
DRAG_BOTTOM = 2,
DRAG_LEFT = 4,
DRAG_RIGHT = 8,
DRAG_TOPLEFT = (DRAG_TOP|DRAG_LEFT),
DRAG_TOPRIGHT = (DRAG_TOP|DRAG_RIGHT),
DRAG_BOTTOMLEFT = (DRAG_BOTTOM|DRAG_LEFT),
DRAG_BOTTOMRIGHT = (DRAG_BOTTOM|DRAG_RIGHT),
DRAG_INVERTED = 16,
DRAG_TITLE = 32
};
public:
long onPaint(FXObject*,FXSelector,void* PTR_EVENT);
long onFocusSelf(FXObject*,FXSelector,void* PTR_EVENT);
long onFocusIn(FXObject*,FXSelector,void* PTR_EVENT);
long onFocusOut(FXObject*,FXSelector,void* PTR_EVENT);
long onRightBtnPress(FXObject*,FXSelector,void* PTR_EVENT);
long onRightBtnRelease(FXObject*,FXSelector,void* PTR_EVENT);
long onLeftBtnPress(FXObject*,FXSelector,void* PTR_EVENT);
long onLeftBtnRelease(FXObject*,FXSelector,void* PTR_EVENT);
long onMiddleBtnPress(FXObject*,FXSelector,void* PTR_EVENT);
long onMiddleBtnRelease(FXObject*,FXSelector,void* PTR_EVENT);
long onMotion(FXObject*,FXSelector,void* PTR_EVENT);
long onSelected(FXObject*,FXSelector,void* PTR_MDICHILD);
long onDeselected(FXObject*,FXSelector,void* PTR_MDICHILD);
long onCmdClose(FXObject*,FXSelector,void* PTR_IGNORE);
long onUpdClose(FXObject*,FXSelector,void* PTR_IGNORE);
long onCmdRestore(FXObject*,FXSelector,void* PTR_IGNORE);
long onUpdRestore(FXObject*,FXSelector,void* PTR_IGNORE);
long onUpdMaximize(FXObject*,FXSelector,void* PTR_IGNORE);
long onUpdMinimize(FXObject*,FXSelector,void* PTR_IGNORE);
long onCmdMaximize(FXObject*,FXSelector,void* PTR_IGNORE);
long onCmdMinimize(FXObject*,FXSelector,void* PTR_IGNORE);
long onUpdWindow(FXObject*,FXSelector,void* PTR_IGNORE);
long onUpdMenuRestore(FXObject*,FXSelector,void* PTR_IGNORE);
long onUpdMenuMinimize(FXObject*,FXSelector,void* PTR_IGNORE);
long onUpdMenuClose(FXObject*,FXSelector,void* PTR_IGNORE);
long onUpdMenuWindow(FXObject*,FXSelector,void* PTR_IGNORE);
long onCmdSetStringValue(FXObject*,FXSelector,void* PTR_STRING);
long onCmdGetStringValue(FXObject*,FXSelector,void* PTR_STRING); // FIXME
long onCmdSetIconValue(FXObject*,FXSelector,void* PTR_STRING); // FIXME
long onCmdGetIconValue(FXObject*,FXSelector,void* PTR_STRING); // FIXME
public:
%extend {
/// Construct MDI Child window with given name and icon
FXMDIChild(FXMDIClient* p,const FXString& name,FXIcon* ic=NULL,FXPopup* pup=NULL,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0){
return new FXRbMDIChild(p,name,ic,pup,opts,x,y,w,h);
}
}
/// Change normal (restored) position
void setNormalX(FXint x);
void setNormalY(FXint y);
void setNormalWidth(FXint w);
void setNormalHeight(FXint h);
/// Return normal (restored) position
FXint getNormalX() const;
FXint getNormalY() const;
FXint getNormalWidth() const;
FXint getNormalHeight() const;
/// Change iconified position
void setIconX(FXint x);
void setIconY(FXint y);
void setIconWidth(FXint w);
void setIconHeight(FXint h);
/// Return iconified position
FXint getIconX() const;
FXint getIconY() const;
FXint getIconWidth() const;
FXint getIconHeight() const;
/// Return content window
FXWindow *contentWindow() const;
/// Change MDI Child's title
void setTitle(const FXString& name);
/// Get current title
FXString getTitle() const;
/// Get colors
FXColor getHiliteColor() const;
FXColor getShadowColor() const;
FXColor getBaseColor() const;
FXColor getBorderColor() const;
FXColor getTitleColor () const;
FXColor getTitleBackColor() const;
/// Change colors
void setHiliteColor(FXColor clr);
void setShadowColor(FXColor clr);
void setBaseColor(FXColor clr);
void setBorderColor(FXColor clr);
void setTitleColor(FXColor clr);
void setTitleBackColor(FXColor clr);
/// Return TRUE if maximized
FXbool isMaximized() const;
/// Return TRUE if minimized
FXbool isMinimized() const;
/// Get window icon
FXIcon *getIcon() const;
/// Set window icon
void setIcon(FXIcon* icon);
/// Get window menu
FXPopup* getMenu() const;
/// Set window menu
void setMenu(FXPopup* menu);
/// Set tracking instead of just outline
void setTracking(FXbool tracking=TRUE);
/// Return true if tracking
FXbool getTracking() const;
/// Set title font
void setFont(FXFont *fnt);
/// Get title font
FXFont* getFont() const;
/// Destroy
virtual ~FXMDIChild();
};
DECLARE_FXOBJECT_VIRTUALS(FXMDIChild)
DECLARE_FXID_VIRTUALS(FXMDIChild)
DECLARE_FXDRAWABLE_VIRTUALS(FXMDIChild)
DECLARE_FXWINDOW_VIRTUALS(FXMDIChild)
DECLARE_FXMDICHILD_VIRTUALS(FXMDIChild)