1) gb_WindowObj seems to be a window object pointer but for this particular call you need a struct Window pointer. The two point to a completely different type of thing!
2) The Window pointer must be followed by a NULL requester pointer.
You can obtain the struct Window pointer when opening the window (it's the actual result of the WM_OPEN method call), or at any time later by querying the WINDOW_Window attribute through GetAttr().
Wouldn't it be better if the window's state was separate from whether it was open or not, such that it could be closed and opened (for example after a screenmode reset) without needing to be destroyed and reinitialised? I appreciate intuition doesn't do that but it'd be nice if the window class abstracted it.
window.class objects do not need to be destroyed or reinsitialised from scrtach when closing the (workbench) screen. they can also jump from screen to screem
In fact the window.class object will send a WMHI_ICONIFY and WMHI_UNICONIFY message to the application, which should then close and reopen the window in response. Or a WMHI_JUMPSCREEN
This is how AmigaOS4 avoids (or at least reduces the frequency of) the annoying can't close workbench screen messages when change prefs settings. Most apps will close automatically.
Some restup may be required if your gadgets needed certain pen colours or other screen specific attributes as the previous data will now be invalid.
SetGadgetAttrs() needs the window pointer and very rarely the requester pointer ( very few modern amiga programs use requesters in the original sense, most modern requesters are actually windows) to provide rendering context to the gadgets. These gadgets are often but need not be associated with a window.class object.
The difference between the two BOOPSI setter functions is that SetGadgetAttrs() also triggers the GM_RENDER method to update the gadget imagery, while SetAttrs() simply sets the new value without the redraw. Typically, you'll use SetGadgetAttrs() in a live window to get immediate visual response, and SetAttrs() before the window opens (or when it's iconified).
The difference between the two BOOPSI setter functions is that SetGadgetAttrs() also triggers the GM_RENDER method to update the gadget imagery, while SetAttrs() simply sets the new value without the redraw. Typically, you'll use SetGadgetAttrs() in a live window to get immediate visual response, and SetAttrs() before the window opens (or when it's iconified).
That's not actually true.
The difference is that SetGadgetAttrs() populates the GadgetInfo entry in the opSet message (OM_SET)
struct opSet
{
ULONG MethodID;
struct TagItem *ops_AttrList; /* new attributes */
struct GadgetInfo *ops_GInfo; /* always there for gadgets,
* when SetGadgetAttrs() is used,
* but will be NULL for OM_NEW
*/
};
In reponse to the values of some attributes some but not all gadgets may trigger a GM_RENDER . A very rough rule of thumb is that simple gadgets will render straight away, more complex ones may not. (but might still perform setup based on the GadgetInfo)
@Jabirulo
The difference with RefreshSetGadgetAttrs() is that it will *always* force a render of the gadget if SetGadgetAttrs() would have returned a non zero value.
It's equivelent of
if(SetGadgetAttrs()) RefreshGList() .
[edit]markdown and adding that the refresh only occurs if SetGadgetAttrs() would return non zero
True, I have oversimplified things a little. Nevertheless, SetGadgetAttrs() and RefreshSetGadgetAttrs() often produce the same result, depending on gadget implementation.
@Jabirulo
As Andy says. RefreshSetGadgetAttrs() is a belt-and-braces call that ensures the refresh takes place after changing the attribute(s).