TGMdiMainFrame.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGMdiMainFrame.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Bertrand Bellenot   20/08/2004
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 /**************************************************************************
00013 
00014     This file is part of TGMdi, an extension to the xclass toolkit.
00015     Copyright (C) 1998-2002 by Harald Radke, Hector Peraza.
00016 
00017     This application is free software; you can redistribute it and/or
00018     modify it under the terms of the GNU Library General Public
00019     License as published by the Free Software Foundation; either
00020     version 2 of the License, or (at your option) any later version.
00021 
00022     This application is distributed in the hope that it will be useful,
00023     but WITHOUT ANY WARRANTY; without even the implied warranty of
00024     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025     Library General Public License for more details.
00026 
00027     You should have received a copy of the GNU Library General Public
00028     License along with this library; if not, write to the Free
00029     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00030 
00031 **************************************************************************/
00032 
00033 #ifndef ROOT_TGMdiMainFrame
00034 #define ROOT_TGMdiMainFrame
00035 
00036 //////////////////////////////////////////////////////////////////////////
00037 //                                                                      //
00038 // TGMdiMainFrame.                                                      //
00039 //                                                                      //
00040 // This file contains the TGMdiMainFrame class.                         //
00041 //                                                                      //
00042 //////////////////////////////////////////////////////////////////////////
00043 
00044 #ifndef ROOT_TGCanvas
00045 #include "TGCanvas.h"
00046 #endif
00047 #ifndef ROOT_TGMenu
00048 #include "TGMenu.h"
00049 #endif
00050 #ifndef ROOT_TGFont
00051 #include "TGFont.h"
00052 #endif
00053 
00054 
00055 // MDI resizing modes
00056 enum EMdiResizingModes {
00057    kMdiOpaque            = 1,
00058    kMdiNonOpaque         = 2,
00059    kMdiDefaultResizeMode = kMdiOpaque
00060 };
00061 
00062 // MDI hints, also used to identify titlebar buttons
00063 enum EMdiHints {
00064    kMdiClose         = 4,
00065    kMdiRestore       = 8,
00066    kMdiMove          = 16,
00067    kMdiSize          = 32,
00068    kMdiMinimize      = 64,
00069    kMdiMaximize      = 128,
00070    kMdiHelp          = 256,
00071    kMdiMenu          = 512,
00072    kMdiDefaultHints  = kMdiMenu | kMdiMinimize | kMdiRestore |
00073                        kMdiMaximize | kMdiSize | kMdiClose
00074 };
00075 
00076 // window arrangement modes
00077 enum EMdiArrangementModes {
00078    kMdiTileHorizontal = 1,
00079    kMdiTileVertical   = 2,
00080    kMdiCascade        = 3
00081 };
00082 
00083 // geometry value masks for ConfigureWindow() call
00084 enum EMdiGeometryMask {
00085    kMdiClientGeometry = BIT(0),
00086    kMdiDecorGeometry  = BIT(1),
00087    kMdiIconGeometry   = BIT(2)
00088 };
00089 
00090 
00091 class TGGC;
00092 class TGMdiMenuBar;
00093 class TGMdiContainer;
00094 class TGMdiDecorFrame;
00095 class TGMdiFrame;
00096 
00097 //----------------------------------------------------------------------
00098 
00099 class TGMdiFrameList {
00100 
00101 friend class TGMdiMainFrame;
00102 
00103 protected:
00104    UInt_t            fFrameId;                  // TGMdiFrameList Id
00105    TGMdiDecorFrame  *fDecor;                    // MDI decor frame
00106    TGMdiFrameList   *fPrev, *fNext;             // pointers on previous and next TGMdiFrameList
00107    TGMdiFrameList   *fCyclePrev, *fCycleNext;   // pointers on previous and next TGMdiFrameList
00108 
00109 public:
00110    virtual ~TGMdiFrameList() { }
00111 
00112    UInt_t            GetFrameId() const { return fFrameId; }
00113    TGMdiDecorFrame  *GetDecorFrame() const { return fDecor; }
00114    TGMdiFrameList   *GetPrev() const { return fPrev; }
00115    TGMdiFrameList   *GetNext() const { return fNext; }
00116    TGMdiFrameList   *GetCyclePrev() const { return fCyclePrev; }
00117    TGMdiFrameList   *GetCycleNext() const { return fCycleNext; }
00118 
00119    void              SetFrameId(UInt_t id) { fFrameId = id; }
00120    void              SetDecorFrame(TGMdiDecorFrame *decor) { fDecor = decor; }
00121    void              SetPrev(TGMdiFrameList *prev) { fPrev = prev; }
00122    void              SetNext(TGMdiFrameList *next) { fNext = next; }
00123    void              SetCyclePrev(TGMdiFrameList *prev) { fCyclePrev = prev; }
00124    void              SetCycleNext(TGMdiFrameList *next) { fCycleNext = next; }
00125 
00126    ClassDef(TGMdiFrameList, 0) // MDI Frame list
00127 };
00128 
00129 
00130 class TGMdiGeometry {
00131 
00132 public:
00133    Int_t            fValueMask;                    // MDI hints mask
00134    TGRectangle      fClient, fDecoration, fIcon;   // client, decoration and icon rectangles
00135 
00136    virtual ~TGMdiGeometry() { }
00137 
00138    ClassDef(TGMdiGeometry, 0) // MDI Geometry
00139 };
00140 
00141 
00142 //----------------------------------------------------------------------
00143 
00144 class TGMdiMainFrame : public TGCanvas {
00145 
00146 friend class TGMdiFrame;
00147 
00148 protected:
00149    enum {
00150       // the width of minimized windows, in "height" units
00151       kMinimizedWidth = 5
00152    };
00153 
00154    Int_t            fCurrentX, fCurrentY, fResizeMode;   // current MDI child XY position and resize mode
00155    Int_t            fArrangementMode;                    // MDI childs arrangement mode
00156    TGFont          *fFontCurrent, *fFontNotCurrent;      // fonts for active and inactive MDI childs
00157    Pixel_t          fBackCurrent, fForeCurrent;          // back and fore colors for active MDI childs
00158    Pixel_t          fBackNotCurrent, fForeNotCurrent;    // back and fore colors for inactive MDI childs
00159 
00160    TGGC            *fBoxGC;                              // GC used to draw resizing box (rectangle)
00161 
00162    Long_t           fNumberOfFrames;                     // number of MDI child windows
00163    TGMdiMenuBar    *fMenuBar;                            // menu bar
00164    TGFrame         *fContainer;                          // MDI container
00165    TGPopupMenu     *fWinListMenu;                        // popup menu with list of MDI child windows
00166    TGMdiFrameList  *fChildren;                           // list of MDI child windows
00167    TGMdiFrameList  *fCurrent;                            // current list of MDI child windows
00168 
00169    void             AddMdiFrame(TGMdiFrame *f);
00170    Bool_t           RemoveMdiFrame(TGMdiFrame *f);
00171 
00172    Bool_t           SetCurrent(TGMdiFrameList *newcurrent);
00173    TGMdiDecorFrame *GetDecorFrame(UInt_t id) const;
00174    TGMdiDecorFrame *GetDecorFrame(TGMdiFrame *frame) const;
00175 
00176    void             UpdateWinListMenu();
00177 
00178 public:
00179    TGMdiMainFrame(const TGWindow *p, TGMdiMenuBar *menu, Int_t w, Int_t h,
00180                   UInt_t options = 0,
00181                   Pixel_t back = GetDefaultFrameBackground());
00182    virtual ~TGMdiMainFrame();
00183 
00184    virtual Bool_t   HandleKey(Event_t *event);
00185    virtual Bool_t   ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00186 
00187    virtual void     Layout();
00188 
00189    virtual void     FreeMove(TGMdiFrame *frame);
00190    virtual void     FreeSize(TGMdiFrame *frame);
00191    virtual void     Restore(TGMdiFrame *frame);
00192    virtual void     Maximize(TGMdiFrame *frame);
00193    virtual void     Minimize(TGMdiFrame *frame);
00194    virtual Int_t    Close(TGMdiFrame *frame);
00195    virtual Int_t    ContextHelp(TGMdiFrame *frame);
00196    virtual void     CloseAll();
00197 
00198    virtual void     Cascade() { ArrangeFrames(kMdiCascade); }
00199    virtual void     TileHorizontal() { ArrangeFrames(kMdiTileHorizontal); }
00200    virtual void     TileVertical() { ArrangeFrames(kMdiTileVertical); }
00201 
00202    virtual void     ArrangeFrames(Int_t mode);
00203    virtual void     ArrangeMinimized();
00204 
00205    virtual void     CirculateUp();
00206    virtual void     CirculateDown();
00207 
00208    TGMdiFrame      *GetCurrent() const;
00209    TGMdiFrame      *GetMdiFrame(UInt_t id) const;
00210    TGFrame         *GetContainer() const { return fContainer; }
00211    Bool_t           SetCurrent(UInt_t newcurrent);
00212    Bool_t           SetCurrent(TGMdiFrame *f);  //*SIGNAL*
00213 
00214    TGPopupMenu     *GetWinListMenu() const { return fWinListMenu; }
00215    TGMdiMenuBar    *GetMenu() const { return fMenuBar; }
00216 
00217    TGMdiFrameList  *GetWindowList(Int_t current = kFALSE) const
00218                      { return current ? fCurrent : fChildren; }
00219    Long_t           GetNumberOfFrames() const { return fNumberOfFrames; }
00220 
00221    void             SetResizeMode(Int_t mode = kMdiDefaultResizeMode);
00222 
00223    TGRectangle      GetBBox() const;
00224    TGRectangle      GetMinimizedBBox() const;
00225 
00226    TGMdiGeometry    GetWindowGeometry(TGMdiFrame *f) const;
00227    void             ConfigureWindow(TGMdiFrame *f, TGMdiGeometry &geom);
00228 
00229    Bool_t           IsMaximized(TGMdiFrame *f);
00230    Bool_t           IsMinimized(TGMdiFrame *f);
00231 
00232    virtual void     FrameCreated(Int_t id) { Emit("FrameCreated(Int_t)", id); } //*SIGNAL*
00233    virtual void     FrameClosed(Int_t id) { Emit("FrameClosed(Int_t)", id); } //*SIGNAL*
00234    virtual void     FrameMaximized(Int_t id) { Emit("FrameMaximized(Int_t)", id); } //*SIGNAL*
00235    virtual void     FrameMinimized(Int_t id) { Emit("FrameMinimized(Int_t)", id); } //*SIGNAL*
00236    virtual void     FrameRestored(Int_t id) { Emit("FrameRestored(Int_t)", id); } //*SIGNAL*
00237    virtual void     FramesArranged(Int_t mode) { Emit("FramesArranged(Int_t)", mode); } //*SIGNAL*
00238 
00239    virtual void     SavePrimitive(ostream &out, Option_t *option = "");
00240 
00241    ClassDef(TGMdiMainFrame, 0) // MDI main frame
00242 };
00243 
00244 
00245 //----------------------------------------------------------------------
00246 
00247 class TGMdiContainer : public TGFrame {
00248 
00249 protected:
00250    const TGMdiMainFrame *fMain;     // pointer to MDI main frame
00251 
00252 public:
00253    TGMdiContainer(const TGMdiMainFrame *p, Int_t w, Int_t h,
00254                   UInt_t options = 0,
00255                   ULong_t back = GetDefaultFrameBackground());
00256 
00257    virtual Bool_t HandleConfigureNotify(Event_t *event);
00258    virtual TGDimension GetDefaultSize() const;
00259 
00260    ClassDef(TGMdiContainer, 0) // MDI container
00261 };
00262 
00263 #endif

Generated on Tue Jul 5 14:20:05 2011 for ROOT_528-00b_version by  doxygen 1.5.1