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