24#include <proto/gadtools.h>
25#include <proto/graphics.h>
26#include <proto/intuition.h>
28#include <libraries/gadtools.h>
30#include <intuition/menuclass.h>
33#include <classes/window.h>
34#include <proto/label.h>
35#include <images/label.h>
36#include <proto/bitmap.h>
37#include <images/bitmap.h>
39#include <reaction/reaction_macros.h>
57#define NSA_MAX_HOTLIST_MENU_LEN 100
70 struct ExtIntuiMessage *emsg = (
struct ExtIntuiMessage *)msg;
72 state =
IDoMethod((Object *)menu, MM_GETSTATE, 0, emsg->eim_LongCode, MS_CHECKED);
73 if(state & MS_CHECKED) checked =
true;
76 if(ItemAddress(menu, msg->Code)->Flags & CHECKED) checked =
true;
85 if(md[i] == NULL)
return;
87 (md[i]->menulab != NM_BARLABEL) &&
89 if(md[i]->menutype & MENU_IMAGE) {
90 if(md[i]->menuobj) DisposeObject(md[i]->menuobj);
96 if(md[i]->menukey != NULL) free(md[i]->menukey);
110 for(i = 0; i <=
max; i++) {
116 const char *restrict label,
const char *restrict key,
const char *restrict icon,
117 void *restrict func,
void *restrict hookdata, UWORD flags)
121 md[num]->
flags = flags;
123 if(
type == NM_END)
return;
125 if((label == NM_BARLABEL) || (strcmp(label,
"--") == 0)) {
126 md[num]->
menulab = NM_BARLABEL;
130 md[num]->
menulab = strdup(label);
137 if(key) md[num]->
menukey = strdup(key);
138 if(func) md[num]->
menu_hook.h_Entry = (HOOKFUNC)func;
139 if(hookdata) md[num]->
menu_hook.h_Data = hookdata;
142 char menu_icon[1024];
147 md[num]->
menuicon = (
char *)strdup(menu_icon);
165 SYSIA_Which, MENUSUB,
169 SYSIA_Which, AMIGAKEY,
201 int space_width = TextLength(rp,
" ", 1);
204 item_size = TextLength(rp, md[j]->menulab, strlen(md[j]->menulab));
205 item_size += space_width;
208 item_size += TextLength(rp, md[j]->menukey, 1);
214 item_size += TextLength(rp,
"M", 1);
218 if(md[j]->menuicon) {
226static int ami_menu_layout_mc_recursive(Object *menu_parent,
struct ami_menu_data **md,
int level,
int i,
int max)
229 Object *menu_item = menu_parent;
231 for(j = i; j <
max; j++) {
233 if(md[j] == NULL)
continue;
234 if(md[j]->menutype == NM_IGNORE)
continue;
236 if(md[j]->menutype == level) {
237 if(md[j]->menulab == NM_BARLABEL)
240 if(level == NM_TITLE) {
244 MA_Label, md[j]->menulab,
250 MA_Label, md[j]->menulab,
255 BITMAP_SourceFile, md[j]->menuicon,
256 BITMAP_Masking, TRUE,
258 MA_Key, md[j]->menukey,
259 MA_UserData, &md[j]->menu_hook,
260 MA_Disabled, (md[j]->flags & NM_ITEMDISABLED),
261 MA_Selected, (md[j]->flags & CHECKED),
262 MA_Toggle, (md[j]->flags & MENUTOGGLE),
266 NSLOG(netsurf, DEEPDEBUG,
267 "Adding item %p ID %d (%s) to parent %p",
268 menu_item, j, md[j]->menulab, menu_parent);
269 IDoMethod(menu_parent, OM_ADDMEMBER, menu_item);
271 }
else if (md[j]->menutype > level) {
272 j = ami_menu_layout_mc_recursive(menu_item, md, md[j]->menutype, j,
max);
282 Object *menu_root =
NewObject(NULL,
"menuclass",
284 MA_EmbeddedKey, FALSE,
287 ami_menu_layout_mc_recursive(menu_root, md, NM_TITLE, 0,
max);
289 return (
struct Menu *)menu_root;
299 struct Menu *imenu = NULL;
300 struct VisualInfo *vi;
302 struct RastPort *rp = &
scrn->RastPort;
303 struct DrawInfo *dri = GetScreenDrawInfo(
scrn);
304 int space_width = TextLength(rp,
" ", 1);
309 nm = calloc(1,
sizeof(
struct NewMenu) * (
max + 1));
310 if(nm == NULL)
return NULL;
312 for(i = 0; i <
max; i++) {
314 nm[i].nm_Type = NM_IGNORE;
318 if(md[i]->menutype == NM_TITLE) {
322 if(md[j]->menulab != NM_BARLABEL) {
323 if(md[j]->menutype == NM_ITEM) {
325 if(item_size > txtlen) {
331 }
while((j <=
max) && (md[j] != NULL) && (md[j]->menutype != NM_TITLE) && (md[j]->menutype != 0));
337 if((md[i]->menuicon != NULL) && (md[i]->menulab != NM_BARLABEL)) {
339 Object *restrict submenuarrow = NULL;
344 BITMAP_Masking, TRUE,
353 GetAttr(IA_Width, icon, (ULONG *)&icon_width);
355 if(md[i]->menutype != NM_SUB) {
359 left_posn = left_posn -
360 TextLength(rp, md[i]->menulab, strlen(md[i]->menulab)) -
361 icon_width - space_width;
363 if((md[i]->menutype == NM_ITEM) && md[i+1] && (md[i+1]->menutype == NM_SUB)) {
366 submenuarrow =
NewObject(NULL,
"sysiclass",
367 SYSIA_Which, MENUSUB,
374 LABEL_MenuMode, TRUE,
376 LABEL_DisposeImage, TRUE,
380 LABEL_DisposeImage, TRUE,
381 LABEL_Image, submenuarrow,
384 if(md[i]->menuobj) md[i]->
menutype |= MENU_IMAGE;
391 nm[i].nm_Label = (
void *)md[i]->menuobj;
393 nm[i].nm_Label = md[i]->
menulab;
395 if((md[i]->menukey) && (strlen(md[i]->menukey) == 1)) {
396 nm[i].nm_CommKey = md[i]->
menukey;
398 nm[i].nm_Flags = md[i]->
flags;
399 if(md[i]->menu_hook.h_Entry) nm[i].nm_UserData = &md[i]->
menu_hook;
401 if(md[i]->menuicon) {
402 free(md[i]->menuicon);
407 FreeScreenDrawInfo(
scrn, dri);
409 vi = GetVisualInfo(
scrn, TAG_DONE);
410 imenu = CreateMenus(nm, TAG_DONE);
411 LayoutMenus(imenu, vi,
412 GTMN_NewLookMenus, TRUE, TAG_DONE);
423 return ami_menu_layout_mc(md,
max);
434 DisposeObject((Object *)imenu);
444 Object *restrict obj;
445 Object *restrict menu_item_obj;
448 if(menu == NULL)
return;
452 menu_item_obj = (Object *)
IDoMethod((Object *)menu, MM_FINDID, 0, menu_item);
455 while((obj = (Object *)
IDoMethod(menu_item_obj, MM_NEXTCHILD, 0, NULL)) != NULL) {
456 IDoMethod(menu_item_obj, OM_REMMEMBER, obj);
461 for(i = (menu_item + 1); i <=
max; i++) {
462 if(md[i] == NULL)
continue;
470 ami_menu_layout_mc_recursive(menu_item_obj, md, NM_ITEM, (menu_item + 1),
max);
struct Screen * ami_gui_get_screen(void)
Get a pointer to the screen NetSurf is running on.
static struct Screen * scrn
bool ami_locate_resource(char *fullpath, const char *file)
nserror
Enumeration of error codes.
void ami_utf8_free(char *ptr)
char * ami_utf8_easy(const char *string)
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
APTR NewObject(struct IClass *classPtr, CONST_STRPTR classID, ULONG tagList,...)
Minimal compatibility header for AmigaOS 3.
#define LIB_IS_AT_LEAST(B, V, R)
Interface to utility string handling.