00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "TControlBarButton.h"
00022 #include "TCanvas.h"
00023 #include "TError.h"
00024 #include "TApplication.h"
00025
00026 #include <ctype.h>
00027
00028 const char *kBStr = "BUTTON";
00029 const char *kDStr = "DRAWNBUTTON";
00030 const char *kSStr = "SEPARATOR";
00031
00032
00033 ClassImp(TControlBarButton)
00034
00035
00036 TControlBarButton::TControlBarButton() : TNamed()
00037 {
00038
00039
00040 fType = 0;
00041 }
00042
00043
00044 TControlBarButton::TControlBarButton(const char *label, const char *action,
00045 const char *hint, const char *type)
00046 : TNamed(label, hint)
00047 {
00048
00049
00050 SetType(type);
00051 SetAction(action);
00052 }
00053
00054
00055 void TControlBarButton::Action()
00056 {
00057
00058
00059 if (!fAction.IsNull()) {
00060
00061 gApplication->ProcessLine(fAction.Data());
00062
00063 if (gPad) gPad->Update();
00064 }
00065 }
00066
00067
00068 void TControlBarButton::SetAction(const char *action)
00069 {
00070
00071
00072 if (action) {
00073 char *s = Strip(action);
00074 fAction = s;
00075 delete [] s;
00076 } else
00077 Error("SetAction", "action missing");
00078 }
00079
00080
00081
00082 void TControlBarButton::SetType(const char *type)
00083 {
00084
00085
00086
00087 fType = kButton;
00088
00089 if (type && *type) {
00090 if (!strcasecmp(type, kBStr))
00091 fType = kButton;
00092 else if (!strcasecmp(type, kDStr))
00093 fType = kDrawnButton;
00094 else if (!strcasecmp(type, kSStr))
00095 fType = kSeparator;
00096 else
00097 Error("SetType", "unknown type '%s' !\n\t(choice of: %s, %s, %s)",
00098 type, kBStr, kDStr, kSStr);
00099 }
00100 }
00101
00102
00103 void TControlBarButton::SetType(Int_t type)
00104 {
00105
00106
00107
00108 switch (type) {
00109
00110 case kButton:
00111 case kDrawnButton:
00112 case kSeparator:
00113 fType = type;
00114 break;
00115
00116 default:
00117 fType = kButton;
00118 Error("SetType", "unknown type: %d !\n\t(choice of: %d, %d, %d)",
00119 type, kButton, kDrawnButton, kSeparator);
00120 }
00121 }