// @(#)root/guibuilder:$Id$
// Author: Valeriy Onuchin   12/09/04

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TGuiBldHintsButton.h"
#include "TGResourcePool.h"

//_____________________________________________________________________________
//
// TGuiBldHintsButton
//
// Special button class used for editing layout hints in the ROOT GUI Builder.
//_____________________________________________________________________________

ClassImp(TGuiBldHintsButton)


////////////////////////////////////////////////////////////////////////////////
//______________________________________________________________________________
TGuiBldHintsButton::TGuiBldHintsButton(const TGWindow* p, Int_t id) :
                     TGButton(p, id)
{
   // Constructor.

   fStayDown = kTRUE;

   switch ((ELayoutHints)fWidgetId) {
      case kLHintsCenterX:
      case kLHintsExpandX:
         Resize(40, 15);
         break;
      case kLHintsCenterY:
      case kLHintsExpandY:
         Resize(15, 40);
         break;
      default:
         Resize(15, 15);
         break;
   }
}

//______________________________________________________________________________
void TGuiBldHintsButton::DoRedraw()
{
   // Redraw button.

   TGButton::DoRedraw();

   switch (fWidgetId) {
      case kLHintsCenterX:
         DrawCenterX();
         break;
      case kLHintsCenterY:
         DrawCenterY();
         break;
      case kLHintsExpandX:
         DrawExpandX();
         break;
      case kLHintsExpandY:
         DrawExpandY();
         break;
      case (kLHintsTop | kLHintsLeft):
         DrawTopLeft();
         break;
      case (kLHintsTop | kLHintsRight):
         DrawTopRight();
         break;
      case (kLHintsBottom | kLHintsLeft):
         DrawBottomLeft();
         break;
      case (kLHintsBottom | kLHintsRight):
         DrawBottomRight();
         break;
      default:
         DrawExpandX();
         break;
   }
}

//______________________________________________________________________________
void TGuiBldHintsButton::DrawExpandX()
{
   // Draw expand X button.

   const int dist = 3;
   const int amplitude = TMath::Min(3, (int)fHeight/3);
   int base = fHeight/2;
   int i = 0;
   const TGResourcePool *pool = fClient->GetResourcePool();
   const TGGC* gc = pool->GetWhiteGC();

   if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
      base++;
   }

   for ( i = 1; i < (int)fWidth/3 - 2; ++i ) {
      gVirtualX->DrawLine(fId, gc->GetGC(), i * dist, base - amplitude,
                           i * dist + dist/2, base + amplitude);
   }
   gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();

   for ( i = 1; i < (int)fWidth/3 - 2; ++i ) {
      gVirtualX->DrawLine(fId, gc->GetGC(), i * dist + dist/2, base + amplitude,
                           i * dist + dist, base - amplitude);
   }
   gVirtualX->DrawLine(fId, gc->GetGC(), 3, 6, 3, fHeight - 6);
   gVirtualX->DrawLine(fId, gc->GetGC(), fWidth - 6, 6, fWidth - 6, fHeight - 6);
}

//______________________________________________________________________________
void TGuiBldHintsButton::DrawExpandY()
{
   // Draw expand Y button.

   const int dist = 3;
   const int amplitude = TMath::Min(3, (int)fWidth/3);
   int base = fWidth/2;
   int i = 0;

   if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
      base++;
   }
   const TGResourcePool *pool = fClient->GetResourcePool();
   const TGGC* gc = pool->GetWhiteGC();

   for ( i = 1; i < (int)fHeight/3 - 2; ++i ) {
      gVirtualX->DrawLine(fId, gc->GetGC(), base - amplitude, i * dist,
                           base + amplitude,i * dist + dist/2);
   }

   gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();

   for ( i = 1; i < (int)fHeight/3 - 2; ++i ) {
      gVirtualX->DrawLine(fId, gc->GetGC(), base + amplitude, i * dist + dist/2,
                           base - amplitude, i * dist + dist );
   }
   gVirtualX->DrawLine(fId, gc->GetGC(), 6, 3, fWidth - 6, 3);
   gVirtualX->DrawLine(fId, gc->GetGC(), 6, fHeight - 6, fWidth - 6, fHeight - 6);
}

