Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGClient.cxx
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
13 This source is based on Xclass95, a Win95-looking GUI toolkit.
14 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15
16 Xclass95 is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21**************************************************************************/
22
23//////////////////////////////////////////////////////////////////////////
24// //
25// TGClient //
26// //
27// Window client. In client server windowing systems, like X11 this //
28// class is used to make the initial connection to the window server. //
29// //
30//////////////////////////////////////////////////////////////////////////
31
32#include "RConfigure.h"
33
34#include "TGClient.h"
35#include "TROOT.h"
36#include "TApplication.h"
37#include "TSystem.h"
38#include "TEnv.h"
39#include "THashList.h"
40#include "TSysEvtHandler.h"
41#include "TVirtualX.h"
42#include "TGWindow.h"
43#include "TGResourcePool.h"
44#include "TGGC.h"
45#include "TGFont.h"
46#include "TGMimeTypes.h"
47#include "TGFrame.h"
48#include "TGIdleHandler.h"
49#include "TError.h"
50#include "TGlobal.h"
51#include "snprintf.h"
52
53// Global pointer to the TGClient object
54static TGClient *gClientGlobal = nullptr;
55
56namespace {
57static struct AddPseudoGlobals {
58AddPseudoGlobals() {
59 // User "gCling" as synonym for "libCore static initialization has happened".
60 // This code here must not trigger it
61 TGlobalMappedFunction::MakeFunctor("gClient", "TGClient*", TGClient::Instance, [] {
62 TGClient::Instance(); // first ensure object is created;
63 return (void *) &gClientGlobal;
64 });
65}
66} gAddPseudoGlobals;
67}
68
69// Initialize gClient in case libGui is loaded in batch mode
71class TGClientInit {
72public:
73 TGClientInit() {
75 if (rootlocal && rootlocal->IsBatch()) {
76 // For now check if the heaeder files (or the module containing them)
77 // has been loaded in Cling.
78 // This is required because the dictionaries must be initialized
79 // __before__ the TGClient creation which will induce the creation
80 // of a TClass object which will need the dictionary for TGClient!
82 new TGClient();
83 }
85 }
86};
87static TGClientInit gClientInit;
88
89////////////////////////////////////////////////////////////////////////////////
90/// Returns global gClient (initialize graphics first, if not already done)
91
93{
96 return gClientGlobal;
97}
98
99//----- Graphics Input handler -------------------------------------------------
100////////////////////////////////////////////////////////////////////////////////
101
102class TGInputHandler : public TFileHandler {
103private:
104 TGClient *fClient; // connection to display server
105public:
106 TGInputHandler(TGClient *c, Int_t fd) : TFileHandler(fd, 1) { fClient = c; }
107 Bool_t Notify();
108 // Important: don't override ReadNotify()
109};
110
111////////////////////////////////////////////////////////////////////////////////
112/// Notify input from the display server.
113
114Bool_t TGInputHandler::Notify()
115{
116 return fClient->HandleInput();
117}
118
119
121
122////////////////////////////////////////////////////////////////////////////////
123/// Create a connection with the display sever on host dpyName and setup
124/// the complete GUI system, i.e., graphics contexts, fonts, etc. for all
125/// widgets.
126
127TGClient::TGClient(const char *dpyName)
128{
129 fRoot = 0;
130 fPicturePool = 0;
131 fMimeTypeList = 0;
132 fWlist = 0;
133 fPlist = 0;
134 fUWHandlers = 0;
135 fIdleHandlers = 0;
136
137 if (gClientGlobal) {
138 Error("TGClient", "only one instance of TGClient allowed");
139 MakeZombie();
140 return;
141 }
142
143 // Set DISPLAY based on utmp (only if DISPLAY is not yet set).
145
146 // Open the connection to the display
147 if ((fXfd = gVirtualX->OpenDisplay(dpyName)) < 0) {
148 MakeZombie();
149 return;
150 }
151
152 if (fXfd >= 0 && !ROOT::Internal::gROOTLocal->IsBatch()) {
153 TGInputHandler *xi = new TGInputHandler(this, fXfd);
154 if (fXfd) gSystem->AddFileHandler(xi);
155 // X11 events are handled via gXDisplay->Notify() in
156 // TUnixSystem::DispatchOneEvent(). When no events available we wait for
157 // events on all TFileHandlers including this one via a select() call.
158 // However, X11 events are always handled via gXDisplay->Notify() and not
159 // via the ReadNotify() (therefore TGInputHandler should not override
160 // TFileHandler::ReadNotify()).
161 gXDisplay = xi;
162 }
163
164 // Initialize internal window list. Use a THashList for fast
165 // finding of windows based on window id (see GetWindowById()).
166
167 fWlist = new THashList(200);
168 fPlist = new TList;
169
170 // Create root window
171
172 fDefaultRoot = fRoot = new TGFrame(this, gVirtualX->GetDefaultRootWindow());
173
174 // Setup some atoms (defined in TVirtualX)...
175
176 gWM_DELETE_WINDOW = gVirtualX->InternAtom("WM_DELETE_WINDOW", kFALSE);
177 gMOTIF_WM_HINTS = gVirtualX->InternAtom("_MOTIF_WM_HINTS", kFALSE);
178 gROOT_MESSAGE = gVirtualX->InternAtom("_ROOT_MESSAGE", kFALSE);
179
180 // Create the graphics event handler, an object for the root window,
181 // a picture pool, mimetype list, etc...
182
187
188 fResourcePool = new TGResourcePool(this);
189
193
196
197 // Set some color defaults...
198
207
208 fStyle = 0;
209 TString style = gEnv->GetValue("Gui.Style", "modern");
210 if (style.Contains("flat", TString::kIgnoreCase))
211 fStyle = 2;
212 else if (style.Contains("modern", TString::kIgnoreCase))
213 fStyle = 1;
214
215 gClientGlobal = this;
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Returns current root (i.e. base) window. By changing the root
220/// window one can change the window hierarchy, e.g. a top level
221/// frame (TGMainFrame) can be embedded in another window.
222
224{
225 return fRoot;
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Returns the root (i.e. desktop) window. Should only be used as parent
230/// for frames that will never be embedded, like popups, message boxes,
231/// etc. (like TGToolTips, TGMessageBox, etc.).
232
234{
235 return fDefaultRoot;
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Sets the current root (i.e. base) window. By changing the root
240/// window one can change the window hierarchy, e.g. a top level
241/// frame (TGMainFrame) can be embedded in another window.
242
244{
245 fRoot = root ? root : fDefaultRoot;
246}
247
248////////////////////////////////////////////////////////////////////////////////
249/// Set the button style (modern or classic).
250
251void TGClient::SetStyle(const char *style)
252{
253 fStyle = 0;
254 if (style && strstr(style, "modern"))
255 fStyle = 1;
256}
257
258////////////////////////////////////////////////////////////////////////////////
259/// Get display width.
260
262{
263 Int_t x, y;
264 UInt_t w, h;
265
266 gVirtualX->GetGeometry(-1, x, y, w, h);
267
268 return w;
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Get display height.
273
275{
276 Int_t x, y;
277 UInt_t w, h;
278
279 gVirtualX->GetGeometry(-1, x, y, w, h);
280
281 return h;
282}
283
284////////////////////////////////////////////////////////////////////////////////
285/// Get picture from the picture pool. Picture must be freed using
286/// TGClient::FreePicture(). If picture is not found 0 is returned.
287
289{
291}
292
293////////////////////////////////////////////////////////////////////////////////
294/// Get picture with specified size from pool (picture will be scaled if
295/// necessary). Picture must be freed using TGClient::FreePicture(). If
296/// picture is not found 0 is returned.
297
299 UInt_t new_width, UInt_t new_height)
300{
301 return fPicturePool->GetPicture(name, new_width, new_height);
302}
303
304////////////////////////////////////////////////////////////////////////////////
305/// Free picture resource.
306
308{
309 if (pic) fPicturePool->FreePicture(pic);
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Get graphics context from the gc pool. Context must be freed via
314/// TGClient::FreeGC(). If rw is true a new read/write-able GC
315/// is returned, otherwise a shared read-only context is returned.
316/// For historical reasons it is also possible to create directly a
317/// TGGC object, but it is advised to use this new interface only.
318
320{
321 return fGCPool->GetGC(values, rw);
322}
323
324////////////////////////////////////////////////////////////////////////////////
325/// Free a graphics context.
326
327void TGClient::FreeGC(const TGGC *gc)
328{
329 fGCPool->FreeGC(gc);
330}
331
332////////////////////////////////////////////////////////////////////////////////
333/// Free a graphics context.
334
336{
337 fGCPool->FreeGC(gc);
338}
339
340////////////////////////////////////////////////////////////////////////////////
341/// Get a font from the font pool. Fonts must be freed via
342/// TGClient::FreeFont(). Returns 0 in case of error or if font
343/// does not exist. If fixedDefault is false the "fixed" font
344/// will not be substituted as fallback when the asked for font
345/// does not exist.
346
347TGFont *TGClient::GetFont(const char *font, Bool_t fixedDefault)
348{
349 return fFontPool->GetFont(font, fixedDefault);
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// Get again specified font. Will increase its usage count.
354
356{
357 return fFontPool->GetFont(font);
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// Free a font.
362
363void TGClient::FreeFont(const TGFont *font)
364{
365 fFontPool->FreeFont(font);
366}
367
368////////////////////////////////////////////////////////////////////////////////
369/// Set redraw flags.
370
372{
373 if (!w) return;
374 if (gVirtualX->NeedRedraw((ULong_t)w,force)) return;
375 if (force) {
376 w->DoRedraw();
377 return;
378 }
379 w->fNeedRedraw = kTRUE;
381}
382
383////////////////////////////////////////////////////////////////////////////////
384
386{
387 w->fNeedRedraw = kFALSE;
388}
389
390////////////////////////////////////////////////////////////////////////////////
391/// Get a color by name. If color is found return kTRUE and pixel is
392/// set to the color's pixel value, kFALSE otherwise.
393
394Bool_t TGClient::GetColorByName(const char *name, Pixel_t &pixel) const
395{
396 ColorStruct_t color;
398 Bool_t status = kTRUE;
399
400 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
401 color.fPixel = 0;
402 if (!gVirtualX->ParseColor(attributes.fColormap, name, color)) {
403 Error("GetColorByName", "couldn't parse color %s", name);
404 status = kFALSE;
405 } else if (!gVirtualX->AllocColor(attributes.fColormap, color)) {
406 Warning("GetColorByName", "couldn't retrieve color %s.\n"
407 "Please close any other application, like netscape, "
408 "that might exhaust\nthe colormap and start ROOT again", name);
409 status = kFALSE;
410 }
411
412 pixel = color.fPixel;
413
414 return status;
415}
416
417////////////////////////////////////////////////////////////////////////////////
418/// Get a font by name. If font is not found, fixed font is returned,
419/// if fixed font also does not exist return 0 and print error.
420/// The loaded font needs to be freed using TVirtualX::DeleteFont().
421/// If fixedDefault is false the "fixed" font will not be substituted
422/// as fallback when the asked for font does not exist.
423
424FontStruct_t TGClient::GetFontByName(const char *name, Bool_t fixedDefault) const
425{
426 if (gROOT->IsBatch())
427 return (FontStruct_t) -1;
428
429 FontStruct_t font = gVirtualX->LoadQueryFont(name);
430
431 if (!font && fixedDefault) {
432 font = gVirtualX->LoadQueryFont("fixed");
433 if (font)
434 Warning("GetFontByName", "couldn't retrieve font %s, using \"fixed\"", name);
435 }
436 if (!font) {
437 if (fixedDefault)
438 Error("GetFontByName", "couldn't retrieve font %s nor backup font \"fixed\"", name);
439 else
440 Warning("GetFontByName", "couldn't retrieve font %s", name);
441 }
442
443 return font;
444}
445
446////////////////////////////////////////////////////////////////////////////////
447/// Return pixel value of hilite color based on base_color.
448
450{
451 ColorStruct_t color, white_p;
453
454 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
455
456 color.fPixel = base_color;
457 gVirtualX->QueryColor(attributes.fColormap, color);
458
459 GetColorByName("white", white_p.fPixel);
460 gVirtualX->QueryColor(attributes.fColormap, white_p);
461
462 color.fRed = TMath::Max((UShort_t)(white_p.fRed/5), color.fRed);
463 color.fGreen = TMath::Max((UShort_t)(white_p.fGreen/5), color.fGreen);
464 color.fBlue = TMath::Max((UShort_t)(white_p.fBlue/5), color.fBlue);
465
466 color.fRed = (UShort_t)TMath::Min((Int_t)white_p.fRed, (Int_t)(color.fRed*140)/100);
467 color.fGreen = (UShort_t)TMath::Min((Int_t)white_p.fGreen, (Int_t)(color.fGreen*140)/100);
468 color.fBlue = (UShort_t)TMath::Min((Int_t)white_p.fBlue, (Int_t)(color.fBlue*140)/100);
469
470 if (!gVirtualX->AllocColor(attributes.fColormap, color))
471 Error("GetHilite", "couldn't allocate hilight color");
472
473 return color.fPixel;
474}
475
476////////////////////////////////////////////////////////////////////////////////
477/// Return pixel value of shadow color based on base_color.
478/// Shadow is 60% of base_color intensity.
479
481{
482 ColorStruct_t color;
484
485 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
486
487 color.fPixel = base_color;
488 gVirtualX->QueryColor(attributes.fColormap, color);
489
490 color.fRed = (UShort_t)((color.fRed*60)/100);
491 color.fGreen = (UShort_t)((color.fGreen*60)/100);
492 color.fBlue = (UShort_t)((color.fBlue*60)/100);
493
494 if (!gVirtualX->AllocColor(attributes.fColormap, color))
495 Error("GetShadow", "couldn't allocate shadow color");
496
497 return color.fPixel;
498}
499
500////////////////////////////////////////////////////////////////////////////////
501/// Free color.
502
504{
505 gVirtualX->FreeColor(fDefaultColormap, color);
506}
507
508////////////////////////////////////////////////////////////////////////////////
509/// Add a TGWindow to the clients list of windows.
510
512{
513 fWlist->Add(w);
514
515 // Emits signal
517}
518
519////////////////////////////////////////////////////////////////////////////////
520/// Remove a TGWindow from the list of windows.
521
523{
524 fWlist->Remove(w);
525}
526
527////////////////////////////////////////////////////////////////////////////////
528/// Add a popup menu to the list of popups. This list is used to pass
529/// events to popup menus that are popped up over a transient window which
530/// is waited for (see WaitFor()).
531
533{
534 fPlist->Add(w);
535
536 // Emits signal
538}
539
540////////////////////////////////////////////////////////////////////////////////
541/// Remove a popup menu from the list of popups.
542
544{
545 fPlist->Remove(w);
546}
547
548////////////////////////////////////////////////////////////////////////////////
549/// Add handler for unknown (i.e. unregistered) windows.
550
552{
553 if (!fUWHandlers) {
554 fUWHandlers = new TList;
556 }
557
558 fUWHandlers->Add(h);
559}
560
561////////////////////////////////////////////////////////////////////////////////
562/// Remove handler for unknown (i.e. unregistered) windows.
563
565{
567}
568
569////////////////////////////////////////////////////////////////////////////////
570/// Add handler for idle events.
571
573{
574 if (!fIdleHandlers) {
575 fIdleHandlers = new TList;
577 }
578
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Remove handler for idle events.
584
586{
588}
589
590////////////////////////////////////////////////////////////////////////////////
591/// Find a TGWindow via its handle. If window is not found return 0.
592
594{
595 TGWindow wt(wid);
596
597 return (TGWindow *) fWlist->FindObject(&wt);
598}
599
600////////////////////////////////////////////////////////////////////////////////
601/// Find a TGWindow via its name (unique name used in TGWindow::SavePrimitive).
602/// If window is not found return 0.
603
605{
606 TIter next(fWlist);
607
608 TObject *obj;
609 while ((obj = next())) {
610 TString n = obj->GetName();
611 if (n == name) {
612 return (TGWindow*)obj;
613 }
614 }
615 return 0;
616}
617
618////////////////////////////////////////////////////////////////////////////////
619/// Closing down client: cleanup and close X connection.
620
622{
623 if (IsZombie())
624 return;
625
626 if (fWlist)
627 fWlist->Delete("slow");
628 delete fWlist;
629 delete fPlist;
630 delete fUWHandlers;
631 delete fIdleHandlers;
632 delete fResourcePool;
633
634 gVirtualX->CloseDisplay(); // this should do a cleanup of the remaining
635 // X allocated objects...
636}
637
638////////////////////////////////////////////////////////////////////////////////
639/// Process one event. This method should only be called when there is
640/// a GUI event ready to be processed. If event has been processed
641/// kTRUE is returned. If processing of a specific event type for a specific
642/// window was requested kFALSE is returned when specific event has been
643/// processed, kTRUE otherwise. If no more pending events return kFALSE.
644
646{
647 Event_t event;
648
649 if (!fRoot) return kFALSE;
650 if (gVirtualX->EventsPending()) {
651 gVirtualX->NextEvent(event);
652 if (fWaitForWindow == kNone) {
653 HandleEvent(&event);
654 if (fForceRedraw)
655 DoRedraw();
656 return kTRUE;
657 } else {
659 if ((event.fType == fWaitForEvent) && (event.fWindow == fWaitForWindow))
661 if (fForceRedraw)
662 DoRedraw();
663 return kTRUE;
664 }
665 }
666
667 // if nothing else to do redraw windows that need redrawing
668 if (DoRedraw()) return kTRUE;
669
670 // process one idle event if there is nothing else to do
671 if (ProcessIdleEvent()) return kTRUE;
672
673 return kFALSE;
674}
675
676////////////////////////////////////////////////////////////////////////////////
677/// Process one idle event.
678
680{
681 if (fIdleHandlers) {
683 if (ih) {
685 ih->HandleEvent();
686 return kTRUE;
687 }
688 }
689 return kFALSE;
690}
691
692////////////////////////////////////////////////////////////////////////////////
693/// Handles input from the display server. Returns kTRUE if one or more
694/// events have been processed, kFALSE otherwise.
695
697{
698 Bool_t handledevent = kFALSE;
699
700 while (ProcessOneEvent())
701 handledevent = kTRUE;
702 return handledevent;
703}
704
705////////////////////////////////////////////////////////////////////////////////
706/// Wait for window to be destroyed.
707
709{
710 Window_t wsave = fWaitForWindow;
712
713 fWaitForWindow = w->GetId();
715
716 //Let VirtualX know, that we are
717 //in a nested loop for a window w.
718 //Noop on X11/win32gdk.
719 if (gVirtualX)
720 gVirtualX->BeginModalSessionFor(w->GetId());
721
722 while (fWaitForWindow != kNone) {
723 if (esave == kUnmapNotify)
724 wsave = kNone;
725 gSystem->ProcessEvents();//gSystem->InnerLoop();
726 gSystem->Sleep(5);
727 }
728
729 fWaitForWindow = wsave;
730 fWaitForEvent = esave;
731}
732
733////////////////////////////////////////////////////////////////////////////////
734/// Wait for window to be unmapped.
735
737{
738 Window_t wsave = fWaitForWindow;
740
741 fWaitForWindow = w->GetId();
743
744 //Let VirtualX know, that we are
745 //in a nested loop for a window w.
746 //Noop on X11/win32gdk.
747 if (gVirtualX)
748 gVirtualX->BeginModalSessionFor(w->GetId());
749
750 while (fWaitForWindow != kNone) {
751 gSystem->ProcessEvents();//gSystem->InnerLoop();
752 gSystem->Sleep(5);
753 }
754
755 fWaitForWindow = wsave;
756 fWaitForEvent = esave;
757}
758
759////////////////////////////////////////////////////////////////////////////////
760/// reset waiting
761
763{
765}
766
767////////////////////////////////////////////////////////////////////////////////
768/// Like gSystem->ProcessEvents() but then only allow events for w to
769/// be processed. For example to interrupt the processing and destroy
770/// the window, call gROOT->SetInterrupt() before destroying the window.
771
773{
774 Window_t wsave = fWaitForWindow;
776
777 fWaitForWindow = w->GetId();
779
780 Bool_t intr = gSystem->ProcessEvents();
781
782 fWaitForWindow = wsave;
783 fWaitForEvent = esave;
784
785 return intr;
786}
787
788////////////////////////////////////////////////////////////////////////////////
789/// Redraw all windows that need redrawing. Returns kFALSE if no redraw
790/// was needed, kTRUE otherwise.
791/// Only redraw the application's windows when the event queue
792/// does not contain expose event anymore.
793
795{
796 if (!fGlobalNeedRedraw) return kFALSE;
797
798 TGWindow *w;
799 TObjLink *lnk = fWlist->FirstLink();
800 while (lnk) {
801 w = (TGWindow *) lnk->GetObject();
802 if (w->fNeedRedraw) {
803 w->DoRedraw();
804 w->fNeedRedraw = kFALSE;
805 }
806 lnk = lnk->Next();
807 }
808
811
812 return kTRUE;
813}
814
815////////////////////////////////////////////////////////////////////////////////
816/// Handle a GUI event.
817
819{
820 TGWindow *w;
821
822 // Emit signal for event recorder(s)
823 if (event->fType != kConfigureNotify) {
824 ProcessedEvent(event, 0);
825 }
826
827 // Find window where event happened
828 if ((w = GetWindowById(event->fWindow)) == 0) {
829 if (fUWHandlers && fUWHandlers->GetSize() > 0) {
832 while ((unkwh = (TGUnknownWindowHandler*)it.Next())) {
833 if (unkwh->HandleEvent(event))
834 return kTRUE;
835 }
836 }
837 //Warning("HandleEvent", "unknown window %ld not handled\n",
838 // event->fWindow);
839 return kFALSE;
840 }
841
842 // and let it handle the event
843 w->HandleEvent(event);
844
845 return kTRUE;
846}
847
848////////////////////////////////////////////////////////////////////////////////
849/// Handle masked events only if window wid is the window for which the
850/// event was reported or if wid is a parent of the event window. The not
851/// masked event are handled directly. The masked events are:
852/// kButtonPress, kButtonRelease, kKeyPress, kKeyRelease, kEnterNotify,
853/// kLeaveNotify, kMotionNotify.
854
856{
857 TGWindow *w, *ptr, *pop;
858
859 if ((w = GetWindowById(event->fWindow)) == 0) return kFALSE;
860
861 // Emit signal for event recorder(s)
862 if (event->fType != kConfigureNotify) {
863 ProcessedEvent(event, wid);
864 }
865
866 // This breaks class member protection, but TGClient is a friend of
867 // TGWindow and _should_ know what to do and what *not* to do...
868
869 for (ptr = w; ptr->fParent != 0; ptr = (TGWindow *) ptr->fParent) {
870 if ((ptr->fId == wid) ||
871 ((event->fType != kButtonPress) &&
872 (event->fType != kButtonRelease) &&
873 (event->fType != kGKeyPress) &&
874 (event->fType != kKeyRelease) &&
875 (event->fType != kEnterNotify) &&
876 (event->fType != kLeaveNotify) &&
877 (event->fType != kMotionNotify))) {
878 w->HandleEvent(event);
879 return kTRUE;
880 }
881 }
882
883 // check if this is a popup menu
884 TIter next(fPlist);
885 while ((pop = (TGWindow *) next())) {
886 for (ptr = w; ptr->fParent != 0; ptr = (TGWindow *) ptr->fParent) {
887 if ((ptr->fId == pop->fId) &&
888 ((event->fType == kButtonPress) ||
889 (event->fType == kButtonRelease) ||
890 (event->fType == kGKeyPress) ||
891 (event->fType == kKeyRelease) ||
892 (event->fType == kEnterNotify) ||
893 (event->fType == kLeaveNotify) ||
894 (event->fType == kMotionNotify))) {
895 w->HandleEvent(event);
896 return kTRUE;
897 }
898 }
899 }
900
901 if (event->fType == kButtonPress || event->fType == kGKeyPress)
902 gVirtualX->Bell(0);
903
904 return kFALSE;
905}
906
907////////////////////////////////////////////////////////////////////////////////
908/// Execute string "cmd" via the interpreter. Before executing replace
909/// in the command string the token $MSG, $PARM1 and $PARM2 by msg,
910/// parm1 and parm2, respectively. The function in cmd string must accept
911/// these as longs.
912
914{
915 if (cmd.IsNull()) return;
916
917 char s[32];
918
919 snprintf(s, sizeof(s), "%ld", msg);
920 cmd.ReplaceAll("$MSG", s);
921
922 snprintf(s, sizeof(s), "%ld", parm1);
923 cmd.ReplaceAll("$PARM1", s);
924
925 snprintf(s, sizeof(s), "%ld", parm2);
926 cmd.ReplaceAll("$PARM2", s);
927
928 gROOT->ProcessLine(cmd.Data());
929}
930
931////////////////////////////////////////////////////////////////////////////////
932/// Returns kTRUE if edit/guibuilding is forbidden.
933
935{
936 return (fDefaultRoot->GetEditDisabled() == 1);
937}
938
939////////////////////////////////////////////////////////////////////////////////
940/// If on is kTRUE editting/guibuilding is forbidden.
941
943{
945}
946
947////////////////////////////////////////////////////////////////////////////////
948/// Emits a signal when an event has been processed.
949/// Used in TRecorder.
950
952{
953 Long_t args[2];
954 args[0] = (Long_t) event;
955 args[1] = (Long_t) wid;
956
957 Emit("ProcessedEvent(Event_t*, Window_t)", args);
958}
959
960////////////////////////////////////////////////////////////////////////////////
961/// Emits a signal when a Window has been registered in TGClient.
962/// Used in TRecorder.
963
965{
966 Emit("RegisteredWindow(Window_t)", w);
967}
EGEventType
Definition GuiTypes.h:59
@ kConfigureNotify
Definition GuiTypes.h:62
@ kGKeyPress
Definition GuiTypes.h:60
@ kUnmapNotify
Definition GuiTypes.h:62
@ kButtonRelease
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
@ kDestroyNotify
Definition GuiTypes.h:62
@ kMotionNotify
Definition GuiTypes.h:61
@ kEnterNotify
Definition GuiTypes.h:61
@ kOtherEvent
Definition GuiTypes.h:64
@ kKeyRelease
Definition GuiTypes.h:60
@ kLeaveNotify
Definition GuiTypes.h:61
const Handle_t kNone
Definition GuiTypes.h:88
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
unsigned short UShort_t
Definition RtypesCore.h:40
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:92
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
R__EXTERN TApplication * gApplication
R__EXTERN TEnv * gEnv
Definition TEnv.h:171
static TGClient * gClientGlobal
Definition TGClient.cxx:54
static TGClientInit gClientInit
Definition TGClient.cxx:87
void TriggerDictionaryInitialization_libGui()
char name[80]
Definition TGX11.cxx:110
#define gROOT
Definition TROOT.h:406
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
R__EXTERN TFileHandler * gXDisplay
Definition TSystem.h:560
#define gVirtualX
Definition TVirtualX.h:338
R__EXTERN Atom_t gROOT_MESSAGE
Definition TVirtualX.h:40
R__EXTERN Atom_t gMOTIF_WM_HINTS
Definition TVirtualX.h:39
R__EXTERN Atom_t gWM_DELETE_WINDOW
Definition TVirtualX.h:38
#define snprintf
Definition civetweb.c:1540
void InitializeGraphics()
Initialize the graphics environment.
static void NeedGraphicsLibs()
Static method.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
virtual Bool_t Notify()
Notify when event occurred on descriptor associated with this handler.
Pixel_t fBackColor
Definition TGClient.h:51
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:223
EGEventType fWaitForEvent
Definition TGClient.h:74
TGGCPool * fGCPool
Definition TGClient.h:63
Bool_t ProcessIdleEvent()
Process one idle event.
Definition TGClient.cxx:679
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:855
void FreeColor(Pixel_t color) const
Free color.
Definition TGClient.cxx:503
Pixel_t fWhite
Definition TGClient.h:57
void CancelRedraw(TGWindow *w)
Definition TGClient.cxx:385
Pixel_t fHilite
Definition TGClient.h:53
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition TGClient.cxx:913
Window_t fWaitForWindow
Definition TGClient.h:75
static TGClient * Instance()
Returns global gClient (initialize graphics first, if not already done)
Definition TGClient.cxx:92
virtual ~TGClient()
Closing down client: cleanup and close X connection.
Definition TGClient.cxx:621
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
Definition TGClient.cxx:532
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition TGClient.cxx:736
TGFontPool * fFontPool
Definition TGClient.h:64
void UnregisterPopup(TGWindow *w)
Remove a popup menu from the list of popups.
Definition TGClient.cxx:543
void ResetWaitFor(TGWindow *w)
reset waiting
Definition TGClient.cxx:762
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition TGClient.cxx:319
Colormap_t fDefaultColormap
Definition TGClient.h:67
TGResourcePool * fResourcePool
Definition TGClient.h:62
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:347
void FreeGC(const TGGC *gc)
Free a graphics context.
Definition TGClient.cxx:327
void AddUnknownWindowHandler(TGUnknownWindowHandler *h)
Add handler for unknown (i.e. unregistered) windows.
Definition TGClient.cxx:551
Pixel_t fForeColor
Definition TGClient.h:52
void SetStyle(UInt_t newstyle)
Definition TGClient.h:151
void RemoveUnknownWindowHandler(TGUnknownWindowHandler *h)
Remove handler for unknown (i.e. unregistered) windows.
Definition TGClient.cxx:564
UInt_t fStyle
Definition TGClient.h:76
void AddIdleHandler(TGIdleHandler *h)
Add handler for idle events.
Definition TGClient.cxx:572
void FreeFont(const TGFont *font)
Free a font.
Definition TGClient.cxx:363
TGWindow * fDefaultRoot
Definition TGClient.h:59
void SetEditDisabled(Bool_t on=kTRUE)
If on is kTRUE editting/guibuilding is forbidden.
Definition TGClient.cxx:942
Bool_t ProcessEventsFor(TGWindow *w)
Like gSystem->ProcessEvents() but then only allow events for w to be processed.
Definition TGClient.cxx:772
Bool_t HandleEvent(Event_t *event)
Handle a GUI event.
Definition TGClient.cxx:818
Bool_t ProcessOneEvent()
Process one event.
Definition TGClient.cxx:645
Bool_t fGlobalNeedRedraw
Definition TGClient.h:68
Pixel_t fSelBackColor
Definition TGClient.h:55
TGClient(const TGClient &)=delete
void ProcessedEvent(Event_t *event, Window_t wid)
Emits a signal when an event has been processed.
Definition TGClient.cxx:951
TGMimeTypes * fMimeTypeList
Definition TGClient.h:66
Bool_t DoRedraw()
Redraw all windows that need redrawing.
Definition TGClient.cxx:794
UInt_t GetDisplayHeight() const
Get display height.
Definition TGClient.cxx:274
Pixel_t fSelForeColor
Definition TGClient.h:56
void WaitFor(TGWindow *w)
Wait for window to be destroyed.
Definition TGClient.cxx:708
void RegisterWindow(TGWindow *w)
Add a TGWindow to the clients list of windows.
Definition TGClient.cxx:511
TList * fIdleHandlers
Definition TGClient.h:73
TGWindow * GetWindowById(Window_t sw) const
Find a TGWindow via its handle. If window is not found return 0.
Definition TGClient.cxx:593
void RegisteredWindow(Window_t w)
Emits a signal when a Window has been registered in TGClient.
Definition TGClient.cxx:964
Pixel_t fBlack
Definition TGClient.h:58
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:288
Pixel_t fShadow
Definition TGClient.h:54
Bool_t GetColorByName(const char *name, Pixel_t &pixel) const
Get a color by name.
Definition TGClient.cxx:394
void SetRoot(TGWindow *root=nullptr)
Sets the current root (i.e.
Definition TGClient.cxx:243
Bool_t fForceRedraw
Definition TGClient.h:69
TGWindow * fRoot
Definition TGClient.h:60
void RemoveIdleHandler(TGIdleHandler *h)
Remove handler for idle events.
Definition TGClient.cxx:585
Bool_t IsEditDisabled() const
Returns kTRUE if edit/guibuilding is forbidden.
Definition TGClient.cxx:934
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:371
TList * fPlist
Definition TGClient.h:71
Pixel_t GetHilite(Pixel_t base_color) const
Return pixel value of hilite color based on base_color.
Definition TGClient.cxx:449
FontStruct_t GetFontByName(const char *name, Bool_t fixedDefault=kTRUE) const
Get a font by name.
Definition TGClient.cxx:424
TList * fUWHandlers
Definition TGClient.h:72
TGPicturePool * fPicturePool
Definition TGClient.h:65
Bool_t HandleInput()
Handles input from the display server.
Definition TGClient.cxx:696
UInt_t GetDisplayWidth() const
Get display width.
Definition TGClient.cxx:261
THashList * fWlist
Definition TGClient.h:70
Pixel_t GetShadow(Pixel_t base_color) const
Return pixel value of shadow color based on base_color.
Definition TGClient.cxx:480
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:307
Int_t fXfd
Definition TGClient.h:61
void UnregisterWindow(TGWindow *w)
Remove a TGWindow from the list of windows.
Definition TGClient.cxx:522
TGWindow * GetWindowByName(const char *name) const
Find a TGWindow via its name (unique name used in TGWindow::SavePrimitive).
Definition TGClient.cxx:604
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get the specified font.
Definition TGFont.cxx:1545
void FreeFont(const TGFont *font)
Free font. If ref count is 0 delete font.
Definition TGFont.cxx:1705
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get the best matching graphics context depending on values.
Definition TGGC.cxx:986
void FreeGC(const TGGC *gc)
Delete graphics context if it is not used anymore.
Definition TGGC.cxx:917
Definition TGGC.h:31
virtual Bool_t HandleEvent()
Handle the idle event.
Handle_t GetId() const
Definition TGObject.h:47
Handle_t fId
Definition TGObject.h:36
void FreePicture(const TGPicture *pic)
Remove picture from cache if nobody is using it anymore.
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition TGPicture.cxx:80
Colormap_t GetDefaultColormap() const
Pixel_t GetSelectedBgndColor() const
Pixel_t GetFrameFgndColor() const
TGPicturePool * GetPicturePool() const
Pixel_t GetBlackColor() const
Pixel_t GetWhiteColor() const
TGFontPool * GetFontPool() const
TGGCPool * GetGCPool() const
TGMimeTypes * GetMimeTypes() const
Pixel_t GetSelectedFgndColor() const
Pixel_t GetFrameBgndColor() const
virtual Bool_t HandleEvent(Event_t *)=0
virtual void DoRedraw()
Definition TGWindow.h:53
virtual Bool_t HandleEvent(Event_t *)
Definition TGWindow.h:104
virtual UInt_t GetEditDisabled() const
Definition TGWindow.h:113
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition TGWindow.h:114
const TGWindow * fParent
Definition TGWindow.h:36
Bool_t fNeedRedraw
Definition TGWindow.h:37
static void MakeFunctor(const char *name, const char *type, GlobFunc &func)
Definition TGlobal.h:73
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
TObject * FindObject(const char *name) const
Find object using its name.
TObject * Remove(TObject *obj)
Remove object from the list.
void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Iterator of linked list.
Definition TList.h:200
TObject * Next()
Return next object in the list. Returns 0 when no more objects in list.
Definition TList.cxx:1113
A doubly linked list.
Definition TList.h:44
virtual void Add(TObject *obj)
Definition TList.h:87
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition TList.cxx:822
virtual TObjLink * FirstLink() const
Definition TList.h:108
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:659
Mother of all ROOT objects.
Definition TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:359
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:879
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:149
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:893
void MakeZombie()
Definition TObject.h:49
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
ROOT top level object description.
Definition TROOT.h:94
Bool_t IsBatch() const
Definition TROOT.h:280
Basic string class.
Definition TString.h:136
const char * Data() const
Definition TString.h:369
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:692
@ kIgnoreCase
Definition TString.h:268
Bool_t IsNull() const
Definition TString.h:407
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
Definition TSystem.cxx:555
virtual void SetDisplay()
Set DISPLAY environment variable based on utmp entry. Only for UNIX.
Definition TSystem.cxx:232
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:438
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:417
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
R__EXTERN TROOT * gROOTLocal
Definition TROOT.h:379
Short_t Max(Short_t a, Short_t b)
Definition TMathBase.h:212
Short_t Min(Short_t a, Short_t b)
Definition TMathBase.h:180
ULong_t fPixel
color pixel value (index in color table)
Definition GuiTypes.h:311
UShort_t fRed
red component (0..65535)
Definition GuiTypes.h:312
UShort_t fGreen
green component (0..65535)
Definition GuiTypes.h:313
UShort_t fBlue
blue component (0..65535)
Definition GuiTypes.h:314
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Window_t fWindow
window reported event is relative to
Definition GuiTypes.h:176
Graphics context structure.
Definition GuiTypes.h:224
Window attributes that can be inquired.
Definition GuiTypes.h:114
Colormap_t fColormap
color map to be associated with window
Definition GuiTypes.h:128
TCanvas * style()
Definition style.C:1