Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
89 user(s) are online (64 user(s) are browsing Forums)

Members: 0
Guests: 89

more...

Support us!

Headlines






OS4 Reaction programming question (beginner)
Just popping in
Joined:
2012/7/16 18:57
From Istanbul
Posts: 216
Let's say we have a gadget like following:

if((gb_StringGad = (struct Gadget *) IIntuition->NewObject(IString->STRING_GetClass(),NULL,
GA_ID, GAD_ID_String,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_MaxChars, 6,
STRINGA_MinVisible, 6,
STRINGA_TextVal, pcbtempstring,
TAG_DONE)))

How can I change some attributes (e.g. text value)

IIntuition->SetGadgetAttrs(gb_StringGad, gb_WindowObj,STRINGA_TextVal, "changed");

Above code does not work, what am I missing ?

Thanks

_________________
Sinan - AmigaOS4 Beta-Tester
- AmigaOne X5000
- AmigaOne A1222
- Sam460ex
   Report Go to top

Re: OS4 Reaction programming question (beginner)
Just popping in
Joined:
2011/7/20 20:01
From In the sticks
Posts: 172
I think you're missing the requester parameter, which can be NULL, and the TAG_DONE as the final argument, try:

IIntuition->SetGadgetAttrs(gb_StringGadgb_WindowObjNULLSTRINGA_TextVal"changed"TAG_DONE);

   Report Go to top

Re: OS4 Reaction programming question (beginner)
Just can't stay away
Joined:
2009/5/1 18:57
From Czech Republic
Posts: 1281
@SinanSam460

Your SetGadgetAttrs() call is wrong:


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.

3) The last parameter must be a closing TAG_DONE.

This is what it should look like:

IIntuition->SetGadgetAttrs(gb_StringGad, myWindow, NULL, STRINGA_TextVal, "changed", TAG_DONE);


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().

_________________
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
   Report Go to top

Re: OS4 Reaction programming question (beginner)
Home away from home
Joined:
2006/12/4 23:15
Posts: 2277
It's worth noting that if the window has not yet been opened then the window argument should be NULL too.


_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: OS4 Reaction programming question (beginner)
Just popping in
Joined:
2020/11/17 12:08
From Slough
Posts: 161
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.

   Report Go to top

Re: OS4 Reaction programming question (beginner)
Just can't stay away
Joined:
2009/5/1 18:57
From Czech Republic
Posts: 1281
Quote:
It's worth noting that if the window has not yet been opened then the window argument should be NULL too.

As broadblues says. Or use SetAttrs() instead of SetGadgetAttrs() in such a case.

_________________
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
   Report Go to top

Re: OS4 Reaction programming question (beginner)
Home away from home
Joined:
2006/12/4 23:15
Posts: 2277
@NinjaCyborg

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.


_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: OS4 Reaction programming question (beginner)
Just popping in
Joined:
2012/7/16 18:57
From Istanbul
Posts: 216
@trixie

Thanks for suggestion and corrections:

Now I use this, I want to change the value of string when I click close gadget.

case WMHI_CLOSEWINDOW:
IDOS->Delay(50);
printf("...");
IIntuition->GetAttr(STRINGA_TextVal,(Object*)gb_StringGad,(ULONG*)&val);
IIntuition->SetAttrs(gb_StringGad, gb_WindowObj, NULL, STRINGA_TextVal, "change", TAG_DONE);

/*laufen = FALSE;*/
break;

But nothing changes in the window...Window is already opened.


Edited by SinanSam460 on 2021/3/10 11:12:19
_________________
Sinan - AmigaOS4 Beta-Tester
- AmigaOne X5000
- AmigaOne A1222
- Sam460ex
   Report Go to top

Re: OS4 Reaction programming question (beginner)
Just popping in
Joined:
2011/7/20 20:01
From In the sticks
Posts: 172
@SinanSam460


struct Window *win_p NULL;
    
/* Obtain window pointer from the window object. */
IIntuition -> GetAttrs (gb_WindowObjWINDOW_Window, &win_p,  TAG_DONE);

IIntuition->SetGadgetAttrs (gb_StringGadwin_pNULLSTRINGA_TextVal"change"TAG_DONE);


   Report Go to top

Re: OS4 Reaction programming question (beginner)
Just popping in
Joined:
2012/7/16 18:57
From Istanbul
Posts: 216
@billyfish

Thanks, now I get it :) and it is working now...

_________________
Sinan - AmigaOS4 Beta-Tester
- AmigaOne X5000
- AmigaOne A1222
- Sam460ex
   Report Go to top

Re: OS4 Reaction programming question (beginner)
Just can't stay away
Joined:
2009/5/1 18:57
From Czech Republic
Posts: 1281
@SinanSam460

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 Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
   Report Go to top

Re: OS4 Reaction programming question (beginner)
Quite a regular
Joined:
2007/2/6 13:57
From Donostia (SPAIN)
Posts: 632
@trixie

sorry for offtiopic, but diffs between RefreshSetGadgetAttrs() and SetGadgetAttrs()?


SetGadgetAttrs autodoc:
---
Typically, the gadgets will refresh their visuals to reflect..


RefreshSetGadgetAttrs autodoc:
...
Same as SetGadgetAttrs() but refreshes the object ..

   Report Go to top

Re: OS4 Reaction programming question (beginner)
Home away from home
Joined:
2006/12/4 23:15
Posts: 2277
@trixie

Quote:

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

_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: OS4 Reaction programming question (beginner)
Just can't stay away
Joined:
2009/5/1 18:57
From Czech Republic
Posts: 1281
@broadblues

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).

_________________
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
   Report Go to top





[Advanced Search]



Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project