//______________________________________________________________________________
void TGuiBldHintsButton::DrawCenterX()
{
   // Draw center X buton.

   int base = fHeight/2;
   int x = 6;
   int y = 6;

   const TGResourcePool *pool = fClient->GetResourcePool();
   const TGGC* gc = pool->GetWhiteGC();

   if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
      base++;
      x++;
      y++;
   }

   gVirtualX->DrawLine(fId, gc->GetGC(), x, base, x + fWidth - 12, base);

   gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();

   gVirtualX->DrawLine(fId, gc->GetGC(), x, base - 1, x + fWidth/2 - 12, base - 1);
   gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth/2, base - 1, x + fWidth - 12, base - 1);
   gVirtualX->DrawLine(fId, gc->GetGC(), x, base + 1, x + fWidth/2 - 12, base +  1);
   gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth/2, base + 1, x + fWidth - 12, base + 1);

   Point_t arrow[3];
   arrow[0].fX = arrow[01].fX = x + fWidth/2 - 12;
   arrow[2].fX = x + fWidth/2 - 6;
   arrow[2].fY = y + fHeight/2 - 6;
   arrow[0].fY = arrow[2].fY - 4;
   arrow[1].fY = arrow[2].fY + 4;
   gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);

   arrow[0].fX = arrow[01].fX = x + fWidth/2;
   gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);

   gVirtualX->DrawLine(fId, gc->GetGC(), x, y, x, y + fHeight - 12);
   gVirtualX->DrawLine(fId, gc->GetGC(), x + fWidth - 12, y, x + fWidth - 12, y + fHeight - 12);
}

//______________________________________________________________________________
void TGuiBldHintsButton::DrawCenterY()
{
   // Draw center Y button.

   int base = fWidth/2;
   int x = 6;
   int y = 6;

   const TGResourcePool *pool = fClient->GetResourcePool();
   const TGGC* gc = pool->GetWhiteGC();

   if ((fState == kButtonDown) || (fState == kButtonEngaged)) {
      base++;
      x++;
      y++;
   }

   gVirtualX->DrawLine(fId, gc->GetGC(), base, y, base, y + fHeight - 12);

   gc = IsEnabled() ? pool->GetSelectedBckgndGC() : pool->GetFrameShadowGC();

   gVirtualX->DrawLine(fId, gc->GetGC(), base - 1, y,  base - 1, y + fHeight/2 - 12);
   gVirtualX->DrawLine(fId, gc->GetGC(),  base - 1, y + fHeight/2, base - 1, y + fHeight - 12);
   gVirtualX->DrawLine(fId, gc->GetGC(), base + 1, y,  base + 1, y + fHeight/2 - 12);
   gVirtualX->DrawLine(fId, gc->GetGC(),  base + 1, y + fHeight/2, base + 1, y + fHeight - 12);

   Point_t arrow[3];
   arrow[0].fY = arrow[01].fY = y + fHeight/2 - 12;
   arrow[2].fY = y + fHeight/2 - 6;
   arrow[2].fX = x + fWidth/2 - 6;
   arrow[0].fX = arrow[2].fX - 4;
   arrow[1].fX = arrow[2].fX + 4;
   gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);

   arrow[0].fY = arrow[01].fY = y + fHeight/2;
   gVirtualX->FillPolygon(fId, gc->GetGC(), (Point_t*)&arrow, 3);
   gVirtualX->DrawLine(fId, gc->GetGC(), x, y, x + fWidth - 12, y);
   gVirtualX->DrawLine(fId, gc->GetGC(), x, y + fHeight - 12,  x + fWidth - 12, y + fHeight - 12);
}

//______________________________________________________________________________
void TGuiBldHintsButton::DrawTopLeft()
{
   // DrawTopLeft.
}

//______________________________________________________________________________
void TGuiBldHintsButton::DrawTopRight()
{
   // DrawTopRight.
}

//______________________________________________________________________________
void TGuiBldHintsButton::DrawBottomLeft()
{
   // DrawBottomLeft.
}

