-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|252|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Text and GUI's


 
Andy_A
Created : 07 October 2010
Edited : 09 October 2010
System : Windows
Language : Blitz

Rounded rect buttons with centered text + word wrap

Rounded Text Buttons/Panels

Was working on some stuff and the need for centered text on a rounded rectangle popped up.

There's a few solutions already posted here on SoCoder but they weren't quite what I needed. One was too slow (can't remember where it was, but I wrote it!), the other was in Cobra (don't know Cobra and not too fond of Pascal anyway).

This little function is simple enough and while not terribly fast, it's fast enough for my needs.



edit: fixed typos

 

Comments


Saturday, 09 October 2010, 08:04
mindstorm8191
Not bad. Blitz has some functions to determine the width and height of a string of text, you may want to include in here. I think its called textwidth & textheight... or something, you should be able to find it. You could then use that to determine the size of your buttons (plus padding), and then use the parameters as a minimum width & height, if they want the buttons bigger than the text.
Saturday, 09 October 2010, 09:15
Andy_A
Currently working on just that! The function wraps and centers (optional) the text inside of a rounded rectangle.

However, seem to be having a an intermittent problem when the last line of text is printed twice. When that is solved I'll post the code.
Saturday, 09 October 2010, 14:19
Andy_A


This function word-wraps the text from an un-formatted string and optionally centers text, all bundled inside of a rounded rectangle.