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
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include "TGComboBox.h"
00044 #include "TGScrollBar.h"
00045 #include "TGPicture.h"
00046 #include "TGResourcePool.h"
00047 #include "Riostream.h"
00048 #include "TGTextEntry.h"
00049
00050
00051
00052 ClassImp(TGComboBoxPopup)
00053 ClassImp(TGComboBox)
00054
00055 ClassImp(TGLineStyleComboBox)
00056 ClassImp(TGLineWidthComboBox)
00057 ClassImp(TGFontTypeComboBox)
00058
00059
00060 TGComboBoxPopup::TGComboBoxPopup(const TGWindow *p, UInt_t w, UInt_t h,
00061 UInt_t options, ULong_t back) :
00062 TGCompositeFrame (p, w, h, options, back), fListBox(0), fSelected(0)
00063 {
00064
00065
00066 SetWindowAttributes_t wattr;
00067
00068 wattr.fMask = kWAOverrideRedirect | kWASaveUnder |
00069 kWABorderPixel | kWABorderWidth;
00070 wattr.fOverrideRedirect = kTRUE;
00071 wattr.fSaveUnder = kTRUE;
00072 wattr.fBorderPixel = fgBlackPixel;
00073 wattr.fBorderWidth = 1;
00074 gVirtualX->ChangeWindowAttributes(fId, &wattr);
00075
00076 AddInput(kStructureNotifyMask);
00077 fEditDisabled = kEditDisable | kEditDisableGrab | kEditDisableBtnEnable;
00078 SetWindowName();
00079 }
00080
00081
00082 Bool_t TGComboBoxPopup::HandleButton(Event_t *event)
00083 {
00084
00085
00086 if (event->fType == kButtonPress && event->fCode == kButton1) {
00087 if ((fListBox != 0) && (fSelected != 0) &&
00088 fListBox->GetSelectedEntry() != fSelected) {
00089
00090
00091 fListBox->Select(fSelected->EntryId());
00092 }
00093 EndPopup();
00094 }
00095 return kTRUE;
00096 }
00097
00098
00099 void TGComboBoxPopup::EndPopup()
00100 {
00101
00102
00103 if (IsMapped()) {
00104 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
00105 UnmapWindow();
00106 }
00107 }
00108
00109
00110 void TGComboBoxPopup::PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h)
00111 {
00112
00113
00114 Int_t rx, ry;
00115 UInt_t rw, rh;
00116
00117
00118 gVirtualX->GetWindowSize(fParent->GetId(), rx, ry, rw, rh);
00119
00120 if (x < 0) x = 0;
00121 if (x + fWidth > rw) x = rw - fWidth;
00122 if (y < 0) y = 0;
00123 if (y + fHeight > rh) y = rh - fHeight;
00124
00125
00126 if (fListBox == 0) {
00127
00128 TGFrameElement *el = (TGFrameElement *)fList->First();
00129 fListBox = dynamic_cast<TGListBox *>(el->fFrame);
00130 }
00131 fSelected = fListBox ? fListBox->GetSelectedEntry() : 0;
00132
00133 MoveResize(x, y, w, h);
00134 MapSubwindows();
00135 Layout();
00136 MapRaised();
00137
00138 gVirtualX->GrabPointer(fId, kButtonPressMask | kButtonReleaseMask |
00139 kPointerMotionMask, kNone,
00140 fClient->GetResourcePool()->GetGrabCursor());
00141
00142 if (fClient->IsEditable()) {
00143 fClient->RegisterPopup(this);
00144 }
00145
00146 fClient->WaitForUnmap(this);
00147 EndPopup();
00148 }
00149
00150
00151
00152 TGComboBox::TGComboBox(const TGWindow *p, Int_t id, UInt_t options,
00153 ULong_t back) :
00154 TGCompositeFrame (p, 10, 10, options | kOwnBackground, back)
00155 {
00156
00157
00158 fWidgetId = id;
00159 fMsgWindow = p;
00160 fTextEntry = 0;
00161
00162 fSelEntry = new TGTextLBEntry(this, new TGString(""), 0);
00163 fSelEntry->ChangeOptions(fSelEntry->GetOptions() | kOwnBackground);
00164
00165 AddFrame(fSelEntry, fLhs = new TGLayoutHints(kLHintsLeft |
00166 kLHintsExpandY | kLHintsExpandX));
00167 Init();
00168 }
00169
00170
00171 TGComboBox::TGComboBox(const TGWindow *p, const char *text, Int_t id,
00172 UInt_t options, ULong_t back) :
00173 TGCompositeFrame (p, 10, 10, options | kOwnBackground, back)
00174 {
00175
00176
00177 fWidgetId = id;
00178 fMsgWindow = p;
00179 fSelEntry = 0;
00180
00181 fTextEntry = new TGTextEntry(this, text, id);
00182 fTextEntry->SetFrameDrawn(kFALSE);
00183 fTextEntry->Connect("ReturnPressed()", "TGComboBox", this, "ReturnPressed()");
00184
00185 AddFrame(fTextEntry, fLhs = new TGLayoutHints(kLHintsLeft |
00186 kLHintsExpandY | kLHintsExpandX));
00187 Init();
00188 }
00189
00190
00191 TGComboBox::~TGComboBox()
00192 {
00193
00194
00195 fClient->FreePicture(fBpic);
00196
00197 if (!MustCleanup()) {
00198 SafeDelete(fDDButton);
00199 SafeDelete(fSelEntry);
00200 SafeDelete(fTextEntry);
00201 SafeDelete(fLhs);
00202 SafeDelete(fLhb);
00203 }
00204
00205 SafeDelete(fLhdd);
00206 SafeDelete(fListBox);
00207 if (fComboFrame) {
00208 fComboFrame->EndPopup();
00209 SafeDelete(fComboFrame);
00210 }
00211 }
00212
00213
00214 void TGComboBox::Init()
00215 {
00216
00217
00218 fBpic = fClient->GetPicture("arrow_down.xpm");
00219
00220 if (!fBpic)
00221 Error("TGComboBox", "arrow_down.xpm not found");
00222
00223 fDDButton = new TGScrollBarElement(this, fBpic, kDefaultScrollBarWidth,
00224 kDefaultScrollBarWidth, kRaisedFrame);
00225
00226 AddFrame(fDDButton, fLhb = new TGLayoutHints(kLHintsRight |
00227 kLHintsExpandY));
00228
00229 fComboFrame = new TGComboBoxPopup(fClient->GetDefaultRoot(), 100, 100, kVerticalFrame);
00230
00231 fListBox = new TGListBox(fComboFrame, fWidgetId, kChildFrame);
00232
00233 fListBox->Resize(100, 100);
00234 fListBox->Associate(this);
00235 fListBox->GetScrollBar()->GrabPointer(kFALSE);
00236
00237 fComboFrame->AddFrame(fListBox, fLhdd = new TGLayoutHints(kLHintsExpandX |
00238 kLHintsExpandY));
00239 fComboFrame->SetListBox(fListBox);
00240 fComboFrame->MapSubwindows();
00241 fComboFrame->Resize(fComboFrame->GetDefaultSize());
00242
00243 gVirtualX->GrabButton(fId, kButton1, kAnyModifier, kButtonPressMask |
00244 kButtonReleaseMask | kPointerMotionMask, kNone, kNone);
00245
00246
00247
00248
00249 fListBox->GetContainer()->AddInput(kButtonPressMask | kButtonReleaseMask |
00250 kPointerMotionMask);
00251
00252 fListBox->SetEditDisabled(kEditDisable);
00253 fListBox->GetContainer()->SetEditDisabled(kEditDisable);
00254 if (fSelEntry) fSelEntry->SetEditDisabled(kEditDisable | kEditDisableEvents | kEditDisableGrab);
00255 if (fTextEntry) fTextEntry->SetEditDisabled(kEditDisable | kEditDisableGrab | kEditDisableBtnEnable);
00256 fDDButton->SetEditDisabled(kEditDisable | kEditDisableGrab);
00257 fEditDisabled = kEditDisableLayout | kEditDisableBtnEnable | kEditDisableHeight;
00258
00259 SetWindowName();
00260 }
00261
00262
00263 void TGComboBox::DrawBorder()
00264 {
00265
00266
00267 switch (fOptions & (kSunkenFrame | kRaisedFrame | kDoubleBorder)) {
00268 case kSunkenFrame | kDoubleBorder:
00269 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
00270 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
00271 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, fWidth-3, 1);
00272 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, 1, fHeight-3);
00273
00274 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
00275 gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
00276 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
00277 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, 1, fWidth-2, fHeight-2);
00278 break;
00279
00280 default:
00281 TGCompositeFrame::DrawBorder();
00282 break;
00283 }
00284 }
00285
00286
00287 void TGComboBox::EnableTextInput(Bool_t on)
00288 {
00289
00290
00291 UInt_t w, h;
00292 const char *text = "";
00293 Pixel_t back = TGFrame::GetWhitePixel();
00294
00295 if (on) {
00296 if (fSelEntry) {
00297 back = fSelEntry->GetBackground();
00298 text = ((TGTextLBEntry*)fSelEntry)->GetText()->GetString();
00299 if (fTextEntry && fSelEntry->InheritsFrom(TGTextLBEntry::Class())) {
00300 fTextEntry->SetText(text);
00301 }
00302 RemoveFrame(fSelEntry);
00303 w = fSelEntry->GetWidth();
00304 h = fSelEntry->GetHeight();
00305 fSelEntry->DestroyWindow();
00306 delete fSelEntry;
00307 fSelEntry = 0;
00308 }
00309 if (!fTextEntry) {
00310 fTextEntry = new TGTextEntry(this, text, 0);
00311 fTextEntry->SetFrameDrawn(kFALSE);
00312 fTextEntry->Connect("ReturnPressed()", "TGComboBox", this, "ReturnPressed()");
00313 AddFrame(fTextEntry, fLhs);
00314 fTextEntry->SetEditDisabled(kEditDisable | kEditDisableGrab | kEditDisableBtnEnable);
00315 }
00316 fTextEntry->SetBackgroundColor(back);
00317 MapSubwindows();
00318 GetLayoutManager()->Layout();
00319 } else {
00320 if (fTextEntry) {
00321 back = fTextEntry->GetBackground();
00322 text = fTextEntry->GetText();
00323 RemoveFrame(fTextEntry);
00324 fTextEntry->DestroyWindow();
00325 w = fTextEntry->GetWidth();
00326 h = fTextEntry->GetHeight();
00327 delete fTextEntry;
00328 fTextEntry = 0;
00329 }
00330 if (!fSelEntry) {
00331 fSelEntry = new TGTextLBEntry(this, new TGString(text), 0);
00332 fSelEntry->ChangeOptions(fSelEntry->GetOptions() | kOwnBackground);
00333 AddFrame(fSelEntry, fLhs);
00334 fSelEntry->SetEditDisabled(kEditDisable | kEditDisableGrab);
00335 }
00336 fSelEntry->SetBackgroundColor(back);
00337 MapSubwindows();
00338 GetLayoutManager()->Layout();
00339 }
00340 }
00341
00342
00343 TGLBEntry *TGComboBox::FindEntry(const char *s) const
00344 {
00345
00346
00347 TGLBEntry *sel = 0;
00348 sel = fListBox->FindEntry(s);
00349 return sel;
00350 }
00351
00352
00353 void TGComboBox::SetTopEntry(TGLBEntry *e, TGLayoutHints *lh)
00354 {
00355
00356
00357
00358 if (!fSelEntry) return;
00359
00360 RemoveFrame(fSelEntry);
00361 fSelEntry->DestroyWindow();
00362 delete fSelEntry;
00363 delete fLhs;
00364 fSelEntry = e;
00365 fLhs = lh;
00366 AddFrame(fSelEntry, fLhs);
00367 Layout();
00368 }
00369
00370
00371 void TGComboBox::Select(Int_t id, Bool_t emit)
00372 {
00373
00374
00375
00376 if (id!=GetSelected()) {
00377 TGLBEntry *e;
00378 e = fListBox->Select(id);
00379 if (e) {
00380 if (fSelEntry) {
00381 fSelEntry->Update(e);
00382 Layout();
00383 if (emit) {
00384 Selected(fWidgetId, id);
00385 Selected(id);
00386 }
00387 }
00388 }
00389 }
00390 }
00391
00392
00393 Bool_t TGComboBox::HandleButton(Event_t *event)
00394 {
00395
00396
00397 if (!fDDButton || !fDDButton->IsEnabled()) return kFALSE;
00398
00399 if (event->fType == kButtonPress) {
00400 Window_t child = (Window_t)event->fUser[0];
00401
00402 if (child == fDDButton->GetId() || (fSelEntry && child == fSelEntry->GetId())) {
00403 fDDButton->SetState(kButtonDown);
00404
00405 if (fTextEntry && (child == fTextEntry->GetId())) {
00406 return fTextEntry->HandleButton(event);
00407 }
00408 int ax, ay;
00409 Window_t wdummy;
00410 gVirtualX->TranslateCoordinates(fId, fComboFrame->GetParent()->GetId(),
00411 0, fHeight, ax, ay, wdummy);
00412
00413 fListBox->GetContainer()->AddInput(kPointerMotionMask);
00414 fComboFrame->PlacePopup(ax, ay, fWidth-2, fComboFrame->GetDefaultHeight());
00415 fDDButton->SetState(kButtonUp);
00416 } else if (fTextEntry) {
00417 return fTextEntry->HandleButton(event);
00418 }
00419 }
00420 return kTRUE;
00421 }
00422
00423
00424 void TGComboBox::RemoveEntry(Int_t id)
00425 {
00426
00427
00428 fListBox->RemoveEntry(id);
00429
00430 if (id < 0) {
00431 if (fSelEntry) {
00432 ((TGTextLBEntry*)fSelEntry)->SetTitle("");
00433 fClient->NeedRedraw(fSelEntry);
00434 } else {
00435 fTextEntry->SetTitle("");
00436 fClient->NeedRedraw(fTextEntry);
00437 }
00438 }
00439 Resize();
00440 }
00441
00442
00443 void TGComboBox::Layout()
00444 {
00445
00446
00447 TGCompositeFrame::Layout();
00448 UInt_t h = fListBox->GetNumberOfEntries()*fListBox->GetItemVsize();
00449
00450 if (h && (h < 100)) {
00451 fListBox->Resize(fListBox->GetWidth(), h);
00452 }
00453 }
00454
00455
00456 Bool_t TGComboBox::HandleDoubleClick(Event_t *event)
00457 {
00458
00459
00460 return fTextEntry ? fTextEntry->HandleDoubleClick(event) : kTRUE;
00461 }
00462
00463
00464 Bool_t TGComboBox::HandleMotion(Event_t *event)
00465 {
00466
00467
00468 return fTextEntry ? fTextEntry->HandleMotion(event) : kTRUE;
00469 }
00470
00471
00472 Bool_t TGComboBox::HandleSelection(Event_t *event)
00473 {
00474
00475
00476 return fTextEntry ? fTextEntry->HandleSelection(event) : kTRUE;
00477 }
00478
00479
00480 Bool_t TGComboBox::HandleSelectionRequest(Event_t *event)
00481 {
00482
00483
00484 return fTextEntry ? fTextEntry->HandleSelectionRequest(event) : kTRUE;
00485 }
00486
00487
00488 Bool_t TGComboBox::ProcessMessage(Long_t msg, Long_t, Long_t parm2)
00489 {
00490
00491
00492
00493
00494 TGLBEntry *e;
00495
00496 switch (GET_MSG(msg)) {
00497 case kC_COMMAND:
00498 switch (GET_SUBMSG(msg)) {
00499 case kCM_LISTBOX:
00500 e = fListBox->GetSelectedEntry();
00501 if (fSelEntry) {
00502 fSelEntry->Update(e);
00503 } else if (fTextEntry &&
00504 e->InheritsFrom(TGTextLBEntry::Class())) {
00505 TGTextLBEntry *te = (TGTextLBEntry*)e;
00506 fTextEntry->SetText(te->GetText()->GetString());
00507 }
00508 GetLayoutManager()->Layout();
00509 fComboFrame->EndPopup();
00510 fDDButton->SetState(kButtonUp);
00511 SendMessage(fMsgWindow, MK_MSG(kC_COMMAND, kCM_COMBOBOX),
00512 fWidgetId, parm2);
00513 if (e->InheritsFrom(TGTextLBEntry::Class())) {
00514 const char *text;
00515 text = ((TGTextLBEntry*)e)->GetText()->GetString();
00516 Selected(text);
00517 }
00518 Selected(fWidgetId, (Int_t)parm2);
00519 Selected((Int_t)parm2);
00520 fClient->NeedRedraw(this);
00521 break;
00522 }
00523 break;
00524
00525 default:
00526 break;
00527 }
00528 return kTRUE;
00529 }
00530
00531
00532 void TGComboBox::Selected(Int_t widgetId, Int_t id)
00533 {
00534
00535
00536 Long_t args[2];
00537
00538 args[0] = widgetId;
00539 args[1] = id;
00540
00541 Emit("Selected(Int_t,Int_t)", args);
00542 }
00543
00544
00545 void TGComboBox::SetEnabled(Bool_t on)
00546 {
00547
00548
00549 fDDButton->SetEnabled(on);
00550 if (on) {
00551 SetFlags(kWidgetIsEnabled);
00552 fSelEntry->SetBackgroundColor(GetBackground());
00553 } else {
00554 ClearFlags(kWidgetIsEnabled);
00555 fSelEntry->SetBackgroundColor(GetDefaultFrameBackground());
00556 }
00557 fClient->NeedRedraw(fSelEntry);
00558 }
00559
00560
00561 void TGComboBox::ReturnPressed()
00562 {
00563
00564
00565
00566 if (!fTextEntry) return;
00567
00568 TGLBContainer *lbc = (TGLBContainer *)fListBox->GetContainer();
00569 TString text = fTextEntry->GetText();
00570
00571 TIter next(lbc->GetList());
00572 TGFrameElement *el;
00573
00574 Emit("ReturnPressed()");
00575
00576 while ((el = (TGFrameElement *)next())) {
00577 TGTextLBEntry *lbe = (TGTextLBEntry *)el->fFrame;
00578 if (lbe->GetText()->GetString() == text) {
00579 return;
00580 }
00581 }
00582
00583 Int_t nn = GetNumberOfEntries() + 1;
00584 AddEntry(text.Data(), nn);
00585 Select(nn);
00586 }
00587
00588
00589 void TGComboBox::RemoveAll()
00590 {
00591
00592
00593 fListBox->RemoveAll();
00594
00595 if (fSelEntry) {
00596 ((TGTextLBEntry*)fSelEntry)->SetTitle("");
00597 fClient->NeedRedraw(fSelEntry);
00598 } else {
00599 fTextEntry->SetTitle("");
00600 fClient->NeedRedraw(fTextEntry);
00601 }
00602 }
00603
00604
00605 void TGComboBox::SavePrimitive(ostream &out, Option_t *option )
00606 {
00607
00608
00609 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
00610
00611 out << endl << " // combo box" << endl;
00612 out << " TGComboBox *";
00613
00614 if (!fTextEntry) {
00615 out << GetName() << " = new TGComboBox(" << fParent->GetName() << "," << fWidgetId;
00616 } else {
00617 out << GetName() << " = new TGComboBox(" << fParent->GetName() << ",";
00618 out << '\"' << fTextEntry->GetText() << '\"' << "," <<fWidgetId;
00619 }
00620
00621 if (fBackground == GetWhitePixel()) {
00622 if (GetOptions() == (kHorizontalFrame | kSunkenFrame | kDoubleBorder)) {
00623 out <<");" << endl;
00624 } else {
00625 out << "," << GetOptionString() << ");" << endl;
00626 }
00627 } else {
00628 out << "," << GetOptionString() << ",ucolor);" << endl;
00629 }
00630 if (option && strstr(option, "keep_names"))
00631 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << endl;
00632
00633 TGTextLBEntry *b;
00634 TGFrameElement *el;
00635 TGListBox *lb = GetListBox();
00636
00637 TIter next(((TGLBContainer *)lb->GetContainer())->GetList());
00638
00639 while ((el = (TGFrameElement *) next())) {
00640 b = (TGTextLBEntry *) el->fFrame;
00641 out << " " << GetName() << "->AddEntry(";
00642 b->SavePrimitive(out, option);
00643 out << ");" << endl;
00644 }
00645
00646 out << " " << GetName() << "->Resize(" << GetWidth() << ","
00647 << GetHeight() << ");" << endl;
00648 out << " " << GetName() << "->Select(" << GetSelected() << ");" << endl;
00649 }
00650
00651
00652 TGLineStyleComboBox::TGLineStyleComboBox(const TGWindow *p, Int_t id,
00653 UInt_t options, Pixel_t back)
00654 : TGComboBox(p, id, options, back)
00655 {
00656
00657
00658 SetTopEntry(new TGLineLBEntry(this, 0),
00659 new TGLayoutHints(kLHintsLeft | kLHintsExpandY | kLHintsExpandX));
00660 fSelEntry->ChangeOptions(fSelEntry->GetOptions() | kOwnBackground);
00661
00662 for (Int_t i = 1; i <= 10; i++)
00663 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
00664 TString::Format("%d",i), 0, i),
00665 new TGLayoutHints(kLHintsTop | kLHintsExpandX));
00666
00667 Select(1, kFALSE);
00668
00669 SetWindowName();
00670 }
00671
00672
00673 void TGLineStyleComboBox::SavePrimitive(ostream &out, Option_t *option )
00674 {
00675
00676
00677 out << endl << " // line style combo box" << endl;
00678 out << " TGLineStyleComboBox *";
00679
00680 out << GetName() << " = new TGLineStyleComboBox(" << fParent->GetName()
00681 << "," << fWidgetId << ");" << endl;
00682 if (option && strstr(option, "keep_names"))
00683 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << endl;
00684 out << " " << GetName() << "->Resize(" << GetWidth() << ","
00685 << GetHeight() << ");" << endl;
00686 out << " " << GetName() << "->Select(" << GetSelected() << ");" << endl;
00687 }
00688
00689
00690 TGLineWidthComboBox::TGLineWidthComboBox(const TGWindow *p, Int_t id,
00691 UInt_t options, Pixel_t back, Bool_t none)
00692 : TGComboBox(p, id, options, back)
00693 {
00694
00695
00696
00697 SetTopEntry(new TGLineLBEntry(this,0),
00698 new TGLayoutHints(kLHintsLeft | kLHintsExpandY | kLHintsExpandX));
00699 fSelEntry->ChangeOptions(fSelEntry->GetOptions() | kOwnBackground);
00700
00701 if (none) {
00702 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), 0, "None", 0, 0),
00703 new TGLayoutHints(kLHintsTop | kLHintsExpandX));
00704 }
00705
00706 for (Int_t i = 1; i < 16; i++)
00707 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
00708 TString::Format("%d",i), i, 0),
00709 new TGLayoutHints(kLHintsTop | kLHintsExpandX));
00710 Select(1, kFALSE);
00711 SetWindowName();
00712 }
00713
00714
00715 void TGLineWidthComboBox::SavePrimitive(ostream &out, Option_t *option )
00716 {
00717
00718
00719 out << endl << " // line width combo box" << endl;
00720 out << " TGLineWidthComboBox *";
00721
00722 out << GetName() << " = new TGLineWidthComboBox(" << fParent->GetName()
00723 << "," << fWidgetId << ");" << endl;
00724 if (option && strstr(option, "keep_names"))
00725 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << endl;
00726 out << " " << GetName() << "->Resize(" << GetWidth() << ","
00727 << GetHeight() << ");" << endl;
00728 out << " " << GetName() << "->Select(" << GetSelected() << ");" << endl;
00729 }
00730
00731 static const char *gFonts[][2] = {
00732 { "", "" },
00733 { "-*-times-medium-i-*-*-12-*-*-*-*-*-*-*", "1. times italic" },
00734 { "-*-times-bold-r-*-*-12-*-*-*-*-*-*-*", "2. times bold" },
00735 { "-*-times-bold-i-*-*-12-*-*-*-*-*-*-*", "3. times bold italic" },
00736 { "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*", "4. helvetica" },
00737 { "-*-helvetica-medium-o-*-*-12-*-*-*-*-*-*-*", "5. helvetica italic" },
00738 { "-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*", "6. helvetica bold" },
00739 { "-*-helvetica-bold-o-*-*-12-*-*-*-*-*-*-*", "7. helvetica bold italic" },
00740 { "-*-courier-medium-r-*-*-12-*-*-*-*-*-*-*", "8. courier" },
00741 { "-*-courier-medium-o-*-*-12-*-*-*-*-*-*-*", "9. courier italic" },
00742 { "-*-courier-bold-r-*-*-12-*-*-*-*-*-*-*", "10. courier bold" },
00743 { "-*-courier-bold-o-*-*-12-*-*-*-*-*-*-*", "11. courier bold italic" },
00744 { "-*-symbol-medium-r-*-*-12-*-*-*-*-*-*-*", "12. symbol" },
00745 { "-*-times-medium-r-*-*-12-*-*-*-*-*-*-*", "13. times" },
00746 { 0, 0}
00747 };
00748
00749
00750 TGFontTypeComboBox::TGFontTypeComboBox(const TGWindow *p, Int_t id,
00751 UInt_t options, Pixel_t back) :
00752 TGComboBox(p, id, options, back)
00753 {
00754
00755
00756 Int_t noFonts = 0;
00757
00758 for (Int_t i = 1; gFonts[i][0] != 0 && noFonts < kMaxFonts; i++) {
00759
00760 fFonts[noFonts] = gVirtualX->LoadQueryFont(gFonts[i][0]);
00761
00762 if (fFonts[noFonts] == 0)
00763 fFonts[noFonts] = TGTextLBEntry::GetDefaultFontStruct();
00764
00765 GCValues_t gval;
00766 gval.fMask = kGCFont;
00767 gval.fFont = gVirtualX->GetFontHandle(fFonts[noFonts]);
00768
00769 AddEntry(new TGTextLBEntry(GetListBox()->GetContainer(),
00770 new TGString(gFonts[i][1]), i,
00771 fClient->GetGC(&gval, kTRUE)->GetGC(), fFonts[noFonts]),
00772 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX));
00773 noFonts++;
00774 }
00775
00776 if (noFonts < kMaxFonts - 1)
00777 fFonts[noFonts] = 0;
00778
00779 Select(1, kFALSE);
00780 SetWindowName();
00781 }
00782
00783
00784 TGFontTypeComboBox::~TGFontTypeComboBox()
00785 {
00786
00787
00788 for (int i = 0; i < kMaxFonts && fFonts[i] != 0; i++) {
00789 if (fFonts[i] != TGTextLBEntry::GetDefaultFontStruct()) gVirtualX->DeleteFont(fFonts[i]);
00790 }
00791 }