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