Code example for new methods

This forum is for general developer support questions.
Post Reply
AmiHyperion
Posts: 28
Joined: Tue Aug 30, 2011 8:26 am

Code example for new methods

Post by AmiHyperion »

Hello everyone,

i would like to have some code example for the new methods.

In the following code, i create a window with two buttons, but how to insert a string, a label and frames using the new methods?

Code: Select all

Object *winobj;
if ((winobj = NewObject (WindowClass,NULL,
WA_PubScreen, scr,
WA_Title, "ReAction Tool Bar",
WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SIZEBBOTTOM | WFLG_SIZEGADGET | WFLG_ACTIVATE,
WA_IDCMP, IDCMP_VANILLAKEY | IDCMP_INTUITICKS,
WA_Width, scr->Width * 6 / 10,
WA_Height, scr->Height * 4 / 10,
WINDOW_NewMenu,newmenu,
WINDOW_BackFillName, "Sys:Prefs/Presets/Patterns/Chalk/ChalkBlue.brush",
WINDOW_Position, WPOS_CENTERSCREEN,
WINDOW_ParentGroup, NewObject (LayoutClass,NULL,
LAYOUT_Orientation,LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_AddChild,ToolBar(tbimg,TB_MAX),
LAYOUT_AddChild,NewObject (LayoutClass,NULL,
TAG_END),
LAYOUT_AddChild,NewObject (LayoutClass,NULL,
LAYOUT_SpaceOuter, FALSE,
LAYOUT_FixedVert, FALSE,
LAYOUT_EvenSize, TRUE,
LAYOUT_AddChild, NewObject (ButtonClass,NULL,
GA_ID, GID_OK,
GA_Text, "Ok",
GA_RelVerify, TRUE,
TAG_END),
LAYOUT_AddChild, NewObject (ButtonClass,NULL,
GA_ID, GID_CANCEL,
GA_Text, "Cancel",
GA_RelVerify, TRUE,
TAG_END),
TAG_END),
TAG_END),
TAG_END)))


Thank you very much
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1483
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

Re: Code example for new methods

Post by tonyw »

You have downloaded and installed the SDK V53.21, right?

Look in the drawer Examples/Reaction/OS4Examples/. There you wil find examples of how to use quite a few Reaction gadgets (or Objects, as they are now known).
What do you mean by "a string"? Do you mean just some fixed text in the window, or a label associated with an Object? Labels are usually declared as part of an Object, but can also be declared as part of a Layout (eg a vertical or horizontal group of other Objects).

When you say "frame", do you mean a layout group?
cheers
tony
AmiHyperion
Posts: 28
Joined: Tue Aug 30, 2011 8:26 am

Re: Code example for new methods

Post by AmiHyperion »

Look in the drawer Examples/Reaction/OS4Examples/.

The syntax used in the examples is slighty different, doesn't use NewObject.

LAYOUT_AddChild, gadgets[GID_STRING1] = (struct Gadget*)StringObject,
GA_ID, GID_STRING1,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_MinVisible, 10,
STRINGA_MaxChars, SMAX,
StringEnd,

Am i missing something?
User avatar
Rigo
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 363
Joined: Mon Jan 17, 2011 9:42 pm

Re: Code example for new methods

Post by Rigo »

Checkout sdk:include/include_h/reaction/reaction_macros/h to see what these macros expand to.

Basically it is just a shortcut for NewObject( "string.gadget", NULL, xx ).

Simon
AmiHyperion
Posts: 28
Joined: Tue Aug 30, 2011 8:26 am

Re: Code example for new methods

Post by AmiHyperion »

Thank you.

I will look into macros
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 534
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland
Contact:

Re: Code example for new methods

Post by salass00 »

@AmiHyperion

Don't just copy the macros directly though. Instead of IXxx->XXX_GetClass() style function calls you should use the class pointers you obtain from opening the class with IIntuition->OpenClass().

For page.gadget if you need it you will have to access it by name like so:

page = IIntuition->NewObject(NULL, "page.gadget", ..., TAG_END);
AmiHyperion
Posts: 28
Joined: Tue Aug 30, 2011 8:26 am

Re: Code example for new methods

Post by AmiHyperion »

Thank you salass
Post Reply