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/** \class TGComboBox
25 \ingroup guiwidgets
26
27A combobox (also known as a drop down listbox) allows the selection
28of one item out of a list of items. The selected item is visible in
29a little window. To view the list of possible items one has to click
30on a button on the right of the little window. This will drop down
31a listbox. After selecting an item from the listbox the box will
32disappear and the newly selected item will be shown in the little
33window.
34
35The TGComboBox is user callable.
36
37\class TGComboBoxPopup
38\ingroup guiwidgets
39
40A service class of the combobox.
41
42Selecting an item in the combobox will generate the event:
43 - kC_COMMAND, kCM_COMBOBOX, combobox id, item id.
44
45*/
46
47
48#include "TGComboBox.h"
49#include "TGScrollBar.h"
50#include "TGResourcePool.h"
51#include "TGTextEntry.h"
52#include "KeySymbols.h"
53#include "TVirtualX.h"
54#include "RConfigure.h"
55
56#include <iostream>
57
58
61
65
66////////////////////////////////////////////////////////////////////////////////
67/// Create a combo box popup frame.
68
70 UInt_t options, Pixel_t back) :
71 TGCompositeFrame (p, w, h, options, back), fListBox(0), fSelected(0)
72{
74
78 wattr.fSaveUnder = kTRUE;
80 wattr.fBorderWidth = 1;
81 gVirtualX->ChangeWindowAttributes(fId, &wattr);
82
86}
87
88////////////////////////////////////////////////////////////////////////////////
89/// Handle mouse button event in combo box popup.
90
92{
93 if (event->fType == kButtonPress && event->fCode == kButton1) {
94 if ((fListBox != 0) && (fSelected != 0) &&
96 // in the case the combo box popup is closed by clicking outside the
97 // list box, then select the previously selected entry
99 }
100 EndPopup();
101 }
102 else {
103 // reset the dragging flag of the scrollbar when the button is
104 // released outside the scrollbar itself
106 }
107 return kTRUE;
108}
109
110////////////////////////////////////////////////////////////////////////////////
111/// Ungrab pointer and unmap popup window.
112
114{
115 if (IsMapped()) {
117 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Up),
119 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Down),
121 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Enter),
123 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Return),
125 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Escape),
127 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Space),
129 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
130 UnmapWindow();
131 }
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Popup combo box popup window at the specified place.
136
138{
139 Int_t rx, ry;
140 UInt_t rw, rh;
141
142 // Parent is root window for the popup:
143 gVirtualX->GetWindowSize(fParent->GetId(), rx, ry, rw, rh);
144
145 if (gVirtualX->InheritsFrom("TGWin32")) {
146 if ((x > 0) && ((x + abs(rx) + (Int_t)fWidth) > (Int_t)rw))
147 x = rw - abs(rx) - fWidth;
148 if ((y > 0) && (y + abs(ry) + (Int_t)fHeight > (Int_t)rh))
149 y = rh - fHeight;
150 } else {
151 if (x < 0) x = 0;
152 if (x + fWidth > rw) x = rw - fWidth;
153 if (y < 0) y = 0;
154 if (y + fHeight > rh) y = rh - fHeight;
155 }
156
157 // remember the current selected entry
158 if (fListBox == 0) {
159 // the listbox should be the first in the list
161 fListBox = dynamic_cast<TGListBox *>(el->fFrame);
162 }
164
165 MoveResize(x, y, w, h);
167 Layout();
168 MapRaised();
169
171 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Up),
173 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Down),
175 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Enter),
177 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Return),
179 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Escape),
181 gVirtualX->GrabKey(id, gVirtualX->KeysymToKeycode(kKey_Space),
184
188
189 if (fClient->IsEditable()) {
190 fClient->RegisterPopup(this);
191 }
192
193 fClient->WaitForUnmap(this);
194 EndPopup();
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Slot handling the key press events.
199
201{
202 switch ((EKeySym)keysym) {
203 case kKey_Enter:
204 case kKey_Return:
205 case kKey_Space:
206 if (fListBox && f) {
207 TGLBEntry *entry = dynamic_cast<TGLBEntry *>(f);
208 if (entry) {
209 fListBox->Select(entry->EntryId());
211 entry->EntryId(), 0);
212 }
213 }
214 EndPopup();
215 break;
216 case kKey_Escape:
217 if (fListBox)
218 ((TGContainer *)fListBox->GetContainer())->UnSelectAll();
219 EndPopup();
220 break;
221 default:
222 break;
223 }
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Create a combo box widget.
228
230 Pixel_t back) :
231 TGCompositeFrame (p, 10, 10, options | kOwnBackground, back)
232{
233 fWidgetId = id;
234 fMsgWindow = p;
235 fTextEntry = 0;
236
237 fSelEntry = new TGTextLBEntry(this, new TGString(""), 0);
239
242 Init();
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Create an editable combo box widget.
247
249 UInt_t options, Pixel_t back) :
250 TGCompositeFrame (p, 10, 10, options | kOwnBackground, back)
251{
252 fWidgetId = id;
253 fMsgWindow = p;
254 fSelEntry = nullptr;
255
256 fTextEntry = new TGTextEntry(this, text, id);
258 fTextEntry->Connect("ReturnPressed()", "TGComboBox", this, "ReturnPressed()");
259
262 Init();
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Delete a combo box widget.
267
269{
271
272 if (!MustCleanup()) {
278 }
279
282 if (fComboFrame) {
283 fComboFrame->EndPopup(); // force popdown in case of Qt interface
285 }
286}
287
288////////////////////////////////////////////////////////////////////////////////
289/// Initiate the internal classes of a combo box.
290
292{
293 fBpic = fClient->GetPicture("arrow_down.xpm");
294
295 if (!fBpic)
296 Error("TGComboBox", "arrow_down.xpm not found");
297
300
303
305
307
308 fListBox->Resize(100, 100);
309 fListBox->Associate(this);
310 fListBox->GetScrollBar()->GrabPointer(kFALSE); // combobox will do a pointergrab
311
317
320
321 fListBox->GetContainer()->Connect("KeyPressed(TGFrame*, UInt_t, UInt_t)",
322 "TGComboBoxPopup", fComboFrame,
323 "KeyPressed(TGFrame*, UInt_t, UInt_t)");
324 // Drop down listbox of combo box should react to pointer motion
325 // so it will be able to Activate() (i.e. highlight) the different
326 // items when the mouse crosses.
329
336
338}
339
340////////////////////////////////////////////////////////////////////////////////
341/// Draw border of combo box widget.
342
344{
347 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
348 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
349 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, fWidth-3, 1);
350 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, 1, fHeight-3);
351 if (gClient->GetStyle() > 1) break;
352 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
353 gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
354 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
355 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, 1, fWidth-2, fHeight-2);
356 break;
357
358 default:
360 break;
361 }
362}
363
364////////////////////////////////////////////////////////////////////////////////
365/// Switch text input or readonly mode of combobox (not perfect yet).
366
368{
369 // UInt_t w, h;
370 TString text = "";
371 Pixel_t back = TGFrame::GetWhitePixel(); // default
372
373 if (on) {
374 if (fSelEntry) {
375 back = fSelEntry->GetBackground();
376 text = ((TGTextLBEntry*)fSelEntry)->GetText()->GetString();
378 fTextEntry->SetText(text.Data());
379 }
381 //w = fSelEntry->GetWidth();
382 //h = fSelEntry->GetHeight();
384 delete fSelEntry;
385 fSelEntry = 0;
386 }
387 if (!fTextEntry) {
388 fTextEntry = new TGTextEntry(this, text.Data(), 0);
390 fTextEntry->Connect("ReturnPressed()", "TGComboBox", this, "ReturnPressed()");
393 }
396 // coverity[returned_null]
397 // coverity[dereference]
399 } else {
400 if (fTextEntry) {
401 back = fTextEntry->GetBackground();
405 //w = fTextEntry->GetWidth();
406 //h = fTextEntry->GetHeight();
407 delete fTextEntry;
408 fTextEntry = 0;
409 }
410 if (!fSelEntry) {
411 fSelEntry = new TGTextLBEntry(this, new TGString(text.Data()), 0);
415 }
418 // coverity[returned_null]
419 // coverity[dereference]
421 }
422}
423
424////////////////////////////////////////////////////////////////////////////////
425/// Find entry by name.
426
427TGLBEntry *TGComboBox::FindEntry(const char *s) const
428{
429 TGLBEntry *sel = 0;
430 sel = fListBox->FindEntry(s);
431 return sel;
432}
433
434////////////////////////////////////////////////////////////////////////////////
435/// Set a new combo box value (normally update of text string in
436/// fSelEntry is done via fSelEntry::Update()).
437
439{
440 if (!fSelEntry) return;
441
444 delete fSelEntry;
445 delete fLhs;
446 fSelEntry = e;
447 fLhs = lh;
449 Layout();
450}
451
452////////////////////////////////////////////////////////////////////////////////
453/// Make the selected item visible in the combo box window
454/// and emit signals according to the second parameter.
455
457{
458 if (id!=GetSelected()) {
459 TGLBEntry *e;
460 e = fListBox->Select(id);
461 if (e) {
462 if (fSelEntry) {
464 Layout();
465 } else if (fTextEntry && e->InheritsFrom(TGTextLBEntry::Class())) {
468 }
469 if (emit) {
470 Selected(fWidgetId, id);
471 Selected(id);
472 Changed();
473 }
474 }
475 }
476}
477
478////////////////////////////////////////////////////////////////////////////////
479/// Handle mouse button events in the combo box.
480
482{
483 if (!fDDButton || !fDDButton->IsEnabled()) return kFALSE;
484
485 if (event->fType == kButtonPress) {
486 Window_t child = (Window_t)event->fUser[0]; // fUser[0] = child window
487
488 if (child == fDDButton->GetId() || (fSelEntry && child == fSelEntry->GetId())) {
490
491 if (fTextEntry && (child == fTextEntry->GetId())) {
492 return fTextEntry->HandleButton(event);
493 }
494 int ax, ay;
495 Window_t wdummy;
496 gVirtualX->TranslateCoordinates(fId, fComboFrame->GetParent()->GetId(),
497 0, fHeight, ax, ay, wdummy);
498 // Drop down listbox of combo box should react to pointer motion...
500#ifdef R__HAS_COCOA
501 gVirtualX->SetWMTransientHint(fComboFrame->GetId(), GetId());
502#endif
505#ifdef R__HAS_COCOA
506 //tp: I need this modification - "button" is not repainted correctly
507 //with Cocoa, when combobox is closed (reason is quite complex), happens
508 //when item is wider than combobox.
509 //TODO: find another way :)
511#endif
512 } else if (fTextEntry) {
513 return fTextEntry->HandleButton(event);
514 }
515 }
516 return kTRUE;
517}
518
519////////////////////////////////////////////////////////////////////////////////
520/// Remove entry. If id == -1, the currently selected entry is removed
521
523{
525
526 if (id < 0) {
527 if (fSelEntry) {
528 ((TGTextLBEntry*)fSelEntry)->SetTitle("");
530 } else {
531 fTextEntry->SetTitle("");
533 }
534 }
535 Resize();
536}
537
538////////////////////////////////////////////////////////////////////////////////
539/// layout combobox
540
542{
545
546 if (h && (h < 100)) {
548 }
549}
550
551////////////////////////////////////////////////////////////////////////////////
552/// Handle double click in text entry.
553
555{
556 return fTextEntry ? fTextEntry->HandleDoubleClick(event) : kTRUE;
557}
558
559////////////////////////////////////////////////////////////////////////////////
560/// Handle pointer motion in text entry.
561
563{
564 return fTextEntry ? fTextEntry->HandleMotion(event) : kTRUE;
565}
566
567////////////////////////////////////////////////////////////////////////////////
568/// Handle selection in text entry.
569
571{
572 return fTextEntry ? fTextEntry->HandleSelection(event) : kTRUE;
573}
574
575////////////////////////////////////////////////////////////////////////////////
576/// Handle selection request in text entry.
577
579{
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Process messages generated by the listbox and forward
585/// messages to the combobox message handling window. Parm2 contains
586/// the id of the selected listbox entry.
587
589{
590 TGLBEntry *e;
591
592 switch (GET_MSG(msg)) {
593 case kC_COMMAND:
594 switch (GET_SUBMSG(msg)) {
595 case kCM_LISTBOX:
597 if (fSelEntry) {
599 } else if (fTextEntry &&
603 }
604 // coverity[returned_null]
605 // coverity[dereference]
610 fWidgetId, parm2);
611 if (e->InheritsFrom(TGTextLBEntry::Class())) {
612 const char *text;
613 text = ((TGTextLBEntry*)e)->GetText()->GetString();
614 Selected(text);
615 }
616 Selected(fWidgetId, (Int_t)parm2);
617 Selected((Int_t)parm2);
618 Changed();
619 fClient->NeedRedraw(this);
620 break;
621 }
622 break;
623
624 default:
625 break;
626 }
627 return kTRUE;
628}
629
630////////////////////////////////////////////////////////////////////////////////
631/// Emit signal, done only when selected entry changed.
632
634{
635 Longptr_t args[2];
636
637 args[0] = widgetId;
638 args[1] = id;
639
640 Emit("Selected(Int_t,Int_t)", args);
641}
642
643////////////////////////////////////////////////////////////////////////////////
644/// Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
645
647{
649 if (on) {
652 } else {
655 }
657}
658
659////////////////////////////////////////////////////////////////////////////////
660/// Add new entry to combo box when return key pressed inside text entry
661/// ReturnPressed signal is emitted.
662
664{
665 if (!fTextEntry) return;
666
669
670 TIter next(lbc->GetList());
671 TGFrameElement *el;
672
673 Emit("ReturnPressed()");
674
675 while ((el = (TGFrameElement *)next())) {
676 TGTextLBEntry *lbe = (TGTextLBEntry *)el->fFrame;
677 if (lbe->GetText()->GetString() == text) {
678 return;
679 }
680 }
681
682 Int_t nn = GetNumberOfEntries() + 1;
683 AddEntry(text.Data(), nn);
684 Select(nn);
685}
686
687////////////////////////////////////////////////////////////////////////////////
688/// Remove all entries from combo box.
689
691{
693
694 if (fSelEntry) {
695 ((TGTextLBEntry*)fSelEntry)->SetTitle("");
697 } else {
698 fTextEntry->SetTitle("");
700 }
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Save a combo box widget as a C++ statement(s) on output stream out.
705
706void TGComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
707{
709
710 out << std::endl << " // combo box" << std::endl;
711 out << " TGComboBox *";
712
713 if (!fTextEntry) {
714 out << GetName() << " = new TGComboBox(" << fParent->GetName() << "," << fWidgetId;
715 } else {
716 out << GetName() << " = new TGComboBox(" << fParent->GetName() << ",";
717 out << '\"' << fTextEntry->GetText() << '\"' << "," <<fWidgetId;
718 }
719
720 if (fBackground == GetWhitePixel()) {
722 out <<");" << std::endl;
723 } else {
724 out << "," << GetOptionString() << ");" << std::endl;
725 }
726 } else {
727 out << "," << GetOptionString() << ",ucolor);" << std::endl;
728 }
729 if (option && strstr(option, "keep_names"))
730 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
731
733 TGFrameElement *el;
734 TGListBox *lb = GetListBox();
735
736 TIter next(((TGLBContainer *)lb->GetContainer())->GetList());
737
738 while ((el = (TGFrameElement *) next())) {
739 b = (TGTextLBEntry *) el->fFrame;
740 out << " " << GetName() << "->AddEntry(";
741 b->SavePrimitive(out, option);
742 out << ");" << std::endl;
743 }
744
745 out << " " << GetName() << "->Resize(" << GetWidth() << ","
746 << GetHeight() << ");" << std::endl;
747 out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
748}
749
750////////////////////////////////////////////////////////////////////////////////
751/// Create a line style combo box.
752
754 UInt_t options, Pixel_t back)
755 : TGComboBox(p, id, options, back)
756{
757 SetTopEntry(new TGLineLBEntry(this, 0),
760
761 for (Int_t i = 1; i <= 10; i++)
762 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
763 TString::Format("%d",i), 0, i),
765
766 Select(1, kFALSE); // to have first entry selected
767
769}
770
771////////////////////////////////////////////////////////////////////////////////
772/// Save a line style combo box widget as a C++ statement(s).
773
774void TGLineStyleComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
775{
776 out << std::endl << " // line style combo box" << std::endl;
777 out << " TGLineStyleComboBox *";
778
779 out << GetName() << " = new TGLineStyleComboBox(" << fParent->GetName()
780 << "," << fWidgetId << ");" << std::endl;
781 if (option && strstr(option, "keep_names"))
782 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
783 out << " " << GetName() << "->Resize(" << GetWidth() << ","
784 << GetHeight() << ");" << std::endl;
785 out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
786}
787
788////////////////////////////////////////////////////////////////////////////////
789/// Create a line width combo box.
790/// If "none" is equal to kTRUE the first entry is "None".
791
793 UInt_t options, Pixel_t back, Bool_t none)
794 : TGComboBox(p, id, options, back)
795{
796 SetTopEntry(new TGLineLBEntry(this,0),
799
800 if (none) {
801 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), 0, "None", 0, 0),
803 }
804
805 for (Int_t i = 0; i < 16; i++)
806 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
807 TString::Format("%d",i), i, 0),
809 Select(1, kFALSE); // to have first entry selected
811}
812
813////////////////////////////////////////////////////////////////////////////////
814/// Save a line width combo box widget as a C++ statement(s).
815
816void TGLineWidthComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
817{
818 out << std::endl << " // line width combo box" << std::endl;
819 out << " TGLineWidthComboBox *";
820
821 out << GetName() << " = new TGLineWidthComboBox(" << fParent->GetName()
822 << "," << fWidgetId << ");" << std::endl;
823 if (option && strstr(option, "keep_names"))
824 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
825 out << " " << GetName() << "->Resize(" << GetWidth() << ","
826 << GetHeight() << ");" << std::endl;
827 out << " " << GetName() << "->Select(" << GetSelected() << ");" << std::endl;
828}
829
830static const char *gFonts[][2] = { // unix name, name
831 { "", "" }, //not used
832 { "-*-times-medium-i-*-*-12-*-*-*-*-*-*-*", "1. times italic" },
833 { "-*-times-bold-r-*-*-12-*-*-*-*-*-*-*", "2. times bold" },
834 { "-*-times-bold-i-*-*-12-*-*-*-*-*-*-*", "3. times bold italic" },
835 { "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*", "4. helvetica" },
836 { "-*-helvetica-medium-o-*-*-12-*-*-*-*-*-*-*", "5. helvetica italic" },
837 { "-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*", "6. helvetica bold" },
838 { "-*-helvetica-bold-o-*-*-12-*-*-*-*-*-*-*", "7. helvetica bold italic" },
839 { "-*-courier-medium-r-*-*-12-*-*-*-*-*-*-*", "8. courier" },
840 { "-*-courier-medium-o-*-*-12-*-*-*-*-*-*-*", "9. courier italic" },
841 { "-*-courier-bold-r-*-*-12-*-*-*-*-*-*-*", "10. courier bold" },
842 { "-*-courier-bold-o-*-*-12-*-*-*-*-*-*-*", "11. courier bold italic" },
843 { "-*-symbol-medium-r-*-*-12-*-*-*-*-*-*-*", "12. symbol" },
844 { "-*-times-medium-r-*-*-12-*-*-*-*-*-*-*", "13. times" },
845 { 0, 0}
846};
847
848////////////////////////////////////////////////////////////////////////////////
849/// Create a text font combo box.
850
852 UInt_t options, Pixel_t back) :
853 TGComboBox(p, id, options, back)
854{
855 Int_t noFonts = 0;
856
857 for (Int_t i = 1; gFonts[i][0] != 0 && noFonts < kMaxFonts; i++) {
858
859 fFonts[noFonts] = gVirtualX->LoadQueryFont(gFonts[i][0]);
860
861 if (fFonts[noFonts] == 0)
863
865 gval.fMask = kGCFont;
866 gval.fFont = gVirtualX->GetFontHandle(fFonts[noFonts]);
867
868 AddEntry(new TGTextLBEntry(GetListBox()->GetContainer(),
869 new TGString(gFonts[i][1]), i,
870 fClient->GetGC(&gval, kTRUE)->GetGC(), fFonts[noFonts]),
872 noFonts++;
873 }
874
875 if (noFonts < kMaxFonts - 1)
876 fFonts[noFonts] = 0;
877
878 Select(1, kFALSE); // to have first entry selected
880}
881
882////////////////////////////////////////////////////////////////////////////////
883/// Text font combo box dtor.
884
886{
887 for (int i = 0; i < kMaxFonts && fFonts[i] != 0; i++) {
888 if (fFonts[i] != TGTextLBEntry::GetDefaultFontStruct()) gVirtualX->DeleteFont(fFonts[i]);
889 }
890}
@ kButtonPress
Definition GuiTypes.h:60
const Mask_t kWABorderPixel
Definition GuiTypes.h:142
const Mask_t kWAOverrideRedirect
Definition GuiTypes.h:149
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
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
const Mask_t kWABorderWidth
Definition GuiTypes.h:143
ULongptr_t Handle_t
Generic resource handle.
Definition GuiTypes.h:26
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:533
#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
long Longptr_t
Definition RtypesCore.h:75
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:157
static const char * gFonts[][2]
const Int_t kMaxFonts
Definition TGComboBox.h:176
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
@ kWidgetIsEnabled
Definition TGWidget.h:37
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t gval
Option_t Option_t TPoint TPoint const char text
#define gVirtualX
Definition TVirtualX.h:337
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:234
Bool_t IsEditable() const
Definition TGClient.h:89
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
Definition TGClient.cxx:542
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition TGClient.cxx:746
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition TGClient.cxx:329
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:381
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:317
A service class of the combobox.
Definition TGComboBox.h:21
void KeyPressed(TGFrame *, UInt_t, UInt_t)
Slot handling the key press events.
TGLBEntry * fSelected
Definition TGComboBox.h:25
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.
Bool_t HandleButton(Event_t *) override
Handle mouse button event in combo box popup.
void SetListBox(TGListBox *lb)
Definition TGComboBox.h:39
TGListBox * fListBox
Definition TGComboBox.h:24
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual Int_t GetSelected() const
Definition TGComboBox.h:114
void Layout() override
layout combobox
Bool_t HandleSelection(Event_t *event) override
Handle selection in text entry.
TGLBEntry * fSelEntry
selected item frame
Definition TGComboBox.h:54
TGComboBox(const TGComboBox &)=delete
void RemoveAll() override
Remove all entries from combo box.
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
void DrawBorder() override
Draw border of combo box widget.
virtual void Changed()
Definition TGComboBox.h:126
TGListBox * fListBox
the listbox with text items
Definition TGComboBox.h:58
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a combo box widget as a C++ statement(s) on output stream out.
Bool_t HandleDoubleClick(Event_t *event) override
Handle double click in text entry.
~TGComboBox() override
Delete a combo box widget.
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 void RemoveEntry(Int_t id=-1)
Remove entry. If id == -1, the currently selected entry is removed.
virtual TGListBox * GetListBox() const
Definition TGComboBox.h:110
TGTextEntry * fTextEntry
text entry
Definition TGComboBox.h:55
TGScrollBarElement * fDDButton
button controlling drop down of popup
Definition TGComboBox.h:56
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
layout hints for selected item frame
Definition TGComboBox.h:60
TGLayoutHints * fLhdd
layout hints for fListBox
Definition TGComboBox.h:62
Bool_t HandleSelectionRequest(Event_t *event) override
Handle selection request in text entry.
virtual void ReturnPressed()
Add new entry to combo box when return key pressed inside text entry ReturnPressed signal is emitted.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process messages generated by the listbox and forward messages to the combobox message handling windo...
Bool_t HandleButton(Event_t *event) override
Handle mouse button events in the combo box.
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.
Bool_t HandleMotion(Event_t *event) override
Handle pointer motion in text entry.
virtual void EnableTextInput(Bool_t on)
Switch text input or readonly mode of combobox (not perfect yet).
virtual Int_t GetNumberOfEntries() const
Definition TGComboBox.h:107
virtual void Init()
Initiate the internal classes of a combo box.
TGComboBoxPopup * fComboFrame
popup containing a listbox
Definition TGComboBox.h:57
const TGPicture * fBpic
down arrow picture used in fDDButton
Definition TGComboBox.h:59
TGLayoutHints * fLhb
layout hints for fDDButton
Definition TGComboBox.h:61
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:316
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
virtual TGLayoutManager * GetLayoutManager() const
Definition TGFrame.h:338
Int_t MustCleanup() const override
Definition TGFrame.h:360
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:314
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1257
TList * fList
container of frame elements
Definition TGFrame.h:292
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1149
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1022
Manages a content area.
Definition TGCanvas.h:31
The TGFontTypeComboBox is user callable and it creates a combobox for selecting the font.
Definition TGComboBox.h:178
TGFontTypeComboBox(const TGWindow *p=nullptr, Int_t id=-1, UInt_t options=kHorizontalFrame|kSunkenFrame|kDoubleBorder, Pixel_t bask=GetWhitePixel())
Create a text font combo box.
~TGFontTypeComboBox() override
Text font combo box dtor.
FontStruct_t fFonts[kMaxFonts]
Definition TGComboBox.h:181
TGFrame * fFrame
Definition TGLayout.h:112
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:321
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:339
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:629
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:735
UInt_t fOptions
frame options
Definition TGFrame.h:94
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:709
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:421
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:312
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:755
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
virtual UInt_t GetOptions() const
Definition TGFrame.h:197
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2506
void UnmapWindow() override
unmap window
Definition TGFrame.h:206
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:645
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:765
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:225
virtual Pixel_t GetBackground() const
Definition TGFrame.h:192
UInt_t GetWidth() const
Definition TGFrame.h:224
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition TGFrame.cxx:2479
Pixel_t fBackground
frame background color
Definition TGFrame.h:95
static Pixel_t fgBlackPixel
Definition TGFrame.h:104
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:775
void MapRaised() override
map raised
Definition TGFrame.h:205
GContext_t GetGC() const
Definition TGGC.h:41
A Composite frame that contains a list of TGLBEnties.
Definition TGListBox.h:163
Basic listbox entries.
Definition TGListBox.h:24
virtual void Update(TGLBEntry *)
Definition TGListBox.h:39
Int_t EntryId() const
Definition TGListBox.h:40
void SetBackgroundColor(Pixel_t col) override
Set background color (override from TGWindow base class).
Definition TGListBox.h:42
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
virtual void Layout()=0
Line style and width listbox entries.
Definition TGListBox.h:97
The TGLineStyleComboBox user callable and it creates a combobox for selecting the line style.
Definition TGComboBox.h:140
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.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a line style combo box widget as a C++ statement(s).
The TGLineWidthComboBox user callable and it creates a combobox for selecting the line width.
Definition TGComboBox.h:158
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a line width combo box widget as a C++ statement(s).
TGLineWidthComboBox(const TGWindow *p=nullptr, Int_t id=-1, UInt_t options=kHorizontalFrame|kSunkenFrame|kDoubleBorder, Pixel_t back=GetWhitePixel(), Bool_t none=kFALSE)
Create a line width combo box.
A listbox is a box, possibly with scrollbar, containing entries.
Definition TGListBox.h:221
virtual TGLBEntry * Select(Int_t id, Bool_t sel=kTRUE)
Definition TGListBox.h:284
virtual Int_t GetNumberOfEntries() const
Definition TGListBox.h:263
virtual TGLBEntry * GetSelectedEntry() const
Definition TGListBox.h:288
virtual void RemoveEntry(Int_t id=-1)
remove entry with id.
void Resize(UInt_t w, UInt_t h) override
Resize the listbox widget.
virtual TGScrollBar * GetScrollBar() const
Definition TGListBox.h:269
UInt_t GetItemVsize() const
Definition TGListBox.h:290
virtual TGFrame * GetContainer() const
Definition TGListBox.h:267
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
void RemoveAll() override
Remove all entries.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
Cursor_t GetGrabCursor() const
virtual Bool_t IsEnabled() const
Definition TGScrollBar.h:54
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)
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
const char * GetString() const
Definition TGString.h:30
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
Bool_t HandleSelectionRequest(Event_t *event) override
Handle request to send current clipboard contents to requestor window.
const char * GetText() const
Bool_t HandleSelection(Event_t *event) override
Handle text selection event.
Bool_t HandleDoubleClick(Event_t *event) override
Handle mouse double click event in the text entry widget.
virtual void SetTitle(const char *label)
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.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in the text entry widget.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in text entry widget.
Text string listbox entries.
Definition TGListBox.h:48
const TGString * GetText() const
Definition TGListBox.h:79
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use for a text listbox entry.
static TClass * Class()
Int_t fWidgetId
the widget id (used for event processing)
Definition TGWidget.h:46
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
Int_t ClearFlags(Int_t flags)
Definition TGWidget.h:59
Int_t SetFlags(Int_t flags)
Definition TGWidget.h:58
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:232
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition TGWindow.h:113
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
@ kEditDisableHeight
window height cannot be edited
Definition TGWindow.h:62
@ kEditDisableLayout
window layout cannot be edited
Definition TGWindow.h:60
@ kEditDisableBtnEnable
window can handle mouse button events
Definition TGWindow.h:64
@ kEditDisableGrab
window grab cannot be edited
Definition TGWindow.h:59
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
@ kEditDisableEvents
window events cannot be edited
Definition TGWindow.h:58
virtual void DestroyWindow()
destroy window
Definition TGWindow.cxx:192
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:129
const TGWindow * GetParent() const
Definition TGWindow.h:83
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:295
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:657
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:542
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:869
Basic string class.
Definition TString.h:139
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:2378
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
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Longptr_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
Graphics context structure.
Definition GuiTypes.h:224
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