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

This forum is for general developer support questions.
Post Reply
blmara
Posts: 76
Joined: Thu Jun 23, 2011 10:03 am
Location: Vantaa, Finland

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

Post 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
Marko
User avatar
ssolie
Beta Tester
Beta Tester
Posts: 1010
Joined: Mon Dec 20, 2010 8:51 pm
Location: Canada
Contact:

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

Post 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. :)
ExecSG Team Lead
blmara
Posts: 76
Joined: Thu Jun 23, 2011 10:03 am
Location: Vantaa, Finland

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

Post 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
Marko
User avatar
trixie
Posts: 411
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

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

Post 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.
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
Post Reply