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-2021, 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
22A canvas specialized to set attributes.
23
24It contains, in general, TGroupButton objects.
25When the APPLY button is executed, the actions corresponding
26to the active buttons are executed via the Interpreter.
27
28See examples in TAttLineCanvas, TAttFillCanvas, TAttTextCanvas, TAttMarkerCanvas
29*/
30
31////////////////////////////////////////////////////////////////////////////////
32/// DialogCanvas default constructor
33
35{
36 fRefObject = nullptr;
37 fRefPad = nullptr;
38}
39
40////////////////////////////////////////////////////////////////////////////////
41/// DialogCanvas constructor
42
43TDialogCanvas::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 = nullptr;
48 fRefPad = nullptr;
49}
50
51////////////////////////////////////////////////////////////////////////////////
52/// DialogCanvas constructor
53
54TDialogCanvas::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 = nullptr;
59 fRefPad = nullptr;
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// DialogCanvas default destructor
64
66{
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// Called when the APPLY button is executed
71
72void 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())) {
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}
int Int_t
Definition: CPyCppyy.h:43
unsigned int UInt_t
Definition: CPyCppyy.h:44
void Class()
Definition: Class.C:29
@ kWatch
Definition: GuiTypes.h:375
static const double x2[5]
static const double x1[5]
double Double_t
Definition: RtypesCore.h:59
#define ClassImp(name)
Definition: Rtypes.h:364
#define gROOT
Definition: TROOT.h:404
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
The Canvas class.
Definition: TCanvas.h:23
void SetCursor(ECursor cursor) override
Set cursor.
Definition: TCanvas.cxx:2006
A canvas specialized to set attributes.
Definition: TDialogCanvas.h:19
virtual ~TDialogCanvas()
DialogCanvas default destructor.
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from a pad and its sub-pads.
TObject * fRefObject
Pointer to object to set attributes.
Definition: TDialogCanvas.h:26
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Set world coordinate system for the pad.
TPad * fRefPad
Pad containing object.
Definition: TDialogCanvas.h:27
virtual void Apply(const char *action="")
Called when the APPLY button is executed.
TDialogCanvas()
DialogCanvas default constructor.
virtual void BuildStandardButtons()
Create APPLY, gStyle and CLOSE buttons.
A specialized TButton used in a group of Buttons.
Definition: TGroupButton.h:17
virtual void ExecuteAction()
Execute action of this button.
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
Short_t GetBorderMode() const override
Definition: TPad.h:193
void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Set world coordinate system for the pad.
Definition: TPad.cxx:5197
void RecursiveRemove(TObject *obj) override
Recursively remove object from a pad and its sub-pads.
Definition: TPad.cxx:5255
TList * fPrimitives
->List of primitives (subpads)
Definition: TPad.h:103
static const std::string name("name")