Logo ROOT   6.08/07
Reference Guide
TGMdiMainFrame.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Bertrand Bellenot 20/08/2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /**************************************************************************
13 
14  This file is part of TGMdi, an extension to the xclass toolkit.
15  Copyright (C) 1998-2002 by Harald Radke, Hector Peraza.
16 
17  This application is free software; you can redistribute it and/or
18  modify it under the terms of the GNU Library General Public
19  License as published by the Free Software Foundation; either
20  version 2 of the License, or (at your option) any later version.
21 
22  This application is distributed in the hope that it will be useful,
23  but WITHOUT ANY WARRANTY; without even the implied warranty of
24  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25  Library General Public License for more details.
26 
27  You should have received a copy of the GNU Library General Public
28  License along with this library; if not, write to the Free
29  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 
31 **************************************************************************/
32 
33 #ifndef ROOT_TGMdiMainFrame
34 #define ROOT_TGMdiMainFrame
35 
36 //////////////////////////////////////////////////////////////////////////
37 // //
38 // TGMdiMainFrame. //
39 // //
40 // This file contains the TGMdiMainFrame class. //
41 // //
42 //////////////////////////////////////////////////////////////////////////
43 
44 #ifndef ROOT_TGCanvas
45 #include "TGCanvas.h"
46 #endif
47 #ifndef ROOT_TGMenu
48 #include "TGMenu.h"
49 #endif
50 #ifndef ROOT_TGFont
51 #include "TGFont.h"
52 #endif
53 
54 
55 // MDI resizing modes
60 };
61 
62 // MDI hints, also used to identify titlebar buttons
63 enum EMdiHints {
64  kMdiClose = 4,
66  kMdiMove = 16,
67  kMdiSize = 32,
69  kMdiMaximize = 128,
70  kMdiHelp = 256,
71  kMdiMenu = 512,
74 };
75 
76 // window arrangement modes
81 };
82 
83 // geometry value masks for ConfigureWindow() call
88 };
89 
90 
91 class TGGC;
92 class TGMdiMenuBar;
93 class TGMdiContainer;
94 class TGMdiDecorFrame;
95 class TGMdiFrame;
96 
97 //----------------------------------------------------------------------
98 
100 
101 friend class TGMdiMainFrame;
102 
103 protected:
104  UInt_t fFrameId; // TGMdiFrameList Id
105  TGMdiDecorFrame *fDecor; // MDI decor frame
106  TGMdiFrameList *fPrev, *fNext; // pointers on previous and next TGMdiFrameList
107  TGMdiFrameList *fCyclePrev, *fCycleNext; // pointers on previous and next TGMdiFrameList
108 
109 public:
110  virtual ~TGMdiFrameList() { }
111 
112  UInt_t GetFrameId() const { return fFrameId; }
113  TGMdiDecorFrame *GetDecorFrame() const { return fDecor; }
114  TGMdiFrameList *GetPrev() const { return fPrev; }
115  TGMdiFrameList *GetNext() const { return fNext; }
118 
119  void SetFrameId(UInt_t id) { fFrameId = id; }
120  void SetDecorFrame(TGMdiDecorFrame *decor) { fDecor = decor; }
121  void SetPrev(TGMdiFrameList *prev) { fPrev = prev; }
122  void SetNext(TGMdiFrameList *next) { fNext = next; }
123  void SetCyclePrev(TGMdiFrameList *prev) { fCyclePrev = prev; }
124  void SetCycleNext(TGMdiFrameList *next) { fCycleNext = next; }
125 
126  ClassDef(TGMdiFrameList, 0) // MDI Frame list
127 };
128 
129 
131 
132 public:
133  Int_t fValueMask; // MDI hints mask
134  TGRectangle fClient, fDecoration, fIcon; // client, decoration and icon rectangles
135 
136  virtual ~TGMdiGeometry() { }
137 
138  ClassDef(TGMdiGeometry, 0) // MDI Geometry
139 };
140 
141 
142 //----------------------------------------------------------------------
143 
144 class TGMdiMainFrame : public TGCanvas {
145 
146 friend class TGMdiFrame;
147 
148 protected:
149  enum {
150  // the width of minimized windows, in "height" units
151  kMinimizedWidth = 5
152  };
153 
154  Int_t fCurrentX, fCurrentY, fResizeMode; // current MDI child XY position and resize mode
155  Int_t fArrangementMode; // MDI children arrangement mode
156  TGFont *fFontCurrent, *fFontNotCurrent; // fonts for active and inactive MDI children
157  Pixel_t fBackCurrent, fForeCurrent; // back and fore colors for active MDI children
158  Pixel_t fBackNotCurrent, fForeNotCurrent; // back and fore colors for inactive MDI children
159 
160  TGGC *fBoxGC; // GC used to draw resizing box (rectangle)
161 
162  Long_t fNumberOfFrames; // number of MDI child windows
163  TGMdiMenuBar *fMenuBar; // menu bar
164  TGFrame *fContainer; // MDI container
165  TGPopupMenu *fWinListMenu; // popup menu with list of MDI child windows
166  TGMdiFrameList *fChildren; // list of MDI child windows
167  TGMdiFrameList *fCurrent; // current list of MDI child windows
168 
169  void AddMdiFrame(TGMdiFrame *f);
170  Bool_t RemoveMdiFrame(TGMdiFrame *f);
171 
172  Bool_t SetCurrent(TGMdiFrameList *newcurrent);
175 
176  void UpdateWinListMenu();
177 
178 public:
179  TGMdiMainFrame(const TGWindow *p, TGMdiMenuBar *menu, Int_t w, Int_t h,
180  UInt_t options = 0,
182  virtual ~TGMdiMainFrame();
183 
184  virtual Bool_t HandleKey(Event_t *event);
185  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
186 
187  virtual void Layout();
188 
189  virtual void FreeMove(TGMdiFrame *frame);
190  virtual void FreeSize(TGMdiFrame *frame);
191  virtual void Restore(TGMdiFrame *frame);
192  virtual void Maximize(TGMdiFrame *frame);
193  virtual void Minimize(TGMdiFrame *frame);
194  virtual Int_t Close(TGMdiFrame *frame);
195  virtual Int_t ContextHelp(TGMdiFrame *frame);
196  virtual void CloseAll();
197 
198  virtual void Cascade() { ArrangeFrames(kMdiCascade); }
199  virtual void TileHorizontal() { ArrangeFrames(kMdiTileHorizontal); }
200  virtual void TileVertical() { ArrangeFrames(kMdiTileVertical); }
201 
202  virtual void ArrangeFrames(Int_t mode);
203  virtual void ArrangeMinimized();
204 
205  virtual void CirculateUp();
206  virtual void CirculateDown();
207 
208  TGMdiFrame *GetCurrent() const;
209  TGMdiFrame *GetMdiFrame(UInt_t id) const;
210  TGFrame *GetContainer() const { return fContainer; }
211  Bool_t SetCurrent(UInt_t newcurrent);
212  Bool_t SetCurrent(TGMdiFrame *f); //*SIGNAL*
213 
214  TGPopupMenu *GetWinListMenu() const { return fWinListMenu; }
215  TGMdiMenuBar *GetMenu() const { return fMenuBar; }
216 
218  { return current ? fCurrent : fChildren; }
219  Long_t GetNumberOfFrames() const { return fNumberOfFrames; }
220 
221  void SetResizeMode(Int_t mode = kMdiDefaultResizeMode);
222  void UpdateMdiButtons();
223 
224  TGRectangle GetBBox() const;
225  TGRectangle GetMinimizedBBox() const;
226 
228  void ConfigureWindow(TGMdiFrame *f, TGMdiGeometry &geom);
229 
230  Bool_t IsMaximized(TGMdiFrame *f);
231  Bool_t IsMinimized(TGMdiFrame *f);
232 
233  virtual void FrameCreated(Int_t id) { Emit("FrameCreated(Int_t)", id); } //*SIGNAL*
234  virtual void FrameClosed(Int_t id) { Emit("FrameClosed(Int_t)", id); } //*SIGNAL*
235  virtual void FrameMaximized(Int_t id) { Emit("FrameMaximized(Int_t)", id); } //*SIGNAL*
236  virtual void FrameMinimized(Int_t id) { Emit("FrameMinimized(Int_t)", id); } //*SIGNAL*
237  virtual void FrameRestored(Int_t id) { Emit("FrameRestored(Int_t)", id); } //*SIGNAL*
238  virtual void FramesArranged(Int_t mode) { Emit("FramesArranged(Int_t)", mode); } //*SIGNAL*
239 
240  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
241 
242  ClassDef(TGMdiMainFrame, 0) // MDI main frame
243 };
244 
245 
246 //----------------------------------------------------------------------
247 
248 class TGMdiContainer : public TGFrame {
249 
250 protected:
251  const TGMdiMainFrame *fMain; // pointer to MDI main frame
252 
253 public:
255  UInt_t options = 0,
256  ULong_t back = GetDefaultFrameBackground());
257 
258  virtual Bool_t HandleConfigureNotify(Event_t *event);
259  virtual TGDimension GetDefaultSize() const;
260 
261  ClassDef(TGMdiContainer, 0) // MDI container
262 };
263 
264 #endif
TGMdiMenuBar * GetMenu() const
EMdiHints
TGPopupMenu * fWinListMenu
virtual void TileVertical()
void SetDecorFrame(TGMdiDecorFrame *decor)
virtual void TileHorizontal()
virtual Bool_t HandleKey(Event_t *)
Definition: TGFrame.h:403
const char Option_t
Definition: RtypesCore.h:62
TGRectangle fIcon
#define BIT(n)
Definition: Rtypes.h:120
virtual void FrameCreated(Int_t id)
TH1 * h
Definition: legend2.C:5
virtual void FrameRestored(Int_t id)
TGFrame * fContainer
virtual void FrameClosed(Int_t id)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
void SetCycleNext(TGMdiFrameList *next)
TGMdiDecorFrame * fDecor
virtual ~TGMdiFrameList()
const TGMdiMainFrame * fMain
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
TGMdiMenuBar * fMenuBar
void SetNext(TGMdiFrameList *next)
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a MDIframe as a C++ statement(s) on output stream out.
Definition: TGMdiFrame.cxx:190
void SetFrameId(UInt_t id)
XFontStruct * id
Definition: TGX11.cxx:108
TGMdiFrameList * fCurrent
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:561
virtual void FrameMinimized(Int_t id)
Long_t GetNumberOfFrames() const
virtual void FrameMaximized(Int_t id)
Pixel_t fForeNotCurrent
TGMdiFrameList * fChildren
Long_t fNumberOfFrames
TGMdiFrameList * GetCycleNext() const
void SetPrev(TGMdiFrameList *prev)
unsigned int UInt_t
Definition: RtypesCore.h:42
TGMdiFrameList * GetNext() const
EMdiResizingModes
TGMdiFrameList * GetCyclePrev() const
virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t)
Definition: TGFrame.h:411
TGPopupMenu * GetWinListMenu() const
long Long_t
Definition: RtypesCore.h:50
double f(double x)
Definition: TGFont.h:155
unsigned long ULong_t
Definition: RtypesCore.h:51
virtual void Cascade()
EMdiGeometryMask
TGFrame * GetContainer() const
TGMdiFrameList * fCyclePrev
TGMdiFrameList * fCycleNext
TGMdiFrameList * fPrev
RooCmdArg Layout(Double_t xmin, Double_t xmax=0.99, Double_t ymin=0.95)
TGMdiDecorFrame * GetDecorFrame() const
TGFont * fFontNotCurrent
UInt_t GetFrameId() const
TGMdiFrameList * fNext
TGMdiFrameList * GetPrev() const
void SetCyclePrev(TGMdiFrameList *prev)
EMdiArrangementModes
Pixel_t fForeCurrent
friend class TGMdiMainFrame
Definition: TGGC.h:35
virtual void FramesArranged(Int_t mode)
TGMdiFrameList * GetWindowList(Int_t current=kFALSE) const
void GetWindowGeometry(NSObject< X11Window > *win, WindowAttributes_t *dst)
virtual ~TGMdiGeometry()