ROOT logo
// @(#)root/gui:$Id$
// Author: Bertrand Bellenot   20/08/2004

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

/**************************************************************************

    This file is part of TGMdi, an extension to the xclass toolkit.
    Copyright (C) 1998-2002 by Harald Radke, Hector Peraza.

    This application is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This application is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

**************************************************************************/

#ifndef ROOT_TGMdiMainFrame
#define ROOT_TGMdiMainFrame

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGMdiMainFrame.                                                      //
//                                                                      //
// This file contains the TGMdiMainFrame class.                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGCanvas
#include "TGCanvas.h"
#endif
#ifndef ROOT_TGMenu
#include "TGMenu.h"
#endif
#ifndef ROOT_TGFont
#include "TGFont.h"
#endif


// MDI resizing modes
enum EMdiResizingModes {
   kMdiOpaque            = 1,
   kMdiNonOpaque         = 2,
   kMdiDefaultResizeMode = kMdiOpaque
};

// MDI hints, also used to identify titlebar buttons
enum EMdiHints {
   kMdiClose         = 4,
   kMdiRestore       = 8,
   kMdiMove          = 16,
   kMdiSize          = 32,
   kMdiMinimize      = 64,
   kMdiMaximize      = 128,
   kMdiHelp          = 256,
   kMdiMenu          = 512,
   kMdiDefaultHints  = kMdiMenu | kMdiMinimize | kMdiRestore |
                       kMdiMaximize | kMdiSize | kMdiClose
};

// window arrangement modes
enum EMdiArrangementModes {
   kMdiTileHorizontal = 1,
   kMdiTileVertical   = 2,
   kMdiCascade        = 3
};

// geometry value masks for ConfigureWindow() call
enum EMdiGeometryMask {
   kMdiClientGeometry = BIT(0),
   kMdiDecorGeometry  = BIT(1),
   kMdiIconGeometry   = BIT(2)
};


class TGGC;
class TGMdiMenuBar;
class TGMdiContainer;
class TGMdiDecorFrame;
class TGMdiFrame;

//----------------------------------------------------------------------

class TGMdiFrameList {

friend class TGMdiMainFrame;

protected:
   UInt_t            fFrameId;                  // TGMdiFrameList Id
   TGMdiDecorFrame  *fDecor;                    // MDI decor frame
   TGMdiFrameList   *fPrev, *fNext;             // pointers on previous and next TGMdiFrameList
   TGMdiFrameList   *fCyclePrev, *fCycleNext;   // pointers on previous and next TGMdiFrameList

public:
   virtual ~TGMdiFrameList() { }

   UInt_t            GetFrameId() const { return fFrameId; }
   TGMdiDecorFrame  *GetDecorFrame() const { return fDecor; }
   TGMdiFrameList   *GetPrev() const { return fPrev; }
   TGMdiFrameList   *GetNext() const { return fNext; }
   TGMdiFrameList   *GetCyclePrev() const { return fCyclePrev; }
   TGMdiFrameList   *GetCycleNext() const { return fCycleNext; }

   void              SetFrameId(UInt_t id) { fFrameId = id; }
   void              SetDecorFrame(TGMdiDecorFrame *decor) { fDecor = decor; }
   void              SetPrev(TGMdiFrameList *prev) { fPrev = prev; }
   void              SetNext(TGMdiFrameList *next) { fNext = next; }
   void              SetCyclePrev(TGMdiFrameList *prev) { fCyclePrev = prev; }
   void              SetCycleNext(TGMdiFrameList *next) { fCycleNext = next; }

   ClassDef(TGMdiFrameList, 0) // MDI Frame list
};


class TGMdiGeometry {

public:
   Int_t            fValueMask;                    // MDI hints mask
   TGRectangle      fClient, fDecoration, fIcon;   // client, decoration and icon rectangles

   virtual ~TGMdiGeometry() { }

   ClassDef(TGMdiGeometry, 0) // MDI Geometry
};


//----------------------------------------------------------------------

