mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-21 22:11:22 +03:00
Change interface to system colours to allow reporting of errors
Allow system colour interface to report errors instead of silently failing and propogate the errors. This also fixes teh system colour documentation.
This commit is contained in:
parent
e72b89ac3d
commit
2f5e5620e2
@ -478,17 +478,27 @@ static bool browser_window_history__enumerate_entry(
|
||||
/* exported interface documented in desktop/browser_history.h */
|
||||
nserror browser_window_history_create(struct browser_window *bw)
|
||||
{
|
||||
nserror res;
|
||||
struct history *history;
|
||||
|
||||
pstyle_bg.fill_colour = ns_system_colour_char("Window");
|
||||
res = ns_system_colour_char("Window", &pstyle_bg.fill_colour);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
pfstyle_node.background = pstyle_bg.fill_colour;
|
||||
pfstyle_node_sel.background = pstyle_bg.fill_colour;
|
||||
|
||||
pstyle_line.stroke_colour = ns_system_colour_char("GrayText");
|
||||
res = ns_system_colour_char("GrayText", &pstyle_line.stroke_colour);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
pstyle_rect.stroke_colour = pstyle_line.stroke_colour;
|
||||
pfstyle_node.foreground = pstyle_line.stroke_colour;
|
||||
|
||||
pstyle_rect_sel.stroke_colour = ns_system_colour_char("Highlight");
|
||||
res = ns_system_colour_char("Highlight", &pstyle_rect_sel.stroke_colour);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
pfstyle_node_sel.foreground = pstyle_rect_sel.stroke_colour;
|
||||
|
||||
bw->history = NULL;
|
||||
|
@ -228,23 +228,31 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
|
||||
struct rect rect;
|
||||
nserror res;
|
||||
|
||||
colour bg_fill_colour = ns_system_colour_char("Scrollbar");
|
||||
colour fg_fill_colour = ns_system_colour_char("ButtonFace");
|
||||
colour arrow_fill_colour = ns_system_colour_char("ButtonText");
|
||||
|
||||
plot_style_t bg_fill_style = {
|
||||
.fill_type = PLOT_OP_TYPE_SOLID,
|
||||
.fill_colour = bg_fill_colour
|
||||
};
|
||||
plot_style_t fg_fill_style = {
|
||||
.fill_type = PLOT_OP_TYPE_SOLID,
|
||||
.fill_colour = fg_fill_colour
|
||||
};
|
||||
plot_style_t arrow_fill_style = {
|
||||
.fill_type = PLOT_OP_TYPE_SOLID,
|
||||
.fill_colour = arrow_fill_colour
|
||||
};
|
||||
|
||||
res = ns_system_colour_char("Scrollbar", &bg_fill_style.fill_colour);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = ns_system_colour_char("ButtonFace", &fg_fill_style.fill_colour);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = ns_system_colour_char("ButtonText", &arrow_fill_style.fill_colour);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
area.x0 = x;
|
||||
area.y0 = y;
|
||||
area.x1 = x + (s->horizontal ? s->length : SCROLLBAR_WIDTH) - 1;
|
||||
@ -277,7 +285,8 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
|
||||
/* scrollbar is horizontal */
|
||||
|
||||
/* scrollbar outline */
|
||||
res = scrollbar_rectangle(ctx, &area, bg_fill_colour, true);
|
||||
res = scrollbar_rectangle(ctx, &area,
|
||||
bg_fill_style.fill_colour, true);
|
||||
if (res != NSERROR_OK) {
|
||||
return false;
|
||||
}
|
||||
@ -287,7 +296,8 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
|
||||
rect.y0 = area.y0 + 1;
|
||||
rect.x1 = area.x0 + w - 2;
|
||||
rect.y1 = area.y1 - 1;
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
|
||||
res = scrollbar_rectangle(ctx, &rect,
|
||||
fg_fill_style.fill_colour, false);
|
||||
if (res != NSERROR_OK) {
|
||||
return false;
|
||||
}
|
||||
@ -329,7 +339,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
|
||||
rect.y0 = area.y0 + 1;
|
||||
rect.x1 = bar_c1;
|
||||
rect.y1 = area.y1 - 1;
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
|
||||
if (res != NSERROR_OK) {
|
||||
return false;
|
||||
}
|
||||
@ -348,7 +358,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
|
||||
rect.y0 = area.y0 + 1;
|
||||
rect.x1 = area.x1 - 1;
|
||||
rect.y1 = area.y1 - 1;
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
|
||||
if (res != NSERROR_OK) {
|
||||
return false;
|
||||
}
|
||||
@ -378,7 +388,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
|
||||
/* scrollbar is vertical */
|
||||
|
||||
/* outline */
|
||||
res = scrollbar_rectangle(ctx, &area, bg_fill_colour, true);
|
||||
res = scrollbar_rectangle(ctx, &area, bg_fill_style.fill_colour, true);
|
||||
if (res != NSERROR_OK) {
|
||||
return false;
|
||||
}
|
||||
@ -388,7 +398,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
|
||||
rect.y0 = area.y0 + 1;
|
||||
rect.x1 = area.x1 - 1;
|
||||
rect.y1 = area.y0 + w - 2;
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
|
||||
if (res != NSERROR_OK) {
|
||||
return false;
|
||||
}
|
||||
@ -430,7 +440,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
|
||||
rect.y0 = bar_c0;
|
||||
rect.x1 = area.x1 - 1;
|
||||
rect.y1 = bar_c1;
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
|
||||
if (res != NSERROR_OK) {
|
||||
return false;
|
||||
}
|
||||
@ -449,7 +459,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y,
|
||||
rect.y0 = area.y1 - w + 2;
|
||||
rect.x1 = area.x1 - 1;
|
||||
rect.y1 = area.y1 - 1;
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false);
|
||||
res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false);
|
||||
if (res != NSERROR_OK) {
|
||||
return false;
|
||||
}
|
||||
|
@ -16,9 +16,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* System colour handling
|
||||
*
|
||||
/**
|
||||
* \file
|
||||
* System colour handling implementation.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
@ -38,6 +38,7 @@ static lwc_string *colour_list[colour_list_len];
|
||||
static lwc_string **ns_system_colour_pw = NULL;
|
||||
|
||||
|
||||
/* exported interface documented in desktop/system_colour.h */
|
||||
nserror ns_system_colour_init(void)
|
||||
{
|
||||
unsigned int ccount;
|
||||
@ -61,6 +62,8 @@ nserror ns_system_colour_init(void)
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/* exported interface documented in desktop/system_colour.h */
|
||||
void ns_system_colour_finalize(void)
|
||||
{
|
||||
unsigned int ccount;
|
||||
@ -70,21 +73,25 @@ void ns_system_colour_finalize(void)
|
||||
}
|
||||
}
|
||||
|
||||
colour ns_system_colour_char(const char *name)
|
||||
|
||||
/* exported interface documented in desktop/system_colour.h */
|
||||
nserror ns_system_colour_char(const char *name, colour *colour_out)
|
||||
{
|
||||
colour ret = 0;
|
||||
unsigned int ccount;
|
||||
|
||||
for (ccount = 0; ccount < colour_list_len; ccount++) {
|
||||
if (strcmp(name,
|
||||
nsoptions[ccount + NSOPTION_SYS_COLOUR_START].key + SLEN("sys_colour_")) == 0) {
|
||||
ret = nsoptions[ccount + NSOPTION_SYS_COLOUR_START].value.c;
|
||||
break;
|
||||
*colour_out = nsoptions[ccount + NSOPTION_SYS_COLOUR_START].value.c;
|
||||
return NSERROR_OK;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
return NSERROR_INVALID;
|
||||
}
|
||||
|
||||
|
||||
/* exported interface documented in desktop/system_colour.h */
|
||||
css_error ns_system_colour(void *pw, lwc_string *name, css_color *colour)
|
||||
{
|
||||
unsigned int ccount;
|
||||
|
@ -16,25 +16,59 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
/**
|
||||
* \file
|
||||
* Interface to system colour values.
|
||||
*
|
||||
* Netsurf has a list of user configurable colours with frontend
|
||||
* specific defaults. These colours are used for the css system
|
||||
* colours and to colour and style internally rendered widgets
|
||||
* (e.g. cookies treeview or local file directory views.
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_DESKTOP_SYSTEM_COLOUR_H_
|
||||
#define _NETSURF_DESKTOP_SYSTEM_COLOUR_H_
|
||||
#ifndef NETSURF_DESKTOP_SYSTEM_COLOUR_H
|
||||
#define NETSURF_DESKTOP_SYSTEM_COLOUR_H
|
||||
|
||||
#include <libcss/libcss.h>
|
||||
|
||||
#include "utils/errors.h"
|
||||
#include "netsurf/types.h"
|
||||
|
||||
/** css callback to obtain named system colours. */
|
||||
/**
|
||||
* css callback to obtain named system colour.
|
||||
*
|
||||
* \param[in] pw context unused in implementation
|
||||
* \param[in] name The name of the colour being looked up
|
||||
* \param[out] color The system colour associated with the name.
|
||||
* \return CSS_OK and \a color updated on success else CSS_INVALID if
|
||||
* the \a name is unrecognised
|
||||
*/
|
||||
css_error ns_system_colour(void *pw, lwc_string *name, css_color *color);
|
||||
|
||||
/** Obtain a named system colour from a frontend. */
|
||||
colour ns_system_colour_char(const char *name);
|
||||
|
||||
/**
|
||||
* Obtain a system colour from a name.
|
||||
*
|
||||
* \param[in] name The name of the colour being looked up
|
||||
* \param[out] color The system colour associated with the name in the
|
||||
* netsurf colour representation.
|
||||
* \return NSERROR_OK and \a color updated on success else appropriate
|
||||
* error code.
|
||||
*/
|
||||
nserror ns_system_colour_char(const char *name, colour *color);
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the system colours
|
||||
*
|
||||
* \return NSERROR_OK on success else appropriate error code.
|
||||
*/
|
||||
nserror ns_system_colour_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* release any resources associated with the system colours.
|
||||
*/
|
||||
void ns_system_colour_finalize(void);
|
||||
|
||||
#endif
|
||||
|
@ -17,12 +17,13 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Single/Multi-line UTF-8 text area (interface)
|
||||
/**
|
||||
* \file
|
||||
* Single/Multi-line UTF-8 text area interface
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_DESKTOP_TEXTAREA_H_
|
||||
#define _NETSURF_DESKTOP_TEXTAREA_H_
|
||||
#ifndef NETSURF_DESKTOP_TEXTAREA_H
|
||||
#define NETSURF_DESKTOP_TEXTAREA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
@ -33,21 +34,31 @@
|
||||
struct textarea;
|
||||
struct redraw_context;
|
||||
|
||||
/* Text area flags */
|
||||
/**
|
||||
* Text area flags
|
||||
*/
|
||||
typedef enum {
|
||||
TEXTAREA_DEFAULT = (1 << 0), /**< Standard input */
|
||||
TEXTAREA_MULTILINE = (1 << 1), /**< Multiline area */
|
||||
TEXTAREA_READONLY = (1 << 2), /**< Non-editable */
|
||||
TEXTAREA_INTERNAL_CARET = (1 << 3), /**< Render own caret */
|
||||
TEXTAREA_PASSWORD = (1 << 4) /**< Obscured display */
|
||||
TEXTAREA_DEFAULT = (1 << 0), /**< Standard input */
|
||||
TEXTAREA_MULTILINE = (1 << 1), /**< Multiline area */
|
||||
TEXTAREA_READONLY = (1 << 2), /**< Non-editable */
|
||||
TEXTAREA_INTERNAL_CARET = (1 << 3), /**< Render own caret */
|
||||
TEXTAREA_PASSWORD = (1 << 4) /**< Obscured display */
|
||||
} textarea_flags;
|
||||
|
||||
|
||||
/**
|
||||
* Textarea drag status
|
||||
*/
|
||||
typedef enum {
|
||||
TEXTAREA_DRAG_NONE,
|
||||
TEXTAREA_DRAG_SCROLLBAR,
|
||||
TEXTAREA_DRAG_SELECTION
|
||||
} textarea_drag_type; /**< Textarea drag status */
|
||||
} textarea_drag_type;
|
||||
|
||||
|
||||
/**
|
||||
* textarea message types
|
||||
*/
|
||||
typedef enum {
|
||||
TEXTAREA_MSG_DRAG_REPORT, /**< Textarea drag start/end report */
|
||||
TEXTAREA_MSG_SELECTION_REPORT, /**< Textarea text selection presence */
|
||||
@ -56,6 +67,10 @@ typedef enum {
|
||||
TEXTAREA_MSG_TEXT_MODIFIED /**< Textarea text modified */
|
||||
} textarea_msg_type;
|
||||
|
||||
|
||||
/**
|
||||
* textarea message
|
||||
*/
|
||||
struct textarea_msg {
|
||||
struct textarea *ta; /**< The textarea widget */
|
||||
|
||||
@ -73,10 +88,10 @@ struct textarea_msg {
|
||||
TEXTAREA_CARET_HIDE /**< Hide */
|
||||
} type;
|
||||
struct {
|
||||
int x; /**< Carret x-coord */
|
||||
int y; /**< Carret y-coord */
|
||||
int height; /**< Carret height */
|
||||
struct rect *clip; /**< Carret clip rect */
|
||||
int x; /**< Caret x-coord */
|
||||
int y; /**< Caret y-coord */
|
||||
int height; /**< Caret height */
|
||||
struct rect *clip; /**< Caret clip rect */
|
||||
} pos; /**< With _CARET_SET_POS */
|
||||
} caret; /**< With _CARET_UPDATE */
|
||||
struct {
|
||||
@ -86,6 +101,10 @@ struct textarea_msg {
|
||||
} data; /**< Depends on msg type */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* textarea setup parameters
|
||||
*/
|
||||
typedef struct textarea_setup {
|
||||
int width; /**< Textarea width */
|
||||
int height; /**< Textarea height */
|
||||
@ -104,99 +123,10 @@ typedef struct textarea_setup {
|
||||
|
||||
} textarea_setup;
|
||||
|
||||
/**
|
||||
* Client callback for the textarea
|
||||
*
|
||||
* \param data user data passed at textarea creation
|
||||
* \param textarea_msg textarea message data
|
||||
*/
|
||||
typedef void(*textarea_client_callback)(void *data, struct textarea_msg *msg);
|
||||
|
||||
/**
|
||||
* Create a text area.
|
||||
*
|
||||
* \param flags flags controlling the text area creation
|
||||
* \param setup textarea settings and style
|
||||
* \param callback will be called when textarea wants to redraw
|
||||
* \param data user specified data which will be passed to callbacks
|
||||
* \return Opaque handle for textarea or 0 on error
|
||||
* Text area mouse input status flags
|
||||
*/
|
||||
struct textarea *textarea_create(const textarea_flags flags,
|
||||
const textarea_setup *setup,
|
||||
textarea_client_callback callback, void *data);
|
||||
|
||||
/**
|
||||
* Destroy a text area
|
||||
*
|
||||
* \param ta Text area to destroy
|
||||
*/
|
||||
void textarea_destroy(struct textarea *ta);
|
||||
|
||||
/**
|
||||
* Set the text in a text area, discarding any current text
|
||||
*
|
||||
* \param ta Text area
|
||||
* \param text UTF-8 text to set text area's contents to
|
||||
* \return true on success, false on memory exhaustion
|
||||
*/
|
||||
bool textarea_set_text(struct textarea *ta, const char *text);
|
||||
|
||||
/**
|
||||
* Insert the text in a text area at the caret, replacing any selection.
|
||||
*
|
||||
* \param ta Text area
|
||||
* \param text UTF-8 text to set text area's contents to
|
||||
* \param text_length length of text.
|
||||
* \return true on success, false on memory exhaustion or if ta lacks caret
|
||||
*/
|
||||
bool textarea_drop_text(struct textarea *ta, const char *text,
|
||||
size_t text_length);
|
||||
|
||||
/**
|
||||
* Extract the text from a text area
|
||||
*
|
||||
* \param ta Text area
|
||||
* \param buf Pointer to buffer to receive data, or NULL
|
||||
* to read length required (includes trailing '\0')
|
||||
* \param len Length (bytes) of buffer pointed to by buf, or 0 to read length
|
||||
* \return Length (bytes) written/required or -1 on error
|
||||
*/
|
||||
int textarea_get_text(struct textarea *ta, char *buf, unsigned int len);
|
||||
|
||||
/**
|
||||
* Set the caret's position
|
||||
*
|
||||
* \param ta Text area
|
||||
* \param caret 0-based character index to place caret at, -1 removes
|
||||
* the caret
|
||||
* \return true on success false otherwise
|
||||
*/
|
||||
bool textarea_set_caret(struct textarea *ta, int caret);
|
||||
|
||||
/**
|
||||
* Handle redraw requests for text areas
|
||||
*
|
||||
* \param ta textarea to render
|
||||
* \param x x coordinate of textarea top
|
||||
* \param y y coordinate of textarea left
|
||||
* \param bg background colour under textarea
|
||||
* \param scale scale to render at
|
||||
* \param clip clip rectangle
|
||||
* \param ctx current redraw context
|
||||
*/
|
||||
void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
|
||||
const struct rect *clip, const struct redraw_context *ctx);
|
||||
|
||||
/**
|
||||
* Key press handling for text areas.
|
||||
*
|
||||
* \param ta The text area which got the keypress
|
||||
* \param key The ucs4 character codepoint
|
||||
* \return true if the keypress is dealt with, false otherwise.
|
||||
*/
|
||||
bool textarea_keypress(struct textarea *ta, uint32_t key);
|
||||
|
||||
/* Text area mouse input status flags */
|
||||
typedef enum {
|
||||
TEXTAREA_MOUSE_NONE = 0, /**< Not relevant */
|
||||
TEXTAREA_MOUSE_USED = (1 << 0), /**< Took action with input */
|
||||
@ -216,6 +146,108 @@ typedef enum {
|
||||
TEXTAREA_MOUSE_SCR_RGT = (1 << 14) /**< Hover: scroll right */
|
||||
} textarea_mouse_status;
|
||||
|
||||
|
||||
/**
|
||||
* Client callback for the textarea
|
||||
*
|
||||
* \param data user data passed at textarea creation
|
||||
* \param msg textarea message data
|
||||
*/
|
||||
typedef void(*textarea_client_callback)(void *data, struct textarea_msg *msg);
|
||||
|
||||
|
||||
/**
|
||||
* Create a text area.
|
||||
*
|
||||
* \param flags flags controlling the text area creation
|
||||
* \param setup textarea settings and style
|
||||
* \param callback will be called when textarea wants to redraw
|
||||
* \param data user specified data which will be passed to callbacks
|
||||
* \return Opaque handle for textarea or 0 on error
|
||||
*/
|
||||
struct textarea *textarea_create(const textarea_flags flags,
|
||||
const textarea_setup *setup,
|
||||
textarea_client_callback callback, void *data);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy a text area
|
||||
*
|
||||
* \param ta Text area to destroy
|
||||
*/
|
||||
void textarea_destroy(struct textarea *ta);
|
||||
|
||||
|
||||
/**
|
||||
* Set the text in a text area, discarding any current text
|
||||
*
|
||||
* \param ta Text area
|
||||
* \param text UTF-8 text to set text area's contents to
|
||||
* \return true on success, false on memory exhaustion
|
||||
*/
|
||||
bool textarea_set_text(struct textarea *ta, const char *text);
|
||||
|
||||
|
||||
/**
|
||||
* Insert the text in a text area at the caret, replacing any selection.
|
||||
*
|
||||
* \param ta Text area
|
||||
* \param text UTF-8 text to set text area's contents to
|
||||
* \param text_length length of text.
|
||||
* \return true on success, false on memory exhaustion or if ta lacks caret
|
||||
*/
|
||||
bool textarea_drop_text(struct textarea *ta, const char *text,
|
||||
size_t text_length);
|
||||
|
||||
|
||||
/**
|
||||
* Extract the text from a text area
|
||||
*
|
||||
* \param ta Text area
|
||||
* \param buf Pointer to buffer to receive data, or NULL
|
||||
* to read length required (includes trailing '\0')
|
||||
* \param len Length (bytes) of buffer pointed to by buf, or 0 to read length
|
||||
* \return Length (bytes) written/required or -1 on error
|
||||
*/
|
||||
int textarea_get_text(struct textarea *ta, char *buf, unsigned int len);
|
||||
|
||||
|
||||
/**
|
||||
* Set the caret's position
|
||||
*
|
||||
* \param ta Text area
|
||||
* \param caret 0-based character index to place caret at, -1 removes
|
||||
* the caret
|
||||
* \return true on success false otherwise
|
||||
*/
|
||||
bool textarea_set_caret(struct textarea *ta, int caret);
|
||||
|
||||
|
||||
/**
|
||||
* Handle redraw requests for text areas
|
||||
*
|
||||
* \param ta textarea to render
|
||||
* \param x x coordinate of textarea top
|
||||
* \param y y coordinate of textarea left
|
||||
* \param bg background colour under textarea
|
||||
* \param scale scale to render at
|
||||
* \param clip clip rectangle
|
||||
* \param ctx current redraw context
|
||||
*/
|
||||
void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale,
|
||||
const struct rect *clip, const struct redraw_context *ctx);
|
||||
|
||||
|
||||
/**
|
||||
* Key press handling for text areas.
|
||||
*
|
||||
* \param ta The text area which got the keypress
|
||||
* \param key The ucs4 character codepoint
|
||||
* \return true if the keypress is dealt with, false otherwise.
|
||||
*/
|
||||
bool textarea_keypress(struct textarea *ta, uint32_t key);
|
||||
|
||||
|
||||
/**
|
||||
* Handles all kinds of mouse action
|
||||
*
|
||||
@ -228,22 +260,28 @@ typedef enum {
|
||||
textarea_mouse_status textarea_mouse_action(struct textarea *ta,
|
||||
browser_mouse_state mouse, int x, int y);
|
||||
|
||||
|
||||
/**
|
||||
* Clear any selection in the textarea.
|
||||
*
|
||||
* \param ta textarea widget
|
||||
* \param ta textarea widget
|
||||
* \return true if there was a selection to clear, false otherwise
|
||||
*/
|
||||
bool textarea_clear_selection(struct textarea *ta);
|
||||
|
||||
|
||||
/**
|
||||
* Get selected text, ownership passed to caller, which needs to free() it.
|
||||
* Get selected text.
|
||||
*
|
||||
* \param ta Textarea widget
|
||||
* ownership of the returned string is passed to caller which needs to
|
||||
* free it.
|
||||
*
|
||||
* \param ta Textarea widget
|
||||
* \return Selected text, or NULL if none.
|
||||
*/
|
||||
char *textarea_get_selection(struct textarea *ta);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the dimensions of a textarea
|
||||
*
|
||||
@ -253,22 +291,28 @@ char *textarea_get_selection(struct textarea *ta);
|
||||
*/
|
||||
void textarea_get_dimensions(struct textarea *ta, int *width, int *height);
|
||||
|
||||
|
||||
/**
|
||||
* Set the dimensions of a textarea, causing a reflow and
|
||||
* Does not emit a redraw request. Up to client to call textarea_redraw.
|
||||
* Set the dimensions of a textarea.
|
||||
*
|
||||
* This causes a reflow of the text and does not emit a redraw
|
||||
* request. Up to client to call textarea_redraw.
|
||||
*
|
||||
* \param ta textarea widget
|
||||
* \param width the new width of the textarea
|
||||
* \param width the new width of the textarea
|
||||
* \param height the new height of the textarea
|
||||
*/
|
||||
void textarea_set_dimensions(struct textarea *ta, int width, int height);
|
||||
|
||||
|
||||
/**
|
||||
* Set the dimensions and padding of a textarea, causing a reflow.
|
||||
* Does not emit a redraw request. Up to client to call textarea_redraw.
|
||||
* Set the dimensions and padding of a textarea.
|
||||
*
|
||||
* This causes a reflow of the text. Does not emit a redraw request.
|
||||
* Up to client to call textarea_redraw.
|
||||
*
|
||||
* \param ta textarea widget
|
||||
* \param width the new width of the textarea
|
||||
* \param width the new width of the textarea
|
||||
* \param height the new height of the textarea
|
||||
* \param top the new top padding of the textarea
|
||||
* \param right the new right padding of the textarea
|
||||
@ -278,9 +322,12 @@ void textarea_set_dimensions(struct textarea *ta, int width, int height);
|
||||
void textarea_set_layout(struct textarea *ta, int width, int height,
|
||||
int top, int right, int bottom, int left);
|
||||
|
||||
|
||||
/**
|
||||
* Scroll a textarea by an amount. Only does anything if multi-line textarea
|
||||
* has scrollbars. If it scrolls, it will emit a redraw request.
|
||||
* Scroll a textarea by an amount.
|
||||
*
|
||||
* Only does anything if multi-line textarea has scrollbars. If it
|
||||
* scrolls, it will emit a redraw request.
|
||||
*
|
||||
* \param ta textarea widget
|
||||
* \param scrx number of px try to scroll in x direction
|
||||
@ -288,5 +335,5 @@ void textarea_set_layout(struct textarea *ta, int width, int height,
|
||||
* \return true iff the textarea was scrolled
|
||||
*/
|
||||
bool textarea_scroll(struct textarea *ta, int scrx, int scry);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -24,19 +24,19 @@
|
||||
* Textual input handling interface
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_DESKTOP_TEXTINPUT_H_
|
||||
#define _NETSURF_DESKTOP_TEXTINPUT_H_
|
||||
#ifndef NETSURF_DESKTOP_TEXTINPUT_H
|
||||
#define NETSURF_DESKTOP_TEXTINPUT_H
|
||||
|
||||
struct browser_window;
|
||||
|
||||
/**
|
||||
* Position the caret and assign a callback for key presses.
|
||||
*
|
||||
* \param bw The browser window in which to place the caret
|
||||
* \param x X coordinate of the caret
|
||||
* \param y Y coordinate
|
||||
* \param height Height of caret
|
||||
* \param clip Clip rectangle for caret, or NULL if none
|
||||
* \param bw The browser window in which to place the caret
|
||||
* \param x X coordinate of the caret
|
||||
* \param y Y coordinate
|
||||
* \param height Height of caret
|
||||
* \param clip Clip rectangle for caret, or NULL if none
|
||||
*/
|
||||
void browser_window_place_caret(struct browser_window *bw, int x, int y,
|
||||
int height, const struct rect *clip);
|
||||
|
@ -1858,7 +1858,7 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
|
||||
|
||||
res = treeview_node_contract_internal(tree, node);
|
||||
if (res == NSERROR_OK) {
|
||||
/* sucessful contraction, request redraw */
|
||||
/* successful contraction, request redraw */
|
||||
r.x0 = 0;
|
||||
r.y0 = treeview_node_y(tree, node);
|
||||
r.x1 = REDRAW_MAX;
|
||||
@ -1933,7 +1933,7 @@ struct treeview_expand_data {
|
||||
* \param ctx node expansion context
|
||||
* \param skip_children flag to allow children to be skipped
|
||||
* \param end flag to allow iteration to be finished early.
|
||||
* \return NSERROR_OK on sucess else error code.
|
||||
* \return NSERROR_OK on success else error code.
|
||||
*/
|
||||
static nserror
|
||||
treeview_expand_cb(treeview_node *n,
|
||||
@ -1978,7 +1978,7 @@ nserror treeview_expand(treeview *tree, bool only_folders)
|
||||
treeview_expand_cb,
|
||||
&data);
|
||||
if (res == NSERROR_OK) {
|
||||
/* expansion suceeded, schedule redraw */
|
||||
/* expansion succeeded, schedule redraw */
|
||||
|
||||
r.x0 = 0;
|
||||
r.y0 = 0;
|
||||
@ -2212,7 +2212,7 @@ treeview_redraw(treeview *tree,
|
||||
render_y += tree_g.line_height;
|
||||
}
|
||||
|
||||
/* Finshed rendering expanded entry */
|
||||
/* Finished rendering expanded entry */
|
||||
|
||||
if (render_y > r.y1) {
|
||||
/* Passed the bottom of what's in the clip region.
|
||||
@ -2303,7 +2303,7 @@ struct treeview_selection_walk_data {
|
||||
* \param ctx node selection context
|
||||
* \param skip_children flag to allow children to be skipped
|
||||
* \param end flag to allow iteration to be finished early.
|
||||
* \return NSERROR_OK on sucess else error code.
|
||||
* \return NSERROR_OK on success else error code.
|
||||
*/
|
||||
static nserror
|
||||
treeview_node_selection_walk_cb(treeview_node *n,
|
||||
@ -2718,7 +2718,7 @@ static bool treeview_propagate_selection(treeview *tree, struct rect *rect)
|
||||
*
|
||||
* \param tree Treeview object to move selected nodes in
|
||||
* \param rect Redraw rectangle
|
||||
* \return NSERROR_OK on sucess else appropriate error code
|
||||
* \return NSERROR_OK on success else appropriate error code
|
||||
*/
|
||||
static nserror treeview_move_selection(treeview *tree, struct rect *rect)
|
||||
{
|
||||
@ -2850,7 +2850,7 @@ treeview_node_launch_walk_bwd_cb(treeview_node *n, void *ctx, bool *end)
|
||||
* \param ctx node launch context
|
||||
* \param skip_children flag to allow children to be skipped
|
||||
* \param end flag to allow iteration to be finished early.
|
||||
* \return NSERROR_OK on sucess else error code.
|
||||
* \return NSERROR_OK on success else error code.
|
||||
*/
|
||||
static nserror
|
||||
treeview_node_launch_walk_fwd_cb(treeview_node *n,
|
||||
@ -2967,11 +2967,11 @@ struct treeview_nav_state {
|
||||
/**
|
||||
* Treewalk node callback for handling mouse action.
|
||||
*
|
||||
* \param n current node
|
||||
* \param node current node
|
||||
* \param ctx node context
|
||||
* \param skip_children flag to allow children to be skipped
|
||||
* \param end flag to allow iteration to be finished early.
|
||||
* \return NSERROR_OK on sucess else error code.
|
||||
* \return NSERROR_OK on success else error code.
|
||||
*/
|
||||
static nserror
|
||||
treeview_node_nav_cb(treeview_node *node,
|
||||
@ -3227,7 +3227,7 @@ treeview_set_move_indicator(treeview *tree,
|
||||
target = target->parent;
|
||||
}
|
||||
|
||||
/* Find top ajdacent selected sibling */
|
||||
/* Find top adjacent selected sibling */
|
||||
while (target->prev_sib &&
|
||||
target->prev_sib->flags & TV_NFLAGS_SELECTED) {
|
||||
target = target->prev_sib;
|
||||
@ -3555,11 +3555,11 @@ struct treeview_mouse_action {
|
||||
/**
|
||||
* Treewalk node callback for handling mouse action.
|
||||
*
|
||||
* \param n current node
|
||||
* \param node current node
|
||||
* \param ctx node context
|
||||
* \param skip_children flag to allow children to be skipped
|
||||
* \param end flag to allow iteration to be finished early.
|
||||
* \return NSERROR_OK on sucess else error code.
|
||||
* \return NSERROR_OK on success else error code.
|
||||
*/
|
||||
static nserror
|
||||
treeview_node_mouse_action_cb(treeview_node *node,
|
||||
@ -3988,46 +3988,67 @@ int treeview_get_height(treeview *tree)
|
||||
* Initialise the plot styles from CSS system colour values.
|
||||
*
|
||||
* \param font_pt_size font size to use
|
||||
* \return NSERROR_OK on success else appropriate error code
|
||||
*/
|
||||
static void treeview_init_plot_styles(int font_pt_size)
|
||||
static nserror treeview_init_plot_styles(int font_pt_size)
|
||||
{
|
||||
nserror res;
|
||||
|
||||
/* Background colour */
|
||||
plot_style_even.bg.stroke_type = PLOT_OP_TYPE_NONE;
|
||||
plot_style_even.bg.stroke_width = 0;
|
||||
plot_style_even.bg.stroke_colour = 0;
|
||||
plot_style_even.bg.fill_type = PLOT_OP_TYPE_SOLID;
|
||||
plot_style_even.bg.fill_colour = ns_system_colour_char("Window");
|
||||
res = ns_system_colour_char("Window", &plot_style_even.bg.fill_colour);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Text colour */
|
||||
plot_style_even.text.family = PLOT_FONT_FAMILY_SANS_SERIF;
|
||||
plot_style_even.text.size = font_pt_size;
|
||||
plot_style_even.text.weight = 400;
|
||||
plot_style_even.text.flags = FONTF_NONE;
|
||||
plot_style_even.text.foreground = ns_system_colour_char("WindowText");
|
||||
plot_style_even.text.background = ns_system_colour_char("Window");
|
||||
res = ns_system_colour_char("WindowText", &plot_style_even.text.foreground);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
res = ns_system_colour_char("Window", &plot_style_even.text.background);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Entry field text colour */
|
||||
plot_style_even.itext = plot_style_even.text;
|
||||
plot_style_even.itext.foreground = mix_colour(
|
||||
plot_style_even.text.foreground,
|
||||
plot_style_even.text.background, 255 * 10 / 16);
|
||||
plot_style_even.text.background,
|
||||
255 * 10 / 16);
|
||||
|
||||
/* Selected background colour */
|
||||
plot_style_even.sbg = plot_style_even.bg;
|
||||
plot_style_even.sbg.fill_colour = ns_system_colour_char("Highlight");
|
||||
res = ns_system_colour_char("Highlight", &plot_style_even.sbg.fill_colour);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Selected text colour */
|
||||
plot_style_even.stext = plot_style_even.text;
|
||||
plot_style_even.stext.foreground =
|
||||
ns_system_colour_char("HighlightText");
|
||||
plot_style_even.stext.background = ns_system_colour_char("Highlight");
|
||||
res = ns_system_colour_char("HighlightText", &plot_style_even.stext.foreground);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
res = ns_system_colour_char("Highlight", &plot_style_even.stext.background);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Selected entry field text colour */
|
||||
plot_style_even.sitext = plot_style_even.stext;
|
||||
plot_style_even.sitext.foreground = mix_colour(
|
||||
plot_style_even.stext.foreground,
|
||||
plot_style_even.stext.background, 255 * 25 / 32);
|
||||
|
||||
plot_style_even.stext.background,
|
||||
255 * 25 / 32);
|
||||
|
||||
/* Odd numbered node styles */
|
||||
plot_style_odd.bg = plot_style_even.bg;
|
||||
@ -4044,14 +4065,16 @@ static void treeview_init_plot_styles(int font_pt_size)
|
||||
plot_style_odd.sbg = plot_style_even.sbg;
|
||||
plot_style_odd.stext = plot_style_even.stext;
|
||||
plot_style_odd.sitext = plot_style_even.sitext;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback for hlcache retreving resources.
|
||||
* Callback for hlcache retrieving resources.
|
||||
*
|
||||
* \param handle content hlcache handle
|
||||
* \param event The event that occoured on the content
|
||||
* \param event The event that occurred on the content
|
||||
* \param pw treeview resource context
|
||||
*/
|
||||
static nserror
|
||||
@ -4373,7 +4396,7 @@ nserror treeview_init(void)
|
||||
{
|
||||
long long font_px_size;
|
||||
long long font_pt_size;
|
||||
nserror err;
|
||||
nserror res;
|
||||
|
||||
if (tree_g.initialised > 0) {
|
||||
tree_g.initialised++;
|
||||
@ -4391,11 +4414,17 @@ nserror treeview_init(void)
|
||||
10 + 36) / 72;
|
||||
tree_g.line_height = (font_px_size * 8 + 3) / 6;
|
||||
|
||||
treeview_init_plot_styles(font_pt_size * FONT_SIZE_SCALE / 10);
|
||||
res = treeview_init_plot_styles(font_pt_size * FONT_SIZE_SCALE / 10);
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
treeview_init_resources();
|
||||
err = treeview_init_furniture();
|
||||
if (err != NSERROR_OK)
|
||||
return err;
|
||||
|
||||
res = treeview_init_furniture();
|
||||
if (res != NSERROR_OK) {
|
||||
return res;
|
||||
}
|
||||
|
||||
tree_g.step_width = tree_g.furniture_width;
|
||||
tree_g.window_padding = 6;
|
||||
|
@ -228,7 +228,7 @@ nserror treeview_destroy(treeview *tree);
|
||||
|
||||
|
||||
/**
|
||||
* Find a releation for node creation.
|
||||
* Find a relation for node creation.
|
||||
*
|
||||
* If at_y is set, we find a relation that will put the created node at that
|
||||
* position.
|
||||
@ -239,7 +239,7 @@ nserror treeview_destroy(treeview *tree);
|
||||
* \param tree Treeview object in which to create folder
|
||||
* \param relation Existing node to insert as relation of, or NULL
|
||||
* \param rel Folder's relationship to relation
|
||||
* \param at_y Iff true, insert at y-offest
|
||||
* \param at_y Iff true, insert at y-offset
|
||||
* \param y Y-offset in px from top of hotlist. Ignored if (!at_y).
|
||||
* \return NSERROR_OK on success, appropriate error otherwise
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user