Size of TGLabel (and TGButton)

Mathieu de Naurois (denauroi@polhp1.in2p3.fr)
Thu, 1 Oct 1998 15:27:22 +0200 (METDST)


Hello Rooters,

In the Layout mechanisms (of Dialog windows), the function GetDefaultSize
is called for each Widget in the frame.

This function is usually defined as (in TGFrame)

TGDimension GetSize() const { return TGDimension(fWidth, fHeight); }

But, TGlabel redefines this function as:

virtual TGDimension GetDefaultSize() const
{ return TGDimension(fTWidth, fTHeight+1); }

And the function Resize does NOT change fTWidth and fTHeight, but just
fWidth and fHeight.

The consequence is:

Even if you resize the widget with a call to the Resize function, the
Layout algorithm will resize it to its default size, that is, to the size
of the text inside. I wanted many TGLabel's to have the same size, so I
can align then on the right (with right justification of the text). The
only solution I found was to created a new classe, derived from TGLabel,
and restoring the GetDimension function to its original value.

Here is my question:

Is there any reason to redefine the GetDefaultSize function in TGLabel
(and also in TGButton and derived classes)? And if yes, how can I change
the size of a Label? (One can imagine to refine the Resize function.)

Thank you.

-----------------------------------------------------
Mathieu de Naurois
LPNHE Ecole Polytechnique
denauroi@polhp1.in2p3.fr