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

FXMDIChild.h

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,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: FXMDIChild.h,v 1.38 2004/02/08 17:17:33 fox Exp $                        *
00023 ********************************************************************************/
00024 #ifndef FXMDICHILD_H
00025 #define FXMDICHILD_H
00026 
00027 #ifndef FXCOMPOSITE_H
00028 #include "FXComposite.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 class FXMDIClient;
00035 class FXMenuButton;
00036 class FXButton;
00037 class FXFont;
00038 
00039 
00040 /// MDI Child Window styles
00041 enum {
00042   MDI_NORMAL    = 0,                /// Normal display mode
00043   MDI_MAXIMIZED = 0x00001000,       /// Window appears maximized
00044   MDI_MINIMIZED = 0x00002000,       /// Window is iconified or minimized
00045   MDI_TRACKING  = 0x00004000        /// Track continuously during dragging
00046   };
00047 
00048 
00049 
00050 /**
00051 * The MDI child window contains the application
00052 * work area in a Multiple Document Interface application.
00053 */
00054 class FXAPI FXMDIChild : public FXComposite {
00055   FXDECLARE(FXMDIChild)
00056 protected:
00057   FXString      title;                  // Window title
00058   FXMenuButton *windowbtn;              // Window button
00059   FXButton     *minimizebtn;            // Minimize button
00060   FXButton     *restorebtn;             // Restore button
00061   FXButton     *maximizebtn;            // Maximize buton
00062   FXButton     *deletebtn;              // Close button
00063   FXFont       *font;                   // Title font
00064   FXColor       baseColor;              // Colors
00065   FXColor       hiliteColor;
00066   FXColor       shadowColor;
00067   FXColor       borderColor;
00068   FXColor       titleColor;
00069   FXColor       titleBackColor;
00070   FXint         iconPosX;               // Saved icon position
00071   FXint         iconPosY;
00072   FXint         iconWidth;
00073   FXint         iconHeight;
00074   FXint         normalPosX;             // Saved normal position
00075   FXint         normalPosY;
00076   FXint         normalWidth;
00077   FXint         normalHeight;
00078   FXint         spotx;                  // Grab-spot of mouse on window
00079   FXint         spoty;
00080   FXint         xoff;                   // Mouse offset to add
00081   FXint         yoff;
00082   FXint         newx;                   // New location of window
00083   FXint         newy;
00084   FXint         neww;
00085   FXint         newh;
00086   FXuchar       mode;                   // Dragging mode
00087 protected:
00088   FXMDIChild();
00089   void drawRubberBox(FXint x,FXint y,FXint w,FXint h);
00090   void animateRectangles(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh);
00091   FXuchar where(FXint x,FXint y);
00092   void changeCursor(FXint x,FXint y);
00093   void revertCursor();
00094 protected:
00095   enum {
00096     DRAG_NONE        = 0,
00097     DRAG_TOP         = 1,
00098     DRAG_BOTTOM      = 2,
00099     DRAG_LEFT        = 4,
00100     DRAG_RIGHT       = 8,
00101     DRAG_TOPLEFT     = (DRAG_TOP|DRAG_LEFT),
00102     DRAG_TOPRIGHT    = (DRAG_TOP|DRAG_RIGHT),
00103     DRAG_BOTTOMLEFT  = (DRAG_BOTTOM|DRAG_LEFT),
00104     DRAG_BOTTOMRIGHT = (DRAG_BOTTOM|DRAG_RIGHT),
00105     DRAG_INVERTED    = 16,
00106     DRAG_TITLE       = 32
00107     };
00108 private:
00109   FXMDIChild(const FXMDIChild&);
00110   FXMDIChild &operator=(const FXMDIChild&);
00111 public:
00112   long onPaint(FXObject*,FXSelector,void*);
00113   long onFocusSelf(FXObject*,FXSelector,void*);
00114   long onFocusIn(FXObject*,FXSelector,void*);
00115   long onFocusOut(FXObject*,FXSelector,void*);
00116   long onRightBtnPress(FXObject*,FXSelector,void*);
00117   long onRightBtnRelease(FXObject*,FXSelector,void*);
00118   long onLeftBtnPress(FXObject*,FXSelector,void*);
00119   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00120   long onMiddleBtnPress(FXObject*,FXSelector,void*);
00121   long onMiddleBtnRelease(FXObject*,FXSelector,void*);
00122   long onMotion(FXObject*,FXSelector,void*);
00123   long onSelected(FXObject*,FXSelector,void*);
00124   long onDeselected(FXObject*,FXSelector,void*);
00125   long onCmdClose(FXObject*,FXSelector,void*);
00126   long onUpdClose(FXObject*,FXSelector,void*);
00127   long onCmdRestore(FXObject*,FXSelector,void*);
00128   long onUpdRestore(FXObject*,FXSelector,void*);
00129   long onUpdMaximize(FXObject*,FXSelector,void*);
00130   long onUpdMinimize(FXObject*,FXSelector,void*);
00131   long onCmdMaximize(FXObject*,FXSelector,void*);
00132   long onCmdMinimize(FXObject*,FXSelector,void*);
00133   long onUpdWindow(FXObject*,FXSelector,void*);
00134   long onUpdMenuRestore(FXObject*,FXSelector,void*);
00135   long onUpdMenuMinimize(FXObject*,FXSelector,void*);
00136   long onUpdMenuClose(FXObject*,FXSelector,void*);
00137   long onUpdMenuWindow(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   virtual long onDefault(FXObject*,FXSelector,void*);
00143 public:
00144 
00145   /// Construct MDI Child window with given name and icon
00146   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);
00147 
00148   /// Create window
00149   virtual void create();
00150 
00151   /// Detach window
00152   virtual void detach();
00153 
00154   /// Perform layout
00155   virtual void layout();
00156 
00157   /// Return the default width of this window
00158   virtual FXint getDefaultWidth();
00159 
00160   /// Return the default height of this window
00161   virtual FXint getDefaultHeight();
00162 
00163   /// Move the focus to this window
00164   virtual void setFocus();
00165 
00166   /// MDI Child can receive focus
00167   virtual FXbool canFocus() const;
00168 
00169   /// Move this window to the specified position in the parent's coordinates
00170   virtual void move(FXint x,FXint y);
00171 
00172   /// Resize this window to the specified width and height
00173   virtual void resize(FXint w,FXint h);
00174 
00175   /// Move and resize this window in the parent's coordinates
00176   virtual void position(FXint x,FXint y,FXint w,FXint h);
00177 
00178   /// Change normal (restored) position
00179   void setNormalX(FXint x){ normalPosX=x; }
00180   void setNormalY(FXint y){ normalPosY=y; }
00181   void setNormalWidth(FXint w){ normalWidth=w; }
00182   void setNormalHeight(FXint h){ normalHeight=h; }
00183 
00184   /// Return normal (restored) position
00185   FXint getNormalX() const { return normalPosX; }
00186   FXint getNormalY() const { return normalPosY; }
00187   FXint getNormalWidth() const { return normalWidth; }
00188   FXint getNormalHeight() const { return normalHeight; }
00189 
00190   /// Change iconified position
00191   void setIconX(FXint x){ iconPosX=x; }
00192   void setIconY(FXint y){ iconPosY=y; }
00193   void setIconWidth(FXint w){ iconWidth=w; }
00194   void setIconHeight(FXint h){ iconHeight=h; }
00195 
00196   /// Return iconified position
00197   FXint getIconX() const { return iconPosX; }
00198   FXint getIconY() const { return iconPosY; }
00199   FXint getIconWidth() const { return iconWidth; }
00200   FXint getIconHeight() const { return iconHeight; }
00201 
00202   /// Return content window
00203   FXWindow *contentWindow() const;
00204 
00205   /// Change MDI Child's title
00206   void setTitle(const FXString& name);
00207 
00208   /// Get current title
00209   FXString getTitle() const { return title; }
00210 
00211   /// Get colors
00212   FXColor getHiliteColor() const { return hiliteColor; }
00213   FXColor getShadowColor() const { return shadowColor; }
00214   FXColor getBaseColor() const { return baseColor; }
00215   FXColor getBorderColor() const { return borderColor; }
00216   FXColor getTitleColor () const { return titleColor; }
00217   FXColor getTitleBackColor() const { return titleBackColor; }
00218 
00219   /// Change colors
00220   void setHiliteColor(FXColor clr);
00221   void setShadowColor(FXColor clr);
00222   void setBaseColor(FXColor clr);
00223   void setBorderColor(FXColor clr);
00224   void setTitleColor(FXColor clr);
00225   void setTitleBackColor(FXColor clr);
00226 
00227   /// Maximize MDI window, return TRUE if maximized
00228   virtual FXbool maximize(FXbool notify=FALSE);
00229 
00230   /// Minimize/iconify MDI window, return TRUE if minimized
00231   virtual FXbool minimize(FXbool notify=FALSE);
00232 
00233   /// Restore MDI window to normal, return TRUE if restored
00234   virtual FXbool restore(FXbool notify=FALSE);
00235 
00236   /// Close MDI window, return TRUE if actually closed
00237   virtual FXbool close(FXbool notify=FALSE);
00238 
00239   /// Return TRUE if maximized
00240   FXbool isMaximized() const;
00241 
00242   /// Return TRUE if minimized
00243   FXbool isMinimized() const;
00244 
00245   /// Get window icon
00246   FXIcon *getIcon() const;
00247 
00248   /// Set window icon
00249   void setIcon(FXIcon* icon);
00250 
00251   /// Get window menu
00252   FXPopup* getMenu() const;
00253 
00254   /// Set window menu
00255   void setMenu(FXPopup* menu);
00256 
00257   /// Set tracking instead of just outline
00258   void setTracking(FXbool tracking=TRUE);
00259 
00260   /// Return true if tracking
00261   FXbool getTracking() const;
00262 
00263   /// Set title font
00264   void setFont(FXFont *fnt);
00265 
00266   /// Get title font
00267   FXFont* getFont() const { return font; }
00268 
00269   /// Save to stream
00270   virtual void save(FXStream& store) const;
00271 
00272   /// Load from stream
00273   virtual void load(FXStream& store);
00274 
00275   /// Destroy
00276   virtual ~FXMDIChild();
00277   };
00278 
00279 }
00280 
00281 #endif

Copyright © 1997-2004 Jeroen van der Zijp