Logo ROOT   6.07/09
Reference Guide
TGSplitFrame.cxx
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Bertrand Bellenot 23/01/2008
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2008, 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 #include "TGFrame.h"
13 #include "TGLayout.h"
14 #include "TGMenu.h"
15 #include "TGSplitter.h"
16 #include "TGSplitFrame.h"
17 #include "TGInputDialog.h"
18 #include "TGResourcePool.h"
19 #include "TRootContextMenu.h"
20 #include "TClassMenuItem.h"
21 #include "TContextMenu.h"
22 #include "TString.h"
23 #include "TClass.h"
24 #include "TList.h"
25 #include "Riostream.h"
26 
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// Create a split frame tool tip. P is the tool tips parent window (normally
32 /// fClient->GetRoot() and f is the frame to which the tool tip is associated.
33 
36 {
39  attr.fOverrideRedirect = kTRUE;
40  attr.fSaveUnder = kTRUE;
41 
42  gVirtualX->ChangeWindowAttributes(fId, &attr);
43  SetBackgroundColor(fClient->GetResourcePool()->GetTipBgndColor());
44 
45  fRectGC.SetFillStyle(kFillSolid);
46  fRectGC.SetForeground(0x99ff99);
47 
48  TClass *cl = TClass::GetClass("TGSplitFrame");
49  cl->MakeCustomMenuList();
50  TList *ml = cl->GetMenuList();
51  ((TClassMenuItem *)ml->At(1))->SetTitle("Cleanup Frame");
52  ((TClassMenuItem *)ml->At(2))->SetTitle("Close and Collapse");
53  ((TClassMenuItem *)ml->At(3))->SetTitle("Undock Frame");
54  ((TClassMenuItem *)ml->At(4))->SetTitle("Dock Frame Back");
55  ((TClassMenuItem *)ml->At(5))->SetTitle("Switch to Main");
56  ((TClassMenuItem *)ml->At(6))->SetTitle("Horizontally Split...");
57  ((TClassMenuItem *)ml->At(7))->SetTitle("Vertically Split...");
58  fContextMenu = new TContextMenu("SplitFrameContextMenu", "Actions");
59  fMap.SetOwner(kTRUE);
60  fMap.SetOwnerValue(kFALSE);
61  MapSubwindows();
62  if (f) Resize(f->GetWidth()/10, f->GetHeight()/10);
64 
65  fWindow = f;
66  fX = fY = -1;
67 }
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// TGSplitTool destructor.
71 
73 {
74  delete fContextMenu;
75 }
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Add a rectangle representation of a split frame in the map, together
79 /// with the frame itself.
80 
82 {
83  TGRectMap *rect = new TGRectMap(x, y, w, h);
84  fMap.Add(rect, frame);
85 }
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Redraw split frame tool.
89 
91 {
92  TGRectMap *rect;
93  TMapIter next(&fMap);
94  while ((rect = (TGRectMap*)next())) {
95  gVirtualX->FillRectangle(fId, GetBckgndGC()(), rect->fX,
96  rect->fY, rect->fW, rect->fH);
97  gVirtualX->DrawRectangle(fId, GetBlackGC()(), rect->fX, rect->fY,
98  rect->fW, rect->fH);
99  }
100  DrawBorder();
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Draw border of tool window.
105 
107 {
108  gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
109  gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
110  gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
111  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
112 }
113 
114 ////////////////////////////////////////////////////////////////////////////////
115 /// Handle mouse click events in the tool.
116 
118 {
119  if (event->fType != kButtonPress)
120  return kTRUE;
121  Int_t px = 0, py = 0;
122  Window_t wtarget;
123  TGRectMap *rect;
124  TGSplitFrame *frm = 0;
125  TMapIter next(&fMap);
126  while ((rect = (TGRectMap*)next())) {
127  if (rect->Contains(event->fX, event->fY)) {
128  frm = (TGSplitFrame *)fMap.GetValue((const TObject *)rect);
129  gVirtualX->TranslateCoordinates(event->fWindow,
130  gClient->GetDefaultRoot()->GetId(),
131  event->fX, event->fY, px, py, wtarget);
132  fContextMenu->Popup(px, py, frm);
133  // connect PoppedDown signal to close the tool window
134  // when the menu is closed
136  ((TGPopupMenu *)menu)->Connect("PoppedDown()", "TGSplitTool", this, "Hide()");
137  return kTRUE;
138  }
139  }
140  Hide();
141  return kTRUE;
142 }
143 
144 ////////////////////////////////////////////////////////////////////////////////
145 /// handle mouse motion events
146 
148 {
149  static TGRectMap *rect = 0, *oldrect = 0;
150  TMapIter next(&fMap);
151  while ((rect = (TGRectMap*)next())) {
152  if (rect->Contains(event->fX, event->fY)) {
153  // if inside a rectangle, highlight it
154  if (rect != oldrect) {
155  if (oldrect) {
156  gVirtualX->FillRectangle(fId, GetBckgndGC()(), oldrect->fX,
157  oldrect->fY, oldrect->fW, oldrect->fH);
158  gVirtualX->DrawRectangle(fId, GetBlackGC()(), oldrect->fX, oldrect->fY,
159  oldrect->fW, oldrect->fH);
160  }
161  gVirtualX->FillRectangle(fId, fRectGC(), rect->fX, rect->fY, rect->fW,
162  rect->fH);
163  gVirtualX->DrawRectangle(fId, GetBlackGC()(), rect->fX, rect->fY,
164  rect->fW, rect->fH);
165  oldrect = rect;
166  }
167  return kTRUE;
168  }
169  }
170  if (oldrect) {
171  gVirtualX->FillRectangle(fId, GetBckgndGC()(), oldrect->fX,
172  oldrect->fY, oldrect->fW, oldrect->fH);
173  gVirtualX->DrawRectangle(fId, GetBlackGC()(), oldrect->fX, oldrect->fY,
174  oldrect->fW, oldrect->fH);
175  }
176  return kTRUE;
177 }
178 ////////////////////////////////////////////////////////////////////////////////
179 /// Hide tool window. Use this method to hide the tool in a client class.
180 
182 {
183  gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
184  fMap.Delete();
185  UnmapWindow();
186 }
187 
188 ////////////////////////////////////////////////////////////////////////////////
189 /// Reset tool tip popup delay timer. Use this method to activate tool tip
190 /// in a client class.
191 
193 {
194  fMap.Delete();
195 }
196 
197 ////////////////////////////////////////////////////////////////////////////////
198 /// Set popup position within specified frame (as specified in the ctor).
199 /// To get back default behaviour (in the middle just below the designated
200 /// frame) set position to -1,-1.
201 
203 {
204  fX = x;
205  fY = y;
206 
207  if (fX < -1)
208  fX = 0;
209  if (fY < -1)
210  fY = 0;
211 
212  if (fWindow) {
213  if (fX > (Int_t) fWindow->GetWidth())
214  fX = fWindow->GetWidth();
215  if (fY > (Int_t) fWindow->GetHeight())
216  fY = fWindow->GetHeight();
217  }
218 }
219 
220 ////////////////////////////////////////////////////////////////////////////////
221 /// Show tool window.
222 
224 {
225  Move(x, y);
226  MapWindow();
227  RaiseWindow();
228 
229  // last argument kFALSE forces all specified events to this window
232  kTRUE, kFALSE);
233  // Long_t args[2];
234  // args[0] = x;
235  // args[1] = y;
236 }
237 
238 ////////////////////////////////////////////////////////////////////////////////
239 /// Default constructor.
240 
242  UInt_t options) : TGCompositeFrame(p, w, h, options),
243  fFrame(0), fSplitter(0), fFirst(0), fSecond(0)
244 {
245  fSplitTool = new TGSplitTool(gClient->GetDefaultRoot(), this);
246  fHRatio = fWRatio = 0.0;
247  fUndocked = 0;
250 }
251 
252 ////////////////////////////////////////////////////////////////////////////////
253 /// Destructor. Make cleanup.
254 
256 {
257  delete fSplitTool;
258  Cleanup();
259 }
260 
261 ////////////////////////////////////////////////////////////////////////////////
262 /// Add a frame in the split frame using layout hints l.
263 
265 {
267  fFrame = f;
268 }
269 
270 ////////////////////////////////////////////////////////////////////////////////
271 /// Add a frame in the split frame using layout hints l.
272 
274 {
276  if (f == fFrame)
277  fFrame = 0;
278 }
279 
280 ////////////////////////////////////////////////////////////////////////////////
281 /// Recursively cleanup child frames.
282 
284 {
286  fFirst = 0;
287  fSecond = 0;
288  fSplitter = 0;
289  fUndocked = 0;
290 }
291 
292 ////////////////////////////////////////////////////////////////////////////////
293 /// Return the top level split frame.
294 
296 {
297  TGSplitFrame *top = this;
298  TGWindow *w = (TGWindow *)GetParent();
299  TGSplitFrame *p = dynamic_cast<TGSplitFrame *>(w);
300  while (p) {
301  top = p;
302  w = (TGWindow *)p->GetParent();
303  p = dynamic_cast<TGSplitFrame *>(w);
304  }
305  return top;
306 }
307 
308 ////////////////////////////////////////////////////////////////////////////////
309 /// Close (unmap and remove from the list of frames) the frame contained in
310 /// this split frame.
311 
313 {
314  if (fFrame) {
315  fFrame->UnmapWindow();
317  }
318  fFrame = 0;
319 }
320 
321 ////////////////////////////////////////////////////////////////////////////////
322 /// Close (unmap, remove from the list of frames and destroy) the frame
323 /// contained in this split frame. Then unsplit the parent frame.
324 
326 {
327  if (!fSplitter || !fFirst || !fSecond) {
328  TGSplitFrame *parent = (TGSplitFrame *)GetParent();
329  if (parent->GetFirst() && parent->GetSecond()) {
330  if (parent->GetFirst() == this)
331  parent->UnSplit("first");
332  else if (parent->GetSecond() == this)
333  parent->UnSplit("second");
334  }
335  }
336 }
337 ////////////////////////////////////////////////////////////////////////////////
338 /// Emit Undocked() signal.
339 
341 {
342  Emit("Docked(TGFrame*)", (Long_t)frame);
343 }
344 
345 ////////////////////////////////////////////////////////////////////////////////
346 /// Extract the frame contained in this split frame an reparent it in a
347 /// transient frame. Keep a pointer on the transient frame to be able to
348 /// swallow the child frame back to this.
349 
351 {
352  if (fFrame) {
353  fFrame->UnmapWindow();
354  fUndocked = new TGTransientFrame(gClient->GetDefaultRoot(), GetMainFrame(), 800, 600);
357  // Layout...
359  fUndocked->Layout();
360  fUndocked->MapWindow();
362  fUndocked->Connect("CloseWindow()", "TGSplitFrame", this, "SwallowBack()");
363  Undocked(fFrame);
364  }
365 }
366 
367 ////////////////////////////////////////////////////////////////////////////////
368 /// Handles resize events for this frame.
369 /// This is needed to keep as much as possible the sizes ratio between
370 /// all subframes.
371 
373 {
374  if (!fFirst) {
375  // case of resizing a frame with the splitter (and not from parent)
376  TGWindow *w = (TGWindow *)GetParent();
377  TGSplitFrame *p = dynamic_cast<TGSplitFrame *>(w);
378  if (p) {
379  if (p->GetFirst()) {
380  // set the correct ratio for this child
381  Float_t hratio = (Float_t)p->GetFirst()->GetHeight() / (Float_t)p->GetHeight();
382  Float_t wratio = (Float_t)p->GetFirst()->GetWidth() / (Float_t)p->GetWidth();
383  p->SetHRatio(hratio);
384  p->SetWRatio(wratio);
385  }
386  }
387  return kTRUE;
388  }
389  // case of resize event comes from the parent (i.e. by rezing TGMainFrame)
390  if ((fHRatio > 0.0) && (fWRatio > 0.0)) {
392  fFirst->SetHeight((UInt_t)h);
393  Float_t w = fWRatio * (Float_t)GetWidth();
394  fFirst->SetWidth((UInt_t)w);
395  }
396  // memorize the actual ratio for next resize event
399  fClient->NeedRedraw(this);
400  if (!gVirtualX->InheritsFrom("TGX11"))
401  Layout();
402  return kTRUE;
403 }
404 
405 ////////////////////////////////////////////////////////////////////////////////
406 /// Horizontally split the frame.
407 
409 {
410  // return if already split
411  if ((fSplitter != 0) || (fFirst != 0) || (fSecond != 0) || (fFrame != 0))
412  return;
413  UInt_t height = (h > 0) ? h : fHeight/2;
414  // set correct option (vertical frame)
416  // create first split frame with fixed height - required for the splitter
417  fFirst = new TGSplitFrame(this, fWidth, height, kSunkenFrame | kFixedHeight);
418  // create second split frame
419  fSecond = new TGSplitFrame(this, fWidth, height, kSunkenFrame);
420  // create horizontal splitter
421  fSplitter = new TGHSplitter(this, 4, 4);
422  // set the splitter's frame to the first one
424  fSplitter->Connect("ProcessedEvent(Event_t*)", "TGSplitFrame", this,
425  "OnSplitterClicked(Event_t*)");
426  // add all frames
431  kLHintsExpandY));
432 }
433 
434 ////////////////////////////////////////////////////////////////////////////////
435 /// Vertically split the frame.
436 
438 {
439  // return if already split
440  if ((fSplitter != 0) || (fFirst != 0) || (fSecond != 0) || (fFrame != 0))
441  return;
442  UInt_t width = (w > 0) ? w : fWidth/2;
443  // set correct option (horizontal frame)
445  // create first split frame with fixed width - required for the splitter
446  fFirst = new TGSplitFrame(this, width, fHeight, kSunkenFrame | kFixedWidth);
447  // create second split frame
448  fSecond = new TGSplitFrame(this, width, fHeight, kSunkenFrame);
449  // create vertical splitter
450  fSplitter = new TGVSplitter(this, 4, 4);
451  // set the splitter's frame to the first one
453  fSplitter->Connect("ProcessedEvent(Event_t*)", "TGSplitFrame", this,
454  "OnSplitterClicked(Event_t*)");
455  // add all frames
460  kLHintsExpandY));
461 }
462 
463 ////////////////////////////////////////////////////////////////////////////////
464 /// Map this split frame in the small overview tooltip.
465 
467 {
468  Int_t px = 0, py = 0;
469  Int_t rx = 0, ry = 0;
470  Int_t cx, cy, cw, ch;
471  Window_t wtarget;
472  if (!fFirst && !fSecond) {
473  TGSplitFrame *parent = dynamic_cast<TGSplitFrame *>((TGFrame *)fParent);
474  if (parent && parent->fSecond == this) {
475  if (parent->GetOptions() & kVerticalFrame)
476  ry = parent->GetFirst()->GetHeight();
477  if (parent->GetOptions() & kHorizontalFrame)
478  rx = parent->GetFirst()->GetWidth();
479  }
480  gVirtualX->TranslateCoordinates(GetId(), top->GetId(),
481  fX, fY, px, py, wtarget);
482  cx = ((px-rx)/10)+2;
483  cy = ((py-ry)/10)+2;
484  cw = (fWidth/10)-4;
485  ch = (fHeight/10)-4;
486  top->GetSplitTool()->AddRectangle(this, cx, cy, cw, ch);
487  return;
488  }
489  if (fFirst)
490  fFirst->MapToSPlitTool(top);
491  if (fSecond)
492  fSecond->MapToSPlitTool(top);
493 }
494 
495 ////////////////////////////////////////////////////////////////////////////////
496 /// Handle mouse click events on the splitter.
497 
499 {
500  Int_t px = 0, py = 0;
501  Window_t wtarget;
502  if (event->fType != kButtonPress)
503  return;
504  if (event->fCode != kButton3)
505  return;
506  gVirtualX->TranslateCoordinates(event->fWindow,
507  gClient->GetDefaultRoot()->GetId(),
508  event->fX, event->fY, px, py, wtarget);
509  TGSplitFrame *top = GetTopFrame();
510  top->GetSplitTool()->Reset();
511  top->GetSplitTool()->Resize(1+top->GetWidth()/10, 1+top->GetHeight()/10);
512  top->MapToSPlitTool(top);
513  top->GetSplitTool()->Show(px, py);
514 }
515 
516 ////////////////////////////////////////////////////////////////////////////////
517 /// Horizontally split the frame, and if it contains a child frame, ask
518 /// the user where to keep it (top or bottom). This is the method used
519 /// via the context menu.
520 
522 {
523  char side[200];
524  snprintf(side, 200, "top");
525  if (fFrame) {
526  new TGInputDialog(gClient->GetRoot(), GetTopFrame(),
527  "In which side the actual frame has to be kept (top / bottom)",
528  side, side);
529  if ( strcmp(side, "") == 0 ) // Cancel button was pressed
530  return;
531  }
532  SplitHorizontal(side);
533 }
534 
535 ////////////////////////////////////////////////////////////////////////////////
536 /// Horizontally split the frame, and if it contains a child frame, ask
537 /// the user where to keep it (top or bottom). This method is the actual
538 /// implementation.
539 
540 void TGSplitFrame::SplitHorizontal(const char *side)
541 {
542  if (fFrame) {
543  TGFrame *frame = fFrame;
544  frame->UnmapWindow();
545  frame->ReparentWindow(gClient->GetDefaultRoot());
547  HSplit();
548  if (!strcmp(side, "top")) {
549  frame->ReparentWindow(GetFirst());
551  }
552  else if (!strcmp(side, "bottom")) {
553  frame->ReparentWindow(GetSecond());
555  }
556  }
557  else {
558  HSplit();
559  }
560  MapSubwindows();
561  Layout();
562 }
563 
564 ////////////////////////////////////////////////////////////////////////////////
565 /// Vertically split the frame, and if it contains a child frame, ask
566 /// the user where to keep it (left or right). This is the method used
567 /// via the context menu.
568 
570 {
571  char side[200];
572  snprintf(side, 200, "left");
573  if (fFrame) {
574  new TGInputDialog(gClient->GetRoot(), GetTopFrame(),
575  "In which side the actual frame has to be kept (left / right)",
576  side, side);
577  if ( strcmp(side, "") == 0 ) // Cancel button was pressed
578  return;
579  }
580  SplitVertical(side);
581 }
582 
583 ////////////////////////////////////////////////////////////////////////////////
584 /// Vertically split the frame, and if it contains a child frame, ask
585 /// the user where to keep it (left or right). This method is the actual
586 /// implementation.
587 
588 void TGSplitFrame::SplitVertical(const char *side)
589 {
590  if (fFrame) {
591  TGFrame *frame = fFrame;
592  frame->UnmapWindow();
593  frame->ReparentWindow(gClient->GetDefaultRoot());
595  VSplit();
596  if (!strcmp(side, "left")) {
597  frame->ReparentWindow(GetFirst());
599  }
600  else if (!strcmp(side, "right")) {
601  frame->ReparentWindow(GetSecond());
603  }
604  }
605  else {
606  VSplit();
607  }
608  MapSubwindows();
609  Layout();
610 }
611 
612 ////////////////////////////////////////////////////////////////////////////////
613 /// Swallow back the child frame previously extracted, and close its
614 /// parent (transient frame).
615 
617 {
618  if (!fUndocked) {
619  fUndocked = dynamic_cast<TGTransientFrame *>((TQObject*)gTQSender);
620  }
621  if (fUndocked) {
622  TGFrameElement *el = dynamic_cast<TGFrameElement*>(fUndocked->GetList()->First());
623  if (!el || !el->fFrame) return;
624  TGSplitFrame *frame = (TGSplitFrame *)el->fFrame;
625  frame->UnmapWindow();
626  fUndocked->RemoveFrame(frame);
627  frame->ReparentWindow(this);
629  // Layout...
630  MapSubwindows();
631  Layout();
633  fUndocked = 0;
634  Docked(frame);
635  }
636 }
637 
638 ////////////////////////////////////////////////////////////////////////////////
639 /// Switch (exchange) two frames.
640 /// frame is the source, dest is the destination (the new parent)
641 /// prev is the frame that has to be exchanged with the source
642 /// (the one actually in the destination)
643 
645  TGFrame *prev)
646 {
647  // get parent of the source (its container)
648  TGCompositeFrame *parent = (TGCompositeFrame *)frame->GetParent();
649 
650  // unmap the window (to avoid flickering)
651  prev->UnmapWindow();
652  // remove it from the destination frame
653  dest->RemoveFrame(prev);
654  // temporary reparent it to root (desktop window)
655  prev->ReparentWindow(gClient->GetDefaultRoot());
656 
657  // now unmap the source window (still to avoid flickering)
658  frame->UnmapWindow();
659  // remove it from its parent (its container)
660  parent->RemoveFrame(frame);
661  // reparent it to the target location
662  frame->ReparentWindow(dest);
663  // add it to its new parent (for layout managment)
665  // Layout...
666  frame->Resize(dest->GetDefaultSize());
667  dest->MapSubwindows();
668  dest->Layout();
669 
670  // now put back the previous one in the previous source parent
671  // reparent to the previous source container
672  prev->ReparentWindow(parent);
673  // add it to the frame (for layout managment)
674  parent->AddFrame(prev, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
675  // Layout...
676  prev->Resize(parent->GetDefaultSize());
677  parent->MapSubwindows();
678  parent->Layout();
679 }
680 
681 ////////////////////////////////////////////////////////////////////////////////
682 /// Switch the actual embedded frame to the main (first) split frame.
683 
685 {
686  TGFrame *source = fFrame;
688  TGFrame *prev = (TGFrame *)(dest->GetFrame());
689  if ((source != prev) && (source != dest))
690  SwitchFrames(source, dest, prev);
691 }
692 
693 ////////////////////////////////////////////////////////////////////////////////
694 /// Emit Undocked() signal.
695 
697 {
698  Emit("Undocked(TGFrame*)", (Long_t)frame);
699 }
700 
701 ////////////////////////////////////////////////////////////////////////////////
702 /// Close (unmap and remove from the list of frames) the frame contained in
703 /// this split frame.
704 
705 void TGSplitFrame::UnSplit(const char *which)
706 {
707  TGCompositeFrame *keepframe = 0;
708  TGSplitFrame *kframe = 0, *dframe = 0;
709  if (!strcmp(which, "first")) {
710  dframe = GetFirst();
711  kframe = GetSecond();
712  }
713  else if (!strcmp(which, "second")) {
714  dframe = GetSecond();
715  kframe = GetFirst();
716  }
717  if (!kframe || !dframe)
718  return;
719  keepframe = (TGCompositeFrame *)kframe->GetFrame();
720  if (keepframe) {
721  keepframe->UnmapWindow();
722  keepframe->ReparentWindow(gClient->GetDefaultRoot());
723  kframe->RemoveFrame(keepframe);
724  }
725  Cleanup();
726  if (keepframe) {
727  keepframe->ReparentWindow(this);
729  }
730  MapSubwindows();
731  Layout();
732 }
733 
734 ////////////////////////////////////////////////////////////////////////////////
735 /// Save a splittable frame as a C++ statement(s) on output stream out.
736 
737 void TGSplitFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
738 {
739  if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
740 
741  out << std::endl << " // splittable frame" << std::endl;
742  out << " TGSplitFrame *";
743  out << GetName() << " = new TGSplitFrame(" << fParent->GetName()
744  << "," << GetWidth() << "," << GetHeight();
745 
747  if (!GetOptions()) {
748  out << ");" << std::endl;
749  } else {
750  out << "," << GetOptionString() <<");" << std::endl;
751  }
752  } else {
753  out << "," << GetOptionString() << ",ucolor);" << std::endl;
754  }
755  if (option && strstr(option, "keep_names"))
756  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
757 
758  // setting layout manager if it differs from the main frame type
759  // coverity[returned_null]
760  // coverity[dereference]
762  if ((GetOptions() & kHorizontalFrame) &&
764  ;
765  } else if ((GetOptions() & kVerticalFrame) &&
767  ;
768  } else {
769  out << " " << GetName() <<"->SetLayoutManager(";
770  lm->SavePrimitive(out, option);
771  out << ");"<< std::endl;
772  }
773 
774  SavePrimitiveSubframes(out, option);
775 }
Describes one element of the context menu associated to a class The menu item may describe...
virtual void SetFrame(TGFrame *frame, Bool_t prev)=0
const TGWindow * fParent
Definition: TGWindow.h:43
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
TList * GetMenuList() const
Return the list of menu items associated with the class.
Definition: TClass.cxx:4094
Int_t fX
Definition: TGSplitFrame.h:33
TGFrame * fFrame
Definition: TGSplitFrame.h:88
void SplitVertical(const char *side="left")
Vertically split the frame, and if it contains a child frame, ask the user where to keep it (left or ...
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
TGTransientFrame * fUndocked
Definition: TGSplitFrame.h:89
void SwallowBack()
Swallow back the child frame previously extracted, and close its parent (transient frame)...
virtual void HSplit(UInt_t h=0)
Horizontally split the frame.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:488
const TGWindow * GetParent() const
Definition: TGWindow.h:87
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
const char Option_t
Definition: RtypesCore.h:62
R__EXTERN void * gTQSender
Definition: TQObject.h:49
void CloseAndCollapse()
Close (unmap, remove from the list of frames and destroy) the frame contained in this split frame...
TH1 * h
Definition: legend2.C:5
UInt_t GetWidth() const
Definition: TGFrame.h:287
Int_t fY
Definition: TGFrame.h:149
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:53
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
Definition: TMap.cxx:53
Int_t fY
Definition: GuiTypes.h:179
Pixel_t fBackground
Definition: TGFrame.h:158
virtual TList * GetList() const
Definition: TGFrame.h:385
#define gClient
Definition: TGClient.h:174
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGSplitFrame * GetSecond() const
Definition: TGSplitFrame.h:111
const Bool_t kFALSE
Definition: Rtypes.h:92
void DrawBorder()
Draw border of tool window.
UInt_t GetHeight() const
Definition: TGFrame.h:288
const char * Class
Definition: TXMLSetup.cxx:64
TGSplitFrame * GetFirst() const
Definition: TGSplitFrame.h:109
void Close()
Close (unmap and remove from the list of frames) the frame contained in this split frame...
Window_t fWindow
Definition: GuiTypes.h:177
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:311
void SetWRatio(Float_t r)
Definition: TGSplitFrame.h:121
void OnSplitterClicked(Event_t *event)
Handle mouse click events on the splitter.
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition: TGFrame.cxx:1131
TGSplitTool * GetSplitTool() const
Definition: TGSplitFrame.h:113
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:164
void SplitHor()
Horizontally split the frame, and if it contains a child frame, ask the user where to keep it (top or...
Double_t x[n]
Definition: legend1.C:17
virtual ~TGSplitTool()
TGSplitTool destructor.
TContextMenu * fContextMenu
Definition: TGSplitFrame.h:57
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
virtual UInt_t GetOptions() const
Definition: TGFrame.h:260
Int_t fX
Definition: TGFrame.h:148
UInt_t fH
Definition: TGSplitFrame.h:36
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:265
void MapToSPlitTool(TGSplitFrame *top)
Map this split frame in the small overview tooltip.
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=0, TVirtualPad *p=0)
Popup context menu at given location in canvas c and pad p for selected object.
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition: TMap.cxx:235
void SplitHorizontal(const char *side="top")
Horizontally split the frame, and if it contains a child frame, ask the user where to keep it (top or...
void SwitchToMain()
Switch the actual embedded frame to the main (first) split frame.
virtual void RemoveFrame(TGFrame *f)
Add a frame in the split frame using layout hints l.
Float_t fHRatio
Definition: TGSplitFrame.h:95
UInt_t fW
Definition: TGSplitFrame.h:35
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:561
A doubly linked list.
Definition: TList.h:47
virtual Bool_t HandleConfigureNotify(Event_t *)
Handles resize events for this frame.
void Show(Int_t x, Int_t y)
Show tool window.
void DoRedraw()
Redraw split frame tool.
const Mask_t kButtonPressMask
Definition: GuiTypes.h:162
Bool_t fOverrideRedirect
Definition: GuiTypes.h:108
Iterator of map.
Definition: TMap.h:148
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a splittable frame as a C++ statement(s) on output stream out.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:1137
TGSplitFrame(const TGSplitFrame &)
Int_t fY
Definition: TGSplitFrame.h:34
void Delete(Option_t *option="")
Remove all (key,value) pairs from the map AND delete the keys when they are allocated on the heap...
Definition: TMap.cxx:133
virtual void SavePrimitiveSubframes(std::ostream &out, Option_t *option="")
Auxilary protected method used to save subframes.
Definition: TGFrame.cxx:2621
const Mask_t kWASaveUnder
Definition: GuiTypes.h:151
EGEventType fType
Definition: GuiTypes.h:176
const TGFrame * fWindow
Definition: TGSplitFrame.h:54
#define dest(otri, vertexptr)
Definition: triangle.c:1040
void MakeCustomMenuList()
Makes a customizable version of the popup menu list, i.e.
Definition: TClass.cxx:4036
void SetHRatio(Float_t r)
Definition: TGSplitFrame.h:120
Bool_t Contains(Int_t px, Int_t py) const
Definition: TGSplitFrame.h:44
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:44
virtual void CloseWindow()
Close and delete main frame.
Definition: TGFrame.cxx:1728
void SetPosition(Int_t x, Int_t y)
Set popup position within specified frame (as specified in the ctor).
unsigned int UInt_t
Definition: RtypesCore.h:42
void AddRectangle(TGFrame *frm, Int_t x, Int_t y, Int_t w, Int_t h)
Add a rectangle representation of a split frame in the map, together with the frame itself...
const Handle_t kNone
Definition: GuiTypes.h:89
TGFrame * fFrame
Definition: TGLayout.h:125
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:1025
TLine * l
Definition: textangle.C:4
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
Bool_t HandleMotion(Event_t *event)
handle mouse motion events
TGFrame * GetFrame() const
Definition: TGSplitFrame.h:110
TGSplitter * fSplitter
Definition: TGSplitFrame.h:90
static const TGGC & GetBlackGC()
Get black graphics context.
Definition: TGFrame.cxx:717
#define gVirtualX
Definition: TVirtualX.h:362
UInt_t fWidth
Definition: TGFrame.h:150
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition: TGFrame.cxx:575
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
long Long_t
Definition: RtypesCore.h:50
virtual TContextMenuImp * GetContextMenuImp()
Definition: TContextMenu.h:87
virtual void SetWidth(UInt_t w)
Definition: TGFrame.h:309
T2 fSecond
Definition: X11Events.mm:87
#define ClassImp(name)
Definition: Rtypes.h:279
double f(double x)
const Mask_t kStructureNotifyMask
Definition: GuiTypes.h:167
const TGResourcePool * GetResourcePool() const
Definition: TGClient.h:141
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1054
Bool_t HandleButton(Event_t *event)
Handle mouse click events in the tool.
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:163
UInt_t fCode
Definition: GuiTypes.h:181
virtual void RaiseWindow()
Definition: TGWindow.h:96
void Hide()
Hide tool window. Use this method to hide the tool in a client class.
const Mask_t kWAOverrideRedirect
Definition: GuiTypes.h:150
TGSplitFrame * fSecond
Definition: TGSplitFrame.h:92
Double_t y[n]
Definition: legend1.C:17
UInt_t fHeight
Definition: TGFrame.h:151
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition: TClass.cxx:2882
virtual void VSplit(UInt_t w=0)
Vertically split the frame.
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
Cursor_t GetGrabCursor() const
void Undocked(TGFrame *frame)
Emit Undocked() signal.
Handle_t fId
Definition: TGObject.h:40
void ExtractFrame()
Extract the frame contained in this split frame an reparent it in a transient frame.
Mother of all ROOT objects.
Definition: TObject.h:44
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:557
Handle_t Window_t
Definition: GuiTypes.h:30
virtual void UnmapWindow()
Definition: TGFrame.h:269
void Reset()
Reset tool tip popup delay timer.
virtual void Cleanup()
Recursively cleanup child frames.
virtual void SetHeight(UInt_t h)
Definition: TGFrame.h:310
virtual void MapWindow()
Definition: TGFrame.h:267
TGClient * fClient
Definition: TGObject.h:41
static void SwitchFrames(TGFrame *frame, TGCompositeFrame *dest, TGFrame *prev)
Switch (exchange) two frames.
virtual ~TGSplitFrame()
Destructor. Make cleanup.
void Docked(TGFrame *frame)
Emit Undocked() signal.
void SplitVer()
Vertically split the frame, and if it contains a child frame, ask the user where to keep it (left or ...
#define snprintf
Definition: civetweb.c:822
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
TGSplitTool * fSplitTool
Definition: TGSplitFrame.h:93
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2433
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:391
TGSplitFrame * fFirst
Definition: TGSplitFrame.h:91
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
const Bool_t kTRUE
Definition: Rtypes.h:91
TGSplitFrame * GetTopFrame()
Return the top level split frame.
void UnSplit(const char *which)
Close (unmap and remove from the list of frames) the frame contained in this split frame...
Handle_t GetId() const
Definition: TGObject.h:52
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2460
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition: TGFrame.cxx:747
Int_t fX
Definition: GuiTypes.h:179
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition: TGFrame.cxx:757
Float_t fWRatio
Definition: TGSplitFrame.h:94
virtual TGLayoutManager * GetLayoutManager() const
Definition: TGFrame.h:413
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add a frame in the split frame using layout hints l.
T1 fFirst
Definition: X11Events.mm:86
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TObject.cxx:709