00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "TGedFrame.h"
00021 #include "TGedEditor.h"
00022 #include "TG3DLine.h"
00023 #include "TClass.h"
00024 #include "TCanvas.h"
00025 #include "TGLabel.h"
00026 #include "TGToolTip.h"
00027 #include "TGCanvas.h"
00028 #include "TGScrollBar.h"
00029
00030
00031 ClassImp(TGedFrame)
00032
00033
00034 TGedFrame::TGedFrame(const TGWindow *p, Int_t width,
00035 Int_t height, UInt_t options, Pixel_t back)
00036 : TGCompositeFrame(p, width, height, options, back),
00037 fInit(kTRUE),
00038 fGedEditor(0),
00039 fModelClass(0),
00040 fAvoidSignal(kFALSE),
00041 fExtraTabs(0),
00042 fPriority(50)
00043 {
00044
00045
00046 fName = "";
00047 fGedEditor = TGedEditor::GetFrameCreator();
00048 SetCleanup(kDeepCleanup);
00049 }
00050
00051
00052 TGedFrame::~TGedFrame()
00053 {
00054
00055
00056 if (fExtraTabs) {
00057 TGedSubFrame* sf;
00058 TIter next(fExtraTabs);
00059 while ((sf = (TGedSubFrame*) next()) != 0) {
00060 delete sf->fFrame;
00061 fExtraTabs->Remove(sf);
00062 delete sf;
00063 }
00064 delete fExtraTabs;
00065 }
00066
00067
00068 }
00069
00070
00071 void TGedFrame::Update()
00072 {
00073
00074
00075 fGedEditor->Update(this);
00076 }
00077
00078
00079 Option_t *TGedFrame::GetDrawOption() const
00080 {
00081
00082
00083 if (!fGedEditor->GetPad()) return "";
00084
00085 TListIter next(fGedEditor->GetPad()->GetListOfPrimitives());
00086 TObject *obj;
00087 while ((obj = next())) {
00088 if (obj == fGedEditor->GetModel()) return next.GetOption();
00089 }
00090 return "";
00091 }
00092
00093
00094 void TGedFrame::MakeTitle(const char *title)
00095 {
00096
00097
00098 TGCompositeFrame *f1 = new TGCompositeFrame(this, 145, 10, kHorizontalFrame |
00099 kFitWidth |
00100 kFixedWidth |
00101 kOwnBackground);
00102 f1->AddFrame(new TGLabel(f1, title),
00103 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00104 f1->AddFrame(new TGHorizontal3DLine(f1),
00105 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00106 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
00107 }
00108
00109
00110 void TGedFrame::AddExtraTab(TGedSubFrame* sf)
00111 {
00112
00113
00114 if (fExtraTabs == 0) fExtraTabs = new TList();
00115 fExtraTabs->Add(sf);
00116 sf->fFrame->SetCleanup(kDeepCleanup);
00117 }
00118
00119
00120 TGVerticalFrame* TGedFrame::CreateEditorTabSubFrame(const char* name)
00121 {
00122
00123
00124
00125 TGCompositeFrame* tabcont = fGedEditor->GetEditorTab(name);
00126
00127 TGVerticalFrame* newframe = new TGVerticalFrame(tabcont);
00128 AddExtraTab(new TGedFrame::TGedSubFrame(TString(name), newframe));
00129 return newframe;
00130 }
00131
00132
00133 void TGedFrame::Refresh(TObject* model)
00134 {
00135
00136
00137 SetModel(model);
00138 }
00139
00140
00141 void TGedFrame::SetDrawOption(Option_t *option)
00142 {
00143
00144
00145
00146
00147 if (!fGedEditor->GetPad() || !option) return;
00148
00149 TListIter next(fGedEditor->GetPad()->GetListOfPrimitives());
00150 delete fGedEditor->GetPad()->FindObject("Tframe");
00151 TObject *obj;
00152 while ((obj = next())) {
00153 if (obj == fGedEditor->GetModel()) {
00154 next.SetOption(option);
00155 fGedEditor->GetPad()->Modified();
00156 fGedEditor->GetPad()->Update();
00157 return;
00158 }
00159 }
00160 }
00161
00162
00163 void TGedFrame::ActivateBaseClassEditors(TClass* cl)
00164 {
00165
00166
00167
00168
00169
00170
00171 if (cl->GetListOfBases()->IsEmpty() == kFALSE) {
00172 fGedEditor->ActivateEditors(cl->GetListOfBases(), kTRUE);
00173 }
00174 }
00175
00176
00177 TGedNameFrame::TGedNameFrame(const TGWindow *p, Int_t width,
00178 Int_t height, UInt_t options, Pixel_t back)
00179 : TGedFrame(p, width, height, options | kVerticalFrame, back)
00180 {
00181
00182
00183 fPriority = 0;
00184
00185 f1 = new TGCompositeFrame(this, 145, 10, kHorizontalFrame |
00186 kFixedWidth |
00187 kOwnBackground);
00188 f1->AddFrame(new TGLabel(f1,"Name"),
00189 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00190 f1->AddFrame(new TGHorizontal3DLine(f1),
00191 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00192 AddFrame(f1, new TGLayoutHints(kLHintsTop));
00193
00194 f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame | kFixedWidth);
00195 fLabel = new TGLabel(f2, "");
00196 f2->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00197 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00198
00199
00200 Pixel_t color;
00201 gClient->GetColorByName("#ff0000", color);
00202 fLabel->SetTextColor(color, kFALSE);
00203
00204
00205 fTip = new TGToolTip(fClient->GetDefaultRoot(), this, "TGedNameFrame", 500);
00206
00207 AddInput(kEnterWindowMask | kLeaveWindowMask | kKeyPressMask | kButtonPressMask);
00208 }
00209
00210
00211 TGedNameFrame::~TGedNameFrame()
00212 {
00213
00214
00215 delete fTip;
00216 }
00217
00218
00219 Bool_t TGedNameFrame::HandleCrossing(Event_t *event)
00220 {
00221
00222
00223 if (event->fType == kEnterNotify)
00224 fTip->Reset();
00225 else
00226 fTip->Hide();
00227
00228 return kFALSE;
00229 }
00230
00231
00232 Bool_t TGedNameFrame::HandleButton(Event_t * )
00233 {
00234
00235
00236 if (fTip) fTip->Hide();
00237
00238 return kFALSE;
00239 }
00240
00241
00242 void TGedNameFrame::SetModel(TObject* obj)
00243 {
00244
00245
00246 TString string;
00247
00248 if (obj == 0) {
00249 fLabel->SetText(new TGString("Object not selected"));
00250 return;
00251 }
00252 string.Append(obj->GetName());
00253 string.Append("::");
00254 string.Append(obj->ClassName());
00255
00256 fLabel->SetText(new TGString(string));
00257 string = TString::Format("Name: %s\nTitle: %s\nClass: %s",
00258 obj->GetName(), obj->GetTitle(), obj->ClassName());
00259 fTip->SetText(string);
00260
00261
00262 {
00263 TGCanvas *canvas = fGedEditor->GetTGCanvas();
00264 TGVScrollBar *vsb = canvas->GetVScrollbar();
00265
00266 Int_t hscrollw = (vsb && vsb->IsMapped()) ? vsb->GetWidth() : 0;
00267 Int_t labwidth = TMath::Min(fLabel->GetDefaultSize().fWidth,
00268 canvas->GetWidth() - 10 - hscrollw);
00269 f2->SetWidth(TMath::Max(labwidth, 80));
00270 }
00271 }