1 /******************************************************************************** 2 * * 3 * 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 * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This library is free software; you can redistribute it and/or * 9 * modify it under the terms of the GNU Lesser General Public * 10 * License as published by the Free Software Foundation; either * 11 * version 2.1 of the License, or (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 16 * Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public * 19 * License along with this library; if not, write to the Free Software * 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 21 ********************************************************************************* 22 * $Id: FXMDIChild.h,v 1.42 2006/01/22 17:58:05 fox Exp $ * 23 ********************************************************************************/ 24 #ifndef FXMDICHILD_H 25 #define FXMDICHILD_H 26 27 #ifndef FXCOMPOSITE_H 28 #include "FXComposite.h" 29 #endif 30 31 namespace FX { 32 33 34 class FXMDIClient; 35 class FXMenuButton; 36 class FXButton; 37 class FXFont; 38 39 40 /// MDI Child Window styles 41 enum { 42 MDI_NORMAL = 0, /// Normal display mode 43 MDI_MAXIMIZED = 0x00001000, /// Window appears maximized 44 MDI_MINIMIZED = 0x00002000, /// Window is iconified or minimized 45 MDI_TRACKING = 0x00004000 /// Track continuously during dragging 46 }; 47 48 49 50 /** 51 * The MDI child window contains the application work area in a Multiple Document 52 * Interface application. GUI Controls are connected to the MDI child via delegation 53 * through the MDI client, which forwards messages it receives to the active MDI child. 54 * The MDI child itself tries to further delegate messages to its single content window, 55 * and if not handled there, to its target object. 56 * When the MDI child is maximized, it sends a SEL_MAXIMIZE message; when the MDI 57 * child is minimized, it sends a SEL_MINIMIZE message. When it is restored, it 58 * sends a SEL_RESTORE message to its target. The MDI child also notifies its 59 * target when it becomes the active MDI child, via the SEL_SELECTED message. 60 * The void* in the SEL_SELECTED message refers to the previously active MDI child, 61 * if any. When an MDI child ceases to be the active one, a SEL_DESELECTED message 62 * is sent. The void* in the SEL_DESELECTED message refers to the newly activated 63 * MDI child, if any. Thus, interception of SEL_SELECTED and SEL_DESELECTED allows 64 * the target object to determine whether the user switched between MDI windows of 65 * the same document (target) or between MDI windows belonging to the same document. 66 * When the MDI child is closed, it sends a SEL_CLOSE message to its target. 67 * The target has an opportunity to object to the closing; if the MDI child should 68 * not be closed, it should return 1 (objection). If the MDI child should be closed, 69 * the target can either just return 0 or simply not handle the SEL_CLOSE message. 70 * The SEL_UPDATE message can be used to modify the MDI child's title (via 71 * ID_SETSTRINGVALUE), and window icon (via ID_SETICONVALUE). 72 */ 73 class FXAPI FXMDIChild : public FXComposite { 74 FXDECLARE(FXMDIChild) 75 protected: 76 FXString title; // Window title 77 FXMenuButton *windowbtn; // Window button 78 FXButton *minimizebtn; // Minimize button 79 FXButton *restorebtn; // Restore button 80 FXButton *maximizebtn; // Maximize buton 81 FXButton *deletebtn; // Close button 82 FXFont *font; // Title font 83 FXColor baseColor; // Colors 84 FXColor hiliteColor; 85 FXColor shadowColor; 86 FXColor borderColor; 87 FXColor titleColor; 88 FXColor titleBackColor; 89 FXint iconPosX; // Saved icon position 90 FXint iconPosY; 91 FXint iconWidth; 92 FXint iconHeight; 93 FXint normalPosX; // Saved normal position 94 FXint normalPosY; 95 FXint normalWidth; 96 FXint normalHeight; 97 FXint spotx; // Grab-spot of mouse on window 98 FXint spoty; 99 FXint xoff; // Mouse offset to add 100 FXint yoff; 101 FXint newx; // New location of window 102 FXint newy; 103 FXint neww; 104 FXint newh; 105 FXuchar mode; // Dragging mode 106 protected: 107 FXMDIChild(); 108 void drawRubberBox(FXint x,FXint y,FXint w,FXint h); 109 void animateRectangles(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh); 110 FXuchar where(FXint x,FXint y); 111 void changeCursor(FXint x,FXint y); 112 void revertCursor(); 113 protected: 114 enum { 115 DRAG_NONE = 0, 116 DRAG_TOP = 1, 117 DRAG_BOTTOM = 2, 118 DRAG_LEFT = 4, 119 DRAG_RIGHT = 8, 120 DRAG_TOPLEFT = (DRAG_TOP|DRAG_LEFT), 121 DRAG_TOPRIGHT = (DRAG_TOP|DRAG_RIGHT), 122 DRAG_BOTTOMLEFT = (DRAG_BOTTOM|DRAG_LEFT), 123 DRAG_BOTTOMRIGHT = (DRAG_BOTTOM|DRAG_RIGHT), 124 DRAG_INVERTED = 16, 125 DRAG_TITLE = 32 126 }; 127 private: 128 FXMDIChild(const FXMDIChild&); 129 FXMDIChild &operator=(const FXMDIChild&); 130 public: 131 long onPaint(FXObject*,FXSelector,void*); 132 long onFocusSelf(FXObject*,FXSelector,void*); 133 long onFocusIn(FXObject*,FXSelector,void*); 134 long onFocusOut(FXObject*,FXSelector,void*); 135 long onRightBtnPress(FXObject*,FXSelector,void*); 136 long onRightBtnRelease(FXObject*,FXSelector,void*); 137 long onLeftBtnPress(FXObject*,FXSelector,void*); 138 long onLeftBtnRelease(FXObject*,FXSelector,void*); 139 long onMiddleBtnPress(FXObject*,FXSelector,void*); 140 long onMiddleBtnRelease(FXObject*,FXSelector,void*); 141 long onMotion(FXObject*,FXSelector,void*); 142 long onSelected(FXObject*,FXSelector,void*); 143 long onDeselected(FXObject*,FXSelector,void*); 144 long onCmdClose(FXObject*,FXSelector,void*); 145 long onUpdClose(FXObject*,FXSelector,void*); 146 long onCmdRestore(FXObject*,FXSelector,void*); 147 long onUpdRestore(FXObject*,FXSelector,void*); 148 long onUpdMaximize(FXObject*,FXSelector,void*); 149 long onUpdMinimize(FXObject*,FXSelector,void*); 150 long onCmdMaximize(FXObject*,FXSelector,void*); 151 long onCmdMinimize(FXObject*,FXSelector,void*); 152 long onUpdWindow(FXObject*,FXSelector,void*); 153 long onUpdMenuRestore(FXObject*,FXSelector,void*); 154 long onUpdMenuMinimize(FXObject*,FXSelector,void*); 155 long onUpdMenuClose(FXObject*,FXSelector,void*); 156 long onUpdMenuWindow(FXObject*,FXSelector,void*); 157 long onCmdSetStringValue(FXObject*,FXSelector,void*); 158 long onCmdGetStringValue(FXObject*,FXSelector,void*); 159 long onCmdSetIconValue(FXObject*,FXSelector,void*); 160 long onCmdGetIconValue(FXObject*,FXSelector,void*); 161 virtual long onDefault(FXObject*,FXSelector,void*); 162 public: 163 164 /// Construct MDI Child window with given name and icon 165 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); 166 167 /// Create window 168 virtual void create(); 169 170 /// Detach window 171 virtual void detach(); 172 173 /// Perform layout 174 virtual void layout(); 175 176 /// Return the default width of this window 177 virtual FXint getDefaultWidth(); 178 179 /// Return the default height of this window 180 virtual FXint getDefaultHeight(); 181 182 /// Move the focus to this window 183 virtual void setFocus(); 184 185 /// MDI Child can receive focus 186 virtual bool canFocus() const; 187 188 /// Move this window to the specified position in the parent's coordinates 189 virtual void move(FXint x,FXint y); 190 191 /// Resize this window to the specified width and height 192 virtual void resize(FXint w,FXint h); 193 194 /// Move and resize this window in the parent's coordinates 195 virtual void position(FXint x,FXint y,FXint w,FXint h); 196 197 /// Change normal (restored) position setNormalX(FXint x)198 void setNormalX(FXint x){ normalPosX=x; } setNormalY(FXint y)199 void setNormalY(FXint y){ normalPosY=y; } setNormalWidth(FXint w)200 void setNormalWidth(FXint w){ normalWidth=w; } setNormalHeight(FXint h)201 void setNormalHeight(FXint h){ normalHeight=h; } 202 203 /// Return normal (restored) position getNormalX()204 FXint getNormalX() const { return normalPosX; } getNormalY()205 FXint getNormalY() const { return normalPosY; } getNormalWidth()206 FXint getNormalWidth() const { return normalWidth; } getNormalHeight()207 FXint getNormalHeight() const { return normalHeight; } 208 209 /// Change iconified position setIconX(FXint x)210 void setIconX(FXint x){ iconPosX=x; } setIconY(FXint y)211 void setIconY(FXint y){ iconPosY=y; } setIconWidth(FXint w)212 void setIconWidth(FXint w){ iconWidth=w; } setIconHeight(FXint h)213 void setIconHeight(FXint h){ iconHeight=h; } 214 215 /// Return iconified position getIconX()216 FXint getIconX() const { return iconPosX; } getIconY()217 FXint getIconY() const { return iconPosY; } getIconWidth()218 FXint getIconWidth() const { return iconWidth; } getIconHeight()219 FXint getIconHeight() const { return iconHeight; } 220 221 /// Return content window 222 FXWindow *contentWindow() const; 223 224 /// Change MDI Child's title 225 void setTitle(const FXString& name); 226 227 /// Get current title getTitle()228 FXString getTitle() const { return title; } 229 230 /// Get colors getHiliteColor()231 FXColor getHiliteColor() const { return hiliteColor; } getShadowColor()232 FXColor getShadowColor() const { return shadowColor; } getBaseColor()233 FXColor getBaseColor() const { return baseColor; } getBorderColor()234 FXColor getBorderColor() const { return borderColor; } getTitleColor()235 FXColor getTitleColor () const { return titleColor; } getTitleBackColor()236 FXColor getTitleBackColor() const { return titleBackColor; } 237 238 /// Change colors 239 void setHiliteColor(FXColor clr); 240 void setShadowColor(FXColor clr); 241 void setBaseColor(FXColor clr); 242 void setBorderColor(FXColor clr); 243 void setTitleColor(FXColor clr); 244 void setTitleBackColor(FXColor clr); 245 246 /// Maximize MDI window, return TRUE if maximized 247 virtual FXbool maximize(FXbool notify=FALSE); 248 249 /// Minimize/iconify MDI window, return TRUE if minimized 250 virtual FXbool minimize(FXbool notify=FALSE); 251 252 /// Restore MDI window to normal, return TRUE if restored 253 virtual FXbool restore(FXbool notify=FALSE); 254 255 /// Close MDI window, return TRUE if actually closed 256 virtual FXbool close(FXbool notify=FALSE); 257 258 /// Return TRUE if maximized 259 FXbool isMaximized() const; 260 261 /// Return TRUE if minimized 262 FXbool isMinimized() const; 263 264 /// Get window icon 265 FXIcon *getIcon() const; 266 267 /// Set window icon 268 void setIcon(FXIcon* icon); 269 270 /// Get window menu 271 FXPopup* getMenu() const; 272 273 /// Set window menu 274 void setMenu(FXPopup* menu); 275 276 /// Set tracking instead of just outline 277 void setTracking(FXbool tracking=TRUE); 278 279 /// Return true if tracking 280 FXbool getTracking() const; 281 282 /// Set title font 283 void setFont(FXFont *fnt); 284 285 /// Get title font getFont()286 FXFont* getFont() const { return font; } 287 288 /// Save to stream 289 virtual void save(FXStream& store) const; 290 291 /// Load from stream 292 virtual void load(FXStream& store); 293 294 /// Destroy 295 virtual ~FXMDIChild(); 296 }; 297 298 } 299 300 #endif 301