Are these tags not honored? If so, why not?Said tag list is made up for the most part of the usual menuclass tags that are used to specify attributes of the individual objects
Intuition Menu Class
Re: Intuition Menu Class
In the wiki, the example "Generating a whole menu (sub-)tree from a single tag list" is what I am using for a large menu. This method is suggested. I can not get MA_Hidden and MA_Image to work. Not hidden and no image.
Workbench Explorer - A better way to browse drawers
- salass00
- AmigaOS Core Developer
- Posts: 530
- Joined: Sat Jun 18, 2011 3:12 pm
- Location: Finland
- Contact:
Re: Intuition Menu Class
@mritter0
I'm using this method for creating menus in a program I'm working on and MA_Image is working just fine on my 4.1 Final Edition system.
Are you passing a valid BOOPSI image for MA_Image?
The code I'm using is:
Where get_image() is:
I'm using this method for creating menus in a program I'm working on and MA_Image is working just fine on my 4.1 Final Edition system.
Are you passing a valid BOOPSI image for MA_Image?
The code I'm using is:
Code: Select all
menustrip = NewObject(NULL, "menuclass", MA_Type, T_ROOT, TAG_END);
if (menustrip == NULL)
THROW();
success = DoNewMenu(menustrip,
NM_Menu, "Project", MA_ID, MID_PROJECT,
NM_Item, "Open...", MA_Key, "O", MA_ID, MID_OPEN, MA_Image, get_image("open"),
NM_Item, "Close", MA_Key, "K", MA_ID, MID_CLOSE, MA_Image, get_image("close"),
NM_Item, ML_SEPARATOR,
NM_Item, "About...", MA_Key, "?", MA_ID, MID_ABOUT, MA_Image, get_image("info"),
NM_Item, ML_SEPARATOR,
NM_Item, "Quit", MA_Key, "Q", MA_ID, MID_QUIT, MA_Image, get_image("quit"),
TAG_END);
if (success == FALSE)
THROW();
Code: Select all
Object *XXXX::get_image(CONST_STRPTR name) {
TEXT normal_path[256];
TEXT selected_path[256];
TEXT disabled_path[256];
Strlcpy(normal_path, "tbimages:", sizeof(normal_path));
AddPart(normal_path, name, sizeof(normal_path));
Strlcpy(selected_path, normal_path, sizeof(selected_path));
Strlcat(selected_path, "_s", sizeof(selected_path));
Strlcpy(disabled_path, normal_path, sizeof(disabled_path));
Strlcat(disabled_path, "_g", sizeof(disabled_path));
return NewObject(BitMapClass, NULL,
BITMAP_Screen, screen,
BITMAP_Masking, TRUE,
BITMAP_SourceFile, normal_path,
BITMAP_SelectSourceFile, selected_path,
BITMAP_DisabledSourceFile, disabled_path,
TAG_END);
}
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: Intuition Menu Class
@xenix
A seperate function to avoid a cast is a bit silly, especially given Salass00's point about other functions in the API.
You could always write a macro
The menuclass object has a menustrip in it, in the same way as a boopsi gadget has a gadget, so there is no need for a seperate function, you just need to cast the pointer, just as you would if you followed the convention of makeing all your gadgets Object * ather than struct Gadgets *s.I also noticed that IIntuition->SetMenuStrip() produces a warning for a menu class argument:
warning: passing argument 3 of 'IIntuition->SetMenuStrip' from incompatible pointer type
Maybe a seperate function (like SetMenuStripObj) with correct argument types would have been more in keeping with C language type identification.
A seperate function to avoid a cast is a bit silly, especially given Salass00's point about other functions in the API.
You could always write a macro
Re: Intuition Menu Class
@broadblues
@all
I would like to point out that I would never have figured out how to use the new menu class without reading the AmigaOS documentation WIKI. I think the SDK should include a text or PDF version of the current developer WIKI with a warning that the online version may be more up-to-date. Some of us would be lost if the WIKI pages ever go down.
I actually read the SDK autodocs but the Intuition autodoc was not updated to cover changes regarding menu class. The autodoc entries for SetMenuStrip() ClearMenuStrip() and ResetMenuStrip() need to be updated to indicate how they should be used with menu class. My program would have had the appropriate type casting to begin with if the autodocs were up-to-date.
It's just my personal opinion but it seems silly to have to fill my programs full of type casting to avoid "type" warnings so I can focus on the meaningfull compiler warnings.The menuclass object has a menustrip in it, in the same way as a boopsi gadget has a gadget, so there is no need for a seperate function, you just need to cast the pointer, just as you would if you followed the convention of makeing all your gadgets Object * ather than struct Gadgets *s.
A seperate function to avoid a cast is a bit silly, especially given Salass00's point about other functions in the API.
@all
I would like to point out that I would never have figured out how to use the new menu class without reading the AmigaOS documentation WIKI. I think the SDK should include a text or PDF version of the current developer WIKI with a warning that the online version may be more up-to-date. Some of us would be lost if the WIKI pages ever go down.
I actually read the SDK autodocs but the Intuition autodoc was not updated to cover changes regarding menu class. The autodoc entries for SetMenuStrip() ClearMenuStrip() and ResetMenuStrip() need to be updated to indicate how they should be used with menu class. My program would have had the appropriate type casting to begin with if the autodocs were up-to-date.
AmigaOne X1000 with 2GB memory - OS4.1 FE
Re: Intuition Menu Class
@salass00
Stupid error on my part for the images. I was locking the screen after creating the menus.
I still can not get MA_Hidden to work at creation. No big deal, I only have 2 items and they are temporary. I use SetAtts() to hide them after menu creation, before SetMenuStrip().
Stupid error on my part for the images. I was locking the screen after creating the menus.
I still can not get MA_Hidden to work at creation. No big deal, I only have 2 items and they are temporary. I use SetAtts() to hide them after menu creation, before SetMenuStrip().
Workbench Explorer - A better way to browse drawers
Re: Intuition Menu Class
SDK:Examples/GUI/MenuClass/MenuClass.cxenic wrote:I would like to point out that I would never have figured out how to use the new menu class without reading the AmigaOS documentation WIKI. I think the SDK should include a text or PDF version of the current developer WIKI with a warning that the online version may be more up-to-date. Some of us would be lost if the WIKI pages ever go down.
SDK:Examples/GUI/MenuClass/MenuClassLocalize.c