コード例 #1
0
ファイル: con_language.c プロジェクト: EyMenZ/NetSurf-OS3
bool ro_gui_options_language_initialise(wimp_w w)
{
	/* set the current values */
	ro_gui_set_icon_string(w, LANGUAGE_INTERFACE_FIELD,
		ro_gui_options_language_name(nsoption_charp(language) ?
			nsoption_charp(language) : "en"), true);
	ro_gui_set_icon_string(w, LANGUAGE_WEB_PAGES_FIELD,
		ro_gui_options_language_name(nsoption_charp(accept_language) ?
			nsoption_charp(accept_language) : "en"), true);

	/* initialise all functions for a newly created window */
	ro_gui_wimp_event_register_menu_gright(w, LANGUAGE_INTERFACE_FIELD,
			LANGUAGE_INTERFACE_GRIGHT, languages_menu);
	ro_gui_wimp_event_register_menu_gright(w, LANGUAGE_WEB_PAGES_FIELD,
			LANGUAGE_WEB_PAGES_GRIGHT, languages_menu);
	ro_gui_wimp_event_register_button(w, LANGUAGE_DEFAULT_BUTTON,
			ro_gui_options_language_default);
	ro_gui_wimp_event_register_cancel(w, LANGUAGE_CANCEL_BUTTON);
	ro_gui_wimp_event_register_ok(w, LANGUAGE_OK_BUTTON,
			ro_gui_options_language_ok);
	ro_gui_wimp_event_set_help_prefix(w, "HelpLanguageConfig");
	ro_gui_wimp_event_memorise(w);
	return true;

}
コード例 #2
0
void ro_gui_dialog_init(void)
{
	dialog_info = ro_gui_dialog_create("info");
	dialog_main = ro_gui_dialog_create("main");
	dialog_saveas = ro_gui_dialog_create("saveas");
	dialog_warning = ro_gui_dialog_create("warning");
	ro_gui_set_icon_string(dialog_main, ICON_MAIN_NAME, "\0");
	ro_gui_set_icon_string(dialog_main, ICON_MAIN_AUTHOR, "\0");
}
コード例 #3
0
ファイル: con_image.c プロジェクト: arczi84/NetSurf-68k
bool ro_gui_options_image_initialise(wimp_w w)
{
	int i;

	/* load the sprite file */
	if (example_users == 0) {
		char pathname[256];
		snprintf(pathname, 256, "%s.Resources.Image", NETSURF_DIR);
		pathname[255] = '\0';
		example_images = ro_gui_load_sprite_file(pathname);
		if (!example_images)
			return false;
	}
	example_users++;

	/* set the current values */
	for (i = 0; (i < 4); i++) {
		if ((unsigned int)nsoption_int(plot_fg_quality) == tinct_options[i])
			ro_gui_set_icon_string(w, IMAGE_FOREGROUND_FIELD,
					image_quality_menu->entries[i].
						data.indirected_text.text, true);
		if ((unsigned int)nsoption_int(plot_bg_quality) == tinct_options[i])
			ro_gui_set_icon_string(w, IMAGE_BACKGROUND_FIELD,
					image_quality_menu->entries[i].
						data.indirected_text.text, true);
	}
	ro_gui_set_icon_decimal(w, IMAGE_SPEED_FIELD,
				nsoption_int(minimum_gif_delay), 2);
	ro_gui_set_icon_selected_state(w, IMAGE_DISABLE_ANIMATION,
				       !nsoption_bool(animate_images));
	ro_gui_options_update_shading(w);

	/* register icons */
	ro_gui_wimp_event_register_menu_gright(w, IMAGE_FOREGROUND_FIELD,
			IMAGE_FOREGROUND_MENU, image_quality_menu);
	ro_gui_wimp_event_register_menu_gright(w, IMAGE_BACKGROUND_FIELD,
			IMAGE_BACKGROUND_MENU, image_quality_menu);
	ro_gui_wimp_event_register_text_field(w, IMAGE_SPEED_TEXT);
	ro_gui_wimp_event_register_numeric_field(w, IMAGE_SPEED_FIELD,
			IMAGE_SPEED_INC, IMAGE_SPEED_DEC, 0, 6000, 10, 2);
	ro_gui_wimp_event_register_checkbox(w, IMAGE_DISABLE_ANIMATION);
	ro_gui_wimp_event_register_text_field(w, IMAGE_SPEED_CS);
	ro_gui_wimp_event_register_redraw_window(w,
			ro_gui_options_image_redraw);
	ro_gui_wimp_event_register_mouse_click(w,
			ro_gui_options_image_click);
	ro_gui_wimp_event_register_menu_selection(w,
			ro_gui_options_image_update);
	ro_gui_wimp_event_register_cancel(w, IMAGE_CANCEL_BUTTON);
	ro_gui_wimp_event_register_ok(w, IMAGE_OK_BUTTON,
			ro_gui_options_image_ok);
	ro_gui_wimp_event_set_help_prefix(w, "HelpImageConfig");
	ro_gui_wimp_event_memorise(w);

	return true;
}
コード例 #4
0
ファイル: con_language.c プロジェクト: EyMenZ/NetSurf-OS3
void ro_gui_options_language_default(wimp_pointer *pointer)
{
	const char *code;

	code = ro_gui_default_language();
	ro_gui_set_icon_string(pointer->w, LANGUAGE_INTERFACE_FIELD,
			ro_gui_options_language_name(code ?
					code : "en"), true);
	ro_gui_set_icon_string(pointer->w, LANGUAGE_WEB_PAGES_FIELD,
			ro_gui_options_language_name(code ?
					code : "en"), true);
}
コード例 #5
0
void ro_gui_save_open(int save_type, int x, int y)
{
	char icon_buf[20];
	const char *icon = icon_buf;
	os_error *error;

	gui_save_current_type = save_type;
	if (save_type == SAVE_THEME) {
	  	if (theme_filename == NULL) {
	  		theme_filename = malloc(6);
	  		if (!theme_filename) {
	  		  	LOG(("No memory for malloc()"));
	  			warn_user("NoMemory", 0);
	  			return;
	  		}
	  		sprintf(theme_filename, "Theme");
	  	}
	 	gui_save_filetype = 0xffd;
	 	ro_gui_set_window_title(dialog_saveas, messages_get("SaveTitle"));
		ro_gui_set_icon_string(dialog_saveas, ICON_SAVE_PATH, theme_filename);
		reset_filename = theme_filename;
	} else {
	  	if (sprite_filename == NULL) {
	  		sprite_filename = malloc(8);
	  		if (!sprite_filename) {
	  		  	LOG(("No memory for malloc()"));
	  			warn_user("NoMemory", 0);
	  			return;
	  		}
	  		sprintf(sprite_filename, "Sprites");
	  	}
		gui_save_filetype = 0xff9;
	 	ro_gui_set_window_title(dialog_saveas, messages_get("ExportTitle"));
		ro_gui_set_icon_string(dialog_saveas, ICON_SAVE_PATH, sprite_filename);
		reset_filename = sprite_filename;
	}
	  

	/* icon */
	sprintf(icon_buf, "file_%.3x", gui_save_filetype);
	ro_gui_set_icon_string(dialog_saveas, ICON_SAVE_ICON, icon);

	/* open sub menu or persistent dialog */
	error = xwimp_create_sub_menu((wimp_menu *) dialog_saveas,
				x, y);
	if (error) {
		LOG(("xwimp_create_sub_menu: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("MenuError", error->errmess);
	}
}
コード例 #6
0
ファイル: con_connect.c プロジェクト: seanregan/browser
void ro_gui_options_connection_default(wimp_pointer *pointer)
{
	ro_gui_set_icon_string(pointer->w, CONNECTION_PROXY_FIELD,
			proxy_type_menu->entries[0].
				data.indirected_text.text, true);
	ro_gui_set_icon_string(pointer->w, CONNECTION_PROXY_HOST, "", true);
	ro_gui_set_icon_integer(pointer->w, CONNECTION_PROXY_PORT, 8080);
	ro_gui_set_icon_string(pointer->w, CONNECTION_PROXY_USERNAME, "", true);
	ro_gui_set_icon_string(pointer->w, CONNECTION_PROXY_PASSWORD, "", true);
	ro_gui_set_icon_integer(pointer->w, CONNECTION_MAX_FETCH_FIELD, 24);
	ro_gui_set_icon_integer(pointer->w, CONNECTION_HOST_FETCH_FIELD, 5);
	ro_gui_set_icon_integer(pointer->w, CONNECTION_CACHE_FETCH_FIELD, 6);
	ro_gui_options_connection_update(pointer->w, -1, NULL, NULL, NO_ACTION);
}
コード例 #7
0
void ro_gui_save_datasave_ack(wimp_message *message)
{
	char *path = message->data.data_xfer.file_name;
	os_error *error;

	if (!ro_gui_save(path)) return;
	ro_gui_set_icon_string(dialog_saveas, ICON_SAVE_PATH, reset_filename);

	/*	Close the save window
	*/
	ro_gui_dialog_close(dialog_saveas);

	/* Ack successful save with message_DATA_LOAD */
	message->action = message_DATA_LOAD;
	message->your_ref = message->my_ref;
	error = xwimp_send_message_to_window(wimp_USER_MESSAGE, message,
			message->data.data_xfer.w, message->data.data_xfer.i, 0);
	if (error) {
		LOG(("xwimp_send_message_to_window: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("FileError", error->errmess);
	}

	if (close_menu) {
		error = xwimp_create_menu(wimp_CLOSE_MENU, 0, 0);
		if (error) {
			LOG(("xwimp_create_menu: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("MenuError", error->errmess);
		}
	}
	close_menu = true;
}
コード例 #8
0
void ro_gui_save_click(wimp_pointer *pointer)
{
	switch (pointer->i) {
	  	case ICON_SAVE_OK:
	  		close_menu = (pointer->buttons == wimp_CLICK_SELECT);
	  		ro_gui_save(ro_gui_get_icon_string(dialog_saveas, ICON_SAVE_PATH));
	  		if (pointer->buttons == wimp_CLICK_SELECT) {
	  		  	xwimp_create_menu((wimp_menu *)-1, 0, 0);
	  		  	ro_gui_dialog_close(pointer->w);
	  		}
	  		break;
	  	case ICON_SAVE_CANCEL:
	  		if (pointer->buttons == wimp_CLICK_SELECT) {
	  		  	xwimp_create_menu((wimp_menu *)-1, 0, 0);
	  		  	ro_gui_dialog_close(pointer->w);
	  		} else if (pointer->buttons == wimp_CLICK_ADJUST) {
	  			ro_gui_set_icon_string(dialog_saveas, ICON_SAVE_PATH, reset_filename);
	  		}
	  		break;
		case ICON_SAVE_ICON:
			if (pointer->buttons == wimp_DRAG_SELECT) {
				ro_gui_drag_icon(pointer);
			}
			break;
	}
}
コード例 #9
0
ファイル: con_home.c プロジェクト: galexcode/NetSurf68k
bool ro_gui_options_home_initialise(wimp_w w)
{
	/* set the current values */
	ro_gui_set_icon_string(w, HOME_URL_FIELD,
                               nsoption_charp(homepage_url) ? 
                               nsoption_charp(homepage_url) : "", true);

	ro_gui_set_icon_selected_state(w, HOME_OPEN_STARTUP,
                                       nsoption_bool(open_browser_at_startup));

	ro_gui_set_icon_shaded_state(w,
			HOME_URL_GRIGHT, !ro_gui_url_suggest_prepare_menu());

	/* initialise all functions for a newly created window */
	ro_gui_wimp_event_register_menu_gright(w, HOME_URL_FIELD,
			HOME_URL_GRIGHT, ro_gui_url_suggest_menu);
	ro_gui_wimp_event_register_checkbox(w, HOME_OPEN_STARTUP);
	ro_gui_wimp_event_register_button(w, HOME_DEFAULT_BUTTON,
			ro_gui_options_home_default);
	ro_gui_wimp_event_register_cancel(w, HOME_CANCEL_BUTTON);
	ro_gui_wimp_event_register_ok(w, HOME_OK_BUTTON,
			ro_gui_options_home_ok);
	ro_gui_wimp_event_register_menu_prepare(w,
			ro_gui_options_home_menu_prepare);
	ro_gui_wimp_event_set_help_prefix(w, "HelpHomeConfig");
	ro_gui_wimp_event_memorise(w);
	return true;

}
コード例 #10
0
ファイル: save.c プロジェクト: MarkieMark/netsurf-git-svn
void ro_gui_save_prepare(gui_save_type save_type, hlcache_handle *h,
		struct selection *s, const char *url, const char *title)
{
	char name_buf[FILENAME_MAX];
	size_t leaf_offset = 0;
	char icon_buf[20];

	assert( (save_type == GUI_SAVE_LINK_URI) ||
			(save_type == GUI_SAVE_LINK_URL) ||
			(save_type == GUI_SAVE_LINK_TEXT) ||
			(save_type == GUI_SAVE_HOTLIST_EXPORT_HTML) ||
			(save_type == GUI_SAVE_HISTORY_EXPORT_HTML) ||
			(save_type == GUI_SAVE_TEXT_SELECTION) || h);

	gui_save_selection = s;
	gui_save_url = url;
	gui_save_title = title;

	if (save_dir) {
		leaf_offset = save_dir_len;
		memcpy(name_buf, save_dir, leaf_offset);
		name_buf[leaf_offset++] = '.';
	}

	ro_gui_save_set_state(h, save_type, h ? content_get_url(h) : url,
			name_buf + leaf_offset, icon_buf);

	ro_gui_set_icon_sprite(dialog_saveas, ICON_SAVE_ICON, saveas_area,
			icon_buf);

	ro_gui_set_icon_string(dialog_saveas, ICON_SAVE_PATH, name_buf, true);
	ro_gui_wimp_event_memorise(dialog_saveas);
}
コード例 #11
0
ファイル: con_inter.c プロジェクト: EyMenZ/NetSurf-OS3
bool ro_gui_options_interface_initialise(wimp_w w)
{
	/* set the current values */
	ro_gui_set_icon_selected_state(w, INTERFACE_STRIP_EXTNS_OPTION,
                                       nsoption_bool(strip_extensions));
	ro_gui_set_icon_selected_state(w, INTERFACE_CONFIRM_OVWR_OPTION,
                                       nsoption_bool(confirm_overwrite));
	ro_gui_set_icon_selected_state(w, INTERFACE_URL_COMPLETE_OPTION,
                                       nsoption_bool(url_suggestion));
	ro_gui_set_icon_selected_state(w, INTERFACE_HISTORY_TOOLTIP_OPTION,
                                       nsoption_bool(history_tooltip));
	ro_gui_set_icon_selected_state(w, INTERFACE_THUMBNAIL_ICONISE_OPTION,
                                       nsoption_bool(thumbnail_iconise));
	ro_gui_set_icon_selected_state(w, INTERFACE_USE_EXTERNAL_HOTLIST,
                                       nsoption_bool(external_hotlists));
	ro_gui_set_icon_string(w, INTERFACE_EXTERNAL_HOTLIST_APP,
                               (nsoption_charp(external_hotlist_app)) ?
                               nsoption_charp(external_hotlist_app) : "", false);

	ro_gui_set_icon_shaded_state(w, INTERFACE_EXTERNAL_HOTLIST_APP,
                                     !nsoption_bool(external_hotlists));

	/* initialise all functions for a newly created window */
	ro_gui_wimp_event_register_mouse_click(w,
			ro_gui_options_interface_click);
	ro_gui_wimp_event_register_button(w, INTERFACE_DEFAULT_BUTTON,
			ro_gui_options_interface_default);
	ro_gui_wimp_event_register_cancel(w, INTERFACE_CANCEL_BUTTON);
	ro_gui_wimp_event_register_ok(w, INTERFACE_OK_BUTTON,
			ro_gui_options_interface_ok);
	ro_gui_wimp_event_set_help_prefix(w, "HelpInterfaceConfig");
	ro_gui_wimp_event_memorise(w);
	return true;

}
コード例 #12
0
nserror theme_install_callback(hlcache_handle *handle,
		const hlcache_event *event, void *pw)
{
	char buffer[256];
	int author_indent = 0;

	switch (event->type) {

	case CONTENT_MSG_DONE:
	{
		const char *source_data;
		unsigned long source_size;

		theme_install_content = handle;

		source_data = content_get_source_data(handle, &source_size);

		if (!theme_install_read(source_data, source_size)) {
			warn_user("ThemeInvalid", 0);
			theme_install_close(dialog_theme_install);
			break;
		}

		/* remove '© ' from the start of the data */
		if (theme_install_descriptor.author[0] == '©')
			author_indent++;
		while (theme_install_descriptor.author[author_indent] == ' ')
			author_indent++;
		snprintf(buffer, sizeof buffer, messages_get("ThemeInstall"),
				theme_install_descriptor.name,
				&theme_install_descriptor.author[author_indent]);
		buffer[sizeof buffer - 1] = '\0';
		ro_gui_set_icon_string(dialog_theme_install,
				ICON_THEME_INSTALL_MESSAGE,
				buffer, true);
		ro_gui_set_icon_shaded_state(dialog_theme_install,
				ICON_THEME_INSTALL_INSTALL, false);
	}
		break;

	case CONTENT_MSG_ERROR:
		theme_install_close(dialog_theme_install);
		warn_user(event->data.error, 0);
		break;

	default:
		break;
	}

	return NSERROR_OK;
}
コード例 #13
0
ファイル: con_image.c プロジェクト: arczi84/NetSurf-68k
bool ro_gui_options_image_click(wimp_pointer *pointer)
{
	unsigned int old_fg, old_bg, bg, fg;

	ro_gui_options_image_read(pointer->w, &old_bg, &old_fg);
	switch (pointer->i) {
		case IMAGE_DEFAULT_BUTTON:
			ro_gui_set_icon_string(pointer->w,
					IMAGE_FOREGROUND_FIELD,
					image_quality_menu->entries[3].
						data.indirected_text.text, true);
  			ro_gui_set_icon_string(pointer->w,
					IMAGE_BACKGROUND_FIELD,
					image_quality_menu->entries[2].
						data.indirected_text.text, true);
			ro_gui_set_icon_decimal(pointer->w, IMAGE_SPEED_FIELD,
					10, 2);
			ro_gui_set_icon_selected_state(pointer->w,
					IMAGE_DISABLE_ANIMATION, false);
		case IMAGE_DISABLE_ANIMATION:
			ro_gui_options_update_shading(pointer->w);
			break;
		case IMAGE_CANCEL_BUTTON:
			ro_gui_wimp_event_restore(pointer->w);
			break;
		default:
			return false;
	}

	ro_gui_options_image_read(pointer->w, &bg, &fg);
	if ((bg != old_bg) || (fg != old_fg))
		ro_gui_options_image_update(pointer->w, pointer->i,
				NULL, NULL, NO_ACTION);

	return false;
}
コード例 #14
0
ファイル: con_inter.c プロジェクト: EyMenZ/NetSurf-OS3
void ro_gui_options_interface_default(wimp_pointer *pointer)
{
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_STRIP_EXTNS_OPTION, true);
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_CONFIRM_OVWR_OPTION, true);
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_URL_COMPLETE_OPTION, true);
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_HISTORY_TOOLTIP_OPTION, true);
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_THUMBNAIL_ICONISE_OPTION, true);
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_USE_EXTERNAL_HOTLIST, false);
	ro_gui_set_icon_string(pointer->w, INTERFACE_EXTERNAL_HOTLIST_APP,
			"", false);
}
コード例 #15
0
ファイル: save.c プロジェクト: arczi84/NetSurf-68k
/**
 * Prepares the save box to reflect gui_save_type and a content, and
 * opens it.
 *
 * \param  save_type  type of save
 * \param  h          content to save
 * \param  s          selection to save
 * \param  url        url to be saved (link types)
 * \param  title      title (if any), when saving links
 */
