Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXTopWindow.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * T o p - L e v e l W i n d o w W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXTopWindow.h,v 1.62 2006/01/22 17:58:11 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXTOPWINDOW_H
25 #define FXTOPWINDOW_H
26 
27 #ifndef FXSHELL_H
28 #include "FXShell.h"
29 #endif
30 
31 
32 namespace FX {
33 
34 
35 /// Title and border decorations
36 enum {
37  DECOR_NONE = 0, /// Borderless window
38  DECOR_TITLE = 0x00020000, /// Window title
39  DECOR_MINIMIZE = 0x00040000, /// Minimize button
40  DECOR_MAXIMIZE = 0x00080000, /// Maximize button
41  DECOR_CLOSE = 0x00100000, /// Close button
42  DECOR_BORDER = 0x00200000, /// Border
43  DECOR_SHRINKABLE = 0x00400000, /// Window can become smaller
44  DECOR_STRETCHABLE = 0x00800000, /// Window can become larger
46  DECOR_MENU = 0x01000000, /// Window menu
48  };
49 
50 
51 /// Initial window placement
52 enum {
53  PLACEMENT_DEFAULT, /// Place it at the default size and location
54  PLACEMENT_VISIBLE, /// Place window to be fully visible
55  PLACEMENT_CURSOR, /// Place it under the cursor position
56  PLACEMENT_OWNER, /// Place it centered on its owner
57  PLACEMENT_SCREEN, /// Place it centered on the screen
58  PLACEMENT_MAXIMIZED /// Place it maximized to the screen size
59  };
60 
61 
62 class FXToolBar;
63 class FXIcon;
64 
65 
66 
67 /**
68 * Abstract base class for all top-level windows.
69 * TopWindows are usually managed by a Window Manager under X11 and
70 * therefore borders and window-menus and other decorations like resize-
71 * handles are subject to the Window Manager's interpretation of the
72 * decoration hints.
73 * When a TopWindow is closed, it sends a SEL_CLOSE message to its
74 * target. The target should return 0 in response to this message if
75 * there is no objection to proceed with the closing of the window, and
76 * return 1 otherwise. After the SEL_CLOSE message has been sent and
77 * no objection was raised, the window will delete itself.
78 * When the session is closed, the window will send a SEL_SESSION_NOTIFY
79 * message to its target, allowing the application to write any unsaved
80 * data to the disk. If the target returns 0, then the system will proceed
81 * to close the session. Subsequently a SEL_SESSION_CLOSED will be received
82 * which causes the window to be closed with prejudice by calling the
83 * function close(FALSE).
84 * When receiving a SEL_UPDATE, the target can update the title string
85 * of the window, so that the title of the window reflects the name
86 * of the document, for example.
87 * For convenience, TopWindow provides the same layout behavior as
88 * the Packer widget, as well as docking and undocking of toolbars.
89 * TopWindows can be owned by other windows, or be free-floating.
90 * Owned TopWindows will usually remain stacked on top of the owner
91 * windows. The lifetime of an owned window should not exceed that of
92 * the owner.
93 */
94 class FXAPI FXTopWindow : public FXShell {
96 protected:
97  FXString title; // Window title
98  FXIcon *icon; // Window icon (big)
99  FXIcon *miniIcon; // Window icon (small)
100  FXint padtop; // Top margin
101  FXint padbottom; // Bottom margin
102  FXint padleft; // Left margin
103  FXint padright; // Right margin
104  FXint hspacing; // Horizontal child spacing
105  FXint vspacing; // Vertical child spacing
106 protected:
107  FXTopWindow();
108  void settitle();
109  void seticons();
110  void setdecorations();
111  FXTopWindow(FXApp* ap,const FXString& name,FXIcon *ic,FXIcon *mi,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs);
112  FXTopWindow(FXWindow* ow,const FXString& name,FXIcon *ic,FXIcon *mi,FXuint opts,FXint x,FXint y,FXint w,FXint h,FXint pl,FXint pr,FXint pt,FXint pb,FXint hs,FXint vs);
113 private:
114  FXTopWindow(const FXTopWindow&);
115  FXTopWindow& operator=(const FXTopWindow&);
116 #ifdef WIN32
117  virtual const char* GetClass() const;
118 #endif
119 public:
120  long onFocusUp(FXObject*,FXSelector,void*);
121  long onFocusDown(FXObject*,FXSelector,void*);
122  long onFocusLeft(FXObject*,FXSelector,void*);
123  long onFocusRight(FXObject*,FXSelector,void*);
124  long onSessionNotify(FXObject*,FXSelector,void*);
125  long onSessionClosed(FXObject*,FXSelector,void*);
126  long onCmdMaximize(FXObject*,FXSelector,void*);
127  long onCmdMinimize(FXObject*,FXSelector,void*);
128  long onCmdRestore(FXObject*,FXSelector,void*);
129  long onCmdClose(FXObject*,FXSelector,void*);
130  long onCmdSetStringValue(FXObject*,FXSelector,void*);
131  long onCmdGetStringValue(FXObject*,FXSelector,void*);
132  long onCmdSetIconValue(FXObject*,FXSelector,void*);
133  long onCmdGetIconValue(FXObject*,FXSelector,void*);
134 public:
135  enum {
136  ID_MAXIMIZE=FXShell::ID_LAST, /// Maximize the window
137  ID_MINIMIZE, /// Minimize the window
138  ID_RESTORE, /// Restore the window
139  ID_CLOSE, /// Close the window
140  ID_QUERY_DOCK, /// Toolbar asks to dock
141  ID_LAST
142  };
143 public:
144 
145  /// Create server-side resources
146  virtual void create();
147 
148  /// Detach the server-side resources for this window
149  virtual void detach();
150 
151  /// Destroy the server-side resources for this window
152  virtual void destroy();
153 
154  /// Perform layout
155  virtual void layout();
156 
157  /// Move the focus to this window
158  virtual void setFocus();
159 
160  /// Remove the focus from this window
161  virtual void killFocus();
162 
163  /// Show this window
164  virtual void show();
165 
166  /// Hide this window
167  virtual void hide();
168 
169  /// Show this window with given placement
170  virtual void show(FXuint placement);
171 
172  /// Position the window based on placement
173  void place(FXuint placement);
174 
175  /// Return the default width of this window
176  virtual FXint getDefaultWidth();
177 
178  /// Return the default height of this window
179  virtual FXint getDefaultHeight();
180 
181  /// Obtain border sizes added to our window by the window manager
182  FXbool getWMBorders(FXint& left,FXint& right,FXint& top,FXint& bottom);
183 
184  /// Raise this window to the top of the stacking order
185  virtual void raise();
186 
187  /// Move this window to the specified position in the parent's coordinates
188  virtual void move(FXint x,FXint y);
189 
190  /// Resize this window to the specified width and height
191  virtual void resize(FXint w,FXint h);
192 
193  /// Move and resize this window in the parent's coordinates
194  virtual void position(FXint x,FXint y,FXint w,FXint h);
195 
196  /// Maximize window, return TRUE if maximized
197  virtual FXbool maximize(FXbool notify=FALSE);
198 
199  /// Minimize or iconify window, return TRUE if minimized
200  virtual FXbool minimize(FXbool notify=FALSE);
201 
202  /// Restore window to normal, return TRUE if restored
203  virtual FXbool restore(FXbool notify=FALSE);
204 
205  /**
206  * Close the window, return TRUE if actually closed. If notify=TRUE, the target
207  * will receive a SEL_CLOSE message to determine if it is OK to close the window.
208  * If the target ignores the SEL_CLOSE message or returns 0, the window will
209  * be closed, and subsequently deleted. When the last main window has been
210  * closed, the application will receive an ID_QUIT message and will be closed.
211  */
212  virtual FXbool close(FXbool notify=FALSE);
214  /// Return TRUE if maximized
215  FXbool isMaximized() const;
216 
217  /// Return TRUE if minimized
218  FXbool isMinimized() const;
220  /// Change window title
221  void setTitle(const FXString& name);
222 
223  /// Return window title
224  FXString getTitle() const { return title; }
226  /// Change top padding
227  void setPadTop(FXint pt);
228 
229  /// Get top interior padding
230  FXint getPadTop() const { return padtop; }
232  /// Change bottom padding
233  void setPadBottom(FXint pb);
234 
235  /// Get bottom interior padding
236  FXint getPadBottom() const { return padbottom; }
238  /// Change left padding
239  void setPadLeft(FXint pl);
241  /// Get left interior padding
242  FXint getPadLeft() const { return padleft; }
244  /// Change right padding
245  void setPadRight(FXint pr);
246 
247  /// Get right interior padding
248  FXint getPadRight() const { return padright; }
249 
250  /// Return horizontal spacing between children
251  FXint getHSpacing() const { return hspacing; }
252 
253  /// Return vertical spacing between children
254  FXint getVSpacing() const { return vspacing; }
255 
256  /// Change horizontal spacing between children
257  void setHSpacing(FXint hs);
258 
259  /// Change vertical spacing between children
260  void setVSpacing(FXint vs);
261 
262  /// Change packing hints for children
263  void setPackingHints(FXuint ph);
265  /// Return packing hints for children
266  FXuint getPackingHints() const;
267 
268  /// Change title and border decorations
269  void setDecorations(FXuint decorations);
271  /// Return current title and border decorations
272  FXuint getDecorations() const;
273 
274  /// Return window icon
275  FXIcon* getIcon() const { return icon; }
276 
277  /// Change window icon
278  void setIcon(FXIcon* ic);
279 
280  /// Return window mini (title) icon
281  FXIcon* getMiniIcon() const { return miniIcon; }
282 
283  /// Change window mini (title) icon
284  void setMiniIcon(FXIcon *ic);
285 
286  /// Save to stream
287  virtual void save(FXStream& store) const;
288 
289  /// Load from stream
290  virtual void load(FXStream& store);
291 
292  /// Destructor
293  virtual ~FXTopWindow();
294  };
295 
296 }
297 
298 #endif
Window can become smaller.
Definition: FXTopWindow.h:46
Base class for all windows.
Definition: FXWindow.h:115
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:389
FXuint FXSelector
Association key.
Definition: FXObject.h:53
Window title.
Definition: FXTopWindow.h:41
Border.
Definition: FXTopWindow.h:45
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:386
Application Object.
Definition: FXApp.h:158
Close button.
Definition: FXTopWindow.h:44
FXString title(const FXString &file)
Return file title, i.e. document name only.
#define FXDECLARE_ABSTRACT(classname)
Macro to set up abstract class declaration.
Definition: FXObject.h:114
Minimize button.
Definition: FXTopWindow.h:42
Place it at the default size and location.
Definition: FXTopWindow.h:60
Place it centered on its owner.
Definition: FXTopWindow.h:63
FXString name(const FXString &file)
Return name and extension part of the path name.
Definition: FXTopWindow.h:50
Place it under the cursor position.
Definition: FXTopWindow.h:62
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
The Shell widget is used as the base class for top level windows, i.e.
Definition: FXShell.h:38
Abstract base class for all top-level windows.
Definition: FXTopWindow.h:106
A tool bar widget can be docked in a dock site; it automatically adjusts its orientation based on the...
Definition: FXToolBar.h:42
Place window to be fully visible.
Definition: FXTopWindow.h:61
#define FALSE
Definition: fxdefs.h:35
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
Window can become larger.
Definition: FXTopWindow.h:47
Borderless window.
Definition: FXTopWindow.h:40
Maximize button.
Definition: FXTopWindow.h:43
Resize handles.
Definition: FXTopWindow.h:48
Place it centered on the screen.
Definition: FXTopWindow.h:64
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33
Place it maximized to the screen size.
Definition: FXTopWindow.h:65
Window menu.
Definition: FXTopWindow.h:49

Copyright © 1997-2005 Jeroen van der Zijp