Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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;
42 class TGUnknownWindowHandler;
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 
81  Bool_t ProcessOneEvent();
82  Bool_t ProcessIdleEvent();
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;
107  void ForceRedraw() { fForceRedraw = kTRUE; }
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);
114  void AddUnknownWindowHandler(TGUnknownWindowHandler *h);
115  void RemoveUnknownWindowHandler(TGUnknownWindowHandler *h);
116  void AddIdleHandler(TGIdleHandler *h);
117  void RemoveIdleHandler(TGIdleHandler *h);
118  Bool_t HandleInput();
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);
123  EGEventType GetWaitForEvent() const { return fWaitForEvent;}
124  Window_t GetWaitForWindow() const { return fWaitForWindow; }
125  void SetWaitForWindow(Window_t wid) {fWaitForWindow = wid;}
126  Bool_t ProcessEventsFor(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 
135  TGPicturePool *GetPicturePool() const { return fPicturePool; }
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 
154  Colormap_t GetDefaultColormap() const { return fDefaultColormap; }
155  TGMimeTypes *GetMimeTypeList() const { return fMimeTypeList; }
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