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