void ro_gui_save_prepare(gui_save_type save_type, struct hlcache_handle *h,
		char *s, const nsurl *url, const char *title)
{
	char name_buf[FILENAME_MAX];
	size_t leaf_offset = 0;
	char icon_buf[20];

	assert( (save_type == GUI_SAVE_LINK_URI) ||
			(save_type == GUI_SAVE_LINK_URL) ||
			(save_type == GUI_SAVE_LINK_TEXT) ||
			(save_type == GUI_SAVE_HOTLIST_EXPORT_HTML) ||
			(save_type == GUI_SAVE_HISTORY_EXPORT_HTML) ||
			(save_type == GUI_SAVE_TEXT_SELECTION) || h);

	if (gui_save_selection == NULL)
		free(gui_save_selection);

	gui_save_selection = s;
	if (url != NULL) {
		gui_save_url = nsurl_access(url);
	} else {
		gui_save_url = NULL;
	}
	gui_save_title = title;

	if (save_dir) {
		leaf_offset = save_dir_len;
		memcpy(name_buf, save_dir, leaf_offset);
		name_buf[leaf_offset++] = '.';
	}

	if (h != NULL) {
		url = hlcache_handle_get_url(h);
	}

	ro_gui_save_set_state(h, save_type, url,
			name_buf + leaf_offset, FILENAME_MAX - leaf_offset,
			icon_buf, sizeof(icon_buf));

	ro_gui_set_icon_sprite(dialog_saveas, ICON_SAVE_ICON, saveas_area,
			icon_buf);

	ro_gui_set_icon_string(dialog_saveas, ICON_SAVE_PATH, name_buf, true);
	ro_gui_wimp_event_memorise(dialog_saveas);
}
コード例 #16
0
ファイル: url_bar.c プロジェクト: galexcode/NetSurf68k
void ro_gui_url_bar_set_url(struct url_bar *url_bar, const char *url,
		bool is_utf8, bool set_caret)
{
	wimp_caret	caret;
	os_error	*error;
	const char	*set_url;

	if (url_bar == NULL || url_bar->text_buffer == NULL)
		return;

	if (url_bar->text_icon == -1) {
		strncpy(url_bar->text_buffer, url, url_bar->text_size);
		return;
	}

	ro_gui_set_icon_string(url_bar->window, url_bar->text_icon,
			url, is_utf8);

	error = xwimp_get_caret_position(&caret);
	if (error) {
		LOG(("xwimp_get_caret_position: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	if (set_caret || (caret.w == url_bar->window &&
			caret.i == url_bar->text_icon)) {
		set_url = ro_gui_get_icon_string(url_bar->window,
				url_bar->text_icon);

		error = xwimp_set_caret_position(url_bar->window,
				url_bar->text_icon, 0, 0, -1, strlen(set_url));
		if (error) {
			LOG(("xwimp_set_caret_position: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("WimpError", error->errmess);
		}
	}
}
コード例 #17
0
void theme_install_start(hlcache_handle *c)
{
	assert(c != NULL);
	assert(content_get_type(c) == CONTENT_THEME);

	if (ro_gui_dialog_open_top(dialog_theme_install, NULL, 0, 0)) {
		warn_user("ThemeInstActive", 0);
		return;
	}

	/* stop theme sitting in memory cache */
	content_invalidate_reuse_data(c);

	hlcache_handle_replace_callback(c, theme_install_callback, NULL);

	ro_gui_set_icon_string(dialog_theme_install, ICON_THEME_INSTALL_MESSAGE,
			messages_get("ThemeInstDown"), true);
	ro_gui_set_icon_shaded_state(dialog_theme_install,
			ICON_THEME_INSTALL_INSTALL, true);
	ro_gui_wimp_event_register_close_window(dialog_theme_install,
			theme_install_close);
}
コード例 #18
0
ファイル: con_fonts.c プロジェクト: galexcode/NetSurf68k
bool ro_gui_options_fonts_initialise(wimp_w w)
{
	/* set the current values */
	ro_gui_set_icon_decimal(w, FONT_DEFAULT_SIZE, nsoption_int(font_size), 1);
	ro_gui_set_icon_decimal(w, FONT_MINIMUM_SIZE, nsoption_int(font_min_size), 1);
	ro_gui_set_icon_string(w, FONT_SANS_FIELD, nsoption_charp(font_sans), true);
	ro_gui_set_icon_string(w, FONT_SERIF_FIELD, nsoption_charp(font_serif), true);
	ro_gui_set_icon_string(w, FONT_MONOSPACE_FIELD, nsoption_charp(font_mono), true);
	ro_gui_set_icon_string(w, FONT_CURSIVE_FIELD, nsoption_charp(font_cursive), true);
	ro_gui_set_icon_string(w, FONT_FANTASY_FIELD, nsoption_charp(font_fantasy), true);
	ro_gui_set_icon_string(w, FONT_DEFAULT_FIELD,
			       font_names[nsoption_int(font_default)], true);

	if (!ro_gui_options_fonts_init_menu())
		return false;

	/* initialise all functions for a newly created window */
	ro_gui_wimp_event_register_menu_gright(w, FONT_SANS_FIELD,
			FONT_SANS_MENU, rufl_family_menu);
	ro_gui_wimp_event_register_menu_gright(w, FONT_SERIF_FIELD,
			FONT_SERIF_MENU, rufl_family_menu);
	ro_gui_wimp_event_register_menu_gright(w, FONT_MONOSPACE_FIELD,
			FONT_MONOSPACE_MENU, rufl_family_menu);
	ro_gui_wimp_event_register_menu_gright(w, FONT_CURSIVE_FIELD,
			FONT_CURSIVE_MENU, rufl_family_menu);
	ro_gui_wimp_event_register_menu_gright(w, FONT_FANTASY_FIELD,
			FONT_FANTASY_MENU, rufl_family_menu);
	ro_gui_wimp_event_register_menu_gright(w, FONT_DEFAULT_FIELD,
			FONT_DEFAULT_MENU, default_menu);
	ro_gui_wimp_event_register_numeric_field(w, FONT_DEFAULT_SIZE,
			FONT_DEFAULT_INC, FONT_DEFAULT_DEC, 50, 1000, 1, 1);
	ro_gui_wimp_event_register_numeric_field(w, FONT_MINIMUM_SIZE,
			FONT_MINIMUM_INC, FONT_MINIMUM_DEC, 10, 500, 1, 1);
	ro_gui_wimp_event_register_button(w, FONT_DEFAULT_BUTTON,
			ro_gui_options_fonts_default);
	ro_gui_wimp_event_register_cancel(w, FONT_CANCEL_BUTTON);
	ro_gui_wimp_event_register_ok(w, FONT_OK_BUTTON,
			ro_gui_options_fonts_ok);
	ro_gui_wimp_event_set_help_prefix(w, "HelpFontConfig");
	ro_gui_wimp_event_memorise(w);
	return true;

}
コード例 #19
0
ファイル: con_fonts.c プロジェクト: galexcode/NetSurf68k
void ro_gui_options_fonts_default(wimp_pointer *pointer)
{
	const char *fallback = nsfont_fallback_font();

	/* set the default values */
	ro_gui_set_icon_decimal(pointer->w, FONT_DEFAULT_SIZE, 128, 1);
	ro_gui_set_icon_decimal(pointer->w, FONT_MINIMUM_SIZE, 85, 1);
	ro_gui_set_icon_string(pointer->w, FONT_SANS_FIELD,
			nsfont_exists("Homerton") ? "Homerton" : fallback, true);
	ro_gui_set_icon_string(pointer->w, FONT_SERIF_FIELD,
			nsfont_exists("Trinity") ? "Trinity" : fallback, true);
	ro_gui_set_icon_string(pointer->w, FONT_MONOSPACE_FIELD,
			nsfont_exists("Corpus") ? "Corpus" : fallback, true);
	ro_gui_set_icon_string(pointer->w, FONT_CURSIVE_FIELD,
			nsfont_exists("Churchill") ? "Churchill" : fallback, true);
	ro_gui_set_icon_string(pointer->w, FONT_FANTASY_FIELD,
			nsfont_exists("Sassoon") ? "Sassoon" : fallback, true);
	ro_gui_set_icon_string(pointer->w, FONT_DEFAULT_FIELD,
			font_names[0], true);
}
コード例 #20
0
ファイル: query.c プロジェクト: Achal-Aggarwal/netsurf
query_id query_user_xy(const char *query, const char *detail,
		const query_callback *cb, void *pw,
		const char *yes, const char *no,
		int x, int y)
{
	struct gui_query_window *qw;
	char query_buffer[300];
	os_error *error;
	wimp_icon *icn;
	int width;
	int len;
	int tx;
	char *local_text = NULL;
	nserror err;

	qw = malloc(sizeof(struct gui_query_window));
	if (!qw) {
		warn_user("NoMemory", NULL);
		return QUERY_INVALID;
	}

	qw->cb = cb;
	qw->pw = pw;
	qw->id = next_id++;
	qw->default_confirm = false;

	if (next_id == QUERY_INVALID)
		next_id++;

	if (!yes) yes = messages_get("Yes");
	if (!no) no = messages_get("No");

	/* set the text of the 'Yes' button and size accordingly */
	err = utf8_to_local_encoding(yes, 0, &local_text);
	if (err != NSERROR_OK) {
		assert(err != NSERROR_BAD_ENCODING);
		LOG(("utf8_to_local_encoding_failed"));
		local_text = NULL;
	}

	icn = &query_template->icons[ICON_QUERY_YES];
	len = strlen(local_text ? local_text : yes);
	len = max(len, icn->data.indirected_text.size - 1);
	memcpy(icn->data.indirected_text.text,
			local_text ? local_text: yes, len);
	icn->data.indirected_text.text[len] = '\0';

	free(local_text);
	local_text = NULL;

	error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width);
	if (error) {
		LOG(("xwimptextop_string_width: 0x%x:%s",
			error->errnum, error->errmess));
		width = len * 16;
	}
	if (!query_yes_width) query_yes_width = icn->extent.x1 - icn->extent.x0;
	width += 44;
	if (width < query_yes_width)
		width = query_yes_width;
	icn->extent.x0 = tx = icn->extent.x1 - width;

	/* set the text of the 'No' button and size accordingly */
	err = utf8_to_local_encoding(no, 0, &local_text);
	if (err != NSERROR_OK) {
		assert(err != NSERROR_BAD_ENCODING);
		LOG(("utf8_to_local_encoding_failed"));
		local_text = NULL;
	}

	icn = &query_template->icons[ICON_QUERY_NO];
	len = strlen(local_text ? local_text : no);
	len = max(len, icn->data.indirected_text.size - 1);
	memcpy(icn->data.indirected_text.text,
			local_text ? local_text : no, len);
	icn->data.indirected_text.text[len] = '\0';

	free(local_text);
	local_text = NULL;

	if (!query_no_width) query_no_width = icn->extent.x1 - icn->extent.x0;
	icn->extent.x1 = tx - 16;
	error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width);
	if (error) {
		LOG(("xwimptextop_string_width: 0x%x:%s",
			error->errnum, error->errmess));
		width = len * 16;
	}
	width += 28;
	if (width < query_no_width)
		width = query_no_width;
	icn->extent.x0 = icn->extent.x1 - width;

	error = xwimp_create_window(query_template, &qw->window);
	if (error) {
		warn_user("WimpError", error->errmess);
		free(qw);
		return QUERY_INVALID;
	}

	snprintf(query_buffer, sizeof query_buffer, "%s %s",
			messages_get(query), detail ? detail : "");
	query_buffer[sizeof query_buffer - 1] = 0;

	ro_gui_set_icon_string(qw->window, ICON_QUERY_MESSAGE,
			query_buffer, true);

	xwimp_set_icon_state(qw->window, ICON_QUERY_HELP,
			wimp_ICON_DELETED, wimp_ICON_DELETED);

	if (x >= 0 && y >= 0) {
		x -= tx - 8;
		y += (query_template->visible.y1 - query_template->visible.y0) / 2;
		ro_gui_dialog_open_xy(qw->window, x, y);
	}
	else
		ro_gui_dialog_open(qw->window);

	ro_gui_wimp_event_set_user_data(qw->window, qw);
	ro_gui_wimp_event_register_mouse_click(qw->window, ro_gui_query_click);
	ro_gui_wimp_event_register_cancel(qw->window, ICON_QUERY_NO);
	ro_gui_wimp_event_register_ok(qw->window, ICON_QUERY_YES, ro_gui_query_apply);
	ro_gui_wimp_event_register_close_window(qw->window, ro_gui_query_close);

	error = xwimp_set_caret_position(qw->window, (wimp_i)-1, 0, 0, 1 << 25, -1);
	if (error) {
		LOG(("xwimp_get_caret_position: 0x%x : %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
	}

	/* put this query window at the head of our list */
	if (gui_query_window_list)
		gui_query_window_list->prev = qw;

	qw->prev = NULL;
	qw->next = gui_query_window_list;
	gui_query_window_list = qw;

	return qw->id;
}
コード例 #21
0
/**
 * Handle mouse clicks in the URL completion window.
 *
 * \param pointer  the pointer state
 * \return whether the click was handled
 */
bool ro_gui_url_complete_click(wimp_pointer *pointer)
{
	wimp_window_state state;
	os_error *error;
	int selection, old_selection;
	struct gui_window *g;
	const char *url;

	if ((mouse_x == pointer->pos.x) && (mouse_y == pointer->pos.y) &&
			(!pointer->buttons))
		return false;

	mouse_x = pointer->pos.x;
	mouse_y = pointer->pos.y;

	state.w = dialog_url_complete;
	error = xwimp_get_window_state(&state);
	if (error) {
		LOG(("xwimp_get_window_state: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return false;
	}

	selection = (state.visible.y1 - pointer->pos.y - state.yscroll) / 44;
	if (selection != url_complete_matches_selection) {
		if (url_complete_matches_selection == -1) {
			g = ro_gui_window_lookup(url_complete_parent);
			if (!g)
				return false;
			url = ro_gui_get_icon_string(
					g->toolbar->toolbar_handle,
					ICON_TOOLBAR_URL);
			free(url_complete_original_url);
			url_complete_original_url = strdup(url);
			if (!url_complete_original_url)
				return false;
		}
		old_selection = url_complete_matches_selection;
		url_complete_matches_selection = selection;
		error = xwimp_force_redraw(dialog_url_complete,
				0, -(old_selection + 1) * 44,
				65536, -old_selection * 44);
		if (error) {
			LOG(("xwimp_force_redraw: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("WimpError", error->errmess);
		}
		error = xwimp_force_redraw(dialog_url_complete,
				0, -(url_complete_matches_selection + 1) * 44,
				65536, -url_complete_matches_selection * 44);
		if (error) {
			LOG(("xwimp_force_redraw: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("WimpError", error->errmess);
		}
	}
	if (!pointer->buttons)
		return true;

	/* find owning window */
	g = ro_gui_window_lookup(url_complete_parent);
	if (!g)
		return false;

	/* Select sets the text and launches */
	if (pointer->buttons == wimp_CLICK_SELECT) {
		ro_gui_set_icon_string(g->toolbar->toolbar_handle,
				ICON_TOOLBAR_URL,
				url_complete_matches[
					url_complete_matches_selection], true);
		global_history_add_recent(url_complete_matches[
					url_complete_matches_selection]);

		/** \todo The interaction of components here is hideous */
		/* Do NOT make any attempt to use any of the global url
		 * completion variables after this call to browser_window_go.
		 * They will be invalidated by (at least):
		 *   + gui_window_set_url
		 *   + destruction of (i)frames within the current page 
		 * Any attempt to use them will probably result in a crash.
		 */

		 browser_window_go(g->bw,
				url_complete_matches[
					url_complete_matches_selection],
				0, true);
		ro_gui_url_complete_close(NULL, 0);

	/* Adjust just sets the text */
	} else if (pointer->buttons == wimp_CLICK_ADJUST) {
		ro_gui_set_icon_string(g->toolbar->toolbar_handle,
				ICON_TOOLBAR_URL,
				url_complete_matches[
					url_complete_matches_selection], true);
		ro_gui_url_complete_keypress(g, 0);
	}
	return true;
}
コード例 #22
0
/**
 * Handles a keypress for URL completion
 *
 * \param g    the gui_window to update
 * \param key  the key pressed (as UTF32 code or wimp key + bit31 set)
 * \return true to indicate keypress handled, false otherwise
 */
bool ro_gui_url_complete_keypress(struct gui_window *g, uint32_t key)
{
	wimp_window_state state;
	char *match_url;
	const char *url;
	int i, lines;
	int old_selection;
	int height;
	os_error *error;
	bool currently_open;

	/* we must have a toolbar/url bar */
	if ((!g->toolbar) || (!g->toolbar->display_url) ||
			(!option_url_suggestion)) {
		ro_gui_url_complete_close(NULL, 0);
		return false;
	}

	/* if we are currently active elsewhere, remove the previous window */
	currently_open = ((g->window == url_complete_parent) &&
			(url_complete_matches_available > 0));
	if (g->window != url_complete_parent)
		ro_gui_url_complete_close(NULL, 0);

	/* forcibly open on down keys */
	if ((!currently_open) && (url_complete_matched_string)) {
		switch (key) {
			case IS_WIMP_KEY | wimp_KEY_DOWN:
			case IS_WIMP_KEY | wimp_KEY_PAGE_DOWN:
			case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_DOWN:
				free(url_complete_matched_string);
				url_complete_matched_string = NULL;
		}
	}


	/* get the text to match */
	url_complete_parent = g->window;
	url = ro_gui_get_icon_string(g->toolbar->toolbar_handle,
			ICON_TOOLBAR_URL);
	match_url = strdup(url);
	if (!match_url) {
		ro_gui_url_complete_close(NULL, 0);
		return false;
	}

	/* if the text to match has changed then update it */
	if ((!url_complete_matched_string) ||
			(strcmp(match_url, url_complete_matched_string))) {

		/* memorize the current matches */
		lines = MAXIMUM_VISIBLE_LINES;
		if (lines > url_complete_matches_available)
			lines = url_complete_matches_available;
		if (url_complete_matches) {
			for (i = 0; i < MAXIMUM_VISIBLE_LINES; i++) {
				if (i < lines) {
					url_complete_redraw[i] = 
						url_complete_matches[i];
				} else {
					url_complete_redraw[i] = NULL;
				}
			}
		}

		/* our selection gets wiped */
		error = xwimp_force_redraw(dialog_url_complete,
				0,
				-(url_complete_matches_selection + 1) * 44,
				65536, -url_complete_matches_selection * 44);
		if (error) {
			LOG(("xwimp_force_redraw: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("WimpError", error->errmess);
		}

		/* clear our state */
		free(url_complete_original_url);
		free(url_complete_matched_string);
		url_complete_matched_string = match_url;
		url_complete_original_url = NULL;
		url_complete_matches_available = 0;
		url_complete_matches_selection = -1;
		url_complete_keypress_selection = -1;

		/* get some initial memory */
		if (!url_complete_matches) {
			url_complete_matches = malloc(64 * sizeof(char *));
			if (!url_complete_matches) {
				ro_gui_url_complete_close(NULL, 0);
				return false;
			}
			url_complete_matches_allocated = 64;
		}

		/* find matches */
		url_complete_memory_exhausted = false;
		if (strlen(match_url) == 0)
			urldb_iterate_entries(url_complete_callback);
		else
			urldb_iterate_partial(match_url, url_complete_callback);
		if ((url_complete_memory_exhausted) ||
				(url_complete_matches_available == 0)) {
			ro_gui_url_complete_close(NULL, 0);
			return false;
		}

		/* update the window */
		state.w = g->window;
		error = xwimp_get_window_state(&state);
		if (error) {
			LOG(("xwimp_get_window_state: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("WimpError", error->errmess);
			return false;
		}
		url_complete_matches_reset = true;
		ro_gui_url_complete_resize(g, PTR_WIMP_OPEN(&state));
		url_complete_matches_reset = false;

		/* redraw the relevant bits of the window */
		lines = MAXIMUM_VISIBLE_LINES;
		if (lines > url_complete_matches_available)
			lines = url_complete_matches_available;
		for (i = 0; i < lines; i++) {
			if (url_complete_redraw[i] !=
					url_complete_matches[i]) {
				error = xwimp_force_redraw(dialog_url_complete,
					0, -(i + 1) * 44, 65536, -i * 44);
				if (error) {
					LOG(("xwimp_force_redraw: 0x%x: %s",
							error->errnum,
							error->errmess));
					warn_user("WimpError",
							error->errmess);
				}
			}
		}
	} else {
		free(match_url);
	}

	/* handle keypresses */
	if (!currently_open)
		return false;

	old_selection = url_complete_matches_selection;

	switch (key) {
		case IS_WIMP_KEY | wimp_KEY_UP:
			url_complete_matches_selection--;
			break;
		case IS_WIMP_KEY | wimp_KEY_DOWN:
			url_complete_matches_selection++;
			break;
		case IS_WIMP_KEY | wimp_KEY_PAGE_UP:
			url_complete_matches_selection -=
					MAXIMUM_VISIBLE_LINES;
			break;
		case IS_WIMP_KEY | wimp_KEY_PAGE_DOWN:
			url_complete_matches_selection +=
					MAXIMUM_VISIBLE_LINES;
			break;
		case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_UP:
			url_complete_matches_selection = 0;
			break;
		case IS_WIMP_KEY | wimp_KEY_CONTROL | wimp_KEY_DOWN:
			url_complete_matches_selection = 65536;
			break;
	}

	if (url_complete_matches_selection >
			url_complete_matches_available - 1)
		url_complete_matches_selection =
				url_complete_matches_available - 1;
	else if (url_complete_matches_selection < -1)
		url_complete_matches_selection = -1;

	if (old_selection == url_complete_matches_selection)
		return false;

	error = xwimp_force_redraw(dialog_url_complete,
			0, -(old_selection + 1) * 44,
			65536, -old_selection * 44);
	if (error) {
		LOG(("xwimp_force_redraw: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
	}

	error = xwimp_force_redraw(dialog_url_complete,
			0, -(url_complete_matches_selection + 1) * 44,
			65536, -url_complete_matches_selection * 44);
	if (error) {
		LOG(("xwimp_force_redraw: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
	}

	if (old_selection == -1) {
		free(url_complete_original_url);
		url_complete_original_url = malloc(strlen(url) + 1);
		if (!url_complete_original_url)
			return false;
		strcpy(url_complete_original_url, url);
	}

	if (url_complete_matches_selection == -1) {
		ro_gui_set_icon_string(g->toolbar->toolbar_handle,
				ICON_TOOLBAR_URL,
				url_complete_original_url, true);
	} else {
		ro_gui_set_icon_string(g->toolbar->toolbar_handle,
				ICON_TOOLBAR_URL,
				url_complete_matches[
					url_complete_matches_selection], true);
		free(url_complete_matched_string);
		url_complete_matched_string = strdup(url_complete_matches[
					url_complete_matches_selection]);
	}
	url_complete_keypress_selection = url_complete_matches_selection;

	/* auto-scroll */
	state.w = dialog_url_complete;
	error = xwimp_get_window_state(&state);
	if (error) {
		LOG(("xwimp_get_window_state: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return true;
	}

	if (state.yscroll < -(url_complete_matches_selection * 44))
		state.yscroll = -(url_complete_matches_selection * 44);
	height = state.visible.y1 - state.visible.y0;
	if (state.yscroll - height >
			-((url_complete_matches_selection + 1) * 44))
		state.yscroll =
			-((url_complete_matches_selection + 1) * 44) + height;

	error = xwimp_open_window(PTR_WIMP_OPEN(&state));
	if (error) {
		LOG(("xwimp_open_window: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return true;
	}

	return true;
}
コード例 #23
0
ファイル: history.c プロジェクト: ysei/NetSurf
void ro_gui_history_mouse_at(wimp_pointer *pointer, void *data)
{
	int x, y;
	int width;
	const char *url;
	wimp_window_state state;
	wimp_icon_state ic;
	os_box box = {0, 0, 0, 0};
	os_error *error;
	
	LOG(("Mouse at..."));

	/* If the mouse hasn't moved, or if we don't want tooltips, exit */
	if ((mouse_x == pointer->pos.x && mouse_y == pointer->pos.y) ||
	    !nsoption_bool(history_tooltip))
		return;

	/* Update mouse position */
	mouse_x = pointer->pos.x;
	mouse_y = pointer->pos.y;

	/* Find history tree entry under mouse */
	state.w = history_window;
	error = xwimp_get_window_state(&state);
	if (error) {
		LOG(("xwimp_get_window_state: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / 2;
	y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / 2;
	url = history_position_url(history_current, x, y);
	if (!url) {
		/* not over a tree entry => close tooltip window. */
		error = xwimp_close_window(dialog_tooltip);
		if (error) {
			LOG(("xwimp_close_window: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("WimpError", error->errmess);
			return;
		}
		return;
	}

	/* get width of string */
	error = xwimptextop_string_width(url,
			strlen(url) > 256 ? 256 : strlen(url),
			&width);
	if (error) {
		LOG(("xwimptextop_string_width: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	ro_gui_set_icon_string(dialog_tooltip, 0, url, true);

	/* resize icon appropriately */
	ic.w = dialog_tooltip;
	ic.i = 0;
	error = xwimp_get_icon_state(&ic);
	if (error) {
		LOG(("xwimp_get_icon_state: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}
	error = xwimp_resize_icon(dialog_tooltip, 0,
			ic.icon.extent.x0, ic.icon.extent.y0,
			width + 16, ic.icon.extent.y1);
	if (error) {
		LOG(("xwimp_resize_icon: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	state.w = dialog_tooltip;
	error = xwimp_get_window_state(&state);
	if (error) {
		LOG(("xwimp_get_window_state: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	/* update window extent */
	box.x1 = width + 16;
	box.y0 = -36;
	error = xwimp_set_extent(dialog_tooltip, &box);
	if (error) {
		LOG(("xwimp_set_extent: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	/* set visible area */
	state.visible.x0 = pointer->pos.x + 24;
	state.visible.y0 = pointer->pos.y - 22 - 36;
	state.visible.x1 = pointer->pos.x + 24 + width + 16;
	state.visible.y1 = pointer->pos.y - 22;
	state.next = wimp_TOP;
	/* open window */
	error = xwimp_open_window(PTR_WIMP_OPEN(&state));
	if (error) {
		LOG(("xwimp_open_window: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}
}
コード例 #24
0
ファイル: history.c プロジェクト: pcwalton/NetSurf
void ro_gui_history_redraw(wimp_draw *redraw)
{
	osbool more;
	os_error *error;
	struct redraw_context ctx = {
		.interactive = true,
		.background_images = true,
		.plot = &ro_plotters
	};

	error = xwimp_redraw_window(redraw, &more);
	if (error) {
		LOG(("xwimp_redraw_window: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}
	while (more) {
		ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
		ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
		history_redraw(history_current, &ctx);
		error = xwimp_get_rectangle(redraw, &more);
		if (error) {
			LOG(("xwimp_get_rectangle: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("WimpError", error->errmess);
			return;
		}
	}
}


/**
 * Handle mouse movements over the history window.
 */

void ro_gui_history_mouse_at(wimp_pointer *pointer)
{
	int x, y;
	int width;
	const char *url;
	wimp_window_state state;
	wimp_icon_state ic;
	os_box box = {0, 0, 0, 0};
	os_error *error;

	/* If the mouse hasn't moved, or if we don't want tooltips, exit */
	if ((mouse_x == pointer->pos.x && mouse_y == pointer->pos.y) ||
	    !nsoption_bool(history_tooltip))
		return;

	/* Update mouse position */
	mouse_x = pointer->pos.x;
	mouse_y = pointer->pos.y;

	/* Find history tree entry under mouse */
	state.w = history_window;
	error = xwimp_get_window_state(&state);
	if (error) {
		LOG(("xwimp_get_window_state: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / 2;
	y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / 2;
	url = history_position_url(history_current, x, y);
	if (!url) {
		/* not over a tree entry => close tooltip window. */
		error = xwimp_close_window(dialog_tooltip);
		if (error) {
			LOG(("xwimp_close_window: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("WimpError", error->errmess);
			return;
		}
		return;
	}

	/* get width of string */
	error = xwimptextop_string_width(url,
			strlen(url) > 256 ? 256 : strlen(url),
			&width);
	if (error) {
		LOG(("xwimptextop_string_width: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	ro_gui_set_icon_string(dialog_tooltip, 0, url, true);

	/* resize icon appropriately */
	ic.w = dialog_tooltip;
	ic.i = 0;
	error = xwimp_get_icon_state(&ic);
	if (error) {
		LOG(("xwimp_get_icon_state: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}
	error = xwimp_resize_icon(dialog_tooltip, 0,
			ic.icon.extent.x0, ic.icon.extent.y0,
			width + 16, ic.icon.extent.y1);
	if (error) {
		LOG(("xwimp_resize_icon: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	state.w = dialog_tooltip;
	error = xwimp_get_window_state(&state);
	if (error) {
		LOG(("xwimp_get_window_state: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	/* update window extent */
	box.x1 = width + 16;
	box.y0 = -36;
	error = xwimp_set_extent(dialog_tooltip, &box);
	if (error) {
		LOG(("xwimp_set_extent: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}

	/* set visible area */
	state.visible.x0 = pointer->pos.x + 24;
	state.visible.y0 = pointer->pos.y - 22 - 36;
	state.visible.x1 = pointer->pos.x + 24 + width + 16;
	state.visible.y1 = pointer->pos.y - 22;
	state.next = wimp_TOP;
	/* open window */
	error = xwimp_open_window(PTR_WIMP_OPEN(&state));
	if (error) {
		LOG(("xwimp_open_window: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return;
	}
}
コード例 #25
0
ファイル: con_connect.c プロジェクト: seanregan/browser
bool ro_gui_options_connection_initialise(wimp_w w)
{
	int proxy_type;

	/* set the current values */
	proxy_type = (option_http_proxy ? (option_http_proxy_auth + 1) : 0);
	ro_gui_set_icon_string(w, CONNECTION_PROXY_FIELD,
			proxy_type_menu->entries[proxy_type].
				data.indirected_text.text, true);
	ro_gui_set_icon_string(w, CONNECTION_PROXY_HOST,
			option_http_proxy_host ?
					option_http_proxy_host : "", true);
	ro_gui_set_icon_integer(w, CONNECTION_PROXY_PORT,
			option_http_proxy_port);
	ro_gui_set_icon_string(w, CONNECTION_PROXY_USERNAME,
			option_http_proxy_auth_user ?
					option_http_proxy_auth_user : "", true);
	ro_gui_set_icon_string(w, CONNECTION_PROXY_PASSWORD,
			option_http_proxy_auth_pass ?
					option_http_proxy_auth_pass : "", true);
	ro_gui_set_icon_integer(w, CONNECTION_MAX_FETCH_FIELD,
			option_max_fetchers);
	ro_gui_set_icon_integer(w, CONNECTION_HOST_FETCH_FIELD,
			option_max_fetchers_per_host);
	ro_gui_set_icon_integer(w, CONNECTION_CACHE_FETCH_FIELD,
			option_max_cached_fetch_handles);
	ro_gui_options_connection_update(w, -1, NULL, NULL, NO_ACTION);

	/* register icons */
	ro_gui_wimp_event_register_menu_gright(w, CONNECTION_PROXY_FIELD,
			CONNECTION_PROXY_MENU, proxy_type_menu);
	ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_HOST_LABEL);
	ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_HOST);
	ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_PORT_LABEL);
	ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_PORT);
	ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_USERNAME_LABEL);
	ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_USERNAME);
	ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_PASSWORD_LABEL);
	ro_gui_wimp_event_register_text_field(w, CONNECTION_PROXY_PASSWORD);
	ro_gui_wimp_event_register_numeric_field(w, CONNECTION_MAX_FETCH_FIELD,
			CONNECTION_MAX_FETCH_INC, CONNECTION_MAX_FETCH_DEC,
			1, 99, 1, 0);
	ro_gui_wimp_event_register_numeric_field(w, CONNECTION_HOST_FETCH_FIELD,
			CONNECTION_HOST_FETCH_INC, CONNECTION_HOST_FETCH_DEC,
			1, 99, 1, 0);
	ro_gui_wimp_event_register_numeric_field(w, CONNECTION_CACHE_FETCH_FIELD,
			CONNECTION_CACHE_FETCH_INC, CONNECTION_CACHE_FETCH_DEC,
			1, 99, 1, 0);
	ro_gui_wimp_event_register_menu_selection(w,
			ro_gui_options_connection_update);
	ro_gui_wimp_event_register_button(w, CONNECTION_DEFAULT_BUTTON,
			ro_gui_options_connection_default);
	ro_gui_wimp_event_register_cancel(w, CONNECTION_CANCEL_BUTTON);
	ro_gui_wimp_event_register_ok(w, CONNECTION_OK_BUTTON,
			ro_gui_options_connection_ok);

	ro_gui_wimp_event_set_help_prefix(w, "HelpConnectConfig");
	ro_gui_wimp_event_memorise(w);
	return true;

}
コード例 #26
0
ファイル: con_home.c プロジェクト: galexcode/NetSurf68k
void ro_gui_options_home_default(wimp_pointer *pointer)
{
	/* set the default values */
	ro_gui_set_icon_string(pointer->w, HOME_URL_FIELD, "", true);
	ro_gui_set_icon_selected_state(pointer->w, HOME_OPEN_STARTUP, false);
}
コード例 #27
0
bool ro_gui_load_theme(char *path) {
  	os_error *error;
	struct theme_file_header *file_header;
	char *workspace;
	int workspace_size, file_size, output_left;
	fileswitch_object_type obj_type;
	squash_output_status status;
	os_fw file_handle;
	char *raw_data;
	char *compressed;
	char *decompressed;

	/*	Get memory for the header
	*/
	file_header = (struct theme_file_header *)calloc(1, 
				sizeof (struct theme_file_header));
	if (!file_header) {
	 	LOG(("No memory for calloc()"));
	 	warn_user("NoMemory", 0);
	}
	
	/*	Load the header
	*/
	error = xosfind_openinw(osfind_NO_PATH, path, 0, &file_handle);
	if (error) {
		free(file_header);
		LOG(("xosfind_openinw: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("FileError", error->errmess);
		return false;
	}
	if (file_handle == 0) {
		free(file_header);
		LOG(("File not present"));
		warn_user("FileError", error->errmess);
		return false;
	}
	error = xosgbpb_read_atw(file_handle, (char *)file_header,
			sizeof (struct theme_file_header),
			0, &output_left);
	xosfind_closew(file_handle);
	if (error) {
		free(file_header);
		LOG(("xosbgpb_read_atw: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("FileError", error->errmess);
		return false;
	}
	if (output_left > 0) {
		free(file_header);
		LOG(("Insufficient data"));
		warn_user("FileError", error->errmess);
		return false;
	}
	
	/*	Check the header is OK
	*/
	if ((file_header->magic_value != 0x4d54534e) ||
		(file_header->parser_version > 2)) return false;

	/*	Try to load the sprite file
	*/
	if (file_header->decompressed_sprite_size > 0) {
		error = xosfile_read_stamped_no_path(path,
				&obj_type, 0, 0, &file_size, 0, 0);
		if (error) {
			free(file_header);
			LOG(("xosfile_read_stamped_no_path: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("FileError", error->errmess);
			return false;
		}
		if (obj_type != fileswitch_IS_FILE) {
			free(file_header);
			return false;
		}
		raw_data = malloc(file_size);
		if (!raw_data) {
			free(file_header);
			LOG(("No memory for malloc()"));
			warn_user("NoMemory", 0);
			return false;
		}
		error = xosfile_load_stamped_no_path(path, (byte *)raw_data,
				0, 0, 0, 0, 0);
		if (error) {
			free(raw_data);
			free(file_header);
			LOG(("xosfile_load_stamped_no_path: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("FileError", error->errmess);
			return false;
		}
		
		/*	Decompress the data
		*/
		decompressed = malloc(file_header->decompressed_sprite_size);
		if (!decompressed) {
			free(raw_data);
			free(file_header);
			LOG(("No memory for malloc()"));
			warn_user("NoMemory", 0);
		}
		error = xsquash_decompress_return_sizes(-1, &workspace_size, 0);
		if (error) {
			free(decompressed);
			free(raw_data);
		  	free(file_header);
			LOG(("xsquash_decompress_return_sizes: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("MiscError", error->errmess);
			return false;
		}
		workspace = malloc(workspace_size);
		if (!workspace) {
			free(decompressed);
			free(raw_data);
		  	free(file_header);
			LOG(("No memory for malloc()"));
			warn_user("NoMemory", 0);
			return false;
		}
		compressed = raw_data + sizeof(struct theme_file_header);
		error = xsquash_decompress(0, /*squash_INPUT_ALL_PRESENT,*/
				workspace,
				(byte *)compressed, file_header->compressed_sprite_size,
				(byte *)decompressed, file_header->decompressed_sprite_size,
				&status, 0, 0, 0, 0);
		free(workspace);
		free(raw_data);
		if (error) {
			free(decompressed);
			LOG(("xsquash_decompress: 0x%x: %s",
					error->errnum, error->errmess));
			warn_user("MiscError", error->errmess);
			return false;
		}
		if (status != 0) {
		  	free(decompressed);
			return false;
		}
		if (theme_sprites) free(theme_sprites);
		theme_sprites = (osspriteop_area *)decompressed;		
	} else {
		if (theme_sprites) free(theme_sprites);
		theme_sprites = NULL;
	}
	
	/*	Set out values
	*/
	ro_gui_set_icon_string(dialog_main, ICON_MAIN_NAME, file_header->name);
	ro_gui_set_icon_string(dialog_main, ICON_MAIN_AUTHOR, file_header->author);
	ro_gui_set_icon_background_colour(dialog_main, ICON_MAIN_BROWSER_COLOUR,
			file_header->browser_bg);
	ro_gui_set_icon_background_colour(dialog_main, ICON_MAIN_HOTLIST_COLOUR,
			file_header->hotlist_bg);
	ro_gui_set_icon_background_colour(dialog_main, ICON_MAIN_STATUSBG_COLOUR,
			file_header->status_bg);
	ro_gui_set_icon_background_colour(dialog_main, ICON_MAIN_STATUSFG_COLOUR,
			file_header->status_fg);
	if (file_header->parser_version >= 2) {
		ro_gui_set_icon_selected_state(dialog_main, ICON_MAIN_THROBBER_LEFT,
				file_header->theme_flags & (1 << 0));
		ro_gui_set_icon_selected_state(dialog_main, ICON_MAIN_THROBBER_REDRAW,
				file_header->theme_flags & (1 << 1));
	} else {
		ro_gui_set_icon_selected_state(dialog_main, ICON_MAIN_THROBBER_LEFT,
				file_header->theme_flags);
		ro_gui_set_icon_selected_state(dialog_main, ICON_MAIN_THROBBER_REDRAW,
				true);
	}

	/*	Remember the filename for saving later on
	*/
	if (theme_filename) free(theme_filename);
	theme_filename = malloc(strlen(path) + 1);
	sprintf(theme_filename, "%s", path);
	if (sprite_filename) free(sprite_filename);
	sprite_filename = NULL;
	
	/*	Exit cleanly
	*/
	free(file_header);
	return true;
}