Logo ROOT  
Reference Guide
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// //
15// TFrameEditor //
16// //
17// Editor of frame objects. //
18// //
19// Frame border can be set to sunken, raised or no border. //
20// Border size can be set for sunken or rized frames (1-15 pixels). //
21// //
22//////////////////////////////////////////////////////////////////////////
23//Begin_Html
24/*
25<img src="gif/TFrameEditor.gif">
26*/
27//End_Html
28
29#include "TFrameEditor.h"
30#include "TGedEditor.h"
31#include "TGComboBox.h"
32#include "TGButtonGroup.h"
33#include "TGLabel.h"
34#include "TFrame.h"
35#include "TVirtualPad.h"
36
38
42};
43
44
45////////////////////////////////////////////////////////////////////////////////
46/// Constructor of TFrame editor GUI.
47
49 Int_t height, UInt_t options, Pixel_t back)
50 : TGedFrame(p, width, height, options | kVerticalFrame, back)
51{
52 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
53 TGButtonGroup *bgr = new TGButtonGroup(f2,3,1,3,0, "Frame Border Mode");
55 fBmode = new TGRadioButton(bgr, " Sunken", 77);
56 fBmode->SetToolTipText("Set a sunken border of the frame");
57 fBmode0 = new TGRadioButton(bgr, " No border", 78);
58 fBmode0->SetToolTipText("Set no border of the frame");
59 fBmode1 = new TGRadioButton(bgr, " Raised", 79);
60 fBmode1->SetToolTipText("Set a raised border of the frame");
61 bgr->SetButton(79, kTRUE);
62 fBmodelh = new TGLayoutHints(kLHintsLeft, 0,0,3,0);
64 bgr->Show();
66 f2->AddFrame(bgr, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4, 1, 0, 0));
67 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
68
69 TGCompositeFrame *f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
70 TGLabel *fSizeLbl = new TGLabel(f3, "Size:");
71 f3->AddFrame(fSizeLbl, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 6, 1, 0, 0));
73 fBsize->Resize(92, 20);
74 f3->AddFrame(fBsize, new TGLayoutHints(kLHintsLeft, 13, 1, 0, 0));
75 fBsize->Associate(this);
76 AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
77}
78
79////////////////////////////////////////////////////////////////////////////////
80/// Destructor of frame editor.
81
83{
84 // children of TGButonGroup are not deleted
85 delete fBmode;
86 delete fBmode0;
87 delete fBmode1;
88 delete fBmodelh;
89}
90
91////////////////////////////////////////////////////////////////////////////////
92/// Connect signals to slots.
93
95{
96 fBmode->Connect("Toggled(Bool_t)","TFrameEditor",this,"DoBorderMode()");
97 fBmode0->Connect("Toggled(Bool_t)","TFrameEditor",this,"DoBorderMode()");
98 fBmode1->Connect("Toggled(Bool_t)","TFrameEditor",this,"DoBorderMode()");
99 fBsize->Connect("Selected(Int_t)", "TFrameEditor", this, "DoBorderSize(Int_t)");
100
101 fInit = kFALSE;
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// Pick up the frame attributes.
106
108{
109 fFrame = (TFrame *)obj;
110
111 Int_t par;
112
113 par = fFrame->GetBorderMode();
114 if (par == -1) fBmode->SetState(kButtonDown, kTRUE);
115 else if (par == 1) fBmode1->SetState(kButtonDown, kTRUE);
117
118 par = fFrame->GetBorderSize();
119 if (par < 1) par = 1;
120 if (par > 16) par = 16;
121 fBsize->Select(par, kFALSE);
122
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// Slot connected to the border mode settings.
128
130{
131 Int_t mode = 0;
132 if (fBmode->GetState() == kButtonDown) mode = -1;
133 else if (fBmode0->GetState() == kButtonDown) mode = 0;
134 else mode = 1;
135
136 if (!mode) {
138 } else {
140 }
141 fFrame->SetBorderMode(mode);
142 Update();
143 gPad->Modified();
144 gPad->Update();
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Slot connected to the border size settings.
149
151{
152 fFrame->SetBorderSize(size);
153 Update();
154}
@ kChildFrame
Definition: GuiTypes.h:379
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kFitWidth
Definition: GuiTypes.h:386
@ kHorizontalFrame
Definition: GuiTypes.h:382
ULong_t Pixel_t
Definition: GuiTypes.h:39
const Bool_t kFALSE
Definition: RtypesCore.h:90
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
EFrameWid
@ kFR_BSIZE
@ kFR_BMODE
@ kButtonDown
Definition: TGButton.h:54
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsCenterY
Definition: TGLayout.h:35
@ kLHintsTop
Definition: TGLayout.h:34
#define gPad
Definition: TVirtualPad.h:287
TFrame * fFrame
Definition: TFrameEditor.h:36
TGRadioButton * fBmode
Definition: TFrameEditor.h:37
TGLineWidthComboBox * fBsize
Definition: TFrameEditor.h:41
TFrameEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of TFrame editor GUI.
virtual void DoBorderMode()
Slot connected to the border mode settings.
virtual void DoBorderSize(Int_t size)
Slot connected to the border size settings.
virtual ~TFrameEditor()
Destructor of frame editor.
TGRadioButton * fBmode0
Definition: TFrameEditor.h:38
virtual void SetModel(TObject *obj)
Pick up the frame attributes.
TGLayoutHints * fBmodelh
Definition: TFrameEditor.h:40
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGRadioButton * fBmode1
Definition: TFrameEditor.h:39
Define a Frame.
Definition: TFrame.h:19
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 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:397
virtual EButtonState GetState() const
Definition: TGButton.h:112
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:451
virtual void SetEnabled(Bool_t on=kTRUE)
Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
Definition: TGComboBox.cxx:639
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:1101
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:1027
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:589
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set radio button state.
Definition: TGButton.cxx:1565
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
Bool_t fInit
Definition: TGedFrame.h:53
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
Mother of all ROOT objects.
Definition: TObject.h:37
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:866
Short_t GetBorderSize() const
Definition: TWbox.h:41
Short_t GetBorderMode() const
Definition: TWbox.h:40
virtual void SetBorderMode(Short_t bordermode)
Definition: TWbox.h:51
virtual void SetBorderSize(Short_t bordersize)
Definition: TWbox.h:52