57#define REDRAW_MAX 8000
326 {
"resource:icons/arrow-l.png", NULL, 0,
false },
327 {
"resource:icons/content.png", NULL, 0,
false },
328 {
"resource:icons/directory.png", NULL, 0,
false },
329 {
"resource:icons/directory2.png", NULL, 0,
false },
330 {
"resource:icons/search.png", NULL, 0,
false }
356 const struct rect *r)
358 if (tree->
cw_t != NULL) {
372 if (tree->
cw_t != NULL) {
373 static const struct rect r = {
409 if (tree->
cw_t != NULL) {
446 if (tree->
cw_t != NULL) {
462 if (tree->
cw_t != NULL) {
487 assert(0 &&
"Bad field index for node");
501 assert(node != NULL);
540 assert(tree != NULL);
541 assert(tree->
root != NULL);
548 if (target_y >= y && target_y < y + h)
573 assert(tree != NULL);
574 assert(tree->
root != NULL);
578 while (n != NULL && n != node) {
631 assert(tree != NULL);
692 bool skip_children =
false;
698 assert(
root != NULL);
711 while (node != NULL) {
713 if (child != NULL && !skip_children) {
721 while (node !=
root && next_sibling == NULL) {
723 if (callback_bwd != NULL &&
724 (entry || !walking_search)) {
726 err = callback_bwd(node, ctx, &abort);
745 if (callback_bwd != NULL) {
747 err = callback_bwd(node, ctx, &abort);
761 assert(node != NULL);
762 assert(node !=
root);
771 if (walking_search && (!entry ||
776 if (callback_fwd != NULL) {
778 err = callback_fwd(node, ctx, &skip_children, &abort);
826 n->
flags &= ~TV_NFLAGS_MATCHED;
830 bool matched =
false;
851 n->
flags &= ~TV_NFLAGS_MATCHED;
888 assert(
text[len] ==
'\0');
890 if (tree->
root == NULL) {
910 r.
y1 = ((
height > prev_height) ?
height : prev_height) + search_height;
965 assert(tree != NULL);
971 case TV_DRAG_SELECTION:
974 case TV_DRAG_TEXTAREA:
1001 switch (msg->
type) {
1055 if (
string == NULL || len == 0) {
1114 bool *skip_children,
1120 *skip_children =
false;
1141 assert(a->
parent == NULL);
1169 assert(a->
parent != NULL);
1192 }
while (a->
parent != NULL);
1209 assert(data != NULL);
1210 assert(tree != NULL);
1211 assert(tree->
root != NULL);
1213 if (relation == NULL) {
1214 relation = tree->
root;
1274 assert(data != NULL);
1275 assert(tree != NULL);
1276 assert(folder != NULL);
1278 assert(folder->
parent != NULL);
1280 assert(field != NULL);
1282 field->
field, &match) == lwc_error_ok &&
1324 assert(data != NULL);
1325 assert(tree != NULL);
1326 assert(entry != NULL);
1328 assert(entry->
parent != NULL);
1331 assert(
fields[0].field != NULL);
1350 for (i = 1; i < tree->
n_fields; i++) {
1351 assert(
fields[i].field != NULL);
1402 assert(data != NULL);
1403 assert(tree != NULL);
1404 assert(tree->
root != NULL);
1406 if (relation == NULL) {
1407 relation = tree->
root;
1426 assert(
fields[0].field != NULL);
1441 for (i = 1; i < tree->
n_fields; i++) {
1442 assert(
fields[i].field != NULL);
1501 bool *skip_children,
1549 assert(tree != NULL);
1550 assert(tree->
root != NULL);
1587 if ((n->
parent != NULL) &&
1614 if (tree->
drag.
type == TV_DRAG_TEXTAREA)
1651 new_text = malloc(len);
1652 if (new_text == NULL) {
1667 msg.data.node_edit.text = new_text;
1776 .user_interaction = interaction
1839 .user_interaction = interaction
1842 assert(
tree != NULL);
1850 while (node != NULL) {
1852 if (child != NULL) {
1860 while (node->
parent != NULL &&
1861 next_sibling == NULL) {
1886 if (node->
parent == NULL)
1907 node = next_sibling;
1910 assert(node != NULL);
1911 assert(node->
parent != NULL);
1933 assert(tree != NULL);
1935 assert(n->
parent != NULL);
2009 .selected_bg = foreground,
2010 .selected_text = background,
2028 struct core_window *cw,
2034 assert((
cw_t == NULL && cw == NULL) || (
cw_t != NULL && cw != NULL));
2037 assert(fields != NULL);
2040 assert(n_fields >= 2);
2042 *tree = malloc(
sizeof(
struct treeview));
2043 if (*tree == NULL) {
2047 (*tree)->fields = malloc(
sizeof(
struct treeview_field) * n_fields);
2048 if ((*tree)->fields == NULL) {
2055 free((*tree)->fields);
2060 (*tree)->field_width = 0;
2061 for (i = 0; i < n_fields; i++) {
2080 (*tree)->n_fields = n_fields - 1;
2082 (*tree)->drag.type = TV_DRAG_NONE;
2083 (*tree)->drag.start_node = NULL;
2084 (*tree)->drag.start.x = 0;
2085 (*tree)->drag.start.y = 0;
2086 (*tree)->drag.start.node_y = 0;
2087 (*tree)->drag.start.node_h = 0;
2088 (*tree)->drag.prev.x = 0;
2089 (*tree)->drag.prev.y = 0;
2090 (*tree)->drag.prev.node_y = 0;
2091 (*tree)->drag.prev.node_h = 0;
2093 (*tree)->move.root = NULL;
2094 (*tree)->move.target = NULL;
2097 (*tree)->edit.textarea = NULL;
2098 (*tree)->edit.node = NULL;
2108 if ((*tree)->search.textarea == NULL) {
2113 (*tree)->search.textarea = NULL;
2115 (*tree)->search.active =
false;
2116 (*tree)->search.search =
false;
2118 (*tree)->flags =
flags;
2120 (*tree)->cw_t =
cw_t;
2131 struct core_window *cw)
2133 assert(
cw_t != NULL);
2136 if (tree->
cw_t != NULL || tree->
cw_h != NULL) {
2137 NSLOG(netsurf, INFO,
"Treeview already attached.");
2164 assert(tree != NULL);
2178 for (f = 0; f <= tree->
n_fields; f++) {
2202 int additional_height_folders = 0;
2203 int additional_height_entries = 0;
2206 assert(tree != NULL);
2207 assert(node != NULL);
2211 NSLOG(netsurf, INFO,
"Tried to expand an expanded node.");
2215 switch (node->
type) {
2218 if (child == NULL) {
2231 additional_height_folders += child->
height;
2234 }
while (child != NULL);
2243 for (i = 0; i < tree->
n_fields - 1; i++) {
2272 n->
height += additional_height_entries +
2273 additional_height_folders;
2283 if (additional_height_entries + additional_height_folders != 0) {
2298 NSLOG(netsurf, INFO,
"Expanding!");
2302 NSLOG(netsurf, INFO,
"Expanded!");
2329 int h_reduction_folder = 0;
2330 int h_reduction_entry = 0;
2335 n->
flags &= ~TV_NFLAGS_SELECTED;
2358 assert(h_reduction_folder + h_reduction_entry >= 0);
2362 node->height -= h_reduction_folder + h_reduction_entry;
2387 assert(node != NULL);
2391 NSLOG(netsurf, INFO,
"Tried to contract a contracted node.");
2421 assert(
tree != NULL);
2424 NSLOG(netsurf, INFO,
"Contracting!");
2428 NSLOG(netsurf, INFO,
"Contracted!");
2444 assert(tree != NULL);
2445 assert(tree->
root != NULL);
2505 bool *skip_children,
2533 assert(tree != NULL);
2534 assert(tree->
root != NULL);
2571 int *render_y_in_out,
2572 const struct rect *r,
2582 int render_y = *render_y_in_out;
2585 int sel_min, sel_max;
2599 while (node != NULL) {
2601 struct bitmap *furniture;
2602 bool invert_selection;
2618 while (node !=
root &&
2629 assert(node != NULL);
2630 assert(node !=
root);
2635 inset = x + node->
inset;
2646 if (tree->
drag.
type == TV_DRAG_SELECTION &&
2647 (render_y +
height >= sel_min &&
2648 render_y < sel_max)) {
2649 invert_selection =
true;
2651 invert_selection =
false;
2655 invert_selection)) {
2656 bg_style = &style->
sbg;
2657 text_style = &style->
stext;
2658 infotext_style = &style->
sitext;
2663 bg_style = &style->
bg;
2664 text_style = &style->
text;
2665 infotext_style = &style->
itext;
2711 x0, render_y + baseline,
2717 if (render_y > r->
y1) {
2731 for (i = 0; i < tree->
n_fields - 1; i++) {
2740 render_y + baseline,
2747 render_y + baseline,
2753 x0, render_y + baseline,
2764 if (render_y > r->
y1) {
2771 *render_y_in_out = render_y;
2790 int *render_y_in_out,
2791 const struct rect *r,
2801 int render_y = *render_y_in_out;
2804 int sel_min, sel_max;
2818 while (node != NULL) {
2820 struct bitmap *furniture;
2821 bool invert_selection;
2836 while (node !=
root &&
2847 assert(node != NULL);
2848 assert(node !=
root);
2868 if (tree->
drag.
type == TV_DRAG_SELECTION &&
2869 (render_y +
height >= sel_min &&
2870 render_y < sel_max)) {
2871 invert_selection =
true;
2873 invert_selection =
false;
2877 invert_selection)) {
2878 bg_style = &style->
sbg;
2879 text_style = &style->
stext;
2880 infotext_style = &style->
sitext;
2885 bg_style = &style->
bg;
2886 text_style = &style->
text;
2887 infotext_style = &style->
itext;
2933 x0, render_y + baseline,
2939 if (render_y > r->
y1) {
2953 for (i = 0; i < tree->
n_fields - 1; i++) {
2962 render_y + baseline,
2969 render_y + baseline,
2975 x0, render_y + baseline,
2986 if (render_y > r->
y1) {
2993 *render_y_in_out = render_y;
3011 assert(tree != NULL);
3012 assert(tree->
root != NULL);
3035 if (render_y < r.
y1) {
3056 &data, &r, &new_ctx);
3071 &render_y, &r, &data, &new_ctx);
3074 &render_y, &r, &data, &new_ctx);
3077 if (render_y < r.
y1) {
3165 bool *skip_children,
3170 bool changed =
false;
3200 *skip_children =
true;
3266 *skip_children =
true;
3370 assert(
tree != NULL);
3530 assert(
tree != NULL);
3563 assert(
tree != NULL);
3599 assert(
tree != NULL);
3612 while (relation->
next_sib != NULL) {
3643 NSLOG(netsurf, INFO,
"Bad drop target for move.");
3657 for (node =
tree->
move.
root; node != NULL; node = next) {
3660 if (node == relation) {
3667 node->
flags &= ~TV_NFLAGS_SELECTED;
3728 bool *skip_children,
3763 assert(
tree != NULL);
3786 assert(
tree != NULL);
3795 if (n != NULL && n->
parent != NULL) {
3850 bool *skip_children,
3860 if (ns->
curr == NULL) {
3900 .prev_n_selected = 0
3904 bool redraw =
false;
3913 scroll_to_node = ns.
curr;
3916 if (ns.
next == NULL)
3918 if (ns.
prev == NULL)
3930 if (ns.
curr != NULL &&
3945 if (ns.
curr != NULL) {
3965 }
else if (ns.
curr != NULL) {
3972 if (ns.
prev != NULL) {
3975 scroll_to_node = ns.
prev;
3980 if (ns.
next != NULL) {
3983 scroll_to_node = ns.
next;
4011 bool redraw =
false;
4013 assert(tree != NULL);
4115 int mouse_pos =
mouse_y - node_y;
4118 assert(tree != NULL);
4119 assert(tree->
root != NULL);
4121 assert(target != NULL);
4137 }
else switch (target->
type) {
4139 if (mouse_pos <= node_height / 4) {
4141 }
else if (mouse_pos <= (3 * node_height) / 4 ||
4150 if (mouse_pos <= node_height / 2) {
4187 if (target != orig) {
4241 switch (msg->
type) {
4248 tree->
drag.
type = TV_DRAG_TEXTAREA;
4293 int field_y = node_y;
4304 field_data = &n->
text;
4314 for (i = 0; i < tree->
n_fields - 1; i++) {
4318 ef = &(tree->
fields[i + 1]);
4329 if (field_data == NULL || field_desc == NULL) {
4371 tree->
edit.
x = field_x;
4372 tree->
edit.
y = field_y;
4398 assert(tree != NULL);
4399 assert(tree->
root != NULL);
4414 if (redraw ==
false)
4451 bool *skip_children,
4456 bool redraw =
false;
4460 TV_NODE_ACTION_NONE = 0,
4461 TV_NODE_ACTION_SELECTION = (1 << 0)
4462 } action = TV_NODE_ACTION_NONE;
4480 int inset = node->
inset;
4484 if (ma->
x >= inset - 1 &&
4516 ma->
x < x + max_width -
4521 }
else if (ma->
x >= x + max_width &&
4522 ma->
x < x + max_width +
4528 if (ma->
x >= x && ma->
x < x +
4589 case TV_DRAG_SELECTION:
4597 r.
y1 = (curr_y1 > prev_y1) ? curr_y1 : prev_y1;
4655 msg.data.node_launch.mouse = ma->
mouse;
4667 action |= TV_NODE_ACTION_SELECTION;
4691 action |= TV_NODE_ACTION_SELECTION;
4695 if (action & TV_NODE_ACTION_SELECTION) {
4728 bool redraw =
false;
4731 assert(tree != NULL);
4732 assert(tree->
root != NULL);
4740 if (tree->
drag.
type == TV_DRAG_TEXTAREA) {
4744 }
else if (tree->
drag.
type == TV_DRAG_SEARCH) {
4756 y < search_height && tree->search.active ==
false) {
4779 int ta_x = x - tree->
edit.
x;
4780 int ta_y = y - tree->
edit.
y;
4782 if (ta_x > 0 && ta_x < tree->edit.w &&
4783 ta_y > 0 && ta_y < tree->edit.h) {
4798 case TV_DRAG_SELECTION:
4846 if (tree->
drag.
type == TV_DRAG_NONE) {
4850 tree->
drag.
type = TV_DRAG_SELECTION;
4854 tree->
drag.
type = TV_DRAG_SELECTION;
4860 tree->
drag.
type == TV_DRAG_SELECTION) {
4867 if (tree->
drag.
type == TV_DRAG_SELECTION) {
4873 r.
y1 = (curr_y1 > prev_y1) ? curr_y1 : prev_y1;
4915 assert(
tree != NULL);
4932 if (
string == NULL || strlen(
string) == 0) {
5019 switch (event->
type) {
5069 unsigned char *rpos;
5089 for (y = 0; y <
size; y++) {
5094 for (x = 0; x < y * 2; x++) {
5111 for (x = y * 2 + 2; x <
size ; x++) {
5118 }
else if ((y ==
size / 2) && (
size & 0x1)) {
5120 for (x = 0; x <
size - 1; x++) {
5134 for (x = 0; x < (
size - y - 1) * 2; x++) {
5151 for (x = (
size - y) * 2; x <
size ; x++) {
5179 unsigned char *data;
5180 unsigned char *orig_data;
5201 memcpy(data, orig_data, stride *
size);
5225 unsigned char *rpos;
5227 unsigned char *orig_data;
5228 unsigned char *orig_pos;
5249 for (y = 0; y <
size; y++) {
5252 for (x = 0; x <
size; x++) {
5253 orig_pos = orig_data + x * stride + y * 4;
5254 *(pos++) = *(orig_pos++);
5255 *(pos++) = *(orig_pos++);
5256 *(pos++) = *(orig_pos);
5339 long long font_px_size;
5340 long long font_pt_size;
5348 NSLOG(netsurf, INFO,
"Initialising treeview module");
5351 if (font_pt_size <= 0) {
5352 font_pt_size = 11 * 10;
5379 NSLOG(netsurf, INFO,
"Initialised treeview module");
5395 NSLOG(netsurf, INFO,
5396 "Warning: tried to finalise uninitialised treeview module");
5400 NSLOG(netsurf, INFO,
"Finalising treeview module");
5417 NSLOG(netsurf, INFO,
"Finalised treeview module");
static os_mode mode
The current sprite mode.
static uint32_t count(const http_directive *list, lwc_string *key)
char * strcasestr(const char *haystack, const char *needle)
Case insensitive strstr implementation.
@ CONTENT_IMAGE
All images.
@ CONTENT_MSG_DONE
content has finished processing
@ CONTENT_MSG_READY
may be displayed
Interface to core window handling.
core_window_drag_status
drag status passed to drag_status callback
@ CORE_WINDOW_DRAG_TEXT_SELECTION
@ CORE_WINDOW_DRAG_SELECTION
css_fixed nscss_screen_dpi
Screen DPI in fixed point units: defaults to 90, which RISC OS uses.
nserror cw_helper_scroll_visible(const struct core_window_callback_table *cw_t, struct core_window *cw_h, const struct rect *r)
Scroll a core window to make the given rectangle visible.
Helpers to simplify core use of corewindow.
Internal core bitmap interface.
void textarea_redraw(struct textarea *ta, int x, int y, colour bg, float scale, const struct rect *clip, const struct redraw_context *ctx)
Handle redraw requests for text areas.
struct textarea * textarea_create(const textarea_flags flags, const textarea_setup *setup, textarea_client_callback callback, void *data)
Create a text area.
void textarea_destroy(struct textarea *ta)
Destroy a text area.
bool textarea_set_caret(struct textarea *ta, int caret)
Set the caret's position.
bool textarea_set_text(struct textarea *ta, const char *text)
Set the text in a text area, discarding any current text.
int textarea_get_text(struct textarea *ta, char *buf, unsigned int len)
Extract the text from a text area.
const char * textarea_data(struct textarea *ta, unsigned int *len)
Access text data in a text area.
textarea_mouse_status textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
bool textarea_keypress(struct textarea *ta, uint32_t key)
Key press handling for text areas.
Single/Multi-line UTF-8 text area interface.
void(* textarea_client_callback)(void *data, struct textarea_msg *msg)
Client callback for the textarea.
textarea_flags
Text area flags.
@ TEXTAREA_INTERNAL_CARET
Render own caret.
@ TEXTAREA_MSG_TEXT_MODIFIED
Textarea text modified.
@ TEXTAREA_MSG_DRAG_REPORT
Textarea drag start/end report.
@ TEXTAREA_MSG_REDRAW_REQUEST
Textarea redraw request.
static nserror treeview_node_mouse_action_cb(treeview_node *node, void *ctx, bool *skip_children, bool *end)
Treewalk node callback for handling mouse action.
static nserror treeview_node_contract_internal(treeview *tree, treeview_node *node)
Contract a treeview node.
nserror treeview_cw_detach(treeview *tree)
Detach a treeview from a corewindow.
static unsigned treeview__get_search_height(const treeview *tree)
Get height used by treeview's search bar (or 0 if not present).
static void treeview_insert_node(treeview *tree, treeview_node *a, treeview_node *b, enum treeview_relationship rel)
Insert a treeview node into a treeview.
static bool treeview_select_all(treeview *tree, struct rect *rect)
Select all in a treeview.
static void treeview_init_resources(void)
Fetch content resources used by treeview.
static void treeview_textarea_search_callback(void *data, struct textarea_msg *msg)
Callback for textarea_create, in desktop/treeview.h.
static nserror treeview_node_selection_walk_cb(treeview_node *n, void *ctx, bool *skip_children, bool *end)
Treewalk node callback for handling selection related actions.
#define REDRAW_MAX
The maximum horizontal size a treeview can possibly be.
nserror treeview_node_contract(treeview *tree, treeview_node *node)
Contract a treeview node.
static void treeview__cw_get_window_dimensions(const struct treeview *tree, int *width, int *height)
Corewindow callback wrapper: Get window viewport dimensions.
static nserror treeview_delete_node_internal(treeview *tree, treeview_node *n, bool interaction, treeview_node_options_flags flags)
Delete a treeview node.
static nserror treeview_walk_fwd_cb(treeview_node *n, void *ctx, bool *skip_children, bool *end)
Treewalk node enter callback.
void treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
static nserror treeview_launch_selection(treeview *tree)
Launch a selection.
static bool treeview_set_move_indicator(treeview *tree, bool need_redraw, treeview_node *target, int node_height, int node_y, int mouse_y, struct rect *rect)
Set the drag&drop drop indicator.
static void treeview__cw_update_size(const struct treeview *tree, int width, int height)
Corewindow callback wrapper: Update the limits of the window.
static bool treeview_keyboard_navigation(treeview *tree, uint32_t key, struct rect *rect)
Handle keyboard navigation.
static void treeview_move_yank_selection(treeview *tree, treeview_node *fixed)
Yank a selection to the node move list.
static struct bitmap * treeview_generate_rotate_bitmap(struct bitmap *orig, int size)
Create bitmap from rotation of another bitmap.
nserror treeview_contract(treeview *tree, bool all)
Contract a treeview's nodes.
nserror treeview_cw_attach(treeview *tree, const struct core_window_callback_table *cw_t, struct core_window *cw)
Attach a treeview to a corewindow.
static bool treeview_unlink_node(treeview_node *n)
Unlink a treeview node.
nserror treeview_delete_node(treeview *tree, treeview_node *n, treeview_node_options_flags flags)
Delete a treeview node.
static nserror treeview__search(treeview *tree, const char *text, unsigned int len)
Search treeview for text.
nserror treeview_create(treeview **tree, const struct treeview_callback_table *callbacks, int n_fields, struct treeview_field_desc fields[], const struct core_window_callback_table *cw_t, struct core_window *cw, treeview_flags flags)
Create a treeview.
enum treeview_node_type treeview_get_selection(treeview *tree, void **node_data)
Get the first selected node.
nserror treeview_fini(void)
Finalise the treeview module (all treeviews must have been destroyed first)
static nserror treeview_expand_cb(treeview_node *n, void *ctx, bool *skip_children, bool *end)
Treewalk node callback for handling recursive node expansion.
treeview_walk_mode
The treeview walk mode.
@ TREEVIEW_WALK_MODE_LOGICAL_EXPANDED
Walk to expanded nodes in the (sub)tree only.
@ TREEVIEW_WALK_MODE_DISPLAY
Walk displayed nodes.
@ TREEVIEW_WALK_MODE_LOGICAL_COMPLETE
Walk to all nodes in the (sub)tree.
static void treeview__redraw_from_node(const treeview *tree, const treeview_node *node)
Redraw tree from given node to the bottom.
static nserror treeview_init_plot_styles(int font_pt_size)
Initialise the plot styles from CSS system colour values.
void treeview_edit_selection(treeview *tree)
Edit the first selected node.
struct treeview_globals tree_g
static void treeview__search_update_display(treeview *tree)
Update the layout for any active search.
bool treeview_has_selection(treeview *tree)
Determine whether treeview has a selection.
static nserror treeview_node_launch_walk_fwd_cb(treeview_node *n, void *ctx, bool *skip_children, bool *end)
Treewalk node walk forward callback for launching nodes.
static treeview_node * treeview_get_first_selected(treeview *tree)
Get first selected node (in any)
treeview_target_pos
Treeview target position.
static int treeview__get_display_height(const treeview *tree)
Get the display height of the treeview data component of the display.
bool treeview_keypress(treeview *tree, uint32_t key)
Key press handling for treeviews.
static struct textarea * treeview__create_textarea(treeview *tree, int width, int height, colour border, colour background, colour foreground, plot_font_style_t text, textarea_client_callback ta_callback)
Helper to create a textarea.
static struct treeview_resource treeview_res[TREE_RES_LAST]
Treeview content resources.
nserror treeview_update_node_entry(treeview *tree, treeview_node *entry, const struct treeview_field_data fields[], void *data)
Update an entry node in given treeview.
static bool treeview_clear_selection(treeview *tree, struct rect *rect)
Clear any selection in a treeview.
static int treeview_node_y(const treeview *tree, const treeview_node *node)
Find y position of the top of a node.
nserror treeview_get_relation(treeview *tree, treeview_node **relation, enum treeview_relationship *rel, bool at_y, int y)
Find a relation for node creation.
nserror treeview_create_node_folder(treeview *tree, treeview_node **folder, treeview_node *relation, enum treeview_relationship rel, const struct treeview_field_data *field, void *data, treeview_node_options_flags flags)
Create a folder node in given treeview.
nserror treeview_destroy(treeview *tree)
Destroy a treeview object.
static void treeview_redraw_search(treeview *tree, const int x, const int y, int *render_y_in_out, const struct rect *r, struct content_redraw_data *data, const struct redraw_context *ctx)
Draw a treeview normally, in tree mode.
static void treeview_copy_selection(treeview *tree)
Copy a selection to the clipboard.
static nserror treeview_node_nav_cb(treeview_node *node, void *ctx, bool *skip_children, bool *end)
Treewalk node callback for handling mouse action.
static void treeview__cw_scroll_to_node(const struct treeview *tree, const struct treeview_node *node)
Corewindow callback_wrapper: Scroll to make node visible.
static nserror treeview_walk_internal(treeview *tree, treeview_node *root, enum treeview_walk_mode mode, nserror(*callback_bwd)(treeview_node *n, void *ctx, bool *end), nserror(*callback_fwd)(treeview_node *n, void *ctx, bool *skip_children, bool *end), void *ctx)
Walk a treeview subtree, calling a callback at each node (depth first)
static nserror treeview__search_walk_cb(treeview_node *n, void *ctx, bool *skip_children, bool *end)
Treewalk node callback for handling search.
nserror treeview_walk(treeview *tree, treeview_node *root, treeview_walk_cb enter_cb, treeview_walk_cb leave_cb, void *ctx, enum treeview_node_type type)
Walk (depth first) a treeview subtree, calling a callback at each node of required type.
static bool treeview_edit_node_at_point(treeview *tree, treeview_node *n, int node_y, int mouse_x, int mouse_y, struct rect *rect)
Start edit of node field, at given y-coord, if editable.
static void treeview__cw_invalidate_area(const struct treeview *tree, const struct rect *r)
Corewindow callback wrapper: Request a redraw of the window.
int treeview_get_height(treeview *tree)
Find current height of a treeview.
static void treeview__search_cancel(treeview *tree, bool drop_focus)
Cancel a treeview search, optionally droping focus from search widget.
struct treeview_node_style plot_style_even
Plot style for even rows.
void treeview_redraw(treeview *tree, const int x, const int y, struct rect *clip, const struct redraw_context *ctx)
Redraw a treeview object.
treeview_resource_id
treeview resource indexes
@ TREE_RES_FOLDER_SPECIAL
static void treeview__cw_drag_status(const struct treeview *tree, core_window_drag_status ds)
Corewindow callback wrapper: Inform corewindow owner of drag status.
treeview_node_flags
flags indicating render state of node.
@ TV_NFLAGS_SELECTED
Whether node is selected.
@ TV_NFLAGS_NONE
No node flags set.
@ TV_NFLAGS_SPECIAL
Render as special node.
@ TV_NFLAGS_MATCHED
Whether node matches search.
@ TV_NFLAGS_EXPANDED
Whether node is expanded.
static void treeview_edit_cancel(treeview *tree, bool redraw)
Cancel the editing of a treeview node.
static void treeview_redraw_tree(treeview *tree, const int x, const int y, int *render_y_in_out, const struct rect *r, struct content_redraw_data *data, const struct redraw_context *ctx)
Draw a treeview normally, in tree mode.
nserror treeview_node_expand(treeview *tree, treeview_node *node)
Expand a treeview node.
static nserror treeview_move_selection(treeview *tree, struct rect *rect)
Move a selection according to the current move drag.
static nserror treeview_node_launch_walk_bwd_cb(treeview_node *n, void *ctx, bool *end)
Treewalk node walk backward callback for tracking folder selection.
static struct bitmap * treeview_generate_copy_bitmap(struct bitmap *orig, int size)
Create bitmap copy of another bitmap.
static nserror treeview_node_expand_internal(treeview *tree, treeview_node *node)
Expand a treeview's nodes.
nserror treeview_init(void)
Prepare treeview module for treeview usage.
static struct treeview_text * treeview_get_text_for_field(treeview *tree, treeview_node *n, int i)
Helper function to access the given field of a node.
static nserror treeview_delete_empty_nodes(treeview *tree, bool interaction)
Delete any empty treeview folder nodes.
static treeview_node * treeview_y_node(treeview *tree, int target_y)
Find node at given y-position.
nserror treeview_create_node_entry(treeview *tree, treeview_node **entry, treeview_node *relation, enum treeview_relationship rel, const struct treeview_field_data fields[], void *data, treeview_node_options_flags flags)
Create an entry node in given treeview.
static core_window_drag_status treeview__get_cw_drag_type(const treeview *tree)
Convert from treeview drag to core window drag type.
static void treeview_edit_done(treeview *tree)
Complete a treeview edit.
nserror treeview_expand(treeview *tree, bool only_folders)
Expand a treeview's nodes.
static nserror treeview_res_cb(struct hlcache_handle *handle, const hlcache_event *event, void *pw)
Callback for hlcache retrieving resources.
static nserror treeview_create_node_root(treeview_node **root)
Create treeview's root node.
static void treeview__cw_full_redraw(const struct treeview *tree)
Corewindow callback wrapper: Request a full redraw of the window.
nserror treeview_set_search_string(treeview *tree, const char *string)
Set the search string for a treeview with TREEVIEW_SEARCHABLE.
treeview_node_part
Section type of a treeview at a point.
@ TV_NODE_PART_TOGGLE
Expansion toggle.
@ TV_NODE_PART_NONE
Empty area.
@ TV_NODE_PART_ON_NODE
Node content (text, icon)
static nserror treeview_init_furniture(void)
Measures width of characters used to represent treeview furniture.
treeview_furniture_id
Treeview furniture states.
static bool treeview_delete_selection(treeview *tree, struct rect *rect)
Delete a selection.
static void treeview_textarea_callback(void *data, struct textarea_msg *msg)
Callback for textarea_create, in desktop/treeview.h.
static void treeview_commit_selection_drag(treeview *tree)
Commit a current selection drag, modifying the node's selection state.
struct treeview_node_style plot_style_odd
Plot style for odd rows.
static bool treeview_propagate_selection(treeview *tree, struct rect *rect)
Propagate selection to visible descendants of selected nodes.
static nserror treeview_walk_bwd_cb(treeview_node *n, void *ctx, bool *end)
Treewalk node leave callback.
static nserror treeview_delete_node_walk_cb(treeview_node *n, void *ctx, bool *end)
Treewalk node callback deleting nodes.
static void treeview__cw_scroll_top(const struct treeview *tree)
Corewindow callback_wrapper: Scroll to top of window.
static nserror treeview_node_contract_cb(treeview_node *n, void *ctx, bool *end)
Treewalk node callback for handling node contraction.
nserror treeview_update_node_folder(treeview *tree, treeview_node *folder, const struct treeview_field_data *field, void *data)
Update an folder node in given treeview.
static struct bitmap * treeview_generate_triangle_bitmap(colour bg, colour fg, int size)
Create a right-pointing anti-aliased triangle bitmap.
static treeview_node * treeview_node_next(treeview_node *node, bool full)
Find the next node in depth first tree order.
static nserror treeview_set_inset_from_parent(treeview_node *n, void *ctx, bool *skip_children, bool *end)
Set a node's inset from its parent.
Treeview handling interface.
nserror(* treeview_walk_cb)(void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
Client callback for treeview_walk.
@ TREE_MSG_NODE_EDIT
Node to be edited.
@ TREE_MSG_NODE_LAUNCH
Node to be launched.
@ TREE_MSG_NODE_DELETE
Node to be deleted.
treeview_node_type
treeview node type
@ TREE_NODE_ENTRY
Node is an entry.
@ TREE_NODE_FOLDER
Node is folder.
@ TREE_NODE_ROOT
Node is treeview's root.
treeview_node_options_flags
Node change handling options.
@ TREE_OPTION_SUPPRESS_RESIZE
@ TREE_OPTION_SPECIAL_DIR
@ TREE_OPTION_SUPPRESS_REDRAW
treeview_field_flags
treeview field flags
@ TREE_FLAG_SEARCHABLE
Whether field is searchable.
@ TREE_FLAG_SHOW_NAME
Whether field name shown.
@ TREE_FLAG_COPY_TEXT
Whether to copy to clipb.
@ TREE_FLAG_ALLOW_EDIT
Whether allow edit field.
@ TREE_FLAG_DEFAULT
Whether field is default.
treeview_relationship
Relationship between nodes.
treeview_flags
treeview control flags
@ TREEVIEW_NO_DELETES
No node deletes.
@ TREEVIEW_DEL_EMPTY_DIRS
Delete dirs on empty.
@ TREEVIEW_SEARCHABLE
Treeview has search bar.
@ TREEVIEW_NO_MOVES
No node drags.
nserror
Enumeration of error codes.
@ NSERROR_BAD_PARAMETER
Bad Parameter.
@ NSERROR_UNKNOWN
Unknown error - DO NOT USE.
@ NSERROR_NOMEM
Memory exhaustion.
static struct directory * root
static struct core_window_callback_table cw_t
Declare Core Window Callbacks:
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
nserror hlcache_handle_release(hlcache_handle *handle)
Release a high-level cache handle.
nserror hlcache_handle_retrieve(nsurl *url, uint32_t flags, nsurl *referer, llcache_post_data *post, hlcache_handle_callback cb, void *pw, hlcache_child_context *child, content_type accepted_types, hlcache_handle **result)
Retrieve a high-level cache handle for an object.
High-level resource cache interface.
Generic bitmap handling interface.
@ BITMAP_OPAQUE
image is opaque
bitmap_layout
NetSurf bitmap pixel layout.
Interface to platform-specific clipboard operations.
Public content interface.
bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Display content on screen with optional tiling.
int content_get_height(struct hlcache_handle *h)
Retrieve height of content.
Interface to platform-specific layout operation table.
browser_mouse_state
Mouse state.
@ BROWSER_MOUSE_PRESS_1
button 1 pressed
@ BROWSER_MOUSE_CLICK_2
button 2 clicked.
@ BROWSER_MOUSE_PRESS_2
button 2 pressed
@ BROWSER_MOUSE_HOVER
No mouse buttons pressed, May be used to indicate hover or end of drag.
@ BROWSER_MOUSE_CLICK_1
button 1 clicked.
@ BROWSER_MOUSE_MOD_2
2nd modifier key pressed (eg.
@ BROWSER_MOUSE_DOUBLE_CLICK
button double clicked
@ BROWSER_MOUSE_MOD_3
3rd modifier key pressed (eg.
@ BROWSER_MOUSE_MOD_1
1st modifier key pressed (eg.
@ BROWSER_MOUSE_DRAG_1
start of button 1 drag
@ BROWSER_MOUSE_LEAVE
pointer leaving window
@ BROWSER_MOUSE_DRAG_2
start of button 2 drag
Target independent plotting interface.
Interface to key press operations.
bool knockout_plot_end(const struct redraw_context *ctx)
End a knockout plotting session.
bool knockout_plot_start(const struct redraw_context *ctx, struct redraw_context *knk_ctx)
Start a knockout plotting session.
Knockout rendering (interface).
#define NSLOG(catname, level, logmsg, args...)
colour nscolours[NSCOLOUR__COUNT]
NetSurf UI colour table.
NetSurf UI colours (interface).
@ NSCOLOUR_WIN_EVEN_FG_FADED
NetSurf URL handling (interface).
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
#define blend_colour(c0, c1)
#define red_from_colour(c)
@ PLOT_OP_TYPE_NONE
No operation.
@ PLOT_OP_TYPE_SOLID
Solid colour.
#define mix_colour(c0, c1, p)
@ PLOT_FONT_FAMILY_SANS_SERIF
#define blue_from_colour(c)
#define green_from_colour(c)
#define PLOT_STYLE_SCALE
Scaling factor for plot styles.
static BList * callbacks
List of all callbacks.
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
Container for border values during table border calculations.
parameters to content redraw
int height
vertical dimension
bool repeat_y
whether content is tiled in y direction
bool repeat_x
whether content is tiled in x direction
int y
coordinate for top-left of redraw
int x
coordinate for top-left of redraw
colour background_colour
The background colour.
int width
dimensions to render content at (for scaling contents with intrinsic dimensions)
float scale
Scale for redraw (for scaling contents without intrinsic dimensions)
Callbacks to achieve various core window functionality.
nserror(* get_window_dimensions)(const struct core_window *cw, int *width, int *height)
Get window viewport dimensions.
nserror(* drag_status)(struct core_window *cw, core_window_drag_status ds)
Inform corewindow owner of drag status.
nserror(* update_size)(struct core_window *cw, int width, int height)
Update the limits of the window.
nserror(* invalidate)(struct core_window *cw, const struct rect *rect)
Invalidate an area of a window.
int(* get_height)(void *bitmap)
Get the bitmap height.
void(* destroy)(void *bitmap)
Destroy a bitmap.
void *(* create)(int width, int height, enum gui_bitmap_flags flags)
Create a new bitmap.
int(* get_width)(void *bitmap)
Get the bitmap width.
size_t(* get_rowstride)(void *bitmap)
Get the number of bytes per row of the image.
void(* modified)(void *bitmap)
Marks a bitmap as modified.
unsigned char *(* get_buffer)(void *bitmap)
Get the image buffer from a bitmap.
void(* set)(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles)
Core tells front end to put given text in clipboard.
nserror(* width)(const struct plot_font_style *fstyle, const char *string, size_t length, int *width)
Measure the width of a string.
content_msg type
Event type.
struct gui_clipboard_table * clipboard
Clipboard table.
struct gui_bitmap_table * bitmap
Bitmap table.
struct gui_layout_table * layout
Layout table.
plot_font_generic_family_t family
Generic family to plot with.
colour foreground
Colour of text.
plot_font_flags_t flags
Font flags.
plot_style_fixed size
Font size, in pt.
colour background
Background colour to blend to, if appropriate.
int weight
Font weight: value in range [100,900] as per CSS.
Plot style for stroke/fill plotters.
colour fill_colour
Colour of fill.
plot_style_fixed stroke_width
Width of stroke, in pixels.
plot_operation_type_t fill_type
Fill plot type.
colour stroke_colour
Colour of stroke.
plot_operation_type_t stroke_type
Stroke plot type.
bool option_knockout
flag to enable knockout rendering.
nserror(* text)(const struct redraw_context *ctx, const plot_font_style_t *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
nserror(* rectangle)(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rectangle)
Plots a rectangle.
nserror(* clip)(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
nserror(* bitmap)(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
const struct plotter_table * plot
Current plot operation table.
unsigned int len
Byte length of text.
const char * text
UTF8 text.
textarea_msg_type type
Indicates message data type.
struct rect redraw
With _REDRAW_REQUEST.
struct textarea_msg::@79::@82 modified
With _TEXT_MODIFIED.
union textarea_msg::@79 data
Depends on msg type.
textarea_drag_type drag
With _DRAG_REPORT.
textarea setup parameters
plot_font_style_t text
Textarea background colour and font.
unsigned int flags
Textarea flags.
Client callbacks for events concerning nodes.
nserror(* folder)(struct treeview_node_msg msg, void *data)
nserror(* entry)(struct treeview_node_msg msg, void *data)
context for treeview contraction callback
struct treeview_pos start
Start pos.
treeview_node * start_node
Start node.
struct treeview_pos prev
Previous pos.
bool selected
Start node is selected.
enum treeview_drag::@85 type
Drag type.
enum treeview_node_part part
Node part at start.
Treeview node edit details.
struct textarea * textarea
Textarea for edit, or NULL.
treeview_node * node
Node being edited, or NULL.
lwc_string * field
The field being edited, or NULL.
int y
Textarea y position.
int x
Textarea x position.
context data for treeview expansion
const char * value
Field value.
lwc_string * field
Field name.
size_t value_len
Field value length (bytes)
Treeview field description.
enum treeview_field_flags flags
Flags for field.
struct treeview_text value
field text
enum treeview_field_flags flags
flags controlling how field is interpreted
lwc_string * field
field contents
Treeview handling global context.
context for treeview launch action
context for treeview mouse handling
browser_mouse_state mouse
Treeview node move details.
enum treeview_target_pos target_pos
Pos wrt render node.
treeview_node * target
Move target.
struct rect target_area
Pos/size of target indicator.
treeview_node * root
Head of yanked node list.
context for treeview keyboard action
context for treeview node deletion iterator
treeview_node base
Entry class inherits node base class.
struct treeview_field fields[FLEX_ARRAY_LEN_DECL]
browser_mouse_state mouse
enum treeview_msg msg
The message type.
plot_font_style_t sitext
Selected entry field text.
struct treeview_node_style::@86 furn[TREE_FURN_LAST]
plot_style_t bg
Background.
plot_font_style_t itext
Entry field text.
plot_font_style_t text
Text.
plot_style_t sbg
Selected background.
plot_font_style_t stext
Selected text.
enum treeview_node_type type
Node type.
treeview_node * prev_sib
previous sibling node
treeview_node * next_sib
next sibling node
struct treeview_text text
treeview_node * parent
parent node
enum treeview_node_flags flags
Node flags.
treeview_node * children
first child node
int inset
Node's inset depending on tree depth (pixels)
void * client_data
Passed to client on node event msg callback.
int height
Includes height of any descendants (pixels)
A mouse position wrt treeview.
int node_h
Height of node at y.
int node_y
Top of node at y.
Treeview content resource data.
struct hlcache_handle * c
Data used when doing a treeview walk for search.
const char * text
The string being searched for.
const unsigned int len
Length of string being searched for.
treeview * tree
The treeview to search.
int window_height
Accumulate height for matching entries.
Treeview search box details.
struct textarea * textarea
Search box.
int height
Current search display height.
bool active
Whether the search box has focus.
bool search
Whether we have a search term.
context for treeview selection
union treeview_selection_walk_data::@88 data
@ TREEVIEW_WALK_GET_FIRST_SELECTED
@ TREEVIEW_WALK_YANK_SELECTION
@ TREEVIEW_WALK_SELECT_ALL
@ TREEVIEW_WALK_CLEAR_SELECTION
@ TREEVIEW_WALK_COPY_SELECTION
@ TREEVIEW_WALK_HAS_SELECTION
@ TREEVIEW_WALK_DELETE_SELECTION
@ TREEVIEW_WALK_PROPAGATE_SELECTION
@ TREEVIEW_WALK_COMMIT_SELECT_DRAG
enum treeview_selection_walk_data::@87 purpose
struct treeview_selection_walk_data::@88::@92 first
struct treeview_selection_walk_data::@88::@93 copy
struct treeview_selection_walk_data::@88::@91 yank
struct treeview_selection_walk_data::@88::@90 drag
struct treeview_selection_walk_data::@88::@89 redraw
Text within a treeview field or node.
uint32_t len
Length of string in bytes.
const char * data
Text string.
int width
Width of text in px.
Treewalk iterator context.
treeview_walk_cb enter_cb
enum treeview_node_type type
treeview_walk_cb leave_cb
int n_fields
fields[n_fields] is folder, lower are entry fields
struct treeview_search search
Treeview search box.
treeview_flags flags
Treeview behaviour settings.
const struct treeview_callback_table * callbacks
For node events.
const struct core_window_callback_table * cw_t
Window cb table.
treeview_node * root
Root node.
int field_width
Max width of shown field names.
struct treeview_move move
Move drag details.
struct treeview_drag drag
Drag state.
struct treeview_edit edit
Edit details.
uint32_t view_width
Viewport horizontal size.
struct core_window * cw_h
Core window handle.
struct treeview_field * fields
Array of fields.
Interface to system colour values.
uint32_t colour
Colour type: XBGR.
struct rect rect
Rectangle coordinates.
Option reading and saving interface.
#define nsoption_int(OPTION)
Get the value of an integer option.
Interface to a number of general purpose functionality.
#define FLEX_ARRAY_LEN_DECL
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.