Esempio n. 1
0
/** Exported interface documented in selectmenu.h **/
BOOL ami_selectmenu_is_safe(void)
{
	struct Library *PopupMenuBase;
	BOOL popupmenu_lib_ok = FALSE;

	if((PopupMenuBase = OpenLibrary("popupmenu.library", 53))) {
		NSLOG(netsurf, INFO, "popupmenu.library v%d.%d",
		      PopupMenuBase->lib_Version, PopupMenuBase->lib_Revision);
		if(LIB_IS_AT_LEAST((struct Library *)PopupMenuBase, 53, 11))
			popupmenu_lib_ok = TRUE;
		CloseLibrary(PopupMenuBase);
	}

	return popupmenu_lib_ok;
}
Esempio n. 2
0
File: menu.c Progetto: ysei/NetSurf
static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
{
	int i, j;
	int txtlen = 0;
	struct RastPort *rp = &scrn->RastPort;
	struct DrawInfo *dri = GetScreenDrawInfo(scrn);
	
	if(menu_glyphs_loaded == false)
		ami_menu_load_glyphs(dri);

	for(i=0; i <= AMI_MENU_AREXX_MAX; i++)
	{
		if(gwin->menutype[i] == NM_TITLE) {
			j = i + 1;
			txtlen = 0;
			int item_size = 0;
			do {
				if(gwin->menulab[j] != NM_BARLABEL) {
					if(gwin->menutype[j] == NM_ITEM) {
						item_size = TextLength(rp, gwin->menulab[j], strlen(gwin->menulab[j]));
						if(gwin->menukey[j]) {
							item_size += TextLength(rp, &gwin->menukey[j], 1);
							item_size += menu_glyph_width[NSA_GLYPH_AMIGAKEY];
							/**TODO: take account of the size of other imagery too
							 */
						}
						
						if(item_size > txtlen) {
							txtlen = item_size;
						}
					}
				}
				j++;
			} while((gwin->menutype[j] != NM_TITLE) && (gwin->menutype[j] != 0));
		}

		if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 6)) {
			/* GadTools 53.6+ only. For now we will only create the menu
				using label.image if there's a bitmap associated with the item. */
			if((gwin->menuicon[i] != NULL) && (gwin->menulab[i] != NM_BARLABEL)) {
				int icon_width = 0;
				Object *submenuarrow = NULL;
				Object *icon = 	BitMapObject,
						BITMAP_Screen, scrn,
						BITMAP_SourceFile, gwin->menuicon[i],
						BITMAP_Masking, TRUE,
					BitMapEnd;
				GetAttr(IA_Width, icon, (ULONG *)&icon_width);
				
				if((gwin->menutype[i] == NM_ITEM) && (gwin->menutype[i+1] == NM_SUB)) {
					submenuarrow = NewObject(NULL, "sysiclass",
										SYSIA_Which, MENUSUB,
										SYSIA_DrawInfo, dri,
										IA_Left, txtlen - TextLength(rp, gwin->menulab[i], strlen(gwin->menulab[i])) -
													menu_glyph_width[NSA_GLYPH_SUBMENU] - icon_width,
									TAG_DONE);
				}

				/**TODO: Checkmark/MX images and keyboard shortcuts
				 */
				
				gwin->menuobj[i] = LabelObject,
					LABEL_DrawInfo, dri,
					LABEL_DisposeImage, TRUE,
					LABEL_Image, icon,
					LABEL_Text, gwin->menulab[i],
					LABEL_DisposeImage, TRUE,
					LABEL_Image, submenuarrow,
				LabelEnd;

				if(gwin->menuobj[i]) gwin->menutype[i] |= MENU_IMAGE;
			}
		}

		gwin->menu[i].nm_Type = gwin->menutype[i];
		
		if(gwin->menuobj[i])
			gwin->menu[i].nm_Label = (void *)gwin->menuobj[i];
		else
			gwin->menu[i].nm_Label = gwin->menulab[i];

		if(gwin->menukey[i]) gwin->menu[i].nm_CommKey = &gwin->menukey[i];
		gwin->menu[i].nm_Flags = 0;
		if(gwin->menu_hook[i].h_Entry) gwin->menu[i].nm_UserData = &gwin->menu_hook[i];
		
		if(gwin->menuicon[i]) {
			free(gwin->menuicon[i]);
			gwin->menuicon[i] = NULL;
		}
	}
	
	FreeScreenDrawInfo(scrn, dri);
	
	return gwin;
}