Logo ROOT   6.08/07
Reference Guide
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 27/12/97
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  *************************************************************************/
12 #ifndef ROOT_TGClient
13 #define ROOT_TGClient
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 //////////////////////////////////////////////////////////////////////////
25 #ifndef ROOT_TObject
26 #include "TObject.h"
27 #endif
28 #ifndef ROOT_GuiTypes
29 #include "GuiTypes.h"
30 #endif
31 #ifndef ROOT_TString
32 #include "TString.h"
33 #endif
34 #ifndef ROOT_TQObject
35 #include "TQObject.h"
36 #endif
39 class TList;
40 class THashList;
41 class TGWindow;
42 class TGResourcePool;
43 class TGPicturePool;
44 class TGPicture;
45 class TGGCPool;
46 class TGGC;
47 class TGFontPool;
48 class TGFont;
49 class TGMimeTypes;
51 class TGIdleHandler;
54 class TGClient : public TObject, public TQObject {
56 friend class TGCocoa;
58 protected:
59  Pixel_t fBackColor; // default background color
60  Pixel_t fForeColor; // default foreground color
61  Pixel_t fHilite; // default hilite color
62  Pixel_t fShadow; // default shadow color
63  Pixel_t fSelBackColor; // default selection background color
64  Pixel_t fSelForeColor; // default selection foreground color
65  Pixel_t fWhite; // white color index
66  Pixel_t fBlack; // black color index
67  TGWindow *fDefaultRoot; // default root window (base window of display)
68  TGWindow *fRoot; // current root window (changing root window allows embedding)
69  Int_t fXfd; // file descriptor of connection to server
70  TGResourcePool *fResourcePool; // global GUI resource pool
71  TGGCPool *fGCPool; // graphics context pool
72  TGFontPool *fFontPool; // font pool
73  TGPicturePool *fPicturePool; // pixmap pool
74  TGMimeTypes *fMimeTypeList; // mimetype list
75  Colormap_t fDefaultColormap; // default colormap
76  Bool_t fGlobalNeedRedraw; // true if at least one window needs to be redrawn
77  Bool_t fForceRedraw; // redraw widgets as soon as possible
78  THashList *fWlist; // list of frames
79  TList *fPlist; // list of popup windows used in HandleMaskEvent()
80  TList *fUWHandlers; // list of event handlers for unknown windows
81  TList *fIdleHandlers; // list of idle handlers
82  EGEventType fWaitForEvent; // event to wait for
83  Window_t fWaitForWindow; // window in which to wait for event
84  UInt_t fStyle; // GUI style (modern or classic)
86  TGClient(const TGClient&); // not implemented
87  TGClient& operator=(const TGClient&); // not implemented
91  Bool_t DoRedraw();
93 public:
94  TGClient(const char *dpyName = 0);
95  virtual ~TGClient();
97  const TGWindow *GetRoot() const;
98  const TGWindow *GetDefaultRoot() const;
99  void SetRoot(TGWindow *root = 0);
100  TGWindow *GetWindowById(Window_t sw) const;
101  TGWindow *GetWindowByName(const char *name) const;
103  UInt_t GetDisplayWidth() const;
104  UInt_t GetDisplayHeight() const;
106  Bool_t IsEditable() const { return fRoot != fDefaultRoot; }
107  Bool_t IsEditDisabled() const;
108  void SetEditDisabled(Bool_t on = kTRUE);
110  FontStruct_t GetFontByName(const char *name, Bool_t fixedDefault = kTRUE) const;
111  Bool_t GetColorByName(const char *name, Pixel_t &pixel) const;
112  Pixel_t GetHilite(Pixel_t base_color) const;
113  Pixel_t GetShadow(Pixel_t base_color) const;
114  void FreeColor(Pixel_t color) const;
115  void ForceRedraw() { fForceRedraw = kTRUE; }
116  void NeedRedraw(TGWindow *w, Bool_t force = kFALSE);
117  void CancelRedraw(TGWindow *w);
118  void RegisterWindow(TGWindow *w);
119  void UnregisterWindow(TGWindow *w);
120  void RegisterPopup(TGWindow *w);
121  void UnregisterPopup(TGWindow *w);
124  void AddIdleHandler(TGIdleHandler *h);
127  void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2);
128  void WaitFor(TGWindow *w);
129  void WaitForUnmap(TGWindow *w);
130  void ResetWaitFor(TGWindow *w);
133  void SetWaitForWindow(Window_t wid) {fWaitForWindow = wid;}
136  Bool_t HandleEvent(Event_t *event);
137  Bool_t HandleMaskEvent(Event_t *event, Window_t wid);
138  void RegisteredWindow(Window_t w); //*SIGNAL*
139  void ProcessedEvent(Event_t *event, Window_t wid); //*SIGNAL*
141  const TGResourcePool *GetResourcePool() const { return fResourcePool; }
144  const TGPicture *GetPicture(const char *name);
145  const TGPicture *GetPicture(const char *name, UInt_t new_width, UInt_t new_height);
146  void FreePicture(const TGPicture *pic);
148  TGGCPool *GetGCPool() const { return fGCPool; }
149  TGGC *GetGC(GCValues_t *values, Bool_t rw = kFALSE);
150  void FreeGC(const TGGC *gc);
151  void FreeGC(GContext_t gc);
153  TGFontPool *GetFontPool() const { return fFontPool; }
154  TGFont *GetFont(const char *font, Bool_t fixedDefault = kTRUE);
155  TGFont *GetFont(const TGFont *font);
156  void FreeFont(const TGFont *font);
158  UInt_t GetStyle() const { return fStyle; }
159  void SetStyle(UInt_t newstyle) { fStyle = newstyle; }
160  void SetStyle(const char *style);
165  THashList *GetListOfWindows() const { return fWlist; }
166  TList *GetListOfPopups() const { return fPlist; }
168  static TGClient *Instance();
170  ClassDef(TGClient,0) // Class making connection to display server
171 };
173 #ifndef __CINT__
174 #define gClient (TGClient::Instance())
175 #endif
177 #endif
void ProcessedEvent(Event_t *event, Window_t wid)
Emits a signal when an event has been processed.
Definition: TGClient.cxx:949
Pixel_t fHilite
Definition: TGClient.h:61
Pixel_t fBlack
Definition: TGClient.h:66
Bool_t IsEditDisabled() const
Returns kTRUE if edit/guibuilding is forbidden.
Definition: TGClient.cxx:932
void ForceRedraw()
Definition: TGClient.h:115
Handle_t FontStruct_t
Definition: GuiTypes.h:40
Bool_t HandleEvent(Event_t *event)
Handle a GUI event.
Definition: TGClient.cxx:816
TGPicturePool * fPicturePool
Definition: TGClient.h:73
void SetRoot(TGWindow *root=0)
Sets the current root (i.e.
Definition: TGClient.cxx:242
virtual ~TGClient()
Closing down client: cleanup and close X connection.
Definition: TGClient.cxx:619
THashList * fWlist
Definition: TGClient.h:78
void RemoveIdleHandler(TGIdleHandler *h)
Remove handler for idle events.
Definition: TGClient.cxx:583
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
void FreeColor(Pixel_t color) const
Free color.
Definition: TGClient.cxx:501
TH1 * h
Definition: legend2.C:5
TGWindow * fRoot
Definition: TGClient.h:68
Definition: GuiTypes.h:60
Pixel_t GetShadow(Pixel_t base_color) const
Return pixel value of shadow color based on base_color.
Definition: TGClient.cxx:478
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:53
const TGResourcePool * GetResourcePool() const
Definition: TGClient.h:141
Handle_t GContext_t
Definition: GuiTypes.h:39
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
Pixel_t fBackColor
Definition: TGClient.h:59
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Bool_t GetColorByName(const char *name, Pixel_t &pixel) const
Get a color by name.
Definition: TGClient.cxx:392
EGEventType GetWaitForEvent() const
Definition: TGClient.h:131
TList * GetListOfPopups() const
Definition: TGClient.h:166
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition: TGClient.cxx:734
void CancelRedraw(TGWindow *w)
Definition: TGClient.cxx:383
void UnregisterWindow(TGWindow *w)
Remove a TGWindow from the list of windows.
Definition: TGClient.cxx:520
Bool_t ProcessIdleEvent()
Process one idle event.
Definition: TGClient.cxx:677
Definition: TGGC.h:116
UInt_t GetDisplayWidth() const
Get display width.
Definition: TGClient.cxx:260
TGWindow * fDefaultRoot
Definition: TGClient.h:67
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
Definition: TGClient.cxx:530
TGWindow * GetWindowByName(const char *name) const
Find a TGWindow via its name (unique name used in TGWindow::SavePrimitive).
Definition: TGClient.cxx:602
TGClient(const TGClient &)
#define ClassDef(name, id)
Definition: Rtypes.h:254
TGPicturePool * GetPicturePool() const
Definition: TGClient.h:143
ULong_t Pixel_t
Definition: GuiTypes.h:41
Pixel_t fSelForeColor
Definition: TGClient.h:64
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
void RegisterWindow(TGWindow *w)
Add a TGWindow to the clients list of windows.
Definition: TGClient.cxx:509
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:306
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition: TGClient.cxx:911
void SetStyle(UInt_t newstyle)
Definition: TGClient.h:159
Pixel_t fSelBackColor
Definition: TGClient.h:63
TList * fIdleHandlers
Definition: TGClient.h:81
Bool_t DoRedraw()
Redraw all windows that need redrawing.
Definition: TGClient.cxx:792
void FreeGC(const TGGC *gc)
Free a graphics context.
Definition: TGClient.cxx:326
void RegisteredWindow(Window_t w)
Emits a signal when a Window has been registered in TGClient.
Definition: TGClient.cxx:962
Bool_t fForceRedraw
Definition: TGClient.h:77
Pixel_t fForeColor
Definition: TGClient.h:60
void SetWaitForWindow(Window_t wid)
Definition: TGClient.h:133
TGMimeTypes * GetMimeTypeList() const
Definition: TGClient.h:163
void WaitFor(TGWindow *w)
Wait for window to be destroyed.
Definition: TGClient.cxx:706
A doubly linked list.
Definition: TList.h:47
void FreeFont(const TGFont *font)
Free a font.
Definition: TGClient.cxx:362
TGResourcePool * fResourcePool
Definition: TGClient.h:70
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:853
Bool_t IsEditable() const
Definition: TGClient.h:106
void RemoveUnknownWindowHandler(TGUnknownWindowHandler *h)
Remove handler for unknown (i.e. unregistered) windows.
Definition: TGClient.cxx:562
void AddUnknownWindowHandler(TGUnknownWindowHandler *h)
Add handler for unknown (i.e. unregistered) windows.
Definition: TGClient.cxx:549
Bool_t ProcessOneEvent()
Process one event.
Definition: TGClient.cxx:643
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t fGlobalNeedRedraw
Definition: TGClient.h:76
static TGClient * Instance()
Returns global gClient (initialize graphics first, if not already done)
Definition: TGClient.cxx:89
Bool_t HandleInput()
Handles input from the display server.
Definition: TGClient.cxx:694
Handle_t Colormap_t
Definition: GuiTypes.h:34
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition: TGClient.cxx:318
TGFontPool * GetFontPool() const
Definition: TGClient.h:153
long Long_t
Definition: RtypesCore.h:50
Pixel_t fWhite
Definition: TGClient.h:65
TGMimeTypes * fMimeTypeList
Definition: TGClient.h:74
Pixel_t GetHilite(Pixel_t base_color) const
Return pixel value of hilite color based on base_color.
Definition: TGClient.cxx:447
Window_t GetWaitForWindow() const
Definition: TGClient.h:132
void ResetWaitFor(TGWindow *w)
reset waiting
Definition: TGClient.cxx:760
TList * fUWHandlers
Definition: TGClient.h:80
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:287
Int_t fXfd
Definition: TGClient.h:69
Definition: TGFont.h:155
TCanvas * style()
Definition: style.C:1
UInt_t GetDisplayHeight() const
Get display height.
Definition: TGClient.cxx:273
void AddIdleHandler(TGIdleHandler *h)
Add handler for idle events.
Definition: TGClient.cxx:570
Mother of all ROOT objects.
Definition: TObject.h:37
FontStruct_t GetFontByName(const char *name, Bool_t fixedDefault=kTRUE) const
Get a font by name.
Definition: TGClient.cxx:422
Colormap_t GetDefaultColormap() const
Definition: TGClient.h:162
Handle_t Window_t
Definition: GuiTypes.h:30
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D. ...
Definition: TGCocoa.h:58
TGFontPool * fFontPool
Definition: TGClient.h:72
Bool_t ProcessEventsFor(TGWindow *w)
Like gSystem->ProcessEvents() but then only allow events for w to be processed.
Definition: TGClient.cxx:770
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:232
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
EGEventType fWaitForEvent
Definition: TGClient.h:82
TList * fPlist
Definition: TGClient.h:79
TGClient & operator=(const TGClient &)
Colormap_t fDefaultColormap
Definition: TGClient.h:75
UInt_t GetStyle() const
Definition: TGClient.h:158
Window_t fWaitForWindow
Definition: TGClient.h:83
const Bool_t kTRUE
Definition: Rtypes.h:91
TGGCPool * fGCPool
Definition: TGClient.h:71
Pixel_t fShadow
Definition: TGClient.h:62
THashList * GetListOfWindows() const
Definition: TGClient.h:165
void SetEditDisabled(Bool_t on=kTRUE)
If on is kTRUE editting/guibuilding is forbidden.
Definition: TGClient.cxx:940
Definition: TGGC.h:35
void UnregisterPopup(TGWindow *w)
Remove a popup menu from the list of popups.
Definition: TGClient.cxx:541
char name[80]
Definition: TGX11.cxx:109
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition: TGClient.cxx:346
TGGCPool * GetGCPool() const
Definition: TGClient.h:148
TGWindow * GetWindowById(Window_t sw) const
Find a TGWindow via its handle. If window is not found return 0.
Definition: TGClient.cxx:591
UInt_t fStyle
Definition: TGClient.h:84