Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Text width in VID

From: carl::cybercraft::co::nz at: 24-Dec-2003 22:50

On 06-Dec-03, Henrik Mikael Kristensen wrote:
> I'm also toying with size adaptable buttons, which size themselves > to the text, so it doesn't wrap, and allow for resizing the main > window with the buttons without screwing up the text and for > resizing the column in a listview and make sure, text is never > obscured.
In later versions of View, but (instead of button) produces a rounded button sized to the text unless you over-ride it's size (I think).
> I can't use automatic calculations for the button size, because I > need to be able to resize the button from the minimum size of the > text width and up. > I've come up with making an image of a layout with the text string > and then determining its width from image/size/x and it works well. > But it seems a little cumbersome, but is (not yet) performance > critical for my application. > Still, are there easier ways?
Yes...
>> ? size-text
USAGE: SIZE-TEXT face DESCRIPTION: Returns the size of the text in a face. SIZE-TEXT is a native value. ARGUMENTS: face -- (Type: object) So...
>> layout [t: text "hello"] >> size-text t
== 25x12 And I've a vague feeling you can create faces directly without needing layout, which would simplify things further, but I can't remember how it was done - if it actually can be... :) -- Carl Read