summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--!NSTheme/Resources/en/Messages4
-rw-r--r--riscos/gui.c119
-rw-r--r--riscos/gui.h1
-rw-r--r--riscos/help.c40
-rw-r--r--riscos/help.h1
-rw-r--r--riscos/wimp.c155
-rw-r--r--riscos/wimp.h14
7 files changed, 23 insertions, 311 deletions
diff --git a/!NSTheme/Resources/en/Messages b/!NSTheme/Resources/en/Messages
index ed58fff..57a3e79 100644
--- a/!NSTheme/Resources/en/Messages
+++ b/!NSTheme/Resources/en/Messages
@@ -30,6 +30,10 @@ expand:hotlist expand entries icon
separator:toolbar separator
pushed: (pushed)
+# Loading errors
+WarnInvalid:Invalid or unknown theme file format.
+WarnBadSpr:Invalid or unknown sprite file format.
+
# Report text
Title:NSTheme Sprites Report
WarnNoFile:Warning: No sprite file present.
diff --git a/riscos/gui.c b/riscos/gui.c
index 84adde0..71a5008 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -72,16 +72,12 @@ struct ro_gui_poll_block *ro_gui_poll_queued_blocks = 0;
static void ro_gui_choose_language(void);
static void ro_gui_icon_bar_create(void);
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
-static void ro_gui_poll_queue(wimp_event_no event, wimp_block *block);
static void ro_gui_open_window_request(wimp_open *open);
-static void ro_gui_close_window_request(wimp_close *close);
static void ro_gui_mouse_click(wimp_pointer *pointer);
static void ro_gui_icon_bar_click(wimp_pointer *pointer);
-static void ro_gui_drag_end(wimp_dragged *drag);
static void ro_gui_keypress(wimp_key *key);
static void ro_gui_user_message(wimp_event_no event, wimp_message *message);
static void ro_msg_dataload(wimp_message *block);
-static void ro_msg_datasave_ack(wimp_message *message);
/**
@@ -260,7 +256,7 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
break;
case wimp_CLOSE_WINDOW_REQUEST:
- ro_gui_close_window_request(&block->close);
+ ro_gui_dialog_close(block->close.w);
break;
case wimp_MOUSE_CLICK:
@@ -268,7 +264,7 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
break;
case wimp_USER_DRAG_BOX:
- ro_gui_drag_end(&(block->dragged));
+ ro_gui_save_drag_end(&(block->dragged));
break;
case wimp_KEY_PRESSED:
@@ -289,75 +285,6 @@ void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
/**
- * Check for important events and yield CPU (RISC OS).
- *
- * Required on RISC OS for cooperative multitasking.
- */
-
-void gui_multitask(void)
-{
- wimp_event_no event;
- wimp_block block;
-
- if (clock() < gui_last_poll + 10)
- return;
-
- xhourglass_off();
- event = wimp_poll(wimp_MASK_LOSE | wimp_MASK_GAIN, &block, 0);
- xhourglass_on();
- gui_last_poll = clock();
-
- switch (event) {
- case wimp_CLOSE_WINDOW_REQUEST:
- /* \todo close the window, and destroy content
- * or abort loading of content */
- break;
-
- case wimp_KEY_PRESSED:
- case wimp_MENU_SELECTION:
- ro_gui_poll_queue(event, &block);
- break;
-
- default:
- ro_gui_handle_event(event, &block);
- break;
- }
-}
-
-
-/**
- * Add a wimp_block to the queue for later handling.
- */
-
-void ro_gui_poll_queue(wimp_event_no event, wimp_block *block)
-{
- struct ro_gui_poll_block *q =
- calloc(1, sizeof(struct ro_gui_poll_block));
- if (!q) return;
- q->event = event;
- q->block = calloc(1, sizeof(*block));
- if (!q->block) {
- free(q);
- return;
- }
- memcpy(q->block, block, sizeof(*block));
- q->next = NULL;
-
- if (ro_gui_poll_queued_blocks == NULL) {
- ro_gui_poll_queued_blocks = q;
- return;
- } else {
- struct ro_gui_poll_block *current =
- ro_gui_poll_queued_blocks;
- while (current->next != NULL)
- current = current->next;
- current->next = q;
- }
- return;
-}
-
-
-/**
* Handle Open_Window_Request events.
*/
@@ -374,15 +301,6 @@ void ro_gui_open_window_request(wimp_open *open) {
/**
- * Handle Close_Window_Request events.
- */
-
-void ro_gui_close_window_request(wimp_close *close) {
- ro_gui_dialog_close(close->w);
-}
-
-
-/**
* Handle Mouse_Click events.
*/
void ro_gui_mouse_click(wimp_pointer *pointer) {
@@ -406,22 +324,13 @@ void ro_gui_icon_bar_click(wimp_pointer *pointer)
96 + iconbar_menu_height);
} else if (pointer->buttons == wimp_CLICK_SELECT) {
ro_gui_dialog_prepare_main();
- ro_gui_open_window_centre(NULL, dialog_main);
+ ro_gui_open_window_centre(dialog_main);
ro_gui_set_caret_first(dialog_main);
}
}
/**
- * Handle User_Drag_Box events.
- */
-
-void ro_gui_drag_end(wimp_dragged *drag) {
- ro_gui_save_drag_end(drag);
-}
-
-
-/**
* Handle Key_Pressed events.
*/
@@ -431,6 +340,7 @@ void ro_gui_keypress(wimp_key *key) {
if (key->c == wimp_KEY_F1) {
xos_cli("Filer_Run <NSTheme$Dir>.!Help");
+ return;
}
if (key->w == dialog_saveas) {
@@ -462,13 +372,11 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message)
break;
case message_DATA_SAVE_ACK:
- ro_msg_datasave_ack(message);
+ ro_gui_save_datasave_ack(message);
break;
case message_DATA_LOAD:
- if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
- }
- else
+ if (event != wimp_USER_MESSAGE_ACKNOWLEDGE)
ro_msg_dataload(message);
break;
@@ -508,13 +416,17 @@ void ro_msg_dataload(wimp_message *message) {
free(sprite_filename);
sprite_filename = NULL;
}
+ } else {
+ warn_user("WarnBadSpr", 0);
}
} else {
success = ro_gui_load_theme(filename);
if (success) {
ro_gui_dialog_prepare_main();
- ro_gui_open_window_centre(NULL, dialog_main);
+ ro_gui_open_window_centre(dialog_main);
ro_gui_set_caret_first(dialog_main);
+ } else {
+ warn_user("WarnInvalid", 0);
}
}
@@ -532,15 +444,6 @@ void ro_msg_dataload(wimp_message *message) {
/**
- * Handle Message_DataSaveAck.
- */
-
-void ro_msg_datasave_ack(wimp_message *message) {
- ro_gui_save_datasave_ack(message);
-}
-
-
-/**
* Find screen size in OS units.
*/
diff --git a/riscos/gui.h b/riscos/gui.h
index 54b312c..78ac3cb 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -47,7 +47,6 @@ struct theme_file_header {
/* in gui.c */
void ro_gui_screen_size(int *width, int *height);
-//void ro_gui_drag_box_start(wimp_pointer *pointer);
/* in menus.c */
void ro_gui_menus_init(void);
diff --git a/riscos/help.c b/riscos/help.c
index 62bfd8a..5581649 100644
--- a/riscos/help.c
+++ b/riscos/help.c
@@ -47,7 +47,6 @@
*/
static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token);
-static os_t help_time = 0;
/**
* Attempts to process an interactive help message request
@@ -69,10 +68,6 @@ void ro_gui_interactive_help_request(wimp_message *message) {
*/
if ((!message) || (message->action != message_HELP_REQUEST)) return;
- /* Remember the time of the request
- */
- xos_read_monotonic_time(&help_time);
-
/* Initialise the basic token to a null byte
*/
message_token[0] = 0x00;
@@ -220,38 +215,3 @@ static void ro_gui_interactive_help_broadcast(wimp_message *message, char *token
wimp_send_message(wimp_USER_MESSAGE, (wimp_message *)reply, reply->sender);
}
-
-/**
- * Checks if interactive help is running
- *
- * \return non-zero if interactive help is available, or 0 if not available
- */
-int ro_gui_interactive_help_available() {
- taskmanager_task task;
- int context = 0;
- char *end;
- os_t time;
-
- /* Check if we've received a help request in the last 0.5s to test for generic
- interactive help applications
- */
- xos_read_monotonic_time(&time);
- if ((help_time + 50) > time) return true;
-
- /* Attempt to find the task 'Help'
- */
- do {
- if (xtaskmanager_enumerate_tasks(context, &task, sizeof(taskmanager_task),
- &context, &end)) return 0;
-
- /* We can't just use strcmp due to string termination issues.
- */
- if (strncmp(task.name, "Help", 4) == 0) {
- if (task.name[4] < 32) return true;
- }
- } while (context >= 0);
-
- /* Return failure
- */
- return 0;
-}
diff --git a/riscos/help.h b/riscos/help.h
index 444dec7..bdf9847 100644
--- a/riscos/help.h
+++ b/riscos/help.h
@@ -15,6 +15,5 @@
#include "oslib/wimp.h"
void ro_gui_interactive_help_request(wimp_message *message);
-int ro_gui_interactive_help_available(void);
#endif
diff --git a/riscos/wimp.c b/riscos/wimp.c
index bb97ec6..44d7c12 100644
--- a/riscos/wimp.c
+++ b/riscos/wimp.c
@@ -26,106 +26,6 @@
#include "nstheme/utils/log.h"
#include "nstheme/utils/utils.h"
-/* Wimp_Extend,11 block
-*/
-static wimpextend_furniture_sizes furniture_sizes;
-
-
-/**
- * Gets the horzontal scrollbar height
- */
-int ro_get_hscroll_height(wimp_w w) {
- wimp_version_no version;
-
- /* Read the hscroll height
- */
- if (!w) return 38;
- furniture_sizes.w = w;
- furniture_sizes.border_widths.y0 = 38;
- xwimpextend_get_furniture_sizes(&furniture_sizes);
-
- /* There is a quirk with the returned size as it differs between versions of the
- WindowManager module. The incorrect height is returned by the version distributed
- with the universal boot sequence (3.98) and presumably any previous version.
- */
- if (!xwimpreadsysinfo_version(&version)) {
- if ((int)version <= 398) {
- return furniture_sizes.border_widths.y0 + 2;
- }
- }
-
- /* Return the standard (unhacked) size
- */
- return furniture_sizes.border_widths.y0;
-}
-
-
-/**
- * Gets the vertical scrollbar width
- */
-int ro_get_vscroll_width(wimp_w w) {
-
- /* Read the hscroll height
- */
- if (!w) return 38;
- furniture_sizes.w = w;
- furniture_sizes.border_widths.x1 = 38;
- xwimpextend_get_furniture_sizes(&furniture_sizes);
-
- /* Return the standard (unhacked) size
- */
- return furniture_sizes.border_widths.x1;
-}
-
-
-/**
- * Reads a modes EIG factors.
- *
- * \param mode mode to read EIG factors for, or -1 for current
- */
-struct eig_factors ro_read_eig_factors(os_mode mode) {
- bits psr;
- struct eig_factors factors;
- xos_read_mode_variable(mode, os_MODEVAR_XEIG_FACTOR, &factors.xeig, &psr);
- xos_read_mode_variable(mode, os_MODEVAR_YEIG_FACTOR, &factors.yeig, &psr);
- return factors;
-}
-
-
-/**
- * Converts the supplied os_coord from OS units to pixels.
- *
- * \param os_units values to convert
- * \param mode mode to use EIG factors for, or -1 for current
- */
-void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode) {
- struct eig_factors factors = ro_read_eig_factors(mode);
- os_units->x = (os_units->x >> factors.xeig);
- os_units->y = (os_units->y >> factors.yeig);
-}
-
-
-/**
- * Converts the supplied os_coord from pixels to OS units.
- *
- * \param pixels values to convert
- * \param mode mode to use EIG factors for, or -1 for current
- */
-void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode) {
- struct eig_factors factors = ro_read_eig_factors(mode);
- pixels->x = (pixels->x << factors.xeig);
- pixels->y = (pixels->y << factors.yeig);
-}
-
-
-/**
- * Redraws an icon
- *
- * \param w window handle
- * \param i icon handle
- */
-#define ro_gui_redraw_icon(w, i) xwimp_set_icon_state(w, i, 0, 0)
-
/**
* Read the contents of an icon.
@@ -208,20 +108,6 @@ void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text) {
/**
- * Set the contents of an icon to a number.
- *
- * \param w window handle
- * \param i icon handle
- * \param value value
- */
-void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value) {
- char buffer[20]; // Big enough for 64-bit int
- sprintf(buffer, "%d", value);
- ro_gui_set_icon_string(w, i, buffer);
-}
-
-
-/**
* Set the selected state of an icon.
*
* \param w window handle
@@ -449,57 +335,30 @@ void ro_gui_set_caret_first(wimp_w w) {
/**
* Opens a window at the centre of either another window or the screen
*
- * /param parent the parent window (NULL for centre of screen)
* /param child the child window
*/
-void ro_gui_open_window_centre(wimp_w parent, wimp_w child) {
+void ro_gui_open_window_centre(wimp_w w) {
os_error *error;
wimp_window_state state;
- int mid_x, mid_y;
- int dimension, scroll_width;
-
- /* Get the parent window state
- */
- if (parent) {
- state.w = parent;
- error = xwimp_get_window_state(&state);
- if (error) {
- warn_user("WimpError", error->errmess);
- return;
- }
- scroll_width = ro_get_vscroll_width(parent);
+ int mid_x, mid_y, dimension;
- /* Get the centre of the parent
- */
- mid_x = (state.visible.x0 + state.visible.x1 + scroll_width) / 2;
- mid_y = (state.visible.y0 + state.visible.y1) / 2;
- } else {
- ro_gui_screen_size(&mid_x, &mid_y);
- mid_x /= 2;
- mid_y /= 2;
- }
-
- /* Get the child window state
- */
- state.w = child;
+ state.w = w;
error = xwimp_get_window_state(&state);
if (error) {
warn_user("WimpError", error->errmess);
return;
}
if (!(state.flags & wimp_WINDOW_OPEN)) {
- /* Move to the centre of the parent at the top of the stack
- */
+ ro_gui_screen_size(&mid_x, &mid_y);
dimension = state.visible.x1 - state.visible.x0;
- scroll_width = ro_get_vscroll_width(child);
- state.visible.x0 = mid_x - (dimension + scroll_width) / 2;
+ state.visible.x0 = (mid_x - dimension) >> 1;
state.visible.x1 = state.visible.x0 + dimension;
dimension = state.visible.y1 - state.visible.y0;
- state.visible.y0 = mid_y - dimension / 2;
+ state.visible.y0 = (mid_y - dimension) >> 1;
state.visible.y1 = state.visible.y0 + dimension;
}
state.next = wimp_TOP;
- wimp_open_window((wimp_open *) &state);
+ wimp_open_window((wimp_open *)&state);
}
diff --git a/riscos/wimp.h b/riscos/wimp.h
index 33c3ae7..bb8a870 100644
--- a/riscos/wimp.h
+++ b/riscos/wimp.h
@@ -21,22 +21,10 @@
#include "oslib/os.h"
#include "oslib/wimp.h"
-struct eig_factors {
- int xeig;
- int yeig;
-};
-
-
-int ro_get_hscroll_height(wimp_w w);
-int ro_get_vscroll_width(wimp_w w);
-struct eig_factors ro_read_eig_factors(os_mode mode);
-void ro_convert_os_units_to_pixels(os_coord *os_units, os_mode mode);
-void ro_convert_pixels_to_os_units(os_coord *pixels, os_mode mode);
#define ro_gui_redraw_icon(w, i) xwimp_set_icon_state(w, i, 0, 0)
char *ro_gui_get_icon_string(wimp_w w, wimp_i i);
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text);
-void ro_gui_set_icon_integer(wimp_w w, wimp_i i, int value);
void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state);
bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i);
void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state);
@@ -45,7 +33,7 @@ int ro_gui_get_icon_background_colour(wimp_w w, wimp_i i);
void ro_gui_set_icon_background_colour(wimp_w w, wimp_i i, int colour);
void ro_gui_set_window_title(wimp_w w, const char *title);
void ro_gui_set_caret_first(wimp_w w);
-void ro_gui_open_window_centre(wimp_w parent, wimp_w child);
+void ro_gui_open_window_centre(wimp_w w);
osspriteop_area *ro_gui_load_sprite_file(const char *pathname);
#endif