mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
add fitButtonToString
This commit is contained in:
parent
50d49e534f
commit
ac6a51dfc7
2 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue