32 #include "RConfigure.h" 56 static struct AddPseudoGlobals {
72 if (rootlocal && rootlocal->
IsBatch()) {
111 Bool_t TGInputHandler::Notify()
113 return fClient->HandleInput();
135 Error(
"TGClient",
"only one instance of TGClient allowed");
144 if ((fXfd =
gVirtualX->OpenDisplay(dpyName)) < 0) {
145 Error(
"TGClient",
"can't open display \"%s\", switching to batch mode...\n In case you run from a remote ssh session, reconnect with ssh -Y",
152 TGInputHandler *xi =
new TGInputHandler(
this, fXfd);
171 fDefaultRoot = fRoot =
new TGFrame(
this,
gVirtualX->GetDefaultRootWindow());
182 fGlobalNeedRedraw =
kFALSE;
184 fWaitForWindow =
kNone;
189 fPicturePool = fResourcePool->GetPicturePool();
190 fGCPool = fResourcePool->GetGCPool();
191 fFontPool = fResourcePool->GetFontPool();
193 fMimeTypeList = fResourcePool->GetMimeTypes();
194 fDefaultColormap = fResourcePool->GetDefaultColormap();
198 fWhite = fResourcePool->GetWhiteColor();
199 fBlack = fResourcePool->GetBlackColor();
200 fBackColor = fResourcePool->GetFrameBgndColor();
201 fForeColor = fResourcePool->GetFrameFgndColor();
204 fSelForeColor = fResourcePool->GetSelectedFgndColor();
205 fSelBackColor = fResourcePool->GetSelectedBgndColor();
214 gClientGlobal =
this;
244 fRoot = root ? root : fDefaultRoot;
253 if (style && strstr(style,
"modern"))
300 return fPicturePool->
GetPicture(name, new_width, new_height);
308 if (pic) fPicturePool->FreePicture(pic);
320 return fGCPool->
GetGC(values, rw);
348 return fFontPool->GetFont(font, fixedDefault);
356 return fFontPool->GetFont(font);
364 fFontPool->FreeFont(font);
377 w->fNeedRedraw =
kTRUE;
378 fGlobalNeedRedraw =
kTRUE;
398 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
401 Error(
"GetColorByName",
"couldn't parse color %s", name);
404 Warning(
"GetColorByName",
"couldn't retrieve color %s.\n" 405 "Please close any other application, like netscape, " 406 "that might exhaust\nthe colormap and start ROOT again", name);
424 if (
gROOT->IsBatch())
429 if (!font && fixedDefault) {
430 font =
gVirtualX->LoadQueryFont(
"fixed");
432 Warning(
"GetFontByName",
"couldn't retrieve font %s, using \"fixed\"", name);
436 Error(
"GetFontByName",
"couldn't retrieve font %s nor backup font \"fixed\"", name);
438 Warning(
"GetFontByName",
"couldn't retrieve font %s", name);
452 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
454 color.
fPixel = base_color;
457 GetColorByName(
"white", white_p.
fPixel);
469 Error(
"GetHilite",
"couldn't allocate hilight color");
483 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
485 color.
fPixel = base_color;
493 Error(
"GetShadow",
"couldn't allocate shadow color");
503 gVirtualX->FreeColor(fDefaultColormap, color);
514 RegisteredWindow(w->
GetId());
535 RegisteredWindow(w->
GetId());
552 fUWHandlers =
new TList;
564 fUWHandlers->Remove(h);
572 if (!fIdleHandlers) {
573 fIdleHandlers =
new TList;
577 fIdleHandlers->Add(h);
585 fIdleHandlers->Remove(h);
595 return (
TGWindow *) fWlist->FindObject(&wt);
607 while ((obj = next())) {
625 fWlist->Delete(
"slow");
629 delete fIdleHandlers;
630 delete fResourcePool;
647 if (!fRoot)
return kFALSE;
650 if (fWaitForWindow ==
kNone) {
656 HandleMaskEvent(&event, fWaitForWindow);
657 if ((event.
fType == fWaitForEvent) && (event.
fWindow == fWaitForWindow))
658 fWaitForWindow =
kNone;
666 if (DoRedraw())
return kTRUE;
669 if (ProcessIdleEvent())
return kTRUE;
682 RemoveIdleHandler(ih);
698 while (ProcessOneEvent())
699 handledevent =
kTRUE;
711 fWaitForWindow = w->
GetId();
720 while (fWaitForWindow !=
kNone) {
727 fWaitForWindow = wsave;
728 fWaitForEvent = esave;
739 fWaitForWindow = w->
GetId();
748 while (fWaitForWindow !=
kNone) {
753 fWaitForWindow = wsave;
754 fWaitForEvent = esave;
762 if (fWaitForWindow == w->
GetId()) fWaitForWindow =
kNone;
775 fWaitForWindow = w->
GetId();
780 fWaitForWindow = wsave;
781 fWaitForEvent = esave;
794 if (!fGlobalNeedRedraw)
return kFALSE;
797 TObjLink *lnk = fWlist->FirstLink();
807 fGlobalNeedRedraw =
kFALSE;
822 ProcessedEvent(event, 0);
826 if ((w = GetWindowById(event->
fWindow)) == 0) {
827 if (fUWHandlers && fUWHandlers->GetSize() > 0) {
861 ProcessedEvent(event, wid);
868 if ((ptr->
fId == wid) ||
883 while ((pop = (
TGWindow *) next())) {
885 if ((ptr->
fId == pop->
fId) &&
920 snprintf(s,
sizeof(s),
"%ld", parm1);
923 snprintf(s,
sizeof(s),
"%ld", parm2);
934 return (fDefaultRoot->GetEditDisabled() == 1);
942 fDefaultRoot->SetEditDisabled(on);
955 Emit(
"ProcessedEvent(Event_t*, Window_t)", args);
964 Emit(
"RegisteredWindow(Window_t)", w);
void ProcessedEvent(Event_t *event, Window_t wid)
Emits a signal when an event has been processed.
Bool_t IsEditDisabled() const
Returns kTRUE if edit/guibuilding is forbidden.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Bool_t HandleEvent(Event_t *event)
Handle a GUI event.
ROOT top level object description.
void SetRoot(TGWindow *root=0)
Sets the current root (i.e.
virtual ~TGClient()
Closing down client: cleanup and close X connection.
void RemoveIdleHandler(TGIdleHandler *h)
Remove handler for idle events.
const TGWindow * GetRoot() const
Returns current root (i.e.
void FreeColor(Pixel_t color) const
Free color.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
void TriggerDictionaryInitialization_libGui()
Pixel_t GetShadow(Pixel_t base_color) const
Return pixel value of shadow color based on base_color.
virtual Bool_t HandleEvent()
Handle the idle event.
R__EXTERN Atom_t gWM_DELETE_WINDOW
Short_t Min(Short_t a, Short_t b)
Bool_t GetColorByName(const char *name, Pixel_t &pixel) const
Get a color by name.
R__EXTERN TApplication * gApplication
TObject * Next()
Return next object in the list. Returns 0 when no more objects in list.
static TGClientInit gClientInit
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
void CancelRedraw(TGWindow *w)
void UnregisterWindow(TGWindow *w)
Remove a TGWindow from the list of windows.
static ARGB32 GetShadow(ARGB32 background)
Calculate shadow color.
Bool_t ProcessIdleEvent()
Process one idle event.
UInt_t GetDisplayWidth() const
Get display width.
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
TGWindow * GetWindowByName(const char *name) const
Find a TGWindow via its name (unique name used in TGWindow::SavePrimitive).
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
void RegisterWindow(TGWindow *w)
Add a TGWindow to the clients list of windows.
void FreePicture(const TGPicture *pic)
Free picture resource.
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
R__EXTERN TFileHandler * gXDisplay
void SetStyle(UInt_t newstyle)
virtual Bool_t HandleEvent(Event_t *)=0
virtual void SetDisplay()
Set DISPLAY environment variable based on utmp entry. Only for UNIX.
Bool_t DoRedraw()
Redraw all windows that need redrawing.
void FreeGC(const TGGC *gc)
Free a graphics context.
void RegisteredWindow(Window_t w)
Emits a signal when a Window has been registered in TGClient.
void Error(const char *location, const char *msgfmt,...)
void WaitFor(TGWindow *w)
Wait for window to be destroyed.
Pixmap_t GetPicture() const
R__EXTERN TROOT * gROOTLocal
void FreeFont(const TGFont *font)
Free a font.
static void NeedGraphicsLibs()
Static method.
R__EXTERN TSystem * gSystem
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...
static TGClient * gClientGlobal
void RemoveUnknownWindowHandler(TGUnknownWindowHandler *h)
Remove handler for unknown (i.e. unregistered) windows.
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
void AddUnknownWindowHandler(TGUnknownWindowHandler *h)
Add handler for unknown (i.e. unregistered) windows.
Bool_t ProcessOneEvent()
Process one event.
static TGClient * Instance()
Returns global gClient (initialize graphics first, if not already done)
Bool_t HandleInput()
Handles input from the display server.
void Warning(const char *location, const char *msgfmt,...)
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
void InitializeGraphics()
Initialize the graphics environment.
static void Add(TGlobalMappedFunction *gmf)
Pixel_t GetHilite(Pixel_t base_color) const
Return pixel value of hilite color based on base_color.
void ResetWaitFor(TGWindow *w)
reset waiting
virtual Bool_t HandleEvent(Event_t *)
Wrapper around a TObject so it can be stored in a TList.
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
static ARGB32 GetHilite(ARGB32 background)
Calculate highlite color.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
UInt_t GetDisplayHeight() const
Get display height.
void AddIdleHandler(TGIdleHandler *h)
Add handler for idle events.
Mother of all ROOT objects.
FontStruct_t GetFontByName(const char *name, Bool_t fixedDefault=kTRUE) const
Get a font by name.
R__EXTERN Atom_t gMOTIF_WM_HINTS
TObject * GetObject() const
Short_t Max(Short_t a, Short_t b)
Bool_t ProcessEventsFor(TGWindow *w)
Like gSystem->ProcessEvents() but then only allow events for w to be processed.
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
virtual const char * GetName() const
Returns name of object.
void SetEditDisabled(Bool_t on=kTRUE)
If on is kTRUE editting/guibuilding is forbidden.
void UnregisterPopup(TGWindow *w)
Remove a popup menu from the list of popups.
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
R__EXTERN Atom_t gROOT_MESSAGE
const char * Data() const
TGWindow * GetWindowById(Window_t sw) const
Find a TGWindow via its handle. If window is not found return 0.