Logo ROOT  
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 "TVirtualPad.h"
13#include "TFrame.h"
14#include "TStyle.h"
15
17
18/** \class TFrame
19\ingroup BasicGraphics
20
21Define a Frame.
22
23A `TFrame` is a `TWbox` for drawing histogram frames.
24*/
25
26////////////////////////////////////////////////////////////////////////////////
27/// Frame default constructor.
28
30{
31}
32
33////////////////////////////////////////////////////////////////////////////////
34/// Frame normal constructor.
35
37 :TWbox(x1,y1,x2,y2)
38{
39}
40
41////////////////////////////////////////////////////////////////////////////////
42/// Frame copy constructor.
43
44TFrame::TFrame(const TFrame &frame) : TWbox(frame)
45{
46 ((TFrame&)frame).Copy(*this);
47}
48
49////////////////////////////////////////////////////////////////////////////////
50/// Frame default destructor.
51
53{
54}
55
56////////////////////////////////////////////////////////////////////////////////
57/// Copy this frame to frame.
58
59void TFrame::Copy(TObject &frame) const
60{
61 TWbox::Copy(frame);
62}
63
64////////////////////////////////////////////////////////////////////////////////
65/// Draw this frame with its current attributes.
66
68{
69 AppendPad(option);
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Execute action corresponding to one event.
74///
75/// This member function is called when a TFrame object is clicked.
76
78{
79 if (!gPad) return;
80
81 if (!gPad->IsEditable()) return;
82
84
85 Bool_t opaque = gPad->OpaqueMoving();
86
87 if ((event == kButton1Up) || ((opaque)&&(event == kButton1Motion))) {
88 // update pad margins
89 Double_t xmin = gPad->GetUxmin();
90 Double_t xmax = gPad->GetUxmax();
91 Double_t ymin = gPad->GetUymin();
92 Double_t ymax = gPad->GetUymax();
93 Double_t dx = xmax-xmin;
94 Double_t dy = ymax-ymin;
95 Double_t leftMargin = (fX1-gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
96 Double_t topMargin = (gPad->GetY2()-fY2)/(gPad->GetY2()-gPad->GetY1());
97 Double_t rightMargin = (gPad->GetX2()-fX2)/(gPad->GetX2()-gPad->GetX1());
98 Double_t bottomMargin = (fY1-gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
99 // margin may get very small negative values
100 if (leftMargin < 0) leftMargin = 0;
101 if (topMargin < 0) topMargin = 0;
102 if (rightMargin < 0) rightMargin = 0;
103 if (bottomMargin < 0) bottomMargin = 0;
104 gPad->SetLeftMargin(leftMargin);
105 gPad->SetRightMargin(rightMargin);
106 gPad->SetBottomMargin(bottomMargin);
107 gPad->SetTopMargin(topMargin);
108 Double_t dxr = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
109 Double_t dyr = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
110
111 // Range() could change the size of the pad pixmap and therefore should
112 // be called before the other paint routines
113 gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
114 ymin - dyr*gPad->GetBottomMargin(),
115 xmax + dxr*gPad->GetRightMargin(),
116 ymax + dyr*gPad->GetTopMargin());
117 gPad->RangeAxis(xmin, ymin, xmax, ymax);
118 fX1 = xmin;
119 fY1 = ymin;
120 fX2 = xmax;
121 fY2 = ymax;
122 }
123}
124
125////////////////////////////////////////////////////////////////////////////////
126/// Paint this wbox with its current attributes.
127
129{
130 const TPickerStackGuard stackGuard(this);
131
132 if (!gPad->PadInHighlightMode() || (gPad->PadInHighlightMode() && this == gPad->GetSelected())) {
133 TWbox::Paint(option);
134
135 gPad->PaintBox(fX1,fY1,fX2,fY2,"s");
136 }
137
138}
139
140////////////////////////////////////////////////////////////////////////////////
141/// Do not pop frame's, if allowed they would cover the picture they frame.
142
144{
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Save primitive as a C++ statement(s) on output stream out
149
150void TFrame::SavePrimitive(std::ostream &, Option_t * /*= ""*/)
151{
152}
153
154////////////////////////////////////////////////////////////////////////////////
155/// Replace current frame attributes by current style.
156
158{
159 if (gStyle->IsReading()) {
167 } else {
175 }
176}
@ 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:45
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:364
float xmin
Definition: THbookFile.cxx:95
float ymin
Definition: THbookFile.cxx:95
float xmax
Definition: THbookFile.cxx:95
float ymax
Definition: THbookFile.cxx:95
R__EXTERN TStyle * gStyle
Definition: TStyle.h:413
#define gPad
Definition: TVirtualPad.h:288
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:28
Double_t fY2
Y of 2nd point.
Definition: TBox.h:31
Double_t fX2
X of 2nd point.
Definition: TBox.h:30
Double_t fY1
Y of 1st point.
Definition: TBox.h:29
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:143
void Copy(TObject &frame) const
Copy this frame to frame.
Definition: TFrame.cxx:59
virtual ~TFrame()
Frame default destructor.
Definition: TFrame.cxx:52
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TFrame.cxx:77
virtual void Paint(Option_t *option="")
Paint this wbox with its current attributes.
Definition: TFrame.cxx:128
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TFrame.cxx:150
virtual void UseCurrentStyle()
Replace current frame attributes by current style.
Definition: TFrame.cxx:157
virtual void Draw(Option_t *option="")
Draw this frame with its current attributes.
Definition: TFrame.cxx:67
TFrame()
Frame default constructor.
Definition: TFrame.cxx:29
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:107
void SetFrameLineColor(Color_t color=1)
Definition: TStyle.h:356
void SetFrameFillColor(Color_t color=1)
Definition: TStyle.h:355
Bool_t IsReading() const
Definition: TStyle.h:282
Color_t GetFrameLineColor() const
Definition: TStyle.h:217
Style_t GetFrameFillStyle() const
Definition: TStyle.h:218
void SetFrameFillStyle(Style_t styl=0)
Definition: TStyle.h:357
void SetFrameBorderMode(Int_t mode=1)
Definition: TStyle.h:361
Width_t GetFrameBorderSize() const
Definition: TStyle.h:221
void SetFrameLineWidth(Width_t width=1)
Definition: TStyle.h:359
void SetFrameBorderSize(Width_t size=1)
Definition: TStyle.h:360
Style_t GetFrameLineStyle() const
Definition: TStyle.h:219
void SetFrameLineStyle(Style_t styl=0)
Definition: TStyle.h:358
Int_t GetFrameBorderMode() const
Definition: TStyle.h:222
Width_t GetFrameLineWidth() const
Definition: TStyle.h:220
Color_t GetFrameFillColor() const
Definition: TStyle.h:216
A TBox with a bordersize and a bordermode.
Definition: TWbox.h:20
Short_t GetBorderSize() const
Definition: TWbox.h:41
Short_t GetBorderMode() const
Definition: TWbox.h:40
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TWbox.cxx:106
virtual void SetBorderMode(Short_t bordermode)
Definition: TWbox.h:51
virtual void SetBorderSize(Short_t bordersize)
Definition: TWbox.h:52
virtual void Paint(Option_t *option="")
Paint this wbox with its current attributes.
Definition: TWbox.cxx:114
void Copy(TObject &wbox) const
Copy this wbox to wbox.
Definition: TWbox.cxx:75