ROOT logo
// @(#)root/graf:$Id: TFrame.cxx 20882 2007-11-19 11:31:26Z rdm $
// Author: Rene Brun   31/10/96

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "Riostream.h"
#include "TROOT.h"
#include "TVirtualPad.h"
#include "TFrame.h"
#include "TStyle.h"

ClassImp(TFrame)

//______________________________________________________________________________
//
// a TFrame is a TWbox for drawing histogram frames.
//

//______________________________________________________________________________
TFrame::TFrame(): TWbox()
{
   // Frame default constructor.

}

//______________________________________________________________________________
TFrame::TFrame(Double_t x1, Double_t y1,Double_t x2, Double_t  y2)
       :TWbox(x1,y1,x2,y2)
{
   // Frame normal constructor.

}

//______________________________________________________________________________
TFrame::TFrame(const TFrame &frame) : TWbox(frame)
{
   // Frame copy constructor.

   ((TFrame&)frame).Copy(*this);
}

//______________________________________________________________________________
TFrame::~TFrame()
{
   // Frame default destructor.

}

//______________________________________________________________________________
void TFrame::Copy(TObject &frame) const
{
   // Copy this frame to frame.

   TWbox::Copy(frame);
}

//______________________________________________________________________________
void TFrame::Draw(Option_t *option)
{
   // Draw this frame with its current attributes.

   AppendPad(option);
}

//______________________________________________________________________________
void TFrame::ExecuteEvent(Int_t event, Int_t px, Int_t py)
{
   // Execute action corresponding to one event.
   //
   //  This member function is called when a TFrame object is clicked.

   if (!gPad->IsEditable()) return;

   TWbox::ExecuteEvent(event, px, py);

   if (event != kButton1Up) return;
   // update pad margins
   Double_t xmin         = gPad->GetUxmin();
   Double_t xmax         = gPad->GetUxmax();
   Double_t ymin         = gPad->GetUymin();
   Double_t ymax         = gPad->GetUymax();
   Double_t dx           = xmax-xmin;
   Double_t dy           = ymax-ymin;
   Double_t leftMargin   = (fX1-gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
   Double_t topMargin    = (gPad->GetY2()-fY2)/(gPad->GetY2()-gPad->GetY1());
   Double_t rightMargin  = (gPad->GetX2()-fX2)/(gPad->GetX2()-gPad->GetX1());
   Double_t bottomMargin = (fY1-gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
   // margin may get very small negative values
   if (leftMargin   < 0) leftMargin   = 0;
   if (topMargin    < 0) topMargin    = 0;
   if (rightMargin  < 0) rightMargin  = 0;
   if (bottomMargin < 0) bottomMargin = 0;
   gPad->SetLeftMargin(leftMargin);
   gPad->SetRightMargin(rightMargin);
   gPad->SetBottomMargin(bottomMargin);
   gPad->SetTopMargin(topMargin);
   Double_t dxr  = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
   Double_t dyr  = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());

   // Range() could change the size of the pad pixmap and therefore should
   // be called before the other paint routines
   gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
                      ymin - dyr*gPad->GetBottomMargin(),
                      xmax + dxr*gPad->GetRightMargin(),
                      ymax + dyr*gPad->GetTopMargin());
   gPad->RangeAxis(xmin, ymin, xmax, ymax);
   fX1 = xmin;
   fY1 = ymin;
   fX2 = xmax;
   fY2 = ymax;
}

//______________________________________________________________________________
void TFrame::Paint(Option_t *option)
{
   // Paint this wbox with its current attributes.

   TWbox::Paint(option);
      
   gPad->PaintBox(fX1,fY1,fX2,fY2,"s");
}

//______________________________________________________________________________
void TFrame::Pop()
{
   // Do not pop frame's, if allowed they would cover the picture they frame.
}

//______________________________________________________________________________
void TFrame::SavePrimitive(ostream &, Option_t * /*= ""*/)
{
    // Save primitive as a C++ statement(s) on output stream out

}

