English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. C/C++ (http://eab.abime.net/forumdisplay.php?f=118)
-   -   Get Gadget Width (http://eab.abime.net/showthread.php?t=74031)

mritter0 10 June 2014 03:55

Get Gadget Width
Not even sure if this is possible. OS3.9 and ReAction gadgets.

- I have a horizontal group split into 2 sections by LAYOUT_WeightBar.
- The left side has a minumum off 100 and max of 300 pixels.
- The right can be what ever size according to the window size.
- The left side is a just a full size (no padding) listbrowser.

I would like to be able get the size of the left area when the user resizes the weight bar so I can save it so when next time the program is started, set that side to actual pixel (not weighted percent) size.

So, GetAttrs() to get the listbrowser's width, save it in prefs, quit, re-open with same pixel width. Either set the width in the layout code (preferred), or do a SetGadgetAttrs() to the width after the window is opened.

thomas 10 June 2014 14:02

1 Attachment(s)
Interesting challenge. Find my first try attached.

mritter0 11 June 2014 03:27

Cool. Got it working. Not pixel perfect because of rounding. And, I also forgot to say that I also save the window width/height, which will also vary.

        ULONG                                                        sum=MainWindow->Width-(!IsOS4 ? 22 : 28)-6+14;
        ULONG                                                        sum2=sum/2;

        ULONG                                                        w1=NavigationGad->Width;

        w1 = (w1 * 100 + sum2) / sum;

        return w1;

The 22 : 28 is for (Window->BorderLeft + Window->BorderRight); 22 for OS3.9, 28 for OS4. The 6 is for the width of the weightbar. The 14, not sure where that is coming from; may be 20 on OS4. But 6 pixels won't ruin the math.

Then in the layout code for the navigation gadget

CHILD_WeightedWidth,                Prefs->NavigationWidth,
And the other listbrowser

CHILD_WeightedWidth,                99-Prefs->NavigationWidth,
I use 99 to accommodate for the weightbar. Slightly more accurate.

All times are GMT +2. The time now is 14:56.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.

Page generated in 0.04749 seconds with 11 queries