summaryrefslogtreecommitdiff
path: root/riscos/query.c
diff options
context:
space:
mode:
authorAdrian Lees <adrian@aemulor.com>2006-02-07 16:16:23 +0000
committerAdrian Lees <adrian@aemulor.com>2006-02-07 16:16:23 +0000
commit57c86c8c0ea8f96756aedb09b3bd29d091e51f5a (patch)
tree0e5cc0a84262b3626c5b88e34cd1c93be39516c1 /riscos/query.c
parent6be0b8e60c81013ece5376779f4c3f30292c93c9 (diff)
downloadnetsurf-57c86c8c0ea8f96756aedb09b3bd29d091e51f5a.tar.gz
netsurf-57c86c8c0ea8f96756aedb09b3bd29d091e51f5a.tar.bz2
[project @ 2006-02-07 16:16:23 by adrianl]
Confirmation before overwriting with download files; Interface Choices dialog svn path=/import/netsurf/; revision=2061
Diffstat (limited to 'riscos/query.c')
-rw-r--r--riscos/query.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/riscos/query.c b/riscos/query.c
index c04aeeb14..846a24a01 100644
--- a/riscos/query.c
+++ b/riscos/query.c
@@ -6,6 +6,7 @@
*/
#include <stdlib.h>
+#include <string.h>
#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/query.h"
@@ -40,6 +41,10 @@ static struct gui_query_window *gui_query_window_list = 0;
/** Template for a query window. */
static struct wimp_window *query_template;
+/** Widths of Yes and No buttons */
+static int query_yes_width = 0;
+static int query_no_width = 0;
+
static void ro_gui_query_window_destroy(struct gui_query_window *qw);
static struct gui_query_window *ro_gui_query_window_lookup_id(query_id id);
@@ -89,14 +94,22 @@ struct gui_query_window *ro_gui_query_window_lookup_id(query_id id)
* \param detail parameter used in expanding tokenised message
* \param cb table of callback functions to be called when user responds
* \param pw handle to be passed to callback functions
+ * \param yes text to use for 'Yes' button' (or NULL for default)
+ * \param no text to use for 'No' button (or NULL for default)
* \return id number of the query (or QUERY_INVALID if it failed)
*/
-query_id query_user(const char *query, const char *detail, const query_callback *cb, void *pw)
+query_id query_user(const char *query, const char *detail,
+ const query_callback *cb, void *pw,
+ const char *yes, const char *no)
{
struct gui_query_window *qw;
char query_buffer[300];
os_error *error;
+ wimp_icon *icn;
+ int width;
+ int len;
+ int x;
qw = malloc(sizeof(struct gui_query_window));
if (!qw) {
@@ -112,9 +125,53 @@ query_id query_user(const char *query, const char *detail, const query_callback
if (next_id == QUERY_INVALID)
next_id++;
+ if (!yes) yes = messages_get("Yes");
+ if (!no) no = messages_get("No");
+
+ /* set the text of the 'No' button and size accordingly */
+ icn = &query_template->icons[ICON_QUERY_NO];
+ len = strnlen(no, icn->data.indirected_text.size - 1);
+ memcpy(icn->data.indirected_text.text, no, len);
+ icn->data.indirected_text.text[len] = '\0';
+
+ 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_no_width) query_no_width = icn->extent.x1 - icn->extent.x0;
+ if (width < query_no_width)
+ width = query_no_width;
+ else
+ width += 44;
+ icn->extent.x0 = x = icn->extent.x1 - width;
+
+ /* set the text of the 'Yes' button and size accordingly */
+ icn = &query_template->icons[ICON_QUERY_YES];
+ len = strnlen(yes, icn->data.indirected_text.size - 1);
+ memcpy(icn->data.indirected_text.text, yes, len);
+ icn->data.indirected_text.text[len] = '\0';
+
+ if (!query_yes_width) query_yes_width = icn->extent.x1 - icn->extent.x0;
+ icn->extent.x1 = x - 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;
+ }
+ if (width < query_yes_width)
+ width = query_yes_width;
+ else
+ width += 28;
+ 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",