Page 1 of 1

Using 'page.gadget' with IIntuition->NewObject(LayoutClass..

Posted: Fri Nov 01, 2013 10:33 pm
by blmara
Hi!

According to the article of Trixie at OS4Coding.net one should use no more reaction_macros.h and use using OpenClass()ed class pointers for creating Reaction objects instead. I managed to transform my current project to the 'new' style but I found one problem: I have generated several windows with page.gadget functionality (combined with clicktab.gadget, for example). But if I create the page with

IIntuition->NewObject(LayoutClass,NULL,TAG_DONE)

and add pages to this gadget with PAGE_Add, these pages are not displayed. But pages work as they should if I use

Intuition->NewObject(ILayout->PAGE_GetClass(),NULL,TAG_DONE)

How one should use LayoutClass in this situation?

Marko

Re: Using 'page.gadget' with IIntuition->NewObject(LayoutCla

Posted: Fri Nov 01, 2013 10:56 pm
by ssolie
There is some example code on how to do this at http://wiki.amigaos.net/index.php/ReAct ... d_Disposal

There are a few cases where a class pointer is not available and you need to use the class name instead. See http://wiki.amigaos.net/index.php/BOOPS ... SI_Classes to figure out which classes are in which files.

For example, intuition.library contains several classes which must be accessed by name. The page.gadget is another case because it is contained within the layout.gadget file.

The "GetClass()" idea was introduced back when there was no way to reliably get the Class pointer.

There is an argument regarding speed because when you search by name it takes a bit of time. However, I find that argument very weak unless you are creating thousands of objects and looking up the name each time. Even in that case you can take the Object pointer and get back to the Class pointer so really you only need to find by name once. But I digress. :)

Re: Using 'page.gadget' with IIntuition->NewObject(LayoutCla

Posted: Fri Nov 01, 2013 11:06 pm
by blmara
ssolie wrote:There is some example code on how to do this at http://wiki.amigaos.net/index.php/ReAct ... d_Disposal
...which must be accessed by name. The page.gadget is another case because it is contained within the layout.gadget file.

The "GetClass()" idea was introduced back when there was no way to reliably get the Class pointer.
...
Ok, thanks, these were good links with good explanations. I understand I shouldn't use the GetClass() here even if still works but the access by name is the way to go here?

Marko

Re: Using 'page.gadget' with IIntuition->NewObject(LayoutCla

Posted: Sat Nov 02, 2013 10:28 am
by trixie
@blmara

As the Page Gadget is embedded in Layout Gadget, you should access it via the public class name, as Steven suggests:

Code: Select all

Object *myPageObject = IIntuition->NewObject(NULL, "page.gadget", ... , TAG_DONE)
The first argument to NewObject() is the class pointer, which you cannot obtain in this particular case because you cannot OpenClass() a gadget that is embedded in another gadget. So you must pass a NULL class pointer and use the public class name instead, which goes in the second argument.