diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-09-02 16:19:16 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-09-02 16:19:16 +0100 |
commit | 49c7994d0580a655ddcc78e07205eea45d74132c (patch) | |
tree | 7047078437c94d519654fd2ad86f5a8e5be43af3 /desktop/tree.h | |
parent | 46e569c481f1c5196fd90b05bd801809355f2d84 (diff) | |
download | netsurf-49c7994d0580a655ddcc78e07205eea45d74132c.tar.gz netsurf-49c7994d0580a655ddcc78e07205eea45d74132c.tar.bz2 |
Remove bulk of old treeview implementation.
Diffstat (limited to 'desktop/tree.h')
-rw-r--r-- | desktop/tree.h | 176 |
1 files changed, 4 insertions, 172 deletions
diff --git a/desktop/tree.h b/desktop/tree.h index 84d90f316..52bea7d13 100644 --- a/desktop/tree.h +++ b/desktop/tree.h @@ -28,48 +28,22 @@ #include <stdint.h> #include "desktop/browser.h" -#include "image/bitmap.h" struct sslcert_session_data; extern struct sslcert_session_data *ssl_current_session; extern const char *tree_hotlist_path; - -struct hlcache_handle; - /* Tree flags */ enum tree_flags { - TREE_NO_FLAGS = 0, - TREE_NO_DRAGS = 1, - TREE_NO_FURNITURE = 2, - TREE_SINGLE_SELECT = 4, - TREE_NO_SELECT = 8, - TREE_MOVABLE = 16, - TREE_DELETE_EMPTY_DIRS = 32, /**< if the last child of a - * directory is deleted the - * directory will be deleted - * too. - */ - /* The following are to aid transition to new treeviews */ - TREE_HISTORY = 64, - TREE_COOKIES = 128, - TREE_SSLCERT = 256, - TREE_HOTLIST = 512 + TREE_HISTORY, + TREE_COOKIES, + TREE_SSLCERT, + TREE_HOTLIST }; -/** A "flag" value to indicate the element data contains title - * text. This value should be the first node_element in every - * node. All other values should be different than this one. The term - * flag is misused as it is actually a value used by the API consumer - * to indicate teh type of data a node element contains. - */ -#define TREE_ELEMENT_TITLE 0x00 -#define TREE_ELEMENT_LAUNCH_IN_TABS 0x05 /* Launch in tabs instead of windows */ struct tree; -struct node; -struct node_element; typedef enum { TREE_NO_DRAG = 0, @@ -79,45 +53,6 @@ typedef enum { TREE_UNKNOWN_DRAG /** < A drag the tree itself won't handle */ } tree_drag_type; -typedef enum { - NODE_ELEMENT_TEXT, /**< Text only */ - NODE_ELEMENT_TEXT_PLUS_ICON, /**< Text and icon */ - NODE_ELEMENT_BITMAP /**< Bitmap only */ -} node_element_type; - -typedef enum { - NODE_DELETE_ELEMENT_TXT, /**< The text of an element of the - * node is being deleted */ - NODE_DELETE_ELEMENT_IMG, /**< The bitmap or icon of a node is - * being deleted */ - NODE_LAUNCH, /**< The node has been launched */ - NODE_ELEMENT_EDIT_CANCELLED, /**< Editing opperation cancelled. */ - NODE_ELEMENT_EDIT_FINISHING, /**< New text has to be accepted - * or rejected. */ - NODE_ELEMENT_EDIT_FINISHED /**< Editing of a node_element has - * been finished. */ -} node_msg; - -typedef enum { - NODE_CALLBACK_HANDLED, - NODE_CALLBACK_NOT_HANDLED, - NODE_CALLBACK_REJECT, /**< reject new text for node element - * and leave editing mode. */ - NODE_CALLBACK_CONTINUE /**< don't leave editig mode. */ -} node_callback_resp; - -/** Internal node message. */ -struct node_msg_data { - node_msg msg; /**< The type of message. */ - unsigned int flag; /**< message flags. */ - struct node *node; /**< tree node messsage concerns. */ - union { - char *text; /**< textural data. */ - void *bitmap; /**< bitmap data. */ - struct browser_window *bw; /**< clone browser_window. */ - } data; /**< The message data. */ -}; - /** callbacks to perform necessary operations on treeview. */ struct treeview_table { void (*redraw_request)(int x, int y, int width, int height, @@ -128,123 +63,20 @@ struct treeview_table { void (*get_window_dimensions)(int *width, int *height, void *data); /**< get dimensions of window */ }; -/** - * Informs the client about any events requiring his action - * - * \param user_data the user data which was passed at tree creation - * \param msg_data structure containing all the message information - * \return the appropriate node_callback_resp response - */ -typedef node_callback_resp (*tree_node_user_callback)(void *user_data, - struct node_msg_data *msg_data); - -/* Non-platform specific code */ - -void tree_set_icon_dir(char *icon_dir); -void tree_setup_colours(void); - -/* Functions for creating/deleting tree primitives and for tree structure - manipulation */ struct tree *tree_create(unsigned int flags, const struct treeview_table *callbacks, void *client_data); -/** - * Creates a folder node with the specified title, and optionally links it into - * the tree. - * - * \param tree the owner tree of 'parent', may be NULL - * \param parent the parent node, or NULL not to link - * \param title the node title - * \param editable if true, the node title will be editable - * \param retain_in_memory if true, the node will stay in memory after deletion - * \param deleted if true, the node is created with the deleted flag - * \return the newly created node or NULL on error. - */ -struct node *tree_create_folder_node(struct tree *tree, struct node *parent, - const char *title, bool editable, bool retain_in_memory, - bool deleted); - -/** - * Creates a leaf node with the specified title, and optionally links it into - * the tree. - * - * \param tree the owner tree of 'parent', may be NULL - * \param parent the parent node, or NULL not to link - * \param title the node title. - * \param editable if true, the node title will be editable - * \param retain_in_memory if true, the node will stay in memory after deletion - * \param deleted if true, the node is created with the deleted flag - * \return the newly created node or NULL on error. - */ -struct node *tree_create_leaf_node(struct tree *tree, struct node *parent, - const char *title, bool editable, bool retain_in_memory, - bool deleted); - -struct node_element *tree_create_node_element(struct node *parent, - node_element_type type, unsigned int flag, bool editable); -void tree_link_node(struct tree *tree, struct node *link, struct node *node, - bool before); -void tree_delink_node(struct tree *tree, struct node *node); void tree_delete(struct tree *tree); -void tree_delete_node(struct tree *tree, struct node *node, bool siblings); - -/* setters and getters for properties and data */ -void tree_set_node_icon(struct tree *tree, struct node *node, - struct hlcache_handle *icon); -void tree_set_node_expanded(struct tree *tree, struct node *node, bool expanded, - bool folder, bool leaf); -void tree_set_node_selected(struct tree *tree, struct node *node, bool all, - bool selected); -void tree_set_node_selected_at(struct tree *tree, int x, int y, bool selected); -void tree_set_node_sort_function(struct tree *tree, struct node *node, - int (*sort) (struct node *, struct node *)); -void tree_set_node_user_callback(struct node *node, - tree_node_user_callback callback, void *data); -void tree_set_redraw(struct tree *tree, bool redraw); -bool tree_get_redraw(struct tree *tree); -bool tree_node_has_selection(struct node *node); -bool tree_node_is_deleted(struct node *node); -bool tree_node_is_folder(struct node *node); -bool tree_node_is_default(struct node *node); -void tree_update_node_element(struct tree *tree, struct node_element *element, - const char *text, void *bitmap); -bool tree_update_element_text(struct tree *tree, struct node_element *element, char *text); -const char *tree_node_element_get_text(struct node_element *element); -struct bitmap *tree_node_element_get_icon(struct node_element *element); -struct node *tree_get_root(struct tree *tree); -bool tree_is_edited(struct tree *tree); tree_drag_type tree_drag_status(struct tree *tree); - -struct node *tree_get_default_folder_node(struct tree *tree); -bool tree_set_default_folder_node(struct tree *tree, struct node *node); -void tree_clear_default_folder_node(struct tree *tree); - -/* functions for traversing the tree */ -struct node *tree_node_get_parent(struct node *node); -struct node *tree_node_get_child(struct node *node); -struct node *tree_node_get_next(struct node *node); - void tree_draw(struct tree *tree, int x, int y, int clip_x, int clip_y, int clip_width, int clip_height, const struct redraw_context *ctx); - -struct node_element *tree_node_find_element(struct node *node, - unsigned int flag, struct node_element *after); -void tree_delete_selected_nodes(struct tree *tree, struct node *node); -struct node *tree_get_selected_node(struct node *node); -struct node *tree_get_link_details(struct tree *tree, int x, int y, - bool *before); -void tree_launch_selected(struct tree *tree, bool tabs); - bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x, int y); void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0, int x1, int y1); bool tree_keypress(struct tree *tree, uint32_t key); -int tree_alphabetical_sort(struct node *, struct node *); -void tree_start_edit(struct tree *tree, struct node_element *element); -struct hlcache_handle *tree_load_icon(const char *name); #endif |