diff --git a/palm/palmutil.c b/palm/palmutil.c index 67d6b0850..ca6a6dce8 100644 --- a/palm/palmutil.c +++ b/palm/palmutil.c @@ -385,6 +385,23 @@ getFormRefcon() XP_ASSERT( ptr != 0L ); return (void*)ptr; } /* getFormRefcon */ + +void +fitButtonToString( XP_U16 id ) +{ + ControlPtr button = getActiveObjectPtr( id ); + const char* label = CtlGetLabel( button ); + XP_U16 width = FntCharsWidth( label, XP_STRLEN(label) ); + RectangleType rect; + width += 14; /* 7 pixels at either end */ + + getObjectBounds( id, &rect ); + rect.topLeft.x -= (rect.extent.x - width); + rect.extent.x = width; + + setObjectBounds( id, &rect ); +} /* fitButtonToString */ + #endif #if defined FEATURE_REALLOC || defined XW_FEATURE_UTILS diff --git a/palm/palmutil.h b/palm/palmutil.h index 689a90570..8333e5b80 100644 --- a/palm/palmutil.h +++ b/palm/palmutil.h @@ -72,6 +72,8 @@ XP_Bool penInGadget( EventPtr event, UInt16* whichGadget ); void setFormRefcon( void* refcon ); void* getFormRefcon(); +void fitButtonToString( XP_U16 id ); + #ifdef DEBUG void logEvent( eventsEnum eType );