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
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
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();
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())) {
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
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t option
Option_t Option_t SetLineWidth
Option_t Option_t SetFillStyle
Option_t Option_t SetLineColor
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char y1
float xmin
float ymin
float xmax
float ymax
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
#define gPad
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:31
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:32
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:35
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:44
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:37
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:36
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
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
Mother of all ROOT objects.
Definition TObject.h:41
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
void SetFrameLineColor(Color_t color=1)
Definition TStyle.h:377
void SetFrameFillColor(Color_t color=1)
Definition TStyle.h:376
Bool_t IsReading() const
Definition TStyle.h:300
Color_t GetFrameLineColor() const
Definition TStyle.h:228
Style_t GetFrameFillStyle() const
Definition TStyle.h:229
void SetFrameFillStyle(Style_t styl=0)
Definition TStyle.h:378
void SetFrameBorderMode(Int_t mode=1)
Definition TStyle.h:382
Width_t GetFrameBorderSize() const
Definition TStyle.h:232
void SetFrameLineWidth(Width_t width=1)
Definition TStyle.h:380
void SetFrameBorderSize(Width_t size=1)
Definition TStyle.h:381
Style_t GetFrameLineStyle() const
Definition TStyle.h:230
void SetFrameLineStyle(Style_t styl=0)
Definition TStyle.h:379
Int_t GetFrameBorderMode() const
Definition TStyle.h:233
Width_t GetFrameLineWidth() const
Definition TStyle.h:231
Color_t GetFrameFillColor() const
Definition TStyle.h:227
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
void Paint(Option_t *option="") override
Paint this wbox with its current attributes.
Definition TWbox.cxx:114
virtual void SetBorderMode(Short_t bordermode)
Definition TWbox.h:51
virtual void SetBorderSize(Short_t bordersize)
Definition TWbox.h:52
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TWbox.cxx:106
void Copy(TObject &wbox) const override
Copy this wbox to wbox.
Definition TWbox.cxx:74