Fl_Labelpad_Group: Measure using actual font of widget instead of always FL_HELVETICA.

This commit is contained in:
Jonathan Moore Liles 2010-01-13 23:02:18 -06:00
parent f70ec7a4d5
commit 2136a8e6d3
1 changed files with 8 additions and 4 deletions

View File

@ -28,6 +28,12 @@ class Fl_Labelpad_Group : public Fl_Group
{ {
public: public:
static void measure_label ( Fl_Widget *o, int &W, int &H )
{
W = fl_width( o->label() );
H = fl_height();
}
Fl_Labelpad_Group ( Fl_Widget *o ) : Fl_Group( 0, 0, 50, 50, 0 ) Fl_Labelpad_Group ( Fl_Widget *o ) : Fl_Group( 0, 0, 50, 50, 0 )
{ {
resizable( 0 ); resizable( 0 );
@ -36,13 +42,11 @@ public:
add( o ); add( o );
fl_font( FL_HELVETICA, o->labelsize() ); fl_font( o->labelfont(), o->labelsize() );
int W, H; int W, H;
W = fl_width( o->label() ); measure_label( o, W, H );
H = fl_height();
// fl_measure( w->label(), H, W );
// set size to contain widget // set size to contain widget
size( W > o->w() ? W : o->w(), o->h() + H ); size( W > o->w() ? W : o->w(), o->h() + H );