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

FXMDIChild.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *          M u l t i p l e   D o c u m e n t   C h i l d   W i n d o w          *
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: FXMDIChild.h,v 1.53 2009/01/06 13:07:25 fox Exp $                        *
00022 ********************************************************************************/
00023 #ifndef FXMDICHILD_H
00024 #define FXMDICHILD_H
00025 
00026 #ifndef FXCOMPOSITE_H
00027 #include "FXComposite.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 class FXMDIClient;
00034 class FXMenuButton;
00035 class FXButton;
00036 class FXFont;
00037 
00038 
00039 /// MDI Child Window styles
00040 enum {
00041   MDI_NORMAL    = 0,                /// Normal display mode
00042   MDI_MAXIMIZED = 0x00001000,       /// Window appears maximized
00043   MDI_MINIMIZED = 0x00002000,       /// Window is iconified or minimized
00044   MDI_TRACKING  = 0x00004000        /// Track continuously during dragging
00045   };
00046 
00047 
00048 
00049 /**
00050 * The MDI child window contains the application work area in a Multiple Document
00051 * Interface application.  GUI Controls are connected to the MDI child via delegation
00052 * through the MDI client, which forwards messages it receives to the active MDI child.
00053 * The MDI child itself tries to further delegate messages to its single content window,
00054 * and if not handled there, to its target object.
00055 * When the MDI child is maximized, it sends a SEL_MAXIMIZE message; when the MDI
00056 * child is minimized, it sends a SEL_MINIMIZE message.  When it is restored, it
00057 * sends a SEL_RESTORE message to its target.
00058 * The MDI child also notifies its target when it becomes the active MDI child, via the
00059 * SEL_SELECTED message.  The void* in the SEL_SELECTED message refers to the previously
00060 * active MDI child, if any.
00061 * When an MDI child ceases to be the active window, a SEL_DESELECTED message
00062 * is sent to its target, and the void* in the SEL_DESELECTED message refers to the newly
00063 * activated MDI child, if any.
00064 * Thus, interception of SEL_SELECTED and SEL_DESELECTED allows the target object to determine
00065 * whether the user switched between MDI windows of the same document (target) or merely between
00066 * two MDI windows belonging to the same document.
00067 * When the MDI child is closed, it first sends a SEL_DESELECTED to its target to
00068 * notify it that it is no longer the active window; next, it sends a SEL_CLOSE message
00069 * to its target to allow the target to clean up (for example, destroy the document
00070 * if this was the last window of the document).
00071 * The target can prevent the MDI child window from being closed by returning 1 from
00072 * the SEL_CLOSE message handler (objection).  If the target returns 0 or does not
00073 * handle the SEL_CLOSE message, the MDI child will be closed.
00074 * If the MDI child windows was not closed, the child window will be reselected
00075 * as the currently active MDI child widget, and a SEL_SELECTED will be sent to
00076 * its target to notify it of this fact.
00077 * The SEL_UPDATE message can be used to modify the MDI child's title (via
00078 * ID_SETSTRINGVALUE), and window icon (via ID_SETICONVALUE).
00079 */
00080 class FXAPI FXMDIChild : public FXComposite {
00081   FXDECLARE(FXMDIChild)
00082 protected:
00083   FXString      title;                  // Window title
00084   FXMenuButton *windowbtn;              // Window button
00085   FXButton     *minimizebtn;            // Minimize button
00086   FXButton     *restorebtn;             // Restore button
00087   FXButton     *maximizebtn;            // Maximize buton
00088   FXButton     *deletebtn;              // Close button
00089   FXFont       *font;                   // Title font
00090   FXColor       baseColor;              // Colors
00091   FXColor       hiliteColor;
00092   FXColor       shadowColor;
00093   FXColor       borderColor;
00094   FXColor       titleColor;
00095   FXColor       titleBackColor;
00096   FXint         iconPosX;               // Saved icon position
00097   FXint         iconPosY;
00098   FXint         iconWidth;
00099   FXint         iconHeight;
00100   FXint         normalPosX;             // Saved normal position
00101   FXint         normalPosY;
00102   FXint         normalWidth;
00103   FXint         normalHeight;
00104   FXint         spotx;                  // Grab-spot of mouse on window
00105   FXint         spoty;
00106   FXint         xoff;                   // Mouse offset to add
00107   FXint         yoff;
00108   FXint         newx;                   // New location of window
00109   FXint         newy;
00110   FXint         neww;
00111   FXint         newh;
00112   FXuchar       mode;                   // Dragging mode
00113 protected:
00114   FXMDIChild();
00115   void drawRubberBox(FXint x,FXint y,FXint w,FXint h);
00116   void animateRectangles(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh);
00117   FXuchar where(FXint x,FXint y) const;
00118   void changeCursor(FXuchar which);
00119 protected:
00120   enum {
00121     DRAG_NONE        = 0,
00122     DRAG_TOP         = 1,
00123     DRAG_BOTTOM      = 2,
00124     DRAG_LEFT        = 4,
00125     DRAG_RIGHT       = 8,
00126     DRAG_TOPLEFT     = (DRAG_TOP|DRAG_LEFT),
00127     DRAG_TOPRIGHT    = (DRAG_TOP|DRAG_RIGHT),
00128     DRAG_BOTTOMLEFT  = (DRAG_BOTTOM|DRAG_LEFT),
00129     DRAG_BOTTOMRIGHT = (DRAG_BOTTOM|DRAG_RIGHT),
00130     DRAG_INVERTED    = 16,
00131     DRAG_TITLE       = 32
00132     };
00133 private:
00134   FXMDIChild(const FXMDIChild&);
00135   FXMDIChild &operator=(const FXMDIChild&);
00136 public:
00137   long onPaint(FXObject*,FXSelector,void*);
00138   long onEnter(FXObject*,FXSelector,void*);
00139   long onLeave(FXObject*,FXSelector,void*);
00140   long onFocusSelf(FXObject*,FXSelector,void*);
00141   long onFocusIn(FXObject*,FXSelector,void*);
00142   long onFocusOut(FXObject*,FXSelector,void*);
00143   long onRightBtnPress(FXObject*,FXSelector,void*);
00144   long onRightBtnRelease(FXObject*,FXSelector,void*);
00145   long onLeftBtnPress(FXObject*,FXSelector,void*);
00146   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00147   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00148   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00149   long onMotion(FXObject*,FXSelector,void*);
00150   long onSelected(FXObject*,FXSelector,void*);
00151   long onDeselected(FXObject*,FXSelector,void*);
00152   long onCmdClose(FXObject*,FXSelector,void*);
00153   long onUpdClose(FXObject*,FXSelector,void*);
00154   long onCmdRestore(FXObject*,FXSelector,void*);
00155   long onUpdRestore(FXObject*,FXSelector,void*);
00156   long onUpdMaximize(FXObject*,FXSelector,void*);
00157   long onUpdMinimize(FXObject*,FXSelector,void*);
00158   long onCmdMaximize(FXObject*,FXSelector,void*);
00159   long onCmdMinimize(FXObject*,FXSelector,void*);
00160   long onUpdWindow(FXObject*,FXSelector,void*);
00161   long onUpdMenuRestore(FXObject*,FXSelector,void*);
00162   long onUpdMenuMinimize(FXObject*,FXSelector,void*);
00163   long onUpdMenuClose(FXObject*,FXSelector,void*);
00164   long onUpdMenuWindow(FXObject*,FXSelector,void*);
00165   long onCmdSetStringValue(FXObject*,FXSelector,void*);
00166   long onCmdGetStringValue(FXObject*,FXSelector,void*);
00167   long onCmdSetIconValue(FXObject*,FXSelector,void*);
00168   long onCmdGetIconValue(FXObject*,FXSelector,void*);
00169   virtual long onDefault(FXObject*,FXSelector,void*);
00170 public:
00171 
00172   /// Construct MDI Child window with given name and icon
00173   FXMDIChild(FXMDIClient* p,const FXString& name,FXIcon* ic=NULL,FXPopup* pup=NULL,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00174 
00175   /// Create window
00176   virtual void create();
00177 
00178   /// Detach window
00179   virtual void detach();
00180 
00181   /// Perform layout
00182   virtual void layout();
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   /// Move the focus to this window
00191   virtual void setFocus();
00192 
00193   /// MDI Child can receive focus
00194   virtual FXbool canFocus() const;
00195 
00196   /// Move this window to the specified position in the parent's coordinates
00197   virtual void move(FXint x,FXint y);
00198 
00199   /// Resize this window to the specified width and height
00200   virtual void resize(FXint w,FXint h);
00201 
00202   /// Move and resize this window in the parent's coordinates
00203   virtual void position(FXint x,FXint y,FXint w,FXint h);
00204 
00205   /// Change normal (restored) position
00206   void setNormalX(FXint x){ normalPosX=x; }
00207   void setNormalY(FXint y){ normalPosY=y; }
00208   void setNormalWidth(FXint w){ normalWidth=w; }
00209   void setNormalHeight(FXint h){ normalHeight=h; }
00210 
00211   /// Return normal (restored) position
00212   FXint getNormalX() const { return normalPosX; }
00213   FXint getNormalY() const { return normalPosY; }
00214   FXint getNormalWidth() const { return normalWidth; }
00215   FXint getNormalHeight() const { return normalHeight; }
00216 
00217   /// Change iconified position
00218   void setIconX(FXint x){ iconPosX=x; }
00219   void setIconY(FXint y){ iconPosY=y; }
00220   void setIconWidth(FXint w){ iconWidth=w; }
00221   void setIconHeight(FXint h){ iconHeight=h; }
00222 
00223   /// Return iconified position
00224   FXint getIconX() const { return iconPosX; }
00225   FXint getIconY() const { return iconPosY; }
00226   FXint getIconWidth() const { return iconWidth; }
00227   FXint getIconHeight() const { return iconHeight; }
00228 
00229   /// Return content window
00230   FXWindow *contentWindow() const;
00231 
00232   /// Change MDI Child's title
00233   void setTitle(const FXString& name);
00234 
00235   /// Get current title
00236   FXString getTitle() const { return title; }
00237 
00238   /// Get colors
00239   FXColor getHiliteColor() const { return hiliteColor; }
00240   FXColor getShadowColor() const { return shadowColor; }
00241   FXColor getBaseColor() const { return baseColor; }
00242   FXColor getBorderColor() const { return borderColor; }
00243   FXColor getTitleColor () const { return titleColor; }
00244   FXColor getTitleBackColor() const { return titleBackColor; }
00245 
00246   /// Change colors
00247   void setHiliteColor(FXColor clr);
00248   void setShadowColor(FXColor clr);
00249   void setBaseColor(FXColor clr);
00250   void setBorderColor(FXColor clr);
00251   void setTitleColor(FXColor clr);
00252   void setTitleBackColor(FXColor clr);
00253 
00254   /// Restore MDI window to normal, return true if restored
00255   virtual FXbool restore(FXbool notify=false);
00256 
00257   /// Maximize MDI window, return true if maximized
00258   virtual FXbool maximize(FXbool notify=false);
00259 
00260   /// Minimize/iconify MDI window, return true if minimized
00261   virtual FXbool minimize(FXbool notify=false);
00262 
00263   /// Close MDI window, return true if actually closed
00264   virtual FXbool close(FXbool notify=false);
00265 
00266   /// Return true if maximized
00267   FXbool isMaximized() const;
00268 
00269   /// Return true if minimized
00270   FXbool isMinimized() const;
00271 
00272   /// Get window icon
00273   FXIcon *getIcon() const;
00274 
00275   /// Set window icon
00276   void setIcon(FXIcon* icon);
00277 
00278   /// Get window menu
00279   FXPopup* getMenu() const;
00280 
00281   /// Set window menu
00282   void setMenu(FXPopup* menu);
00283 
00284   /// Set tracking instead of just outline
00285   void setTracking(FXbool tracking=true);
00286 
00287   /// Return true if tracking
00288   FXbool getTracking() const;
00289 
00290   /// Set title font
00291   void setFont(FXFont *fnt);
00292 
00293   /// Get title font
00294   FXFont* getFont() const { return font; }
00295 
00296   /// Save to stream
00297   virtual void save(FXStream& store) const;
00298 
00299   /// Load from stream
00300   virtual void load(FXStream& store);
00301 
00302   /// Destroy
00303   virtual ~FXMDIChild();
00304   };
00305 
00306 }
00307 
00308 #endif

Copyright © 1997-2009 Jeroen van der Zijp