// @(#)root/gpad:$Id$
// Author: Nenad Buncic   20/02/96

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

/////////////////////////////////////////////////////////////////////////
//                                                                     //
// TControlBarButton                                                   //
//                                                                     //
// TControlBarButtons are created by the TControlBar. Not for general  //
// consumption.                                                        //
//                                                                     //
/////////////////////////////////////////////////////////////////////////

#include "TControlBarButton.h"
#include "TCanvas.h"
#include "TError.h"
#include "TApplication.h"

#include <ctype.h>

const char *kBStr = "BUTTON";
const char *kDStr = "DRAWNBUTTON";
const char *kSStr = "SEPARATOR";


ClassImp(TControlBarButton)

//_______________________________________________________________________
TControlBarButton::TControlBarButton() : TNamed()
{
   // Default controlbar button ctor.

   fType   = 0;
}

//_______________________________________________________________________
TControlBarButton::TControlBarButton(const char *label, const char *action,
                                     const char *hint, const char *type)
   : TNamed(label, hint)
{
   // Create controlbar button.

   SetType(type);
   SetAction(action);
}

//_______________________________________________________________________
void TControlBarButton::Action()
{
   // Execute controlbar button command.

   if (!fAction.IsNull()) {

      gApplication->ProcessLine(fAction.Data());

      if (gPad) gPad->Update();
   }
}

//_______________________________________________________________________
void TControlBarButton::SetAction(const char *action)
{
   // Set action to be executed by this button.

   if (action) {
      char *s = Strip(action);
      fAction = s;
      delete [] s;
   } else
      Error("SetAction", "action missing");
}


//_______________________________________________________________________
void TControlBarButton::SetType(const char *type)
{
   // Set button type. Type can be either "button", "drawnbutton" or
   // "separator". String is case insensitive. Default is "button".

   fType = kButton;

   if (type && *type) {
      if (!strcasecmp(type, kBStr))
         fType = kButton;
      else if (!strcasecmp(type, kDStr))
         fType = kDrawnButton;
      else if (!strcasecmp(type, kSStr))
         fType = kSeparator;
      else
         Error("SetType", "unknown type '%s' !\n\t(choice of: %s, %s, %s)",
               type, kBStr, kDStr, kSStr);
   }
}

//_______________________________________________________________________
void TControlBarButton::SetType(Int_t type)
{
   // Set button type. Type can be either kButton, kDrawnButton or kSeparator.
   // Default is kButton.

   switch (type) {

      case kButton:
      case kDrawnButton:
      case kSeparator:
         fType = type;
         break;

      default:
         fType = kButton;
         Error("SetType", "unknown type: %d !\n\t(choice of: %d, %d, %d)",
               type, kButton, kDrawnButton, kSeparator);
   }
}
 TControlBarButton.cxx:1
 TControlBarButton.cxx:2
 TControlBarButton.cxx:3
 TControlBarButton.cxx:4
 TControlBarButton.cxx:5
 TControlBarButton.cxx:6
 TControlBarButton.cxx:7
 TControlBarButton.cxx:8
 TControlBarButton.cxx:9
 TControlBarButton.cxx:10
 TControlBarButton.cxx:11
 TControlBarButton.cxx:12
 TControlBarButton.cxx:13
 TControlBarButton.cxx:14
 TControlBarButton.cxx:15
 TControlBarButton.cxx:16
 TControlBarButton.cxx:17
 TControlBarButton.cxx:18
 TControlBarButton.cxx:19
 TControlBarButton.cxx:20
 TControlBarButton.cxx:21
 TControlBarButton.cxx:22
 TControlBarButton.cxx:23
 TControlBarButton.cxx:24
 TControlBarButton.cxx:25
 TControlBarButton.cxx:26
 TControlBarButton.cxx:27
 TControlBarButton.cxx:28
 TControlBarButton.cxx:29
 TControlBarButton.cxx:30
 TControlBarButton.cxx:31
 TControlBarButton.cxx:32
 TControlBarButton.cxx:33
 TControlBarButton.cxx:34
 TControlBarButton.cxx:35
 TControlBarButton.cxx:36
 TControlBarButton.cxx:37
 TControlBarButton.cxx:38
 TControlBarButton.cxx:39
 TControlBarButton.cxx:40
 TControlBarButton.cxx:41
 TControlBarButton.cxx:42
 TControlBarButton.cxx:43
 TControlBarButton.cxx:44
 TControlBarButton.cxx:45
 TControlBarButton.cxx:46
 TControlBarButton.cxx:47
 TControlBarButton.cxx:48
 TControlBarButton.cxx:49
 TControlBarButton.cxx:50
 TControlBarButton.cxx:51
 TControlBarButton.cxx:52
 TControlBarButton.cxx:53
 TControlBarButton.cxx:54
 TControlBarButton.cxx:55
 TControlBarButton.cxx:56
 TControlBarButton.cxx:57
 TControlBarButton.cxx:58
 TControlBarButton.cxx:59
 TControlBarButton.cxx:60
 TControlBarButton.cxx:61
 TControlBarButton.cxx:62
 TControlBarButton.cxx:63
 TControlBarButton.cxx:64
 TControlBarButton.cxx:65
 TControlBarButton.cxx:66
 TControlBarButton.cxx:67
 TControlBarButton.cxx:68
 TControlBarButton.cxx:69
 TControlBarButton.cxx:70
 TControlBarButton.cxx:71
 TControlBarButton.cxx:72
 TControlBarButton.cxx:73
 TControlBarButton.cxx:74
 TControlBarButton.cxx:75
 TControlBarButton.cxx:76
 TControlBarButton.cxx:77
 TControlBarButton.cxx:78
 TControlBarButton.cxx:79
 TControlBarButton.cxx:80
 TControlBarButton.cxx:81
 TControlBarButton.cxx:82
 TControlBarButton.cxx:83
 TControlBarButton.cxx:84
 TControlBarButton.cxx:85
 TControlBarButton.cxx:86
 TControlBarButton.cxx:87
 TControlBarButton.cxx:88
 TControlBarButton.cxx:89
 TControlBarButton.cxx:90
 TControlBarButton.cxx:91
 TControlBarButton.cxx:92
 TControlBarButton.cxx:93
 TControlBarButton.cxx:94
 TControlBarButton.cxx:95
 TControlBarButton.cxx:96
 TControlBarButton.cxx:97
 TControlBarButton.cxx:98
 TControlBarButton.cxx:99
 TControlBarButton.cxx:100
 TControlBarButton.cxx:101
 TControlBarButton.cxx:102
 TControlBarButton.cxx:103
 TControlBarButton.cxx:104
 TControlBarButton.cxx:105
 TControlBarButton.cxx:106
 TControlBarButton.cxx:107
 TControlBarButton.cxx:108
 TControlBarButton.cxx:109
 TControlBarButton.cxx:110
 TControlBarButton.cxx:111
 TControlBarButton.cxx:112
 TControlBarButton.cxx:113
 TControlBarButton.cxx:114
 TControlBarButton.cxx:115
 TControlBarButton.cxx:116
 TControlBarButton.cxx:117
 TControlBarButton.cxx:118
 TControlBarButton.cxx:119
 TControlBarButton.cxx:120
 TControlBarButton.cxx:121