library: libGui #include "TGClient.h"

# TGClient

class description - source file - inheritance tree (.pdf)

## class TGClient : public TObject

| Inheritance Chart:
`TObject`
| <- | `TGClient` |

        protected:

          Bool_t DoRedraw()
          Bool_t HandleEvent(Event_t* event)
          Bool_t HandleMaskEvent(Event_t* event, Window_t wid)
          Bool_t ProcessIdleEvent()
          Bool_t ProcessOneEvent()

        public:

                                TGClient(const char* dpyName = "0")
                                TGClient(const TGClient&)
                        virtual ~TGClient()
                           void AddIdleHandler(TGIdleHandler* h)
                           void AddUnknownWindowHandler(TGUnknownWindowHandler* h)
                 static TClass* Class()
                           void ForceRedraw()
                           void FreeColor(Pixel_t color) const
                           void FreeFont(const TGFont* font)
                           void FreeGC(const TGGC* gc)
                           void FreeGC(GContext_t gc)
                           void FreePicture(const TGPicture* pic)
                         Bool_t GetColorByName(const char* name, Pixel_t& pixel) const
                     Colormap_t GetDefaultColormap() const
                const TGWindow* GetDefaultRoot() const
                         UInt_t GetDisplayHeight() const
                         UInt_t GetDisplayWidth() const
                        TGFont* GetFont(const char* font, Bool_t fixedDefault = kTRUE)
                        TGFont* GetFont(const TGFont* font)
                   FontStruct_t GetFontByName(const char* name, Bool_t fixedDefault = kTRUE) const
                    TGFontPool* GetFontPool() const
                          TGGC* GetGC(GCValues_t* values, Bool_t rw = kFALSE)
                      TGGCPool* GetGCPool() const
                        Pixel_t GetHilite(Pixel_t base_color) const
                         TList* GetListOfPopups() const
                     THashList* GetListOfWindows() const
                   TGMimeTypes* GetMimeTypeList() const
               const TGPicture* GetPicture(const char* name) const
               const TGPicture* GetPicture(const char* name, UInt_t new_width, UInt_t new_height) const
                 TGPicturePool* GetPicturePool() const
          const TGResourcePool* GetResourcePool() const
                const TGWindow* GetRoot() const
                        Pixel_t GetShadow(Pixel_t base_color) const
                      TGWindow* GetWindowById(Window_t sw) const
                      TGWindow* GetWindowByName(const char* name) const
                         Bool_t HandleInput()
                virtual TClass* IsA() const
                         Bool_t IsEditable() const
                         Bool_t IsEditDisabled() const
                           void NeedRedraw(TGWindow* w, Bool_t force = kFALSE)
                      TGClient& operator=(const TGClient&)
                         Bool_t ProcessEventsFor(TGWindow* w)
                           void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
                           void RegisterPopup(TGWindow* w)
                           void RegisterWindow(TGWindow* w)
                           void RemoveIdleHandler(TGIdleHandler* h)
                           void RemoveUnknownWindowHandler(TGUnknownWindowHandler* h)
                           void SetEditDisabled(Bool_t on = kTRUE)
                           void SetRoot(TGWindow* root = 0)
                   virtual void ShowMembers(TMemberInspector& insp, char* parent)
                   virtual void Streamer(TBuffer& b)
                           void StreamerNVirtual(TBuffer& b)
                           void UnregisterPopup(TGWindow* w)
                           void UnregisterWindow(TGWindow* w)
                           void WaitFor(TGWindow* w)
                           void WaitForUnmap(TGWindow* w)

