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,2004 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.53 2004/02/08 17:17:34 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 receiving a SEL_UPDATE, the target can update the title string
00079 * of the window, so that the title of the window reflects the name
00080 * of the document, for example.
00081 * For convenience, TopWindow provides the same layout behavior as
00082 * the Packer widget, as well as docking and undocking of toolbars.
00083 * TopWindows can be owned by other windows, or be free-floating.
00084 * Owned TopWindows will usually remain stacked on top of the owner
00085 * windows. The lifetime of an owned window should not exceed that of
00086 * the owner.
00087 */
00088 class FXAPI FXTopWindow : public FXShell {
00089   FXDECLARE_ABSTRACT(FXTopWindow)
00090 protected:
00091   FXString  title;                    // Window title
00092   FXIcon   *icon;                     // Window icon (big)
00093   FXIcon   *miniIcon;                 // Window icon (small)
00094   FXint     padtop;                   // Top margin
00095   FXint     padbottom;                // Bottom margin
00096   FXint     padleft;                  // Left margin
00097   FXint     padright;                 // Right margin
00098   FXint     hspacing;                 // Horizontal child spacing
00099   FXint     vspacing;                 // Vertical child spacing
00100   FXint     offx;
00101   FXint     offy;
00102 protected:
00103   FXTopWindow(){}
00104   void settitle();
00105   void seticons();
00106   void setdecorations();
00107   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);
00108   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);
00109 private:
00110   FXTopWindow(const FXTopWindow&);
00111   FXTopWindow& operator=(const FXTopWindow&);
00112 #ifdef WIN32
00113   virtual const char* GetClass() const;
00114   static void* makeicon(FXIcon* icon);
00115 #endif
00116 public:
00117   long onFocusUp(FXObject*,FXSelector,void*);
00118   long onFocusDown(FXObject*,FXSelector,void*);
00119   long onFocusLeft(FXObject*,FXSelector,void*);
00120   long onFocusRight(FXObject*,FXSelector,void*);
00121   long onCmdMaximize(FXObject*,FXSelector,void*);
00122   long onCmdMinimize(FXObject*,FXSelector,void*);
00123   long onCmdRestore(FXObject*,FXSelector,void*);
00124   long onCmdClose(FXObject*,FXSelector,void*);
00125   long onCmdSetStringValue(FXObject*,FXSelector,void*);
00126   long onCmdGetStringValue(FXObject*,FXSelector,void*);
00127   long onCmdSetIconValue(FXObject*,FXSelector,void*);
00128   long onCmdGetIconValue(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   /// Perform layout
00147   virtual void layout();
00148 
00149   /// Move the focus to this window
00150   virtual void setFocus();
00151 
00152   /// Remove the focus from this window
00153   virtual void killFocus();
00154 
00155   /// Show this window
00156   virtual void show();
00157 
00158   /// Hide this window
00159   virtual void hide();
00160 
00161   /// Show this window with given placement
00162   virtual void show(FXuint placement);
00163 
00164   /// Position the window based on placement
00165   void place(FXuint placement);
00166 
00167   /// Return the default width of this window
00168   virtual FXint getDefaultWidth();
00169 
00170   /// Return the default height of this window
00171   virtual FXint getDefaultHeight();
00172 
00173   /// Move this window to the specified position in the parent's coordinates
00174   virtual void move(FXint x,FXint y);
00175 
00176   /// Resize this window to the specified width and height
00177   virtual void resize(FXint w,FXint h);
00178 
00179   /// Move and resize this window in the parent's coordinates
00180   virtual void position(FXint x,FXint y,FXint w,FXint h);
00181 
00182   /// Maximize window, return TRUE if maximized
00183   virtual FXbool maximize(FXbool notify=FALSE);
00184 
00185   /// Minimize or iconify window, return TRUE if minimized
00186   virtual FXbool minimize(FXbool notify=FALSE);
00187 
00188   /// Restore window to normal, return TRUE if restored
00189   virtual FXbool restore(FXbool notify=FALSE);
00190 
00191   /// Close the window, return TRUE if actually closed
00192   virtual FXbool close(FXbool notify=FALSE);
00193 
00194   /// Return TRUE if maximized
00195   FXbool isMaximized() const;
00196 
00197   /// Return TRUE if minimized
00198   FXbool isMinimized() const;
00199 
00200   /// Change window title
00201   void setTitle(const FXString& name);
00202 
00203   /// Return window title
00204   FXString getTitle() const { return title; }
00205 
00206   /// Change top padding
00207   void setPadTop(FXint pt);
00208 
00209   /// Get top interior padding
00210   FXint getPadTop() const { return padtop; }
00211 
00212   /// Change bottom padding
00213   void setPadBottom(FXint pb);
00214 
00215   /// Get bottom interior padding
00216   FXint getPadBottom() const { return padbottom; }
00217 
00218   /// Change left padding
00219   void setPadLeft(FXint pl);
00220 
00221   /// Get left interior padding
00222   FXint getPadLeft() const { return padleft; }
00223 
00224   /// Change right padding
00225   void setPadRight(FXint pr);
00226 
00227   /// Get right interior padding
00228   FXint getPadRight() const { return padright; }
00229 
00230   /// Return horizontal spacing between children
00231   FXint getHSpacing() const { return hspacing; }
00232 
00233   /// Return vertical spacing between children
00234   FXint getVSpacing() const { return vspacing; }
00235 
00236   /// Change horizontal spacing between children
00237   void setHSpacing(FXint hs);
00238 
00239   /// Change vertical spacing between children
00240   void setVSpacing(FXint vs);
00241 
00242   /// Change packing hints for children
00243   void setPackingHints(FXuint ph);
00244 
00245   /// Return packing hints for children
00246   FXuint getPackingHints() const;
00247 
00248   /// Change title and border decorations
00249   void setDecorations(FXuint decorations);
00250 
00251   /// Return current title and border decorations
00252   FXuint getDecorations() const;
00253 
00254   /// Return window icon
00255   FXIcon* getIcon() const { return icon; }
00256 
00257   /// Change window icon
00258   void setIcon(FXIcon* ic);
00259 
00260   /// Return window mini (title) icon
00261   FXIcon* getMiniIcon() const { return miniIcon; }
00262 
00263   /// Change window mini (title) icon
00264   void setMiniIcon(FXIcon *ic);
00265 
00266   /// Save to stream
00267   virtual void save(FXStream& store) const;
00268 
00269   /// Load from stream
00270   virtual void load(FXStream& store);
00271 
00272   /// Destructor
00273   virtual ~FXTopWindow();
00274   };
00275 
00276 }
00277 
00278 #endif

Copyright © 1997-2004 Jeroen van der Zijp