Page 1 of 1
ChangeWindowBox & Gadget resizing
Posted: Mon Feb 27, 2012 3:06 pm
by JosDuchIt
Using ChangeWindowBox() you can make a command that redraws an applications window to new position and size
For testing i wrote a number of simple Gui4Cli scripts that just present a window with one button.
You can define with Gui4Cli how the button should be resized if the window is
xBUTTON 60 60 60 30 "" ; <<>>
Attr Resize 1100
(here L T change proportional with window width and height W & H don't change )
Using my proggy i do observe that the button, is effectively redrawn as expected , using different variants for Attr Resize
What i can't figure out is how this information is known to Intuition.
I guess this resizing info must be stored in struct Gadget, or extended, but i don't see where.
Re: ChangeWindowBox & Gadget resizing
Posted: Mon Feb 27, 2012 6:31 pm
by thomasrapp
Check Gadget->Flags:
GFLG_RELBOTTOM -> position is relative to window bottom
GFLG_RELRIGHT -> position is relative to window right border
GFLG_RELWIDTH -> size is relative to window width
GFLG_RELHEIGHT -> size is relative to window height
Note that the repective value must be negative to make any sense, for example if GFLG_RELWIDTH is set, Gadget->Width must be negative so that the gadget is smaller than the window. Similarly if GFLG_RELBOTTOM is set, Gadget->Top must be negative, otherwise the gadget would reside outside the window (i.e. be invisible).
Re: ChangeWindowBox & Gadget resizing
Posted: Mon Feb 27, 2012 8:18 pm
by JosDuchIt
@Thomas
- None of the mentioned flags appear in the Gui4Cli source
GFLG_RELSPECIAl would be imho a better candidate to acheave the varied resize behaviour.
But it is not used either.
#define GFLG_RELSPECIAL 0x4000 /* custom gadget has special relativity.
* Gadget box values are absolutes, but
* can be changed via the GM_LAYOUT method.
*/
More info on Gui4Cli:
- Gui4Cli is GadTools based; the gadgets for a script are created with CreateGadget
case xBUTTON :
gf->gad = CreateGadget (BUTTON_KIND, gf->gad, &ng,
GT_Underscore, '_',
GFLG_EXTENDED, extflag,
GA_Disabled, onoff, TAG_END);
where ng is a pointer to struct NewGadget
As a matter of fact, the source does give a resize() function that calculates new sizes and takes the different resize methods into account. I guess it is called when a user manually uses the size gadget and changes the window size.
I could not figure out how that would be the case when some other program uses ChangeWondowBox()
Must I conclude that ChangeWindowBox triggers a similar message to the windows owner (application - Gui4Cli in this case °° ?)
Re: ChangeWindowBox & Gadget resizing
Posted: Tue Feb 28, 2012 8:23 pm
by thomasrapp
GadTools does not support automatic layout in any way. The only way to resize a GadTools GUI is to delete it entirely and to recreate it at the new size.
This means if you get an IDCMP_NEWSIZE message, you remove all GadTools gadgets from the window, free them, read the new window size and then recreate the GUI. This can not be done automatically.
If you need automatic layout, you have to use MUI or ReAction/ClassAct. Or write your own BOOPSI layout class.