ROOT  6.06/09
Reference Guide
TGWindow.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 28/12/97
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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_TGWindow
13 #define ROOT_TGWindow
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGWindow //
19 // //
20 // ROOT GUI Window base class. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_TGObject
25 #include "TGObject.h"
26 #endif
27 #ifndef ROOT_TGClient
28 #include "TGClient.h"
29 #endif
30 #ifndef ROOT_TVirtualX
31 #include "TVirtualX.h"
32 #endif
33 
34 class TGClient;
35 class TGIdleHandler;
36 
37 
38 class TGWindow : public TGObject {
39 
40 friend class TGClient;
41 
42 protected:
43  const TGWindow *fParent; // Parent window
44  Bool_t fNeedRedraw; // kTRUE if window needs to be redrawn
45  TString fName; // name of the window used in SavePrimitive()
46  static Int_t fgCounter; // counter of created windows in SavePrimitive
47  UInt_t fEditDisabled; // flags used for "guibuilding"
48 
50  fParent(0), fNeedRedraw(kFALSE), fName(), fEditDisabled(0) { fClient = 0; fId = id; }
51  TGWindow(const TGWindow& tgw) :
52  TGObject(tgw), fParent(tgw.fParent), fNeedRedraw(tgw.fNeedRedraw),
53  fName(tgw.fName), fEditDisabled(tgw.fEditDisabled) { }
54 
56  { if (this!=&tgw) { TGObject::operator=(tgw); fParent=tgw.fParent;
57  fNeedRedraw=tgw.fNeedRedraw; fName=tgw.fName;
58  fEditDisabled=tgw.fEditDisabled; } return *this; }
59 
60  virtual void DoRedraw() { }
61 
62 public:
63  enum EEditMode {
64  kEditEnable = 0, // allow edit of this window
65  kEditDisable = BIT(0), // disable edit of this window
66  kEditDisableEvents = BIT(1), // window events cannot be editted
67  kEditDisableGrab = BIT(2), // window grab cannot be editted
68  kEditDisableLayout = BIT(3), // window layout cannot be editted
69  kEditDisableResize = BIT(4), // window size cannot be editted
70  kEditDisableHeight = BIT(5), // window height cannot be editted
71  kEditDisableWidth = BIT(6), // window width cannot be editted
72  kEditDisableBtnEnable = BIT(7), // window can handle mouse button events
73  kEditDisableKeyEnable = BIT(8) // window can handle keyboard events
74  };
75 
76  TGWindow(const TGWindow *p = 0, Int_t x = 0, Int_t y = 0,
77  UInt_t w = 0, UInt_t h = 0, UInt_t border = 0,
78  Int_t depth = 0,
79  UInt_t clss = 0,
80  void *visual = 0,
82  UInt_t wtype = 0);
83  TGWindow(TGClient *c, Window_t id, const TGWindow *parent = 0);
84 
85  virtual ~TGWindow();
86 
87  const TGWindow *GetParent() const { return fParent; }
88  virtual const TGWindow *GetMainFrame() const;
89 
90  virtual void MapWindow() { gVirtualX->MapWindow(fId); }
91  virtual void MapSubwindows() { gVirtualX->MapSubwindows(fId); }
92  virtual void MapRaised() { gVirtualX->MapRaised(fId); }
93  virtual void UnmapWindow() { gVirtualX->UnmapWindow(fId); }
94  virtual void DestroyWindow() { gVirtualX->DestroyWindow(fId); }
95  virtual void DestroySubwindows() { gVirtualX->DestroySubwindows(fId); }
96  virtual void RaiseWindow() { gVirtualX->RaiseWindow(fId); }
97  virtual void LowerWindow() { gVirtualX->LowerWindow(fId); }
98  virtual void IconifyWindow() { gVirtualX->IconifyWindow(fId); }
99  virtual void ReparentWindow(const TGWindow *p, Int_t x = 0, Int_t y = 0);
100  virtual void RequestFocus() { gVirtualX->SetInputFocus(fId); }
101 
102  virtual void SetBackgroundColor(Pixel_t color)
103  { gVirtualX->SetWindowBackground(fId, color); }
104  virtual void SetBackgroundPixmap(Pixmap_t pixmap)
105  { gVirtualX->SetWindowBackgroundPixmap(fId, pixmap); }
106 
107  virtual Bool_t HandleExpose(Event_t *event)
108  { if (event->fCount == 0) fClient->NeedRedraw(this); return kTRUE; }
109  virtual Bool_t HandleEvent(Event_t *) { return kFALSE; }
110  virtual Bool_t HandleTimer(TTimer *) { return kFALSE; }
112 
113  virtual void Move(Int_t x, Int_t y);
114  virtual void Resize(UInt_t w, UInt_t h);
115  virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h);
116  virtual Bool_t IsMapped();
117  virtual Bool_t IsEditable() const { return (fClient->GetRoot() == this); }
118  virtual UInt_t GetEditDisabled() const { return fEditDisabled; }
119  virtual void SetEditDisabled(UInt_t on = kEditDisable) { fEditDisabled = on; }
120  virtual void SetEditable(Bool_t on = kTRUE)
121  { if (!(fEditDisabled & kEditDisable)) fClient->SetRoot(on ? this : 0); }
122  virtual Int_t MustCleanup() const { return 0; }
123  virtual void Print(Option_t *option="") const;
124 
125  virtual void SetWindowName(const char *name = 0);
126  virtual const char *GetName() const;
127  virtual void SetName(const char *name) { fName = name; }
128 
129  virtual void SetMapSubwindows(Bool_t /*on*/) { }
130  virtual Bool_t IsMapSubwindows() const { return kTRUE; }
131 
132  static Int_t GetCounter();
133 
134  ClassDef(TGWindow,1) // GUI Window base class
135 };
136 
137 
138 //////////////////////////////////////////////////////////////////////////
139 // //
140 // TGUnknownWindowHandler //
141 // //
142 // Handle events for windows that are not part of the native ROOT GUI. //
143 // Typically windows created by Xt or Motif. //
144 // //
145 //////////////////////////////////////////////////////////////////////////
146 
148 
149 public:
152 
153  virtual Bool_t HandleEvent(Event_t *) = 0;
154 
155  ClassDef(TGUnknownWindowHandler,0) // Abstract event handler for unknown windows
156 };
157 
158 #endif
TGWindow & operator=(const TGWindow &tgw)
Definition: TGWindow.h:55
const TGWindow * fParent
Definition: TGWindow.h:43
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
void SetRoot(TGWindow *root=0)
Sets the current root (i.e.
Definition: TGClient.cxx:242
virtual Bool_t HandleIdleEvent(TGIdleHandler *)
Definition: TGWindow.h:111
virtual ~TGWindow()
Window destructor. Unregisters the window.
Definition: TGWindow.cxx:106
const TGWindow * GetParent() const
Definition: TGWindow.h:87
const char Option_t
Definition: RtypesCore.h:62
Int_t fCount
Definition: GuiTypes.h:184
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
#define BIT(n)
Definition: Rtypes.h:120
TH1 * h
Definition: legend2.C:5
static Int_t fgCounter
Definition: TGWindow.h:46
Bool_t fNeedRedraw
Definition: TGWindow.h:44
virtual void MapSubwindows()
Definition: TGWindow.h:91
virtual void MapWindow()
Definition: TGWindow.h:90
Basic string class.
Definition: TString.h:137
virtual ~TGUnknownWindowHandler()
Definition: TGWindow.h:151
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Bool_t HandleTimer(TTimer *)
Execute action in response of a timer timing out.
Definition: TGWindow.h:110
virtual void DestroySubwindows()
Definition: TGWindow.h:95
TGWindow(Window_t id)
Definition: TGWindow.h:49
virtual void LowerWindow()
Definition: TGWindow.h:97
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
virtual Int_t MustCleanup() const
Definition: TGWindow.h:122
virtual void ReparentWindow(const TGWindow *p, Int_t x=0, Int_t y=0)
Reparent window, make p the new parent and position the window at position (x,y) in new parent...
Definition: TGWindow.cxx:142
virtual Bool_t HandleEvent(Event_t *)=0
virtual void SetName(const char *name)
Definition: TGWindow.h:127
virtual Bool_t HandleExpose(Event_t *event)
Definition: TGWindow.h:107
XFontStruct * id
Definition: TGX11.cxx:108
virtual void RequestFocus()
Definition: TGWindow.h:100
virtual UInt_t GetEditDisabled() const
Definition: TGWindow.h:118
virtual void Print(Option_t *option="") const
Print window id.
Definition: TGWindow.cxx:192
virtual void Resize(UInt_t w, UInt_t h)
Resize the window.
Definition: TGWindow.cxx:164
unsigned int UInt_t
Definition: RtypesCore.h:42
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
virtual Bool_t IsEditable() const
Definition: TGWindow.h:117
virtual void DoRedraw()
Definition: TGWindow.h:60
TString fName
Definition: TGWindow.h:45
virtual void SetBackgroundPixmap(Pixmap_t pixmap)
Definition: TGWindow.h:104
#define gVirtualX
Definition: TVirtualX.h:362
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
virtual void MapRaised()
Definition: TGWindow.h:92
virtual void Move(Int_t x, Int_t y)
Move the window.
Definition: TGWindow.cxx:156
virtual void IconifyWindow()
Definition: TGWindow.h:98
virtual Bool_t HandleEvent(Event_t *)
Definition: TGWindow.h:109
virtual void RaiseWindow()
Definition: TGWindow.h:96
Double_t y[n]
Definition: legend1.C:17
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:180
TGObject & operator=(const TGObject &tgo)
Definition: TGObject.h:43
Handle_t fId
Definition: TGObject.h:40
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
Move and resize the window.
Definition: TGWindow.cxx:172
Handle_t Window_t
Definition: GuiTypes.h:30
virtual void SetBackgroundColor(Pixel_t color)
Definition: TGWindow.h:102
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition: TGWindow.h:119
TGClient * fClient
Definition: TGObject.h:41
static Int_t GetCounter()
Return global window counter (total number of created windows).
Definition: TGWindow.cxx:213
Handle_t Pixmap_t
Definition: GuiTypes.h:31
TGWindow(const TGWindow &tgw)
Definition: TGWindow.h:51
virtual void SetMapSubwindows(Bool_t)
Definition: TGWindow.h:129
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
UInt_t fEditDisabled
Definition: TGWindow.h:47
virtual void UnmapWindow()
Definition: TGWindow.h:93
virtual Bool_t IsMapSubwindows() const
Definition: TGWindow.h:130
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetEditable(Bool_t on=kTRUE)
Definition: TGWindow.h:120
virtual void DestroyWindow()
Definition: TGWindow.h:94
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118