Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TDialogCanvas.cxx
Go to the documentation of this file.
1 // @(#)root/gpad:$Id$
2 // Author: Rene Brun 03/07/96
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 #include "TROOT.h"
13 #include "TDialogCanvas.h"
14 #include "TGroupButton.h"
15 #include "TText.h"
16 #include "TStyle.h"
17 
18 ClassImp(TDialogCanvas);
19 
20 /** \class TDialogCanvas
21 \ingroup gpad
22 
23 A canvas specialized to set attributes.
24 
25 It contains, in general, TGroupButton objects.
26 When the APPLY button is executed, the actions corresponding
27 to the active buttons are executed via the Interpreter.
28 
29 See examples in TAttLineCanvas, TAttFillCanvas, TAttTextCanvas, TAttMarkerCanvas
30 */
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// DialogCanvas default constructor
34 
35 TDialogCanvas::TDialogCanvas() : TCanvas()
36 {
37  fRefObject = 0;
38  fRefPad = 0;
39 }
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// DialogCanvas constructor
43 
44 TDialogCanvas::TDialogCanvas(const char *name, const char *title, Int_t ww, Int_t wh)
45  : TCanvas(name,title,-ww,wh)
46 {
47  SetFillColor(36);
48  fRefObject = 0;
49  fRefPad = 0;
50 }
51 
52 ////////////////////////////////////////////////////////////////////////////////
53 /// DialogCanvas constructor
54 
55 TDialogCanvas::TDialogCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy, UInt_t ww, UInt_t wh)
56  : TCanvas(name,title,-wtopx,wtopy,ww,wh)
57 {
58  SetFillColor(36);
59  fRefObject = 0;
60  fRefPad = 0;
61 }
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// DialogCanvas default destructor
65 
66 TDialogCanvas::~TDialogCanvas()
67 {
68 }
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// Called when the APPLY button is executed
72 
73 void TDialogCanvas::Apply(const char *action)
74 {
75  if (!fRefPad) return;
76  SetCursor(kWatch);
77 
78  TIter next(fPrimitives);
79  TObject *refobj = fRefObject;
80  TObject *obj;
81  TGroupButton *button;
82  if (!strcmp(action,"gStyle")) fRefObject = gStyle;
83 
84  while ((obj = next())) {
85  if (obj->InheritsFrom(TGroupButton::Class())) {
86  button = (TGroupButton*)obj;
87  if (button->GetBorderMode() < 0) button->ExecuteAction();
88  }
89  }
90  fRefObject = refobj;
91  if (!gROOT->GetSelectedPad()) return;
92  gROOT->GetSelectedPad()->Modified();
93  gROOT->GetSelectedPad()->Update();
94 }
95 
96 
97 ////////////////////////////////////////////////////////////////////////////////
98 /// Create APPLY, gStyle and CLOSE buttons
99 
100 void TDialogCanvas::BuildStandardButtons()
101 {
102  TGroupButton *apply = new TGroupButton("APPLY","Apply","",.05,.01,.3,.09);
103  apply->SetTextSize(0.55);
104  apply->SetBorderSize(3);
105  apply->SetFillColor(44);
106  apply->Draw();
107 
108  apply = new TGroupButton("APPLY","gStyle","",.375,.01,.625,.09);
109  apply->SetTextSize(0.55);
110  apply->SetBorderSize(3);
111  apply->SetFillColor(44);
112  apply->Draw();
113 
114  apply = new TGroupButton("APPLY","Close","",.70,.01,.95,.09);
115  apply->SetTextSize(0.55);
116  apply->SetBorderSize(3);
117  apply->SetFillColor(44);
118  apply->Draw();
119 }
120 
121 
122 ////////////////////////////////////////////////////////////////////////////////
123 /// Set world coordinate system for the pad
124 
125 void TDialogCanvas::Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
126 {
127  TPad::Range(x1,y1,x2,y2);
128 }
129 
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Recursively remove object from a pad and its sub-pads
133 
134 void TDialogCanvas::RecursiveRemove(TObject *obj)
135 {
136  TPad::RecursiveRemove(obj);
137  if (fRefObject == obj) fRefObject = 0;
138  if (fRefPad == obj) fRefPad = 0;
139 }