Logo ROOT   master
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 "TVirtualX.h"
51 #include "RConfigure.h"
52 
53 
56 
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 /// Create a combo box popup frame.
63 
65  UInt_t options, ULong_t back) :
66  TGCompositeFrame (p, w, h, options, back), fListBox(0), fSelected(0)
67 {
69 
72  wattr.fOverrideRedirect = kTRUE;
73  wattr.fSaveUnder = kTRUE;
74  wattr.fBorderPixel = fgBlackPixel;
75  wattr.fBorderWidth = 1;
76  gVirtualX->ChangeWindowAttributes(fId, &wattr);
77 
80  SetWindowName();
81 }
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Handle mouse button event in combo box popup.
85 
87 {
88  if (event->fType == kButtonPress && event->fCode == kButton1) {
89  if ((fListBox != 0) && (fSelected != 0) &&
91  // in the case the combo box popup is closed by clicking outside the
92  // list box, then select the previously selected entry
94  }
95  EndPopup();
96  }
97  else {
98  // reset the dragging flag of the scrollbar when the button is
99  // released outside the scrollbar itself
101  }
102  return kTRUE;
103 }
104 
105 ////////////////////////////////////////////////////////////////////////////////
106 /// Ungrab pointer and unmap popup window.
107 
109 {
110  if (IsMapped()) {
111  Handle_t id = fListBox->GetContainer()->GetId();
112  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Up),
114  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Down),
116  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Enter),
118  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Return),
120  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Escape),
122  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Space),
124  gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
125  UnmapWindow();
126  }
127 }
128 
129 ////////////////////////////////////////////////////////////////////////////////
130 /// Popup combo box popup window at the specified place.
131 
133 {
134  Int_t rx, ry;
135  UInt_t rw, rh;
136 
137  // Parent is root window for the popup:
138  gVirtualX->GetWindowSize(fParent->GetId(), rx, ry, rw, rh);
139 
140  if (gVirtualX->InheritsFrom("TGWin32")) {
141  if ((x > 0) && ((x + abs(rx) + (Int_t)fWidth) > (Int_t)rw))
142  x = rw - abs(rx) - fWidth;
143  if ((y > 0) && (y + abs(ry) + (Int_t)fHeight > (Int_t)rh))
144  y = rh - fHeight;
145  } else {
146  if (x < 0) x = 0;
147  if (x + fWidth > rw) x = rw - fWidth;
148  if (y < 0) y = 0;
149  if (y + fHeight > rh) y = rh - fHeight;
150  }
151 
152  // remember the current selected entry
153  if (fListBox == 0) {
154  // the listbox should be the first in the list
156  fListBox = dynamic_cast<TGListBox *>(el->fFrame);
157  }
159 
160  MoveResize(x, y, w, h);
161  MapSubwindows();
162  Layout();
163  MapRaised();
164 
165  Handle_t id = fListBox->GetContainer()->GetId();
166  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Up),
168  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Down),
170  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Enter),
172  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Return),
174  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Escape),
176  gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Space),
179 
183 
184  if (fClient->IsEditable()) {
185  fClient->RegisterPopup(this);
186  }
187 
188  fClient->WaitForUnmap(this);
189  EndPopup();
190 }
191 
192 ////////////////////////////////////////////////////////////////////////////////
193 /// Slot handling the key press events.
194 
196 {
197  switch ((EKeySym)keysym) {
198  case kKey_Enter:
199  case kKey_Return:
200  case kKey_Space:
201  if (fListBox && f) {
202  TGLBEntry *entry = dynamic_cast<TGLBEntry *>(f);
203  if (entry) {
204  fListBox->Select(entry->EntryId());
206  entry->EntryId(), 0);
207  }
208  }
209  EndPopup();
210  break;
211  case kKey_Escape:
212  if (fListBox)
213  ((TGContainer *)fListBox->GetContainer())->UnSelectAll();
214  EndPopup();
215  break;
216  default:
217  break;
218  }
219 }
220 
221 ////////////////////////////////////////////////////////////////////////////////
222 /// Create a combo box widget.
223 
225  ULong_t back) :
226  TGCompositeFrame (p, 10, 10, options | kOwnBackground, back)
227 {
228  fWidgetId = id;
229  fMsgWindow = p;
230  fTextEntry = 0;
231 
232  fSelEntry = new TGTextLBEntry(this, new TGString(""), 0);
234 
237  Init();
238 }
239 
240 ////////////////////////////////////////////////////////////////////////////////
241 /// Create an editable combo box widget.
242 
243 TGComboBox::TGComboBox(const TGWindow *p, const char *text, Int_t id,
244  UInt_t options, ULong_t back) :
245  TGCompositeFrame (p, 10, 10, options | kOwnBackground, back)
246 {
247  fWidgetId = id;
248  fMsgWindow = p;
249  fSelEntry = 0;
250 
251  fTextEntry = new TGTextEntry(this, text, id);
253  fTextEntry->Connect("ReturnPressed()", "TGComboBox", this, "ReturnPressed()");
254 
257  Init();
258 }
259 
260 ////////////////////////////////////////////////////////////////////////////////
261 /// Delete a combo box widget.
262 
264 {
266 
267  if (!MustCleanup()) {
271  SafeDelete(fLhs);
272  SafeDelete(fLhb);
273  }
274 
275  SafeDelete(fLhdd);
277  if (fComboFrame) {
278  fComboFrame->EndPopup(); // force popdown in case of Qt interface
280  }
281 }
282 
283 ////////////////////////////////////////////////////////////////////////////////
284 /// Initiate the internal classes of a combo box.
285 
287 {
288  fBpic = fClient->GetPicture("arrow_down.xpm");
289 
290  if (!fBpic)
291  Error("TGComboBox", "arrow_down.xpm not found");
292 
295 
297  kLHintsExpandY));
298 
300 
302 
303  fListBox->Resize(100, 100);
304  fListBox->Associate(this);
305  fListBox->GetScrollBar()->GrabPointer(kFALSE); // combobox will do a pointergrab
306 
308  kLHintsExpandY));
312 
315 
316  fListBox->GetContainer()->Connect("KeyPressed(TGFrame*, UInt_t, UInt_t)",
317  "TGComboBoxPopup", fComboFrame,
318  "KeyPressed(TGFrame*, UInt_t, UInt_t)");
319  // Drop down listbox of combo box should react to pointer motion
320  // so it will be able to Activate() (i.e. highlight) the different
321  // items when the mouse crosses.
324 
331 
332  SetWindowName();
333 }
334 
335 ////////////////////////////////////////////////////////////////////////////////
336 /// Draw border of combo box widget.
337 
339 {
342  gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
343  gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
344  gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, fWidth-3, 1);
345  gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, 1, fHeight-3);
346  if (gClient->GetStyle() > 1) break;
347  gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
348  gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
349  gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
350  gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, 1, fWidth-2, fHeight-2);
351  break;
352 
353  default:
355  break;
356  }
357 }
358 
359 ////////////////////////////////////////////////////////////////////////////////
360 /// Switch text input or readonly mode of combobox (not perfect yet).
361 
363 {
364  // UInt_t w, h;
365  TString text = "";
366  Pixel_t back = TGFrame::GetWhitePixel(); // default
367 
368  if (on) {
369  if (fSelEntry) {
370  back = fSelEntry->GetBackground();
371  text = ((TGTextLBEntry*)fSelEntry)->GetText()->GetString();
373  fTextEntry->SetText(text.Data());
374  }
376  //w = fSelEntry->GetWidth();
377  //h = fSelEntry->GetHeight();
379  delete fSelEntry;
380  fSelEntry = 0;
381  }
382  if (!fTextEntry) {
383  fTextEntry = new TGTextEntry(this, text.Data(), 0);
385  fTextEntry->Connect("ReturnPressed()", "TGComboBox", this, "ReturnPressed()");
388  }
390  MapSubwindows();
391  // coverity[returned_null]
392  // coverity[dereference]
394  } else {
395  if (fTextEntry) {
396  back = fTextEntry->GetBackground();
397  text = fTextEntry->GetText();
400  //w = fTextEntry->GetWidth();
401  //h = fTextEntry->GetHeight();
402  delete fTextEntry;
403  fTextEntry = 0;
404  }
405  if (!fSelEntry) {
406  fSelEntry = new TGTextLBEntry(this, new TGString(text.Data()), 0);
410  }
412  MapSubwindows();
413  // coverity[returned_null]
414  // coverity[dereference]
416  }
417 }
418 
419 ////////////////////////////////////////////////////////////////////////////////
420 /// Find entry by name.
421 
422 TGLBEntry *TGComboBox::FindEntry(const char *s) const
423 {
424  TGLBEntry *sel = 0;
425  sel = fListBox->FindEntry(s);
426  return sel;
427 }
428 
429 ////////////////////////////////////////////////////////////////////////////////
430 /// Set a new combo box value (normally update of text string in
431 /// fSelEntry is done via fSelEntry::Update()).
432 
434 {
435  if (!fSelEntry) return;
436 
439  delete fSelEntry;
440  delete fLhs;
441  fSelEntry = e;
442  fLhs = lh;
444  Layout();
445 }
446 
447 ////////////////////////////////////////////////////////////////////////////////
448 /// Make the selected item visible in the combo box window
449 /// and emit signals according to the second parameter.
450 
452 {
453  if (id!=GetSelected()) {
454  TGLBEntry *e;
455  e = fListBox->Select(id);
456  if (e) {
457  if (fSelEntry) {
458  fSelEntry->Update(e);
459  Layout();
460  } else if (fTextEntry && e->InheritsFrom(TGTextLBEntry::Class())) {
461  TGTextLBEntry *te = (TGTextLBEntry*)e;
462  fTextEntry->SetText(te->GetText()->GetString());
463  }
464  if (emit) {
465  Selected(fWidgetId, id);
466  Selected(id);
467  }
468  }
469  }
470 }
471 
472 ////////////////////////////////////////////////////////////////////////////////
473 /// Handle mouse button events in the combo box.
474 
476 {
477  if (!fDDButton || !fDDButton->IsEnabled()) return kFALSE;
478 
479  if (event->fType == kButtonPress) {
480  Window_t child = (Window_t)event->fUser[0]; // fUser[0] = child window
481 
482  if (child == fDDButton->GetId() || (fSelEntry && child == fSelEntry->GetId())) {
484 
485  if (fTextEntry && (child == fTextEntry->GetId())) {
486  return fTextEntry->HandleButton(event);
487  }
488  int ax, ay;
489  Window_t wdummy;
490  gVirtualX->TranslateCoordinates(fId, fComboFrame->GetParent()->GetId(),
491  0, fHeight, ax, ay, wdummy);
492  // Drop down listbox of combo box should react to pointer motion...
494 #ifdef R__HAS_COCOA
495  gVirtualX->SetWMTransientHint(fComboFrame->GetId(), GetId());
496 #endif
499 #ifdef R__HAS_COCOA
500  //tp: I need this modification - "button" is not repainted correctly
501  //with Cocoa, when combobox is closed (reason is quite complex), happens
502  //when item is wider than combobox.
503  //TODO: find another way :)
505 #endif
506  } else if (fTextEntry) {
507  return fTextEntry->HandleButton(event);
508  }
509  }
510  return kTRUE;
511 }
512 
513 ////////////////////////////////////////////////////////////////////////////////
514 /// Remove entry. If id == -1, the currently selected entry is removed
515 
517 {
518  fListBox->RemoveEntry(id);
519 
520  if (id < 0) {
521  if (fSelEntry) {
522  ((TGTextLBEntry*)fSelEntry)->SetTitle("");
524  } else {
525  fTextEntry->SetTitle("");
527  }
528  }
529  Resize();
530 }
531 
532 ////////////////////////////////////////////////////////////////////////////////
533 /// layout combobox
534 
536 {
539 
540  if (h && (h < 100)) {
542  }
543 }
544 
545 ////////////////////////////////////////////////////////////////////////////////
546 /// Handle double click in text entry.
547 
549 {
550  return fTextEntry ? fTextEntry->HandleDoubleClick(event) : kTRUE;
551 }
552 
553 ////////////////////////////////////////////////////////////////////////////////
554 /// Handle pointer motion in text entry.
555 
557 {
558  return fTextEntry ? fTextEntry->HandleMotion(event) : kTRUE;
559 }
560 
561 ////////////////////////////////////////////////////////////////////////////////
562 /// Handle selection in text entry.
563 
565 {
566  return fTextEntry ? fTextEntry->HandleSelection(event) : kTRUE;
567 }
568 
569 ////////////////////////////////////////////////////////////////////////////////
570 /// Handle selection request in text entry.
571 
573 {
575 }
576 
577 ////////////////////////////////////////////////////////////////////////////////
578 /// Process messages generated by the listbox and forward
579 /// messages to the combobox message handling window. Parm2 contains
580 /// the id of the selected listbox entry.
581 
583 {
584  TGLBEntry *e;
585 
586  switch (GET_MSG(msg)) {
587  case kC_COMMAND:
588  switch (GET_SUBMSG(msg)) {
589  case kCM_LISTBOX:
591  if (fSelEntry) {
592  fSelEntry->Update(e);
593  } else if (fTextEntry &&
594  e->InheritsFrom(TGTextLBEntry::Class())) {
595  TGTextLBEntry *te = (TGTextLBEntry*)e;
596  fTextEntry->SetText(te->GetText()->GetString());
597  }
598  // coverity[returned_null]
599  // coverity[dereference]
604  fWidgetId, parm2);
605  if (e->InheritsFrom(TGTextLBEntry::Class())) {
606  const char *text;
607  text = ((TGTextLBEntry*)e)->GetText()->GetString();
608  Selected(text);
609  }
610  Selected(fWidgetId, (Int_t)parm2);
611  Selected((Int_t)parm2);
612  fClient->NeedRedraw(this);
613  break;
614  }
615  break;
616 
617  default:
618  break;
619  }
620  return kTRUE;
621 }
622 
623 ////////////////////////////////////////////////////////////////////////////////
624 /// Emit signal.
625 
626 void TGComboBox::Selected(Int_t widgetId, Int_t id)
627 {
628  Long_t args[2];
629 
630  args[0] = widgetId;
631  args[1] = id;
632 
633  Emit("Selected(Int_t,Int_t)", args);
634 }
635 
636 ////////////////////////////////////////////////////////////////////////////////
637 /// Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
638 
640 {
641  fDDButton->SetEnabled(on);
642  if (on) {
645  } else {
648  }
650 }
651 
652 ////////////////////////////////////////////////////////////////////////////////
653 /// Add new entry to combo box when return key pressed inside text entry
654 /// ReturnPressed signal is emitted.
655 
657 {
658  if (!fTextEntry) return;
659 
662 
663  TIter next(lbc->GetList());
664  TGFrameElement *el;
665 
666  Emit("ReturnPressed()");
667 
668  while ((el = (TGFrameElement *)next())) {
669  TGTextLBEntry *lbe = (TGTextLBEntry *)el->fFrame;
670  if (lbe->GetText()->GetString() == text) {
671  return;
672  }
673  }
674 
675  Int_t nn = GetNumberOfEntries() + 1;
676  AddEntry(text.Data(), nn);
677  Select(nn);
678 }
679 
680 ////////////////////////////////////////////////////////////////////////////////
681 /// Remove all entries from combo box.
682 
684 {
685  fListBox->RemoveAll();
686 
687  if (fSelEntry) {
688  ((TGTextLBEntry*)fSelEntry)->SetTitle("");
690  } else {
691  fTextEntry->SetTitle("");
693  }
694 }
695 
696 ////////////////////////////////////////////////////////////////////////////////
697 /// Save a combo box widget as a C++ statement(s) on output stream out.
698 
699 void TGComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
700 {
701  if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
702 
703  out << std::endl << " // combo box" << std::endl;
704  out << " TGComboBox *";
705 
706  if (!fTextEntry) {
707  out << GetName() << " = new TGComboBox(" << fParent->GetName() << "," << fWidgetId;
708  } else {
709  out << GetName() << " = new TGComboBox(" << fParent->GetName() << ",";
710  out << '\"' << fTextEntry->GetText() << '\"' << "," <<fWidgetId;
711  }
712 
713  if (fBackground == GetWhitePixel()) {
715  out <<");" << std::endl;
716  } else {
717  out << "," << GetOptionString() << ");" << std::endl;
718  }
719  } else {
720  out << "," << GetOptionString() << ",ucolor);" << std::endl;
721  }
722  if (option && strstr(option, "keep_names"))
723  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
724 
725  TGTextLBEntry *b;
726  TGFrameElement *el;
727  TGListBox *lb = GetListBox();
728 
729  TIter next(((TGLBContainer *)lb->GetContainer())->GetList());
730 
731  while ((el = (TGFrameElement *) next())) {
732  b = (TGTextLBEntry *) el->fFrame;
733  out << " " << GetName() << "->AddEntry(";
734  b->SavePrimitive(out, option);
735  out << ");" << std::endl;
736  }
737 
738  out << " " << GetName() << "->Resize(" << GetWidth() << ","
739  << GetHeight() << ");" << std::endl;
740  out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
741 }
742 
743 ////////////////////////////////////////////////////////////////////////////////
744 /// Create a line style combo box.
745 
747  UInt_t options, Pixel_t back)
748  : TGComboBox(p, id, options, back)
749 {
750  SetTopEntry(new TGLineLBEntry(this, 0),
753 
754  for (Int_t i = 1; i <= 10; i++)
755  AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
756  TString::Format("%d",i), 0, i),
758 
759  Select(1, kFALSE); // to have first entry selected
760 
761  SetWindowName();
762 }
763 
764 ////////////////////////////////////////////////////////////////////////////////
765 /// Save a line style combo box widget as a C++ statement(s).
766 
767 void TGLineStyleComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
768 {
769  out << std::endl << " // line style combo box" << std::endl;
770  out << " TGLineStyleComboBox *";
771 
772  out << GetName() << " = new TGLineStyleComboBox(" << fParent->GetName()
773  << "," << fWidgetId << ");" << std::endl;
774  if (option && strstr(option, "keep_names"))
775  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
776  out << " " << GetName() << "->Resize(" << GetWidth() << ","
777  << GetHeight() << ");" << std::endl;
778  out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
779 }
780 
781 ////////////////////////////////////////////////////////////////////////////////
782 /// Create a line width combo box.
783 /// If "none" is equal to kTRUE the first entry is "None".
784 
786  UInt_t options, Pixel_t back, Bool_t none)
787  : TGComboBox(p, id, options, back)
788 {
789  SetTopEntry(new TGLineLBEntry(this,0),
792 
793  if (none) {
794  AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), 0, "None", 0, 0),
796  }
797 
798  for (Int_t i = 0; i < 16; i++)
799  AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
800  TString::Format("%d",i), i, 0),
802  Select(1, kFALSE); // to have first entry selected
803  SetWindowName();
804 }
805 
806 ////////////////////////////////////////////////////////////////////////////////
807 /// Save a line width combo box widget as a C++ statement(s).
808 
809 void TGLineWidthComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
810 {
811  out << std::endl << " // line width combo box" << std::endl;
812  out << " TGLineWidthComboBox *";
813 
814  out << GetName() << " = new TGLineWidthComboBox(" << fParent->GetName()
815  << "," << fWidgetId << ");" << std::endl;
816  if (option && strstr(option, "keep_names"))
817  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
818  out << " " << GetName() << "->Resize(" << GetWidth() << ","
819  << GetHeight() << ");" << std::endl;
820  out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
821 }
822 
823 static const char *gFonts[][2] = { // unix name, name
824  { "", "" }, //not used
825  { "-*-times-medium-i-*-*-12-*-*-*-*-*-*-*", "1. times italic" },
826  { "-*-times-bold-r-*-*-12-*-*-*-*-*-*-*", "2. times bold" },
827  { "-*-times-bold-i-*-*-12-*-*-*-*-*-*-*", "3. times bold italic" },
828  { "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*", "4. helvetica" },
829  { "-*-helvetica-medium-o-*-*-12-*-*-*-*-*-*-*", "5. helvetica italic" },
830  { "-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*", "6. helvetica bold" },
831  { "-*-helvetica-bold-o-*-*-12-*-*-*-*-*-*-*", "7. helvetica bold italic" },
832  { "-*-courier-medium-r-*-*-12-*-*-*-*-*-*-*", "8. courier" },
833  { "-*-courier-medium-o-*-*-12-*-*-*-*-*-*-*", "9. courier italic" },
834  { "-*-courier-bold-r-*-*-12-*-*-*-*-*-*-*", "10. courier bold" },
835  { "-*-courier-bold-o-*-*-12-*-*-*-*-*-*-*", "11. courier bold italic" },
836  { "-*-symbol-medium-r-*-*-12-*-*-*-*-*-*-*", "12. symbol" },
837  { "-*-times-medium-r-*-*-12-*-*-*-*-*-*-*", "13. times" },
838  { 0, 0}
839 };
840 
841 ////////////////////////////////////////////////////////////////////////////////
842 /// Create a text font combo box.
843 
845  UInt_t options, Pixel_t back) :
846  TGComboBox(p, id, options, back)
847 {
848  Int_t noFonts = 0;
849 
850  for (Int_t i = 1; gFonts[i][0] != 0 && noFonts < kMaxFonts; i++) {
851 
852  fFonts[noFonts] = gVirtualX->LoadQueryFont(gFonts[i][0]);
853 
854  if (fFonts[noFonts] == 0)
856 
857  GCValues_t gval;
858  gval.fMask = kGCFont;
859  gval.fFont = gVirtualX->GetFontHandle(fFonts[noFonts]);
860 
861  AddEntry(new TGTextLBEntry(GetListBox()->GetContainer(),
862  new TGString(gFonts[i][1]), i,
863  fClient->GetGC(&gval, kTRUE)->GetGC(), fFonts[noFonts]),
865  noFonts++;
866  }
867 
868  if (noFonts < kMaxFonts - 1)
869  fFonts[noFonts] = 0;
870 
871  Select(1, kFALSE); // to have first entry selected
872  SetWindowName();
873 }
874 
875 ////////////////////////////////////////////////////////////////////////////////
876 /// Text font combo box dtor.
877 
879 {
880  for (int i = 0; i < kMaxFonts && fFonts[i] != 0; i++) {
881  if (fFonts[i] != TGTextLBEntry::GetDefaultFontStruct()) gVirtualX->DeleteFont(fFonts[i]);
882  }
883 }
virtual Bool_t HandleSelectionRequest(Event_t *event)
Handle request to send current clipboard contents to requestor window.
const TGWindow * fParent
Definition: TGWindow.h:36
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:589
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1420
Cursor_t GetGrabCursor() const
virtual UInt_t GetOptions() const
Definition: TGFrame.h:222
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:613
TGScrollBarElement * fDDButton
Definition: TGComboBox.h:76
virtual Bool_t HandleMotion(Event_t *event)
Handle pointer motion in text entry.
Definition: TGComboBox.cxx:556
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
Definition: TGListBox.cxx:1644
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:323
UInt_t GetItemVsize() const
Definition: TGListBox.h:358
const char Option_t
Definition: RtypesCore.h:64
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition: TGFrame.cxx:739
virtual Bool_t HandleSelection(Event_t *event)
Handle text selection event.
void EndPopup()
Ungrab pointer and unmap popup window.
Definition: TGComboBox.cxx:108
UInt_t GetHeight() const
Definition: TGFrame.h:250
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:693
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 DestroyWindow()
destroy window
Definition: TGWindow.cxx:174
virtual void DrawBorder()
Draw border of combo box widget.
Definition: TGComboBox.cxx:338
virtual void DrawBorder()
Draw frame border.
Definition: TGFrame.cxx:405
virtual void SetTitle(const char *label)
Definition: TGTextEntry.h:170
Basic string class.
Definition: TString.h:131
Pixel_t fBackground
Definition: TGFrame.h:120
#define gClient
Definition: TGClient.h:166
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:43
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:351
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:746
virtual void SetEnabled(Bool_t on=kTRUE)
Enable/Disable scroll bar button chaging the state.
UInt_t GetWidth() const
Definition: TGFrame.h:249
virtual void MapRaised()
map raised
Definition: TGFrame.h:230
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:1241
TGComboBoxPopup * fComboFrame
Definition: TGComboBox.h:77
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition: TGFrame.cxx:1133
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:667
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:451
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:422
static Pixel_t fgBlackPixel
Definition: TGFrame.h:129
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:433
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:629
virtual ~TGComboBox()
Delete a combo box widget.
Definition: TGComboBox.cxx:263
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition: TGFrame.cxx:296
virtual TList * GetList() const
Definition: TGFrame.h:347
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:683
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:866
virtual void RemoveAll()
Remove all entries.
Definition: TGListBox.cxx:1353
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:329
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click in text entry.
Definition: TGComboBox.cxx:548
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:132
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:658
UInt_t fOptions
Definition: TGFrame.h:119
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:353
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:767
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:699
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:318
TGListBox * fListBox
Definition: TGComboBox.h:78
unsigned int UInt_t
Definition: RtypesCore.h:44
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:888
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:362
virtual Pixel_t GetBackground() const
Definition: TGFrame.h:217
virtual ~TGFontTypeComboBox()
Text font combo box dtor.
Definition: TGComboBox.cxx:878
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button events in the combo box.
Definition: TGComboBox.cxx:475
static const TGGC & GetBlackGC()
Get black graphics context.
Definition: TGFrame.cxx:719
virtual void SetEnabled(Bool_t on=kTRUE)
Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
Definition: TGComboBox.cxx:639
#define gVirtualX
Definition: TVirtualX.h:338
#define h(i)
Definition: RSha256.hxx:106
UInt_t fWidth
Definition: TGFrame.h:112
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:90
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:52
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:844
void SetListBox(TGListBox *lb)
Definition: TGComboBox.h:59
#define ClassImp(name)
Definition: Rtypes.h:361
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition: TGFrame.cxx:1006
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:564
virtual void Selected(Int_t widgetId, Int_t id)
Emit signal.
Definition: TGComboBox.cxx:626
GContext_t GetGC() const
Definition: TGGC.h:50
const Mask_t kWAOverrideRedirect
Definition: GuiTypes.h:148
unsigned long ULong_t
Definition: RtypesCore.h:53
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:277
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:113
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
TGLayoutHints * fLhs
Definition: TGComboBox.h:80
const TGWindow * GetParent() const
Definition: TGWindow.h:84
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:1148
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:785
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a line width combo box widget as a C++ statement(s).
Definition: TGComboBox.cxx:809
TGTextEntry * fTextEntry
Definition: TGComboBox.h:75
virtual TGLayoutManager * GetLayoutManager() const
Definition: TGFrame.h:375
Handle_t Window_t
Definition: GuiTypes.h:28
virtual void UnmapWindow()
unmap window
Definition: TGFrame.h:231
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:114
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:656
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:823
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:582
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:86
virtual void Layout()=0
virtual void RequestFocus()
request focus
Definition: TGWindow.cxx:214
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:372
UInt_t fEditDisabled
Definition: TGWindow.h:40
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2437
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2464
virtual void RemoveEntry(Int_t id=-1)
Remove entry. If id == -1, the currently selected entry is removed.
Definition: TGComboBox.cxx:516
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:286
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:535
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:89
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use for a text listbox entry.
Definition: TGListBox.cxx:190
virtual Bool_t HandleSelectionRequest(Event_t *event)
Handle selection request in text entry.
Definition: TGComboBox.cxx:572
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:305
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition: TGFrame.cxx:749
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition: TGFrame.cxx:759
void KeyPressed(TGFrame *, UInt_t, UInt_t)
Slot handling the key press events.
Definition: TGComboBox.cxx:195
virtual void RemoveEntry(Int_t id=-1)
remove entry with id.
Definition: TGListBox.cxx:1327
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:119
TGLBEntry * fSelected
Definition: TGComboBox.h:45
virtual Int_t MustCleanup() const
Definition: TGFrame.h:398
ULong_t Handle_t
Definition: GuiTypes.h:25