Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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
16
17/** \class TFrame
18\ingroup BasicGraphics
19
20Define a Frame.
21
22A `TFrame` is a `TWbox` for drawing histogram frames.
23*/
24
25////////////////////////////////////////////////////////////////////////////////
26/// Frame default constructor.
27
29{
30}
31
32////////////////////////////////////////////////////////////////////////////////
33/// Frame normal constructor.
34
36 :TWbox(x1,y1,x2,y2)
37{
38}
39
40////////////////////////////////////////////////////////////////////////////////
41/// Frame copy constructor.
42
43TFrame::TFrame(const TFrame &frame) : TWbox(frame)
44{
45 frame.TFrame::Copy(*this);
46}
47
48////////////////////////////////////////////////////////////////////////////////
49/// Frame default destructor.
50
54
55////////////////////////////////////////////////////////////////////////////////
56/// Copy this frame to frame.
57
58void TFrame::Copy(TObject &frame) const
59{
60 TWbox::Copy(frame);
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// Draw this frame with its current attributes.
65
67{
68 AppendPad(option);
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Execute action corresponding to one event.
73///
74/// This member function is called when a TFrame object is clicked.
75
77{
78 if (!gPad) return;
79
80 if (!gPad->IsEditable()) return;
81
82 TWbox::ExecuteEvent(event, px, py);
83
84 Bool_t opaque = gPad->OpaqueMoving();
85
86 if ((event == kButton1Up) || ((opaque)&&(event == kButton1Motion))) {
87 // update pad margins
88 Double_t xmin = gPad->GetUxmin();
89 Double_t xmax = gPad->GetUxmax();
90 Double_t ymin = gPad->GetUymin();
91 Double_t ymax = gPad->GetUymax();
92 Double_t dx = xmax-xmin;
93 Double_t dy = ymax-ymin;
94 Double_t leftMargin = (fX1-gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
95 Double_t topMargin = (gPad->GetY2()-fY2)/(gPad->GetY2()-gPad->GetY1());
96 Double_t rightMargin = (gPad->GetX2()-fX2)/(gPad->GetX2()-gPad->GetX1());
97 Double_t bottomMargin = (fY1-gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
98 // margin may get very small negative values
99 if (leftMargin < 0) leftMargin = 0;
100 if (topMargin < 0) topMargin = 0;
101 if (rightMargin < 0) rightMargin = 0;
102 if (bottomMargin < 0) bottomMargin = 0;
103 gPad->SetLeftMargin(leftMargin);
104 gPad->SetRightMargin(rightMargin);
105 gPad->SetBottomMargin(bottomMargin);
106 gPad->SetTopMargin(topMargin);
107 Double_t dxr = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
108 Double_t dyr = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
109
110 // Range() could change the size of the pad pixmap and therefore should
111 // be called before the other paint routines
112 gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
113 ymin - dyr*gPad->GetBottomMargin(),
114 xmax + dxr*gPad->GetRightMargin(),
115 ymax + dyr*gPad->GetTopMargin());
116 gPad->RangeAxis(xmin, ymin, xmax, ymax);
117 fX1 = xmin;
118 fY1 = ymin;
119 fX2 = xmax;
120 fY2 = ymax;
121 }
122}
123
124////////////////////////////////////////////////////////////////////////////////
125/// Paint this wbox with its current attributes.
126
128{
129 if (!gPad) return;
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()) {
160 SetFillColor(gStyle->GetFrameFillColor());
161 SetLineColor(gStyle->GetFrameLineColor());
162 SetFillStyle(gStyle->GetFrameFillStyle());
163 SetLineStyle(gStyle->GetFrameLineStyle());
164 SetLineWidth(gStyle->GetFrameLineWidth());
165 SetBorderSize(gStyle->GetFrameBorderSize());
166 SetBorderMode(gStyle->GetFrameBorderMode());
167 } else {
168 gStyle->SetFrameFillColor(GetFillColor());
169 gStyle->SetFrameLineColor(GetLineColor());
170 gStyle->SetFrameFillStyle(GetFillStyle());
171 gStyle->SetFrameLineStyle(GetLineStyle());
172 gStyle->SetFrameLineWidth(GetLineWidth());
173 gStyle->SetFrameBorderSize(GetBorderSize());
174 gStyle->SetFrameBorderMode(GetBorderMode());
175 }
176}
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
float xmin
float ymin
float xmax
float ymax
externTStyle * gStyle
Definition TStyle.h:442
#define gPad
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:32
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:33
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:40
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:42
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:36
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:46
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:38
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:47
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:44
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:37
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
void Pop() override
Do not pop frame's, if allowed they would cover the picture they frame.
Definition TFrame.cxx:143
~TFrame() override
Frame default destructor.
Definition TFrame.cxx:51
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TFrame.cxx:150
void Copy(TObject &frame) const override
Copy this frame to frame.
Definition TFrame.cxx:58
void Draw(Option_t *option="") override
Draw this frame with its current attributes.
Definition TFrame.cxx:66
void Paint(Option_t *option="") override
Paint this wbox with its current attributes.
Definition TFrame.cxx:127
void UseCurrentStyle() override
Replace current frame attributes by current style.
Definition TFrame.cxx:157
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TFrame.cxx:76
TFrame()
Frame default constructor.
Definition TFrame.cxx:28
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:204
TObject()
TObject constructor.
Definition TObject.h:259
Short_t GetBorderSize() const
Definition TWbox.h:41
TWbox()
Definition TWbox.h:27
Short_t GetBorderMode() const
Definition TWbox.h:40
void Paint(Option_t *option="") override
Paint this box with its current attributes.
virtual void SetBorderMode(Short_t bordermode)
Definition TWbox.h:54
virtual void SetBorderSize(Short_t bordersize)
Definition TWbox.h:55
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
void Copy(TObject &wbox) const override
Copy a Box.