Logo ROOT  
Reference Guide
TGClient.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 27/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_TGClient
13 #define ROOT_TGClient
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGClient //
19 // //
20 // Window client. In client server windowing systems, like X11 this //
21 // class is used to make the initial connection to the window server. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #include "TObject.h"
26 #include "GuiTypes.h"
27 #include "TString.h"
28 #include "TQObject.h"
29 
30 
31 class TList;
32 class THashList;
33 class TGWindow;
34 class TGResourcePool;
35 class TGPicturePool;
36 class TGPicture;
37 class TGGCPool;
38 class TGGC;
39 class TGFontPool;
40 class TGFont;
41 class TGMimeTypes;
43 class TGIdleHandler;
44 
45 
46 class TGClient : public TObject, public TQObject {
47 
48 friend class TGCocoa;
49 
50 protected:
51  Pixel_t fBackColor; // default background color
52  Pixel_t fForeColor; // default foreground color
53  Pixel_t fHilite; // default hilite color
54  Pixel_t fShadow; // default shadow color
55  Pixel_t fSelBackColor; // default selection background color
56  Pixel_t fSelForeColor; // default selection foreground color
57  Pixel_t fWhite; // white color index
58  Pixel_t fBlack; // black color index
59  TGWindow *fDefaultRoot; // default root window (base window of display)
60  TGWindow *fRoot; // current root window (changing root window allows embedding)
61  Int_t fXfd; // file descriptor of connection to server
62  TGResourcePool *fResourcePool; // global GUI resource pool
63  TGGCPool *fGCPool; // graphics context pool
64  TGFontPool *fFontPool; // font pool
65  TGPicturePool *fPicturePool; // pixmap pool
66  TGMimeTypes *fMimeTypeList; // mimetype list
67  Colormap_t fDefaultColormap; // default colormap
68  Bool_t fGlobalNeedRedraw; // true if at least one window needs to be redrawn
69  Bool_t fForceRedraw; // redraw widgets as soon as possible
70  THashList *fWlist; // list of frames
71  TList *fPlist; // list of popup windows used in HandleMaskEvent()
72  TList *fUWHandlers; // list of event handlers for unknown windows
73  TList *fIdleHandlers; // list of idle handlers
74  EGEventType fWaitForEvent; // event to wait for
75  Window_t fWaitForWindow; // window in which to wait for event
76  UInt_t fStyle; // GUI style (modern or classic)
77 
78  TGClient(const TGClient&); // not implemented
79  TGClient& operator=(const TGClient&); // not implemented
80 
83  Bool_t DoRedraw();
84 
85 public:
86  TGClient(const char *dpyName = 0);
87  virtual ~TGClient();
88 
89  const TGWindow *GetRoot() const;
90  const TGWindow *GetDefaultRoot() const;
91  void SetRoot(TGWindow *root = 0);
92  TGWindow *GetWindowById(Window_t sw) const;
93  TGWindow *GetWindowByName(const char *name) const;
94 
95  UInt_t GetDisplayWidth() const;
96  UInt_t GetDisplayHeight() const;
97 
98  Bool_t IsEditable() const { return fRoot != fDefaultRoot; }
99  Bool_t IsEditDisabled() const;
100  void SetEditDisabled(Bool_t on = kTRUE);
101 
102  FontStruct_t GetFontByName(const char *name, Bool_t fixedDefault = kTRUE) const;
103  Bool_t GetColorByName(const char *name, Pixel_t &pixel) const;
104  Pixel_t GetHilite(Pixel_t base_color) const;
105  Pixel_t GetShadow(Pixel_t base_color) const;
106  void FreeColor(Pixel_t color) const;
108  void NeedRedraw(TGWindow *w, Bool_t force = kFALSE);
109  void CancelRedraw(TGWindow *w);
110  void RegisterWindow(TGWindow *w);
111  void UnregisterWindow(TGWindow *w);
112  void RegisterPopup(TGWindow *w);
113  void UnregisterPopup(TGWindow *w);
119  void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2);
120  void WaitFor(TGWindow *w);
121  void WaitForUnmap(TGWindow *w);
122  void ResetWaitFor(TGWindow *w);
127 
128  Bool_t HandleEvent(Event_t *event);
129  Bool_t HandleMaskEvent(Event_t *event, Window_t wid);
130  void RegisteredWindow(Window_t w); //*SIGNAL*
131  void ProcessedEvent(Event_t *event, Window_t wid); //*SIGNAL*
132 
133  const TGResourcePool *GetResourcePool() const { return fResourcePool; }
134 
136  const TGPicture *GetPicture(const char *name);
137  const TGPicture *GetPicture(const char *name, UInt_t new_width, UInt_t new_height);
138  void FreePicture(const TGPicture *pic);
139 
140  TGGCPool *GetGCPool() const { return fGCPool; }
141  TGGC *GetGC(GCValues_t *values, Bool_t rw = kFALSE);
142  void FreeGC(const TGGC *gc);
143  void FreeGC(GContext_t gc);
144 
145  TGFontPool *GetFontPool() const { return fFontPool; }
146  TGFont *GetFont(const char *font, Bool_t fixedDefault = kTRUE);
147  TGFont *GetFont(const TGFont *font);
148  void FreeFont(const TGFont *font);
149 
150  UInt_t GetStyle() const { return fStyle; }
151  void SetStyle(UInt_t newstyle) { fStyle = newstyle; }
152  void SetStyle(const char *style);
153 
156 
157  THashList *GetListOfWindows() const { return fWlist; }
158  TList *GetListOfPopups() const { return fPlist; }
159 
160  static TGClient *Instance();
161 
162  ClassDef(TGClient,0) // Class making connection to display server
163 };
164 
165 #ifndef __CINT__
166 #define gClient (TGClient::Instance())
167 #endif
168 
169 #endif
TGClient::fMimeTypeList
TGMimeTypes * fMimeTypeList
Definition: TGClient.h:66
TGClient::fXfd
Int_t fXfd
Definition: TGClient.h:61
TGClient::GetDefaultRoot
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:235
TGClient::RegisterPopup
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
Definition: TGClient.cxx:533
TGClient::AddUnknownWindowHandler
void AddUnknownWindowHandler(TGUnknownWindowHandler *h)
Add handler for unknown (i.e. unregistered) windows.
Definition: TGClient.cxx:552
TGClient::FreeFont
void FreeFont(const TGFont *font)
Free a font.
Definition: TGClient.cxx:365
TGClient::fDefaultRoot
TGWindow * fDefaultRoot
Definition: TGClient.h:59
TGClient::fForeColor
Pixel_t fForeColor
Definition: TGClient.h:52
TGWindow
Definition: TGWindow.h:31
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGClient::GetDisplayWidth
UInt_t GetDisplayWidth() const
Get display width.
Definition: TGClient.cxx:263
TGClient::RegisterWindow
void RegisterWindow(TGWindow *w)
Add a TGWindow to the clients list of windows.
Definition: TGClient.cxx:512
TGClient::fWlist
THashList * fWlist
Definition: TGClient.h:70
TGClient::GetWindowByName
TGWindow * GetWindowByName(const char *name) const
Find a TGWindow via its name (unique name used in TGWindow::SavePrimitive).
Definition: TGClient.cxx:605
TGClient::RegisteredWindow
void RegisteredWindow(Window_t w)
Emits a signal when a Window has been registered in TGClient.
Definition: TGClient.cxx:965
TGPicture
Definition: TGPicture.h:36
TGClient::fPlist
TList * fPlist
Definition: TGClient.h:71
TGClient::ProcessLine
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition: TGClient.cxx:914
TGClient::ProcessEventsFor
Bool_t ProcessEventsFor(TGWindow *w)
Like gSystem->ProcessEvents() but then only allow events for w to be processed.
Definition: TGClient.cxx:773
TGIdleHandler
Definition: TGIdleHandler.h:29
TGClient::fUWHandlers
TList * fUWHandlers
Definition: TGClient.h:72
TGClient::SetWaitForWindow
void SetWaitForWindow(Window_t wid)
Definition: TGClient.h:125
TGClient::GetFontPool
TGFontPool * GetFontPool() const
Definition: TGClient.h:145
TGClient::fPicturePool
TGPicturePool * fPicturePool
Definition: TGClient.h:65
TGClient::GetGCPool
TGGCPool * GetGCPool() const
Definition: TGClient.h:140
TGClient::GetShadow
Pixel_t GetShadow(Pixel_t base_color) const
Return pixel value of shadow color based on base_color.
Definition: TGClient.cxx:481
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGClient::RemoveUnknownWindowHandler
void RemoveUnknownWindowHandler(TGUnknownWindowHandler *h)
Remove handler for unknown (i.e. unregistered) windows.
Definition: TGClient.cxx:565
TGClient::operator=
TGClient & operator=(const TGClient &)
TGClient::AddIdleHandler
void AddIdleHandler(TGIdleHandler *h)
Add handler for idle events.
Definition: TGClient.cxx:573
TGClient::UnregisterPopup
void UnregisterPopup(TGWindow *w)
Remove a popup menu from the list of popups.
Definition: TGClient.cxx:544
FontStruct_t
Handle_t FontStruct_t
Definition: GuiTypes.h:38
TGClient::DoRedraw
Bool_t DoRedraw()
Redraw all windows that need redrawing.
Definition: TGClient.cxx:795
TGClient::RemoveIdleHandler
void RemoveIdleHandler(TGIdleHandler *h)
Remove handler for idle events.
Definition: TGClient.cxx:586
TGClient::fShadow
Pixel_t fShadow
Definition: TGClient.h:54
GCValues_t
Definition: GuiTypes.h:223
TGClient::fStyle
UInt_t fStyle
Definition: TGClient.h:76
TGClient::WaitFor
void WaitFor(TGWindow *w)
Wait for window to be destroyed.
Definition: TGClient.cxx:709
TGClient::IsEditable
Bool_t IsEditable() const
Definition: TGClient.h:98
TGClient::fFontPool
TGFontPool * fFontPool
Definition: TGClient.h:64
TGClient::SetRoot
void SetRoot(TGWindow *root=0)
Sets the current root (i.e.
Definition: TGClient.cxx:245
TGClient::WaitForUnmap
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition: TGClient.cxx:737
TGClient::GetHilite
Pixel_t GetHilite(Pixel_t base_color) const
Return pixel value of hilite color based on base_color.
Definition: TGClient.cxx:450
TGClient::FreePicture
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:309
TGClient::GetResourcePool
const TGResourcePool * GetResourcePool() const
Definition: TGClient.h:133
TGClient::fSelBackColor
Pixel_t fSelBackColor
Definition: TGClient.h:55
TGClient::fDefaultColormap
Colormap_t fDefaultColormap
Definition: TGClient.h:67
TGClient::ProcessedEvent
void ProcessedEvent(Event_t *event, Window_t wid)
Emits a signal when an event has been processed.
Definition: TGClient.cxx:952
TString
Basic string class.
Definition: TString.h:136
TGClient::fResourcePool
TGResourcePool * fResourcePool
Definition: TGClient.h:62
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGClient::GetPicturePool
TGPicturePool * GetPicturePool() const
Definition: TGClient.h:135
TString.h
TGResourcePool
Definition: TGResourcePool.h:36
bool
TGClient::fWaitForWindow
Window_t fWaitForWindow
Definition: TGClient.h:75
TGFontPool
Definition: TGFont.h:226
GContext_t
Handle_t GContext_t
Definition: GuiTypes.h:37
TGClient::GetFontByName
FontStruct_t GetFontByName(const char *name, Bool_t fixedDefault=kTRUE) const
Get a font by name.
Definition: TGClient.cxx:425
TGClient::GetStyle
UInt_t GetStyle() const
Definition: TGClient.h:150
style
TCanvas * style()
Definition: style.C:1
TQObject.h
TGClient::GetListOfPopups
TList * GetListOfPopups() const
Definition: TGClient.h:158
TQObject
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition: TQObject.h:48
TGClient::GetWaitForEvent
EGEventType GetWaitForEvent() const
Definition: TGClient.h:123
TGClient::GetColorByName
Bool_t GetColorByName(const char *name, Pixel_t &pixel) const
Get a color by name.
Definition: TGClient.cxx:395
TGClient::SetEditDisabled
void SetEditDisabled(Bool_t on=kTRUE)
If on is kTRUE editting/guibuilding is forbidden.
Definition: TGClient.cxx:943
TGClient::fIdleHandlers
TList * fIdleHandlers
Definition: TGClient.h:73
TGClient::GetDisplayHeight
UInt_t GetDisplayHeight() const
Get display height.
Definition: TGClient.cxx:276
Colormap_t
Handle_t Colormap_t
Definition: GuiTypes.h:32
THashList
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
h
#define h(i)
Definition: RSha256.hxx:106
TGCocoa
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D.
Definition: TGCocoa.h:58
TGClient::fBackColor
Pixel_t fBackColor
Definition: TGClient.h:51
TGClient::fGCPool
TGGCPool * fGCPool
Definition: TGClient.h:63
TGGC
Definition: TGGC.h:31
TGClient::ProcessOneEvent
Bool_t ProcessOneEvent()
Process one event.
Definition: TGClient.cxx:646
GuiTypes.h
TGClient::HandleMaskEvent
Bool_t HandleMaskEvent(Event_t *event, Window_t wid)
Handle masked events only if window wid is the window for which the event was reported or if wid is a...
Definition: TGClient.cxx:856
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGClient::GetDefaultColormap
Colormap_t GetDefaultColormap() const
Definition: TGClient.h:154
TGClient::fWaitForEvent
EGEventType fWaitForEvent
Definition: TGClient.h:74
Long_t
long Long_t
Definition: RtypesCore.h:54
TGClient::GetWindowById
TGWindow * GetWindowById(Window_t sw) const
Find a TGWindow via its handle. If window is not found return 0.
Definition: TGClient.cxx:594
TGClient::ForceRedraw
void ForceRedraw()
Definition: TGClient.h:107
TGClient::HandleEvent
Bool_t HandleEvent(Event_t *event)
Handle a GUI event.
Definition: TGClient.cxx:819
TGClient::fWhite
Pixel_t fWhite
Definition: TGClient.h:57
TGClient::HandleInput
Bool_t HandleInput()
Handles input from the display server.
Definition: TGClient.cxx:697
TGClient::fSelForeColor
Pixel_t fSelForeColor
Definition: TGClient.h:56
TGPicturePool
Definition: TGPicture.h:100
TGClient::GetPicture
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:290
Window_t
Handle_t Window_t
Definition: GuiTypes.h:28
TGClient::fGlobalNeedRedraw
Bool_t fGlobalNeedRedraw
Definition: TGClient.h:68
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TGClient::fRoot
TGWindow * fRoot
Definition: TGClient.h:60
TGMimeTypes
Definition: TGMimeTypes.h:50
TGClient::GetListOfWindows
THashList * GetListOfWindows() const
Definition: TGClient.h:157
unsigned int
TGClient::GetMimeTypeList
TGMimeTypes * GetMimeTypeList() const
Definition: TGClient.h:155
TGClient::SetStyle
void SetStyle(UInt_t newstyle)
Definition: TGClient.h:151
TGClient::GetWaitForWindow
Window_t GetWaitForWindow() const
Definition: TGClient.h:124
TGClient::fBlack
Pixel_t fBlack
Definition: TGClient.h:58
TGClient::IsEditDisabled
Bool_t IsEditDisabled() const
Returns kTRUE if edit/guibuilding is forbidden.
Definition: TGClient.cxx:935
TGClient::GetGC
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition: TGClient.cxx:321
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:373
TGClient::TGClient
TGClient(const TGClient &)
TObject.h
TGClient::fHilite
Pixel_t fHilite
Definition: TGClient.h:53
TGGCPool
Definition: TGGC.h:112
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
Event_t
Definition: GuiTypes.h:173
name
char name[80]
Definition: TGX11.cxx:110
TGClient::ProcessIdleEvent
Bool_t ProcessIdleEvent()
Process one idle event.
Definition: TGClient.cxx:680
TGClient::GetFont
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition: TGClient.cxx:349
TGClient::fForceRedraw
Bool_t fForceRedraw
Definition: TGClient.h:69
TGClient::FreeColor
void FreeColor(Pixel_t color) const
Free color.
Definition: TGClient.cxx:504
TGUnknownWindowHandler
Definition: TGWindow.h:142
TGFont
Definition: TGFont.h:149
TGClient::Instance
static TGClient * Instance()
Returns global gClient (initialize graphics first, if not already done)
Definition: TGClient.cxx:92
TGClient::ResetWaitFor
void ResetWaitFor(TGWindow *w)
reset waiting
Definition: TGClient.cxx:763
TGClient::GetRoot
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:225
TGClient::CancelRedraw
void CancelRedraw(TGWindow *w)
Definition: TGClient.cxx:386
TGClient
Definition: TGClient.h:46
EGEventType
EGEventType
Definition: GuiTypes.h:58
TGClient::~TGClient
virtual ~TGClient()
Closing down client: cleanup and close X connection.
Definition: TGClient.cxx:622
TList
A doubly linked list.
Definition: TList.h:44
int
TGClient::UnregisterWindow
void UnregisterWindow(TGWindow *w)
Remove a TGWindow from the list of windows.
Definition: TGClient.cxx:523
TGClient::FreeGC
void FreeGC(const TGGC *gc)
Free a graphics context.
Definition: TGClient.cxx:329