Logo ROOT  
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 #include "TGObject.h"
17 #include "TGClient.h"
18 
19 class TGClient;
20 class TGIdleHandler;
21 
22 
23 class TGWindow : public TGObject {
24 
25 friend class TGClient;
26 
27 protected:
28  const TGWindow *fParent; ///< Parent window
29  Bool_t fNeedRedraw; ///< kTRUE if window needs to be redrawn
30  TString fName; ///< name of the window used in SavePrimitive()
31  static Int_t fgCounter; ///< counter of created windows in SavePrimitive
32  UInt_t fEditDisabled; ///< flags used for "guibuilding"
33 
35  fParent(0), fNeedRedraw(kFALSE), fName(), fEditDisabled(0) { fClient = 0; fId = id; }
36  TGWindow(const TGWindow& tgw) :
38  fName(tgw.fName), fEditDisabled(tgw.fEditDisabled) { }
39 
41  { if (this!=&tgw) { TGObject::operator=(tgw); fParent=tgw.fParent;
43  fEditDisabled=tgw.fEditDisabled; } return *this; }
44 
45  virtual void DoRedraw() { }
46 
47 public:
48  enum EEditMode {
49  kEditEnable = 0, ///< allow edit of this window
50  kEditDisable = BIT(0), ///< disable edit of this window
51  kEditDisableEvents = BIT(1), ///< window events cannot be edited
52  kEditDisableGrab = BIT(2), ///< window grab cannot be edited
53  kEditDisableLayout = BIT(3), ///< window layout cannot be edited
54  kEditDisableResize = BIT(4), ///< window size cannot be edited
55  kEditDisableHeight = BIT(5), ///< window height cannot be edited
56  kEditDisableWidth = BIT(6), ///< window width cannot be edited
57  kEditDisableBtnEnable = BIT(7), ///< window can handle mouse button events
58  kEditDisableKeyEnable = BIT(8) ///< window can handle keyboard events
59  };
60 
61  enum EStatusBits {
62  kIsHtmlView = BIT(14)
63  };
64 
65  TGWindow(const TGWindow *p = 0, Int_t x = 0, Int_t y = 0,
66  UInt_t w = 0, UInt_t h = 0, UInt_t border = 0,
67  Int_t depth = 0,
68  UInt_t clss = 0,
69  void *visual = 0,
70  SetWindowAttributes_t *attr = 0,
71  UInt_t wtype = 0);
72  TGWindow(TGClient *c, Window_t id, const TGWindow *parent = 0);
73 
74  virtual ~TGWindow();
75 
76  const TGWindow *GetParent() const { return fParent; }
77  virtual const TGWindow *GetMainFrame() const;
78 
79  virtual void MapWindow();
80  virtual void MapSubwindows();
81  virtual void MapRaised();
82  virtual void UnmapWindow();
83  virtual void DestroyWindow();
84  virtual void DestroySubwindows();
85  virtual void RaiseWindow();
86  virtual void LowerWindow();
87  virtual void IconifyWindow();
88  virtual void ReparentWindow(const TGWindow *p, Int_t x = 0, Int_t y = 0);
89  virtual void RequestFocus();
90 
91  virtual void SetBackgroundColor(Pixel_t color);
92  virtual void SetBackgroundPixmap(Pixmap_t pixmap);
93 
94  virtual Bool_t HandleExpose(Event_t *event)
95  { if (event->fCount == 0) fClient->NeedRedraw(this); return kTRUE; }
96  virtual Bool_t HandleEvent(Event_t *) { return kFALSE; }
97  virtual Bool_t HandleTimer(TTimer *) { return kFALSE; }
98  virtual Bool_t HandleIdleEvent(TGIdleHandler *) { return kFALSE; }
99 
100  virtual void Move(Int_t x, Int_t y);
101  virtual void Resize(UInt_t w, UInt_t h);
102  virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h);
103  virtual Bool_t IsMapped();
104  virtual Bool_t IsEditable() const { return (fClient->GetRoot() == this); }
105  virtual UInt_t GetEditDisabled() const { return fEditDisabled; }
106  virtual void SetEditDisabled(UInt_t on = kEditDisable) { fEditDisabled = on; }
107  virtual void SetEditable(Bool_t on = kTRUE)
108  { if (!(fEditDisabled & kEditDisable)) fClient->SetRoot(on ? this : 0); }
109  virtual Int_t MustCleanup() const { return 0; }
110  virtual void Print(Option_t *option="") const;
111 
112  virtual void SetWindowName(const char *name = 0);
113  virtual const char *GetName() const;
114  virtual void SetName(const char *name) { fName = name; }
115 
116  virtual void SetMapSubwindows(Bool_t /*on*/) { }
117  virtual Bool_t IsMapSubwindows() const { return kTRUE; }
118 
119  static Int_t GetCounter();
120 
121  ClassDef(TGWindow, 0); // GUI Window base class
122 };
123 
124 
125 /** \class TGUnknownWindowHandler
126  \ingroup guiwidgets
127 
128 Handle events for windows that are not part of the native ROOT GUI.
129 Typically windows created by Xt or Motif.
130 
131 */
132 
133 
135 
136 public:
139 
140  virtual Bool_t HandleEvent(Event_t *) = 0;
141 
142  ClassDef(TGUnknownWindowHandler,0) // Abstract event handler for unknown windows
143 };
144 
145 #endif
TGWindow::SetWindowName
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:129
TGWindow::fNeedRedraw
Bool_t fNeedRedraw
kTRUE if window needs to be redrawn
Definition: TGWindow.h:29
c
#define c(i)
Definition: RSha256.hxx:101
TGObject
This class is the baseclass for all ROOT GUI widgets.
Definition: TGObject.h:22
TGWindow::SetEditable
virtual void SetEditable(Bool_t on=kTRUE)
Definition: TGWindow.h:107
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
Pixmap_t
Handle_t Pixmap_t
Pixmap handle.
Definition: GuiTypes.h:30
TGWindow::fgCounter
static Int_t fgCounter
counter of created windows in SavePrimitive
Definition: TGWindow.h:31
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGIdleHandler
Handle idle events, i.e.
Definition: TGIdleHandler.h:21
TGWindow::RequestFocus
virtual void RequestFocus()
request focus
Definition: TGWindow.cxx:232
TGWindow::RaiseWindow
virtual void RaiseWindow()
raise window
Definition: TGWindow.cxx:208
TGWindow::HandleIdleEvent
virtual Bool_t HandleIdleEvent(TGIdleHandler *)
Definition: TGWindow.h:98
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGWindow::~TGWindow
virtual ~TGWindow()
Window destructor. Unregisters the window.
Definition: TGWindow.cxx:117
TGWindow::HandleTimer
virtual Bool_t HandleTimer(TTimer *)
Execute action in response of a timer timing out.
Definition: TGWindow.h:97
TGWindow::kEditDisableLayout
@ kEditDisableLayout
window layout cannot be edited
Definition: TGWindow.h:53
TGWindow::kEditDisable
@ kEditDisable
disable edit of this window
Definition: TGWindow.h:50
TGWindow::TGWindow
TGWindow(Window_t id)
Definition: TGWindow.h:34
TGWindow::MapRaised
virtual void MapRaised()
map raised
Definition: TGWindow.cxx:176
Int_t
int Int_t
Definition: RtypesCore.h:45
x
Double_t x[n]
Definition: legend1.C:17
TGWindow::kEditDisableHeight
@ kEditDisableHeight
window height cannot be edited
Definition: TGWindow.h:55
TGWindow::GetEditDisabled
virtual UInt_t GetEditDisabled() const
Definition: TGWindow.h:105
TGObject.h
TGWindow::SetBackgroundPixmap
virtual void SetBackgroundPixmap(Pixmap_t pixmap)
set background pixmap
Definition: TGWindow.cxx:248
TGWindow::IsMapSubwindows
virtual Bool_t IsMapSubwindows() const
Definition: TGWindow.h:117
TString
Basic string class.
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGWindow::HandleExpose
virtual Bool_t HandleExpose(Event_t *event)
Definition: TGWindow.h:94
TGWindow::kEditDisableEvents
@ kEditDisableEvents
window events cannot be edited
Definition: TGWindow.h:51
bool
id
XFontStruct * id
Definition: TGX11.cxx:109
TGWindow::kEditDisableBtnEnable
@ kEditDisableBtnEnable
window can handle mouse button events
Definition: TGWindow.h:57
TGWindow::DestroyWindow
virtual void DestroyWindow()
destroy window
Definition: TGWindow.cxx:192
TGWindow::DoRedraw
virtual void DoRedraw()
Definition: TGWindow.h:45
TGWindow::ReparentWindow
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:257
TTimer
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
TGWindow::SetName
virtual void SetName(const char *name)
Definition: TGWindow.h:114
TGClient::SetRoot
void SetRoot(TGWindow *root=nullptr)
Sets the current root (i.e.
Definition: TGClient.cxx:246
TGUnknownWindowHandler::TGUnknownWindowHandler
TGUnknownWindowHandler()
Definition: TGWindow.h:137
TGWindow::kEditDisableGrab
@ kEditDisableGrab
window grab cannot be edited
Definition: TGWindow.h:52
TGObject::operator=
TGObject & operator=(const TGObject &tgo)
Definition: TGObject.h:29
TGWindow::TGWindow
TGWindow(const TGWindow &tgw)
Definition: TGWindow.h:36
h
#define h(i)
Definition: RSha256.hxx:106
TGWindow::GetName
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:336
TGObject::fId
Handle_t fId
X11/Win32 Window identifier.
Definition: TGObject.h:26
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TGWindow::Print
virtual void Print(Option_t *option="") const
Print window id.
Definition: TGWindow.cxx:307
BIT
#define BIT(n)
Definition: Rtypes.h:85
Window_t
Handle_t Window_t
Window handle.
Definition: GuiTypes.h:29
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TGWindow::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:168
y
Double_t y[n]
Definition: legend1.C:17
TGWindow::kEditDisableKeyEnable
@ kEditDisableKeyEnable
window can handle keyboard events
Definition: TGWindow.h:58
TGWindow::SetBackgroundColor
virtual void SetBackgroundColor(Pixel_t color)
set background color
Definition: TGWindow.cxx:240
TGWindow::kIsHtmlView
@ kIsHtmlView
Definition: TGWindow.h:62
TGClient.h
unsigned int
TGWindow::EEditMode
EEditMode
Definition: TGWindow.h:48
TGWindow::MustCleanup
virtual Int_t MustCleanup() const
Definition: TGWindow.h:109
TGWindow::MapWindow
virtual void MapWindow()
map window
Definition: TGWindow.cxx:160
TGWindow::HandleEvent
virtual Bool_t HandleEvent(Event_t *)
Definition: TGWindow.h:96
TGWindow::GetParent
const TGWindow * GetParent() const
Definition: TGWindow.h:76
TGWindow::LowerWindow
virtual void LowerWindow()
lower window
Definition: TGWindow.cxx:216
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:374
TGWindow::SetMapSubwindows
virtual void SetMapSubwindows(Bool_t)
Definition: TGWindow.h:116
TGWindow::operator=
TGWindow & operator=(const TGWindow &tgw)
Definition: TGWindow.h:40
TGObject::fClient
TGClient * fClient
Connection to display server.
Definition: TGObject.h:27
TGWindow::GetMainFrame
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:152
TGWindow::Resize
virtual void Resize(UInt_t w, UInt_t h)
Resize the window.
Definition: TGWindow.cxx:279
TGWindow::IconifyWindow
virtual void IconifyWindow()
iconify window
Definition: TGWindow.cxx:224
TGWindow::kEditEnable
@ kEditEnable
allow edit of this window
Definition: TGWindow.h:49
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TGWindow::Move
virtual void Move(Int_t x, Int_t y)
Move the window.
Definition: TGWindow.cxx:271
TGWindow::SetEditDisabled
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition: TGWindow.h:106
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
Event_t
Event structure.
Definition: GuiTypes.h:174
name
char name[80]
Definition: TGX11.cxx:110
TGWindow::GetCounter
static Int_t GetCounter()
Return global window counter (total number of created windows).
Definition: TGWindow.cxx:328
TGWindow::kEditDisableWidth
@ kEditDisableWidth
window width cannot be edited
Definition: TGWindow.h:56
TGUnknownWindowHandler::HandleEvent
virtual Bool_t HandleEvent(Event_t *)=0
TGUnknownWindowHandler
Handle events for windows that are not part of the native ROOT GUI.
Definition: TGWindow.h:134
TGWindow::fEditDisabled
UInt_t fEditDisabled
flags used for "guibuilding"
Definition: TGWindow.h:32
Event_t::fCount
Int_t fCount
if non-zero, at least this many more exposes
Definition: GuiTypes.h:183
TGWindow::IsEditable
virtual Bool_t IsEditable() const
Definition: TGWindow.h:104
TGWindow::UnmapWindow
virtual void UnmapWindow()
unmap window
Definition: TGWindow.cxx:184
TGClient::GetRoot
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:226
TGWindow::DestroySubwindows
virtual void DestroySubwindows()
destroy sub windows
Definition: TGWindow.cxx:200
TGClient
Window client.
Definition: TGClient.h:37
TGWindow::kEditDisableResize
@ kEditDisableResize
window size cannot be edited
Definition: TGWindow.h:54
TObject::EStatusBits
EStatusBits
Definition: TObject.h:57
TGWindow::MoveResize
virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
Move and resize the window.
Definition: TGWindow.cxx:287
TGWindow::fParent
const TGWindow * fParent
Parent window.
Definition: TGWindow.h:28
TGUnknownWindowHandler::~TGUnknownWindowHandler
virtual ~TGUnknownWindowHandler()
Definition: TGWindow.h:138
TGWindow::fName
TString fName
name of the window used in SavePrimitive()
Definition: TGWindow.h:30
int
SetWindowAttributes_t
Attributes that can be used when creating or changing a window.
Definition: GuiTypes.h:93
TGWindow::IsMapped
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:295