Logo ROOT  
Reference Guide
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// //
25// TGButton, TGTextButton, TGPictureButton, TGCheckButton, //
26// TGRadioButton and TGSplitButton //
27// //
28// This header defines all GUI button widgets. //
29// //
30// TGButton is a button abstract base class. It defines general button //
31// behaviour. //
32// //
33// TGTextButton and TGPictureButton yield an action as soon as they are //
34// clicked. These buttons usually provide fast access to frequently //
35// used or critical commands. They may appear alone or placed in a //
36// group. //
37// //
38// The action they perform can be inscribed with a meaningful tooltip //
39// set by SetToolTipText(const char* text, Long_t delayms=400). //
40// //
41// The text button has a label indicating the action to be taken when //
42// the button is pressed. The text can be a hot string ("&Exit") that //
43// defines the label "Exit" and keyboard mnemonics Alt+E for button //
44// selection. A button label can be changed by SetText(new_label). //
45// //
46// Selecting a text or picture button will generate the event: //
47// kC_COMMAND, kCM_BUTTON, button id, user data. //
48// //
49// The purpose of TGCheckButton and TGRadioButton is for selecting //
50// different options. Like text buttons, they have text or hot string //
51// as a label. //
52// //
53// Radio buttons are grouped usually in logical sets of two or more //
54// buttons to present mutually exclusive choices. //
55// //
56// Selecting a check button will generate the event: //
57// kC_COMMAND, kCM_CHECKBUTTON, button id, user data. //
58// //
59// Selecting a radio button will generate the event: //
60// kC_COMMAND, kCM_RADIOBUTTON, button id, user data. //
61// //
62// If a command string has been specified (via SetCommand()) then this //
63// command string will be executed via the interpreter whenever a //
64// button is selected. A command string can contain the macros: //
65// $MSG -- kC_COMMAND, kCM[CHECK|RADIO]BUTTON packed message //
66// (use GET_MSG() and GET_SUBMSG() to unpack) //
67// $PARM1 -- button id //
68// $PARM2 -- user data pointer //
69// Before executing these macros are expanded into the respective //
70// Long_t's //
71// //
72// TGSplitButton implements a button with added menu functionality. //
73// There are 2 modes of operation available. //
74// //
75// If the button is split, a menu will popup when the menu area of the //
76// button is clicked. Activating a menu item changes the functionality //
77// of the button by having it emit a additional signal when it is //
78// clicked. The signal emitted when the button is clicked, is the //
79// ItemClicked(Int_t) signal with a different fixed value for the //
80// Int_t that corresponds to the id of the activated menu entry. //
81// //
82// If the button is not split, clicking it will popup the menu and the //
83// ItemClicked(Int_t) signal will be emitted when a menu entry is //
84// acitvated. The value of the Int_t is again equal to the value of //
85// the id of the activated menu entry. //
86// //
87// The mode of operation of a SplitButton can be changed on the fly //
88// by calling the SetSplit(Bool_t) method. //
89//////////////////////////////////////////////////////////////////////////
90
91#include "TGButton.h"
92#include "TGWidget.h"
93#include "TGPicture.h"
94#include "TGToolTip.h"
95#include "TGButtonGroup.h"
96#include "TGResourcePool.h"
97#include "Riostream.h"
98#include "TSystem.h"
99#include "TImage.h"
100#include "TEnv.h"
101#include "TClass.h"
102#include "TGMenu.h"
103#include "KeySymbols.h"
104#include "TVirtualX.h"
105
106
108const TGGC *TGButton::fgDefaultGC = 0;
109
111
114
117
119
126
127////////////////////////////////////////////////////////////////////////////////
128/// Create button base class part.
129
131 : TGFrame(p, 1, 1, options)
132{
133 fWidgetId = id;
135 fMsgWindow = p;
136 fUserData = 0;
137 fTip = 0;
138 fGroup = 0;
139 fStyle = 0;
140 fTWidth = fTHeight = 0;
141
142 fNormGC = norm;
146
147// fStyle = gClient->GetStyle();
148// if (fStyle > 0) {
149// fOptions &= ~(kRaisedFrame | kDoubleBorder);
150// }
151
152 // coverity[returned_null]
153 // coverity[dereference]
154 if (p && p->IsA()->InheritsFrom(TGButtonGroup::Class())) {
155 TGButtonGroup *bg = (TGButtonGroup*) p;
156 bg->Insert(this, id);
157 }
158
160 fHighColor = gClient->GetResourcePool()->GetHighLightColor();
161
162 gVirtualX->GrabButton(fId, kButton1, kAnyModifier,
164 kNone, kNone);
165
168}
169
170////////////////////////////////////////////////////////////////////////////////
171/// Delete button.
172
174{
175 // remove from button group
176 if (fGroup) {
177 fGroup->Remove(this);
178 fGroup = 0;
179 }
180
181 if (fTip) delete fTip;
182}
183
184////////////////////////////////////////////////////////////////////////////////
185/// Set button state.
186
188{
189 Bool_t was = !IsDown(); // kTRUE if button was off
190
191 if (state == kButtonDisabled)
192 fWidgetFlags &= ~kWidgetIsEnabled;
193 else
195 if (state != fState) {
196 switch (state) {
197 case kButtonEngaged:
198 case kButtonDown:
199 fOptions &= ~kRaisedFrame;
201 break;
202 case kButtonDisabled:
203 case kButtonUp:
204 if (fStyle > 0) {
205 fOptions &= ~kRaisedFrame;
206 fOptions &= ~kSunkenFrame;
207 }
208 else {
209 fOptions &= ~kSunkenFrame;
211 }
212 break;
213 }
214 fState = state;
215 DoRedraw();
216 if (emit || fGroup) EmitSignals(was);
217 }
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Set the button style (modern or classic).
222
224{
225 fStyle = newstyle;
227 if (fStyle > 0) {
229 }
230 else {
232 }
233}
234
235////////////////////////////////////////////////////////////////////////////////
236/// Set the button style (modern or classic).
237
238void TGButton::SetStyle(const char *style)
239{
241 if (style && strstr(style, "modern")) {
242 fStyle = 1;
244 }
245 else {
246 fStyle = 0;
248 }
249}
250
251////////////////////////////////////////////////////////////////////////////////
252
254{
255 if (fStyle > 0)
256 return (fOptions & kSunkenFrame);
257 return !(fOptions & kRaisedFrame);
258}
259
260////////////////////////////////////////////////////////////////////////////////
261
263{
264 // Set button state down according to the parameter 'on'.
265
266 if (GetState() == kButtonDisabled) return;
267
268 SetState(on ? kButtonDown : kButtonUp, emit);
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Sets new button-group for this button.
273
275{
276 fGroup = group;
277}
278
279////////////////////////////////////////////////////////////////////////////////
280/// Handle mouse button event.
281
283{
284 Bool_t click = kFALSE;
285
286 if (fTip) fTip->Hide();
287
288 if (fState == kButtonDisabled) return kTRUE;
289
290 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
291 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
292
293 // We don't need to check the button number as GrabButton will
294 // only allow button1 events
295 if (event->fType == kButtonPress) {
296 fgReleaseBtn = 0;
297
298 if (fState == kButtonEngaged) {
299 return kTRUE;
300 }
301 if (in) SetState(kButtonDown, kTRUE);
302 } else { // ButtonRelease
303 if (fState == kButtonEngaged) {
304 if (in) SetState(kButtonUp, kTRUE);
305 click = kTRUE;
306 } else {
307 click = (fState == kButtonDown) && in;
308 if (click && fStayDown) {
309 if (in) {
311 fgReleaseBtn = 0;
312 }
313 } else {
314 if (in) {
317 }
318 }
319 }
320 }
321 if (click) {
323 (Long_t) fUserData);
325 (Long_t) fUserData);
326 }
327 if ((fStyle > 0) && (event->fType == kButtonRelease)) {
329 }
330 DoRedraw();
331 return kTRUE;
332}
333
334////////////////////////////////////////////////////////////////////////////////
335/// Emit button signals.
336
338{
339 Bool_t now = !IsDown(); // kTRUE if button now is off
340
341 // emit signals
342 if (was && !now) {
343 Pressed(); // emit Pressed = was off , now on
344 if (fStayDown) Clicked(); // emit Clicked
345 }
346 if (!was && now) {
347 Released(); // emit Released = was on , now off
348 Clicked(); // emit Clicked
349 }
350 if ((was != now) && IsToggleButton()) Toggled(!now); // emit Toggled = was != now
351}
352
353////////////////////////////////////////////////////////////////////////////////
354/// Handle mouse crossing event.
355
357{
358 if (fTip) {
359 if (event->fType == kEnterNotify)
360 fTip->Reset();
361 else
362 fTip->Hide();
363 }
364
365 if (fStyle > 0) {
366 if ((event->fType == kEnterNotify) && (fState != kButtonDisabled)) {
368 } else {
370 }
371 if (event->fType == kLeaveNotify) {
373 }
374 DoRedraw();
375 }
376
377 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
378
379 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
380 return kTRUE;
381
382 if (fState == kButtonEngaged || fState == kButtonDisabled) return kTRUE;
383
384 if (event->fType == kLeaveNotify) {
387 }
388 DoRedraw();
389 return kTRUE;
390}
391
392////////////////////////////////////////////////////////////////////////////////
393/// Set tool tip text associated with this button. The delay is in
394/// milliseconds (minimum 250). To remove tool tip call method with
395/// text = 0.
396
397void TGButton::SetToolTipText(const char *text, Long_t delayms)
398{
399 if (fTip) {
400 delete fTip;
401 fTip = 0;
402 }
403
404 if (text && strlen(text))
405 fTip = new TGToolTip(fClient->GetDefaultRoot(), this, text, delayms);
406}
407
408////////////////////////////////////////////////////////////////////////////////
409/// Set enabled or disabled state of button
410
412{
414
416 else fWidgetFlags &= ~kWidgetIsEnabled;
417}
418
419////////////////////////////////////////////////////////////////////////////////
420/// Return default graphics context.
421
423{
424 if (!fgDefaultGC)
425 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
426 return *fgDefaultGC;
427}
428
429////////////////////////////////////////////////////////////////////////////////
430/// Return graphics context for highlighted frame background.
431
433{
434 if (!fgHibckgndGC) {
435 GCValues_t gval;
438 gval.fForeground = gClient->GetResourcePool()->GetFrameHiliteColor();
439 gval.fBackground = gClient->GetResourcePool()->GetFrameBgndColor();
440 gval.fFillStyle = kFillTiled;
441 gval.fTile = gClient->GetResourcePool()->GetCheckeredPixmap();
443 fgHibckgndGC = gClient->GetGC(&gval, kTRUE);
444 }
445 return *fgHibckgndGC;
446}
447
448
449////////////////////////////////////////////////////////////////////////////////
450/// Create a text button widget. The hotstring will be adopted and deleted
451/// by the text button.
452
454 GContext_t norm, FontStruct_t font,
455 UInt_t options) : TGButton(p, id, norm, options)
456{
457 fLabel = s;
458 fFontStruct = font;
459
460 Init();
461}
462
463////////////////////////////////////////////////////////////////////////////////
464/// Create a text button widget.
465
466TGTextButton::TGTextButton(const TGWindow *p, const char *s, Int_t id,
467 GContext_t norm, FontStruct_t font,
468 UInt_t options) : TGButton(p, id, norm, options)
469{
470 fLabel = new TGHotString(!p && !s ? GetName() : s);
471 fFontStruct = font;
472
473 Init();
474}
475
476////////////////////////////////////////////////////////////////////////////////
477/// Create a text button widget and set cmd string at same time.
478
479TGTextButton::TGTextButton(const TGWindow *p, const char *s, const char *cmd,
480 Int_t id, GContext_t norm, FontStruct_t font,
481 UInt_t options) : TGButton(p, id, norm, options)
482{
483 fLabel = new TGHotString(s);
484 fFontStruct = font;
485 fCommand = cmd;
486
487 Init();
488}
489
490////////////////////////////////////////////////////////////////////////////////
491/// Common initialization used by the different ctors.
492
494{
495 int hotchar;
496
498 fHKeycode = 0;
502 fWrapLength = -1;
503 fMLeft = fMRight = fMTop = fMBottom = 0;
504
506 if (!font) {
508 if (font) fFontStruct = font->GetFontStruct();
509 }
510 if (font) {
513 &fTWidth, &fTHeight);
514 }
515 Resize();
516 fWidth = fTWidth;
518
519 if ((hotchar = fLabel->GetHotChar()) != 0) {
520 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
522 if (main) {
523 main->BindKey(this, fHKeycode, kKeyMod1Mask);
524 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
525 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
527
528 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
532 }
533 }
534 }
537 wattr.fBitGravity = 5; // center
538 wattr.fWinGravity = 1;
539 gVirtualX->ChangeWindowAttributes(fId, &wattr);
540
542}
543
544////////////////////////////////////////////////////////////////////////////////
545/// Delete a text button widget.
546
548{
549 if (fHKeycode && (fParent->MustCleanup() != kDeepCleanup)) {
551 if (main) {
552 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
553 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
554 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
555 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
556
557 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
558 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
559 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
561 }
562 }
563 if (fLabel) delete fLabel;
564 if (fHasOwnFont) {
565 TGGCPool *pool = fClient->GetGCPool();
566 TGGC *gc = pool->FindGC(fNormGC);
567 pool->FreeGC(gc);
568 }
569
570 delete fTLayout;
571}
572
573////////////////////////////////////////////////////////////////////////////////
574/// layout text button
575
577{
578 delete fTLayout;
579
581 if (!font) {
583 if (font) fFontStruct = font->GetFontStruct();
584 }
585 if (font) {
588 &fTWidth, &fTHeight);
589 }
590 fClient->NeedRedraw(this);
591}
592
593////////////////////////////////////////////////////////////////////////////////
594/// Set new button text.
595
597{
598 int hotchar;
600
601 if (fLabel) {
602 if (main && fHKeycode) {
603 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
604 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
605 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
606 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
607
608 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
609 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
610 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
612 }
613 delete fLabel;
614 }
615
616 fLabel = new_label;
617 if ((hotchar = fLabel->GetHotChar()) != 0) {
618 if (main && ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0)) {
619 main->BindKey(this, fHKeycode, kKeyMod1Mask);
620 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
621 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
623
624 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
628 }
629 }
630
631 Layout();
632}
633
634////////////////////////////////////////////////////////////////////////////////
635/// Set new button text.
636
637void TGTextButton::SetText(const TString &new_label)
638{
639 SetText(new TGHotString(new_label));
640}
641
642////////////////////////////////////////////////////////////////////////////////
643/// Set text justification. Mode is an OR of the bits:
644/// kTextTop, kTextBottom, kTextLeft, kTextRight, kTextCenterX and
645/// kTextCenterY.
646
648{
649 fTMode = mode;
650
653 wattr.fWinGravity = 1;
654
655 switch (mode) {
656 case kTextTop | kTextLeft:
657 wattr.fBitGravity = 1; //NorthWestGravity
658 break;
659 case kTextTop | kTextCenterX:
660 case kTextTop:
661 wattr.fBitGravity = 2; //NorthGravity
662 break;
663 case kTextTop | kTextRight:
664 wattr.fBitGravity = 3; //NorthEastGravity
665 break;
666 case kTextLeft | kTextCenterY:
667 case kTextLeft:
668 wattr.fBitGravity = 4; //WestGravity
669 break;
671 wattr.fBitGravity = 5; //CenterGravity
672 break;
674 case kTextRight:
675 wattr.fBitGravity = 6; //EastGravity
676 break;
677 case kTextBottom | kTextLeft:
678 wattr.fBitGravity = 7; //SouthWestGravity
679 break;
681 case kTextBottom:
682 wattr.fBitGravity = 8; //SouthGravity
683 break;
684 case kTextBottom | kTextRight:
685 wattr.fBitGravity = 9; //SouthEastGravity
686 break;
687 default:
688 wattr.fBitGravity = 5; //CenterGravity
689 break;
690 }
691
692 gVirtualX->ChangeWindowAttributes(fId, &wattr);
693 Layout();
694}
695
696////////////////////////////////////////////////////////////////////////////////
697/// Draw the text button.
698
700{
701 int x, y;
702 UInt_t w = GetWidth() - 1;
703 UInt_t h = GetHeight()- 1;
704
705 if ((fStyle > 0) && !(fOptions & kOwnBackground))
706 gVirtualX->SetWindowBackground(fId, fBgndColor);
708
709 if (fTMode & kTextLeft) {
710 x = fMLeft + 4;
711 } else if (fTMode & kTextRight) {
712 x = fWidth - fTWidth - fMRight - 4;
713 } else {
714 x = (fWidth - fTWidth + fMLeft - fMRight) >> 1;
715 }
716
717 if (fTMode & kTextTop) {
718 y = fMTop + 3;
719 } else if (fTMode & kTextBottom) {
720 y = fHeight - fTHeight - fMBottom - 3;
721 } else {
722 y = (fHeight - fTHeight + fMTop - fMBottom) >> 1;
723 }
724
726 ++x; ++y;
727 w--; h--;
728 }
729 if (fStyle == 0) {
730 if (fState == kButtonEngaged) {
731 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
732 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
733 }
734 }
735
736 Int_t hotpos = fLabel->GetHotPos();
737
738 if (fStyle > 0) {
739 gVirtualX->DrawRectangle(fId, TGFrame::GetShadowGC()(), 0, 0, w, h);
740 }
741 if (fState == kButtonDisabled) {
743 TGGC *gc = pool->FindGC(fNormGC);
744 if (gc) {
745 Pixel_t fore = gc->GetForeground();
748
749 gc->SetForeground(hi);
750 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
751 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x + 1, y + 1, hotpos - 1);
752
753 gc->SetForeground(sh);
754 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
755 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
756 gc->SetForeground(fore);
757 }
758 } else {
759 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
760 if (hotpos) fTLayout->UnderlineChar(fId, fNormGC, x, y, hotpos - 1);
761 }
762}
763
764////////////////////////////////////////////////////////////////////////////////
765/// Handle key event. This function will be called when the hotkey is hit.
766
768{
769 Bool_t click = kFALSE;
770 Bool_t was = !IsDown(); // kTRUE if button was off
771
772 if (event->fType == kGKeyPress) {
773 gVirtualX->SetKeyAutoRepeat(kFALSE);
774 } else {
775 gVirtualX->SetKeyAutoRepeat(kTRUE);
776 }
777
778 if (fTip && event->fType == kGKeyPress) fTip->Hide();
779
780 if (fState == kButtonDisabled) return kTRUE;
781
782 // We don't need to check the key number as GrabKey will only
783 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
784
785 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
786 if (fState == kButtonEngaged) return kTRUE;
788 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
789 if (fState == kButtonEngaged /*&& !allowRelease*/) return kTRUE;
790 click = (fState == kButtonDown);
791 if (click && fStayDown) {
793 } else {
795 }
796 }
797 if (click) {
799 (Long_t) fUserData);
801 (Long_t) fUserData);
802 }
803 EmitSignals(was);
804
805 return kTRUE;
806}
807
808////////////////////////////////////////////////////////////////////////////////
809/// returns default size
810
812{
815 return TGDimension(w, h);
816}
817
818////////////////////////////////////////////////////////////////////////////////
819/// Return default font structure.
820
822{
823 if (!fgDefaultFont)
824 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
826}
827
828////////////////////////////////////////////////////////////////////////////////
829/// Changes text font.
830/// If global is kTRUE font is changed globally, otherwise - locally.
831
833{
834 if (font != fFontStruct) {
835 FontH_t v = gVirtualX->GetFontHandle(font);
836 if (!v) return;
837
838 fFontStruct = font;
840 TGGC *gc = pool->FindGC(fNormGC);
841
842 if (gc && !global) {
843 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
845 }
846 if (gc) {
847 gc->SetFont(v);
848 fNormGC = gc->GetGC();
849 }
850 Layout();
851 }
852}
853
854////////////////////////////////////////////////////////////////////////////////
855/// Changes text font specified by name.
856/// If global is true color is changed globally, otherwise - locally.
857
858void TGTextButton::SetFont(const char *fontName, Bool_t global)
859{
860 TGFont *font = fClient->GetFont(fontName);
861 if (font) {
862 SetFont(font->GetFontStruct(), global);
863 }
864}
865
866////////////////////////////////////////////////////////////////////////////////
867/// Changes text color.
868/// If global is true color is changed globally, otherwise - locally.
869
871{
873 TGGC *gc = pool->FindGC(fNormGC);
874
875 if (gc && !global) {
876 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
878 }
879 if (gc) {
880 gc->SetForeground(color);
881 fNormGC = gc->GetGC();
882 }
883 fClient->NeedRedraw(this);
884}
885
886////////////////////////////////////////////////////////////////////////////////
887/// Returns kTRUE if text attributes are unique,
888/// returns kFALSE if text attributes are shared (global).
889
891{
892 return fHasOwnFont;
893}
894
895////////////////////////////////////////////////////////////////////////////////
896/// Create a picture button widget. The picture is not adopted and must
897/// later be freed by the user once the picture button is deleted (a single
898/// picture reference might be used by other buttons).
899
901 Int_t id, GContext_t norm, UInt_t option) : TGButton(p, id, norm, option)
902{
903 if (!pic) {
904 Error("TGPictureButton", "pixmap not found for button %d", id);
905 fPic = fClient->GetPicture("mb_question_s.xpm");
906 } else {
907 fPic = pic;
908 }
909
910 if (fPic) {
911 fTWidth = fPic->GetWidth();
913
915 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
916 }
917 fPicD = 0;
920}
921
922////////////////////////////////////////////////////////////////////////////////
923/// Create a picture button widget and set action command. The picture is
924/// not adopted and must later be freed by the user once the picture button
925/// is deleted (a single picture reference might be used by other
926/// buttons).
927
929 const char *cmd, Int_t id, GContext_t norm, UInt_t option)
930 : TGButton(p, id, norm, option)
931{
932 if (!pic) {
933 Error("TGPictureButton", "pixmap not found for button\n%s",
934 cmd ? cmd : "");
935 fPic = fClient->GetPicture("mb_question_s.xpm");
936 } else {
937 fPic = pic;
938 }
939
940 fCommand = cmd;
941
942 if (fPic) {
943 fTWidth = fPic->GetWidth();
945
947 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
948 }
949 fPicD = 0;
952}
953
954////////////////////////////////////////////////////////////////////////////////
955/// Create a picture button. Where pic is the file name of the picture.
956
958 Int_t id, GContext_t norm, UInt_t option) : TGButton(p, id, norm, option)
959{
960 if (!pic || !pic[0]) {
961 if (p) Error("TGPictureButton", "pixmap not found for button");
962 fPic = fClient->GetPicture("mb_question_s.xpm");
963 } else {
964 fPic = fClient->GetPicture(pic);
965 }
966
967 if (fPic) {
968 fTWidth = fPic->GetWidth();
970
972 fTHeight + (fBorderWidth << 1) + fBorderWidth); // *3
973 }
974 fPicD = 0;
977}
978
979////////////////////////////////////////////////////////////////////////////////
980/// Destructor.
981
983{
985}
986
987////////////////////////////////////////////////////////////////////////////////
988/// Change a picture in a picture button. The picture is not adopted and
989/// must later be freed by the user once the picture button is deleted
990/// (a single picture reference might be used by other buttons).
991
993{
994 if (!new_pic) {
995 Error("SetPicture", "pixmap not found for button %d\n%s",
997 return;
998 }
999
1000 fPic = new_pic;
1001
1002 if (fState == kButtonDisabled) {
1004 fPicD = 0;
1005 }
1006
1007 fTWidth = fPic->GetWidth();
1008 fTHeight = fPic->GetHeight();
1009
1010 fClient->NeedRedraw(this);
1011}
1012
1013////////////////////////////////////////////////////////////////////////////////
1014/// Redraw picture button.
1015
1017{
1018 if (!fPic) {
1020 return;
1021 }
1022
1023 int x = (fWidth - fTWidth) >> 1;
1024 int y = (fHeight - fTHeight) >> 1;
1025 UInt_t w = GetWidth() - 1;
1026 UInt_t h = GetHeight()- 1;
1027
1028 if ((fStyle > 0) && !(fOptions & kOwnBackground))
1029 gVirtualX->SetWindowBackground(fId, fBgndColor);
1031
1032 if (fState == kButtonDown || fState == kButtonEngaged) {
1033 ++x; ++y;
1034 w--; h--;
1035 }
1036 if (fStyle == 0) {
1037 if (fState == kButtonEngaged) {
1038 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
1039 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
1040 }
1041 }
1042
1043 const TGPicture *pic = fPic;
1044 if (fState == kButtonDisabled) {
1046 pic = fPicD ? fPicD : fPic;
1047 }
1048 if (fStyle > 0) {
1049 if (fBgndColor == fHighColor) {
1050 gVirtualX->DrawRectangle(fId, TGFrame::GetShadowGC()(), 0, 0, w, h);
1051 }
1052 }
1053
1054 pic->Draw(fId, fNormGC, x, y);
1055}
1056
1057////////////////////////////////////////////////////////////////////////////////
1058/// Creates disabled picture.
1059
1061{
1062 TImage *img = TImage::Create();
1063 if (!img) return;
1064 TImage *img2 = TImage::Create();
1065 if (!img2) {
1066 if (img) delete img;
1067 return;
1068 }
1069 TString back = gEnv->GetValue("Gui.BackgroundColor", "#c0c0c0");
1070 img2->FillRectangle(back.Data(), 0, 0, fPic->GetWidth(), fPic->GetHeight());
1071 img->SetImage(fPic->GetPicture(), fPic->GetMask());
1072 Pixmap_t mask = img->GetMask();
1073 img2->Merge(img, "overlay");
1074
1075 TString name = "disbl_";
1076 name += fPic->GetName();
1077 fPicD = fClient->GetPicturePool()->GetPicture(name.Data(), img2->GetPixmap(),
1078 mask);
1080 delete img;
1081 delete img2;
1082}
1083
1084////////////////////////////////////////////////////////////////////////////////
1085/// Changes disabled picture.
1086
1088{
1089 if (!pic) return;
1090
1092 fPicD = pic;
1093 ((TGPicture*)pic)->AddReference();
1095}
1096
1097////////////////////////////////////////////////////////////////////////////////
1098/// Create a check button widget. The hotstring will be adopted and deleted
1099/// by the check button.
1100
1102 GContext_t norm, FontStruct_t font, UInt_t option)
1103 : TGTextButton(p, s, id, norm, font, option)
1104{
1105 Init();
1106}
1107
1108////////////////////////////////////////////////////////////////////////////////
1109/// Create a check button widget.
1110
1112 GContext_t norm, FontStruct_t font, UInt_t option)
1113 : TGTextButton(p, s, id, norm, font, option)
1114{
1115 Init();
1116}
1117
1118////////////////////////////////////////////////////////////////////////////////
1119/// Create a check button widget.
1120
1121TGCheckButton::TGCheckButton(const TGWindow *p, const char *s, const char *cmd,
1122 Int_t id, GContext_t norm, FontStruct_t font,
1123 UInt_t option) : TGTextButton(p, s, cmd, id, norm, font, option)
1124{
1125 Init();
1126}
1127
1128////////////////////////////////////////////////////////////////////////////////
1129/// Common check button initialization.
1130
1132{
1133 fPrevState =
1134 fState = kButtonUp;
1135 fHKeycode = 0;
1136
1137 fOn = fClient->GetPicture("checked_t.xpm");
1138 fOff = fClient->GetPicture("unchecked_t.xpm");
1139 fDisOn = fClient->GetPicture("checked_dis_t.xpm");
1140 fDisOff = fClient->GetPicture("unchecked_dis_t.xpm");
1141
1142 Resize();
1143
1144 if (!fOn) {
1145 Error("TGCheckButton", "checked_t.xpm not found");
1146 } else if (!fOff) {
1147 Error("TGCheckButton", "unchecked_t.xpm not found");
1148 } else if (!fDisOn) {
1149 Error("TGCheckButton", "checked_dis_t.xpm not found");
1150 } else if (!fDisOff) {
1151 Error("TGCheckButton", "unchecked_dis_t.xpm not found");
1152 }
1153 int hotchar;
1154
1155 if ((hotchar = fLabel->GetHotChar()) != 0) {
1156 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
1158 if (main) {
1159 main->BindKey(this, fHKeycode, kKeyMod1Mask);
1160 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
1161 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
1163
1164 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
1168 }
1169 }
1170 }
1171 SetWindowName();
1172}
1173
1174////////////////////////////////////////////////////////////////////////////////
1175/// Delete a check button.
1176
1178{
1179 if (fOn) fClient->FreePicture(fOn);
1183}
1184
1185////////////////////////////////////////////////////////////////////////////////
1186/// default size
1187
1189{
1190 UInt_t w = !fTWidth ? fOff->GetWidth() : fTWidth + fOff->GetWidth() + 9;
1191 UInt_t h = !fTHeight ? fOff->GetHeight() : fTHeight + 2;
1192
1193 w = GetOptions() & kFixedWidth ? fWidth : w;
1194 h = GetOptions() & kFixedHeight ? fHeight : h;
1195
1196 return TGDimension(w, h);
1197}
1198
1199////////////////////////////////////////////////////////////////////////////////
1200/// Set check button state.
1201
1203{
1204 if (state == kButtonDisabled)
1205 fWidgetFlags &= ~kWidgetIsEnabled;
1206 else
1208 PSetState(state, emit);
1209}
1210
1211////////////////////////////////////////////////////////////////////////////////
1212/// Emit signals.
1213
1215{
1216 if (fState == kButtonUp) Released(); // emit Released
1217 if (fState == kButtonDown) Pressed(); // emit Pressed
1218 Clicked(); // emit Clicked
1219 Toggled(fStateOn); // emit Toggled
1220}
1221
1222////////////////////////////////////////////////////////////////////////////////
1223/// Set check button state.
1224
1226{
1227 if (state != fState) {
1228 if (state == kButtonUp) {
1229 if (fPrevState == kButtonDisabled) {
1230 if (fStateOn) {
1233 } else {
1234 fState = state;
1235 fPrevState = state;
1236 }
1237 } else if (fPrevState == kButtonDown) {
1238 fStateOn = kFALSE;
1239 fState = state;
1240 fPrevState = state;
1241 }
1242 } else if (state == kButtonDown) {
1243 fStateOn = kTRUE;
1244 fState = state;
1245 fPrevState = state;
1246 } else {
1247 fState = state;
1248 fPrevState = state;
1249 }
1250 if (emit) {
1251 // button signals
1252 EmitSignals();
1253 }
1254 DoRedraw();
1255 }
1256}
1257
1258////////////////////////////////////////////////////////////////////////////////
1259/// Set the state of a check button to disabled and either on or
1260/// off.
1261
1263{
1264 if (!enable) {
1265 if (fState == kButtonDisabled && fStateOn) {
1266 PSetState(kButtonUp, kFALSE); // enable button
1267 PSetState(kButtonUp, kFALSE); // set button up
1268 PSetState(kButtonDisabled, kFALSE); // disable button
1269 } else {
1272 }
1273 } else {
1274 PSetState(kButtonDown, kFALSE); // set button down
1275 PSetState(kButtonDisabled, kFALSE); // disable button
1276 }
1277}
1278
1279////////////////////////////////////////////////////////////////////////////////
1280/// Handle mouse button event.
1281
1283{
1284 Bool_t click = kFALSE;
1285
1286 if (fTip) fTip->Hide();
1287
1288 if (fState == kButtonDisabled) return kTRUE;
1289
1290 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
1291 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
1292
1293 // We don't need to check the button number as GrabButton will
1294 // only allow button1 events
1295 if (event->fType == kButtonPress) {
1296 fgReleaseBtn = 0;
1297 if (in) {
1299 Pressed();
1300 }
1301 } else { // ButtonRelease
1302 if (in) {
1304 click = kTRUE;
1306 Released();
1307 }
1308 fgReleaseBtn = fId;
1309 fOptions &= ~kSunkenFrame;
1310 }
1311 if (click) {
1312 Clicked();
1318 }
1319 DoRedraw();
1320 return kTRUE;
1321}
1322
1323////////////////////////////////////////////////////////////////////////////////
1324/// Handle mouse crossing event.
1325
1327{
1328 if (fTip) {
1329 if (event->fType == kEnterNotify)
1330 fTip->Reset();
1331 else
1332 fTip->Hide();
1333 }
1334
1335 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
1336
1337 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
1338 return kTRUE;
1339
1340 if (fState == kButtonDisabled) return kTRUE;
1341
1342 if (event->fType == kEnterNotify) {
1344 } else {
1345 fOptions &= ~kSunkenFrame;
1346 }
1347 DoRedraw();
1348
1349 return kTRUE;
1350}
1351
1352////////////////////////////////////////////////////////////////////////////////
1353/// Handle key event. This function will be called when the hotkey is hit.
1354
1356{
1357 Bool_t click = kFALSE;
1358
1359 if (event->fType == kGKeyPress)
1360 gVirtualX->SetKeyAutoRepeat(kFALSE);
1361 else
1362 gVirtualX->SetKeyAutoRepeat(kTRUE);
1363
1364 if (fTip && event->fType == kGKeyPress) fTip->Hide();
1365
1366 if (fState == kButtonDisabled) return kTRUE;
1367
1368 // We don't need to check the key number as GrabKey will only
1369 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
1370
1371 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
1373 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
1374 click = (fState != fPrevState);
1376 }
1377 if (click) {
1379 (Long_t) fUserData);
1381 (Long_t) fUserData);
1382 }
1383 return kTRUE;
1384}
1385
1386////////////////////////////////////////////////////////////////////////////////
1387/// Draw the check button widget.
1388
1390{
1391 int x, y, y0;
1392
1394
1395 x = 20;
1396 y = (fHeight - fTHeight) >> 1;
1397
1398 y0 = !fTHeight ? 0 : y + 1;
1399 if (fOn && fOff) {
1400 Int_t smax = TMath::Max(fOn->GetHeight(), fOff->GetHeight());
1401 y0 = ((Int_t)fHeight <= smax) ? 0 : 1 + (((Int_t)fHeight - smax) >> 1);
1402 }
1403
1404 if (fStateOn) {
1405 if (fOn) fOn->Draw(fId, fNormGC, 0, y0);
1406 } else {
1407 if (fOff) fOff->Draw(fId, fNormGC, 0, y0);
1408 }
1409
1410 Int_t hotpos = fLabel->GetHotPos();
1411
1412 if (fState == kButtonDisabled) {
1413 if (fStateOn == kTRUE) {
1414 if (fDisOn) fDisOn->Draw(fId, fNormGC, 0, y0);
1415 } else {
1416 if (fDisOff) fDisOff->Draw(fId, fNormGC, 0, y0);
1417 }
1418
1420 TGGC *gc = pool->FindGC(fNormGC);
1421 if (gc) {
1422 Pixel_t fore = gc->GetForeground();
1425
1426 gc->SetForeground(hi);
1427 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
1428 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
1429
1430 gc->SetForeground(sh);
1431 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
1432 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
1433
1434 gc->SetForeground(fore);
1435 }
1436 } else {
1437 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
1438 if (hotpos) fTLayout->UnderlineChar(fId, fNormGC, x, y, hotpos - 1);
1439 }
1440}
1441
1442////////////////////////////////////////////////////////////////////////////////
1443/// Return default font structure.
1444
1446{
1447 if (!fgDefaultFont)
1448 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
1449 return fgDefaultFont->GetFontStruct();
1450}
1451
1452////////////////////////////////////////////////////////////////////////////////
1453/// Return default graphics context.
1454
1456{
1457 if (!fgDefaultGC)
1458 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1459 return *fgDefaultGC;
1460}
1461
1462
1463////////////////////////////////////////////////////////////////////////////////
1464/// Create a radio button widget. The hotstring will be adopted and deleted
1465/// by the radio button.
1466
1468 GContext_t norm, FontStruct_t font, UInt_t option)
1469 : TGTextButton(p, s, id, norm, font, option)
1470{
1471 Init();
1472}
1473
1474////////////////////////////////////////////////////////////////////////////////
1475/// Create a radio button widget.
1476
1478 GContext_t norm, FontStruct_t font, UInt_t option)
1479 : TGTextButton(p, s, id, norm, font, option)
1480{
1481 Init();
1482}
1483////////////////////////////////////////////////////////////////////////////////
1484/// Create a radio button widget.
1485
1486TGRadioButton::TGRadioButton(const TGWindow *p, const char *s, const char *cmd,
1487 Int_t id, GContext_t norm,
1488 FontStruct_t font, UInt_t option)
1489 : TGTextButton(p, s, cmd, id, norm, font, option)
1490{
1491 Init();
1492}
1493
1494////////////////////////////////////////////////////////////////////////////////
1495/// Common radio button initialization.
1496
1498{
1499 fPrevState =
1500 fState = kButtonUp;
1501 fHKeycode = 0;
1502
1503 fOn = fClient->GetPicture("rbutton_on.xpm");
1504 fOff = fClient->GetPicture("rbutton_off.xpm");
1505 fDisOn = fClient->GetPicture("rbutton_dis_on.xpm");
1506 fDisOff = fClient->GetPicture("rbutton_dis_off.xpm");
1507
1508 if (!fOn || !fOff || !fDisOn || !fDisOff)
1509 Error("TGRadioButton", "rbutton_*.xpm not found");
1510
1511 Resize();
1512
1513 int hotchar;
1514
1515 if ((hotchar = fLabel->GetHotChar()) != 0) {
1516 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
1518 if (main) {
1519 main->BindKey(this, fHKeycode, kKeyMod1Mask);
1520 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
1521 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
1523
1524 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
1528 }
1529 }
1530 }
1531
1532 if (fParent->IsA()->InheritsFrom(TGButtonGroup::Class())) {
1533 ((TGButtonGroup*)fParent)->SetRadioButtonExclusive(kTRUE);
1534 }
1535 SetWindowName();
1536}
1537
1538////////////////////////////////////////////////////////////////////////////////
1539/// Delete a radio button.
1540
1542{
1543 if (fOn) fClient->FreePicture(fOn);
1547}
1548
1549////////////////////////////////////////////////////////////////////////////////
1550/// default size
1551
1553{
1554 UInt_t w = !fTWidth ? fOff->GetWidth() : fTWidth + fOff->GetWidth() + 10;
1555 UInt_t h = !fTHeight ? fOff->GetHeight() : fTHeight + 2;
1556
1557 w = GetOptions() & kFixedWidth ? fWidth : w;
1558 h = GetOptions() & kFixedHeight ? fHeight : h;
1559
1560 return TGDimension(w, h);
1561}
1562////////////////////////////////////////////////////////////////////////////////
1563/// Set radio button state.
1564
1566{
1567 if (state == kButtonDisabled)
1568 fWidgetFlags &= ~kWidgetIsEnabled;
1569 else
1571 PSetState(state, emit);
1572}
1573
1574////////////////////////////////////////////////////////////////////////////////
1575/// Set the state of a radio button to disabled and either on or
1576/// off.
1577
1579{
1580 if (!enable) {
1581 if (fState == kButtonDisabled && fStateOn) {
1582 PSetState(kButtonUp, kFALSE); // enable button
1583 PSetState(kButtonUp, kFALSE); // set button up
1584 PSetState(kButtonDisabled, kFALSE); // disable button
1585 } else {
1588 }
1589 } else {
1590 PSetState(kButtonDown, kFALSE); // set button down
1591 PSetState(kButtonDisabled, kFALSE); // disable button
1592 }
1593}
1594
1595////////////////////////////////////////////////////////////////////////////////
1596/// Emit signals.
1597
1599{
1600 if (fState == kButtonUp) Released(); // emit Released
1601 if (fState == kButtonDown) Pressed(); // emit Pressed
1602 Clicked(); // emit Clicked
1603 Toggled(fStateOn); // emit Toggled
1604}
1605
1606////////////////////////////////////////////////////////////////////////////////
1607/// Set radio button state.
1608
1610{
1611 if (state != fState) {
1612 // fPrevState = fState = state;
1613 if (state == kButtonUp) {
1614 if (fPrevState == kButtonDisabled) {
1615 if (fStateOn) {
1618 } else {
1619 fState = state;
1620 fPrevState = state;
1621 }
1622 } else if (fPrevState == kButtonDown) {
1623 fStateOn = kFALSE;
1624 fState = state;
1625 fPrevState = state;
1626 }
1627 } else if (state == kButtonDown) {
1628 fStateOn = kTRUE;
1629 fState = state;
1630 fPrevState = state;
1631 } else {
1632 fState = state;
1633 fPrevState = state;
1634 }
1635 if (emit) {
1636 // button signals
1637 EmitSignals();
1638 }
1639 DoRedraw();
1640 }
1641}
1642
1643////////////////////////////////////////////////////////////////////////////////
1644/// Handle mouse button event.
1645
1647{
1648 Bool_t click = kFALSE;
1649 Bool_t toggled = kFALSE;
1650
1651 if (fTip) fTip->Hide();
1652
1653 if (fState == kButtonDisabled) return kFALSE;
1654
1655
1656 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
1657 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
1658
1659 if (event->fType == kButtonPress) { // button pressed
1660 fgReleaseBtn = 0;
1661 if (in) {
1663 Pressed();
1664 }
1665 } else { // ButtonRelease
1666 if (in) {
1667 if (!fStateOn) {
1669 toggled = kTRUE;
1670 }
1672 Released();
1673 click = kTRUE;
1674 }
1675 fOptions &= ~kSunkenFrame;
1676 fgReleaseBtn = fId;
1677 }
1678 if (click) {
1679 Clicked();
1684 }
1685 if (toggled) {
1687 }
1688 DoRedraw();
1689 return kTRUE;
1690}
1691
1692////////////////////////////////////////////////////////////////////////////////
1693/// Handle mouse crossing event.
1694
1696{
1697 if (fTip) {
1698 if (event->fType == kEnterNotify)
1699 fTip->Reset();
1700 else
1701 fTip->Hide();
1702 }
1703
1704 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
1705
1706 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
1707 return kTRUE;
1708
1709 if (fState == kButtonDisabled) return kTRUE;
1710
1711 if (event->fType == kEnterNotify) {
1713 } else {
1714 fOptions &= ~kSunkenFrame;
1715 }
1716 DoRedraw();
1717
1718 return kTRUE;
1719}
1720
1721////////////////////////////////////////////////////////////////////////////////
1722/// Handle key event. This function will be called when the hotkey is hit.
1723
1725{
1726 if (event->fType == kGKeyPress)
1727 gVirtualX->SetKeyAutoRepeat(kFALSE);
1728 else
1729 gVirtualX->SetKeyAutoRepeat(kTRUE);
1730
1731 if (fTip && event->fType == kGKeyPress)
1732 fTip->Hide();
1733
1734 if (fState == kButtonDisabled) return kTRUE;
1735
1736 // We don't need to check the key number as GrabKey will only
1737 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
1738
1739 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
1745 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
1747 }
1748 return kTRUE;
1749}
1750
1751////////////////////////////////////////////////////////////////////////////////
1752/// Draw a radio button.
1753
1755{
1756 Int_t tx, ty, y0;
1757
1759
1760 tx = 20;
1761 ty = (fHeight - fTHeight) >> 1;
1762
1763// pw = 12;
1764 y0 = !fTHeight ? 0 : ty + 1;
1765 if (fOn && fOff) {
1766 Int_t smax = TMath::Max(fOn->GetHeight(), fOff->GetHeight());
1767 y0 = ((Int_t)fHeight <= smax) ? 0 : 1 + (((Int_t)fHeight - smax) >> 1);
1768 }
1769
1770 if (fStateOn) {
1771 if (fOn) fOn->Draw(fId, fNormGC, 0, y0);
1772 } else {
1773 if (fOff) fOff->Draw(fId, fNormGC, 0, y0);
1774 }
1775
1776 Int_t hotpos = fLabel->GetHotPos();
1777
1778 if (fState == kButtonDisabled) {
1779 if (fStateOn == kTRUE) {
1780 if (fDisOn) fDisOn->Draw(fId, fNormGC, 0, y0);
1781 } else {
1782 if (fDisOff) fDisOff->Draw(fId, fNormGC, 0, y0);
1783 }
1784
1786 TGGC *gc = pool->FindGC(fNormGC);
1787 if (gc) {
1788 Pixel_t fore = gc->GetForeground();
1791
1792 gc->SetForeground(hi);
1793 fTLayout->DrawText(fId, gc->GetGC(), tx + 1, ty + 1, 0, -1);
1794 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), tx, ty, hotpos - 1);
1795
1796 gc->SetForeground(sh);
1797 fTLayout->DrawText(fId, gc->GetGC(), tx, ty, 0, -1);
1798 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), tx, ty, hotpos - 1);
1799
1800 gc->SetForeground(fore);
1801 }
1802 } else {
1803 fTLayout->DrawText(fId, fNormGC, tx, ty, 0, -1);
1804 if (hotpos) fTLayout->UnderlineChar(fId, fNormGC, tx, ty, hotpos-1);
1805 }
1806}
1807
1808////////////////////////////////////////////////////////////////////////////////
1809/// Return default font structure.
1810
1812{
1813 if (!fgDefaultFont)
1814 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
1815 return fgDefaultFont->GetFontStruct();
1816}
1817
1818////////////////////////////////////////////////////////////////////////////////
1819/// Return default graphics context.
1820
1822{
1823 if (!fgDefaultGC)
1824 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1825 return *fgDefaultGC;
1826}
1827
1828////////////////////////////////////////////////////////////////////////////////
1829/// Save a button widget as a C++ statement(s) on output stream out.
1830
1831void TGButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1832{
1833 char quote = '"';
1834
1835 if (option && strstr(option, "keep_names"))
1836 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
1837
1838 if (fState == kButtonDown) {
1839 out << " " << GetName() << "->SetState(kButtonDown);" << std::endl;
1840 }
1841 if (fState == kButtonDisabled) {
1842 out << " " << GetName() << "->SetState(kButtonDisabled);" << std::endl;
1843 }
1844 if (fState == kButtonEngaged) {
1845 out << " " << GetName() << "->SetState(kButtonEngaged);" << std::endl;
1846 }
1848 SaveUserColor(out, option);
1849 out << " " << GetName() << "->ChangeBackground(ucolor);" << std::endl;
1850 }
1851
1852 if (fTip) {
1853 TString tiptext = fTip->GetText()->GetString();
1854 tiptext.ReplaceAll("\n", "\\n");
1855 out << " ";
1856 out << GetName() << "->SetToolTipText(" << quote
1857 << tiptext << quote << ");" << std::endl;
1858 }
1859 if (strlen(fCommand)) {
1860 out << " " << GetName() << "->SetCommand(" << quote << fCommand
1861 << quote << ");" << std::endl;
1862 }
1863}
1864
1865////////////////////////////////////////////////////////////////////////////////
1866/// Save a text button widget as a C++ statement(s) on output stream out.
1867
1868void TGTextButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1869{
1870 char quote = '"';
1871 TString outext(fLabel->GetString());
1872 if (fLabel->GetHotPos() > 0)
1873 outext.Insert(fLabel->GetHotPos()-1, "&");
1874 if (outext.First('\n') >= 0)
1875 outext.ReplaceAll("\n", "\\n");
1876
1877 // font + GC
1878 option = GetName()+5; // unique digit id of the name
1879 TString parGC, parFont;
1880 parFont.Form("%s::GetDefaultFontStruct()",IsA()->GetName());
1881 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
1882
1883 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
1884 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
1885 if (ufont) {
1886 ufont->SavePrimitive(out, option);
1887 parFont.Form("ufont->GetFontStruct()");
1888 }
1889
1890 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
1891 if (userGC) {
1892 userGC->SavePrimitive(out, option);
1893 parGC.Form("uGC->GetGC()");
1894 }
1895 }
1896
1898
1899 out << " TGTextButton *";
1900 out << GetName() << " = new TGTextButton(" << fParent->GetName()
1901 << "," << quote << outext.Data() << quote;
1902
1903 if (GetOptions() == (kRaisedFrame | kDoubleBorder)) {
1905 if (fNormGC == GetDefaultGC()()) {
1906 if (fWidgetId == -1) {
1907 out << ");" << std::endl;
1908 } else {
1909 out << "," << fWidgetId <<");" << std::endl;
1910 }
1911 } else {
1912 out << "," << fWidgetId << "," << parGC << ");" << std::endl;
1913 }
1914 } else {
1915 out << "," << fWidgetId << "," << parGC << "," << parFont << ");" << std::endl;
1916 }
1917 } else {
1918 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");" << std::endl;
1919 }
1920
1921 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");" << std::endl;
1922 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << ",";
1923 out << fMTop << "," << fMBottom << ");" << std::endl;
1924 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");" << std::endl;
1925
1926 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetHeight()
1927 << ");" << std::endl;
1928
1929 TGButton::SavePrimitive(out,option);
1930}
1931
1932////////////////////////////////////////////////////////////////////////////////
1933/// Save a picture button widget as a C++ statement(s) on output stream out.
1934
1935void TGPictureButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1936{
1937 if (!fPic) {
1938 Error("SavePrimitive()", "pixmap not found for picture button %d ", fWidgetId);
1939 return;
1940 }
1941
1942 // GC
1943 option = GetName()+5; // unique digit id of the name
1944 TString parGC;
1945 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
1946
1947 if (GetDefaultGC()() != fNormGC) {
1948 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
1949 if (userGC) {
1950 userGC->SavePrimitive(out, option);
1951 parGC.Form("uGC->GetGC()");
1952 }
1953 }
1954
1955 char quote = '"';
1956 TString picname = gSystem->UnixPathName(fPic->GetName());
1957 gSystem->ExpandPathName(picname);
1958
1959 out <<" TGPictureButton *";
1960
1961 out << GetName() << " = new TGPictureButton(" << fParent->GetName()
1962 << ",gClient->GetPicture(" << quote
1963 << picname << quote << ")";
1964
1965 if (GetOptions() == (kRaisedFrame | kDoubleBorder)) {
1966 if (fNormGC == GetDefaultGC()()) {
1967 if (fWidgetId == -1) {
1968 out << ");" << std::endl;
1969 } else {
1970 out << "," << fWidgetId << ");" << std::endl;
1971 }
1972 } else {
1973 out << "," << fWidgetId << "," << parGC.Data() << ");" << std::endl;
1974 }
1975 } else {
1976 out << "," << fWidgetId << "," << parGC.Data() << "," << GetOptionString()
1977 << ");" << std::endl;
1978 }
1979
1980 TGButton::SavePrimitive(out,option);
1981}
1982
1983////////////////////////////////////////////////////////////////////////////////
1984/// Save a check button widget as a C++ statement(s) on output stream out.
1985
1986void TGCheckButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1987{
1988 char quote = '"';
1989
1990 TString outext(fLabel->GetString());
1991 if (fLabel->GetHotPos() > 0)
1992 outext.Insert(fLabel->GetHotPos()-1, "&");
1993 if (outext.First('\n') >= 0)
1994 outext.ReplaceAll("\n", "\\n");
1995
1996 out <<" TGCheckButton *";
1997 out << GetName() << " = new TGCheckButton(" << fParent->GetName()
1998 << "," << quote << outext.Data() << quote;
1999
2000 // font + GC
2001 option = GetName()+5; // unique digit id of the name
2002 TString parGC, parFont;
2003 parFont.Form("%s::GetDefaultFontStruct()",IsA()->GetName());
2004 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
2005
2006 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
2007 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
2008 if (ufont) {
2009 ufont->SavePrimitive(out, option);
2010 parFont.Form("ufont->GetFontStruct()");
2011 }
2012
2013 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
2014 if (userGC) {
2015 userGC->SavePrimitive(out, option);
2016 parGC.Form("uGC->GetGC()");
2017 }
2018 }
2019
2020 if (GetOptions() == kChildFrame) {
2022 if (fNormGC == GetDefaultGC()()) {
2023 if (fWidgetId == -1) {
2024 out << ");" << std::endl;
2025 } else {
2026 out << "," << fWidgetId << ");" << std::endl;
2027 }
2028 } else {
2029 out << "," << fWidgetId << "," << parGC << ");" << std::endl;
2030 }
2031 } else {
2032 out << "," << fWidgetId << "," << parGC << "," << parFont << ");" << std::endl;
2033 }
2034 } else {
2035 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");" << std::endl;
2036 }
2037
2038 TGButton::SavePrimitive(out,option);
2039 if (fState == kButtonDisabled) {
2041 out << " " << GetName() << "->SetDisabledAndSelected(kTRUE);" << std::endl;
2042 else
2043 out << " " << GetName() << "->SetDisabledAndSelected(kFALSE);" << std::endl;
2044 }
2045 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");" << std::endl;
2046 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << ",";
2047 out << fMTop << "," << fMBottom << ");" << std::endl;
2048 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");" << std::endl;
2049}
2050
2051////////////////////////////////////////////////////////////////////////////////
2052/// Save a radio button widget as a C++ statement(s) on output stream out.
2053
2054void TGRadioButton::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2055{
2056 char quote = '"';
2057
2058 TString outext(fLabel->GetString());
2059 if (fLabel->GetHotPos() > 0)
2060 outext.Insert(fLabel->GetHotPos()-1, "&");
2061 if (outext.First('\n') >= 0)
2062 outext.ReplaceAll("\n", "\\n");
2063
2064 out << " TGRadioButton *";
2065 out << GetName() << " = new TGRadioButton(" << fParent->GetName()
2066 << "," << quote << outext.Data() << quote;
2067
2068 // font + GC
2069 option = GetName()+5; // unique digit id of the name
2070 TString parGC, parFont;
2071 parFont.Form("%s::GetDefaultFontStruct()",IsA()->GetName());
2072 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
2073
2074 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
2075 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
2076 if (ufont) {
2077 ufont->SavePrimitive(out, option);
2078 parFont.Form("ufont->GetFontStruct()");
2079 }
2080
2081 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
2082 if (userGC) {
2083 userGC->SavePrimitive(out, option);
2084 parGC.Form("uGC->GetGC()");
2085 }
2086 }
2087
2088 if (GetOptions() == (kChildFrame)) {
2090 if (fNormGC == GetDefaultGC()()) {
2091 if (fWidgetId == -1) {
2092 out <<");" << std::endl;
2093 } else {
2094 out << "," << fWidgetId << ");" << std::endl;
2095 }
2096 } else {
2097 out << "," << fWidgetId << "," << parGC << ");" << std::endl;
2098 }
2099 } else {
2100 out << "," << fWidgetId << "," << parGC << "," << parFont << ");" << std::endl;
2101 }
2102 } else {
2103 out << "," << fWidgetId << "," << parGC << "," << parFont << "," << GetOptionString() << ");" << std::endl;
2104 }
2105
2106 TGButton::SavePrimitive(out,option);
2107 if (fState == kButtonDisabled) {
2109 out << " " << GetName() << "->SetDisabledAndSelected(kTRUE);" << std::endl;
2110 else
2111 out << " " << GetName() << "->SetDisabledAndSelected(kFALSE);" << std::endl;
2112 }
2113 out << " " << GetName() << "->SetTextJustify(" << fTMode << ");" << std::endl;
2114 out << " " << GetName() << "->SetMargins(" << fMLeft << "," << fMRight << ",";
2115 out << fMTop << "," << fMBottom << ");" << std::endl;
2116 out << " " << GetName() << "->SetWrapLength(" << fWrapLength << ");" << std::endl;
2117}
2118
2119////////////////////////////////////////////////////////////////////////////////
2120/// Create a menu button widget. The hotstring will be adopted and
2121/// deleted by the menu button. This constructior creates a
2122/// menubutton with a popup menu attached that appears when the
2123/// button for it is clicked. The popup menu is adopted.
2124
2126 TGPopupMenu *popmenu, Bool_t split, Int_t id,
2127 GContext_t norm, FontStruct_t fontstruct, UInt_t options)
2128 : TGTextButton(p, menulabel, id, norm, fontstruct, options)
2129{
2130 fFontStruct = fontstruct;
2131 fMBWidth = 16;
2132 fMenuLabel = new TGHotString(*menulabel);
2133 fPopMenu = popmenu;
2134 fPopMenu->fSplitButton = this;
2135 fSplit = split;
2136 fTMode = 0;
2137 fHKeycode = 0;
2140 fWidestLabel = "";
2141 fHeighestLabel = "";
2142
2143 // Find and set the correct size for the menu and the button.
2144 TGMenuEntry *entry = 0;
2145 TGHotString lstring(*fMenuLabel);
2146 TGHotString hstring(*fMenuLabel);
2147 const TList *list = fPopMenu->GetListOfEntries();
2148 UInt_t lwidth = 0, lheight = 0;
2149 UInt_t twidth = 0, theight = 0;
2150
2152 if (!font) {
2154 if (font) fFontStruct = font->GetFontStruct();
2155 }
2156
2157 if (font) font->ComputeTextLayout(lstring, lstring.GetLength(),
2159 &lwidth, &lheight);
2160
2161 TIter iter(list);
2162 entry = (TGMenuEntry *)iter.Next();
2163 while (entry != 0) {
2164 if (entry->GetType() == kMenuEntry) {
2165 const TGHotString string(*(entry->GetLabel()));
2166 if (font) font->ComputeTextLayout(string, string.GetLength(),
2168 &twidth, &theight);
2169 if(twidth > lwidth) {
2170 lstring = string;
2171 }
2172 if(theight > lheight) {
2173 hstring = string;
2174 }
2175 }
2176 entry = (TGMenuEntry *)iter.Next();
2177 }
2178 fWidestLabel = lstring;
2179 fHeighestLabel = hstring;
2180
2181 if (font) {
2182 UInt_t dummy = 0;
2183 font->ComputeTextLayout(lstring, lstring.GetLength(),
2185 &fTWidth, &dummy);
2186 font->ComputeTextLayout(hstring, hstring.GetLength(),
2188 &dummy, &fTHeight);
2189 }
2190 fTBWidth = fTWidth + 8;
2191 fHeight = fTHeight + 7;
2193
2195
2196 // Save the id of the 1st item on the menu.
2197 TIter iter1(list);
2198 do {
2199 entry = (TGMenuEntry *)iter1.Next();
2200 if ((entry) && (entry->GetStatus() & kMenuEnableMask) &&
2201 !(entry->GetStatus() & kMenuHideMask) &&
2202 (entry->GetType() != kMenuSeparator) &&
2203 (entry->GetType() != kMenuLabel)) break;
2204 entry = (TGMenuEntry *)iter1.Next();
2205 } while (entry);
2206 if (entry) fEntryId = entry->GetEntryId();
2207
2208 // An additional connection that is needed.
2209 fPopMenu->Connect("Activated(Int_t)", "TGSplitButton", this, "HandleMenu(Int_t)");
2211
2212 Init();
2213}
2214
2215
2216////////////////////////////////////////////////////////////////////////////////
2217/// Common initialization used by the different ctors.
2218
2220{
2221 Int_t hotchar;
2222
2224 fHKeycode = 0;
2226 fPrevStateOn =
2227 fStateOn = kFALSE;
2229
2231
2232 if ((hotchar = fLabel->GetHotChar()) != 0) {
2233 if ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0) {
2235 if (main) {
2236 main->BindKey(this, fHKeycode, kKeyMod1Mask);
2237 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2238 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2240
2241 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2245 }
2246 }
2247 }
2250 wattr.fBitGravity = 5; // center
2251 wattr.fWinGravity = 1;
2252 gVirtualX->ChangeWindowAttributes(fId, &wattr);
2253
2254 // Make sure motion is detected too.
2256
2257 SetWindowName();
2258}
2259
2260////////////////////////////////////////////////////////////////////////////////
2261/// Delete a split button widget.
2262
2264{
2265 if (fPopMenu) delete fPopMenu;
2266 if (fMenuLabel) delete fMenuLabel;
2267}
2268
2269////////////////////////////////////////////////////////////////////////////////
2270/// Draw triangle (arrow) on which user can click to open Popup.
2271
2273{
2274 Point_t points[3];
2275
2276 points[0].fX = x;
2277 points[0].fY = y;
2278 points[1].fX = x + 5;
2279 points[1].fY = y;
2280 points[2].fX = x + 2;
2281 points[2].fY = y + 3;
2282
2283 gVirtualX->FillPolygon(fId, gc, points, 3);
2284}
2285
2286////////////////////////////////////////////////////////////////////////////////
2287/// Calculate the size of the button.
2288
2290{
2291 Int_t max_ascent, max_descent;
2293 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2294 fTHeight = max_ascent + max_descent;
2295
2296 fTBWidth = fTWidth + 8;
2297 fHeight = fTHeight + 7;
2298 fWidth = fTBWidth;
2299}
2300
2301////////////////////////////////////////////////////////////////////////////////
2302/// Handle mouse button event in case the button is split.
2303
2305{
2306 if (fState == kButtonDisabled) return kFALSE;
2307
2308 Bool_t activate = kFALSE;
2309 Bool_t bclick = kFALSE;
2310 static Bool_t mbpress = kFALSE;
2311 static Bool_t tbpress = kFALSE;
2312 static Bool_t outpress = kFALSE;
2313
2314 Bool_t inTB = (event->fX >= 0) && (event->fY >= 0) &&
2315 (event->fX <= (Int_t)fTBWidth) && (event->fY <= (Int_t)fHeight);
2316
2317 Bool_t inMB = (event->fX >= (Int_t)(fWidth -fMBWidth)) && (event->fY >= 0) &&
2318 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2319
2320 // We don't need to check the button number as GrabButton will
2321 // only allow button1 events
2322
2323 if (inTB) {
2324 if (event->fType == kButtonPress) {
2325 mbpress = kFALSE;
2326 tbpress = kTRUE;
2327 fgReleaseBtn = 0;
2328 if (fState == kButtonEngaged) {
2329 return kTRUE;
2330 }
2332 Pressed();
2333 } else { // ButtonRelease
2334 if (fMBState == kButtonDown) {
2336 }
2337 if (fState == kButtonEngaged && tbpress) {
2339 Released();
2340 bclick = kTRUE;
2341 } else if (fState == kButtonDown && tbpress) {
2342 tbpress = kFALSE;
2343 if (fStayDown) {
2344 bclick = kTRUE;
2346 fgReleaseBtn = 0;
2347 } else {
2348 bclick = kTRUE;
2350 Released();
2351 fgReleaseBtn = fId;
2352 }
2353 }else {
2355 }
2356 }
2357 } else if (inMB) {
2358 if (event->fType == kButtonPress) {
2359 fgReleaseBtn = 0;
2360 mbpress = kTRUE;
2361 tbpress = kFALSE;
2362 if (fMBState == kButtonEngaged) {
2363 return kTRUE;
2364 }
2366 MBPressed();
2369 } else { // ButtonRelease
2370 if (fState == kButtonDown) {
2372 }
2373 if (fMBState == kButtonEngaged && mbpress) {
2374 mbpress = kFALSE;
2377 MBReleased();
2378 MBClicked();
2379 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2380 } else if (fMBState == kButtonDown && mbpress) {
2381 MBClicked();
2384 fgReleaseBtn = 0;
2385 } else {
2387 }
2388 }
2389 } else {
2390 if (event->fType == kButtonPress) {
2391 fgReleaseBtn = 0;
2392 outpress = kTRUE;
2393 } else { // ButtonRelease
2394 if(outpress) {
2395 outpress = kFALSE;
2398 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2399 activate = kTRUE;
2400 }
2401 }
2402 }
2403 if (bclick) {
2404 Clicked();
2406 (Long_t) fUserData);
2408 (Long_t) fUserData);
2409 }
2410 if (activate) {
2411 TGMenuEntry *entry = fPopMenu->GetCurrent();
2412 if (entry) {
2413 if ((entry->GetStatus() & kMenuEnableMask) &&
2414 !(entry->GetStatus() & kMenuHideMask) &&
2415 (entry->GetType() != kMenuSeparator) &&
2416 (entry->GetType() != kMenuLabel)) {
2417 Int_t id = entry->GetEntryId();
2418 fPopMenu->Activated(id);
2419 }
2420 }
2421 }
2422 // if (mbclick) {
2423 // MBClicked();
2424 // SendMessage(fMsgWindow, MK_MSG(kC_COMMAND, kCM_BUTTON), fWidgetId,
2425 // (Long_t) fUserData);
2426 // fClient->ProcessLine(fCommand, MK_MSG(kC_COMMAND, kCM_BUTTON), fWidgetId,
2427 // (Long_t) fUserData);
2428 // }
2429 return kTRUE;
2430}
2431
2432////////////////////////////////////////////////////////////////////////////////
2433/// Handle mouse crossing event in case of split menu.
2434
2436{
2437 if (fTip) {
2438 if (event->fType == kEnterNotify)
2439 fTip->Reset();
2440 else
2441 fTip->Hide();
2442 }
2443
2444 if ((fgDbw != event->fWindow) || (fgReleaseBtn == event->fWindow)) return kTRUE;
2445
2446 if (!(event->fState & (kButton1Mask | kButton2Mask | kButton3Mask)))
2447 return kTRUE;
2448
2449 if (fState == kButtonEngaged || fState == kButtonDisabled) return kTRUE;
2450
2451 Bool_t inTB = (event->fX <= (Int_t)fTBWidth);
2452
2453 // Bool_t inMB = (event->fX >= (Int_t)(fWidth -fMBWidth)) && (event->fY >= 0) &&
2454 // (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2455
2456 if (event->fType == kEnterNotify) {
2457 if (inTB) {
2459 } else {
2460 if(fMBState == kButtonEngaged) return kTRUE;
2462 }
2463 } else {
2464 // kLeaveNotify
2465 if(fState == kButtonDown) {
2467 }
2468 if (fMBState == kButtonEngaged) return kTRUE;
2470 }
2471 return kTRUE;
2472}
2473
2474////////////////////////////////////////////////////////////////////////////////
2475/// Handle key event. This function will be called when the hotkey is hit.
2476
2478{
2479 if (fState == kButtonDisabled) return kFALSE;
2480
2481 Bool_t click = kFALSE;
2482
2483 if (event->fType == kGKeyPress) {
2484 gVirtualX->SetKeyAutoRepeat(kFALSE);
2485 } else {
2486 gVirtualX->SetKeyAutoRepeat(kTRUE);
2487 }
2488
2489 if (fTip && event->fType == kGKeyPress) fTip->Hide();
2490
2491 // We don't need to check the key number as GrabKey will only
2492 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
2493
2494 if ((event->fType == kGKeyPress) && (event->fState & kKeyMod1Mask)) {
2495 if (fState == kButtonEngaged) return kTRUE;
2497 Pressed();
2498 } else if ((event->fType == kKeyRelease) && (event->fState & kKeyMod1Mask)) {
2499 if (fState == kButtonEngaged) {
2501 Released();
2502 }
2503 if (fStayDown) {
2505 } else {
2507 Released();
2508 }
2509 click = kTRUE;
2510 }
2511 if (click) {
2512 Clicked();
2514 (Long_t) fUserData);
2516 (Long_t) fUserData);
2517 }
2518
2519 return kTRUE;
2520}
2521
2522////////////////////////////////////////////////////////////////////////////////
2523/// Popup the attached menu.
2524
2526{
2527 if (state) {
2528 Int_t ax, ay;
2529 Window_t wdummy;
2530
2531 if (fSplit) {
2532 Int_t n_entries = 0;
2533 TGMenuEntry *entry = 0;
2535
2536 while ((entry = (TGMenuEntry *) next())) {
2537 if ((entry->GetType() != kMenuSeparator) &&
2538 (entry->GetType() != kMenuLabel)) {
2539 n_entries++;
2540 }
2541 }
2542 if (n_entries <= 1) {
2543 Info("TGSplitButton", "Only one entry in the menu.");
2544 return;
2545 }
2546 }
2547
2548 gVirtualX->TranslateCoordinates(fId, fPopMenu->GetParent()->GetId(),
2549 0, 0, ax, ay, wdummy);
2550
2551 // place the menu just under the window:
2552 fPopMenu->PlaceMenu(ax-1, ay+fHeight, kTRUE, kFALSE); //kTRUE);
2553 BindKeys(kTRUE);
2555 } else {
2560 }
2561}
2562
2563////////////////////////////////////////////////////////////////////////////////
2564/// Draw the text button.
2565
2567{
2568 int x, y;
2570
2573
2574 if (fTMode & kTextLeft) {
2575 x = fMLeft + 4;
2576 } else if (fTMode & kTextRight) {
2577 x = fWidth - fTWidth -fMBWidth - fMRight - 4;
2578 } else {
2579 x = (fWidth - fTWidth -fMBWidth + fMLeft - fMRight) >> 1;
2580 }
2581
2582 if (fTMode & kTextTop) {
2583 y = fMTop + 3;
2584 } else if (fTMode & kTextBottom) {
2585 y = fHeight - fTHeight - fMBottom - 3;
2586 } else {
2587 y = (fHeight - fTHeight + fMTop - fMBottom) >> 1;
2588 }
2589
2590 if (fState == kButtonDown || fState == kButtonEngaged) { ++x; ++y; }
2591 if (fState == kButtonEngaged) {
2592 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), 2, 2, fWidth-4, fHeight-4);
2593 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 2, fWidth-3, 2);
2594 }
2595
2596 Int_t hotpos = fLabel->GetHotPos();
2597
2598 if (fState == kButtonDisabled) {
2600 TGGC *gc = pool->FindGC(fNormGC);
2601 if (gc) {
2602 Pixel_t fore = gc->GetForeground();
2605
2606 gc->SetForeground(hi);
2607 fTLayout->DrawText(fId, gc->GetGC(), x + 1, y + 1, 0, -1);
2608 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x + 1, y + 1, hotpos - 1);
2609
2610 gc->SetForeground(sh);
2611 fTLayout->DrawText(fId, gc->GetGC(), x, y, 0, -1);
2612 if (hotpos) fTLayout->UnderlineChar(fId, gc->GetGC(), x, y, hotpos - 1);
2613 gc->SetForeground(fore);
2614 }
2615 } else {
2616 fTLayout->DrawText(fId, fNormGC, x, y, 0, -1);
2617 if (hotpos) fTLayout->UnderlineChar(fId, fNormGC, x, y, hotpos - 1);
2618 }
2619
2620 // Draw the parts of the button needed when a menu is attached.
2621
2622 // triangle position
2623 x = fWidth - 11;
2624 y = fHeight - 10;
2625
2626 if (fSplit) {
2627 // separator position
2628 Int_t lx = fWidth - fMBWidth;
2629 Int_t ly = 2;
2630 Int_t lh = fHeight - 2;
2631
2633 x++;
2634 y++;
2635 }
2636
2637 gVirtualX->DrawLine(fId, GetShadowGC()(), lx, ly + 2, lx, lh - 4);
2638 gVirtualX->DrawLine(fId, GetHilightGC()(), lx + 1, ly + 2, lx + 1, lh - 3);
2639 gVirtualX->DrawLine(fId, GetHilightGC()(), lx, lh - 3, lx + 1, lh - 3);
2640
2641 if (fMBState == kButtonEngaged) {
2642 gVirtualX->FillRectangle(fId, GetHibckgndGC()(), fTBWidth + 1, 1, fMBWidth - 3, fHeight - 3);
2643 }
2644
2645 if (fMBState == kButtonDisabled) {
2646 DrawTriangle(GetHilightGC()(), x + 1, y + 1);
2647 DrawTriangle(GetShadowGC()(), x, y);
2648 } else {
2650 }
2651
2652 } else {
2653 x -= 2;
2655 x++;
2656 y++;
2657 }
2658 if (fState == kButtonDisabled) {
2659 DrawTriangle(GetHilightGC()(), x + 1, y + 1);
2660 DrawTriangle(GetShadowGC()(), x, y);
2661 } else {
2663 }
2664 }
2665
2666}
2667
2668////////////////////////////////////////////////////////////////////////////////
2669/// If on kTRUE bind arrow, popup menu hot keys, otherwise
2670/// remove key bindings.
2671
2673{
2674 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Up), kAnyModifier, on);
2675 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Down), kAnyModifier, on);
2676 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Enter), kAnyModifier, on);
2677 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Return), kAnyModifier, on);
2678 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Escape), kAnyModifier, on);
2679}
2680
2681////////////////////////////////////////////////////////////////////////////////
2682/// If on kTRUE bind Menu hot keys, otherwise remove key bindings.
2683
2685{
2686 TGMenuEntry *e = 0;
2688
2689 while ((e = (TGMenuEntry*)next())) {
2690 Int_t hot = 0;
2691 if (e->GetLabel()) {
2692 hot = e->GetLabel()->GetHotChar();
2693 }
2694 if (!hot) continue;
2695 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), 0, on);
2696 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask, on);
2697 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyLockMask, on);
2698 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyMod2Mask, on);
2699 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyLockMask, on);
2700 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyMod2Mask, on);
2701 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyLockMask | kKeyMod2Mask, on);
2702 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(hot), kKeyShiftMask | kKeyLockMask | kKeyMod2Mask, on);
2703 }
2704}
2705
2706////////////////////////////////////////////////////////////////////////////////
2707/// returns default size
2708
2710{
2713 return TGDimension(w, h);
2714}
2715
2716////////////////////////////////////////////////////////////////////////////////
2717/// Set new button text.
2718
2720{
2721 Int_t hotchar;
2722 static Bool_t longlabeltip = kFALSE;
2724
2726 if (!font) {
2728 if (font) fFontStruct = font->GetFontStruct();
2729 }
2730
2731 UInt_t width = 0, bwidth = 0, dummy;
2732 if (font) {
2733 font->ComputeTextLayout(new_label->GetString(), new_label->GetLength(),
2735 &width, &dummy);
2738 &bwidth, &dummy);
2739 }
2740 if (width > bwidth) {
2741 if (!fTip) {
2742 SetToolTipText(new_label->GetString());
2743 longlabeltip = kTRUE;
2744 }
2745 Info("TGSplitbutton", "Length of new label to long, label truncated.");
2746 new_label->Resize(fWidestLabel.GetLength());
2747 } else if (new_label->GetLength() <= fWidestLabel.GetLength() && longlabeltip) {
2748 if (fTip) delete fTip;
2749 fTip = 0;
2750 longlabeltip = kFALSE;
2751 }
2752
2753 if (fLabel) {
2754 if (main && fHKeycode) {
2755 main->RemoveBind(this, fHKeycode, kKeyMod1Mask);
2756 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2757 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2758 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyLockMask);
2759
2760 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2761 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask | kKeyMod2Mask);
2762 main->RemoveBind(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask | kKeyLockMask);
2764 }
2765 delete fLabel;
2766 }
2767
2768 fLabel = new_label;
2769 if ((hotchar = fLabel->GetHotChar()) != 0) {
2770 if (main && ((fHKeycode = gVirtualX->KeysymToKeycode(hotchar)) != 0)) {
2771 main->BindKey(this, fHKeycode, kKeyMod1Mask);
2772 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyShiftMask);
2773 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyLockMask);
2775
2776 main->BindKey(this, fHKeycode, kKeyMod1Mask | kKeyMod2Mask);
2780 }
2781 }
2782
2783 Layout();
2784}
2785
2786////////////////////////////////////////////////////////////////////////////////
2787/// Set new button text.
2788
2789void TGSplitButton::SetText(const TString &new_label)
2790{
2791 SetText(new TGHotString(new_label));
2792}
2793
2794////////////////////////////////////////////////////////////////////////////////
2795/// Changes text font.
2796/// If global is kTRUE font is changed globally, otherwise - locally.
2797
2799{
2800 if (font != fFontStruct) {
2801 FontH_t v = gVirtualX->GetFontHandle(font);
2802 if (!v) return;
2803
2804 fFontStruct = font;
2806 TGGC *gc = pool->FindGC(fNormGC);
2807
2808 if ((gc) && !global) {
2809 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE); // copy
2811 }
2812 if (gc) {
2813 gc->SetFont(v);
2814 fNormGC = gc->GetGC();
2815 }
2816 fClient->NeedRedraw(this);
2817 }
2818}
2819
2820////////////////////////////////////////////////////////////////////////////////
2821/// Changes text font specified by name.
2822/// If global is true color is changed globally, otherwise - locally.
2823
2824void TGSplitButton::SetFont(const char *fontName, Bool_t global)
2825{
2826 TGFont *font = fClient->GetFont(fontName);
2827 if (font) {
2828 SetFont(font->GetFontStruct(), global);
2829 }
2830}
2831
2832////////////////////////////////////////////////////////////////////////////////
2833/// Set the state of the Menu Button part
2834
2836{
2837 if (state != fMBState) {
2838 fMBState = state;
2839 DoRedraw();
2840 }
2841}
2842
2843////////////////////////////////////////////////////////////////////////////////
2844/// Set the split status of a button.
2845
2847{
2848 if(split) {
2849 fStayDown = kFALSE;
2850 Disconnect(fPopMenu, "PoppedDown()");
2851 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "SetMBState(=kButtonUp)");
2852 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "MBReleased()");
2853
2855 if (entry) {
2856 TGHotString *tmp = new TGHotString(*(entry->GetLabel()));
2857 SetText(tmp);
2858
2859 TString str("ItemClicked(=");
2860 str += entry->GetEntryId();
2861 str += ")";
2862 Connect("Clicked()", "TGSplitButton", this, str);
2863 fEntryId = entry->GetEntryId();
2865 }
2866 } else {
2867 fStayDown = kTRUE;
2868 Disconnect(fPopMenu, "PoppedDown()");
2869 Disconnect(this, "Clicked()", this);
2870 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "SetState(=kButtonUp)");
2871 fPopMenu->Connect("PoppedDown()", "TGSplitButton", this, "Released()");
2873 TGHotString *tmp = new TGHotString(*fMenuLabel);
2874 SetText(tmp);
2875 }
2876
2877 fSplit = split;
2878 DoRedraw();
2879}
2880
2881////////////////////////////////////////////////////////////////////////////////
2882/// Handle button events.
2883
2885{
2886 if (fState == kButtonDisabled) return kFALSE;
2887
2888 if (fSplit) return HandleSButton(event);
2889
2890 Bool_t in = (event->fX >= 0) && (event->fY >= 0) &&
2891 (event->fX <= (Int_t)fWidth) && (event->fY <= (Int_t)fHeight);
2892
2893 Bool_t activate = kFALSE;
2894 Bool_t click = kFALSE;
2895
2896 if (in) {
2897 if (event->fType == kButtonPress) {
2898 fgReleaseBtn = 0;
2899 if (fState == kButtonEngaged) {
2900 return kTRUE;
2901 }
2903 Pressed();
2906 } else { // ButtonRelease
2907 if (fState == kButtonEngaged) {
2910 Released();
2911 click = kTRUE;
2912 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2913 } else {
2914 click = (fState == kButtonDown);
2915 if (click && fStayDown) {
2918 fgReleaseBtn = 0;
2919 } else {
2921 Released();
2922 fgReleaseBtn = fId;
2923 }
2924 }
2926 }
2927 } else {
2928 if (event->fType == kButtonPress) {
2929 fgReleaseBtn = 0;
2930 } else { // ButtonRelease
2933 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); // ungrab pointer
2934 activate = kTRUE;
2935 }
2936 }
2937 if (click) {
2938 Clicked();
2940 (Long_t) fUserData);
2942 (Long_t) fUserData);
2943 }
2944 if (activate && !fKeyNavigate) {
2945 TGMenuEntry *entry = fPopMenu->GetCurrent();
2946 if (entry) {
2947 if ((entry->GetStatus() & kMenuEnableMask) &&
2948 !(entry->GetStatus() & kMenuHideMask) &&
2949 (entry->GetType() != kMenuSeparator) &&
2950 (entry->GetType() != kMenuLabel)) {
2951 Int_t id = entry->GetEntryId();
2952 fPopMenu->Activated(id);
2953 }
2954 }
2955 }
2956
2957 return kTRUE;
2958
2959}
2960
2961////////////////////////////////////////////////////////////////////////////////
2962/// Handle mouse crossing event.
2963
2965{
2966 if (fSplit) {
2967 return HandleSCrossing(event);
2968 } else {
2969 return TGButton::HandleCrossing(event);
2970 }
2971}
2972
2973////////////////////////////////////////////////////////////////////////////////
2974/// Handle key event. This function will be called when the hotkey is hit.
2975
2977{
2978 Bool_t click = kFALSE;
2979
2980 if (fState == kButtonDisabled) return kTRUE;
2981
2982 if(fSplit) return HandleSKey(event);
2983
2984 if (event->fType == kGKeyPress) {
2985 gVirtualX->SetKeyAutoRepeat(kFALSE);
2986 } else {
2987 gVirtualX->SetKeyAutoRepeat(kTRUE);
2988 }
2989
2990 if (fTip && event->fType == kGKeyPress) fTip->Hide();
2991
2992 // We don't need to check the key number as GrabKey will only
2993 // allow fHotchar events if Alt button is pressed (kKeyMod1Mask)
2994 if (event->fState & kKeyMod1Mask) {
2995 RequestFocus();
2997 if (event->fType == kGKeyPress) {
2998 if (fState == kButtonEngaged) return kTRUE;
3000 Pressed();
3001 } else if (event->fType == kKeyRelease) {
3002 click = kTRUE;
3003 if (fState == kButtonEngaged) {
3006 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3007 } else if (fState == kButtonDown && fStayDown) {
3012 TGMenuEntry *entry = 0;
3014
3015 while ((entry = (TGMenuEntry *) next())) {
3016 if ((entry->GetStatus() & kMenuEnableMask) &&
3017 !(entry->GetStatus() & kMenuHideMask) &&
3018 (entry->GetType() != kMenuSeparator) &&
3019 (entry->GetType() != kMenuLabel)) break;
3020 }
3021 if (entry) {
3022 fPopMenu->Activate(entry);
3023 }
3024 } else {
3025 Released();
3027 }
3028 }
3029 } else {
3031 if (event->fType == kGKeyPress) {
3032 Event_t ev;
3033 ev.fX = ev.fY = 1;
3034 UInt_t keysym;
3035 char tmp[2];
3036
3037 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
3038
3039 TGMenuEntry *ce = 0;
3041
3042 while ((ce = (TGMenuEntry*)next())) {
3043 UInt_t hot = 0;
3044 if (ce->GetLabel()) hot = ce->GetLabel()->GetHotChar();
3045 if (!hot || (hot != keysym)) continue;
3046
3047 fPopMenu->Activate(ce);
3048 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3050 ev.fType = kButtonRelease;
3051 ev.fWindow = fPopMenu->GetId();
3053 return HandleButton(&ev);
3054 }
3055
3056 ce = fPopMenu->GetCurrent();
3057
3058 switch ((EKeySym)keysym) {
3059 case kKey_Up:
3060 if (ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->Before(ce);
3061 while (ce && ((ce->GetType() == kMenuSeparator) ||
3062 (ce->GetType() == kMenuLabel) ||
3063 !(ce->GetStatus() & kMenuEnableMask))) {
3065 }
3066 if (!ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->Last();
3067 break;
3068 case kKey_Down:
3069 if (ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->After(ce);
3070 while (ce && ((ce->GetType() == kMenuSeparator) ||
3071 (ce->GetType() == kMenuLabel) ||
3072 !(ce->GetStatus() & kMenuEnableMask))) {
3074 }
3075 if (!ce) ce = (TGMenuEntry*)fPopMenu->GetListOfEntries()->First();
3076 break;
3077 case kKey_Enter:
3078 case kKey_Return:
3079 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3081 ev.fType = kButtonRelease;
3082 ev.fWindow = fPopMenu->GetId();
3084 HandleButton(&ev);
3085 break;
3086 case kKey_Escape:
3087 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
3089 break;
3090 default:
3091 break;
3092 }
3093 if (ce) fPopMenu->Activate(ce);
3094 }
3095 }
3096 if (click) {
3097 Clicked();
3099 (Long_t) fUserData);
3101 (Long_t) fUserData);
3102 }
3103
3104 return kTRUE;
3105}
3106
3107////////////////////////////////////////////////////////////////////////////////
3108/// Handle a motion event in a TGSplitButton.
3109
3111{
3112 if (fKeyNavigate) return kTRUE;
3113
3114 if (fSplit) {
3115 if (fMBState == kButtonDown) {
3116 if (event->fX < (Int_t)fTBWidth) {
3119 }
3120 } else if (fState == kButtonDown) {
3121 if (event->fX > (Int_t)fTBWidth) {
3124 }
3125
3126 }
3127 }
3128 return kTRUE;
3129}
3130
3131////////////////////////////////////////////////////////////////////////////////
3132/// layout text button
3133
3135{
3136 UInt_t dummya = 0, dummyb = 0;
3137 delete fTLayout;
3138
3140 if (!font) {
3142 if (font) fFontStruct = font->GetFontStruct();
3143 }
3144 if (font) {
3146 fLabel->GetLength(),
3148 &dummya, &dummyb);
3149 UInt_t dummy = 0;
3152 &fTWidth, &dummy);
3155 &dummy, &fTHeight);
3156 }
3157 fTBWidth = fTWidth + 8;
3159 fHeight = fTHeight + 7;
3160 fClient->NeedRedraw(this);
3161}
3162
3163////////////////////////////////////////////////////////////////////////////////
3164/// Handle a menu item activation.
3165
3167{
3169
3170 if (fSplit) {
3172 Disconnect(this, "Clicked()", this);
3173 // connect clicked to the ItemClicked signal with the correct id
3174 Connect("Clicked()", "TGSplitButton", this,
3175 TString::Format("ItemClicked(=%d)", id));
3176
3177 // reenable hidden entries
3178 const TList *list = fPopMenu->GetListOfEntries();
3179 TIter iter(list);
3181 TGMenuEntry *entry = fPopMenu->GetEntry(id);
3182 if (entry) {
3183 TGHotString *label = entry->GetLabel();
3184 TGHotString *tmp = new TGHotString(*label);
3185 SetText(tmp);
3186 }
3187 fPopMenu->HideEntry(id);
3188 if (entry) fEntryId = entry->GetEntryId();
3189 } else {
3191 ItemClicked(id);
3192 }
3193 DoRedraw();
3194}
void Class()
Definition: Class.C:29
@ kGKeyPress
Definition: GuiTypes.h:59
@ kButtonRelease
Definition: GuiTypes.h:59
@ kButtonPress
Definition: GuiTypes.h:59
@ kEnterNotify
Definition: GuiTypes.h:60
@ kKeyRelease
Definition: GuiTypes.h:59
@ kLeaveNotify
Definition: GuiTypes.h:60
const Mask_t kWABitGravity
Definition: GuiTypes.h:143
const Mask_t kGCBackground
Definition: GuiTypes.h:288
const Mask_t kGCForeground
Definition: GuiTypes.h:287
const Mask_t kGCTile
Definition: GuiTypes.h:295
const Mask_t kKeyLockMask
Definition: GuiTypes.h:195
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
Handle_t FontH_t
Definition: GuiTypes.h:34
const Mask_t kKeyMod1Mask
Definition: GuiTypes.h:197
const Mask_t kGCFillStyle
Definition: GuiTypes.h:293
const Mask_t kWAWinGravity
Definition: GuiTypes.h:144
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
Handle_t Pixmap_t
Definition: GuiTypes.h:29
const Mask_t kButton1Mask
Definition: GuiTypes.h:202
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:162
const Mask_t kKeyShiftMask
Definition: GuiTypes.h:194
@ 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:87
const Mask_t kKeyMod2Mask
Definition: GuiTypes.h:198
const Mask_t kButton3Mask
Definition: GuiTypes.h:204
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:167
@ kFillTiled
Definition: GuiTypes.h:50
const Mask_t kButton2Mask
Definition: GuiTypes.h:203
Handle_t GContext_t
Definition: GuiTypes.h:37
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:161
const Mask_t kGCGraphicsExposures
Definition: GuiTypes.h:301
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:166
Handle_t FontStruct_t
Definition: GuiTypes.h:38
ULong_t Pixel_t
Definition: GuiTypes.h:39
@ kButton1
Definition: GuiTypes.h:213
Handle_t Window_t
Definition: GuiTypes.h:28
EKeySym
Definition: KeySymbols.h:25
@ kKey_Down
Definition: KeySymbols.h:43
@ kKey_Up
Definition: KeySymbols.h:41
@ kKey_Return
Definition: KeySymbols.h:30
@ kKey_Escape
Definition: KeySymbols.h:26
@ kKey_Enter
Definition: KeySymbols.h:31
#define h(i)
Definition: RSha256.hxx:106
#define e(i)
Definition: RSha256.hxx:103
static RooMathCoreReg dummy
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
long Long_t
Definition: RtypesCore.h:52
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassImp(name)
Definition: Rtypes.h:361
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
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:166
@ kDeepCleanup
Definition: TGFrame.h:51
@ kMenuHideMask
Definition: TGMenu.h:40
@ kMenuEnableMask
Definition: TGMenu.h:36
@ kMenuEntry
Definition: TGMenu.h:49
@ kMenuSeparator
Definition: TGMenu.h:47
@ kMenuLabel
Definition: TGMenu.h:48
@ kTextCenterX
Definition: TGWidget.h:36
@ kTextLeft
Definition: TGWidget.h:34
@ kTextBottom
Definition: TGWidget.h:38
@ kTextTop
Definition: TGWidget.h:37
@ kTextRight
Definition: TGWidget.h:35
@ kTextCenterY
Definition: TGWidget.h:39
@ kWidgetIsEnabled
Definition: TGWidget.h:48
@ kWidgetWantFocus
Definition: TGWidget.h:46
XFontStruct * id
Definition: TGX11.cxx:108
char name[80]
Definition: TGX11.cxx:109
float type_of_call hi(const int &, const int &)
R__EXTERN TSystem * gSystem
Definition: TSystem.h:556
#define gVirtualX
Definition: TVirtualX.h:338
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kC_COMMAND
@ kCM_BUTTON
@ kCM_RADIOBUTTON
@ kCM_CHECKBUTTON
point * points
Definition: X3DBuffer.c:22
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
virtual void Remove(TGButton *button)
Removes a button from the button group.
virtual Int_t Insert(TGButton *button, int id=-1)
Inserts a button with the identifier id into the button group.
virtual void SetGroup(TGButtonGroup *gr)
Sets new button-group for this button.
Definition: TGButton.cxx:274
virtual void Pressed()
Definition: TGButton.h:133
static const TGGC & GetDefaultGC()
Return default graphics context.
Definition: TGButton.cxx:422
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:397
virtual EButtonState GetState() const
Definition: TGButton.h:112
UInt_t fStyle
Definition: TGButton.h:83
TGButtonGroup * fGroup
Definition: TGButton.h:80
Pixel_t fBgndColor
Definition: TGButton.h:81
static const TGGC & GetHibckgndGC()
Return graphics context for highlighted frame background.
Definition: TGButton.cxx:432
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGButton.cxx:262
static Window_t fgReleaseBtn
Definition: TGButton.h:91
Pixel_t fHighColor
Definition: TGButton.h:82
virtual void Released()
Definition: TGButton.h:134
virtual void EmitSignals(Bool_t wasUp)
Emit button signals.
Definition: TGButton.cxx:337
UInt_t fTWidth
Definition: TGButton.h:73
UInt_t fTHeight
Definition: TGButton.h:74
virtual void SetStyle(UInt_t newstyle)
Set the button style (modern or classic).
Definition: TGButton.cxx:223
void * fUserData
Definition: TGButton.h:78
static const TGGC * fgHibckgndGC
Definition: TGButton.h:89
virtual ~TGButton()
Delete button.
Definition: TGButton.cxx:173
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGButton.cxx:356
virtual Bool_t IsToggleButton() const
Definition: TGButton.h:121
virtual void Clicked()
Definition: TGButton.h:135
EButtonState fState
Definition: TGButton.h:75
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:411
static const TGGC * fgDefaultGC
Definition: TGButton.h:88
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:187
TGToolTip * fTip
Definition: TGButton.h:79
virtual void Toggled(Bool_t on)
Definition: TGButton.h:136
virtual Bool_t IsDown() const
Definition: TGButton.cxx:253
TGButton(const TGButton &)
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGButton.cxx:282
Bool_t fStayDown
Definition: TGButton.h:76
GContext_t fNormGC
Definition: TGButton.h:77
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a button widget as a C++ statement(s) on output stream out.
Definition: TGButton.cxx:1831
const TGPicture * fOff
Definition: TGButton.h:274
virtual ~TGCheckButton()
Delete a check button.
Definition: TGButton.cxx:1177
TGCheckButton(const TGCheckButton &)
virtual void EmitSignals(Bool_t wasUp=kTRUE)
Emit signals.
Definition: TGButton.cxx:1214
static const TGFont * fgDefaultFont
Definition: TGButton.h:284
static const TGGC * fgDefaultGC
Definition: TGButton.h:285
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGButton.cxx:1282
const TGPicture * fOn
Definition: TGButton.h:273
void Init()
Common check button initialization.
Definition: TGButton.cxx:1131
virtual void DoRedraw()
Draw the check button widget.
Definition: TGButton.cxx:1389
static const TGGC & GetDefaultGC()
Return default graphics context.
Definition: TGButton.cxx:1455
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
Definition: TGButton.cxx:1445
virtual void SetDisabledAndSelected(Bool_t)
Set the state of a check button to disabled and either on or off.
Definition: TGButton.cxx:1262
virtual Bool_t IsDisabledAndSelected() const
Definition: TGButton.h:313
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1202
virtual Bool_t HandleKey(Event_t *event)
Handle key event. This function will be called when the hotkey is hit.
Definition: TGButton.cxx:1355
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a check button widget as a C++ statement(s) on output stream out.
Definition: TGButton.cxx:1986
EButtonState fPrevState
Definition: TGButton.h:272
const TGPicture * fDisOff
Definition: TGButton.h:276
virtual TGDimension GetDefaultSize() const
default size
Definition: TGButton.cxx:1188
const TGPicture * fDisOn
Definition: TGButton.h:275
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGButton.cxx:1326
void PSetState(EButtonState state, Bool_t emit)
Set check button state.
Definition: TGButton.cxx:1225
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:234
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition: TGClient.cxx:913
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition: TGClient.cxx:348
const TGResourcePool * GetResourcePool() const
Definition: TGClient.h:133
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:289
TGGCPool * GetGCPool() const
Definition: TGClient.h:140
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:372
TGPicturePool * GetPicturePool() const
Definition: TGClient.h:135
TGFontPool * GetFontPool() const
Definition: TGClient.h:145
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:308
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get the specified font.
Definition: TGFont.cxx:1543
TGFont * FindFont(FontStruct_t font) const
Find font based on its font struct. Returns 0 if font is not found.
Definition: TGFont.cxx:1729
Definition: TGFont.h:149
FontStruct_t GetFontStruct() const
Definition: TGFont.h:193
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save the used font as a C++ statement(s) on output stream out.
Definition: TGFont.cxx:1869
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:649
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:305
virtual void SetSize(const TGDimension &s)
Definition: TGFrame.h:277
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:323
virtual void DoRedraw()
Redraw the frame.
Definition: TGFrame.cxx:414
UInt_t fOptions
Definition: TGFrame.h:119
UInt_t fHeight
Definition: TGFrame.h:113
Int_t fBorderWidth
Definition: TGFrame.h:118
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition: TGFrame.cxx:739
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:629
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:667
virtual UInt_t GetOptions() const
Definition: TGFrame.h:222
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2464
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition: TGFrame.cxx:749
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:589
UInt_t fWidth
Definition: TGFrame.h:112
UInt_t GetHeight() const
Definition: TGFrame.h:250
static Window_t fgDbw
Definition: TGFrame.h:138
UInt_t GetWidth() const
Definition: TGFrame.h:249
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2437
Pixel_t fBackground
Definition: TGFrame.h:120
static Pixel_t fgDefaultFrameBackground
Definition: TGFrame.h:126
Definition: TGGC.h:112
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get the best matching graphics context depending on values.
Definition: TGGC.cxx:985
void FreeGC(const TGGC *gc)
Delete graphics context if it is not used anymore.
Definition: TGGC.cxx:916
TGGC * FindGC(const TGGC *gc)
Find graphics context. Returns 0 in case gc is not found.
Definition: TGGC.cxx:949
Definition: TGGC.h:31
GContext_t GetGC() const
Definition: TGGC.h:50
void SavePrimitive(std::ostream &out, Option_t *option="")
Save graphics context info as a C++ statement(s) on output stream out.
Definition: TGGC.cxx:625
void SetFont(FontH_t v)
Set font.
Definition: TGGC.cxx:409
Pixel_t GetForeground() const
Definition: TGGC.h:82
void SetForeground(Pixel_t v)
Set foreground color.
Definition: TGGC.cxx:276
const GCValues_t * GetAttributes() const
Definition: TGGC.h:78
Int_t GetHotPos() const
Definition: TGString.h:68
Int_t GetHotChar() const
Definition: TGString.h:67
TGHotString * GetLabel() const
Definition: TGMenu.h:101
virtual Int_t GetStatus() const
Definition: TGMenu.h:98
EMenuEntryType GetType() const
Definition: TGMenu.h:99
Int_t GetEntryId() const
Definition: TGMenu.h:95
TGClient * fClient
Definition: TGObject.h:37
Handle_t GetId() const
Definition: TGObject.h:47
Handle_t fId
Definition: TGObject.h:36
virtual void SetPicture(const TGPicture *new_pic)
Change a picture in a picture button.
Definition: TGButton.cxx:992
virtual void CreateDisabledPicture()
Creates disabled picture.
Definition: TGButton.cxx:1060
virtual void SetDisabledPicture(const TGPicture *pic)
Changes disabled picture.
Definition: TGButton.cxx:1087
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a picture button widget as a C++ statement(s) on output stream out.
Definition: TGButton.cxx:1935
const TGPicture * fPicD
Definition: TGButton.h:232
const TGPicture * fPic
Definition: TGButton.h:231
virtual ~TGPictureButton()
Destructor.
Definition: TGButton.cxx:982
TGPictureButton(const TGPictureButton &)
Bool_t fOwnDisabledPic
Definition: TGButton.h:233
virtual void DoRedraw()
Redraw picture button.
Definition: TGButton.cxx:1016
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition: TGPicture.cxx:80
Pixmap_t GetMask() const
Definition: TGPicture.h:66
const char * GetName() const
Returns name of object.
Definition: TGPicture.h:62
UInt_t GetHeight() const
Definition: TGPicture.h:64
void Draw(Option_t *="")
Default Draw method for all objects.
Definition: TGPicture.h:57
Pixmap_t GetPicture() const
Definition: TGPicture.h:65
UInt_t GetWidth() const
Definition: TGPicture.h:63
virtual void HideEntry(Int_t id)
Hide entry (hidden entries are not shown in the menu).
Definition: TGMenu.cxx:1749
virtual TGMenuEntry * GetEntry(Int_t id)
Find entry with specified id.
Definition: TGMenu.cxx:1895
TGSplitButton * fSplitButton
Definition: TGMenu.h:147
virtual void Activate(Bool_t)
Definition: TGMenu.h:222
virtual void EnableEntry(Int_t id)
Enable entry. By default entries are enabled.
Definition: TGMenu.cxx:1703
virtual Int_t EndMenu(void *&userData)
Close menu and return ID of selected menu item.
Definition: TGMenu.cxx:1287
virtual TGMenuEntry * GetCurrent() const
Definition: TGMenu.h:211
virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
Popup a popup menu.
Definition: TGMenu.cxx:1239
const TList * GetListOfEntries() const
Definition: TGMenu.h:213
virtual void Activated(Int_t id)
Definition: TGMenu.h:232
const TGPicture * fOn
Definition: TGButton.h:330
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
Definition: TGButton.cxx:1811
static const TGGC * fgDefaultGC
Definition: TGButton.h:341
const TGPicture * fDisOn
Definition: TGButton.h:332
virtual void DoRedraw()
Draw a radio button.
Definition: TGButton.cxx:1754
virtual Bool_t HandleKey(Event_t *event)
Handle key event. This function will be called when the hotkey is hit.
Definition: TGButton.cxx:1724
virtual ~TGRadioButton()
Delete a radio button.
Definition: TGButton.cxx:1541
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGButton.cxx:1695
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGButton.cxx:1646
EButtonState fPrevState
Definition: TGButton.h:329
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set radio button state.
Definition: TGButton.cxx:1565
static const TGGC & GetDefaultGC()
Return default graphics context.
Definition: TGButton.cxx:1821
const TGPicture * fDisOff
Definition: TGButton.h:333
virtual TGDimension GetDefaultSize() const
default size
Definition: TGButton.cxx:1552
TGRadioButton(const TGRadioButton &)
static const TGFont * fgDefaultFont
Definition: TGButton.h:340
virtual Bool_t IsDisabledAndSelected() const
Definition: TGButton.h:372
virtual void SetDisabledAndSelected(Bool_t)
Set the state of a radio button to disabled and either on or off.
Definition: TGButton.cxx:1578
const TGPicture * fOff
Definition: TGButton.h:331
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a radio button widget as a C++ statement(s) on output stream out.
Definition: TGButton.cxx:2054
void PSetState(EButtonState state, Bool_t emit)
Set radio button state.
Definition: TGButton.cxx:1609
void Init()
Common radio button initialization.
Definition: TGButton.cxx:1497
virtual void EmitSignals(Bool_t wasUp=kTRUE)
Emit signals.
Definition: TGButton.cxx:1598
Cursor_t GetGrabCursor() const
TGGCPool * GetGCPool() const
void CalcSize()
Calculate the size of the button.
Definition: TGButton.cxx:2289
virtual Bool_t HandleKey(Event_t *event)
Handle key event. This function will be called when the hotkey is hit.
Definition: TGButton.cxx:2976
virtual void ItemClicked(Int_t id)
Definition: TGButton.h:440
Bool_t HandleSKey(Event_t *event)
Handle key event. This function will be called when the hotkey is hit.
Definition: TGButton.cxx:2477
TGPopupMenu * fPopMenu
Definition: TGButton.h:400
virtual void Layout()
layout text button
Definition: TGButton.cxx:3134
void DrawTriangle(const GContext_t gc, Int_t x, Int_t y)
Draw triangle (arrow) on which user can click to open Popup.
Definition: TGButton.cxx:2272
Int_t fEntryId
Definition: TGButton.h:401
Bool_t fSplit
Definition: TGButton.h:396
virtual void MBClicked()
Definition: TGButton.h:439
EButtonState fMBState
Definition: TGButton.h:397
void Init()
Common initialization used by the different ctors.
Definition: TGButton.cxx:2219
virtual Bool_t HandleButton(Event_t *event)
Handle button events.
Definition: TGButton.cxx:2884
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGButton.cxx:2964
virtual Bool_t HandleMotion(Event_t *event)
Handle a motion event in a TGSplitButton.
Definition: TGButton.cxx:3110
Bool_t HandleSButton(Event_t *event)
Handle mouse button event in case the button is split.
Definition: TGButton.cxx:2304
void BindKeys(Bool_t on=kTRUE)
If on kTRUE bind arrow, popup menu hot keys, otherwise remove key bindings.
Definition: TGButton.cxx:2672
Cursor_t fDefaultCursor
Definition: TGButton.h:403
virtual void SetText(TGHotString *new_label)
Set new button text.
Definition: TGButton.cxx:2719
void SetMenuState(Bool_t state)
Popup the attached menu.
Definition: TGButton.cxx:2525
UInt_t fMBWidth
Definition: TGButton.h:399
Bool_t HandleSCrossing(Event_t *event)
Handle mouse crossing event in case of split menu.
Definition: TGButton.cxx:2435
void BindMenuKeys(Bool_t on=kTRUE)
If on kTRUE bind Menu hot keys, otherwise remove key bindings.
Definition: TGButton.cxx:2684
virtual ~TGSplitButton()
Delete a split button widget.
Definition: TGButton.cxx:2263
virtual void MBReleased()
Definition: TGButton.h:438
TGSplitButton(const TGSplitButton &)
TGHotString * fMenuLabel
Definition: TGButton.h:402
void HandleMenu(Int_t id)
Handle a menu item activation.
Definition: TGButton.cxx:3166
virtual void SetFont(FontStruct_t font, Bool_t global=kFALSE)
Changes text font.
Definition: TGButton.cxx:2798
virtual TGDimension GetDefaultSize() const
returns default size
Definition: TGButton.cxx:2709
TGString fHeighestLabel
Definition: TGButton.h:406
UInt_t fTBWidth
Definition: TGButton.h:398
virtual void MBPressed()
Definition: TGButton.h:437
virtual void SetMBState(EButtonState state)
Set the state of the Menu Button part.
Definition: TGButton.cxx:2835
Bool_t fKeyNavigate
Definition: TGButton.h:404
virtual void SetSplit(Bool_t split)
Set the split status of a button.
Definition: TGButton.cxx:2846
TGString fWidestLabel
Definition: TGButton.h:405
virtual void DoRedraw()
Draw the text button.
Definition: TGButton.cxx:2566
Int_t GetLength() const
Definition: TGString.h:39
const char * GetString() const
Definition: TGString.h:40
void Init()
Common initialization used by the different ctors.
Definition: TGButton.cxx:493
virtual void Layout()
layout text button
Definition: TGButton.cxx:576
virtual Bool_t HandleKey(Event_t *event)
Handle key event. This function will be called when the hotkey is hit.
Definition: TGButton.cxx:767
TGTextButton(const TGTextButton &)
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
Definition: TGButton.cxx:821
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a text button widget as a C++ statement(s) on output stream out.
Definition: TGButton.cxx:1868
Int_t fMTop
Definition: TGButton.h:148
Int_t fMBottom
Definition: TGButton.h:149
virtual void SetTextJustify(Int_t tmode)
Set text justification.
Definition: TGButton.cxx:647
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:596
static const TGFont * fgDefaultFont
Definition: TGButton.h:159
Int_t fMRight
Definition: TGButton.h:147
virtual ~TGTextButton()
Delete a text button widget.
Definition: TGButton.cxx:547
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:890
virtual void DoRedraw()
Draw the text button.
Definition: TGButton.cxx:699
Bool_t fPrevStateOn
Definition: TGButton.h:157
virtual void SetFont(FontStruct_t font, Bool_t global=kFALSE)
Changes text font.
Definition: TGButton.cxx:832
virtual TGDimension GetDefaultSize() const
returns default size
Definition: TGButton.cxx:811
Int_t fTMode
Definition: TGButton.h:150
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:870
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:908
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:955
void Hide()
Hide tool tip window.
Definition: TGToolTip.cxx:247
const TGString * GetText() const
Get the tool tip text.
Definition: TGToolTip.cxx:427
void Reset()
Reset tool tip popup delay timer.
Definition: TGToolTip.cxx:260
Int_t fWidgetId
Definition: TGWidget.h:58
TString fCommand
Definition: TGWidget.h:61
Int_t fWidgetFlags
Definition: TGWidget.h:59
const TGWindow * fMsgWindow
Definition: TGWidget.h:60
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:119
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:142
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:326
virtual void RequestFocus()
request focus
Definition: TGWindow.cxx:222
const TGWindow * fParent
Definition: TGWindow.h:36
virtual Int_t MustCleanup() const
Definition: TGWindow.h:117
const TGWindow * GetParent() const
Definition: TGWindow.h:84
An abstract interface to image processing library.
Definition: TImage.h:29
virtual void SetImage(const Double_t *, UInt_t, UInt_t, TImagePalette *=0)
Definition: TImage.h:116
static TImage * Create()
Create an image.
Definition: TImage.cxx:36
virtual void Merge(const TImage *, const char *="alphablend", Int_t=0, Int_t=0)
Definition: TImage.h:172
virtual Pixmap_t GetPixmap()
Definition: TImage.h:235
virtual void FillRectangle(const char *=0, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition: TImage.h:192
virtual Pixmap_t GetMask()
Definition: TImage.h:236
TObject * Next()
Definition: TCollection.h:249
A doubly linked list.
Definition: TList.h:44
virtual TObject * After(const TObject *obj) const
Returns the object after object obj.
Definition: TList.cxx:329
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TList.cxx:692
virtual TObject * Before(const TObject *obj) const
Returns the object before object obj.
Definition: TList.cxx:370
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:658
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:891
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:865
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:866
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1024
void AddReference()
Definition: TRefCnt.h:40
Basic string class.
Definition: TString.h:131
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:644
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition: TString.cxx:499
const char * Data() const
Definition: TString.h:364
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:687
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition: TString.cxx:1095
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:2311
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2289
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1269
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition: TSystem.cxx:1058
TText * text
int main(int argc, char **argv)
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
static constexpr double s
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
EGEventType fType
Definition: GuiTypes.h:174
Int_t fY
Definition: GuiTypes.h:177
Window_t fWindow
Definition: GuiTypes.h:175
UInt_t fState
Definition: GuiTypes.h:180
Int_t fX
Definition: GuiTypes.h:177
ULong_t fBackground
Definition: GuiTypes.h:227
Mask_t fMask
Definition: GuiTypes.h:250
Pixmap_t fTile
Definition: GuiTypes.h:237
Bool_t fGraphicsExposures
Definition: GuiTypes.h:243
ULong_t fForeground
Definition: GuiTypes.h:226
Int_t fFillStyle
Definition: GuiTypes.h:233
TCanvas * style()
Definition: style.C:1