NetSurf
|
Scrollbar widget interface. More...
#include <stdbool.h>
#include <limits.h>
Go to the source code of this file.
Data Structures | |
struct | scrollbar_msg_data |
scrollbar message context data More... | |
Macros | |
#define | SCROLLBAR_WIDTH 16 |
#define | SCROLL_TOP INT_MIN |
#define | SCROLL_PAGE_UP (INT_MIN + 1) |
#define | SCROLL_PAGE_DOWN (INT_MAX - 1) |
#define | SCROLL_BOTTOM INT_MAX |
Typedefs | |
typedef void(* | scrollbar_client_callback) (void *client_data, struct scrollbar_msg_data *scrollbar_data) |
Client callback for the scrollbar. More... | |
Enumerations | |
enum | scrollbar_msg { SCROLLBAR_MSG_MOVED , SCROLLBAR_MSG_SCROLL_START , SCROLLBAR_MSG_SCROLL_FINISHED } |
scrollbar message types More... | |
enum | scrollbar_mouse_status { SCROLLBAR_MOUSE_NONE = 0 , SCROLLBAR_MOUSE_USED = (1 << 0) , SCROLLBAR_MOUSE_BOTH = (1 << 1) , SCROLLBAR_MOUSE_UP = (1 << 2) , SCROLLBAR_MOUSE_PUP = (1 << 3) , SCROLLBAR_MOUSE_VRT = (1 << 4) , SCROLLBAR_MOUSE_PDWN = (1 << 5) , SCROLLBAR_MOUSE_DWN = (1 << 6) , SCROLLBAR_MOUSE_LFT = (1 << 7) , SCROLLBAR_MOUSE_PLFT = (1 << 8) , SCROLLBAR_MOUSE_HRZ = (1 << 9) , SCROLLBAR_MOUSE_PRGT = (1 << 10) , SCROLLBAR_MOUSE_RGT = (1 << 11) } |
Scrollbar mouse input status flags. More... | |
Functions | |
nserror | scrollbar_create (bool horizontal, int length, int full_size, int visible_size, void *client_data, scrollbar_client_callback client_callback, struct scrollbar **s) |
Create a scrollbar. More... | |
void | scrollbar_destroy (struct scrollbar *s) |
Destroy a scrollbar. More... | |
nserror | scrollbar_redraw (struct scrollbar *s, int x, int y, const struct rect *clip, float scale, const struct redraw_context *ctx) |
Redraw a part of the scrollbar. More... | |
void | scrollbar_set (struct scrollbar *s, int value, bool bar_pos) |
Set the scroll value of the scrollbar. More... | |
bool | scrollbar_scroll (struct scrollbar *s, int change) |
Scroll the scrollbar by given amount. More... | |
int | scrollbar_get_offset (struct scrollbar *s) |
Get the current scroll offset to the visible part of the full area. More... | |
void | scrollbar_set_extents (struct scrollbar *s, int length, int visible_size, int full_size) |
Set the length of the scrollbar widget, the size of the visible area, and the size of the full area. More... | |
bool | scrollbar_is_horizontal (struct scrollbar *s) |
Check orientation of the scrollbar. More... | |
scrollbar_mouse_status | scrollbar_mouse_action (struct scrollbar *s, browser_mouse_state mouse, int x, int y) |
Handle mouse actions other then drag ends. More... | |
const char * | scrollbar_mouse_status_to_message (scrollbar_mouse_status status) |
Get a status bar message from a scrollbar mouse input status. More... | |
void | scrollbar_mouse_drag_end (struct scrollbar *s, browser_mouse_state mouse, int x, int y) |
Handle end of mouse drags. More... | |
void | scrollbar_start_content_drag (struct scrollbar *s, int x, int y) |
Called when the content is being dragged to the scrollbars have to adjust. More... | |
void | scrollbar_make_pair (struct scrollbar *horizontal, struct scrollbar *vertical) |
Connect a horizontal and a vertical scrollbar into a pair so that they co-operate during 2D drags. More... | |
void * | scrollbar_get_data (struct scrollbar *s) |
Get the scrollbar's client data. More... | |
Scrollbar widget interface.
Scrollbar widgets used in frames code, not for frontend use
Definition in file scrollbar.h.
#define SCROLL_BOTTOM INT_MAX |
Definition at line 38 of file scrollbar.h.
#define SCROLL_PAGE_DOWN (INT_MAX - 1) |
Definition at line 37 of file scrollbar.h.
#define SCROLL_PAGE_UP (INT_MIN + 1) |
Definition at line 36 of file scrollbar.h.
#define SCROLL_TOP INT_MIN |
Definition at line 35 of file scrollbar.h.
#define SCROLLBAR_WIDTH 16 |
Definition at line 32 of file scrollbar.h.
typedef void(* scrollbar_client_callback) (void *client_data, struct scrollbar_msg_data *scrollbar_data) |
Client callback for the scrollbar.
client_data | user data passed at scroll creation |
scrollbar_data | scrollbar message data |
Definition at line 93 of file scrollbar.h.
Scrollbar mouse input status flags.
Definition at line 70 of file scrollbar.h.
enum scrollbar_msg |
scrollbar message types
Definition at line 46 of file scrollbar.h.
nserror scrollbar_create | ( | bool | horizontal, |
int | length, | ||
int | full_size, | ||
int | visible_size, | ||
void * | client_data, | ||
scrollbar_client_callback | client_callback, | ||
struct scrollbar ** | s | ||
) |
Create a scrollbar.
horizontal | true = horizontal scrollbar, false = vertical |
length | length of scrollbar widget |
full_size | length of contained scrollable area |
visible_size | length of visible part of scrollable area |
client_data | data for the client callback |
client_callback | client callback for scrollbar events |
s | updated to point at the newly created scrollbar |
Definition at line 93 of file scrollbar.c.
References scrollbar::bar_len, scrollbar::bar_pos, scrollbar::client_callback, scrollbar::client_data, scrollbar::drag_content, scrollbar::dragging, scrollbar::full_size, scrollbar::horizontal, scrollbar::length, NSERROR_NOMEM, NSERROR_OK, scrollbar::offset, scrollbar::pair, scrollbar::pair_drag, SCROLLBAR_WIDTH, and scrollbar::visible_size.
Referenced by box_handle_scrollbars(), browser_window_handle_scrollbars(), form_open_select_menu(), and textarea_reflow_multiline().
void scrollbar_destroy | ( | struct scrollbar * | s | ) |
Destroy a scrollbar.
s | the scrollbar to be destroyed |
Definition at line 138 of file scrollbar.c.
References scrollbar::pair.
Referenced by box_free_box(), box_handle_scrollbars(), box_talloc_destructor(), browser_window_destroy_internal(), browser_window_handle_scrollbars(), form_free_select_menu(), textarea_destroy(), and textarea_reflow_multiline().
void * scrollbar_get_data | ( | struct scrollbar * | s | ) |
Get the scrollbar's client data.
s | the scrollbar to get the client data from |
Definition at line 1004 of file scrollbar.c.
References scrollbar::client_data.
Referenced by box_handle_scrollbars(), box_talloc_destructor(), html_overflow_scroll_drag_end(), and mouse_action_drag_scrollbar().
int scrollbar_get_offset | ( | struct scrollbar * | s | ) |
Get the current scroll offset to the visible part of the full area.
s | the scrollbar to get the scroll offset value from |
Definition at line 628 of file scrollbar.c.
References scrollbar::offset.
Referenced by box_at_point(), box_coords(), box_nearest_text_box(), browser_window__get_contextual_content(), browser_window_drop_file_at_point_internal(), browser_window_get_position(), browser_window_mouse_click_internal(), browser_window_mouse_drag_end(), browser_window_mouse_track_internal(), browser_window_page_drag_start(), browser_window_redraw(), browser_window_scroll_at_point_internal(), browser_window_scroll_callback(), browser_window_update(), form_redraw_select_menu(), form_select_menu_clicked(), get_mouse_action_node(), html_redraw_box(), html_redraw_box_children(), textarea_scroll_visible(), and textarea_scrollbar_callback().
bool scrollbar_is_horizontal | ( | struct scrollbar * | s | ) |
Check orientation of the scrollbar.
s | the scrollbar to check the orientation of |
Definition at line 695 of file scrollbar.c.
References scrollbar::horizontal.
Referenced by browser_window_scroll_callback(), html_overflow_scroll_drag_end(), and mouse_action_drag_scrollbar().
Connect a horizontal and a vertical scrollbar into a pair so that they co-operate during 2D drags.
horizontal | the scrollbar used for horizontal scrolling |
vertical | the scrollbar used for vertical scrolling |
Definition at line 990 of file scrollbar.c.
References scrollbar::horizontal, and scrollbar::pair.
Referenced by box_handle_scrollbars(), browser_window_handle_scrollbars(), and textarea_reflow_multiline().
scrollbar_mouse_status scrollbar_mouse_action | ( | struct scrollbar * | s, |
browser_mouse_state | mouse, | ||
int | x, | ||
int | y | ||
) |
Handle mouse actions other then drag ends.
s | the scrollbar which gets the mouse action |
mouse | mouse state |
x | X coordinate of the mouse |
y | Y coordinate of the mouse |
Definition at line 769 of file scrollbar.c.
References scrollbar::bar_len, scrollbar::bar_pos, BROWSER_MOUSE_DRAG_1, BROWSER_MOUSE_DRAG_2, BROWSER_MOUSE_DRAG_ON, BROWSER_MOUSE_HOLDING_1, BROWSER_MOUSE_HOLDING_2, BROWSER_MOUSE_PRESS_1, BROWSER_MOUSE_PRESS_2, scrollbar::drag_content, scrollbar::drag_start_coord, scrollbar::drag_start_pos, scrollbar::dragging, scrollbar::horizontal, scrollbar::length, scrollbar::offset, scrollbar::pair, scrollbar::pair_drag, scrollbar_drag_start_internal(), scrollbar_mouse_action(), SCROLLBAR_MOUSE_BOTH, SCROLLBAR_MOUSE_DWN, SCROLLBAR_MOUSE_HRZ, SCROLLBAR_MOUSE_LFT, SCROLLBAR_MOUSE_NONE, SCROLLBAR_MOUSE_PDWN, SCROLLBAR_MOUSE_PLFT, SCROLLBAR_MOUSE_PRGT, SCROLLBAR_MOUSE_PUP, SCROLLBAR_MOUSE_RGT, SCROLLBAR_MOUSE_UP, SCROLLBAR_MOUSE_VRT, scrollbar_set(), SCROLLBAR_WIDTH, scrollbar_msg_data::x0, scrollbar_msg_data::x1, scrollbar_msg_data::y0, and scrollbar_msg_data::y1.
Referenced by browser_window_mouse_click_internal(), browser_window_mouse_track_internal(), form_select_mouse_action(), mouse_action_drag_none(), mouse_action_drag_scrollbar(), scrollbar_mouse_action(), and textarea_mouse_scrollbar_action().
void scrollbar_mouse_drag_end | ( | struct scrollbar * | s, |
browser_mouse_state | mouse, | ||
int | x, | ||
int | y | ||
) |
Handle end of mouse drags.
s | the scrollbar for which the drag ends |
mouse | mouse state |
x | X coordinate of the mouse |
y | Y coordinate of the mouse |
Definition at line 933 of file scrollbar.c.
References scrollbar::client_callback, scrollbar::client_data, scrollbar::drag_content, scrollbar::drag_start_coord, scrollbar::drag_start_pos, scrollbar::dragging, scrollbar::horizontal, scrollbar_msg_data::msg, scrollbar::pair, scrollbar::pair_drag, SCROLLBAR_MSG_SCROLL_FINISHED, and scrollbar_set().
Referenced by browser_window_mouse_drag_end(), form_select_mouse_drag_end(), html_overflow_scroll_drag_end(), and textarea_drag_end().
const char * scrollbar_mouse_status_to_message | ( | scrollbar_mouse_status | status | ) |
Get a status bar message from a scrollbar mouse input status.
status | Status to convert to message |
Definition at line 889 of file scrollbar.c.
References messages_get(), SCROLLBAR_MOUSE_DWN, SCROLLBAR_MOUSE_HRZ, SCROLLBAR_MOUSE_LFT, SCROLLBAR_MOUSE_PDWN, SCROLLBAR_MOUSE_PLFT, SCROLLBAR_MOUSE_PRGT, SCROLLBAR_MOUSE_PUP, SCROLLBAR_MOUSE_RGT, SCROLLBAR_MOUSE_UP, SCROLLBAR_MOUSE_USED, and SCROLLBAR_MOUSE_VRT.
Referenced by browser_window_mouse_click_internal(), browser_window_mouse_track_internal(), form_select_mouse_action(), gadget_mouse_action(), mouse_action_drag_none(), and mouse_action_drag_scrollbar().
nserror scrollbar_redraw | ( | struct scrollbar * | s, |
int | x, | ||
int | y, | ||
const struct rect * | clip, | ||
float | scale, | ||
const struct redraw_context * | ctx | ||
) |
Redraw a part of the scrollbar.
s | the scrollbar to be redrawn |
x | the X coordinate to draw the scrollbar at |
y | the Y coordinate to draw the scrollbar at |
clip | the clipping rectangle |
scale | scale for the redraw |
ctx | current redraw context |
Definition at line 239 of file scrollbar.c.
References scrollbar::bar_len, scrollbar::bar_pos, clip(), plot_style_s::fill_colour, plot_style_s::fill_type, scrollbar::horizontal, scrollbar::length, NSCOLOUR_BUTTON_BG, NSCOLOUR_BUTTON_FG, NSCOLOUR_SCROLL_WELL, nscolours, NSERROR_OK, redraw_context::plot, PLOT_OP_TYPE_SOLID, plotter_table::polygon, plotter_table::rectangle, scrollbar_rectangle(), SCROLLBAR_WIDTH, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by browser_window_redraw(), form_redraw_select_menu(), html_redraw_box(), and textarea_redraw().
bool scrollbar_scroll | ( | struct scrollbar * | s, |
int | change | ||
) |
Scroll the scrollbar by given amount.
s | the scrollbar to be scrolled |
change | the change in scroll offset required (in px) |
Definition at line 562 of file scrollbar.c.
References scrollbar::bar_pos, scrollbar::client_callback, scrollbar::client_data, scrollbar::full_size, scrollbar::length, scrollbar_msg_data::msg, scrollbar::offset, SCROLL_BOTTOM, SCROLL_PAGE_DOWN, SCROLL_PAGE_UP, SCROLL_TOP, SCROLLBAR_MSG_MOVED, SCROLLBAR_WIDTH, and scrollbar::visible_size.
Referenced by browser_window_scroll_at_point_internal(), html_scroll_at_point(), and textarea_scroll().
void scrollbar_set | ( | struct scrollbar * | s, |
int | value, | ||
bool | bar_pos | ||
) |
Set the scroll value of the scrollbar.
s | the scrollbar to have the value set |
value | the new value to be set |
bar_pos | true if the value is for the scrollbar indication bar position, false if it is for the scrolled area offset |
Definition at line 512 of file scrollbar.c.
References scrollbar::bar_len, scrollbar::bar_pos, scrollbar::client_callback, scrollbar::client_data, scrollbar::full_size, scrollbar::length, scrollbar_msg_data::msg, scrollbar::offset, SCROLLBAR_MSG_MOVED, SCROLLBAR_WIDTH, and scrollbar::visible_size.
Referenced by browser_window_set_scroll(), html_object_callback(), scrollbar_mouse_action(), scrollbar_mouse_drag_end(), and textarea_scroll_visible().
void scrollbar_set_extents | ( | struct scrollbar * | s, |
int | length, | ||
int | visible_size, | ||
int | full_size | ||
) |
Set the length of the scrollbar widget, the size of the visible area, and the size of the full area.
s | the scrollbar to set the values for |
length | -1 or the new scrollbar widget length |
visible_size | -1 or the new size of the visible area |
full_size | -1 or the new size of the full contained area |
Definition at line 640 of file scrollbar.c.
References scrollbar::bar_len, scrollbar::bar_pos, scrollbar::client_callback, scrollbar::client_data, scrollbar::full_size, scrollbar::length, scrollbar_msg_data::msg, scrollbar::offset, SCROLLBAR_MSG_MOVED, SCROLLBAR_WIDTH, and scrollbar::visible_size.
Referenced by box_handle_scrollbars(), browser_window_handle_scrollbars(), and textarea_reflow_multiline().
void scrollbar_start_content_drag | ( | struct scrollbar * | s, |
int | x, | ||
int | y | ||
) |
Called when the content is being dragged to the scrollbars have to adjust.
If the content has both scrollbars, and scrollbar_make_pair has beed called before, only the one scroll which will receive further mouse events has to be passed.
s | one of the the scrollbars owned by the dragged content |
x | X coordinate of mouse during drag start |
y | Y coordinate of mouse during drag start |
Definition at line 981 of file scrollbar.c.
References scrollbar_drag_start_internal().
Referenced by html_box_drag_start().