ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
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 
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 
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;
77 
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 
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 
126 {
127  TPad::Range(x1,y1,x2,y2);
128 }
129 
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Recursively remove object from a pad and its sub-pads
133 
135 {
137  if (fRefObject == obj) fRefObject = 0;
138  if (fRefPad == obj) fRefPad = 0;
139 }
TList * fPrimitives
Pointer to mother canvas.
Definition: TPad.h:123
virtual void SetCursor(ECursor cursor)
Set cursor.
Definition: TCanvas.cxx:1851
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
virtual void BuildStandardButtons()
Create APPLY, gStyle and CLOSE buttons.
#define gROOT
Definition: TROOT.h:344
int Int_t
Definition: RtypesCore.h:41
virtual Short_t GetBorderMode() const
Definition: TPad.h:200
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from a pad and its sub-pads.
Definition: TPad.cxx:4681
virtual void Draw(Option_t *option="")
Draw this button with its current attributes.
Definition: TButton.cxx:139
static const double x2[5]
void Class()
Definition: Class.C:29
virtual ~TDialogCanvas()
DialogCanvas default destructor.
virtual void Apply(const char *action="")
Called when the APPLY button is executed.
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
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:4623
virtual void ExecuteAction()
Execute action of this button.
unsigned int UInt_t
Definition: RtypesCore.h:42
The Canvas class.
Definition: TCanvas.h:48
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from a pad and its sub-pads.
static const double x1[5]
#define ClassImp(name)
Definition: Rtypes.h:279
double Double_t
Definition: RtypesCore.h:55
TObject * fRefObject
Definition: TDialogCanvas.h:38
A canvas specialized to set attributes.
Definition: TDialogCanvas.h:31
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Set world coordinate system for the pad.
virtual void SetBorderSize(Short_t bordersize)
Definition: TPad.h:317
virtual void SetTextSize(Float_t tsize=1)
Definition: TAttText.h:60
TObject * obj
A specialized TButton used in a group of Buttons.
Definition: TGroupButton.h:34