Page 1 of 1

Code example for new methods

Posted: Sun Dec 01, 2013 10:46 am
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

Re: Code example for new methods

Posted: Sun Dec 01, 2013 10:58 am
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?

Re: Code example for new methods

Posted: Sun Dec 01, 2013 2:24 pm
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?

Re: Code example for new methods

Posted: Sun Dec 01, 2013 8:28 pm
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

Re: Code example for new methods

Posted: Mon Dec 02, 2013 1:17 pm
by AmiHyperion
Thank you.

I will look into macros

Re: Code example for new methods

Posted: Mon Dec 02, 2013 3:13 pm
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);

Re: Code example for new methods

Posted: Tue Dec 10, 2013 8:03 am
by AmiHyperion
Thank you salass