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 {
33  fStayDown = kTRUE;
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:
59  DrawCenterX();
60  break;
61  case kLHintsCenterY:
62  DrawCenterY();
63  break;
64  case kLHintsExpandX:
65  DrawExpandX();
66  break;
67  case kLHintsExpandY:
68  DrawExpandY();
69  break;
70  case (kLHintsTop | kLHintsLeft):
71  DrawTopLeft();
72  break;
73  case (kLHintsTop | kLHintsRight):
74  DrawTopRight();
75  break;
76  case (kLHintsBottom | kLHintsLeft):
78  break;
79  case (kLHintsBottom | kLHintsRight):
81  break;
82  default:
83  DrawExpandX();
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 
TGWindow
Definition: TGWindow.h:31
kLHintsCenterX
@ kLHintsCenterX
Definition: TGLayout.h:38
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGGC::GetGC
GContext_t GetGC() const
Definition: TGGC.h:50
gVirtualX
#define gVirtualX
Definition: TVirtualX.h:338
kButtonDown
@ kButtonDown
Definition: TGButton.h:60
kLHintsTop
@ kLHintsTop
Definition: TGLayout.h:40
Point_t
Definition: GuiTypes.h:355
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TGFrame::fWidth
UInt_t fWidth
Definition: TGFrame.h:112
TGuiBldHintsButton.h
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:37
TGuiBldHintsButton::DrawExpandX
virtual void DrawExpandX()
Draw expand X button.
Definition: TGuiBldHintsButton.cxx:91
x
Double_t x[n]
Definition: legend1.C:17
TVirtualX.h
TGClient::GetResourcePool
const TGResourcePool * GetResourcePool() const
Definition: TGClient.h:133
TGuiBldHintsButton::DrawTopRight
virtual void DrawTopRight()
DrawTopRight.
Definition: TGuiBldHintsButton.cxx:242
TGResourcePool
Definition: TGResourcePool.h:36
TGuiBldHintsButton::DrawExpandY
virtual void DrawExpandY()
Draw expand Y button.
Definition: TGuiBldHintsButton.cxx:121
id
XFontStruct * id
Definition: TGX11.cxx:109
TGResourcePool::GetSelectedBckgndGC
const TGGC * GetSelectedBckgndGC() const
Definition: TGResourcePool.h:153
kLHintsBottom
@ kLHintsBottom
Definition: TGLayout.h:42
ROOT::Math::gv_detail::dist
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:63
TGuiBldHintsButton::DrawTopLeft
virtual void DrawTopLeft()
DrawTopLeft.
Definition: TGuiBldHintsButton.cxx:235
kLHintsCenterY
@ kLHintsCenterY
Definition: TGLayout.h:41
TGuiBldHintsButton::DrawBottomLeft
virtual void DrawBottomLeft()
DrawBottomLeft.
Definition: TGuiBldHintsButton.cxx:249
kButtonEngaged
@ kButtonEngaged
Definition: TGButton.h:61
TGGC
Definition: TGGC.h:31
ELayoutHints
ELayoutHints
Definition: TGLayout.h:29
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:590
TGObject::fId
Handle_t fId
Definition: TGObject.h:36
kLHintsRight
@ kLHintsRight
Definition: TGLayout.h:39
TGWidget::IsEnabled
Bool_t IsEnabled() const
Definition: TGWidget.h:81
TGuiBldHintsButton::DrawCenterX
virtual void DrawCenterX()
Draw center X buton.
Definition: TGuiBldHintsButton.cxx:152
TGuiBldHintsButton::DoRedraw
virtual void DoRedraw()
Redraw button.
Definition: TGuiBldHintsButton.cxx:53
y
Double_t y[n]
Definition: legend1.C:17
kLHintsExpandY
@ kLHintsExpandY
Definition: TGLayout.h:44
TGuiBldHintsButton
Definition: TGuiBldHintsButton.h:27
TMath::Min
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
TGuiBldHintsButton::DrawBottomRight
virtual void DrawBottomRight()
DrawBottomRight.
Definition: TGuiBldHintsButton.cxx:256
TGuiBldHintsButton::TGuiBldHintsButton
TGuiBldHintsButton(const TGWindow *p, Int_t id)
Constructor.
Definition: TGuiBldHintsButton.cxx:30
TGWidget::fWidgetId
Int_t fWidgetId
Definition: TGWidget.h:58
TGObject::fClient
TGClient * fClient
Definition: TGObject.h:37
arrow
Definition: RArrowDS.hxx:9
TGButton::fState
EButtonState fState
Definition: TGButton.h:75
TGResourcePool::GetWhiteGC
const TGGC * GetWhiteGC() const
Definition: TGResourcePool.h:140
TGuiBldHintsButton::DrawCenterY
virtual void DrawCenterY()
Draw center Y button.
Definition: TGuiBldHintsButton.cxx:194
kLHintsExpandX
@ kLHintsExpandX
Definition: TGLayout.h:43
TGResourcePool.h
TGFrame::fHeight
UInt_t fHeight
Definition: TGFrame.h:113
TGButton
Definition: TGButton.h:68
TGResourcePool::GetFrameShadowGC
const TGGC * GetFrameShadowGC() const
Definition: TGResourcePool.h:146
TGButton::fStayDown
Bool_t fStayDown
Definition: TGButton.h:76
int
TGFrame::DoRedraw
virtual void DoRedraw()
Redraw the frame.
Definition: TGFrame.cxx:415