Logo ROOT   6.16/01
Reference Guide
TFrame.cxx
Go to the documentation of this file.
1// @(#)root/graf:$Id$
2// Author: Rene Brun 31/10/96
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "Riostream.h"
13#include "TROOT.h"
14#include "TVirtualPad.h"
15#include "TFrame.h"
16#include "TStyle.h"
17
19
20/** \class TFrame
21\ingroup BasicGraphics
22
23Define a Frame.
24
25A `TFrame` is a `TWbox` for drawing histogram frames.
26*/
27
28////////////////////////////////////////////////////////////////////////////////
29/// Frame default constructor.
30
32{
33}
34
35////////////////////////////////////////////////////////////////////////////////
36/// Frame normal constructor.
37
39 :TWbox(x1,y1,x2,y2)
40{
41}
42
43////////////////////////////////////////////////////////////////////////////////
44/// Frame copy constructor.
45
46TFrame::TFrame(const TFrame &frame) : TWbox(frame)
47{
48 ((TFrame&)frame).Copy(*this);
49}
50
51////////////////////////////////////////////////////////////////////////////////
52/// Frame default destructor.
53
55{
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// Copy this frame to frame.
60
61void TFrame::Copy(TObject &frame) const
62{
63 TWbox::Copy(frame);
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// Draw this frame with its current attributes.
68
70{
71 AppendPad(option);
72}
73
74////////////////////////////////////////////////////////////////////////////////
75/// Execute action corresponding to one event.
76///
77/// This member function is called when a TFrame object is clicked.
78
80{
81 if (!gPad) return;
82
83 if (!gPad->IsEditable()) return;
84
85 TWbox::ExecuteEvent(event, px, py);
86
87 Bool_t opaque = gPad->OpaqueMoving();
88
89 if ((event == kButton1Up) || ((opaque)&&(event == kButton1Motion))) {
90 // update pad margins
91 Double_t xmin = gPad->GetUxmin();
92 Double_t xmax = gPad->GetUxmax();
93 Double_t ymin = gPad->GetUymin();
94 Double_t ymax = gPad->GetUymax();
95 Double_t dx = xmax-xmin;
96 Double_t dy = ymax-ymin;
97 Double_t leftMargin = (fX1-gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
98 Double_t topMargin = (gPad->GetY2()-fY2)/(gPad->GetY2()-gPad->GetY1());
99 Double_t rightMargin = (gPad->GetX2()-fX2)/(gPad->GetX2()-gPad->GetX1());
100 Double_t bottomMargin = (fY1-gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
101 // margin may get very small negative values
102 if (leftMargin < 0) leftMargin = 0;
103 if (topMargin < 0) topMargin = 0;
104 if (rightMargin < 0) rightMargin = 0;
105 if (bottomMargin < 0) bottomMargin = 0;
106 gPad->SetLeftMargin(leftMargin);
107 gPad->SetRightMargin(rightMargin);
108 gPad->SetBottomMargin(bottomMargin);
109 gPad->SetTopMargin(topMargin);
110 Double_t dxr = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
111 Double_t dyr = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
112
113 // Range() could change the size of the pad pixmap and therefore should
114 // be called before the other paint routines
115 gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
116 ymin - dyr*gPad->GetBottomMargin(),
117 xmax + dxr*gPad->GetRightMargin(),
118 ymax + dyr*gPad->GetTopMargin());
119 gPad->RangeAxis(xmin, ymin, xmax, ymax);
120 fX1 = xmin;
121 fY1 = ymin;
122 fX2 = xmax;
123 fY2 = ymax;
124 }
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// Paint this wbox with its current attributes.
129
131{
132 const TPickerStackGuard stackGuard(this);
133
134 if (!gPad->PadInHighlightMode() || (gPad->PadInHighlightMode() && this == gPad->GetSelected())) {
135 TWbox::Paint(option);
136
137 gPad->PaintBox(fX1,fY1,fX2,fY2,"s");
138 }
139
140}
141
142////////////////////////////////////////////////////////////////////////////////
143/// Do not pop frame's, if allowed they would cover the picture they frame.
144
146{
147}
148
149////////////////////////////////////////////////////////////////////////////////
150/// Save primitive as a C++ statement(s) on output stream out
151
152void TFrame::SavePrimitive(std::ostream &, Option_t * /*= ""*/)
153{
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Replace current frame attributes by current style.
158
160{
161 if (gStyle->IsReading()) {
169 } else {
177 }
178}
@ kButton1Motion
Definition: Buttons.h:20
@ kButton1Up
Definition: Buttons.h:19
static const double x2[5]
static const double x1[5]
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:363
float xmin
Definition: THbookFile.cxx:93
float ymin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
float ymax
Definition: THbookFile.cxx:93
R__EXTERN TStyle * gStyle
Definition: TStyle.h:406
#define gPad
Definition: TVirtualPad.h:286
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition: TAttFill.h:31
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:33
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:35
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual Style_t GetLineStyle() const
Return the line style.
Definition: TAttLine.h:34
Double_t fX1
X of 1st point.
Definition: TBox.h:30
Double_t fY2
Y of 2nd point.
Definition: TBox.h:33
Double_t fX2
X of 2nd point.
Definition: TBox.h:32
Double_t fY1
Y of 1st point.
Definition: TBox.h:31
Define a Frame.
Definition: TFrame.h:19
virtual void Pop()
Do not pop frame's, if allowed they would cover the picture they frame.
Definition: TFrame.cxx:145
void Copy(TObject &frame) const
Copy this frame to frame.
Definition: TFrame.cxx:61
virtual ~TFrame()
Frame default destructor.
Definition: TFrame.cxx:54
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TFrame.cxx:79
virtual void Paint(Option_t *option="")
Paint this wbox with its current attributes.
Definition: TFrame.cxx:130
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TFrame.cxx:152
virtual void UseCurrentStyle()
Replace current frame attributes by current style.
Definition: TFrame.cxx:159
virtual void Draw(Option_t *option="")
Draw this frame with its current attributes.
Definition: TFrame.cxx:69
TFrame()
Frame default constructor.
Definition: TFrame.cxx:31
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:105
void SetFrameLineColor(Color_t color=1)
Definition: TStyle.h:350
void SetFrameFillColor(Color_t color=1)
Definition: TStyle.h:349
Bool_t IsReading() const
Definition: TStyle.h:277
Color_t GetFrameLineColor() const
Definition: TStyle.h:213
Style_t GetFrameFillStyle() const
Definition: TStyle.h:214
void SetFrameFillStyle(Style_t styl=0)
Definition: TStyle.h:351
void SetFrameBorderMode(Int_t mode=1)
Definition: TStyle.h:355
Width_t GetFrameBorderSize() const
Definition: TStyle.h:217
void SetFrameLineWidth(Width_t width=1)
Definition: TStyle.h:353
void SetFrameBorderSize(Width_t size=1)
Definition: TStyle.h:354
Style_t GetFrameLineStyle() const
Definition: TStyle.h:215
void SetFrameLineStyle(Style_t styl=0)
Definition: TStyle.h:352
Int_t GetFrameBorderMode() const
Definition: TStyle.h:218
Width_t GetFrameLineWidth() const
Definition: TStyle.h:216
Color_t GetFrameFillColor() const
Definition: TStyle.h:212
A TBox with a bordersize and a bordermode.
Definition: TWbox.h:20
Short_t GetBorderSize() const
Definition: TWbox.h:39
Short_t GetBorderMode() const
Definition: TWbox.h:38
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TWbox.cxx:115
virtual void SetBorderMode(Short_t bordermode)
Definition: TWbox.h:49
virtual void SetBorderSize(Short_t bordersize)
Definition: TWbox.h:50
virtual void Paint(Option_t *option="")
Paint this wbox with its current attributes.
Definition: TWbox.cxx:123
void Copy(TObject &wbox) const
Copy this wbox to wbox.
Definition: TWbox.cxx:84