ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
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
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; }
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
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  }
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; }
316  Int_t GetMinimizedX() const { return fMinimizedX; }
317  Int_t GetMinimizedY() const { return fMinimizedY; }
319 
320  void SetCurrent(Bool_t cur = kTRUE) {fIsCurrent = cur; }
321  void SetDecorBorderWidth(Int_t bw);
331 
332  TGMdiFrame *GetMdiFrame() const { return fFrame; }
333  TGMdiTitleBar *GetTitleBar() const { return fTitlebar; }
334 
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(const TGWindow *p, const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew, Int_t mdioptions=kMdiDefaultResizeMode, Int_t w=20, Int_t h=20)
TGMdiCornerWinResizer constructor.
void Maximize(Bool_t max=kTRUE)
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
TGCompositeFrame * fRFrame
TGMdiVerticalWinResizer * fUpperHR
TGMdiHorizontalWinResizer * GetRightVR() const
TGCompositeFrame * fMFrame
Int_t GetPreResizeY() const
void SetMdiButtons(ULong_t buttons)
Set-up MDI buttons.
virtual Bool_t HandleMotion(Event_t *event)
Handle motion events in resizer (resize associated MDI window).
TGMdiTitleIcon(const TGWindow *p, const TGWindow *titlebar, const TGPicture *pic, Int_t w, Int_t h)
TGMdiTitleIcon constructor.
Bool_t fRightButPressed
void SetDecorBorderWidth(Int_t bw)
Set border width of the decor.
TGMdiTitleIcon * fWinIcon
TGMdiVerticalWinResizer * fLowerHR
void SetLeftButPressed(Bool_t press=kTRUE)
TH1 * h
Definition: legend2.C:5
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion events in title bar (used to move MDI window).
virtual void DoRedraw()
Redraw icon.
TGPopupMenu * GetPopup() const
Bool_t IsCurrent() const
virtual ~TGMdiTitleIcon()
TGMdiTitleIcon destructor.
TGLayoutHints * fLHint
TGCompositeFrame * fLFrame
virtual Int_t CloseWindow()
TGLayoutHints * fMiddleHint
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t fMinimizedUserPlacement
virtual void DrawBorder()
Draw corner resizer frame border.
void SetTitleBarColors(UInt_t fore, UInt_t back, TGFont *f)
Set title bar color (blue or grey, depends on active state).
Bool_t fLeftButPressed
TGLayoutHints * fLHint
void SetX0(Int_t x0)
virtual void DrawBorder()
Draw vertical resizer frame border.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse click on title bar.
EMdiResizerPlacement
TFile * f
TGLayoutHints * fCloseHint
void Minimize(Bool_t min=kTRUE)
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages for title bar.
virtual ~TGMdiTitleBar()
TGMdiTitleBar destructor.
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
virtual void Move(Int_t x, Int_t y)
Move the MDI window at position x, y.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button events.
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)
Int_t GetMinimizedX() const
TGMdiCornerWinResizer * fLowerLeftCR
TGPopupMenu * fPopup
TGPictureButton * GetButton(Int_t no) const
TGLayoutHints * fRightHint
void SetY0(Int_t y0)
void SetMidButPressed(Bool_t press=kTRUE)
TGMdiButtons * fButtons
Int_t GetMinimizedY() const
TGMdiButtons * GetButtons() const
virtual Bool_t HandleMotion(Event_t *event)
Handle motion events in resizer (resize associated MDI window).
virtual Bool_t HandleMotion(Event_t *event)
Handle motion events in resizer (resize associated MDI window).
virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
Move the MDI window at position x, y and set size to w, h.
void SetPreResizeY(Int_t y)
TGMdiTitleBar(const TGWindow *p, const TGWindow *mdiwin, const char *name="Untitled")
TGMdiTitleBar constructor.
TGLabel * fWinName
Bool_t IsMaximized() const
void RemoveFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
This is called from TGMdiMainFrame on Maximize().
tuple main
Definition: hsum.py:20
TGMdiFrame * fFrame
TGMdiTitleIcon * GetWinIcon() const
TGMdiButtons(const TGWindow *p, const TGWindow *titlebar)
TGMdiButtons constructor.
Bool_t GetMinUserPlacement() const
TGLayoutHints * fExpandHint
TGMdiTitleBar * fTitlebar
unsigned int UInt_t
Definition: RtypesCore.h:42
tuple w
Definition: qtexample.py:51
TGMdiCornerWinResizer * fLowerRightCR
TGMdiTitleBar * GetTitleBar() const
TGMdiHorizontalWinResizer * fRightVR
const TGPicture * GetWindowIcon()
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handle configure notify event.
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click in title bar (maximize window)
TGPictureButton * fButton[5]
long Long_t
Definition: RtypesCore.h:50
TGMdiDecorFrame(TGMdiMainFrame *main, TGMdiFrame *frame, Int_t w, Int_t h, const TGGC *boxGC, UInt_t options=0, Pixel_t back=GetDefaultFrameBackground())
const TGGC * fBoxGC
void SetWindowIcon(const TGPicture *pic)
Set Window icon (appearing in the title bar)
TGMdiCornerWinResizer * GetUpperLeftCR() const
Int_t GetPreResizeWidth() const
virtual Bool_t CloseWindow()
Close MDI frame window.
Definition: TGMdiFrame.cxx:74
Bool_t IsMidButPressed()
Int_t GetPreResizeX() const
ULong_t GetMdiButtons() const
TGMdiFrame * GetMdiFrame() const
const char * GetWindowName()
Definition: TGFont.h:155
unsigned long ULong_t
Definition: RtypesCore.h:51
TGMdiCornerWinResizer * GetLowerRightCR() const
Double_t y[n]
Definition: legend1.C:17
void SetMinimizedX(Int_t x)
Bool_t IsMinimized() const
virtual void DrawBorder()
Draw frame border.
virtual ~TGMdiDecorFrame()
TGMdiDecorFrame destructor.
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click event on MDI icon (close the window)
#define name(a, b)
Definition: linkTestLib0.cpp:5
TGMdiHorizontalWinResizer(const TGWindow *p, const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew, Int_t mdioptions=kMdiDefaultResizeMode, Int_t w=5, Int_t h=4)
TGMdiHorizontalWinResizer constructor.
const TGPicture * GetPicture() const
Definition: TGIcon.h:57
const TGWindow * fMdiWin
TGLayoutHints * fLeftHint
void LayoutButtons(UInt_t buttonmask, Bool_t isMinimized, Bool_t isMaximized)
Recalculates the position of every enabled (displayed) buttons.
TGMdiVerticalWinResizer(const TGWindow *p, const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew, Int_t mdioptions=kMdiDefaultResizeMode, Int_t w=4, Int_t h=5)
TGMdiVerticalWinResizer constructor.
void SetPreResizeWidth(Int_t w)
void SetCurrent(Bool_t cur=kTRUE)
TGMdiCornerWinResizer * fUpperRightCR
TGMdiVerticalWinResizer * GetUpperHR() const
TGMdiCornerWinResizer * GetUpperRightCR() const
const TGString * GetText() const
Definition: TGLabel.h:88
virtual void Layout()
Recalculates the postion and the size of all decor frame components.
void AddFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
This is called from TGMdiMainFrame on Restore().
TGMdiHorizontalWinResizer * fLeftVR
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.
const char * GetString() const
Definition: TGString.h:44
TGLayoutHints * fDefaultHint
Bool_t IsLeftButPressed()
void SetMinSize(Int_t w=50, Int_t h=20)
virtual ~TGMdiButtons()
TGMdiButtons destructor.
void MoveResizeIt()
Move (resize) parent MDI window.
const TGWindow * fMdiWin
TGLabel * GetWinName() const
const Bool_t kTRUE
Definition: Rtypes.h:91
TGMdiMainFrame * fMdiMainFrame
void SetWindowName(const char *name)
Set MDI Window name (appearing in the title bar)
virtual void DrawBorder()
Draw horizontal resizer frame border.
const TGWindow * fMsgWindow
Definition: TGGC.h:35
TGMdiVerticalWinResizer * GetLowerHR() const
void SetResizeMode(Int_t mode=kMdiDefaultResizeMode)
Set resize mode (opaque or transparent)
TGMdiHorizontalWinResizer * GetLeftVR() const
TGMdiCornerWinResizer * GetLowerLeftCR() const
void SetResizeMode(Int_t mode)
Int_t GetPreResizeHeight() const
virtual Bool_t HandleButton(Event_t *event)
Handle button event on MDI icon (popup menu)
Bool_t IsRightButPressed()
void SetRightButPressed(Bool_t press=kTRUE)