Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 "TEnv.h"
147#include "TClass.h"
148#include "TGMenu.h"
149#include "KeySymbols.h"
150#include "TVirtualX.h"
151
152#include <iostream>
153
154
155const TGGC *TGButton::fgHibckgndGC = nullptr;
156const TGGC *TGButton::fgDefaultGC = nullptr;
157
158const TGFont *TGTextButton::fgDefaultFont = nullptr;
159
160const TGFont *TGCheckButton::fgDefaultFont = nullptr;
161const TGGC *TGCheckButton::fgDefaultGC = nullptr;
162
163const TGFont *TGRadioButton::fgDefaultFont = nullptr;
164const TGGC *TGRadioButton::fgDefaultGC = nullptr;
165
167
174
175////////////////////////////////////////////////////////////////////////////////
176/// Create button base class part.
177
179 : TGFrame(p, 1, 1, options)
180{
181 fWidgetId = id;
183 fMsgWindow = p;
184 fUserData = 0;
185 fTip = 0;
186 fGroup = 0;
187 fStyle = 0;
188 fTWidth = fTHeight = 0;
189
190 fNormGC = norm;
194
195// fStyle = gClient->GetStyle();
196// if (fStyle > 0) {
197// fOptions &= ~(kRaisedFrame | kDoubleBorder);
198// }
199
200 // coverity[returned_null]
201 // coverity[dereference]
202 if (p && p->IsA()->InheritsFrom(TGButtonGroup::Class())) {
204 bg->Insert(this, id);
205 }
206
208 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
209
210 gVirtualX->GrabButton(fId, kButton1, kAnyModifier,
212 kNone, kNone);
213
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Delete button.
220
222{
223 // remove from button group
224 if (fGroup) {
225 fGroup->Remove(this);
226 fGroup = 0;
227 }
228
229 if (fTip) delete fTip;
230}
231
232////////////////////////////////////////////////////////////////////////////////
233/// Set button state.
234
236{
237 Bool_t was = !IsDown(); // kTRUE if button was off
238
239 if (state == kButtonDisabled)
241 else
243 if (state != fState) {
244 switch (state) {
245 case kButtonEngaged:
246 case kButtonDown:
249 break;
250 case kButtonDisabled:
251 case kButtonUp:
252 if (fStyle > 0) {
255 }
256 else {
259 }
260 break;
261 }
262 fState = state;
263 DoRedraw();
264 if (emit || fGroup) EmitSignals(was);
265 }
266}
267
268////////////////////////////////////////////////////////////////////////////////
269/// Set the button style (modern or classic).
270
272{
275 if (fStyle > 0) {
277 }
278 else {
280 }
281}
282
283////////////////////////////////////////////////////////////////////////////////
284/// Set the button style (modern or classic).
285
286void TGButton::SetStyle(const char *style)
287{
289 if (style && strstr(style, "modern")) {
290 fStyle = 1;
292 }
293 else {
294 fStyle = 0;
296 }
297}
298
299////////////////////////////////////////////////////////////////////////////////
300
302{
303 if (fStyle > 0)
304 return (fOptions & kSunkenFrame);
305 return !(fOptions & kRaisedFrame);
306}
307
308////////////////////////////////////////////////////////////////////////////////
309
311{
312 // Set button state down according to the parameter 'on'.
313
314 if (GetState() == kButtonDisabled) return;
315
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// Sets new button-group for this button.
321
326
327////////////////////////////////////////////////////////////////////////////////
328/// Handle mouse button event.
329
331{
333
334 if (fTip) fTip->Hide();
335
336 if (fState == kButtonDisabled) return kTRUE;
337
338 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
339 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
340
341 // We don't need to check the button number as GrabButton will
342 // only allow button1 events
343 if (event->fType == kButtonPress) {
344 fgReleaseBtn = 0;
345
346 if (fState == kButtonEngaged) {
347 return kTRUE;
348 }
349 if (in) SetState(kButtonDown, kTRUE);
350 } else { // ButtonRelease
351 if (fState == kButtonEngaged) {
352 if (in) SetState(kButtonUp, kTRUE);
353 click = kTRUE;
354 } else {
355 click = (fState == kButtonDown) && in;
356 if (click && fStayDown) {
357 if (in) {
359 fgReleaseBtn = 0;
360 }
361 } else {
362 if (in) {
365 }
366 }
367 }
368 }
369 if (click) {
374 }
375 if ((fStyle > 0) && (event->fType == kButtonRelease)) {
377 }
378 DoRedraw();
379 return kTRUE;
380}
381
382////////////////////////////////////////////////////////////////////////////////
383/// Emit button signals.
384
386{
387 Bool_t now = !IsDown(); // kTRUE if button now is off
388
389 // emit signals
390 if (was && !now) {
391 Pressed(); // emit Pressed = was off , now on
392 if (fStayDown) Clicked(); // emit Clicked
393 }
394 if (!was && now) {
395 Released(); // emit Released = was on , now off
396 Clicked(); // emit Clicked
397 }
398 if ((was != now) && IsToggleButton()) Toggled(!now); // emit Toggled = was != now
399}
400
401////////////////////////////////////////////////////////////////////////////////
402/// Handle mouse crossing event.
403
405{
406 if (fTip) {
407 if (event->fType == kEnterNotify)
408 fTip->Reset();
409 else
410 fTip->Hide();
411 }
412
413 if (fStyle > 0) {
414 if ((event->fType == kEnterNotify) && (fState != kButtonDisabled)) {
416 } else {
418 }
419 if (event->fType == kLeaveNotify) {
421 }
422 DoRedraw();
423 }
424
425 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
426
427 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
428 return kTRUE;
429
430 if (fState == kButtonEngaged || fState == kButtonDisabled) return kTRUE;
431
432 if (event->fType == kLeaveNotify) {
435 }
436 DoRedraw();
437 return kTRUE;
438}
439
440////////////////////////////////////////////////////////////////////////////////
441/// Set tool tip text associated with this button. The delay is in
442/// milliseconds (minimum 250). To remove tool tip call method with
443/// text = 0.
444
446{
447 if (fTip) {
448 delete fTip;
449 fTip = 0;
450 }
451
452 if (text && strlen(text))
454}
455
456////////////////////////////////////////////////////////////////////////////////
457/// Set enabled or disabled state of button
458
466
467////////////////////////////////////////////////////////////////////////////////
468/// Return default graphics context.
469
471{
472 if (!fgDefaultGC)
473 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
474 return *fgDefaultGC;
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Return graphics context for highlighted frame background.
479
481{
482 if (!fgHibckgndGC) {
486 gval.fForeground = gClient->GetResourcePool()->GetFrameHiliteColor();
487 gval.fBackground = gClient->GetResourcePool()->GetFrameBgndColor();
488 gval.fFillStyle = kFillTiled;
489 gval.fTile = gClient->GetResourcePool()->GetCheckeredPixmap();
490 gval.fGraphicsExposures = kFALSE;
491 fgHibckgndGC = gClient->GetGC(&gval, kTRUE);
492 }
493 return *fgHibckgndGC;
494}
495
496
497////////////////////////////////////////////////////////////////////////////////
498/// Create a text button widget. The hotstring will be adopted and deleted
499/// by the text button.
500
503 UInt_t options) : TGButton(p, id, norm, options)
504{
505 fLabel = s;
506 fFontStruct = font;
507
508 Init();
509}
510
511////////////////////////////////////////////////////////////////////////////////
512/// Create a text button widget.
513
514TGTextButton::TGTextButton(const TGWindow *p, const char *s, Int_t id,
516 UInt_t options) : TGButton(p, id, norm, options)
517{
518 fLabel = new TGHotString(!p && !s ? GetName() : s);
519 fFontStruct = font;
520
521 Init();
522}
523
524////////////////////////////////////////////////////////////////////////////////
525/// Create a text button widget and set cmd string at same time.
526
527TGTextButton::TGTextButton(const TGWindow *p, const char *s, const char *cmd,
529 UInt_t options) : TGButton(p, id, norm, options)
530{
531 fLabel = new TGHotString(s);
532 fFontStruct = font;
533 fCommand = cmd;
534
535 Init();
536}
537
538////////////////////////////////////////////////////////////////////////////////
539/// Common initialization used by the different ctors.
540
542{
543 int hotchar;
544
546 fHKeycode = 0;
550 fWrapLength = -1;
551 fMLeft = fMRight = fMTop = fMBottom = 0;
552
554 if (!font) {
556 if (font) fFontStruct = font->GetFontStruct();
557 }
558 if (font) {
561 &fTWidth, &fTHeight);
562 }
563 Resize();
564 fWidth = fTWidth;
566
567 if ((hotchar = fLabel->GetHotChar()) != 0) {
568 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
570 if (main) {
571 main->BindKey(this, fHKeycode, kKeyMod1Mask);
572 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
573 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
575
576 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
580 }
581 }
582 }
585 wattr.fBitGravity = 5; // center
586 wattr.fWinGravity = 1;
587 gVirtualX->ChangeWindowAttributes(fId, &wattr);
588
590}
591
592////////////////////////////////////////////////////////////////////////////////
593/// Delete a text button widget.
594
596{
597 if (fHKeycode && (fParent->MustCleanup() != kDeepCleanup)) {
599 if (main) {
600 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
601 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
602 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
603 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
604
605 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
606 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
607 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
609 }
610 }
611 if (fLabel) delete fLabel;
612 if (fHasOwnFont) {
614 TGGC *gc = pool->FindGC(fNormGC);
615 pool->FreeGC(gc);
616 }
617
618 delete fTLayout;
619}
620
621////////////////////////////////////////////////////////////////////////////////
622/// layout text button
623
625{
627
629 if (!font) {
631 if (font) fFontStruct = font->GetFontStruct();
632 }
633 if (font) {
636 &fTWidth, &fTHeight);
637 }
638 fClient->NeedRedraw(this);
639}
640
641////////////////////////////////////////////////////////////////////////////////
642/// Set new button text.
643
645{
646 int hotchar;
648
649 if (fLabel) {
650 if (main && fHKeycode) {
651 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
652 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
653 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
654 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
655
656 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
657 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
658 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
660 }
661 delete fLabel;
662 }
663
665 if ((hotchar = fLabel->GetHotChar()) != 0) {
666 if (main && ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0)) {
667 main->BindKey(this, fHKeycode, kKeyMod1Mask);
668 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
669 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
671
672 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
676 }
677 }
678
679 Layout();
680}
681
682////////////////////////////////////////////////////////////////////////////////
683/// Set new button text.
684
689
690////////////////////////////////////////////////////////////////////////////////
691/// Set text justification. Mode is an OR of the bits:
692/// kTextTop, kTextBottom, kTextLeft, kTextRight, kTextCenterX and
693/// kTextCenterY.
694
696{
697 fTMode = mode;
698
701 wattr.fWinGravity = 1;
702
703 switch (mode) {
704 case kTextTop | kTextLeft:
705 wattr.fBitGravity = 1; //NorthWestGravity
706 break;
707 case kTextTop | kTextCenterX:
708 case kTextTop:
709 wattr.fBitGravity = 2; //NorthGravity
710 break;
711 case kTextTop | kTextRight:
712 wattr.fBitGravity = 3; //NorthEastGravity
713 break;
714 case kTextLeft | kTextCenterY:
715 case kTextLeft:
716 wattr.fBitGravity = 4; //WestGravity
717 break;
719 wattr.fBitGravity = 5; //CenterGravity
720 break;
722 case kTextRight:
723 wattr.fBitGravity = 6; //EastGravity
724 break;
725 case kTextBottom | kTextLeft:
726 wattr.fBitGravity = 7; //SouthWestGravity
727 break;
729 case kTextBottom:
730 wattr.fBitGravity = 8; //SouthGravity
731 break;
732 case kTextBottom | kTextRight:
733 wattr.fBitGravity = 9; //SouthEastGravity
734 break;
735 default:
736 wattr.fBitGravity = 5; //CenterGravity
737 break;
738 }
739
740 gVirtualX->ChangeWindowAttributes(fId, &wattr);
741 Layout();
742}
743
744////////////////////////////////////////////////////////////////////////////////
745/// Draw the text button.
746
748{
749 int x, y;
750 UInt_t w = GetWidth() - 1;
751 UInt_t h = GetHeight()- 1;
752
753 if ((fStyle > 0) && !(fOptions & kOwnBackground))
754 gVirtualX->SetWindowBackground(fId, fBgndColor);
756
757 if (fTMode & kTextLeft) {
758 x = fMLeft + 4;
759 } else if (fTMode & kTextRight) {
760 x = fWidth - fTWidth - fMRight - 4;
761 } else {
762 x = (fWidth - fTWidth + fMLeft - fMRight) >> 1;
763 }
764
765 if (fTMode & kTextTop) {
766 y = fMTop + 3;
767 } else if (fTMode & kTextBottom) {
768 y = fHeight - fTHeight - fMBottom - 3;
769 } else {
770 y = (fHeight - fTHeight + fMTop - fMBottom) >> 1;
771 }
772
774 ++x; ++y;
775 w--; h--;
776 }
777 if (fStyle == 0) {
778 if (fState == kButtonEngaged) {
779 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
780 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
781 }
782 }
783
785
786 if (fStyle > 0) {
787 gVirtualX->DrawRectangle(fId, TGFrame::GetShadowGC()(), 0, 0, w, h);
788 }
789 if (fState == kButtonDisabled) {
790 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
791 TGGC *gc = pool->FindGC(fNormGC);
792 if (gc) {
793 Pixel_t fore = gc->GetForeground();
794 Pixel_t hi = GetHilightGC().GetForeground();
795 Pixel_t sh = GetShadowGC().GetForeground();
796
797 gc->SetForeground(hi);
798 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
799 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x + 1, y + 1, hotpos - 1);
800
801 gc->SetForeground(sh);
802 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
803 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
804 gc->SetForeground(fore);
805 }
806 } else {
807 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
809 }
810}
811
812////////////////////////////////////////////////////////////////////////////////
813/// Handle key event. This function will be called when the hotkey is hit.
814
816{
817 if (fState == kButtonDisabled || !(event->fState & kKeyMod1Mask)) return kFALSE;
818
820 Bool_t was = !IsDown(); // kTRUE if button was off
821
822 if (event->fType == kGKeyPress) {
823 gVirtualX->SetKeyAutoRepeat(kFALSE);
824 } else {
825 gVirtualX->SetKeyAutoRepeat(kTRUE);
826 }
827
828 if (fTip && event->fType == kGKeyPress) fTip->Hide();
829
830 // We don't need to check the key number as GrabKey will only
831 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
832
833 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
834 if (fState == kButtonEngaged) return kTRUE;
836 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
837 if (fState == kButtonEngaged /*&& !allowRelease*/) return kTRUE;
838 click = (fState == kButtonDown);
839 if (click && fStayDown) {
841 } else {
843 }
844 }
845 if (click) {
850 }
852
853 return kTRUE;
854}
855
856////////////////////////////////////////////////////////////////////////////////
857/// returns default size
858
865
866////////////////////////////////////////////////////////////////////////////////
867/// Return default font structure.
868
870{
871 if (!fgDefaultFont)
872 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
873 return fgDefaultFont->GetFontStruct();
874}
875
876////////////////////////////////////////////////////////////////////////////////
877/// Changes text font.
878/// If global is kTRUE font is changed globally, otherwise - locally.
879
881{
882 if (font != fFontStruct) {
883 FontH_t v = gVirtualX->GetFontHandle(font);
884 if (!v) return;
885
886 fFontStruct = font;
887 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
888 TGGC *gc = pool->FindGC(fNormGC);
889
890 if (gc && !global) {
891 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
893 }
894 if (gc) {
895 gc->SetFont(v);
896 fNormGC = gc->GetGC();
897 }
898 Layout();
899 }
900}
901
902////////////////////////////////////////////////////////////////////////////////
903/// Changes text font specified by name.
904/// If global is true color is changed globally, otherwise - locally.
905
907{
908 TGFont *font = fClient->GetFont(fontName);
909 if (font) {
910 SetFont(font->GetFontStruct(), global);
911 }
912}
913
914////////////////////////////////////////////////////////////////////////////////
915/// Changes text color.
916/// If global is true color is changed globally, otherwise - locally.
917
919{
920 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
921 TGGC *gc = pool->FindGC(fNormGC);
922
923 if (gc && !global) {
924 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
926 }
927 if (gc) {
928 gc->SetForeground(color);
929 fNormGC = gc->GetGC();
930 }
931 fClient->NeedRedraw(this);
932}
933
934////////////////////////////////////////////////////////////////////////////////
935/// Returns kTRUE if text attributes are unique,
936/// returns kFALSE if text attributes are shared (global).
937
939{
940 return fHasOwnFont;
941}
942
943////////////////////////////////////////////////////////////////////////////////
944/// Create a picture button widget. The picture is not adopted and must
945/// later be freed by the user once the picture button is deleted (a single
946/// picture reference might be used by other buttons).
947
950{
951 if (!pic) {
952 Error("TGPictureButton", "pixmap not found or the file format is not supported for button %d", id);
953 fPic = fClient->GetPicture("mb_question_s.xpm");
954 } else {
955 fPic = pic;
956 }
957
958 if (fPic) {
959 fTWidth = fPic->GetWidth();
960 fTHeight = fPic->GetHeight();
961
963 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
964 }
965 fPicD = 0;
968}
969
970////////////////////////////////////////////////////////////////////////////////
971/// Create a picture button widget and set action command. The picture is
972/// not adopted and must later be freed by the user once the picture button
973/// is deleted (a single picture reference might be used by other
974/// buttons).
975
977 const char *cmd, Int_t id, GContext_t norm, UInt_t option)
978 : TGButton(p, id, norm, option)
979{
980 if (!pic) {
981 Error("TGPictureButton", "pixmap not found or the file format is not supported for button\n%s",
982 cmd ? cmd : "");
983 fPic = fClient->GetPicture("mb_question_s.xpm");
984 } else {
985 fPic = pic;
986 }
987
988 fCommand = cmd;
989
990 if (fPic) {
991 fTWidth = fPic->GetWidth();
992 fTHeight = fPic->GetHeight();
993
995 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
996 }
997 fPicD = 0;
1000}
1001
1002////////////////////////////////////////////////////////////////////////////////
1003/// Create a picture button. Where pic is the file name of the picture.
1004
1007{
1008 if (!pic || !pic[0]) {
1009 if (p) Error("TGPictureButton", "pixmap not found or the file format is not supported for button");
1010 fPic = fClient->GetPicture("mb_question_s.xpm");
1011 } else {
1013 }
1014
1015 if (fPic) {
1016 fTWidth = fPic->GetWidth();
1017 fTHeight = fPic->GetHeight();
1018
1019 Resize(fTWidth + (fBorderWidth << 1) + fBorderWidth + 1,
1020 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
1021 }
1022 fPicD = 0;
1024 SetWindowName();
1025}
1026
1027////////////////////////////////////////////////////////////////////////////////
1028/// Destructor.
1029
1034
1035////////////////////////////////////////////////////////////////////////////////
1036/// Change a picture in a picture button. The picture is not adopted and
1037/// must later be freed by the user once the picture button is deleted
1038/// (a single picture reference might be used by other buttons).
1039
1041{
1042 if (!new_pic) {
1043 Error("SetPicture", "pixmap not found or the file format is not supported for button %d\n%s",
1045 return;
1046 }
1047
1048 fPic = new_pic;
1049
1050 if (fState == kButtonDisabled) {
1052 fPicD = 0;
1053 }
1054
1055 fTWidth = fPic->GetWidth();
1056 fTHeight = fPic->GetHeight();
1057
1058 fClient->NeedRedraw(this);
1059}
1060
1061////////////////////////////////////////////////////////////////////////////////
1062/// Redraw picture button.
1063
1065{
1066 if (!fPic) {
1068 return;
1069 }
1070
1071 int x = (fWidth - fTWidth) >> 1;
1072 int y = (fHeight - fTHeight) >> 1;
1073 UInt_t w = GetWidth() - 1;
1074 UInt_t h = GetHeight()- 1;
1075
1076 if ((fStyle > 0) && !(fOptions & kOwnBackground))
1077 gVirtualX->SetWindowBackground(fId, fBgndColor);
1079
1080 if (fState == kButtonDown || fState == kButtonEngaged) {
1081 ++x; ++y;
1082 w--; h--;
1083 }
1084 if (fStyle == 0) {
1085 if (fState == kButtonEngaged) {
1086 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
1087 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
1088 }
1089 }
1090
1091 const TGPicture *pic = fPic;
1092 if (fState == kButtonDisabled) {
1094 pic = fPicD ? fPicD : fPic;
1095 }
1096 if (fStyle > 0) {
1097 if (fBgndColor == fHighColor) {
1098 gVirtualX->DrawRectangle(fId, TGFrame::GetShadowGC()(), 0, 0, w, h);
1099 }
1100 }
1101
1102 pic->Draw(fId, fNormGC, x, y);
1103}
1104
1105////////////////////////////////////////////////////////////////////////////////
1106/// Creates disabled picture.
1107
1109{
1111 if (!img) return;
1113 if (!img2) {
1114 if (img) delete img;
1115 return;
1116 }
1117 TString back = gEnv->GetValue("Gui.BackgroundColor", "#c0c0c0");
1118 img2->FillRectangle(back.Data(), 0, 0, fPic->GetWidth(), fPic->GetHeight());
1119 img->SetImage(fPic->GetPicture(), fPic->GetMask());
1120 Pixmap_t mask = img->GetMask();
1121 img2->Merge(img, "overlay");
1122
1123 TString name = "disbl_";
1124 name += fPic->GetName();
1125 fPicD = fClient->GetPicturePool()->GetPicture(name.Data(), img2->GetPixmap(),
1126 mask);
1128 delete img;
1129 delete img2;
1130}
1131
1132////////////////////////////////////////////////////////////////////////////////
1133/// Changes disabled picture.
1134
1136{
1137 if (!pic) return;
1138
1140 fPicD = pic;
1141 ((TGPicture*)pic)->AddReference();
1143}
1144
1145////////////////////////////////////////////////////////////////////////////////
1146/// Create a check button widget. The hotstring will be adopted and deleted
1147/// by the check button.
1148
1151 : TGTextButton(p, s, id, norm, font, option)
1152{
1153 Init();
1154}
1155
1156////////////////////////////////////////////////////////////////////////////////
1157/// Create a check button widget.
1158
1161 : TGTextButton(p, s, id, norm, font, option)
1162{
1163 Init();
1164}
1165
1166////////////////////////////////////////////////////////////////////////////////
1167/// Create a check button widget.
1168
1169TGCheckButton::TGCheckButton(const TGWindow *p, const char *s, const char *cmd,
1171 UInt_t option) : TGTextButton(p, s, cmd, id, norm, font, option)
1172{
1173 Init();
1174}
1175
1176////////////////////////////////////////////////////////////////////////////////
1177/// Common check button initialization.
1178
1180{
1181 fPrevState =
1182 fState = kButtonUp;
1183 fHKeycode = 0;
1184
1185 fOn = fClient->GetPicture("checked_t.xpm");
1186 fOff = fClient->GetPicture("unchecked_t.xpm");
1187 fDisOn = fClient->GetPicture("checked_dis_t.xpm");
1188 fDisOff = fClient->GetPicture("unchecked_dis_t.xpm");
1189
1190 Resize();
1191
1192 if (!fOn) {
1193 Error("TGCheckButton", "checked_t.xpm not found or the file format is not supported.");
1194 } else if (!fOff) {
1195 Error("TGCheckButton", "unchecked_t.xpm not found or the file format is not supported.");
1196 } else if (!fDisOn) {
1197 Error("TGCheckButton", "checked_dis_t.xpm not found or the file format is not supported.");
1198 } else if (!fDisOff) {
1199 Error("TGCheckButton", "unchecked_dis_t.xpm not found or the file format is not supported.");
1200 }
1201 int hotchar;
1202
1203 if ((hotchar = fLabel->GetHotChar()) != 0) {
1204 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
1206 if (main) {
1207 main->BindKey(this, fHKeycode, kKeyMod1Mask);
1208 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
1209 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
1211
1212 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
1216 }
1217 }
1218 }
1219 SetWindowName();
1220}
1221
1222////////////////////////////////////////////////////////////////////////////////
1223/// Delete a check button.
1224
1232
1233////////////////////////////////////////////////////////////////////////////////
1234/// default size
1235
1237{
1238 UInt_t w = !fTWidth ? fOff->GetWidth() : fTWidth + fOff->GetWidth() + 9;
1239 UInt_t h = !fTHeight ? fOff->GetHeight() : fTHeight + 2;
1240
1241 w = GetOptions() & kFixedWidth ? fWidth : w;
1242 h = GetOptions() & kFixedHeight ? fHeight : h;
1243
1244 return TGDimension(w, h);
1245}
1246
1247////////////////////////////////////////////////////////////////////////////////
1248/// Set check button state.
1249
1251{
1252 if (state == kButtonDisabled)
1254 else
1256 PSetState(state, emit);
1257}
1258
1259////////////////////////////////////////////////////////////////////////////////
1260/// Emit signals.
1261
1263{
1264 if (fState == kButtonUp) Released(); // emit Released
1265 if (fState == kButtonDown) Pressed(); // emit Pressed
1266 Clicked(); // emit Clicked
1267 Toggled(fStateOn); // emit Toggled
1268}
1269
1270////////////////////////////////////////////////////////////////////////////////
1271/// Set check button state.
1272
1274{
1275 if (state != fState) {
1276 if (state == kButtonUp) {
1277 if (fPrevState == kButtonDisabled) {
1278 if (fStateOn) {
1281 } else {
1282 fState = state;
1283 fPrevState = state;
1284 }
1285 } else if (fPrevState == kButtonDown) {
1286 fStateOn = kFALSE;
1287 fState = state;
1288 fPrevState = state;
1289 }
1290 } else if (state == kButtonDown) {
1291 fStateOn = kTRUE;
1292 fState = state;
1293 fPrevState = state;
1294 } else {
1295 fState = state;
1296 fPrevState = state;
1297 }
1298 if (emit) {
1299 // button signals
1300 EmitSignals();
1301 }
1302 DoRedraw();
1303 }
1304}
1305
1306////////////////////////////////////////////////////////////////////////////////
1307/// Set the state of a check button to disabled and either on or
1308/// off.
1309
1311{
1312 if (!enable) {
1313 if (fState == kButtonDisabled && fStateOn) {
1314 PSetState(kButtonUp, kFALSE); // enable button
1315 PSetState(kButtonUp, kFALSE); // set button up
1316 PSetState(kButtonDisabled, kFALSE); // disable button
1317 } else {
1320 }
1321 } else {
1322 PSetState(kButtonDown, kFALSE); // set button down
1323 PSetState(kButtonDisabled, kFALSE); // disable button
1324 }
1325}
1326
1327////////////////////////////////////////////////////////////////////////////////
1328/// Handle mouse button event.
1329
1331{
1333
1334 if (fTip) fTip->Hide();
1335
1336 if (fState == kButtonDisabled) return kTRUE;
1337
1338 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
1339 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
1340
1341 // We don't need to check the button number as GrabButton will
1342 // only allow button1 events
1343 if (event->fType == kButtonPress) {
1344 fgReleaseBtn = 0;
1345 if (in) {
1347 Pressed();
1348 }
1349 } else { // ButtonRelease
1350 if (in) {
1352 click = kTRUE;
1354 Released();
1355 }
1356 fgReleaseBtn = fId;
1358 }
1359 if (click) {
1360 Clicked();
1366 }
1367 DoRedraw();
1368 return kTRUE;
1369}
1370
1371////////////////////////////////////////////////////////////////////////////////
1372/// Handle mouse crossing event.
1373
1375{
1376 if (fTip) {
1377 if (event->fType == kEnterNotify)
1378 fTip->Reset();
1379 else
1380 fTip->Hide();
1381 }
1382
1383 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
1384
1385 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
1386 return kTRUE;
1387
1388 if (fState == kButtonDisabled) return kTRUE;
1389
1390 if (event->fType == kEnterNotify) {
1392 } else {
1394 }
1395 DoRedraw();
1396
1397 return kTRUE;
1398}
1399
1400////////////////////////////////////////////////////////////////////////////////
1401/// Handle key event. This function will be called when the hotkey is hit.
1402
1404{
1406
1407 if (event->fType == kGKeyPress)
1408 gVirtualX->SetKeyAutoRepeat(kFALSE);
1409 else
1410 gVirtualX->SetKeyAutoRepeat(kTRUE);
1411
1412 if (fTip && event->fType == kGKeyPress) fTip->Hide();
1413
1414 if (fState == kButtonDisabled) return kTRUE;
1415
1416 // We don't need to check the key number as GrabKey will only
1417 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
1418
1419 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
1421 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
1422 click = (fState != fPrevState);
1424 }
1425 if (click) {
1430 }
1431 return kTRUE;
1432}
1433
1434////////////////////////////////////////////////////////////////////////////////
1435/// Draw the check button widget.
1436
1438{
1439 int x, y, y0;
1440
1442
1443 x = 20;
1444 y = (fHeight - fTHeight) >> 1;
1445
1446 y0 = !fTHeight ? 0 : y + 1;
1447 if (fOn && fOff) {
1448 Int_t smax = TMath::Max(fOn->GetHeight(), fOff->GetHeight());
1449 y0 = ((Int_t)fHeight <= smax) ? 0 : 1 + (((Int_t)fHeight - smax) >> 1);
1450 }
1451
1452 if (fStateOn) {
1453 if (fOn) fOn->Draw(fId, fNormGC, 0, y0);
1454 } else {
1455 if (fOff) fOff->Draw(fId, fNormGC, 0, y0);
1456 }
1457
1459
1460 if (fState == kButtonDisabled) {
1461 if (fStateOn == kTRUE) {
1462 if (fDisOn) fDisOn->Draw(fId, fNormGC, 0, y0);
1463 } else {
1464 if (fDisOff) fDisOff->Draw(fId, fNormGC, 0, y0);
1465 }
1466
1467 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
1468 TGGC *gc = pool->FindGC(fNormGC);
1469 if (gc) {
1470 Pixel_t fore = gc->GetForeground();
1471 Pixel_t hi = GetHilightGC().GetForeground();
1472 Pixel_t sh = GetShadowGC().GetForeground();
1473
1474 gc->SetForeground(hi);
1475 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
1476 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
1477
1478 gc->SetForeground(sh);
1479 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
1480 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
1481
1482 gc->SetForeground(fore);
1483 }
1484 } else {
1485 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
1487 }
1488}
1489
1490////////////////////////////////////////////////////////////////////////////////
1491/// Return default font structure.
1492
1494{
1495 if (!fgDefaultFont)
1496 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
1497 return fgDefaultFont->GetFontStruct();
1498}
1499
1500////////////////////////////////////////////////////////////////////////////////
1501/// Return default graphics context.
1502
1504{
1505 if (!fgDefaultGC)
1506 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1507 return *fgDefaultGC;
1508}
1509
1510
1511////////////////////////////////////////////////////////////////////////////////
1512/// Create a radio button widget. The hotstring will be adopted and deleted
1513/// by the radio button.
1514
1517 : TGTextButton(p, s, id, norm, font, option)
1518{
1519 Init();
1520}
1521
1522////////////////////////////////////////////////////////////////////////////////
1523/// Create a radio button widget.
1524
1527 : TGTextButton(p, s, id, norm, font, option)
1528{
1529 Init();
1530}
1531////////////////////////////////////////////////////////////////////////////////
1532/// Create a radio button widget.
1533
1534TGRadioButton::TGRadioButton(const TGWindow *p, const char *s, const char *cmd,
1535 Int_t id, GContext_t norm,
1537 : TGTextButton(p, s, cmd, id, norm, font, option)
1538{
1539 Init();
1540}
1541
1542////////////////////////////////////////////////////////////////////////////////
1543/// Common radio button initialization.
1544
1546{
1547 fPrevState =
1548 fState = kButtonUp;
1549 fHKeycode = 0;
1550
1551 fOn = fClient->GetPicture("rbutton_on.xpm");
1552 fOff = fClient->GetPicture("rbutton_off.xpm");
1553 fDisOn = fClient->GetPicture("rbutton_dis_on.xpm");
1554 fDisOff = fClient->GetPicture("rbutton_dis_off.xpm");
1555
1556 if (!fOn || !fOff || !fDisOn || !fDisOff)
1557 Error("TGRadioButton", "rbutton_*.xpm not found or the file format is not supported.");
1558
1559 Resize();
1560
1561 int hotchar;
1562
1563 if ((hotchar = fLabel->GetHotChar()) != 0) {
1564 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
1566 if (main) {
1567 main->BindKey(this, fHKeycode, kKeyMod1Mask);
1568 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
1569 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
1571
1572 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
1576 }
1577 }
1578 }
1579
1580 if (fParent->IsA()->InheritsFrom(TGButtonGroup::Class())) {
1581 ((TGButtonGroup*)fParent)->SetRadioButtonExclusive(kTRUE);
1582 }
1583 SetWindowName();
1584}
1585
1586////////////////////////////////////////////////////////////////////////////////
1587/// Delete a radio button.
1588
1596
1597////////////////////////////////////////////////////////////////////////////////
1598/// default size
1599
1601{
1602 UInt_t w = !fTWidth ? ( fOff?fOff->GetWidth():10) : fTWidth + fOff->GetWidth() + 10;
1603 UInt_t h = !fTHeight ? ( fOff?fOff->GetHeight():2) : fTHeight + 2;
1604
1605 w = GetOptions() & kFixedWidth ? fWidth : w;
1606 h = GetOptions() & kFixedHeight ? fHeight : h;
1607
1608 return TGDimension(w, h);
1609}
1610////////////////////////////////////////////////////////////////////////////////
1611/// Set radio button state.
1612
1614{
1615 if (state == kButtonDisabled)
1617 else
1619 PSetState(state, emit);
1620}
1621
1622////////////////////////////////////////////////////////////////////////////////
1623/// Set the state of a radio button to disabled and either on or
1624/// off.
1625
1627{
1628 if (!enable) {
1629 if (fState == kButtonDisabled && fStateOn) {
1630 PSetState(kButtonUp, kFALSE); // enable button
1631 PSetState(kButtonUp, kFALSE); // set button up
1632 PSetState(kButtonDisabled, kFALSE); // disable button
1633 } else {
1636 }
1637 } else {
1638 PSetState(kButtonDown, kFALSE); // set button down
1639 PSetState(kButtonDisabled, kFALSE); // disable button
1640 }
1641}
1642
1643////////////////////////////////////////////////////////////////////////////////
1644/// Emit signals.
1645
1647{
1648 if (fState == kButtonUp) Released(); // emit Released
1649 if (fState == kButtonDown) Pressed(); // emit Pressed
1650 Clicked(); // emit Clicked
1651 Toggled(fStateOn); // emit Toggled
1652}
1653
1654////////////////////////////////////////////////////////////////////////////////
1655/// Set radio button state.
1656
1658{
1659 if (state != fState) {
1660 // fPrevState = fState = state;
1661 if (state == kButtonUp) {
1662 if (fPrevState == kButtonDisabled) {
1663 if (fStateOn) {
1666 } else {
1667 fState = state;
1668 fPrevState = state;
1669 }
1670 } else if (fPrevState == kButtonDown) {
1671 fStateOn = kFALSE;
1672 fState = state;
1673 fPrevState = state;
1674 }
1675 } else if (state == kButtonDown) {
1676 fStateOn = kTRUE;
1677 fState = state;
1678 fPrevState = state;
1679 } else {
1680 fState = state;
1681 fPrevState = state;
1682 }
1683 if (emit) {
1684 // button signals
1685 EmitSignals();
1686 }
1687 DoRedraw();
1688 }
1689}
1690
1691////////////////////////////////////////////////////////////////////////////////
1692/// Handle mouse button event.
1693
1695{
1698
1699 if (fTip) fTip->Hide();
1700
1701 if (fState == kButtonDisabled) return kFALSE;
1702
1703
1704 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
1705 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
1706
1707 if (event->fType == kButtonPress) { // button pressed
1708 fgReleaseBtn = 0;
1709 if (in) {
1711 Pressed();
1712 }
1713 } else { // ButtonRelease
1714 if (in) {
1715 if (!fStateOn) {
1717 toggled = kTRUE;
1718 }
1720 Released();
1721 click = kTRUE;
1722 }
1724 fgReleaseBtn = fId;
1725 }
1726 if (click) {
1727 Clicked();
1732 }
1733 if (toggled) {
1735 }
1736 DoRedraw();
1737 return kTRUE;
1738}
1739
1740////////////////////////////////////////////////////////////////////////////////
1741/// Handle mouse crossing event.
1742
1744{
1745 if (fTip) {
1746 if (event->fType == kEnterNotify)
1747 fTip->Reset();
1748 else
1749 fTip->Hide();
1750 }
1751
1752 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
1753
1754 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
1755 return kTRUE;
1756
1757 if (fState == kButtonDisabled) return kTRUE;
1758
1759 if (event->fType == kEnterNotify) {
1761 } else {
1763 }
1764 DoRedraw();
1765
1766 return kTRUE;
1767}
1768
1769////////////////////////////////////////////////////////////////////////////////
1770/// Handle key event. This function will be called when the hotkey is hit.
1771
1773{
1774 if (event->fType == kGKeyPress)
1775 gVirtualX->SetKeyAutoRepeat(kFALSE);
1776 else
1777 gVirtualX->SetKeyAutoRepeat(kTRUE);
1778
1779 if (fTip && event->fType == kGKeyPress)
1780 fTip->Hide();
1781
1782 if (fState == kButtonDisabled) return kTRUE;
1783
1784 // We don't need to check the key number as GrabKey will only
1785 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
1786
1787 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
1793 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
1795 }
1796 return kTRUE;
1797}
1798
1799////////////////////////////////////////////////////////////////////////////////
1800/// Draw a radio button.
1801
1803{
1804 Int_t tx, ty, y0;
1805
1807
1808 tx = 20;
1809 ty = (fHeight - fTHeight) >> 1;
1810
1811// pw = 12;
1812 y0 = !fTHeight ? 0 : ty + 1;
1813 if (fOn && fOff) {
1814 Int_t smax = TMath::Max(fOn->GetHeight(), fOff->GetHeight());
1815 y0 = ((Int_t)fHeight <= smax) ? 0 : 1 + (((Int_t)fHeight - smax) >> 1);
1816 }
1817
1818 if (fStateOn) {
1819 if (fOn) fOn->Draw(fId, fNormGC, 0, y0);
1820 } else {
1821 if (fOff) fOff->Draw(fId, fNormGC, 0, y0);
1822 }
1823
1825
1826 if (fState == kButtonDisabled) {
1827 if (fStateOn == kTRUE) {
1828 if (fDisOn) fDisOn->Draw(fId, fNormGC, 0, y0);
1829 } else {
1830 if (fDisOff) fDisOff->Draw(fId, fNormGC, 0, y0);
1831 }
1832
1833 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
1834 TGGC *gc = pool->FindGC(fNormGC);
1835 if (gc) {
1836 Pixel_t fore = gc->GetForeground();
1837 Pixel_t hi = GetHilightGC().GetForeground();
1838 Pixel_t sh = GetShadowGC().GetForeground();
1839
1840 gc->SetForeground(hi);
1841 fTLayout->DrawText(fId, gc->GetGC(), tx + 1, ty + 1, 0, -1);
1842 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), tx, ty, hotpos - 1);
1843
1844 gc->SetForeground(sh);
1845 fTLayout->DrawText(fId, gc->GetGC(), tx, ty, 0, -1);
1846 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), tx, ty, hotpos - 1);
1847
1848 gc->SetForeground(fore);
1849 }
1850 } else {
1851 fTLayout->DrawText(fId, fNormGC, tx, ty, 0, -1);
1853 }
1854}
1855
1856////////////////////////////////////////////////////////////////////////////////
1857/// Return default font structure.
1858
1860{
1861 if (!fgDefaultFont)
1862 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
1863 return fgDefaultFont->GetFontStruct();
1864}
1865
1866////////////////////////////////////////////////////////////////////////////////
1867/// Return default graphics context.
1868
1870{
1871 if (!fgDefaultGC)
1872 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1873 return *fgDefaultGC;
1874}
1875
1876////////////////////////////////////////////////////////////////////////////////
1877/// Save a button widget as a C++ statement(s) on output stream out.
1878
1879void TGButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1880{
1881 if (option && strstr(option, "keep_names"))
1882 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
1883
1884 if (fState == kButtonDown)
1885 out << " " << GetName() << "->SetState(kButtonDown);\n";
1886 if (fState == kButtonDisabled)
1887 out << " " << GetName() << "->SetState(kButtonDisabled);\n";
1888 if (fState == kButtonEngaged)
1889 out << " " << GetName() << "->SetState(kButtonEngaged);\n";
1890
1892 SaveUserColor(out, option);
1893 out << " " << GetName() << "->ChangeBackground(ucolor);\n";
1894 }
1895
1896 if (fTip)
1897 out << " " << GetName() << "->SetToolTipText(\""
1898 << TString(fTip->GetText()->GetString()).ReplaceSpecialCppChars() << "\");\n";
1899 if (fCommand.Length() > 0)
1900 out << " " << GetName() << "->SetCommand(\"" << TString(fCommand).ReplaceSpecialCppChars() << "\");\n";
1901}
1902
1903////////////////////////////////////////////////////////////////////////////////
1904/// Save a text button widget as a C++ statement(s) on output stream out.
1905
1906void TGTextButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1907{
1909 if (fLabel->GetHotPos() > 0)
1910 outext.Insert(fLabel->GetHotPos()-1, "&");
1911
1912 // font + GC
1913 option = GetName()+5; // unique digit id of the name
1915 parFont.Form("%s::GetDefaultFontStruct()",IsA()->GetName());
1916 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
1917
1918 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
1919 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
1920 if (ufont) {
1921 ufont->SavePrimitive(out, option);
1922 parFont.Form("ufont->GetFontStruct()");
1923 }
1924
1925 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
1926 if (userGC) {
1927 userGC->SavePrimitive(out, option);
1928 parGC.Form("uGC->GetGC()");
1929 }
1930 }
1931
1932 out << " TGTextButton *" << GetName() << " = new TGTextButton(" << fParent->GetName()
1933 << ", \"" << outext.ReplaceSpecialCppChars() << "\"";
1934
1935 if (GetOptions() == (kRaisedFrame | kDoubleBorder)) {
1937 if (fNormGC == GetDefaultGC()()) {
1938 if (fWidgetId == -1) {
1939 out << ");\n";
1940 } else {
1941 out << "," << fWidgetId <<");\n";
1942 }
1943 } else {
1944 out << "," << fWidgetId << "," << parGC << ");\n";
1945 }
1946 } else {
1947 out << "," << fWidgetId << "," << parGC << "," << parFont << ");\n";
1948 }
1949 } else {
1950 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");\n";
1951 }
1952
1953 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");\n";
1954 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << "," << fMTop << "," << fMBottom
1955 << ");\n";
1956 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");\n";
1957
1958 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetHeight() << ");\n";
1959
1961}
1962
1963////////////////////////////////////////////////////////////////////////////////
1964/// Save a picture button widget as a C++ statement(s) on output stream out.
1965
1966void TGPictureButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1967{
1968 if (!fPic) {
1969 Error("SavePrimitive", "pixmap not found or the file format is not supported for picture button %d ", fWidgetId);
1970 return;
1971 }
1972
1973 // GC
1974 option = GetName()+5; // unique digit id of the name
1975 TString parGC;
1976 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
1977
1978 if (GetDefaultGC()() != fNormGC) {
1979 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
1980 if (userGC) {
1981 userGC->SavePrimitive(out, option);
1982 parGC.Form("uGC->GetGC()");
1983 }
1984 }
1985
1986 TString picname = gSystem->UnixPathName(fPic->GetName());
1988
1989 out << " TGPictureButton *" << GetName() << " = new TGPictureButton(" << fParent->GetName()
1990 << ", gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\")";
1991
1992 if (GetOptions() == (kRaisedFrame | kDoubleBorder)) {
1993 if (fNormGC == GetDefaultGC()()) {
1994 if (fWidgetId == -1) {
1995 out << ");\n";
1996 } else {
1997 out << "," << fWidgetId << ");\n";
1998 }
1999 } else {
2000 out << "," << fWidgetId << "," << parGC << ");\n";
2001 }
2002 } else {
2003 out << "," << fWidgetId << "," << parGC << "," << GetOptionString() << ");\n";
2004 }
2005
2007}
2008
2009////////////////////////////////////////////////////////////////////////////////
2010/// Save a check button widget as a C++ statement(s) on output stream out.
2011
2012void TGCheckButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2013{
2015 if (fLabel->GetHotPos() > 0)
2016 outext.Insert(fLabel->GetHotPos()-1, "&");
2017
2018 out <<" TGCheckButton *" << GetName() << " = new TGCheckButton(" << fParent->GetName()
2019 << ", \"" << outext.ReplaceSpecialCppChars() << "\"";
2020
2021 // font + GC
2022 option = GetName()+5; // unique digit id of the name
2024 parFont.Form("%s::GetDefaultFontStruct()", IsA()->GetName());
2025 parGC.Form("%s::GetDefaultGC()()", IsA()->GetName());
2026
2027 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
2028 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
2029 if (ufont) {
2030 ufont->SavePrimitive(out, option);
2031 parFont.Form("ufont->GetFontStruct()");
2032 }
2033
2034 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
2035 if (userGC) {
2036 userGC->SavePrimitive(out, option);
2037 parGC.Form("uGC->GetGC()");
2038 }
2039 }
2040
2041 if (GetOptions() == kChildFrame) {
2043 if (fNormGC == GetDefaultGC()()) {
2044 if (fWidgetId == -1) {
2045 out << ");\n";
2046 } else {
2047 out << "," << fWidgetId << ");\n";
2048 }
2049 } else {
2050 out << "," << fWidgetId << "," << parGC << ");\n";
2051 }
2052 } else {
2053 out << "," << fWidgetId << "," << parGC << "," << parFont << ");\n";
2054 }
2055 } else {
2056 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");\n";
2057 }
2058
2060 if (fState == kButtonDisabled) {
2062 out << " " << GetName() << "->SetDisabledAndSelected(kTRUE);\n";
2063 else
2064 out << " " << GetName() << "->SetDisabledAndSelected(kFALSE);\n";
2065 }
2066 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");\n";
2067 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << "," << fMTop << "," << fMBottom
2068 << ");\n";
2069 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");\n";
2070}
2071
2072////////////////////////////////////////////////////////////////////////////////
2073/// Save a radio button widget as a C++ statement(s) on output stream out.
2074
2075void TGRadioButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2076{
2078 if (fLabel->GetHotPos() > 0)
2079 outext.Insert(fLabel->GetHotPos() - 1, "&");
2080
2081 out << " TGRadioButton *" << GetName() << " = new TGRadioButton(" << fParent->GetName() << ", \""
2082 << outext.ReplaceSpecialCppChars() << "\"";
2083
2084 // font + GC
2085 option = GetName() + 5; // unique digit id of the name
2087 parFont.Form("%s::GetDefaultFontStruct()", IsA()->GetName());
2088 parGC.Form("%s::GetDefaultGC()()", IsA()->GetName());
2089
2090 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
2091 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
2092 if (ufont) {
2093 ufont->SavePrimitive(out, option);
2094 parFont.Form("ufont->GetFontStruct()");
2095 }
2096
2097 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
2098 if (userGC) {
2099 userGC->SavePrimitive(out, option);
2100 parGC.Form("uGC->GetGC()");
2101 }
2102 }
2103
2104 if (GetOptions() == (kChildFrame)) {
2106 if (fNormGC == GetDefaultGC()()) {
2107 if (fWidgetId == -1) {
2108 out << ");\n";
2109 } else {
2110 out << "," << fWidgetId << ");\n";
2111 }
2112 } else {
2113 out << "," << fWidgetId << "," << parGC << ");\n";
2114 }
2115 } else {
2116 out << "," << fWidgetId << "," << parGC << "," << parFont << ");\n";
2117 }
2118 } else {
2119 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");\n";
2120 }
2121
2123 if (fState == kButtonDisabled) {
2125 out << " " << GetName() << "->SetDisabledAndSelected(kTRUE);\n";
2126 else
2127 out << " " << GetName() << "->SetDisabledAndSelected(kFALSE);\n";
2128 }
2129 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");\n";
2130 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << "," << fMTop << "," << fMBottom
2131 << ");\n";
2132 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");\n";
2133}
2134
2135////////////////////////////////////////////////////////////////////////////////
2136/// Create a menu button widget. The hotstring will be adopted and
2137/// deleted by the menu button. This constructor creates a
2138/// menubutton with a popup menu attached that appears when the
2139/// button for it is clicked. The popup menu is adopted.
2140
2142 TGPopupMenu *popmenu, Bool_t split, Int_t id,
2144 : TGTextButton(p, menulabel, id, norm, fontstruct, options)
2145{
2147 fMBWidth = 16;
2149 fPopMenu = popmenu;
2150 fPopMenu->fSplitButton = this;
2151 fSplit = split;
2152 fTMode = 0;
2153 fHKeycode = 0;
2154 fMBState = kButtonUp; fDefaultCursor = fClient->GetResourcePool()->GetGrabCursor();
2156 fWidestLabel = "";
2157 fHeighestLabel = "";
2158
2159 // Find and set the correct size for the menu and the button.
2160 TGMenuEntry *entry = 0;
2163 const TList *list = fPopMenu->GetListOfEntries();
2164 UInt_t lwidth = 0, lheight = 0;
2165 UInt_t twidth = 0, theight = 0;
2166
2168 if (!font) {
2170 if (font) fFontStruct = font->GetFontStruct();
2171 }
2172
2173 if (font) font->ComputeTextLayout(lstring, lstring.GetLength(),
2175 &lwidth, &lheight);
2176
2177 TIter iter(list);
2178 entry = (TGMenuEntry *)iter.Next();
2179 while (entry != 0) {
2180 if (entry->GetType() == kMenuEntry) {
2181 const TGHotString string(*(entry->GetLabel()));
2182 if (font) font->ComputeTextLayout(string, string.GetLength(),
2184 &twidth, &theight);
2185 if(twidth > lwidth) {
2186 lstring = string;
2187 }
2188 if(theight > lheight) {
2189 hstring = string;
2190 }
2191 }
2192 entry = (TGMenuEntry *)iter.Next();
2193 }
2196
2197 if (font) {
2198 UInt_t dummy = 0;
2199 font->ComputeTextLayout(lstring, lstring.GetLength(),
2201 &fTWidth, &dummy);
2202 font->ComputeTextLayout(hstring, hstring.GetLength(),
2204 &dummy, &fTHeight);
2205 }
2206 fTBWidth = fTWidth + 8;
2207 fHeight = fTHeight + 7;
2209
2211
2212 // Save the id of the 1st item on the menu.
2213 TIter iter1(list);
2214 do {
2215 entry = (TGMenuEntry *)iter1.Next();
2216 if ((entry) && (entry->GetStatus() & kMenuEnableMask) &&
2217 !(entry->GetStatus() & kMenuHideMask) &&
2218 (entry->GetType() != kMenuSeparator) &&
2219 (entry->GetType() != kMenuLabel)) break;
2220 entry = (TGMenuEntry *)iter1.Next();
2221 } while (entry);
2222 if (entry) fEntryId = entry->GetEntryId();
2223
2224 // An additional connection that is needed.
2225 fPopMenu->Connect("Activated(Int_t)", "TGSplitButton", this, "HandleMenu(Int_t)");
2227
2228 Init();
2229}
2230
2231
2232////////////////////////////////////////////////////////////////////////////////
2233/// Common initialization used by the different ctors.
2234
2236{
2237 Int_t hotchar;
2238
2240 fHKeycode = 0;
2242 fPrevStateOn =
2243 fStateOn = kFALSE;
2245
2247
2248 if ((hotchar = fLabel->GetHotChar()) != 0) {
2249 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
2251 if (main) {
2252 main->BindKey(this, fHKeycode, kKeyMod1Mask);
2253 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2254 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2256
2257 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2261 }
2262 }
2263 }
2266 wattr.fBitGravity = 5; // center
2267 wattr.fWinGravity = 1;
2268 gVirtualX->ChangeWindowAttributes(fId, &wattr);
2269
2270 // Make sure motion is detected too.
2272
2273 SetWindowName();
2274}
2275
2276////////////////////////////////////////////////////////////////////////////////
2277/// Delete a split button widget.
2278
2280{
2281 if (fPopMenu) delete fPopMenu;
2282 if (fMenuLabel) delete fMenuLabel;
2283}
2284
2285////////////////////////////////////////////////////////////////////////////////
2286/// Draw triangle (arrow) on which user can click to open Popup.
2287
2289{
2290 Point_t points[3];
2291
2292 points[0].fX = x;
2293 points[0].fY = y;
2294 points[1].fX = x + 5;
2295 points[1].fY = y;
2296 points[2].fX = x + 2;
2297 points[2].fY = y + 3;
2298
2299 gVirtualX->FillPolygon(fId, gc, points, 3);
2300}
2301
2302////////////////////////////////////////////////////////////////////////////////
2303/// Calculate the size of the button.
2304
2306{
2309 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2311
2312 fTBWidth = fTWidth + 8;
2313 fHeight = fTHeight + 7;
2314 fWidth = fTBWidth;
2315}
2316
2317////////////////////////////////////////////////////////////////////////////////
2318/// Handle mouse button event in case the button is split.
2319
2321{
2322 if (fState == kButtonDisabled) return kFALSE;
2323
2324 Bool_t activate = kFALSE;
2326 static Bool_t mbpress = kFALSE;
2327 static Bool_t tbpress = kFALSE;
2328 static Bool_t outpress = kFALSE;
2329
2330 Bool_t inTB = (event->fX >= 0) && (event->fY >= 0) &&
2331 (event->fX <= (Int_t)fTBWidth) && (event->fY <= (Int_t)fHeight);
2332
2333 Bool_t inMB = (event->fX >= (Int_t)(fWidth -fMBWidth)) && (event->fY >= 0) &&
2334 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2335
2336 // We don't need to check the button number as GrabButton will
2337 // only allow button1 events
2338
2339 if (inTB) {
2340 if (event->fType == kButtonPress) {
2341 mbpress = kFALSE;
2342 tbpress = kTRUE;
2343 fgReleaseBtn = 0;
2344 if (fState == kButtonEngaged) {
2345 return kTRUE;
2346 }
2348 Pressed();
2349 } else { // ButtonRelease
2350 if (fMBState == kButtonDown) {
2352 }
2353 if (fState == kButtonEngaged && tbpress) {
2355 Released();
2356 bclick = kTRUE;
2357 } else if (fState == kButtonDown && tbpress) {
2358 tbpress = kFALSE;
2359 if (fStayDown) {
2360 bclick = kTRUE;
2362 fgReleaseBtn = 0;
2363 } else {
2364 bclick = kTRUE;
2366 Released();
2367 fgReleaseBtn = fId;
2368 }
2369 }else {
2371 }
2372 }
2373 } else if (inMB) {
2374 if (event->fType == kButtonPress) {
2375 fgReleaseBtn = 0;
2376 mbpress = kTRUE;
2377 tbpress = kFALSE;
2378 if (fMBState == kButtonEngaged) {
2379 return kTRUE;
2380 }
2382 MBPressed();
2385 } else { // ButtonRelease
2386 if (fState == kButtonDown) {
2388 }
2389 if (fMBState == kButtonEngaged && mbpress) {
2390 mbpress = kFALSE;
2393 MBReleased();
2394 MBClicked();
2395 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2396 } else if (fMBState == kButtonDown && mbpress) {
2397 MBClicked();
2400 fgReleaseBtn = 0;
2401 } else {
2403 }
2404 }
2405 } else {
2406 if (event->fType == kButtonPress) {
2407 fgReleaseBtn = 0;
2408 outpress = kTRUE;
2409 } else { // ButtonRelease
2410 if(outpress) {
2411 outpress = kFALSE;
2414 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2415 activate = kTRUE;
2416 }
2417 }
2418 }
2419 if (bclick) {
2420 Clicked();
2425 }
2426 if (activate) {
2428 if (entry) {
2429 if ((entry->GetStatus() & kMenuEnableMask) &&
2430 !(entry->GetStatus() & kMenuHideMask) &&
2431 (entry->GetType() != kMenuSeparator) &&
2432 (entry->GetType() != kMenuLabel)) {
2433 Int_t id = entry->GetEntryId();
2434 fPopMenu->Activated(id);
2435 }
2436 }
2437 }
2438 // if (mbclick) {
2439 // MBClicked();
2440 // SendMessage(fMsgWindow, MK_MSG(kC_COMMAND, kCM_BUTTON), fWidgetId,
2441 // (Longptr_t) fUserData);
2442 // fClient->ProcessLine(fCommand, MK_MSG(kC_COMMAND, kCM_BUTTON), fWidgetId,
2443 // (Longptr_t) fUserData);
2444 // }
2445 return kTRUE;
2446}
2447
2448////////////////////////////////////////////////////////////////////////////////
2449/// Handle mouse crossing event in case of split menu.
2450
2452{
2453 if (fTip) {
2454 if (event->fType == kEnterNotify)
2455 fTip->Reset();
2456 else
2457 fTip->Hide();
2458 }
2459
2460 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
2461
2462 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
2463 return kTRUE;
2464
2465 if (fState == kButtonEngaged || fState == kButtonDisabled) return kTRUE;
2466
2467 Bool_t inTB = (event->fX <= (Int_t)fTBWidth);
2468
2469 // Bool_t inMB = (event->fX >= (Int_t)(fWidth -fMBWidth)) && (event->fY >= 0) &&
2470 // (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2471
2472 if (event->fType == kEnterNotify) {
2473 if (inTB) {
2475 } else {
2476 if(fMBState == kButtonEngaged) return kTRUE;
2478 }
2479 } else {
2480 // kLeaveNotify
2481 if(fState == kButtonDown) {
2483 }
2484 if (fMBState == kButtonEngaged) return kTRUE;
2486 }
2487 return kTRUE;
2488}
2489
2490////////////////////////////////////////////////////////////////////////////////
2491/// Handle key event. This function will be called when the hotkey is hit.
2492
2494{
2495 if (fState == kButtonDisabled) return kFALSE;
2496
2498
2499 if (event->fType == kGKeyPress) {
2500 gVirtualX->SetKeyAutoRepeat(kFALSE);
2501 } else {
2502 gVirtualX->SetKeyAutoRepeat(kTRUE);
2503 }
2504
2505 if (fTip && event->fType == kGKeyPress) fTip->Hide();
2506
2507 // We don't need to check the key number as GrabKey will only
2508 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
2509
2510 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
2511 if (fState == kButtonEngaged) return kTRUE;
2513 Pressed();
2514 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
2515 if (fState == kButtonEngaged) {
2517 Released();
2518 }
2519 if (fStayDown) {
2521 } else {
2523 Released();
2524 }
2525 click = kTRUE;
2526 }
2527 if (click) {
2528 Clicked();
2533 }
2534
2535 return kTRUE;
2536}
2537
2538////////////////////////////////////////////////////////////////////////////////
2539/// Popup the attached menu.
2540
2542{
2543 if (state) {
2544 Int_t ax, ay;
2546
2547 if (fSplit) {
2548 Int_t n_entries = 0;
2549 TGMenuEntry *entry = 0;
2551
2552 while ((entry = (TGMenuEntry *) next())) {
2553 if ((entry->GetType() != kMenuSeparator) &&
2554 (entry->GetType() != kMenuLabel)) {
2555 n_entries++;
2556 }
2557 }
2558 if (n_entries <= 1) {
2559 Info("TGSplitButton", "Only one entry in the menu.");
2560 return;
2561 }
2562 }
2563
2564 gVirtualX->TranslateCoordinates(fId, fPopMenu->GetParent()->GetId(),
2565 0, 0, ax, ay, wdummy);
2566
2567 // place the menu just under the window:
2568 fPopMenu->PlaceMenu(ax-1, ay+fHeight, kTRUE, kFALSE); //kTRUE);
2569 BindKeys(kTRUE);
2571 } else {
2576 }
2577}
2578
2579////////////////////////////////////////////////////////////////////////////////
2580/// Draw the text button.
2581
2583{
2584 int x, y;
2586
2589
2590 if (fTMode & kTextLeft) {
2591 x = fMLeft + 4;
2592 } else if (fTMode & kTextRight) {
2593 x = fWidth - fTWidth -fMBWidth - fMRight - 4;
2594 } else {
2595 x = (fWidth - fTWidth -fMBWidth + fMLeft - fMRight) >> 1;
2596 }
2597
2598 if (fTMode & kTextTop) {
2599 y = fMTop + 3;
2600 } else if (fTMode & kTextBottom) {
2601 y = fHeight - fTHeight - fMBottom - 3;
2602 } else {
2603 y = (fHeight - fTHeight + fMTop - fMBottom) >> 1;
2604 }
2605
2606 if (fState == kButtonDown || fState == kButtonEngaged) { ++x; ++y; }
2607 if (fState == kButtonEngaged) {
2608 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
2609 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
2610 }
2611
2613
2614 if (fState == kButtonDisabled) {
2615 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
2616 TGGC *gc = pool->FindGC(fNormGC);
2617 if (gc) {
2618 Pixel_t fore = gc->GetForeground();
2619 Pixel_t hi = GetHilightGC().GetForeground();
2620 Pixel_t sh = GetShadowGC().GetForeground();
2621
2622 gc->SetForeground(hi);
2623 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
2624 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x + 1, y + 1, hotpos - 1);
2625
2626 gc->SetForeground(sh);
2627 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
2628 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
2629 gc->SetForeground(fore);
2630 }
2631 } else {
2632 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
2634 }
2635
2636 // Draw the parts of the button needed when a menu is attached.
2637
2638 // triangle position
2639 x = fWidth - 11;
2640 y = fHeight - 10;
2641
2642 if (fSplit) {
2643 // separator position
2644 Int_t lx = fWidth - fMBWidth;
2645 Int_t ly = 2;
2646 Int_t lh = fHeight - 2;
2647
2649 x++;
2650 y++;
2651 }
2652
2653 gVirtualX->DrawLine(fId, GetShadowGC()(), lx, ly + 2, lx, lh - 4);
2654 gVirtualX->DrawLine(fId, GetHilightGC()(), lx + 1, ly + 2, lx + 1, lh - 3);
2655 gVirtualX->DrawLine(fId, GetHilightGC()(), lx, lh - 3, lx + 1, lh - 3);
2656
2657 if (fMBState == kButtonEngaged) {
2658 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), fTBWidth + 1, 1, fMBWidth - 3, fHeight - 3);
2659 }
2660
2661 if (fMBState == kButtonDisabled) {
2662 DrawTriangle(GetHilightGC()(), x + 1, y + 1);
2663 DrawTriangle(GetShadowGC()(), x, y);
2664 } else {
2666 }
2667
2668 } else {
2669 x -= 2;
2671 x++;
2672 y++;
2673 }
2674 if (fState == kButtonDisabled) {
2675 DrawTriangle(GetHilightGC()(), x + 1, y + 1);
2676 DrawTriangle(GetShadowGC()(), x, y);
2677 } else {
2679 }
2680 }
2681
2682}
2683
2684////////////////////////////////////////////////////////////////////////////////
2685/// If on kTRUE bind arrow, popup menu hot keys, otherwise
2686/// remove key bindings.
2687
2689{
2690 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Up), kAnyModifier, on);
2691 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Down), kAnyModifier, on);
2692 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Enter), kAnyModifier, on);
2693 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Return), kAnyModifier, on);
2694 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Escape), kAnyModifier, on);
2695}
2696
2697////////////////////////////////////////////////////////////////////////////////
2698/// If on kTRUE bind Menu hot keys, otherwise remove key bindings.
2699
2701{
2702 TGMenuEntry *e = 0;
2704
2705 while ((e = (TGMenuEntry*)next())) {
2706 Int_t hot = 0;
2707 if (e->GetLabel()) {
2708 hot = e->GetLabel()->GetHotChar();
2709 }
2710 if (!hot) continue;
2711 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), 0, on);
2712 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask, on);
2713 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyLockMask, on);
2714 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyMod2Mask, on);
2715 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyLockMask, on);
2716 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyMod2Mask, on);
2717 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyLockMask | kKeyMod2Mask, on);
2718 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyLockMask | kKeyMod2Mask, on);
2719 }
2720}
2721
2722////////////////////////////////////////////////////////////////////////////////
2723/// returns default size
2724
2731
2732////////////////////////////////////////////////////////////////////////////////
2733/// Set new button text.
2734
2736{
2737 Int_t hotchar;
2738 static Bool_t longlabeltip = kFALSE;
2740
2742 if (!font) {
2744 if (font) fFontStruct = font->GetFontStruct();
2745 }
2746
2747 UInt_t width = 0, bwidth = 0, dummy;
2748 if (font) {
2749 font->ComputeTextLayout(new_label->GetString(), new_label->GetLength(),
2751 &width, &dummy);
2754 &bwidth, &dummy);
2755 }
2756 if (width > bwidth) {
2757 if (!fTip) {
2758 SetToolTipText(new_label->GetString());
2760 }
2761 Info("TGSplitbutton", "Length of new label to long, label truncated.");
2762 new_label->Resize(fWidestLabel.GetLength());
2763 } else if (new_label->GetLength() <= fWidestLabel.GetLength() && longlabeltip) {
2764 if (fTip) delete fTip;
2765 fTip = 0;
2767 }
2768
2769 if (fLabel) {
2770 if (main && fHKeycode) {
2771 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
2772 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2773 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2774 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
2775
2776 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2777 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
2778 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
2780 }
2781 delete fLabel;
2782 }
2783
2784 fLabel = new_label;
2785 if ((hotchar = fLabel->GetHotChar()) != 0) {
2786 if (main && ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0)) {
2787 main->BindKey(this, fHKeycode, kKeyMod1Mask);
2788 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2789 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2791
2792 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2796 }
2797 }
2798
2799 Layout();
2800}
2801
2802////////////////////////////////////////////////////////////////////////////////
2803/// Set new button text.
2804
2809
2810////////////////////////////////////////////////////////////////////////////////
2811/// Changes text font.
2812/// If global is kTRUE font is changed globally, otherwise - locally.
2813
2815{
2816 if (font != fFontStruct) {
2817 FontH_t v = gVirtualX->GetFontHandle(font);
2818 if (!v) return;
2819
2820 fFontStruct = font;
2821 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
2822 TGGC *gc = pool->FindGC(fNormGC);
2823
2824 if ((gc) && !global) {
2825 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
2827 }
2828 if (gc) {
2829 gc->SetFont(v);
2830 fNormGC = gc->GetGC();
2831 }
2832 fClient->NeedRedraw(this);
2833 }
2834}
2835
2836////////////////////////////////////////////////////////////////////////////////
2837/// Changes text font specified by name.
2838/// If global is true color is changed globally, otherwise - locally.
2839
2841{
2842 TGFont *font = fClient->GetFont(fontName);
2843 if (font) {
2844 SetFont(font->GetFontStruct(), global);
2845 }
2846}
2847
2848////////////////////////////////////////////////////////////////////////////////
2849/// Set the state of the Menu Button part
2850
2852{
2853 if (state != fMBState) {
2854 fMBState = state;
2855 DoRedraw();
2856 }
2857}
2858
2859////////////////////////////////////////////////////////////////////////////////
2860/// Set the split status of a button.
2861
2863{
2864 if(split) {
2865 fStayDown = kFALSE;
2866 Disconnect(fPopMenu, "PoppedDown()");
2867 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "SetMBState(=kButtonUp)");
2868 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "MBReleased()");
2869
2871 if (entry) {
2872 TGHotString *tmp = new TGHotString(*(entry->GetLabel()));
2873 SetText(tmp);
2874
2875 TString str("ItemClicked(=");
2876 str += entry->GetEntryId();
2877 str += ")";
2878 Connect("Clicked()", "TGSplitButton", this, str);
2879 fEntryId = entry->GetEntryId();
2881 }
2882 } else {
2883 fStayDown = kTRUE;
2884 Disconnect(fPopMenu, "PoppedDown()");
2885 Disconnect(this, "Clicked()", this);
2886 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "SetState(=kButtonUp)");
2887 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "Released()");
2889 TGHotString *tmp = new TGHotString(*fMenuLabel);
2890 SetText(tmp);
2891 }
2892
2893 fSplit = split;
2894 DoRedraw();
2895}
2896
2897////////////////////////////////////////////////////////////////////////////////
2898/// Handle button events.
2899
2901{
2902 if (fState == kButtonDisabled) return kFALSE;
2903
2904 if (fSplit) return HandleSButton(event);
2905
2906 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
2907 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2908
2909 Bool_t activate = kFALSE;
2911
2912 if (in) {
2913 if (event->fType == kButtonPress) {
2914 fgReleaseBtn = 0;
2915 if (fState == kButtonEngaged) {
2916 return kTRUE;
2917 }
2919 Pressed();
2922 } else { // ButtonRelease
2923 if (fState == kButtonEngaged) {
2926 Released();
2927 click = kTRUE;
2928 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2929 } else {
2930 click = (fState == kButtonDown);
2931 if (click && fStayDown) {
2934 fgReleaseBtn = 0;
2935 } else {
2937 Released();
2938 fgReleaseBtn = fId;
2939 }
2940 }
2942 }
2943 } else {
2944 if (event->fType == kButtonPress) {
2945 fgReleaseBtn = 0;
2946 } else { // ButtonRelease
2949 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2950 activate = kTRUE;
2951 }
2952 }
2953 if (click) {
2954 Clicked();
2959 }
2960 if (activate && !fKeyNavigate) {
2962 if (entry) {
2963 if ((entry->GetStatus() & kMenuEnableMask) &&
2964 !(entry->GetStatus() & kMenuHideMask) &&
2965 (entry->GetType() != kMenuSeparator) &&
2966 (entry->GetType() != kMenuLabel)) {
2967 Int_t id = entry->GetEntryId();
2968 fPopMenu->Activated(id);
2969 }
2970 }
2971 }
2972
2973 return kTRUE;
2974
2975}
2976
2977////////////////////////////////////////////////////////////////////////////////
2978/// Handle mouse crossing event.
2979
2981{
2982 if (fSplit) {
2983 return HandleSCrossing(event);
2984 } else {
2985 return TGButton::HandleCrossing(event);
2986 }
2987}
2988
2989////////////////////////////////////////////////////////////////////////////////
2990/// Handle key event. This function will be called when the hotkey is hit.
2991
2993{
2995
2996 if (fState == kButtonDisabled) return kTRUE;
2997
2998 if(fSplit) return HandleSKey(event);
2999
3000 if (event->fType == kGKeyPress) {
3001 gVirtualX->SetKeyAutoRepeat(kFALSE);
3002 } else {
3003 gVirtualX->SetKeyAutoRepeat(kTRUE);
3004 }
3005
3006 if (fTip && event->fType == kGKeyPress) fTip->Hide();
3007
3008 // We don't need to check the key number as GrabKey will only
3009 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
3010 if (event->fState & kKeyMod1Mask) {
3011 RequestFocus();
3013 if (event->fType == kGKeyPress) {
3014 if (fState == kButtonEngaged) return kTRUE;
3016 Pressed();
3017 } else if (event->fType == kKeyRelease) {
3018 click = kTRUE;
3019 if (fState == kButtonEngaged) {
3022 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3023 } else if (fState == kButtonDown && fStayDown) {
3028 TGMenuEntry *entry = 0;
3030
3031 while ((entry = (TGMenuEntry *) next())) {
3032 if ((entry->GetStatus() & kMenuEnableMask) &&
3033 !(entry->GetStatus() & kMenuHideMask) &&
3034 (entry->GetType() != kMenuSeparator) &&
3035 (entry->GetType() != kMenuLabel)) break;
3036 }
3037 if (entry) {
3039 }
3040 } else {
3041 Released();
3043 }
3044 }
3045 } else {
3047 if (event->fType == kGKeyPress) {
3048 Event_t ev;
3049 ev.fX = ev.fY = 1;
3050 UInt_t keysym;
3051 char tmp[2];
3052
3053 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
3054
3055 TGMenuEntry *ce = 0;
3057
3058 while ((ce = (TGMenuEntry*)next())) {
3059 UInt_t hot = 0;
3060 if (ce->GetLabel()) hot = ce->GetLabel()->GetHotChar();
3061 if (!hot || (hot != keysym)) continue;
3062
3064 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3066 ev.fType = kButtonRelease;
3067 ev.fWindow = fPopMenu->GetId();
3069 return HandleButton(&ev);
3070 }
3071
3072 ce = fPopMenu->GetCurrent();
3073
3074 switch ((EKeySym)keysym) {
3075 case kKey_Up:
3076 if (ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->Before(ce);
3077 while (ce && ((ce->GetType() == kMenuSeparator) ||
3078 (ce->GetType() == kMenuLabel) ||
3079 !(ce->GetStatus() & kMenuEnableMask))) {
3080 ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->Before(ce);
3081 }
3082 if (!ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->Last();
3083 break;
3084 case kKey_Down:
3085 if (ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->After(ce);
3086 while (ce && ((ce->GetType() == kMenuSeparator) ||
3087 (ce->GetType() == kMenuLabel) ||
3088 !(ce->GetStatus() & kMenuEnableMask))) {
3089 ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->After(ce);
3090 }
3091 if (!ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->First();
3092 break;
3093 case kKey_Enter:
3094 case kKey_Return:
3095 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3097 ev.fType = kButtonRelease;
3098 ev.fWindow = fPopMenu->GetId();
3100 HandleButton(&ev);
3101 break;
3102 case kKey_Escape:
3103 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3105 break;
3106 default:
3107 break;
3108 }
3109 if (ce) fPopMenu->Activate(ce);
3110 }
3111 }
3112 if (click) {
3113 Clicked();
3118 }
3119
3120 return kTRUE;
3121}
3122
3123////////////////////////////////////////////////////////////////////////////////
3124/// Handle a motion event in a TGSplitButton.
3125
3127{
3128 if (fKeyNavigate) return kTRUE;
3129
3130 if (fSplit) {
3131 if (fMBState == kButtonDown) {
3132 if (event->fX < (Int_t)fTBWidth) {
3135 }
3136 } else if (fState == kButtonDown) {
3137 if (event->fX > (Int_t)fTBWidth) {
3140 }
3141
3142 }
3143 }
3144 return kTRUE;
3145}
3146
3147////////////////////////////////////////////////////////////////////////////////
3148/// layout text button
3149
3151{
3152 UInt_t dummya = 0, dummyb = 0;
3154
3156 if (!font) {
3158 if (font) fFontStruct = font->GetFontStruct();
3159 }
3160 if (font) {
3162 fLabel->GetLength(),
3164 &dummya, &dummyb);
3165 UInt_t dummy = 0;
3168 &fTWidth, &dummy);
3171 &dummy, &fTHeight);
3172 }
3173 fTBWidth = fTWidth + 8;
3175 fHeight = fTHeight + 7;
3176 fClient->NeedRedraw(this);
3177}
3178
3179////////////////////////////////////////////////////////////////////////////////
3180/// Handle a menu item activation.
3181
3183{
3185
3186 if (fSplit) {
3188 Disconnect(this, "Clicked()", this);
3189 // connect clicked to the ItemClicked signal with the correct id
3190 Connect("Clicked()", "TGSplitButton", this,
3191 TString::Format("ItemClicked(=%d)", id));
3192
3193 // reenable hidden entries
3194 const TList *list = fPopMenu->GetListOfEntries();
3195 TIter iter(list);
3198 if (entry) {
3199 TGHotString *label = entry->GetLabel();
3200 TGHotString *tmp = new TGHotString(*label);
3201 SetText(tmp);
3202 }
3203 fPopMenu->HideEntry(id);
3204 if (entry) fEntryId = entry->GetEntryId();
3205 } else {
3207 ItemClicked(id);
3208 }
3209 DoRedraw();
3210}
@ kGKeyPress
Definition GuiTypes.h:60
@ kButtonRelease
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
@ kEnterNotify
Definition GuiTypes.h:61
@ kKeyRelease
Definition GuiTypes.h:60
@ kLeaveNotify
Definition GuiTypes.h:61
const Mask_t kWABitGravity
Definition GuiTypes.h:144
const Mask_t kGCBackground
Definition GuiTypes.h:289
const Mask_t kGCForeground
Definition GuiTypes.h:288
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
const Mask_t kGCTile
Definition GuiTypes.h:296
const Mask_t kKeyLockMask
Definition GuiTypes.h:196
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index)
Definition GuiTypes.h:35
const Mask_t kKeyMod1Mask
typically the Alt key
Definition GuiTypes.h:198
const Mask_t kGCFillStyle
Definition GuiTypes.h:294
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kWAWinGravity
Definition GuiTypes.h:145
const Mask_t kAnyModifier
Definition GuiTypes.h:210
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Mask_t kButton1Mask
Definition GuiTypes.h:203
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
const Mask_t kKeyShiftMask
Definition GuiTypes.h:195
@ kChildFrame
Definition GuiTypes.h:379
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kFixedHeight
Definition GuiTypes.h:389
@ kFixedSize
Definition GuiTypes.h:390
@ kOwnBackground
Definition GuiTypes.h:391
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kKeyMod2Mask
typically mod on numeric keys
Definition GuiTypes.h:199
const Mask_t kButton3Mask
Definition GuiTypes.h:205
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:168
@ kFillTiled
Definition GuiTypes.h:51
const Mask_t kButton2Mask
Definition GuiTypes.h:204
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
const Mask_t kGCGraphicsExposures
Definition GuiTypes.h:302
const Mask_t kEnterWindowMask
Definition GuiTypes.h:167
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton1
Definition GuiTypes.h:214
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
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
int main()
Definition Prototype.cxx:12
#define SafeDelete(p)
Definition RConfig.hxx:541
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:75
long Long_t
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
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:110
#define hi
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kC_COMMAND
@ kCM_BUTTON
@ kCM_RADIOBUTTON
@ kCM_CHECKBUTTON
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
Organizes TGButton widgets in a group.
static TClass * Class()
virtual void Remove(TGButton *button)
Removes a button from 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:322
virtual void Pressed()
Definition TGButton.h:133
static const TGGC & GetDefaultGC()
Return default graphics context.
Definition TGButton.cxx:470
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:445
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:480
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition TGButton.cxx:310
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:330
virtual void EmitSignals(Bool_t wasUp)
Emit button signals.
Definition TGButton.cxx:385
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:271
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:459
static const TGGC * fgDefaultGC
Definition TGButton.h:88
~TGButton() override
Delete button.
Definition TGButton.cxx:221
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:235
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:301
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
Definition TGButton.cxx:404
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
Selects different options.
Definition TGButton.h:264
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:1558
TGFont * FindFont(FontStruct_t font) const
Find font based on its font struct. Returns 0 if font is not found.
Definition TGFont.cxx:1744
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
FontStruct_t GetFontStruct() const
Definition TGFont.h:184
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:661
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:321
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:339
UInt_t fOptions
frame options
Definition TGFrame.h:94
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
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:430
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:755
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2520
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:645
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:765
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h: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:2479
Pixel_t fBackground
frame background color
Definition TGFrame.h:95
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
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
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
Yield an action as soon as it is clicked.
Definition TGButton.h:228
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:83
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
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:1751
void Activate(Bool_t) override
Definition TGMenu.h:209
virtual TGMenuEntry * GetEntry(Int_t id)
Find entry with specified id.
Definition TGMenu.cxx:1897
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:1705
virtual Int_t EndMenu(void *&userData)
Close menu and return ID of selected menu item.
Definition TGMenu.cxx:1289
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:1241
const TList * GetListOfEntries() const
Definition TGMenu.h:200
virtual void Activated(Int_t id)
Definition TGMenu.h:219
Selects different options.
Definition TGButton.h:321
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
Implements a button with added menu functionality.
Definition TGButton.h:378
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:541
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
Definition TGButton.cxx:869
void Layout() override
layout text button
Definition TGButton.cxx:624
Bool_t HandleKey(Event_t *event) override
Handle key event. This function will be called when the hotkey is hit.
Definition TGButton.cxx:815
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:695
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:644
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:859
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:938
Bool_t fPrevStateOn
Definition TGButton.h:157
virtual void SetFont(FontStruct_t font, Bool_t global=kFALSE)
Changes text font.
Definition TGButton.cxx:880
Int_t fTMode
Definition TGButton.h:150
~TGTextButton() override
Delete a text button widget.
Definition TGButton.cxx:595
void DoRedraw() override
Draw the text button.
Definition TGButton.cxx:747
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:918
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:923
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:970
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:152
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:232
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:129
const TGWindow * GetParent() const
Definition TGWindow.h:83
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
An abstract interface to image processing library.
Definition TImage.h:29
static TImage * Create()
Create an image.
Definition TImage.cxx:35
TObject * Next()
A doubly linked list.
Definition TList.h:38
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:869
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1114
const char * Data() const
Definition TString.h:376
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1285
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1074
std::ostream & Info()
Definition hadd.cxx:171
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Window_t fWindow
window reported event is relative to
Definition GuiTypes.h:176
UInt_t fState
key or button mask
Definition GuiTypes.h:181
Int_t fX
Definition GuiTypes.h:178
Graphics context structure.
Definition GuiTypes.h:224
Point structure (maps to the X11 XPoint structure)
Definition GuiTypes.h:356
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:93