Logo ROOT   6.10/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 #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  TGWindow(const TGWindow *p = 0, Int_t x = 0, Int_t y = 0,
71  UInt_t w = 0, UInt_t h = 0, UInt_t border = 0,
72  Int_t depth = 0,
73  UInt_t clss = 0,
74  void *visual = 0,
75  SetWindowAttributes_t *attr = 0,
76  UInt_t wtype = 0);
77  TGWindow(TGClient *c, Window_t id, const TGWindow *parent = 0);
78 
79  virtual ~TGWindow();
80 
81  const TGWindow *GetParent() const { return fParent; }
82  virtual const TGWindow *GetMainFrame() const;
83 
84  virtual void MapWindow() { gVirtualX->MapWindow(fId); }
85  virtual void MapSubwindows() { gVirtualX->MapSubwindows(fId); }
86  virtual void MapRaised() { gVirtualX->MapRaised(fId); }
87  virtual void UnmapWindow() { gVirtualX->UnmapWindow(fId); }
88  virtual void DestroyWindow() { gVirtualX->DestroyWindow(fId); }
89  virtual void DestroySubwindows() { gVirtualX->DestroySubwindows(fId); }
90  virtual void RaiseWindow() { gVirtualX->RaiseWindow(fId); }
91  virtual void LowerWindow() { gVirtualX->LowerWindow(fId); }
92  virtual void IconifyWindow() { gVirtualX->IconifyWindow(fId); }
93  virtual void ReparentWindow(const TGWindow *p, Int_t x = 0, Int_t y = 0);
94  virtual void RequestFocus() { gVirtualX->SetInputFocus(fId); }
95 
96  virtual void SetBackgroundColor(Pixel_t color)
97  { gVirtualX->SetWindowBackground(fId, color); }
98  virtual void SetBackgroundPixmap(Pixmap_t pixmap)
99  { gVirtualX->SetWindowBackgroundPixmap(fId, pixmap); }
100 
101  virtual Bool_t HandleExpose(Event_t *event)
102  { if (event->fCount == 0) fClient->NeedRedraw(this); return kTRUE; }
103  virtual Bool_t HandleEvent(Event_t *) { return kFALSE; }
104  virtual Bool_t HandleTimer(TTimer *) { return kFALSE; }
106 
107  virtual void Move(Int_t x, Int_t y);
108  virtual void Resize(UInt_t w, UInt_t h);
109  virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h);
110  virtual Bool_t IsMapped();
111  virtual Bool_t IsEditable() const { return (fClient->GetRoot() == this); }
112  virtual UInt_t GetEditDisabled() const { return fEditDisabled; }
113  virtual void SetEditDisabled(UInt_t on = kEditDisable) { fEditDisabled = on; }
114  virtual void SetEditable(Bool_t on = kTRUE)
115  { if (!(fEditDisabled & kEditDisable)) fClient->SetRoot(on ? this : 0); }
116  virtual Int_t MustCleanup() const { return 0; }
117  virtual void Print(Option_t *option="") const;
118 
119  virtual void SetWindowName(const char *name = 0);
120  virtual const char *GetName() const;
121  virtual void SetName(const char *name) { fName = name; }
122 
123  virtual void SetMapSubwindows(Bool_t /*on*/) { }
124  virtual Bool_t IsMapSubwindows() const { return kTRUE; }
125 
126  static Int_t GetCounter();
127 
128  ClassDef(TGWindow, 0); // GUI Window base class
129 };
130 
131 
132 //////////////////////////////////////////////////////////////////////////
133 // //
134 // TGUnknownWindowHandler //
135 // //
136 // Handle events for windows that are not part of the native ROOT GUI. //
137 // Typically windows created by Xt or Motif. //
138 // //
139 //////////////////////////////////////////////////////////////////////////
140 
142 
143 public:
146 
147  virtual Bool_t HandleEvent(Event_t *) = 0;
148 
149  ClassDef(TGUnknownWindowHandler,0) // Abstract event handler for unknown windows
150 };
151 
152 #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:112
void SetRoot(TGWindow *root=0)
Sets the current root (i.e.
Definition: TGClient.cxx:242
virtual Bool_t HandleIdleEvent(TGIdleHandler *)
Definition: TGWindow.h:105
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:75
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:85
virtual void MapWindow()
Definition: TGWindow.h:84
Basic string class.
Definition: TString.h:129
virtual ~TGUnknownWindowHandler()
Definition: TGWindow.h:145
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t IsMapSubwindows() const
Definition: TGWindow.h:124
virtual Bool_t HandleTimer(TTimer *)
Execute action in response of a timer timing out.
Definition: TGWindow.h:104
virtual void DestroySubwindows()
Definition: TGWindow.h:89
virtual Int_t MustCleanup() const
Definition: TGWindow.h:116
TGWindow(Window_t id)
Definition: TGWindow.h:43
virtual void LowerWindow()
Definition: TGWindow.h:91
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:297
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:121
virtual Bool_t HandleExpose(Event_t *event)
Definition: TGWindow.h:101
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
virtual void Print(Option_t *option="") const
Print window id.
Definition: TGWindow.cxx:192
virtual void RequestFocus()
Definition: TGWindow.h:94
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:98
#define gVirtualX
Definition: TVirtualX.h:350
const Bool_t kFALSE
Definition: RtypesCore.h:92
virtual void MapRaised()
Definition: TGWindow.h:86
virtual void Move(Int_t x, Int_t y)
Move the window.
Definition: TGWindow.cxx:156
virtual void IconifyWindow()
Definition: TGWindow.h:92
virtual Bool_t HandleEvent(Event_t *)
Definition: TGWindow.h:103
virtual void RaiseWindow()
Definition: TGWindow.h:90
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:81
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:96
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition: TGWindow.h:113
virtual Bool_t IsEditable() const
Definition: TGWindow.h:111
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:123
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:87
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual void SetEditable(Bool_t on=kTRUE)
Definition: TGWindow.h:114
virtual void DestroyWindow()
Definition: TGWindow.h:88
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118