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