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

FXTopWindow.h

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

Copyright © 1997-2010 Jeroen van der Zijp