License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
Archicad C++ API
About Archicad add-on development using the C++ API.

how to determine the pixel-width of a widgets text

Anonymous
Not applicable
Hi 🙂

My addon is dynamically creating widgets.
Example:
Buttons are created and the width of the buttons should fit the width of text of the buttons.
The buttons text is not known before so i need to get the pixel width of the text at run time.

I see a way to get the maximum length of the widgets font. (API_FontType.widMax)
("w" is longer than "i"...)
I could multiply that with the number of characters, but perhaps someone has a hint how to determine the exact length of a widget-text?

greetings,
John
1 REPLY 1
Anonymous
Not applicable
John wrote:
Hi 🙂
I see a way to get the maximum length of the widgets font. (API_FontType.widMax)


oh, i think these has nothing to do with the fonts of GUI-Widgets.
I just tried a little bit and choosed 5.4 as standard width of a letter.
Hmm.

Example:
Creation of two labels:
Text of Label1 = "iiiiiiiiii" (10 letters)
Text of Label2 = "wwwwwwwwww" (10 letters)

the labels will look like that:
<_iiiiiiiiii__________>
<_wwwwwwwwww_>

but i'am searching for a way to let them look like that:
<_iiiiiiiiii_>
<_wwwwwwwwww_>

any hints?