TButton
class description - source file - inheritance tree
private:
TButton TButton(const TButton& org)
TButton& operator=(const TButton& rhs)
public:
TButton TButton()
TButton TButton(const char* title, const char* method, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
virtual void ~TButton()
static TClass* Class()
virtual void Divide(Int_t nx = 1, Int_t ny = 1, Float_t xmargin = 0.01, Float_t ymargin = 0.01, Int_t color = 0)
virtual void Draw(Option_t* option)
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual Bool_t GetFraming()
virtual const char* GetMethod() const
virtual TClass* IsA() const
virtual void Paint(Option_t* option)
virtual void PaintModified()
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
virtual void SavePrimitive(ofstream& out, Option_t* option)
virtual void SetBorderMode(Short_t bordermode)
virtual void SetFraming(Bool_t f = 1)
virtual void SetGrid(Int_t valuex = 1, Int_t valuey = 1)
virtual void SetLogx(Int_t value = 1)
virtual void SetLogy(Int_t value = 1)
virtual void SetMethod(char* method)
virtual void SetName(const char* name)
virtual void ShowMembers(TMemberInspector& insp, char* parent)
virtual void Streamer(TBuffer& b)
virtual void x3d(Option_t* option)
private:
Bool_t fFocused If cursor is in...
Bool_t fFraming True if you want a frame to be painted when pressed
protected:
TString fMethod Method to be executed by this button
See also
-
TGroupButton
A TButton object is a user interface object.
A TButton has a name and an associated action.
When the button is clicked with the left mouse button, the cooresponding
action is executed.
A Tbutton can be created by direct invokation of the constructors
or via the graphics editor.
The Action can be set via TButton::SetMethod.
The action can be any command. Examples of actions:
"34+78" When the button is clicked, the result of addition is printed.
".x macro.C" . Clicking the button executes the macro macro.C
The action can be modified at any time via TButton::SetMethod.
To modify the layout/size/contents of one or several buttons
in a canvas, you must set the canvas editable via TCanvas::SetEditable.
By default a TCanvas is editable.
By default a TDialogCanvas is not editable.
TButtons are in general placed in a TDialogCanvas.
A TButton being a TPad, one can draw graphics primitives in it
when the TCanvas/TDialogCanvas is editable.
Example of a macro creating a dialogcanvas with buttons
void but() {
// example of a dialogcanvas with a few buttons
TDialogCanvas *dialog = new TDialogCanvas("dialog","",200,300);
// Create first button. Clicking on this button will execute 34+56
TButton *but1 = new TButton("button1","34+56",.05,.8,.45,.88);
but1->Draw();
// Create second button. Clicking on this button will create a new canvas
TButton *but2 = new TButton("canvas","c2 = new TCanvas("c2")",.55,.8,.95,.88);
but2->Draw();
// Create third button. Clicking on this button will invoke the browser
but3 = new TButton("Browser","br = new TBrowser("br")",0.25,0.54,0.75,0.64);
but3->SetFillColor(42);
but3->Draw();
// Create last button with no name. Instead a graph is draw inside the button
// Clicking on this button will invoke the macro tutorials/graph.C
button = new TButton("",".x tutorials/graph.C",0.15,0.15,0.85,0.38);
button->SetFillColor(42);
button->Draw();
button->cd();
Double_t x[8] = {0.08,0.21,0.34,0.48,0.61,0.7,0.81,0.92};
Double_t y[8] = {0.2,0.65,0.4,0.34,0.24,0.43,0.75,0.52};
TGraph *graph = new TGraph(8,x,y);
graph->SetMarkerColor(4);
graph->SetMarkerStyle(21);
graph->Draw("lp");
dialog->cd();
}
Executing the macro above produces the following dialogcanvas
/*
*/
TButton(): TPad()
*-*-*-*-*-*-*-*-*-*-*Button default constructor*-*-*-*-*-*-*-*-*-*-*-*-*
*-* ==========================
TButton(const char *title, const char *method, Double_t x1, Double_t y1,Double_t x2, Double_t y2)
:TPad("button",title,x1,y1,x2,y2,18,2,1), TAttText(22,0,1,61,0.65)
*-*-*-*-*-*-*-*-*-*-*Button normal constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* =========================
Note that the button coordinates x1,y1,x2,y2 are always in the range [0,1]
~TButton()
*-*-*-*-*-*-*-*-*-*-*Button default destructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* =========================
void Draw(Option_t *option)
*-*-*-*-*-*-*-*-*-*-*Draw this button with its current attributes*-*-*-*-*
*-* ============================================
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
*-*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*
*-* =========================================
This member function is called when a Button object is clicked.
void Paint(Option_t *option)
*-*-*-*-*-*-*-*-*-*-*Paint this button with its current attributes*-*-*-*
*-* =============================================
void PaintModified()
void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
*-*-*-*-*-*-*-*-*-*-*Set world coordinate system for the pad*-*-*-*-*-*-*
*-* =======================================
void SavePrimitive(ofstream &out, Option_t *)
Save primitive as a C++ statement(s) on output stream out
void SetFraming(Bool_t f)
if framing is set, button will be highlighted
Inline Functions
TButton& operator=(const TButton& rhs)
TButton TButton(const char* title, const char* method, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
void Divide(Int_t nx = 1, Int_t ny = 1, Float_t xmargin = 0.01, Float_t ymargin = 0.01, Int_t color = 0)
const char* GetMethod() const
void SetBorderMode(Short_t bordermode)
Bool_t GetFraming()
void SetGrid(Int_t valuex = 1, Int_t valuey = 1)
void SetLogx(Int_t value = 1)
void SetLogy(Int_t value = 1)
void SetMethod(char* method)
void SetName(const char* name)
void x3d(Option_t* option)
TClass* Class()
TClass* IsA() const
void ShowMembers(TMemberInspector& insp, char* parent)
void Streamer(TBuffer& b)
Author: Rene Brun 01/07/96
Last update: root/gpad:$Name: $:$Id: TButton.cxx,v 1.2 2000/06/13 11:25:02 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
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.