2003-08-27 02:37:32 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
2004-08-07 03:45:21 +04:00
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2003-08-27 02:37:32 +04:00
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2005-02-25 01:00:41 +03:00
|
|
|
* Copyright 2005 James Bursa <bursa@users.sourceforge.net>
|
2003-08-27 02:37:32 +04:00
|
|
|
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
2005-04-08 00:46:22 +04:00
|
|
|
* Copyright 2005 Richard Wilson <not_ginger_matt@users.sourceforge.net>
|
2004-07-25 23:25:26 +04:00
|
|
|
* Copyright 2004 Andrew Timmins <atimmins@blueyonder.co.uk>
|
2003-08-27 02:37:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
2003-12-19 03:40:28 +03:00
|
|
|
#include <stddef.h>
|
2004-08-08 15:39:31 +04:00
|
|
|
#include <stdlib.h>
|
2003-08-27 02:37:32 +04:00
|
|
|
#include <string.h>
|
2003-08-28 00:09:57 +04:00
|
|
|
#include "oslib/colourtrans.h"
|
|
|
|
#include "oslib/osfile.h"
|
|
|
|
#include "oslib/osgbpb.h"
|
|
|
|
#include "oslib/osspriteop.h"
|
2003-08-27 02:37:32 +04:00
|
|
|
#include "oslib/wimp.h"
|
2005-02-25 01:00:41 +03:00
|
|
|
#include "rufl.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2003-12-19 20:11:07 +03:00
|
|
|
#include "netsurf/desktop/netsurf.h"
|
2004-09-14 03:56:18 +04:00
|
|
|
#include "netsurf/render/font.h"
|
2003-08-27 02:37:32 +04:00
|
|
|
#include "netsurf/riscos/gui.h"
|
2005-04-08 00:46:22 +04:00
|
|
|
#include "netsurf/riscos/menus.h"
|
2003-08-27 02:37:32 +04:00
|
|
|
#include "netsurf/riscos/options.h"
|
2004-05-23 03:04:44 +04:00
|
|
|
#include "netsurf/riscos/theme.h"
|
2004-05-05 02:23:44 +04:00
|
|
|
#include "netsurf/riscos/wimp.h"
|
2003-08-28 00:09:57 +04:00
|
|
|
#include "netsurf/utils/log.h"
|
2003-11-09 00:47:10 +03:00
|
|
|
#include "netsurf/utils/messages.h"
|
2005-04-08 00:46:22 +04:00
|
|
|
#include "netsurf/utils/url.h"
|
2003-08-27 02:37:32 +04:00
|
|
|
#include "netsurf/utils/utils.h"
|
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
/* The maximum number of persistant dialogues
|
|
|
|
*/
|
|
|
|
#define MAX_PERSISTANT 8
|
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
|
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
|
2005-04-23 06:58:27 +04:00
|
|
|
dialog_config_prox, dialog_config_th,
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_AUTH
|
2004-02-25 18:12:58 +03:00
|
|
|
dialog_401li,
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2004-05-07 23:14:54 +04:00
|
|
|
dialog_zoom, dialog_pageinfo, dialog_objinfo, dialog_tooltip,
|
2004-07-09 02:05:35 +04:00
|
|
|
dialog_warning, dialog_config_th_pane, dialog_debug,
|
2004-09-14 03:56:18 +04:00
|
|
|
dialog_folder, dialog_entry, dialog_search, dialog_print,
|
2005-04-08 00:46:22 +04:00
|
|
|
dialog_config_font, dialog_config_image, dialog_url_complete,
|
|
|
|
dialog_openurl;
|
2003-08-28 00:09:57 +04:00
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
static int ro_gui_choices_font_size;
|
|
|
|
static int ro_gui_choices_font_min_size;
|
2004-09-14 03:56:18 +04:00
|
|
|
static int config_font_icon = -1;
|
2004-07-27 19:49:28 +04:00
|
|
|
static bool ro_gui_choices_http_proxy;
|
|
|
|
static int ro_gui_choices_http_proxy_auth;
|
2004-07-28 00:44:46 +04:00
|
|
|
static int config_br_icon = -1;
|
|
|
|
static const char *ro_gui_choices_lang = 0;
|
|
|
|
static const char *ro_gui_choices_alang = 0;
|
2004-11-03 02:23:07 +03:00
|
|
|
static int ro_gui_choices_image_edit_type = 0;
|
|
|
|
static unsigned int ro_gui_choices_fg_plot_style = 0;
|
|
|
|
static unsigned int ro_gui_choices_bg_plot_style = 0;
|
2004-02-14 02:07:42 +03:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
struct gui_window *ro_gui_current_zoom_gui;
|
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
struct toolbar_display {
|
|
|
|
struct toolbar *toolbar;
|
|
|
|
struct theme_descriptor *descriptor;
|
|
|
|
int icon_number;
|
|
|
|
struct toolbar_display *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct theme_descriptor *theme_choice = NULL;
|
|
|
|
static struct theme_descriptor *theme_list = NULL;
|
|
|
|
static int theme_count = 0;
|
|
|
|
static struct toolbar_display *toolbars = NULL;
|
|
|
|
static char theme_radio_validation[] = "Sradiooff,radioon\0";
|
2004-09-08 03:05:34 +04:00
|
|
|
static char theme_null_validation[] = "\0";
|
|
|
|
static char theme_line_validation[] = "R2\0";
|
2004-08-31 01:03:48 +04:00
|
|
|
|
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
static const char *ro_gui_proxy_auth_name[] = {
|
|
|
|
"ProxyNone", "ProxyBasic", "ProxyNTLM"
|
|
|
|
};
|
|
|
|
|
2004-11-03 02:23:07 +03:00
|
|
|
static const char *ro_gui_image_name[] = {
|
|
|
|
"ImgStyle0", "ImgStyle1", "ImgStyle2", "ImgStyle3"
|
|
|
|
};
|
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
/* A simple mapping of parent and child
|
|
|
|
*/
|
2004-07-27 19:49:28 +04:00
|
|
|
static struct {
|
|
|
|
wimp_w dialog;
|
|
|
|
wimp_w parent;
|
|
|
|
} persistant_dialog[MAX_PERSISTANT];
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
static void ro_gui_dialog_config_prepare(void);
|
2004-11-03 02:23:07 +03:00
|
|
|
static void ro_gui_dialog_set_image_quality(int icon, unsigned int tinct_options);
|
2004-07-27 19:49:28 +04:00
|
|
|
static void ro_gui_dialog_config_set(void);
|
2003-08-27 02:37:32 +04:00
|
|
|
static void ro_gui_dialog_click_config(wimp_pointer *pointer);
|
|
|
|
static void ro_gui_dialog_click_config_br(wimp_pointer *pointer);
|
|
|
|
static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer);
|
2004-11-03 02:23:07 +03:00
|
|
|
static void ro_gui_dialog_click_config_image(wimp_pointer *pointer);
|
2004-07-27 19:49:28 +04:00
|
|
|
static void ro_gui_dialog_config_proxy_update(void);
|
2003-08-27 02:37:32 +04:00
|
|
|
static void ro_gui_dialog_click_config_th(wimp_pointer *pointer);
|
2004-05-23 03:04:44 +04:00
|
|
|
static void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer);
|
2004-09-14 03:56:18 +04:00
|
|
|
static void ro_gui_dialog_update_config_font(void);
|
|
|
|
static void ro_gui_dialog_click_config_font(wimp_pointer *pointer);
|
2005-04-18 03:32:09 +04:00
|
|
|
static unsigned ro_gui_clamp_scale(unsigned scale);
|
2004-02-25 18:12:58 +03:00
|
|
|
static void ro_gui_dialog_click_zoom(wimp_pointer *pointer);
|
2005-04-18 03:32:09 +04:00
|
|
|
static bool ro_gui_zoom_keypress(wimp_key *key);
|
2005-04-08 00:46:22 +04:00
|
|
|
static void ro_gui_dialog_click_open_url(wimp_pointer *pointer);
|
2004-05-07 23:14:54 +04:00
|
|
|
static void ro_gui_dialog_click_warning(wimp_pointer *pointer);
|
2004-03-08 03:03:58 +03:00
|
|
|
static const char *language_name(const char *code);
|
2004-08-31 01:03:48 +04:00
|
|
|
|
|
|
|
static void ro_gui_dialog_load_themes(void);
|
|
|
|
static void ro_gui_dialog_free_themes(void);
|
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load and create dialogs from template file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_init(void)
|
|
|
|
{
|
|
|
|
dialog_info = ro_gui_dialog_create("info");
|
2003-11-09 00:47:10 +03:00
|
|
|
/* fill in about box version info */
|
2004-02-26 03:44:42 +03:00
|
|
|
ro_gui_set_icon_string(dialog_info, 4, netsurf_version);
|
2003-12-19 04:00:22 +03:00
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
dialog_saveas = ro_gui_dialog_create("saveas");
|
|
|
|
dialog_config = ro_gui_dialog_create("config");
|
|
|
|
dialog_config_br = ro_gui_dialog_create("config_br");
|
|
|
|
dialog_config_prox = ro_gui_dialog_create("config_prox");
|
|
|
|
dialog_config_th = ro_gui_dialog_create("config_th");
|
2004-06-05 20:07:13 +04:00
|
|
|
dialog_config_th_pane = ro_gui_dialog_create("config_th_p");
|
2004-02-25 18:12:58 +03:00
|
|
|
dialog_zoom = ro_gui_dialog_create("zoom");
|
2004-04-03 06:59:35 +04:00
|
|
|
dialog_pageinfo = ro_gui_dialog_create("pageinfo");
|
2004-05-05 04:02:13 +04:00
|
|
|
dialog_objinfo = ro_gui_dialog_create("objectinfo");
|
2004-04-13 01:46:08 +04:00
|
|
|
dialog_tooltip = ro_gui_dialog_create("tooltip");
|
2004-05-07 23:14:54 +04:00
|
|
|
dialog_warning = ro_gui_dialog_create("warning");
|
2004-06-11 00:41:26 +04:00
|
|
|
dialog_debug = ro_gui_dialog_create("debug");
|
2004-07-09 02:05:35 +04:00
|
|
|
dialog_folder = ro_gui_dialog_create("new_folder");
|
|
|
|
dialog_entry = ro_gui_dialog_create("new_entry");
|
2004-08-06 00:32:00 +04:00
|
|
|
dialog_search = ro_gui_dialog_create("search");
|
2004-08-09 10:28:57 +04:00
|
|
|
dialog_print = ro_gui_dialog_create("print");
|
2004-09-14 03:56:18 +04:00
|
|
|
dialog_config_font = ro_gui_dialog_create("config_font");
|
2004-11-03 02:23:07 +03:00
|
|
|
dialog_config_image = ro_gui_dialog_create("config_img");
|
2005-01-23 19:09:05 +03:00
|
|
|
dialog_theme_install = ro_gui_dialog_create("theme_inst");
|
2005-02-03 16:18:22 +03:00
|
|
|
dialog_url_complete = ro_gui_dialog_create("url_suggest");
|
2005-04-08 00:46:22 +04:00
|
|
|
dialog_openurl = ro_gui_dialog_create("open_url");
|
2003-08-27 02:37:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a window from a template.
|
2004-05-09 00:44:00 +04:00
|
|
|
*
|
|
|
|
* \param template_name name of template to load
|
|
|
|
* \return window handle
|
|
|
|
*
|
|
|
|
* Exits through die() on error.
|
2003-08-27 02:37:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
wimp_w ro_gui_dialog_create(const char *template_name)
|
|
|
|
{
|
|
|
|
wimp_window *window;
|
|
|
|
wimp_w w;
|
2004-05-09 00:44:00 +04:00
|
|
|
os_error *error;
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2004-05-09 00:44:00 +04:00
|
|
|
window = ro_gui_dialog_load_template(template_name);
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2004-05-09 00:44:00 +04:00
|
|
|
/* create window */
|
|
|
|
error = xwimp_create_window(window, &w);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_create_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
xwimp_close_template();
|
|
|
|
die(error->errmess);
|
|
|
|
}
|
2003-08-27 02:37:32 +04:00
|
|
|
|
|
|
|
/* the window definition is copied by the wimp and may be freed */
|
2004-05-09 00:44:00 +04:00
|
|
|
free(window);
|
2003-08-27 02:37:32 +04:00
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-09 00:44:00 +04:00
|
|
|
/**
|
|
|
|
* Load a template without creating a window.
|
|
|
|
*
|
|
|
|
* \param template_name name of template to load
|
|
|
|
* \return window block
|
|
|
|
*
|
|
|
|
* Exits through die() on error.
|
|
|
|
*/
|
|
|
|
|
|
|
|
wimp_window * ro_gui_dialog_load_template(const char *template_name)
|
|
|
|
{
|
|
|
|
char name[20];
|
|
|
|
int context, window_size, data_size;
|
|
|
|
char *data;
|
|
|
|
wimp_window *window;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* wimp_load_template won't accept a const char * */
|
|
|
|
strncpy(name, template_name, sizeof name);
|
|
|
|
|
|
|
|
/* find required buffer sizes */
|
|
|
|
error = xwimp_load_template(wimp_GET_SIZE, 0, 0, wimp_NO_FONTS,
|
|
|
|
name, 0, &window_size, &data_size, &context);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_load_template: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
xwimp_close_template();
|
|
|
|
die(error->errmess);
|
|
|
|
}
|
|
|
|
if (!context) {
|
|
|
|
LOG(("template '%s' missing", template_name));
|
|
|
|
xwimp_close_template();
|
|
|
|
die("Template");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate space for indirected data and temporary window buffer */
|
|
|
|
data = malloc(data_size);
|
|
|
|
window = malloc(window_size);
|
|
|
|
if (!data || !window) {
|
|
|
|
xwimp_close_template();
|
|
|
|
die("NoMemory");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* load template */
|
|
|
|
error = xwimp_load_template(window, data, data + data_size,
|
|
|
|
wimp_NO_FONTS, name, 0, 0, 0, 0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_load_template: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
xwimp_close_template();
|
|
|
|
die(error->errmess);
|
|
|
|
}
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-28 00:09:57 +04:00
|
|
|
/**
|
|
|
|
* Open a dialog box, centered on the screen.
|
|
|
|
*/
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2003-08-28 00:09:57 +04:00
|
|
|
void ro_gui_dialog_open(wimp_w w)
|
|
|
|
{
|
2003-11-08 02:51:13 +03:00
|
|
|
int screen_x, screen_y, dx, dy;
|
2004-05-23 03:04:44 +04:00
|
|
|
wimp_window_state open;
|
2004-07-27 19:49:28 +04:00
|
|
|
os_error *error;
|
2003-08-28 00:09:57 +04:00
|
|
|
|
2003-10-23 04:09:17 +04:00
|
|
|
/* find screen centre in os units */
|
2003-11-08 02:51:13 +03:00
|
|
|
ro_gui_screen_size(&screen_x, &screen_y);
|
|
|
|
screen_x /= 2;
|
|
|
|
screen_y /= 2;
|
2003-08-28 00:09:57 +04:00
|
|
|
|
|
|
|
/* centre and open */
|
|
|
|
open.w = w;
|
2004-07-27 19:49:28 +04:00
|
|
|
error = xwimp_get_window_state(&open);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2003-08-28 00:09:57 +04:00
|
|
|
dx = (open.visible.x1 - open.visible.x0) / 2;
|
|
|
|
dy = (open.visible.y1 - open.visible.y0) / 2;
|
|
|
|
open.visible.x0 = screen_x - dx;
|
|
|
|
open.visible.x1 = screen_x + dx;
|
|
|
|
open.visible.y0 = screen_y - dy;
|
|
|
|
open.visible.y1 = screen_y + dy;
|
|
|
|
open.next = wimp_TOP;
|
2004-07-27 19:49:28 +04:00
|
|
|
error = xwimp_open_window((wimp_open *) &open);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-07-12 01:45:51 +04:00
|
|
|
/* Set the caret position
|
|
|
|
*/
|
|
|
|
ro_gui_set_caret_first(w);
|
2003-08-28 00:09:57 +04:00
|
|
|
}
|
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a persistant dialog box relative to the pointer.
|
|
|
|
*
|
2004-07-27 19:49:28 +04:00
|
|
|
* \param parent the owning window (NULL for no owner)
|
2004-08-07 03:45:21 +04:00
|
|
|
* \param w the dialog window
|
2004-07-27 19:49:28 +04:00
|
|
|
* \param pointer open the window at the pointer (centre of the parent
|
2004-08-07 03:45:21 +04:00
|
|
|
* otherwise)
|
2004-07-08 21:28:56 +04:00
|
|
|
*/
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2004-07-16 20:33:45 +04:00
|
|
|
void ro_gui_dialog_open_persistant(wimp_w parent, wimp_w w, bool pointer) {
|
2004-07-08 21:28:56 +04:00
|
|
|
int dx, dy, i;
|
|
|
|
wimp_window_state open;
|
|
|
|
os_error *error;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
/* Move and open
|
|
|
|
*/
|
2004-07-16 20:33:45 +04:00
|
|
|
if (pointer) {
|
2005-04-15 09:54:44 +04:00
|
|
|
wimp_pointer ptr;
|
|
|
|
|
|
|
|
/* Get the pointer position
|
|
|
|
*/
|
|
|
|
error = xwimp_get_pointer_info(&ptr);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_pointer_info: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-07-16 20:33:45 +04:00
|
|
|
open.w = w;
|
2004-07-27 19:49:28 +04:00
|
|
|
error = xwimp_get_window_state(&open);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2004-07-16 20:33:45 +04:00
|
|
|
dx = (open.visible.x1 - open.visible.x0);
|
|
|
|
dy = (open.visible.y1 - open.visible.y0);
|
|
|
|
open.visible.x0 = ptr.pos.x - 64;
|
|
|
|
open.visible.x1 = ptr.pos.x - 64 + dx;
|
|
|
|
open.visible.y0 = ptr.pos.y - dy;
|
|
|
|
open.visible.y1 = ptr.pos.y;
|
|
|
|
open.next = wimp_TOP;
|
2004-07-27 19:49:28 +04:00
|
|
|
error = xwimp_open_window((wimp_open *) &open);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2004-07-16 20:33:45 +04:00
|
|
|
} else {
|
|
|
|
ro_gui_open_window_centre(parent, w);
|
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
/* Set the caret position and window furniture
|
2004-07-12 01:45:51 +04:00
|
|
|
*/
|
2005-04-08 00:46:22 +04:00
|
|
|
if ((w == dialog_pageinfo) || (w == dialog_objinfo))
|
|
|
|
ro_gui_wimp_update_window_furniture(w, wimp_WINDOW_CLOSE_ICON,
|
|
|
|
wimp_WINDOW_CLOSE_ICON);
|
|
|
|
ro_gui_wimp_update_window_furniture(w, wimp_WINDOW_BACK_ICON,
|
|
|
|
wimp_WINDOW_BACK_ICON);
|
2004-07-12 01:45:51 +04:00
|
|
|
ro_gui_set_caret_first(w);
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
/* Add a mapping
|
|
|
|
*/
|
2004-07-27 19:49:28 +04:00
|
|
|
if (parent == NULL)
|
|
|
|
return;
|
2004-07-08 21:28:56 +04:00
|
|
|
for (i = 0; i < MAX_PERSISTANT; i++) {
|
2004-07-27 19:49:28 +04:00
|
|
|
if (persistant_dialog[i].dialog == NULL ||
|
|
|
|
persistant_dialog[i].dialog == w) {
|
|
|
|
persistant_dialog[i].dialog = w;
|
|
|
|
persistant_dialog[i].parent = parent;
|
2004-07-08 21:28:56 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Log that we failed to create a mapping
|
2004-07-17 17:00:38 +04:00
|
|
|
*/
|
2004-07-08 21:28:56 +04:00
|
|
|
LOG(("Unable to map persistant dialog to parent."));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2004-07-27 19:49:28 +04:00
|
|
|
* Close persistent dialogs associated with a window.
|
2004-07-08 21:28:56 +04:00
|
|
|
*
|
2004-07-27 19:49:28 +04:00
|
|
|
* \param parent the window to close children of
|
2004-07-08 21:28:56 +04:00
|
|
|
*/
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
void ro_gui_dialog_close_persistant(wimp_w parent) {
|
2004-07-27 19:49:28 +04:00
|
|
|
int i;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-07-08 21:28:56 +04:00
|
|
|
/* Check our mappings
|
|
|
|
*/
|
|
|
|
for (i = 0; i < MAX_PERSISTANT; i++) {
|
2004-07-27 19:49:28 +04:00
|
|
|
if (persistant_dialog[i].parent == parent &&
|
|
|
|
persistant_dialog[i].dialog != NULL) {
|
|
|
|
ro_gui_dialog_close(persistant_dialog[i].dialog);
|
|
|
|
persistant_dialog[i].dialog = NULL;
|
2004-07-08 21:28:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-26 21:18:17 +03:00
|
|
|
/**
|
|
|
|
* Handle key presses in one of the dialog boxes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ro_gui_dialog_keypress(wimp_key *key)
|
|
|
|
{
|
2004-07-12 03:14:24 +04:00
|
|
|
wimp_pointer pointer;
|
2004-08-06 00:32:00 +04:00
|
|
|
|
2004-08-06 02:03:56 +04:00
|
|
|
#ifdef WITH_SEARCH
|
|
|
|
if (key->w == dialog_search)
|
|
|
|
return ro_gui_search_keypress(key);
|
2004-08-09 10:28:57 +04:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_PRINT
|
|
|
|
if (key->w == dialog_print)
|
|
|
|
return ro_gui_print_keypress(key);
|
2004-08-06 02:03:56 +04:00
|
|
|
#endif
|
2005-04-18 03:32:09 +04:00
|
|
|
if (key->w == dialog_zoom)
|
|
|
|
return ro_gui_zoom_keypress(key);
|
2004-07-12 01:45:51 +04:00
|
|
|
if (key->c == wimp_KEY_ESCAPE) {
|
|
|
|
ro_gui_dialog_close(key->w);
|
|
|
|
return true;
|
|
|
|
}
|
2004-07-27 19:49:28 +04:00
|
|
|
else if (key->c == wimp_KEY_RETURN) {
|
2004-07-12 03:14:24 +04:00
|
|
|
if ((key->w == dialog_folder) || (key->w == dialog_entry)) {
|
2004-07-27 19:49:28 +04:00
|
|
|
pointer.w = key->w;
|
|
|
|
/** \todo replace magic numbers with defines */
|
|
|
|
pointer.i = (key->w == dialog_folder) ? 3 : 5;
|
2004-07-12 03:14:24 +04:00
|
|
|
pointer.buttons = wimp_CLICK_SELECT;
|
2004-07-17 17:00:38 +04:00
|
|
|
ro_gui_hotlist_dialog_click(&pointer);
|
2004-07-12 03:14:24 +04:00
|
|
|
return true;
|
2005-04-15 09:54:44 +04:00
|
|
|
} else if (key->w == dialog_saveas)
|
|
|
|
ro_gui_save_ok(key->w);
|
2005-05-11 02:49:41 +04:00
|
|
|
else if (key->w == dialog_openurl) {
|
|
|
|
pointer.w = key->w;
|
|
|
|
pointer.i = ICON_OPENURL_OPEN;
|
|
|
|
pointer.buttons = wimp_CLICK_SELECT;
|
|
|
|
ro_gui_dialog_click_open_url(&pointer);
|
|
|
|
}
|
2004-07-27 19:49:28 +04:00
|
|
|
}
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_AUTH
|
2003-12-26 21:18:17 +03:00
|
|
|
if (key->w == dialog_401li)
|
2004-07-27 19:49:28 +04:00
|
|
|
return ro_gui_401login_keypress(key);
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2005-05-11 02:49:41 +04:00
|
|
|
|
2003-12-26 21:18:17 +03:00
|
|
|
return false;
|
|
|
|
}
|
2003-08-28 00:09:57 +04:00
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
/**
|
|
|
|
* Handle clicks in one of the dialog boxes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_click(wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
if (pointer->buttons == wimp_CLICK_MENU)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pointer->w == dialog_config)
|
|
|
|
ro_gui_dialog_click_config(pointer);
|
|
|
|
else if (pointer->w == dialog_config_br)
|
|
|
|
ro_gui_dialog_click_config_br(pointer);
|
|
|
|
else if (pointer->w == dialog_config_prox)
|
|
|
|
ro_gui_dialog_click_config_prox(pointer);
|
2004-11-03 02:23:07 +03:00
|
|
|
else if (pointer->w == dialog_config_image)
|
|
|
|
ro_gui_dialog_click_config_image(pointer);
|
2003-08-27 02:37:32 +04:00
|
|
|
else if (pointer->w == dialog_config_th)
|
|
|
|
ro_gui_dialog_click_config_th(pointer);
|
2004-05-23 03:04:44 +04:00
|
|
|
else if (pointer->w == dialog_config_th_pane)
|
|
|
|
ro_gui_dialog_click_config_th_pane(pointer);
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_AUTH
|
2003-10-23 04:09:17 +04:00
|
|
|
else if (pointer->w == dialog_401li)
|
2004-08-07 03:45:21 +04:00
|
|
|
ro_gui_401login_click(pointer);
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2004-02-25 18:12:58 +03:00
|
|
|
else if (pointer->w == dialog_zoom)
|
2004-05-07 23:14:54 +04:00
|
|
|
ro_gui_dialog_click_zoom(pointer);
|
|
|
|
else if (pointer->w == dialog_warning)
|
|
|
|
ro_gui_dialog_click_warning(pointer);
|
2004-07-12 03:14:24 +04:00
|
|
|
else if ((pointer->w == dialog_folder) || (pointer->w == dialog_entry))
|
|
|
|
ro_gui_hotlist_dialog_click(pointer);
|
2004-08-09 10:28:57 +04:00
|
|
|
#ifdef WITH_SEARCH
|
2004-08-06 02:03:56 +04:00
|
|
|
else if (pointer->w == dialog_search)
|
|
|
|
ro_gui_search_click(pointer);
|
2004-08-09 10:28:57 +04:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_PRINT
|
|
|
|
else if (pointer->w == dialog_print)
|
|
|
|
ro_gui_print_click(pointer);
|
|
|
|
#endif
|
2004-09-14 03:56:18 +04:00
|
|
|
else if (pointer->w == dialog_config_font)
|
|
|
|
ro_gui_dialog_click_config_font(pointer);
|
2005-01-23 19:09:05 +03:00
|
|
|
else if (pointer->w == dialog_theme_install)
|
|
|
|
ro_gui_theme_install_click(pointer);
|
2005-04-08 00:46:22 +04:00
|
|
|
else if (pointer->w == dialog_openurl)
|
|
|
|
ro_gui_dialog_click_open_url(pointer);
|
2003-08-27 02:37:32 +04:00
|
|
|
}
|
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2004-11-04 04:19:46 +03:00
|
|
|
/**
|
|
|
|
* Redraw a dialog window
|
|
|
|
*/
|
2005-02-23 02:36:14 +03:00
|
|
|
|
|
|
|
void ro_gui_dialog_redraw(wimp_draw *redraw)
|
|
|
|
{
|
2004-11-04 04:19:46 +03:00
|
|
|
struct toolbar_display *display;
|
2005-02-20 16:19:19 +03:00
|
|
|
|
2005-03-14 16:58:43 +03:00
|
|
|
for (display = toolbars; display; display = display->next)
|
2005-02-23 02:36:14 +03:00
|
|
|
if ((display->toolbar) && (display->toolbar->toolbar_handle ==
|
|
|
|
redraw->w)) {
|
2004-11-04 04:19:46 +03:00
|
|
|
ro_gui_theme_redraw(display->toolbar, redraw);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-03-14 16:58:43 +03:00
|
|
|
ro_gui_user_redraw(redraw, false, (os_gcol)0);
|
2004-11-04 04:19:46 +03:00
|
|
|
}
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
/**
|
|
|
|
* Prepare and open the Choices dialog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_open_config(void)
|
|
|
|
{
|
|
|
|
ro_gui_dialog_config_prepare();
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_BROWSER,
|
|
|
|
true);
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_PROXY,
|
|
|
|
false);
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_THEME,
|
|
|
|
false);
|
2004-09-14 03:56:18 +04:00
|
|
|
ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_FONT,
|
|
|
|
false);
|
2004-11-03 02:23:07 +03:00
|
|
|
ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_IMAGE,
|
|
|
|
false);
|
2004-07-27 19:49:28 +04:00
|
|
|
ro_gui_dialog_open(dialog_config);
|
|
|
|
ro_gui_open_pane(dialog_config, dialog_config_br, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the choices panes with the current options.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_config_prepare(void)
|
|
|
|
{
|
|
|
|
/* browser pane */
|
|
|
|
ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_LANG,
|
|
|
|
language_name(option_language ?
|
|
|
|
option_language : "en"));
|
|
|
|
ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_ALANG,
|
|
|
|
language_name(option_accept_language ?
|
|
|
|
option_accept_language : "en"));
|
|
|
|
ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_HOMEPAGE,
|
|
|
|
option_homepage_url ? option_homepage_url : "");
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config_br,
|
|
|
|
ICON_CONFIG_BR_OPENBROWSER,
|
|
|
|
option_open_browser_at_startup);
|
2004-09-14 03:56:18 +04:00
|
|
|
ro_gui_set_icon_selected_state(dialog_config_br,
|
|
|
|
ICON_CONFIG_BR_BLOCKADS,
|
|
|
|
option_block_ads);
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config_br,
|
|
|
|
ICON_CONFIG_BR_PLUGINS,
|
|
|
|
option_no_plugins);
|
2004-07-27 19:49:28 +04:00
|
|
|
|
|
|
|
/* proxy pane */
|
|
|
|
ro_gui_choices_http_proxy = option_http_proxy;
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config_prox,
|
|
|
|
ICON_CONFIG_PROX_HTTP,
|
|
|
|
option_http_proxy);
|
|
|
|
ro_gui_set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_HTTPHOST,
|
|
|
|
option_http_proxy_host ? option_http_proxy_host : "");
|
|
|
|
ro_gui_set_icon_integer(dialog_config_prox, ICON_CONFIG_PROX_HTTPPORT,
|
|
|
|
option_http_proxy_port);
|
|
|
|
ro_gui_choices_http_proxy_auth = option_http_proxy_auth;
|
|
|
|
ro_gui_set_icon_string(dialog_config_prox,
|
|
|
|
ICON_CONFIG_PROX_AUTHTYPE,
|
|
|
|
messages_get(ro_gui_proxy_auth_name[
|
|
|
|
ro_gui_choices_http_proxy_auth]));
|
|
|
|
ro_gui_set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_AUTHUSER,
|
|
|
|
option_http_proxy_auth_user ?
|
|
|
|
option_http_proxy_auth_user : "");
|
|
|
|
ro_gui_set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_AUTHPASS,
|
|
|
|
option_http_proxy_auth_pass ?
|
|
|
|
option_http_proxy_auth_pass : "");
|
2004-10-02 03:48:15 +04:00
|
|
|
ro_gui_set_icon_selected_state(dialog_config_prox,
|
|
|
|
ICON_CONFIG_PROX_REFERER, option_send_referer);
|
2004-07-27 19:49:28 +04:00
|
|
|
ro_gui_dialog_config_proxy_update();
|
|
|
|
|
|
|
|
/* themes pane */
|
2004-08-31 01:03:48 +04:00
|
|
|
ro_gui_dialog_load_themes();
|
|
|
|
theme_choice = ro_gui_theme_find(option_theme);
|
2004-09-14 03:56:18 +04:00
|
|
|
|
|
|
|
/* font pane */
|
|
|
|
ro_gui_choices_font_size = option_font_size;
|
|
|
|
ro_gui_choices_font_min_size = option_font_min_size;
|
|
|
|
ro_gui_dialog_update_config_font();
|
|
|
|
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_SANS,
|
2005-02-23 02:36:14 +03:00
|
|
|
option_font_sans);
|
2004-09-14 03:56:18 +04:00
|
|
|
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_SERIF,
|
2005-02-23 02:36:14 +03:00
|
|
|
option_font_serif);
|
2004-09-14 03:56:18 +04:00
|
|
|
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_MONO,
|
2005-02-23 02:36:14 +03:00
|
|
|
option_font_mono);
|
2004-09-14 03:56:18 +04:00
|
|
|
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_CURS,
|
2005-02-23 02:36:14 +03:00
|
|
|
option_font_cursive);
|
2004-09-14 03:56:18 +04:00
|
|
|
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_FANT,
|
2005-02-23 02:36:14 +03:00
|
|
|
option_font_fantasy);
|
2004-09-14 03:56:18 +04:00
|
|
|
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_DEF,
|
2005-02-23 02:36:14 +03:00
|
|
|
css_font_family_name[option_font_default]);
|
2005-02-20 16:19:19 +03:00
|
|
|
|
2004-11-03 02:23:07 +03:00
|
|
|
/* image pane */
|
|
|
|
ro_gui_choices_fg_plot_style = option_fg_plot_style;
|
|
|
|
ro_gui_choices_bg_plot_style = option_bg_plot_style;
|
2005-02-23 02:36:14 +03:00
|
|
|
ro_gui_dialog_set_image_quality(ICON_CONFIG_IMG_FG_DISP,
|
|
|
|
option_fg_plot_style);
|
|
|
|
ro_gui_dialog_set_image_quality(ICON_CONFIG_IMG_BG_DISP,
|
|
|
|
option_bg_plot_style);
|
2004-07-27 19:49:28 +04:00
|
|
|
}
|
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set an icon in the Image config window with Tinct options.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_set_image_quality(int icon, unsigned int tinct_options)
|
|
|
|
{
|
2004-11-03 02:23:07 +03:00
|
|
|
int i = 1;
|
|
|
|
if (tinct_options & tinct_USE_OS_SPRITE_OP) {
|
|
|
|
i = 0;
|
|
|
|
} else if (tinct_options & tinct_ERROR_DIFFUSE) {
|
|
|
|
i = 3;
|
|
|
|
} else if (tinct_options & tinct_DITHER) {
|
|
|
|
i = 2;
|
|
|
|
}
|
|
|
|
ro_gui_set_icon_string(dialog_config_image, icon,
|
|
|
|
messages_get(ro_gui_image_name[i]));
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config_image, icon + 3,
|
|
|
|
(tinct_options & tinct_BILINEAR_FILTER));
|
2005-02-20 16:19:19 +03:00
|
|
|
|
2004-11-03 02:23:07 +03:00
|
|
|
}
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
/**
|
|
|
|
* Set the current options to the settings in the choices panes.
|
|
|
|
*/
|
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
void ro_gui_dialog_config_set(void)
|
|
|
|
{
|
|
|
|
char *font_default;
|
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
/* browser pane */
|
2004-09-14 03:56:18 +04:00
|
|
|
if (option_homepage_url)
|
|
|
|
free(option_homepage_url);
|
2004-07-27 19:49:28 +04:00
|
|
|
option_homepage_url = strdup(ro_gui_get_icon_string(dialog_config_br,
|
|
|
|
ICON_CONFIG_BR_HOMEPAGE));
|
|
|
|
option_open_browser_at_startup = ro_gui_get_icon_selected_state(
|
|
|
|
dialog_config_br,
|
|
|
|
ICON_CONFIG_BR_OPENBROWSER);
|
2004-09-14 03:56:18 +04:00
|
|
|
option_block_ads = ro_gui_get_icon_selected_state(
|
|
|
|
dialog_config_br,
|
|
|
|
ICON_CONFIG_BR_BLOCKADS);
|
|
|
|
option_no_plugins = ro_gui_get_icon_selected_state(
|
|
|
|
dialog_config_br,
|
|
|
|
ICON_CONFIG_BR_PLUGINS);
|
2004-07-28 00:44:46 +04:00
|
|
|
if (ro_gui_choices_lang) {
|
|
|
|
free(option_language);
|
|
|
|
option_language = strdup(ro_gui_choices_lang);
|
|
|
|
ro_gui_choices_lang = 0;
|
|
|
|
}
|
|
|
|
if (ro_gui_choices_alang) {
|
|
|
|
free(option_accept_language);
|
|
|
|
option_accept_language = strdup(ro_gui_choices_alang);
|
|
|
|
ro_gui_choices_alang = 0;
|
|
|
|
}
|
2004-07-27 19:49:28 +04:00
|
|
|
|
|
|
|
/* proxy pane */
|
|
|
|
option_http_proxy = ro_gui_choices_http_proxy;
|
2004-09-14 03:56:18 +04:00
|
|
|
if (option_http_proxy_host)
|
|
|
|
free(option_http_proxy_host);
|
2004-07-27 19:49:28 +04:00
|
|
|
option_http_proxy_host = strdup(ro_gui_get_icon_string(
|
|
|
|
dialog_config_prox,
|
|
|
|
ICON_CONFIG_PROX_HTTPHOST));
|
|
|
|
option_http_proxy_port = atoi(ro_gui_get_icon_string(dialog_config_prox,
|
|
|
|
ICON_CONFIG_PROX_HTTPPORT));
|
|
|
|
option_http_proxy_auth = ro_gui_choices_http_proxy_auth;
|
2004-09-14 03:56:18 +04:00
|
|
|
if (option_http_proxy_auth_user)
|
|
|
|
free(option_http_proxy_auth_user);
|
2004-07-27 19:49:28 +04:00
|
|
|
option_http_proxy_auth_user = strdup(ro_gui_get_icon_string(
|
|
|
|
dialog_config_prox,
|
|
|
|
ICON_CONFIG_PROX_AUTHUSER));
|
2004-09-14 03:56:18 +04:00
|
|
|
if (option_http_proxy_auth_pass)
|
|
|
|
free(option_http_proxy_auth_pass);
|
2004-07-27 19:49:28 +04:00
|
|
|
option_http_proxy_auth_pass = strdup(ro_gui_get_icon_string(
|
|
|
|
dialog_config_prox,
|
|
|
|
ICON_CONFIG_PROX_AUTHPASS));
|
2004-10-02 03:48:15 +04:00
|
|
|
option_send_referer = ro_gui_get_icon_selected_state(
|
|
|
|
dialog_config_prox,
|
|
|
|
ICON_CONFIG_PROX_REFERER);
|
2004-07-27 19:49:28 +04:00
|
|
|
|
|
|
|
/* theme pane */
|
2004-08-31 01:03:48 +04:00
|
|
|
if (option_theme) {
|
|
|
|
free(option_theme);
|
|
|
|
option_theme = NULL;
|
|
|
|
}
|
|
|
|
if (theme_choice) {
|
2005-02-08 02:00:09 +03:00
|
|
|
option_theme = strdup(theme_choice->leafname);
|
2004-08-31 01:03:48 +04:00
|
|
|
ro_gui_theme_apply(theme_choice);
|
|
|
|
}
|
2004-09-14 03:56:18 +04:00
|
|
|
|
|
|
|
/* font pane */
|
|
|
|
option_font_size = ro_gui_choices_font_size;
|
|
|
|
option_font_min_size = ro_gui_choices_font_min_size;
|
2005-02-23 02:36:14 +03:00
|
|
|
free(option_font_sans);
|
2004-09-14 03:56:18 +04:00
|
|
|
option_font_sans = strdup(ro_gui_get_icon_string(dialog_config_font,
|
|
|
|
ICON_CONFIG_FONT_SANS));
|
2005-02-23 02:36:14 +03:00
|
|
|
free(option_font_serif);
|
2004-09-14 03:56:18 +04:00
|
|
|
option_font_serif = strdup(ro_gui_get_icon_string(dialog_config_font,
|
|
|
|
ICON_CONFIG_FONT_SERIF));
|
2005-02-23 02:36:14 +03:00
|
|
|
free(option_font_mono);
|
2004-09-14 03:56:18 +04:00
|
|
|
option_font_mono = strdup(ro_gui_get_icon_string(dialog_config_font,
|
|
|
|
ICON_CONFIG_FONT_MONO));
|
2005-02-23 02:36:14 +03:00
|
|
|
free(option_font_cursive);
|
2004-09-14 03:56:18 +04:00
|
|
|
option_font_cursive = strdup(ro_gui_get_icon_string(
|
|
|
|
dialog_config_font, ICON_CONFIG_FONT_CURS));
|
2005-02-23 02:36:14 +03:00
|
|
|
free(option_font_fantasy);
|
2004-09-14 03:56:18 +04:00
|
|
|
option_font_fantasy = strdup(ro_gui_get_icon_string(
|
|
|
|
dialog_config_font, ICON_CONFIG_FONT_FANT));
|
2005-02-23 02:36:14 +03:00
|
|
|
font_default = ro_gui_get_icon_string(dialog_config_font,
|
|
|
|
ICON_CONFIG_FONT_DEF);
|
|
|
|
option_font_default = css_font_family_parse(font_default,
|
|
|
|
strlen(font_default));
|
2005-02-20 16:19:19 +03:00
|
|
|
|
2004-11-03 02:23:07 +03:00
|
|
|
/* image pane */
|
|
|
|
if ((option_fg_plot_style != (int)ro_gui_choices_fg_plot_style) ||
|
2005-02-23 02:36:14 +03:00
|
|
|
(option_bg_plot_style !=
|
|
|
|
(int) ro_gui_choices_bg_plot_style)) {
|
2004-11-03 02:23:07 +03:00
|
|
|
option_fg_plot_style = ro_gui_choices_fg_plot_style;
|
|
|
|
option_bg_plot_style = ro_gui_choices_bg_plot_style;
|
|
|
|
ro_gui_window_redraw_all();
|
|
|
|
}
|
2004-07-27 19:49:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
/**
|
|
|
|
* Handle clicks in the main Choices dialog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_click_config(wimp_pointer *pointer)
|
|
|
|
{
|
2004-08-31 01:57:47 +04:00
|
|
|
wimp_window_state state;
|
2003-08-27 02:37:32 +04:00
|
|
|
switch (pointer->i) {
|
|
|
|
case ICON_CONFIG_SAVE:
|
2004-07-27 19:49:28 +04:00
|
|
|
ro_gui_dialog_config_set();
|
2004-06-27 18:41:14 +04:00
|
|
|
ro_gui_save_options();
|
2003-08-27 02:37:32 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_SELECT) {
|
|
|
|
ro_gui_dialog_close(dialog_config);
|
2004-08-31 01:03:48 +04:00
|
|
|
ro_gui_dialog_free_themes();
|
2003-08-27 02:37:32 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICON_CONFIG_CANCEL:
|
2004-08-31 01:03:48 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_SELECT) {
|
2003-08-27 02:37:32 +04:00
|
|
|
ro_gui_dialog_close(dialog_config);
|
2004-08-31 01:03:48 +04:00
|
|
|
ro_gui_dialog_free_themes();
|
|
|
|
} else {
|
|
|
|
ro_gui_dialog_config_prepare();
|
|
|
|
}
|
2003-08-27 02:37:32 +04:00
|
|
|
break;
|
|
|
|
case ICON_CONFIG_BROWSER:
|
2004-07-27 06:34:13 +04:00
|
|
|
/* set selected state of radio icon to prevent
|
|
|
|
* de-selection of all radio icons */
|
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST)
|
2004-07-27 19:49:28 +04:00
|
|
|
ro_gui_set_icon_selected_state(dialog_config,
|
|
|
|
ICON_CONFIG_BROWSER, true);
|
|
|
|
ro_gui_open_pane(dialog_config, dialog_config_br, 0);
|
2003-08-27 02:37:32 +04:00
|
|
|
break;
|
|
|
|
case ICON_CONFIG_PROXY:
|
2004-07-27 06:34:13 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST)
|
2004-07-27 19:49:28 +04:00
|
|
|
ro_gui_set_icon_selected_state(dialog_config,
|
|
|
|
ICON_CONFIG_PROXY, true);
|
|
|
|
ro_gui_open_pane(dialog_config, dialog_config_prox, 0);
|
2003-08-27 02:37:32 +04:00
|
|
|
break;
|
|
|
|
case ICON_CONFIG_THEME:
|
2004-07-27 06:34:13 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST)
|
2004-07-27 19:49:28 +04:00
|
|
|
ro_gui_set_icon_selected_state(dialog_config,
|
|
|
|
ICON_CONFIG_THEME, true);
|
|
|
|
ro_gui_open_pane(dialog_config, dialog_config_th, 0);
|
2004-08-31 01:57:47 +04:00
|
|
|
state.w = dialog_config_th;
|
|
|
|
xwimp_get_window_state(&state);
|
|
|
|
state.w = dialog_config_th_pane;
|
|
|
|
state.visible.x0 += 12;
|
|
|
|
state.visible.x1 -= 12;
|
|
|
|
state.visible.y0 += 128;
|
|
|
|
state.visible.y1 -= 12;
|
2005-04-08 00:46:22 +04:00
|
|
|
xwimp_open_window_nested((wimp_open *) &state,
|
|
|
|
dialog_config_th,
|
2004-08-31 01:57:47 +04:00
|
|
|
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
|
|
|
|
<< wimp_CHILD_XORIGIN_SHIFT |
|
|
|
|
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
|
|
|
|
<< wimp_CHILD_YORIGIN_SHIFT |
|
|
|
|
wimp_CHILD_LINKS_PARENT_VISIBLE_BOTTOM_OR_LEFT
|
|
|
|
<< wimp_CHILD_LS_EDGE_SHIFT |
|
|
|
|
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
|
|
|
|
<< wimp_CHILD_BS_EDGE_SHIFT |
|
|
|
|
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
|
|
|
|
<< wimp_CHILD_RS_EDGE_SHIFT |
|
|
|
|
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
|
|
|
|
<< wimp_CHILD_TS_EDGE_SHIFT);
|
2003-08-27 02:37:32 +04:00
|
|
|
break;
|
2004-09-14 03:56:18 +04:00
|
|
|
case ICON_CONFIG_FONT:
|
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST)
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config,
|
|
|
|
ICON_CONFIG_FONT, true);
|
|
|
|
ro_gui_open_pane(dialog_config, dialog_config_font, 0);
|
|
|
|
break;
|
2004-11-03 02:23:07 +03:00
|
|
|
case ICON_CONFIG_IMAGE:
|
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST)
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config,
|
|
|
|
ICON_CONFIG_IMAGE, true);
|
|
|
|
ro_gui_open_pane(dialog_config, dialog_config_image, 0);
|
|
|
|
break;
|
2003-08-27 02:37:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-06-27 18:41:14 +04:00
|
|
|
/**
|
2004-07-27 19:49:28 +04:00
|
|
|
* Save the current options.
|
2004-06-27 18:41:14 +04:00
|
|
|
*/
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
void ro_gui_save_options(void)
|
|
|
|
{
|
2004-07-27 19:49:28 +04:00
|
|
|
/* NCOS doesnt have the fancy Universal Boot vars; so select
|
|
|
|
* the path to the choices file based on the build options */
|
|
|
|
#ifndef NCOS
|
2004-06-27 18:41:14 +04:00
|
|
|
options_write("<Choices$Write>.WWW.NetSurf.Choices");
|
2004-07-27 19:49:28 +04:00
|
|
|
#else
|
2004-07-25 23:25:26 +04:00
|
|
|
options_write("<User$Path>.Choices.NetSurf.Choices");
|
2004-07-27 19:49:28 +04:00
|
|
|
#endif
|
2004-06-27 18:41:14 +04:00
|
|
|
}
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
/**
|
2004-07-27 19:49:28 +04:00
|
|
|
* Handle clicks in the Browser Choices pane.
|
2003-08-27 02:37:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_click_config_br(wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
switch (pointer->i) {
|
2004-07-28 00:44:46 +04:00
|
|
|
case ICON_CONFIG_BR_LANG_PICK:
|
|
|
|
/* drop through */
|
|
|
|
case ICON_CONFIG_BR_ALANG_PICK:
|
|
|
|
config_br_icon = pointer->i;
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_popup_menu(languages_menu, dialog_config_br,
|
|
|
|
pointer->i);
|
2004-07-28 00:44:46 +04:00
|
|
|
break;
|
2003-08-27 02:37:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-28 00:44:46 +04:00
|
|
|
/**
|
|
|
|
* Handle a selection from the language selection popup menu.
|
|
|
|
*
|
|
|
|
* \param lang The language name (as returned by messages_get)
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_languages_menu_selection(char *lang)
|
|
|
|
{
|
|
|
|
int offset = strlen("lang_");
|
|
|
|
|
|
|
|
const char *temp = messages_get_key(lang);
|
|
|
|
if (temp == NULL) {
|
|
|
|
warn_user("MiscError", "Failed to retrieve message key");
|
|
|
|
config_br_icon = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (config_br_icon) {
|
|
|
|
case ICON_CONFIG_BR_LANG_PICK:
|
|
|
|
ro_gui_choices_lang = temp + offset;
|
|
|
|
ro_gui_set_icon_string(dialog_config_br,
|
|
|
|
ICON_CONFIG_BR_LANG,
|
|
|
|
lang);
|
|
|
|
break;
|
|
|
|
case ICON_CONFIG_BR_ALANG_PICK:
|
|
|
|
ro_gui_choices_alang = temp + offset;
|
|
|
|
ro_gui_set_icon_string(dialog_config_br,
|
|
|
|
ICON_CONFIG_BR_ALANG,
|
|
|
|
lang);
|
|
|
|
break;
|
|
|
|
}
|
2004-02-14 02:07:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
/**
|
2004-07-27 19:49:28 +04:00
|
|
|
* Handle clicks in the Proxy Choices pane.
|
2003-08-27 02:37:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_click_config_prox(wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
switch (pointer->i) {
|
2004-07-27 19:49:28 +04:00
|
|
|
case ICON_CONFIG_PROX_HTTP:
|
|
|
|
ro_gui_choices_http_proxy = !ro_gui_choices_http_proxy;
|
|
|
|
ro_gui_dialog_config_proxy_update();
|
2003-08-27 02:37:32 +04:00
|
|
|
break;
|
2004-07-27 19:49:28 +04:00
|
|
|
case ICON_CONFIG_PROX_AUTHTYPE_PICK:
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_popup_menu(proxy_auth_menu, dialog_config_prox,
|
2004-07-27 19:49:28 +04:00
|
|
|
ICON_CONFIG_PROX_AUTHTYPE_PICK);
|
2003-08-27 02:37:32 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-25 23:25:26 +04:00
|
|
|
|
2004-11-03 02:23:07 +03:00
|
|
|
/**
|
|
|
|
* Handle clicks in the Proxy Choices pane.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_click_config_image(wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
switch (pointer->i) {
|
|
|
|
case ICON_CONFIG_IMG_FG_MENU:
|
|
|
|
ro_gui_choices_image_edit_type = 1;
|
|
|
|
ro_gui_menu_prepare_image_quality(ro_gui_choices_fg_plot_style);
|
|
|
|
ro_gui_popup_menu(image_quality_menu, dialog_config_image,
|
|
|
|
pointer->i);
|
|
|
|
break;
|
|
|
|
case ICON_CONFIG_IMG_FG_FILTER:
|
|
|
|
if (ro_gui_get_icon_selected_state(dialog_config_image,
|
|
|
|
ICON_CONFIG_IMG_FG_FILTER)) {
|
|
|
|
ro_gui_choices_fg_plot_style |= tinct_BILINEAR_FILTER;
|
|
|
|
} else {
|
|
|
|
ro_gui_choices_fg_plot_style &= ~tinct_BILINEAR_FILTER;
|
|
|
|
}
|
2005-04-08 00:46:22 +04:00
|
|
|
break;
|
2004-11-03 02:23:07 +03:00
|
|
|
case ICON_CONFIG_IMG_BG_MENU:
|
|
|
|
ro_gui_choices_image_edit_type = 2;
|
|
|
|
ro_gui_menu_prepare_image_quality(ro_gui_choices_bg_plot_style);
|
|
|
|
ro_gui_popup_menu(image_quality_menu, dialog_config_image,
|
|
|
|
pointer->i);
|
|
|
|
break;
|
|
|
|
case ICON_CONFIG_IMG_BG_FILTER:
|
|
|
|
if (ro_gui_get_icon_selected_state(dialog_config_image,
|
|
|
|
ICON_CONFIG_IMG_BG_FILTER)) {
|
|
|
|
ro_gui_choices_bg_plot_style |= tinct_BILINEAR_FILTER;
|
|
|
|
} else {
|
|
|
|
ro_gui_choices_bg_plot_style &= ~tinct_BILINEAR_FILTER;
|
|
|
|
}
|
2005-04-08 00:46:22 +04:00
|
|
|
break;
|
2004-11-03 02:23:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-25 23:25:26 +04:00
|
|
|
/**
|
2004-07-27 19:49:28 +04:00
|
|
|
* Handle a selection from the proxy auth method popup menu.
|
2004-07-25 23:25:26 +04:00
|
|
|
*/
|
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
void ro_gui_dialog_proxyauth_menu_selection(int item)
|
2004-07-25 23:25:26 +04:00
|
|
|
{
|
2004-07-27 19:49:28 +04:00
|
|
|
ro_gui_choices_http_proxy_auth = item;
|
|
|
|
ro_gui_set_icon_string(dialog_config_prox,
|
|
|
|
ICON_CONFIG_PROX_AUTHTYPE,
|
|
|
|
messages_get(ro_gui_proxy_auth_name[
|
|
|
|
ro_gui_choices_http_proxy_auth]));
|
|
|
|
ro_gui_dialog_config_proxy_update();
|
2004-07-25 23:25:26 +04:00
|
|
|
}
|
2003-08-27 02:37:32 +04:00
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
|
2004-11-03 02:23:07 +03:00
|
|
|
/**
|
|
|
|
* Handle a selection from the image quality popup menu.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_image_menu_selection(int item)
|
|
|
|
{
|
|
|
|
unsigned int tinct_options = 0;
|
|
|
|
if (item == 0) {
|
|
|
|
tinct_options = tinct_USE_OS_SPRITE_OP;
|
|
|
|
} else if (item == 2) {
|
|
|
|
tinct_options = tinct_DITHER;
|
|
|
|
} else if (item == 3) {
|
|
|
|
tinct_options = tinct_ERROR_DIFFUSE;
|
|
|
|
}
|
|
|
|
if (ro_gui_choices_image_edit_type == 1) {
|
|
|
|
ro_gui_choices_fg_plot_style &= tinct_BILINEAR_FILTER;
|
|
|
|
ro_gui_choices_fg_plot_style |= tinct_options;
|
|
|
|
ro_gui_dialog_set_image_quality(ICON_CONFIG_IMG_FG_DISP,
|
|
|
|
ro_gui_choices_fg_plot_style);
|
|
|
|
} else {
|
|
|
|
ro_gui_choices_bg_plot_style &= tinct_BILINEAR_FILTER;
|
|
|
|
ro_gui_choices_bg_plot_style |= tinct_options;
|
|
|
|
ro_gui_dialog_set_image_quality(ICON_CONFIG_IMG_BG_DISP,
|
|
|
|
ro_gui_choices_bg_plot_style);
|
|
|
|
}
|
|
|
|
ro_gui_menu_prepare_image_quality(tinct_options);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-23 03:04:44 +04:00
|
|
|
/**
|
2004-07-27 19:49:28 +04:00
|
|
|
* Update greying of icons in the proxy choices pane.
|
2004-05-23 03:04:44 +04:00
|
|
|
*/
|
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
void ro_gui_dialog_config_proxy_update(void)
|
2004-05-23 03:04:44 +04:00
|
|
|
{
|
2004-07-27 19:49:28 +04:00
|
|
|
int icon;
|
|
|
|
for (icon = ICON_CONFIG_PROX_HTTPHOST;
|
|
|
|
icon <= ICON_CONFIG_PROX_AUTHTYPE_PICK;
|
|
|
|
icon++)
|
|
|
|
ro_gui_set_icon_shaded_state(dialog_config_prox,
|
|
|
|
icon, !ro_gui_choices_http_proxy);
|
|
|
|
for (icon = ICON_CONFIG_PROX_AUTHTYPE_PICK + 1;
|
|
|
|
icon <= ICON_CONFIG_PROX_AUTHPASS;
|
|
|
|
icon++)
|
|
|
|
ro_gui_set_icon_shaded_state(dialog_config_prox,
|
|
|
|
icon, !ro_gui_choices_http_proxy ||
|
|
|
|
ro_gui_choices_http_proxy_auth ==
|
|
|
|
OPTION_HTTP_PROXY_AUTH_NONE);
|
2004-05-23 03:04:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
/**
|
2004-07-27 19:49:28 +04:00
|
|
|
* Handle clicks in the Theme Choices pane.
|
2003-08-27 02:37:32 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_click_config_th(wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
switch (pointer->i) {
|
|
|
|
case ICON_CONFIG_TH_MANAGE:
|
2005-01-23 19:09:05 +03:00
|
|
|
os_cli("Filer_OpenDir Choices:WWW.NetSurf.Themes");
|
2003-08-27 02:37:32 +04:00
|
|
|
break;
|
|
|
|
case ICON_CONFIG_TH_GET:
|
2004-06-21 19:27:56 +04:00
|
|
|
browser_window_create(
|
|
|
|
"http://netsurf.sourceforge.net/themes/",
|
2004-10-02 01:31:55 +04:00
|
|
|
NULL, 0);
|
2003-08-27 02:37:32 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-23 03:04:44 +04:00
|
|
|
#define THEME_HEIGHT 80
|
2004-07-27 06:34:13 +04:00
|
|
|
#define THEME_WIDTH 705
|
2004-05-23 03:04:44 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle clicks in the scrolling Theme Choices list pane.
|
|
|
|
*/
|
2004-08-31 01:03:48 +04:00
|
|
|
void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer) {
|
|
|
|
struct toolbar_display *link;
|
2004-11-03 02:23:07 +03:00
|
|
|
int i = pointer->i;
|
|
|
|
if (i < 0) return;
|
2004-05-23 03:04:44 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/* Set the clicked theme as selected
|
|
|
|
*/
|
|
|
|
link = toolbars;
|
|
|
|
while (link) {
|
2004-11-03 02:23:07 +03:00
|
|
|
if ((link->icon_number == i) || (link->icon_number == (i - 1))) {
|
|
|
|
theme_choice = link->descriptor;
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config_th_pane,
|
|
|
|
link->icon_number, true);
|
|
|
|
} else {
|
|
|
|
ro_gui_set_icon_selected_state(dialog_config_th_pane,
|
|
|
|
link->icon_number, false);
|
|
|
|
}
|
2004-09-14 03:56:18 +04:00
|
|
|
link = link->next;
|
2004-05-23 03:04:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2004-09-14 03:56:18 +04:00
|
|
|
/**
|
|
|
|
* Update font size icons in font choices pane.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_update_config_font(void)
|
|
|
|
{
|
|
|
|
char s[10];
|
|
|
|
sprintf(s, "%i.%ipt", ro_gui_choices_font_size / 10,
|
|
|
|
ro_gui_choices_font_size % 10);
|
|
|
|
ro_gui_set_icon_string(dialog_config_font,
|
|
|
|
ICON_CONFIG_FONT_FONTSIZE, s);
|
|
|
|
sprintf(s, "%i.%ipt", ro_gui_choices_font_min_size / 10,
|
|
|
|
ro_gui_choices_font_min_size % 10);
|
|
|
|
ro_gui_set_icon_string(dialog_config_font,
|
|
|
|
ICON_CONFIG_FONT_MINSIZE, s);
|
|
|
|
}
|
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2004-09-14 03:56:18 +04:00
|
|
|
/**
|
|
|
|
* Handle clicks in the font choices pane
|
|
|
|
*/
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2004-09-14 03:56:18 +04:00
|
|
|
void ro_gui_dialog_click_config_font(wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
int stepping = 1;
|
|
|
|
|
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST)
|
|
|
|
stepping = -stepping;
|
|
|
|
|
|
|
|
switch (pointer->i) {
|
|
|
|
case ICON_CONFIG_FONT_FONTSIZE_DEC:
|
|
|
|
ro_gui_choices_font_size -= stepping;
|
|
|
|
if (ro_gui_choices_font_size < 50)
|
|
|
|
ro_gui_choices_font_size = 50;
|
|
|
|
if (ro_gui_choices_font_size > 1000)
|
|
|
|
ro_gui_choices_font_size = 1000;
|
|
|
|
|
|
|
|
if (ro_gui_choices_font_size <
|
|
|
|
ro_gui_choices_font_min_size)
|
|
|
|
ro_gui_choices_font_min_size =
|
|
|
|
ro_gui_choices_font_size;
|
|
|
|
ro_gui_dialog_update_config_font();
|
|
|
|
break;
|
|
|
|
case ICON_CONFIG_FONT_FONTSIZE_INC:
|
|
|
|
ro_gui_choices_font_size += stepping;
|
|
|
|
if (ro_gui_choices_font_size < 50)
|
|
|
|
ro_gui_choices_font_size = 50;
|
|
|
|
if (ro_gui_choices_font_size > 1000)
|
|
|
|
ro_gui_choices_font_size = 1000;
|
|
|
|
ro_gui_dialog_update_config_font();
|
|
|
|
break;
|
|
|
|
case ICON_CONFIG_FONT_MINSIZE_DEC:
|
|
|
|
ro_gui_choices_font_min_size -= stepping;
|
|
|
|
if (ro_gui_choices_font_min_size < 10)
|
|
|
|
ro_gui_choices_font_min_size = 10;
|
|
|
|
if (ro_gui_choices_font_min_size > 500)
|
|
|
|
ro_gui_choices_font_min_size = 500;
|
|
|
|
ro_gui_dialog_update_config_font();
|
|
|
|
break;
|
|
|
|
case ICON_CONFIG_FONT_MINSIZE_INC:
|
|
|
|
ro_gui_choices_font_min_size += stepping;
|
|
|
|
if (ro_gui_choices_font_min_size < 10)
|
|
|
|
ro_gui_choices_font_min_size = 10;
|
|
|
|
if (ro_gui_choices_font_min_size > 500)
|
|
|
|
ro_gui_choices_font_min_size = 500;
|
|
|
|
|
|
|
|
if (ro_gui_choices_font_size <
|
|
|
|
ro_gui_choices_font_min_size)
|
|
|
|
ro_gui_choices_font_size =
|
|
|
|
ro_gui_choices_font_min_size;
|
|
|
|
ro_gui_dialog_update_config_font();
|
|
|
|
break;
|
2005-02-25 01:00:41 +03:00
|
|
|
case ICON_CONFIG_FONT_SANS:
|
2004-09-14 03:56:18 +04:00
|
|
|
case ICON_CONFIG_FONT_SANS_PICK:
|
2005-02-25 01:00:41 +03:00
|
|
|
case ICON_CONFIG_FONT_SERIF:
|
2004-09-14 03:56:18 +04:00
|
|
|
case ICON_CONFIG_FONT_SERIF_PICK:
|
2005-02-25 01:00:41 +03:00
|
|
|
case ICON_CONFIG_FONT_MONO:
|
2004-09-14 03:56:18 +04:00
|
|
|
case ICON_CONFIG_FONT_MONO_PICK:
|
2005-02-25 01:00:41 +03:00
|
|
|
case ICON_CONFIG_FONT_CURS:
|
2004-09-14 03:56:18 +04:00
|
|
|
case ICON_CONFIG_FONT_CURS_PICK:
|
2005-02-25 01:00:41 +03:00
|
|
|
case ICON_CONFIG_FONT_FANT:
|
2004-09-14 03:56:18 +04:00
|
|
|
case ICON_CONFIG_FONT_FANT_PICK:
|
2005-02-25 01:00:41 +03:00
|
|
|
config_font_icon = pointer->i & ~1;
|
|
|
|
ro_gui_popup_menu(font_menu, dialog_config_font,
|
|
|
|
pointer->i | 1);
|
2005-02-23 02:36:14 +03:00
|
|
|
break;
|
|
|
|
case ICON_CONFIG_FONT_DEF_PICK:
|
2004-09-14 03:56:18 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2004-09-14 03:56:18 +04:00
|
|
|
/**
|
2005-02-23 02:36:14 +03:00
|
|
|
* Handle font menu selections.
|
2004-09-14 03:56:18 +04:00
|
|
|
*/
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2005-02-25 01:00:41 +03:00
|
|
|
void ro_gui_dialog_font_menu_selection(int item)
|
2004-09-14 03:56:18 +04:00
|
|
|
{
|
2005-02-25 01:00:41 +03:00
|
|
|
if (item < 0 || rufl_family_list_entries <= (unsigned int) item)
|
2004-09-14 03:56:18 +04:00
|
|
|
return;
|
2005-02-25 01:00:41 +03:00
|
|
|
ro_gui_set_icon_string(dialog_config_font, config_font_icon,
|
|
|
|
rufl_family_list[item]);
|
2004-09-14 03:56:18 +04:00
|
|
|
}
|
2004-05-23 03:04:44 +04:00
|
|
|
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2005-04-18 03:32:09 +04:00
|
|
|
/**
|
|
|
|
* Ensure that a scale percentage lies within a sensible range.
|
|
|
|
*
|
|
|
|
* \param scale scale percentage
|
|
|
|
* \return corrected scale value
|
|
|
|
*/
|
|
|
|
|
|
|
|
unsigned ro_gui_clamp_scale(unsigned scale)
|
|
|
|
{
|
|
|
|
if (scale < 10)
|
|
|
|
scale = 10;
|
|
|
|
else if (1600 < scale)
|
|
|
|
scale = 1600;
|
|
|
|
return scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
/**
|
|
|
|
* Handle clicks in the Scale view dialog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_click_zoom(wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
unsigned int scale;
|
2004-04-17 20:45:46 +04:00
|
|
|
int stepping = 10;
|
2004-02-26 03:44:42 +03:00
|
|
|
scale = atoi(ro_gui_get_icon_string(dialog_zoom, ICON_ZOOM_VALUE));
|
2004-02-25 18:12:58 +03:00
|
|
|
|
2004-04-17 20:45:46 +04:00
|
|
|
/* Adjust moves values the opposite direction
|
|
|
|
*/
|
2004-06-12 21:43:37 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST)
|
|
|
|
stepping = -stepping;
|
2004-04-17 20:45:46 +04:00
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
switch (pointer->i) {
|
2004-04-17 20:45:46 +04:00
|
|
|
case ICON_ZOOM_DEC: scale -= stepping; break;
|
|
|
|
case ICON_ZOOM_INC: scale += stepping; break;
|
2005-03-13 04:23:10 +03:00
|
|
|
case ICON_ZOOM_75: scale = 75; break;
|
2004-02-25 18:12:58 +03:00
|
|
|
case ICON_ZOOM_100: scale = 100; break;
|
2005-03-13 04:23:10 +03:00
|
|
|
case ICON_ZOOM_150: scale = 150; break;
|
|
|
|
case ICON_ZOOM_200: scale = 200; break;
|
2004-02-25 18:12:58 +03:00
|
|
|
}
|
|
|
|
|
2005-04-18 03:32:09 +04:00
|
|
|
scale = ro_gui_clamp_scale(scale);
|
2004-05-05 02:23:44 +04:00
|
|
|
ro_gui_set_icon_integer(dialog_zoom, ICON_ZOOM_VALUE, scale);
|
2004-02-25 18:12:58 +03:00
|
|
|
|
2005-04-18 03:32:09 +04:00
|
|
|
if (pointer->i == ICON_ZOOM_OK)
|
2005-04-18 04:42:03 +04:00
|
|
|
ro_gui_window_set_scale(ro_gui_current_zoom_gui, scale * 0.01);
|
2004-02-25 18:12:58 +03:00
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST &&
|
|
|
|
pointer->i == ICON_ZOOM_CANCEL)
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_dialog_prepare_zoom(ro_gui_current_zoom_gui);
|
2004-04-17 20:45:46 +04:00
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
if (pointer->buttons == wimp_CLICK_SELECT &&
|
|
|
|
(pointer->i == ICON_ZOOM_CANCEL ||
|
2004-08-07 03:45:21 +04:00
|
|
|
pointer->i == ICON_ZOOM_OK)) {
|
|
|
|
ro_gui_dialog_close(dialog_zoom);
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_menu_closed();
|
2004-08-07 03:45:21 +04:00
|
|
|
}
|
2004-02-25 18:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-18 03:32:09 +04:00
|
|
|
/**
|
|
|
|
* Handle keypresses in the Scale view dialog.
|
|
|
|
*
|
|
|
|
* \param key keypress info from Wimp
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ro_gui_zoom_keypress(wimp_key *key)
|
|
|
|
{
|
|
|
|
if (key->c == wimp_KEY_RETURN) {
|
|
|
|
unsigned int scale;
|
|
|
|
scale = atoi(ro_gui_get_icon_string(dialog_zoom, ICON_ZOOM_VALUE));
|
|
|
|
scale = ro_gui_clamp_scale(scale);
|
|
|
|
ro_gui_window_set_scale(ro_gui_current_zoom_gui, scale * 0.01);
|
|
|
|
ro_gui_dialog_close(dialog_zoom);
|
|
|
|
ro_gui_menu_closed();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-23 03:04:44 +04:00
|
|
|
/**
|
2005-04-08 00:46:22 +04:00
|
|
|
* Prepares the Scale view dialog.
|
2004-04-17 20:45:46 +04:00
|
|
|
*/
|
2004-05-23 03:04:44 +04:00
|
|
|
|
2005-04-08 00:46:22 +04:00
|
|
|
void ro_gui_dialog_prepare_zoom(struct gui_window *g)
|
2005-02-23 02:36:14 +03:00
|
|
|
{
|
2004-05-23 03:04:44 +04:00
|
|
|
char scale_buffer[8];
|
2005-04-08 00:46:22 +04:00
|
|
|
sprintf(scale_buffer, "%.0f", g->option.scale * 100);
|
2004-04-17 20:45:46 +04:00
|
|
|
ro_gui_set_icon_string(dialog_zoom, ICON_ZOOM_VALUE, scale_buffer);
|
2005-04-08 00:46:22 +04:00
|
|
|
|
|
|
|
ro_gui_current_zoom_gui = g;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle clicks in the Open URL dialog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_click_open_url(wimp_pointer *pointer)
|
|
|
|
{
|
2005-05-11 02:49:41 +04:00
|
|
|
wimp_window_state open;
|
2005-04-08 00:46:22 +04:00
|
|
|
url_func_result res;
|
|
|
|
const char *url;
|
|
|
|
char *url2;
|
2005-05-11 02:49:41 +04:00
|
|
|
bool reopen_window = false;
|
|
|
|
wimp_caret caret;
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
if (pointer->i == ICON_OPENURL_MENU) {
|
|
|
|
/* we can't have two open menus, so we close the iconbar menu
|
|
|
|
* and detach our window from it */
|
|
|
|
if (current_menu == iconbar_menu) {
|
|
|
|
reopen_window = true;
|
|
|
|
open.w = dialog_openurl;
|
|
|
|
error = xwimp_get_window_state(&open);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_window_state: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
ro_gui_menu_closed();
|
|
|
|
gui_poll(true);
|
|
|
|
ro_gui_wimp_update_window_furniture(dialog_openurl,
|
|
|
|
wimp_WINDOW_BACK_ICON,
|
|
|
|
wimp_WINDOW_BACK_ICON);
|
|
|
|
error = xwimp_open_window((wimp_open *) &open);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (caret.w == dialog_openurl) {
|
|
|
|
error = xwimp_set_caret_position(dialog_openurl,
|
|
|
|
ICON_OPENURL_URL,
|
|
|
|
caret.pos.x, caret.pos.y,
|
|
|
|
-1, caret.index);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_set_caret_position: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ro_gui_popup_menu(url_suggest_menu,
|
|
|
|
dialog_openurl,
|
|
|
|
ICON_OPENURL_MENU);
|
|
|
|
return;
|
|
|
|
}
|
2005-04-08 00:46:22 +04:00
|
|
|
|
|
|
|
if ((pointer->i != ICON_OPENURL_OPEN) &&
|
|
|
|
(pointer->i != ICON_OPENURL_CANCEL))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pointer->i == ICON_OPENURL_OPEN) {
|
|
|
|
url = ro_gui_get_icon_string(dialog_openurl,
|
|
|
|
ICON_OPENURL_URL);
|
|
|
|
res = url_normalize(url, &url2);
|
|
|
|
if (res == URL_FUNC_OK) {
|
|
|
|
browser_window_create(url2, 0, 0);
|
|
|
|
global_history_add_recent(url2);
|
|
|
|
free(url2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pointer->buttons == wimp_CLICK_ADJUST &&
|
|
|
|
pointer->i == ICON_OPENURL_CANCEL)
|
|
|
|
ro_gui_dialog_prepare_open_url();
|
|
|
|
|
|
|
|
if (pointer->buttons == wimp_CLICK_SELECT) {
|
|
|
|
ro_gui_dialog_close(dialog_openurl);
|
|
|
|
ro_gui_menu_closed();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepares the Open URL dialog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_prepare_open_url(void)
|
|
|
|
{
|
2005-05-11 02:49:41 +04:00
|
|
|
int suggestions;
|
|
|
|
ro_gui_set_icon_string(dialog_openurl, ICON_OPENURL_URL, "");
|
|
|
|
global_history_get_recent(&suggestions);
|
|
|
|
ro_gui_set_icon_shaded_state(dialog_openurl,
|
|
|
|
ICON_OPENURL_MENU, (suggestions <= 0));
|
2004-04-17 20:45:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-07 23:14:54 +04:00
|
|
|
/**
|
|
|
|
* Handle clicks in the warning dialog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_click_warning(wimp_pointer *pointer)
|
|
|
|
{
|
|
|
|
if (pointer->i == ICON_WARNING_CONTINUE)
|
|
|
|
ro_gui_dialog_close(dialog_warning);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-27 02:37:32 +04:00
|
|
|
/**
|
|
|
|
* Close a dialog box.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_dialog_close(wimp_w close)
|
|
|
|
{
|
2004-07-27 19:49:28 +04:00
|
|
|
int i;
|
2004-07-12 23:55:49 +04:00
|
|
|
wimp_caret caret;
|
2004-07-27 19:49:28 +04:00
|
|
|
os_error *error;
|
2004-07-12 23:55:49 +04:00
|
|
|
|
2004-07-27 19:49:28 +04:00
|
|
|
/* Give the caret back to the parent window. This code relies on
|
2005-04-08 00:46:22 +04:00
|
|
|
the fact that only tree windows and browser windows open
|
2004-07-27 19:49:28 +04:00
|
|
|
persistant dialogues, as the caret gets placed to no icon.
|
2004-07-12 23:55:49 +04:00
|
|
|
*/
|
2004-07-27 19:49:28 +04:00
|
|
|
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);
|
2004-08-05 23:27:31 +04:00
|
|
|
} else if (caret.w == close) {
|
2004-07-27 19:49:28 +04:00
|
|
|
/* Check if we are a persistant window
|
|
|
|
*/
|
|
|
|
for (i = 0; i < MAX_PERSISTANT; i++) {
|
|
|
|
if (persistant_dialog[i].dialog == close) {
|
|
|
|
persistant_dialog[i].dialog = NULL;
|
|
|
|
error = xwimp_set_caret_position(
|
|
|
|
persistant_dialog[i].parent,
|
|
|
|
wimp_ICON_WINDOW, -100, -100,
|
|
|
|
32, -1);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_set_caret_position: "
|
|
|
|
"0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
2004-07-12 23:55:49 +04:00
|
|
|
}
|
2004-07-27 19:49:28 +04:00
|
|
|
break;
|
2004-07-12 23:55:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-23 03:04:44 +04:00
|
|
|
|
|
|
|
error = xwimp_close_window(close);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_close_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
2003-08-28 00:09:57 +04:00
|
|
|
}
|
|
|
|
|
2004-02-13 19:09:12 +03:00
|
|
|
|
2004-03-08 03:03:58 +03:00
|
|
|
/**
|
|
|
|
* Convert a 2-letter ISO language code to the language name.
|
|
|
|
*
|
|
|
|
* \param code 2-letter ISO language code
|
|
|
|
* \return language name, or code if unknown
|
|
|
|
*/
|
|
|
|
|
|
|
|
const char *language_name(const char *code)
|
|
|
|
{
|
|
|
|
char key[] = "lang_xx";
|
|
|
|
key[5] = code[0];
|
|
|
|
key[6] = code[1];
|
|
|
|
return messages_get(key);
|
|
|
|
}
|
2004-08-31 01:03:48 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads and nests all available themes in the theme pane.
|
|
|
|
*/
|
2005-02-23 02:36:14 +03:00
|
|
|
|
|
|
|
void ro_gui_dialog_load_themes(void)
|
|
|
|
{
|
2004-08-31 01:03:48 +04:00
|
|
|
os_error *error;
|
|
|
|
os_box extent = { 0, 0, 0, 0 };
|
|
|
|
struct theme_descriptor *descriptor;
|
|
|
|
struct toolbar_display *link;
|
|
|
|
struct toolbar_display *toolbar_display;
|
|
|
|
struct toolbar *toolbar;
|
|
|
|
wimp_icon_create new_icon;
|
|
|
|
wimp_window_state state;
|
|
|
|
int parent_width, nested_y, min_extent, base_extent;
|
2004-09-08 03:05:34 +04:00
|
|
|
int item_height;
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/* Delete our old list and get/open a new one
|
|
|
|
*/
|
|
|
|
ro_gui_dialog_free_themes();
|
|
|
|
theme_list = ro_gui_theme_get_available();
|
|
|
|
ro_gui_theme_open(theme_list, true);
|
|
|
|
theme_choice = ro_gui_theme_find(option_theme);
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/* Create toolbars for each theme
|
|
|
|
*/
|
|
|
|
theme_count = 0;
|
|
|
|
descriptor = theme_list;
|
|
|
|
while (descriptor) {
|
|
|
|
/* Try to create a toolbar
|
|
|
|
*/
|
2005-04-08 00:46:22 +04:00
|
|
|
toolbar = ro_gui_theme_create_toolbar(descriptor,
|
|
|
|
THEME_BROWSER_TOOLBAR);
|
2004-08-31 01:03:48 +04:00
|
|
|
if (toolbar) {
|
|
|
|
toolbar_display = calloc(sizeof(struct toolbar_display), 1);
|
|
|
|
if (!toolbar_display) {
|
|
|
|
LOG(("No memory for calloc()"));
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
toolbar_display->toolbar = toolbar;
|
|
|
|
toolbar_display->descriptor = descriptor;
|
|
|
|
if (!toolbars) {
|
|
|
|
toolbars = toolbar_display;
|
|
|
|
} else {
|
|
|
|
link = toolbars;
|
|
|
|
while (link->next) link = link->next;
|
|
|
|
link->next = toolbar_display;
|
|
|
|
}
|
|
|
|
theme_count++;
|
|
|
|
}
|
|
|
|
descriptor = descriptor->next;
|
|
|
|
}
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/* Nest the toolbars
|
|
|
|
*/
|
|
|
|
state.w = dialog_config_th_pane;
|
|
|
|
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;
|
|
|
|
}
|
2005-02-20 16:19:19 +03:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
parent_width = state.visible.x1 - state.visible.x0;
|
|
|
|
min_extent = state.visible.y0 - state.visible.y1;
|
|
|
|
nested_y = 0;
|
2005-02-07 17:18:33 +03:00
|
|
|
base_extent = state.visible.y1 - state.yscroll;
|
2004-08-31 01:03:48 +04:00
|
|
|
extent.x1 = parent_width;
|
|
|
|
link = toolbars;
|
|
|
|
new_icon.w = dialog_config_th_pane;
|
2004-09-14 03:56:18 +04:00
|
|
|
new_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED |
|
2004-08-31 01:03:48 +04:00
|
|
|
wimp_ICON_VCENTRED |
|
|
|
|
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
|
|
|
|
(wimp_COLOUR_VERY_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT) |
|
2004-09-08 03:05:34 +04:00
|
|
|
(wimp_BUTTON_CLICK << wimp_ICON_BUTTON_TYPE_SHIFT);
|
2004-08-31 01:03:48 +04:00
|
|
|
while (link) {
|
2004-09-08 03:05:34 +04:00
|
|
|
/* Update the toolbar
|
2004-08-31 01:03:48 +04:00
|
|
|
*/
|
2004-09-08 03:05:34 +04:00
|
|
|
item_height = 44 + 44 + 16;
|
|
|
|
if (link->next) item_height += 16;
|
2004-08-31 01:03:48 +04:00
|
|
|
ro_gui_theme_process_toolbar(link->toolbar, parent_width);
|
2004-09-08 03:05:34 +04:00
|
|
|
extent.y0 = nested_y - link->toolbar->height - item_height;
|
2004-08-31 01:03:48 +04:00
|
|
|
if (link->next) extent.y0 -= 16;
|
|
|
|
if (extent.y0 > min_extent) extent.y0 = min_extent;
|
|
|
|
xwimp_set_extent(dialog_config_th_pane, &extent);
|
2005-01-23 19:09:05 +03:00
|
|
|
ro_gui_set_icon_button_type(link->toolbar->toolbar_handle,
|
|
|
|
ICON_TOOLBAR_URL, wimp_BUTTON_NEVER);
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-09-08 03:05:34 +04:00
|
|
|
/* Create the descriptor icons and separator line
|
2004-08-31 01:03:48 +04:00
|
|
|
*/
|
2004-09-08 03:05:34 +04:00
|
|
|
new_icon.icon.extent.x0 = 8;
|
|
|
|
new_icon.icon.extent.x1 = parent_width - 8;
|
|
|
|
new_icon.icon.flags &= ~wimp_ICON_BORDER;
|
|
|
|
new_icon.icon.flags |= wimp_ICON_SPRITE;
|
|
|
|
new_icon.icon.extent.y1 = nested_y - link->toolbar->height - 8;
|
|
|
|
new_icon.icon.extent.y0 = nested_y - link->toolbar->height - 52;
|
2004-08-31 01:03:48 +04:00
|
|
|
new_icon.icon.data.indirected_text_and_sprite.text =
|
2004-09-08 03:05:34 +04:00
|
|
|
(char *)&link->descriptor->name;
|
2004-08-31 01:03:48 +04:00
|
|
|
new_icon.icon.data.indirected_text_and_sprite.size =
|
2004-09-08 03:05:34 +04:00
|
|
|
strlen(link->descriptor->name) + 1;
|
|
|
|
new_icon.icon.data.indirected_text_and_sprite.validation =
|
|
|
|
theme_radio_validation;
|
2004-08-31 01:03:48 +04:00
|
|
|
xwimp_create_icon(&new_icon, &link->icon_number);
|
2004-09-08 03:05:34 +04:00
|
|
|
new_icon.icon.flags &= ~wimp_ICON_SPRITE;
|
|
|
|
new_icon.icon.extent.x0 = 52;
|
|
|
|
new_icon.icon.extent.y1 -= 44;
|
|
|
|
new_icon.icon.extent.y0 -= 44;
|
|
|
|
new_icon.icon.data.indirected_text.text =
|
|
|
|
(char *)&link->descriptor->author;
|
|
|
|
new_icon.icon.data.indirected_text.size =
|
|
|
|
strlen(link->descriptor->filename) + 1;
|
|
|
|
new_icon.icon.data.indirected_text.validation =
|
|
|
|
theme_null_validation;
|
|
|
|
xwimp_create_icon(&new_icon, 0);
|
|
|
|
if (link->next) {
|
|
|
|
new_icon.icon.flags |= wimp_ICON_BORDER;
|
|
|
|
new_icon.icon.extent.x0 = -8;
|
|
|
|
new_icon.icon.extent.x1 = parent_width + 8;
|
|
|
|
new_icon.icon.extent.y1 -= 52;
|
|
|
|
new_icon.icon.extent.y0 = new_icon.icon.extent.y1 - 8;
|
|
|
|
new_icon.icon.data.indirected_text.text =
|
|
|
|
theme_null_validation;
|
|
|
|
new_icon.icon.data.indirected_text.validation =
|
|
|
|
theme_line_validation;
|
|
|
|
new_icon.icon.data.indirected_text.size = 1;
|
|
|
|
strlen(link->descriptor->filename) + 1;
|
|
|
|
xwimp_create_icon(&new_icon, 0);
|
|
|
|
}
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/* Nest the toolbar window
|
|
|
|
*/
|
|
|
|
state.w = link->toolbar->toolbar_handle;
|
2004-08-31 22:01:22 +04:00
|
|
|
state.yscroll = 0;
|
2004-08-31 01:03:48 +04:00
|
|
|
state.visible.y1 = nested_y + base_extent;
|
|
|
|
state.visible.y0 = state.visible.y1 - link->toolbar->height + 2;
|
2005-04-08 00:46:22 +04:00
|
|
|
xwimp_open_window_nested((wimp_open *)&state,
|
|
|
|
dialog_config_th_pane,
|
2004-08-31 01:03:48 +04:00
|
|
|
wimp_CHILD_LINKS_PARENT_WORK_AREA
|
|
|
|
<< wimp_CHILD_BS_EDGE_SHIFT |
|
2004-09-14 03:56:18 +04:00
|
|
|
wimp_CHILD_LINKS_PARENT_WORK_AREA
|
2004-08-31 01:03:48 +04:00
|
|
|
<< wimp_CHILD_TS_EDGE_SHIFT);
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/* Continue processing
|
|
|
|
*/
|
2004-09-08 03:05:34 +04:00
|
|
|
nested_y -= link->toolbar->height + item_height;
|
2004-08-31 01:03:48 +04:00
|
|
|
link = link->next;
|
|
|
|
}
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/* Set the current theme as selected
|
|
|
|
*/
|
|
|
|
link = toolbars;
|
|
|
|
while (link) {
|
2004-11-03 02:23:07 +03:00
|
|
|
ro_gui_set_icon_selected_state(dialog_config_th_pane,
|
2005-04-08 00:46:22 +04:00
|
|
|
link->icon_number,
|
|
|
|
(link->descriptor == theme_choice));
|
2004-09-14 03:56:18 +04:00
|
|
|
link = link->next;
|
2004-08-31 01:03:48 +04:00
|
|
|
}
|
2004-08-31 22:01:22 +04:00
|
|
|
xwimp_force_redraw(dialog_config_th_pane, 0, -16384, 16384, 16384);
|
2004-08-31 01:03:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes and closes all themes in the theme pane.
|
|
|
|
*/
|
2005-02-23 02:36:14 +03:00
|
|
|
|
|
|
|
void ro_gui_dialog_free_themes(void)
|
|
|
|
{
|
2004-08-31 01:03:48 +04:00
|
|
|
struct toolbar_display *toolbar;
|
|
|
|
struct toolbar_display *next_toolbar;
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/* Free all our toolbars
|
|
|
|
*/
|
|
|
|
next_toolbar = toolbars;
|
|
|
|
while ((toolbar = next_toolbar) != NULL) {
|
|
|
|
xwimp_delete_icon(dialog_config_th_pane, toolbar->icon_number);
|
2004-09-08 03:05:34 +04:00
|
|
|
xwimp_delete_icon(dialog_config_th_pane, toolbar->icon_number + 1);
|
|
|
|
if (toolbar->next)
|
2005-04-08 00:46:22 +04:00
|
|
|
xwimp_delete_icon(dialog_config_th_pane,
|
|
|
|
toolbar->icon_number + 2);
|
2004-08-31 01:03:48 +04:00
|
|
|
ro_gui_theme_destroy_toolbar(toolbar->toolbar);
|
|
|
|
next_toolbar = toolbar->next;
|
|
|
|
free(toolbar);
|
|
|
|
}
|
|
|
|
toolbars = NULL;
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2004-08-31 01:03:48 +04:00
|
|
|
/* Close all our themes
|
|
|
|
*/
|
|
|
|
if (theme_list) ro_gui_theme_close(theme_list, true);
|
|
|
|
theme_list = NULL;
|
|
|
|
theme_count = 0;
|
|
|
|
theme_choice = NULL;
|
|
|
|
}
|