Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGFrame.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 03/01/98
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 TGFrame
25 \ingroup guiwidgets
26
27A subclasses of TGWindow, and is used as base
28class for some simple widgets (buttons, labels, etc.).
29It provides:
30 - position & dimension fields
31 - an 'options' attribute (see constant above)
32 - a generic event handler
33 - a generic layout mechanism
34 - a generic border
35
36
37\class TGCompositeFrame
38\ingroup guiwidgets
39
40The base class for composite widgets
41(menu bars, list boxes, etc.).
42It provides:
43 - a layout manager
44 - a frame container (TList *)
45
46
47\class TGVerticalFrame
48\ingroup guiwidgets
49A composite frame that layout their children in vertical way.
50
51
52\class TGHorizontalFrame
53\ingroup guiwidgets
54A composite frame that layout their children in horizontal way.
55
56
57\class TGMainFrame
58\ingroup guiwidgets
59Defines top level windows that interact with the system Window Manager.
60
61
62\class TGTransientFrame
63\ingroup guiwidgets
64Defines transient windows that typically are used for dialogs windows.
65
66
67\class TGGroupFrame
68\ingroup guiwidgets
69A composite frame with a border and a title.
70It is typically used to group a number of logically related widgets visually together.
71
72\class TGHeaderFrame
73\ingroup guiwidgets
74Horizontal Frame used to contain header buttons and splitters
75in a list view. Used to have resizable column headers.
76
77*/
78
79
80#include "TError.h"
81#include "TGFrame.h"
82#include "TGResourcePool.h"
83#include "TGPicture.h"
84#include "TList.h"
85#include "TApplication.h"
86#include "TTimer.h"
87#include "TClass.h"
88
89#include "TObjString.h"
90#include "TBits.h"
91#include "TColor.h"
92#include "TROOT.h"
93#include "TDatime.h"
94#include "KeySymbols.h"
95#include "TGFileDialog.h"
96#include "TGMsgBox.h"
97#include "TSystem.h"
98#include "TVirtualDragManager.h"
99#include "TGuiBuilder.h"
100#include "TQConnection.h"
101#include "TGButton.h"
102#include "TGSplitter.h"
103#include "TGDNDManager.h"
104#include "TImage.h"
105#include "TObjectSpy.h"
106#include "TVirtualX.h"
107
108#include <iostream>
109#include <fstream>
110
111
117const TGGC *TGFrame::fgBlackGC = nullptr;
118const TGGC *TGFrame::fgWhiteGC = nullptr;
119const TGGC *TGFrame::fgHilightGC = nullptr;
120const TGGC *TGFrame::fgShadowGC = nullptr;
121const TGGC *TGFrame::fgBckgndGC = nullptr;
128
129const TGFont *TGGroupFrame::fgDefaultFont = nullptr;
130const TGGC *TGGroupFrame::fgDefaultGC = nullptr;
131
133
134static const char *gSaveMacroTypes[] = {
135 "ROOT macros", "*.C",
136 "GIF", "*.gif",
137 "PNG", "*.png",
138 "JPEG", "*.jpg",
139 "TIFF", "*.tiff",
140 "XPM", "*.xpm",
141 "All files", "*",
142 0, 0
143};
144
146
155
156
157////////////////////////////////////////////////////////////////////////////////
158/// Create a TGFrame object. Options is an OR of the EFrameTypes.
159
161 UInt_t options, Pixel_t back)
162 : TGWindow(p, 0, 0, w, h, 0, 0, 0, 0, 0, options)
163{
164 if (!fgInit && gClient) {
174 fgInit = kTRUE;
175 }
176
178
179 fDNDState = 0;
180 fBackground = back;
181 fOptions = options;
182 fWidth = w; fHeight = h; fX = fY = fBorderWidth = 0;
183 fMinWidth = 0;
184 fMinHeight = 0;
187 fFE = 0;
188
190 fBorderWidth = (gClient->GetStyle() > 1) ? 1 : (fOptions & kDoubleBorder) ? 2 : 1;
191
193 wattr.fBackgroundPixel = back;
194 wattr.fEventMask = kExposureMask;
195 if (fOptions & kMainFrame) {
196 wattr.fEventMask |= kStructureNotifyMask;
197 gVirtualX->ChangeWindowAttributes(fId, &wattr);
198 //if (fgDefaultBackgroundPicture)
199 // SetBackgroundPixmap(fgDefaultBackgroundPicture->GetPicture());
200 } else {
201 gVirtualX->ChangeWindowAttributes(fId, &wattr);
202 //if (!(fOptions & kOwnBackground))
203 // SetBackgroundPixmap(kParentRelative);
204 }
205 fEventMask = (UInt_t) wattr.fEventMask;
206
207 if ((fOptions & kDoubleBorder) && (gClient->GetStyle() > 1))
209
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Create a frame using an externally created window. For example
215/// to register the root window (called by TGClient), or a window
216/// created via TVirtualX::InitWindow() (id is obtained with
217/// TVirtualX::GetWindowID()).
218
220 : TGWindow(c, id, parent)
221{
222 if (!fgInit && gClient) {
232 fgInit = kTRUE;
233 }
234
235 WindowAttributes_t attributes;
236 // Initialize some values - needed for batch mode!
237 attributes.fX = 0;
238 attributes.fY = 0;
239 attributes.fWidth = 100;
240 attributes.fHeight = 100;
241 attributes.fBorderWidth = 4;
242 attributes.fYourEventMask = 0;
243 gVirtualX->GetWindowAttributes(id, attributes);
244
245 fDNDState = 0;
246 fX = attributes.fX;
247 fY = attributes.fY;
248 fWidth = attributes.fWidth;
249 fHeight = attributes.fHeight;
250 fBorderWidth = attributes.fBorderWidth;
251 fEventMask = (UInt_t) attributes.fYourEventMask;
252 fBackground = 0;
253 fOptions = 0;
254 fMinWidth = 0;
255 fMinHeight = 0;
258 fFE = 0;
259
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Destructor.
265
269
270////////////////////////////////////////////////////////////////////////////////
271/// Delete window. Use single shot timer to call final delete method.
272/// We use this indirect way since deleting the window in its own
273/// execution "thread" can cause side effects because frame methods
274/// can still be called while the window object has already been deleted.
275
277{
278 if (gDNDManager) {
279 if (gDNDManager->GetMainFrame() == this)
281 }
283 // coverity[returned_null]
284 // coverity[dereference]
285 TTimer::SingleShot(150, IsA()->GetName(), this, "ReallyDelete()");
286 }
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Change frame background color.
292
294{
295 fBackground = back;
296 gVirtualX->SetWindowBackground(fId, back);
297 fClient->NeedRedraw(this);
298}
299
300////////////////////////////////////////////////////////////////////////////////
301/// Return frame foreground color.
302
304{
305 return fgBlackPixel;
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Set background color (override from TGWindow base class).
310/// Same effect as ChangeBackground().
311
317
318////////////////////////////////////////////////////////////////////////////////
319/// Change frame options. Options is an OR of the EFrameTypes.
320
322{
323 if ((options & (kDoubleBorder | kSunkenFrame | kRaisedFrame)) !=
326 if (options & (kSunkenFrame | kRaisedFrame))
327 fBorderWidth = (gClient->GetStyle() > 1) ? 1 : (fOptions & kDoubleBorder) ? 2 : 1;
328 else
329 fBorderWidth = 0;
330 }
331 }
332
333 fOptions = options;
334}
335
336////////////////////////////////////////////////////////////////////////////////
337/// Add events specified in the emask to the events the frame should handle.
338
340{
341 fEventMask |= emask;
342 gVirtualX->SelectInput(fId, fEventMask);
343}
344
345////////////////////////////////////////////////////////////////////////////////
346/// Remove events specified in emask from the events the frame should handle.
347
349{
351 gVirtualX->SelectInput(fId, fEventMask);
352}
353
354////////////////////////////////////////////////////////////////////////////////
355/// Draw 3D rectangle on the frame border.
356
358 UInt_t w, UInt_t h)
359{
360 switch (type) {
361 case kSunkenFrame:
362 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x+w-2, y);
363 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x, y+h-2);
364 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y+h-1, x+w-1, y+h-1);
365 gVirtualX->DrawLine(fId, GetHilightGC()(), x+w-1, y+h-1, x+w-1, y);
366 break;
367
369 if (gClient->GetStyle() < 2) {
370 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x+w-2, y);
371 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x, y+h-2);
372 gVirtualX->DrawLine(fId, GetBlackGC()(), x+1, y+1, x+w-3, y+1);
373 gVirtualX->DrawLine(fId, GetBlackGC()(), x+1, y+1, x+1, y+h-3);
374 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y+h-1, x+w-1, y+h-1);
375 gVirtualX->DrawLine(fId, GetHilightGC()(), x+w-1, y+h-1, x+w-1, y);
376 gVirtualX->DrawLine(fId, GetBckgndGC()(), x+1, y+h-2, x+w-2, y+h-2);
377 gVirtualX->DrawLine(fId, GetBckgndGC()(), x+w-2, y+1, x+w-2, y+h-2);
378 }
379 else {
380 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x+w-2, y);
381 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x, y+h-2);
382 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y+h-1, x+w-1, y+h-1);
383 gVirtualX->DrawLine(fId, GetHilightGC()(), x+w-1, y+h-1, x+w-1, y);
384 }
385 break;
386
387 case kRaisedFrame:
388 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x+w-2, y);
389 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x, y+h-2);
390 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y+h-1, x+w-1, y+h-1);
391 gVirtualX->DrawLine(fId, GetShadowGC()(), x+w-1, y+h-1, x+w-1, y);
392 break;
393
395 if (gClient->GetStyle() < 2) {
396 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x+w-2, y);
397 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x, y+h-2);
398 gVirtualX->DrawLine(fId, GetBckgndGC()(), x+1, y+1, x+w-3, y+1);
399 gVirtualX->DrawLine(fId, GetBckgndGC()(), x+1, y+1, x+1, y+h-3);
400 gVirtualX->DrawLine(fId, GetShadowGC()(), x+1, y+h-2, x+w-2, y+h-2);
401 gVirtualX->DrawLine(fId, GetShadowGC()(), x+w-2, y+h-2, x+w-2, y+1);
402 gVirtualX->DrawLine(fId, GetBlackGC()(), x, y+h-1, x+w-1, y+h-1);
403 gVirtualX->DrawLine(fId, GetBlackGC()(), x+w-1, y+h-1, x+w-1, y);
404 }
405 else {
406 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x+w-2, y);
407 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x, y+h-2);
408 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y+h-1, x+w-1, y+h-1);
409 gVirtualX->DrawLine(fId, GetShadowGC()(), x+w-1, y+h-1, x+w-1, y);
410 }
411 break;
412
413 default:
414 break;
415 }
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Draw frame border.
420
426
427////////////////////////////////////////////////////////////////////////////////
428/// Redraw the frame.
429
431{
433 fWidth - (fBorderWidth << 1), fHeight - (fBorderWidth << 1));
434
435 // border will only be drawn if we have a 3D option hint
436 // (kRaisedFrame or kSunkenFrame)
437 DrawBorder();
438}
439
440////////////////////////////////////////////////////////////////////////////////
441/// This event is generated when the frame is resized.
442
444{
445 if ((event->fWidth != fWidth) || (event->fHeight != fHeight)) {
446 fWidth = event->fWidth;
447 fHeight = event->fHeight;
448 Layout();
449 }
450 return kTRUE;
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Handle all frame events. Events are dispatched to the specific
455/// event handlers.
456
458{
460 gDragManager->HandleEvent(event)) return kTRUE;
461
463
464 switch (event->fType) {
465
466 case kExpose:
467 HandleExpose(event);
468 break;
469
470 case kConfigureNotify:
471 while (gVirtualX->CheckEvent(fId, kConfigureNotify, *event))
472 ;
473 // protection
474 if ((event->fWidth < 32768) && (event->fHeight < 32768)){
475 ProcessedConfigure(event); // emit signal
477 }
478 break;
479
480 case kGKeyPress:
481 case kKeyRelease:
482 HandleKey(event);
483 break;
484
485 case kFocusIn:
486 case kFocusOut:
487 HandleFocusChange(event);
488 break;
489
490 case kButtonPress:
491 {
493
494 if ((event->fTime - fgLastClick < 350) &&
495 (event->fCode == fgLastButton) &&
496 (TMath::Abs(event->fXRoot - fgDbx) < 6) &&
497 (TMath::Abs(event->fYRoot - fgDby) < 6) &&
498 (event->fWindow == fgDbw))
499 dbl_clk = kTRUE;
500
501 fgLastClick = event->fTime;
502 fgLastButton = event->fCode;
503 fgDbx = event->fXRoot;
504 fgDby = event->fYRoot;
505 fgDbw = event->fWindow;
506
507 if (dbl_clk) {
508 if ((event->fState & kKeyControlMask) &&
511 return kTRUE;
512 }
513
514 if (!HandleDoubleClick(event)) {
515 HandleButton(event);
516 }
517 } else {
518 HandleButton(event);
519 }
520 }
521 break;
522
524 {
525 fgLastClick = event->fTime;
526 fgLastButton = event->fCode;
527 fgDbx = event->fXRoot;
528 fgDby = event->fYRoot;
529 fgDbw = event->fWindow;
530
531 HandleDoubleClick(event);
532 }
533 break;
534
535 case kButtonRelease:
536 HandleButton(event);
537 break;
538
539 case kEnterNotify:
540 case kLeaveNotify:
541 HandleCrossing(event);
542 break;
543
544 case kMotionNotify:
545 while (gVirtualX->CheckEvent(fId, kMotionNotify, *event))
546 ;
547 HandleMotion(event);
548 break;
549
550 case kClientMessage:
551 HandleClientMessage(event);
552 break;
553
554 case kSelectionNotify:
555 HandleSelection(event);
556 break;
557
560 break;
561
562 case kSelectionClear:
564 break;
565
566 case kColormapNotify:
568 break;
569
570 default:
571 //Warning("HandleEvent", "unknown event (%#x) for (%#x)", event->fType, fId);
572 break;
573 }
574
575 if (deleteCheck.GetObject())
576 ProcessedEvent(event); // emit signal
577
578 return kTRUE;
579}
580
581////////////////////////////////////////////////////////////////////////////////
582/// std::cout << fWidth << "x" << fHeight << std::endl;
583
588
589
590////////////////////////////////////////////////////////////////////////////////
591/// Move frame.
592
594{
595 if (x != fX || y != fY) {
597 fX = x; fY = y;
598 }
599}
600
601////////////////////////////////////////////////////////////////////////////////
602/// Resize the frame.
603/// If w=0 && h=0 - Resize to default size
604
606{
607 if (w != fWidth || h != fHeight) {
608 TGDimension siz(0,0);
610 fWidth = w ? w : siz.fWidth;
611 fHeight = h ? h : siz.fHeight;
613 Layout();
614 }
615}
616
617////////////////////////////////////////////////////////////////////////////////
618/// Resize the frame.
619
621{
622 Resize(size.fWidth, size.fHeight);
623}
624
625////////////////////////////////////////////////////////////////////////////////
626/// Move and/or resize the frame.
627/// If w=0 && h=0 - Resize to default size
628
630{
631 // we do it anyway as we don't know if it's only a move or only a resize
632 TGDimension siz(0,0);
634 fWidth = w ? w : siz.fWidth;
635 fHeight = h ? h : siz.fHeight;
636 fX = x; fY = y;
638 Layout();
639}
640
641////////////////////////////////////////////////////////////////////////////////
642/// Send message (i.e. event) to window w. Message is encoded in one long
643/// as message type and up to two long parameters.
644
646{
647 Event_t event;
648
649 if (w) {
650 event.fType = kClientMessage;
651 event.fFormat = 32;
652 event.fHandle = gROOT_MESSAGE;
653
654 event.fWindow = w->GetId();
655 event.fUser[0] = msg;
656 event.fUser[1] = parm1;
657 event.fUser[2] = parm2;
658 event.fUser[3] = 0;
659 event.fUser[4] = 0;
660
661 gVirtualX->SendEvent(w->GetId(), &event);
662 }
663}
664
665////////////////////////////////////////////////////////////////////////////////
666/// Handle a client message. Client messages are the ones sent via
667/// TGFrame::SendMessage (typically by widgets).
668
670{
671 if (gDNDManager) {
673 }
674 if (event->fHandle == gROOT_MESSAGE) {
675 ProcessMessage(event->fUser[0], event->fUser[1], event->fUser[2]);
676 }
677 return kTRUE;
678}
679
680////////////////////////////////////////////////////////////////////////////////
681/// Get default frame background.
682
684{
685 static Bool_t init = kFALSE;
686 if (!init && gClient) {
687 fgDefaultFrameBackground = gClient->GetResourcePool()->GetFrameBgndColor();
688 init = kTRUE;
689 }
691}
692
693////////////////////////////////////////////////////////////////////////////////
694/// Get default selected frame background.
695
697{
698 static Bool_t init = kFALSE;
699 if (!init && gClient) {
700 fgDefaultSelectedBackground = gClient->GetResourcePool()->GetSelectedBgndColor();
701 init = kTRUE;
702 }
704}
705
706////////////////////////////////////////////////////////////////////////////////
707/// Get white pixel value.
708
710{
711 static Bool_t init = kFALSE;
712 if (!init && gClient) {
713 fgWhitePixel = gClient->GetResourcePool()->GetWhiteColor();
714 init = kTRUE;
715 }
716 return fgWhitePixel;
717}
718
719////////////////////////////////////////////////////////////////////////////////
720/// Get black pixel value.
721
723{
724 static Bool_t init = kFALSE;
725 if (!init && gClient) {
726 fgBlackPixel = gClient->GetResourcePool()->GetBlackColor();
727 init = kTRUE;
728 }
729 return fgBlackPixel;
730}
731
732////////////////////////////////////////////////////////////////////////////////
733/// Get black graphics context.
734
736{
737 if (!fgBlackGC && gClient)
738 fgBlackGC = gClient->GetResourcePool()->GetBlackGC();
739 return *fgBlackGC;
740}
741
742////////////////////////////////////////////////////////////////////////////////
743/// Get white graphics context.
744
746{
747 if (!fgWhiteGC && gClient)
748 fgWhiteGC = gClient->GetResourcePool()->GetWhiteGC();
749 return *fgWhiteGC;
750}
751
752////////////////////////////////////////////////////////////////////////////////
753/// Get highlight color graphics context.
754
756{
757 if (!fgHilightGC && gClient)
758 fgHilightGC = gClient->GetResourcePool()->GetFrameHiliteGC();
759 return *fgHilightGC;
760}
761
762////////////////////////////////////////////////////////////////////////////////
763/// Get shadow color graphics context.
764
766{
767 if (!fgShadowGC && gClient)
768 fgShadowGC = gClient->GetResourcePool()->GetFrameShadowGC();
769 return *fgShadowGC;
770}
771
772////////////////////////////////////////////////////////////////////////////////
773/// Get background color graphics context.
774
776{
777 if (!fgBckgndGC && gClient)
778 fgBckgndGC = gClient->GetResourcePool()->GetFrameBckgndGC();
779 return *fgBckgndGC;
780}
781
782////////////////////////////////////////////////////////////////////////////////
783/// Get time of last mouse click.
784
789
790////////////////////////////////////////////////////////////////////////////////
791/// Print window id.
792
794{
795 TString opt = option;
796 if (opt.Contains("tree")) {
798 return;
799 }
800
801 std::cout << option << ClassName() << ":\tid=" << fId << " parent=" << fParent->GetId();
802 std::cout << " x=" << fX << " y=" << fY;
803 std::cout << " w=" << fWidth << " h=" << fHeight << std::endl;
804}
805
806////////////////////////////////////////////////////////////////////////////////
807/// SetDragType
808
812
813////////////////////////////////////////////////////////////////////////////////
814/// SetDropType
815
819
820////////////////////////////////////////////////////////////////////////////////
821/// Returns drag source type.
822/// If frame is not "draggable" - return zero
823
825{
826 return fClient->IsEditable();
827}
828
829////////////////////////////////////////////////////////////////////////////////
830/// Returns drop target type.
831/// If frame cannot accept drop - return zero
832
834{
835 return 0;
836}
837
838////////////////////////////////////////////////////////////////////////////////
839/// Go into GUI building mode.
840
842{
843 if (GetEditDisabled()) return;
845 if (!gDragManager) return;
846
848
850 comp = (TGCompositeFrame *)this;
851 } else if (fParent->InheritsFrom(TGCompositeFrame::Class())) {
853 }
854 if (comp) comp->SetEditable(on);
855}
856
857////////////////////////////////////////////////////////////////////////////////
858/// Create a composite frame. A composite frame has in addition to a TGFrame
859/// also a layout manager and a list of child frames.
860
862 UInt_t options, Pixel_t back) : TGFrame(p, w, h, options, back)
863{
864 fLayoutManager = 0;
865 fList = new TList;
868 fMapSubwindows = fParent->IsMapSubwindows();
869 if (!fgDefaultHints)
871
874 else
876
878}
879
880////////////////////////////////////////////////////////////////////////////////
881/// Create a frame using an externally created window. For example
882/// to register the root window (called by TGClient), or a window
883/// created via TVirtualX::InitWindow() (id is obtained with TVirtualX::GetWindowID()).
884
886 : TGFrame(c, id, parent)
887{
888 fLayoutManager = 0;
889 fList = new TList;
892 fMapSubwindows = fParent->IsMapSubwindows();
893 if (!fgDefaultHints)
895
897
899}
900
901////////////////////////////////////////////////////////////////////////////////
902/// Delete a composite frame.
903
905{
906 if (fMustCleanup != kNoCleanup) {
907 Cleanup();
908 } else {
909 TGFrameElement *el = 0;
910 TIter next(fList);
911
912 while ((el = (TGFrameElement *) next())) {
913 fList->Remove(el);
914 delete el;
915 }
916 }
917
918 delete fList;
919 delete fLayoutManager;
920 fList = 0;
921 fLayoutManager = 0;
922}
923
924////////////////////////////////////////////////////////////////////////////////
925/// Return kTRUE if frame is being edited.
926
928{
929 return (fClient->GetRoot() == (TGWindow*)this);
930}
931
932////////////////////////////////////////////////////////////////////////////////
933/// Switch ON/OFF edit mode.
934/// If edit mode is ON it is possible:
935///
936/// 1. embed other ROOT GUI application (a la ActiveX)
937///
938/// For example:
939/// TGMainFrame *m = new TGMainFrame(gClient->GetRoot(), 500, 500);
940/// m->SetEditable();
941/// gSystem->Load("$ROOTSYS/test/Aclock"); // load Aclock demo
942/// Aclock a;
943/// gROOT->Macro("$ROOTSYS/tutorials/visualisation/gui/guitest.C");
944/// m->SetEditable(0);
945/// m->MapWindow();
946///
947
949{
950 if (on && ((fEditDisabled & kEditDisable) ||
952
953 if (on) {
954 fClient->SetRoot(this);
955 } else {
956 fClient->SetRoot(0);
957 }
959}
960
961////////////////////////////////////////////////////////////////////////////////
962/// Cleanup and delete all objects contained in this composite frame.
963/// This will delete all objects added via AddFrame().
964/// CAUTION: all objects (frames and layout hints) must be unique, i.e.
965/// cannot be shared.
966
968{
969 if (!fList) return;
970
972 TIter next(fList);
973
974 while ((el = (TGFrameElement *) next())) {
975 if (el->fFrame) {
976 el->fFrame->SetFrameElement(0);
977 if (!gVirtualX->InheritsFrom("TGX11") && !gVirtualX->InheritsFrom("TGCocoa"))
978 el->fFrame->DestroyWindow();
979 delete el->fFrame;
980 }
981
982 if (el->fLayout && (el->fLayout != fgDefaultHints) &&
983 (el->fLayout->References() > 0)) {
984 el->fLayout->RemoveReference();
985 if (!el->fLayout->References()) {
986 el->fLayout->fFE = 0;
987 delete el->fLayout;
988 }
989 }
990 fList->Remove(el);
991 delete el;
992 }
993}
994
995////////////////////////////////////////////////////////////////////////////////
996/// Set the layout manager for the composite frame.
997/// The layout manager is adopted by the frame and will be deleted
998/// by the frame.
999
1001{
1002 if (l) {
1003 delete fLayoutManager;
1004 fLayoutManager = l;
1005 } else
1006 Error("SetLayoutManager", "no layout manager specified");
1007}
1008
1009////////////////////////////////////////////////////////////////////////////////
1010/// Set broken layout. No Layout method is called.
1011
1016
1017////////////////////////////////////////////////////////////////////////////////
1018/// Set edit disable flag for this frame and subframes
1019///
1020/// - if (on & kEditDisable) - disable edit for this frame and all subframes.
1021
1023{
1024 fEditDisabled = on;
1025 UInt_t set = on & kEditDisable;
1026
1027 // propagate only kEditDisable
1028 if (set == kEditDisable) {
1029
1031 TIter next(fList);
1032 while ((el = (TGFrameElement *) next())) {
1033 if (el->fFrame) {
1034 el->fFrame->SetEditDisabled(set);
1035 }
1036 }
1037 }
1038}
1039
1040////////////////////////////////////////////////////////////////////////////////
1041/// Change composite frame options. Options is an OR of the EFrameTypes.
1042
1044{
1045 TGFrame::ChangeOptions(options);
1046
1047 if (options & kHorizontalFrame)
1049 else if (options & kVerticalFrame)
1051}
1052
1053////////////////////////////////////////////////////////////////////////////////
1054/// Turn on automatic cleanup of child frames in dtor.
1055///
1056/// if mode = kNoCleanup - no automatic cleanup
1057/// if mode = kLocalCleanup - automatic cleanup in this composite frame only
1058/// if mode = kDeepCleanup - automatic deep cleanup in this composite frame
1059/// and all child composite frames (hierarchical)
1060///
1061/// Attention!
1062/// Hierarchical cleaning is dangerous and must be used with caution.
1063/// There are many GUI components (in ROOT and in user code) which do not
1064/// use Clean method in destructor ("custom deallocation").
1065/// Adding such component to GUI container which is using hierarchical
1066/// cleaning will produce seg. violation when container is deleted.
1067/// The reason is double deletion: first when Clean method is invoked,
1068/// then at "custom deallocation".
1069/// We are going to correct all ROOT code to make it to be
1070/// consistent with hierarchical cleaning scheme.
1071
1073{
1074 if (mode == fMustCleanup)
1075 return;
1076
1078
1079 if (fMustCleanup == kDeepCleanup) {
1081 TIter next(fList);
1082
1083 while ((el = (TGFrameElement *) next())) {
1084 if (el->fFrame->InheritsFrom(TGCompositeFrame::Class())) {
1085 el->fFrame->SetCleanup(kDeepCleanup);
1086 }
1087 }
1088 }
1089}
1090
1091////////////////////////////////////////////////////////////////////////////////
1092/// Find frame-element holding frame f.
1093
1095{
1096 if (!fList) return 0;
1097
1099 TIter next(fList);
1100
1101 while ((el = (TGFrameElement *) next()))
1102 if (el->fFrame == f)
1103 return el;
1104
1105 return 0;
1106}
1107
1108////////////////////////////////////////////////////////////////////////////////
1109/// Add frame to the composite frame using the specified layout hints.
1110/// If no hints are specified default hints TGLayoutHints(kLHintsNormal,0,0,0,0)
1111/// will be used. Most of the time, however, you will want to provide
1112/// specific hints. User specified hints can be reused many times
1113/// and need to be destroyed by the user. The added frames cannot not be
1114/// added to different composite frames but still need to be deleted by
1115/// the user.
1116
1118{
1120 fList->Add(nw);
1121
1122 // in case of recursive cleanup, propagate cleanup setting to all
1123 // child composite frames
1125 f->SetCleanup(kDeepCleanup);
1126}
1127
1128////////////////////////////////////////////////////////////////////////////////
1129/// Remove all frames from composite frame.
1130
1132{
1133 if (!fList) return;
1134
1136 TIter next(fList);
1137
1138 while ((el = (TGFrameElement *) next())) {
1139 fList->Remove(el);
1140 if (el->fLayout) el->fLayout->RemoveReference();
1141// el->fFrame->SetFrameElement(0);
1142 delete el;
1143 }
1144}
1145
1146////////////////////////////////////////////////////////////////////////////////
1147/// Remove frame from composite frame.
1148
1150{
1152
1153 if (el) {
1154 fList->Remove(el);
1155 if (el->fLayout) el->fLayout->RemoveReference();
1156 f->SetFrameElement(0);
1157 delete el;
1158 }
1159}
1160
1161////////////////////////////////////////////////////////////////////////////////
1162/// Map all sub windows that are part of the composite frame.
1163
1165{
1166 if (!fMapSubwindows) {
1167 //MapWindow();
1168 return;
1169 }
1170
1172
1173 if (!fList) return;
1174
1176 TIter next(fList);
1177
1178 while ((el = (TGFrameElement *) next())) {
1179 if (el->fFrame) {
1180 el->fFrame->MapSubwindows();
1181 TGFrameElement *fe = el->fFrame->GetFrameElement();
1182 if (fe) fe->fState |= kIsVisible;
1183 }
1184 }
1185}
1186
1187////////////////////////////////////////////////////////////////////////////////
1188/// Hide sub frame.
1189
1191{
1193
1194 if (el) {
1195 el->fState = 0;
1196 el->fFrame->UnmapWindow();
1197 Layout();
1198 }
1199}
1200
1201////////////////////////////////////////////////////////////////////////////////
1202/// Show sub frame.
1203
1205{
1207
1208 if (el) {
1209 el->fState = 1;
1210 el->fFrame->MapWindow();
1211 Layout();
1212 }
1213}
1214
1215////////////////////////////////////////////////////////////////////////////////
1216/// Get state of sub frame.
1217
1219{
1221
1222 if (el)
1223 return el->fState;
1224 else
1225 return 0;
1226}
1227
1228////////////////////////////////////////////////////////////////////////////////
1229/// Get state of sub frame.
1230
1232{
1234
1235 if (el)
1236 return (el->fState & kIsVisible);
1237 else
1238 return kFALSE;
1239}
1240
1241////////////////////////////////////////////////////////////////////////////////
1242/// Get state of sub frame.
1243
1245{
1247
1248 if (el)
1249 return (el->fState & kIsArranged);
1250 else
1251 return kFALSE;
1252}
1253
1254////////////////////////////////////////////////////////////////////////////////
1255/// Layout the elements of the composite frame.
1256
1258{
1259 if (IsLayoutBroken()) return;
1261}
1262
1263////////////////////////////////////////////////////////////////////////////////
1264/// Print all frames in this composite frame.
1265
1267{
1268 TString opt = option;
1269 if (opt.Contains("tree")) {
1271 return;
1272 }
1273
1275 TIter next(fList);
1276 TString tab = option;
1277
1278 TGFrame::Print(tab.Data());
1279 tab += " ";
1280 while ((el = (TGFrameElement*)next())) {
1281 el->fFrame->Print(tab.Data());
1282 }
1283}
1284
1285////////////////////////////////////////////////////////////////////////////////
1286/// Change background color for this frame and all subframes.
1287
1289{
1292
1293 TIter next(fList);
1294
1295 while ((el = (TGFrameElement*)next())) {
1296 el->fFrame->SetBackgroundColor(back);
1297 if (el->fFrame->InheritsFrom(TGCompositeFrame::Class())) {
1298 ((TGCompositeFrame*)el->fFrame)->ChangeSubframesBackground(back);
1299 }
1300 fClient->NeedRedraw(el->fFrame);
1301 }
1302 fClient->NeedRedraw(this);
1303}
1304
1305////////////////////////////////////////////////////////////////////////////////
1306/// Get frame located at specified point.
1307
1309{
1310 if (!Contains(x, y)) return 0;
1311
1312 if (!fList) return this;
1313
1314 TGFrame *f;
1316 TIter next(fList);
1317
1318 while ((el = (TGFrameElement *) next())) {
1319 //if (el->fFrame->IsVisible()) { //for this need to move IsVisible to TGFrame
1320 if (el->fState & kIsVisible) {
1321 f = el->fFrame->GetFrameFromPoint(x - el->fFrame->GetX(),
1322 y - el->fFrame->GetY());
1323 if (f) return f;
1324 }
1325 }
1326 return this;
1327}
1328
1329////////////////////////////////////////////////////////////////////////////////
1330/// Translate coordinates to child frame.
1331
1333 Int_t &fx, Int_t &fy)
1334{
1335 if (child == this) {
1336 fx = x;
1337 fy = y;
1338 return kTRUE;
1339 }
1340
1341 if (!Contains(x, y)) return kFALSE;
1342
1343 if (!fList) return kFALSE;
1344
1346 TIter next(fList);
1347
1348 while ((el = (TGFrameElement *) next())) {
1349 if (el->fFrame == child) {
1350 fx = x - el->fFrame->GetX();
1351 fy = y - el->fFrame->GetY();
1352 return kTRUE;
1353 } else if (el->fFrame->IsComposite()) {
1354 if (((TGCompositeFrame *)el->fFrame)->TranslateCoordinates(child,
1355 x - el->fFrame->GetX(), y - el->fFrame->GetY(), fx, fy))
1356 return kTRUE;
1357 }
1358 }
1359 return kFALSE;
1360}
1361
1362////////////////////////////////////////////////////////////////////////////////
1363/// Handle drag enter event.
1364
1366{
1367 if (fClient && fClient->IsEditable() &&
1368 (fId != fClient->GetRoot()->GetId())) {
1369
1370 // the dragged frame cannot be dropped
1372
1373 //
1374 if (IsEditable()) {
1375 return kTRUE;
1376 }
1377
1378 Float_t r, g, b;
1380 r *= 1.12;
1381 g *= 1.13;
1382 b *= 1.12;
1383 Pixel_t back = TColor::RGB2Pixel(r, g, b);
1384 gVirtualX->SetWindowBackground(fId, back);
1385 DoRedraw();
1386 return kTRUE;
1387 }
1388
1389 return kFALSE;
1390}
1391
1392////////////////////////////////////////////////////////////////////////////////
1393/// Handle drag leave event.
1394
1396{
1397 if (fClient && fClient->IsEditable() &&
1398 (fId != fClient->GetRoot()->GetId())) {
1399
1401
1402 gVirtualX->SetWindowBackground(fId, fBackground);
1403 DoRedraw();
1404 return kTRUE;
1405 }
1406
1407 return kFALSE;
1408}
1409
1410////////////////////////////////////////////////////////////////////////////////
1411/// Handle drag motion event.
1412
1417
1418////////////////////////////////////////////////////////////////////////////////
1419/// Handle drop event.
1420
1422 TGLayoutHints *lo)
1423{
1424 if (fClient && fClient->IsEditable() && frame && (x >= 0) && (y >= 0) &&
1425 (x + frame->GetWidth() <= fWidth) && (y + frame->GetHeight() <= fHeight)) {
1426
1428
1429 frame->ReparentWindow(this, x, y);
1430 AddFrame(frame, lo);
1431 frame->MapWindow();
1433 return kTRUE;
1434 }
1435
1436 return kFALSE;
1437}
1438
1439
1440////////////////////////////////////////////////////////////////////////////////
1441/// Create a top level main frame. A main frame interacts
1442/// with the window manager.
1443
1445 UInt_t options) : TGCompositeFrame(p, w, h, options | kMainFrame)
1446{
1447 // WMDeleteNotify causes the system to send a kClientMessage to the
1448 // window with fFormat=32 and fUser[0]=gWM_DELETE_WINDOW when window
1449 // closed via WM
1450
1451 gVirtualX->WMDeleteNotify(fId);
1452
1453 fBindList = new TList;
1454
1455 fMWMValue = 0;
1456 fMWMFuncs = 0;
1457 fMWMInput = 0;
1458 fWMX = -1;
1459 fWMY = -1;
1460 fWMWidth = (UInt_t) -1;
1461 fWMHeight = (UInt_t) -1;
1462 fWMMinWidth = (UInt_t) -1;
1463 fWMMinHeight = (UInt_t) -1;
1464 fWMMaxWidth = (UInt_t) -1;
1465 fWMMaxHeight = (UInt_t) -1;
1466 fWMWidthInc = (UInt_t) -1;
1467 fWMHeightInc = (UInt_t) -1;
1469
1470 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_s),
1471 kKeyControlMask, kTRUE);//grab CTRL+s
1472 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_s),
1473 kKeyControlMask | kKeyMod2Mask, kTRUE);//grab CTRL+s also if NumLock is active
1474 if (p == fClient->GetDefaultRoot()) {
1478 gVirtualX->SetMWMHints(fId, fMWMValue, fMWMFuncs, fMWMInput);
1479 }
1480 // if parent is editing/embeddable add this frame to the parent
1481 if (fClient->IsEditable() && (p == fClient->GetRoot())) {
1482 TGCompositeFrame *frame;
1483 if (p && p->InheritsFrom(TGCompositeFrame::Class())) {
1484 frame = (TGCompositeFrame*)p;
1486
1487 // used during paste operation
1490 }
1491 }
1492 }
1493 //AddInput(kButtonPressMask); // to allow Drag and Drop
1494 // Create Drag&Drop Manager and define a few DND types
1495 fDNDTypeList = new Atom_t[3];
1496 fDNDTypeList[0] = gVirtualX->InternAtom("application/root", kFALSE);
1497 fDNDTypeList[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
1498 fDNDTypeList[2] = 0;
1499 if (!gDNDManager)
1500 new TGDNDManager(this, fDNDTypeList);
1501 SetWindowName();
1502}
1503
1504////////////////////////////////////////////////////////////////////////////////
1505/// TGMainFrame destructor.
1506
1508{
1509 delete [] fDNDTypeList;
1510 if (fBindList) {
1511 fBindList->Delete();
1512 delete fBindList;
1513 }
1514 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_s),
1516 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_s),
1518}
1519
1520////////////////////////////////////////////////////////////////////////////////
1521/// Opens dialog window allowing user to save the frame contents
1522/// as a ROOT macro or as an image.
1523/// Returns kTRUE if something was saved.
1524///
1525/// This is bound to Ctrl-S by default.
1526
1528{
1529 static TString dir(".");
1530 static Bool_t overwr = kFALSE;
1531
1533 do {
1535
1536 TGFileInfo fi;
1537 fi.fFileTypes = gSaveMacroTypes;
1538 fi.SetIniDir(dir);
1539 fi.fOverwrite = overwr;
1540 new TGFileDialog(fClient->GetDefaultRoot(), this, kFDSave, &fi);
1541 if (!fi.fFilename) return kFALSE;
1542 dir = fi.fIniDir;
1543 overwr = fi.fOverwrite;
1544 const Bool_t res = SaveFrameAsCodeOrImage(fi.fFilename);
1545 if (!res) {
1546 Int_t retval;
1547 new TGMsgBox(fClient->GetDefaultRoot(), this, "Error...",
1548 TString::Format("file (%s) cannot be saved with this extension",
1549 fi.fFilename),
1552 }
1553 } while (repeat_save);
1554
1555 return kTRUE;
1556}
1557
1558////////////////////////////////////////////////////////////////////////////////
1559/// Saves the frame contents as a ROOT macro or as an image,
1560/// depending on the extension of the fileName argument.
1561/// If preexisting, the file is overwritten.
1562/// Returns kTRUE if something was saved.
1563
1565{
1566 static TString dir(".");
1567
1568 const TString fname = gSystem->UnixPathName(fileName);
1569 if (fname.EndsWith(".C")) {
1571 main->SaveSource(fname.Data(), "");
1572 } else {
1574 if (fname.EndsWith("gif")) {
1576 } else if (fname.EndsWith(".png")) {
1578 } else if (fname.EndsWith(".jpg")) {
1580 } else if (fname.EndsWith(".tiff")) {
1582 } else if (fname.EndsWith(".xpm")) {
1584 }
1585 if (gtype != TImage::kUnknown) {
1589 RaiseWindow();
1590 img->FromWindow(GetId());
1591 img->WriteImage(fname, gtype);
1593 delete img;
1594 } else {
1595 Error("SaveFrameAsCodeOrImage", "File cannot be saved with this extension");
1596 return kFALSE;
1597 }
1598 }
1599
1600 return kTRUE;
1601}
1602
1603////////////////////////////////////////////////////////////////////////////////
1604/// Handle keyboard events.
1605
1607{
1608 if (fBindList) {
1609
1610 TIter next(fBindList);
1611 TGMapKey *m;
1612 TGFrame *w = 0;
1613
1614 while ((m = (TGMapKey *) next())) {
1615 if (m->fKeyCode == event->fCode) {
1616 w = (TGFrame *) m->fWindow;
1617 if (w->HandleKey(event)) return kTRUE;
1618 }
1619 }
1620 }
1621
1622 if ((event->fType == kGKeyPress) && (event->fState & kKeyControlMask)) {
1623 UInt_t keysym;
1624 char str[2];
1625 gVirtualX->LookupString(event, str, sizeof(str), keysym);
1626
1627 if ((keysym & ~0x20) == kKey_S) { // case insensitive ctrl-s
1628 return SaveFrameAsCodeOrImage();
1629 }
1630 }
1631 return kFALSE;
1632}
1633
1634////////////////////////////////////////////////////////////////////////////////
1635/// Bind key to a window.
1636
1638{
1639 TList *list = fBindList;
1640 Handle_t id = fId;
1641
1642 if (fClient->IsEditable()) {
1644 list = main->GetBindList();
1645 id = main->GetId();
1646 }
1647
1648 if (list) {
1649 TGMapKey *m = new TGMapKey(keycode, (TGWindow *)w);
1650 list->Add(m);
1651 gVirtualX->GrabKey(id, keycode, modifier, kTRUE);
1652 return kTRUE;
1653 }
1654 return kFALSE;
1655}
1656
1657////////////////////////////////////////////////////////////////////////////////
1658/// Remove key binding.
1659
1661{
1662 if (fBindList) {
1663 TIter next(fBindList);
1664 TGMapKey *m;
1665 while ((m = (TGMapKey *) next())) {
1666 if (m->fKeyCode == (UInt_t) keycode) {
1667 fBindList->Remove(m);
1668 delete m;
1669 gVirtualX->GrabKey(fId, keycode, modifier, kFALSE);
1670 return;
1671 }
1672 }
1673 }
1674}
1675
1676////////////////////////////////////////////////////////////////////////////////
1677/// Handle mouse button events.
1678
1680{
1681 if (event->fType == kButtonRelease) {
1683 }
1684 return TGCompositeFrame::HandleButton(event);
1685}
1686
1687
1688////////////////////////////////////////////////////////////////////////////////
1689/// Handle mouse motion events.
1690
1692{
1694 gDNDManager->Drag(event->fXRoot, event->fYRoot,
1696 }
1697 return TGCompositeFrame::HandleMotion(event);
1698}
1699
1700////////////////////////////////////////////////////////////////////////////////
1701/// Handle primary selection event.
1702
1704{
1705 if ((Atom_t)event->fUser[1] == TGDNDManager::GetDNDSelection()) {
1706 if (gDNDManager)
1707 return gDNDManager->HandleSelection(event);
1708 }
1710}
1711
1712////////////////////////////////////////////////////////////////////////////////
1713/// Handle selection request event.
1714
1723
1724////////////////////////////////////////////////////////////////////////////////
1725/// Handle client messages sent to this frame.
1726
1728{
1730
1731 if ((event->fFormat == 32) && ((Atom_t)event->fUser[0] == gWM_DELETE_WINDOW) &&
1732 (event->fHandle != gROOT_MESSAGE)) {
1733 Emit("CloseWindow()");
1735 CloseWindow();
1736 }
1737 return kTRUE;
1738}
1739
1740////////////////////////////////////////////////////////////////////////////////
1741/// Send close message to self. This method should be called from
1742/// a button to close this window.
1743
1745{
1746 Event_t event;
1747
1748 event.fType = kClientMessage;
1749 event.fFormat = 32;
1750 event.fHandle = gWM_DELETE_WINDOW;
1751
1752 event.fWindow = GetId();
1753 event.fUser[0] = (Long_t) gWM_DELETE_WINDOW;
1754 event.fUser[1] = 0;
1755 event.fUser[2] = 0;
1756 event.fUser[3] = 0;
1757 event.fUser[4] = 0;
1758
1759 gVirtualX->SendEvent(GetId(), &event);
1760}
1761
1762////////////////////////////////////////////////////////////////////////////////
1763/// Close and delete main frame. We get here in response to ALT+F4 or
1764/// a window manager close command. To terminate the application when this
1765/// happens override this method and call gApplication->Terminate(0) or
1766/// make a connection to this signal (if after the slot this method
1767/// should not be called call DontCallClose() in the slot).
1768/// By default the window will be deleted.
1769
1771{
1772 DeleteWindow();
1773}
1774
1775////////////////////////////////////////////////////////////////////////////////
1776/// Typically call this method in the slot connected to the CloseWindow()
1777/// signal to prevent the calling of the default or any derived CloseWindow()
1778/// methods to prevent premature or double deletion of this window.
1779
1784
1785////////////////////////////////////////////////////////////////////////////////
1786/// Set window name. This is typically done via the window manager.
1787
1789{
1790 if (!name) {
1792 } else {
1793 fWindowName = name;
1794 gVirtualX->SetWindowName(fId, (char *)name);
1795 }
1796}
1797
1798////////////////////////////////////////////////////////////////////////////////
1799/// Set window icon name. This is typically done via the window manager.
1800
1802{
1803 fIconName = name;
1804 gVirtualX->SetIconName(fId, (char *)name);
1805}
1806
1807////////////////////////////////////////////////////////////////////////////////
1808/// Set window icon pixmap by name. This is typically done via the window
1809/// manager. Icon can be in any image format supported by TImage, e.g.
1810/// GIF, XPM, PNG, JPG .. or even PS, PDF (see EImageFileTypes in TImage.h
1811/// for the full list of supported formats).
1812///
1813/// For example,
1814/// main_frame->SetIconPixmap("/home/root/icons/bld_rgb.png");
1815
1817{
1820 if (iconPic) {
1821 Pixmap_t pic = iconPic->GetPicture();
1822 gVirtualX->SetIconPixmap(fId, pic);
1823 return iconPic;
1824 } else
1825 return 0;
1826}
1827
1828////////////////////////////////////////////////////////////////////////////////
1829/// Set window icon by xpm array. That allows to have icons
1830/// builtin to the source code.
1831///
1832/// For example,
1833/// \code{.cpp}
1834/// #include "/home/root/icons/bld_rgb.xpm"
1835/// //bld_rgb.xpm contains char *bld_rgb[] array
1836/// main_frame->SetIconPixmap(bld_rgb);
1837/// \endcode
1838
1840{
1842 if (!img) return;
1843 img->SetImageBuffer(xpm_array, TImage::kXpm);
1844 Pixmap_t pic = img->GetPixmap();
1845 if (pic) {
1846 gVirtualX->SetIconPixmap(fId, pic);
1847 } else {
1848 Warning("SetIconPixmap", "Failed to set window icon from xpm array.");
1849 }
1850 delete img;
1851}
1852
1853////////////////////////////////////////////////////////////////////////////////
1854/// Set the windows class and resource name. Used to get the right
1855/// resources from the resource database. However, ROOT applications
1856/// will typically use the .rootrc file for this.
1857
1858void TGMainFrame::SetClassHints(const char *className, const char *resourceName)
1859{
1860 fClassName = className;
1862 gVirtualX->SetClassHints(fId, (char *)className, (char *)resourceName);
1863}
1864
1865////////////////////////////////////////////////////////////////////////////////
1866/// Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
1867
1869{
1870 if (fClient->IsEditable() && (fParent == fClient->GetRoot())) return;
1871
1872 fMWMValue = value;
1873 fMWMFuncs = funcs;
1874 fMWMInput = input;
1875 gVirtualX->SetMWMHints(fId, value, funcs, input);
1876}
1877
1878////////////////////////////////////////////////////////////////////////////////
1879/// Give the window manager a window position hint.
1880
1882{
1883 if (fClient->IsEditable() && (fParent == fClient->GetRoot())) return;
1884
1885 fWMX = x;
1886 fWMY = y;
1887 gVirtualX->SetWMPosition(fId, x, y);
1888}
1889
1890////////////////////////////////////////////////////////////////////////////////
1891/// Give the window manager a window size hint.
1892
1894{
1895 if (fClient->IsEditable() && (fParent == fClient->GetRoot())) return;
1896
1897 fWMWidth = w;
1898 fWMHeight = h;
1899 gVirtualX->SetWMSize(fId, w, h);
1900}
1901
1902////////////////////////////////////////////////////////////////////////////////
1903/// Give the window manager minimum and maximum size hints. Also
1904/// specify via winc and hinc the resize increments.
1905
1920
1921////////////////////////////////////////////////////////////////////////////////
1922/// Set the initial state of the window. Either kNormalState or kIconicState.
1923
1925{
1926 if (fClient->IsEditable() && (fParent == fClient->GetRoot())) return;
1927
1928 fWMInitState = state;
1929 gVirtualX->SetWMState(fId, state);
1930}
1931
1932
1933////////////////////////////////////////////////////////////////////////////////
1934/// Create a transient window. A transient window is typically used for
1935/// dialog boxes.
1936
1938 UInt_t w, UInt_t h, UInt_t options)
1939 : TGMainFrame(p, w, h, options | kTransientFrame)
1940{
1941 fMain = main;
1942 if (!fMain && gClient)
1943 fMain = gClient->GetRoot();
1944
1945 if (fMain) {
1946 gVirtualX->SetWMTransientHint(fId, fMain->GetId());
1947 }
1948}
1949
1950////////////////////////////////////////////////////////////////////////////////
1951/// Position transient frame centered relative to the parent frame.
1952/// If fMain is 0 (i.e. TGTransientFrame is acting just like a
1953/// TGMainFrame) and croot is true, the window will be centered on
1954/// the root window, otherwise no action is taken and the default
1955/// wm placement will be used.
1956
1958{
1959 Int_t x=0, y=0, ax, ay;
1961
1964
1965 if (fMain) {
1966
1967 switch (pos) {
1968 case kCenter:
1969 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - fWidth) >> 1;
1970 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - fHeight) >> 1;
1971 break;
1972 case kRight:
1973 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - (fWidth >> 1));
1974 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - fHeight) >> 1;
1975 break;
1976 case kLeft:
1977 x = (Int_t)(-1 * (Int_t)(fWidth >> 1));
1978 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - fHeight) >> 1;
1979 break;
1980 case kTop:
1981 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - fWidth) >> 1;
1982 y = (Int_t)(-1 * (Int_t)(fHeight >> 1));
1983 break;
1984 case kBottom:
1985 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - fWidth) >> 1;
1986 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - (fHeight >> 1));
1987 break;
1988 case kTopLeft:
1989 x = (Int_t)(-1 * (Int_t)(fWidth >> 1));
1990 y = (Int_t)(-1 * (Int_t)(fHeight >> 1));
1991 break;
1992 case kTopRight:
1993 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - (fWidth >> 1));
1994 y = (Int_t)(-1 * (Int_t)(fHeight >> 1));
1995 break;
1996 case kBottomLeft:
1997 x = (Int_t)(-1 * (Int_t)(fWidth >> 1));
1998 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - (fHeight >> 1));
1999 break;
2000 case kBottomRight:
2001 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - (fWidth >> 1));
2002 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - (fHeight >> 1));
2003 break;
2004 }
2005
2006 gVirtualX->TranslateCoordinates(fMain->GetId(), GetParent()->GetId(),
2007 x, y, ax, ay, wdummy);
2008 if (!gVirtualX->InheritsFrom("TGWin32")) {
2009 if (ax < 10)
2010 ax = 10;
2011 else if (ax + fWidth + 10 > dw)
2012 ax = dw - fWidth - 10;
2013
2014 if (ay < 20)
2015 ay = 20;
2016 else if (ay + fHeight + 50 > dh)
2017 ay = dh - fHeight - 50;
2018 }
2019
2020 } else if (croot) {
2021
2022 switch (pos) {
2023 case kCenter:
2024 x = (dw - fWidth) >> 1;
2025 y = (dh - fHeight) >> 1;
2026 break;
2027 case kRight:
2028 x = dw - (fWidth >> 1);
2029 y = (dh - fHeight) >> 1;
2030 break;
2031 case kLeft:
2032 x = -1 * (Int_t)(fWidth >> 1);
2033 y = (dh - fHeight) >> 1;
2034 break;
2035 case kTop:
2036 x = (dw - fWidth) >> 1;
2037 y = -1 * (Int_t)(fHeight >> 1);
2038 break;
2039 case kBottom:
2040 x = (dw - fWidth) >> 1;
2041 y = dh - (fHeight >> 1);
2042 break;
2043 case kTopLeft:
2044 x = -1 * (Int_t)(fWidth >> 1);
2045 y = -1 * (Int_t)(fHeight >> 1);
2046 break;
2047 case kTopRight:
2048 x = dw - (fWidth >> 1);
2049 y = -1 * (Int_t)(fHeight >> 1);
2050 break;
2051 case kBottomLeft:
2052 x = -1 * (Int_t)(fWidth >> 1);
2053 y = dh - (fHeight >> 1);
2054 break;
2055 case kBottomRight:
2056 x = dw - (fWidth >> 1);
2057 y = dh - (fHeight >> 1);
2058 break;
2059 }
2060
2061 ax = x;
2062 ay = y;
2063
2064 } else {
2065
2066 return;
2067
2068 }
2069
2070 Move(ax, ay);
2072}
2073
2074////////////////////////////////////////////////////////////////////////////////
2075/// Create a group frame. The title will be adopted and deleted by the
2076/// group frame.
2077
2079 UInt_t options, GContext_t norm,
2080 FontStruct_t font, Pixel_t back) :
2081 TGCompositeFrame(p, 1, 1, options, back)
2082{
2083 fText = title;
2084 fFontStruct = font;
2085 fNormGC = norm;
2086 fTitlePos = kLeft;
2088
2090 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2092}
2093
2094////////////////////////////////////////////////////////////////////////////////
2095/// Create a group frame.
2096
2097TGGroupFrame::TGGroupFrame(const TGWindow *p, const char *title,
2098 UInt_t options, GContext_t norm,
2099 FontStruct_t font, Pixel_t back) :
2100 TGCompositeFrame(p, 1, 1, options, back)
2101{
2102 fText = new TGString(!p && !title ? GetName() : title);
2103 fFontStruct = font;
2104 fNormGC = norm;
2105 fTitlePos = kLeft;
2107
2109 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2111
2112 SetWindowName();
2113}
2114
2115////////////////////////////////////////////////////////////////////////////////
2116/// Delete a group frame.
2117
2119{
2120 if (fHasOwnFont) {
2122 TGGC *gc = pool->FindGC(fNormGC);
2123 pool->FreeGC(gc);
2124 }
2125 delete fText;
2126}
2127
2128////////////////////////////////////////////////////////////////////////////////
2129/// Returns default size.
2130
2132{
2133 UInt_t tw = gVirtualX->TextWidth(fFontStruct, fText->GetString(),
2134 fText->GetLength()) + 24;
2135
2137
2138 return tw>dim.fWidth ? TGDimension(tw, dim.fHeight) : dim;
2139}
2140
2141////////////////////////////////////////////////////////////////////////////////
2142/// Redraw the group frame. Need special DoRedraw() since we need to
2143/// redraw with fBorderWidth=0.
2144
2146{
2147 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
2148
2149 DrawBorder();
2150}
2151
2152
2153////////////////////////////////////////////////////////////////////////////////
2154/// Changes text color.
2155/// If local is true color is changed locally, otherwise - globally.
2156
2158{
2159 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
2160 TGGC *gc = pool->FindGC(fNormGC);
2161
2162 if (gc && local) {
2163 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
2165 }
2166 if (gc) {
2167 gc->SetForeground(color);
2168 fNormGC = gc->GetGC();
2169 }
2170 fClient->NeedRedraw(this);
2171}
2172
2173////////////////////////////////////////////////////////////////////////////////
2174/// Changes text font.
2175/// If local is true font is changed locally - otherwise globally.
2176
2178{
2179 FontH_t v = gVirtualX->GetFontHandle(font);
2180 if (!v) return;
2181
2182 fFontStruct = font;
2183
2184 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
2185 TGGC *gc = pool->FindGC(fNormGC);
2186
2187 if (gc && local) {
2188 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
2190 }
2191 if (gc) {
2192 gc->SetFont(v);
2193 fNormGC = gc->GetGC();
2194 }
2195 fClient->NeedRedraw(this);
2196}
2197
2198////////////////////////////////////////////////////////////////////////////////
2199/// Changes text font specified by name.
2200/// If local is true font is changed locally - otherwise globally.
2201
2203{
2204 TGFont *font = fClient->GetFont(fontName);
2205
2206 if (font) {
2208 }
2209}
2210
2211////////////////////////////////////////////////////////////////////////////////
2212/// Returns kTRUE if text attributes are unique,
2213/// returns kFALSE if text attributes are shared (global).
2214
2216{
2217 return fHasOwnFont;
2218}
2219
2220////////////////////////////////////////////////////////////////////////////////
2221/// Draw border of around the group frame.
2222///
2223/// if frame is kRaisedFrame - a frame border is of "wall style",
2224/// otherwise of "groove style".
2225
2227{
2228 Int_t x, y, l, t, r, b, gl, gr, sep, max_ascent, max_descent;
2229
2231 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2232
2233 l = 0;
2234 t = (max_ascent + max_descent + 2) >> 1;
2235 r = fWidth - 1;
2236 // next three lines are for backward compatibility in case of horizontal layout
2237 // coverity[returned_null]
2238 // coverity[dereference]
2240 if ((lm->InheritsFrom(TGHorizontalLayout::Class())) ||
2241 (lm->InheritsFrom(TGMatrixLayout::Class())))
2242 b = fHeight - 1;
2243 else
2244 b = fHeight - t;
2245
2246 sep = 3;
2247 UInt_t rr = 5 + (sep << 1) + tw;
2248
2249 switch (fTitlePos) {
2250 case kRight:
2251 gl = fWidth>rr ? Int_t(fWidth - rr) : 5 + sep;
2252 break;
2253 case kCenter:
2254 gl = fWidth>tw ? Int_t((fWidth - tw)>>1) - sep : 5 + sep;
2255 break;
2256 case kLeft:
2257 default:
2258 gl = 5 + sep;
2259 }
2260 gr = gl + tw + (sep << 1);
2261
2262 switch (fOptions & (kSunkenFrame | kRaisedFrame)) {
2263 case kRaisedFrame:
2264 gVirtualX->DrawLine(fId, GetHilightGC()(), l, t, gl, t);
2265 gVirtualX->DrawLine(fId, GetShadowGC()(), l+1, t+1, gl, t+1);
2266
2267 gVirtualX->DrawLine(fId, GetHilightGC()(), gr, t, r-1, t);
2268 gVirtualX->DrawLine(fId, GetShadowGC()(), gr, t+1, r-2, t+1);
2269
2270 gVirtualX->DrawLine(fId, GetHilightGC()(), r-1, t, r-1, b-1);
2271 gVirtualX->DrawLine(fId, GetShadowGC()(), r, t, r, b);
2272
2273 gVirtualX->DrawLine(fId, GetHilightGC()(), r-1, b-1, l, b-1);
2274 gVirtualX->DrawLine(fId, GetShadowGC()(), r, b, l, b);
2275
2276 gVirtualX->DrawLine(fId, GetHilightGC()(), l, b-1, l, t);
2277 gVirtualX->DrawLine(fId, GetShadowGC()(), l+1, b-2, l+1, t+1);
2278 break;
2279 case kSunkenFrame:
2280 default:
2281 gVirtualX->DrawLine(fId, GetShadowGC()(), l, t, gl, t);
2282 gVirtualX->DrawLine(fId, GetHilightGC()(), l+1, t+1, gl, t+1);
2283
2284 gVirtualX->DrawLine(fId, GetShadowGC()(), gr, t, r-1, t);
2285 gVirtualX->DrawLine(fId, GetHilightGC()(), gr, t+1, r-2, t+1);
2286
2287 gVirtualX->DrawLine(fId, GetShadowGC()(), r-1, t, r-1, b-1);
2288 gVirtualX->DrawLine(fId, GetHilightGC()(), r, t, r, b);
2289
2290 gVirtualX->DrawLine(fId, GetShadowGC()(), r-1, b-1, l, b-1);
2291 gVirtualX->DrawLine(fId, GetHilightGC()(), r, b, l, b);
2292
2293 gVirtualX->DrawLine(fId, GetShadowGC()(), l, b-1, l, t);
2294 gVirtualX->DrawLine(fId, GetHilightGC()(), l+1, b-2, l+1, t+1);
2295 break;
2296 }
2297
2298 x = gl + sep;
2299 y = 1;
2300
2302}
2303
2304////////////////////////////////////////////////////////////////////////////////
2305/// Set or change title of the group frame. Title TGString is adopted
2306/// by the TGGroupFrame.
2307
2309{
2310 if (!title) {
2311 Warning("SetTitle", "title cannot be 0, try \"\"");
2312 title = new TGString("");
2313 }
2314
2315 delete fText;
2316
2317 fText = title;
2318 fClient->NeedRedraw(this);
2319}
2320
2321////////////////////////////////////////////////////////////////////////////////
2322/// Set or change title of the group frame.
2323
2324void TGGroupFrame::SetTitle(const char *title)
2325{
2326 if (!title) {
2327 Error("SetTitle", "title cannot be 0, try \"\"");
2328 return;
2329 }
2330
2331 SetTitle(new TGString(title));
2332}
2333
2334////////////////////////////////////////////////////////////////////////////////
2335/// Return default font structure in use.
2336
2338{
2339 if (!fgDefaultFont && gClient)
2340 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
2341 return fgDefaultFont->GetFontStruct();
2342}
2343
2344////////////////////////////////////////////////////////////////////////////////
2345/// Return default graphics context in use.
2346
2348{
2349 if (!fgDefaultGC && gClient)
2350 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
2351 return *fgDefaultGC;
2352}
2353
2354////////////////////////////////////////////////////////////////////////////////
2355/// Header Frame constructor.
2356
2358 UInt_t options, Pixel_t back) :
2359 TGHorizontalFrame(p, w, h, options | kVerticalFrame, back)
2360{
2362 fSplitCursor = gVirtualX->CreateCursor(kArrowHor);
2363 fOverSplitter = false;
2364 fOverButton = -1;
2365 fLastButton = -1;
2366 fNColumns = 1;
2367 fColHeader = 0;
2368 fSplitHeader = 0;
2369
2370 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
2372 kNone, kNone);
2374}
2375
2376////////////////////////////////////////////////////////////////////////////////
2377/// Set columns information in the header frame.
2378
2386
2387////////////////////////////////////////////////////////////////////////////////
2388/// Handle mouse button event in header frame.
2389
2391{
2392 if ( event->fY > 0 &&
2393 event->fY <= (Int_t) this->GetHeight() ) {
2394 for (Int_t i = 1; i < fNColumns; ++i ) {
2395 if ( event->fX < fColHeader[i]->GetX() &&
2396 event->fX >= fColHeader[i-1]->GetX() ) {
2397 if ( fOverSplitter ) {
2398 if ( event->fX <= fColHeader[i-1]->GetX() + 5 )
2399 fSplitHeader[i-2]->HandleButton(event);
2400 else
2401 fSplitHeader[i-1]->HandleButton(event);
2402 } else {
2403 if ( event->fType == kButtonPress ) {
2404 fLastButton = i - 1;
2405 } else {
2406 fLastButton = -1;
2407 }
2408 event->fX -= fColHeader[i-1]->GetX();
2409 fColHeader[i-1]->HandleButton(event);
2410 }
2411 break;
2412 }
2413 }
2414 }
2415
2416 return kTRUE;
2417}
2418
2419////////////////////////////////////////////////////////////////////////////////
2420/// Handle double click mouse event in header frame.
2421
2423{
2424 if ( event->fY > 0 &&
2425 event->fY <= (Int_t) this->GetHeight() ) {
2426 for (Int_t i = 1; i < fNColumns; ++i ) {
2427 if ( event->fX < fColHeader[i]->GetX() &&
2428 event->fX >= fColHeader[i-1]->GetX() ) {
2429 if ( fOverSplitter ) {
2430 if ( event->fX <= fColHeader[i-1]->GetX() + 5 )
2431 fSplitHeader[i-2]->HandleDoubleClick(event);
2432 else
2433 fSplitHeader[i-1]->HandleDoubleClick(event);
2434 } else {
2435 event->fX -= fColHeader[i-1]->GetX();
2436 fColHeader[i-1]->HandleDoubleClick(event);
2437 }
2438 break;
2439 }
2440 }
2441 }
2442
2443 return kTRUE;
2444}
2445
2446////////////////////////////////////////////////////////////////////////////////
2447/// Handle mouse motion events in header frame.
2448
2450{
2451 if ( event->fY > 0 &&
2452 event->fY <= (Int_t) this->GetHeight() ) {
2453 Bool_t inMiddle = false;
2454
2455 for (Int_t i = 1; i < fNColumns; ++i ) {
2456 if ( event->fX > fColHeader[i]->GetX() - 5 &&
2457 event->fX < fColHeader[i]->GetX() + 5 ) {
2458 inMiddle = true;
2459 }
2460 if ( event->fX < fColHeader[i]->GetX() &&
2461 event->fX >= fColHeader[i-1]->GetX() ) {
2462 fOverButton = i - 1;
2463 }
2464 }
2466 if ( fOverSplitter ) {
2467 gVirtualX->SetCursor(fId, fSplitCursor);
2468 }
2469 else {
2470 gVirtualX->SetCursor(fId, kNone);
2471 }
2472 }
2473 return kTRUE;
2474}
2475
2476////////////////////////////////////////////////////////////////////////////////
2477/// Save a user color in a C++ macro file - used in SavePrimitive().
2478
2479void TGFrame::SaveUserColor(std::ostream &out, Option_t *option)
2480{
2481 // declare a color variable to reflect required user changes
2482 if (!gROOT->ClassSaved(TGFrame::Class()))
2483 out << "\n ULong_t ucolor; // will reflect user color changes\n";
2484
2486 if (option && !strcmp(option, "slider"))
2488 else
2490 if ((ucolor != fgUserColor) || (ucolor == GetWhitePixel())) {
2492 out << " gClient->GetColorByName(\"" << ucolorname << "\", ucolor);\n";
2494 }
2495}
2496
2497////////////////////////////////////////////////////////////////////////////////
2498/// Return options and custom color as constructor args
2499/// Used in the SavePrimitive methods, includes comma "," if any argument is not default
2500
2502{
2504
2505 if (GetBackground() == default_color) {
2506 if (GetOptions() == dflt_options)
2507 return "";
2508 return TString(", ") + GetOptionString();
2509 }
2510
2511 SaveUserColor(out, "");
2512
2513 return TString(", ") + GetOptionString() + ", ucolor";
2514}
2515
2516
2517////////////////////////////////////////////////////////////////////////////////
2518/// Returns a frame option string - used in SavePrimitive().
2519
2521{
2522 TString str;
2523 auto add = [this, &str](Int_t bit, const char *name) {
2524 if (fOptions & bit) {
2525 if (str.Length() > 0)
2526 str.Append(" | ");
2527 str.Append(name);
2528 }
2529 };
2530
2531 if (!GetOptions()) {
2532 str = "kChildFrame";
2533 } else {
2534 add(kMainFrame, "kMainFrame");
2535 add(kVerticalFrame, "kVerticalFrame");
2536 add(kHorizontalFrame, "kHorizontalFrame");
2537 add(kSunkenFrame, "kSunkenFrame");
2538 add(kRaisedFrame, "kRaisedFrame");
2539 add(kDoubleBorder, "kDoubleBorder");
2540 add(kFitWidth, "kFitWidth");
2541 add(kFixedWidth, "kFixedWidth");
2542 add(kFitHeight, "kFitHeight");
2543 add(kFixedHeight, "kFixedHeight");
2544 add(kOwnBackground, "kOwnBackground");
2545 add(kTransientFrame, "kTransientFrame");
2546 add(kTempFrame, "kTempFrame");
2547 }
2548 return str;
2549}
2550
2551////////////////////////////////////////////////////////////////////////////////
2552/// Returns MWM decoration hints as a string - used in SavePrimitive().
2553
2555{
2556 TString hints;
2557
2558 if (fMWMValue) {
2559 if (fMWMValue & kMWMDecorAll) {
2560 if (hints.Length() == 0) hints = "kMWMDecorAll";
2561 else hints += " | kMWMDecorAll";
2562 }
2563 if (fMWMValue & kMWMDecorBorder) {
2564 if (hints.Length() == 0) hints = "kMWMDecorBorder";
2565 else hints += " | kMWMDecorBorder";
2566 }
2568 if (hints.Length() == 0) hints = "kMWMDecorResizeH";
2569 else hints += " | kMWMDecorResizeH";
2570 }
2571 if (fMWMValue & kMWMDecorTitle) {
2572 if (hints.Length() == 0) hints = "kMWMDecorTitle";
2573 else hints += " | kMWMDecorTitle";
2574 }
2575 if (fMWMValue & kMWMDecorMenu) {
2576 if (hints.Length() == 0) hints = "kMWMDecorMenu";
2577 else hints += " | kMWMDecorMenu";
2578 }
2580 if (hints.Length() == 0) hints = "kMWMDecorMinimize";
2581 else hints += " | kMWMDecorMinimize";
2582 }
2584 if (hints.Length() == 0) hints = "kMWMDecorMaximize";
2585 else hints += " | kMWMDecorMaximize";
2586 }
2587 }
2588 return hints;
2589}
2590
2591////////////////////////////////////////////////////////////////////////////////
2592/// Returns MWM function hints as a string - used in SavePrimitive().
2593
2595{
2596 TString hints;
2597
2598 if (fMWMFuncs) {
2599
2600 if (fMWMFuncs & kMWMFuncAll) {
2601 if (hints.Length() == 0) hints = "kMWMFuncAll";
2602 else hints += " | kMWMFuncAll";
2603 }
2604 if (fMWMFuncs & kMWMFuncResize) {
2605 if (hints.Length() == 0) hints = "kMWMFuncResize";
2606 else hints += " | kMWMFuncResize";
2607 }
2608 if (fMWMFuncs & kMWMFuncMove) {
2609 if (hints.Length() == 0) hints = "kMWMFuncMove";
2610 else hints += " | kMWMFuncMove";
2611 }
2613 if (hints.Length() == 0) hints = "kMWMFuncMinimize";
2614 else hints += " | kMWMFuncMinimize";
2615 }
2617 if (hints.Length() == 0) hints = "kMWMFuncMaximize";
2618 else hints += " | kMWMFuncMaximize";
2619 }
2620 if (fMWMFuncs & kMWMFuncClose) {
2621 if (hints.Length() == 0) hints = "kMWMFuncClose";
2622 else hints += " | kMWMFuncClose";
2623 }
2624 }
2625 return hints;
2626}
2627
2628////////////////////////////////////////////////////////////////////////////////
2629/// Returns MWM input mode hints as a string - used in SavePrimitive().
2630
2632{
2633 TString hints;
2634
2635 if (fMWMInput == 0) hints = "kMWMInputModeless";
2636
2637 if (fMWMInput == 1) hints = "kMWMInputPrimaryApplicationModal";
2638
2639 if (fMWMInput == 2) hints = "kMWMInputSystemModal";
2640
2641 if (fMWMInput == 3) hints = "kMWMInputFullApplicationModal";
2642
2643 return hints;
2644}
2645
2646////////////////////////////////////////////////////////////////////////////////
2647/// Auxiliary protected method used to save subframes.
2648
2650{
2651 if (fLayoutBroken)
2652 out << " " << GetName() << "->SetLayoutBroken(kTRUE);\n";
2653
2654 if (!fList)
2655 return;
2656
2657 static TGHSplitter *hsplit = nullptr;
2658 static TGVSplitter *vsplit = nullptr;
2659
2660 TIter next(fList);
2661
2662 while (auto el = static_cast<TGFrameElement *>(next())) {
2663
2664 // Don't save hidden (unmapped) frames having a parent different
2665 // than this frame. Solves a problem with shared frames
2666 // (e.g. shared menus in the new Browser)
2667 if ((!(el->fState & kIsVisible)) && (el->fFrame->GetParent() != this))
2668 continue;
2669
2670 // Remember if the frame to be saved is a TG(H,V)Splitter
2671 // See comments below and in TG[H/V]Splitter::SavePrimitive()
2672 if (el->fFrame->InheritsFrom("TGVSplitter")) {
2673 vsplit = (TGVSplitter *)el->fFrame;
2674 if (vsplit->GetLeft())
2675 vsplit = 0;
2676 } else if (el->fFrame->InheritsFrom("TGHSplitter")) {
2677 hsplit = (TGHSplitter *)el->fFrame;
2678 if (hsplit->GetAbove())
2679 hsplit = 0;
2680 }
2681 el->fFrame->SavePrimitive(out, option);
2682 out << " " << GetName() << "->AddFrame(" << el->fFrame->GetName();
2683 el->fLayout->SavePrimitive(out, option);
2684 out << ");\n";
2685 if (IsLayoutBroken()) {
2686 out << " " << el->fFrame->GetName() << "->MoveResize(" << el->fFrame->GetX() << "," << el->fFrame->GetY()
2687 << "," << el->fFrame->GetWidth() << "," << el->fFrame->GetHeight() << ");\n";
2688 }
2689 // TG(H,V)Splitter->SetFrame(theframe) can only be saved _AFTER_
2690 // having saved "theframe", when "theframe" is either at right
2691 // or below the splitter (that means after the splitter in the
2692 // list of frames), otherwise "theframe" would be undefined
2693 // (aka used before to be created)...
2694 if (vsplit && el->fFrame == vsplit->GetFrame()) {
2695 out << " " << vsplit->GetName() << "->SetFrame(" << vsplit->GetFrame()->GetName();
2696 if (vsplit->GetLeft())
2697 out << ",kTRUE);\n";
2698 else
2699 out << ",kFALSE);\n";
2700 vsplit = nullptr;
2701 }
2702 if (hsplit && el->fFrame == hsplit->GetFrame()) {
2703 out << " " << hsplit->GetName() << "->SetFrame(" << hsplit->GetFrame()->GetName();
2704 if (hsplit->GetAbove())
2705 out << ",kTRUE);\n";
2706 else
2707 out << ",kFALSE);\n";
2708 hsplit = nullptr;
2709 }
2710
2711 if (!(el->fState & kIsVisible)) {
2712 gListOfHiddenFrames->Add(el->fFrame);
2713 }
2714
2715 // saving signals/slots
2716 auto signalslist = el->fFrame->GetListOfSignals();
2717 if (!signalslist)
2718 continue;
2719 auto connlist = static_cast<TList *>(signalslist->Last());
2720 if (connlist) {
2721 auto conn = static_cast<TQConnection *>(connlist->Last());
2722 if (conn) {
2723 TString signal_name = connlist->GetName();
2724 TString slot_name = conn->GetName();
2725 Int_t eq = slot_name.First('=');
2726 Int_t rb = slot_name.First(')');
2727 if (eq != -1)
2728 slot_name.Remove(eq, rb - eq);
2729 if ((signal_name == "ColorSelected(unsigned long)") && el->fFrame->InheritsFrom("TGColorSelect"))
2730 signal_name = "ColorSelected(Pixel_t)";
2731
2732 out << " " << el->fFrame->GetName() << "->Connect(\"" << signal_name << "\", 0, 0, \"" << slot_name
2733 << "\");\n";
2734
2735 TList *lsl = (TList *)gROOT->GetListOfSpecials()->FindObject("ListOfSlots");
2736 if (lsl) {
2737 TObjString *slotel = (TObjString *)lsl->FindObject(slot_name);
2738 if (!slotel)
2739 lsl->Add(new TObjString(slot_name));
2740 }
2741 }
2742 }
2743 }
2744 out << " \n";
2745}
2746
2747////////////////////////////////////////////////////////////////////////////////
2748/// Save a composite frame widget as a C++ statement(s) on output stream out.
2749
2750void TGCompositeFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2751{
2752 if (!strcmp(GetName(), "")) {
2753 SetName(Form("fCompositeframe%d", fgCounter));
2754 fgCounter++;
2755 }
2756
2757 // save options and custom color if not default
2758 auto extra_args = SaveCtorArgs(out);
2759
2760 out << "\n // composite frame\n";
2761 out << " TGCompositeFrame *" << GetName() << " = new TGCompositeFrame(" << fParent->GetName() << "," << GetWidth()
2762 << "," << GetHeight() << extra_args << ");\n";
2763
2764 if (option && strstr(option, "keep_names"))
2765 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
2766
2767 // setting layout manager if it differs from the composite frame type
2768 // coverity[returned_null]
2769 // coverity[dereference]
2771 if (!((GetOptions() & kHorizontalFrame) && lm->InheritsFrom(TGHorizontalLayout::Class())) &&
2772 !((GetOptions() & kVerticalFrame) && lm->InheritsFrom(TGVerticalLayout::Class()))) {
2773 out << " " << GetName() << "->SetLayoutManager(";
2774 lm->SavePrimitive(out, option);
2775 out << ");\n";
2776 }
2777
2779}
2780
2781////////////////////////////////////////////////////////////////////////////////
2782/// Save the GUI main frame widget in a C++ macro file.
2783
2785{
2786 // iteration over all active classes to exclude the base ones
2787 TString opt = option;
2788 TBits bc;
2789 TClass *c1, *c2, *c3;
2790 UInt_t k = 0; // will mark k-bit of TBits if the class is a base class
2791
2792 // Reset the ClassSaved status of all classes
2793 gROOT->ResetClassSaved();
2794
2795 TIter nextc1(gROOT->GetListOfClasses());
2796 //gROOT->GetListOfClasses()->ls(); // valid. test
2797 while((c1 = (TClass *)nextc1())) {
2798
2799 TIter nextc2(gROOT->GetListOfClasses());
2800 while ((c2 = (TClass *)nextc2())) {
2801 if (c1==c2) continue;
2802 else {
2803 c3 = c2->GetBaseClass(c1);
2804 if (c3 != 0) {
2805 bc.SetBitNumber(k, kTRUE);
2806 break;
2807 }
2808 }
2809 }
2810 k++;
2811 }
2812
2813 TList *ilist = new TList(); // will contain include file names without '.h'
2814 ilist->SetName("ListOfIncludes");
2815 gROOT->GetListOfSpecials()->Add(ilist);
2816 k=0;
2817
2818 // completes list of include file names
2819 TIter nextdo(gROOT->GetListOfClasses());
2820 while ((c2 = (TClass *)nextdo())) {
2821 // for used GUI header files
2822 if (bc.TestBitNumber(k) == 0 && c2->InheritsFrom(TGObject::Class()) == 1) {
2823 // for any used ROOT header files activate the line below, comment the line above
2824 //if (bc.TestBitNumber(k) == 0) {
2825 const char *iname;
2826 iname = c2->GetDeclFileName();
2827 if (iname[0] && strstr(iname,".h")) {
2828 const char *lastsl = strrchr(iname,'/');
2829 if (lastsl) iname = lastsl + 1;
2830 char *tname = new char[strlen(iname)+1];
2831 Int_t i=0;
2832 while (*iname != '.') {
2833 tname[i] = *iname;
2834 i++; iname++;
2835 }
2836 tname[i] = 0; //tname = include file name without '.h'
2837
2838 TObjString *iel = (TObjString *)ilist->FindObject(tname);
2839 if (!iel) {
2840 ilist->Add(new TObjString(tname));
2841 }
2842 // Weird, but when saving a canvas, the following two classes
2843 // may be missing if the toolbar has not been displayed...
2844 if (strstr(tname, "TRootCanvas")) {
2845 if (!ilist->FindObject("TGDockableFrame"))
2846 ilist->Add(new TObjString("TGDockableFrame"));
2847 if (!ilist->FindObject("TG3DLine"))
2848 ilist->Add(new TObjString("TG3DLine"));
2849 }
2850 delete [] tname;
2851 }
2852 k++; continue;
2853 }
2854 k++;
2855 }
2856
2857 char quote = '"';
2858 std::ofstream out;
2859
2860 TString ff = filename && strlen(filename) ? filename : "Rootappl.C";
2861
2862 // Computes the main method name.
2863 const char *fname = gSystem->BaseName(ff.Data());
2865 char *sname = new char[lenfname+1];
2866
2867 Int_t i = 0;
2868 while ((*fname != '.') && (i < lenfname)) {
2869 sname[i] = *fname;
2870 i++; fname++;
2871 }
2872 if (i == lenfname)
2873 ff += ".C";
2874 sname[i] = 0;
2875
2876 out.open(ff.Data(), std::ios::out);
2877 if (!out.good()) {
2878 Error("SaveSource", "cannot open file: %s", ff.Data());
2879 delete [] sname;
2880 return;
2881 }
2882
2883 // writes include files in C++ macro
2884 ilist = (TList *)gROOT->GetListOfSpecials()->FindObject("ListOfIncludes");
2885
2886 if (!ilist) {
2887 delete [] sname;
2888 return;
2889 }
2890
2891 // write macro header, date/time stamp as string, and the used Root version
2892 TDatime t;
2893 out <<"// Mainframe macro generated from application: "<< gApplication->Argv(0) << std::endl;
2894 out <<"// By ROOT version "<< gROOT->GetVersion() <<" on "<<t.AsSQLString()<< std::endl;
2895 out << std::endl;
2896
2897 TIter nexti(ilist);
2898 while (auto inc = (TObjString *)nexti()) {
2899 out << "#include \"" << inc->GetString() << ".h\"\n";
2900 if (strstr(inc->GetString(), "TRootEmbeddedCanvas"))
2901 out << "#include \"TCanvas.h\"\n";
2902 }
2903 out << "\n#include \"Riostream.h\"\n\n";
2904 // deletes created ListOfIncludes
2905 gROOT->GetListOfSpecials()->Remove(ilist);
2906 ilist->Delete();
2907 delete ilist;
2908
2909 // writes the macro entry point equal to the fname
2910 out << std::endl;
2911 out << "void " << sname << "()" << std::endl;
2912 out <<"{"<< std::endl;
2913 delete [] sname;
2914
2916
2917 // saving slots
2918 TList *lSlots = new TList;
2919 lSlots->SetName("ListOfSlots");
2920 gROOT->GetListOfSpecials()->Add(lSlots);
2921
2923
2925 out << " " << GetName() << "->SetClassHints(" << quote << fClassName
2926 << quote << "," << quote << fResourceName << quote << ");" << std::endl;
2927 }
2928
2930 if (fMWMValue || fMWMFuncs || fMWMInput) {
2931 out << " " << GetName() << "->SetMWMHints(";
2932 out << GetMWMvalueString() << "," << std::endl;
2933 out << " ";
2934 out << GetMWMfuncString() << "," << std::endl;
2935 out << " ";
2936 out << GetMWMinpString() << ");"<< std::endl;
2937 }
2938
2939/// GetWMPosition(fWMX, fWMY);
2940/// if ((fWMX != -1) || (fWMY != -1)) {
2941/// out <<" "<<GetName()<<"->SetWMPosition("<<fWMX<<","<<fWMY<<");"<<std::endl;
2942/// } // does not work - fixed via Move() below...
2943
2945 if (fWMWidth != UInt_t(-1) || fWMHeight != UInt_t(-1)) {
2946 out <<" "<<GetName()<<"->SetWMSize("<<fWMWidth<<","<<fWMHeight<<");"<<std::endl;
2947 }
2948
2950 if (fWMMinWidth != UInt_t(-1) || fWMMinHeight != UInt_t(-1) ||
2951 fWMMaxWidth != UInt_t(-1) || fWMMaxHeight != UInt_t(-1) ||
2952 fWMWidthInc != UInt_t(-1) || fWMHeightInc != UInt_t(-1)) {
2953 out <<" "<<GetName()<<"->SetWMSizeHints("<<fWMMinWidth<<","<<fWMMinHeight
2954 <<","<<fWMMaxWidth<<","<<fWMMaxHeight
2955 <<","<<fWMWidthInc<<","<<fWMHeightInc <<");"<<std::endl;
2956 }
2957
2958 out << " " <<GetName()<< "->MapSubwindows();" << std::endl;
2959
2961 while (auto fhidden = static_cast<TGFrame *>(nexth())) {
2962 out << " " << fhidden->GetName() << "->UnmapWindow();" << std::endl;
2963 }
2964 out << std::endl;
2966
2968 // coverity[returned_null]
2969 // coverity[dereference]
2971 if (lm->InheritsFrom("TGXYLayout"))
2972 usexy = kTRUE;
2973
2974 if (!usexy)
2975 out << " " <<GetName()<< "->Resize("<< GetName()<< "->GetDefaultSize());" << std::endl;
2976 else
2977 out << " " <<GetName()<< "->Resize("<< GetWidth()<<","<<GetHeight()<<");"<<std::endl;
2978
2979 out << " " <<GetName()<< "->MapWindow();" <<std::endl;
2980
2982 if ((fWMX != -1) || (fWMY != -1)) {
2983 out <<" "<<GetName()<<"->Move("<<fWMX<<","<<fWMY<<");"<<std::endl;
2984 }
2985
2986 // needed in case the frame was resized
2987 // otherwise the frame became bigger showing all hidden widgets (layout algorithm)
2988 if (!usexy) out << " " <<GetName()<< "->Resize("<< GetWidth()<<","<<GetHeight()<<");"<<std::endl;
2989 out << "} " << std::endl;
2990
2991 // writing slots
2992 TList *sl = (TList *)gROOT->GetListOfSpecials()->FindObject("ListOfSlots");
2993 if (sl) {
2994 TIter nextsl(sl);
2996 Int_t pnumber = 1;
2997
2998 while ((slobj = (TObjString*) nextsl())) {
2999 TString s = slobj->GetString();
3000 TString p = "";
3001 Int_t lb, rb, eq;
3002 lb = s.First('(');
3003 rb = s.First(')');
3004 eq = s.First('=');
3005 out << std::endl;
3006
3007 if (rb - lb > 1 && eq == -1) {
3008 p = TString::Format(" par%d", pnumber);
3009 s.Insert(rb, p);
3010 pnumber++;
3011 out << "void " << s << std::endl;
3012 out << "{" << std::endl;
3013 s = slobj->GetString();
3014 s[rb] = ' ';
3015 out << " std::cout << " << quote << "Slot " << s << quote
3016 << " <<" << p << " << " << quote << ")" << quote
3017 << " << std::endl; " << std::endl;
3018 } else {
3019 if (eq != -1) {
3020 s.Remove(eq, rb-eq);
3021 out << "void " << s << std::endl;
3022 out << "{" << std::endl;
3023 out << " std::cout << " << quote << "Slot " << s
3024 << quote << " << std::endl; " << std::endl;
3025 } else {
3026 out << "void " << slobj->GetString() << std::endl;
3027 out << "{" << std::endl;
3028 out << " std::cout << " << quote << "Slot " << slobj->GetString()
3029 << quote << " << std::endl; " << std::endl;
3030 }
3031 }
3032 out << "}" << std::endl;
3033 }
3034 gROOT->GetListOfSpecials()->Remove(sl);
3035 sl->Delete();
3036 delete sl;
3037 }
3038 out.close();
3039
3040 if (!opt.Contains("quiet"))
3041 printf(" C++ macro file %s has been generated\n", gSystem->BaseName(ff.Data()));
3042
3043 // Reset the ClassSaved status of all classes
3044 gROOT->ResetClassSaved();
3045}
3046
3047////////////////////////////////////////////////////////////////////////////////
3048/// Save a main frame widget as a C++ statement(s) on output stream out.
3049
3050void TGMainFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
3051{
3052 if (fParent != gClient->GetDefaultRoot()) { // frame is embedded
3056 return;
3057 }
3058
3059 out << "\n // main frame\n";
3060 out << " TGMainFrame *" << GetName() << " = new TGMainFrame(gClient->GetRoot(), 5, 5, " // layout alg.
3061 << GetOptionString() << ");\n";
3062 if (option && strstr(option, "keep_names"))
3063 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
3064
3065 // setting layout manager if it differs from the main frame type
3066 // coverity[returned_null]
3067 // coverity[dereference]
3069 if (!((GetOptions() & kHorizontalFrame) && lm->InheritsFrom(TGHorizontalLayout::Class())) &&
3070 !((GetOptions() & kVerticalFrame) && lm->InheritsFrom(TGVerticalLayout::Class()))) {
3071 out << " " << GetName() << "->SetLayoutManager(";
3072 lm->SavePrimitive(out, option);
3073 out << ");\n";
3074 }
3075
3077
3078 if (fWindowName.Length())
3079 out << " " << GetName() << "->SetWindowName(\"" << TString(GetWindowName()).ReplaceSpecialCppChars()
3080 << "\");\n";
3081 if (fIconName.Length())
3082 out << " " << GetName() << "->SetIconName(\"" << TString(GetIconName()).ReplaceSpecialCppChars() << "\");\n";
3083 if (fIconPixmap.Length())
3084 out << " " << GetName() << "->SetIconPixmap(\"" << TString(GetIconPixmap()).ReplaceSpecialCppChars() << "\");\n";
3085
3086 out << " " << GetName() << "->MapSubwindows();\n";
3087 out << " " << GetName() << "->Resize({" << GetDefaultWidth() << ", " << GetDefaultHeight() << "});\n";
3088 out << " " << GetName() << "->MapWindow();\n";
3089}
3090
3091////////////////////////////////////////////////////////////////////////////////
3092/// Save a horizontal frame widget as a C++ statement(s) on output stream out.
3093
3094void TGHorizontalFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
3095{
3096 // save options and custom color if not default
3097 auto extra_args = SaveCtorArgs(out);
3098
3099 out << "\n // horizontal frame\n";
3100 out << " TGHorizontalFrame *" << GetName() << " = new TGHorizontalFrame(" << fParent->GetName() << ","
3101 << GetWidth() << "," << GetHeight() << extra_args << ");\n";
3102
3103 if (option && strstr(option, "keep_names"))
3104 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
3105
3106 // setting layout manager if it differs from the main frame type
3107 // coverity[returned_null]
3108 // coverity[dereference]
3110 if (!((GetOptions() & kHorizontalFrame) && lm->InheritsFrom(TGHorizontalLayout::Class())) &&
3111 !((GetOptions() & kVerticalFrame) && lm->InheritsFrom(TGVerticalLayout::Class()))) {
3112 out << " " << GetName() << "->SetLayoutManager(";
3113 lm->SavePrimitive(out, option);
3114 out << ");\n";
3115 }
3116
3118}
3119
3120////////////////////////////////////////////////////////////////////////////////
3121/// Save a vertical frame widget as a C++ statement(s) on output stream out.
3122
3123void TGVerticalFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
3124{
3125 // save options and custom color if not default
3126 auto extra_args = SaveCtorArgs(out);
3127
3128 out << "\n // vertical frame\n";
3129 out << " TGVerticalFrame *" << GetName() << " = new TGVerticalFrame(" << fParent->GetName() << "," << GetWidth()
3130 << "," << GetHeight() << extra_args << ");\n";
3131
3132 if (option && strstr(option, "keep_names"))
3133 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
3134
3135 // setting layout manager if it differs from the main frame type
3136 // coverity[returned_null]
3137 // coverity[dereference]
3139 if (!((GetOptions() & kHorizontalFrame) && lm->InheritsFrom(TGHorizontalLayout::Class())) &&
3140 !((GetOptions() & kVerticalFrame) && lm->InheritsFrom(TGVerticalLayout::Class()))) {
3141 out << " " << GetName() << "->SetLayoutManager(";
3142 lm->SavePrimitive(out, option);
3143 out << ");\n";
3144 }
3145
3147}
3148
3149////////////////////////////////////////////////////////////////////////////////
3150/// Save a frame widget as a C++ statement(s) on output stream out.
3151
3152void TGFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
3153{
3154 // save options and custom color if not default
3155 auto extra_args = SaveCtorArgs(out);
3156
3157 out << " TGFrame *" << GetName() << " = new TGFrame("<< fParent->GetName()
3158 << "," << GetWidth() << "," << GetHeight() << extra_args << ");\n";
3159
3160 if (option && strstr(option, "keep_names"))
3161 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
3162}
3163
3164////////////////////////////////////////////////////////////////////////////////
3165/// Save a group frame widget as a C++ statement(s) on output stream out.
3166
3167void TGGroupFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
3168{
3169 // font + GC
3170 option = GetName() + 5; // unique digit id of the name
3172 // coverity[returned_null]
3173 // coverity[dereference]
3174 parFont.Form("%s::GetDefaultFontStruct()", IsA()->GetName());
3175 // coverity[returned_null]
3176 // coverity[dereference]
3177 parGC.Form("%s::GetDefaultGC()()", IsA()->GetName());
3178
3179 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
3180 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
3181 if (ufont) {
3182 ufont->SavePrimitive(out, option);
3183 parFont.Form("ufont->GetFontStruct()");
3184 }
3185
3186 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
3187 if (userGC) {
3188 userGC->SavePrimitive(out, option);
3189 parGC.Form("uGC->GetGC()");
3190 }
3191 }
3192
3194 SaveUserColor(out, option);
3195
3196 out << "\n // \"" << GetTitle() << "\" group frame\n";
3197 out << " TGGroupFrame *" << GetName() << " = new TGGroupFrame(" << fParent->GetName() << ", \""
3198 << TString(GetTitle()).ReplaceSpecialCppChars() << "\"";
3199
3202 if (fNormGC == GetDefaultGC()()) {
3203 if (GetOptions() & kVerticalFrame) {
3204 out << ");\n";
3205 } else {
3206 out << "," << GetOptionString() << ");\n";
3207 }
3208 } else {
3209 out << "," << GetOptionString() << "," << parGC << ");\n";
3210 }
3211 } else {
3212 out << "," << GetOptionString() << "," << parGC << "," << parFont << ");\n";
3213 }
3214 } else {
3215 out << "," << GetOptionString() << "," << parGC << "," << parFont << ", ucolor);\n";
3216 }
3217 if (option && strstr(option, "keep_names"))
3218 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
3219
3220 if (GetTitlePos() != -1)
3221 out << " " << GetName() << "->SetTitlePos(TGGroupFrame::" << (GetTitlePos() == 0 ? "kCenter" : "kRight")
3222 << ");\n";
3223
3225
3226 // setting layout manager
3227 out << " " << GetName() << "->SetLayoutManager(";
3228 // coverity[returned_null]
3229 // coverity[dereference]
3230 GetLayoutManager()->SavePrimitive(out, option);
3231 out << ");\n";
3232
3233 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetHeight() << ");\n";
3234}
3235
3236////////////////////////////////////////////////////////////////////////////////
3237/// Save the GUI transient frame widget in a C++ macro file.
3238
3240{
3241 // iterate over all active classes to exclude the base ones
3242
3243 TString opt = option;
3244 TBits bc;
3245 TClass *c1, *c2, *c3;
3246 UInt_t k = 0; // will mark k-bit of TBits if the class is a base class
3247
3248 // Reset the ClassSaved status of all classes
3249 gROOT->ResetClassSaved();
3250
3251 TIter nextc1(gROOT->GetListOfClasses());
3252 while((c1 = (TClass *)nextc1())) {
3253
3254 TIter nextc2(gROOT->GetListOfClasses());
3255 while ((c2 = (TClass *)nextc2())) {
3256 if (c1==c2) continue;
3257 else {
3258 c3 = c2->GetBaseClass(c1);
3259 if (c3 != 0) {
3260 bc.SetBitNumber(k, kTRUE);
3261 break;
3262 }
3263 }
3264 }
3265 k++;
3266 }
3267
3268 TList *ilist = new TList(); // will contain include file names without '.h'
3269 ilist->SetName("ListOfIncludes");
3270 gROOT->GetListOfSpecials()->Add(ilist);
3271 k=0;
3272
3273 // completes list of include file names
3274 TIter nextdo(gROOT->GetListOfClasses());
3275 while ((c2 = (TClass *)nextdo())) {
3276 // to have only used GUI header files
3277 if (bc.TestBitNumber(k) == 0 && c2->InheritsFrom(TGObject::Class()) == 1) {
3278 // for any used ROOT header files activate the line below, comment the line above
3279 //if (bc.TestBitNumber(k) == 0) {
3280 const char *iname;
3281 iname = c2->GetDeclFileName();
3282 if (iname[0] && strstr(iname,".h")) {
3283 const char *lastsl = strrchr(iname,'/');
3284 if (lastsl) iname = lastsl + 1;
3285 char *tname = new char[strlen(iname)+1];
3286 Int_t i=0;
3287 while (*iname != '.') {
3288 tname[i] = *iname;
3289 i++; iname++;
3290 }
3291 tname[i] = 0; //tname = include file name without '.h'
3292
3293 TObjString *iel = (TObjString *)ilist->FindObject(tname);
3294 if (!iel) {
3295 ilist->Add(new TObjString(tname));
3296 }
3297 delete [] tname;
3298 }
3299 k++; continue;
3300 }
3301 k++;
3302 }
3303
3304 char quote = '"';
3305 std::ofstream out;
3306
3307 TString ff = filename && strlen(filename) ? filename : "Rootdlog.C";
3308
3309 // Computes the main method name.
3310 const char *fname = gSystem->BaseName(ff.Data());
3312 char *sname = new char[lenfname+1];
3313
3314 Int_t i = 0;
3315 while ((*fname != '.') && (i < lenfname)) {
3316 sname[i] = *fname;
3317 i++; fname++;
3318 }
3319 if (i == lenfname)
3320 ff += ".C";
3321 sname[i] = 0;
3322
3323 out.open(ff.Data(), std::ios::out);
3324 if (!out.good()) {
3325 Error("SaveSource", "cannot open file: %s", ff.Data());
3326 delete [] sname;
3327 return;
3328 }
3329
3330 // writes include files in C++ macro
3331 ilist = (TList *)gROOT->GetListOfSpecials()->FindObject("ListOfIncludes");
3332
3333 if (!ilist) {
3334 delete [] sname;
3335 return;
3336 }
3337
3338 // write macro header, date/time stamp as string, and the used Root version
3339 TDatime t;
3340 out <<"// Dialog macro generated from application: "<< gApplication->Argv(0) << std::endl;
3341 out <<"// By ROOT version "<< gROOT->GetVersion() <<" on "<<t.AsSQLString()<< std::endl;
3342 out << std::endl;
3343
3344 out << std::endl << std::endl;
3345
3346 TIter nexti(ilist);
3347 while(auto inc = (TObjString *)nexti()) {
3348 out << "#include \"" << inc->GetString() << ".h\"\n";
3349 if (strstr(inc->GetString(), "TRootEmbeddedCanvas"))
3350 out << "#include \"TCanvas.h\"\n";
3351 }
3352 out << "\n#include \"Riostream.h\"\n\n";
3353 // deletes created ListOfIncludes
3354 gROOT->GetListOfSpecials()->Remove(ilist);
3355 ilist->Delete();
3356 delete ilist;
3357
3358 // writes the macro entry point equal to the fname
3359 out << std::endl;
3360 out << "void " << sname << "()" << std::endl;
3361 delete [] sname;
3362
3363 // Save GUI widgets as a C++ macro in a file
3364 out <<"{"<< std::endl;
3365
3367
3368 // saving slots
3369 TList *lSlots = new TList;
3370 lSlots->SetName("ListOfSlots");
3371 gROOT->GetListOfSpecials()->Add(lSlots);
3372
3374
3376 out<<" "<<GetName()<< "->SetClassHints("<<quote<<fClassName<<quote
3377 <<"," <<quote<<fResourceName<<quote
3378 <<");"<<std::endl;
3379 }
3380
3382 if (fMWMValue || fMWMFuncs || fMWMInput) {
3383 out << " " << GetName() << "->SetMWMHints(";
3384 out << GetMWMvalueString() << "," << std::endl;
3385 out << " ";
3386 out << GetMWMfuncString() << "," << std::endl;
3387 out << " ";
3388 out << GetMWMinpString() << ");"<< std::endl;
3389 }
3390
3392 if ((fWMX != -1) || (fWMY != -1)) {
3393 out <<" "<<GetName()<<"->SetWMPosition("<<fWMX<<","<<fWMY<<");"<<std::endl;
3394 }
3395
3397 if (fWMWidth != UInt_t(-1) || fWMHeight != UInt_t(-1)) {
3398 out <<" "<<GetName()<<"->SetWMSize("<<fWMWidth<<","<<fWMHeight<<");"<<std::endl;
3399 }
3400
3402 if (fWMMinWidth != UInt_t(-1) || fWMMinHeight != UInt_t(-1) ||
3403 fWMMaxWidth != UInt_t(-1) || fWMMaxHeight != UInt_t(-1) ||
3404 fWMWidthInc != UInt_t(-1) || fWMHeightInc != UInt_t(-1)) {
3405
3406 out <<" "<<GetName()<<"->SetWMSizeHints("<<fWMMinWidth<<","<<fWMMinHeight
3407 <<","<<fWMMaxWidth<<","<<fWMMaxHeight <<","<<fWMWidthInc<<","<<fWMHeightInc
3408 <<");"<<std::endl;
3409 }
3410
3412 if ((fWMX != -1) || (fWMY != -1)) {
3413 out <<" "<<GetName()<<"->Move("<<fWMX<<","<<fWMY<<");"<<std::endl;
3414 }
3415
3416 out << " " <<GetName()<< "->MapSubwindows();" << std::endl;
3417
3419 while (auto fhidden = static_cast<TGFrame *>(nexth()))
3420 out << " " << fhidden->GetName() << "->UnmapWindow();" << std::endl;
3421 out << std::endl;
3423
3425 // coverity[returned_null]
3426 // coverity[dereference]
3428 if (lm->InheritsFrom("TGXYLayout"))
3429 usexy = kTRUE;
3430
3431 if (!usexy)
3432 out << " " <<GetName()<< "->Resize("<< GetName()<< "->GetDefaultSize());" << std::endl;
3433 else
3434 out << " " <<GetName()<< "->Resize("<< GetWidth()<<","<<GetHeight()<<");"<<std::endl;
3435
3436 out << " " <<GetName()<< "->MapWindow();" <<std::endl;
3437 if (!usexy) out << " " <<GetName()<< "->Resize();" << std::endl;
3438 out << "} " << std::endl;
3439
3440 // writing slots
3441 TList *sl = (TList *)gROOT->GetListOfSpecials()->FindObject("ListOfSlots");
3442 if (sl) {
3443 TIter nextsl(sl);
3445 Int_t pnumber = 1;
3446
3447 while ((slobj = (TObjString*) nextsl())) {
3448 TString s = slobj->GetString();
3449 TString p = "";
3450 Int_t lb, rb, eq;
3451 lb = s.First('(');
3452 rb = s.First(')');
3453 eq = s.First('=');
3454 out << std::endl;
3455
3456 if (rb - lb > 1 && eq == -1) {
3457 p = TString::Format(" par%d", pnumber);
3458 s.Insert(rb, p);
3459 pnumber++;
3460 out << "void " << s << std::endl;
3461 out << "{" << std::endl;
3462 s = slobj->GetString();
3463 s[rb] = ' ';
3464 out << " std::cout << " << quote << "Slot " << s << quote
3465 << " <<" << p << " << " << quote << ")" << quote
3466 << " << std::endl; " << std::endl;
3467 } else {
3468 if (eq != -1) {
3469 s.Remove(eq, rb-eq);
3470 out << "void " << s << std::endl;
3471 out << "{" << std::endl;
3472 out << " std::cout << " << quote << "Slot " << s
3473 << quote << " << std::endl; " << std::endl;
3474 } else {
3475 out << "void " << slobj->GetString() << std::endl;
3476 out << "{" << std::endl;
3477 out << " std::cout << " << quote << "Slot " << slobj->GetString()
3478 << quote << " << std::endl; " << std::endl;
3479 }
3480 }
3481 out << "}" << std::endl;
3482 }
3483 gROOT->GetListOfSpecials()->Remove(sl);
3484 sl->Delete();
3485 delete sl;
3486 }
3487
3488 out.close();
3489
3490 if (!opt.Contains("quiet"))
3491 printf(" C++ macro file %s has been generated\n", gSystem->BaseName(ff.Data()));
3492
3493 // Reset the ClassSaved status of all classes
3494 gROOT->ResetClassSaved();
3495}
3496
3497////////////////////////////////////////////////////////////////////////////////
3498/// Save a transient frame widget as a C++ statement(s) on output stream out.
3499
3500void TGTransientFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
3501{
3502 out << "\n // transient frame\n";
3503 out << " TGTransientFrame *" << GetName() << " = new TGTransientFrame(gClient->GetRoot(),0"
3504 << "," << GetWidth() << "," << GetHeight() << "," << GetOptionString() << ");\n";
3505
3506 if (option && strstr(option, "keep_names"))
3507 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
3508
3509 // setting layout manager if it differs from transient frame type
3510 // coverity[returned_null]
3511 // coverity[dereference]
3513 if (!((GetOptions() & kHorizontalFrame) && lm->InheritsFrom(TGHorizontalLayout::Class())) &&
3514 !((GetOptions() & kVerticalFrame) && lm->InheritsFrom(TGVerticalLayout::Class()))) {
3515 out << " " << GetName() << "->SetLayoutManager(";
3516 lm->SavePrimitive(out, option);
3517 out << ");\n";
3518 }
3519
3521
3522 if (fWindowName.Length())
3523 out << " " << GetName() << "->SetWindowName(\"" << TString(GetWindowName()).ReplaceSpecialCppChars()
3524 << "\");\n";
3525 if (fIconName.Length())
3526 out << " " << GetName() << "->SetIconName(\"" << TString(GetIconName()).ReplaceSpecialCppChars() << "\");\n";
3527 if (fIconPixmap.Length())
3528 out << " " << GetName() << "->SetIconPixmap(\"" << TString(GetIconPixmap()).ReplaceSpecialCppChars()
3529 << "\");\n";
3530}
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
@ kSelectionClear
Definition GuiTypes.h:63
@ kColormapNotify
Definition GuiTypes.h:64
@ kConfigureNotify
Definition GuiTypes.h:62
@ kGKeyPress
Definition GuiTypes.h:60
@ kExpose
Definition GuiTypes.h:62
@ kButtonRelease
Definition GuiTypes.h:60
@ kSelectionNotify
Definition GuiTypes.h:63
@ kButtonPress
Definition GuiTypes.h:60
@ kButtonDoubleClick
Definition GuiTypes.h:64
@ kFocusOut
Definition GuiTypes.h:61
@ kMotionNotify
Definition GuiTypes.h:61
@ kFocusIn
Definition GuiTypes.h:61
@ kClientMessage
Definition GuiTypes.h:63
@ kEnterNotify
Definition GuiTypes.h:61
@ kSelectionRequest
Definition GuiTypes.h:63
@ kKeyRelease
Definition GuiTypes.h:60
@ kLeaveNotify
Definition GuiTypes.h:61
@ kArrowHor
Definition GuiTypes.h:374
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index)
Definition GuiTypes.h:35
const Mask_t kExposureMask
Definition GuiTypes.h:165
const Mask_t kWAEventMask
Definition GuiTypes.h:151
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kWABackPixel
Definition GuiTypes.h:140
const Mask_t kAnyModifier
Definition GuiTypes.h:210
ULong_t Time_t
Event time.
Definition GuiTypes.h:42
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
EInitialState
Initial window mapping state.
Definition GuiTypes.h:345
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
@ kFitHeight
Definition GuiTypes.h:388
@ kRaisedFrame
Definition GuiTypes.h:384
@ kTempFrame
Definition GuiTypes.h:393
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kFitWidth
Definition GuiTypes.h:386
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kFixedHeight
Definition GuiTypes.h:389
@ kOwnBackground
Definition GuiTypes.h:391
@ kTransientFrame
Definition GuiTypes.h:392
@ kMainFrame
Definition GuiTypes.h:380
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kKeyControlMask
Definition GuiTypes.h:197
const Mask_t kKeyMod2Mask
typically mod on numeric keys
Definition GuiTypes.h:199
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:166
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kAnyButton
Definition GuiTypes.h:214
ULongptr_t Handle_t
Generic resource handle.
Definition GuiTypes.h:26
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
@ kKey_S
Definition KeySymbols.h:144
@ kKey_s
Definition KeySymbols.h:176
int main()
Definition Prototype.cxx:12
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:75
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr UInt_t kMaxUInt
Definition RtypesCore.h:104
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
constexpr Int_t kFatal
Definition TError.h:50
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
Int_t gErrorIgnoreLevel
Error handling routines.
Definition TError.cxx:31
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
#define gClient
Definition TGClient.h:157
R__EXTERN TGDNDManager * gDNDManager
@ kFDSave
TList * gListOfHiddenFrames
Definition TGFrame.cxx:145
static const char * gSaveMacroTypes[]
Definition TGFrame.cxx:134
@ kMWMDecorResizeH
Definition TGFrame.h:65
@ kMWMFuncAll
Definition TGFrame.h:49
@ kMWMFuncMove
Definition TGFrame.h:51
@ kMWMDecorBorder
Definition TGFrame.h:64
@ kMWMFuncResize
Definition TGFrame.h:50
@ kMWMDecorMaximize
Definition TGFrame.h:69
@ kMWMDecorTitle
Definition TGFrame.h:66
@ kMWMDecorMinimize
Definition TGFrame.h:68
@ kMWMDecorMenu
Definition TGFrame.h:67
@ kMWMDecorAll
Definition TGFrame.h:63
@ kMWMFuncMaximize
Definition TGFrame.h:53
@ kMWMInputModeless
Definition TGFrame.h:57
@ kMWMFuncClose
Definition TGFrame.h:54
@ kMWMFuncMinimize
Definition TGFrame.h:52
@ kNoCleanup
Definition TGFrame.h:40
@ kDeepCleanup
Definition TGFrame.h:42
@ kIsArranged
Definition TGFrame.h:35
@ kIsVisible
Definition TGFrame.h:33
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsExpandX
Definition TGLayout.h:30
@ kMBRetry
Definition TGMsgBox.h:35
@ kMBCancel
Definition TGMsgBox.h:37
@ kMBIconExclamation
Definition TGMsgBox.h:24
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t hmin
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t hmax
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t wmin
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t SetTextFont
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void funcs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetWMPosition
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t winc
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t modifier
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t wmax
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t hinc
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
R__EXTERN TGuiBuilder * gGuiBuilder
Definition TGuiBuilder.h:66
#define gROOT
Definition TROOT.h:414
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
R__EXTERN TVirtualDragManager * gDragManager
#define gVirtualX
Definition TVirtualX.h:337
R__EXTERN Atom_t gROOT_MESSAGE
Definition TVirtualX.h:40
R__EXTERN Atom_t gWM_DELETE_WINDOW
Definition TVirtualX.h:38
char ** Argv() const
Container of bits.
Definition TBits.h:26
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static ULong_t RGB2Pixel(Int_t r, Int_t g, Int_t b)
Convert r,g,b to graphics system dependent pixel value.
Definition TColor.cxx:2484
static void Pixel2RGB(ULong_t pixel, Int_t &r, Int_t &g, Int_t &b)
Convert machine dependent pixel value (obtained via RGB2Pixel or via Number2Pixel() or via TColor::Ge...
Definition TColor.cxx:2522
static const char * PixelAsHexString(ULong_t pixel)
Convert machine dependent pixel value (obtained via RGB2Pixel or via Number2Pixel() or via TColor::Ge...
Definition TColor.cxx:2543
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
const char * AsSQLString() const
Return the date & time in SQL compatible string format, like: 1997-01-15 20:16:28.
Definition TDatime.cxx:152
Bool_t HandleButton(Event_t *event) override
Handle mouse button event.
Definition TGButton.cxx:330
Window client.
Definition TGClient.h:37
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:234
Bool_t IsEditable() const
Definition TGClient.h:89
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:224
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:357
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
UInt_t GetDisplayHeight() const
Get display height.
Definition TGClient.cxx:275
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
TGGCPool * GetGCPool() const
Definition TGClient.h:132
void SetRoot(TGWindow *root=nullptr)
Sets the current root (i.e.
Definition TGClient.cxx:244
Bool_t IsEditDisabled() const
Returns kTRUE if edit/guibuilding is forbidden.
Definition TGClient.cxx:944
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:381
UInt_t GetDisplayWidth() const
Get display width.
Definition TGClient.cxx:262
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
Bool_t HandleDragDrop(TGFrame *frame, Int_t x, Int_t y, TGLayoutHints *lo) override
Handle drop event.
Definition TGFrame.cxx:1421
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
~TGCompositeFrame() override
Delete a composite frame.
Definition TGFrame.cxx:904
virtual TGFrameElement * FindFrameElement(TGFrame *f) const
Find frame-element holding frame f.
Definition TGFrame.cxx:1094
TGLayoutManager * fLayoutManager
layout manager
Definition TGFrame.h:293
virtual void ChangeSubframesBackground(Pixel_t back)
Change background color for this frame and all subframes.
Definition TGFrame.cxx:1288
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition TGFrame.cxx:1000
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
UInt_t GetDefaultWidth() const override
Definition TGFrame.h:314
TGFrame * GetFrameFromPoint(Int_t x, Int_t y) override
Get frame located at specified point.
Definition TGFrame.cxx:1308
Int_t GetState(TGFrame *f) const
Get state of sub frame.
Definition TGFrame.cxx:1218
void Print(Option_t *option="") const override
Print all frames in this composite frame.
Definition TGFrame.cxx:1266
Bool_t HandleDragMotion(TGFrame *) override
Handle drag motion event.
Definition TGFrame.cxx:1413
virtual TGLayoutManager * GetLayoutManager() const
Definition TGFrame.h:340
Bool_t HandleSelection(Event_t *) override
Definition TGFrame.h:332
Bool_t HandleDragEnter(TGFrame *) override
Handle drag enter event.
Definition TGFrame.cxx:1365
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
Bool_t HandleDragLeave(TGFrame *) override
Handle drag leave event.
Definition TGFrame.cxx:1395
Int_t fMustCleanup
cleanup mode (see EFrameCleanup)
Definition TGFrame.h:296
virtual void SavePrimitiveSubframes(std::ostream &out, Option_t *option="")
Auxiliary protected method used to save subframes.
Definition TGFrame.cxx:2649
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:316
TGCompositeFrame(const TGCompositeFrame &)=delete
virtual Bool_t TranslateCoordinates(TGFrame *child, Int_t x, Int_t y, Int_t &fx, Int_t &fy)
Translate coordinates to child frame.
Definition TGFrame.cxx:1332
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1257
Bool_t HandleMotion(Event_t *) override
Definition TGFrame.h:329
Bool_t fLayoutBroken
no layout manager is used
Definition TGFrame.h:295
Bool_t fMapSubwindows
kTRUE - map subwindows
Definition TGFrame.h:297
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1204
TList * fList
container of frame elements
Definition TGFrame.h:294
Bool_t IsEditable() const override
Return kTRUE if frame is being edited.
Definition TGFrame.cxx:927
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1072
Bool_t IsLayoutBroken() const override
Definition TGFrame.h:359
Bool_t HandleButton(Event_t *) override
Definition TGFrame.h:326
Bool_t IsArranged(TGFrame *f) const
Get state of sub frame.
Definition TGFrame.cxx:1244
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1149
void SetEditable(Bool_t on=kTRUE) override
Switch ON/OFF edit mode.
Definition TGFrame.cxx:948
static TGLayoutHints * fgDefaultHints
Definition TGFrame.h:299
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a composite frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:2750
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1022
virtual void RemoveAll()
Remove all frames from composite frame.
Definition TGFrame.cxx:1131
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1043
static TClass * Class()
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1190
Bool_t IsVisible(TGFrame *f) const
Get state of sub frame.
Definition TGFrame.cxx:1231
void SetLayoutBroken(Bool_t on=kTRUE) override
Set broken layout. No Layout method is called.
Definition TGFrame.cxx:1012
Bool_t HandleSelectionRequest(Event_t *event)
Handle selection request event.
Bool_t HandleClientMessage(Event_t *event)
Handle DND related client messages.
Bool_t HandleSelection(Event_t *event)
Handle selection event.
Bool_t IsDragging() const
void SetMainFrame(TGFrame *main)
static Atom_t GetDNDSelection()
Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp)
Process drag event.
Bool_t Drop()
Drop.
TGFrame * GetMainFrame() const
static Atom_t GetDNDActionCopy()
UInt_t fHeight
Definition TGDimension.h:21
UInt_t fWidth
Definition TGDimension.h:20
This class creates a file selection dialog.
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
FontStruct_t GetFontStruct() const
Definition TGFont.h:184
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:321
virtual Bool_t HandleSelectionClear(Event_t *)
Definition TGFrame.h:172
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.cxx:584
static Pixel_t GetDefaultSelectedBackground()
Get default selected frame background.
Definition TGFrame.cxx:696
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:339
static const TGGC * fgWhiteGC
Definition TGFrame.h:106
virtual Int_t GetDragType() const
Returns drag source type.
Definition TGFrame.cxx:824
~TGFrame() override
Destructor.
Definition TGFrame.cxx:266
virtual void StartGuiBuilding(Bool_t on=kTRUE)
Go into GUI building mode.
Definition TGFrame.cxx:841
Bool_t IsEditable() const override
Definition TGFrame.h:215
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:629
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:735
static Pixel_t GetBlackPixel()
Get black pixel value.
Definition TGFrame.cxx:722
UInt_t fOptions
frame options
Definition TGFrame.h:94
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition TGFrame.cxx:443
Int_t fX
frame x position
Definition TGFrame.h:85
virtual Bool_t HandleDoubleClick(Event_t *)
Definition TGFrame.h:164
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
UInt_t fMinHeight
minimal frame height
Definition TGFrame.h:90
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
Definition TGFrame.cxx:348
static Bool_t fgInit
Definition TGFrame.h:100
virtual Bool_t HandleKey(Event_t *)
Definition TGFrame.h:167
TGFrame(const TGFrame &)=delete
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:709
UInt_t fHeight
frame height
Definition TGFrame.h:88
static Int_t fgDby
Definition TGFrame.h:112
virtual Bool_t HandleColormapChange(Event_t *)
Definition TGFrame.h:173
virtual void SetDropType(Int_t type)
SetDropType.
Definition TGFrame.cxx:816
virtual void SetDragType(Int_t type)
SetDragType.
Definition TGFrame.cxx:809
void ReparentWindow(const TGWindow *p, Int_t x=0, Int_t y=0) override
Reparent window, make p the new parent and position the window at position (x,y) in new parent.
Definition TGFrame.h:204
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:3152
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:421
static const TGGC * fgBckgndGC
Definition TGFrame.h:109
virtual Bool_t ProcessMessage(Longptr_t, Longptr_t, Longptr_t)
Definition TGFrame.h:185
virtual void Draw3dRectangle(UInt_t type, Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw 3D rectangle on the frame border.
Definition TGFrame.cxx:357
Int_t fBorderWidth
frame border width
Definition TGFrame.h:93
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:312
static const TGGC * fgShadowGC
Definition TGFrame.h:108
Bool_t HandleEvent(Event_t *event) override
Handle all frame events.
Definition TGFrame.cxx:457
static Pixel_t fgDefaultSelectedBackground
Definition TGFrame.h:102
UInt_t fMinWidth
minimal frame width
Definition TGFrame.h:89
void DoRedraw() override
Redraw the frame.
Definition TGFrame.cxx:430
void MapWindow() override
map window
Definition TGFrame.h:206
@ kDeleteWindowCalled
Definition TGFrame.h:83
virtual Pixel_t GetForeground() const
Return frame foreground color.
Definition TGFrame.cxx:303
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:755
static UInt_t fgLastButton
Definition TGFrame.h:111
TGFrameElement * fFE
pointer to frame element
Definition TGFrame.h:98
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
virtual Int_t GetDropType() const
Returns drop target type.
Definition TGFrame.cxx:833
Int_t fDNDState
EDNDFlags.
Definition TGFrame.h:97
static Time_t GetLastClick()
Get time of last mouse click.
Definition TGFrame.cxx:785
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:593
TClass * IsA() const override
Definition TGFrame.h:285
static const TGGC * fgBlackGC
Definition TGFrame.h:105
Int_t GetX() const
Definition TGFrame.h:233
static Int_t fgDbx
Definition TGFrame.h:112
static UInt_t fgUserColor
Definition TGFrame.h:114
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:276
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2520
static Time_t fgLastClick
Definition TGFrame.h:110
Int_t fY
frame y position
Definition TGFrame.h:86
virtual Bool_t HandleFocusChange(Event_t *)
Definition TGFrame.h:168
virtual void ChangeBackground(Pixel_t back)
Change frame background color.
Definition TGFrame.cxx:293
UInt_t fMaxWidth
maximal frame width
Definition TGFrame.h:91
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:645
virtual void ProcessedConfigure(Event_t *event)
Definition TGFrame.h:179
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:765
virtual Bool_t HandleSelectionRequest(Event_t *)
Definition TGFrame.h:171
virtual Bool_t HandleSelection(Event_t *)
Definition TGFrame.h:170
void Print(Option_t *option="") const override
Print window id.
Definition TGFrame.cxx:793
UInt_t fWidth
frame width
Definition TGFrame.h:87
virtual Bool_t HandleButton(Event_t *)
Definition TGFrame.h:163
virtual Bool_t HandleMotion(Event_t *)
Definition TGFrame.h:166
UInt_t GetHeight() const
Definition TGFrame.h:227
virtual Bool_t HandleClientMessage(Event_t *event)
Handle a client message.
Definition TGFrame.cxx:669
TString SaveCtorArgs(std::ostream &out, UInt_t dflt_options=kChildFrame, Bool_t check_white_pixel=kFALSE)
Return options and custom color as constructor args Used in the SavePrimitive methods,...
Definition TGFrame.cxx:2501
virtual void Layout()
Definition TGFrame.h:201
virtual Pixel_t GetBackground() const
Definition TGFrame.h:194
UInt_t fEventMask
currently active event mask
Definition TGFrame.h:96
UInt_t fMaxHeight
maximal frame height
Definition TGFrame.h:92
virtual Bool_t HandleCrossing(Event_t *)
Definition TGFrame.h:165
virtual void ProcessedEvent(Event_t *event)
Definition TGFrame.h:181
static Window_t fgDbw
Definition TGFrame.h:113
Bool_t Contains(Int_t x, Int_t y) const
Definition TGFrame.h:240
static const TGGC & GetWhiteGC()
Get white graphics context.
Definition TGFrame.cxx:745
static Pixel_t fgWhitePixel
Definition TGFrame.h:103
UInt_t GetWidth() const
Definition TGFrame.h:226
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition TGFrame.cxx:2479
static TClass * Class()
Pixel_t fBackground
frame background color
Definition TGFrame.h:95
static Pixel_t fgBlackPixel
Definition TGFrame.h:104
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:775
static const TGGC * fgHilightGC
Definition TGFrame.h:107
static Pixel_t fgDefaultFrameBackground
Definition TGFrame.h:101
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
A composite frame with a border and a title.
Definition TGFrame.h:524
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a group frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:3167
static TClass * Class()
TGString * fText
title text
Definition TGFrame.h:527
Bool_t fHasOwnFont
kTRUE - font defined locally, kFALSE - globally
Definition TGFrame.h:531
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Definition TGFrame.cxx:2347
static const TGGC * fgDefaultGC
Definition TGFrame.h:536
TGGroupFrame(const TGGroupFrame &)=delete
Int_t fTitlePos
OPTION={GetMethod="GetTitlePos";SetMethod="SetTitlePos";Items=(-1="Left",0="Center",...
Definition TGFrame.h:530
static const TGFont * fgDefaultFont
Definition TGFrame.h:535
void DrawBorder() override
Draw border of around the group frame.
Definition TGFrame.cxx:2226
TGDimension GetDefaultSize() const override
Returns default size.
Definition TGFrame.cxx:2131
TClass * IsA() const override
Definition TGFrame.h:578
void DoRedraw() override
Redraw the group frame.
Definition TGFrame.cxx:2145
FontStruct_t fFontStruct
title fontstruct
Definition TGFrame.h:528
virtual void SetTextFont(const char *fontName, Bool_t local=kTRUE)
Changes text font specified by name.
Definition TGFrame.cxx:2202
GContext_t fNormGC
title graphics context
Definition TGFrame.h:529
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition TGFrame.cxx:2337
~TGGroupFrame() override
Delete a group frame.
Definition TGFrame.cxx:2118
Bool_t HasOwnFont() const
Returns kTRUE if text attributes are unique, returns kFALSE if text attributes are shared (global).
Definition TGFrame.cxx:2215
virtual void SetTextColor(Pixel_t color, Bool_t local=kTRUE)
Changes text color.
Definition TGFrame.cxx:2157
Int_t GetTitlePos() const
Definition TGFrame.h:565
const char * GetTitle() const override
Returns title of object.
Definition TGFrame.h:573
virtual void SetTitle(TGString *title)
Set or change title of the group frame.
Definition TGFrame.cxx:2308
Horizontal Frame used to contain header buttons and splitters in a list view.
Definition TGFrame.h:582
Bool_t HandleDoubleClick(Event_t *event) override
Handle double click mouse event in header frame.
Definition TGFrame.cxx:2422
Int_t fLastButton
Indicates the last button clicked if any.
Definition TGFrame.h:594
void SetColumnsInfo(Int_t nColumns, TGTextButton **colHeader, TGVFileSplitter **splitHeader)
Set columns information in the header frame.
Definition TGFrame.cxx:2379
TGVFileSplitter ** fSplitHeader
column splitters
Definition TGFrame.h:590
Bool_t fOverSplitter
Indicates if the cursor is over a splitter.
Definition TGFrame.h:592
TGHeaderFrame(const TGHeaderFrame &)=delete
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion events in header frame.
Definition TGFrame.cxx:2449
TGTextButton ** fColHeader
column headers for in detailed mode
Definition TGFrame.h:589
Cursor_t fSplitCursor
split cursor;
Definition TGFrame.h:591
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in header frame.
Definition TGFrame.cxx:2390
Int_t fNColumns
number of columns
Definition TGFrame.h:588
Int_t fOverButton
Indicates over which button the mouse is.
Definition TGFrame.h:593
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a horizontal frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:3094
static TClass * Class()
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Frame layout manager.
Definition TGLayout.h:135
virtual void Layout()=0
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
void GetWMSizeHints(UInt_t &wmin, UInt_t &hmin, UInt_t &wmax, UInt_t &hmax, UInt_t &winc, UInt_t &hinc) const
Definition TGFrame.h:487
TGMainFrame(const TGMainFrame &)=delete
UInt_t fWMWidthInc
WM width increments.
Definition TGFrame.h:433
UInt_t fWMHeightInc
WM height increments.
Definition TGFrame.h:434
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion events.
Definition TGFrame.cxx:1691
virtual Bool_t SaveFrameAsCodeOrImage()
Opens dialog window allowing user to save the frame contents as a ROOT macro or as an image.
Definition TGFrame.cxx:1527
virtual void SaveSource(const char *filename="Rootappl.C", Option_t *option="")
Save the GUI main frame widget in a C++ macro file.
Definition TGFrame.cxx:2784
TString GetMWMfuncString() const
used in SaveSource()
Definition TGFrame.cxx:2594
void DontCallClose()
Typically call this method in the slot connected to the CloseWindow() signal to prevent the calling o...
Definition TGFrame.cxx:1780
UInt_t fWMWidth
WM width.
Definition TGFrame.h:427
UInt_t fWMMinHeight
WM min height.
Definition TGFrame.h:430
void GetWMPosition(Int_t &x, Int_t &y) const
Definition TGFrame.h:485
Int_t fWMY
WM y position.
Definition TGFrame.h:426
UInt_t fWMMinWidth
WM min width.
Definition TGFrame.h:429
TString fResourceName
WM resource name.
Definition TGFrame.h:421
UInt_t fMWMValue
MWM decoration hints.
Definition TGFrame.h:422
void GetWMSize(UInt_t &w, UInt_t &h) const
Definition TGFrame.h:486
Atom_t * fDNDTypeList
handles DND types
Definition TGFrame.h:415
virtual void SendCloseMessage()
Send close message to self.
Definition TGFrame.cxx:1744
void GetMWMHints(UInt_t &value, UInt_t &funcs, UInt_t &input) const
Definition TGFrame.h:483
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition TGFrame.cxx:1858
Int_t fWMX
WM x position.
Definition TGFrame.h:425
virtual void CloseWindow()
Close and delete main frame.
Definition TGFrame.cxx:1770
TString fIconPixmap
icon pixmap name
Definition TGFrame.h:419
UInt_t fWMMaxWidth
WM max width.
Definition TGFrame.h:431
~TGMainFrame() override
TGMainFrame destructor.
Definition TGFrame.cxx:1507
Bool_t HandleButton(Event_t *event) override
Handle mouse button events.
Definition TGFrame.cxx:1679
Bool_t HandleClientMessage(Event_t *event) override
Handle client messages sent to this frame.
Definition TGFrame.cxx:1727
TString fWindowName
window name
Definition TGFrame.h:417
@ kDontCallClose
Definition TGFrame.h:402
UInt_t fWMHeight
WM height.
Definition TGFrame.h:428
TList * fBindList
list with key bindings
Definition TGFrame.h:416
UInt_t fWMMaxHeight
WM max height.
Definition TGFrame.h:432
void SetWMState(EInitialState state)
Set the initial state of the window. Either kNormalState or kIconicState.
Definition TGFrame.cxx:1924
virtual Bool_t BindKey(const TGWindow *w, Int_t keycode, Int_t modifier) const
Bind key to a window.
Definition TGFrame.cxx:1637
UInt_t fMWMFuncs
MWM functions.
Definition TGFrame.h:423
EInitialState fWMInitState
WM initial state.
Definition TGFrame.h:435
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1801
TString GetMWMinpString() const
used in SaveSource()
Definition TGFrame.cxx:2631
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
Definition TGFrame.cxx:1893
TString fClassName
WM class name.
Definition TGFrame.h:420
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
Definition TGFrame.cxx:1881
TString fIconName
icon name
Definition TGFrame.h:418
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1788
TString GetMWMvalueString() const
used in SaveSource()
Definition TGFrame.cxx:2554
Bool_t HandleKey(Event_t *event) override
Handle keyboard events.
Definition TGFrame.cxx:1606
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
Definition TGFrame.cxx:1868
const char * GetWindowName() const
Definition TGFrame.h:478
Bool_t HandleSelection(Event_t *event) override
Handle primary selection event.
Definition TGFrame.cxx:1703
void SetWMSizeHints(UInt_t wmin, UInt_t hmin, UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc)
Give the window manager minimum and maximum size hints.
Definition TGFrame.cxx:1906
const char * GetIconPixmap() const
Definition TGFrame.h:480
const char * GetIconName() const override
Returns mime type name of object.
Definition TGFrame.h:479
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a main frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:3050
virtual void RemoveBind(const TGWindow *w, Int_t keycode, Int_t modifier) const
Remove key binding.
Definition TGFrame.cxx:1660
Bool_t HandleSelectionRequest(Event_t *event) override
Handle selection request event.
Definition TGFrame.cxx:1715
const TGPicture * SetIconPixmap(const char *iconName)
Set window icon pixmap by name.
Definition TGFrame.cxx:1816
UInt_t fMWMInput
MWM input modes.
Definition TGFrame.h:424
static TClass * Class()
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
static TClass * Class()
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
Int_t GetLength() const
Definition TGString.h:29
const char * GetString() const
Definition TGString.h:30
virtual void Draw(Drawable_t id, GContext_t gc, Int_t x, Int_t y)
Draw string.
Definition TGString.cxx:56
Yield an action as soon as it is clicked.
Definition TGButton.h:142
Defines transient windows that typically are used for dialogs windows.
Definition TGFrame.h:500
void SaveSource(const char *filename="Rootdlog.C", Option_t *option="") override
Save the GUI transient frame widget in a C++ macro file.
Definition TGFrame.cxx:3239
TGTransientFrame(const TGTransientFrame &)=delete
const TGWindow * fMain
Definition TGFrame.h:503
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
Position transient frame centered relative to the parent frame.
Definition TGFrame.cxx:1957
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a transient frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:3500
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in vertical splitter.
Bool_t HandleDoubleClick(Event_t *) override
Handle double click mouse event in splitter.
A composite frame that layout their children in vertical way.
Definition TGFrame.h:376
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a vertical frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:3123
static TClass * Class()
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:152
virtual void Move(Int_t x, Int_t y)
Move the window.
Definition TGWindow.cxx:271
static Int_t fgCounter
counter of created windows in SavePrimitive
Definition TGWindow.h:31
void Print(Option_t *option="") const override
Print window id.
Definition TGWindow.cxx:307
virtual UInt_t GetEditDisabled() const
Definition TGWindow.h:112
virtual Bool_t HandleExpose(Event_t *event)
Definition TGWindow.h:101
virtual void SetName(const char *name)
Definition TGWindow.h:121
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
@ kEditDisableLayout
window layout cannot be edited
Definition TGWindow.h:60
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
Move and resize the window.
Definition TGWindow.cxx:287
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:129
const TGWindow * GetParent() const
Definition TGWindow.h:83
virtual void Resize(UInt_t w, UInt_t h)
Resize the window.
Definition TGWindow.cxx:279
virtual void SetBackgroundColor(Pixel_t color)
set background color
Definition TGWindow.cxx:240
virtual void RaiseWindow()
raise window
Definition TGWindow.cxx:208
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
virtual void MapSubwindows()
map sub windows
Definition TGWindow.cxx:168
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
An abstract interface to image processing library.
Definition TImage.h:29
EImageFileTypes
Definition TImage.h:36
@ kPng
Definition TImage.h:40
@ kJpeg
Definition TImage.h:41
@ kXpm
Definition TImage.h:37
@ kUnknown
Definition TImage.h:54
@ kTiff
Definition TImage.h:49
@ kGif
Definition TImage.h:48
static TImage * Create()
Create an image.
Definition TImage.cxx:35
A doubly linked list.
Definition TList.h:38
void Clear(Option_t *option="") override
Remove all objects from the list.
Definition TList.cxx:400
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:820
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:468
Collectable string class.
Definition TObjString.h:28
Monitors objects for deletion and reflects the deletion by reverting the internal pointer to zero.
Definition TObjectSpy.h:30
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:205
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
TQConnection class is an internal class, used in the object communication mechanism.
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
TString & Insert(Ssiz_t pos, const char *s)
Definition TString.h:661
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1114
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition TString.cxx:538
TString & Remove(Ssiz_t pos)
Definition TString.h:685
TString & Append(const char *cs)
Definition TString.h:572
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1075
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:946
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition TTimer.cxx:262
virtual void SetPasteFrame(TGFrame *f)
static TVirtualDragManager * Instance()
Load plugin and create drag manager object.
virtual Bool_t HandleEvent(Event_t *)
virtual void SetEditable(Bool_t)
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
TGraphErrors * gr
Definition legend1.C:25
return c2
Definition legend2.C:14
return c3
Definition legend3.C:15
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
Definition TObject.h:408
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Int_t fXRoot
Definition GuiTypes.h:179
Handle_t fHandle
general resource handle (used for atoms or windows)
Definition GuiTypes.h:185
Int_t fFormat
Next fields only used by kClientMessageEvent.
Definition GuiTypes.h:186
UInt_t fWidth
Definition GuiTypes.h:182
UInt_t fHeight
width and height of exposed area
Definition GuiTypes.h:182
Window_t fWindow
window reported event is relative to
Definition GuiTypes.h:176
UInt_t fState
key or button mask
Definition GuiTypes.h:181
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:179
Int_t fX
Definition GuiTypes.h:178
Time_t fTime
time event event occurred in ms
Definition GuiTypes.h:177
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Longptr_t fUser[5]
5 longs can be used by client message events NOTE: only [0], [1] and [2] may be used.
Definition GuiTypes.h:187
Graphics context structure.
Definition GuiTypes.h:224
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:93
Window attributes that can be inquired.
Definition GuiTypes.h:114
Long_t fYourEventMask
my event mask
Definition GuiTypes.h:132
Int_t fHeight
width and height of window
Definition GuiTypes.h:116
Int_t fBorderWidth
border width of window
Definition GuiTypes.h:117
Int_t fY
location of window
Definition GuiTypes.h:115
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4