English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 10 June 2014, 02:55   #1
mritter0
Registered User
 
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
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.
mritter0 is offline  
Old 10 June 2014, 13:02   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
Interesting challenge. Find my first try attached.
Attached Files
File Type: lha weight.lha (8.7 KB, 157 views)
thomas is offline  
Old 11 June 2014, 02:27   #3
mritter0
Registered User
 
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
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.
Code:
ULONG
GetNavigationWidth()
{
	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
Code:
CHILD_WeightedWidth,		Prefs->NavigationWidth,
And the other listbrowser
Code:
CHILD_WeightedWidth,		99-Prefs->NavigationWidth,
I use 99 to accommodate for the weightbar. Slightly more accurate.
mritter0 is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where can I get the Progress.gadget from? Tony Landais request.Apps 6 16 December 2015 19:16
Width adjustment stopped working on 1084S-P2. e5frog support.Hardware 3 17 April 2014 23:16
How to add an Iconify-Gadget to a Window? AGS Coders. System 5 15 January 2014 15:41
Decent fixed width fonts. killergorilla request.Other 29 02 February 2007 19:16
Gadget/Layout.gadget V44 ruliovega support.Apps 6 02 January 2006 11:50

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:38.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10886 seconds with 14 queries