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
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 frame.TFrame::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{
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 if (!gPad) return;
131 const TPickerStackGuard stackGuard(this);
132
133 if (!gPad->PadInHighlightMode() || (gPad->PadInHighlightMode() && this == gPad->GetSelected())) {
135
136 gPad->PaintBox(fX1,fY1,fX2,fY2,"s");
137 }
138
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Do not pop frame's, if allowed they would cover the picture they frame.
143
145{
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Save primitive as a C++ statement(s) on output stream out
150
151void TFrame::SavePrimitive(std::ostream &, Option_t * /*= ""*/)
152{
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Replace current frame attributes by current style.
157
159{
160 if (gStyle->IsReading()) {
168 } else {
176 }
177}
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
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:433
#define gPad
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 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 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
void Pop() override
Do not pop frame's, if allowed they would cover the picture they frame.
Definition TFrame.cxx:144
~TFrame() override
Frame default destructor.
Definition TFrame.cxx:52
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TFrame.cxx:151
void Copy(TObject &frame) const override
Copy this frame to frame.
Definition TFrame.cxx:59
void Draw(Option_t *option="") override
Draw this frame with its current attributes.
Definition TFrame.cxx:67
void Paint(Option_t *option="") override
Paint this wbox with its current attributes.
Definition TFrame.cxx:128
void UseCurrentStyle() override
Replace current frame attributes by current style.
Definition TFrame.cxx:158
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TFrame.cxx:77
TFrame()
Frame default constructor.
Definition TFrame.cxx:29
Mother of all ROOT objects.
Definition TObject.h:41
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:184
void SetFrameLineColor(Color_t color=1)
Definition TStyle.h:370
void SetFrameFillColor(Color_t color=1)
Definition TStyle.h:369
Bool_t IsReading() const
Definition TStyle.h:294
Color_t GetFrameLineColor() const
Definition TStyle.h:224
Style_t GetFrameFillStyle() const
Definition TStyle.h:225
void SetFrameFillStyle(Style_t styl=0)
Definition TStyle.h:371
void SetFrameBorderMode(Int_t mode=1)
Definition TStyle.h:375
Width_t GetFrameBorderSize() const
Definition TStyle.h:228
void SetFrameLineWidth(Width_t width=1)
Definition TStyle.h:373
void SetFrameBorderSize(Width_t size=1)
Definition TStyle.h:374
Style_t GetFrameLineStyle() const
Definition TStyle.h:226
void SetFrameLineStyle(Style_t styl=0)
Definition TStyle.h:372
Int_t GetFrameBorderMode() const
Definition TStyle.h:229
Width_t GetFrameLineWidth() const
Definition TStyle.h:227
Color_t GetFrameFillColor() const
Definition TStyle.h:223
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:115
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:107
void Copy(TObject &wbox) const override
Copy this wbox to wbox.
Definition TWbox.cxx:75