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