mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 04:56:50 +03:00
[project @ 2005-04-17 23:32:09 by adrianl]
better keyboard support for scale and find dialogs svn path=/import/netsurf/; revision=1665
This commit is contained in:
parent
f3f63a1cac
commit
89d98d0577
@ -108,7 +108,9 @@ static void ro_gui_dialog_click_config_th(wimp_pointer *pointer);
|
||||
static void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer);
|
||||
static void ro_gui_dialog_update_config_font(void);
|
||||
static void ro_gui_dialog_click_config_font(wimp_pointer *pointer);
|
||||
static unsigned ro_gui_clamp_scale(unsigned scale);
|
||||
static void ro_gui_dialog_click_zoom(wimp_pointer *pointer);
|
||||
static bool ro_gui_zoom_keypress(wimp_key *key);
|
||||
static void ro_gui_dialog_click_open_url(wimp_pointer *pointer);
|
||||
static void ro_gui_dialog_click_warning(wimp_pointer *pointer);
|
||||
static const char *language_name(const char *code);
|
||||
@ -406,6 +408,8 @@ bool ro_gui_dialog_keypress(wimp_key *key)
|
||||
if (key->w == dialog_print)
|
||||
return ro_gui_print_keypress(key);
|
||||
#endif
|
||||
if (key->w == dialog_zoom)
|
||||
return ro_gui_zoom_keypress(key);
|
||||
if (key->c == wimp_KEY_ESCAPE) {
|
||||
ro_gui_dialog_close(key->w);
|
||||
return true;
|
||||
@ -1146,6 +1150,23 @@ void ro_gui_dialog_font_menu_selection(int item)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle clicks in the Scale view dialog.
|
||||
*/
|
||||
@ -1154,7 +1175,6 @@ void ro_gui_dialog_click_zoom(wimp_pointer *pointer)
|
||||
{
|
||||
unsigned int scale;
|
||||
int stepping = 10;
|
||||
struct content *c;
|
||||
scale = atoi(ro_gui_get_icon_string(dialog_zoom, ICON_ZOOM_VALUE));
|
||||
|
||||
/* Adjust moves values the opposite direction
|
||||
@ -1171,20 +1191,11 @@ void ro_gui_dialog_click_zoom(wimp_pointer *pointer)
|
||||
case ICON_ZOOM_200: scale = 200; break;
|
||||
}
|
||||
|
||||
if (scale < 10)
|
||||
scale = 10;
|
||||
else if (1600 < scale)
|
||||
scale = 1600;
|
||||
scale = ro_gui_clamp_scale(scale);
|
||||
ro_gui_set_icon_integer(dialog_zoom, ICON_ZOOM_VALUE, scale);
|
||||
|
||||
if (pointer->i == ICON_ZOOM_OK) {
|
||||
ro_gui_current_zoom_gui->option.scale = scale * 0.01;
|
||||
ro_gui_current_zoom_gui->reformat_pending = true;
|
||||
c = ro_gui_current_zoom_gui->bw->current_content;
|
||||
if ((c) && (c->type != CONTENT_HTML))
|
||||
browser_window_update(ro_gui_current_zoom_gui->bw, false);
|
||||
gui_reformat_pending = true;
|
||||
}
|
||||
if (pointer->i == ICON_ZOOM_OK)
|
||||
ro_gui_window_set_scale(ro_gui_current_zoom_gui, (float)scale);
|
||||
|
||||
if (pointer->buttons == wimp_CLICK_ADJUST &&
|
||||
pointer->i == ICON_ZOOM_CANCEL)
|
||||
@ -1199,6 +1210,27 @@ void ro_gui_dialog_click_zoom(wimp_pointer *pointer)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepares the Scale view dialog.
|
||||
*/
|
||||
|
@ -170,6 +170,7 @@ browser_mouse_state ro_gui_mouse_click_state(wimp_mouse_state buttons);
|
||||
bool ro_gui_shift_pressed(void);
|
||||
bool ro_gui_ctrl_pressed(void);
|
||||
void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag);
|
||||
void ro_gui_window_set_scale(struct gui_window *g, float scale);
|
||||
|
||||
/* in history.c */
|
||||
void ro_gui_history_init(void);
|
||||
|
@ -65,6 +65,7 @@ static const char *find_pattern(const char *string, int s_len,
|
||||
const char *pattern, int p_len, bool case_sens, int *m_len);
|
||||
static bool find_occurrences(const char *pattern, int p_len, struct box *cur,
|
||||
bool case_sens);
|
||||
static void show_search_direction(bool forwards);
|
||||
|
||||
|
||||
/**
|
||||
@ -81,10 +82,7 @@ void ro_gui_search_prepare(struct gui_window *g)
|
||||
search_current_window = g;
|
||||
|
||||
ro_gui_set_icon_string(dialog_search, ICON_SEARCH_TEXT, "");
|
||||
ro_gui_set_icon_selected_state(dialog_search, ICON_SEARCH_FORWARDS,
|
||||
true);
|
||||
ro_gui_set_icon_selected_state(dialog_search, ICON_SEARCH_BACKWARDS,
|
||||
false);
|
||||
show_search_direction(true);
|
||||
ro_gui_set_icon_selected_state(dialog_search, ICON_SEARCH_START,
|
||||
false);
|
||||
ro_gui_set_icon_selected_state(dialog_search,
|
||||
@ -147,12 +145,10 @@ bool ro_gui_search_keypress(wimp_key *key)
|
||||
|
||||
switch (key->c) {
|
||||
case 2: /* ctrl b */
|
||||
ro_gui_set_icon_selected_state(dialog_search, ICON_SEARCH_FORWARDS, false);
|
||||
ro_gui_set_icon_selected_state(dialog_search, ICON_SEARCH_BACKWARDS, true);
|
||||
show_search_direction(false);
|
||||
return true;
|
||||
case 6: /* ctrl f */
|
||||
ro_gui_set_icon_selected_state(dialog_search, ICON_SEARCH_FORWARDS, true);
|
||||
ro_gui_set_icon_selected_state(dialog_search, ICON_SEARCH_BACKWARDS, false);
|
||||
show_search_direction(true);
|
||||
return true;
|
||||
case 9: /* ctrl i */
|
||||
state = ro_gui_get_icon_selected_state(dialog_search, ICON_SEARCH_CASE_SENSITIVE);
|
||||
@ -161,7 +157,6 @@ bool ro_gui_search_keypress(wimp_key *key)
|
||||
case 19: /* ctrl s */
|
||||
state = ro_gui_get_icon_selected_state(dialog_search, ICON_SEARCH_START);
|
||||
ro_gui_set_icon_selected_state(dialog_search, ICON_SEARCH_START, !state);
|
||||
|
||||
return true;
|
||||
case wimp_KEY_RETURN:
|
||||
start_search();
|
||||
@ -169,6 +164,14 @@ bool ro_gui_search_keypress(wimp_key *key)
|
||||
case wimp_KEY_ESCAPE:
|
||||
end_search();
|
||||
return true;
|
||||
case wimp_KEY_UP:
|
||||
show_search_direction(false);
|
||||
start_search();
|
||||
return true;
|
||||
case wimp_KEY_DOWN:
|
||||
show_search_direction(true);
|
||||
start_search();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -563,4 +566,16 @@ bool gui_search_term_highlighted(struct gui_window *g, struct box *box,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change the displayed search direction.
|
||||
*
|
||||
* \param forwards true for forwards, else backwards
|
||||
*/
|
||||
|
||||
void show_search_direction(bool forwards)
|
||||
{
|
||||
ro_gui_set_icon_selected_state(dialog_search, ICON_SEARCH_FORWARDS, forwards);
|
||||
ro_gui_set_icon_selected_state(dialog_search, ICON_SEARCH_BACKWARDS, !forwards);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1592,6 +1592,7 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
|
||||
osbool unclaimed;
|
||||
/* Alphabet has changed, so read UCS table location */
|
||||
alphabet = t_alphabet;
|
||||
|
||||
error = xserviceinternational_get_ucs_conversion_table(
|
||||
alphabet, &unclaimed,
|
||||
(void**)&ucstable);
|
||||
@ -2451,3 +2452,21 @@ void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag)
|
||||
ro_gui_mouse_click_state(pointer.buttons), x, y);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alter the scale setting of a window
|
||||
*
|
||||
* \param g gui window
|
||||
* \param scale scale value (1.0 == normal scale)
|
||||
*/
|
||||
|
||||
void ro_gui_window_set_scale(struct gui_window *g, float scale)
|
||||
{
|
||||
struct content *c;
|
||||
g->option.scale = scale;
|
||||
g->reformat_pending = true;
|
||||
c = g->bw->current_content;
|
||||
if ((c) && (c->type != CONTENT_HTML))
|
||||
browser_window_update(g->bw, false);
|
||||
gui_reformat_pending = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user