Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TFrameEditor.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Ilka Antcheva 08/03/05
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/** \class TFrameEditor
15 \ingroup ged
16
17Editor of frame objects.
18
19Frame border can be set to sunken, raised or no border.
20Border size can be set for sunken or rized frames (1-15 pixels).
21
22*/
23
24#include "TFrameEditor.h"
25#include "TGedEditor.h"
26#include "TGComboBox.h"
27#include "TGButtonGroup.h"
28#include "TGLabel.h"
29#include "TFrame.h"
30#include "TVirtualPad.h"
31
32
37
38
39////////////////////////////////////////////////////////////////////////////////
40/// Constructor of TFrame editor GUI.
41
43 Int_t height, UInt_t options, Pixel_t back)
44 : TGedFrame(p, width, height, options | kVerticalFrame, back)
45{
46 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
47 TGButtonGroup *bgr = new TGButtonGroup(f2,3,1,3,0, "Frame Border Mode");
49 fBmode = new TGRadioButton(bgr, " Sunken", 77);
50 fBmode->SetToolTipText("Set a sunken border of the frame");
51 fBmode0 = new TGRadioButton(bgr, " No border", 78);
52 fBmode0->SetToolTipText("Set no border of the frame");
53 fBmode1 = new TGRadioButton(bgr, " Raised", 79);
54 fBmode1->SetToolTipText("Set a raised border of the frame");
55 bgr->SetButton(79, kTRUE);
56 fBmodelh = new TGLayoutHints(kLHintsLeft, 0,0,3,0);
58 bgr->Show();
60 f2->AddFrame(bgr, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4, 1, 0, 0));
61 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
62
63 TGCompositeFrame *f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
64 TGLabel *fSizeLbl = new TGLabel(f3, "Size:");
65 f3->AddFrame(fSizeLbl, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 6, 1, 0, 0));
67 fBsize->Resize(92, 20);
68 f3->AddFrame(fBsize, new TGLayoutHints(kLHintsLeft, 13, 1, 0, 0));
69 fBsize->Associate(this);
70 AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Destructor of frame editor.
75
77{
78 // children of TGButonGroup are not deleted
79 delete fBmode;
80 delete fBmode0;
81 delete fBmode1;
82 delete fBmodelh;
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Connect signals to slots.
87
89{
90 fBmode->Connect("Toggled(Bool_t)","TFrameEditor",this,"DoBorderMode()");
91 fBmode0->Connect("Toggled(Bool_t)","TFrameEditor",this,"DoBorderMode()");
92 fBmode1->Connect("Toggled(Bool_t)","TFrameEditor",this,"DoBorderMode()");
93 fBsize->Connect("Selected(Int_t)", "TFrameEditor", this, "DoBorderSize(Int_t)");
94
95 fInit = kFALSE;
96}
97
98////////////////////////////////////////////////////////////////////////////////
99/// Pick up the frame attributes.
100
102{
103 fFrame = (TFrame *)obj;
104
105 Int_t par;
106
107 par = fFrame->GetBorderMode();
108 if (par == -1) fBmode->SetState(kButtonDown, kTRUE);
109 else if (par == 1) fBmode1->SetState(kButtonDown, kTRUE);
110 else fBmode0->SetState(kButtonDown, kTRUE);
111
112 par = fFrame->GetBorderSize();
113 if (par < 1) par = 1;
114 if (par > 16) par = 16;
115 fBsize->Select(par, kFALSE);
116
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// Slot connected to the border mode settings.
122
124{
125 Int_t mode = 0;
126 if (fBmode->GetState() == kButtonDown) mode = -1;
127 else if (fBmode0->GetState() == kButtonDown) mode = 0;
128 else mode = 1;
129
130 if (!mode) {
131 fBsize->SetEnabled(kFALSE);
132 } else {
133 fBsize->SetEnabled(kTRUE);
134 }
135 fFrame->SetBorderMode(mode);
136 Update();
137 gPad->Modified();
138 gPad->Update();
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Slot connected to the border size settings.
143
145{
146 fFrame->SetBorderSize(size);
147 Update();
148}
@ kChildFrame
Definition GuiTypes.h:380
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFitWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:383
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
EFrameWid
@ kFR_BSIZE
@ kFR_BMODE
@ kButtonDown
Definition TGButton.h:54
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsTop
Definition TGLayout.h:27
#define gPad
TFrame * fFrame
TGRadioButton * fBmode
set sinken frame border mode
TGLineWidthComboBox * fBsize
set frame border size
~TFrameEditor() override
Destructor of frame editor.
virtual void DoBorderMode()
Slot connected to the border mode settings.
virtual void DoBorderSize(Int_t size)
Slot connected to the border size settings.
void SetModel(TObject *obj) override
Pick up the frame attributes.
TGRadioButton * fBmode0
set no border
TFrameEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of TFrame editor GUI.
TGLayoutHints * fBmodelh
layout hints for border mode buttons
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGRadioButton * fBmode1
set raised frame border mode
Define a Frame.
Definition TFrame.h:19
Organizes TGButton widgets in a group.
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=nullptr)
Set layout hints for the specified button or if button=0 for all buttons.
virtual void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive,...
virtual void Show()
Show group of 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 AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
TGCompositeFrame(const TGCompositeFrame &)=delete
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1035
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
The TGLineWidthComboBox user callable and it creates a combobox for selecting the line width.
Definition TGComboBox.h:158
Selects different options.
Definition TGButton.h:321
ROOT GUI Window base class.
Definition TGWindow.h:23
TGedFrame(const TGedFrame &)=delete
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:71
Mother of all ROOT objects.
Definition TObject.h:42