Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGButton.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id: ee86415852b0e43b57190b9645717cf508b7920e $
2// Author: Fons Rademakers 06/01/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11/**************************************************************************
12
13 This source is based on Xclass95, a Win95-looking GUI toolkit.
14 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15
16 Xclass95 is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21**************************************************************************/
22
23
24/** \class TGButton
25 \ingroup guiwidgets
26
27A button abstract base class. It defines general button behaviour.
28
29*/
30
31
32/** \class TGTextButton
33 \ingroup guiwidgets
34
35Yield an action as soon as it is clicked. This buttons usually provides fast access to
36frequently used or critical commands. It may appear alone or placed in a group.
37
38The action it performs can be inscribed with a meaningful tooltip
39set by `SetToolTipText(const char* text, Long_t delayms=400).
40
41The text button has a label indicating the action to be taken when
42the button is pressed. The text can be a hot string ("&Exit") that
43defines the label "Exit" and keyboard mnemonics Alt+E for button
44selection. A button label can be changed by SetText(new_label).
45
46Selecting a text or picture button will generate the event:
47 - kC_COMMAND, kCM_BUTTON, button id, user data.
48*/
49
50
51/** \class TGPictureButton
52 \ingroup guiwidgets
53
54Yield an action as soon as it is clicked. This buttons usually provides fast access to
55frequently used or critical commands. It may appear alone or placed in a group.
56
57The action it performs can be inscribed with a meaningful tooltip
58set by `SetToolTipText(const char* text, Long_t delayms=400).
59
60The text button has a label indicating the action to be taken when
61the button is pressed. The text can be a hot string ("&Exit") that
62defines the label "Exit" and keyboard mnemonics Alt+E for button
63selection. A button label can be changed by SetText(new_label).
64
65Selecting a text or picture button will generate the event:
66 - kC_COMMAND, kCM_BUTTON, button id, user data.
67*/
68
69
70/** \class TGCheckButton
71 \ingroup guiwidgets
72
73Selects different options. Like text buttons, they have text or hot string as a label.
74
75Selecting a check button will generate the event:
76 - kC_COMMAND, kCM_CHECKBUTTON, button id, user data.
77
78If a command string has been specified (via SetCommand()) then this
79command string will be executed via the interpreter whenever a
80button is selected. A command string can contain the macros:
81
82 - $MSG -- kC_COMMAND, kCMCHECKBUTTON packed message
83 (use GET_MSG() and GET_SUBMSG() to unpack)
84 - $PARM1 -- button id
85 - $PARM2 -- user data pointer
86
87Before executing these macros are expanded into the respective Long_t's
88*/
89
90
91/** \class TGRadioButton
92 \ingroup guiwidgets
93
94Selects different options. Like text buttons, they have text or hot string as a label.
95
96Radio buttons are grouped usually in logical sets of two or more
97buttons to present mutually exclusive choices.
98
99Selecting a radio button will generate the event:
100 - kC_COMMAND, kCM_RADIOBUTTON, button id, user data.
101
102If a command string has been specified (via SetCommand()) then this
103command string will be executed via the interpreter whenever a
104button is selected. A command string can contain the macros:
105
106 - $MSG -- kC_COMMAND, kCMRADIOBUTTON packed message
107 (use GET_MSG() and GET_SUBMSG() to unpack)
108 - $PARM1 -- button id
109 - $PARM2 -- user data pointer
110
111Before executing these macros are expanded into the respective Long_t's
112*/
113
114
115/** \class TGSplitButton
116 \ingroup guiwidgets
117
118Implements a button with added menu functionality.
119There are 2 modes of operation available.
120
121If the button is split, a menu will popup when the menu area of the
122button is clicked. Activating a menu item changes the functionality
123of the button by having it emit a additional signal when it is
124clicked. The signal emitted when the button is clicked, is the
125ItemClicked(Int_t) signal with a different fixed value for the
126Int_t that corresponds to the id of the activated menu entry.
127
128If the button is not split, clicking it will popup the menu and the
129ItemClicked(Int_t) signal will be emitted when a menu entry is
130activated. The value of the Int_t is again equal to the value of
131the id of the activated menu entry.
132
133The mode of operation of a SplitButton can be changed on the fly
134by calling the SetSplit(Bool_t) method.
135*/
136
137
138#include "TGButton.h"
139#include "TGWidget.h"
140#include "TGPicture.h"
141#include "TGToolTip.h"
142#include "TGButtonGroup.h"
143#include "TGResourcePool.h"
144#include "TSystem.h"
145#include "TImage.h"
146#include "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
168
169////////////////////////////////////////////////////////////////////////////////
170/// Create button base class part.
171
173 : TGFrame(p, 1, 1, options)
174{
175 fWidgetId = id;
177 fMsgWindow = p;
178 fUserData = 0;
179 fTip = 0;
180 fGroup = 0;
181 fStyle = 0;
182 fTWidth = fTHeight = 0;
183
184 fNormGC = norm;
188
189// fStyle = gClient->GetStyle();
190// if (fStyle > 0) {
191// fOptions &= ~(kRaisedFrame | kDoubleBorder);
192// }
193
194 // coverity[returned_null]
195 // coverity[dereference]
196 if (p && p->IsA()->InheritsFrom(TGButtonGroup::Class())) {
198 bg->Insert(this, id);
199 }
200
202 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
203
204 gVirtualX->GrabButton(fId, kButton1, kAnyModifier,
206 kNone, kNone);
207
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Delete button.
214
216{
217 // remove from button group
218 if (fGroup) {
219 fGroup->Remove(this);
220 fGroup = 0;
221 }
222
223 if (fTip) delete fTip;
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Set button state.
228
230{
231 Bool_t was = !IsDown(); // kTRUE if button was off
232
233 if (state == kButtonDisabled)
235 else
237 if (state != fState) {
238 switch (state) {
239 case kButtonEngaged:
240 case kButtonDown:
243 break;
244 case kButtonDisabled:
245 case kButtonUp:
246 if (fStyle > 0) {
249 }
250 else {
253 }
254 break;
255 }
256 fState = state;
257 DoRedraw();
258 if (emit || fGroup) EmitSignals(was);
259 }
260}
261
262////////////////////////////////////////////////////////////////////////////////
263/// Set the button style (modern or classic).
264
266{
269 if (fStyle > 0) {
271 }
272 else {
274 }
275}
276
277////////////////////////////////////////////////////////////////////////////////
278/// Set the button style (modern or classic).
279
280void TGButton::SetStyle(const char *style)
281{
283 if (style && strstr(style, "modern")) {
284 fStyle = 1;
286 }
287 else {
288 fStyle = 0;
290 }
291}
292
293////////////////////////////////////////////////////////////////////////////////
294
296{
297 if (fStyle > 0)
298 return (fOptions & kSunkenFrame);
299 return !(fOptions & kRaisedFrame);
300}
301
302////////////////////////////////////////////////////////////////////////////////
303
305{
306 // Set button state down according to the parameter 'on'.
307
308 if (GetState() == kButtonDisabled) return;
309
311}
312
313////////////////////////////////////////////////////////////////////////////////
314/// Sets new button-group for this button.
315
320
321////////////////////////////////////////////////////////////////////////////////
322/// Handle mouse button event.
323
325{
327
328 if (fTip) fTip->Hide();
329
330 if (fState == kButtonDisabled) return kTRUE;
331
332 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
333 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
334
335 // We don't need to check the button number as GrabButton will
336 // only allow button1 events
337 if (event->fType == kButtonPress) {
338 fgReleaseBtn = 0;
339
340 if (fState == kButtonEngaged) {
341 return kTRUE;
342 }
344 } else { // ButtonRelease
345 if (fState == kButtonEngaged) {
346 if (in) SetState(kButtonUp, kTRUE);
347 click = kTRUE;
348 } else {
349 click = (fState == kButtonDown) && in;
350 if (click && fStayDown) {
351 if (in) {
353 fgReleaseBtn = 0;
354 }
355 } else {
356 if (in) {
359 }
360 }
361 }
362 }
363 if (click) {
368 }
369 if ((fStyle > 0) && (event->fType == kButtonRelease)) {
371 }
372 DoRedraw();
373 return kTRUE;
374}
375
376////////////////////////////////////////////////////////////////////////////////
377/// Emit button signals.
378
380{
381 Bool_t now = !IsDown(); // kTRUE if button now is off
382
383 // emit signals
384 if (was && !now) {
385 Pressed(); // emit Pressed = was off , now on
386 if (fStayDown) Clicked(); // emit Clicked
387 }
388 if (!was && now) {
389 Released(); // emit Released = was on , now off
390 Clicked(); // emit Clicked
391 }
392 if ((was != now) && IsToggleButton()) Toggled(!now); // emit Toggled = was != now
393}
394
395////////////////////////////////////////////////////////////////////////////////
396/// Handle mouse crossing event.
397
399{
400 if (fTip) {
401 if (event->fType == kEnterNotify)
402 fTip->Reset();
403 else
404 fTip->Hide();
405 }
406
407 if (fStyle > 0) {
408 if ((event->fType == kEnterNotify) && (fState != kButtonDisabled)) {
410 } else {
412 }
413 if (event->fType == kLeaveNotify) {
415 }
416 DoRedraw();
417 }
418
419 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
420
421 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
422 return kTRUE;
423
424 if (fState == kButtonEngaged || fState == kButtonDisabled) return kTRUE;
425
426 if (event->fType == kLeaveNotify) {
429 }
430 DoRedraw();
431 return kTRUE;
432}
433
434////////////////////////////////////////////////////////////////////////////////
435/// Set tool tip text associated with this button. The delay is in
436/// milliseconds (minimum 250). To remove tool tip call method with
437/// text = 0.
438
440{
441 if (fTip) {
442 delete fTip;
443 fTip = 0;
444 }
445
446 if (text && strlen(text))
448}
449
450////////////////////////////////////////////////////////////////////////////////
451/// Set enabled or disabled state of button
452
460
461////////////////////////////////////////////////////////////////////////////////
462/// Return default graphics context.
463
465{
466 if (!fgDefaultGC)
467 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
468 return *fgDefaultGC;
469}
470
471////////////////////////////////////////////////////////////////////////////////
472/// Return graphics context for highlighted frame background.
473
475{
476 if (!fgHibckgndGC) {
480 gval.fForeground = gClient->GetResourcePool()->GetFrameHiliteColor();
481 gval.fBackground = gClient->GetResourcePool()->GetFrameBgndColor();
482 gval.fFillStyle = kFillTiled;
483 gval.fTile = gClient->GetResourcePool()->GetCheckeredPixmap();
484 gval.fGraphicsExposures = kFALSE;
485 fgHibckgndGC = gClient->GetGC(&gval, kTRUE);
486 }
487 return *fgHibckgndGC;
488}
489
490
491////////////////////////////////////////////////////////////////////////////////
492/// Create a text button widget. The hotstring will be adopted and deleted
493/// by the text button.
494
497 UInt_t options) : TGButton(p, id, norm, options)
498{
499 fLabel = s;
500 fFontStruct = font;
501
502 Init();
503}
504
505////////////////////////////////////////////////////////////////////////////////
506/// Create a text button widget.
507
508TGTextButton::TGTextButton(const TGWindow *p, const char *s, Int_t id,
510 UInt_t options) : TGButton(p, id, norm, options)
511{
512 fLabel = new TGHotString(!p && !s ? GetName() : s);
513 fFontStruct = font;
514
515 Init();
516}
517
518////////////////////////////////////////////////////////////////////////////////
519/// Create a text button widget and set cmd string at same time.
520
521TGTextButton::TGTextButton(const TGWindow *p, const char *s, const char *cmd,
523 UInt_t options) : TGButton(p, id, norm, options)
524{
525 fLabel = new TGHotString(s);
526 fFontStruct = font;
527 fCommand = cmd;
528
529 Init();
530}
531
532////////////////////////////////////////////////////////////////////////////////
533/// Common initialization used by the different ctors.
534
536{
537 int hotchar;
538
540 fHKeycode = 0;
544 fWrapLength = -1;
545 fMLeft = fMRight = fMTop = fMBottom = 0;
546
548 if (!font) {
550 if (font) fFontStruct = font->GetFontStruct();
551 }
552 if (font) {
555 &fTWidth, &fTHeight);
556 }
557 Resize();
558 fWidth = fTWidth;
560
561 if ((hotchar = fLabel->GetHotChar()) != 0) {
562 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
564 if (main) {
565 main->BindKey(this, fHKeycode, kKeyMod1Mask);
566 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
567 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
569
570 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
574 }
575 }
576 }
579 wattr.fBitGravity = 5; // center
580 wattr.fWinGravity = 1;
581 gVirtualX->ChangeWindowAttributes(fId, &wattr);
582
584}
585
586////////////////////////////////////////////////////////////////////////////////
587/// Delete a text button widget.
588
590{
591 if (fHKeycode && (fParent->MustCleanup() != kDeepCleanup)) {
593 if (main) {
594 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
595 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
596 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
597 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
598
599 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
600 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
601 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
603 }
604 }
605 if (fLabel) delete fLabel;
606 if (fHasOwnFont) {
608 TGGC *gc = pool->FindGC(fNormGC);
609 pool->FreeGC(gc);
610 }
611
612 delete fTLayout;
613}
614
615////////////////////////////////////////////////////////////////////////////////
616/// layout text button
617
619{
621
623 if (!font) {
625 if (font) fFontStruct = font->GetFontStruct();
626 }
627 if (font) {
630 &fTWidth, &fTHeight);
631 }
632 fClient->NeedRedraw(this);
633}
634
635////////////////////////////////////////////////////////////////////////////////
636/// Set new button text.
637
639{
640 int hotchar;
642
643 if (fLabel) {
644 if (main && fHKeycode) {
645 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
646 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
647 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
648 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
649
650 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
651 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
652 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
654 }
655 delete fLabel;
656 }
657
659 if ((hotchar = fLabel->GetHotChar()) != 0) {
660 if (main && ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0)) {
661 main->BindKey(this, fHKeycode, kKeyMod1Mask);
662 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
663 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
665
666 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
670 }
671 }
672
673 Layout();
674}
675
676////////////////////////////////////////////////////////////////////////////////
677/// Set new button text.
678
683
684////////////////////////////////////////////////////////////////////////////////
685/// Set text justification. Mode is an OR of the bits:
686/// kTextTop, kTextBottom, kTextLeft, kTextRight, kTextCenterX and
687/// kTextCenterY.
688
690{
691 fTMode = mode;
692
695 wattr.fWinGravity = 1;
696
697 switch (mode) {
698 case kTextTop | kTextLeft:
699 wattr.fBitGravity = 1; //NorthWestGravity
700 break;
701 case kTextTop | kTextCenterX:
702 case kTextTop:
703 wattr.fBitGravity = 2; //NorthGravity
704 break;
705 case kTextTop | kTextRight:
706 wattr.fBitGravity = 3; //NorthEastGravity
707 break;
708 case kTextLeft | kTextCenterY:
709 case kTextLeft:
710 wattr.fBitGravity = 4; //WestGravity
711 break;
713 wattr.fBitGravity = 5; //CenterGravity
714 break;
716 case kTextRight:
717 wattr.fBitGravity = 6; //EastGravity
718 break;
719 case kTextBottom | kTextLeft:
720 wattr.fBitGravity = 7; //SouthWestGravity
721 break;
723 case kTextBottom:
724 wattr.fBitGravity = 8; //SouthGravity
725 break;
726 case kTextBottom | kTextRight:
727 wattr.fBitGravity = 9; //SouthEastGravity
728 break;
729 default:
730 wattr.fBitGravity = 5; //CenterGravity
731 break;
732 }
733
734 gVirtualX->ChangeWindowAttributes(fId, &wattr);
735 Layout();
736}
737
738////////////////////////////////////////////////////////////////////////////////
739/// Draw the text button.
740
742{
743 int x, y;
744 UInt_t w = GetWidth() - 1;
745 UInt_t h = GetHeight()- 1;
746
747 if ((fStyle > 0) && !(fOptions & kOwnBackground))
748 gVirtualX->SetWindowBackground(fId, fBgndColor);
750
751 if (fTMode & kTextLeft) {
752 x = fMLeft + 4;
753 } else if (fTMode & kTextRight) {
754 x = fWidth - fTWidth - fMRight - 4;
755 } else {
756 x = (fWidth - fTWidth + fMLeft - fMRight) >> 1;
757 }
758
759 if (fTMode & kTextTop) {
760 y = fMTop + 3;
761 } else if (fTMode & kTextBottom) {
762 y = fHeight - fTHeight - fMBottom - 3;
763 } else {
764 y = (fHeight - fTHeight + fMTop - fMBottom) >> 1;
765 }
766
768 ++x; ++y;
769 w--; h--;
770 }
771 if (fStyle == 0) {
772 if (fState == kButtonEngaged) {
773 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
774 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
775 }
776 }
777
779
780 if (fStyle > 0) {
781 gVirtualX->DrawRectangle(fId, TGFrame::GetShadowGC()(), 0, 0, w, h);
782 }
783 if (fState == kButtonDisabled) {
784 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
785 TGGC *gc = pool->FindGC(fNormGC);
786 if (gc) {
787 Pixel_t fore = gc->GetForeground();
788 Pixel_t hi = GetHilightGC().GetForeground();
789 Pixel_t sh = GetShadowGC().GetForeground();
790
791 gc->SetForeground(hi);
792 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
793 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x + 1, y + 1, hotpos - 1);
794
795 gc->SetForeground(sh);
796 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
797 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
798 gc->SetForeground(fore);
799 }
800 } else {
801 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
803 }
804}
805
806////////////////////////////////////////////////////////////////////////////////
807/// Handle key event. This function will be called when the hotkey is hit.
808
810{
811 if (fState == kButtonDisabled || !(event->fState & kKeyMod1Mask)) return kFALSE;
812
814 Bool_t was = !IsDown(); // kTRUE if button was off
815
816 if (event->fType == kGKeyPress) {
817 gVirtualX->SetKeyAutoRepeat(kFALSE);
818 } else {
819 gVirtualX->SetKeyAutoRepeat(kTRUE);
820 }
821
822 if (fTip && event->fType == kGKeyPress) fTip->Hide();
823
824 // We don't need to check the key number as GrabKey will only
825 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
826
827 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
828 if (fState == kButtonEngaged) return kTRUE;
830 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
831 if (fState == kButtonEngaged /*&& !allowRelease*/) return kTRUE;
832 click = (fState == kButtonDown);
833 if (click && fStayDown) {
835 } else {
837 }
838 }
839 if (click) {
844 }
846
847 return kTRUE;
848}
849
850////////////////////////////////////////////////////////////////////////////////
851/// returns default size
852
859
860////////////////////////////////////////////////////////////////////////////////
861/// Return default font structure.
862
864{
865 if (!fgDefaultFont)
866 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
867 return fgDefaultFont->GetFontStruct();
868}
869
870////////////////////////////////////////////////////////////////////////////////
871/// Changes text font.
872/// If global is kTRUE font is changed globally, otherwise - locally.
873
875{
876 if (font != fFontStruct) {
877 FontH_t v = gVirtualX->GetFontHandle(font);
878 if (!v) return;
879
880 fFontStruct = font;
881 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
882 TGGC *gc = pool->FindGC(fNormGC);
883
884 if (gc && !global) {
885 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
887 }
888 if (gc) {
889 gc->SetFont(v);
890 fNormGC = gc->GetGC();
891 }
892 Layout();
893 }
894}
895
896////////////////////////////////////////////////////////////////////////////////
897/// Changes text font specified by name.
898/// If global is true color is changed globally, otherwise - locally.
899
901{
902 TGFont *font = fClient->GetFont(fontName);
903 if (font) {
904 SetFont(font->GetFontStruct(), global);
905 }
906}
907
908////////////////////////////////////////////////////////////////////////////////
909/// Changes text color.
910/// If global is true color is changed globally, otherwise - locally.
911
913{
914 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
915 TGGC *gc = pool->FindGC(fNormGC);
916
917 if (gc && !global) {
918 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
920 }
921 if (gc) {
922 gc->SetForeground(color);
923 fNormGC = gc->GetGC();
924 }
925 fClient->NeedRedraw(this);
926}
927
928////////////////////////////////////////////////////////////////////////////////
929/// Returns kTRUE if text attributes are unique,
930/// returns kFALSE if text attributes are shared (global).
931
933{
934 return fHasOwnFont;
935}
936
937////////////////////////////////////////////////////////////////////////////////
938/// Create a picture button widget. The picture is not adopted and must
939/// later be freed by the user once the picture button is deleted (a single
940/// picture reference might be used by other buttons).
941
944{
945 if (!pic) {
946 Error("TGPictureButton", "pixmap not found or the file format is not supported for button %d", id);
947 fPic = fClient->GetPicture("mb_question_s.xpm");
948 } else {
949 fPic = pic;
950 }
951
952 if (fPic) {
953 fTWidth = fPic->GetWidth();
954 fTHeight = fPic->GetHeight();
955
957 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
958 }
959 fPicD = 0;
962}
963
964////////////////////////////////////////////////////////////////////////////////
965/// Create a picture button widget and set action command. The picture is
966/// not adopted and must later be freed by the user once the picture button
967/// is deleted (a single picture reference might be used by other
968/// buttons).
969
971 const char *cmd, Int_t id, GContext_t norm, UInt_t option)
972 : TGButton(p, id, norm, option)
973{
974 if (!pic) {
975 Error("TGPictureButton", "pixmap not found or the file format is not supported for button\n%s",
976 cmd ? cmd : "");
977 fPic = fClient->GetPicture("mb_question_s.xpm");
978 } else {
979 fPic = pic;
980 }
981
982 fCommand = cmd;
983
984 if (fPic) {
985 fTWidth = fPic->GetWidth();
986 fTHeight = fPic->GetHeight();
987
989 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
990 }
991 fPicD = 0;
994}
995
996////////////////////////////////////////////////////////////////////////////////
997/// Create a picture button. Where pic is the file name of the picture.
998
1001{
1002 if (!pic || !pic[0]) {
1003 if (p) Error("TGPictureButton", "pixmap not found or the file format is not supported for button");
1004 fPic = fClient->GetPicture("mb_question_s.xpm");
1005 } else {
1007 }
1008
1009 if (fPic) {
1010 fTWidth = fPic->GetWidth();
1011 fTHeight = fPic->GetHeight();
1012
1013 Resize(fTWidth + (fBorderWidth << 1) + fBorderWidth + 1,
1014 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
1015 }
1016 fPicD = 0;
1018 SetWindowName();
1019}
1020
1021////////////////////////////////////////////////////////////////////////////////
1022/// Destructor.
1023
1028
1029////////////////////////////////////////////////////////////////////////////////
1030/// Change a picture in a picture button. The picture is not adopted and
1031/// must later be freed by the user once the picture button is deleted
1032/// (a single picture reference might be used by other buttons).
1033
1035{
1036 if (!new_pic) {
1037 Error("SetPicture", "pixmap not found or the file format is not supported for button %d\n%s",
1039 return;
1040 }
1041
1042 fPic = new_pic;
1043
1044 if (fState == kButtonDisabled) {
1046 fPicD = 0;
1047 }
1048
1049 fTWidth = fPic->GetWidth();
1050 fTHeight = fPic->GetHeight();
1051
1052 fClient->NeedRedraw(this);
1053}
1054
1055////////////////////////////////////////////////////////////////////////////////
1056/// Redraw picture button.
1057
1059{
1060 if (!fPic) {
1062 return;
1063 }
1064
1065 int x = (fWidth - fTWidth) >> 1;
1066 int y = (fHeight - fTHeight) >> 1;
1067 UInt_t w = GetWidth() - 1;
1068 UInt_t h = GetHeight()- 1;
1069
1070 if ((fStyle > 0) && !(fOptions & kOwnBackground))
1071 gVirtualX->SetWindowBackground(fId, fBgndColor);
1073
1074 if (fState == kButtonDown || fState == kButtonEngaged) {
1075 ++x; ++y;
1076 w--; h--;
1077 }
1078 if (fStyle == 0) {
1079 if (fState == kButtonEngaged) {
1080 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
1081 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
1082 }
1083 }
1084
1085 const TGPicture *pic = fPic;
1086 if (fState == kButtonDisabled) {
1088 pic = fPicD ? fPicD : fPic;
1089 }
1090 if (fStyle > 0) {
1091 if (fBgndColor == fHighColor) {
1092 gVirtualX->DrawRectangle(fId, TGFrame::GetShadowGC()(), 0, 0, w, h);
1093 }
1094 }
1095
1096 pic->Draw(fId, fNormGC, x, y);
1097}
1098
1099////////////////////////////////////////////////////////////////////////////////
1100/// Creates disabled picture.
1101
1103{
1105 if (!img) return;
1107 if (!img2) {
1108 if (img) delete img;
1109 return;
1110 }
1111 TString back = gEnv->GetValue("Gui.BackgroundColor", "#c0c0c0");
1112 img2->FillRectangle(back.Data(), 0, 0, fPic->GetWidth(), fPic->GetHeight());
1113 img->SetImage(fPic->GetPicture(), fPic->GetMask());
1114 Pixmap_t mask = img->GetMask();
1115 img2->Merge(img, "overlay");
1116
1117 TString name = "disbl_";
1118 name += fPic->GetName();
1119 fPicD = fClient->GetPicturePool()->GetPicture(name.Data(), img2->GetPixmap(),
1120 mask);
1122 delete img;
1123 delete img2;
1124}
1125
1126////////////////////////////////////////////////////////////////////////////////
1127/// Changes disabled picture.
1128
1130{
1131 if (!pic) return;
1132
1134 fPicD = pic;
1135 ((TGPicture*)pic)->AddReference();
1137}
1138
1139////////////////////////////////////////////////////////////////////////////////
1140/// Create a check button widget. The hotstring will be adopted and deleted
1141/// by the check button.
1142
1145 : TGTextButton(p, s, id, norm, font, option)
1146{
1147 Init();
1148}
1149
1150////////////////////////////////////////////////////////////////////////////////
1151/// Create a check button widget.
1152
1155 : TGTextButton(p, s, id, norm, font, option)
1156{
1157 Init();
1158}
1159
1160////////////////////////////////////////////////////////////////////////////////
1161/// Create a check button widget.
1162
1163TGCheckButton::TGCheckButton(const TGWindow *p, const char *s, const char *cmd,
1165 UInt_t option) : TGTextButton(p, s, cmd, id, norm, font, option)
1166{
1167 Init();
1168}
1169
1170////////////////////////////////////////////////////////////////////////////////
1171/// Common check button initialization.
1172
1174{
1175 fPrevState =
1176 fState = kButtonUp;
1177 fHKeycode = 0;
1178
1179 fOn = fClient->GetPicture("checked_t.xpm");
1180 fOff = fClient->GetPicture("unchecked_t.xpm");
1181 fDisOn = fClient->GetPicture("checked_dis_t.xpm");
1182 fDisOff = fClient->GetPicture("unchecked_dis_t.xpm");
1183
1184 Resize();
1185
1186 if (!fOn) {
1187 Error("TGCheckButton", "checked_t.xpm not found or the file format is not supported.");
1188 } else if (!fOff) {
1189 Error("TGCheckButton", "unchecked_t.xpm not found or the file format is not supported.");
1190 } else if (!fDisOn) {
1191 Error("TGCheckButton", "checked_dis_t.xpm not found or the file format is not supported.");
1192 } else if (!fDisOff) {
1193 Error("TGCheckButton", "unchecked_dis_t.xpm not found or the file format is not supported.");
1194 }
1195 int hotchar;
1196
1197 if ((hotchar = fLabel->GetHotChar()) != 0) {
1198 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
1200 if (main) {
1201 main->BindKey(this, fHKeycode, kKeyMod1Mask);
1202 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
1203 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
1205
1206 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
1210 }
1211 }
1212 }
1213 SetWindowName();
1214}
1215
1216////////////////////////////////////////////////////////////////////////////////
1217/// Delete a check button.
1218
1226
1227////////////////////////////////////////////////////////////////////////////////
1228/// default size
1229
1231{
1232 UInt_t w = !fTWidth ? fOff->GetWidth() : fTWidth + fOff->GetWidth() + 9;
1233 UInt_t h = !fTHeight ? fOff->GetHeight() : fTHeight + 2;
1234
1235 w = GetOptions() & kFixedWidth ? fWidth : w;
1236 h = GetOptions() & kFixedHeight ? fHeight : h;
1237
1238 return TGDimension(w, h);
1239}
1240
1241////////////////////////////////////////////////////////////////////////////////
1242/// Set check button state.
1243
1245{
1246 if (state == kButtonDisabled)
1248 else
1250 PSetState(state, emit);
1251}
1252
1253////////////////////////////////////////////////////////////////////////////////
1254/// Emit signals.
1255
1257{
1258 if (fState == kButtonUp) Released(); // emit Released
1259 if (fState == kButtonDown) Pressed(); // emit Pressed
1260 Clicked(); // emit Clicked
1261 Toggled(fStateOn); // emit Toggled
1262}
1263
1264////////////////////////////////////////////////////////////////////////////////
1265/// Set check button state.
1266
1268{
1269 if (state != fState) {
1270 if (state == kButtonUp) {
1271 if (fPrevState == kButtonDisabled) {
1272 if (fStateOn) {
1275 } else {
1276 fState = state;
1277 fPrevState = state;
1278 }
1279 } else if (fPrevState == kButtonDown) {
1280 fStateOn = kFALSE;
1281 fState = state;
1282 fPrevState = state;
1283 }
1284 } else if (state == kButtonDown) {
1285 fStateOn = kTRUE;
1286 fState = state;
1287 fPrevState = state;
1288 } else {
1289 fState = state;
1290 fPrevState = state;
1291 }
1292 if (emit) {
1293 // button signals
1294 EmitSignals();
1295 }
1296 DoRedraw();
1297 }
1298}
1299
1300////////////////////////////////////////////////////////////////////////////////
1301/// Set the state of a check button to disabled and either on or
1302/// off.
1303
1305{
1306 if (!enable) {
1307 if (fState == kButtonDisabled && fStateOn) {
1308 PSetState(kButtonUp, kFALSE); // enable button
1309 PSetState(kButtonUp, kFALSE); // set button up
1310 PSetState(kButtonDisabled, kFALSE); // disable button
1311 } else {
1314 }
1315 } else {
1316 PSetState(kButtonDown, kFALSE); // set button down
1317 PSetState(kButtonDisabled, kFALSE); // disable button
1318 }
1319}
1320
1321////////////////////////////////////////////////////////////////////////////////
1322/// Handle mouse button event.
1323
1325{
1327
1328 if (fTip) fTip->Hide();
1329
1330 if (fState == kButtonDisabled) return kTRUE;
1331
1332 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
1333 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
1334
1335 // We don't need to check the button number as GrabButton will
1336 // only allow button1 events
1337 if (event->fType == kButtonPress) {
1338 fgReleaseBtn = 0;
1339 if (in) {
1341 Pressed();
1342 }
1343 } else { // ButtonRelease
1344 if (in) {
1346 click = kTRUE;
1348 Released();
1349 }
1350 fgReleaseBtn = fId;
1352 }
1353 if (click) {
1354 Clicked();
1360 }
1361 DoRedraw();
1362 return kTRUE;
1363}
1364
1365////////////////////////////////////////////////////////////////////////////////
1366/// Handle mouse crossing event.
1367
1369{
1370 if (fTip) {
1371 if (event->fType == kEnterNotify)
1372 fTip->Reset();
1373 else
1374 fTip->Hide();
1375 }
1376
1377 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
1378
1379 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
1380 return kTRUE;
1381
1382 if (fState == kButtonDisabled) return kTRUE;
1383
1384 if (event->fType == kEnterNotify) {
1386 } else {
1388 }
1389 DoRedraw();
1390
1391 return kTRUE;
1392}
1393
1394////////////////////////////////////////////////////////////////////////////////
1395/// Handle key event. This function will be called when the hotkey is hit.
1396
1398{
1400
1401 if (event->fType == kGKeyPress)
1402 gVirtualX->SetKeyAutoRepeat(kFALSE);
1403 else
1404 gVirtualX->SetKeyAutoRepeat(kTRUE);
1405
1406 if (fTip && event->fType == kGKeyPress) fTip->Hide();
1407
1408 if (fState == kButtonDisabled) return kTRUE;
1409
1410 // We don't need to check the key number as GrabKey will only
1411 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
1412
1413 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
1415 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
1416 click = (fState != fPrevState);
1418 }
1419 if (click) {
1424 }
1425 return kTRUE;
1426}
1427
1428////////////////////////////////////////////////////////////////////////////////
1429/// Draw the check button widget.
1430
1432{
1433 int x, y, y0;
1434
1436
1437 x = 20;
1438 y = (fHeight - fTHeight) >> 1;
1439
1440 y0 = !fTHeight ? 0 : y + 1;
1441 if (fOn && fOff) {
1442 Int_t smax = std::max(fOn->GetHeight(), fOff->GetHeight());
1443 y0 = ((Int_t)fHeight <= smax) ? 0 : 1 + (((Int_t)fHeight - smax) >> 1);
1444 }
1445
1446 if (fStateOn) {
1447 if (fOn) fOn->Draw(fId, fNormGC, 0, y0);
1448 } else {
1449 if (fOff) fOff->Draw(fId, fNormGC, 0, y0);
1450 }
1451
1453
1454 if (fState == kButtonDisabled) {
1455 if (fStateOn == kTRUE) {
1456 if (fDisOn) fDisOn->Draw(fId, fNormGC, 0, y0);
1457 } else {
1458 if (fDisOff) fDisOff->Draw(fId, fNormGC, 0, y0);
1459 }
1460
1461 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
1462 TGGC *gc = pool->FindGC(fNormGC);
1463 if (gc) {
1464 Pixel_t fore = gc->GetForeground();
1465 Pixel_t hi = GetHilightGC().GetForeground();
1466 Pixel_t sh = GetShadowGC().GetForeground();
1467
1468 gc->SetForeground(hi);
1469 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
1470 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
1471
1472 gc->SetForeground(sh);
1473 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
1474 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
1475
1476 gc->SetForeground(fore);
1477 }
1478 } else {
1479 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
1481 }
1482}
1483
1484////////////////////////////////////////////////////////////////////////////////
1485/// Return default font structure.
1486
1488{
1489 if (!fgDefaultFont)
1490 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
1491 return fgDefaultFont->GetFontStruct();
1492}
1493
1494////////////////////////////////////////////////////////////////////////////////
1495/// Return default graphics context.
1496
1498{
1499 if (!fgDefaultGC)
1500 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1501 return *fgDefaultGC;
1502}
1503
1504
1505////////////////////////////////////////////////////////////////////////////////
1506/// Create a radio button widget. The hotstring will be adopted and deleted
1507/// by the radio button.
1508
1511 : TGTextButton(p, s, id, norm, font, option)
1512{
1513 Init();
1514}
1515
1516////////////////////////////////////////////////////////////////////////////////
1517/// Create a radio button widget.
1518
1521 : TGTextButton(p, s, id, norm, font, option)
1522{
1523 Init();
1524}
1525////////////////////////////////////////////////////////////////////////////////
1526/// Create a radio button widget.
1527
1528TGRadioButton::TGRadioButton(const TGWindow *p, const char *s, const char *cmd,
1529 Int_t id, GContext_t norm,
1531 : TGTextButton(p, s, cmd, id, norm, font, option)
1532{
1533 Init();
1534}
1535
1536////////////////////////////////////////////////////////////////////////////////
1537/// Common radio button initialization.
1538
1540{
1541 fPrevState =
1542 fState = kButtonUp;
1543 fHKeycode = 0;
1544
1545 fOn = fClient->GetPicture("rbutton_on.xpm");
1546 fOff = fClient->GetPicture("rbutton_off.xpm");
1547 fDisOn = fClient->GetPicture("rbutton_dis_on.xpm");
1548 fDisOff = fClient->GetPicture("rbutton_dis_off.xpm");
1549
1550 if (!fOn || !fOff || !fDisOn || !fDisOff)
1551 Error("TGRadioButton", "rbutton_*.xpm not found or the file format is not supported.");
1552
1553 Resize();
1554
1555 int hotchar;
1556
1557 if ((hotchar = fLabel->GetHotChar()) != 0) {
1558 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
1560 if (main) {
1561 main->BindKey(this, fHKeycode, kKeyMod1Mask);
1562 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
1563 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
1565
1566 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
1570 }
1571 }
1572 }
1573
1574 if (fParent->IsA()->InheritsFrom(TGButtonGroup::Class())) {
1575 ((TGButtonGroup*)fParent)->SetRadioButtonExclusive(kTRUE);
1576 }
1577 SetWindowName();
1578}
1579
1580////////////////////////////////////////////////////////////////////////////////
1581/// Delete a radio button.
1582
1590
1591////////////////////////////////////////////////////////////////////////////////
1592/// default size
1593
1595{
1596 UInt_t w = !fTWidth ? ( fOff?fOff->GetWidth():10) : fTWidth + fOff->GetWidth() + 10;
1597 UInt_t h = !fTHeight ? ( fOff?fOff->GetHeight():2) : fTHeight + 2;
1598
1599 w = GetOptions() & kFixedWidth ? fWidth : w;
1600 h = GetOptions() & kFixedHeight ? fHeight : h;
1601
1602 return TGDimension(w, h);
1603}
1604////////////////////////////////////////////////////////////////////////////////
1605/// Set radio button state.
1606
1608{
1609 if (state == kButtonDisabled)
1611 else
1613 PSetState(state, emit);
1614}
1615
1616////////////////////////////////////////////////////////////////////////////////
1617/// Set the state of a radio button to disabled and either on or
1618/// off.
1619
1621{
1622 if (!enable) {
1623 if (fState == kButtonDisabled && fStateOn) {
1624 PSetState(kButtonUp, kFALSE); // enable button
1625 PSetState(kButtonUp, kFALSE); // set button up
1626 PSetState(kButtonDisabled, kFALSE); // disable button
1627 } else {
1630 }
1631 } else {
1632 PSetState(kButtonDown, kFALSE); // set button down
1633 PSetState(kButtonDisabled, kFALSE); // disable button
1634 }
1635}
1636
1637////////////////////////////////////////////////////////////////////////////////
1638/// Emit signals.
1639
1641{
1642 if (fState == kButtonUp) Released(); // emit Released
1643 if (fState == kButtonDown) Pressed(); // emit Pressed
1644 Clicked(); // emit Clicked
1645 Toggled(fStateOn); // emit Toggled
1646}
1647
1648////////////////////////////////////////////////////////////////////////////////
1649/// Set radio button state.
1650
1652{
1653 if (state != fState) {
1654 // fPrevState = fState = state;
1655 if (state == kButtonUp) {
1656 if (fPrevState == kButtonDisabled) {
1657 if (fStateOn) {
1660 } else {
1661 fState = state;
1662 fPrevState = state;
1663 }
1664 } else if (fPrevState == kButtonDown) {
1665 fStateOn = kFALSE;
1666 fState = state;
1667 fPrevState = state;
1668 }
1669 } else if (state == kButtonDown) {
1670 fStateOn = kTRUE;
1671 fState = state;
1672 fPrevState = state;
1673 } else {
1674 fState = state;
1675 fPrevState = state;
1676 }
1677 if (emit) {
1678 // button signals
1679 EmitSignals();
1680 }
1681 DoRedraw();
1682 }
1683}
1684
1685////////////////////////////////////////////////////////////////////////////////
1686/// Handle mouse button event.
1687
1689{
1692
1693 if (fTip) fTip->Hide();
1694
1695 if (fState == kButtonDisabled) return kFALSE;
1696
1697
1698 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
1699 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
1700
1701 if (event->fType == kButtonPress) { // button pressed
1702 fgReleaseBtn = 0;
1703 if (in) {
1705 Pressed();
1706 }
1707 } else { // ButtonRelease
1708 if (in) {
1709 if (!fStateOn) {
1711 toggled = kTRUE;
1712 }
1714 Released();
1715 click = kTRUE;
1716 }
1718 fgReleaseBtn = fId;
1719 }
1720 if (click) {
1721 Clicked();
1726 }
1727 if (toggled) {
1729 }
1730 DoRedraw();
1731 return kTRUE;
1732}
1733
1734////////////////////////////////////////////////////////////////////////////////
1735/// Handle mouse crossing event.
1736
1738{
1739 if (fTip) {
1740 if (event->fType == kEnterNotify)
1741 fTip->Reset();
1742 else
1743 fTip->Hide();
1744 }
1745
1746 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
1747
1748 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
1749 return kTRUE;
1750
1751 if (fState == kButtonDisabled) return kTRUE;
1752
1753 if (event->fType == kEnterNotify) {
1755 } else {
1757 }
1758 DoRedraw();
1759
1760 return kTRUE;
1761}
1762
1763////////////////////////////////////////////////////////////////////////////////
1764/// Handle key event. This function will be called when the hotkey is hit.
1765
1767{
1768 if (event->fType == kGKeyPress)
1769 gVirtualX->SetKeyAutoRepeat(kFALSE);
1770 else
1771 gVirtualX->SetKeyAutoRepeat(kTRUE);
1772
1773 if (fTip && event->fType == kGKeyPress)
1774 fTip->Hide();
1775
1776 if (fState == kButtonDisabled) return kTRUE;
1777
1778 // We don't need to check the key number as GrabKey will only
1779 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
1780
1781 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
1787 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
1789 }
1790 return kTRUE;
1791}
1792
1793////////////////////////////////////////////////////////////////////////////////
1794/// Draw a radio button.
1795
1797{
1798 Int_t tx, ty, y0;
1799
1801
1802 tx = 20;
1803 ty = (fHeight - fTHeight) >> 1;
1804
1805// pw = 12;
1806 y0 = !fTHeight ? 0 : ty + 1;
1807 if (fOn && fOff) {
1808 Int_t smax = std::max(fOn->GetHeight(), fOff->GetHeight());
1809 y0 = ((Int_t)fHeight <= smax) ? 0 : 1 + (((Int_t)fHeight - smax) >> 1);
1810 }
1811
1812 if (fStateOn) {
1813 if (fOn) fOn->Draw(fId, fNormGC, 0, y0);
1814 } else {
1815 if (fOff) fOff->Draw(fId, fNormGC, 0, y0);
1816 }
1817
1819
1820 if (fState == kButtonDisabled) {
1821 if (fStateOn == kTRUE) {
1822 if (fDisOn) fDisOn->Draw(fId, fNormGC, 0, y0);
1823 } else {
1824 if (fDisOff) fDisOff->Draw(fId, fNormGC, 0, y0);
1825 }
1826
1827 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
1828 TGGC *gc = pool->FindGC(fNormGC);
1829 if (gc) {
1830 Pixel_t fore = gc->GetForeground();
1831 Pixel_t hi = GetHilightGC().GetForeground();
1832 Pixel_t sh = GetShadowGC().GetForeground();
1833
1834 gc->SetForeground(hi);
1835 fTLayout->DrawText(fId, gc->GetGC(), tx + 1, ty + 1, 0, -1);
1836 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), tx, ty, hotpos - 1);
1837
1838 gc->SetForeground(sh);
1839 fTLayout->DrawText(fId, gc->GetGC(), tx, ty, 0, -1);
1840 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), tx, ty, hotpos - 1);
1841
1842 gc->SetForeground(fore);
1843 }
1844 } else {
1845 fTLayout->DrawText(fId, fNormGC, tx, ty, 0, -1);
1847 }
1848}
1849
1850////////////////////////////////////////////////////////////////////////////////
1851/// Return default font structure.
1852
1854{
1855 if (!fgDefaultFont)
1856 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
1857 return fgDefaultFont->GetFontStruct();
1858}
1859
1860////////////////////////////////////////////////////////////////////////////////
1861/// Return default graphics context.
1862
1864{
1865 if (!fgDefaultGC)
1866 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1867 return *fgDefaultGC;
1868}
1869
1870////////////////////////////////////////////////////////////////////////////////
1871/// Save a button widget as a C++ statement(s) on output stream out.
1872
1873void TGButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1874{
1875 if (option && strstr(option, "keep_names"))
1876 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
1877
1878 if (fState == kButtonDown)
1879 out << " " << GetName() << "->SetState(kButtonDown);\n";
1880 if (fState == kButtonDisabled)
1881 out << " " << GetName() << "->SetState(kButtonDisabled);\n";
1882 if (fState == kButtonEngaged)
1883 out << " " << GetName() << "->SetState(kButtonEngaged);\n";
1884
1886 SaveUserColor(out, option);
1887 out << " " << GetName() << "->ChangeBackground(ucolor);\n";
1888 }
1889
1890 if (fTip)
1891 out << " " << GetName() << "->SetToolTipText(\""
1892 << TString(fTip->GetText()->GetString()).ReplaceSpecialCppChars() << "\");\n";
1893 if (fCommand.Length() > 0)
1894 out << " " << GetName() << "->SetCommand(\"" << TString(fCommand).ReplaceSpecialCppChars() << "\");\n";
1895}
1896
1897////////////////////////////////////////////////////////////////////////////////
1898/// Save a text button widget as a C++ statement(s) on output stream out.
1899
1900void TGTextButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1901{
1903 if (fLabel->GetHotPos() > 0)
1904 outext.Insert(fLabel->GetHotPos()-1, "&");
1905
1906 // font + GC
1907 option = GetName()+5; // unique digit id of the name
1909 parFont.Form("%s::GetDefaultFontStruct()",IsA()->GetName());
1910 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
1911
1912 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
1913 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
1914 if (ufont) {
1915 ufont->SavePrimitive(out, option);
1916 parFont.Form("ufont->GetFontStruct()");
1917 }
1918
1919 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
1920 if (userGC) {
1921 userGC->SavePrimitive(out, option);
1922 parGC.Form("uGC->GetGC()");
1923 }
1924 }
1925
1926 out << " TGTextButton *" << GetName() << " = new TGTextButton(" << fParent->GetName()
1927 << ", \"" << outext.ReplaceSpecialCppChars() << "\"";
1928
1929 if (GetOptions() == (kRaisedFrame | kDoubleBorder)) {
1931 if (fNormGC == GetDefaultGC()()) {
1932 if (fWidgetId == -1) {
1933 out << ");\n";
1934 } else {
1935 out << "," << fWidgetId <<");\n";
1936 }
1937 } else {
1938 out << "," << fWidgetId << "," << parGC << ");\n";
1939 }
1940 } else {
1941 out << "," << fWidgetId << "," << parGC << "," << parFont << ");\n";
1942 }
1943 } else {
1944 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");\n";
1945 }
1946
1947 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");\n";
1948 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << "," << fMTop << "," << fMBottom
1949 << ");\n";
1950 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");\n";
1951
1952 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetHeight() << ");\n";
1953
1955}
1956
1957////////////////////////////////////////////////////////////////////////////////
1958/// Save a picture button widget as a C++ statement(s) on output stream out.
1959
1960void TGPictureButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1961{
1962 if (!fPic) {
1963 Error("SavePrimitive", "pixmap not found or the file format is not supported for picture button %d ", fWidgetId);
1964 return;
1965 }
1966
1967 // GC
1968 option = GetName()+5; // unique digit id of the name
1969 TString parGC;
1970 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
1971
1972 if (GetDefaultGC()() != fNormGC) {
1973 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
1974 if (userGC) {
1975 userGC->SavePrimitive(out, option);
1976 parGC.Form("uGC->GetGC()");
1977 }
1978 }
1979
1980 TString picname = gSystem->UnixPathName(fPic->GetName());
1982
1983 out << " TGPictureButton *" << GetName() << " = new TGPictureButton(" << fParent->GetName()
1984 << ", gClient->GetPicture(\"" << picname.ReplaceSpecialCppChars() << "\")";
1985
1986 if (GetOptions() == (kRaisedFrame | kDoubleBorder)) {
1987 if (fNormGC == GetDefaultGC()()) {
1988 if (fWidgetId == -1) {
1989 out << ");\n";
1990 } else {
1991 out << "," << fWidgetId << ");\n";
1992 }
1993 } else {
1994 out << "," << fWidgetId << "," << parGC << ");\n";
1995 }
1996 } else {
1997 out << "," << fWidgetId << "," << parGC << "," << GetOptionString() << ");\n";
1998 }
1999
2001}
2002
2003////////////////////////////////////////////////////////////////////////////////
2004/// Save a check button widget as a C++ statement(s) on output stream out.
2005
2006void TGCheckButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2007{
2009 if (fLabel->GetHotPos() > 0)
2010 outext.Insert(fLabel->GetHotPos()-1, "&");
2011
2012 out <<" TGCheckButton *" << GetName() << " = new TGCheckButton(" << fParent->GetName()
2013 << ", \"" << outext.ReplaceSpecialCppChars() << "\"";
2014
2015 // font + GC
2016 option = GetName()+5; // unique digit id of the name
2018 parFont.Form("%s::GetDefaultFontStruct()", IsA()->GetName());
2019 parGC.Form("%s::GetDefaultGC()()", IsA()->GetName());
2020
2021 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
2022 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
2023 if (ufont) {
2024 ufont->SavePrimitive(out, option);
2025 parFont.Form("ufont->GetFontStruct()");
2026 }
2027
2028 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
2029 if (userGC) {
2030 userGC->SavePrimitive(out, option);
2031 parGC.Form("uGC->GetGC()");
2032 }
2033 }
2034
2035 if (GetOptions() == kChildFrame) {
2037 if (fNormGC == GetDefaultGC()()) {
2038 if (fWidgetId == -1) {
2039 out << ");\n";
2040 } else {
2041 out << "," << fWidgetId << ");\n";
2042 }
2043 } else {
2044 out << "," << fWidgetId << "," << parGC << ");\n";
2045 }
2046 } else {
2047 out << "," << fWidgetId << "," << parGC << "," << parFont << ");\n";
2048 }
2049 } else {
2050 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");\n";
2051 }
2052
2054 if (fState == kButtonDisabled) {
2056 out << " " << GetName() << "->SetDisabledAndSelected(kTRUE);\n";
2057 else
2058 out << " " << GetName() << "->SetDisabledAndSelected(kFALSE);\n";
2059 }
2060 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");\n";
2061 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << "," << fMTop << "," << fMBottom
2062 << ");\n";
2063 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");\n";
2064}
2065
2066////////////////////////////////////////////////////////////////////////////////
2067/// Save a radio button widget as a C++ statement(s) on output stream out.
2068
2069void TGRadioButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2070{
2072 if (fLabel->GetHotPos() > 0)
2073 outext.Insert(fLabel->GetHotPos() - 1, "&");
2074
2075 out << " TGRadioButton *" << GetName() << " = new TGRadioButton(" << fParent->GetName() << ", \""
2076 << outext.ReplaceSpecialCppChars() << "\"";
2077
2078 // font + GC
2079 option = GetName() + 5; // unique digit id of the name
2081 parFont.Form("%s::GetDefaultFontStruct()", IsA()->GetName());
2082 parGC.Form("%s::GetDefaultGC()()", IsA()->GetName());
2083
2084 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
2085 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
2086 if (ufont) {
2087 ufont->SavePrimitive(out, option);
2088 parFont.Form("ufont->GetFontStruct()");
2089 }
2090
2091 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
2092 if (userGC) {
2093 userGC->SavePrimitive(out, option);
2094 parGC.Form("uGC->GetGC()");
2095 }
2096 }
2097
2098 if (GetOptions() == (kChildFrame)) {
2100 if (fNormGC == GetDefaultGC()()) {
2101 if (fWidgetId == -1) {
2102 out << ");\n";
2103 } else {
2104 out << "," << fWidgetId << ");\n";
2105 }
2106 } else {
2107 out << "," << fWidgetId << "," << parGC << ");\n";
2108 }
2109 } else {
2110 out << "," << fWidgetId << "," << parGC << "," << parFont << ");\n";
2111 }
2112 } else {
2113 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");\n";
2114 }
2115
2117 if (fState == kButtonDisabled) {
2119 out << " " << GetName() << "->SetDisabledAndSelected(kTRUE);\n";
2120 else
2121 out << " " << GetName() << "->SetDisabledAndSelected(kFALSE);\n";
2122 }
2123 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");\n";
2124 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << "," << fMTop << "," << fMBottom
2125 << ");\n";
2126 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");\n";
2127}
2128
2129////////////////////////////////////////////////////////////////////////////////
2130/// Create a menu button widget. The hotstring will be adopted and
2131/// deleted by the menu button. This constructor creates a
2132/// menubutton with a popup menu attached that appears when the
2133/// button for it is clicked. The popup menu is adopted.
2134
2136 TGPopupMenu *popmenu, Bool_t split, Int_t id,
2138 : TGTextButton(p, menulabel, id, norm, fontstruct, options)
2139{
2141 fMBWidth = 16;
2143 fPopMenu = popmenu;
2144 fPopMenu->fSplitButton = this;
2145 fSplit = split;
2146 fTMode = 0;
2147 fHKeycode = 0;
2148 fMBState = kButtonUp; fDefaultCursor = fClient->GetResourcePool()->GetGrabCursor();
2150 fWidestLabel = "";
2151 fHeighestLabel = "";
2152
2153 // Find and set the correct size for the menu and the button.
2154 TGMenuEntry *entry = 0;
2157 const TList *list = fPopMenu->GetListOfEntries();
2158 UInt_t lwidth = 0, lheight = 0;
2159 UInt_t twidth = 0, theight = 0;
2160
2162 if (!font) {
2164 if (font) fFontStruct = font->GetFontStruct();
2165 }
2166
2167 if (font) font->ComputeTextLayout(lstring, lstring.GetLength(),
2169 &lwidth, &lheight);
2170
2171 TIter iter(list);
2172 entry = (TGMenuEntry *)iter.Next();
2173 while (entry != 0) {
2174 if (entry->GetType() == kMenuEntry) {
2175 const TGHotString string(*(entry->GetLabel()));
2176 if (font) font->ComputeTextLayout(string, string.GetLength(),
2178 &twidth, &theight);
2179 if(twidth > lwidth) {
2180 lstring = string;
2181 }
2182 if(theight > lheight) {
2183 hstring = string;
2184 }
2185 }
2186 entry = (TGMenuEntry *)iter.Next();
2187 }
2190
2191 if (font) {
2192 UInt_t dummy = 0;
2193 font->ComputeTextLayout(lstring, lstring.GetLength(),
2195 &fTWidth, &dummy);
2196 font->ComputeTextLayout(hstring, hstring.GetLength(),
2198 &dummy, &fTHeight);
2199 }
2200 fTBWidth = fTWidth + 8;
2201 fHeight = fTHeight + 7;
2203
2205
2206 // Save the id of the 1st item on the menu.
2207 TIter iter1(list);
2208 do {
2209 entry = (TGMenuEntry *)iter1.Next();
2210 if ((entry) && (entry->GetStatus() & kMenuEnableMask) &&
2211 !(entry->GetStatus() & kMenuHideMask) &&
2212 (entry->GetType() != kMenuSeparator) &&
2213 (entry->GetType() != kMenuLabel)) break;
2214 entry = (TGMenuEntry *)iter1.Next();
2215 } while (entry);
2216 if (entry) fEntryId = entry->GetEntryId();
2217
2218 // An additional connection that is needed.
2219 fPopMenu->Connect("Activated(Int_t)", "TGSplitButton", this, "HandleMenu(Int_t)");
2221
2222 Init();
2223}
2224
2225
2226////////////////////////////////////////////////////////////////////////////////
2227/// Common initialization used by the different ctors.
2228
2230{
2231 Int_t hotchar;
2232
2234 fHKeycode = 0;
2236 fPrevStateOn =
2237 fStateOn = kFALSE;
2239
2241
2242 if ((hotchar = fLabel->GetHotChar()) != 0) {
2243 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
2245 if (main) {
2246 main->BindKey(this, fHKeycode, kKeyMod1Mask);
2247 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2248 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2250
2251 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2255 }
2256 }
2257 }
2260 wattr.fBitGravity = 5; // center
2261 wattr.fWinGravity = 1;
2262 gVirtualX->ChangeWindowAttributes(fId, &wattr);
2263
2264 // Make sure motion is detected too.
2266
2267 SetWindowName();
2268}
2269
2270////////////////////////////////////////////////////////////////////////////////
2271/// Delete a split button widget.
2272
2274{
2275 if (fPopMenu) delete fPopMenu;
2276 if (fMenuLabel) delete fMenuLabel;
2277}
2278
2279////////////////////////////////////////////////////////////////////////////////
2280/// Draw triangle (arrow) on which user can click to open Popup.
2281
2283{
2284 Point_t points[3];
2285
2286 points[0].fX = x;
2287 points[0].fY = y;
2288 points[1].fX = x + 5;
2289 points[1].fY = y;
2290 points[2].fX = x + 2;
2291 points[2].fY = y + 3;
2292
2293 gVirtualX->FillPolygon(fId, gc, points, 3);
2294}
2295
2296////////////////////////////////////////////////////////////////////////////////
2297/// Calculate the size of the button.
2298
2300{
2303 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2305
2306 fTBWidth = fTWidth + 8;
2307 fHeight = fTHeight + 7;
2308 fWidth = fTBWidth;
2309}
2310
2311////////////////////////////////////////////////////////////////////////////////
2312/// Handle mouse button event in case the button is split.
2313
2315{
2316 if (fState == kButtonDisabled) return kFALSE;
2317
2318 Bool_t activate = kFALSE;
2320 static Bool_t mbpress = kFALSE;
2321 static Bool_t tbpress = kFALSE;
2322 static Bool_t outpress = kFALSE;
2323
2324 Bool_t inTB = (event->fX >= 0) && (event->fY >= 0) &&
2325 (event->fX <= (Int_t)fTBWidth) && (event->fY <= (Int_t)fHeight);
2326
2327 Bool_t inMB = (event->fX >= (Int_t)(fWidth -fMBWidth)) && (event->fY >= 0) &&
2328 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2329
2330 // We don't need to check the button number as GrabButton will
2331 // only allow button1 events
2332
2333 if (inTB) {
2334 if (event->fType == kButtonPress) {
2335 mbpress = kFALSE;
2336 tbpress = kTRUE;
2337 fgReleaseBtn = 0;
2338 if (fState == kButtonEngaged) {
2339 return kTRUE;
2340 }
2342 Pressed();
2343 } else { // ButtonRelease
2344 if (fMBState == kButtonDown) {
2346 }
2347 if (fState == kButtonEngaged && tbpress) {
2349 Released();
2350 bclick = kTRUE;
2351 } else if (fState == kButtonDown && tbpress) {
2352 tbpress = kFALSE;
2353 if (fStayDown) {
2354 bclick = kTRUE;
2356 fgReleaseBtn = 0;
2357 } else {
2358 bclick = kTRUE;
2360 Released();
2361 fgReleaseBtn = fId;
2362 }
2363 }else {
2365 }
2366 }
2367 } else if (inMB) {
2368 if (event->fType == kButtonPress) {
2369 fgReleaseBtn = 0;
2370 mbpress = kTRUE;
2371 tbpress = kFALSE;
2372 if (fMBState == kButtonEngaged) {
2373 return kTRUE;
2374 }
2376 MBPressed();
2379 } else { // ButtonRelease
2380 if (fState == kButtonDown) {
2382 }
2383 if (fMBState == kButtonEngaged && mbpress) {
2384 mbpress = kFALSE;
2387 MBReleased();
2388 MBClicked();
2389 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2390 } else if (fMBState == kButtonDown && mbpress) {
2391 MBClicked();
2394 fgReleaseBtn = 0;
2395 } else {
2397 }
2398 }
2399 } else {
2400 if (event->fType == kButtonPress) {
2401 fgReleaseBtn = 0;
2402 outpress = kTRUE;
2403 } else { // ButtonRelease
2404 if(outpress) {
2405 outpress = kFALSE;
2408 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2409 activate = kTRUE;
2410 }
2411 }
2412 }
2413 if (bclick) {
2414 Clicked();
2419 }
2420 if (activate) {
2422 if (entry) {
2423 if ((entry->GetStatus() & kMenuEnableMask) &&
2424 !(entry->GetStatus() & kMenuHideMask) &&
2425 (entry->GetType() != kMenuSeparator) &&
2426 (entry->GetType() != kMenuLabel)) {
2427 Int_t id = entry->GetEntryId();
2428 fPopMenu->Activated(id);
2429 }
2430 }
2431 }
2432 // if (mbclick) {
2433 // MBClicked();
2434 // SendMessage(fMsgWindow, MK_MSG(kC_COMMAND, kCM_BUTTON), fWidgetId,
2435 // (Longptr_t) fUserData);
2436 // fClient->ProcessLine(fCommand, MK_MSG(kC_COMMAND, kCM_BUTTON), fWidgetId,
2437 // (Longptr_t) fUserData);
2438 // }
2439 return kTRUE;
2440}
2441
2442////////////////////////////////////////////////////////////////////////////////
2443/// Handle mouse crossing event in case of split menu.
2444
2446{
2447 if (fTip) {
2448 if (event->fType == kEnterNotify)
2449 fTip->Reset();
2450 else
2451 fTip->Hide();
2452 }
2453
2454 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
2455
2456 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
2457 return kTRUE;
2458
2459 if (fState == kButtonEngaged || fState == kButtonDisabled) return kTRUE;
2460
2461 Bool_t inTB = (event->fX <= (Int_t)fTBWidth);
2462
2463 // Bool_t inMB = (event->fX >= (Int_t)(fWidth -fMBWidth)) && (event->fY >= 0) &&
2464 // (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2465
2466 if (event->fType == kEnterNotify) {
2467 if (inTB) {
2469 } else {
2470 if(fMBState == kButtonEngaged) return kTRUE;
2472 }
2473 } else {
2474 // kLeaveNotify
2475 if(fState == kButtonDown) {
2477 }
2478 if (fMBState == kButtonEngaged) return kTRUE;
2480 }
2481 return kTRUE;
2482}
2483
2484////////////////////////////////////////////////////////////////////////////////
2485/// Handle key event. This function will be called when the hotkey is hit.
2486
2488{
2489 if (fState == kButtonDisabled) return kFALSE;
2490
2492
2493 if (event->fType == kGKeyPress) {
2494 gVirtualX->SetKeyAutoRepeat(kFALSE);
2495 } else {
2496 gVirtualX->SetKeyAutoRepeat(kTRUE);
2497 }
2498
2499 if (fTip && event->fType == kGKeyPress) fTip->Hide();
2500
2501 // We don't need to check the key number as GrabKey will only
2502 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
2503
2504 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
2505 if (fState == kButtonEngaged) return kTRUE;
2507 Pressed();
2508 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
2509 if (fState == kButtonEngaged) {
2511 Released();
2512 }
2513 if (fStayDown) {
2515 } else {
2517 Released();
2518 }
2519 click = kTRUE;
2520 }
2521 if (click) {
2522 Clicked();
2527 }
2528
2529 return kTRUE;
2530}
2531
2532////////////////////////////////////////////////////////////////////////////////
2533/// Popup the attached menu.
2534
2536{
2537 if (state) {
2538 Int_t ax, ay;
2540
2541 if (fSplit) {
2542 Int_t n_entries = 0;
2543 TGMenuEntry *entry = 0;
2545
2546 while ((entry = (TGMenuEntry *) next())) {
2547 if ((entry->GetType() != kMenuSeparator) &&
2548 (entry->GetType() != kMenuLabel)) {
2549 n_entries++;
2550 }
2551 }
2552 if (n_entries <= 1) {
2553 Info("TGSplitButton", "Only one entry in the menu.");
2554 return;
2555 }
2556 }
2557
2558 gVirtualX->TranslateCoordinates(fId, fPopMenu->GetParent()->GetId(),
2559 0, 0, ax, ay, wdummy);
2560
2561 // place the menu just under the window:
2562 fPopMenu->PlaceMenu(ax-1, ay+fHeight, kTRUE, kFALSE); //kTRUE);
2563 BindKeys(kTRUE);
2565 } else {
2570 }
2571}
2572
2573////////////////////////////////////////////////////////////////////////////////
2574/// Draw the text button.
2575
2577{
2578 int x, y;
2580
2583
2584 if (fTMode & kTextLeft) {
2585 x = fMLeft + 4;
2586 } else if (fTMode & kTextRight) {
2587 x = fWidth - fTWidth -fMBWidth - fMRight - 4;
2588 } else {
2589 x = (fWidth - fTWidth -fMBWidth + fMLeft - fMRight) >> 1;
2590 }
2591
2592 if (fTMode & kTextTop) {
2593 y = fMTop + 3;
2594 } else if (fTMode & kTextBottom) {
2595 y = fHeight - fTHeight - fMBottom - 3;
2596 } else {
2597 y = (fHeight - fTHeight + fMTop - fMBottom) >> 1;
2598 }
2599
2600 if (fState == kButtonDown || fState == kButtonEngaged) { ++x; ++y; }
2601 if (fState == kButtonEngaged) {
2602 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
2603 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
2604 }
2605
2607
2608 if (fState == kButtonDisabled) {
2609 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
2610 TGGC *gc = pool->FindGC(fNormGC);
2611 if (gc) {
2612 Pixel_t fore = gc->GetForeground();
2613 Pixel_t hi = GetHilightGC().GetForeground();
2614 Pixel_t sh = GetShadowGC().GetForeground();
2615
2616 gc->SetForeground(hi);
2617 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
2618 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x + 1, y + 1, hotpos - 1);
2619
2620 gc->SetForeground(sh);
2621 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
2622 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
2623 gc->SetForeground(fore);
2624 }
2625 } else {
2626 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
2628 }
2629
2630 // Draw the parts of the button needed when a menu is attached.
2631
2632 // triangle position
2633 x = fWidth - 11;
2634 y = fHeight - 10;
2635
2636 if (fSplit) {
2637 // separator position
2638 Int_t lx = fWidth - fMBWidth;
2639 Int_t ly = 2;
2640 Int_t lh = fHeight - 2;
2641
2643 x++;
2644 y++;
2645 }
2646
2647 gVirtualX->DrawLine(fId, GetShadowGC()(), lx, ly + 2, lx, lh - 4);
2648 gVirtualX->DrawLine(fId, GetHilightGC()(), lx + 1, ly + 2, lx + 1, lh - 3);
2649 gVirtualX->DrawLine(fId, GetHilightGC()(), lx, lh - 3, lx + 1, lh - 3);
2650
2651 if (fMBState == kButtonEngaged) {
2652 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), fTBWidth + 1, 1, fMBWidth - 3, fHeight - 3);
2653 }
2654
2655 if (fMBState == kButtonDisabled) {
2656 DrawTriangle(GetHilightGC()(), x + 1, y + 1);
2657 DrawTriangle(GetShadowGC()(), x, y);
2658 } else {
2660 }
2661
2662 } else {
2663 x -= 2;
2665 x++;
2666 y++;
2667 }
2668 if (fState == kButtonDisabled) {
2669 DrawTriangle(GetHilightGC()(), x + 1, y + 1);
2670 DrawTriangle(GetShadowGC()(), x, y);
2671 } else {
2673 }
2674 }
2675
2676}
2677
2678////////////////////////////////////////////////////////////////////////////////
2679/// If on kTRUE bind arrow, popup menu hot keys, otherwise
2680/// remove key bindings.
2681
2683{
2684 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Up), kAnyModifier, on);
2685 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Down), kAnyModifier, on);
2686 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Enter), kAnyModifier, on);
2687 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Return), kAnyModifier, on);
2688 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Escape), kAnyModifier, on);
2689}
2690
2691////////////////////////////////////////////////////////////////////////////////
2692/// If on kTRUE bind Menu hot keys, otherwise remove key bindings.
2693
2695{
2696 TGMenuEntry *e = 0;
2698
2699 while ((e = (TGMenuEntry*)next())) {
2700 Int_t hot = 0;
2701 if (e->GetLabel()) {
2702 hot = e->GetLabel()->GetHotChar();
2703 }
2704 if (!hot) continue;
2705 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), 0, on);
2706 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask, on);
2707 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyLockMask, on);
2708 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyMod2Mask, on);
2709 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyLockMask, on);
2710 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyMod2Mask, on);
2711 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyLockMask | kKeyMod2Mask, on);
2712 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyLockMask | kKeyMod2Mask, on);
2713 }
2714}
2715
2716////////////////////////////////////////////////////////////////////////////////
2717/// returns default size
2718
2725
2726////////////////////////////////////////////////////////////////////////////////
2727/// Set new button text.
2728
2730{
2731 Int_t hotchar;
2732 static Bool_t longlabeltip = kFALSE;
2734
2736 if (!font) {
2738 if (font) fFontStruct = font->GetFontStruct();
2739 }
2740
2741 UInt_t width = 0, bwidth = 0, dummy;
2742 if (font) {
2743 font->ComputeTextLayout(new_label->GetString(), new_label->GetLength(),
2745 &width, &dummy);
2748 &bwidth, &dummy);
2749 }
2750 if (width > bwidth) {
2751 if (!fTip) {
2752 SetToolTipText(new_label->GetString());
2754 }
2755 Info("TGSplitbutton", "Length of new label to long, label truncated.");
2756 new_label->Resize(fWidestLabel.GetLength());
2757 } else if (new_label->GetLength() <= fWidestLabel.GetLength() && longlabeltip) {
2758 if (fTip) delete fTip;
2759 fTip = 0;
2761 }
2762
2763 if (fLabel) {
2764 if (main && fHKeycode) {
2765 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
2766 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2767 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2768 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
2769
2770 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2771 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
2772 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
2774 }
2775 delete fLabel;
2776 }
2777
2778 fLabel = new_label;
2779 if ((hotchar = fLabel->GetHotChar()) != 0) {
2780 if (main && ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0)) {
2781 main->BindKey(this, fHKeycode, kKeyMod1Mask);
2782 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2783 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2785
2786 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2790 }
2791 }
2792
2793 Layout();
2794}
2795
2796////////////////////////////////////////////////////////////////////////////////
2797/// Set new button text.
2798
2803
2804////////////////////////////////////////////////////////////////////////////////
2805/// Changes text font.
2806/// If global is kTRUE font is changed globally, otherwise - locally.
2807
2809{
2810 if (font != fFontStruct) {
2811 FontH_t v = gVirtualX->GetFontHandle(font);
2812 if (!v) return;
2813
2814 fFontStruct = font;
2815 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
2816 TGGC *gc = pool->FindGC(fNormGC);
2817
2818 if ((gc) && !global) {
2819 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
2821 }
2822 if (gc) {
2823 gc->SetFont(v);
2824 fNormGC = gc->GetGC();
2825 }
2826 fClient->NeedRedraw(this);
2827 }
2828}
2829
2830////////////////////////////////////////////////////////////////////////////////
2831/// Changes text font specified by name.
2832/// If global is true color is changed globally, otherwise - locally.
2833
2835{
2836 TGFont *font = fClient->GetFont(fontName);
2837 if (font) {
2838 SetFont(font->GetFontStruct(), global);
2839 }
2840}
2841
2842////////////////////////////////////////////////////////////////////////////////
2843/// Set the state of the Menu Button part
2844
2846{
2847 if (state != fMBState) {
2848 fMBState = state;
2849 DoRedraw();
2850 }
2851}
2852
2853////////////////////////////////////////////////////////////////////////////////
2854/// Set the split status of a button.
2855
2857{
2858 if(split) {
2859 fStayDown = kFALSE;
2860 Disconnect(fPopMenu, "PoppedDown()");
2861 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "SetMBState(=kButtonUp)");
2862 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "MBReleased()");
2863
2865 if (entry) {
2866 TGHotString *tmp = new TGHotString(*(entry->GetLabel()));
2867 SetText(tmp);
2868
2869 TString str("ItemClicked(=");
2870 str += entry->GetEntryId();
2871 str += ")";
2872 Connect("Clicked()", "TGSplitButton", this, str);
2873 fEntryId = entry->GetEntryId();
2875 }
2876 } else {
2877 fStayDown = kTRUE;
2878 Disconnect(fPopMenu, "PoppedDown()");
2879 Disconnect(this, "Clicked()", this);
2880 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "SetState(=kButtonUp)");
2881 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "Released()");
2883 TGHotString *tmp = new TGHotString(*fMenuLabel);
2884 SetText(tmp);
2885 }
2886
2887 fSplit = split;
2888 DoRedraw();
2889}
2890
2891////////////////////////////////////////////////////////////////////////////////
2892/// Handle button events.
2893
2895{
2896 if (fState == kButtonDisabled) return kFALSE;
2897
2898 if (fSplit) return HandleSButton(event);
2899
2900 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
2901 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2902
2903 Bool_t activate = kFALSE;
2905
2906 if (in) {
2907 if (event->fType == kButtonPress) {
2908 fgReleaseBtn = 0;
2909 if (fState == kButtonEngaged) {
2910 return kTRUE;
2911 }
2913 Pressed();
2916 } else { // ButtonRelease
2917 if (fState == kButtonEngaged) {
2920 Released();
2921 click = kTRUE;
2922 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2923 } else {
2924 click = (fState == kButtonDown);
2925 if (click && fStayDown) {
2928 fgReleaseBtn = 0;
2929 } else {
2931 Released();
2932 fgReleaseBtn = fId;
2933 }
2934 }
2936 }
2937 } else {
2938 if (event->fType == kButtonPress) {
2939 fgReleaseBtn = 0;
2940 } else { // ButtonRelease
2943 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2944 activate = kTRUE;
2945 }
2946 }
2947 if (click) {
2948 Clicked();
2953 }
2954 if (activate && !fKeyNavigate) {
2956 if (entry) {
2957 if ((entry->GetStatus() & kMenuEnableMask) &&
2958 !(entry->GetStatus() & kMenuHideMask) &&
2959 (entry->GetType() != kMenuSeparator) &&
2960 (entry->GetType() != kMenuLabel)) {
2961 Int_t id = entry->GetEntryId();
2962 fPopMenu->Activated(id);
2963 }
2964 }
2965 }
2966
2967 return kTRUE;
2968
2969}
2970
2971////////////////////////////////////////////////////////////////////////////////
2972/// Handle mouse crossing event.
2973
2975{
2976 if (fSplit) {
2977 return HandleSCrossing(event);
2978 } else {
2979 return TGButton::HandleCrossing(event);
2980 }
2981}
2982
2983////////////////////////////////////////////////////////////////////////////////
2984/// Handle key event. This function will be called when the hotkey is hit.
2985
2987{
2989
2990 if (fState == kButtonDisabled) return kTRUE;
2991
2992 if(fSplit) return HandleSKey(event);
2993
2994 if (event->fType == kGKeyPress) {
2995 gVirtualX->SetKeyAutoRepeat(kFALSE);
2996 } else {
2997 gVirtualX->SetKeyAutoRepeat(kTRUE);
2998 }
2999
3000 if (fTip && event->fType == kGKeyPress) fTip->Hide();
3001
3002 // We don't need to check the key number as GrabKey will only
3003 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
3004 if (event->fState & kKeyMod1Mask) {
3005 RequestFocus();
3007 if (event->fType == kGKeyPress) {
3008 if (fState == kButtonEngaged) return kTRUE;
3010 Pressed();
3011 } else if (event->fType == kKeyRelease) {
3012 click = kTRUE;
3013 if (fState == kButtonEngaged) {
3016 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3017 } else if (fState == kButtonDown && fStayDown) {
3022 TGMenuEntry *entry = 0;
3024
3025 while ((entry = (TGMenuEntry *) next())) {
3026 if ((entry->GetStatus() & kMenuEnableMask) &&
3027 !(entry->GetStatus() & kMenuHideMask) &&
3028 (entry->GetType() != kMenuSeparator) &&
3029 (entry->GetType() != kMenuLabel)) break;
3030 }
3031 if (entry) {
3033 }
3034 } else {
3035 Released();
3037 }
3038 }
3039 } else {
3041 if (event->fType == kGKeyPress) {
3042 Event_t ev;
3043 ev.fX = ev.fY = 1;
3044 UInt_t keysym;
3045 char tmp[2];
3046
3047 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
3048
3049 TGMenuEntry *ce = 0;
3051
3052 while ((ce = (TGMenuEntry*)next())) {
3053 UInt_t hot = 0;
3054 if (ce->GetLabel()) hot = ce->GetLabel()->GetHotChar();
3055 if (!hot || (hot != keysym)) continue;
3056
3058 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3060 ev.fType = kButtonRelease;
3061 ev.fWindow = fPopMenu->GetId();
3063 return HandleButton(&ev);
3064 }
3065
3066 ce = fPopMenu->GetCurrent();
3067
3068 switch ((EKeySym)keysym) {
3069 case kKey_Up:
3070 if (ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->Before(ce);
3071 while (ce && ((ce->GetType() == kMenuSeparator) ||
3072 (ce->GetType() == kMenuLabel) ||
3073 !(ce->GetStatus() & kMenuEnableMask))) {
3074 ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->Before(ce);
3075 }
3076 if (!ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->Last();
3077 break;
3078 case kKey_Down:
3079 if (ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->After(ce);
3080 while (ce && ((ce->GetType() == kMenuSeparator) ||
3081 (ce->GetType() == kMenuLabel) ||
3082 !(ce->GetStatus() & kMenuEnableMask))) {
3083 ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->After(ce);
3084 }
3085 if (!ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->First();
3086 break;
3087 case kKey_Enter:
3088 case kKey_Return:
3089 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3091 ev.fType = kButtonRelease;
3092 ev.fWindow = fPopMenu->GetId();
3094 HandleButton(&ev);
3095 break;
3096 case kKey_Escape:
3097 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3099 break;
3100 default:
3101 break;
3102 }
3103 if (ce) fPopMenu->Activate(ce);
3104 }
3105 }
3106 if (click) {
3107 Clicked();
3112 }
3113
3114 return kTRUE;
3115}
3116
3117////////////////////////////////////////////////////////////////////////////////
3118/// Handle a motion event in a TGSplitButton.
3119
3121{
3122 if (fKeyNavigate) return kTRUE;
3123
3124 if (fSplit) {
3125 if (fMBState == kButtonDown) {
3126 if (event->fX < (Int_t)fTBWidth) {
3129 }
3130 } else if (fState == kButtonDown) {
3131 if (event->fX > (Int_t)fTBWidth) {
3134 }
3135
3136 }
3137 }
3138 return kTRUE;
3139}
3140
3141////////////////////////////////////////////////////////////////////////////////
3142/// layout text button
3143
3145{
3146 UInt_t dummya = 0, dummyb = 0;
3148
3150 if (!font) {
3152 if (font) fFontStruct = font->GetFontStruct();
3153 }
3154 if (font) {
3156 fLabel->GetLength(),
3158 &dummya, &dummyb);
3159 UInt_t dummy = 0;
3162 &fTWidth, &dummy);
3165 &dummy, &fTHeight);
3166 }
3167 fTBWidth = fTWidth + 8;
3169 fHeight = fTHeight + 7;
3170 fClient->NeedRedraw(this);
3171}
3172
3173////////////////////////////////////////////////////////////////////////////////
3174/// Handle a menu item activation.
3175
3177{
3179
3180 if (fSplit) {
3182 Disconnect(this, "Clicked()", this);
3183 // connect clicked to the ItemClicked signal with the correct id
3184 Connect("Clicked()", "TGSplitButton", this,
3185 TString::Format("ItemClicked(=%d)", id));
3186
3187 // reenable hidden entries
3188 const TList *list = fPopMenu->GetListOfEntries();
3189 TIter iter(list);
3192 if (entry) {
3193 TGHotString *label = entry->GetLabel();
3194 TGHotString *tmp = new TGHotString(*label);
3195 SetText(tmp);
3196 }
3197 fPopMenu->HideEntry(id);
3198 if (entry) fEntryId = entry->GetEntryId();
3199 } else {
3201 ItemClicked(id);
3202 }
3203 DoRedraw();
3204}
@ 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:533
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
EButtonState
Definition TGButton.h:52
@ kButtonDown
Definition TGButton.h:54
@ kButtonDisabled
Definition TGButton.h:56
@ kButtonUp
Definition TGButton.h:53
@ kButtonEngaged
Definition TGButton.h:55
#define gClient
Definition TGClient.h:157
@ kDeepCleanup
Definition TGFrame.h:42
@ kMenuHideMask
Definition TGMenu.h:29
@ kMenuEnableMask
Definition TGMenu.h:25
@ kMenuEntry
Definition TGMenu.h:38
@ kMenuSeparator
Definition TGMenu.h:36
@ kMenuLabel
Definition TGMenu.h:37
@ kTextCenterX
Definition TGWidget.h:25
@ kTextLeft
Definition TGWidget.h:23
@ kTextBottom
Definition TGWidget.h:27
@ kTextTop
Definition TGWidget.h:26
@ kTextRight
Definition TGWidget.h:24
@ kTextCenterY
Definition TGWidget.h:28
@ kWidgetIsEnabled
Definition TGWidget.h:37
@ kWidgetWantFocus
Definition TGWidget.h:35
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t gval
Option_t Option_t style
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx: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:490
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:316
virtual void Pressed()
Definition TGButton.h:133
static const TGGC & GetDefaultGC()
Return default graphics context.
Definition TGButton.cxx:464
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:439
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:474
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition TGButton.cxx:304
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:324
virtual void EmitSignals(Bool_t wasUp)
Emit button signals.
Definition TGButton.cxx:379
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:265
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:453
static const TGGC * fgDefaultGC
Definition TGButton.h:88
~TGButton() override
Delete button.
Definition TGButton.cxx:215
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:229
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:295
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
Definition TGButton.cxx:398
Bool_t fStayDown
true if button has to stay down
Definition TGButton.h:76
GContext_t fNormGC
graphics context used for drawing button
Definition TGButton.h:77
const TGPicture * fOff
button OFF picture
Definition TGButton.h:274
static const TGFont * fgDefaultFont
Definition TGButton.h:283
static const TGGC * fgDefaultGC
Definition TGButton.h:284
Bool_t HandleKey(Event_t *event) override
Handle key event. This function will be called when the hotkey is hit.
const TGPicture * fOn
button ON picture
Definition TGButton.h:273
void Init()
Common check button initialization.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event.
static const TGGC & GetDefaultGC()
Return default graphics context.
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
virtual void SetDisabledAndSelected(Bool_t)
Set the state of a check button to disabled and either on or off.
virtual Bool_t IsDisabledAndSelected() const
Definition TGButton.h:312
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
TClass * IsA() const override
Definition TGButton.h:317
~TGCheckButton() override
Delete a check button.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a check button widget as a C++ statement(s) on output stream out.
TGCheckButton(const TGCheckButton &)=delete
void EmitSignals(Bool_t wasUp=kTRUE) override
Emit signals.
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
EButtonState fPrevState
previous check button state
Definition TGButton.h:272
void DoRedraw() override
Draw the check button widget.
const TGPicture * fDisOff
button disabled and was OFF picture
Definition TGButton.h:276
const TGPicture * fDisOn
button disabled and was ON picture
Definition TGButton.h:275
TGDimension GetDefaultSize() const override
default size
void PSetState(EButtonState state, Bool_t emit)
Set check button state.
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition TGClient.cxx:922
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:356
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:288
TGGCPool * GetGCPool() const
Definition TGClient.h:132
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:380
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:316
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get the specified font.
Definition TGFont.cxx:1555
TGFont * FindFont(FontStruct_t font) const
Find font based on its font struct. Returns 0 if font is not found.
Definition TGFont.cxx:1741
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
FontStruct_t GetFontStruct() const
Definition TGFont.h:184
TGTextLayout * ComputeTextLayout(const char *string, Int_t numChars, Int_t wrapLength, Int_t justify, Int_t flags, UInt_t *width, UInt_t *height) const
Computes the amount of screen space needed to display a multi-line, justified string of text.
Definition TGFont.cxx:658
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:313
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:331
UInt_t fOptions
frame options
Definition TGFrame.h:94
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
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:422
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:747
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:675
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2512
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:637
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:757
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:227
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:2471
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
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:80
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:1747
void Activate(Bool_t) override
Definition TGMenu.h:209
virtual TGMenuEntry * GetEntry(Int_t id)
Find entry with specified id.
Definition TGMenu.cxx:1893
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:1701
virtual Int_t EndMenu(void *&userData)
Close menu and return ID of selected menu item.
Definition TGMenu.cxx:1285
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:1237
const TList * GetListOfEntries() const
Definition TGMenu.h:200
virtual void Activated(Int_t id)
Definition TGMenu.h:219
const TGPicture * fOn
button ON picture
Definition TGButton.h:329
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
static const TGGC * fgDefaultGC
Definition TGButton.h:340
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set radio button state.
void DoRedraw() override
Draw a radio button.
const TGPicture * fDisOn
button disabled and was ON picture
Definition TGButton.h:331
Bool_t HandleButton(Event_t *event) override
Handle mouse button event.
TClass * IsA() const override
Definition TGButton.h:374
EButtonState fPrevState
previous radio button state
Definition TGButton.h:328
void EmitSignals(Bool_t wasUp=kTRUE) override
Emit signals.
static const TGGC & GetDefaultGC()
Return default graphics context.
const TGPicture * fDisOff
button disabled and was OFF picture
Definition TGButton.h:332
static const TGFont * fgDefaultFont
Definition TGButton.h:339
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
virtual Bool_t IsDisabledAndSelected() const
Definition TGButton.h:371
virtual void SetDisabledAndSelected(Bool_t)
Set the state of a radio button to disabled and either on or off.
const TGPicture * fOff
button OFF picture
Definition TGButton.h:330
~TGRadioButton() override
Delete a radio button.
void PSetState(EButtonState state, Bool_t emit)
Set radio button state.
void Init()
Common radio button initialization.
Bool_t HandleKey(Event_t *event) override
Handle key event. This function will be called when the hotkey is hit.
TGDimension GetDefaultSize() const override
default size
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a radio button widget as a C++ statement(s) on output stream out.
TGRadioButton(const TGRadioButton &)=delete
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:535
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
Definition TGButton.cxx:863
void Layout() override
layout text button
Definition TGButton.cxx:618
Bool_t HandleKey(Event_t *event) override
Handle key event. This function will be called when the hotkey is hit.
Definition TGButton.cxx:809
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:689
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:638
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:853
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:932
Bool_t fPrevStateOn
Definition TGButton.h:157
virtual void SetFont(FontStruct_t font, Bool_t global=kFALSE)
Changes text font.
Definition TGButton.cxx:874
Int_t fTMode
Definition TGButton.h:150
~TGTextButton() override
Delete a text button widget.
Definition TGButton.cxx:589
void DoRedraw() override
Draw the text button.
Definition TGButton.cxx:741
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:912
Int_t fMLeft
Definition TGButton.h:146
void DrawText(Drawable_t dst, GContext_t gc, Int_t x, Int_t y, Int_t firstChar, Int_t lastChar) const
Use the information in the TGTextLayout object to display a multi-line, justified string of text.
Definition TGFont.cxx:920
void UnderlineChar(Drawable_t dst, GContext_t gc, Int_t x, Int_t y, Int_t underline) const
Use the information in the TGTextLayout object to display an underline below an individual character.
Definition TGFont.cxx:967
A tooltip can be a one or multiple lines help text that is displayed in a window when the mouse curso...
Definition TGToolTip.h:24
void Hide()
Hide tool tip window.
const TGString * GetText() const
Get the tool tip text.
void Reset()
Reset tool tip popup delay timer.
Int_t fWidgetId
the widget id (used for event processing)
Definition TGWidget.h:46
TString fCommand
command to be executed
Definition TGWidget.h:49
Int_t fWidgetFlags
widget status flags (OR of EWidgetStatus)
Definition TGWidget.h:47
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:150
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:230
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:127
const TGWindow * GetParent() const
Definition TGWindow.h:83
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
An abstract interface to image processing library.
Definition TImage.h:29
static TImage * Create()
Create an image.
Definition TImage.cxx:34
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:865
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:138
Ssiz_t Length() const
Definition TString.h:425
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1121
const char * Data() const
Definition TString.h:384
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2384
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:1073
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
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