From 5648a8132e0f786b4ab2ee23dda7cb8f0961900d Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Tue, 26 Sep 2006 08:05:44 +0000
Subject: [PATCH] From Matevz: Resize ged-name-frame to fit within the
 editor-canvas; fixed a compilation warning.

git-svn-id: http://root.cern.ch/svn/root/trunk@16343 27541ba8-7e3a-0410-8455-c3a389f83636
---
 ged/src/TGedFrame.cxx | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/ged/src/TGedFrame.cxx b/ged/src/TGedFrame.cxx
index c9c20b4ac03..61620194ee5 100644
--- a/ged/src/TGedFrame.cxx
+++ b/ged/src/TGedFrame.cxx
@@ -1,4 +1,4 @@
-// @(#)root/ged:$Name:  $:$Id: TGedFrame.cxx,v 1.13 2006/07/26 13:36:42 rdm Exp $
+// @(#)root/ged:$Name:  $:$Id: TGedFrame.cxx,v 1.14 2006/09/25 13:32:57 rdm Exp $
 // Author: Ilka Antcheva   10/05/04
  
 /*************************************************************************
@@ -24,7 +24,8 @@
 #include "TCanvas.h"
 #include "TGLabel.h"
 #include "TGToolTip.h"
-#include "TGTab.h"
+#include "TGCanvas.h"
+#include "TGScrollBar.h"
 #include <snprintf.h>
 
 
@@ -191,8 +192,7 @@ TGedNameFrame::TGedNameFrame(const TGWindow *p, Int_t width,
                 new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
    AddFrame(f1, new TGLayoutHints(kLHintsTop));
 
-   f2 = new TGCompositeFrame(this, 140, 20, kHorizontalFrame |
-                                            kFixedWidth);
+   f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame | kFixedWidth);
    fLabel = new TGLabel(f2, "");
    f2->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
    AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
@@ -230,7 +230,7 @@ Bool_t TGedNameFrame::HandleCrossing(Event_t *event)
 }
 
 //______________________________________________________________________________
-Bool_t TGedNameFrame::HandleButton(Event_t *event)
+Bool_t TGedNameFrame::HandleButton(Event_t */*event*/)
 {
    // Handle mouse button event.
 
@@ -239,7 +239,6 @@ Bool_t TGedNameFrame::HandleButton(Event_t *event)
    return kFALSE;
 }
 
-
 //______________________________________________________________________________
 void TGedNameFrame::SetModel(TObject* obj)
 {
@@ -258,4 +257,15 @@ void TGedNameFrame::SetModel(TObject* obj)
    fLabel->SetText(new TGString(string));
    string = Form("Name: '%s'; Title: '%s'; Class: '%s'", obj->GetName(), obj->GetTitle(), obj->ClassName());
    fTip->SetText(string);
+
+   // Resize label-frame to a reasonable width.
+   {
+      TGCanvas     *canvas = fGedEditor->GetTGCanvas();
+      TGVScrollBar *vsb    = canvas->GetVScrollbar();
+      
+      Int_t hscrollw = (vsb && vsb->IsMapped()) ? vsb->GetWidth() : 0;
+      Int_t labwidth = TMath::Min(fLabel->GetDefaultSize().fWidth,
+                                  canvas->GetWidth() - 10 - hscrollw);
+      f2->SetWidth(TMath::Max(labwidth, 80));
+   }
 }
-- 
GitLab