summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser_history.c16
-rw-r--r--desktop/scrollbar.c40
-rw-r--r--desktop/system_colour.c23
-rw-r--r--desktop/system_colour.h46
-rw-r--r--desktop/textarea.h153
-rw-r--r--desktop/textinput.h14
-rw-r--r--desktop/treeview.c89
-rw-r--r--desktop/treeview.h4
8 files changed, 261 insertions, 124 deletions
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 10154b780..cf70c4700 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -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;
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 4f3043416..04326965c 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -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;
}
diff --git a/desktop/system_colour.c b/desktop/system_colour.c
index f33b57a37..42a51eaea 100644
--- a/desktop/system_colour.c
+++ b/desktop/system_colour.c
@@ -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;
diff --git a/desktop/system_colour.h b/desktop/system_colour.h
index 8e82818aa..0b7553003 100644
--- a/desktop/system_colour.h
+++ b/desktop/system_colour.h
@@ -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
diff --git a/desktop/textarea.h b/desktop/textarea.h
index 65e2594c7..898609730 100644
--- a/desktop/textarea.h
+++ b/desktop/textarea.h
@@ -1,6 +1,6 @@
/*
* Copyright 2006 John-Mark Bell <jmb@netsurf-browser.org>
- * Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
+ * Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -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,14 +123,39 @@ typedef struct textarea_setup {
} textarea_setup;
+
+/**
+ * Text area mouse input status flags
+ */
+typedef enum {
+ TEXTAREA_MOUSE_NONE = 0, /**< Not relevant */
+ TEXTAREA_MOUSE_USED = (1 << 0), /**< Took action with input */
+ TEXTAREA_MOUSE_EDITOR = (1 << 1), /**< Hover: caret pointer */
+ TEXTAREA_MOUSE_SELECTION= (1 << 2), /**< Hover: selection */
+ TEXTAREA_MOUSE_SCR_USED = (1 << 3), /**< Scrollbar action */
+ TEXTAREA_MOUSE_SCR_BOTH = (1 << 4), /**< Scrolling both bars */
+ TEXTAREA_MOUSE_SCR_UP = (1 << 5), /**< Hover: scroll up */
+ TEXTAREA_MOUSE_SCR_PUP = (1 << 6), /**< Hover: scroll page up */
+ TEXTAREA_MOUSE_SCR_VRT = (1 << 7), /**< Hover: vert. drag bar */
+ TEXTAREA_MOUSE_SCR_PDWN = (1 << 8), /**< Hover: scroll page down */
+ TEXTAREA_MOUSE_SCR_DWN = (1 << 9), /**< Hover: scroll down */
+ TEXTAREA_MOUSE_SCR_LFT = (1 << 10), /**< Hover: scroll left */
+ TEXTAREA_MOUSE_SCR_PLFT = (1 << 11), /**< Hover: scroll page left */
+ TEXTAREA_MOUSE_SCR_HRZ = (1 << 12), /**< Hover: horiz. drag bar */
+ TEXTAREA_MOUSE_SCR_PRGT = (1 << 13), /**< Hover: scroll page right */
+ 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 textarea_msg textarea message data
+ * \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.
*
@@ -125,6 +169,7 @@ struct textarea *textarea_create(const textarea_flags flags,
const textarea_setup *setup,
textarea_client_callback callback, void *data);
+
/**
* Destroy a text area
*
@@ -132,6 +177,7 @@ struct textarea *textarea_create(const textarea_flags flags,
*/
void textarea_destroy(struct textarea *ta);
+
/**
* Set the text in a text area, discarding any current text
*
@@ -141,6 +187,7 @@ void textarea_destroy(struct textarea *ta);
*/
bool textarea_set_text(struct textarea *ta, const char *text);
+
/**
* Insert the text in a text area at the caret, replacing any selection.
*
@@ -152,6 +199,7 @@ bool textarea_set_text(struct textarea *ta, const char *text);
bool textarea_drop_text(struct textarea *ta, const char *text,
size_t text_length);
+
/**
* Extract the text from a text area
*
@@ -163,16 +211,18 @@ bool textarea_drop_text(struct textarea *ta, const char *text,
*/
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
+ * \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
*
@@ -187,34 +237,16 @@ bool textarea_set_caret(struct textarea *ta, int caret);
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.
+ * \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 */
- TEXTAREA_MOUSE_EDITOR = (1 << 1), /**< Hover: caret pointer */
- TEXTAREA_MOUSE_SELECTION= (1 << 2), /**< Hover: selection */
- TEXTAREA_MOUSE_SCR_USED = (1 << 3), /**< Scrollbar action */
- TEXTAREA_MOUSE_SCR_BOTH = (1 << 4), /**< Scrolling both bars */
- TEXTAREA_MOUSE_SCR_UP = (1 << 5), /**< Hover: scroll up */
- TEXTAREA_MOUSE_SCR_PUP = (1 << 6), /**< Hover: scroll page up */
- TEXTAREA_MOUSE_SCR_VRT = (1 << 7), /**< Hover: vert. drag bar */
- TEXTAREA_MOUSE_SCR_PDWN = (1 << 8), /**< Hover: scroll page down */
- TEXTAREA_MOUSE_SCR_DWN = (1 << 9), /**< Hover: scroll down */
- TEXTAREA_MOUSE_SCR_LFT = (1 << 10), /**< Hover: scroll left */
- TEXTAREA_MOUSE_SCR_PLFT = (1 << 11), /**< Hover: scroll page left */
- TEXTAREA_MOUSE_SCR_HRZ = (1 << 12), /**< Hover: horiz. drag bar */
- TEXTAREA_MOUSE_SCR_PRGT = (1 << 13), /**< Hover: scroll page right */
- TEXTAREA_MOUSE_SCR_RGT = (1 << 14) /**< Hover: scroll right */
-} textarea_mouse_status;
/**
* 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.
+ *
+ * ownership of the returned string is passed to caller which needs to
+ * free it.
*
- * \param ta Textarea widget
+ * \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
diff --git a/desktop/textinput.h b/desktop/textinput.h
index 5859ea8d6..7c6be9547 100644
--- a/desktop/textinput.h
+++ b/desktop/textinput.h
@@ -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);
diff --git a/desktop/treeview.c b/desktop/treeview.c
index c0d685e97..ff13fb0cb 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -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;
diff --git a/desktop/treeview.h b/desktop/treeview.h
index 0dbde1119..45469b77f 100644
--- a/desktop/treeview.h
+++ b/desktop/treeview.h
@@ -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
*/