Logo ROOT  
Reference Guide
TPadEditor.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Ilka Antcheva 24/06/04
3
4/*************************************************************************
5 * Copyright (C) 1995-2002, 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
13//////////////////////////////////////////////////////////////////////////
14// //
15// TPadEditor //
16// //
17// Editor of pad/canvas objects. //
18// color and fill style, //
19// 'Edit' check box sets pad/canvad editable, //
20// 'Crosshair' sets a cross hair on the pad, //
21// 'Fixed aspect ratio' can be set when resizing the pad //
22// 'TickX' and 'TickY' set ticks along the X and Y axis //
23// 'GridX' and 'GridY' set a grid along the X and Y axis //
24// pad/canvas border size can be set if a sinken or a raised //
25// border mode is selected; no border mode can be set to //
26// //
27//////////////////////////////////////////////////////////////////////////
28//Begin_Html
29/*
30<img src="gif/TPadEditor.gif">
31*/
32//End_Html
33
34#include "TPadEditor.h"
35#include "TGedEditor.h"
36#include "TGComboBox.h"
37#include "TGButtonGroup.h"
38#include "TGLabel.h"
39#include "TCanvas.h"
40
42
43enum EPadWid {
57};
58
59
60////////////////////////////////////////////////////////////////////////////////
61/// Constructor of TPad editor GUI.
62
64 Int_t height, UInt_t options, Pixel_t back)
65 : TGedFrame(p, width, height, options | kVerticalFrame, back)
66{
67 fPadPointer = 0;
68
69 MakeTitle("Pad/Canvas");
70
71 fFixedAR = new TGCheckButton(this, "Fixed aspect ratio", kPAD_FAR);
72 fFixedAR->SetToolTipText("Set fixed aspect ratio");
73 AddFrame(fFixedAR, new TGLayoutHints(kLHintsTop, 4, 1, 2, 1));
74
75 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
77 fCrosshair = new TGCheckButton(f3, "Crosshair", kPAD_CROSS);
78 fCrosshair->SetToolTipText("Set crosshair");
79 f3->AddFrame(fCrosshair, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
80 fGridX = new TGCheckButton(f3, "GridX", kPAD_GRIDX);
81 fGridX->SetToolTipText("Set grid along X");
82 f3->AddFrame(fGridX, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
83 fTickX = new TGCheckButton(f3, "TickX", kPAD_TICKX);
84 fTickX->SetToolTipText("Set tick marks along X");
85 f3->AddFrame(fTickX, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
86 f2->AddFrame(f3, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
87
89 fEditable = new TGCheckButton(f4, "Edit", kPAD_EDIT);
90 fEditable->SetToolTipText("Set editable mode");
91 f4->AddFrame(fEditable, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
92 fGridY = new TGCheckButton(f4, "GridY", kPAD_GRIDY);
93 fGridY->SetToolTipText("Set grid along Y");
94 f4->AddFrame(fGridY, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
95 fTickY = new TGCheckButton(f4, "TickY", kPAD_TICKY);
96 fTickY->SetToolTipText("Set tick marks along Y");
97 f4->AddFrame(fTickY, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
98 f2->AddFrame(f4, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
99
100 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
101
102 MakeTitle("Log Scale");
103
104 TGCompositeFrame *f5 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
105 fLogX = new TGCheckButton(f5, ":X", kPAD_LOGX);
106 fLogX->SetToolTipText("Set logarithmic scale along X");
107 f5->AddFrame(fLogX, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
108 fLogY = new TGCheckButton(f5, ":Y", kPAD_LOGY);
109 fLogY->SetToolTipText("Set logarithmic scale along Y");
110 f5->AddFrame(fLogY, new TGLayoutHints(kLHintsTop, 15, 1, 1, 1));
111 fLogZ = new TGCheckButton(f5, ":Z", kPAD_LOGZ);
112 fLogZ->SetToolTipText("Set logarithmic scale along Z");
113 f5->AddFrame(fLogZ, new TGLayoutHints(kLHintsTop, 15, 1, 1, 1));
114 AddFrame(f5, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
115
116 TGCompositeFrame *f6 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
117 fBgroup = new TGButtonGroup(f6,3,1,3,0, "Border Mode");
119 fBmode = new TGRadioButton(fBgroup, " Sunken border", 77);
120 fBmode->SetToolTipText("Set a sinken border of the pad/canvas");
121 fBmode0 = new TGRadioButton(fBgroup, " No border", 78);
122 fBmode0->SetToolTipText("Set no border of the pad/canvas");
123 fBmode1 = new TGRadioButton(fBgroup, " Raised border", 79);
124 fBmode1->SetToolTipText("Set a raised border of the pad/canvas");
125 fBmodelh = new TGLayoutHints(kLHintsLeft, 0,0,3,0);
129 AddFrame(f6, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
130
131 TGCompositeFrame *f7 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
132 TGLabel *fSizeLbl = new TGLabel(f7, "Size:");
133 f7->AddFrame(fSizeLbl, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 6, 1, 0, 0));
135 fBsize->Resize(92, 20);
136 f7->AddFrame(fBsize, new TGLayoutHints(kLHintsLeft, 13, 1, 0, 0));
137 fBsize->Associate(this);
138 AddFrame(f7, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
139
140 fInit = kTRUE;
141}
142
143////////////////////////////////////////////////////////////////////////////////
144/// Destructor of fill editor.
145
147{
148 // children of TGButonGroup are not deleted
149 delete fBmode;
150 delete fBmode0;
151 delete fBmode1;
152 delete fBmodelh;
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Connect signals to slots.
157
159{
160 fFixedAR->Connect("Toggled(Bool_t)","TPadEditor",this,"DoFixedAspectRatio(Bool_t)");
161 fCrosshair->Connect("Toggled(Bool_t)","TPadEditor",this,"DoCrosshair(Bool_t)");
162 fEditable->Connect("Toggled(Bool_t)","TPadEditor",this,"DoEditable(Bool_t)");
163 fGridX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoGridX(Bool_t)");
164 fGridY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoGridY(Bool_t)");
165 fTickX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoTickX(Bool_t)");
166 fTickY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoTickY(Bool_t)");
167 fLogX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogX(Bool_t)");
168 fLogY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogY(Bool_t)");
169 fLogZ->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogZ(Bool_t)");
170 fBgroup->Connect("Clicked(Int_t)","TPadEditor",this,"DoBorderMode()");
171 fBsize->Connect("Selected(Int_t)", "TPadEditor", this, "DoBorderSize(Int_t)");
172 fInit = kFALSE;
173}
174
175////////////////////////////////////////////////////////////////////////////////
176/// Pick up the used fill attributes.
177
179{
180 if (!obj || !obj->InheritsFrom("TPad"))
181 return;
182 fPadPointer = (TPad *)obj;
184 Bool_t on;
185
187 if (on) fFixedAR->SetState(kButtonDown);
189
193
194 on = fPadPointer->IsEditable();
197
198 on = fPadPointer->GetGridx();
199 if (on) fGridX->SetState(kButtonDown);
201
202 on = fPadPointer->GetGridy();
203 if (on) fGridY->SetState(kButtonDown);
205
206 Int_t par;
207 par = fPadPointer->GetLogx();
208 if (par) fLogX->SetState(kButtonDown);
209 else fLogX->SetState(kButtonUp);
210
211 par = fPadPointer->GetLogy();
212 if (par) fLogY->SetState(kButtonDown);
213 else fLogY->SetState(kButtonUp);
214
215 par = fPadPointer->GetLogz();
216 if (par) fLogZ->SetState(kButtonDown);
217 else fLogZ->SetState(kButtonUp);
218
219 par = fPadPointer->GetTickx();
220 if (par) fTickX->SetState(kButtonDown);
222
223 par = fPadPointer->GetTicky();
224 if (par) fTickY->SetState(kButtonDown);
226
227 par = fPadPointer->GetBorderMode();
228 if (par == -1) {
229 fBgroup->SetButton(77, kTRUE);
231 } else if (par == 1) {
232 fBgroup->SetButton(79, kTRUE);
234 } else {
235 fBgroup->SetButton(78, kTRUE);
237 }
238 par = fPadPointer->GetBorderSize();
239 if (par < 1) par = 1;
240 if (par > 16) par = 16;
241 fBsize->Select(par);
242
244
246}
247
248////////////////////////////////////////////////////////////////////////////////
249/// Exclude TAttLineEditor from this interface.
250
252{
255}
256
257////////////////////////////////////////////////////////////////////////////////
258/// Slot connected to the check box 'Editable'.
259
261{
262 if (fAvoidSignal) return;
264 Update();
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Slot connected to the check box 'Crosshair'.
269
271{
272 if (fAvoidSignal) return;
274 Update();
275}
276
277////////////////////////////////////////////////////////////////////////////////
278/// Slot connected to the check box 'Fixed aspect ratio'.
279
281{
282 if (fAvoidSignal) return;
284 Update();
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Slot connected to the check box 'GridX'.
289
291{
292 if (fAvoidSignal) return;
294 Update();
295}
296
297////////////////////////////////////////////////////////////////////////////////
298/// Slot connected to the check box 'GridY'.
299
301{
302 if (fAvoidSignal) return;
304 Update();
305}
306
307////////////////////////////////////////////////////////////////////////////////
308/// Slot connected to the check box 'LogX'.
309
311{
312 if (fAvoidSignal) return;
313 fPadPointer->SetLogx(on);
314 Update();
315}
316
317////////////////////////////////////////////////////////////////////////////////
318/// Slot connected to the check box 'LogY'.
319
321{
322 if (fAvoidSignal) return;
323 fPadPointer->SetLogy(on);
324 Update();
325}
326
327////////////////////////////////////////////////////////////////////////////////
328/// Slot connected to the check box 'LogZ'.
329
331{
332 if (fAvoidSignal) return;
333 fPadPointer->SetLogz(on);
334 Update();
335}
336
337////////////////////////////////////////////////////////////////////////////////
338/// Slot connected to the check box 'TickX'.
339
341{
342 if (fAvoidSignal) return;
344 Update();
345}
346
347////////////////////////////////////////////////////////////////////////////////
348/// Slot connected to the check box 'TickY'.
349
351{
352 if (fAvoidSignal) return;
354 Update();
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Slot connected to the border mode settings.
359
361{
362 if (fAvoidSignal) return;
363 Int_t mode = 0;
364 if (fBmode->GetState() == kButtonDown) mode = -1;
365 else if (fBmode0->GetState() == kButtonDown) mode = 0;
366 else mode = 1;
367
368 if (!mode) {
370 } else {
372 }
374 Update();
375}
376
377////////////////////////////////////////////////////////////////////////////////
378/// Slot connected to the border size settings.
379
381{
382 if (fAvoidSignal) return;
384 Update();
385}
void Class()
Definition: Class.C:29
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kButtonUp
Definition: TGButton.h:53
@ kChildFrame
Definition: TGFrame.h:57
@ kVerticalFrame
Definition: TGFrame.h:59
@ kFitWidth
Definition: TGFrame.h:64
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsCenterY
Definition: TGLayout.h:35
@ kLHintsTop
Definition: TGLayout.h:34
EPadWid
Definition: TPadEditor.cxx:43
@ kPAD_TICKX
Definition: TPadEditor.cxx:53
@ kPAD_BSIZE
Definition: TPadEditor.cxx:55
@ kPAD_FAR
Definition: TPadEditor.cxx:45
@ kPAD_TICKY
Definition: TPadEditor.cxx:54
@ kPAD_LOGX
Definition: TPadEditor.cxx:50
@ kPAD_CROSS
Definition: TPadEditor.cxx:47
@ kPAD_GRIDX
Definition: TPadEditor.cxx:48
@ kPAD_LOGY
Definition: TPadEditor.cxx:51
@ kPAD_EDIT
Definition: TPadEditor.cxx:46
@ kPAD_LOGZ
Definition: TPadEditor.cxx:52
@ kCOLOR
Definition: TPadEditor.cxx:44
@ kPAD_BMODE
Definition: TPadEditor.cxx:56
@ kPAD_GRIDY
Definition: TPadEditor.cxx:49
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
virtual void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive,...
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=0)
Set layout hints for the specified button or if button=0 for all buttons.
virtual void SetButton(Int_t id, Bool_t down=kTRUE)
Sets the button with id to be on/down, and if this is an exclusive group, all other button in the gro...
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
virtual EButtonState GetState() const
Definition: TGButton.h:112
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
Definition: TGComboBox.cxx:450
virtual void SetEnabled(Bool_t on=kTRUE)
Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
Definition: TGComboBox.cxx:638
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:1025
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
void ExcludeClassEditor(TClass *cl, Bool_t recurse=kFALSE)
Exclude editor for class cl from current construction.
Definition: TGedEditor.cxx:578
virtual void ActivateBaseClassEditors(TClass *cl)
Provide list of editors for base-classes.
Definition: TGedFrame.cxx:168
TGedEditor * fGedEditor
Definition: TGedFrame.h:54
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
Bool_t fAvoidSignal
Definition: TGedFrame.h:56
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:443
virtual void ConnectSignals2Slots()
Connect signals to slots.
Definition: TPadEditor.cxx:158
TGRadioButton * fBmode0
Definition: TPadEditor.h:47
virtual void DoGridX(Bool_t on)
Slot connected to the check box 'GridX'.
Definition: TPadEditor.cxx:290
TGButtonGroup * fBgroup
Definition: TPadEditor.h:51
virtual void DoLogY(Bool_t on)
Slot connected to the check box 'LogY'.
Definition: TPadEditor.cxx:320
virtual void DoEditable(Bool_t on)
Slot connected to the check box 'Editable'.
Definition: TPadEditor.cxx:260
TGCheckButton * fLogX
Definition: TPadEditor.h:41
TGCheckButton * fFixedAR
Definition: TPadEditor.h:38
virtual void SetModel(TObject *obj)
Pick up the used fill attributes.
Definition: TPadEditor.cxx:178
TGCheckButton * fLogZ
Definition: TPadEditor.h:43
virtual void DoBorderSize(Int_t size)
Slot connected to the border size settings.
Definition: TPadEditor.cxx:380
virtual void DoCrosshair(Bool_t on)
Slot connected to the check box 'Crosshair'.
Definition: TPadEditor.cxx:270
virtual void DoTickY(Bool_t on)
Slot connected to the check box 'TickY'.
Definition: TPadEditor.cxx:350
TGCheckButton * fLogY
Definition: TPadEditor.h:42
TGLineWidthComboBox * fBsize
Definition: TPadEditor.h:50
virtual void DoBorderMode()
Slot connected to the border mode settings.
Definition: TPadEditor.cxx:360
TGCheckButton * fTickX
Definition: TPadEditor.h:44
virtual ~TPadEditor()
Destructor of fill editor.
Definition: TPadEditor.cxx:146
TGRadioButton * fBmode1
Definition: TPadEditor.h:48
TGCheckButton * fGridY
Definition: TPadEditor.h:40
TGCheckButton * fCrosshair
Definition: TPadEditor.h:37
virtual void DoFixedAspectRatio(Bool_t on)
Slot connected to the check box 'Fixed aspect ratio'.
Definition: TPadEditor.cxx:280
TPad * fPadPointer
Definition: TPadEditor.h:35
virtual void DoLogX(Bool_t on)
Slot connected to the check box 'LogX'.
Definition: TPadEditor.cxx:310
TGCheckButton * fGridX
Definition: TPadEditor.h:39
virtual void DoGridY(Bool_t on)
Slot connected to the check box 'GridY'.
Definition: TPadEditor.cxx:300
TPadEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of TPad editor GUI.
Definition: TPadEditor.cxx:63
TGRadioButton * fBmode
Definition: TPadEditor.h:46
virtual void DoTickX(Bool_t on)
Slot connected to the check box 'TickX'.
Definition: TPadEditor.cxx:340
TGCheckButton * fEditable
Definition: TPadEditor.h:36
virtual void ActivateBaseClassEditors(TClass *cl)
Exclude TAttLineEditor from this interface.
Definition: TPadEditor.cxx:251
TGCheckButton * fTickY
Definition: TPadEditor.h:45
virtual void DoLogZ(Bool_t on)
Slot connected to the check box 'LogZ'.
Definition: TPadEditor.cxx:330
TGLayoutHints * fBmodelh
Definition: TPadEditor.h:49
The most important graphics class in the ROOT system.
Definition: TPad.h:29
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.
Definition: TPad.cxx:5864
virtual void SetGridx(Int_t value=1)
Definition: TPad.h:331
Int_t GetLogx() const
Definition: TPad.h:253
virtual Bool_t HasCrosshair() const
Return kTRUE if the crosshair has been activated (via SetCrosshair).
Definition: TPad.cxx:6389
virtual void SetGridy(Int_t value=1)
Definition: TPad.h:332
virtual void SetLogx(Int_t value=1)
Set Lin/Log scale for X.
Definition: TPad.cxx:5850
Int_t GetLogz() const
Definition: TPad.h:255
virtual Bool_t IsEditable() const
Definition: TPad.h:269
Int_t GetTicky() const
Definition: TPad.h:236
Int_t GetTickx() const
Definition: TPad.h:235
virtual void SetCrosshair(Int_t crhair=1)
Set crosshair active/inactive.
Definition: TPad.cxx:6411
virtual void SetTickx(Int_t value=1)
Definition: TPad.h:351
virtual void SetBorderMode(Short_t bordermode)
Definition: TPad.h:320
virtual void SetFixedAspectRatio(Bool_t fixed=kTRUE)
Fix pad aspect ratio to current value if fixed is true.
Definition: TPad.cxx:5795
virtual Short_t GetBorderMode() const
Definition: TPad.h:196
virtual Short_t GetBorderSize() const
Definition: TPad.h:197
virtual void SetTicky(Int_t value=1)
Definition: TPad.h:352
Bool_t GetGridx() const
Definition: TPad.h:232
Int_t GetLogy() const
Definition: TPad.h:254
virtual void SetLogz(Int_t value=1)
Set Lin/Log scale for Z.
Definition: TPad.cxx:5875
virtual void SetEditable(Bool_t mode=kTRUE)
Set pad editable yes/no If a pad is not editable:
Definition: TPad.cxx:5819
Bool_t HasFixedAspectRatio() const
Definition: TPad.h:267
virtual void SetBorderSize(Short_t bordersize)
Definition: TPad.h:321
Bool_t GetGridy() const
Definition: TPad.h:233
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:867