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