00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "Riostream.h"
00013 #include "TROOT.h"
00014 #include "TVirtualPad.h"
00015 #include "TFrame.h"
00016 #include "TStyle.h"
00017
00018 ClassImp(TFrame)
00019
00020
00021
00022
00023
00024
00025
00026 TFrame::TFrame(): TWbox()
00027 {
00028
00029
00030 }
00031
00032
00033 TFrame::TFrame(Double_t x1, Double_t y1,Double_t x2, Double_t y2)
00034 :TWbox(x1,y1,x2,y2)
00035 {
00036
00037
00038 }
00039
00040
00041 TFrame::TFrame(const TFrame &frame) : TWbox(frame)
00042 {
00043
00044
00045 ((TFrame&)frame).Copy(*this);
00046 }
00047
00048
00049 TFrame::~TFrame()
00050 {
00051
00052
00053 }
00054
00055
00056 void TFrame::Copy(TObject &frame) const
00057 {
00058
00059
00060 TWbox::Copy(frame);
00061 }
00062
00063
00064 void TFrame::Draw(Option_t *option)
00065 {
00066
00067
00068 AppendPad(option);
00069 }
00070
00071
00072 void TFrame::ExecuteEvent(Int_t event, Int_t px, Int_t py)
00073 {
00074
00075
00076
00077
00078 if (!gPad->IsEditable()) return;
00079
00080 TWbox::ExecuteEvent(event, px, py);
00081
00082 if (event != kButton1Up) return;
00083
00084 Double_t xmin = gPad->GetUxmin();
00085 Double_t xmax = gPad->GetUxmax();
00086 Double_t ymin = gPad->GetUymin();
00087 Double_t ymax = gPad->GetUymax();
00088 Double_t dx = xmax-xmin;
00089 Double_t dy = ymax-ymin;
00090 Double_t leftMargin = (fX1-gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
00091 Double_t topMargin = (gPad->GetY2()-fY2)/(gPad->GetY2()-gPad->GetY1());
00092 Double_t rightMargin = (gPad->GetX2()-fX2)/(gPad->GetX2()-gPad->GetX1());
00093 Double_t bottomMargin = (fY1-gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
00094
00095 if (leftMargin < 0) leftMargin = 0;
00096 if (topMargin < 0) topMargin = 0;
00097 if (rightMargin < 0) rightMargin = 0;
00098 if (bottomMargin < 0) bottomMargin = 0;
00099 gPad->SetLeftMargin(leftMargin);
00100 gPad->SetRightMargin(rightMargin);
00101 gPad->SetBottomMargin(bottomMargin);
00102 gPad->SetTopMargin(topMargin);
00103 Double_t dxr = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
00104 Double_t dyr = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
00105
00106
00107
00108 gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
00109 ymin - dyr*gPad->GetBottomMargin(),
00110 xmax + dxr*gPad->GetRightMargin(),
00111 ymax + dyr*gPad->GetTopMargin());
00112 gPad->RangeAxis(xmin, ymin, xmax, ymax);
00113 fX1 = xmin;
00114 fY1 = ymin;
00115 fX2 = xmax;
00116 fY2 = ymax;
00117 }
00118
00119
00120 void TFrame::Paint(Option_t *option)
00121 {
00122
00123
00124 TWbox::Paint(option);
00125
00126 gPad->PaintBox(fX1,fY1,fX2,fY2,"s");
00127 }
00128
00129
00130 void TFrame::Pop()
00131 {
00132
00133 }
00134
00135
00136 void TFrame::SavePrimitive(ostream &, Option_t * )
00137 {
00138
00139
00140 }
00141
00142
00143 void TFrame::UseCurrentStyle()
00144 {
00145
00146
00147 if (gStyle->IsReading()) {
00148 SetFillColor(gStyle->GetFrameFillColor());
00149 SetLineColor(gStyle->GetFrameLineColor());
00150 SetFillStyle(gStyle->GetFrameFillStyle());
00151 SetLineStyle(gStyle->GetFrameLineStyle());
00152 SetLineWidth(gStyle->GetFrameLineWidth());
00153 SetBorderSize(gStyle->GetFrameBorderSize());
00154 SetBorderMode(gStyle->GetFrameBorderMode());
00155 } else {
00156 gStyle->SetFrameFillColor(GetFillColor());
00157 gStyle->SetFrameLineColor(GetLineColor());
00158 gStyle->SetFrameFillStyle(GetFillStyle());
00159 gStyle->SetFrameLineStyle(GetLineStyle());
00160 gStyle->SetFrameLineWidth(GetLineWidth());
00161 gStyle->SetFrameBorderSize(GetBorderSize());
00162 gStyle->SetFrameBorderMode(GetBorderMode());
00163 }
00164 }