Logo ROOT  
Reference Guide
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// TGuiBldHintsButton
19//
20// Special button class used for editing layout hints in the ROOT GUI Builder.
21//_____________________________________________________________________________
22
24
25
26////////////////////////////////////////////////////////////////////////////////
27////////////////////////////////////////////////////////////////////////////////
28/// Constructor.
29
31 TGButton(p, id)
32{
34
35 switch ((ELayoutHints)fWidgetId) {
36 case kLHintsCenterX:
37 case kLHintsExpandX:
38 Resize(40, 15);
39 break;
40 case kLHintsCenterY:
41 case kLHintsExpandY:
42 Resize(15, 40);
43 break;
44 default:
45 Resize(15, 15);
46 break;
47 }
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Redraw button.
52
54{
56
57 switch (fWidgetId) {
58 case kLHintsCenterX:
60 break;
61 case kLHintsCenterY:
63 break;
64 case kLHintsExpandX:
66 break;
67 case kLHintsExpandY:
69 break;
70 case (kLHintsTop | kLHintsLeft):
72 break;
73 case (kLHintsTop | kLHintsRight):
75 break;
78 break;
81 break;
82 default:
84 break;
85 }
86}
87
88////////////////////////////////////////////////////////////////////////////////
89/// Draw expand X button.
90
92{
93 const int dist = 3;
94 const int amplitude = TMath::Min(3, (int)fHeight/3);
95 int base = fHeight/2;
96 int i = 0;
97 const TGResourcePool *pool = fClient->GetResourcePool();
98 const TGGC* gc = pool->GetWhiteGC();
99
100 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
101 base++;
102 }
103
104 for ( i = 1; i < (int)fWidth/3 - 2; ++i ) {
105 gVirtualX->DrawLine(fId, gc->GetGC(), i * dist, base - amplitude,
106 i * dist + dist/2, base + amplitude);
107 }
108 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
109
110 for ( i = 1; i < (int)fWidth/3 - 2; ++i ) {
111 gVirtualX->DrawLine(fId, gc->GetGC(), i * dist + dist/2, base + amplitude,
112 i * dist + dist, base - amplitude);
113 }
114 gVirtualX->DrawLine(fId, gc->GetGC(), 3, 6, 3, fHeight - 6);
115 gVirtualX->DrawLine(fId, gc->GetGC(), fWidth - 6, 6, fWidth - 6, fHeight - 6);
116}
117
118////////////////////////////////////////////////////////////////////////////////
119/// Draw expand Y button.
120
122{
123 const int dist = 3;
124 const int amplitude = TMath::Min(3, (int)fWidth/3);
125 int base = fWidth/2;
126 int i = 0;
127
128 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
129 base++;
130 }
131 const TGResourcePool *pool = fClient->GetResourcePool();
132 const TGGC* gc = pool->GetWhiteGC();
133
134 for ( i = 1; i < (int)fHeight/3 - 2; ++i ) {
135 gVirtualX->DrawLine(fId, gc->GetGC(), base - amplitude, i * dist,
136 base + amplitude,i * dist + dist/2);
137 }
138
139 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
140
141 for ( i = 1; i < (int)fHeight/3 - 2; ++i ) {
142 gVirtualX->DrawLine(fId, gc->GetGC(), base + amplitude, i * dist + dist/2,
143 base - amplitude, i * dist + dist );
144 }
145 gVirtualX->DrawLine(fId, gc->GetGC(), 6, 3, fWidth - 6, 3);
146 gVirtualX->DrawLine(fId, gc->GetGC(), 6, fHeight - 6, fWidth - 6, fHeight - 6);
147}
148
149////////////////////////////////////////////////////////////////////////////////
150/// Draw center X buton.
151
153{
154 int base = fHeight/2;
155 int x = 6;
156 int y = 6;
157
158 const TGResourcePool *pool = fClient->GetResourcePool();
159 const TGGC* gc = pool->GetWhiteGC();
160
161 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
162 base++;
163 x++;
164 y++;
165 }
166
167 gVirtualX->DrawLine(fId, gc->GetGC(), x, base, x + fWidth - 12, base);
168
169 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
170
171 gVirtualX->DrawLine(fId, gc->GetGC(), x, base - 1, x + fWidth/2 - 12, base - 1);
172 gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth/2, base - 1, x + fWidth - 12, base - 1);
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
176 Point_t arrow[3];
177 arrow[0].fX = arrow[01].fX = x + fWidth/2 - 12;
178 arrow[2].fX = x + fWidth/2 - 6;
179 arrow[2].fY = y + fHeight/2 - 6;
180 arrow[0].fY = arrow[2].fY - 4;
181 arrow[1].fY = arrow[2].fY + 4;
182 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
183
184 arrow[0].fX = arrow[01].fX = x + fWidth/2;
185 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
186
187 gVirtualX->DrawLine(fId, gc->GetGC(), x, y, x, y + fHeight - 12);
188 gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth - 12, y, x + fWidth - 12, y + fHeight - 12);
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Draw center Y button.
193
195{
196 int base = fWidth/2;
197 int x = 6;
198 int y = 6;
199
200 const TGResourcePool *pool = fClient->GetResourcePool();
201 const TGGC* gc = pool->GetWhiteGC();
202
203 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
204 base++;
205 x++;
206 y++;
207 }
208
209 gVirtualX->DrawLine(fId, gc->GetGC(), base, y, base, y + fHeight - 12);
210
211 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
212
213 gVirtualX->DrawLine(fId, gc->GetGC(), base - 1, y, base - 1, y + fHeight/2 - 12);
214 gVirtualX->DrawLine(fId, gc->GetGC(), base - 1, y + fHeight/2, base - 1, y + fHeight - 12);
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
218 Point_t arrow[3];
219 arrow[0].fY = arrow[01].fY = y + fHeight/2 - 12;
220 arrow[2].fY = y + fHeight/2 - 6;
221 arrow[2].fX = x + fWidth/2 - 6;
222 arrow[0].fX = arrow[2].fX - 4;
223 arrow[1].fX = arrow[2].fX + 4;
224 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
225
226 arrow[0].fY = arrow[01].fY = y + fHeight/2;
227 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
228 gVirtualX->DrawLine(fId, gc->GetGC(), x, y, x + fWidth - 12, y);
229 gVirtualX->DrawLine(fId, gc->GetGC(), x, y + fHeight - 12, x + fWidth - 12, y + fHeight - 12);
230}
231
232////////////////////////////////////////////////////////////////////////////////
233/// DrawTopLeft.
234
236{
237}
238
239////////////////////////////////////////////////////////////////////////////////
240/// DrawTopRight.
241
243{
244}
245
246////////////////////////////////////////////////////////////////////////////////
247/// DrawBottomLeft.
248
250{
251}
252
253////////////////////////////////////////////////////////////////////////////////
254/// DrawBottomRight.
255
257{
258}
259
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
@ kButtonDown
Definition: TGButton.h:54
@ kButtonEngaged
Definition: TGButton.h:55
ELayoutHints
Definition: TGLayout.h:29
@ kLHintsRight
Definition: TGLayout.h:33
@ kLHintsExpandY
Definition: TGLayout.h:38
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsCenterY
Definition: TGLayout.h:35
@ kLHintsCenterX
Definition: TGLayout.h:32
@ kLHintsBottom
Definition: TGLayout.h:36
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
XFontStruct * id
Definition: TGX11.cxx:108
#define gVirtualX
Definition: TVirtualX.h:338
EButtonState fState
Definition: TGButton.h:75
Bool_t fStayDown
Definition: TGButton.h:76
const TGResourcePool * GetResourcePool() const
Definition: TGClient.h:133
virtual void DoRedraw()
Redraw the frame.
Definition: TGFrame.cxx:414
UInt_t fHeight
Definition: TGFrame.h:113
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:589
UInt_t fWidth
Definition: TGFrame.h:112
Definition: TGGC.h:31
GContext_t GetGC() const
Definition: TGGC.h:50
TGClient * fClient
Definition: TGObject.h:37
Handle_t fId
Definition: TGObject.h:36
const TGGC * GetFrameShadowGC() const
const TGGC * GetSelectedBckgndGC() const
const TGGC * GetWhiteGC() const
Int_t fWidgetId
Definition: TGWidget.h:58
Bool_t IsEnabled() const
Definition: TGWidget.h:81
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.
virtual void DrawTopLeft()
DrawTopLeft.
virtual void DoRedraw()
Redraw button.
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
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180