[JW Lua] Dynamic dialog sizing
carlvine
carlvine at iinet.net.au
Sat Feb 25 00:42:02 CET 2023
Is this what you’re after?
enigma_string.calc_text_advance_width(inp_string)
https://www.finalelua.com/docs/library/enigma-string#calc_text_advance_width
(I think it returns EVPU)
Carl
> On 25 Feb 2023, at 5:41 am, jwlua-request at jwmusic.nu wrote:
>
>
> Message: 1
> Date: Fri, 24 Feb 2023 08:51:02 -0500
> From: Aaron Sherber <aaron at sherber.com <mailto:aaron at sherber.com>>
> To: "The JW Lua script plug-in." <jwlua at jwmusic.nu <mailto:jwlua at jwmusic.nu>>
> Subject: [JW Lua] Dynamic dialog sizing
> Message-ID:
> <CABCgyHU4Zaw2DatEnpFR+EP-W94NEWaw1LED4cRh8EJU502y7A at mail.gmail.com <mailto:CABCgyHU4Zaw2DatEnpFR+EP-W94NEWaw1LED4cRh8EJU502y7A at mail.gmail.com>>
> Content-Type: text/plain; charset="utf-8"
>
> Hi all,
>
> I'm working with FCCustom(Lua)Window and having some difficulties with
> sizing.
>
> I want to display a static label on a dialog, but I don't know at design
> time how long the text in the label is -- let's say it's a path+filename. I
> don't see a way to make the FCCtrlStatic dynamically fit the length of the
> text, or to make the overall width of the dialog fit the length of the
> control.
>
> Is there a good way to accomplish this? Or is my best bet to approximate
> the needed control length in points based on the character count and then
> set sizes based on that, hoping that everything works?
>
> Thanks,
> Aaron.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20230224/63d00c9a/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 24 Feb 2023 12:43:47 -0500
> From: Aaron Sherber <aaron at sherber.com <mailto:aaron at sherber.com>>
> To: "The JW Lua script plug-in." <jwlua at jwmusic.nu <mailto:jwlua at jwmusic.nu>>
> Subject: Re: [JW Lua] Dynamic dialog sizing
> Message-ID:
> <CABCgyHUDwms6bZujJHLyKnCMLfds6xdZpqVvmW9_tMb13GAWTA at mail.gmail.com <mailto:CABCgyHUDwms6bZujJHLyKnCMLfds6xdZpqVvmW9_tMb13GAWTA at mail.gmail.com>>
> Content-Type: text/plain; charset="utf-8"
>
> Hi all,
>
> I see that a couple of places in the library multiply character count by 6
> in order to get control length. Is that a reasonable approximation for the
> default text fonts?
>
> Thanks,
> Aaron.
>
>
>
>
> On Fri, Feb 24, 2023 at 8:51 AM Aaron Sherber <aaron at sherber.com <mailto:aaron at sherber.com>> wrote:
>
>> Hi all,
>>
>> I'm working with FCCustom(Lua)Window and having some difficulties with
>> sizing.
>>
>> I want to display a static label on a dialog, but I don't know at design
>> time how long the text in the label is -- let's say it's a path+filename. I
>> don't see a way to make the FCCtrlStatic dynamically fit the length of the
>> text, or to make the overall width of the dialog fit the length of the
>> control.
>>
>> Is there a good way to accomplish this? Or is my best bet to approximate
>> the needed control length in points based on the character count and then
>> set sizes based on that, hoping that everything works?
>>
>> Thanks,
>> Aaron.
>>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20230224/51ee93f1/attachment-0001.html>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 24 Feb 2023 12:00:01 -0600
> From: Robert Patterson <robert at robertgpatterson.com <mailto:robert at robertgpatterson.com>>
> To: "The JW Lua script plug-in." <jwlua at jwmusic.nu <mailto:jwlua at jwmusic.nu>>
> Subject: Re: [JW Lua] Dynamic dialog sizing
> Message-ID:
> <CAACncetcA-J=12+1jRKbuePN6gZFckK3YNEVg2YWbaq5E1Sncw at mail.gmail.com <mailto:CAACncetcA-J=12+1jRKbuePN6gZFckK3YNEVg2YWbaq5E1Sncw at mail.gmail.com>>
> Content-Type: text/plain; charset="utf-8"
>
> You could call CreateFontInfo on the control and then use that to get the
> text width. You probably need to do this in the InitWindow callback.
>
> On Fri, Feb 24, 2023 at 11:45 AM Aaron Sherber <aaron at sherber.com <mailto:aaron at sherber.com>> wrote:
>
>> Hi all,
>>
>> I see that a couple of places in the library multiply character count by 6
>> in order to get control length. Is that a reasonable approximation for the
>> default text fonts?
>>
>> Thanks,
>> Aaron.
>>
>>
>>
>>
>> On Fri, Feb 24, 2023 at 8:51 AM Aaron Sherber <aaron at sherber.com <mailto:aaron at sherber.com>> wrote:
>>
>>> Hi all,
>>>
>>> I'm working with FCCustom(Lua)Window and having some difficulties with
>>> sizing.
>>>
>>> I want to display a static label on a dialog, but I don't know at design
>>> time how long the text in the label is -- let's say it's a path+filename. I
>>> don't see a way to make the FCCtrlStatic dynamically fit the length of the
>>> text, or to make the overall width of the dialog fit the length of the
>>> control.
>>>
>>> Is there a good way to accomplish this? Or is my best bet to approximate
>>> the needed control length in points based on the character count and then
>>> set sizes based on that, hoping that everything works?
>>>
>>> Thanks,
>>> Aaron.
>>>
>> _______________________________________________
>> JWLua mailing list
>> JWLua at jwmusic.nu <mailto:JWLua at jwmusic.nu>
>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20230224/eed946fc/attachment-0001.html>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 24 Feb 2023 13:40:41 -0500
> From: Aaron Sherber <aaron at sherber.com <mailto:aaron at sherber.com>>
> To: "The JW Lua script plug-in." <jwlua at jwmusic.nu <mailto:jwlua at jwmusic.nu>>
> Subject: Re: [JW Lua] Dynamic dialog sizing
> Message-ID:
> <CABCgyHW19sXDqc4DU248KSk=a8+nidwjMOww2MUux=QKs9_gsQ at mail.gmail.com <mailto:CABCgyHW19sXDqc4DU248KSk=a8+nidwjMOww2MUux=QKs9_gsQ at mail.gmail.com>>
> Content-Type: text/plain; charset="utf-8"
>
> How can you get the text width from FCFontInfo? I don't see any functions
> for that.
>
> Thanks,
> Aaron.
>
>
>
>
>
>
> On Fri, Feb 24, 2023 at 1:01 PM Robert Patterson <
> robert at robertgpatterson.com <mailto:robert at robertgpatterson.com>> wrote:
>
>> You could call CreateFontInfo on the control and then use that to get the
>> text width. You probably need to do this in the InitWindow callback.
>>
>> On Fri, Feb 24, 2023 at 11:45 AM Aaron Sherber <aaron at sherber.com <mailto:aaron at sherber.com>> wrote:
>>
>>> Hi all,
>>>
>>> I see that a couple of places in the library multiply character count by
>>> 6 in order to get control length. Is that a reasonable approximation for
>>> the default text fonts?
>>>
>>> Thanks,
>>> Aaron.
>>>
>>>
>>>
>>>
>>> On Fri, Feb 24, 2023 at 8:51 AM Aaron Sherber <aaron at sherber.com <mailto:aaron at sherber.com>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I'm working with FCCustom(Lua)Window and having some difficulties with
>>>> sizing.
>>>>
>>>> I want to display a static label on a dialog, but I don't know at design
>>>> time how long the text in the label is -- let's say it's a path+filename. I
>>>> don't see a way to make the FCCtrlStatic dynamically fit the length of the
>>>> text, or to make the overall width of the dialog fit the length of the
>>>> control.
>>>>
>>>> Is there a good way to accomplish this? Or is my best bet to approximate
>>>> the needed control length in points based on the character count and then
>>>> set sizes based on that, hoping that everything works?
>>>>
>>>> Thanks,
>>>> Aaron.
>>>>
>>> _______________________________________________
>>> JWLua mailing list
>>> JWLua at jwmusic.nu <mailto:JWLua at jwmusic.nu>
>>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>>
>> _______________________________________________
>> JWLua mailing list
>> JWLua at jwmusic.nu <mailto:JWLua at jwmusic.nu>
>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20230224/5563da7e/attachment.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20230225/295145fd/attachment.htm>
More information about the JWLua
mailing list