00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "TFrameEditor.h"
00030 #include "TGedEditor.h"
00031 #include "TGComboBox.h"
00032 #include "TGButtonGroup.h"
00033 #include "TGLabel.h"
00034 #include "TFrame.h"
00035 #include "TVirtualPad.h"
00036
00037 ClassImp(TFrameEditor)
00038
00039 enum EFrameWid {
00040 kFR_BSIZE,
00041 kFR_BMODE
00042 };
00043
00044
00045
00046 TFrameEditor::TFrameEditor(const TGWindow *p, Int_t width,
00047 Int_t height, UInt_t options, Pixel_t back)
00048 : TGedFrame(p, width, height, options | kVerticalFrame, back)
00049 {
00050
00051
00052 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00053 TGButtonGroup *bgr = new TGButtonGroup(f2,3,1,3,0, "Frame Border Mode");
00054 bgr->SetRadioButtonExclusive(kTRUE);
00055 fBmode = new TGRadioButton(bgr, " Sunken", 77);
00056 fBmode->SetToolTipText("Set a sunken border of the frame");
00057 fBmode0 = new TGRadioButton(bgr, " No border", 78);
00058 fBmode0->SetToolTipText("Set no border of the frame");
00059 fBmode1 = new TGRadioButton(bgr, " Raised", 79);
00060 fBmode1->SetToolTipText("Set a raised border of the frame");
00061 bgr->SetButton(79, kTRUE);
00062 fBmodelh = new TGLayoutHints(kLHintsLeft, 0,0,3,0);
00063 bgr->SetLayoutHints(fBmodelh, fBmode);
00064 bgr->Show();
00065 bgr->ChangeOptions(kFitWidth|kChildFrame|kVerticalFrame);
00066 f2->AddFrame(bgr, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4, 1, 0, 0));
00067 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00068
00069 TGCompositeFrame *f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00070 TGLabel *fSizeLbl = new TGLabel(f3, "Size:");
00071 f3->AddFrame(fSizeLbl, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 6, 1, 0, 0));
00072 fBsize = new TGLineWidthComboBox(f3, kFR_BSIZE);
00073 fBsize->Resize(92, 20);
00074 f3->AddFrame(fBsize, new TGLayoutHints(kLHintsLeft, 13, 1, 0, 0));
00075 fBsize->Associate(this);
00076 AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00077 }
00078
00079
00080 TFrameEditor::~TFrameEditor()
00081 {
00082
00083
00084
00085 delete fBmode;
00086 delete fBmode0;
00087 delete fBmode1;
00088 delete fBmodelh;
00089 }
00090
00091
00092 void TFrameEditor::ConnectSignals2Slots()
00093 {
00094
00095
00096 fBmode->Connect("Toggled(Bool_t)","TFrameEditor",this,"DoBorderMode()");
00097 fBmode0->Connect("Toggled(Bool_t)","TFrameEditor",this,"DoBorderMode()");
00098 fBmode1->Connect("Toggled(Bool_t)","TFrameEditor",this,"DoBorderMode()");
00099 fBsize->Connect("Selected(Int_t)", "TFrameEditor", this, "DoBorderSize(Int_t)");
00100
00101 fInit = kFALSE;
00102 }
00103
00104
00105 void TFrameEditor::SetModel(TObject* obj)
00106 {
00107
00108
00109 fFrame = (TFrame *)obj;
00110
00111 Int_t par;
00112
00113 par = fFrame->GetBorderMode();
00114 if (par == -1) fBmode->SetState(kButtonDown, kTRUE);
00115 else if (par == 1) fBmode1->SetState(kButtonDown, kTRUE);
00116 else fBmode0->SetState(kButtonDown, kTRUE);
00117
00118 par = fFrame->GetBorderSize();
00119 if (par < 1) par = 1;
00120 if (par > 16) par = 16;
00121 fBsize->Select(par, kFALSE);
00122
00123 if (fInit) ConnectSignals2Slots();
00124 }
00125
00126
00127 void TFrameEditor::DoBorderMode()
00128 {
00129
00130
00131 Int_t mode = 0;
00132 if (fBmode->GetState() == kButtonDown) mode = -1;
00133 else if (fBmode0->GetState() == kButtonDown) mode = 0;
00134 else mode = 1;
00135
00136 if (!mode) {
00137 fBsize->SetEnabled(kFALSE);
00138 } else {
00139 fBsize->SetEnabled(kTRUE);
00140 }
00141 fFrame->SetBorderMode(mode);
00142 Update();
00143 gPad->Modified();
00144 gPad->Update();
00145 }
00146
00147
00148 void TFrameEditor::DoBorderSize(Int_t size)
00149 {
00150
00151
00152 fFrame->SetBorderSize(size);
00153 Update();
00154 }