//*CMZ : 2.00/04 06/04/98 21.22.50 by Fons Rademakers
//*CMZ : 2.00/00 06/04/98 10.05.09 by Fons Rademakers
//*CMZ : 1.00/06 23/03/97 11.21.50 by Rene Brun
//*-- Author : Nenad Buncic 20/02/96
//*KEEP,CopyRight,T=C.
/*************************************************************************
* Copyright(c) 1995-1999, The ROOT System, All rights reserved. *
* Authors: Rene Brun, Fons Rademakers. *
* For list of contributors see $ROOTSYS/AA_CREDITS. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation for non-commercial purposes is hereby granted without *
* fee, provided that the above copyright notice appears in all copies *
* and that both the copyright notice and this permission notice appear *
* in the supporting documentation. The authors make no claims about the *
* suitability of this software for any purpose. It is provided "as is" *
* without express or implied warranty. *
*************************************************************************/
//*KEND.
/////////////////////////////////////////////////////////////////////////
// //
// TControlBarButton //
// //
// TControlBarButtons are created by the TControlBar. Not for general //
// consumption. //
// //
/////////////////////////////////////////////////////////////////////////
//*KEEP,TControlBarButton,T=C++.
#include "TControlBarButton.h"
//*KEEP,TCanvas.
#include "TCanvas.h"
//*KEEP,TError.
#include "TError.h"
//*KEEP,TApplication.
#include "TApplication.h"
//*KEND.
#include <ctype.h>
const Text_t *kBStr = "BUTTON";
const Text_t *kDStr = "DRAWNBUTTON";
const Text_t *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);
}
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.