From 5270715eb9f35b3dd402d72618c5281e7e39d6aa Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Tue, 5 Jun 2001 11:29:42 +0000
Subject: [PATCH] keep track of title and stat font size. Needed in case of
 fixed font size in pixels.

git-svn-id: http://root.cern.ch/svn/root/trunk@2369 27541ba8-7e3a-0410-8455-c3a389f83636
---
 base/inc/TStyle.h   | 12 ++++++++---
 base/src/TStyle.cxx | 52 ++++++++++++++++++++++++---------------------
 2 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/base/inc/TStyle.h b/base/inc/TStyle.h
index 74c36f78207..86b4e2ac46d 100644
--- a/base/inc/TStyle.h
+++ b/base/inc/TStyle.h
@@ -1,4 +1,4 @@
-// @(#)root/base:$Name:  $:$Id: TStyle.h,v 1.4 2001/04/09 07:53:41 brun Exp $
+// @(#)root/base:$Name:  $:$Id: TStyle.h,v 1.5 2001/05/09 13:27:44 brun Exp $
 // Author: Rene Brun   12/12/94
 
 /*************************************************************************
@@ -113,6 +113,7 @@ private:
         Color_t       fStatTextColor;     //stat text color
         Width_t       fStatBorderSize;    //border size of Stats PaveLabel
         Style_t       fStatFont;          //font style of Stats PaveLabel
+        Float_t       fStatFontSize;      //font size in pixels for fonts with precision type 3
         Style_t       fStatStyle;         //fill area style of Stats PaveLabel
         TString       fStatFormat;        //Printing format for stats
         Float_t       fStatX;             //X position of top right corner of stat box
@@ -123,6 +124,7 @@ private:
         Color_t       fTitleTextColor;    //title text color
         Width_t       fTitleBorderSize;   //border size of Title PavelLabel
         Style_t       fTitleFont;         //font style of Title PaveLabel
+        Float_t       fTitleFontSize;     //font size in pixels for fonts with precision type 3
         Style_t       fTitleStyle;        //fill area style of title PaveLabel
         Float_t       fTitleX;            //X position of top left corner of title box
         Float_t       fTitleY;            //Y position of top left corner of title box
@@ -149,7 +151,7 @@ public:
         virtual void     Copy(TObject &style);
         virtual void     cd();
 
-        static Int_t     CreateGradientColorTable(UInt_t Number, Double_t* Length, 
+        static Int_t     CreateGradientColorTable(UInt_t Number, Double_t* Length,
                               Double_t* Red, Double_t* Green, Double_t* Blue, UInt_t NColors);
         Int_t            GetNdivisions(Option_t *axis="X") const;
         TAttText        *GetAttDate() {return &fAttDate;}
@@ -225,6 +227,7 @@ public:
         Color_t          GetStatTextColor() const {return fStatTextColor;}
         Width_t          GetStatBorderSize() const {return fStatBorderSize;}
         Style_t          GetStatFont() const  {return fStatFont;}
+        Float_t          GetStatFontSize() const  {return fStatFontSize;}
         Style_t          GetStatStyle() const  {return fStatStyle;}
         const char      *GetStatFormat() const {return fStatFormat.Data();}
         Float_t          GetStatX() const     {return fStatX;}
@@ -236,6 +239,7 @@ public:
         Color_t          GetTitleTextColor() const {return fTitleTextColor;}  //return histogram title text color
         Style_t          GetTitleStyle() const  {return fTitleStyle;}
         Style_t          GetTitleFont() const  {return fTitleFont;} //return histogram title font
+        Float_t          GetTitleFontSize() const  {return fTitleFontSize;} //return histogram title font size
         Width_t          GetTitleBorderSize() const {return fTitleBorderSize;} //return border size of histogram title TPaveLabel
         Float_t          GetTitleXOffset() const {return GetTitleOffset("X");} //return X axis title offset
         Float_t          GetTitleXSize() const   {return GetTitleSize("X");}   //return X axis title size
@@ -324,6 +328,7 @@ public:
         void             SetStatStyle(Style_t style=1001) {fStatStyle=style;}
         void             SetStatBorderSize(Width_t size=2) {fStatBorderSize=size;}
         void             SetStatFont(Style_t font=62) {fStatFont=font;}
+        void             SetStatFontSize(Float_t size=0)  {fStatFontSize=size;}
         void             SetStatFormat(const char *format="6.4g") {fStatFormat = format;}
         void             SetStatX(Float_t x=0)    {fStatX=x;}
         void             SetStatY(Float_t y=0)    {fStatY=y;}
@@ -334,6 +339,7 @@ public:
         void             SetTitleTextColor(Int_t color=1)   {fTitleTextColor=color;}
         void             SetTitleStyle(Style_t style=1001)  {fTitleStyle=style;}
         void             SetTitleFont(Style_t font=62)      {fTitleFont=font;}
+        void             SetTitleFontSize(Float_t size=0)   {fTitleFontSize=size;}
         void             SetTitleBorderSize(Width_t size=2) {fTitleBorderSize=size;}
         void             SetTitleXOffset(Float_t offset=1)  {SetTitleOffset(offset,"X");}
         void             SetTitleXSize(Float_t size=0.02)   {SetTitleSize(size,"X");}
@@ -346,7 +352,7 @@ public:
         void             ToggleEventStatus() { fShowEventStatus = fShowEventStatus ? 0 : 1; }
         void             SetPalette(Int_t ncolors=0, Int_t *colors=0);
 
-        ClassDef(TStyle,4)  //A collection of all graphics attributes
+        ClassDef(TStyle,5)  //A collection of all graphics attributes
 };
 
 
diff --git a/base/src/TStyle.cxx b/base/src/TStyle.cxx
index 623e10d222c..bf7b7b1b43c 100644
--- a/base/src/TStyle.cxx
+++ b/base/src/TStyle.cxx
@@ -1,4 +1,4 @@
-// @(#)root/base:$Name:  $:$Id: TStyle.cxx,v 1.7 2001/01/30 11:29:27 brun Exp $
+// @(#)root/base:$Name:  $:$Id: TStyle.cxx,v 1.8 2001/05/09 13:27:44 brun Exp $
 // Author: Rene Brun   12/12/94
 
 /*************************************************************************
@@ -21,7 +21,7 @@
 TStyle  *gStyle;
 
 ClassImp(TStyle)
-   
+
 
 //______________________________________________________________________________
 //
@@ -269,6 +269,7 @@ void TStyle::Copy(TObject &obj)
    ((TStyle&)obj).fStatTextColor  = fStatTextColor;
    ((TStyle&)obj).fStatBorderSize = fStatBorderSize;
    ((TStyle&)obj).fStatFont       = fStatFont;
+   ((TStyle&)obj).fStatFontSize   = fStatFontSize;
    ((TStyle&)obj).fStatStyle      = fStatStyle;
    ((TStyle&)obj).fStatFormat     = fStatFormat;
    ((TStyle&)obj).fStatW          = fStatW;
@@ -278,6 +279,7 @@ void TStyle::Copy(TObject &obj)
    ((TStyle&)obj).fTitleColor     = fTitleColor;
    ((TStyle&)obj).fTitleTextColor = fTitleTextColor;
    ((TStyle&)obj).fTitleFont      = fTitleFont;
+   ((TStyle&)obj).fTitleFontSize  = fTitleFontSize;
    ((TStyle&)obj).fTitleStyle     = fTitleStyle;
    ((TStyle&)obj).fTitleBorderSize= fTitleBorderSize;
    ((TStyle&)obj).fTitleW         = fTitleW;
@@ -370,6 +372,7 @@ void TStyle::Reset(Option_t *)
    fStatTextColor  = 1;
    fStatBorderSize = 2;
    fStatFont       = 62;
+   fStatFontSize   = 0;
    fStatStyle      = 1001;
    fStatW          = 0.20;
    fStatH          = 0.16;
@@ -380,6 +383,7 @@ void TStyle::Reset(Option_t *)
    fTitleColor     = fCanvasColor;
    fTitleTextColor = 1;
    fTitleFont      = 62;
+   fTitleFontSize  = 0;
    fTitleStyle     = 1001;
    fTitleBorderSize= 2;
    fTitleW         = 0;
@@ -790,7 +794,7 @@ void TStyle::SetPaperSize(Float_t xsize, Float_t ysize)
    // Set paper size for PostScript output.
    // The paper size is specified in centimeters. Default is 20x26.
    // See also TPad::Print
-   
+
    fPaperSizeX = xsize;
    fPaperSizeY = ysize;
 }
@@ -847,19 +851,19 @@ void TStyle::SetTitleSize(Float_t size, Option_t *axis)
 }
 
 //______________________________________________________________________________
-Int_t TStyle::CreateGradientColorTable(UInt_t Number, Double_t* Length, 
-                              Double_t* Red, Double_t* Green, 
+Int_t TStyle::CreateGradientColorTable(UInt_t Number, Double_t* Length,
+                              Double_t* Red, Double_t* Green,
                               Double_t* Blue, UInt_t NColors)
 {
   // STATIC function.
-  // Linear gradient color table: 
+  // Linear gradient color table:
   // Red, Green and Blue are several RGB colors with values from 0.0 .. 1.0.
   // Their number is "Intervals".
   // Length is the length of the color interval between the RGB-colors:
   // Imaging the whole gradient goes from 0.0 for the first RGB color to 1.0
-  // for the last RGB color, then each "Length"-entry in between stands for 
+  // for the last RGB color, then each "Length"-entry in between stands for
   // the length of the intervall between the according RGB colors.
-  // 
+  //
   // This definition is similar to the povray-definition of gradient
   // color tables.
   //
@@ -869,13 +873,13 @@ Int_t TStyle::CreateGradientColorTable(UInt_t Number, Double_t* Length,
   // > Double_t Red[5]   = { 0.00, 0.09, 0.18, 0.09, 0.00 };
   // > Double_t Green[5] = { 0.01, 0.02, 0.39, 0.68, 0.97 };
   // > Double_t Blue[5]  = { 0.17, 0.39, 0.62, 0.79, 0.97 };
-  // Define the length of the (color)-interval between this points 
+  // Define the length of the (color)-interval between this points
   // > Double_t Stops[5] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
-  // i.e. the color interval between Color 2 and Color 3 is 
+  // i.e. the color interval between Color 2 and Color 3 is
   // 0.79 - 0.62 => 17 % of the total palette area between these colors
   //
   //  Original code by Andreas Zoglauer <zog@mpe.mpg.de>
-  
+
   UInt_t g, c;
   UInt_t NPalette = 0;
   Int_t *Palette = new Int_t[NColors+1];
@@ -883,12 +887,12 @@ Int_t TStyle::CreateGradientColorTable(UInt_t Number, Double_t* Length,
   TColor *Color;
   Int_t HighestIndex = 0;
 
-  // Check if all RGB values are between 0.0 and 1.0 and 
+  // Check if all RGB values are between 0.0 and 1.0 and
   // Length goes from 0.0 to 1.0 in increasing order.
   for (c = 0; c < Number; c++) {
-    if (Red[c] < 0 || Red[c] > 1.0 || 
-        Green[c] < 0 || Green[c] > 1.0 || 
-        Blue[c] < 0 || Blue[c] > 1.0 || 
+    if (Red[c] < 0 || Red[c] > 1.0 ||
+        Green[c] < 0 || Green[c] > 1.0 ||
+        Blue[c] < 0 || Blue[c] > 1.0 ||
         Length[c] < 0 || Length[c] > 1.0) {
       //Error("CreateGradientColorTable",
       //      "All RGB colors and interval lengths have to be between 0.0 and 1.0");
@@ -902,7 +906,7 @@ Int_t TStyle::CreateGradientColorTable(UInt_t Number, Double_t* Length,
         delete [] Palette;
         return -1;
       }
-    } 
+    }
   }
 
   // Search for the highest color index not used in ROOT:
@@ -920,14 +924,14 @@ Int_t TStyle::CreateGradientColorTable(UInt_t Number, Double_t* Length,
   }
   HighestIndex++;
 
-  // Now create the colors and add them to the default palette:  
-  
+  // Now create the colors and add them to the default palette:
+
   // For each defined gradient...
   for (g = 1; g < Number; g++) {
     // create the colors...
     NColorsGradient = (Int_t) (floor(NColors*Length[g]) - floor(NColors*Length[g-1]));
     for (c = 0; c < NColorsGradient; c++) {
-      Color = new TColor(HighestIndex, 
+      Color = new TColor(HighestIndex,
                          Red[g-1] + c * (Red[g] - Red[g-1])/ NColorsGradient,
                          Green[g-1] + c * (Green[g] - Green[g-1])/ NColorsGradient,
                          Blue[g-1] + c * (Blue[g] - Blue[g-1])/ NColorsGradient,
@@ -937,10 +941,10 @@ Int_t TStyle::CreateGradientColorTable(UInt_t Number, Double_t* Length,
       HighestIndex++;
     }
   }
-  
+
   gStyle->SetPalette(NPalette, Palette);
   delete [] Palette;
-  
+
   return HighestIndex - NColors;
 }
 
@@ -993,7 +997,7 @@ void TStyle::SetPalette(Int_t ncolors, Int_t *colors)
       for (i=0;i<ncolors;i++) fPalette.fArray[i] = palette[i];
       return;
    }
-   
+
    // set Pretty Palette Spectrum Violet->Red
    if (ncolors == 1 && colors == 0) {
       ncolors = 50;
@@ -1001,7 +1005,7 @@ void TStyle::SetPalette(Int_t ncolors, Int_t *colors)
       for (i=0;i<ncolors;i++) fPalette.fArray[i] = 51+i;
       return;
    }
-   
+
    // set DeepSea palette
    if (colors == 0 && ncolors > 50) {
       const Int_t NRGBs = 5;
@@ -1012,7 +1016,7 @@ void TStyle::SetPalette(Int_t ncolors, Int_t *colors)
       CreateGradientColorTable(NRGBs, Stops, Red, Green, Blue, ncolors);
       return;
    }
-   
+
    // set user defined palette
    fPalette.Set(ncolors);
    if (colors)  for (i=0;i<ncolors;i++) fPalette.fArray[i] = colors[i];
-- 
GitLab