Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TGResourcePool.h"
46#include "TGTextEntry.h"
47#include "KeySymbols.h"
48#include "TVirtualX.h"
49#include "RConfigure.h"
50
51#include <iostream>
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
73 wattr.fSaveUnder = kTRUE;
75 wattr.fBorderWidth = 1;
76 gVirtualX->ChangeWindowAttributes(fId, &wattr);
77
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()) {
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);
162 Layout();
163 MapRaised();
164
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
243TGComboBox::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()) {
273 }
274
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
298
300
302
303 fListBox->Resize(100, 100);
304 fListBox->Associate(this);
305 fListBox->GetScrollBar()->GrabPointer(kFALSE); // combobox will do a pointergrab
306
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
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();
372 if (fTextEntry && fSelEntry->InheritsFrom(TGTextLBEntry::Class())) {
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 }
391 // coverity[returned_null]
392 // coverity[dereference]
394 } else {
395 if (fTextEntry) {
396 back = fTextEntry->GetBackground();
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 }
413 // coverity[returned_null]
414 // coverity[dereference]
416 }
417}
418
419////////////////////////////////////////////////////////////////////////////////
420/// Find entry by name.
421
422TGLBEntry *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) {
459 Layout();
460 } else if (fTextEntry && e->InheritsFrom(TGTextLBEntry::Class())) {
463 }
464 if (emit) {
465 Selected(fWidgetId, id);
466 Selected(id);
467 Changed();
468 }
469 }
470 }
471}
472
473////////////////////////////////////////////////////////////////////////////////
474/// Handle mouse button events in the combo box.
475
477{
478 if (!fDDButton || !fDDButton->IsEnabled()) return kFALSE;
479
480 if (event->fType == kButtonPress) {
481 Window_t child = (Window_t)event->fUser[0]; // fUser[0] = child window
482
483 if (child == fDDButton->GetId() || (fSelEntry && child == fSelEntry->GetId())) {
485
486 if (fTextEntry && (child == fTextEntry->GetId())) {
487 return fTextEntry->HandleButton(event);
488 }
489 int ax, ay;
490 Window_t wdummy;
491 gVirtualX->TranslateCoordinates(fId, fComboFrame->GetParent()->GetId(),
492 0, fHeight, ax, ay, wdummy);
493 // Drop down listbox of combo box should react to pointer motion...
495#ifdef R__HAS_COCOA
496 gVirtualX->SetWMTransientHint(fComboFrame->GetId(), GetId());
497#endif
500#ifdef R__HAS_COCOA
501 //tp: I need this modification - "button" is not repainted correctly
502 //with Cocoa, when combobox is closed (reason is quite complex), happens
503 //when item is wider than combobox.
504 //TODO: find another way :)
506#endif
507 } else if (fTextEntry) {
508 return fTextEntry->HandleButton(event);
509 }
510 }
511 return kTRUE;
512}
513
514////////////////////////////////////////////////////////////////////////////////
515/// Remove entry. If id == -1, the currently selected entry is removed
516
518{
520
521 if (id < 0) {
522 if (fSelEntry) {
523 ((TGTextLBEntry*)fSelEntry)->SetTitle("");
525 } else {
526 fTextEntry->SetTitle("");
528 }
529 }
530 Resize();
531}
532
533////////////////////////////////////////////////////////////////////////////////
534/// layout combobox
535
537{
540
541 if (h && (h < 100)) {
543 }
544}
545
546////////////////////////////////////////////////////////////////////////////////
547/// Handle double click in text entry.
548
550{
551 return fTextEntry ? fTextEntry->HandleDoubleClick(event) : kTRUE;
552}
553
554////////////////////////////////////////////////////////////////////////////////
555/// Handle pointer motion in text entry.
556
558{
559 return fTextEntry ? fTextEntry->HandleMotion(event) : kTRUE;
560}
561
562////////////////////////////////////////////////////////////////////////////////
563/// Handle selection in text entry.
564
566{
567 return fTextEntry ? fTextEntry->HandleSelection(event) : kTRUE;
568}
569
570////////////////////////////////////////////////////////////////////////////////
571/// Handle selection request in text entry.
572
574{
576}
577
578////////////////////////////////////////////////////////////////////////////////
579/// Process messages generated by the listbox and forward
580/// messages to the combobox message handling window. Parm2 contains
581/// the id of the selected listbox entry.
582
584{
585 TGLBEntry *e;
586
587 switch (GET_MSG(msg)) {
588 case kC_COMMAND:
589 switch (GET_SUBMSG(msg)) {
590 case kCM_LISTBOX:
592 if (fSelEntry) {
594 } else if (fTextEntry &&
595 e->InheritsFrom(TGTextLBEntry::Class())) {
598 }
599 // coverity[returned_null]
600 // coverity[dereference]
605 fWidgetId, parm2);
606 if (e->InheritsFrom(TGTextLBEntry::Class())) {
607 const char *text;
608 text = ((TGTextLBEntry*)e)->GetText()->GetString();
609 Selected(text);
610 }
611 Selected(fWidgetId, (Int_t)parm2);
612 Selected((Int_t)parm2);
613 Changed();
614 fClient->NeedRedraw(this);
615 break;
616 }
617 break;
618
619 default:
620 break;
621 }
622 return kTRUE;
623}
624
625////////////////////////////////////////////////////////////////////////////////
626/// Emit signal, done only when selected entry changed.
627
629{
630 Long_t args[2];
631
632 args[0] = widgetId;
633 args[1] = id;
634
635 Emit("Selected(Int_t,Int_t)", args);
636}
637
638////////////////////////////////////////////////////////////////////////////////
639/// Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
640
642{
644 if (on) {
647 } else {
650 }
652}
653
654////////////////////////////////////////////////////////////////////////////////
655/// Add new entry to combo box when return key pressed inside text entry
656/// ReturnPressed signal is emitted.
657
659{
660 if (!fTextEntry) return;
661
664
665 TIter next(lbc->GetList());
666 TGFrameElement *el;
667
668 Emit("ReturnPressed()");
669
670 while ((el = (TGFrameElement *)next())) {
671 TGTextLBEntry *lbe = (TGTextLBEntry *)el->fFrame;
672 if (lbe->GetText()->GetString() == text) {
673 return;
674 }
675 }
676
677 Int_t nn = GetNumberOfEntries() + 1;
678 AddEntry(text.Data(), nn);
679 Select(nn);
680}
681
682////////////////////////////////////////////////////////////////////////////////
683/// Remove all entries from combo box.
684
686{
688
689 if (fSelEntry) {
690 ((TGTextLBEntry*)fSelEntry)->SetTitle("");
692 } else {
693 fTextEntry->SetTitle("");
695 }
696}
697
698////////////////////////////////////////////////////////////////////////////////
699/// Save a combo box widget as a C++ statement(s) on output stream out.
700
701void TGComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
702{
704
705 out << std::endl << " // combo box" << std::endl;
706 out << " TGComboBox *";
707
708 if (!fTextEntry) {
709 out << GetName() << " = new TGComboBox(" << fParent->GetName() << "," << fWidgetId;
710 } else {
711 out << GetName() << " = new TGComboBox(" << fParent->GetName() << ",";
712 out << '\"' << fTextEntry->GetText() << '\"' << "," <<fWidgetId;
713 }
714
715 if (fBackground == GetWhitePixel()) {
717 out <<");" << std::endl;
718 } else {
719 out << "," << GetOptionString() << ");" << std::endl;
720 }
721 } else {
722 out << "," << GetOptionString() << ",ucolor);" << std::endl;
723 }
724 if (option && strstr(option, "keep_names"))
725 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
726
728 TGFrameElement *el;
729 TGListBox *lb = GetListBox();
730
731 TIter next(((TGLBContainer *)lb->GetContainer())->GetList());
732
733 while ((el = (TGFrameElement *) next())) {
734 b = (TGTextLBEntry *) el->fFrame;
735 out << " " << GetName() << "->AddEntry(";
736 b->SavePrimitive(out, option);
737 out << ");" << std::endl;
738 }
739
740 out << " " << GetName() << "->Resize(" << GetWidth() << ","
741 << GetHeight() << ");" << std::endl;
742 out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
743}
744
745////////////////////////////////////////////////////////////////////////////////
746/// Create a line style combo box.
747
749 UInt_t options, Pixel_t back)
750 : TGComboBox(p, id, options, back)
751{
752 SetTopEntry(new TGLineLBEntry(this, 0),
755
756 for (Int_t i = 1; i <= 10; i++)
757 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
758 TString::Format("%d",i), 0, i),
760
761 Select(1, kFALSE); // to have first entry selected
762
764}
765
766////////////////////////////////////////////////////////////////////////////////
767/// Save a line style combo box widget as a C++ statement(s).
768
769void TGLineStyleComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
770{
771 out << std::endl << " // line style combo box" << std::endl;
772 out << " TGLineStyleComboBox *";
773
774 out << GetName() << " = new TGLineStyleComboBox(" << fParent->GetName()
775 << "," << fWidgetId << ");" << std::endl;
776 if (option && strstr(option, "keep_names"))
777 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
778 out << " " << GetName() << "->Resize(" << GetWidth() << ","
779 << GetHeight() << ");" << std::endl;
780 out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
781}
782
783////////////////////////////////////////////////////////////////////////////////
784/// Create a line width combo box.
785/// If "none" is equal to kTRUE the first entry is "None".
786
788 UInt_t options, Pixel_t back, Bool_t none)
789 : TGComboBox(p, id, options, back)
790{
791 SetTopEntry(new TGLineLBEntry(this,0),
794
795 if (none) {
796 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), 0, "None", 0, 0),
798 }
799
800 for (Int_t i = 0; i < 16; i++)
801 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
802 TString::Format("%d",i), i, 0),
804 Select(1, kFALSE); // to have first entry selected
806}
807
808////////////////////////////////////////////////////////////////////////////////
809/// Save a line width combo box widget as a C++ statement(s).
810
811void TGLineWidthComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
812{
813 out << std::endl << " // line width combo box" << std::endl;
814 out << " TGLineWidthComboBox *";
815
816 out << GetName() << " = new TGLineWidthComboBox(" << fParent->GetName()
817 << "," << fWidgetId << ");" << std::endl;
818 if (option && strstr(option, "keep_names"))
819 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
820 out << " " << GetName() << "->Resize(" << GetWidth() << ","
821 << GetHeight() << ");" << std::endl;
822 out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
823}
824
825static const char *gFonts[][2] = { // unix name, name
826 { "", "" }, //not used
827 { "-*-times-medium-i-*-*-12-*-*-*-*-*-*-*", "1. times italic" },
828 { "-*-times-bold-r-*-*-12-*-*-*-*-*-*-*", "2. times bold" },
829 { "-*-times-bold-i-*-*-12-*-*-*-*-*-*-*", "3. times bold italic" },
830 { "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*", "4. helvetica" },
831 { "-*-helvetica-medium-o-*-*-12-*-*-*-*-*-*-*", "5. helvetica italic" },
832 { "-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*", "6. helvetica bold" },
833 { "-*-helvetica-bold-o-*-*-12-*-*-*-*-*-*-*", "7. helvetica bold italic" },
834 { "-*-courier-medium-r-*-*-12-*-*-*-*-*-*-*", "8. courier" },
835 { "-*-courier-medium-o-*-*-12-*-*-*-*-*-*-*", "9. courier italic" },
836 { "-*-courier-bold-r-*-*-12-*-*-*-*-*-*-*", "10. courier bold" },
837 { "-*-courier-bold-o-*-*-12-*-*-*-*-*-*-*", "11. courier bold italic" },
838 { "-*-symbol-medium-r-*-*-12-*-*-*-*-*-*-*", "12. symbol" },
839 { "-*-times-medium-r-*-*-12-*-*-*-*-*-*-*", "13. times" },
840 { 0, 0}
841};
842
843////////////////////////////////////////////////////////////////////////////////
844/// Create a text font combo box.
845
847 UInt_t options, Pixel_t back) :
848 TGComboBox(p, id, options, back)
849{
850 Int_t noFonts = 0;
851
852 for (Int_t i = 1; gFonts[i][0] != 0 && noFonts < kMaxFonts; i++) {
853
854 fFonts[noFonts] = gVirtualX->LoadQueryFont(gFonts[i][0]);
855
856 if (fFonts[noFonts] == 0)
858
859 GCValues_t gval;
860 gval.fMask = kGCFont;
861 gval.fFont = gVirtualX->GetFontHandle(fFonts[noFonts]);
862
863 AddEntry(new TGTextLBEntry(GetListBox()->GetContainer(),
864 new TGString(gFonts[i][1]), i,
865 fClient->GetGC(&gval, kTRUE)->GetGC(), fFonts[noFonts]),
867 noFonts++;
868 }
869
870 if (noFonts < kMaxFonts - 1)
871 fFonts[noFonts] = 0;
872
873 Select(1, kFALSE); // to have first entry selected
875}
876
877////////////////////////////////////////////////////////////////////////////////
878/// Text font combo box dtor.
879
881{
882 for (int i = 0; i < kMaxFonts && fFonts[i] != 0; i++) {
883 if (fFonts[i] != TGTextLBEntry::GetDefaultFontStruct()) gVirtualX->DeleteFont(fFonts[i]);
884 }
885}
@ kButtonPress
Definition GuiTypes.h:60
const Mask_t kWABorderPixel
Definition GuiTypes.h:142
const Mask_t kWAOverrideRedirect
Definition GuiTypes.h:149
ULong_t Handle_t
Generic resource handle.
Definition GuiTypes.h:26
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kWASaveUnder
Definition GuiTypes.h:150
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Mask_t kGCFont
Definition GuiTypes.h:300
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
@ kChildFrame
Definition GuiTypes.h:379
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kDoubleBorder
Definition GuiTypes.h:385
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
const Handle_t kNone
Definition GuiTypes.h:88
@ kDefaultScrollBarWidth
Definition GuiTypes.h:86
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:166
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton1
Definition GuiTypes.h:214
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kWABorderWidth
Definition GuiTypes.h:143
EKeySym
Definition KeySymbols.h:25
@ kKey_Down
Definition KeySymbols.h:43
@ kKey_Space
Definition KeySymbols.h:93
@ kKey_Up
Definition KeySymbols.h:41
@ kKey_Return
Definition KeySymbols.h:30
@ kKey_Escape
Definition KeySymbols.h:26
@ kKey_Enter
Definition KeySymbols.h:31
#define SafeDelete(p)
Definition RConfig.hxx:547
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
const Bool_t kFALSE
Definition RtypesCore.h:92
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:187
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:166
static const char * gFonts[][2]
const Int_t kMaxFonts
Definition TGComboBox.h:205
@ kLHintsRight
Definition TGLayout.h:33
@ kLHintsExpandY
Definition TGLayout.h:38
@ kLHintsLeft
Definition TGLayout.h:31
@ kLHintsTop
Definition TGLayout.h:34
@ kLHintsExpandX
Definition TGLayout.h:37
@ kWidgetIsEnabled
Definition TGWidget.h:47
XFontStruct * id
Definition TGX11.cxx:109
#define gVirtualX
Definition TVirtualX.h:338
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Int_t GET_MSG(Long_t val)
@ kCM_COMBOBOX
@ kCT_ITEMCLICK
@ kC_COMMAND
@ kCM_LISTBOX
@ kC_CONTAINER
Int_t GET_SUBMSG(Long_t val)
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
Bool_t IsEditable() const
Definition TGClient.h:98
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
Definition TGClient.cxx:532
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition TGClient.cxx:736
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition TGClient.cxx:319
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:133
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:288
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:371
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:307
void KeyPressed(TGFrame *, UInt_t, UInt_t)
Slot handling the key press events.
TGLBEntry * fSelected
Definition TGComboBox.h:45
virtual Bool_t HandleButton(Event_t *)
Handle mouse button event in combo box popup.
void EndPopup()
Ungrab pointer and unmap popup window.
TGComboBoxPopup(const TGComboBoxPopup &)=delete
void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h)
Popup combo box popup window at the specified place.
void SetListBox(TGListBox *lb)
Definition TGComboBox.h:59
TGListBox * fListBox
Definition TGComboBox.h:44
virtual Int_t GetSelected() const
Definition TGComboBox.h:134
TGLBEntry * fSelEntry
Definition TGComboBox.h:74
virtual Bool_t HandleSelectionRequest(Event_t *event)
Handle selection request in text entry.
TGComboBox(const TGComboBox &)=delete
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button events in the combo box.
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:106
virtual void Changed()
Definition TGComboBox.h:146
TGListBox * fListBox
Definition TGComboBox.h:78
virtual void RemoveAll()
Remove all entries from combo box.
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(...
virtual Bool_t HandleSelection(Event_t *event)
Handle selection in text entry.
virtual void RemoveEntry(Int_t id=-1)
Remove entry. If id == -1, the currently selected entry is removed.
virtual TGListBox * GetListBox() const
Definition TGComboBox.h:130
virtual ~TGComboBox()
Delete a combo box widget.
TGTextEntry * fTextEntry
Definition TGComboBox.h:75
virtual Bool_t HandleMotion(Event_t *event)
Handle pointer motion in text entry.
TGScrollBarElement * fDDButton
Definition TGComboBox.h:76
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...
TGLayoutHints * fLhs
Definition TGComboBox.h:80
TGLayoutHints * fLhdd
Definition TGComboBox.h:82
virtual void ReturnPressed()
Add new entry to combo box when return key pressed inside text entry ReturnPressed signal is emitted.
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click in text entry.
virtual void DrawBorder()
Draw border of combo box widget.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a combo box widget as a C++ statement(s) on output stream out.
virtual void SetEnabled(Bool_t on=kTRUE)
Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
virtual void Selected(Int_t widgetId, Int_t id)
Emit signal, done only when selected entry changed.
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
virtual void EnableTextInput(Bool_t on)
Switch text input or readonly mode of combobox (not perfect yet).
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...
virtual void Layout()
layout combobox
virtual Int_t GetNumberOfEntries() const
Definition TGComboBox.h:127
virtual void Init()
Initiate the internal classes of a combo box.
TGComboBoxPopup * fComboFrame
Definition TGComboBox.h:77
const TGPicture * fBpic
Definition TGComboBox.h:79
TGLayoutHints * fLhb
Definition TGComboBox.h:81
virtual TList * GetList() const
Definition TGFrame.h:346
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual TGLayoutManager * GetLayoutManager() const
Definition TGFrame.h:374
virtual void Layout()
Layout the elements of the composite frame.
Definition TGFrame.cxx:1242
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:352
virtual Int_t MustCleanup() const
Definition TGFrame.h:397
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1149
TList * fList
Definition TGFrame.h:328
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:350
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1007
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1134
virtual ~TGFontTypeComboBox()
Text font combo box dtor.
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.
FontStruct_t fFonts[kMaxFonts]
Definition TGComboBox.h:210
TGFrame * fFrame
Definition TGLayout.h:119
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:306
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:324
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:720
UInt_t fOptions
Definition TGFrame.h:118
virtual void MapRaised()
map raised
Definition TGFrame.h:229
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:694
UInt_t fHeight
Definition TGFrame.h:112
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:406
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:740
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:297
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition TGFrame.cxx:630
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:668
virtual UInt_t GetOptions() const
Definition TGFrame.h:221
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2465
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:750
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
UInt_t fWidth
Definition TGFrame.h:111
UInt_t GetHeight() const
Definition TGFrame.h:249
virtual Pixel_t GetBackground() const
Definition TGFrame.h:216
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:614
UInt_t GetWidth() const
Definition TGFrame.h:248
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition TGFrame.cxx:2438
Pixel_t fBackground
Definition TGFrame.h:119
static Pixel_t fgBlackPixel
Definition TGFrame.h:128
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:760
virtual void UnmapWindow()
unmap window
Definition TGFrame.h:230
GContext_t GetGC() const
Definition TGGC.h:50
virtual void SetBackgroundColor(Pixel_t col)
Set background color (override from TGWindow base class).
Definition TGListBox.h:69
virtual void Update(TGLBEntry *)
Definition TGListBox.h:66
Int_t EntryId() const
Definition TGListBox.h:67
virtual void Layout()=0
TGLineStyleComboBox(const TGWindow *p=nullptr, Int_t id=-1, UInt_t options=kHorizontalFrame|kSunkenFrame|kDoubleBorder, Pixel_t back=GetWhitePixel())
Create a line style combo box.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a line style combo box widget as a C++ statement(s).
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.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a line width combo box widget as a C++ statement(s).
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
virtual TGLBEntry * Select(Int_t id, Bool_t sel=kTRUE)
Definition TGListBox.h:351
virtual Int_t GetNumberOfEntries() const
Definition TGListBox.h:330
virtual TGLBEntry * GetSelectedEntry() const
Definition TGListBox.h:355
virtual void RemoveEntry(Int_t id=-1)
remove entry with id.
virtual void RemoveAll()
Remove all entries.
virtual TGScrollBar * GetScrollBar() const
Definition TGListBox.h:336
UInt_t GetItemVsize() const
Definition TGListBox.h:357
virtual TGFrame * GetContainer() const
Definition TGListBox.h:334
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
TGClient * fClient
Definition TGObject.h:37
Handle_t GetId() const
Definition TGObject.h:47
Handle_t fId
Definition TGObject.h:36
Cursor_t GetGrabCursor() const
virtual Bool_t IsEnabled() const
Definition TGScrollBar.h:73
virtual void SetEnabled(Bool_t on=kTRUE)
Enable/Disable scroll bar button chaging the state.
virtual void SetState(Int_t state)
Change state of scrollbar element (either up or down).
void GrabPointer(Bool_t grab)
virtual void SetDragging(Bool_t drag)
const char * GetString() const
Definition TGString.h:40
virtual Bool_t HandleSelectionRequest(Event_t *event)
Handle request to send current clipboard contents to requestor window.
const char * GetText() const
virtual void SetTitle(const char *label)
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in the text entry widget.
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...
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 Bool_t HandleSelection(Event_t *event)
Handle text selection event.
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle mouse double click event in the text entry widget.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in text entry widget.
const TGString * GetText() const
Definition TGListBox.h:114
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use for a text listbox entry.
Int_t fWidgetId
Definition TGWidget.h:56
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:82
Int_t ClearFlags(Int_t flags)
Definition TGWidget.h:69
Int_t SetFlags(Int_t flags)
Definition TGWidget.h:68
const TGWindow * fMsgWindow
Definition TGWidget.h:58
virtual void SetWindowName(const char *name=0)
Set window name.
Definition TGWindow.cxx:128
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:335
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:231
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition TGWindow.h:114
const TGWindow * fParent
Definition TGWindow.h:36
@ kEditDisableHeight
Definition TGWindow.h:63
@ kEditDisableLayout
Definition TGWindow.h:61
@ kEditDisableBtnEnable
Definition TGWindow.h:65
@ kEditDisableGrab
Definition TGWindow.h:60
@ kEditDisable
Definition TGWindow.h:58
@ kEditDisableEvents
Definition TGWindow.h:59
virtual void DestroyWindow()
destroy window
Definition TGWindow.cxx:191
const TGWindow * GetParent() const
Definition TGWindow.h:84
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:294
UInt_t fEditDisabled
Definition TGWindow.h:40
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:659
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:445
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
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
Basic string class.
Definition TString.h:136
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:2331
TText * text
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Long_t fUser[5]
5 longs can be used by client message events NOTE: only [0], [1] and [2] may be used.
Definition GuiTypes.h:187
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Graphics context structure.
Definition GuiTypes.h:224
Mask_t fMask
bit mask specifying which fields are valid
Definition GuiTypes.h:251
FontH_t fFont
default text font for text operations
Definition GuiTypes.h:242
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:93
UInt_t fBorderWidth
border width in pixels
Definition GuiTypes.h:98
Bool_t fOverrideRedirect
boolean value for override-redirect
Definition GuiTypes.h:107
Mask_t fMask
bit mask specifying which fields are valid
Definition GuiTypes.h:110
ULong_t fBorderPixel
border pixel value
Definition GuiTypes.h:97
Bool_t fSaveUnder
should bits under be saved (popups)?
Definition GuiTypes.h:104