Logo ROOT  
Reference Guide
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 "TStyle.h"
16 
18 
19 /** \class TDialogCanvas
20 \ingroup gpad
21 
22 A canvas specialized to set attributes.
23 
24 It contains, in general, TGroupButton objects.
25 When the APPLY button is executed, the actions corresponding
26 to the active buttons are executed via the Interpreter.
27 
28 See examples in TAttLineCanvas, TAttFillCanvas, TAttTextCanvas, TAttMarkerCanvas
29 */
30 
31 ////////////////////////////////////////////////////////////////////////////////
32 /// DialogCanvas default constructor
33 
35 {
36  fRefObject = 0;
37  fRefPad = 0;
38 }
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// DialogCanvas constructor
42 
43 TDialogCanvas::TDialogCanvas(const char *name, const char *title, Int_t ww, Int_t wh)
44  : TCanvas(name,title,-ww,wh)
45 {
46  SetFillColor(36);
47  fRefObject = 0;
48  fRefPad = 0;
49 }
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// DialogCanvas constructor
53 
54 TDialogCanvas::TDialogCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy, UInt_t ww, UInt_t wh)
55  : TCanvas(name,title,-wtopx,wtopy,ww,wh)
56 {
57  SetFillColor(36);
58  fRefObject = 0;
59  fRefPad = 0;
60 }
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// DialogCanvas default destructor
64 
66 {
67 }
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// Called when the APPLY button is executed
71 
72 void TDialogCanvas::Apply(const char *action)
73 {
74  if (!fRefPad) return;
76 
77  TIter next(fPrimitives);
78  TObject *refobj = fRefObject;
79  TObject *obj;
80  TGroupButton *button;
81  if (!strcmp(action,"gStyle")) fRefObject = gStyle;
82 
83  while ((obj = next())) {
84  if (obj->InheritsFrom(TGroupButton::Class())) {
85  button = (TGroupButton*)obj;
86  if (button->GetBorderMode() < 0) button->ExecuteAction();
87  }
88  }
89  fRefObject = refobj;
90  if (!gROOT->GetSelectedPad()) return;
91  gROOT->GetSelectedPad()->Modified();
92  gROOT->GetSelectedPad()->Update();
93 }
94 
95 
96 ////////////////////////////////////////////////////////////////////////////////
97 /// Create APPLY, gStyle and CLOSE buttons
98 
100 {
101  TGroupButton *apply = new TGroupButton("APPLY","Apply","",.05,.01,.3,.09);
102  apply->SetTextSize(0.55);
103  apply->SetBorderSize(3);
104  apply->SetFillColor(44);
105  apply->Draw();
106 
107  apply = new TGroupButton("APPLY","gStyle","",.375,.01,.625,.09);
108  apply->SetTextSize(0.55);
109  apply->SetBorderSize(3);
110  apply->SetFillColor(44);
111  apply->Draw();
112 
113  apply = new TGroupButton("APPLY","Close","",.70,.01,.95,.09);
114  apply->SetTextSize(0.55);
115  apply->SetBorderSize(3);
116  apply->SetFillColor(44);
117  apply->Draw();
118 }
119 
120 
121 ////////////////////////////////////////////////////////////////////////////////
122 /// Set world coordinate system for the pad
123 
125 {
126  TPad::Range(x1,y1,x2,y2);
127 }
128 
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 /// Recursively remove object from a pad and its sub-pads
132 
134 {
136  if (fRefObject == obj) fRefObject = 0;
137  if (fRefPad == obj) fRefPad = 0;
138 }
TDialogCanvas::Range
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Set world coordinate system for the pad.
Definition: TDialogCanvas.cxx:124
TDialogCanvas.h
TDialogCanvas::fRefObject
TObject * fRefObject
Pointer to object to set attributes.
Definition: TDialogCanvas.h:32
TPad::Range
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Set world coordinate system for the pad.
Definition: TPad.cxx:5174
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TDialogCanvas::Apply
virtual void Apply(const char *action="")
Called when the APPLY button is executed.
Definition: TDialogCanvas.cxx:72
TStyle.h
TObject::InheritsFrom
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
TDialogCanvas::RecursiveRemove
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from a pad and its sub-pads.
Definition: TDialogCanvas.cxx:133
kWatch
@ kWatch
Definition: GuiTypes.h:374
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TROOT.h
TPad::GetBorderMode
virtual Short_t GetBorderMode() const
Definition: TPad.h:193
gStyle
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
SetFillColor
h1 SetFillColor(kGreen)
TPad::fPrimitives
TList * fPrimitives
->List of primitives (subpads)
Definition: TPad.h:103
TGroupButton.h
TDialogCanvas::~TDialogCanvas
virtual ~TDialogCanvas()
DialogCanvas default destructor.
Definition: TDialogCanvas.cxx:65
TDialogCanvas::fRefPad
TPad * fRefPad
Pad containing object.
Definition: TDialogCanvas.h:33
TGroupButton::ExecuteAction
virtual void ExecuteAction()
Execute action of this button.
Definition: TGroupButton.cxx:104
unsigned int
TDialogCanvas::BuildStandardButtons
virtual void BuildStandardButtons()
Create APPLY, gStyle and CLOSE buttons.
Definition: TDialogCanvas.cxx:99
Double_t
double Double_t
Definition: RtypesCore.h:59
TCanvas
Definition: TCanvas.h:23
TObject
Definition: TObject.h:37
name
char name[80]
Definition: TGX11.cxx:110
TGroupButton
Definition: TGroupButton.h:18
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
TIter
Definition: TCollection.h:233
TPad::RecursiveRemove
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from a pad and its sub-pads.
Definition: TPad.cxx:5232
TDialogCanvas::TDialogCanvas
TDialogCanvas()
DialogCanvas default constructor.
Definition: TDialogCanvas.cxx:34
TCanvas::SetCursor
virtual void SetCursor(ECursor cursor)
Set cursor.
Definition: TCanvas.cxx:2004
TDialogCanvas
Definition: TDialogCanvas.h:19
Class
void Class()
Definition: Class.C:29
gROOT
#define gROOT
Definition: TROOT.h:406
int