#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()
{
fType = 0;
}
TControlBarButton::TControlBarButton(const char *label, const char *action,
const char *hint, const char *type)
: TNamed(label, hint)
{
SetType(type);
SetAction(action);
}
void TControlBarButton::Action()
{
if (!fAction.IsNull()) {
gApplication->ProcessLine(fAction.Data());
if (gPad) gPad->Update();
}
}
void TControlBarButton::SetAction(const char *action)
{
if (action) {
char *s = Strip(action);
fAction = s;
delete [] s;
} else
Error("SetAction", "action missing");
}
void TControlBarButton::SetType(const char *type)
{
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)
{
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: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