Merge branch 'chris/gadtools-53-5'
This commit is contained in:
commit
864762cbe6
45
amiga/menu.c
45
amiga/menu.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2008-9 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
* Copyright 2008-9,2013 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
|
@ -64,17 +64,6 @@
|
|||
#include "utils/messages.h"
|
||||
#include "utils/schedule.h"
|
||||
|
||||
#define IMAGE_MENU_ITEM(n, i, t) \
|
||||
gwin->menulab[n] = LabelObject, \
|
||||
LABEL_DrawInfo, dri, \
|
||||
LABEL_DisposeImage, TRUE, \
|
||||
LABEL_Image, BitMapObject, \
|
||||
BITMAP_Screen, scrn, \
|
||||
BITMAP_SourceFile, i, \
|
||||
BitMapEnd, \
|
||||
LABEL_Text, t, \
|
||||
LabelEnd;
|
||||
|
||||
BOOL menualreadyinit;
|
||||
const char * const netsurf_version;
|
||||
const char * const verdate;
|
||||
|
@ -170,6 +159,32 @@ static void ami_menu_alloc_item(struct gui_window_2 *gwin, int num, UBYTE type,
|
|||
}
|
||||
}
|
||||
|
||||
if((GadToolsBase->lib_Version > 53) ||
|
||||
((GadToolsBase->lib_Version == 53) && (GadToolsBase->lib_Revision >= 5))) {
|
||||
/* GadTools 53.5+ only. For now we will only create the menu
|
||||
using label.image if there's a bitmap associated with the item. */
|
||||
if(bm != NULL) {
|
||||
struct DrawInfo *dri = GetScreenDrawInfo(scrn);
|
||||
struct BitMap *menu_icon = ami_bitmap_get_native(bm, 16, 16, NULL);
|
||||
|
||||
gwin->menuobj[num] = LabelObject,
|
||||
LABEL_DrawInfo, dri,
|
||||
LABEL_DisposeImage, TRUE,
|
||||
LABEL_Image, BitMapObject,
|
||||
BITMAP_Screen, scrn,
|
||||
BITMAP_BitMap, menu_icon,
|
||||
BITMAP_Width, 16,
|
||||
BITMAP_Height, 16,
|
||||
BitMapEnd,
|
||||
LABEL_Text, gwin->menulab[num],
|
||||
LabelEnd;
|
||||
|
||||
gwin->menutype[num] |= MENU_IMAGE;
|
||||
|
||||
FreeScreenDrawInfo(scrn, dri);
|
||||
}
|
||||
}
|
||||
|
||||
if(key) gwin->menukey[num] = key;
|
||||
if(func) gwin->menu_hook[num].h_Entry = (HOOKFUNC)func;
|
||||
if(hookdata) gwin->menu_hook[num].h_Data = hookdata;
|
||||
|
@ -178,7 +193,6 @@ static void ami_menu_alloc_item(struct gui_window_2 *gwin, int num, UBYTE type,
|
|||
void ami_init_menulabs(struct gui_window_2 *gwin)
|
||||
{
|
||||
int i;
|
||||
struct DrawInfo *dri = GetScreenDrawInfo(scrn);
|
||||
|
||||
gwin->menutype = AllocVec(AMI_MENU_AREXX_MAX + 1, MEMF_PRIVATE | MEMF_CLEAR);
|
||||
|
||||
|
@ -290,8 +304,6 @@ void ami_init_menulabs(struct gui_window_2 *gwin)
|
|||
ami_menu_item_arexx_execute, NULL);
|
||||
ami_menu_alloc_item(gwin, M_BAR_A1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL);
|
||||
gwin->menutype[AMI_MENU_AREXX_MAX] = NM_END;
|
||||
|
||||
FreeScreenDrawInfo(scrn, dri);
|
||||
}
|
||||
|
||||
/* Menu refresh for hotlist */
|
||||
|
@ -458,7 +470,8 @@ void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
|
|||
if(*gen == 1) menu_type = NM_ITEM;
|
||||
if(*gen == 2) menu_type = NM_SUB;
|
||||
|
||||
ami_menu_alloc_item(gwin, *item, menu_type, tree_url_node_get_title(node), 0, NULL,
|
||||
ami_menu_alloc_item(gwin, *item, menu_type, tree_url_node_get_title(node),
|
||||
0, tree_url_node_get_icon(node),
|
||||
ami_menu_item_hotlist_entries, (void *)tree_url_node_get_url(node));
|
||||
if(tree_node_is_folder(node) && (!tree_node_get_child(node)))
|
||||
gwin->menu[*item].nm_Flags = NM_ITEMDISABLED;
|
||||
|
|
|
@ -1551,6 +1551,17 @@ const char *tree_node_element_get_text(struct node_element *element)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the node element's icon
|
||||
*
|
||||
* \return the node element's icon
|
||||
*/
|
||||
struct bitmap *tree_node_element_get_icon(struct node_element *element)
|
||||
{
|
||||
return element->bitmap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the root node of a tree
|
||||
*
|
||||
|
|
|
@ -200,6 +200,7 @@ void tree_update_node_element(struct tree *tree, struct node_element *element,
|
|||
const char *text, void *bitmap);
|
||||
bool tree_update_element_text(struct tree *tree, struct node_element *element, char *text);
|
||||
const char *tree_node_element_get_text(struct node_element *element);
|
||||
struct bitmap *tree_node_element_get_icon(struct node_element *element);
|
||||
struct node *tree_get_root(struct tree *tree);
|
||||
bool tree_is_edited(struct tree *tree);
|
||||
tree_drag_type tree_drag_status(struct tree *tree);
|
||||
|
|
|
@ -339,6 +339,17 @@ const char *tree_url_node_get_url(struct node *node)
|
|||
return tree_node_element_get_text(element);
|
||||
}
|
||||
|
||||
|
||||
struct bitmap *tree_url_node_get_icon(struct node *node)
|
||||
{
|
||||
struct node_element *element;
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
|
||||
if (element == NULL)
|
||||
return NULL;
|
||||
return tree_node_element_get_icon(element);
|
||||
}
|
||||
|
||||
|
||||
void tree_url_node_edit_title(struct tree *tree, struct node *node)
|
||||
{
|
||||
struct node_element *element;
|
||||
|
|
|
@ -43,6 +43,7 @@ void tree_update_URL_node(struct tree *tree, struct node *node,
|
|||
nsurl *url, const struct url_data *data);
|
||||
const char *tree_url_node_get_title(struct node *node);
|
||||
const char *tree_url_node_get_url(struct node *node);
|
||||
struct bitmap *tree_url_node_get_icon(struct node *node);
|
||||
void tree_url_node_edit_title(struct tree *tree, struct node *node);
|
||||
void tree_url_node_edit_url(struct tree *tree, struct node *node);
|
||||
|
||||
|
|
Loading…
Reference in New Issue