Logo ROOT   6.08/07
Reference Guide
TGMdiDecorFrame.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 #ifndef ROOT_TGMdiDecorFrame
13 #define ROOT_TGMdiDecorFrame
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TGMdiDecorFrame, TGMdiTitleBar, TGMdiButtons, TGMdiTitleIcon, //
18 // TGMdiWinResizer, TGMdiVerticalWinResizer, TGMdiHorizontalWinResizer, //
19 // and TGMdiCornerWinResizer. //
20 // //
21 // This header contains all different MDI frame decoration classes. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #ifndef ROOT_TGFrame
26 #include "TGFrame.h"
27 #endif
28 #ifndef ROOT_TGMenu
29 #include "TGMenu.h"
30 #endif
31 #ifndef ROOT_TGButton
32 #include "TGButton.h"
33 #endif
34 #ifndef ROOT_TGIcon
35 #include "TGIcon.h"
36 #endif
37 #ifndef ROOT_TGLabel
38 #include "TGLabel.h"
39 #endif
40 #ifndef ROOT_TGFont
41 #include "TGFont.h"
42 #endif
43 #ifndef ROOT_TGMdiMainFrame
44 #include "TGMdiMainFrame.h"
45 #endif
46 #ifndef ROOT_TGMdiFrame
47 #include "TGMdiFrame.h"
48 #endif
49 
50 
51 // placement of window resizers
57 };
58 
59 
60 class TGMdiMainFrame;
61 class TGMdiDecorFrame;
62 class TGMdiFrame;
63 class TGMdiTitleBar;
64 class TGMdiTitleIcon;
65 class TGMdiButtons;
66 
67 
68 //----------------------------------------------------------------------
69 
70 class TGMdiWinResizer : public TGFrame, public TGWidget {
71 
72 friend class TGMdiMainFrame;
73 
74 protected:
75  const TGWindow *fMdiWin; // owner MDI Window
76  Int_t fWinX, fWinY, fWinW, fWinH; // MDI win position and dimension
77  Int_t fOldX, fOldY, fOldW, fOldH; // old MDI win position and dimension
78  Int_t fNewX, fNewY, fNewW, fNewH; // new MDI win position and dimension
79  Int_t fMinW, fMinH; // Min width and height of the MDI Win
80  Int_t fMdiOptions; // MDI options
81  Int_t fPos; // position of the resizer
82  Int_t fX0, fY0; // initial position of the mouse click
84 
85  const TGGC *fBoxGC; // GC used for resizing rectangle
86  Int_t fLineW; // line width of resizing rectangle
87 
88  void MoveResizeIt();
89  void DrawBox(Int_t x, Int_t y, UInt_t width, UInt_t height);
90 
91 public:
92  TGMdiWinResizer(const TGWindow *p, const TGWindow *mdiwin, Int_t pos,
93  const TGGC *boxGC, Int_t linew,
94  Int_t mdioptions = kMdiDefaultResizeMode,
95  Int_t w = 1, Int_t h = 1, UInt_t options = kOwnBackground);
96 
97  virtual Bool_t HandleButton(Event_t *event);
98  virtual void DrawBorder() {};
99 
100  void SetResizeMode(Int_t mode) { fMdiOptions = mode; }
101  void SetMinSize(Int_t w = 50, Int_t h = 20) { fMinW = w; fMinH = h; }
102 
103  ClassDef(TGMdiWinResizer, 0) // Window Resizer
104 };
105 
106 
108 
109 public:
110  TGMdiVerticalWinResizer(const TGWindow *p, const TGWindow *mdiwin,
111  Int_t pos, const TGGC *boxGC, Int_t linew,
112  Int_t mdioptions = kMdiDefaultResizeMode,
113  Int_t w = 4, Int_t h = 5);
114 
115  virtual Bool_t HandleMotion(Event_t *event);
116  virtual void DrawBorder();
117 
118  ClassDef(TGMdiVerticalWinResizer, 0) // Vertical Window Resizer
119 };
120 
121 
123 
124 public:
125  TGMdiHorizontalWinResizer(const TGWindow *p, const TGWindow *mdiwin,
126  Int_t pos, const TGGC *boxGC, Int_t linew,
127  Int_t mdioptions = kMdiDefaultResizeMode,
128  Int_t w = 5, Int_t h = 4);
129 
130  virtual Bool_t HandleMotion(Event_t *event);
131  virtual void DrawBorder();
132 
133  ClassDef(TGMdiHorizontalWinResizer, 0) // Horizontal Window Resizer
134 };
135 
136 
138 
139 public:
140  TGMdiCornerWinResizer(const TGWindow *p, const TGWindow *mdiwin,
141  Int_t pos, const TGGC *boxGC, Int_t linew,
142  Int_t mdioptions = kMdiDefaultResizeMode,
143  Int_t w = 20, Int_t h = 20);
144 
145  virtual Bool_t HandleMotion(Event_t *event);
146  virtual void DrawBorder();
147 
148  ClassDef(TGMdiCornerWinResizer, 0) // Corner Window Resizer
149 };
150 
151 
152 //----------------------------------------------------------------------
153 
155 
156 friend class TGMdiTitleBar;
157 
158 protected:
159  TGPictureButton *fButton[5]; // MDI picture buttons
160  TGLayoutHints *fDefaultHint, *fCloseHint; // Layout hints
161  const TGWindow *fMsgWindow; // window handling container messages
162 
163 public:
164  TGMdiButtons(const TGWindow *p, const TGWindow *titlebar);
165  virtual ~TGMdiButtons();
166 
167  TGPictureButton *GetButton(Int_t no) const { return fButton[no]; }
168 
169  ClassDef(TGMdiButtons, 0) // MDI Buttons Frame
170 };
171 
172 
173 //----------------------------------------------------------------------
174 
175 class TGMdiTitleIcon : public TGIcon {
176 
177 friend class TGMdiFrame;
178 friend class TGMdiTitleBar;
179 
180 protected:
181  const TGWindow *fMsgWindow; // window handling container messages
182  TGPopupMenu *fPopup; // Popup menu associated to the title icon
183 
184  virtual void DoRedraw();
185 
186 public:
187  TGMdiTitleIcon(const TGWindow *p, const TGWindow *titlebar,
188  const TGPicture *pic, Int_t w, Int_t h);
189  virtual ~TGMdiTitleIcon();
190 
191  virtual Bool_t HandleDoubleClick(Event_t *event);
192  virtual Bool_t HandleButton(Event_t *event);
193  TGPopupMenu *GetPopup() const { return fPopup; }
194 
195  ClassDef(TGMdiTitleIcon, 0) // MDI Title Icon
196 };
197 
198 
199 //----------------------------------------------------------------------
200 
202 
203 friend class TGMdiDecorFrame;
204 friend class TGMdiMainFrame;
205 
206 protected:
207  const TGWindow *fMdiWin; // owner MDI window
208  TGMdiButtons *fButtons; // MDI buttons
209  TGMdiTitleIcon *fWinIcon; // title icon
210  TGLabel *fWinName; // window name label
211  TGCompositeFrame *fLFrame, *fMFrame,*fRFrame; // the three parts of the title bar
212  TGLayoutHints *fLHint, *fLeftHint, *fMiddleHint, *fRightHint; // layout hints
213  Int_t fX0, fY0; // initial position of the mouse click
215 
216  TGMdiTitleBar(const TGWindow *p, const TGWindow *mdiwin,
217  const char *name = "Untitled");
218  void LayoutButtons(UInt_t buttonmask, Bool_t isMinimized,
219  Bool_t isMaximized);
220 
221  void AddFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons);
222  void RemoveFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons);
223 
224 public:
225  virtual ~TGMdiTitleBar();
226 
227  virtual Bool_t HandleButton(Event_t *event);
228  virtual Bool_t HandleDoubleClick(Event_t *event);
229  virtual Bool_t HandleMotion(Event_t *event);
230  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
231 
232  void SetTitleBarColors(UInt_t fore, UInt_t back, TGFont *f);
233  TGMdiButtons *GetButtons() const { return fButtons; }
234  TGMdiTitleIcon *GetWinIcon() const { return fWinIcon; }
235  TGLabel *GetWinName() const { return fWinName; }
236  Int_t GetX0() { return fX0; }
237  Int_t GetY0() { return fY0; }
241 
242  void SetX0(Int_t x0) { fX0 = x0; }
243  void SetY0(Int_t y0) { fY0 = y0; }
244  void SetLeftButPressed(Bool_t press = kTRUE) { fLeftButPressed = press; }
245  void SetRightButPressed(Bool_t press = kTRUE) { fRightButPressed= press; }
246  void SetMidButPressed(Bool_t press = kTRUE) { fMidButPressed = press; }
247 
248  ClassDef(TGMdiTitleBar, 0) // MDI Title Bar
249 };
250 
251 
252 //----------------------------------------------------------------------
253 
255 
256 friend class TGMdiMainFrame;
257 
258 protected:
259  Int_t fPreResizeX, fPreResizeY; // position before resizing
260  Int_t fPreResizeWidth, fPreResizeHeight; // dimension before resizing
261  Int_t fMinimizedX, fMinimizedY; // minimized position
262  Bool_t fIsMinimized, fIsMaximized; // minimized and maximized flags
263  Bool_t fMinimizedUserPlacement; // user placement flag
264  Bool_t fIsCurrent; // current mdi window flag
265 
266  TGMdiFrame *fFrame; // parent (owner) MDI frame
267  TGMdiMainFrame *fMdiMainFrame; // MDI main frame
268 
269  TGMdiVerticalWinResizer *fUpperHR, *fLowerHR; // upper and lower vertical resizers
270  TGMdiCornerWinResizer *fUpperLeftCR, *fLowerLeftCR; // upper left and lower left resizers
271  TGMdiCornerWinResizer *fUpperRightCR, *fLowerRightCR; // upper right and lower right resizers
272  TGMdiHorizontalWinResizer *fLeftVR, *fRightVR; // left and right horizontal resizers
273  TGLayoutHints *fLHint, *fExpandHint; // layout hints
274 
275  ULong_t fButtonMask; // mask used to display/hide buttons
276  TGMdiTitleBar *fTitlebar; // MDI window title bar
277 
278 public:
279  enum {
280  // border width of decorated windows
281  kMdiBorderWidth = 5
282  };
283 
285  const TGGC *boxGC, UInt_t options = 0,
287  virtual ~TGMdiDecorFrame();
288 
289  virtual Bool_t HandleButton(Event_t *event);
290  virtual Bool_t HandleConfigureNotify(Event_t *event);
291 
292  virtual Int_t CloseWindow() { return fFrame->CloseWindow(); }
293  virtual void Layout();
294 
295  virtual void Move(Int_t x, Int_t y);
296  virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h);
297 
298  void SetMdiButtons(ULong_t buttons);
299  ULong_t GetMdiButtons() const { return fButtonMask; }
300 
302 
303  void SetWindowName(const char *name);
304  void SetWindowIcon(const TGPicture *pic);
305  const char *GetWindowName() {
306  return (const char *)fTitlebar->GetWinName()->GetText()->GetString();
307  }
308  const TGPicture *GetWindowIcon() { return fTitlebar->GetWinIcon()->GetPicture(); }
309  Bool_t IsCurrent() const { return fIsCurrent; }
310  Bool_t IsMinimized() const { return fIsMinimized; }
311  Bool_t IsMaximized() const { return fIsMaximized; }
312  Int_t GetPreResizeX() const { return fPreResizeX; }
313  Int_t GetPreResizeY() const { return fPreResizeY; }
314  Int_t GetPreResizeWidth() const { return fPreResizeWidth; }
315  Int_t GetPreResizeHeight() const { return fPreResizeHeight; }
316  Int_t GetMinimizedX() const { return fMinimizedX; }
317  Int_t GetMinimizedY() const { return fMinimizedY; }
318  Bool_t GetMinUserPlacement() const { return fMinimizedUserPlacement; }
319 
320  void SetCurrent(Bool_t cur = kTRUE) {fIsCurrent = cur; }
321  void SetDecorBorderWidth(Int_t bw);
322  void SetPreResizeX(Int_t x) { fPreResizeX = x; }
323  void SetPreResizeY(Int_t y) { fPreResizeY = y; }
324  void SetPreResizeWidth(Int_t w) { fPreResizeWidth = w; }
325  void SetPreResizeHeight(Int_t h) { fPreResizeHeight = h; }
326  void SetMinimizedX(Int_t x) { fMinimizedX = x; }
327  void SetMinimizedY(Int_t y) { fMinimizedY = y; }
328  void Minimize(Bool_t min = kTRUE) { fIsMinimized = min; }
329  void Maximize(Bool_t max = kTRUE) { fIsMaximized = max; }
330  void SetMinUserPlacement(Bool_t place = kTRUE) { fMinimizedUserPlacement = place; }
331 
332  TGMdiFrame *GetMdiFrame() const { return fFrame; }
333  TGMdiTitleBar *GetTitleBar() const { return fTitlebar; }
334 
335  TGMdiVerticalWinResizer *GetUpperHR() const { return fUpperHR; }
336  TGMdiVerticalWinResizer *GetLowerHR() const { return fLowerHR; }
337  TGMdiCornerWinResizer *GetUpperLeftCR() const { return fUpperLeftCR; }
338  TGMdiCornerWinResizer *GetLowerLeftCR() const { return fLowerLeftCR; }
339  TGMdiCornerWinResizer *GetUpperRightCR() const { return fUpperRightCR; }
340  TGMdiCornerWinResizer *GetLowerRightCR() const { return fLowerRightCR; }
341  TGMdiHorizontalWinResizer *GetLeftVR() const { return fLeftVR; }
342  TGMdiHorizontalWinResizer *GetRightVR() const { return fRightVR; }
343 
344  ClassDef(TGMdiDecorFrame, 0) // MDI Decor Frame
345 };
346 
347 #endif
void SetMinUserPlacement(Bool_t place=kTRUE)
virtual Bool_t HandleButton(Event_t *event)
Handle button events in resizer (grab button and resize).
TGMdiCornerWinResizer * fUpperLeftCR
void SetPreResizeHeight(Int_t h)
TGMdiCornerWinResizer * GetLowerLeftCR() const
void Maximize(Bool_t max=kTRUE)
virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t)
Definition: TGFrame.h:246
Int_t GetPreResizeY() const
TGCompositeFrame * fRFrame
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGFrame.cxx:611
TGMdiVerticalWinResizer * fUpperHR
Bool_t IsCurrent() const
Bool_t fRightButPressed
TGMdiTitleIcon * fWinIcon
const TGString * GetText() const
Definition: TGLabel.h:88
void SetLeftButPressed(Bool_t press=kTRUE)
TH1 * h
Definition: legend2.C:5
virtual Int_t CloseWindow()
Int_t GetMinimizedX() const
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t fMinimizedUserPlacement
TGLayoutHints * fLHint
void SetX0(Int_t x0)
EMdiResizerPlacement
TGPopupMenu * GetPopup() const
void Minimize(Bool_t min=kTRUE)
virtual void DoRedraw()
Redraw the frame.
Definition: TGFrame.cxx:412
const TGWindow * fMsgWindow
void SetMinimizedY(Int_t y)
Double_t x[n]
Definition: legend1.C:17
#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
Int_t GetMinimizedY() const
Bool_t IsMinimized() const
void DrawBox(Int_t x, Int_t y, UInt_t width, UInt_t height)
Draw resize box (rectangle).
Definition: TGIcon.h:34
void SetPreResizeX(Int_t x)
virtual void Layout()
Definition: TGFrame.h:262
TGPopupMenu * fPopup
const TGPicture * GetPicture() const
Definition: TGIcon.h:57
TGLayoutHints * fRightHint
void SetY0(Int_t y0)
void SetMidButPressed(Bool_t press=kTRUE)
TGLabel * GetWinName() const
TGMdiButtons * fButtons
TGMdiVerticalWinResizer * GetUpperHR() const
TGMdiHorizontalWinResizer * GetRightVR() const
ULong_t GetMdiButtons() const
Int_t GetPreResizeX() const
TGMdiVerticalWinResizer * GetLowerHR() const
Int_t GetPreResizeHeight() const
void SetPreResizeY(Int_t y)
TGLabel * fWinName
virtual Bool_t HandleMotion(Event_t *)
Definition: TGFrame.h:227
TGMdiFrame * fFrame
TGMdiTitleBar * fTitlebar
TGMdiTitleIcon * GetWinIcon() const
unsigned int UInt_t
Definition: RtypesCore.h:42
TGMdiCornerWinResizer * GetLowerRightCR() const
TGMdiHorizontalWinResizer * GetLeftVR() const
TGMdiHorizontalWinResizer * fRightVR
const TGPicture * GetWindowIcon()
Bool_t IsMaximized() const
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition: TGFrame.cxx:575
const char * GetString() const
Definition: TGString.h:44
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition: TGFrame.cxx:425
long Long_t
Definition: RtypesCore.h:50
const TGGC * fBoxGC
double f(double x)
virtual Bool_t CloseWindow()
Close MDI frame window.
Definition: TGMdiFrame.cxx:74
Bool_t IsMidButPressed()
Int_t GetPreResizeWidth() const
TGMdiCornerWinResizer * GetUpperRightCR() const
const char * GetWindowName()
Definition: TGFont.h:155
unsigned long ULong_t
Definition: RtypesCore.h:51
Double_t y[n]
Definition: legend1.C:17
TGPictureButton * GetButton(Int_t no) const
void SetMinimizedX(Int_t x)
virtual void DrawBorder()
Draw frame border.
TGMdiTitleBar * GetTitleBar() const
virtual Bool_t HandleDoubleClick(Event_t *)
Definition: TGFrame.h:225
const TGWindow * fMdiWin
void SetPreResizeWidth(Int_t w)
void SetCurrent(Bool_t cur=kTRUE)
TGMdiCornerWinResizer * fUpperRightCR
TGMdiWinResizer(const TGWindow *p, const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew, Int_t mdioptions=kMdiDefaultResizeMode, Int_t w=1, Int_t h=1, UInt_t options=kOwnBackground)
TGMdiWinResizer constructor.
TGLayoutHints * fDefaultHint
Bool_t IsLeftButPressed()
void SetMinSize(Int_t w=50, Int_t h=20)
TGMdiCornerWinResizer * GetUpperLeftCR() const
void MoveResizeIt()
Move (resize) parent MDI window.
const TGWindow * fMdiWin
const Bool_t kTRUE
Definition: Rtypes.h:91
TGMdiMainFrame * fMdiMainFrame
Bool_t GetMinUserPlacement() const
const TGWindow * fMsgWindow
Definition: TGGC.h:35
int main(int argc, char **argv)
char name[80]
Definition: TGX11.cxx:109
TGMdiButtons * GetButtons() const
void SetResizeMode(Int_t mode)
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118
TGMdiFrame * GetMdiFrame() const
Bool_t IsRightButPressed()
void SetRightButPressed(Bool_t press=kTRUE)