00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TGuiBldHintsButton.h"
00013 #include "TGResourcePool.h"
00014
00015
00016
00017
00018
00019
00020
00021
00022 ClassImp(TGuiBldHintsButton)
00023
00024
00025
00026
00027 TGuiBldHintsButton::TGuiBldHintsButton(const TGWindow* p, Int_t id) :
00028 TGButton(p, id)
00029 {
00030
00031
00032 fStayDown = kTRUE;
00033
00034 switch ((ELayoutHints)fWidgetId) {
00035 case kLHintsCenterX:
00036 case kLHintsExpandX:
00037 Resize(40, 15);
00038 break;
00039 case kLHintsCenterY:
00040 case kLHintsExpandY:
00041 Resize(15, 40);
00042 break;
00043 default:
00044 Resize(15, 15);
00045 break;
00046 }
00047 }
00048
00049
00050 void TGuiBldHintsButton::DoRedraw()
00051 {
00052
00053
00054 TGButton::DoRedraw();
00055
00056 switch (fWidgetId) {
00057 case kLHintsCenterX:
00058 DrawCenterX();
00059 break;
00060 case kLHintsCenterY:
00061 DrawCenterY();
00062 break;
00063 case kLHintsExpandX:
00064 DrawExpandX();
00065 break;
00066 case kLHintsExpandY:
00067 DrawExpandY();
00068 break;
00069 case (kLHintsTop | kLHintsLeft):
00070 DrawTopLeft();
00071 break;
00072 case (kLHintsTop | kLHintsRight):
00073 DrawTopRight();
00074 break;
00075 case (kLHintsBottom | kLHintsLeft):
00076 DrawBottomLeft();
00077 break;
00078 case (kLHintsBottom | kLHintsRight):
00079 DrawBottomRight();
00080 break;
00081 default:
00082 DrawExpandX();
00083 break;
00084 }
00085 }
00086
00087
00088 void TGuiBldHintsButton::DrawExpandX()
00089 {
00090
00091
00092 const int dist = 3;
00093 const int amplitude = TMath::Min(3, (int)fHeight/3);
00094 int base = fHeight/2;
00095 int i = 0;
00096 const TGResourcePool *pool = fClient->GetResourcePool();
00097 const TGGC* gc = pool->GetWhiteGC();
00098
00099 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
00100 base++;
00101 }
00102
00103 for ( i = 1; i < (int)fWidth/3 - 2; ++i ) {
00104 gVirtualX->DrawLine(fId, gc->GetGC(), i * dist, base - amplitude,
00105 i * dist + dist/2, base + amplitude);
00106 }
00107 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
00108
00109 for ( i = 1; i < (int)fWidth/3 - 2; ++i ) {
00110 gVirtualX->DrawLine(fId, gc->GetGC(), i * dist + dist/2, base + amplitude,
00111 i * dist + dist, base - amplitude);
00112 }
00113 gVirtualX->DrawLine(fId, gc->GetGC(), 3, 6, 3, fHeight - 6);
00114 gVirtualX->DrawLine(fId, gc->GetGC(), fWidth - 6, 6, fWidth - 6, fHeight - 6);
00115 }
00116
00117
00118 void TGuiBldHintsButton::DrawExpandY()
00119 {
00120
00121
00122 const int dist = 3;
00123 const int amplitude = TMath::Min(3, (int)fWidth/3);
00124 int base = fWidth/2;
00125 int i = 0;
00126
00127 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
00128 base++;
00129 }
00130 const TGResourcePool *pool = fClient->GetResourcePool();
00131 const TGGC* gc = pool->GetWhiteGC();
00132
00133 for ( i = 1; i < (int)fHeight/3 - 2; ++i ) {
00134 gVirtualX->DrawLine(fId, gc->GetGC(), base - amplitude, i * dist,
00135 base + amplitude,i * dist + dist/2);
00136 }
00137
00138 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
00139
00140 for ( i = 1; i < (int)fHeight/3 - 2; ++i ) {
00141 gVirtualX->DrawLine(fId, gc->GetGC(), base + amplitude, i * dist + dist/2,
00142 base - amplitude, i * dist + dist );
00143 }
00144 gVirtualX->DrawLine(fId, gc->GetGC(), 6, 3, fWidth - 6, 3);
00145 gVirtualX->DrawLine(fId, gc->GetGC(), 6, fHeight - 6, fWidth - 6, fHeight - 6);
00146 }
00147
00148
00149 void TGuiBldHintsButton::DrawCenterX()
00150 {
00151
00152
00153 int base = fHeight/2;
00154 int x = 6;
00155 int y = 6;
00156
00157 const TGResourcePool *pool = fClient->GetResourcePool();
00158 const TGGC* gc = pool->GetWhiteGC();
00159
00160 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
00161 base++;
00162 x++;
00163 y++;
00164 }
00165
00166 gVirtualX->DrawLine(fId, gc->GetGC(), x, base, x + fWidth - 12, base);
00167
00168 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
00169
00170 gVirtualX->DrawLine(fId, gc->GetGC(), x, base - 1, x + fWidth/2 - 12, base - 1);
00171 gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth/2, base - 1, x + fWidth - 12, base - 1);
00172 gVirtualX->DrawLine(fId, gc->GetGC(), x, base + 1, x + fWidth/2 - 12, base + 1);
00173 gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth/2, base + 1, x + fWidth - 12, base + 1);
00174
00175 Point_t arrow[3];
00176 arrow[0].fX = arrow[01].fX = x + fWidth/2 - 12;
00177 arrow[2].fX = x + fWidth/2 - 6;
00178 arrow[2].fY = y + fHeight/2 - 6;
00179 arrow[0].fY = arrow[2].fY - 4;
00180 arrow[1].fY = arrow[2].fY + 4;
00181 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
00182
00183 arrow[0].fX = arrow[01].fX = x + fWidth/2;
00184 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
00185
00186 gVirtualX->DrawLine(fId, gc->GetGC(), x, y, x, y + fHeight - 12);
00187 gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth - 12, y, x + fWidth - 12, y + fHeight - 12);
00188 }
00189
00190
00191 void TGuiBldHintsButton::DrawCenterY()
00192 {
00193
00194
00195 int base = fWidth/2;
00196 int x = 6;
00197 int y = 6;
00198
00199 const TGResourcePool *pool = fClient->GetResourcePool();
00200 const TGGC* gc = pool->GetWhiteGC();
00201
00202 if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
00203 base++;
00204 x++;
00205 y++;
00206 }
00207
00208 gVirtualX->DrawLine(fId, gc->GetGC(), base, y, base, y + fHeight - 12);
00209
00210 gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();
00211
00212 gVirtualX->DrawLine(fId, gc->GetGC(), base - 1, y, base - 1, y + fHeight/2 - 12);
00213 gVirtualX->DrawLine(fId, gc->GetGC(), base - 1, y + fHeight/2, base - 1, y + fHeight - 12);
00214 gVirtualX->DrawLine(fId, gc->GetGC(), base + 1, y, base + 1, y + fHeight/2 - 12);
00215 gVirtualX->DrawLine(fId, gc->GetGC(), base + 1, y + fHeight/2, base + 1, y + fHeight - 12);
00216
00217 Point_t arrow[3];
00218 arrow[0].fY = arrow[01].fY = y + fHeight/2 - 12;
00219 arrow[2].fY = y + fHeight/2 - 6;
00220 arrow[2].fX = x + fWidth/2 - 6;
00221 arrow[0].fX = arrow[2].fX - 4;
00222 arrow[1].fX = arrow[2].fX + 4;
00223 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
00224
00225 arrow[0].fY = arrow[01].fY = y + fHeight/2;
00226 gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
00227 gVirtualX->DrawLine(fId, gc->GetGC(), x, y, x + fWidth - 12, y);
00228 gVirtualX->DrawLine(fId, gc->GetGC(), x, y + fHeight - 12, x + fWidth - 12, y + fHeight - 12);
00229 }
00230
00231
00232 void TGuiBldHintsButton::DrawTopLeft()
00233 {
00234
00235 }
00236
00237
00238 void TGuiBldHintsButton::DrawTopRight()
00239 {
00240
00241 }
00242
00243
00244 void TGuiBldHintsButton::DrawBottomLeft()
00245 {
00246
00247 }
00248
00249
00250 void TGuiBldHintsButton::DrawBottomRight()
00251 {
00252
00253 }
00254