Logo ROOT   6.14/05
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 "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 
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 
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
->List of primitives (subpads)
Definition: TPad.h:106
virtual void SetCursor(ECursor cursor)
Set cursor.
Definition: TCanvas.cxx:1891
R__EXTERN TStyle * gStyle
Definition: TStyle.h:406
virtual void BuildStandardButtons()
Create APPLY, gStyle and CLOSE buttons.
#define gROOT
Definition: TROOT.h:410
int Int_t
Definition: RtypesCore.h:41
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from a pad and its sub-pads.
Definition: TPad.cxx:5179
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.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
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:5121
virtual void ExecuteAction()
Execute action of this button.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
unsigned int UInt_t
Definition: RtypesCore.h:42
The Canvas class.
Definition: TCanvas.h:31
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from a pad and its sub-pads.
TPad * fRefPad
Pad containing object.
Definition: TDialogCanvas.h:27
static const double x1[5]
#define ClassImp(name)
Definition: Rtypes.h:359
double Double_t
Definition: RtypesCore.h:55
TObject * fRefObject
Pointer to object to set attributes.
Definition: TDialogCanvas.h:26
A canvas specialized to set attributes.
Definition: TDialogCanvas.h:19
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Short_t GetBorderMode() const
Definition: TPad.h:196
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:318
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:46
TDialogCanvas()
DialogCanvas default constructor.
decltype(auto) constexpr apply(F &&f, Tuple &&t)
char name[80]
Definition: TGX11.cxx:109
A specialized TButton used in a group of Buttons.
Definition: TGroupButton.h:18