class TGMdiMainFrame : public TGCanvas {

friend class TGMdiFrame;

protected:
   enum {
      // the width of minimized windows, in "height" units
      kMinimizedWidth = 5
   };

   Int_t            fCurrentX, fCurrentY, fResizeMode;   // current MDI child XY position and resize mode
   Int_t            fArrangementMode;                    // MDI children arrangement mode
   TGFont          *fFontCurrent, *fFontNotCurrent;      // fonts for active and inactive MDI children
   Pixel_t          fBackCurrent, fForeCurrent;          // back and fore colors for active MDI children
   Pixel_t          fBackNotCurrent, fForeNotCurrent;    // back and fore colors for inactive MDI children

   TGGC            *fBoxGC;                              // GC used to draw resizing box (rectangle)

   Long_t           fNumberOfFrames;                     // number of MDI child windows
   TGMdiMenuBar    *fMenuBar;                            // menu bar
   TGFrame         *fContainer;                          // MDI container
   TGPopupMenu     *fWinListMenu;                        // popup menu with list of MDI child windows
   TGMdiFrameList  *fChildren;                           // list of MDI child windows
   TGMdiFrameList  *fCurrent;                            // current list of MDI child windows

   void             AddMdiFrame(TGMdiFrame *f);
   Bool_t           RemoveMdiFrame(TGMdiFrame *f);

   Bool_t           SetCurrent(TGMdiFrameList *newcurrent);
   TGMdiDecorFrame *GetDecorFrame(UInt_t id) const;
   TGMdiDecorFrame *GetDecorFrame(TGMdiFrame *frame) const;

   void             UpdateWinListMenu();

public:
   TGMdiMainFrame(const TGWindow *p, TGMdiMenuBar *menu, Int_t w, Int_t h,
                  UInt_t options = 0,
                  Pixel_t back = GetDefaultFrameBackground());
   virtual ~TGMdiMainFrame();

   virtual Bool_t   HandleKey(Event_t *event);
   virtual Bool_t   ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);

   virtual void     Layout();

   virtual void     FreeMove(TGMdiFrame *frame);
   virtual void     FreeSize(TGMdiFrame *frame);
   virtual void     Restore(TGMdiFrame *frame);
   virtual void     Maximize(TGMdiFrame *frame);
   virtual void     Minimize(TGMdiFrame *frame);
   virtual Int_t    Close(TGMdiFrame *frame);
   virtual Int_t    ContextHelp(TGMdiFrame *frame);
   virtual void     CloseAll();

   virtual void     Cascade() { ArrangeFrames(kMdiCascade); }
   virtual void     TileHorizontal() { ArrangeFrames(kMdiTileHorizontal); }
   virtual void     TileVertical() { ArrangeFrames(kMdiTileVertical); }

   virtual void     ArrangeFrames(Int_t mode);
   virtual void     ArrangeMinimized();

   virtual void     CirculateUp();
   virtual void     CirculateDown();

   TGMdiFrame      *GetCurrent() const;
   TGMdiFrame      *GetMdiFrame(UInt_t id) const;
   TGFrame         *GetContainer() const { return fContainer; }
   Bool_t           SetCurrent(UInt_t newcurrent);
   Bool_t           SetCurrent(TGMdiFrame *f);  //*SIGNAL*

   TGPopupMenu     *GetWinListMenu() const { return fWinListMenu; }
   TGMdiMenuBar    *GetMenu() const { return fMenuBar; }

   TGMdiFrameList  *GetWindowList(Int_t current = kFALSE) const
                     { return current ? fCurrent : fChildren; }
   Long_t           GetNumberOfFrames() const { return fNumberOfFrames; }

   void             SetResizeMode(Int_t mode = kMdiDefaultResizeMode);
   void             UpdateMdiButtons();

   TGRectangle      GetBBox() const;
   TGRectangle      GetMinimizedBBox() const;

   TGMdiGeometry    GetWindowGeometry(TGMdiFrame *f) const;
   void             ConfigureWindow(TGMdiFrame *f, TGMdiGeometry &geom);

   Bool_t           IsMaximized(TGMdiFrame *f);
   Bool_t           IsMinimized(TGMdiFrame *f);

   virtual void     FrameCreated(Int_t id) { Emit("FrameCreated(Int_t)", id); } //*SIGNAL*
   virtual void     FrameClosed(Int_t id) { Emit("FrameClosed(Int_t)", id); } //*SIGNAL*
   virtual void     FrameMaximized(Int_t id) { Emit("FrameMaximized(Int_t)", id); } //*SIGNAL*
   virtual void     FrameMinimized(Int_t id) { Emit("FrameMinimized(Int_t)", id); } //*SIGNAL*
   virtual void     FrameRestored(Int_t id) { Emit("FrameRestored(Int_t)", id); } //*SIGNAL*
   virtual void     FramesArranged(Int_t mode) { Emit("FramesArranged(Int_t)", mode); } //*SIGNAL*

   virtual void     SavePrimitive(ostream &out, Option_t *option = "");

   ClassDef(TGMdiMainFrame, 0) // MDI main frame
};


