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