ROOT  6.06/09
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 
39 enum EFrameWid {
40  kFR_BSIZE,
41  kFR_BMODE
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 {
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));
72  fBsize = new TGLineWidthComboBox(f3, kFR_BSIZE);
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 }
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
double par[1]
Definition: unuranDistr.cxx:38
TGRadioButton * fBmode
Definition: TFrameEditor.h:39
virtual void ConnectSignals2Slots()
Connect signals to slots.
virtual ~TFrameEditor()
Destructor of frame editor.
virtual void SetBorderMode(Short_t bordermode)
Definition: TWbox.h:62
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 SetModel(TObject *obj)
Pick up the frame attributes.
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void DoBorderMode()
Slot connected to the border mode settings.
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set radio button state.
Definition: TGButton.cxx:1563
ULong_t Pixel_t
Definition: GuiTypes.h:41
TGRadioButton * fBmode1
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 Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
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:443
TGCompositeFrame(const TGCompositeFrame &)
virtual void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive, and other buttons according to IsExclusive().
virtual void SetBorderSize(Short_t bordersize)
Definition: TWbox.h:63
ClassImp(TFrameEditor) enum EFrameWid
TGLineWidthComboBox * fBsize
Definition: TFrameEditor.h:43
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:1135
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=0)
Set layout hints for the specified button or if button=0 for all buttons.
virtual EButtonState GetState() const
Definition: TGButton.h:116
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:1025
virtual void SetEnabled(Bool_t on=kTRUE)
Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
Definition: TGComboBox.cxx:628
Define a Frame.
Definition: TFrame.h:29
TGRadioButton * fBmode0
Definition: TFrameEditor.h:40
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 DoBorderSize(Int_t size)
Slot connected to the border size settings.
virtual void Show()
Show group of buttons.
Mother of all ROOT objects.
Definition: TObject.h:58
TFrame * fFrame
Definition: TFrameEditor.h:38
Bool_t fInit
Definition: TGedFrame.h:55
double f2(const double *x)
#define gPad
Definition: TVirtualPad.h:288
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
Short_t GetBorderMode() const
Definition: TWbox.h:51
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
TGLayoutHints * fBmodelh
Definition: TFrameEditor.h:42
Short_t GetBorderSize() const
Definition: TWbox.h:52