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 //////////////////////////////////////////////////////////////////////////
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::SetWindowName
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118
TGWindow::fNeedRedraw
Bool_t fNeedRedraw
Definition: TGWindow.h:37
c
#define c(i)
Definition: RSha256.hxx:119
TGObject
Definition: TGObject.h:32
TGWindow::SetEditable
virtual void SetEditable(Bool_t on=kTRUE)
Definition: TGWindow.h:115
TGWindow
Definition: TGWindow.h:31
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
Pixmap_t
Handle_t Pixmap_t
Definition: GuiTypes.h:29
TGWindow::fgCounter
static Int_t fgCounter
Definition: TGWindow.h:39
TGIdleHandler
Definition: TGIdleHandler.h:29
TGWindow::RequestFocus
virtual void RequestFocus()
request focus
Definition: TGWindow.cxx:213
TGWindow::RaiseWindow
virtual void RaiseWindow()
raise window
Definition: TGWindow.cxx:189
TGWindow::HandleIdleEvent
virtual Bool_t HandleIdleEvent(TGIdleHandler *)
Definition: TGWindow.h:106
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGWindow::~TGWindow
virtual ~TGWindow()
Window destructor. Unregisters the window.
Definition: TGWindow.cxx:106
TGWindow::HandleTimer
virtual Bool_t HandleTimer(TTimer *)
Execute action in response of a timer timing out.
Definition: TGWindow.h:105
TGWindow::kEditDisableLayout
@ kEditDisableLayout
Definition: TGWindow.h:61
TGWindow::kEditDisable
@ kEditDisable
Definition: TGWindow.h:58
TGWindow::TGWindow
TGWindow(Window_t id)
Definition: TGWindow.h:42
TGWindow::MapRaised
virtual void MapRaised()
map raised
Definition: TGWindow.cxx:157
Int_t
int Int_t
Definition: RtypesCore.h:45
TGClient::SetRoot
void SetRoot(TGWindow *root=0)
Sets the current root (i.e.
Definition: TGClient.cxx:245
x
Double_t x[n]
Definition: legend1.C:17
TGWindow::kEditDisableHeight
@ kEditDisableHeight
Definition: TGWindow.h:63
TGWindow::GetEditDisabled
virtual UInt_t GetEditDisabled() const
Definition: TGWindow.h:113
TGObject.h
TGWindow::SetBackgroundPixmap
virtual void SetBackgroundPixmap(Pixmap_t pixmap)
set background pixmap
Definition: TGWindow.cxx:229
TGWindow::IsMapSubwindows
virtual Bool_t IsMapSubwindows() const
Definition: TGWindow.h:125
TString
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:102
TGWindow::kEditDisableEvents
@ kEditDisableEvents
Definition: TGWindow.h:59
bool
id
XFontStruct * id
Definition: TGX11.cxx:109
TGWindow::kEditDisableBtnEnable
@ kEditDisableBtnEnable
Definition: TGWindow.h:65
TGWindow::DestroyWindow
virtual void DestroyWindow()
destroy window
Definition: TGWindow.cxx:173
TGWindow::DoRedraw
virtual void DoRedraw()
Definition: TGWindow.h:53
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:238
TTimer
Definition: TTimer.h:51
TGWindow::SetName
virtual void SetName(const char *name)
Definition: TGWindow.h:122
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGUnknownWindowHandler::TGUnknownWindowHandler
TGUnknownWindowHandler()
Definition: TGWindow.h:145
TGWindow::kEditDisableGrab
@ kEditDisableGrab
Definition: TGWindow.h:60
TGObject::operator=
TGObject & operator=(const TGObject &tgo)
Definition: TGObject.h:39
TGWindow::TGWindow
TGWindow(const TGWindow &tgw)
Definition: TGWindow.h:44
h
#define h(i)
Definition: RSha256.hxx:124
TGWindow::GetName
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:317
TGObject::fId
Handle_t fId
Definition: TGObject.h:36
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGWindow::Print
virtual void Print(Option_t *option="") const
Print window id.
Definition: TGWindow.cxx:288
BIT
#define BIT(n)
Definition: Rtypes.h:85
Window_t
Handle_t Window_t
Definition: GuiTypes.h:28
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TGWindow::MapSubwindows
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:149
y
Double_t y[n]
Definition: legend1.C:17
TGWindow::kEditDisableKeyEnable
@ kEditDisableKeyEnable
Definition: TGWindow.h:66
TGWindow::SetBackgroundColor
virtual void SetBackgroundColor(Pixel_t color)
set background color
Definition: TGWindow.cxx:221
TGWindow::kIsHtmlView
@ kIsHtmlView
Definition: TGWindow.h:70
TGClient.h
unsigned int
TGWindow::EEditMode
EEditMode
Definition: TGWindow.h:56
TGWindow::MustCleanup
virtual Int_t MustCleanup() const
Definition: TGWindow.h:117
TGWindow::MapWindow
virtual void MapWindow()
map window
Definition: TGWindow.cxx:141
TGWindow::HandleEvent
virtual Bool_t HandleEvent(Event_t *)
Definition: TGWindow.h:104
TGWindow::GetParent
const TGWindow * GetParent() const
Definition: TGWindow.h:84
TGWindow::LowerWindow
virtual void LowerWindow()
lower window
Definition: TGWindow.cxx:197
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:373
TGWindow::SetMapSubwindows
virtual void SetMapSubwindows(Bool_t)
Definition: TGWindow.h:124
TGWindow::operator=
TGWindow & operator=(const TGWindow &tgw)
Definition: TGWindow.h:48
TGObject::fClient
TGClient * fClient
Definition: TGObject.h:37
TGWindow::GetMainFrame
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
TGWindow::Resize
virtual void Resize(UInt_t w, UInt_t h)
Resize the window.
Definition: TGWindow.cxx:260
TGWindow::IconifyWindow
virtual void IconifyWindow()
iconify window
Definition: TGWindow.cxx:205
TGWindow::kEditEnable
@ kEditEnable
Definition: TGWindow.h:57
TObject
Definition: TObject.h:37
TGWindow::Move
virtual void Move(Int_t x, Int_t y)
Move the window.
Definition: TGWindow.cxx:252
TGWindow::SetEditDisabled
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition: TGWindow.h:114
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
Event_t
Definition: GuiTypes.h:173
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:309
TGWindow::kEditDisableWidth
@ kEditDisableWidth
Definition: TGWindow.h:64
TGUnknownWindowHandler::HandleEvent
virtual Bool_t HandleEvent(Event_t *)=0
TGUnknownWindowHandler
Definition: TGWindow.h:142
TGWindow::fEditDisabled
UInt_t fEditDisabled
Definition: TGWindow.h:40
Event_t::fCount
Int_t fCount
Definition: GuiTypes.h:182
TGWindow::IsEditable
virtual Bool_t IsEditable() const
Definition: TGWindow.h:112
TGWindow::UnmapWindow
virtual void UnmapWindow()
unmap window
Definition: TGWindow.cxx:165
TGClient::GetRoot
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:225
TGWindow::DestroySubwindows
virtual void DestroySubwindows()
destroy sub windows
Definition: TGWindow.cxx:181
TGClient
Definition: TGClient.h:46
TGWindow::kEditDisableResize
@ kEditDisableResize
Definition: TGWindow.h:62
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:268
TGWindow::fParent
const TGWindow * fParent
Definition: TGWindow.h:36
TGUnknownWindowHandler::~TGUnknownWindowHandler
virtual ~TGUnknownWindowHandler()
Definition: TGWindow.h:146
TGWindow::fName
TString fName
Definition: TGWindow.h:38
int
SetWindowAttributes_t
Definition: GuiTypes.h:92
TGWindow::IsMapped
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:276