Re: Changing font sizes

From: Onuchin Valeriy (onuchin@sirius.ihep.su)
Date: Fri Jul 16 1999 - 14:09:02 MEST


Laurent.Aphecetche@subatech.in2p3.fr wrote:
> Hi,
> 
> I know that using the .rootrc resources Gui.xFont (where
> x=Bold,Normal,Small or Proportional) one
>  can change the default fonts used by the TG* Classes.
> 
>  What I would like to know is if it's possible to dynamically change the
> fonts of widgets that are
>  already shown in a window. The functionality I would like to have is
> the following : having all the
>  labels, texts, and so on becoming either bigger or smaller when I click
> on a button. Is that possible ?
> 
> Thanks.

 There is nothing impossible because you can overload TG* Classses
methods.

 The following is an example how to implement the button with 2-state
(On/Off) pictures.
(for example Qt's QToolButton = http://www.troll.no/qt/qtoolbutton.html  
can be displayed as one of the 6 pictures
smallOff,smallOn,smallDisabled,largeOn,largeOff,largeDisabled )

////////////////////////////////////////////////////////////////////////////// 
class MyButton : public QTGPictureButton 
{
  protected:
	const TGPicture* fOn;      // picture displayed when button is On
	const TGPicture* fOff	   // picture displayed when button is Off 
 
	Bool_t      IsDown() const { return  !(fOptions & kRaisedFrame); }    
  public:
	MyButton(const TGWindow *p, Int_t id,  const TGPicture *Off, const
TGPicture *On);
	~MyButton();
   virtual     void        SetState(EButtonState state); 

 ClassDef(MyButton,0)	// 2 state picture button	 		
}; 


 ClassImp(MyButton)

//______________________________________________________________________________
 MyButton::MyButton(const TGWindow* p, Int_t id,const TGPicture *Off,
const TGPicture *On  ):
	TGPictureButton(p,Off,id)
{
    // ctor

    fState  = kButtonUp;
    fPic    = fOff;
   
   // supposed fOff/fOn pictures has the same size
   // comment :  settings of button's sizes are different from
TGPictureButton's ( you can play with it)	 
        
   fTWidth  = fPic->GetWidth(); 
   fTHeight = fPic->GetHeight();
 
   Resize(fTWidth+1,fTHeight+1);        
   fClient->NeedRedraw(this);		
}

//______________________________________________________________________________
 MyButton::~MyButton()
{
   // dtor

  if(fOn) fClient->FreePicture(fOn);
  if(fOff) fClient->FreePicture(fOff);  	 
}

//______________________________________________________________________________
 void MyButton::SetState(EButtonState state)
{
   // we need overload only this method
  
   TGPictureButton::SetState(state);

   if(fState == kButtonDisable) return;
   fPic= IsDown() ? fOn : fOff;
}

//////////////////////////////////////////////////////////////////////////////// 
 
  Hope these hints could help, 

		with best regards  . 			Valery



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:35 MET