### Data Members

        protected:

                  Pixel_t fBackColor         default background color
                  Pixel_t fForeColor         default foreground color
                  Pixel_t fHilite            default hilite color
                  Pixel_t fShadow            default shadow color
                  Pixel_t fSelBackColor      default selection background color
                  Pixel_t fSelForeColor      default selection foreground color
                  Pixel_t fWhite             white color index
                  Pixel_t fBlack             black color index
                TGWindow* fDefaultRoot       default root window (base window of display)
                TGWindow* fRoot              current root window (changing root window allows embedding)
                    Int_t fXfd               file descriptor of connection to server
          TGResourcePool* fResourcePool      global GUI resource pool
                TGGCPool* fGCPool            graphics context pool
              TGFontPool* fFontPool          font pool
           TGPicturePool* fPicturePool       pixmap pool
             TGMimeTypes* fMimeTypeList      mimetype list
               Colormap_t fDefaultColormap   default colormap
                   Bool_t fGlobalNeedRedraw  true if at least one window needs to be redrawn
                   Bool_t fForceRedraw       redraw widgets as soon as possible
               THashList* fWlist             list of frames
                   TList* fPlist             list of popup windows used in HandleMaskEvent()
                   TList* fUWHandlers        list of event handlers for unknown windows
                   TList* fIdleHandlers      list of idle handlers
              EGEventType fWaitForEvent      event to wait for
                 Window_t fWaitForWindow     window in which to wait for event

## Class Description

     TGClient

     Window client. In client server windowing systems, like X11 this
     class is used to make the initial connection to the window server.

TGClient(const char *dpyName)

     Create a connection with the display sever on host dpyName and setup
     the complete GUI system, i.e., graphics contexts, fonts, etc. for all
     widgets.

const TGWindow* GetRoot() const

     Returns current root (i.e. base) window. By changing the root
     window one can change the window hierarchy, e.g. a top level
     frame (TGMainFrame) can be embedded in another window.

const TGWindow* GetDefaultRoot() const

     Returns the root (i.e. desktop) window. Should only be used as parent
     for frames that will never be embedded, like popups, message boxes,
     etc. (like TGToolTips, TGMessageBox, etc.).

void SetRoot(TGWindow *root)

     Sets the current root (i.e. base) window. By changing the root
     window one can change the window hierarchy, e.g. a top level
     frame (TGMainFrame) can be embedded in another window.

UInt_t GetDisplayWidth() const

     Get display width.

UInt_t GetDisplayHeight() const

     Get display height.

const TGPicture* GetPicture(const char *name)

     Get picture from the picture pool. Picture must be freed using
     TGClient::FreePicture(). If picture is not found 0 is returned.

const TGPicture* GetPicture(const char *name, UInt_t new_width, UInt_t new_height)

     Get picture with specified size from pool (picture will be scaled if
     necessary). Picture must be freed using TGClient::FreePicture(). If
     picture is not found 0 is returned.

void FreePicture(const TGPicture *pic)

     Free picture resource.

TGGC* GetGC(GCValues_t *values, Bool_t rw)

     Get graphics context from the gc pool. Context must be freed via
     TGClient::FreeGC(). If rw is true a new read/write-able GC
     is returned, otherwise a shared read-only context is returned.
     For historical reasons it is also possible to create directly a
     TGGC object, but it is advised to use this new interface only.

void FreeGC(const TGGC *gc)

     Free a graphics context.

void FreeGC(GContext_t gc)

     Free a graphics context.

TGFont* GetFont(const char *font, Bool_t fixedDefault)

     Get a font from the font pool. Fonts must be freed via
     TGClient::FreeFont(). Returns 0 in case of error or if font
     does not exist. If fixedDefault is false the "fixed" font
     will not be substituted as fallback when the asked for font
     does not exist.

TGFont* GetFont(const TGFont *font)

     Get again specified font. Will increase its usage count.

void FreeFont(const TGFont *font)

     Free a font.

void NeedRedraw(TGWindow *w, Bool_t force)

     Set redraw flags.

Bool_t GetColorByName(const char *name, Pixel_t &pixel) const

     Get a color by name. If color is found return kTRUE and pixel is
     set to the color's pixel value, kFALSE otherwise.

FontStruct_t GetFontByName(const char *name, Bool_t fixedDefault) const

     Get a font by name. If font is not found, fixed font is returned,
     if fixed font also does not exist return 0 and print error.
     The loaded font needs to be freed using TVirtualX::DeleteFont().
     If fixedDefault is false the "fixed" font will not be substituted
     as fallback when the asked for font does not exist.

Pixel_t GetHilite(Pixel_t base_color) const

     Return pixel value of hilite color based on base_color.

Pixel_t GetShadow(Pixel_t base_color) const

     Return pixel value of shadow color based on base_color.
     Shadow is 60% of base_color intensity.

