Hello,
i have this function that open a window with a menu:
struct Window *open_window (struct Screen *scr,const char *title,long x,long y,long w,long h,struct NewMenu *newmenu,struct VisualInfo *vi,struct Menu **menuptr)
{
struct Menu *menu = NULL;
struct Window *win;
if ((win = OpenWindowTags (NULL,
WA_CustomScreen,scr,
WA_Title,title,
WA_Left,x,
WA_Top,y,
WA_Width,w,
WA_Height,h,
WA_Flags,WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SIZEGADGET | WFLG_SIZEBBOTTOM | WFLG_ACTIVATE | WFLG_NEWLOOKMENUS | WFLG_NOCAREREFRESH,
WA_IDCMP,IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | IDCMP_MENUPICK,
WA_MaxWidth,scr->Width,
WA_MaxHeight,scr->Height,
TAG_END)))
{
if (vi)
if (menu = CreateMenusA (newmenu,NULL))
if (LayoutMenus (menu,vi,GTMN_NewLookMenus,TRUE,TAG_END))
SetMenuStrip (win,menu);
}
*menuptr = menu;
return (win);
}
how would you change this function to reflect the modern approach described by trixie?
thank you very much
Tue, 2013-11-26 15:12
#1
How would this function look like using newobject method?
#define __USE_INLINE__
In that case don't use "IIntuition->" or other interface names in function calls.IIntuition->GetAttrs()
in code compiled without __USE_INLINE__. The "IIntuition->" prefix refers to the name of the Intuition library interface. As of OS4.x, Amiga libraries can have multiple interfaces ("function groups") inside them, so the interface name specifies where the function comes from. This is what most new code should use. Older code can be compiled with the __USE_INLINE__ switch. In that case, functions are used without interface names, i.e.GetAttrs()
in your particular case.Object *gadgets[GID_LAST];
When creating new objects and adding them to the layout, you must assign the resulting object pointer to the particular variable (field item), like this:IIntuition->GetAttrs(gadgets[GID_STRING], STRINGA_TextVal, (uint32 *)&stringContents, TAG_DONE);
Hope it's clearer now. But you should really have a look at some ReAction examples in the SDK/Examples directory - they will give you a lot of insight.Pages