![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * T o p - L e v e l W i n d o w W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1998,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXTopWindow.h,v 1.77 2009/01/06 13:07:28 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXTOPWINDOW_H 00024 #define FXTOPWINDOW_H 00025 00026 #ifndef FXSHELL_H 00027 #include "FXShell.h" 00028 #endif 00029 00030 00031 namespace FX { 00032 00033 00034 /// Title and border decorations 00035 enum { 00036 DECOR_NONE = 0, /// Borderless window 00037 DECOR_TITLE = 0x00020000, /// Window title 00038 DECOR_MINIMIZE = 0x00040000, /// Minimize button 00039 DECOR_MAXIMIZE = 0x00080000, /// Maximize button 00040 DECOR_CLOSE = 0x00100000, /// Close button 00041 DECOR_BORDER = 0x00200000, /// Border 00042 DECOR_SHRINKABLE = 0x00400000, /// Window can become smaller 00043 DECOR_STRETCHABLE = 0x00800000, /// Window can become larger 00044 DECOR_RESIZE = DECOR_SHRINKABLE|DECOR_STRETCHABLE, /// Resize handles 00045 DECOR_MENU = 0x01000000, /// Window menu 00046 DECOR_ALL = (DECOR_TITLE|DECOR_MINIMIZE|DECOR_MAXIMIZE|DECOR_CLOSE|DECOR_BORDER|DECOR_SHRINKABLE|DECOR_STRETCHABLE|DECOR_MENU) 00047 }; 00048 00049 00050 /// Initial window placement 00051 enum { 00052 PLACEMENT_DEFAULT, /// Place it at the default size and location 00053 PLACEMENT_VISIBLE, /// Place window to be fully visible 00054 PLACEMENT_CURSOR, /// Place it under the cursor position 00055 PLACEMENT_OWNER, /// Place it centered on its owner 00056 PLACEMENT_SCREEN, /// Place it centered on the screen 00057 PLACEMENT_MAXIMIZED /// Place it maximized to the screen size 00058 }; 00059 00060 00061 /// Special stacking orders 00062 enum { 00063 STACK_NORMAL, /// Stack normally (default) 00064 STACK_BOTTOM, /// Stack below other windows 00065 STACK_TOP /// Stack above other windows 00066 }; 00067 00068 00069 class FXToolBar; 00070 class FXIcon; 00071 00072 00073 /** 00074 * Abstract base class for all top-level windows. 00075 * TopWindows are usually managed by a Window Manager under X11 and 00076 * therefore borders and window-menus and other decorations like resize- 00077 * handles are subject to the Window Manager's interpretation of the 00078 * decoration hints. 00079 * When a TopWindow is closed, it sends a SEL_CLOSE message to its 00080 * target. The target should return 0 in response to this message if 00081 * there is no objection to proceed with the closing of the window, and 00082 * return 1 otherwise. After the SEL_CLOSE message has been sent and 00083 * no objection was raised, the window will delete itself. 00084 * When the session is closed, the window will send a SEL_SESSION_NOTIFY 00085 * message to its target, allowing the application to write any unsaved 00086 * data to the disk. If the target returns 0, then the system will proceed 00087 * to close the session. Subsequently a SEL_SESSION_CLOSED will be received 00088 * which causes the window to be closed with prejudice by calling the 00089 * function close(false). 00090 * When receiving a SEL_UPDATE, the target can update the title string 00091 * of the window, so that the title of the window reflects the name 00092 * of the document, for example. 00093 * For convenience, TopWindow provides the same layout behavior as 00094 * the Packer widget, as well as docking and undocking of toolbars. 00095 * TopWindows can be owned by other windows, or be free-floating. 00096 * Owned TopWindows will usually remain stacked on top of the owner 00097 * windows. The lifetime of an owned window should not exceed that of 00098 * the owner. 00099 */ 00100 class FXAPI FXTopWindow : public FXShell { 00101 FXDECLARE_ABSTRACT(FXTopWindow) 00102 protected: 00103 FXString title; // Window title 00104 FXIcon *icon; // Window icon (big) 00105 FXIcon *miniIcon; // Window icon (small) 00106 FXint padtop; // Top margin 00107 FXint padbottom; // Bottom margin 00108 FXint padleft; // Left margin 00109 FXint padright; // Right margin 00110 FXint hspacing; // Horizontal child spacing 00111 FXint vspacing; // Vertical child spacing 00112 protected: 00113 FXTopWindow(); 00114 void settitle(); 00115 void seticons(); 00116 void setdecorations(); 00117 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); 00118 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); 00119 private: 00120 FXTopWindow(const FXTopWindow&); 00121 FXTopWindow& operator=(const FXTopWindow&); 00122 #ifdef WIN32 00123 virtual const void* GetClass() const; 00124 #endif 00125 public: 00126 long onFocusUp(FXObject*,FXSelector,void*); 00127 long onFocusDown(FXObject*,FXSelector,void*); 00128 long onFocusLeft(FXObject*,FXSelector,void*); 00129 long onFocusRight(FXObject*,FXSelector,void*); 00130 long onSessionNotify(FXObject*,FXSelector,void*); 00131 long onSessionClosed(FXObject*,FXSelector,void*); 00132 long onRestore(FXObject*,FXSelector,void*); 00133 long onMaximize(FXObject*,FXSelector,void*); 00134 long onMinimize(FXObject*,FXSelector,void*); 00135 long onCmdRestore(FXObject*,FXSelector,void*); 00136 long onCmdMaximize(FXObject*,FXSelector,void*); 00137 long onCmdMinimize(FXObject*,FXSelector,void*); 00138 long onCmdFullScreen(FXObject*,FXSelector,void*); 00139 long onCmdClose(FXObject*,FXSelector,void*); 00140 long onCmdSetStringValue(FXObject*,FXSelector,void*); 00141 long onCmdGetStringValue(FXObject*,FXSelector,void*); 00142 long onCmdSetIconValue(FXObject*,FXSelector,void*); 00143 long onCmdGetIconValue(FXObject*,FXSelector,void*); 00144 public: 00145 enum { 00146 ID_RESTORE=FXShell::ID_LAST, /// Restore the window 00147 ID_MAXIMIZE, /// Maximize the window 00148 ID_MINIMIZE, /// Minimize the window 00149 ID_FULLSCREEN, /// Make the window full screen 00150 ID_CLOSE, /// Close the window 00151 ID_QUERY_DOCK, /// Toolbar asks to dock 00152 ID_LAST 00153 }; 00154 public: 00155 00156 /// Create server-side resources 00157 virtual void create(); 00158 00159 /// Detach the server-side resources for this window 00160 virtual void detach(); 00161 00162 /// Destroy the server-side resources for this window 00163 virtual void destroy(); 00164 00165 /// Perform layout 00166 virtual void layout(); 00167 00168 /// Move the focus to this window 00169 virtual void setFocus(); 00170 00171 /// Remove the focus from this window 00172 virtual void killFocus(); 00173 00174 /// Show this window 00175 virtual void show(); 00176 00177 /// Hide this window 00178 virtual void hide(); 00179 00180 /// Show this window with given placement 00181 virtual void show(FXuint placement); 00182 00183 /// Position the window based on placement 00184 void place(FXuint placement); 00185 00186 /// Return the default width of this window 00187 virtual FXint getDefaultWidth(); 00188 00189 /// Return the default height of this window 00190 virtual FXint getDefaultHeight(); 00191 00192 /// Obtain border sizes added to our window by the window manager 00193 FXbool getWMBorders(FXint& left,FXint& right,FXint& top,FXint& bottom); 00194 00195 /// Raise this window to the top of the stacking order 00196 virtual void raise(); 00197 00198 /// Lower this window to the bottom of the stacking order 00199 virtual void lower(); 00200 00201 /// Move this window to the specified position in the parent's coordinates 00202 virtual void move(FXint x,FXint y); 00203 00204 /// Resize this window to the specified width and height 00205 virtual void resize(FXint w,FXint h); 00206 00207 /// Move and resize this window in the parent's coordinates 00208 virtual void position(FXint x,FXint y,FXint w,FXint h); 00209 00210 /// Flash the window to get user's attention 00211 virtual void flash(FXbool yes); 00212 00213 /// Restore window to normal, return true if restored 00214 virtual FXbool restore(FXbool notify=false); 00215 00216 /// Maximize window, return true if maximized 00217 virtual FXbool maximize(FXbool notify=false); 00218 00219 /// Minimize or iconify window, return true if minimized 00220 virtual FXbool minimize(FXbool notify=false); 00221 00222 /// Make window full screen, return true if success 00223 virtual FXbool fullScreen(FXbool notify=false); 00224 00225 /// Special stacking order level 00226 virtual FXbool stackingOrder(FXuint order); 00227 00228 /** 00229 * Close the window, return true if actually closed. If notify=true, the target 00230 * will receive a SEL_CLOSE message to determine if it is OK to close the window. 00231 * If the target ignores the SEL_CLOSE message or returns 0, the window will 00232 * be closed, and subsequently deleted. When the last main window has been 00233 * closed, the application will receive an ID_QUIT message and will be closed. 00234 */ 00235 virtual FXbool close(FXbool notify=false); 00236 00237 /// Return true if maximized 00238 FXbool isMaximized() const; 00239 00240 /// Return true if minimized 00241 FXbool isMinimized() const; 00242 00243 /// Return true if full screen 00244 FXbool isFullScreen() const; 00245 00246 /// Change window title 00247 void setTitle(const FXString& name); 00248 00249 /// Return window title 00250 FXString getTitle() const { return title; } 00251 00252 /// Change top padding 00253 void setPadTop(FXint pt); 00254 00255 /// Get top interior padding 00256 FXint getPadTop() const { return padtop; } 00257 00258 /// Change bottom padding 00259 void setPadBottom(FXint pb); 00260 00261 /// Get bottom interior padding 00262 FXint getPadBottom() const { return padbottom; } 00263 00264 /// Change left padding 00265 void setPadLeft(FXint pl); 00266 00267 /// Get left interior padding 00268 FXint getPadLeft() const { return padleft; } 00269 00270 /// Change right padding 00271 void setPadRight(FXint pr); 00272 00273 /// Get right interior padding 00274 FXint getPadRight() const { return padright; } 00275 00276 /// Return horizontal spacing between children 00277 FXint getHSpacing() const { return hspacing; } 00278 00279 /// Return vertical spacing between children 00280 FXint getVSpacing() const { return vspacing; } 00281 00282 /// Change horizontal spacing between children 00283 void setHSpacing(FXint hs); 00284 00285 /// Change vertical spacing between children 00286 void setVSpacing(FXint vs); 00287 00288 /// Change packing hints for children 00289 void setPackingHints(FXuint ph); 00290 00291 /// Return packing hints for children 00292 FXuint getPackingHints() const; 00293 00294 /// Change title and border decorations 00295 void setDecorations(FXuint decorations); 00296 00297 /// Return current title and border decorations 00298 FXuint getDecorations() const; 00299 00300 /// Return window icon 00301 FXIcon* getIcon() const { return icon; } 00302 00303 /// Change window icon 00304 void setIcon(FXIcon* ic); 00305 00306 /// Return window mini (title) icon 00307 FXIcon* getMiniIcon() const { return miniIcon; } 00308 00309 /// Change window mini (title) icon 00310 void setMiniIcon(FXIcon *ic); 00311 00312 /// Save to stream 00313 virtual void save(FXStream& store) const; 00314 00315 /// Load from stream 00316 virtual void load(FXStream& store); 00317 00318 /// Destructor 00319 virtual ~FXTopWindow(); 00320 }; 00321 00322 } 00323 00324 #endif
![]() |