NetSurf
Data Structures | Macros | Functions | Variables
query.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utf8.h"
#include "utils/utils.h"
#include "riscos/gui.h"
#include "riscos/query.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/ucstables.h"
#include "riscos/dialog.h"
Include dependency graph for query.c:

Go to the source code of this file.

Data Structures

struct  gui_query_window
 Data for a query window. More...
 

Macros

#define ICON_QUERY_MESSAGE   0
 
#define ICON_QUERY_YES   1
 
#define ICON_QUERY_NO   2
 
#define ICON_QUERY_HELP   3
 

Functions

static struct gui_query_windowro_gui_query_window_lookup_id (query_id id)
 Lookup a query window using its ID number. More...
 
static bool ro_gui_query_click (wimp_pointer *pointer)
 Handle clicks in query dialog. More...
 
static void ro_gui_query_close (wimp_w w)
 Handle closing of query dialog. More...
 
static bool ro_gui_query_apply (wimp_w w)
 Handle acceptance of query dialog. More...
 
void ro_gui_query_init (void)
 
query_id query_user (const char *query, const char *detail, const query_callback *cb, void *pw, const char *yes, const char *no)
 Display a query to the user, requesting a response, near the current pointer position to keep the required mouse travel small, but also protecting against spurious mouse clicks. More...
 
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)
 Display a query to the user, requesting a response, at a specified screen position (x,y). More...
 
void query_close (query_id id)
 Close a query window without waiting for a response from the user. More...
 
void ro_gui_query_window_bring_to_front (query_id id)
 

Variables

static query_id next_id = (query_id)1
 Next unallocated query id. More...
 
static struct gui_query_windowgui_query_window_list = 0
 List of all query windows. More...
 
static struct wimp_window * query_template
 Template for a query window. More...
 
static int query_yes_width = 0
 Widths of Yes and No buttons. More...
 
static int query_no_width = 0
 

Macro Definition Documentation

◆ ICON_QUERY_HELP

#define ICON_QUERY_HELP   3

Definition at line 38 of file query.c.

◆ ICON_QUERY_MESSAGE

#define ICON_QUERY_MESSAGE   0

Definition at line 35 of file query.c.

◆ ICON_QUERY_NO

#define ICON_QUERY_NO   2

Definition at line 37 of file query.c.

◆ ICON_QUERY_YES

#define ICON_QUERY_YES   1

Definition at line 36 of file query.c.

Function Documentation

◆ query_close()

void query_close ( query_id  id)

Close a query window without waiting for a response from the user.

(should normally only be called if the user has responded in some other way of which the query window in unaware.)

Parameters
idid of query window to close

Definition at line 293 of file query.c.

References ro_gui_query_close(), ro_gui_query_window_lookup_id(), and gui_query_window::window.

Referenced by ro_gui_download_window_destroy(), ro_gui_download_window_destroy_wrapper(), and ro_gui_hotlist_remove_page().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ query_user()

query_id query_user ( const char *  query,
const char *  detail,
const query_callback cb,
void *  pw,
const char *  yes,
const char *  no 
)

Display a query to the user, requesting a response, near the current pointer position to keep the required mouse travel small, but also protecting against spurious mouse clicks.

Parameters
querymessage token of query
detailparameter used in expanding tokenised message
cbtable of callback functions to be called when user responds
pwhandle to be passed to callback functions
yestext to use for 'Yes' button' (or NULL for default)
notext to use for 'No' button (or NULL for default)
Returns
id number of the query (or QUERY_INVALID if it failed)

Definition at line 112 of file query.c.

References gui_query_window::cb, gui_query_window::pw, and query_user_xy().

Referenced by ro_gui_download_save(), ro_gui_download_window_destroy(), ro_gui_hotlist_remove_page(), and ro_gui_save_content().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ query_user_xy()

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 
)

Display a query to the user, requesting a response, at a specified screen position (x,y).

The window is positioned relative to the given location such that the required mouse travel is small, but non-zero for protection spurious double-clicks.

Parameters
querymessage token of query
detailparameter used in expanding tokenised message
cbtable of callback functions to be called when user responds
pwhandle to be passed to callback functions
yestext to use for 'Yes' button' (or NULL for default)
notext to use for 'No' button (or NULL for default)
xx position in screen coordinates (-1 = centred on screen)
yy position in screen coordinates (-1 = centred on screen)
Returns
id number of the query (or QUERY_INVALID if it failed)

