Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGButton.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id: ee86415852b0e43b57190b9645717cf508b7920e $
2// Author: Fons Rademakers 06/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 TGButton
25 \ingroup guiwidgets
26
27A button abstract base class. It defines general button behaviour.
28
29*/
30
31
32/** \class TGTextButton
33 \ingroup guiwidgets
34
35Yield an action as soon as it is clicked. This buttons usually provides fast access to
36frequently used or critical commands. It may appear alone or placed in a group.
37
38The action it performs can be inscribed with a meaningful tooltip
39set by `SetToolTipText(const char* text, Long_t delayms=400).
40
41The text button has a label indicating the action to be taken when
42the button is pressed. The text can be a hot string ("&Exit") that
43defines the label "Exit" and keyboard mnemonics Alt+E for button
44selection. A button label can be changed by SetText(new_label).
45
46Selecting a text or picture button will generate the event:
47 - kC_COMMAND, kCM_BUTTON, button id, user data.
48*/
49
50
51/** \class TGPictureButton
52 \ingroup guiwidgets
53
54Yield an action as soon as it is clicked. This buttons usually provides fast access to
55frequently used or critical commands. It may appear alone or placed in a group.
56
57The action it performs can be inscribed with a meaningful tooltip
58set by `SetToolTipText(const char* text, Long_t delayms=400).
59
60The text button has a label indicating the action to be taken when
61the button is pressed. The text can be a hot string ("&Exit") that
62defines the label "Exit" and keyboard mnemonics Alt+E for button
63selection. A button label can be changed by SetText(new_label).
64
65Selecting a text or picture button will generate the event:
66 - kC_COMMAND, kCM_BUTTON, button id, user data.
67*/
68
69
70/** \class TGCheckButton
71 \ingroup guiwidgets
72
73Selects different options. Like text buttons, they have text or hot string as a label.
74
75Selecting a check button will generate the event:
76 - kC_COMMAND, kCM_CHECKBUTTON, button id, user data.
77
78If a command string has been specified (via SetCommand()) then this
79command string will be executed via the interpreter whenever a
80button is selected. A command string can contain the macros:
81
82 - $MSG -- kC_COMMAND, kCMCHECKBUTTON packed message
83 (use GET_MSG() and GET_SUBMSG() to unpack)
84 - $PARM1 -- button id
85 - $PARM2 -- user data pointer
86
87Before executing these macros are expanded into the respective Long_t's
88*/
89
90
91/** \class TGRadioButton
92 \ingroup guiwidgets
93
94Selects different options. Like text buttons, they have text or hot string as a label.
95
96Radio buttons are grouped usually in logical sets of two or more
97buttons to present mutually exclusive choices.
98
99Selecting a radio button will generate the event:
100 - kC_COMMAND, kCM_RADIOBUTTON, button id, user data.
101
102If a command string has been specified (via SetCommand()) then this
103command string will be executed via the interpreter whenever a
104button is selected. A command string can contain the macros:
105
106 - $MSG -- kC_COMMAND, kCMRADIOBUTTON packed message
107 (use GET_MSG() and GET_SUBMSG() to unpack)
108 - $PARM1 -- button id
109 - $PARM2 -- user data pointer
110
111Before executing these macros are expanded into the respective Long_t's
112*/
113
114
115/** \class TGSplitButton
116 \ingroup guiwidgets
117
118Implements a button with added menu functionality.
119There are 2 modes of operation available.
120
121If the button is split, a menu will popup when the menu area of the
122button is clicked. Activating a menu item changes the functionality
123of the button by having it emit a additional signal when it is
124clicked. The signal emitted when the button is clicked, is the
125ItemClicked(Int_t) signal with a different fixed value for the
126Int_t that corresponds to the id of the activated menu entry.
127
128If the button is not split, clicking it will popup the menu and the
129ItemClicked(Int_t) signal will be emitted when a menu entry is
130activated. The value of the Int_t is again equal to the value of
131the id of the activated menu entry.
132
133The mode of operation of a SplitButton can be changed on the fly
134by calling the SetSplit(Bool_t) method.
135*/
136
137
138#include "TGButton.h"
139#include "TGWidget.h"
140#include "TGPicture.h"
141#include "TGToolTip.h"
142#include "TGButtonGroup.h"
143#include "TGResourcePool.h"
144#include "TSystem.h"
145#include "TImage.h"
146#include "TASUtils.h"
147#include "TEnv.h"
148#include "TClass.h"
149#include "TGMenu.h"
150#include "KeySymbols.h"
151#include "TVirtualX.h"
152
153#include <iostream>
154
155
156const TGGC *TGButton::fgHibckgndGC = nullptr;
157const TGGC *TGButton::fgDefaultGC = nullptr;
158
159const TGFont *TGTextButton::fgDefaultFont = nullptr;
160
161const TGFont *TGCheckButton::fgDefaultFont = nullptr;
162const TGGC *TGCheckButton::fgDefaultGC = nullptr;
163
164const TGFont *TGRadioButton::fgDefaultFont = nullptr;
165const TGGC *TGRadioButton::fgDefaultGC = nullptr;
166
168
169
170////////////////////////////////////////////////////////////////////////////////
171/// Create button base class part.
172
174 : TGFrame(p, 1, 1, options)
175{
176 fWidgetId = id;
178 fMsgWindow = p;
179 fUserData = 0;
180 fTip = 0;
181 fGroup = 0;
182 fStyle = 0;
183 fTWidth = fTHeight = 0;
184
185 fNormGC = norm;
189
190// fStyle = gClient->GetStyle();
191// if (fStyle > 0) {
192// fOptions &= ~(kRaisedFrame | kDoubleBorder);
193// }
194
195 // coverity[returned_null]
196 // coverity[dereference]
197 if (p && p->IsA()->InheritsFrom(TGButtonGroup::Class())) {
199 bg->Insert(this, id);
200 }
201
203 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
204
205 gVirtualX->GrabButton(fId, kButton1, kAnyModifier,
207 kNone, kNone);
208
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Delete button.
215
217{
218 // remove from button group
219 if (fGroup) {
220 fGroup->Remove(this);
221 fGroup = 0;
222 }
223
224 if (fTip) delete fTip;
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Set button state.
229
231{
232 Bool_t was = !IsDown(); // kTRUE if button was off
233
234 if (state == kButtonDisabled)
235 fWidgetFlags &= ~kWidgetIsEnabled;
236 else
238 if (state != fState) {
239 switch (state) {
240 case kButtonEngaged:
241 case kButtonDown:
242 fOptions &= ~kRaisedFrame;
244 break;
245 case kButtonDisabled:
246 case kButtonUp:
247 if (fStyle > 0) {
248 fOptions &= ~kRaisedFrame;
249 fOptions &= ~kSunkenFrame;
250 }
251 else {
252 fOptions &= ~kSunkenFrame;
254 }
255 break;
256 }
257 fState = state;
258 DoRedraw();
259 if (emit || fGroup) EmitSignals(was);
260 }
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Set the button style (modern or classic).
265
267{
268 fStyle = newstyle;
270 if (fStyle > 0) {
272 }
273 else {
275 }
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Set the button style (modern or classic).
280
281void TGButton::SetStyle(const char *style)
282{
284 if (style && strstr(style, "modern")) {
285 fStyle = 1;
287 }
288 else {
289 fStyle = 0;
291 }
292}
293
294////////////////////////////////////////////////////////////////////////////////
295
297{
298 if (fStyle > 0)
299 return (fOptions & kSunkenFrame);
300 return !(fOptions & kRaisedFrame);
301}
302
303////////////////////////////////////////////////////////////////////////////////
304
306{
307 // Set button state down according to the parameter 'on'.
308
309 if (GetState() == kButtonDisabled) return;
310
311 SetState(on ? kButtonDown : kButtonUp, emit);
312}
313
314////////////////////////////////////////////////////////////////////////////////
315/// Sets new button-group for this button.
316
321
322////////////////////////////////////////////////////////////////////////////////
323/// Handle mouse button event.
324
326{
327 Bool_t click = kFALSE;
328
329 if (fTip) fTip->Hide();
330
331 if (fState == kButtonDisabled) return kTRUE;
332
333 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
334 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
335
336 // We don't need to check the button number as GrabButton will
337 // only allow button1 events
338 if (event->fType == kButtonPress) {
339 fgReleaseBtn = 0;
340
341 if (fState == kButtonEngaged) {
342 return kTRUE;
343 }
344 if (in) SetState(kButtonDown, kTRUE);
345 } else { // ButtonRelease
346 if (fState == kButtonEngaged) {
347 if (in) SetState(kButtonUp, kTRUE);
348 click = kTRUE;
349 } else {
350 click = (fState == kButtonDown) && in;
351 if (click && fStayDown) {
352 if (in) {
354 fgReleaseBtn = 0;
355 }
356 } else {
357 if (in) {
360 }
361 }
362 }
363 }
364 if (click) {
369 }
370 if ((fStyle > 0) && (event->fType == kButtonRelease)) {
372 }
373 DoRedraw();
374 return kTRUE;
375}
376
377////////////////////////////////////////////////////////////////////////////////
378/// Emit button signals.
379
381{
382 Bool_t now = !IsDown(); // kTRUE if button now is off
383
384 // emit signals
385 if (was && !now) {
386 Pressed(); // emit Pressed = was off , now on
387 if (fStayDown) Clicked(); // emit Clicked
388 }
389 if (!was && now) {
390 Released(); // emit Released = was on , now off
391 Clicked(); // emit Clicked
392 }
393 if ((was != now) && IsToggleButton()) Toggled(!now); // emit Toggled = was != now
394}
395
396////////////////////////////////////////////////////////////////////////////////
397/// Handle mouse crossing event.
398
400{
401 if (fTip) {
402 if (event->fType == kEnterNotify)
403 fTip->Reset();
404 else
405 fTip->Hide();
406 }
407
408 if (fStyle > 0) {
409 if ((event->fType == kEnterNotify) && (fState != kButtonDisabled)) {
411 } else {
413 }
414 if (event->fType == kLeaveNotify) {
416 }
417 DoRedraw();
418 }
419
420 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
421
422 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
423 return kTRUE;
424
425 if (fState == kButtonEngaged || fState == kButtonDisabled) return kTRUE;
426
427 if (event->fType == kLeaveNotify) {
430 }
431 DoRedraw();
432 return kTRUE;
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// Set tool tip text associated with this button. The delay is in
437/// milliseconds (minimum 250). To remove tool tip call method with
438/// text = 0.
439
440void TGButton::SetToolTipText(const char *text, Long_t delayms)
441{
442 if (fTip) {
443 delete fTip;
444 fTip = 0;
445 }
446
447 if (text && strlen(text))
448 fTip = new TGToolTip(fClient->GetDefaultRoot(), this, text, delayms);
449}
450
451////////////////////////////////////////////////////////////////////////////////
452/// Set enabled or disabled state of button
453
455{
457
459 else fWidgetFlags &= ~kWidgetIsEnabled;
460}
461
462////////////////////////////////////////////////////////////////////////////////
463/// Return default graphics context.
464
466{
467 if (!fgDefaultGC)
468 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
469 return *fgDefaultGC;
470}
471
472////////////////////////////////////////////////////////////////////////////////
473/// Return graphics context for highlighted frame background.
474
476{
477 if (!fgHibckgndGC) {
481 gval.fForeground = gClient->GetResourcePool()->GetFrameHiliteColor();
482 gval.fBackground = gClient->GetResourcePool()->GetFrameBgndColor();
483 gval.fFillStyle = kFillTiled;
484 gval.fTile = gClient->GetResourcePool()->GetCheckeredPixmap();
485 gval.fGraphicsExposures = kFALSE;
487 }
488 return *fgHibckgndGC;
489}
490
491
492////////////////////////////////////////////////////////////////////////////////
493/// Create a text button widget. The hotstring will be adopted and deleted
494/// by the text button.
495
497 GContext_t norm, FontStruct_t font,
498 UInt_t options) : TGButton(p, id, norm, options)
499{
500 fLabel = s;
501 fFontStruct = font;
502
503 Init();
504}
505
506////////////////////////////////////////////////////////////////////////////////
507/// Create a text button widget.
508
509TGTextButton::TGTextButton(const TGWindow *p, const char *s, Int_t id,
510 GContext_t norm, FontStruct_t font,
511 UInt_t options) : TGButton(p, id, norm, options)
512{
513 fLabel = new TGHotString(!p && !s ? GetName() : s);
514 fFontStruct = font;
515
516 Init();
517}
518
519////////////////////////////////////////////////////////////////////////////////
520/// Create a text button widget and set cmd string at same time.
521
522TGTextButton::TGTextButton(const TGWindow *p, const char *s, const char *cmd,
523 Int_t id, GContext_t norm, FontStruct_t font,
524 UInt_t options) : TGButton(p, id, norm, options)
525{
526 fLabel = new TGHotString(s);
527 fFontStruct = font;
528 fCommand = cmd;
529
530 Init();
531}
532
533////////////////////////////////////////////////////////////////////////////////
534/// Common initialization used by the different ctors.
535
537{
538 int hotchar;
539
541 fHKeycode = 0;
545 fWrapLength = -1;
546 fMLeft = fMRight = fMTop = fMBottom = 0;
547
549 if (!font) {
551 if (font) fFontStruct = font->GetFontStruct();
552 }
553 if (font) {
556 &fTWidth, &fTHeight);
557 }
558 Resize();
559 fWidth = fTWidth;
561
562 if ((hotchar = fLabel->GetHotChar()) != 0) {
563 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
565 if (main) {
566 main->BindKey(this, fHKeycode, kKeyMod1Mask);
567 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
568 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
570
571 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
575 }
576 }
577 }
580 wattr.fBitGravity = 5; // center
581 wattr.fWinGravity = 1;
582 gVirtualX->ChangeWindowAttributes(fId, &wattr);
583
585}
586
587////////////////////////////////////////////////////////////////////////////////
588/// Delete a text button widget.
589
591{
592 if (fHKeycode && (fParent->MustCleanup() != kDeepCleanup)) {
594 if (main) {
595 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
596 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
597 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
598 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
599
600 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
601 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
602 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
604 }
605 }
606 if (fLabel) delete fLabel;
607 if (fHasOwnFont) {
608 TGGCPool *pool = fClient->GetGCPool();
609 TGGC *gc = pool->FindGC(fNormGC);
610 pool->FreeGC(gc);
611 }
612
613 delete fTLayout;
614}
615
616////////////////////////////////////////////////////////////////////////////////
617/// layout text button
618
620{
622
624 if (!font) {
626 if (font) fFontStruct = font->GetFontStruct();
627 }
628 if (font) {
631 &fTWidth, &fTHeight);
632 }
633 fClient->NeedRedraw(this);
634}
635
636////////////////////////////////////////////////////////////////////////////////
637/// Set new button text.
638
640{
641 int hotchar;
643
644 if (fLabel) {
645 if (main && fHKeycode) {
646 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
647 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
648 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
649 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
650
651 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
652 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
653 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
655 }
656 delete fLabel;
657 }
658
659 fLabel = new_label;
660 if ((hotchar = fLabel->GetHotChar()) != 0) {
661 if (main && ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0)) {
662 main->BindKey(this, fHKeycode, kKeyMod1Mask);
663 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
664 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
666
667 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
671 }
672 }
673
674 Layout();
675}
676
677////////////////////////////////////////////////////////////////////////////////
678/// Set new button text.
679
680void TGTextButton::SetText(const TString &new_label)
681{
682 SetText(new TGHotString(new_label));
683}
684
685////////////////////////////////////////////////////////////////////////////////
686/// Set text justification. Mode is an OR of the bits:
687/// kTextTop, kTextBottom, kTextLeft, kTextRight, kTextCenterX and
688/// kTextCenterY.
689
691{
692 fTMode = mode;
693
696 wattr.fWinGravity = 1;
697
698 switch (mode) {
699 case kTextTop | kTextLeft:
700 wattr.fBitGravity = 1; //NorthWestGravity
701 break;
702 case kTextTop | kTextCenterX:
703 case kTextTop:
704 wattr.fBitGravity = 2; //NorthGravity
705 break;
706 case kTextTop | kTextRight:
707 wattr.fBitGravity = 3; //NorthEastGravity
708 break;
709 case kTextLeft | kTextCenterY:
710 case kTextLeft:
711 wattr.fBitGravity = 4; //WestGravity
712 break;
714 wattr.fBitGravity = 5; //CenterGravity
715 break;
717 case kTextRight:
718 wattr.fBitGravity = 6; //EastGravity
719 break;
720 case kTextBottom | kTextLeft:
721 wattr.fBitGravity = 7; //SouthWestGravity
722 break;
724 case kTextBottom:
725 wattr.fBitGravity = 8; //SouthGravity
726 break;
727 case kTextBottom | kTextRight:
728 wattr.fBitGravity = 9; //SouthEastGravity
729 break;
730 default:
731 wattr.fBitGravity = 5; //CenterGravity
732 break;
733 }
734
735 gVirtualX->ChangeWindowAttributes(fId, &wattr);
736 Layout();
737}
738
739////////////////////////////////////////////////////////////////////////////////
740/// Draw the text button.
741
743{
744 int x, y;
745 UInt_t w = GetWidth() - 1;
746 UInt_t h = GetHeight()- 1;
747
748 if ((fStyle > 0) && !(fOptions & kOwnBackground))
749 gVirtualX->SetWindowBackground(fId, fBgndColor);
751
752 if (fTMode & kTextLeft) {
753 x = fMLeft + 4;
754 } else if (fTMode & kTextRight) {
755 x = fWidth - fTWidth - fMRight - 4;
756 } else {
757 x = (fWidth - fTWidth + fMLeft - fMRight) >> 1;
758 }
759
760 if (fTMode & kTextTop) {
761 y = fMTop + 3;
762 } else if (fTMode & kTextBottom) {
763 y = fHeight - fTHeight - fMBottom - 3;
764 } else {
765 y = (fHeight - fTHeight + fMTop - fMBottom) >> 1;
766 }
767
769 ++x; ++y;
770 w--; h--;
771 }
772 if (fStyle == 0) {
773 if (fState == kButtonEngaged) {
774 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
775 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
776 }
777 }
778
779 Int_t hotpos = fLabel->GetHotPos();
780
781 if (fStyle > 0) {
782 gVirtualX->DrawRectangle(fId, TGFrame::GetShadowGC()(), 0, 0, w, h);
783 }
784 if (fState == kButtonDisabled) {
786 TGGC *gc = pool->FindGC(fNormGC);
787 if (gc) {
788 Pixel_t fore = gc->GetForeground();
791
792 gc->SetForeground(hi);
793 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
794 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x + 1, y + 1, hotpos - 1);
795
796 gc->SetForeground(sh);
797 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
798 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
799 gc->SetForeground(fore);
800 }
801 } else {
802 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
803 if (hotpos) fTLayout->UnderlineChar(fId, fNormGC, x, y, hotpos - 1);
804 }
805}
806
807////////////////////////////////////////////////////////////////////////////////
808/// Handle key event. This function will be called when the hotkey is hit.
809
811{
812 if (fState == kButtonDisabled || !(event->fState & kKeyMod1Mask)) return kFALSE;
813
814 Bool_t click = kFALSE;
815 Bool_t was = !IsDown(); // kTRUE if button was off
816
817 if (event->fType == kGKeyPress) {
818 gVirtualX->SetKeyAutoRepeat(kFALSE);
819 } else {
820 gVirtualX->SetKeyAutoRepeat(kTRUE);
821 }
822
823 if (fTip && event->fType == kGKeyPress) fTip->Hide();
824
825 // We don't need to check the key number as GrabKey will only
826 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
827
828 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
829 if (fState == kButtonEngaged) return kTRUE;
831 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
832 if (fState == kButtonEngaged /*&& !allowRelease*/) return kTRUE;
833 click = (fState == kButtonDown);
834 if (click && fStayDown) {
836 } else {
838 }
839 }
840 if (click) {
845 }
846 EmitSignals(was);
847
848 return kTRUE;
849}
850
851////////////////////////////////////////////////////////////////////////////////
852/// returns default size
853
860
861////////////////////////////////////////////////////////////////////////////////
862/// Return default font structure.
863
865{
866 if (!fgDefaultFont)
867 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
869}
870
871////////////////////////////////////////////////////////////////////////////////
872/// Changes text font.
873/// If global is kTRUE font is changed globally, otherwise - locally.
874
876{
877 if (font != fFontStruct) {
878 FontH_t v = gVirtualX->GetFontHandle(font);
879 if (!v) return;
880
881 fFontStruct = font;
883 TGGC *gc = pool->FindGC(fNormGC);
884
885 if (gc && !global) {
886 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
888 }
889 if (gc) {
890 gc->SetFont(v);
891 fNormGC = gc->GetGC();
892 }
893 Layout();
894 }
895}
896
897////////////////////////////////////////////////////////////////////////////////
898/// Changes text font specified by name.
899/// If global is true color is changed globally, otherwise - locally.
900
901void TGTextButton::SetFont(const char *fontName, Bool_t global)
902{
903 TGFont *font = fClient->GetFont(fontName);
904 if (font) {
905 SetFont(font->GetFontStruct(), global);
906 }
907}
908
909////////////////////////////////////////////////////////////////////////////////
910/// Changes text color.
911/// If global is true color is changed globally, otherwise - locally.
912
914{
916 TGGC *gc = pool->FindGC(fNormGC);
917
918 if (gc && !global) {
919 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
921 }
922 if (gc) {
923 gc->SetForeground(color);
924 fNormGC = gc->GetGC();
925 }
926 fClient->NeedRedraw(this);
927}
928
929////////////////////////////////////////////////////////////////////////////////
930/// Returns kTRUE if text attributes are unique,
931/// returns kFALSE if text attributes are shared (global).
932
934{
935 return fHasOwnFont;
936}
937
938////////////////////////////////////////////////////////////////////////////////
939/// Create a picture button widget. The picture is not adopted and must
940/// later be freed by the user once the picture button is deleted (a single
941/// picture reference might be used by other buttons).
942
944 Int_t id, GContext_t norm, UInt_t option) : TGButton(p, id, norm, option)
945{
946 if (!pic) {
947 Error("TGPictureButton", "pixmap not found or the file format is not supported for button %d", id);
948 fPic = fClient->GetPicture("mb_question_s.xpm");
949 } else {
950 fPic = pic;
951 }
952
953 if (fPic) {
954 fTWidth = fPic->GetWidth();
956
958 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
959 }
960 fPicD = 0;
963}
964
965////////////////////////////////////////////////////////////////////////////////
966/// Create a picture button widget and set action command. The picture is
967/// not adopted and must later be freed by the user once the picture button
968/// is deleted (a single picture reference might be used by other
969/// buttons).
970
972 const char *cmd, Int_t id, GContext_t norm, UInt_t option)
973 : TGButton(p, id, norm, option)
974{
975 if (!pic) {
976 Error("TGPictureButton", "pixmap not found or the file format is not supported for button\n%s",
977 cmd ? cmd : "");
978 fPic = fClient->GetPicture("mb_question_s.xpm");
979 } else {
980 fPic = pic;
981 }
982
983 fCommand = cmd;
984
985 if (fPic) {
986 fTWidth = fPic->GetWidth();
988
990 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
991 }
992 fPicD = 0;
995}
996
997////////////////////////////////////////////////////////////////////////////////
998/// Create a picture button. Where pic is the file name of the picture.
999
1001 Int_t id, GContext_t norm, UInt_t option) : TGButton(p, id, norm, option)
1002{
1003 if (!pic || !pic[0]) {
1004 if (p) Error("TGPictureButton", "pixmap not found or the file format is not supported for button");
1005 fPic = fClient->GetPicture("mb_question_s.xpm");
1006 } else {
1007 fPic = fClient->GetPicture(pic);
1008 }
1009
1010 if (fPic) {
1011 fTWidth = fPic->GetWidth();
1012 fTHeight = fPic->GetHeight();
1013
1014 Resize(fTWidth + (fBorderWidth << 1) + fBorderWidth + 1,
1015 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
1016 }
1017 fPicD = 0;
1019 SetWindowName();
1020}
1021
1022////////////////////////////////////////////////////////////////////////////////
1023/// Destructor.
1024
1029
1030////////////////////////////////////////////////////////////////////////////////
1031/// Change a picture in a picture button. The picture is not adopted and
1032/// must later be freed by the user once the picture button is deleted
1033/// (a single picture reference might be used by other buttons).
1034
1036{
1037 if (!new_pic) {
1038 Error("SetPicture", "pixmap not found or the file format is not supported for button %d\n%s",
1040 return;
1041 }
1042
1043 fPic = new_pic;
1044
1045 if (fState == kButtonDisabled) {
1047 fPicD = 0;
1048 }
1049
1050 fTWidth = fPic->GetWidth();
1051 fTHeight = fPic->GetHeight();
1052
1053 fClient->NeedRedraw(this);
1054}
1055
1056////////////////////////////////////////////////////////////////////////////////
1057/// Redraw picture button.
1058
1060{
1061 if (!fPic) {
1063 return;
1064 }
1065
1066 int x = (fWidth - fTWidth) >> 1;
1067 int y = (fHeight - fTHeight) >> 1;
1068 UInt_t w = GetWidth() - 1;
1069 UInt_t h = GetHeight()- 1;
1070
1071 if ((fStyle > 0) && !(fOptions & kOwnBackground))
1072 gVirtualX->SetWindowBackground(fId, fBgndColor);
1074
1075 if (fState == kButtonDown || fState == kButtonEngaged) {
1076 ++x; ++y;
1077 w--; h--;
1078 }
1079 if (fStyle == 0) {
1080 if (fState == kButtonEngaged) {
1081 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
1082 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
1083 }
1084 }
1085
1086 const TGPicture *pic = fPic;
1087 if (fState == kButtonDisabled) {
1089 pic = fPicD ? fPicD : fPic;
1090 }
1091 if (fStyle > 0) {
1092 if (fBgndColor == fHighColor) {
1093 gVirtualX->DrawRectangle(fId, TGFrame::GetShadowGC()(), 0, 0, w, h);
1094 }
1095 }
1096
1097 pic->Draw(fId, fNormGC, x, y);
1098}
1099
1100////////////////////////////////////////////////////////////////////////////////
1101/// Creates disabled picture.
1102
1104{
1105 std::unique_ptr<TImage> img2(TImage::Create());
1106 if (!img2)
1107 return;
1108 TString back = gEnv->GetValue("Gui.BackgroundColor", "#c0c0c0");
1109 img2->FillRectangle(back.Data(), 0, 0, fPic->GetWidth(), fPic->GetHeight());
1110 auto img = TASUtils::FromPixmap(fPic->GetPicture(), fPic->GetMask());
1111 if (img) {
1112 Pixmap_t mask = TASUtils::GetMask(img.get());
1113 img2->Merge(img.get(), "overlay");
1114
1115 TString name = "disbl_";
1116 name += fPic->GetName();
1118 mask);
1120 }
1121}
1122
1123////////////////////////////////////////////////////////////////////////////////
1124/// Changes disabled picture.
1125
1127{
1128 if (!pic) return;
1129
1131 fPicD = pic;
1132 ((TGPicture*)pic)->AddReference();
1134}
1135
1136////////////////////////////////////////////////////////////////////////////////
1137/// Create a check button widget. The hotstring will be adopted and deleted
1138/// by the check button.
1139
1142 : TGTextButton(p, s, id, norm, font, option)
1143{
1144 Init();
1145}
1146
1147////////////////////////////////////////////////////////////////////////////////
1148/// Create a check button widget.
1149
1152 : TGTextButton(p, s, id, norm, font, option)
1153{
1154 Init();
1155}
1156
1157////////////////////////////////////////////////////////////////////////////////
1158/// Create a check button widget.
1159
1160TGCheckButton::TGCheckButton(const TGWindow *p, const char *s, const char *cmd,
1161 Int_t id, GContext_t norm, FontStruct_t font,
1162 UInt_t option) : TGTextButton(p, s, cmd, id, norm, font, option)
1163{
1164 Init();
1165}
1166
1167////////////////////////////////////////////////////////////////////////////////
1168/// Common check button initialization.
1169
1171{
1172 fPrevState =
1173 fState = kButtonUp;
1174 fHKeycode = 0;
1175
1176 fOn = fClient->GetPicture("checked_t.xpm");
1177 fOff = fClient->GetPicture("unchecked_t.xpm");
1178 fDisOn = fClient->GetPicture("checked_dis_t.xpm");
1179 fDisOff = fClient->GetPicture("unchecked_dis_t.xpm");
1180
1181 Resize();
1182
1183 if (!fOn || !fOff || !fDisOn || !fDisOff)
1184 Error("Init", "checked*_t.xpm not found or the file format is not supported.");
1185
1186 int hotchar;
1187
1188 if ((hotchar = fLabel->GetHotChar()) != 0) {
1189 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
1191 if (main) {
1192 main->BindKey(this, fHKeycode, kKeyMod1Mask);
1193 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
1194 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
1196
1197 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
1201 }
1202 }
1203 }
1204 SetWindowName();
1205}
1206
1207////////////////////////////////////////////////////////////////////////////////
1208/// Delete a check button.
1209
1217
1218////////////////////////////////////////////////////////////////////////////////
1219/// default size
1220
1222{
1223 UInt_t pic_width = fOff ? fOff->GetWidth() : 10;
1224 UInt_t pic_height = fOff ? fOff->GetHeight() : 2;
1225
1226 UInt_t w = !fTWidth ? pic_width : fTWidth + pic_width + 9;
1227 UInt_t h = !fTHeight ? pic_height : fTHeight + 2;
1228
1229 w = GetOptions() & kFixedWidth ? fWidth : w;
1230 h = GetOptions() & kFixedHeight ? fHeight : h;
1231
1232 return TGDimension(w, h);
1233}
1234
1235////////////////////////////////////////////////////////////////////////////////
1236/// Set check button state.
1237
1239{
1240 if (state == kButtonDisabled)
1241 fWidgetFlags &= ~kWidgetIsEnabled;
1242 else
1244 PSetState(state, emit);
1245}
1246
1247////////////////////////////////////////////////////////////////////////////////
1248/// Emit signals.
1249
1251{
1252 if (fState == kButtonUp) Released(); // emit Released
1253 if (fState == kButtonDown) Pressed(); // emit Pressed
1254 Clicked(); // emit Clicked
1255 Toggled(fStateOn); // emit Toggled
1256}
1257
1258////////////////////////////////////////////////////////////////////////////////
1259/// Set check button state.
1260
1262{
1263 if (state != fState) {
1264 if (state == kButtonUp) {
1265 if (fPrevState == kButtonDisabled) {
1266 if (fStateOn) {
1269 } else {
1270 fState = state;
1271 fPrevState = state;
1272 }
1273 } else if (fPrevState == kButtonDown) {
1274 fStateOn = kFALSE;
1275 fState = state;
1276 fPrevState = state;
1277 }
1278 } else if (state == kButtonDown) {
1279 fStateOn = kTRUE;
1280 fState = state;
1281 fPrevState = state;
1282 } else {
1283 fState = state;
1284 fPrevState = state;
1285 }
1286 if (emit) {
1287 // button signals
1288 EmitSignals();
1289 }
1290 DoRedraw();
1291 }
1292}
1293
1294////////////////////////////////////////////////////////////////////////////////
1295/// Set the state of a check button to disabled and either on or
1296/// off.
1297
1299{
1300 if (!enable) {
1301 if (fState == kButtonDisabled && fStateOn) {
1302 PSetState(kButtonUp, kFALSE); // enable button
1303 PSetState(kButtonUp, kFALSE); // set button up
1304 PSetState(kButtonDisabled, kFALSE); // disable button
1305 } else {
1308 }
1309 } else {
1310 PSetState(kButtonDown, kFALSE); // set button down
1311 PSetState(kButtonDisabled, kFALSE); // disable button
1312 }
1313}
1314
1315////////////////////////////////////////////////////////////////////////////////
1316/// Handle mouse button event.
1317
1319{
1320 Bool_t click = kFALSE;
1321
1322 if (fTip) fTip->Hide();
1323
1324 if (fState == kButtonDisabled) return kTRUE;
1325
1326 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
1327 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
1328
1329 // We don't need to check the button number as GrabButton will
1330 // only allow button1 events
1331 if (event->fType == kButtonPress) {
1332 fgReleaseBtn = 0;
1333 if (in) {
1335 Pressed();
1336 }
1337 } else { // ButtonRelease
1338 if (in) {
1340 click = kTRUE;
1342 Released();
1343 }
1344 fgReleaseBtn = fId;
1345 fOptions &= ~kSunkenFrame;
1346 }
1347 if (click) {
1348 Clicked();
1354 }
1355 DoRedraw();
1356 return kTRUE;
1357}
1358
1359////////////////////////////////////////////////////////////////////////////////
1360/// Handle mouse crossing event.
1361
1363{
1364 if (fTip) {
1365 if (event->fType == kEnterNotify)
1366 fTip->Reset();
1367 else
1368 fTip->Hide();
1369 }
1370
1371 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
1372
1373 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
1374 return kTRUE;
1375
1376 if (fState == kButtonDisabled) return kTRUE;
1377
1378 if (event->fType == kEnterNotify) {
1380 } else {
1381 fOptions &= ~kSunkenFrame;
1382 }
1383 DoRedraw();
1384
1385 return kTRUE;
1386}
1387
1388////////////////////////////////////////////////////////////////////////////////
1389/// Handle key event. This function will be called when the hotkey is hit.
1390
1392{
1393 Bool_t click = kFALSE;
1394
1395 if (event->fType == kGKeyPress)
1396 gVirtualX->SetKeyAutoRepeat(kFALSE);
1397 else
1398 gVirtualX->SetKeyAutoRepeat(kTRUE);
1399
1400 if (fTip && event->fType == kGKeyPress) fTip->Hide();
1401
1402 if (fState == kButtonDisabled) return kTRUE;
1403
1404 // We don't need to check the key number as GrabKey will only
1405 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
1406
1407 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
1409 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
1410 click = (fState != fPrevState);
1412 }
1413 if (click) {
1418 }
1419 return kTRUE;
1420}
1421
1422////////////////////////////////////////////////////////////////////////////////
1423/// Draw the check button widget.
1424
1426{
1427 int x, y, y0;
1428
1430
1431 x = 20;
1432 y = (fHeight - fTHeight) >> 1;
1433
1434 y0 = !fTHeight ? 0 : y + 1;
1435 if (fOn && fOff) {
1436 Int_t smax = std::max(fOn->GetHeight(), fOff->GetHeight());
1437 y0 = ((Int_t)fHeight <= smax) ? 0 : 1 + (((Int_t)fHeight - smax) >> 1);
1438 }
1439
1440 if (fStateOn) {
1441 if (fOn) fOn->Draw(fId, fNormGC, 0, y0);
1442 } else {
1443 if (fOff) fOff->Draw(fId, fNormGC, 0, y0);
1444 }
1445
1446 Int_t hotpos = fLabel->GetHotPos();
1447
1448 if (fState == kButtonDisabled) {
1449 if (fStateOn == kTRUE) {
1450 if (fDisOn) fDisOn->Draw(fId, fNormGC, 0, y0);
1451 } else {
1452 if (fDisOff) fDisOff->Draw(fId, fNormGC, 0, y0);
1453 }
1454
1456 TGGC *gc = pool->FindGC(fNormGC);
1457 if (gc) {
1458 Pixel_t fore = gc->GetForeground();
1461
1462 gc->SetForeground(hi);
1463 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
1464 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
1465
1466 gc->SetForeground(sh);
1467 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
1468 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
1469
1470 gc->SetForeground(fore);
1471 }
1472 } else {
1473 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
1474 if (hotpos) fTLayout->UnderlineChar(fId, fNormGC, x, y, hotpos - 1);
1475 }
1476}
1477
1478////////////////////////////////////////////////////////////////////////////////
1479/// Return default font structure.
1480
1482{
1483 if (!fgDefaultFont)
1484 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
1485 return fgDefaultFont->GetFontStruct();
1486}
1487
1488////////////////////////////////////////////////////////////////////////////////
1489/// Return default graphics context.
1490
1492{
1493 if (!fgDefaultGC)
1494 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1495 return *fgDefaultGC;
1496}
1497
1498
1499////////////////////////////////////////////////////////////////////////////////
1500/// Create a radio button widget. The hotstring will be adopted and deleted
1501/// by the radio button.
1502
1505 : TGTextButton(p, s, id, norm, font, option)
1506{
1507 Init();
1508}
1509
1510////////////////////////////////////////////////////////////////////////////////
1511/// Create a radio button widget.
1512
1515 : TGTextButton(p, s, id, norm, font, option)
1516{
1517 Init();
1518}
1519////////////////////////////////////////////////////////////////////////////////
1520/// Create a radio button widget.
1521
1522TGRadioButton::TGRadioButton(const TGWindow *p, const char *s, const char *cmd,
1523 Int_t id, GContext_t norm,
1525 : TGTextButton(p, s, cmd, id, norm, font, option)
1526{
1527 Init();
1528}
1529
1530////////////////////////////////////////////////////////////////////////////////
1531/// Common radio button initialization.
1532
1534{
1535 fPrevState =
1536 fState = kButtonUp;
1537 fHKeycode = 0;
1538
1539 fOn = fClient->GetPicture("rbutton_on.xpm");
1540 fOff = fClient->GetPicture("rbutton_off.xpm");
1541 fDisOn = fClient->GetPicture("rbutton_dis_on.xpm");
1542 fDisOff = fClient->GetPicture("rbutton_dis_off.xpm");
1543
1544 if (!fOn || !fOff || !fDisOn || !fDisOff)
1545 Error("Init", "rbutton_*.xpm not found or the file format is not supported.");
1546
1547 Resize();
1548
1549 int hotchar;
1550
1551 if ((hotchar = fLabel->GetHotChar()) != 0) {
1552 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
1554 if (main) {
1555 main->BindKey(this, fHKeycode, kKeyMod1Mask);
1556 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
1557 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
1559
1560 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
1564 }
1565 }
1566 }
1567
1569 ((TGButtonGroup*)fParent)->SetRadioButtonExclusive(kTRUE);
1570 }
1571 SetWindowName();
1572}
1573
1574////////////////////////////////////////////////////////////////////////////////
1575/// Delete a radio button.
1576
1584
1585////////////////////////////////////////////////////////////////////////////////
1586/// default size
1587
1589{
1590 UInt_t pic_width = fOff ? fOff->GetWidth() : 10;
1591 UInt_t pic_height = fOff ? fOff->GetHeight() : 2;
1592
1593 UInt_t w = !fTWidth ? pic_width : fTWidth + pic_width + 10;
1594 UInt_t h = !fTHeight ? pic_height : fTHeight + 2;
1595
1596 w = GetOptions() & kFixedWidth ? fWidth : w;
1597 h = GetOptions() & kFixedHeight ? fHeight : h;
1598
1599 return TGDimension(w, h);
1600}
1601
1602////////////////////////////////////////////////////////////////////////////////
1603/// Set radio button state.
1604
1606{
1607 if (state == kButtonDisabled)
1608 fWidgetFlags &= ~kWidgetIsEnabled;
1609 else
1611 PSetState(state, emit);
1612}
1613
1614////////////////////////////////////////////////////////////////////////////////
1615/// Set the state of a radio button to disabled and either on or
1616/// off.
1617
1619{
1620 if (!enable) {
1621 if (fState == kButtonDisabled && fStateOn) {
1622 PSetState(kButtonUp, kFALSE); // enable button
1623 PSetState(kButtonUp, kFALSE); // set button up
1624 PSetState(kButtonDisabled, kFALSE); // disable button
1625 } else {
1628 }
1629 } else {
1630 PSetState(kButtonDown, kFALSE); // set button down
1631 PSetState(kButtonDisabled, kFALSE); // disable button
1632 }
1633}
1634
1635////////////////////////////////////////////////////////////////////////////////
1636/// Emit signals.
1637
1639{
1640 if (fState == kButtonUp) Released(); // emit Released
1641 if (fState == kButtonDown) Pressed(); // emit Pressed
1642 Clicked(); // emit Clicked
1643 Toggled(fStateOn); // emit Toggled
1644}
1645
1646////////////////////////////////////////////////////////////////////////////////
1647/// Set radio button state.
1648
1650{
1651 if (state != fState) {
1652 // fPrevState = fState = state;
1653 if (state == kButtonUp) {
1654 if (fPrevState == kButtonDisabled) {
1655 if (fStateOn) {
1658 } else {
1659 fState = state;
1660 fPrevState = state;
1661 }
1662 } else if (fPrevState == kButtonDown) {
1663 fStateOn = kFALSE;
1664 fState = state;
1665 fPrevState = state;
1666 }
1667 } else if (state == kButtonDown) {
1668 fStateOn = kTRUE;
1669 fState = state;
1670 fPrevState = state;
1671 } else {
1672 fState = state;
1673 fPrevState = state;
1674 }
1675 if (emit) {
1676 // button signals
1677 EmitSignals();
1678 }
1679 DoRedraw();
1680 }
1681}
1682
1683////////////////////////////////////////////////////////////////////////////////
1684/// Handle mouse button event.
1685
1687{
1688 Bool_t click = kFALSE;
1689 Bool_t toggled = kFALSE;
1690
1691 if (fTip) fTip->Hide();
1692
1693 if (fState == kButtonDisabled) return kFALSE;
1694
1695
1696 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
1697 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
1698
1699 if (event->fType == kButtonPress) { // button pressed
1700 fgReleaseBtn = 0;
1701 if (in) {
1703 Pressed();
1704 }
1705 } else { // ButtonRelease
1706 if (in) {
1707 if (!fStateOn) {
1709 toggled = kTRUE;
1710 }
1712 Released();
1713 click = kTRUE;
1714 }
1715 fOptions &= ~kSunkenFrame;
1716 fgReleaseBtn = fId;
1717 }
1718 if (click) {
1719 Clicked();
1724 }
1725 if (toggled) {
1727 }
1728 DoRedraw();
1729 return kTRUE;
1730}
1731
1732////////////////////////////////////////////////////////////////////////////////
1733/// Handle mouse crossing event.
1734
1736{
1737 if (fTip) {
1738 if (event->fType == kEnterNotify)
1739 fTip->Reset();
1740 else
1741 fTip->Hide();
1742 }
1743
1744 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
1745
1746 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
1747 return kTRUE;
1748
1749 if (fState == kButtonDisabled) return kTRUE;
1750
1751 if (event->fType == kEnterNotify) {
1753 } else {
1754 fOptions &= ~kSunkenFrame;
1755 }
1756 DoRedraw();
1757
1758 return kTRUE;
1759}
1760
1761////////////////////////////////////////////////////////////////////////////////
1762/// Handle key event. This function will be called when the hotkey is hit.
1763
1765{
1766 if (event->fType == kGKeyPress)
1767 gVirtualX->SetKeyAutoRepeat(kFALSE);
1768 else
1769 gVirtualX->SetKeyAutoRepeat(kTRUE);
1770
1771 if (fTip && event->fType == kGKeyPress)
1772 fTip->Hide();
1773
1774 if (fState == kButtonDisabled) return kTRUE;
1775
1776 // We don't need to check the key number as GrabKey will only
1777 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
1778
1779 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
1785 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
1787 }
1788 return kTRUE;
1789}
1790
1791////////////////////////////////////////////////////////////////////////////////
1792/// Draw a radio button.
1793
1795{
1796 Int_t tx, ty, y0;
1797
1799
1800 tx = 20;
1801 ty = (fHeight - fTHeight) >> 1;
1802
1803// pw = 12;
1804 y0 = !fTHeight ? 0 : ty + 1;
1805 if (fOn && fOff) {
1806 Int_t smax = std::max(fOn->GetHeight(), fOff->GetHeight());
1807 y0 = ((Int_t)fHeight <= smax) ? 0 : 1 + (((Int_t)fHeight - smax) >> 1);
1808 }
1809
1810 if (fStateOn) {
1811 if (fOn) fOn->Draw(fId, fNormGC, 0, y0);
1812 } else {
1813 if (fOff) fOff->Draw(fId, fNormGC, 0, y0);
1814 }
1815
1816 Int_t hotpos = fLabel->GetHotPos();
1817
1818 if (fState == kButtonDisabled) {
1819 if (fStateOn == kTRUE) {
1820 if (fDisOn) fDisOn->Draw(fId, fNormGC, 0, y0);
1821 } else {
1822 if (fDisOff) fDisOff->Draw(fId, fNormGC, 0, y0);
1823 }
1824
1826 TGGC *gc = pool->FindGC(fNormGC);
1827 if (gc) {
1828 Pixel_t fore = gc->GetForeground();
1831
1832 gc->SetForeground(hi);
1833 fTLayout->DrawText(fId, gc->GetGC(), tx + 1, ty + 1, 0, -1);
1834 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), tx, ty, hotpos - 1);
1835
1836 gc->SetForeground(sh);
1837 fTLayout->DrawText(fId, gc->GetGC(), tx, ty, 0, -1);
1838 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), tx, ty, hotpos - 1);
1839
1840 gc->SetForeground(fore);
1841 }
1842 } else {
1843 fTLayout->DrawText(fId, fNormGC, tx, ty, 0, -1);
1844 if (hotpos) fTLayout->UnderlineChar(fId, fNormGC, tx, ty, hotpos-1);
1845 }
1846}
1847
1848////////////////////////////////////////////////////////////////////////////////
1849/// Return default font structure.
1850
1852{
1853 if (!fgDefaultFont)
1854 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
1855 return fgDefaultFont->GetFontStruct();
1856}
1857
1858////////////////////////////////////////////////////////////////////////////////
1859/// Return default graphics context.
1860
1862{
1863 if (!fgDefaultGC)
1864 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1865 return *fgDefaultGC;
1866}
1867
1868////////////////////////////////////////////////////////////////////////////////
1869/// Save a button widget as a C++ statement(s) on output stream out.
1870
1871void TGButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1872{
1873 if (option && strstr(option, "keep_names"))
1874 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
1875
1876 if (fState == kButtonDown)
1877 out << " " << GetName() << "->SetState(kButtonDown);\n";
1878 if (fState == kButtonDisabled)
1879 out << " " << GetName() << "->SetState(kButtonDisabled);\n";
1880 if (fState == kButtonEngaged)
1881 out << " " << GetName() << "->SetState(kButtonEngaged);\n";
1882
1884 SaveUserColor(out, option);
1885 out << " " << GetName() << "->ChangeBackground(ucolor);\n";
1886 }
1887
1888 if (fTip)
1889 out << " " << GetName() << "->SetToolTipText(\""
1890 << TString(fTip->GetText()->GetString()).ReplaceSpecialCppChars() << "\");\n";
1891 if (fCommand.Length() > 0)
1892 out << " " << GetName() << "->SetCommand(\"" << TString(fCommand).ReplaceSpecialCppChars() << "\");\n";
1893}
1894
1895////////////////////////////////////////////////////////////////////////////////
1896/// Save a text button widget as a C++ statement(s) on output stream out.
1897
1898void TGTextButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1899{
1900 TString outext(fLabel->GetString());
1901 if (fLabel->GetHotPos() > 0)
1902 outext.Insert(fLabel->GetHotPos()-1, "&");
1903
1904 // font + GC
1905 option = GetName()+5; // unique digit id of the name
1906 TString parGC, parFont;
1907 parFont.Form("%s::GetDefaultFontStruct()",IsA()->GetName());
1908 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
1909
1910 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
1911 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
1912 if (ufont) {
1913 ufont->SavePrimitive(out, option);
1914 parFont.Form("ufont->GetFontStruct()");
1915 }
1916
1917 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
1918 if (userGC) {
1919 userGC->SavePrimitive(out, option);
1920 parGC.Form("uGC->GetGC()");
1921 }
1922 }
1923
1924 out << " TGTextButton *" << GetName() << " = new TGTextButton(" << fParent->GetName()
1925 << ", \"" << outext.ReplaceSpecialCppChars() << "\"";
1926
1927 if (GetOptions() == (kRaisedFrame | kDoubleBorder)) {
1929 if (fNormGC == GetDefaultGC()()) {
1930 if (fWidgetId == -1) {
1931 out << ");\n";
1932 } else {
1933 out << "," << fWidgetId <<");\n";
1934 }
1935 } else {
1936 out << "," << fWidgetId << "," << parGC << ");\n";
1937 }
1938 } else {
1939 out << "," << fWidgetId << "," << parGC << "," << parFont << ");\n";
1940 }
1941 } else {
1942 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");\n";
1943 }
1944
1945 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");\n";
1946 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << "," << fMTop << "," << fMBottom
1947 << ");\n";
1948 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");\n";
1949
1950 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetHeight() << ");\n";
1951
1953}
1954
1955////////////////////////////////////////////////////////////////////////////////
1956/// Save a picture button widget as a C++ statement(s) on output stream out.
1957
1958void TGPictureButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1959{
1960 if (!fPic) {
1961 Error("SavePrimitive", "pixmap not found or the file format is not supported for picture button %d ", fWidgetId);
1962 return;
1963 }
1964
1965 // GC
1966 option = GetName()+5; // unique digit id of the name
1967 TString parGC;
1968 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
1969
1970 if (GetDefaultGC()() != fNormGC) {
1971 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
1972 if (userGC) {
1973 userGC->SavePrimitive(out, option);
1974 parGC.Form("uGC->GetGC()");
1975 }
1976 }
1977
1978 TString picname = gSystem->UnixPathName(fPic->GetName());
1979 gSystem->ExpandPathName(picname);
1980
1981 out << " TGPictureButton *" << GetName() << " = new TGPictureButton(" << fParent->GetName()
1982 << ", gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\")";
1983
1984 if (GetOptions() == (kRaisedFrame | kDoubleBorder)) {
1985 if (fNormGC == GetDefaultGC()()) {
1986 if (fWidgetId == -1) {
1987 out << ");\n";
1988 } else {
1989 out << "," << fWidgetId << ");\n";
1990 }
1991 } else {
1992 out << "," << fWidgetId << "," << parGC << ");\n";
1993 }
1994 } else {
1995 out << "," << fWidgetId << "," << parGC << "," << GetOptionString() << ");\n";
1996 }
1997
1999}
2000
2001////////////////////////////////////////////////////////////////////////////////
2002/// Save a check button widget as a C++ statement(s) on output stream out.
2003
2004void TGCheckButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2005{
2006 TString outext(fLabel->GetString());
2007 if (fLabel->GetHotPos() > 0)
2008 outext.Insert(fLabel->GetHotPos()-1, "&");
2009
2010 out <<" TGCheckButton *" << GetName() << " = new TGCheckButton(" << fParent->GetName()
2011 << ", \"" << outext.ReplaceSpecialCppChars() << "\"";
2012
2013 // font + GC
2014 option = GetName()+5; // unique digit id of the name
2015 TString parGC, parFont;
2016 parFont.Form("%s::GetDefaultFontStruct()", IsA()->GetName());
2017 parGC.Form("%s::GetDefaultGC()()", IsA()->GetName());
2018
2019 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
2020 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
2021 if (ufont) {
2022 ufont->SavePrimitive(out, option);
2023 parFont.Form("ufont->GetFontStruct()");
2024 }
2025
2026 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
2027 if (userGC) {
2028 userGC->SavePrimitive(out, option);
2029 parGC.Form("uGC->GetGC()");
2030 }
2031 }
2032
2033 if (GetOptions() == kChildFrame) {
2035 if (fNormGC == GetDefaultGC()()) {
2036 if (fWidgetId == -1) {
2037 out << ");\n";
2038 } else {
2039 out << "," << fWidgetId << ");\n";
2040 }
2041 } else {
2042 out << "," << fWidgetId << "," << parGC << ");\n";
2043 }
2044 } else {
2045 out << "," << fWidgetId << "," << parGC << "," << parFont << ");\n";
2046 }
2047 } else {
2048 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");\n";
2049 }
2050
2052 if (fState == kButtonDisabled) {
2054 out << " " << GetName() << "->SetDisabledAndSelected(kTRUE);\n";
2055 else
2056 out << " " << GetName() << "->SetDisabledAndSelected(kFALSE);\n";
2057 }
2058 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");\n";
2059 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << "," << fMTop << "," << fMBottom
2060 << ");\n";
2061 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");\n";
2062}
2063
2064////////////////////////////////////////////////////////////////////////////////
2065/// Save a radio button widget as a C++ statement(s) on output stream out.
2066
2067void TGRadioButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2068{
2069 TString outext(fLabel->GetString());
2070 if (fLabel->GetHotPos() > 0)
2071 outext.Insert(fLabel->GetHotPos() - 1, "&");
2072
2073 out << " TGRadioButton *" << GetName() << " = new TGRadioButton(" << fParent->GetName() << ", \""
2074 << outext.ReplaceSpecialCppChars() << "\"";
2075
2076 // font + GC
2077 option = GetName() + 5; // unique digit id of the name
2078 TString parGC, parFont;
2079 parFont.Form("%s::GetDefaultFontStruct()", IsA()->GetName());
2080 parGC.Form("%s::GetDefaultGC()()", IsA()->GetName());
2081
2082 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
2083 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
2084 if (ufont) {
2085 ufont->SavePrimitive(out, option);
2086 parFont.Form("ufont->GetFontStruct()");
2087 }
2088
2089 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
2090 if (userGC) {
2091 userGC->SavePrimitive(out, option);
2092 parGC.Form("uGC->GetGC()");
2093 }
2094 }
2095
2096 if (GetOptions() == (kChildFrame)) {
2098 if (fNormGC == GetDefaultGC()()) {
2099 if (fWidgetId == -1) {
2100 out << ");\n";
2101 } else {
2102 out << "," << fWidgetId << ");\n";
2103 }
2104 } else {
2105 out << "," << fWidgetId << "," << parGC << ");\n";
2106 }
2107 } else {
2108 out << "," << fWidgetId << "," << parGC << "," << parFont << ");\n";
2109 }
2110 } else {
2111 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");\n";
2112 }
2113
2115 if (fState == kButtonDisabled) {
2117 out << " " << GetName() << "->SetDisabledAndSelected(kTRUE);\n";
2118 else
2119 out << " " << GetName() << "->SetDisabledAndSelected(kFALSE);\n";
2120 }
2121 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");\n";
2122 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << "," << fMTop << "," << fMBottom
2123 << ");\n";
2124 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");\n";
2125}
2126
2127////////////////////////////////////////////////////////////////////////////////
2128/// Create a menu button widget. The hotstring will be adopted and
2129/// deleted by the menu button. This constructor creates a
2130/// menubutton with a popup menu attached that appears when the
2131/// button for it is clicked. The popup menu is adopted.
2132
2134 TGPopupMenu *popmenu, Bool_t split, Int_t id,
2135 GContext_t norm, FontStruct_t fontstruct, UInt_t options)
2136 : TGTextButton(p, menulabel, id, norm, fontstruct, options)
2137{
2138 fFontStruct = fontstruct;
2139 fMBWidth = 16;
2140 fMenuLabel = new TGHotString(*menulabel);
2141 fPopMenu = popmenu;
2142 fPopMenu->fSplitButton = this;
2143 fSplit = split;
2144 fTMode = 0;
2145 fHKeycode = 0;
2148 fWidestLabel = "";
2149 fHeighestLabel = "";
2150
2151 // Find and set the correct size for the menu and the button.
2152 TGMenuEntry *entry = 0;
2153 TGHotString lstring(*fMenuLabel);
2154 TGHotString hstring(*fMenuLabel);
2155 const TList *list = fPopMenu->GetListOfEntries();
2156 UInt_t lwidth = 0, lheight = 0;
2157 UInt_t twidth = 0, theight = 0;
2158
2160 if (!font) {
2162 if (font) fFontStruct = font->GetFontStruct();
2163 }
2164
2165 if (font) font->ComputeTextLayout(lstring, lstring.GetLength(),
2167 &lwidth, &lheight);
2168
2169 TIter iter(list);
2170 entry = (TGMenuEntry *)iter.Next();
2171 while (entry != 0) {
2172 if (entry->GetType() == kMenuEntry) {
2173 const TGHotString string(*(entry->GetLabel()));
2174 if (font) font->ComputeTextLayout(string, string.GetLength(),
2176 &twidth, &theight);
2177 if(twidth > lwidth) {
2178 lstring = string;
2179 }
2180 if(theight > lheight) {
2181 hstring = string;
2182 }
2183 }
2184 entry = (TGMenuEntry *)iter.Next();
2185 }
2186 fWidestLabel = lstring;
2187 fHeighestLabel = hstring;
2188
2189 if (font) {
2190 UInt_t dummy = 0;
2191 font->ComputeTextLayout(lstring, lstring.GetLength(),
2193 &fTWidth, &dummy);
2194 font->ComputeTextLayout(hstring, hstring.GetLength(),
2196 &dummy, &fTHeight);
2197 }
2198 fTBWidth = fTWidth + 8;
2199 fHeight = fTHeight + 7;
2201
2203
2204 // Save the id of the 1st item on the menu.
2205 TIter iter1(list);
2206 do {
2207 entry = (TGMenuEntry *)iter1.Next();
2208 if ((entry) && (entry->GetStatus() & kMenuEnableMask) &&
2209 !(entry->GetStatus() & kMenuHideMask) &&
2210 (entry->GetType() != kMenuSeparator) &&
2211 (entry->GetType() != kMenuLabel)) break;
2212 entry = (TGMenuEntry *)iter1.Next();
2213 } while (entry);
2214 if (entry) fEntryId = entry->GetEntryId();
2215
2216 // An additional connection that is needed.
2217 fPopMenu->Connect("Activated(Int_t)", "TGSplitButton", this, "HandleMenu(Int_t)");
2219
2220 Init();
2221}
2222
2223
2224////////////////////////////////////////////////////////////////////////////////
2225/// Common initialization used by the different ctors.
2226
2228{
2229 Int_t hotchar;
2230
2232 fHKeycode = 0;
2234 fPrevStateOn =
2235 fStateOn = kFALSE;
2237
2239
2240 if ((hotchar = fLabel->GetHotChar()) != 0) {
2241 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
2243 if (main) {
2244 main->BindKey(this, fHKeycode, kKeyMod1Mask);
2245 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2246 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2248
2249 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2253 }
2254 }
2255 }
2258 wattr.fBitGravity = 5; // center
2259 wattr.fWinGravity = 1;
2260 gVirtualX->ChangeWindowAttributes(fId, &wattr);
2261
2262 // Make sure motion is detected too.
2264
2265 SetWindowName();
2266}
2267
2268////////////////////////////////////////////////////////////////////////////////
2269/// Delete a split button widget.
2270
2272{
2273 if (fPopMenu) delete fPopMenu;
2274 if (fMenuLabel) delete fMenuLabel;
2275}
2276
2277////////////////////////////////////////////////////////////////////////////////
2278/// Draw triangle (arrow) on which user can click to open Popup.
2279
2281{
2282 Point_t points[3];
2283
2284 points[0].fX = x;
2285 points[0].fY = y;
2286 points[1].fX = x + 5;
2287 points[1].fY = y;
2288 points[2].fX = x + 2;
2289 points[2].fY = y + 3;
2290
2291 gVirtualX->FillPolygon(fId, gc, points, 3);
2292}
2293
2294////////////////////////////////////////////////////////////////////////////////
2295/// Calculate the size of the button.
2296
2298{
2299 Int_t max_ascent, max_descent;
2301 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2302 fTHeight = max_ascent + max_descent;
2303
2304 fTBWidth = fTWidth + 8;
2305 fHeight = fTHeight + 7;
2306 fWidth = fTBWidth;
2307}
2308
2309////////////////////////////////////////////////////////////////////////////////
2310/// Handle mouse button event in case the button is split.
2311
2313{
2314 if (fState == kButtonDisabled) return kFALSE;
2315
2316 Bool_t activate = kFALSE;
2317 Bool_t bclick = kFALSE;
2318 static Bool_t mbpress = kFALSE;
2319 static Bool_t tbpress = kFALSE;
2320 static Bool_t outpress = kFALSE;
2321
2322 Bool_t inTB = (event->fX >= 0) && (event->fY >= 0) &&
2323 (event->fX <= (Int_t)fTBWidth) && (event->fY <= (Int_t)fHeight);
2324
2325 Bool_t inMB = (event->fX >= (Int_t)(fWidth -fMBWidth)) && (event->fY >= 0) &&
2326 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2327
2328 // We don't need to check the button number as GrabButton will
2329 // only allow button1 events
2330
2331 if (inTB) {
2332 if (event->fType == kButtonPress) {
2333 mbpress = kFALSE;
2334 tbpress = kTRUE;
2335 fgReleaseBtn = 0;
2336 if (fState == kButtonEngaged) {
2337 return kTRUE;
2338 }
2340 Pressed();
2341 } else { // ButtonRelease
2342 if (fMBState == kButtonDown) {
2344 }
2345 if (fState == kButtonEngaged && tbpress) {
2347 Released();
2348 bclick = kTRUE;
2349 } else if (fState == kButtonDown && tbpress) {
2350 tbpress = kFALSE;
2351 if (fStayDown) {
2352 bclick = kTRUE;
2354 fgReleaseBtn = 0;
2355 } else {
2356 bclick = kTRUE;
2358 Released();
2359 fgReleaseBtn = fId;
2360 }
2361 }else {
2363 }
2364 }
2365 } else if (inMB) {
2366 if (event->fType == kButtonPress) {
2367 fgReleaseBtn = 0;
2368 mbpress = kTRUE;
2369 tbpress = kFALSE;
2370 if (fMBState == kButtonEngaged) {
2371 return kTRUE;
2372 }
2374 MBPressed();
2377 } else { // ButtonRelease
2378 if (fState == kButtonDown) {
2380 }
2381 if (fMBState == kButtonEngaged && mbpress) {
2382 mbpress = kFALSE;
2385 MBReleased();
2386 MBClicked();
2387 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2388 } else if (fMBState == kButtonDown && mbpress) {
2389 MBClicked();
2392 fgReleaseBtn = 0;
2393 } else {
2395 }
2396 }
2397 } else {
2398 if (event->fType == kButtonPress) {
2399 fgReleaseBtn = 0;
2400 outpress = kTRUE;
2401 } else { // ButtonRelease
2402 if(outpress) {
2403 outpress = kFALSE;
2406 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2407 activate = kTRUE;
2408 }
2409 }
2410 }
2411 if (bclick) {
2412 Clicked();
2417 }
2418 if (activate) {
2419 TGMenuEntry *entry = fPopMenu->GetCurrent();
2420 if (entry) {
2421 if ((entry->GetStatus() & kMenuEnableMask) &&
2422 !(entry->GetStatus() & kMenuHideMask) &&
2423 (entry->GetType() != kMenuSeparator) &&
2424 (entry->GetType() != kMenuLabel)) {
2425 Int_t id = entry->GetEntryId();
2426 fPopMenu->Activated(id);
2427 }
2428 }
2429 }
2430 // if (mbclick) {
2431 // MBClicked();
2432 // SendMessage(fMsgWindow, MK_MSG(kC_COMMAND, kCM_BUTTON), fWidgetId,
2433 // (Longptr_t) fUserData);
2434 // fClient->ProcessLine(fCommand, MK_MSG(kC_COMMAND, kCM_BUTTON), fWidgetId,
2435 // (Longptr_t) fUserData);
2436 // }
2437 return kTRUE;
2438}
2439
2440////////////////////////////////////////////////////////////////////////////////
2441/// Handle mouse crossing event in case of split menu.
2442
2444{
2445 if (fTip) {
2446 if (event->fType == kEnterNotify)
2447 fTip->Reset();
2448 else
2449 fTip->Hide();
2450 }
2451
2452 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
2453
2454 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
2455 return kTRUE;
2456
2457 if (fState == kButtonEngaged || fState == kButtonDisabled) return kTRUE;
2458
2459 Bool_t inTB = (event->fX <= (Int_t)fTBWidth);
2460
2461 // Bool_t inMB = (event->fX >= (Int_t)(fWidth -fMBWidth)) && (event->fY >= 0) &&
2462 // (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2463
2464 if (event->fType == kEnterNotify) {
2465 if (inTB) {
2467 } else {
2468 if(fMBState == kButtonEngaged) return kTRUE;
2470 }
2471 } else {
2472 // kLeaveNotify
2473 if(fState == kButtonDown) {
2475 }
2476 if (fMBState == kButtonEngaged) return kTRUE;
2478 }
2479 return kTRUE;
2480}
2481
2482////////////////////////////////////////////////////////////////////////////////
2483/// Handle key event. This function will be called when the hotkey is hit.
2484
2486{
2487 if (fState == kButtonDisabled) return kFALSE;
2488
2489 Bool_t click = kFALSE;
2490
2491 if (event->fType == kGKeyPress) {
2492 gVirtualX->SetKeyAutoRepeat(kFALSE);
2493 } else {
2494 gVirtualX->SetKeyAutoRepeat(kTRUE);
2495 }
2496
2497 if (fTip && event->fType == kGKeyPress) fTip->Hide();
2498
2499 // We don't need to check the key number as GrabKey will only
2500 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
2501
2502 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
2503 if (fState == kButtonEngaged) return kTRUE;
2505 Pressed();
2506 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
2507 if (fState == kButtonEngaged) {
2509 Released();
2510 }
2511 if (fStayDown) {
2513 } else {
2515 Released();
2516 }
2517 click = kTRUE;
2518 }
2519 if (click) {
2520 Clicked();
2525 }
2526
2527 return kTRUE;
2528}
2529
2530////////////////////////////////////////////////////////////////////////////////
2531/// Popup the attached menu.
2532
2534{
2535 if (state) {
2536 Int_t ax, ay;
2537 Window_t wdummy;
2538
2539 if (fSplit) {
2540 Int_t n_entries = 0;
2541 TGMenuEntry *entry = 0;
2543
2544 while ((entry = (TGMenuEntry *) next())) {
2545 if ((entry->GetType() != kMenuSeparator) &&
2546 (entry->GetType() != kMenuLabel)) {
2547 n_entries++;
2548 }
2549 }
2550 if (n_entries <= 1) {
2551 Info("TGSplitButton", "Only one entry in the menu.");
2552 return;
2553 }
2554 }
2555
2556 gVirtualX->TranslateCoordinates(fId, fPopMenu->GetParent()->GetId(),
2557 0, 0, ax, ay, wdummy);
2558
2559 // place the menu just under the window:
2560 fPopMenu->PlaceMenu(ax-1, ay+fHeight, kTRUE, kFALSE); //kTRUE);
2561 BindKeys(kTRUE);
2563 } else {
2568 }
2569}
2570
2571////////////////////////////////////////////////////////////////////////////////
2572/// Draw the text button.
2573
2575{
2576 int x, y;
2578
2581
2582 if (fTMode & kTextLeft) {
2583 x = fMLeft + 4;
2584 } else if (fTMode & kTextRight) {
2585 x = fWidth - fTWidth -fMBWidth - fMRight - 4;
2586 } else {
2587 x = (fWidth - fTWidth -fMBWidth + fMLeft - fMRight) >> 1;
2588 }
2589
2590 if (fTMode & kTextTop) {
2591 y = fMTop + 3;
2592 } else if (fTMode & kTextBottom) {
2593 y = fHeight - fTHeight - fMBottom - 3;
2594 } else {
2595 y = (fHeight - fTHeight + fMTop - fMBottom) >> 1;
2596 }
2597
2598 if (fState == kButtonDown || fState == kButtonEngaged) { ++x; ++y; }
2599 if (fState == kButtonEngaged) {
2600 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
2601 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
2602 }
2603
2604 Int_t hotpos = fLabel->GetHotPos();
2605
2606 if (fState == kButtonDisabled) {
2608 TGGC *gc = pool->FindGC(fNormGC);
2609 if (gc) {
2610 Pixel_t fore = gc->GetForeground();
2613
2614 gc->SetForeground(hi);
2615 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
2616 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x + 1, y + 1, hotpos - 1);
2617
2618 gc->SetForeground(sh);
2619 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
2620 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
2621 gc->SetForeground(fore);
2622 }
2623 } else {
2624 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
2625 if (hotpos) fTLayout->UnderlineChar(fId, fNormGC, x, y, hotpos - 1);
2626 }
2627
2628 // Draw the parts of the button needed when a menu is attached.
2629
2630 // triangle position
2631 x = fWidth - 11;
2632 y = fHeight - 10;
2633
2634 if (fSplit) {
2635 // separator position
2636 Int_t lx = fWidth - fMBWidth;
2637 Int_t ly = 2;
2638 Int_t lh = fHeight - 2;
2639
2641 x++;
2642 y++;
2643 }
2644
2645 gVirtualX->DrawLine(fId, GetShadowGC()(), lx, ly + 2, lx, lh - 4);
2646 gVirtualX->DrawLine(fId, GetHilightGC()(), lx + 1, ly + 2, lx + 1, lh - 3);
2647 gVirtualX->DrawLine(fId, GetHilightGC()(), lx, lh - 3, lx + 1, lh - 3);
2648
2649 if (fMBState == kButtonEngaged) {
2650 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), fTBWidth + 1, 1, fMBWidth - 3, fHeight - 3);
2651 }
2652
2653 if (fMBState == kButtonDisabled) {
2654 DrawTriangle(GetHilightGC()(), x + 1, y + 1);
2655 DrawTriangle(GetShadowGC()(), x, y);
2656 } else {
2658 }
2659
2660 } else {
2661 x -= 2;
2663 x++;
2664 y++;
2665 }
2666 if (fState == kButtonDisabled) {
2667 DrawTriangle(GetHilightGC()(), x + 1, y + 1);
2668 DrawTriangle(GetShadowGC()(), x, y);
2669 } else {
2671 }
2672 }
2673
2674}
2675
2676////////////////////////////////////////////////////////////////////////////////
2677/// If on kTRUE bind arrow, popup menu hot keys, otherwise
2678/// remove key bindings.
2679
2681{
2682 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Up), kAnyModifier, on);
2683 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Down), kAnyModifier, on);
2684 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Enter), kAnyModifier, on);
2685 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Return), kAnyModifier, on);
2686 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Escape), kAnyModifier, on);
2687}
2688
2689////////////////////////////////////////////////////////////////////////////////
2690/// If on kTRUE bind Menu hot keys, otherwise remove key bindings.
2691
2693{
2694 TGMenuEntry *e = 0;
2696
2697 while ((e = (TGMenuEntry*)next())) {
2698 Int_t hot = 0;
2699 if (e->GetLabel()) {
2700 hot = e->GetLabel()->GetHotChar();
2701 }
2702 if (!hot) continue;
2703 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), 0, on);
2704 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask, on);
2705 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyLockMask, on);
2706 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyMod2Mask, on);
2707 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyLockMask, on);
2708 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyMod2Mask, on);
2709 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyLockMask | kKeyMod2Mask, on);
2710 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyLockMask | kKeyMod2Mask, on);
2711 }
2712}
2713
2714////////////////////////////////////////////////////////////////////////////////
2715/// returns default size
2716
2723
2724////////////////////////////////////////////////////////////////////////////////
2725/// Set new button text.
2726
2728{
2729 Int_t hotchar;
2730 static Bool_t longlabeltip = kFALSE;
2732
2734 if (!font) {
2736 if (font) fFontStruct = font->GetFontStruct();
2737 }
2738
2739 UInt_t width = 0, bwidth = 0, dummy;
2740 if (font) {
2741 font->ComputeTextLayout(new_label->GetString(), new_label->GetLength(),
2743 &width, &dummy);
2746 &bwidth, &dummy);
2747 }
2748 if (width > bwidth) {
2749 if (!fTip) {
2750 SetToolTipText(new_label->GetString());
2751 longlabeltip = kTRUE;
2752 }
2753 Info("TGSplitbutton", "Length of new label to long, label truncated.");
2754 new_label->Resize(fWidestLabel.GetLength());
2755 } else if (new_label->GetLength() <= fWidestLabel.GetLength() && longlabeltip) {
2756 if (fTip) delete fTip;
2757 fTip = 0;
2758 longlabeltip = kFALSE;
2759 }
2760
2761 if (fLabel) {
2762 if (main && fHKeycode) {
2763 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
2764 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2765 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2766 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
2767
2768 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2769 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
2770 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
2772 }
2773 delete fLabel;
2774 }
2775
2776 fLabel = new_label;
2777 if ((hotchar = fLabel->GetHotChar()) != 0) {
2778 if (main && ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0)) {
2779 main->BindKey(this, fHKeycode, kKeyMod1Mask);
2780 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2781 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2783
2784 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2788 }
2789 }
2790
2791 Layout();
2792}
2793
2794////////////////////////////////////////////////////////////////////////////////
2795/// Set new button text.
2796
2797void TGSplitButton::SetText(const TString &new_label)
2798{
2799 SetText(new TGHotString(new_label));
2800}
2801
2802////////////////////////////////////////////////////////////////////////////////
2803/// Changes text font.
2804/// If global is kTRUE font is changed globally, otherwise - locally.
2805
2807{
2808 if (font != fFontStruct) {
2809 FontH_t v = gVirtualX->GetFontHandle(font);
2810 if (!v) return;
2811
2812 fFontStruct = font;
2814 TGGC *gc = pool->FindGC(fNormGC);
2815
2816 if ((gc) && !global) {
2817 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
2819 }
2820 if (gc) {
2821 gc->SetFont(v);
2822 fNormGC = gc->GetGC();
2823 }
2824 fClient->NeedRedraw(this);
2825 }
2826}
2827
2828////////////////////////////////////////////////////////////////////////////////
2829/// Changes text font specified by name.
2830/// If global is true color is changed globally, otherwise - locally.
2831
2832void TGSplitButton::SetFont(const char *fontName, Bool_t global)
2833{
2834 TGFont *font = fClient->GetFont(fontName);
2835 if (font) {
2836 SetFont(font->GetFontStruct(), global);
2837 }
2838}
2839
2840////////////////////////////////////////////////////////////////////////////////
2841/// Set the state of the Menu Button part
2842
2844{
2845 if (state != fMBState) {
2846 fMBState = state;
2847 DoRedraw();
2848 }
2849}
2850
2851////////////////////////////////////////////////////////////////////////////////
2852/// Set the split status of a button.
2853
2855{
2856 if(split) {
2857 fStayDown = kFALSE;
2858 Disconnect(fPopMenu, "PoppedDown()");
2859 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "SetMBState(=kButtonUp)");
2860 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "MBReleased()");
2861
2863 if (entry) {
2864 TGHotString *tmp = new TGHotString(*(entry->GetLabel()));
2865 SetText(tmp);
2866
2867 TString str("ItemClicked(=");
2868 str += entry->GetEntryId();
2869 str += ")";
2870 Connect("Clicked()", "TGSplitButton", this, str);
2871 fEntryId = entry->GetEntryId();
2873 }
2874 } else {
2875 fStayDown = kTRUE;
2876 Disconnect(fPopMenu, "PoppedDown()");
2877 Disconnect(this, "Clicked()", this);
2878 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "SetState(=kButtonUp)");
2879 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "Released()");
2881 TGHotString *tmp = new TGHotString(*fMenuLabel);
2882 SetText(tmp);
2883 }
2884
2885 fSplit = split;
2886 DoRedraw();
2887}
2888
2889////////////////////////////////////////////////////////////////////////////////
2890/// Handle button events.
2891
2893{
2894 if (fState == kButtonDisabled) return kFALSE;
2895
2896 if (fSplit) return HandleSButton(event);
2897
2898 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
2899 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2900
2901 Bool_t activate = kFALSE;
2902 Bool_t click = kFALSE;
2903
2904 if (in) {
2905 if (event->fType == kButtonPress) {
2906 fgReleaseBtn = 0;
2907 if (fState == kButtonEngaged) {
2908 return kTRUE;
2909 }
2911 Pressed();
2914 } else { // ButtonRelease
2915 if (fState == kButtonEngaged) {
2918 Released();
2919 click = kTRUE;
2920 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2921 } else {
2922 click = (fState == kButtonDown);
2923 if (click && fStayDown) {
2926 fgReleaseBtn = 0;
2927 } else {
2929 Released();
2930 fgReleaseBtn = fId;
2931 }
2932 }
2934 }
2935 } else {
2936 if (event->fType == kButtonPress) {
2937 fgReleaseBtn = 0;
2938 } else { // ButtonRelease
2941 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2942 activate = kTRUE;
2943 }
2944 }
2945 if (click) {
2946 Clicked();
2951 }
2952 if (activate && !fKeyNavigate) {
2953 TGMenuEntry *entry = fPopMenu->GetCurrent();
2954 if (entry) {
2955 if ((entry->GetStatus() & kMenuEnableMask) &&
2956 !(entry->GetStatus() & kMenuHideMask) &&
2957 (entry->GetType() != kMenuSeparator) &&
2958 (entry->GetType() != kMenuLabel)) {
2959 Int_t id = entry->GetEntryId();
2960 fPopMenu->Activated(id);
2961 }
2962 }
2963 }
2964
2965 return kTRUE;
2966
2967}
2968
2969////////////////////////////////////////////////////////////////////////////////
2970/// Handle mouse crossing event.
2971
2973{
2974 if (fSplit) {
2975 return HandleSCrossing(event);
2976 } else {
2978 }
2979}
2980
2981////////////////////////////////////////////////////////////////////////////////
2982/// Handle key event. This function will be called when the hotkey is hit.
2983
2985{
2986 Bool_t click = kFALSE;
2987
2988 if (fState == kButtonDisabled) return kTRUE;
2989
2990 if(fSplit) return HandleSKey(event);
2991
2992 if (event->fType == kGKeyPress) {
2993 gVirtualX->SetKeyAutoRepeat(kFALSE);
2994 } else {
2995 gVirtualX->SetKeyAutoRepeat(kTRUE);
2996 }
2997
2998 if (fTip && event->fType == kGKeyPress) fTip->Hide();
2999
3000 // We don't need to check the key number as GrabKey will only
3001 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
3002 if (event->fState & kKeyMod1Mask) {
3003 RequestFocus();
3005 if (event->fType == kGKeyPress) {
3006 if (fState == kButtonEngaged) return kTRUE;
3008 Pressed();
3009 } else if (event->fType == kKeyRelease) {
3010 click = kTRUE;
3011 if (fState == kButtonEngaged) {
3014 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3015 } else if (fState == kButtonDown && fStayDown) {
3020 TGMenuEntry *entry = 0;
3022
3023 while ((entry = (TGMenuEntry *) next())) {
3024 if ((entry->GetStatus() & kMenuEnableMask) &&
3025 !(entry->GetStatus() & kMenuHideMask) &&
3026 (entry->GetType() != kMenuSeparator) &&
3027 (entry->GetType() != kMenuLabel)) break;
3028 }
3029 if (entry) {
3030 fPopMenu->Activate(entry);
3031 }
3032 } else {
3033 Released();
3035 }
3036 }
3037 } else {
3039 if (event->fType == kGKeyPress) {
3040 Event_t ev;
3041 ev.fX = ev.fY = 1;
3042 UInt_t keysym;
3043 char tmp[2];
3044
3045 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
3046
3047 TGMenuEntry *ce = 0;
3049
3050 while ((ce = (TGMenuEntry*)next())) {
3051 UInt_t hot = 0;
3052 if (ce->GetLabel()) hot = ce->GetLabel()->GetHotChar();
3053 if (!hot || (hot != keysym)) continue;
3054
3055 fPopMenu->Activate(ce);
3056 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3058 ev.fType = kButtonRelease;
3059 ev.fWindow = fPopMenu->GetId();
3061 return HandleButton(&ev);
3062 }
3063
3064 ce = fPopMenu->GetCurrent();
3065
3066 switch ((EKeySym)keysym) {
3067 case kKey_Up:
3068 if (ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->Before(ce);
3069 while (ce && ((ce->GetType() == kMenuSeparator) ||
3070 (ce->GetType() == kMenuLabel) ||
3071 !(ce->GetStatus() & kMenuEnableMask))) {
3073 }
3074 if (!ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->Last();
3075 break;
3076 case kKey_Down:
3077 if (ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->After(ce);
3078 while (ce && ((ce->GetType() == kMenuSeparator) ||
3079 (ce->GetType() == kMenuLabel) ||
3080 !(ce->GetStatus() & kMenuEnableMask))) {
3082 }
3083 if (!ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->First();
3084 break;
3085 case kKey_Enter:
3086 case kKey_Return:
3087 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3089 ev.fType = kButtonRelease;
3090 ev.fWindow = fPopMenu->GetId();
3092 HandleButton(&ev);
3093 break;
3094 case kKey_Escape:
3095 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3097 break;
3098 default:
3099 break;
3100 }
3101 if (ce) fPopMenu->Activate(ce);
3102 }
3103 }
3104 if (click) {
3105 Clicked();
3110 }
3111
3112 return kTRUE;
3113}
3114
3115////////////////////////////////////////////////////////////////////////////////
3116/// Handle a motion event in a TGSplitButton.
3117
3119{
3120 if (fKeyNavigate) return kTRUE;
3121
3122 if (fSplit) {
3123 if (fMBState == kButtonDown) {
3124 if (event->fX < (Int_t)fTBWidth) {
3127 }
3128 } else if (fState == kButtonDown) {
3129 if (event->fX > (Int_t)fTBWidth) {
3132 }
3133
3134 }
3135 }
3136 return kTRUE;
3137}
3138
3139////////////////////////////////////////////////////////////////////////////////
3140/// layout text button
3141
3143{
3144 UInt_t dummya = 0, dummyb = 0;
3146
3148 if (!font) {
3150 if (font) fFontStruct = font->GetFontStruct();
3151 }
3152 if (font) {
3154 fLabel->GetLength(),
3156 &dummya, &dummyb);
3157 UInt_t dummy = 0;
3160 &fTWidth, &dummy);
3163 &dummy, &fTHeight);
3164 }
3165 fTBWidth = fTWidth + 8;
3167 fHeight = fTHeight + 7;
3168 fClient->NeedRedraw(this);
3169}
3170
3171////////////////////////////////////////////////////////////////////////////////
3172/// Handle a menu item activation.
3173
3175{
3177
3178 if (fSplit) {
3180 Disconnect(this, "Clicked()", this);
3181 // connect clicked to the ItemClicked signal with the correct id
3182 Connect("Clicked()", "TGSplitButton", this,
3183 TString::Format("ItemClicked(=%d)", id));
3184
3185 // reenable hidden entries
3186 const TList *list = fPopMenu->GetListOfEntries();
3187 TIter iter(list);
3189 TGMenuEntry *entry = fPopMenu->GetEntry(id);
3190 if (entry) {
3191 TGHotString *label = entry->GetLabel();
3192 TGHotString *tmp = new TGHotString(*label);
3193 SetText(tmp);
3194 }
3195 fPopMenu->HideEntry(id);
3196 if (entry) fEntryId = entry->GetEntryId();
3197 } else {
3199 ItemClicked(id);
3200 }
3201 DoRedraw();
3202}
@ kGKeyPress
Definition GuiTypes.h:61
@ kButtonRelease
Definition GuiTypes.h:61
@ kButtonPress
Definition GuiTypes.h:61
@ kEnterNotify
Definition GuiTypes.h:62
@ kKeyRelease
Definition GuiTypes.h:61
@ kLeaveNotify
Definition GuiTypes.h:62
const Mask_t kWABitGravity
Definition GuiTypes.h:145
const Mask_t kGCBackground
Definition GuiTypes.h:290
const Mask_t kGCForeground
Definition GuiTypes.h:289
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:31
const Mask_t kGCTile
Definition GuiTypes.h:297
const Mask_t kKeyLockMask
Definition GuiTypes.h:197
const Mask_t kButtonPressMask
Definition GuiTypes.h:162
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index)
Definition GuiTypes.h:36
const Mask_t kKeyMod1Mask
typically the Alt key
Definition GuiTypes.h:199
const Mask_t kGCFillStyle
Definition GuiTypes.h:295
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kWAWinGravity
Definition GuiTypes.h:146
const Mask_t kAnyModifier
Definition GuiTypes.h:211
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:39
const Mask_t kButton1Mask
Definition GuiTypes.h:204
const Mask_t kPointerMotionMask
Definition GuiTypes.h:164
const Mask_t kKeyShiftMask
Definition GuiTypes.h:196
@ kChildFrame
Definition GuiTypes.h:380
@ kRaisedFrame
Definition GuiTypes.h:385
@ kSunkenFrame
Definition GuiTypes.h:384
@ kDoubleBorder
Definition GuiTypes.h:386
@ kFixedWidth
Definition GuiTypes.h:388
@ kFixedHeight
Definition GuiTypes.h:390
@ kFixedSize
Definition GuiTypes.h:391
@ kOwnBackground
Definition GuiTypes.h:392
const Handle_t kNone
Definition GuiTypes.h:89
const Mask_t kKeyMod2Mask
typically mod on numeric keys
Definition GuiTypes.h:200
const Mask_t kButton3Mask
Definition GuiTypes.h:206
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:169
@ kFillTiled
Definition GuiTypes.h:52
const Mask_t kButton2Mask
Definition GuiTypes.h:205
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:163
const Mask_t kGCGraphicsExposures
Definition GuiTypes.h:303
const Mask_t kEnterWindowMask
Definition GuiTypes.h:168
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
@ kButton1
Definition GuiTypes.h:215
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:40
EKeySym
Definition KeySymbols.h:25
@ kKey_Down
Definition KeySymbols.h:43
@ 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:507
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
cudaEvent_t event
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
EButtonState
Definition TGButton.h:52
@ kButtonDown
Definition TGButton.h:54
@ kButtonDisabled
Definition TGButton.h:56
@ kButtonUp
Definition TGButton.h:53
@ kButtonEngaged
Definition TGButton.h:55
#define gClient
Definition TGClient.h:157
@ kDeepCleanup
Definition TGFrame.h:42
@ kMenuHideMask
Definition TGMenu.h:29
@ kMenuEnableMask
Definition TGMenu.h:25
@ kMenuEntry
Definition TGMenu.h:38
@ kMenuSeparator
Definition TGMenu.h:36
@ kMenuLabel
Definition TGMenu.h:37
@ kTextCenterX
Definition TGWidget.h:25
@ kTextLeft
Definition TGWidget.h:23
@ kTextBottom
Definition TGWidget.h:27
@ kTextTop
Definition TGWidget.h:26
@ kTextRight
Definition TGWidget.h:24
@ kTextCenterY
Definition TGWidget.h:28
@ kWidgetIsEnabled
Definition TGWidget.h:37
@ kWidgetWantFocus
Definition TGWidget.h:35
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 mask
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 on
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t width
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 style
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:142
#define hi
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define gVirtualX
Definition TVirtualX.h:379
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kC_COMMAND
@ kCM_BUTTON
@ kCM_RADIOBUTTON
@ kCM_CHECKBUTTON
static Pixmap_t GetPixmap(TImage *timg)
Returns image pixmap.
Definition TASUtils.cxx:135
static Pixmap_t GetMask(TImage *timg)
Returns image mask pixmap (alpha channel).
Definition TASUtils.cxx:181
static std::unique_ptr< TImage > FromPixmap(Pixmap_t pxm, Pixmap_t mask)
Create image from pixmap.
Definition TASUtils.cxx:271
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4995
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
Organizes TGButton widgets in a group.
static TClass * Class()
virtual void Remove(TGButton *button)
Removes a button from the button group.
virtual Int_t Insert(TGButton *button, int id=-1)
Inserts a button with the identifier id into the button group.
A button abstract base class.
Definition TGButton.h:68
virtual void SetGroup(TGButtonGroup *gr)
Sets new button-group for this button.
Definition TGButton.cxx:317
virtual void Pressed()
Definition TGButton.h:133
static const TGGC & GetDefaultGC()
Return default graphics context.
Definition TGButton.cxx:465
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:440
virtual EButtonState GetState() const
Definition TGButton.h:112
UInt_t fStyle
button style (modern or classic)
Definition TGButton.h:83
TGButtonGroup * fGroup
button group this button belongs to
Definition TGButton.h:80
Pixel_t fBgndColor
actual background color
Definition TGButton.h:81
static const TGGC & GetHibckgndGC()
Return graphics context for highlighted frame background.
Definition TGButton.cxx:475
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition TGButton.cxx:305
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a button widget as a C++ statement(s) on output stream out.
static Window_t fgReleaseBtn
Definition TGButton.h:91
Pixel_t fHighColor
highlight color
Definition TGButton.h:82
virtual void Released()
Definition TGButton.h:134
Bool_t HandleButton(Event_t *event) override
Handle mouse button event.
Definition TGButton.cxx:325
virtual void EmitSignals(Bool_t wasUp)
Emit button signals.
Definition TGButton.cxx:380
UInt_t fTWidth
button width
Definition TGButton.h:73
UInt_t fTHeight
button height
Definition TGButton.h:74
virtual void SetStyle(UInt_t newstyle)
Set the button style (modern or classic).
Definition TGButton.cxx:266
void * fUserData
pointer to user data structure
Definition TGButton.h:78
static const TGGC * fgHibckgndGC
Definition TGButton.h:89
virtual Bool_t IsToggleButton() const
Definition TGButton.h:121
virtual void Clicked()
Definition TGButton.h:135
TGButton(const TGButton &)=delete
EButtonState fState
button state
Definition TGButton.h:75
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:454
static const TGGC * fgDefaultGC
Definition TGButton.h:88
~TGButton() override
Delete button.
Definition TGButton.cxx:216
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:230
TGToolTip * fTip
tool tip associated with button
Definition TGButton.h:79
virtual void Toggled(Bool_t on)
Definition TGButton.h:136
virtual Bool_t IsDown() const
Definition TGButton.cxx:296
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
Definition TGButton.cxx:399
Bool_t fStayDown
true if button has to stay down
Definition TGButton.h:76
GContext_t fNormGC
graphics context used for drawing button
Definition TGButton.h:77
const TGPicture * fOff
button OFF picture
Definition TGButton.h:274
static const TGFont * fgDefaultFont
Definition TGButton.h:283
static const TGGC * fgDefaultGC
Definition TGButton.h:284
Bool_t HandleKey(Event_t *event) override
Handle key event. This function will be called when the hotkey is hit.
const TGPicture * fOn
button ON picture
Definition TGButton.h:273
void Init()
Common check button initialization.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event.
static const TGGC & GetDefaultGC()
Return default graphics context.
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
virtual void SetDisabledAndSelected(Bool_t)
Set the state of a check button to disabled and either on or off.
virtual Bool_t IsDisabledAndSelected() const
Definition TGButton.h:312
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
TClass * IsA() const override
Definition TGButton.h:317
~TGCheckButton() override
Delete a check button.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a check button widget as a C++ statement(s) on output stream out.
TGCheckButton(const TGCheckButton &)=delete
void EmitSignals(Bool_t wasUp=kTRUE) override
Emit signals.
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
EButtonState fPrevState
previous check button state
Definition TGButton.h:272
void DoRedraw() override
Draw the check button widget.
const TGPicture * fDisOff
button disabled and was OFF picture
Definition TGButton.h:276
const TGPicture * fDisOn
button disabled and was ON picture
Definition TGButton.h:275
TGDimension GetDefaultSize() const override
default size
void PSetState(EButtonState state, Bool_t emit)
Set check button state.
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:234
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition TGClient.cxx:923
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:357
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
TGGCPool * GetGCPool() const
Definition TGClient.h:132
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:381
TGPicturePool * GetPicturePool() const
Definition TGClient.h:126
TGFontPool * GetFontPool() const
Definition TGClient.h:137
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:317
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get the specified font.
Definition TGFont.cxx:1555
TGFont * FindFont(FontStruct_t font) const
Find font based on its font struct. Returns 0 if font is not found.
Definition TGFont.cxx:1741
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
FontStruct_t GetFontStruct() const
Definition TGFont.h:184
void SavePrimitive(std::ostream &out, Option_t *="") override
Save the used font as a C++ statement(s) on output stream out.
Definition TGFont.cxx:1881
TGTextLayout * ComputeTextLayout(const char *string, Int_t numChars, Int_t wrapLength, Int_t justify, Int_t flags, UInt_t *width, UInt_t *height) const
Computes the amount of screen space needed to display a multi-line, justified string of text.
Definition TGFont.cxx:658
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:315
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:254
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:333
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:599
UInt_t fHeight
frame height
Definition TGFrame.h:88
Int_t fBorderWidth
frame border width
Definition TGFrame.h:93
void DoRedraw() override
Redraw the frame.
Definition TGFrame.cxx:424
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:749
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:677
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2513
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:639
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:759
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:227
static Window_t fgDbw
Definition TGFrame.h:113
UInt_t GetWidth() const
Definition TGFrame.h:226
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition TGFrame.cxx:2472
Pixel_t fBackground
frame background color
Definition TGFrame.h:95
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get the best matching graphics context depending on values.
Definition TGGC.cxx:969
void FreeGC(const TGGC *gc)
Delete graphics context if it is not used anymore.
Definition TGGC.cxx:900
TGGC * FindGC(const TGGC *gc)
Find graphics context. Returns 0 in case gc is not found.
Definition TGGC.cxx:933
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
GContext_t GetGC() const
Definition TGGC.h:41
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save graphics context info as a C++ statement(s) on output stream out.
Definition TGGC.cxx:619
Pixel_t GetForeground() const
Definition TGGC.h:73
TGHotString is a string with a "hot" character underlined.
Definition TGString.h:42
Int_t GetHotPos() const
Definition TGString.h:58
Int_t GetHotChar() const
Definition TGString.h:57
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
This class contains all information about a menu entry.
Definition TGMenu.h:57
TGHotString * GetLabel() const
Definition TGMenu.h:89
virtual Int_t GetStatus() const
Definition TGMenu.h:86
EMenuEntryType GetType() const
Definition TGMenu.h:87
Int_t GetEntryId() const
Definition TGMenu.h:83
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 void SetPicture(const TGPicture *new_pic)
Change a picture in a picture button.
virtual void CreateDisabledPicture()
Creates disabled picture.
virtual void SetDisabledPicture(const TGPicture *pic)
Changes disabled picture.
TClass * IsA() const override
Definition TGButton.h:260
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a picture button widget as a C++ statement(s) on output stream out.
const TGPicture * fPicD
picture shown when button disabled
Definition TGButton.h:232
const TGPicture * fPic
picture to be put in button
Definition TGButton.h:231
~TGPictureButton() override
Destructor.
TGPictureButton(const TGPictureButton &)=delete
void DoRedraw() override
Redraw picture button.
Bool_t fOwnDisabledPic
kTRUE if disabled picture was autogenerated
Definition TGButton.h:233
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition TGPicture.cxx:81
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
Pixmap_t GetMask() const
Definition TGPicture.h:55
void Draw(Option_t *="") override
Default Draw method for all objects.
Definition TGPicture.h:46
UInt_t GetHeight() const
Definition TGPicture.h:53
const char * GetName() const override
Returns name of object.
Definition TGPicture.h:51
Pixmap_t GetPicture() const
Definition TGPicture.h:54
UInt_t GetWidth() const
Definition TGPicture.h:52
This class creates a popup menu object.
Definition TGMenu.h:110
virtual void HideEntry(Int_t id)
Hide entry (hidden entries are not shown in the menu).
Definition TGMenu.cxx:1748
void Activate(Bool_t) override
Definition TGMenu.h:209
virtual TGMenuEntry * GetEntry(Int_t id)
Find entry with specified id.
Definition TGMenu.cxx:1894
TGSplitButton * fSplitButton
split button (if any)
Definition TGMenu.h:134
virtual void EnableEntry(Int_t id)
Enable entry. By default entries are enabled.
Definition TGMenu.cxx:1702
virtual Int_t EndMenu(void *&userData)
Close menu and return ID of selected menu item.
Definition TGMenu.cxx:1286
virtual TGMenuEntry * GetCurrent() const
Definition TGMenu.h:198
virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
Popup a popup menu.
Definition TGMenu.cxx:1238
const TList * GetListOfEntries() const
Definition TGMenu.h:200
virtual void Activated(Int_t id)
Definition TGMenu.h:219
const TGPicture * fOn
button ON picture
Definition TGButton.h:329
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
static const TGGC * fgDefaultGC
Definition TGButton.h:340
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set radio button state.
void DoRedraw() override
Draw a radio button.
const TGPicture * fDisOn
button disabled and was ON picture
Definition TGButton.h:331
Bool_t HandleButton(Event_t *event) override
Handle mouse button event.
TClass * IsA() const override
Definition TGButton.h:374
EButtonState fPrevState
previous radio button state
Definition TGButton.h:328
void EmitSignals(Bool_t wasUp=kTRUE) override
Emit signals.
static const TGGC & GetDefaultGC()
Return default graphics context.
const TGPicture * fDisOff
button disabled and was OFF picture
Definition TGButton.h:332
static const TGFont * fgDefaultFont
Definition TGButton.h:339
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
virtual Bool_t IsDisabledAndSelected() const
Definition TGButton.h:371
virtual void SetDisabledAndSelected(Bool_t)
Set the state of a radio button to disabled and either on or off.
const TGPicture * fOff
button OFF picture
Definition TGButton.h:330
~TGRadioButton() override
Delete a radio button.
void PSetState(EButtonState state, Bool_t emit)
Set radio button state.
void Init()
Common radio button initialization.
Bool_t HandleKey(Event_t *event) override
Handle key event. This function will be called when the hotkey is hit.
TGDimension GetDefaultSize() const override
default size
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a radio button widget as a C++ statement(s) on output stream out.
TGRadioButton(const TGRadioButton &)=delete
Cursor_t GetGrabCursor() const
TGGCPool * GetGCPool() const
void CalcSize()
Calculate the size of the button.
virtual void ItemClicked(Int_t id)
Definition TGButton.h:441
Bool_t HandleSKey(Event_t *event)
Handle key event. This function will be called when the hotkey is hit.
Bool_t HandleMotion(Event_t *event) override
Handle a motion event in a TGSplitButton.
~TGSplitButton() override
Delete a split button widget.
TGPopupMenu * fPopMenu
pointer to popup menu
Definition TGButton.h:400
void DrawTriangle(const GContext_t gc, Int_t x, Int_t y)
Draw triangle (arrow) on which user can click to open Popup.
void Layout() override
layout text button
Int_t fEntryId
Id of the currently active menu entry.
Definition TGButton.h:401
Bool_t HandleButton(Event_t *event) override
Handle button events.
Bool_t fSplit
kTRUE if menu is in split mode
Definition TGButton.h:396
virtual void MBClicked()
Definition TGButton.h:440
EButtonState fMBState
state for menu button in split mode
Definition TGButton.h:397
TGSplitButton(const TGSplitButton &)=delete
void Init()
Common initialization used by the different ctors.
Bool_t HandleSButton(Event_t *event)
Handle mouse button event in case the button is split.
void BindKeys(Bool_t on=kTRUE)
If on kTRUE bind arrow, popup menu hot keys, otherwise remove key bindings.
Cursor_t fDefaultCursor
Default Cursor.
Definition TGButton.h:403
void SetMenuState(Bool_t state)
Popup the attached menu.
UInt_t fMBWidth
width of menu button
Definition TGButton.h:399
TGDimension GetDefaultSize() const override
returns default size
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
Bool_t HandleSCrossing(Event_t *event)
Handle mouse crossing event in case of split menu.
void BindMenuKeys(Bool_t on=kTRUE)
If on kTRUE bind Menu hot keys, otherwise remove key bindings.
void SetFont(FontStruct_t font, Bool_t global=kFALSE) override
Changes text font.
Bool_t HandleKey(Event_t *event) override
Handle key event. This function will be called when the hotkey is hit.
virtual void MBReleased()
Definition TGButton.h:439
TGHotString * fMenuLabel
Label of the menu;.
Definition TGButton.h:402
void HandleMenu(Int_t id)
Handle a menu item activation.
void DoRedraw() override
@]
TGString fHeighestLabel
highest label that can be on the button
Definition TGButton.h:406
UInt_t fTBWidth
width of text button
Definition TGButton.h:398
virtual void MBPressed()
Definition TGButton.h:438
virtual void SetMBState(EButtonState state)
Set the state of the Menu Button part.
Bool_t fKeyNavigate
kTRUE if key navigation is being used
Definition TGButton.h:404
virtual void SetSplit(Bool_t split)
Set the split status of a button.
TGString fWidestLabel
longest label that can be on the button
Definition TGButton.h:405
void SetText(TGHotString *new_label) override
Set new button text.
Int_t GetLength() const
Definition TGString.h:29
const char * GetString() const
Definition TGString.h:30
Yield an action as soon as it is clicked.
Definition TGButton.h:142
void Init()
Common initialization used by the different ctors.
Definition TGButton.cxx:536
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
Definition TGButton.cxx:864
void Layout() override
layout text button
Definition TGButton.cxx:619
Bool_t HandleKey(Event_t *event) override
Handle key event. This function will be called when the hotkey is hit.
Definition TGButton.cxx:810
Int_t fMTop
Definition TGButton.h:148
TClass * IsA() const override
Definition TGButton.h:224
Int_t fMBottom
Definition TGButton.h:149
virtual void SetTextJustify(Int_t tmode)
Set text justification.
Definition TGButton.cxx:690
Bool_t fHasOwnFont
Definition TGButton.h:155
Bool_t fStateOn
Definition TGButton.h:156
Int_t fHKeycode
Definition TGButton.h:152
virtual void SetText(TGHotString *new_label)
Set new button text.
Definition TGButton.cxx:639
TGTextButton(const TGTextButton &)=delete
static const TGFont * fgDefaultFont
Definition TGButton.h:159
Int_t fMRight
Definition TGButton.h:147
TGDimension GetDefaultSize() const override
returns default size
Definition TGButton.cxx:854
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a text button widget as a C++ statement(s) on output stream out.
TGHotString * fLabel
Definition TGButton.h:145
Bool_t HasOwnFont() const
Returns kTRUE if text attributes are unique, returns kFALSE if text attributes are shared (global).
Definition TGButton.cxx:933
Bool_t fPrevStateOn
Definition TGButton.h:157
virtual void SetFont(FontStruct_t font, Bool_t global=kFALSE)
Changes text font.
Definition TGButton.cxx:875
Int_t fTMode
Definition TGButton.h:150
~TGTextButton() override
Delete a text button widget.
Definition TGButton.cxx:590
void DoRedraw() override
Draw the text button.
Definition TGButton.cxx:742
Int_t fWrapLength
Definition TGButton.h:151
TGTextLayout * fTLayout
Definition TGButton.h:153
FontStruct_t fFontStruct
Definition TGButton.h:154
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition TGButton.cxx:913
Int_t fMLeft
Definition TGButton.h:146
void DrawText(Drawable_t dst, GContext_t gc, Int_t x, Int_t y, Int_t firstChar, Int_t lastChar) const
Use the information in the TGTextLayout object to display a multi-line, justified string of text.
Definition TGFont.cxx:920
void UnderlineChar(Drawable_t dst, GContext_t gc, Int_t x, Int_t y, Int_t underline) const
Use the information in the TGTextLayout object to display an underline below an individual character.
Definition TGFont.cxx:967
A tooltip can be a one or multiple lines help text that is displayed in a window when the mouse curso...
Definition TGToolTip.h:24
void Hide()
Hide tool tip window.
const TGString * GetText() const
Get the tool tip text.
void Reset()
Reset tool tip popup delay timer.
Int_t fWidgetId
the widget id (used for event processing)
Definition TGWidget.h:46
TString fCommand
command to be executed
Definition TGWidget.h:49
Int_t fWidgetFlags
widget status flags (OR of EWidgetStatus)
Definition TGWidget.h:47
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:153
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:233
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
virtual Int_t MustCleanup() const
Definition TGWindow.h:116
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:130
const TGWindow * GetParent() const
Definition TGWindow.h:83
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:337
TClass * IsA() const override
Definition TGWindow.h:128
virtual void Option_t *static TImage * Create()
Create an image.
Definition TImage.cxx:34
TObject * Next()
A doubly linked list.
Definition TList.h:38
TObject * After(const TObject *obj) const override
Returns the object after object obj.
Definition TList.cxx:460
TObject * Before(const TObject *obj) const override
Returns the object before object obj.
Definition TList.cxx:501
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:823
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:789
SCoord_t fY
Definition TPoint.h:36
SCoord_t fX
Definition TPoint.h:35
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
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
void AddReference()
Definition TRefCnt.h:40
Basic string class.
Definition TString.h:137
Ssiz_t Length() const
Definition TString.h:426
TString & Insert(Ssiz_t pos, const char *s)
Definition TString.h:671
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1122
const char * Data() const
Definition TString.h:385
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition TString.cxx:1160
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:2460
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2438
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1296
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1078
TClass * IsA() const override
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
int main()
Definition main.cpp:18
Event structure.
Definition GuiTypes.h:175
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:176
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:179
Window_t fWindow
window reported event is relative to
Definition GuiTypes.h:177
Int_t fX
Definition GuiTypes.h:179
Graphics context structure.
Definition GuiTypes.h:225
Point structure (maps to the X11 XPoint structure)
Definition GuiTypes.h:357
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:94
Mask_t fMask
bit mask specifying which fields are valid
Definition GuiTypes.h:111
Int_t fWinGravity
one of the window gravity values
Definition GuiTypes.h:101
Int_t fBitGravity
one of bit gravity values
Definition GuiTypes.h:100