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