Definition at line 142 of file query.c.

References gui_query_window::cb, gui_query_window::default_confirm, gui_query_window_list, ICON_QUERY_HELP, ICON_QUERY_MESSAGE, ICON_QUERY_NO, ICON_QUERY_YES, gui_query_window::id, max, messages_get(), gui_query_window::next, next_id, NSERROR_BAD_ENCODING, NSERROR_OK, NSLOG, gui_query_window::prev, gui_query_window::pw, QUERY_INVALID, query_no_width, query_template, query_yes_width, ro_gui_dialog_open(), ro_gui_dialog_open_xy(), ro_gui_query_apply(), ro_gui_query_click(), ro_gui_query_close(), ro_gui_set_icon_string(), ro_gui_wimp_event_register_cancel(), ro_gui_wimp_event_register_close_window(), ro_gui_wimp_event_register_mouse_click(), ro_gui_wimp_event_register_ok(), ro_gui_wimp_event_set_user_data(), ro_warn_user(), utf8_to_local_encoding(), width, and gui_query_window::window.

Referenced by query_user().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_query_apply()

bool ro_gui_query_apply ( wimp_w  w)
static

Handle acceptance of query dialog.

Definition at line 357 of file query.c.

References gui_query_window::cb, query_callback::confirm, gui_query_window::id, gui_query_window::pw, QUERY_YES, and ro_gui_wimp_event_get_user_data().

Referenced by query_user_xy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_query_click()

bool ro_gui_query_click ( wimp_pointer *  pointer)
static

Handle clicks in query dialog.

Definition at line 372 of file query.c.

References query_callback::cancel, gui_query_window::cb, ICON_QUERY_NO, gui_query_window::id, gui_query_window::pw, QUERY_NO, and ro_gui_wimp_event_get_user_data().

Referenced by query_user_xy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_query_close()

void ro_gui_query_close ( wimp_w  w)
static

Handle closing of query dialog.

Definition at line 326 of file query.c.

References gui_query_window_list, gui_query_window::next, NSLOG, gui_query_window::prev, ro_gui_dialog_close(), ro_gui_wimp_event_finalise(), ro_gui_wimp_event_get_user_data(), ro_warn_user(), and gui_query_window::window.

Referenced by query_close(), and query_user_xy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_query_init()

void ro_gui_query_init ( void  )

Definition at line 76 of file query.c.

References query_template, and ro_gui_dialog_load_template().

Referenced by gui_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_query_window_bring_to_front()

void ro_gui_query_window_bring_to_front ( query_id  id)

Definition at line 303 of file query.c.

References NSLOG, ro_gui_dialog_open(), ro_gui_query_window_lookup_id(), ro_warn_user(), and gui_query_window::window.

Referenced by ro_gui_download_window_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ro_gui_query_window_lookup_id()

struct gui_query_window * ro_gui_query_window_lookup_id ( query_id  id)
static

Lookup a query window using its ID number.

Parameters
idid to search for
Returns
pointer to query window or NULL

Definition at line 89 of file query.c.

References gui_query_window_list, gui_query_window::id, and gui_query_window::next.

Referenced by query_close(), and ro_gui_query_window_bring_to_front().

Here is the caller graph for this function:

Variable Documentation

◆ gui_query_window_list

struct gui_query_window* gui_query_window_list = 0
static

List of all query windows.

Definition at line 60 of file query.c.

Referenced by query_user_xy(), ro_gui_query_close(), and ro_gui_query_window_lookup_id().

◆ next_id

query_id next_id = (query_id)1
static

Next unallocated query id.

Definition at line 57 of file query.c.

Referenced by query_user_xy().

◆ query_no_width

int query_no_width = 0
static

Definition at line 67 of file query.c.

Referenced by query_user_xy().

◆ query_template

struct wimp_window* query_template
static

Template for a query window.

Definition at line 63 of file query.c.

Referenced by query_user_xy(), and ro_gui_query_init().

◆ query_yes_width

int query_yes_width = 0
static

Widths of Yes and No buttons.

Definition at line 66 of file query.c.

Referenced by query_user_xy().