//----------------------------------------------------------------------

class TGMdiContainer : public TGFrame {

protected:
   const TGMdiMainFrame *fMain;     // pointer to MDI main frame

public:
   TGMdiContainer(const TGMdiMainFrame *p, Int_t w, Int_t h,
                  UInt_t options = 0,
                  ULong_t back = GetDefaultFrameBackground());

   virtual Bool_t HandleConfigureNotify(Event_t *event);
   virtual TGDimension GetDefaultSize() const;

   ClassDef(TGMdiContainer, 0) // MDI container
};

#endif
 TGMdiMainFrame.h:1
 TGMdiMainFrame.h:2
 TGMdiMainFrame.h:3
 TGMdiMainFrame.h:4
 TGMdiMainFrame.h:5
 TGMdiMainFrame.h:6
 TGMdiMainFrame.h:7
 TGMdiMainFrame.h:8
 TGMdiMainFrame.h:9
 TGMdiMainFrame.h:10
 TGMdiMainFrame.h:11
 TGMdiMainFrame.h:12
 TGMdiMainFrame.h:13
 TGMdiMainFrame.h:14
 TGMdiMainFrame.h:15
 TGMdiMainFrame.h:16
 TGMdiMainFrame.h:17
 TGMdiMainFrame.h:18
 TGMdiMainFrame.h:19
 TGMdiMainFrame.h:20
 TGMdiMainFrame.h:21
 TGMdiMainFrame.h:22
 TGMdiMainFrame.h:23
 TGMdiMainFrame.h:24
 TGMdiMainFrame.h:25
 TGMdiMainFrame.h:26
 TGMdiMainFrame.h:27
 TGMdiMainFrame.h:28
 TGMdiMainFrame.h:29
 TGMdiMainFrame.h:30
 TGMdiMainFrame.h:31
 TGMdiMainFrame.h:32
 TGMdiMainFrame.h:33
 TGMdiMainFrame.h:34
 TGMdiMainFrame.h:35
 TGMdiMainFrame.h:36
 TGMdiMainFrame.h:37
 TGMdiMainFrame.h:38
 TGMdiMainFrame.h:39
 TGMdiMainFrame.h:40
 TGMdiMainFrame.h:41
 TGMdiMainFrame.h:42
 TGMdiMainFrame.h:43
 TGMdiMainFrame.h:44
 TGMdiMainFrame.h:45
 TGMdiMainFrame.h:46
 TGMdiMainFrame.h:47
 TGMdiMainFrame.h:48
 TGMdiMainFrame.h:49
 TGMdiMainFrame.h:50
 TGMdiMainFrame.h:51
 TGMdiMainFrame.h:52
 TGMdiMainFrame.h:53
 TGMdiMainFrame.h:54
 TGMdiMainFrame.h:55
 TGMdiMainFrame.h:56
 TGMdiMainFrame.h:57
 TGMdiMainFrame.h:58
 TGMdiMainFrame.h:59
 TGMdiMainFrame.h:60
 TGMdiMainFrame.h:61
 TGMdiMainFrame.h:62
 TGMdiMainFrame.h:63
 TGMdiMainFrame.h:64
 TGMdiMainFrame.h:65
 TGMdiMainFrame.h:66
 TGMdiMainFrame.h:67
 TGMdiMainFrame.h:68
 TGMdiMainFrame.h:69
 TGMdiMainFrame.h:70
 TGMdiMainFrame.h:71
 TGMdiMainFrame.h:72
 TGMdiMainFrame.h:73
 TGMdiMainFrame.h:74
 TGMdiMainFrame.h:75
 TGMdiMainFrame.h:76
 TGMdiMainFrame.h:77
 TGMdiMainFrame.h:78
 TGMdiMainFrame.h:79
 TGMdiMainFrame.h:80
 TGMdiMainFrame.h:81
 TGMdiMainFrame.h:82
 TGMdiMainFrame.h:83
 TGMdiMainFrame.h:84
 TGMdiMainFrame.h:85
 TGMdiMainFrame.h:86
 TGMdiMainFrame.h:87
 TGMdiMainFrame.h:88
 TGMdiMainFrame.h:89
 TGMdiMainFrame.h:90
 TGMdiMainFrame.h:91
 TGMdiMainFrame.h:92
 TGMdiMainFrame.h:93
 TGMdiMainFrame.h:94
 TGMdiMainFrame.h:95
 TGMdiMainFrame.h:96
 TGMdiMainFrame.h:97
 TGMdiMainFrame.h:98
 TGMdiMainFrame.h:99
 TGMdiMainFrame.h:100
 TGMdiMainFrame.h:101
 TGMdiMainFrame.h:102
 TGMdiMainFrame.h:103
 TGMdiMainFrame.h:104
 TGMdiMainFrame.h:105
 TGMdiMainFrame.h:106
 TGMdiMainFrame.h:107
 TGMdiMainFrame.h:108
 TGMdiMainFrame.h:109
 TGMdiMainFrame.h:110
 TGMdiMainFrame.h:111
 TGMdiMainFrame.h:112
 TGMdiMainFrame.h:113
 TGMdiMainFrame.h:114
 TGMdiMainFrame.h:115
 TGMdiMainFrame.h:116
 TGMdiMainFrame.h:117
 TGMdiMainFrame.h:118
 TGMdiMainFrame.h:119
 TGMdiMainFrame.h:120
 TGMdiMainFrame.h:121
 TGMdiMainFrame.h:122
 TGMdiMainFrame.h:123
 TGMdiMainFrame.h:124
 TGMdiMainFrame.h:125
 TGMdiMainFrame.h:126
 TGMdiMainFrame.h:127
 TGMdiMainFrame.h:128
 TGMdiMainFrame.h:129
 TGMdiMainFrame.h:130
 TGMdiMainFrame.h:131
 TGMdiMainFrame.h:132
 TGMdiMainFrame.h:133
 TGMdiMainFrame.h:134
 TGMdiMainFrame.h:135
 TGMdiMainFrame.h:136
 TGMdiMainFrame.h:137
 TGMdiMainFrame.h:138
 TGMdiMainFrame.h:139
 TGMdiMainFrame.h:140
 TGMdiMainFrame.h:141
 TGMdiMainFrame.h:142
 TGMdiMainFrame.h:143
 TGMdiMainFrame.h:144
 TGMdiMainFrame.h:145
 TGMdiMainFrame.h:146
 TGMdiMainFrame.h:147
 TGMdiMainFrame.h:148
 TGMdiMainFrame.h:149
 TGMdiMainFrame.h:150
 TGMdiMainFrame.h:151
 TGMdiMainFrame.h:152
 TGMdiMainFrame.h:153
 TGMdiMainFrame.h:154
 TGMdiMainFrame.h:155
 TGMdiMainFrame.h:156
 TGMdiMainFrame.h:157
 TGMdiMainFrame.h:158
 TGMdiMainFrame.h:159
 TGMdiMainFrame.h:160
 TGMdiMainFrame.h:161
 TGMdiMainFrame.h:162
 TGMdiMainFrame.h:163
 TGMdiMainFrame.h:164
 TGMdiMainFrame.h:165
 TGMdiMainFrame.h:166
 TGMdiMainFrame.h:167
 TGMdiMainFrame.h:168
 TGMdiMainFrame.h:169
 TGMdiMainFrame.h:170
 TGMdiMainFrame.h:171
 TGMdiMainFrame.h:172
 TGMdiMainFrame.h:173
 TGMdiMainFrame.h:174
 TGMdiMainFrame.h:175
 TGMdiMainFrame.h:176
 TGMdiMainFrame.h:177
 TGMdiMainFrame.h:178
 TGMdiMainFrame.h:179
 TGMdiMainFrame.h:180
 TGMdiMainFrame.h:181
 TGMdiMainFrame.h:182
 TGMdiMainFrame.h:183
 TGMdiMainFrame.h:184
 TGMdiMainFrame.h:185
 TGMdiMainFrame.h:186
 TGMdiMainFrame.h:187
 TGMdiMainFrame.h:188
 TGMdiMainFrame.h:189
 TGMdiMainFrame.h:190
 TGMdiMainFrame.h:191
 TGMdiMainFrame.h:192
 TGMdiMainFrame.h:193
 TGMdiMainFrame.h:194
 TGMdiMainFrame.h:195
 TGMdiMainFrame.h:196
 TGMdiMainFrame.h:197
 TGMdiMainFrame.h:198
 TGMdiMainFrame.h:199
 TGMdiMainFrame.h:200
 TGMdiMainFrame.h:201
 TGMdiMainFrame.h:202
 TGMdiMainFrame.h:203
 TGMdiMainFrame.h:204
 TGMdiMainFrame.h:205
 TGMdiMainFrame.h:206
 TGMdiMainFrame.h:207
 TGMdiMainFrame.h:208
 TGMdiMainFrame.h:209
 TGMdiMainFrame.h:210
 TGMdiMainFrame.h:211
 TGMdiMainFrame.h:212
 TGMdiMainFrame.h:213
 TGMdiMainFrame.h:214
 TGMdiMainFrame.h:215
 TGMdiMainFrame.h:216
 TGMdiMainFrame.h:217
 TGMdiMainFrame.h:218
 TGMdiMainFrame.h:219
 TGMdiMainFrame.h:220
 TGMdiMainFrame.h:221
 TGMdiMainFrame.h:222
 TGMdiMainFrame.h:223
 TGMdiMainFrame.h:224
 TGMdiMainFrame.h:225
 TGMdiMainFrame.h:226
 TGMdiMainFrame.h:227
 TGMdiMainFrame.h:228
 TGMdiMainFrame.h:229
 TGMdiMainFrame.h:230
 TGMdiMainFrame.h:231
 TGMdiMainFrame.h:232
 TGMdiMainFrame.h:233
 TGMdiMainFrame.h:234
 TGMdiMainFrame.h:235
 TGMdiMainFrame.h:236
 TGMdiMainFrame.h:237
 TGMdiMainFrame.h:238
 TGMdiMainFrame.h:239
 TGMdiMainFrame.h:240
 TGMdiMainFrame.h:241
 TGMdiMainFrame.h:242
 TGMdiMainFrame.h:243
 TGMdiMainFrame.h:244
 TGMdiMainFrame.h:245
 TGMdiMainFrame.h:246
 TGMdiMainFrame.h:247
 TGMdiMainFrame.h:248
 TGMdiMainFrame.h:249
 TGMdiMainFrame.h:250
 TGMdiMainFrame.h:251
 TGMdiMainFrame.h:252
 TGMdiMainFrame.h:253
 TGMdiMainFrame.h:254
 TGMdiMainFrame.h:255
 TGMdiMainFrame.h:256
 TGMdiMainFrame.h:257
 TGMdiMainFrame.h:258
 TGMdiMainFrame.h:259
 TGMdiMainFrame.h:260
 TGMdiMainFrame.h:261
 TGMdiMainFrame.h:262
 TGMdiMainFrame.h:263
 TGMdiMainFrame.h:264