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/** \class TGClient
25 \ingroup guiwidgets
26
27Window client. In client server windowing systems, like X11 this
28class is used to make the initial connection to the window server.
29
30*/
31
32
33#include "RConfigure.h"
34
35#include "TGClient.h"
36#include "TROOT.h"
37#include "TApplication.h"
38#include "TSystem.h"
39#include "TEnv.h"
40#include "THashList.h"
41#include "TSysEvtHandler.h"
42#include "TVirtualX.h"
43#include "TGWindow.h"
44#include "TGResourcePool.h"
45#include "TGGC.h"
46#include "TGFont.h"
47#include "TGMimeTypes.h"
48#include "TGFrame.h"
49#include "TGIdleHandler.h"
50#include "TError.h"
51#include "TGlobal.h"
52#include "snprintf.h"
53
54// Global pointer to the TGClient object
55static TGClient *gClientGlobal = nullptr;
56
57namespace {
58static struct AddPseudoGlobals {
59AddPseudoGlobals() {
60 // User "gCling" as synonym for "libCore static initialization has happened".
61 // This code here must not trigger it
62 TGlobalMappedFunction::MakeFunctor("gClient", "TGClient*", TGClient::Instance, [] {
63 TGClient::Instance(); // first ensure object is created;
64 return (void *) &gClientGlobal;
65 });
66}
68}
69
70// Initialize gClient in case libGui is loaded in batch mode
73public:
76 if (rootlocal && rootlocal->IsBatch()) {
77 // For now check if the header files (or the module containing them)
78 // has been loaded in Cling.
79 // This is required because the dictionaries must be initialized
80 // __before__ the TGClient creation which will induce the creation
81 // of a TClass object which will need the dictionary for TGClient!
83 new TGClient();
84 }
86 }
87};
89
90////////////////////////////////////////////////////////////////////////////////
91/// Returns global gClient (initialize graphics first, if not already done)
92
99
100//----- Graphics Input handler -------------------------------------------------
101////////////////////////////////////////////////////////////////////////////////
102
104private:
105 TGClient *fClient; // connection to display server
106public:
108 Bool_t Notify() override;
109 // Important: don't override ReadNotify()
110};
111
112////////////////////////////////////////////////////////////////////////////////
113/// Notify input from the display server.
114
119
120
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
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/// @copydoc TGPicturePool::GetPictureOrEmpty(const char*)
295
300
301
302////////////////////////////////////////////////////////////////////////////////
303/// Get picture with specified size from pool (picture will be scaled if
304/// necessary). Picture must be freed using TGClient::FreePicture(). If
305/// picture is not found 0 is returned.
306
312
313////////////////////////////////////////////////////////////////////////////////
314/// Free picture resource.
315
320
321////////////////////////////////////////////////////////////////////////////////
322/// Get graphics context from the gc pool. Context must be freed via
323/// TGClient::FreeGC(). If rw is true a new read/write-able GC
324/// is returned, otherwise a shared read-only context is returned.
325/// For historical reasons it is also possible to create directly a
326/// TGGC object, but it is advised to use this new interface only.
327
329{
330 return fGCPool->GetGC(values, rw);
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Free a graphics context.
335
337{
338 fGCPool->FreeGC(gc);
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// Free a graphics context.
343
348
349////////////////////////////////////////////////////////////////////////////////
350/// Get a font from the font pool. Fonts must be freed via
351/// TGClient::FreeFont(). Returns 0 in case of error or if font
352/// does not exist. If fixedDefault is false the "fixed" font
353/// will not be substituted as fallback when the asked for font
354/// does not exist.
355
357{
358 return fFontPool->GetFont(font, fixedDefault);
359}
360
361////////////////////////////////////////////////////////////////////////////////
362/// Get again specified font. Will increase its usage count.
363
365{
366 return fFontPool->GetFont(font);
367}
368
369////////////////////////////////////////////////////////////////////////////////
370/// Free a font.
371
372void TGClient::FreeFont(const TGFont *font)
373{
374 fFontPool->FreeFont(font);
375}
376
377////////////////////////////////////////////////////////////////////////////////
378/// Set redraw flags.
379
381{
382 if (!w) return;
383 if (gVirtualX->NeedRedraw((ULongptr_t)w,force)) return;
384 if (force) {
385 w->DoRedraw();
386 return;
387 }
388 w->fNeedRedraw = kTRUE;
390}
391
392////////////////////////////////////////////////////////////////////////////////
393
395{
396 w->fNeedRedraw = kFALSE;
397}
398
399////////////////////////////////////////////////////////////////////////////////
400/// Get a color by name. If color is found return kTRUE and pixel is
401/// set to the color's pixel value, kFALSE otherwise.
402
404{
405 ColorStruct_t color;
407 Bool_t status = kTRUE;
408
409 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
410 color.fPixel = 0;
411 if (!gVirtualX->ParseColor(attributes.fColormap, name, color)) {
412 Error("GetColorByName", "couldn't parse color %s", name);
413 status = kFALSE;
414 } else if (!gVirtualX->AllocColor(attributes.fColormap, color)) {
415 Warning("GetColorByName", "couldn't retrieve color %s.\n"
416 "Please close any other application, like web browsers, "
417 "that might exhaust\nthe colormap and start ROOT again", name);
418 status = kFALSE;
419 }
420
421 pixel = color.fPixel;
422
423 return status;
424}
425
426////////////////////////////////////////////////////////////////////////////////
427/// Get a font by name. If font is not found, fixed font is returned,
428/// if fixed font also does not exist return 0 and print error.
429/// The loaded font needs to be freed using TVirtualX::DeleteFont().
430/// If fixedDefault is false the "fixed" font will not be substituted
431/// as fallback when the asked for font does not exist.
432
434{
435 if (gROOT->IsBatch())
436 return (FontStruct_t) -1;
437
438 FontStruct_t font = gVirtualX->LoadQueryFont(name);
439
440 if (!font && fixedDefault) {
441 font = gVirtualX->LoadQueryFont("fixed");
442 if (font)
443 Warning("GetFontByName", "couldn't retrieve font %s, using \"fixed\"", name);
444 }
445 if (!font) {
446 if (fixedDefault)
447 Error("GetFontByName", "couldn't retrieve font %s nor backup font \"fixed\"", name);
448 else
449 Warning("GetFontByName", "couldn't retrieve font %s", name);
450 }
451
452 return font;
453}
454
455////////////////////////////////////////////////////////////////////////////////
456/// Return pixel value of hilite color based on base_color.
457
459{
460 ColorStruct_t color, white_p;
462
463 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
464
465 color.fPixel = base_color;
466 gVirtualX->QueryColor(attributes.fColormap, color);
467
468 GetColorByName("white", white_p.fPixel);
469 gVirtualX->QueryColor(attributes.fColormap, white_p);
470
471 color.fRed = std::max((UShort_t)(white_p.fRed/5), color.fRed);
472 color.fGreen = std::max((UShort_t)(white_p.fGreen/5), color.fGreen);
473 color.fBlue = std::max((UShort_t)(white_p.fBlue/5), color.fBlue);
474
475 color.fRed = (UShort_t)std::min((Int_t)white_p.fRed, (Int_t)(color.fRed*140)/100);
476 color.fGreen = (UShort_t)std::min((Int_t)white_p.fGreen, (Int_t)(color.fGreen*140)/100);
477 color.fBlue = (UShort_t)std::min((Int_t)white_p.fBlue, (Int_t)(color.fBlue*140)/100);
478
479 if (!gVirtualX->AllocColor(attributes.fColormap, color))
480 Error("GetHilite", "couldn't allocate hilight color");
481
482 return color.fPixel;
483}
484
485////////////////////////////////////////////////////////////////////////////////
486/// Return pixel value of shadow color based on base_color.
487/// Shadow is 60% of base_color intensity.
488
490{
491 ColorStruct_t color;
493
494 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
495
496 color.fPixel = base_color;
497 gVirtualX->QueryColor(attributes.fColormap, color);
498
499 color.fRed = (UShort_t)((color.fRed*60)/100);
500 color.fGreen = (UShort_t)((color.fGreen*60)/100);
501 color.fBlue = (UShort_t)((color.fBlue*60)/100);
502
503 if (!gVirtualX->AllocColor(attributes.fColormap, color))
504 Error("GetShadow", "couldn't allocate shadow color");
505
506 return color.fPixel;
507}
508
509////////////////////////////////////////////////////////////////////////////////
510/// Free color.
511
513{
514 gVirtualX->FreeColor(fDefaultColormap, color);
515}
516
517////////////////////////////////////////////////////////////////////////////////
518/// Add a TGWindow to the clients list of windows.
519
521{
522 fWlist->Add(w);
523
524 // Emits signal
525 RegisteredWindow(w->GetId());
526}
527
528////////////////////////////////////////////////////////////////////////////////
529/// Remove a TGWindow from the list of windows.
530
535
536////////////////////////////////////////////////////////////////////////////////
537/// Add a popup menu to the list of popups. This list is used to pass
538/// events to popup menus that are popped up over a transient window which
539/// is waited for (see WaitFor()).
540
542{
543 fPlist->Add(w);
544
545 // Emits signal
546 RegisteredWindow(w->GetId());
547}
548
549////////////////////////////////////////////////////////////////////////////////
550/// Remove a popup menu from the list of popups.
551
556
557////////////////////////////////////////////////////////////////////////////////
558/// Add handler for unknown (i.e. unregistered) windows.
559
569
570////////////////////////////////////////////////////////////////////////////////
571/// Remove handler for unknown (i.e. unregistered) windows.
572
577
578////////////////////////////////////////////////////////////////////////////////
579/// Add handler for idle events.
580
582{
583 if (!fIdleHandlers) {
584 fIdleHandlers = new TList;
586 }
587
589}
590
591////////////////////////////////////////////////////////////////////////////////
592/// Remove handler for idle events.
593
598
599////////////////////////////////////////////////////////////////////////////////
600/// Find a TGWindow via its handle. If window is not found return 0.
601
603{
604 TGWindow wt(wid);
605
606 return (TGWindow *) fWlist->FindObject(&wt);
607}
608
609////////////////////////////////////////////////////////////////////////////////
610/// Find a TGWindow via its name (unique name used in TGWindow::SavePrimitive).
611/// If window is not found return 0.
612
614{
615 TIter next(fWlist);
616
617 TObject *obj;
618 while ((obj = next())) {
619 TString n = obj->GetName();
620 if (n == name) {
621 return (TGWindow*)obj;
622 }
623 }
624 return 0;
625}
626
627////////////////////////////////////////////////////////////////////////////////
628/// Closing down client: cleanup and close X connection.
629
631{
632 if (IsZombie())
633 return;
634
635 if (fWlist)
636 fWlist->Delete("slow");
637 delete fWlist;
638 delete fPlist;
639 delete fUWHandlers;
640 delete fIdleHandlers;
641 delete fResourcePool;
642
643 gVirtualX->CloseDisplay(); // this should do a cleanup of the remaining
644 // X allocated objects...
645}
646
647////////////////////////////////////////////////////////////////////////////////
648/// Process one event. This method should only be called when there is
649/// a GUI event ready to be processed. If event has been processed
650/// kTRUE is returned. If processing of a specific event type for a specific
651/// window was requested kFALSE is returned when specific event has been
652/// processed, kTRUE otherwise. If no more pending events return kFALSE.
653
655{
656 Event_t event;
657
658 if (!fRoot) return kFALSE;
659 if (gVirtualX->EventsPending()) {
660 gVirtualX->NextEvent(event);
661 if (fWaitForWindow == kNone) {
662 HandleEvent(&event);
663 if (fForceRedraw)
664 DoRedraw();
665 return kTRUE;
666 } else {
668 if ((event.fType == fWaitForEvent) && (event.fWindow == fWaitForWindow))
670 if (fForceRedraw)
671 DoRedraw();
672 return kTRUE;
673 }
674 }
675
676 // if nothing else to do redraw windows that need redrawing
677 if (DoRedraw()) return kTRUE;
678
679 // process one idle event if there is nothing else to do
680 if (ProcessIdleEvent()) return kTRUE;
681
682 return kFALSE;
683}
684
685////////////////////////////////////////////////////////////////////////////////
686/// Process one idle event.
687
689{
690 if (fIdleHandlers) {
692 if (ih) {
694 ih->HandleEvent();
695 return kTRUE;
696 }
697 }
698 return kFALSE;
699}
700
701////////////////////////////////////////////////////////////////////////////////
702/// Handles input from the display server. Returns kTRUE if one or more
703/// events have been processed, kFALSE otherwise.
704
713
714////////////////////////////////////////////////////////////////////////////////
715/// Wait for window to be destroyed.
716
718{
721
722 fWaitForWindow = w->GetId();
724
725 //Let VirtualX know, that we are
726 //in a nested loop for a window w.
727 //Noop on X11/win32gdk.
728 if (gVirtualX)
729 gVirtualX->BeginModalSessionFor(w->GetId());
730
731 while (fWaitForWindow != kNone) {
732 if (esave == kUnmapNotify)
733 wsave = kNone;
734 gSystem->ProcessEvents();//gSystem->InnerLoop();
735 gSystem->Sleep(5);
736 }
737
740}
741
742////////////////////////////////////////////////////////////////////////////////
743/// Wait for window to be unmapped.
744
746{
749
750 fWaitForWindow = w->GetId();
752
753 //Let VirtualX know, that we are
754 //in a nested loop for a window w.
755 //Noop on X11/win32gdk.
756 if (gVirtualX)
757 gVirtualX->BeginModalSessionFor(w->GetId());
758
759 while (fWaitForWindow != kNone) {
760 gSystem->ProcessEvents();//gSystem->InnerLoop();
761 gSystem->Sleep(5);
762 }
763
766}
767
768////////////////////////////////////////////////////////////////////////////////
769/// reset waiting
770
772{
773 if (fWaitForWindow == w->GetId()) fWaitForWindow = kNone;
774}
775
776////////////////////////////////////////////////////////////////////////////////
777/// Like gSystem->ProcessEvents() but then only allow events for w to
778/// be processed. For example to interrupt the processing and destroy
779/// the window, call gROOT->SetInterrupt() before destroying the window.
780
796
797////////////////////////////////////////////////////////////////////////////////
798/// Redraw all windows that need redrawing. Returns kFALSE if no redraw
799/// was needed, kTRUE otherwise.
800/// Only redraw the application's windows when the event queue
801/// does not contain expose event anymore.
802
804{
805 if (!fGlobalNeedRedraw) return kFALSE;
806
807 TGWindow *w;
809 while (lnk) {
810 w = (TGWindow *) lnk->GetObject();
811 if (w->fNeedRedraw) {
812 w->DoRedraw();
813 w->fNeedRedraw = kFALSE;
814 }
815 lnk = lnk->Next();
816 }
817
820
821 return kTRUE;
822}
823
824////////////////////////////////////////////////////////////////////////////////
825/// Handle a GUI event.
826
828{
829 TGWindow *w;
830
831 // Emit signal for event recorder(s)
832 if (event->fType != kConfigureNotify) {
833 ProcessedEvent(event, 0);
834 }
835
836 // Find window where event happened
837 if ((w = GetWindowById(event->fWindow)) == 0) {
838 if (fUWHandlers && fUWHandlers->GetSize() > 0) {
841 while ((unkwh = (TGUnknownWindowHandler*)it.Next())) {
842 if (unkwh->HandleEvent(event))
843 return kTRUE;
844 }
845 }
846 //Warning("HandleEvent", "unknown window %ld not handled\n",
847 // event->fWindow);
848 return kFALSE;
849 }
850
851 // and let it handle the event
852 w->HandleEvent(event);
853
854 return kTRUE;
855}
856
857////////////////////////////////////////////////////////////////////////////////
858/// Handle masked events only if window wid is the window for which the
859/// event was reported or if wid is a parent of the event window. The not
860/// masked event are handled directly. The masked events are:
861/// kButtonPress, kButtonRelease, kKeyPress, kKeyRelease, kEnterNotify,
862/// kLeaveNotify, kMotionNotify.
863
865{
866 TGWindow *w, *ptr, *pop;
867
868 if ((w = GetWindowById(event->fWindow)) == 0) return kFALSE;
869
870 // Emit signal for event recorder(s)
871 if (event->fType != kConfigureNotify) {
872 ProcessedEvent(event, wid);
873 }
874
875 // This breaks class member protection, but TGClient is a friend of
876 // TGWindow and _should_ know what to do and what *not* to do...
877
878 for (ptr = w; ptr->fParent != 0; ptr = (TGWindow *) ptr->fParent) {
879 if ((ptr->fId == wid) ||
880 ((event->fType != kButtonPress) &&
881 (event->fType != kButtonRelease) &&
882 (event->fType != kGKeyPress) &&
883 (event->fType != kKeyRelease) &&
884 (event->fType != kEnterNotify) &&
885 (event->fType != kLeaveNotify) &&
886 (event->fType != kMotionNotify))) {
887 w->HandleEvent(event);
888 return kTRUE;
889 }
890 }
891
892 // check if this is a popup menu
893 TIter next(fPlist);
894 while ((pop = (TGWindow *) next())) {
895 for (ptr = w; ptr->fParent != 0; ptr = (TGWindow *) ptr->fParent) {
896 if ((ptr->fId == pop->fId) &&
897 ((event->fType == kButtonPress) ||
898 (event->fType == kButtonRelease) ||
899 (event->fType == kGKeyPress) ||
900 (event->fType == kKeyRelease) ||
901 (event->fType == kEnterNotify) ||
902 (event->fType == kLeaveNotify) ||
903 (event->fType == kMotionNotify))) {
904 w->HandleEvent(event);
905 return kTRUE;
906 }
907 }
908 }
909
910 if (event->fType == kButtonPress || event->fType == kGKeyPress)
911 gVirtualX->Bell(0);
912
913 return kFALSE;
914}
915
916////////////////////////////////////////////////////////////////////////////////
917/// Execute string "cmd" via the interpreter. Before executing replace
918/// in the command string the token $MSG, $PARM1 and $PARM2 by msg,
919/// parm1 and parm2, respectively. The function in cmd string must accept
920/// these as longs.
921
923{
924 if (cmd.IsNull()) return;
925
926 char s[32];
927
928 snprintf(s, sizeof(s), "%ld", msg);
929 cmd.ReplaceAll("$MSG", s);
930
931 snprintf(s, sizeof(s), "%ld", parm1);
932 cmd.ReplaceAll("$PARM1", s);
933
934 snprintf(s, sizeof(s), "%ld", parm2);
935 cmd.ReplaceAll("$PARM2", s);
936
937 gROOT->ProcessLine(cmd.Data());
938}
939
940////////////////////////////////////////////////////////////////////////////////
941/// Returns kTRUE if edit/guibuilding is forbidden.
942
944{
945 return (fDefaultRoot->GetEditDisabled() == 1);
946}
947
948////////////////////////////////////////////////////////////////////////////////
949/// If on is kTRUE editting/guibuilding is forbidden.
950
955
956////////////////////////////////////////////////////////////////////////////////
957/// Emits a signal when an event has been processed.
958/// Used in TRecorder.
959
961{
962 Longptr_t args[2];
963 args[0] = (Longptr_t) event;
964 args[1] = (Longptr_t) wid;
965
966 Emit("ProcessedEvent(Event_t*, Window_t)", args);
967}
968
969////////////////////////////////////////////////////////////////////////////////
970/// Emits a signal when a Window has been registered in TGClient.
971/// Used in TRecorder.
972
974{
975 Emit("RegisteredWindow(Window_t)", w);
976}
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
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Handle_t kNone
Definition GuiTypes.h:88
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:54
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
static TGClient * gClientGlobal
Definition TGClient.cxx:55
static TGClientInit gClientInit
Definition TGClient.cxx:88
void TriggerDictionaryInitialization_libGui()
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t style
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
char name[80]
Definition TGX11.cxx:110
#define gROOT
Definition TROOT.h:411
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
R__EXTERN TFileHandler * gXDisplay
Definition TSystem.h:573
#define gVirtualX
Definition TVirtualX.h:337
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:1579
void InitializeGraphics(Bool_t only_web=kFALSE)
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:490
Window client.
Definition TGClient.h:37
Pixel_t fBackColor
default background color
Definition TGClient.h:42
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
event to wait for
Definition TGClient.h:65
TGGCPool * fGCPool
graphics context pool
Definition TGClient.h:54
Bool_t ProcessIdleEvent()
Process one idle event.
Definition TGClient.cxx:688
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:864
void FreeColor(Pixel_t color) const
Free color.
Definition TGClient.cxx:512
Pixel_t fWhite
white color index
Definition TGClient.h:48
void CancelRedraw(TGWindow *w)
Definition TGClient.cxx:394
Pixel_t fHilite
default highlight color
Definition TGClient.h:44
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition TGClient.cxx:922
Window_t fWaitForWindow
window in which to wait for event
Definition TGClient.h:66
static TGClient * Instance()
Returns global gClient (initialize graphics first, if not already done)
Definition TGClient.cxx:93
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
Definition TGClient.cxx:541
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition TGClient.cxx:745
TGFontPool * fFontPool
font pool
Definition TGClient.h:55
void UnregisterPopup(TGWindow *w)
Remove a popup menu from the list of popups.
Definition TGClient.cxx:552
void ResetWaitFor(TGWindow *w)
reset waiting
Definition TGClient.cxx:771
~TGClient() override
Closing down client: cleanup and close X connection.
Definition TGClient.cxx:630
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition TGClient.cxx:328
Colormap_t fDefaultColormap
default colormap
Definition TGClient.h:58
TGResourcePool * fResourcePool
global GUI resource pool
Definition TGClient.h:53
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:356
void FreeGC(const TGGC *gc)
Free a graphics context.
Definition TGClient.cxx:336
void AddUnknownWindowHandler(TGUnknownWindowHandler *h)
Add handler for unknown (i.e. unregistered) windows.
Definition TGClient.cxx:560
Pixel_t fForeColor
default foreground color
Definition TGClient.h:43
void SetStyle(UInt_t newstyle)
Definition TGClient.h:143
void RemoveUnknownWindowHandler(TGUnknownWindowHandler *h)
Remove handler for unknown (i.e. unregistered) windows.
Definition TGClient.cxx:573
UInt_t fStyle
GUI style (modern or classic)
Definition TGClient.h:67
void AddIdleHandler(TGIdleHandler *h)
Add handler for idle events.
Definition TGClient.cxx:581
void FreeFont(const TGFont *font)
Free a font.
Definition TGClient.cxx:372
TGWindow * fDefaultRoot
default root window (base window of display)
Definition TGClient.h:50
void SetEditDisabled(Bool_t on=kTRUE)
If on is kTRUE editting/guibuilding is forbidden.
Definition TGClient.cxx:951
Bool_t ProcessEventsFor(TGWindow *w)
Like gSystem->ProcessEvents() but then only allow events for w to be processed.
Definition TGClient.cxx:781
Bool_t HandleEvent(Event_t *event)
Handle a GUI event.
Definition TGClient.cxx:827
Bool_t ProcessOneEvent()
Process one event.
Definition TGClient.cxx:654
Pixel_t fSelBackColor
default selection background color
Definition TGClient.h:46
TGClient(const TGClient &)=delete
void ProcessedEvent(Event_t *event, Window_t wid)
Emits a signal when an event has been processed.
Definition TGClient.cxx:960
TGMimeTypes * fMimeTypeList
mimetype list
Definition TGClient.h:57
Bool_t DoRedraw()
Redraw all windows that need redrawing.
Definition TGClient.cxx:803
UInt_t GetDisplayHeight() const
Get display height.
Definition TGClient.cxx:274
Pixel_t fSelForeColor
default selection foreground color
Definition TGClient.h:47
std::atomic< Bool_t > fGlobalNeedRedraw
true if at least one window needs to be redrawn
Definition TGClient.h:59
void WaitFor(TGWindow *w)
Wait for window to be destroyed.
Definition TGClient.cxx:717
void RegisterWindow(TGWindow *w)
Add a TGWindow to the clients list of windows.
Definition TGClient.cxx:520
TList * fIdleHandlers
list of idle handlers
Definition TGClient.h:64
const TGPicture * GetPictureOrEmpty(const char *name)
Like TGPicturePool::GetPicture() but, instead of returning null when the picture is not found,...
Definition TGClient.cxx:296
TGWindow * GetWindowById(Window_t sw) const
Find a TGWindow via its handle. If window is not found return 0.
Definition TGClient.cxx:602
void RegisteredWindow(Window_t w)
Emits a signal when a Window has been registered in TGClient.
Definition TGClient.cxx:973
Pixel_t fBlack
black color index
Definition TGClient.h:49
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:288
Pixel_t fShadow
default shadow color
Definition TGClient.h:45
Bool_t GetColorByName(const char *name, Pixel_t &pixel) const
Get a color by name.
Definition TGClient.cxx:403
void SetRoot(TGWindow *root=nullptr)
Sets the current root (i.e.
Definition TGClient.cxx:243
Bool_t fForceRedraw
redraw widgets as soon as possible
Definition TGClient.h:60
TGWindow * fRoot
current root window (changing root window allows embedding)
Definition TGClient.h:51
void RemoveIdleHandler(TGIdleHandler *h)
Remove handler for idle events.
Definition TGClient.cxx:594
Bool_t IsEditDisabled() const
Returns kTRUE if edit/guibuilding is forbidden.
Definition TGClient.cxx:943
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:380
TList * fPlist
list of popup windows used in HandleMaskEvent()
Definition TGClient.h:62
Pixel_t GetHilite(Pixel_t base_color) const
Return pixel value of hilite color based on base_color.
Definition TGClient.cxx:458
FontStruct_t GetFontByName(const char *name, Bool_t fixedDefault=kTRUE) const
Get a font by name.
Definition TGClient.cxx:433
TList * fUWHandlers
list of event handlers for unknown windows
Definition TGClient.h:63
TGPicturePool * fPicturePool
pixmap pool
Definition TGClient.h:56
Bool_t HandleInput()
Handles input from the display server.
Definition TGClient.cxx:705
UInt_t GetDisplayWidth() const
Get display width.
Definition TGClient.cxx:261
THashList * fWlist
list of frames
Definition TGClient.h:61
Pixel_t GetShadow(Pixel_t base_color) const
Return pixel value of shadow color based on base_color.
Definition TGClient.cxx:489
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:316
Int_t fXfd
file descriptor of connection to server
Definition TGClient.h:52
void UnregisterWindow(TGWindow *w)
Remove a TGWindow from the list of windows.
Definition TGClient.cxx:531
TGWindow * GetWindowByName(const char *name) const
Find a TGWindow via its name (unique name used in TGWindow::SavePrimitive).
Definition TGClient.cxx:613
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get the specified font.
Definition TGFont.cxx:1555
void FreeFont(const TGFont *font)
Free font. If ref count is 0 delete font.
Definition TGFont.cxx:1715
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get the best matching graphics context depending on values.
Definition TGGC.cxx:976
void FreeGC(const TGGC *gc)
Delete graphics context if it is not used anymore.
Definition TGGC.cxx:907
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
Handle idle events, i.e.
TGClient * fClient
Definition TGClient.cxx:105
Bool_t Notify() override
Notify input from the display server.
Definition TGClient.cxx:115
TGInputHandler(TGClient *c, Int_t fd)
Definition TGClient.cxx:107
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
void FreePicture(const TGPicture *pic)
Remove picture from cache if nobody is using it anymore.
const TGPicture * GetPictureOrEmpty(const char *name)
Like TGPicturePool::GetPicture() but, instead of returning null when the picture is not found,...
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition TGPicture.cxx:80
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
This class implements a pool for the default GUI resource set, like GC's, colors, fonts,...
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
Handle events for windows that are not part of the native ROOT GUI.
Definition TGWindow.h:141
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual UInt_t GetEditDisabled() const
Definition TGWindow.h:112
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition TGWindow.h:113
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
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
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
TObject * Remove(TObject *obj) override
Remove object from the list.
TObject * FindObject(const char *name) const override
Find object using its name.
Iterator of linked list.
Definition TList.h:191
TObject * Next() override
Return next object in the list. Returns 0 when no more objects in list.
Definition TList.cxx:1110
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:819
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:656
virtual TObjLink * FirstLink() const
Definition TList.h:102
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:457
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:159
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
void MakeZombie()
Definition TObject.h:53
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:102
Basic string class.
Definition TString.h:138
@ kIgnoreCase
Definition TString.h:285
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
Definition TSystem.cxx:552
virtual void SetDisplay()
Set DISPLAY environment variable based on utmp entry. Only for UNIX.
Definition TSystem.cxx:233
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:435
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:414
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:384
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