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#include "TVirtualX.h"
27
28class TGClient;
29class TGIdleHandler;
30
31
32class TGWindow : public TGObject {
33
34friend class TGClient;
35
36protected:
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
45 TGWindow(const TGWindow& tgw) :
48
50 { if (this!=&tgw) { TGObject::operator=(tgw); fParent=tgw.fParent;
52 fEditDisabled=tgw.fEditDisabled; } return *this; }
53
54 virtual void DoRedraw() { }
55
56public:
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
71 kIsHtmlView = BIT(14)
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
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; }
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
147public:
150
151 virtual Bool_t HandleEvent(Event_t *) = 0;
152
153 ClassDef(TGUnknownWindowHandler,0) // Abstract event handler for unknown windows
154};
155
156#endif
Handle_t Pixmap_t
Definition: GuiTypes.h:29
ULong_t Pixel_t
Definition: GuiTypes.h:39
Handle_t Window_t
Definition: GuiTypes.h:28
#define c(i)
Definition: RSha256.hxx:101
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
#define BIT(n)
Definition: Rtypes.h:83
XFontStruct * id
Definition: TGX11.cxx:108
char name[80]
Definition: TGX11.cxx:109
#define gVirtualX
Definition: TVirtualX.h:345
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:224
void SetRoot(TGWindow *root=0)
Sets the current root (i.e.
Definition: TGClient.cxx:244
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:372
TGClient * fClient
Definition: TGObject.h:37
TGObject & operator=(const TGObject &tgo)
Definition: TGObject.h:39
Handle_t fId
Definition: TGObject.h:36
virtual ~TGUnknownWindowHandler()
Definition: TGWindow.h:149
virtual Bool_t HandleEvent(Event_t *)=0
virtual void MapWindow()
Definition: TGWindow.h:88
virtual void SetBackgroundColor(Pixel_t color)
Definition: TGWindow.h:100
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
virtual void Move(Int_t x, Int_t y)
Move the window.
Definition: TGWindow.cxx:156
virtual void DoRedraw()
Definition: TGWindow.h:54
virtual void DestroySubwindows()
Definition: TGWindow.h:93
virtual Bool_t HandleEvent(Event_t *)
Definition: TGWindow.h:107
virtual void MapSubwindows()
Definition: TGWindow.h:89
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
TGWindow(const TGWindow &tgw)
Definition: TGWindow.h:45
virtual ~TGWindow()
Window destructor. Unregisters the window.
Definition: TGWindow.cxx:106
virtual void Print(Option_t *option="") const
Print window id.
Definition: TGWindow.cxx:192
virtual void IconifyWindow()
Definition: TGWindow.h:96
static Int_t fgCounter
Definition: TGWindow.h:40
virtual Bool_t HandleIdleEvent(TGIdleHandler *)
Definition: TGWindow.h:109
TGWindow & operator=(const TGWindow &tgw)
Definition: TGWindow.h:49
virtual UInt_t GetEditDisabled() const
Definition: TGWindow.h:116
virtual void MapRaised()
Definition: TGWindow.h:90
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition: TGWindow.h:117
virtual Bool_t HandleExpose(Event_t *event)
Definition: TGWindow.h:105
virtual void SetName(const char *name)
Definition: TGWindow.h:125
virtual void LowerWindow()
Definition: TGWindow.h:95
const TGWindow * fParent
Definition: TGWindow.h:37
virtual void SetMapSubwindows(Bool_t)
Definition: TGWindow.h:127
virtual void SetEditable(Bool_t on=kTRUE)
Definition: TGWindow.h:118
virtual Int_t MustCleanup() const
Definition: TGWindow.h:120
@ kEditDisableResize
Definition: TGWindow.h:63
@ kEditDisableHeight
Definition: TGWindow.h:64
@ kEditEnable
Definition: TGWindow.h:58
@ kEditDisableLayout
Definition: TGWindow.h:62
@ kEditDisableBtnEnable
Definition: TGWindow.h:66
@ kEditDisableWidth
Definition: TGWindow.h:65
@ kEditDisableGrab
Definition: TGWindow.h:61
@ kEditDisable
Definition: TGWindow.h:59
@ kEditDisableEvents
Definition: TGWindow.h:60
@ kEditDisableKeyEnable
Definition: TGWindow.h:67
virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
Move and resize the window.
Definition: TGWindow.cxx:172
virtual Bool_t IsMapSubwindows() const
Definition: TGWindow.h:128
TGWindow(Window_t id)
Definition: TGWindow.h:43
virtual void DestroyWindow()
Definition: TGWindow.h:92
virtual Bool_t IsEditable() const
Definition: TGWindow.h:115
virtual void UnmapWindow()
Definition: TGWindow.h:91
static Int_t GetCounter()
Return global window counter (total number of created windows).
Definition: TGWindow.cxx:213
const TGWindow * GetParent() const
Definition: TGWindow.h:85
virtual void RequestFocus()
Definition: TGWindow.h:98
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:180
virtual void Resize(UInt_t w, UInt_t h)
Resize the window.
Definition: TGWindow.cxx:164
virtual void RaiseWindow()
Definition: TGWindow.h:94
TString fName
Definition: TGWindow.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
Bool_t fNeedRedraw
Definition: TGWindow.h:38
@ kIsHtmlView
Definition: TGWindow.h:71
UInt_t fEditDisabled
Definition: TGWindow.h:41
virtual Bool_t HandleTimer(TTimer *)
Execute action in response of a timer timing out.
Definition: TGWindow.h:108
virtual void SetBackgroundPixmap(Pixmap_t pixmap)
Definition: TGWindow.h:102
Mother of all ROOT objects.
Definition: TObject.h:37
EStatusBits
Definition: TObject.h:57
Basic string class.
Definition: TString.h:131
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
Int_t fCount
Definition: GuiTypes.h:182