Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGuiBldHintsButton.cxx
Go to the documentation of this file.
1// @(#)root/guibuilder:$Id$
2// Author: Valeriy Onuchin 12/09/04
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, 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#include "TGuiBldHintsButton.h"
13#include "TGResourcePool.h"
14#include "TVirtualX.h"
15
16
17
18/** \class TGuiBldHintsButton
19 \ingroup guibuilder
20
21Special button class used for editing layout hints in the ROOT GUI Builder.
22
23*/
24
25
26
27
28////////////////////////////////////////////////////////////////////////////////
29////////////////////////////////////////////////////////////////////////////////
30/// Constructor.
31
33 TGButton(p, id)
34{
36
37 switch ((ELayoutHints)fWidgetId) {
38 case kLHintsCenterX:
39 case kLHintsExpandX:
40 Resize(40, 15);
41 break;
42 case kLHintsCenterY:
43 case kLHintsExpandY:
44 Resize(15, 40);
45 break;
46 default:
47 Resize(15, 15);
48 break;
49 }
50}
51
52////////////////////////////////////////////////////////////////////////////////
53/// Redraw button.
54
56{
58
59 switch (fWidgetId) {
60 case kLHintsCenterX:
62 break;
63 case kLHintsCenterY:
65 break;
66 case kLHintsExpandX:
68 break;
69 case kLHintsExpandY:
71 break;
72 case (kLHintsTop | kLHintsLeft):
74 break;
75 case (kLHintsTop | kLHintsRight):
77 break;
80 break;
83 break;
84 default:
86 break;
87 }
88}
89
90////////////////////////////////////////////////////////////////////////////////
91/// Draw expand X button.
92
94{
95 const int dist = 3;
96 const int amplitude = std::min(3, (int)fHeight/3);
97 int base = fHeight/2;
98 int i = 0;
100 const TGGC* gc = pool->GetWhiteGC();
101
102 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
103 base++;
104 }
105
106 for ( i = 1; i < (int)fWidth/3 - 2; ++i ) {
107 gVirtualX->DrawLine(fId, gc->GetGC(), i * dist, base - amplitude,
108 i * dist + dist/2, base + amplitude);
109 }
110 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
111
112 for ( i = 1; i < (int)fWidth/3 - 2; ++i ) {
113 gVirtualX->DrawLine(fId, gc->GetGC(), i * dist + dist/2, base + amplitude,
114 i * dist + dist, base - amplitude);
115 }
116 gVirtualX->DrawLine(fId, gc->GetGC(), 3, 6, 3, fHeight - 6);
117 gVirtualX->DrawLine(fId, gc->GetGC(), fWidth - 6, 6, fWidth - 6, fHeight - 6);
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// Draw expand Y button.
122
124{
125 const int dist = 3;
126 const int amplitude = std::min(3, (int)fWidth/3);
127 int base = fWidth/2;
128 int i = 0;
129
130 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
131 base++;
132 }
134 const TGGC* gc = pool->GetWhiteGC();
135
136 for ( i = 1; i < (int)fHeight/3 - 2; ++i ) {
137 gVirtualX->DrawLine(fId, gc->GetGC(), base - amplitude, i * dist,
138 base + amplitude,i * dist + dist/2);
139 }
140
141 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
142
143 for ( i = 1; i < (int)fHeight/3 - 2; ++i ) {
144 gVirtualX->DrawLine(fId, gc->GetGC(), base + amplitude, i * dist + dist/2,
145 base - amplitude, i * dist + dist );
146 }
147 gVirtualX->DrawLine(fId, gc->GetGC(), 6, 3, fWidth - 6, 3);
148 gVirtualX->DrawLine(fId, gc->GetGC(), 6, fHeight - 6, fWidth - 6, fHeight - 6);
149}
150
151////////////////////////////////////////////////////////////////////////////////
152/// Draw center X buton.
153
155{
156 int base = fHeight/2;
157 int x = 6;
158 int y = 6;
159
161 const TGGC* gc = pool->GetWhiteGC();
162
163 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
164 base++;
165 x++;
166 y++;
167 }
168
169 gVirtualX->DrawLine(fId, gc->GetGC(), x, base, x + fWidth - 12, base);
170
171 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
172
173 gVirtualX->DrawLine(fId, gc->GetGC(), x, base - 1, x + fWidth/2 - 12, base - 1);
174 gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth/2, base - 1, x + fWidth - 12, base - 1);
175 gVirtualX->DrawLine(fId, gc->GetGC(), x, base + 1, x + fWidth/2 - 12, base + 1);
176 gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth/2, base + 1, x + fWidth - 12, base + 1);
177
178 Point_t arrow[3];
179 arrow[0].fX = arrow[01].fX = x + fWidth/2 - 12;
180 arrow[2].fX = x + fWidth/2 - 6;
181 arrow[2].fY = y + fHeight/2 - 6;
182 arrow[0].fY = arrow[2].fY - 4;
183 arrow[1].fY = arrow[2].fY + 4;
184 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
185
186 arrow[0].fX = arrow[01].fX = x + fWidth/2;
187 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
188
189 gVirtualX->DrawLine(fId, gc->GetGC(), x, y, x, y + fHeight - 12);
190 gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth - 12, y, x + fWidth - 12, y + fHeight - 12);
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Draw center Y button.
195
197{
198 int base = fWidth/2;
199 int x = 6;
200 int y = 6;
201
203 const TGGC* gc = pool->GetWhiteGC();
204
205 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
206 base++;
207 x++;
208 y++;
209 }
210
211 gVirtualX->DrawLine(fId, gc->GetGC(), base, y, base, y + fHeight - 12);
212
213 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
214
215 gVirtualX->DrawLine(fId, gc->GetGC(), base - 1, y, base - 1, y + fHeight/2 - 12);
216 gVirtualX->DrawLine(fId, gc->GetGC(), base - 1, y + fHeight/2, base - 1, y + fHeight - 12);
217 gVirtualX->DrawLine(fId, gc->GetGC(), base + 1, y, base + 1, y + fHeight/2 - 12);
218 gVirtualX->DrawLine(fId, gc->GetGC(), base + 1, y + fHeight/2, base + 1, y + fHeight - 12);
219
220 Point_t arrow[3];
221 arrow[0].fY = arrow[01].fY = y + fHeight/2 - 12;
222 arrow[2].fY = y + fHeight/2 - 6;
223 arrow[2].fX = x + fWidth/2 - 6;
224 arrow[0].fX = arrow[2].fX - 4;
225 arrow[1].fX = arrow[2].fX + 4;
226 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
227
228 arrow[0].fY = arrow[01].fY = y + fHeight/2;
229 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
230 gVirtualX->DrawLine(fId, gc->GetGC(), x, y, x + fWidth - 12, y);
231 gVirtualX->DrawLine(fId, gc->GetGC(), x, y + fHeight - 12, x + fWidth - 12, y + fHeight - 12);
232}
233
234////////////////////////////////////////////////////////////////////////////////
235/// DrawTopLeft.
236
240
241////////////////////////////////////////////////////////////////////////////////
242/// DrawTopRight.
243
247
248////////////////////////////////////////////////////////////////////////////////
249/// DrawBottomLeft.
250
254
255////////////////////////////////////////////////////////////////////////////////
256/// DrawBottomRight.
257
261
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kButtonDown
Definition TGButton.h:54
@ kButtonEngaged
Definition TGButton.h:55
ELayoutHints
Definition TGLayout.h:22
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsCenterX
Definition TGLayout.h:25
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
#define gVirtualX
Definition TVirtualX.h:337
A button abstract base class.
Definition TGButton.h:68
EButtonState fState
button state
Definition TGButton.h:75
Bool_t fStayDown
true if button has to stay down
Definition TGButton.h:76
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
UInt_t fHeight
frame height
Definition TGFrame.h:88
void DoRedraw() override
Redraw the frame.
Definition TGFrame.cxx:422
UInt_t fWidth
frame width
Definition TGFrame.h:87
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
This class implements a pool for the default GUI resource set, like GC's, colors, fonts,...
Int_t fWidgetId
the widget id (used for event processing)
Definition TGWidget.h:46
Bool_t IsEnabled() const
Definition TGWidget.h:69
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void DrawBottomLeft()
DrawBottomLeft.
virtual void DrawExpandX()
Draw expand X button.
virtual void DrawTopRight()
DrawTopRight.
virtual void DrawCenterX()
Draw center X buton.
virtual void DrawCenterY()
Draw center Y button.
virtual void DrawBottomRight()
DrawBottomRight.
void DoRedraw() override
Redraw button.
virtual void DrawTopLeft()
DrawTopLeft.
TGuiBldHintsButton(const TGWindow *p, Int_t id)
Constructor.
virtual void DrawExpandY()
Draw expand Y button.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Point structure (maps to the X11 XPoint structure)
Definition GuiTypes.h:356