add fitButtonToString

This commit is contained in:
ehouse 2004-11-05 14:40:37 +00:00
parent 50d49e534f
commit ac6a51dfc7
2 changed files with 19 additions and 0 deletions

View file

@ -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

View file

@ -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 );