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
27class TGClient;
28class TGIdleHandler;
29
30
31class TGWindow : public TGObject {
32
33friend class TGClient;
34
35protected:
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
44 TGWindow(const TGWindow& tgw) :
47
49 { if (this!=&tgw) { TGObject::operator=(tgw); fParent=tgw.fParent;
51 fEditDisabled=tgw.fEditDisabled; } return *this; }
52
53 virtual void DoRedraw() { }
54
55public:
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
70 kIsHtmlView = BIT(14)
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
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; }
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
144public:
147
148 virtual Bool_t HandleEvent(Event_t *) = 0;
149
150 ClassDef(TGUnknownWindowHandler,0) // Abstract event handler for unknown windows
151};
152
153#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:43
unsigned int UInt_t
Definition: RtypesCore.h:44
const Bool_t kFALSE
Definition: RtypesCore.h:90
bool Bool_t
Definition: RtypesCore.h:61
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
#define BIT(n)
Definition: Rtypes.h:83
XFontStruct * id
Definition: TGX11.cxx:108
char name[80]
Definition: TGX11.cxx:109
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:146
virtual Bool_t HandleEvent(Event_t *)=0
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:119
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:142
virtual void Move(Int_t x, Int_t y)
Move the window.
Definition: TGWindow.cxx:261
virtual void DoRedraw()
Definition: TGWindow.h:53
virtual Bool_t HandleEvent(Event_t *)
Definition: TGWindow.h:104
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:326
TGWindow(const TGWindow &tgw)
Definition: TGWindow.h:44
virtual ~TGWindow()
Window destructor. Unregisters the window.
Definition: TGWindow.cxx:107
virtual void Print(Option_t *option="") const
Print window id.
Definition: TGWindow.cxx:297
virtual void MapRaised()
map raised
Definition: TGWindow.cxx:166
static Int_t fgCounter
Definition: TGWindow.h:39
virtual Bool_t HandleIdleEvent(TGIdleHandler *)
Definition: TGWindow.h:106
TGWindow & operator=(const TGWindow &tgw)
Definition: TGWindow.h:48
virtual UInt_t GetEditDisabled() const
Definition: TGWindow.h:113
virtual void SetBackgroundPixmap(Pixmap_t pixmap)
set background pixmap
Definition: TGWindow.cxx:238
virtual void RequestFocus()
request focus
Definition: TGWindow.cxx:222
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition: TGWindow.h:114
virtual Bool_t HandleExpose(Event_t *event)
Definition: TGWindow.h:102
virtual void SetName(const char *name)
Definition: TGWindow.h:122
const TGWindow * fParent
Definition: TGWindow.h:36
virtual void DestroySubwindows()
destroy sub windows
Definition: TGWindow.cxx:190
virtual void SetMapSubwindows(Bool_t)
Definition: TGWindow.h:124
virtual void SetEditable(Bool_t on=kTRUE)
Definition: TGWindow.h:115
virtual Int_t MustCleanup() const
Definition: TGWindow.h:117
@ kEditDisableResize
Definition: TGWindow.h:62
@ kEditDisableHeight
Definition: TGWindow.h:63
@ kEditEnable
Definition: TGWindow.h:57
@ kEditDisableLayout
Definition: TGWindow.h:61
@ kEditDisableBtnEnable
Definition: TGWindow.h:65
@ kEditDisableWidth
Definition: TGWindow.h:64
@ kEditDisableGrab
Definition: TGWindow.h:60
@ kEditDisable
Definition: TGWindow.h:58
@ kEditDisableEvents
Definition: TGWindow.h:59
@ kEditDisableKeyEnable
Definition: TGWindow.h:66
virtual void IconifyWindow()
iconify window
Definition: TGWindow.cxx:214
virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
Move and resize the window.
Definition: TGWindow.cxx:277
virtual void MapWindow()
map window
Definition: TGWindow.cxx:150
virtual void UnmapWindow()
unmap window
Definition: TGWindow.cxx:174
virtual Bool_t IsMapSubwindows() const
Definition: TGWindow.h:125
TGWindow(Window_t id)
Definition: TGWindow.h:42
virtual void LowerWindow()
lower window
Definition: TGWindow.cxx:206
virtual void DestroyWindow()
destroy window
Definition: TGWindow.cxx:182
virtual Bool_t IsEditable() const
Definition: TGWindow.h:112
static Int_t GetCounter()
Return global window counter (total number of created windows).
Definition: TGWindow.cxx:318
const TGWindow * GetParent() const
Definition: TGWindow.h:84
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:285
virtual void Resize(UInt_t w, UInt_t h)
Resize the window.
Definition: TGWindow.cxx:269
virtual void SetBackgroundColor(Pixel_t color)
set background color
Definition: TGWindow.cxx:230
TString fName
Definition: TGWindow.h:38
virtual void RaiseWindow()
raise window
Definition: TGWindow.cxx:198
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:247
Bool_t fNeedRedraw
Definition: TGWindow.h:37
virtual void MapSubwindows()
map sub windows
Definition: TGWindow.cxx:158
@ kIsHtmlView
Definition: TGWindow.h:70
UInt_t fEditDisabled
Definition: TGWindow.h:40
virtual Bool_t HandleTimer(TTimer *)
Execute action in response of a timer timing out.
Definition: TGWindow.h:105
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