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

FXTopWindow.h

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,2002 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.47 2002/09/30 13:06:56 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 
00064 
00065 
00066 /**
00067 * Abstract base class for all top-level windows.
00068 * TopWindows are usually managed by a Window Manager under X11 and
00069 * therefore borders and window-menus and other decorations like resize-
00070 * handles are subject to the Window Manager's interpretation of the
00071 * decoration hints.
00072 * When a TopWindow is closed, it sends a SEL_CLOSE message to its
00073 * target.  The target should return 0 in response to this message if
00074 * there is no objection to proceed with the closing of the window, and
00075 * return 1 otherwise.  After the SEL_CLOSE message has been sent and
00076 * no objection was raised, the window will delete itself.
00077 * When receiving a SEL_UPDATE, the target can update the title string
00078 * of the window, so that the title of the window reflects the name
00079 * of the document, for example.
00080 * For convenience, TopWindow provides the same layout behavior as
00081 * the Packer widget, as well as docking and undocking of toolbars.
00082 * TopWindows can be owned by other windows, or be free-floating.
00083 * Owned TopWindows will usually remain stacked on top of the owner
00084 * windows; also, the lifetime of an owned window should not
00085 * exceed that of the owner.
00086 * The application will receive an ID_QUIT message when the last
00087 * MainWindow is hidden, therefore normally terminating the application.
00088 */
00089 class FXAPI FXTopWindow : public FXShell {
00090   FXDECLARE_ABSTRACT(FXTopWindow)
00091 protected:
00092   FXString  title;                    // Window title
00093   FXIcon   *icon;                     // Window icon (big)
00094   FXIcon   *miniIcon;                 // Window icon (small)
00095   FXint     padtop;                   // Top margin
00096   FXint     padbottom;                // Bottom margin
00097   FXint     padleft;                  // Left margin
00098   FXint     padright;                 // Right margin
00099   FXint     hspacing;                 // Horizontal child spacing
00100   FXint     vspacing;                 // Vertical child spacing
00101   FXint     offx;
00102   FXint     offy;
00103 protected:
00104   FXTopWindow(){}
00105   void settitle();
00106   void seticons();
00107   void setdecorations();
00108   virtual void layout();
00109   FXTopWindow(FXApp* a,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);
00110   FXTopWindow(FXWindow* owner,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);
00111 private:
00112   FXTopWindow(const FXTopWindow&);
00113   FXTopWindow& operator=(const FXTopWindow&);
00114 #ifdef WIN32
00115   virtual const char* GetClass() const;
00116   static void* makeicon(FXIcon* icon);
00117 #endif
00118 public:
00119   long onFocusUp(FXObject*,FXSelector,void*);
00120   long onFocusDown(FXObject*,FXSelector,void*);
00121   long onFocusLeft(FXObject*,FXSelector,void*);
00122   long onFocusRight(FXObject*,FXSelector,void*);
00123   long onCmdSetStringValue(FXObject*,FXSelector,void*);
00124   long onCmdGetStringValue(FXObject*,FXSelector,void*);
00125   long onCmdMaximize(FXObject*,FXSelector,void*);
00126   long onCmdMinimize(FXObject*,FXSelector,void*);
00127   long onCmdRestore(FXObject*,FXSelector,void*);
00128   long onCmdClose(FXObject*,FXSelector,void*);
00129 public:
00130   enum {
00131     ID_MAXIMIZE=FXShell::ID_LAST,       /// Maximize the window
00132     ID_MINIMIZE,                        /// Minimize the window
00133     ID_RESTORE,                         /// Restore the window
00134     ID_CLOSE,                           /// Close the window
00135     ID_QUERY_DOCK,                      /// Toolbar asks to dock
00136     ID_LAST
00137     };
00138 public:
00139 
00140   /// Create server-side resources
00141   virtual void create();
00142 
00143   /// Detach the server-side resources for this window
00144   virtual void detach();
00145 
00146   /// Move the focus to this window
00147   virtual void setFocus();
00148 
00149   /// Remove the focus from this window
00150   virtual void killFocus();
00151 
00152   /// Show this window
00153   virtual void show();
00154 
00155   /// Hide this window
00156   virtual void hide();
00157 
00158   /// Show this window with given placement
00159   virtual void show(FXuint placement);
00160 
00161   /// Position the window based on placement
00162   void place(FXuint placement);
00163 
00164   /// Return the default width of this window
00165   virtual FXint getDefaultWidth();
00166 
00167   /// Return the default height of this window
00168   virtual FXint getDefaultHeight();
00169 
00170   /// Move this window to the specified position in the parent's coordinates
00171   virtual void move(FXint x,FXint y);
00172 
00173   /// Resize this window to the specified width and height
00174   virtual void resize(FXint w,FXint h);
00175 
00176   /// Move and resize this window in the parent's coordinates
00177   virtual void position(FXint x,FXint y,FXint w,FXint h);
00178 
00179   /// Maximize window, return TRUE if maximized
00180   virtual FXbool maximize(FXbool notify=FALSE);
00181 
00182   /// Minimize or iconify window, return TRUE if minimized
00183   virtual FXbool minimize(FXbool notify=FALSE);
00184 
00185   /// Restore window to normal, return TRUE if restored
00186   virtual FXbool restore(FXbool notify=FALSE);
00187 
00188   /// Close the window, return TRUE if actually closed
00189   virtual FXbool close(FXbool notify=FALSE);
00190 
00191   /// Return TRUE if maximized
00192   FXbool isMaximized() const;
00193 
00194   /// Return TRUE if minimized
00195   FXbool isMinimized() const;
00196 
00197   /// Change window title
00198   void setTitle(const FXString& name);
00199 
00200   /// Return window title
00201   const FXString& getTitle() const { return title; }
00202 
00203   /// Change top padding
00204   void setPadTop(FXint pt);
00205 
00206   /// Get top interior padding
00207   FXint getPadTop() const { return padtop; }
00208 
00209   /// Change bottom padding
00210   void setPadBottom(FXint pb);
00211 
00212   /// Get bottom interior padding
00213   FXint getPadBottom() const { return padbottom; }
00214 
00215   /// Change left padding
00216   void setPadLeft(FXint pl);
00217 
00218   /// Get left interior padding
00219   FXint getPadLeft() const { return padleft; }
00220 
00221   /// Change right padding
00222   void setPadRight(FXint pr);
00223 
00224   /// Get right interior padding
00225   FXint getPadRight() const { return padright; }
00226 
00227   /// Return horizontal spacing between children
00228   FXint getHSpacing() const { return hspacing; }
00229 
00230   /// Return vertical spacing between children
00231   FXint getVSpacing() const { return vspacing; }
00232 
00233   /// Change horizontal spacing between children
00234   void setHSpacing(FXint hs);
00235 
00236   /// Change vertical spacing between children
00237   void setVSpacing(FXint vs);
00238 
00239   /// Change packing hints for children
00240   void setPackingHints(FXuint ph);
00241 
00242   /// Return packing hints for children
00243   FXuint getPackingHints() const;
00244 
00245   /// Change title and border decorations
00246   void setDecorations(FXuint decorations);
00247 
00248   /// Return current title and border decorations
00249   FXuint getDecorations() const;
00250 
00251   /// Return window icon
00252   FXIcon* getIcon() const { return icon; }
00253 
00254   /// Change window icon
00255   void setIcon(FXIcon* ic);
00256 
00257   /// Return window mini (title) icon
00258   FXIcon* getMiniIcon() const { return miniIcon; }
00259 
00260   /// Change window mini (title) icon
00261   void setMiniIcon(FXIcon *ic);
00262 
00263   /// Save to stream
00264   virtual void save(FXStream& store) const;
00265 
00266   /// Load from stream
00267   virtual void load(FXStream& store);
00268 
00269   /// Destructor
00270   virtual ~FXTopWindow();
00271   };
00272 
00273 }
00274 
00275 #endif