//______________________________________________________________________________
void TFrame::UseCurrentStyle()
{
   // Replace current frame attributes by current style.

   if (gStyle->IsReading()) {
      SetFillColor(gStyle->GetFrameFillColor());
      SetLineColor(gStyle->GetFrameLineColor());
      SetFillStyle(gStyle->GetFrameFillStyle());
      SetLineStyle(gStyle->GetFrameLineStyle());
      SetLineWidth(gStyle->GetFrameLineWidth());
      SetBorderSize(gStyle->GetFrameBorderSize());
      SetBorderMode(gStyle->GetFrameBorderMode());
   } else {
      gStyle->SetFrameFillColor(GetFillColor());
      gStyle->SetFrameLineColor(GetLineColor());
      gStyle->SetFrameFillStyle(GetFillStyle());
      gStyle->SetFrameLineStyle(GetLineStyle());
      gStyle->SetFrameLineWidth(GetLineWidth());
      gStyle->SetFrameBorderSize(GetBorderSize());
      gStyle->SetFrameBorderMode(GetBorderMode());
   }
}
 TFrame.cxx:1
 TFrame.cxx:2
 TFrame.cxx:3
 TFrame.cxx:4
 TFrame.cxx:5
 TFrame.cxx:6
 TFrame.cxx:7
 TFrame.cxx:8
 TFrame.cxx:9
 TFrame.cxx:10
 TFrame.cxx:11
 TFrame.cxx:12
 TFrame.cxx:13
 TFrame.cxx:14
 TFrame.cxx:15
 TFrame.cxx:16
 TFrame.cxx:17
 TFrame.cxx:18
 TFrame.cxx:19
 TFrame.cxx:20
 TFrame.cxx:21
 TFrame.cxx:22
 TFrame.cxx:23
 TFrame.cxx:24
 TFrame.cxx:25
 TFrame.cxx:26
 TFrame.cxx:27
 TFrame.cxx:28
 TFrame.cxx:29
 TFrame.cxx:30
 TFrame.cxx:31
 TFrame.cxx:32
 TFrame.cxx:33
 TFrame.cxx:34
 TFrame.cxx:35
 TFrame.cxx:36
 TFrame.cxx:37
 TFrame.cxx:38
 TFrame.cxx:39
 TFrame.cxx:40
 TFrame.cxx:41
 TFrame.cxx:42
 TFrame.cxx:43
 TFrame.cxx:44
 TFrame.cxx:45
 TFrame.cxx:46
 TFrame.cxx:47
 TFrame.cxx:48
 TFrame.cxx:49
 TFrame.cxx:50
 TFrame.cxx:51
 TFrame.cxx:52
 TFrame.cxx:53
 TFrame.cxx:54
 TFrame.cxx:55
 TFrame.cxx:56
 TFrame.cxx:57
 TFrame.cxx:58
 TFrame.cxx:59
 TFrame.cxx:60
 TFrame.cxx:61
 TFrame.cxx:62
 TFrame.cxx:63
 TFrame.cxx:64
 TFrame.cxx:65
 TFrame.cxx:66
 TFrame.cxx:67
 TFrame.cxx:68
 TFrame.cxx:69
 TFrame.cxx:70
 TFrame.cxx:71
 TFrame.cxx:72
 TFrame.cxx:73
 TFrame.cxx:74
 TFrame.cxx:75
 TFrame.cxx:76
 TFrame.cxx:77
 TFrame.cxx:78
 TFrame.cxx:79
 TFrame.cxx:80
 TFrame.cxx:81
 TFrame.cxx:82
 TFrame.cxx:83
 TFrame.cxx:84
 TFrame.cxx:85
 TFrame.cxx:86
 TFrame.cxx:87
 TFrame.cxx:88
 TFrame.cxx:89
 TFrame.cxx:90
 TFrame.cxx:91
 TFrame.cxx:92
 TFrame.cxx:93
 TFrame.cxx:94
 TFrame.cxx:95
 TFrame.cxx:96
 TFrame.cxx:97
 TFrame.cxx:98
 TFrame.cxx:99
 TFrame.cxx:100
 TFrame.cxx:101
 TFrame.cxx:102
 TFrame.cxx:103
 TFrame.cxx:104
 TFrame.cxx:105
 TFrame.cxx:106
 TFrame.cxx:107
 TFrame.cxx:108
 TFrame.cxx:109
 TFrame.cxx:110
 TFrame.cxx:111
 TFrame.cxx:112
 TFrame.cxx:113
 TFrame.cxx:114
 TFrame.cxx:115
 TFrame.cxx:116
 TFrame.cxx:117
 TFrame.cxx:118
 TFrame.cxx:119
 TFrame.cxx:120
 TFrame.cxx:121
 TFrame.cxx:122
 TFrame.cxx:123
 TFrame.cxx:124
 TFrame.cxx:125
 TFrame.cxx:126
 TFrame.cxx:127
 TFrame.cxx:128
 TFrame.cxx:129
 TFrame.cxx:130
 TFrame.cxx:131
 TFrame.cxx:132
 TFrame.cxx:133
 TFrame.cxx:134
 TFrame.cxx:135
 TFrame.cxx:136
 TFrame.cxx:137
 TFrame.cxx:138
 TFrame.cxx:139
 TFrame.cxx:140
 TFrame.cxx:141
 TFrame.cxx:142
 TFrame.cxx:143
 TFrame.cxx:144
 TFrame.cxx:145
 TFrame.cxx:146
 TFrame.cxx:147
 TFrame.cxx:148
 TFrame.cxx:149
 TFrame.cxx:150
 TFrame.cxx:151
 TFrame.cxx:152
 TFrame.cxx:153
 TFrame.cxx:154
 TFrame.cxx:155
 TFrame.cxx:156
 TFrame.cxx:157
 TFrame.cxx:158
 TFrame.cxx:159
 TFrame.cxx:160
 TFrame.cxx:161
 TFrame.cxx:162
 TFrame.cxx:163
 TFrame.cxx:164