Logo ROOT   6.21/01
Reference Guide
TGComboBox.cxx
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 13/01/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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  This source is based on Xclass95, a Win95-looking GUI toolkit.
14  Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15 
16  Xclass95 is free software; you can redistribute it and/or
17  modify it under the terms of the GNU Library General Public
18  License as published by the Free Software Foundation; either
19  version 2 of the License, or (at your option) any later version.
20 
21 **************************************************************************/
22 
23 //////////////////////////////////////////////////////////////////////////
24 // //
25 // TGComboBox, TGComboBoxPopup //
26 // //
27 // A combobox (also known as a drop down listbox) allows the selection //
28 // of one item out of a list of items. The selected item is visible in //
29 // a little window. To view the list of possible items one has to click //
30 // on a button on the right of the little window. This will drop down //
31 // a listbox. After selecting an item from the listbox the box will //
32 // disappear and the newly selected item will be shown in the little //
33 // window. //
34 // //
35 // The TGComboBox is user callable. The TGComboBoxPopup is a service //
36 // class of the combobox. //
37 // //
38 // Selecting an item in the combobox will generate the event: //
39 // kC_COMMAND, kCM_COMBOBOX, combobox id, item id. //
40 // //
41 //////////////////////////////////////////////////////////////////////////
42 
43 #include "TGComboBox.h"
44 #include "TGScrollBar.h"
45 #include "TGPicture.h"
46 #include "TGResourcePool.h"
47 #include "Riostream.h"
48 #include "TGTextEntry.h"
49 #include "KeySymbols.h"
50 #include "RConfigure.h"
51 
52 
55 
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// Create a combo box popup frame.
62 
64  UInt_t options, ULong_t back) :
65  TGCompositeFrame (p, w, h, options, back), fListBox(0), fSelected(0)
66 {
68 
71  wattr.fOverrideRedirect = kTRUE;
72  wattr.fSaveUnder = kTRUE;
73  wattr.fBorderPixel = fgBlackPixel;
74  wattr.fBorderWidth = 1;
75  gVirtualX->ChangeWindowAttributes(fId, &wattr);
76 
79  SetWindowName();
80 }
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Handle mouse button event in combo box popup.
84 
86 {
87  if (event->fType == kButtonPress && event->fCode == kButton1) {
88  if ((fListBox != 0) && (fSelected != 0) &&
90  // in the case the combo box popup is closed by clicking outside the
91  // list box, then select the previously selected entry
93  }
94  EndPopup();
95  }
96  else {
97  // reset the dragging flag of the scrollbar when the button is
98  // released outside the scrollbar itself
100  }
101  return kTRUE;
102 }
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 /// Ungrab pointer and unmap popup window.
106 
108 {
109  if (IsMapped()) {
110  Handle_t id = fListBox->GetContainer()->GetId();
111  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Up),
113  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Down),
115  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Enter),
117  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Return),
119  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Escape),
121  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Space),
123  gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
124  UnmapWindow();
125  }
126 }
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 /// Popup combo box popup window at the specified place.
130 
132 {
133  Int_t rx, ry;
134  UInt_t rw, rh;
135 
136  // Parent is root window for the popup:
137  gVirtualX->GetWindowSize(fParent->GetId(), rx, ry, rw, rh);
138 
139  if (gVirtualX->InheritsFrom("TGWin32")) {
140  if ((x > 0) && ((x + abs(rx) + (Int_t)fWidth) > (Int_t)rw))
141  x = rw - abs(rx) - fWidth;
142  if ((y > 0) && (y + abs(ry) + (Int_t)fHeight > (Int_t)rh))
143  y = rh - fHeight;
144  } else {
145  if (x < 0) x = 0;
146  if (x + fWidth > rw) x = rw - fWidth;
147  if (y < 0) y = 0;
148  if (y + fHeight > rh) y = rh - fHeight;
149  }
150 
151  // remember the current selected entry
152  if (fListBox == 0) {
153  // the listbox should be the first in the list
155  fListBox = dynamic_cast<TGListBox *>(el->fFrame);
156  }
158 
159  MoveResize(x, y, w, h);
160  MapSubwindows();
161  Layout();
162  MapRaised();
163 
164  Handle_t id = fListBox->GetContainer()->GetId();
165  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Up),
167  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Down),
169  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Enter),
171  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Return),
173  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Escape),
175  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Space),
178 
182 
183  if (fClient->IsEditable()) {
184  fClient->RegisterPopup(this);
185  }
186 
187  fClient->WaitForUnmap(this);
188  EndPopup();
189 }
190 
191 ////////////////////////////////////////////////////////////////////////////////
192 /// Slot handling the key press events.
193 
195 {
196  switch ((EKeySym)keysym) {
197  case kKey_Enter:
198  case kKey_Return:
199  case kKey_Space:
200  if (fListBox && f) {
201  TGLBEntry *entry = dynamic_cast<TGLBEntry *>(f);
202  if (entry) {
203  fListBox->Select(entry->EntryId());
205  entry->EntryId(), 0);
206  }
207  }
208  EndPopup();
209  break;
210  case kKey_Escape:
211  if (fListBox)
212  ((TGContainer *)fListBox->GetContainer())->UnSelectAll();
213  EndPopup();
214  break;
215  default:
216  break;
217  }
218 }
219 
220 ////////////////////////////////////////////////////////////////////////////////
221 /// Create a combo box widget.
222 
224  ULong_t back) :
225  TGCompositeFrame (p, 10, 10, options | kOwnBackground, back)
226 {
227  fWidgetId = id;
228  fMsgWindow = p;
229  fTextEntry = 0;
230 
231  fSelEntry = new TGTextLBEntry(this, new TGString(""), 0);
233 
236  Init();
237 }
238 
239 ////////////////////////////////////////////////////////////////////////////////
240 /// Create an editable combo box widget.
241 
242 TGComboBox::TGComboBox(const TGWindow *p, const char *text, Int_t id,
243  UInt_t options, ULong_t back) :
244  TGCompositeFrame (p, 10, 10, options | kOwnBackground, back)
245 {
246  fWidgetId = id;
247  fMsgWindow = p;
248  fSelEntry = 0;
249 
250  fTextEntry = new TGTextEntry(this, text, id);
252  fTextEntry->Connect("ReturnPressed()", "TGComboBox", this, "ReturnPressed()");
253 
256  Init();
257 }
258 
259 ////////////////////////////////////////////////////////////////////////////////
260 /// Delete a combo box widget.
261 
263 {
265 
266  if (!MustCleanup()) {
270  SafeDelete(fLhs);
271  SafeDelete(fLhb);
272  }
273 
274  SafeDelete(fLhdd);
276  if (fComboFrame) {
277  fComboFrame->EndPopup(); // force popdown in case of Qt interface
279  }
280 }
281 
282 ////////////////////////////////////////////////////////////////////////////////
283 /// Initiate the internal classes of a combo box.
284 
286 {
287  fBpic = fClient->GetPicture("arrow_down.xpm");
288 
289  if (!fBpic)
290  Error("TGComboBox", "arrow_down.xpm not found");
291 
294 
296  kLHintsExpandY));
297 
299 
301 
302  fListBox->Resize(100, 100);
303  fListBox->Associate(this);
304  fListBox->GetScrollBar()->GrabPointer(kFALSE); // combobox will do a pointergrab
305 
307  kLHintsExpandY));
311 
314 
315  fListBox->GetContainer()->Connect("KeyPressed(TGFrame*, UInt_t, UInt_t)",
316  "TGComboBoxPopup", fComboFrame,
317  "KeyPressed(TGFrame*, UInt_t, UInt_t)");
318  // Drop down listbox of combo box should react to pointer motion
319  // so it will be able to Activate() (i.e. highlight) the different
320  // items when the mouse crosses.
323 
330 
331  SetWindowName();
332 }
333 
334 ////////////////////////////////////////////////////////////////////////////////
335 /// Draw border of combo box widget.
336 
338 {
341  gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
342  gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
343  gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, fWidth-3, 1);
344  gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, 1, fHeight-3);
345  if (gClient->GetStyle() > 1) break;
346  gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
347  gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
348  gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
349  gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, 1, fWidth-2, fHeight-2);
350  break;
351 
352  default:
354  break;
355  }
356 }
357 
358 ////////////////////////////////////////////////////////////////////////////////
359 /// Switch text input or readonly mode of combobox (not perfect yet).
360 
362 {
363  // UInt_t w, h;
364  const char *text = "";
365  Pixel_t back = TGFrame::GetWhitePixel(); // default
366 
367  if (on) {
368  if (fSelEntry) {
369  back = fSelEntry->GetBackground();
370  text = ((TGTextLBEntry*)fSelEntry)->GetText()->GetString();
373  }
375  //w = fSelEntry->GetWidth();
376  //h = fSelEntry->GetHeight();
378  delete fSelEntry;
379  fSelEntry = 0;
380  }
381  if (!fTextEntry) {
382  fTextEntry = new TGTextEntry(this, text, 0);
384  fTextEntry->Connect("ReturnPressed()", "TGComboBox", this, "ReturnPressed()");
387  }
389  MapSubwindows();
390  // coverity[returned_null]
391  // coverity[dereference]
393  } else {
394  if (fTextEntry) {
395  back = fTextEntry->GetBackground();
396  text = fTextEntry->GetText();
399  //w = fTextEntry->GetWidth();
400  //h = fTextEntry->GetHeight();
401  delete fTextEntry;
402  fTextEntry = 0;
403  }
404  if (!fSelEntry) {
405  fSelEntry = new TGTextLBEntry(this, new TGString(text), 0);
409  }
411  MapSubwindows();
412  // coverity[returned_null]
413  // coverity[dereference]
415  }
416 }
417 
418 ////////////////////////////////////////////////////////////////////////////////
419 /// Find entry by name.
420 
421 TGLBEntry *TGComboBox::FindEntry(const char *s) const
422 {
423  TGLBEntry *sel = 0;
424  sel = fListBox->FindEntry(s);
425  return sel;
426 }
427 
428 ////////////////////////////////////////////////////////////////////////////////
429 /// Set a new combo box value (normally update of text string in
430 /// fSelEntry is done via fSelEntry::Update()).
431 
433 {
434  if (!fSelEntry) return;
435 
438  delete fSelEntry;
439  delete fLhs;
440  fSelEntry = e;
441  fLhs = lh;
443  Layout();
444 }
445 
446 ////////////////////////////////////////////////////////////////////////////////
447 /// Make the selected item visible in the combo box window
448 /// and emit signals according to the second parameter.
449 
451 {
452  if (id!=GetSelected()) {
453  TGLBEntry *e;
454  e = fListBox->Select(id);
455  if (e) {
456  if (fSelEntry) {
457  fSelEntry->Update(e);
458  Layout();
459  } else if (fTextEntry && e->InheritsFrom(TGTextLBEntry::Class())) {
460  TGTextLBEntry *te = (TGTextLBEntry*)e;
461  fTextEntry->SetText(te->GetText()->GetString());
462  }
463  if (emit) {
464  Selected(fWidgetId, id);
465  Selected(id);
466  }
467  }
468  }
469 }
470 
471 ////////////////////////////////////////////////////////////////////////////////
472 /// Handle mouse button events in the combo box.
473 
475 {
476  if (!fDDButton || !fDDButton->IsEnabled()) return kFALSE;
477 
478  if (event->fType == kButtonPress) {
479  Window_t child = (Window_t)event->fUser[0]; // fUser[0] = child window
480 
481  if (child == fDDButton->GetId() || (fSelEntry && child == fSelEntry->GetId())) {
483 
484  if (fTextEntry && (child == fTextEntry->GetId())) {
485  return fTextEntry->HandleButton(event);
486  }
487  int ax, ay;
488  Window_t wdummy;
489  gVirtualX->TranslateCoordinates(fId, fComboFrame->GetParent()->GetId(),
490  0, fHeight, ax, ay, wdummy);
491  // Drop down listbox of combo box should react to pointer motion...
493 #ifdef R__HAS_COCOA
494  gVirtualX->SetWMTransientHint(fComboFrame->GetId(), GetId());
495 #endif
498 #ifdef R__HAS_COCOA
499  //tp: I need this modification - "button" is not repainted correctly
500  //with Cocoa, when combobox is closed (reason is quite complex), happens
501  //when item is wider than combobox.
502  //TODO: find another way :)
504 #endif
505  } else if (fTextEntry) {
506  return fTextEntry->HandleButton(event);
507  }
508  }
509  return kTRUE;
510 }
511 
512 ////////////////////////////////////////////////////////////////////////////////
513 /// Remove entry. If id == -1, the currently selected entry is removed
514 
516 {
517  fListBox->RemoveEntry(id);
518 
519  if (id < 0) {
520  if (fSelEntry) {
521  ((TGTextLBEntry*)fSelEntry)->SetTitle("");
523  } else {
524  fTextEntry->SetTitle("");
526  }
527  }
528  Resize();
529 }
530 
531 ////////////////////////////////////////////////////////////////////////////////
532 /// layout combobox
533 
535 {
538 
539  if (h && (h < 100)) {
541  }
542 }
543 
544 ////////////////////////////////////////////////////////////////////////////////
545 /// Handle double click in text entry.
546 
548 {
549  return fTextEntry ? fTextEntry->HandleDoubleClick(event) : kTRUE;
550 }
551 
552 ////////////////////////////////////////////////////////////////////////////////
553 /// Handle pointer motion in text entry.
554 
556 {
557  return fTextEntry ? fTextEntry->HandleMotion(event) : kTRUE;
558 }
559 
560 ////////////////////////////////////////////////////////////////////////////////
561 /// Handle selection in text entry.
562 
564 {
565  return fTextEntry ? fTextEntry->HandleSelection(event) : kTRUE;
566 }
567 
568 ////////////////////////////////////////////////////////////////////////////////
569 /// Handle selection request in text entry.
570 
572 {
574 }
575 
576 ////////////////////////////////////////////////////////////////////////////////
577 /// Process messages generated by the listbox and forward
578 /// messages to the combobox message handling window. Parm2 contains
579 /// the id of the selected listbox entry.
580 
582 {
583  TGLBEntry *e;
584 
585  switch (GET_MSG(msg)) {
586  case kC_COMMAND:
587  switch (GET_SUBMSG(msg)) {
588  case kCM_LISTBOX:
590  if (fSelEntry) {
591  fSelEntry->Update(e);
592  } else if (fTextEntry &&
593  e->InheritsFrom(TGTextLBEntry::Class())) {
594  TGTextLBEntry *te = (TGTextLBEntry*)e;
595  fTextEntry->SetText(te->GetText()->GetString());
596  }
597  // coverity[returned_null]
598  // coverity[dereference]
603  fWidgetId, parm2);
604  if (e->InheritsFrom(TGTextLBEntry::Class())) {
605  const char *text;
606  text = ((TGTextLBEntry*)e)->GetText()->GetString();
607  Selected(text);
608  }
609  Selected(fWidgetId, (Int_t)parm2);
610  Selected((Int_t)parm2);
611  fClient->NeedRedraw(this);
612  break;
613  }
614  break;
615 
616  default:
617  break;
618  }
619  return kTRUE;
620 }
621 
622 ////////////////////////////////////////////////////////////////////////////////
623 /// Emit signal.
624 
625 void TGComboBox::Selected(Int_t widgetId, Int_t id)
626 {
627  Long_t args[2];
628 
629  args[0] = widgetId;
630  args[1] = id;
631 
632  Emit("Selected(Int_t,Int_t)", args);
633 }
634 
635 ////////////////////////////////////////////////////////////////////////////////
636 /// Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
637 
639 {
640  fDDButton->SetEnabled(on);
641  if (on) {
644  } else {
647  }
649 }
650 
651 ////////////////////////////////////////////////////////////////////////////////
652 /// Add new entry to combo box when return key pressed inside text entry
653 /// ReturnPressed signal is emitted.
654 
656 {
657  if (!fTextEntry) return;
658 
661 
662  TIter next(lbc->GetList());
663  TGFrameElement *el;
664 
665  Emit("ReturnPressed()");
666 
667  while ((el = (TGFrameElement *)next())) {
668  TGTextLBEntry *lbe = (TGTextLBEntry *)el->fFrame;
669  if (lbe->GetText()->GetString() == text) {
670  return;
671  }
672  }
673 
674  Int_t nn = GetNumberOfEntries() + 1;
675  AddEntry(text.Data(), nn);
676  Select(nn);
677 }
678 
679 ////////////////////////////////////////////////////////////////////////////////
680 /// Remove all entries from combo box.
681 
683 {
684  fListBox->RemoveAll();
685 
686  if (fSelEntry) {
687  ((TGTextLBEntry*)fSelEntry)->SetTitle("");
689  } else {
690  fTextEntry->SetTitle("");
692  }
693 }
694 
695 ////////////////////////////////////////////////////////////////////////////////
696 /// Save a combo box widget as a C++ statement(s) on output stream out.
697 
698 void TGComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
699 {
700  if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
701 
702  out << std::endl << " // combo box" << std::endl;
703  out << " TGComboBox *";
704 
705  if (!fTextEntry) {
706  out << GetName() << " = new TGComboBox(" << fParent->GetName() << "," << fWidgetId;
707  } else {
708  out << GetName() << " = new TGComboBox(" << fParent->GetName() << ",";
709  out << '\"' << fTextEntry->GetText() << '\"' << "," <<fWidgetId;
710  }
711 
712  if (fBackground == GetWhitePixel()) {
714  out <<");" << std::endl;
715  } else {
716  out << "," << GetOptionString() << ");" << std::endl;
717  }
718  } else {
719  out << "," << GetOptionString() << ",ucolor);" << std::endl;
720  }
721  if (option && strstr(option, "keep_names"))
722  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
723 
724  TGTextLBEntry *b;
725  TGFrameElement *el;
726  TGListBox *lb = GetListBox();
727 
728  TIter next(((TGLBContainer *)lb->GetContainer())->GetList());
729 
730  while ((el = (TGFrameElement *) next())) {
731  b = (TGTextLBEntry *) el->fFrame;
732  out << " " << GetName() << "->AddEntry(";
733  b->SavePrimitive(out, option);
734  out << ");" << std::endl;
735  }
736 
737  out << " " << GetName() << "->Resize(" << GetWidth() << ","
738  << GetHeight() << ");" << std::endl;
739  out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
740 }
741 
742 ////////////////////////////////////////////////////////////////////////////////
743 /// Create a line style combo box.
744 
746  UInt_t options, Pixel_t back)
747  : TGComboBox(p, id, options, back)
748 {
749  SetTopEntry(new TGLineLBEntry(this, 0),
752 
753  for (Int_t i = 1; i <= 10; i++)
754  AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
755  TString::Format("%d",i), 0, i),
757 
758  Select(1, kFALSE); // to have first entry selected
759 
760  SetWindowName();
761 }
762 
763 ////////////////////////////////////////////////////////////////////////////////
764 /// Save a line style combo box widget as a C++ statement(s).
765 
766 void TGLineStyleComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
767 {
768  out << std::endl << " // line style combo box" << std::endl;
769  out << " TGLineStyleComboBox *";
770 
771  out << GetName() << " = new TGLineStyleComboBox(" << fParent->GetName()
772  << "," << fWidgetId << ");" << std::endl;
773  if (option && strstr(option, "keep_names"))
774  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
775  out << " " << GetName() << "->Resize(" << GetWidth() << ","
776  << GetHeight() << ");" << std::endl;
777  out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
778 }
779 
780 ////////////////////////////////////////////////////////////////////////////////
781 /// Create a line width combo box.
782 /// If "none" is equal to kTRUE the first entry is "None".
783 
785  UInt_t options, Pixel_t back, Bool_t none)
786  : TGComboBox(p, id, options, back)
787 {
788  SetTopEntry(new TGLineLBEntry(this,0),
791 
792  if (none) {
793  AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), 0, "None", 0, 0),
795  }
796 
797  for (Int_t i = 0; i < 16; i++)
798  AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
799  TString::Format("%d",i), i, 0),
801  Select(1, kFALSE); // to have first entry selected
802  SetWindowName();
803 }
804 
805 ////////////////////////////////////////////////////////////////////////////////
806 /// Save a line width combo box widget as a C++ statement(s).
807 
808 void TGLineWidthComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
809 {
810  out << std::endl << " // line width combo box" << std::endl;
811  out << " TGLineWidthComboBox *";
812 
813  out << GetName() << " = new TGLineWidthComboBox(" << fParent->GetName()
814  << "," << fWidgetId << ");" << std::endl;
815  if (option && strstr(option, "keep_names"))
816  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
817  out << " " << GetName() << "->Resize(" << GetWidth() << ","
818  << GetHeight() << ");" << std::endl;
819  out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
820 }
821 
822 static const char *gFonts[][2] = { // unix name, name
823  { "", "" }, //not used
824  { "-*-times-medium-i-*-*-12-*-*-*-*-*-*-*", "1. times italic" },
825  { "-*-times-bold-r-*-*-12-*-*-*-*-*-*-*", "2. times bold" },
826  { "-*-times-bold-i-*-*-12-*-*-*-*-*-*-*", "3. times bold italic" },
827  { "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*", "4. helvetica" },
828  { "-*-helvetica-medium-o-*-*-12-*-*-*-*-*-*-*", "5. helvetica italic" },
829  { "-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*", "6. helvetica bold" },
830  { "-*-helvetica-bold-o-*-*-12-*-*-*-*-*-*-*", "7. helvetica bold italic" },
831  { "-*-courier-medium-r-*-*-12-*-*-*-*-*-*-*", "8. courier" },
832  { "-*-courier-medium-o-*-*-12-*-*-*-*-*-*-*", "9. courier italic" },
833  { "-*-courier-bold-r-*-*-12-*-*-*-*-*-*-*", "10. courier bold" },
834  { "-*-courier-bold-o-*-*-12-*-*-*-*-*-*-*", "11. courier bold italic" },
835  { "-*-symbol-medium-r-*-*-12-*-*-*-*-*-*-*", "12. symbol" },
836  { "-*-times-medium-r-*-*-12-*-*-*-*-*-*-*", "13. times" },
837  { 0, 0}
838 };
839 
840 ////////////////////////////////////////////////////////////////////////////////
841 /// Create a text font combo box.
842 
844  UInt_t options, Pixel_t back) :
845  TGComboBox(p, id, options, back)
846 {
847  Int_t noFonts = 0;
848 
849  for (Int_t i = 1; gFonts[i][0] != 0 && noFonts < kMaxFonts; i++) {
850 
851  fFonts[noFonts] = gVirtualX->LoadQueryFont(gFonts[i][0]);
852 
853  if (fFonts[noFonts] == 0)
855 
856  GCValues_t gval;
857  gval.fMask = kGCFont;
858  gval.fFont = gVirtualX->GetFontHandle(fFonts[noFonts]);
859 
860  AddEntry(new TGTextLBEntry(GetListBox()->GetContainer(),
861  new TGString(gFonts[i][1]), i,
862  fClient->GetGC(&gval, kTRUE)->GetGC(), fFonts[noFonts]),
864  noFonts++;
865  }
866 
867  if (noFonts < kMaxFonts - 1)
868  fFonts[noFonts] = 0;
869 
870  Select(1, kFALSE); // to have first entry selected
871  SetWindowName();
872 }
873 
874 ////////////////////////////////////////////////////////////////////////////////
875 /// Text font combo box dtor.
876 
878 {
879  for (int i = 0; i < kMaxFonts && fFonts[i] != 0; i++) {
880  if (fFonts[i] != TGTextLBEntry::GetDefaultFontStruct()) gVirtualX->DeleteFont(fFonts[i]);
881  }
882 }
virtual Bool_t HandleSelectionRequest(Event_t *event)
Handle request to send current clipboard contents to requestor window.
const TGWindow * fParent
Definition: TGWindow.h:37
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1419
Cursor_t GetGrabCursor() const
virtual UInt_t GetOptions() const
Definition: TGFrame.h:244
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGFrame.cxx:611
TGScrollBarElement * fDDButton
Definition: TGComboBox.h:76
virtual Bool_t HandleMotion(Event_t *event)
Handle pointer motion in text entry.
Definition: TGComboBox.cxx:555
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
Definition: TGListBox.cxx:1643
virtual TGFrame * GetContainer() const
Definition: TGListBox.h:335
FontH_t fFont
Definition: GuiTypes.h:241
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:321
UInt_t GetItemVsize() const
Definition: TGListBox.h:358
const char Option_t
Definition: RtypesCore.h:62
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition: TGFrame.cxx:737
virtual Bool_t HandleSelection(Event_t *event)
Handle text selection event.
void EndPopup()
Ungrab pointer and unmap popup window.
Definition: TGComboBox.cxx:107
UInt_t GetHeight() const
Definition: TGFrame.h:272
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
virtual void Update(TGLBEntry *)
Definition: TGListBox.h:67
TGComboBox(const TGComboBox &)
const Mask_t kWABorderPixel
Definition: GuiTypes.h:141
Int_t SetFlags(Int_t flags)
Definition: TGWidget.h:70
virtual void SetDragging(Bool_t drag)
Definition: TGScrollBar.h:129
const TGResourcePool * GetResourcePool() const
Definition: TGClient.h:133
virtual void DrawBorder()
Draw border of combo box widget.
Definition: TGComboBox.cxx:337
virtual void DrawBorder()
Draw frame border.
Definition: TGFrame.cxx:403
virtual void SetTitle(const char *label)
Definition: TGTextEntry.h:170
Basic string class.
Definition: TString.h:131
Pixel_t fBackground
Definition: TGFrame.h:142
#define gClient
Definition: TGClient.h:166
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:373
TGLineStyleComboBox(const TGWindow *p=0, Int_t id=-1, UInt_t options=kHorizontalFrame|kSunkenFrame|kDoubleBorder, Pixel_t back=GetWhitePixel())
Create a line style combo box.
Definition: TGComboBox.cxx:745
virtual void SetEnabled(Bool_t on=kTRUE)
Enable/Disable scroll bar button chaging the state.
UInt_t GetWidth() const
Definition: TGFrame.h:271
virtual void MapRaised()
Definition: TGFrame.h:252
virtual Bool_t IsEnabled() const
Definition: TGScrollBar.h:73
Int_t fWidgetId
Definition: TGWidget.h:58
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition: TGClient.cxx:736
Handle_t GetId() const
Definition: TGObject.h:47
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
TGComboBoxPopup * fComboFrame
Definition: TGComboBox.h:77
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition: TGFrame.cxx:1131
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:162
TGLBEntry * fSelEntry
Definition: TGComboBox.h:74
TGLayoutHints * fLhdd
Definition: TGComboBox.h:82
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
Definition: TGClient.cxx:532
Double_t x[n]
Definition: legend1.C:17
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2311
ULong_t Pixel_t
Definition: GuiTypes.h:39
void Class()
Definition: Class.C:29
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
void GrabPointer(Bool_t grab)
Definition: TGScrollBar.h:120
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:308
const TGPicture * fBpic
Definition: TGComboBox.h:79
const Mask_t kGCFont
Definition: GuiTypes.h:299
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:450
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in the text entry widget.
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
Definition: TGComboBox.cxx:421
static Pixel_t fgBlackPixel
Definition: TGFrame.h:151
virtual void SetTopEntry(TGLBEntry *e, TGLayoutHints *lh)
Set a new combo box value (normally update of text string in fSelEntry is done via fSelEntry::Update(...
Definition: TGComboBox.cxx:432
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:627
virtual ~TGComboBox()
Delete a combo box widget.
Definition: TGComboBox.cxx:262
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition: TGFrame.cxx:294
virtual TList * GetList() const
Definition: TGFrame.h:369
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in text entry widget.
TGLayoutHints * fLhb
Definition: TGComboBox.h:81
static constexpr double s
XFontStruct * id
Definition: TGX11.cxx:108
virtual void RemoveAll()
Remove all entries from combo box.
Definition: TGComboBox.cxx:682
virtual void RequestFocus()
Definition: TGWindow.h:98
const TGWindow * fMsgWindow
Definition: TGWidget.h:60
virtual TGLBEntry * Select(Int_t id, Bool_t sel=kTRUE)
Definition: TGListBox.h:352
virtual TGLBEntry * GetSelectedEntry() const
Definition: TGListBox.h:356
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:130
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
Bool_t fOverrideRedirect
Definition: GuiTypes.h:106
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:867
virtual void RemoveAll()
Remove all entries.
Definition: TGListBox.cxx:1352
virtual void SetFrameDrawn(Bool_t flag=kTRUE)
Sets the text entry to draw itself inside a two-pixel frame if enable is kTRUE, and to draw itself wi...
TList * fList
Definition: TGFrame.h:351
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click in text entry.
Definition: TGComboBox.cxx:547
void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h)
Popup combo box popup window at the specified place.
Definition: TGComboBox.cxx:131
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:656
UInt_t fOptions
Definition: TGFrame.h:141
const Mask_t kWASaveUnder
Definition: GuiTypes.h:149
Bool_t IsEditable() const
Definition: TGClient.h:98
Int_t ClearFlags(Int_t flags)
Definition: TGWidget.h:71
EGEventType fType
Definition: GuiTypes.h:174
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:375
Int_t GET_SUBMSG(Long_t val)
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a line style combo box widget as a C++ statement(s).
Definition: TGComboBox.cxx:766
Int_t EntryId() const
Definition: TGListBox.h:68
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a combo box widget as a C++ statement(s) on output stream out.
Definition: TGComboBox.cxx:698
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
TGListBox * fListBox
Definition: TGComboBox.h:78
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
const Handle_t kNone
Definition: GuiTypes.h:87
TGListBox * fListBox
Definition: TGComboBox.h:44
TGFrame * fFrame
Definition: TGLayout.h:119
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle mouse double click event in the text entry widget.
virtual void EnableTextInput(Bool_t on)
Switch text input or readonly mode of combobox (not perfect yet).
Definition: TGComboBox.cxx:361
virtual Pixel_t GetBackground() const
Definition: TGFrame.h:239
virtual ~TGFontTypeComboBox()
Text font combo box dtor.
Definition: TGComboBox.cxx:877
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button events in the combo box.
Definition: TGComboBox.cxx:474
static const TGGC & GetBlackGC()
Get black graphics context.
Definition: TGFrame.cxx:717
virtual void SetEnabled(Bool_t on=kTRUE)
Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
Definition: TGComboBox.cxx:638
#define gVirtualX
Definition: TVirtualX.h:345
#define h(i)
Definition: RSha256.hxx:106
UInt_t fWidth
Definition: TGFrame.h:134
virtual Int_t GetNumberOfEntries() const
Definition: TGListBox.h:331
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition: TGClient.cxx:320
Int_t GET_MSG(Long_t val)
const char * GetString() const
Definition: TGString.h:40
const Bool_t kFALSE
Definition: RtypesCore.h:88
EKeySym
Definition: KeySymbols.h:25
#define SafeDelete(p)
Definition: RConfig.hxx:543
const char * GetText() const
Definition: TGTextEntry.h:134
long Long_t
Definition: RtypesCore.h:50
TGFontTypeComboBox(const TGWindow *p=0, Int_t id=-1, UInt_t options=kHorizontalFrame|kSunkenFrame|kDoubleBorder, Pixel_t bask=GetWhitePixel())
Create a text font combo box.
Definition: TGComboBox.cxx:843
void SetListBox(TGListBox *lb)
Definition: TGComboBox.h:59
#define ClassImp(name)
Definition: Rtypes.h:365
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition: TGFrame.cxx:1004
const TGString * GetText() const
Definition: TGListBox.h:115
const Mask_t kStructureNotifyMask
Definition: GuiTypes.h:165
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
TText * text
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:161
UInt_t fCode
Definition: GuiTypes.h:179
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:289
virtual Bool_t HandleSelection(Event_t *event)
Handle selection in text entry.
Definition: TGComboBox.cxx:563
virtual void Selected(Int_t widgetId, Int_t id)
Emit signal.
Definition: TGComboBox.cxx:625
GContext_t GetGC() const
Definition: TGGC.h:50
const Mask_t kWAOverrideRedirect
Definition: GuiTypes.h:148
unsigned long ULong_t
Definition: RtypesCore.h:51
Double_t y[n]
Definition: legend1.C:17
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:180
TGComboBoxPopup(const TGComboBoxPopup &)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
UInt_t fHeight
Definition: TGFrame.h:135
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
TGLayoutHints * fLhs
Definition: TGComboBox.h:80
const TGWindow * GetParent() const
Definition: TGWindow.h:85
Long_t fUser[5]
Definition: GuiTypes.h:186
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
Handle_t fId
Definition: TGObject.h:36
virtual Int_t GetNumberOfEntries() const
Definition: TGComboBox.h:127
ULong_t fBorderPixel
Definition: GuiTypes.h:96
virtual TGScrollBar * GetScrollBar() const
Definition: TGListBox.h:337
TGLineWidthComboBox(const TGWindow *p=0, Int_t id=-1, UInt_t options=kHorizontalFrame|kSunkenFrame|kDoubleBorder, Pixel_t back=GetWhitePixel(), Bool_t none=kFALSE)
Create a line width combo box.
Definition: TGComboBox.cxx:784
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a line width combo box widget as a C++ statement(s).
Definition: TGComboBox.cxx:808
TGTextEntry * fTextEntry
Definition: TGComboBox.h:75
virtual TGLayoutManager * GetLayoutManager() const
Definition: TGFrame.h:397
Handle_t Window_t
Definition: GuiTypes.h:28
virtual void UnmapWindow()
Definition: TGFrame.h:253
virtual void SetBackgroundColor(Pixel_t col)
Set background color (override from TGWindow base class).
Definition: TGListBox.h:70
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition: TGWindow.h:117
Mask_t fMask
Definition: GuiTypes.h:250
virtual void ReturnPressed()
Add new entry to combo box when return key pressed inside text entry ReturnPressed signal is emitted...
Definition: TGComboBox.cxx:655
virtual Int_t GetSelected() const
Definition: TGComboBox.h:134
const Mask_t kWABorderWidth
Definition: GuiTypes.h:142
TGClient * fClient
Definition: TGObject.h:37
static const char * gFonts[][2]
Definition: TGComboBox.cxx:822
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages generated by the listbox and forward messages to the combobox message handling windo...
Definition: TGComboBox.cxx:581
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:234
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual Bool_t HandleButton(Event_t *)
Handle mouse button event in combo box popup.
Definition: TGComboBox.cxx:85
virtual void Layout()=0
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:372
UInt_t fEditDisabled
Definition: TGWindow.h:41
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2435
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2462
virtual void RemoveEntry(Int_t id=-1)
Remove entry. If id == -1, the currently selected entry is removed.
Definition: TGComboBox.cxx:515
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
virtual void Init()
Initiate the internal classes of a combo box.
Definition: TGComboBox.cxx:285
FontStruct_t fFonts[kMaxFonts]
Definition: TGComboBox.h:209
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line...
virtual void Layout()
layout combobox
Definition: TGComboBox.cxx:534
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
virtual void SetState(Int_t state)
Change state of scrollbar element (either up or down).
const Bool_t kTRUE
Definition: RtypesCore.h:87
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use for a text listbox entry.
Definition: TGListBox.cxx:189
virtual Bool_t HandleSelectionRequest(Event_t *event)
Handle selection request in text entry.
Definition: TGComboBox.cxx:571
const Int_t kMaxFonts
Definition: TGComboBox.h:204
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:303
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition: TGFrame.cxx:747
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition: TGFrame.cxx:757
virtual void DestroyWindow()
Definition: TGWindow.h:92
void KeyPressed(TGFrame *, UInt_t, UInt_t)
Slot handling the key press events.
Definition: TGComboBox.cxx:194
virtual void RemoveEntry(Int_t id=-1)
remove entry with id.
Definition: TGListBox.cxx:1326
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:118
TGLBEntry * fSelected
Definition: TGComboBox.h:45
virtual Int_t MustCleanup() const
Definition: TGFrame.h:420
ULong_t Handle_t
Definition: GuiTypes.h:25