Hi Mathieu, to do what you want, i.e. equal sized labels and buttons, use the right layout manager options when putting the buttons in the frames. For an example see: http://root.cern.ch/root/html/src/TRootDialog.cxx.html#TRootDialog:Popup where three buttons (OK, Apply and Cancel) are layed out with the same size. Notice how TGLayoutHints *l1 = new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 5, 5, 0, 0); is used to make equal sized widgets evenly spaced in X. I am a bit reluctant to change the default behaviour since it might break the look of many GUI's. Cheers, Fons. Mathieu de Naurois wrote: > > 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 -- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland Phone: +41 22 7679248 E-Mail: Fons.Rademakers@cern.ch Fax: +41 22 7677910
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:38 MET