Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
37 ClassImp(TFrameEditor);
38 
39 enum EFrameWid {
40  kFR_BSIZE,
41  kFR_BMODE
42 };
43 
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// Constructor of TFrame editor GUI.
47 
48 TFrameEditor::TFrameEditor(const TGWindow *p, Int_t width,
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");
54  bgr->SetRadioButtonExclusive(kTRUE);
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);
63  bgr->SetLayoutHints(fBmodelh, fBmode);
64  bgr->Show();
65  bgr->ChangeOptions(kFitWidth|kChildFrame|kVerticalFrame);
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 
82 TFrameEditor::~TFrameEditor()
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 
94 void TFrameEditor::ConnectSignals2Slots()
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 
107 void TFrameEditor::SetModel(TObject* obj)
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);
116  else fBmode0->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 
123  if (fInit) ConnectSignals2Slots();
124 }
125 
126 ////////////////////////////////////////////////////////////////////////////////
127 /// Slot connected to the border mode settings.
128 
129 void TFrameEditor::DoBorderMode()
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) {
137  fBsize->SetEnabled(kFALSE);
138  } else {
139  fBsize->SetEnabled(kTRUE);
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 
150 void TFrameEditor::DoBorderSize(Int_t size)
151 {
152  fFrame->SetBorderSize(size);
153  Update();
154 }