//______________________________________________________________________________
void TGuiBldHintsButton::DrawBottomRight()
{
   // DrawBottomRight.
}

 TGuiBldHintsButton.cxx:1
 TGuiBldHintsButton.cxx:2
 TGuiBldHintsButton.cxx:3
 TGuiBldHintsButton.cxx:4
 TGuiBldHintsButton.cxx:5
 TGuiBldHintsButton.cxx:6
 TGuiBldHintsButton.cxx:7
 TGuiBldHintsButton.cxx:8
 TGuiBldHintsButton.cxx:9
 TGuiBldHintsButton.cxx:10
 TGuiBldHintsButton.cxx:11
 TGuiBldHintsButton.cxx:12
 TGuiBldHintsButton.cxx:13
 TGuiBldHintsButton.cxx:14
 TGuiBldHintsButton.cxx:15
 TGuiBldHintsButton.cxx:16
 TGuiBldHintsButton.cxx:17
 TGuiBldHintsButton.cxx:18
 TGuiBldHintsButton.cxx:19
 TGuiBldHintsButton.cxx:20
 TGuiBldHintsButton.cxx:21
 TGuiBldHintsButton.cxx:22
 TGuiBldHintsButton.cxx:23
 TGuiBldHintsButton.cxx:24
 TGuiBldHintsButton.cxx:25
 TGuiBldHintsButton.cxx:26
 TGuiBldHintsButton.cxx:27
 TGuiBldHintsButton.cxx:28
 TGuiBldHintsButton.cxx:29
 TGuiBldHintsButton.cxx:30
 TGuiBldHintsButton.cxx:31
 TGuiBldHintsButton.cxx:32
 TGuiBldHintsButton.cxx:33
 TGuiBldHintsButton.cxx:34
 TGuiBldHintsButton.cxx:35
 TGuiBldHintsButton.cxx:36
 TGuiBldHintsButton.cxx:37
 TGuiBldHintsButton.cxx:38
 TGuiBldHintsButton.cxx:39
 TGuiBldHintsButton.cxx:40
 TGuiBldHintsButton.cxx:41
 TGuiBldHintsButton.cxx:42
 TGuiBldHintsButton.cxx:43
 TGuiBldHintsButton.cxx:44
 TGuiBldHintsButton.cxx:45
 TGuiBldHintsButton.cxx:46
 TGuiBldHintsButton.cxx:47
 TGuiBldHintsButton.cxx:48
 TGuiBldHintsButton.cxx:49
 TGuiBldHintsButton.cxx:50
 TGuiBldHintsButton.cxx:51
 TGuiBldHintsButton.cxx:52
 TGuiBldHintsButton.cxx:53
 TGuiBldHintsButton.cxx:54
 TGuiBldHintsButton.cxx:55
 TGuiBldHintsButton.cxx:56
 TGuiBldHintsButton.cxx:57
 TGuiBldHintsButton.cxx:58
 TGuiBldHintsButton.cxx:59
 TGuiBldHintsButton.cxx:60
 TGuiBldHintsButton.cxx:61
 TGuiBldHintsButton.cxx:62
 TGuiBldHintsButton.cxx:63
 TGuiBldHintsButton.cxx:64
 TGuiBldHintsButton.cxx:65
 TGuiBldHintsButton.cxx:66
 TGuiBldHintsButton.cxx:67
 TGuiBldHintsButton.cxx:68
 TGuiBldHintsButton.cxx:69
 TGuiBldHintsButton.cxx:70
 TGuiBldHintsButton.cxx:71
 TGuiBldHintsButton.cxx:72
 TGuiBldHintsButton.cxx:73
 TGuiBldHintsButton.cxx:74
 TGuiBldHintsButton.cxx:75
 TGuiBldHintsButton.cxx:76
 TGuiBldHintsButton.cxx:77
 TGuiBldHintsButton.cxx:78
 TGuiBldHintsButton.cxx:79
 TGuiBldHintsButton.cxx:80
 TGuiBldHintsButton.cxx:81
 TGuiBldHintsButton.cxx:82
 TGuiBldHintsButton.cxx:83
 TGuiBldHintsButton.cxx:84
 TGuiBldHintsButton.cxx:85
 TGuiBldHintsButton.cxx:86
 TGuiBldHintsButton.cxx:87
 TGuiBldHintsButton.cxx:88
 TGuiBldHintsButton.cxx:89
 TGuiBldHintsButton.cxx:90
 TGuiBldHintsButton.cxx:91
 TGuiBldHintsButton.cxx:92
 TGuiBldHintsButton.cxx:93
 TGuiBldHintsButton.cxx:94
 TGuiBldHintsButton.cxx:95
 TGuiBldHintsButton.cxx:96
 TGuiBldHintsButton.cxx:97
 TGuiBldHintsButton.cxx:98
 TGuiBldHintsButton.cxx:99
 TGuiBldHintsButton.cxx:100
 TGuiBldHintsButton.cxx:101
 TGuiBldHintsButton.cxx:102
 TGuiBldHintsButton.cxx:103
 TGuiBldHintsButton.cxx:104
 TGuiBldHintsButton.cxx:105
 TGuiBldHintsButton.cxx:106
 TGuiBldHintsButton.cxx:107
 TGuiBldHintsButton.cxx:108
 TGuiBldHintsButton.cxx:109
 TGuiBldHintsButton.cxx:110
 TGuiBldHintsButton.cxx:111
 TGuiBldHintsButton.cxx:112
 TGuiBldHintsButton.cxx:113
 TGuiBldHintsButton.cxx:114
 TGuiBldHintsButton.cxx:115
 TGuiBldHintsButton.cxx:116
 TGuiBldHintsButton.cxx:117
 TGuiBldHintsButton.cxx:118
 TGuiBldHintsButton.cxx:119
 TGuiBldHintsButton.cxx:120
 TGuiBldHintsButton.cxx:121
 TGuiBldHintsButton.cxx:122
 TGuiBldHintsButton.cxx:123
 TGuiBldHintsButton.cxx:124
 TGuiBldHintsButton.cxx:125
 TGuiBldHintsButton.cxx:126
 TGuiBldHintsButton.cxx:127
 TGuiBldHintsButton.cxx:128
 TGuiBldHintsButton.cxx:129
 TGuiBldHintsButton.cxx:130
 TGuiBldHintsButton.cxx:131
 TGuiBldHintsButton.cxx:132
 TGuiBldHintsButton.cxx:133
 TGuiBldHintsButton.cxx:134
 TGuiBldHintsButton.cxx:135
 TGuiBldHintsButton.cxx:136
 TGuiBldHintsButton.cxx:137
 TGuiBldHintsButton.cxx:138
 TGuiBldHintsButton.cxx:139
 TGuiBldHintsButton.cxx:140
 TGuiBldHintsButton.cxx:141
 TGuiBldHintsButton.cxx:142
 TGuiBldHintsButton.cxx:143
 TGuiBldHintsButton.cxx:144
 TGuiBldHintsButton.cxx:145
 TGuiBldHintsButton.cxx:146
 TGuiBldHintsButton.cxx:147
 TGuiBldHintsButton.cxx:148
 TGuiBldHintsButton.cxx:149
 TGuiBldHintsButton.cxx:150
 TGuiBldHintsButton.cxx:151
 TGuiBldHintsButton.cxx:152
 TGuiBldHintsButton.cxx:153
 TGuiBldHintsButton.cxx:154
 TGuiBldHintsButton.cxx:155
 TGuiBldHintsButton.cxx:156
 TGuiBldHintsButton.cxx:157
 TGuiBldHintsButton.cxx:158
 TGuiBldHintsButton.cxx:159
 TGuiBldHintsButton.cxx:160
 TGuiBldHintsButton.cxx:161
 TGuiBldHintsButton.cxx:162
 TGuiBldHintsButton.cxx:163
 TGuiBldHintsButton.cxx:164
 TGuiBldHintsButton.cxx:165
 TGuiBldHintsButton.cxx:166
 TGuiBldHintsButton.cxx:167
 TGuiBldHintsButton.cxx:168
 TGuiBldHintsButton.cxx:169
 TGuiBldHintsButton.cxx:170
 TGuiBldHintsButton.cxx:171
 TGuiBldHintsButton.cxx:172
 TGuiBldHintsButton.cxx:173
 TGuiBldHintsButton.cxx:174
 TGuiBldHintsButton.cxx:175
 TGuiBldHintsButton.cxx:176
 TGuiBldHintsButton.cxx:177
 TGuiBldHintsButton.cxx:178
 TGuiBldHintsButton.cxx:179
 TGuiBldHintsButton.cxx:180
 TGuiBldHintsButton.cxx:181
 TGuiBldHintsButton.cxx:182
 TGuiBldHintsButton.cxx:183
 TGuiBldHintsButton.cxx:184
 TGuiBldHintsButton.cxx:185
 TGuiBldHintsButton.cxx:186
 TGuiBldHintsButton.cxx:187
 TGuiBldHintsButton.cxx:188
 TGuiBldHintsButton.cxx:189
 TGuiBldHintsButton.cxx:190
 TGuiBldHintsButton.cxx:191
 TGuiBldHintsButton.cxx:192
 TGuiBldHintsButton.cxx:193
 TGuiBldHintsButton.cxx:194
 TGuiBldHintsButton.cxx:195
 TGuiBldHintsButton.cxx:196
 TGuiBldHintsButton.cxx:197
 TGuiBldHintsButton.cxx:198
 TGuiBldHintsButton.cxx:199
 TGuiBldHintsButton.cxx:200
 TGuiBldHintsButton.cxx:201
 TGuiBldHintsButton.cxx:202
 TGuiBldHintsButton.cxx:203
 TGuiBldHintsButton.cxx:204
 TGuiBldHintsButton.cxx:205
 TGuiBldHintsButton.cxx:206
 TGuiBldHintsButton.cxx:207
 TGuiBldHintsButton.cxx:208
 TGuiBldHintsButton.cxx:209
 TGuiBldHintsButton.cxx:210
 TGuiBldHintsButton.cxx:211
 TGuiBldHintsButton.cxx:212
 TGuiBldHintsButton.cxx:213
 TGuiBldHintsButton.cxx:214
 TGuiBldHintsButton.cxx:215
 TGuiBldHintsButton.cxx:216
 TGuiBldHintsButton.cxx:217
 TGuiBldHintsButton.cxx:218
 TGuiBldHintsButton.cxx:219
 TGuiBldHintsButton.cxx:220
 TGuiBldHintsButton.cxx:221
 TGuiBldHintsButton.cxx:222
 TGuiBldHintsButton.cxx:223
 TGuiBldHintsButton.cxx:224
 TGuiBldHintsButton.cxx:225
 TGuiBldHintsButton.cxx:226
 TGuiBldHintsButton.cxx:227
 TGuiBldHintsButton.cxx:228
 TGuiBldHintsButton.cxx:229
 TGuiBldHintsButton.cxx:230
 TGuiBldHintsButton.cxx:231
 TGuiBldHintsButton.cxx:232
 TGuiBldHintsButton.cxx:233
 TGuiBldHintsButton.cxx:234
 TGuiBldHintsButton.cxx:235
 TGuiBldHintsButton.cxx:236
 TGuiBldHintsButton.cxx:237
 TGuiBldHintsButton.cxx:238
 TGuiBldHintsButton.cxx:239
 TGuiBldHintsButton.cxx:240
 TGuiBldHintsButton.cxx:241
 TGuiBldHintsButton.cxx:242
 TGuiBldHintsButton.cxx:243
 TGuiBldHintsButton.cxx:244
 TGuiBldHintsButton.cxx:245
 TGuiBldHintsButton.cxx:246
 TGuiBldHintsButton.cxx:247
 TGuiBldHintsButton.cxx:248
 TGuiBldHintsButton.cxx:249
 TGuiBldHintsButton.cxx:250
 TGuiBldHintsButton.cxx:251
 TGuiBldHintsButton.cxx:252
 TGuiBldHintsButton.cxx:253
 TGuiBldHintsButton.cxx:254