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
59
60
61////////////////////////////////////////////////////////////////////////////////
62/// Create a combo box popup frame.
63
65 UInt_t options, Pixel_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
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
100 fListBox->GetScrollBar()->SetDragging(kFALSE);
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);
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),
178 fListBox->GetContainer()->RequestFocus();
179
182 fClient->GetResourcePool()->GetGrabCursor());
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 Pixel_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
244 UInt_t options, Pixel_t back) :
245 TGCompositeFrame (p, 10, 10, options | kOwnBackground, back)
246{
247 fWidgetId = id;
248 fMsgWindow = p;
249 fSelEntry = nullptr;
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
326 fListBox->GetContainer()->SetEditDisabled(kEditDisable);
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();
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]
393 GetLayoutManager()->Layout();
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]
415 GetLayoutManager()->Layout();
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())) {
462 fTextEntry->SetText(te->GetText()->GetString());
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;
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
553
554////////////////////////////////////////////////////////////////////////////////
555/// Handle pointer motion in text entry.
556
561
562////////////////////////////////////////////////////////////////////////////////
563/// Handle selection in text entry.
564
569
570////////////////////////////////////////////////////////////////////////////////
571/// Handle selection request in text entry.
572
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 &&
597 fTextEntry->SetText(te->GetText()->GetString());
598 }
599 // coverity[returned_null]
600 // coverity[dereference]
601 GetLayoutManager()->Layout();
606 if (e->InheritsFrom(TGTextLBEntry::Class())) {
607 const char *text;
608 text = ((TGTextLBEntry*)e)->GetText()->GetString();
609 Selected(text);
610 }
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 Longptr_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
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());
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
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{
703 // save options and custom color if not default
705
706 out << "\n // combo box\n";
707
708 out << " TGComboBox *" << GetName() << " = new TGComboBox(" << fParent->GetName();
709 if (fTextEntry)
710 out << ", \"" << TString(fTextEntry->GetText()).ReplaceSpecialCppChars() << "\"";
711 out << ", " << fWidgetId << extra_args << ");\n";
712
713 if (option && strstr(option, "keep_names"))
714 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
715
717
718 TIter next(((TGLBContainer *)lb->GetContainer())->GetList());
719
720 while (auto el = (TGFrameElement *)next()) {
721 auto b = (TGTextLBEntry *)el->fFrame;
722 out << " " << GetName() << "->AddEntry(";
723 b->SavePrimitive(out, option);
724 out << ");" << std::endl;
725 }
726
727 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetHeight() << ");\n";
728 out << " " << GetName() << "->Select(" << GetSelected() << ");\n";
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Create a line style combo box.
733
735 UInt_t options, Pixel_t back)
736 : TGComboBox(p, id, options, back)
737{
738 SetTopEntry(new TGLineLBEntry(this, 0),
741
742 for (Int_t i = 1; i <= 10; i++)
743 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
744 TString::Format("%d",i), 0, i),
746
747 Select(1, kFALSE); // to have first entry selected
748
750}
751
752////////////////////////////////////////////////////////////////////////////////
753/// Save a line style combo box widget as a C++ statement(s).
754
755void TGLineStyleComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
756{
757 out << "\n // line style combo box\n";
758 out << " TGLineStyleComboBox *" << GetName() << " = new TGLineStyleComboBox(" << fParent->GetName() << ","
759 << fWidgetId << ");\n";
760 if (option && strstr(option, "keep_names"))
761 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
762 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetHeight() << ");\n";
763 out << " " << GetName() << "->Select(" << GetSelected() << ");\n";
764}
765
766////////////////////////////////////////////////////////////////////////////////
767/// Create a line width combo box.
768/// If "none" is equal to kTRUE the first entry is "None".
769
771 UInt_t options, Pixel_t back, Bool_t none)
772 : TGComboBox(p, id, options, back)
773{
774 SetTopEntry(new TGLineLBEntry(this,0),
777
778 if (none) {
779 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), 0, "None", 0, 0),
781 }
782
783 for (Int_t i = 0; i < 16; i++)
784 AddEntry(new TGLineLBEntry(GetListBox()->GetContainer(), i,
785 TString::Format("%d",i), i, 0),
787 Select(1, kFALSE); // to have first entry selected
789}
790
791////////////////////////////////////////////////////////////////////////////////
792/// Save a line width combo box widget as a C++ statement(s).
793
794void TGLineWidthComboBox::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
795{
796 out << "\n // line width combo box\n";
797 out << " TGLineWidthComboBox *" << GetName() << " = new TGLineWidthComboBox(" << fParent->GetName() << ","
798 << fWidgetId << ");\n";
799 if (option && strstr(option, "keep_names"))
800 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
801 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetHeight() << ");\n";
802 out << " " << GetName() << "->Select(" << GetSelected() << ");\n";
803}
804
805static const char *gFonts[][2] = { // unix name, name
806 { "", "" }, //not used
807 { "-*-times-medium-i-*-*-12-*-*-*-*-*-*-*", "1. times italic" },
808 { "-*-times-bold-r-*-*-12-*-*-*-*-*-*-*", "2. times bold" },
809 { "-*-times-bold-i-*-*-12-*-*-*-*-*-*-*", "3. times bold italic" },
810 { "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*", "4. helvetica" },
811 { "-*-helvetica-medium-o-*-*-12-*-*-*-*-*-*-*", "5. helvetica italic" },
812 { "-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*", "6. helvetica bold" },
813 { "-*-helvetica-bold-o-*-*-12-*-*-*-*-*-*-*", "7. helvetica bold italic" },
814 { "-*-courier-medium-r-*-*-12-*-*-*-*-*-*-*", "8. courier" },
815 { "-*-courier-medium-o-*-*-12-*-*-*-*-*-*-*", "9. courier italic" },
816 { "-*-courier-bold-r-*-*-12-*-*-*-*-*-*-*", "10. courier bold" },
817 { "-*-courier-bold-o-*-*-12-*-*-*-*-*-*-*", "11. courier bold italic" },
818 { "-*-symbol-medium-r-*-*-12-*-*-*-*-*-*-*", "12. symbol" },
819 { "-*-times-medium-r-*-*-12-*-*-*-*-*-*-*", "13. times" },
820 { nullptr, nullptr }
821};
822
823////////////////////////////////////////////////////////////////////////////////
824/// Create a text font combo box.
825
827 UInt_t options, Pixel_t back) :
828 TGComboBox(p, id, options, back)
829{
830 Int_t noFonts = 0;
831
832 for (Int_t i = 1; gFonts[i][0] != 0 && noFonts < kMaxFonts; i++) {
833
834 fFonts[noFonts] = gVirtualX->LoadQueryFont(gFonts[i][0]);
835
836 if (fFonts[noFonts] == 0)
838
840 gval.fMask = kGCFont;
841 gval.fFont = gVirtualX->GetFontHandle(fFonts[noFonts]);
842
843 AddEntry(new TGTextLBEntry(GetListBox()->GetContainer(),
844 new TGString(gFonts[i][1]), i,
847 noFonts++;
848 }
849
850 if (noFonts < kMaxFonts - 1)
851 fFonts[noFonts] = 0;
852
853 Select(1, kFALSE); // to have first entry selected
855}
856
857////////////////////////////////////////////////////////////////////////////////
858/// Text font combo box dtor.
859
861{
862 for (int i = 0; i < kMaxFonts && fFonts[i] != 0; i++) {
863 if (fFonts[i] != TGTextLBEntry::GetDefaultFontStruct()) gVirtualX->DeleteFont(fFonts[i]);
864 }
865}
@ 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
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
@ 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:233
Bool_t IsEditable() const
Definition TGClient.h:89
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
Definition TGClient.cxx:541
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition TGClient.cxx:745
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition TGClient.cxx:328
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
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:380
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:316
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:289
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TGLayoutManager * GetLayoutManager() const
Definition TGFrame.h:340
Int_t MustCleanup() const override
Definition TGFrame.h:362
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:316
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1249
TList * fList
container of frame elements
Definition TGFrame.h:294
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1141
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1014
Manages a content area.
Definition TGCanvas.h:31
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
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:313
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:331
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:621
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:727
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:597
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:701
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:413
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:304
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:747
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:675
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
void UnmapWindow() override
unmap window
Definition TGFrame.h:208
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:637
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:757
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:227
TString SaveCtorArgs(std::ostream &out, UInt_t dflt_options=kChildFrame, Bool_t check_white_pixel=kFALSE)
Return options and custom color as constructor args Used in the SavePrimitive methods,...
Definition TGFrame.cxx:2493
virtual Pixel_t GetBackground() const
Definition TGFrame.h:194
UInt_t GetWidth() const
Definition TGFrame.h:226
static Pixel_t fgBlackPixel
Definition TGFrame.h:104
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:767
void MapRaised() override
map raised
Definition TGFrame.h:207
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
Line style and width listbox entries.
Definition TGListBox.h:97
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).
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
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).
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
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
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 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:190
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:127
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:293
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
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:656
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
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:865
Basic string class.
Definition TString.h:138
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1121
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:2384
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