Page 1 of 1

eLabel and multiline

Posted: 28 May 2008 10:27
by JuNeau
Hi everybody !

I'm using Gildas Menier ebutton and elabel, it's wonderfull, but I wonder : does anybody know if it is possible to set an elabel as multiline ? I'd like to write a text (rather long) over a bmp file, and the elabel seems the simplest way to do so... unless you have a better idea ?

Thanks a lot

Posted: 28 May 2008 12:02
by Tonton Luc
Hi,
1) add a custom control named text_ctl with class = textControl and add your text in this control using this code :

Code: Select all

text_ctl:setText("Line 1\nLine 2\n etc..."), text_ctl:setForegroundColor(color_red),
2) or add your own draw control in your project + use vpi::drawText in the onPaint of this control...

Posted: 28 May 2008 14:18
by JuNeau
Thanks Tonton :D ,

Your first proposal seems the simplest, I'll probably use it... Thanks again !

By the way, still concerning eLabel : do you know if it is possible to use a bmp using its resourceID rather than its file name ? I'd prefer that the bmp doesn't appear in the exe directory...

Posted: 28 May 2008 18:44
by Gildas Menier
Hi Juneau !

You can use a resourceID of course (but outside the GUI builder). Have a look at setBackgroundPictureFromRes for instance (see the predicates ending with 'FromRes')
As for the multiline feature, I doubt it is possible using the published code.

regards

Gildas

Posted: 29 May 2008 13:22
by JuNeau
Hi Gildas !

setBackgroundPictureFromRes works fine, thanks a lot !
Too bad for the multiline eLabel, I'll do as Tonton Luc suggested... It's not a big deal :D

Anyway good job for the ui_ext pack, it is really great ! Thanks again !

Posted: 26 Jan 2012 22:25
by vjoer
Hi

Multiline can be obtained for an ebutton (elabel) using drawTextInRect instead of drawText.

Basically replace the line

GDI:drawText(pnt(PositionX+TextOffsetX,PositionY+TextOffsetY+2), Txt)

with:

This:getSize(W, H),
GDI:drawTextInRect( rct(2,2,W-2,H-2), Txt, [dtext_Wordbreak])

regards