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