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