void FreeColor(Pixel_t color) const

     Free color.

void RegisterWindow(TGWindow *w)

     Add a TGWindow to the clients list of windows.

void UnregisterWindow(TGWindow *w)

     Remove a TGWindow from the list of windows.

void RegisterPopup(TGWindow *w)

     Add a popup menu to the list of popups. This list is used to pass
     events to popup menus that are popped up over a transient window which
     is waited for (see WaitFor()).

void UnregisterPopup(TGWindow *w)

     Remove a popup menu from the list of popups.

void AddUnknownWindowHandler(TGUnknownWindowHandler *h)

     Add handler for unknown (i.e. unregistered) windows.

void RemoveUnknownWindowHandler(TGUnknownWindowHandler *h)

     Remove handler for unknown (i.e. unregistered) windows.

void AddIdleHandler(TGIdleHandler *h)

     Add handler for idle events.

void RemoveIdleHandler(TGIdleHandler *h)

     Remove handler for idle events.

TGWindow* GetWindowById(Window_t wid) const

     Find a TGWindow via its handle. If window is not found return 0.

TGWindow* GetWindowByName(const char *name) const

     Find a TGWindow via its name (unique name used in TGWindow::SavePrimitive).
     If window is not found return 0.

~TGClient()

     Closing down client: cleanup and close X connection.

Bool_t ProcessOneEvent()

     Process one event. This method should only be called when there is
     a GUI event ready to be processed. If event has been processed
     kTRUE is returned. If processing of a specific event type for a specific
     window was requested kFALSE is returned when specific event has been
     processed, kTRUE otherwise. If no more pending events return kFALSE.

Bool_t ProcessIdleEvent()

     Process one idle event.

Bool_t HandleInput()

     Handles input from the display server. Returns kTRUE if one or more
     events have been processed, kFALSE otherwise.

void WaitFor(TGWindow *w)

     Wait for window to be destroyed.

void WaitForUnmap(TGWindow *w)

     Wait for window to be unmapped.

Bool_t ProcessEventsFor(TGWindow *w)

     Like gSystem->ProcessEvents() but then only allow events for w to
     be processed. For example to interrupt the processing and destroy
     the window, call gROOT->SetInterrupt() before destroying the window.

Bool_t DoRedraw()

     Redraw all windows that need redrawing. Returns kFALSE if no redraw
     was needed, kTRUE otherwise.
     Only redraw the application's windows when the event queue
     does not contain expose event anymore.

Bool_t HandleEvent(Event_t *event)

     Handle a GUI event.

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 parent of the event window. The not
     masked event are handled directly. The masked events are:
     kButtonPress, kButtonRelease, kKeyPress, kKeyRelease, kEnterNotify,
     kLeaveNotify, kMotionNotify.

void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)

     Execute string "cmd" via the interpreter. Before executing replace
     in the command string the token $MSG, $PARM1 and $PARM2 by msg,
     parm1 and parm2, respectively. The function in cmd string must accept
     these as longs.

Bool_t IsEditDisabled() const

     returns kTRUE if edit/guibuilding is forbidden

void SetEditDisabled(Bool_t on)

     if on is kTRUE editting/guibuilding is forbidden

### Inline Functions

                           Bool_t IsEditable() const
                             void ForceRedraw()
            const TGResourcePool* GetResourcePool() const
                   TGPicturePool* GetPicturePool() const
                        TGGCPool* GetGCPool() const
                      TGFontPool* GetFontPool() const
                       Colormap_t GetDefaultColormap() const
                     TGMimeTypes* GetMimeTypeList() const
                       THashList* GetListOfWindows() const
                           TList* GetListOfPopups() const
                          TClass* Class()
                          TClass* IsA() const
                             void ShowMembers(TMemberInspector& insp, char* parent)
                             void Streamer(TBuffer& b)
                             void StreamerNVirtual(TBuffer& b)
                         TGClient TGClient(const TGClient&)
                        TGClient& operator=(const TGClient&)

Author: Fons Rademakers 27/12/97
Last update: root/gui:$Name: $:$Id: TGClient.cxx,v 1.44 2004/10/30 07:30:28 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *