r7746 paulblokus - /branches/paulblokus/corewidgets/desktop/tree.c

netsurf at semichrome.net netsurf at semichrome.net
Wed Jun 10 22:52:40 BST 2009


Author: paulblokus
Date: Wed Jun 10 16:52:40 2009
New Revision: 7746

URL: http://source.netsurf-browser.org?rev=7746&view=rev
Log:
break too long lines
minor style changes

Modified:
    branches/paulblokus/corewidgets/desktop/tree.c

Modified: branches/paulblokus/corewidgets/desktop/tree.c
URL: http://source.netsurf-browser.org/branches/paulblokus/corewidgets/desktop/tree.c?rev=7746&r1=7745&r2=7746&view=diff
==============================================================================
--- branches/paulblokus/corewidgets/desktop/tree.c (original)
+++ branches/paulblokus/corewidgets/desktop/tree.c Wed Jun 10 16:52:40 2009
@@ -41,7 +41,8 @@
 		int clip_y, int clip_width, int clip_height);
 static struct node_element *tree_create_node_element(struct node *parent,
 		node_element_data data);
-static void tree_delete_node_internal(struct tree *tree, struct node *node, bool siblings);
+static void tree_delete_node_internal(struct tree *tree, struct node *node,
+		bool siblings);
 static int tree_get_node_width(struct node *node);
 static int tree_get_node_height(struct node *node);
 static void tree_handle_selection_area_node(struct tree *tree,
@@ -64,7 +65,8 @@
  *
  * \param tree  the tree to initialise
  */
-void tree_initialise(struct tree *tree) {
+void tree_initialise(struct tree *tree)
+{
 
 	assert(tree);
 
@@ -83,7 +85,8 @@
  *
  * \param root  the root node to update from
  */
-void tree_initialise_nodes(struct tree *tree, struct node *root) {
+void tree_initialise_nodes(struct tree *tree, struct node *root)
+{
 	struct node *node;
 
 	assert(root);
@@ -111,7 +114,8 @@
  * \param expansion	     the request is the result of a node expansion
  */
 void tree_handle_node_changed(struct tree *tree, struct node *node,
-		bool recalculate_sizes, bool expansion) {
+		bool recalculate_sizes, bool expansion)
+{
 	int width, height;
 
 	assert(node);
@@ -130,7 +134,8 @@
 		tree_redraw_area(tree, 0, node->box.y, 16384, 16384);
 	} else {
 		width = (width > node->box.width) ? width : node->box.width;
-		tree_redraw_area(tree, node->box.x, node->box.y, width, node->box.height);
+		tree_redraw_area(tree, node->box.x, node->box.y, width,
+				node->box.height);
 	}
 	if ((recalculate_sizes) || (expansion))
 		tree_recalculate_size(tree);
@@ -144,7 +149,9 @@
  * \param tree	   the tree to redraw
  * \param element  the node element to update
  */
-void tree_handle_node_element_changed(struct tree *tree, struct node_element *element) {
+void tree_handle_node_element_changed(struct tree *tree,
+		struct node_element *element)
+{
 	int width, height;
 
 	assert(element);
@@ -172,7 +179,9 @@
  * \param node		     the node to update
  * \param recalculate_sizes  whether the node elements have changed
  */
-void tree_recalculate_node(struct tree *tree, struct node *node, bool recalculate_sizes) {
+void tree_recalculate_node(struct tree *tree, struct node *node,
+		bool recalculate_sizes)
+{
 	struct node_element *element;
 	int width, height;
 
@@ -194,7 +203,8 @@
 		}
 	} else {
 		if (recalculate_sizes)
-			for (element = &node->data; element; element = element->next)
+			for (element = &node->data; element;
+					element = element->next)
 				tree_recalculate_node_element(element);
 		else
 			tree_recalculate_node_element(&node->data);
@@ -215,7 +225,8 @@
  *
  * \param root  the root node to update from
  */
-void tree_recalculate_node_positions(struct tree *tree, struct node *root) {
+void tree_recalculate_node_positions(struct tree *tree, struct node *root)
+{
 	struct node *parent;
 	struct node *node;
 	struct node *child;
@@ -250,7 +261,8 @@
 					if (element->type == NODE_ELEMENT_TEXT_PLUS_SPRITE) {
 						element->box.x = node->box.x;
 					} else {
-						element->box.x = node->box.x + NODE_INSTEP;
+						element->box.x = node->box.x +
+								NODE_INSTEP;
 					}
 					element->box.y = y;
 					y += element->box.height;
@@ -270,7 +282,8 @@
  * \param node  the node to calculate the height of
  * \return the total width of the node and children
  */
-int tree_get_node_width(struct node *node) {
+int tree_get_node_width(struct node *node)
+{
 	int width = 0;
 	int child_width;
 
@@ -324,7 +337,8 @@
  * \param node	    the node to set all siblings and descendants of
  * \param expanded  the expansion state to set
  */
-void tree_set_node_expanded(struct tree *tree, struct node *node, bool expanded) {
+void tree_set_node_expanded(struct tree *tree, struct node *node, bool expanded)
+{
 	for (; node; node = node->next) {
 		if (node->expanded != expanded) {
 			node->expanded = expanded;
@@ -346,14 +360,16 @@
  * \param leaf	    whether to update leaves
  * \return whether any changes were made
  */
-bool tree_handle_expansion(struct tree *tree, struct node *node, bool expanded, bool folder,
+bool tree_handle_expansion(struct tree *tree, struct node *node, bool expanded,
+		bool folder,
 		bool leaf) {
 	struct node *entry = node;
 	bool redraw = false;
 
 	for (; node; node = node->next) {
 		if ((node->expanded != expanded) && (node != tree->root) &&
-				((folder && (node->folder)) || (leaf && (!node->folder)))) {
+				((folder && (node->folder)) ||
+				(leaf && (!node->folder)))) {
 			node->expanded = expanded;
 			if (node->child)
 				tree_set_node_expanded(tree, node->child, false);
@@ -364,7 +380,8 @@
 			redraw = true;
 		}
 		if ((node->child) && (node->expanded))
-			redraw |= tree_handle_expansion(tree, node->child, expanded, folder, leaf);
+			redraw |= tree_handle_expansion(tree, node->child,
+					expanded, folder, leaf);
 	}
 	if ((entry == tree->root) && (redraw)) {
 		tree_recalculate_node_positions(tree, tree->root);
@@ -383,12 +400,13 @@
  * \param node	    the node to set all siblings and descendants of
  * \param selected  the selection state to set
  */
-void tree_set_node_selected(struct tree *tree, struct node *node, bool selected) {
+void tree_set_node_selected(struct tree *tree, struct node *node, bool selected)
+{
 	for (; node; node = node->next) {
 		if ((node->selected != selected) && (node != tree->root)) {
 			node->selected = selected;
-			tree_redraw_area(tree, node->box.x, node->box.y, node->box.width,
-					node->data.box.height);
+			tree_redraw_area(tree, node->box.x, node->box.y,
+					node->box.width, node->data.box.height);
 		}
 		if ((node->child) && (node->expanded))
 			tree_set_node_selected(tree, node->child, selected);
@@ -438,7 +456,8 @@
 			if (node->expanded) {
 				for (element = &node->data; element;
 						element = element->next) {
-					if ((element->box.x < x) && (element->box.y < y) &&
+					if ((element->box.x < x) &&
+							(element->box.y < y) &&
 							(element->box.x + element->box.width >= x) &&
 							(element->box.y + element->box.height >= y))
 						return element;
@@ -459,8 +478,8 @@
 		}
 
 		if ((node->child) && (node->expanded) &&
-				((element = tree_get_node_element_at(node->child, x, y,
-				furniture))))
+				((element = tree_get_node_element_at(
+						node->child, x, y, furniture))))
 			return element;
 	}
 	return NULL;
@@ -474,7 +493,9 @@
  * \param user_type  the user_type to check for
  * \return the corresponding element
  */
-struct node_element *tree_find_element(struct node *node, node_element_data data) {
+struct node_element *tree_find_element(struct node *node,
+		node_element_data data)
+{
 	struct node_element *element;
 	for (element = &node->data; element; element = element->next)
 		if (element->data == data) return element;
@@ -489,7 +510,9 @@
  * \param link	  the node to link before/as a child (folders) or before/after (link)
  * \param before  whether to link siblings before or after the supplied node
  */
-void tree_move_selected_nodes(struct tree *tree, struct node *destination, bool before) {
+void tree_move_selected_nodes(struct tree *tree, struct node *destination,
+		bool before)
+{
 	struct node *link;
 	struct node *test;
 	bool error;
@@ -497,7 +520,8 @@
 	tree_clear_processing(tree->root);
 	tree_selected_to_processing(tree->root);
 
-	/* the destination node cannot be a child of any node with the processing flag set */
+	/* the destination node cannot be a child of any node with
+	   the processing flag set */
 	error = destination->processing;
 	for (test = destination; test; test = test->parent)
 		error |= test->processing;
@@ -556,8 +580,8 @@
  * \param first   whether to always link after the supplied node (ie not inside of folders)
  * \return the node moved
  */
-struct node *tree_move_processing_node(struct node *node, struct node *link, bool before,
-		bool first)
+struct node *tree_move_processing_node(struct node *node, struct node *link,
+		bool before, bool first)
 {
 	struct node *result;
 
@@ -574,7 +598,8 @@
 	  		return node;
 	  	}
 		if (node->child) {
-		  	result = tree_move_processing_node(node->child, link, before, first);
+		  	result = tree_move_processing_node(node->child, link,
+					before, first);
 		  	if (result)
 		  		return result;
 		}
@@ -587,7 +612,8 @@
  *
  * \param node  the root node to check from
  */
-bool tree_has_selection(struct node *node) {
+bool tree_has_selection(struct node *node)
+{
 	for (; node; node = node->next) {
 		if (node->selected)
 			return true;
@@ -609,8 +635,9 @@
  * \param height  the height of the selection rectangle
  * \param invert  whether to invert the selected state
  */
-void tree_handle_selection_area(struct tree *tree, int x, int y, int width, int height,
-		bool invert) {
+void tree_handle_selection_area(struct tree *tree, int x, int y, int width,
+		int height, bool invert)
+{
 	assert(tree);
 	assert(tree->root);
 
@@ -640,8 +667,9 @@
  * \param height  the height of the selection rectangle
  * \param invert  whether to invert the selected state
  */
-void tree_handle_selection_area_node(struct tree *tree, struct node *node, int x, int y,
-		int width, int height, bool invert) {
+void tree_handle_selection_area_node(struct tree *tree, struct node *node,
+		int x, int y, int width, int height, bool invert)
+{
 
 	struct node_element *element;
 	struct node *update;
@@ -677,10 +705,12 @@
 			if ((update) && (node != tree->root)) {
 				if (invert) {
 					node->selected = !node->selected;
-					tree_handle_node_element_changed(tree, &node->data);
+					tree_handle_node_element_changed(tree,
+							&node->data);
 				} else if (!node->selected) {
 					node->selected = true;
-					tree_handle_node_element_changed(tree, &node->data);
+					tree_handle_node_element_changed(tree,
+							&node->data);
 				}
 			}
 		}
@@ -724,8 +754,8 @@
  * \param clip_width   the width of the clipping rectangle
  * \param clip_height  the height of the clipping rectangle
  */
-void tree_draw_node(struct tree *tree, struct node *node, int clip_x, int clip_y,
-		int clip_width, int clip_height) {
+void tree_draw_node(struct tree *tree, struct node *node, int clip_x,
+		int clip_y, int clip_width, int clip_height) {
 
 	struct node_element *element;
 	int x_max, y_max;
@@ -789,7 +819,9 @@
  * \param before  set to whether the node should be linked before on exit
  * \return the node to link with
  */
-struct node *tree_get_link_details(struct tree *tree, int x, int y, bool *before) {
+struct node *tree_get_link_details(struct tree *tree, int x, int y,
+		bool *before)
+{
 	struct node *node = NULL;
 	bool furniture;
 
@@ -819,7 +851,8 @@
  * \param node	  the node to link
  * \param before  whether to link siblings before or after the supplied node
  */
-void tree_link_node(struct node *link, struct node *node, bool before) {
+void tree_link_node(struct node *link, struct node *node, bool before)
+{
 	
 	struct node *parent;
 	bool sort = false;
@@ -876,7 +909,8 @@
  *
  * \param node  the node to delink
  */
-void tree_delink_node(struct node *node) {
+void tree_delink_node(struct node *node)
+{
 	assert(node);
 
 	if (node->parent) {
@@ -906,7 +940,8 @@
  * \param tree  the tree to delete from
  * \param node  the node to delete
  */
-void tree_delete_selected_nodes(struct tree *tree, struct node *node) {
+void tree_delete_selected_nodes(struct tree *tree, struct node *node)
+{
 	struct node *next;
 
 	while (node) {
@@ -927,7 +962,8 @@
  * \param node	    the node to delete
  * \param siblings  whether to delete all siblings
  */
-void tree_delete_node(struct tree *tree, struct node *node, bool siblings) {
+void tree_delete_node(struct tree *tree, struct node *node, bool siblings)
+{
 	tree_delete_node_internal(tree, node, siblings);
 	if (tree->root)
 		tree_recalculate_node_positions(tree, tree->root);
@@ -943,7 +979,9 @@
  * \param node	    the node to delete
  * \param siblings  whether to delete all siblings
  */
-void tree_delete_node_internal(struct tree *tree, struct node *node, bool siblings) {
+void tree_delete_node_internal(struct tree *tree, struct node *node,
+		bool siblings)
+{
 	struct node *next, *child;
 	struct node_element *e, *f, *domain, *path;
 	const char *domain_t, *path_t, *name_t;
@@ -1035,7 +1073,8 @@
  * \param title	  the node title (copied)
  * \return the newly created node.
  */
-struct node *tree_create_folder_node(struct node *parent, const char *title) {
+struct node *tree_create_folder_node(struct node *parent, const char *title)
+{
 	struct node *node;
 
 	assert(title);
@@ -1064,7 +1103,8 @@
  * \param title	  the node title (copied)
  * \return the newly created node.
  */
-struct node *tree_create_leaf_node(struct node *parent, const char *title) {
+struct node *tree_create_leaf_node(struct node *parent, const char *title)
+{
 	struct node *node;
 
 	assert(title);
@@ -1091,7 +1131,9 @@
  * \param title	  the node title
  * \return the newly created node.
  */
-struct node *tree_create_leaf_node_shared(struct node *parent, const char *title) {
+struct node *tree_create_leaf_node_shared(struct node *parent,
+		const char *title)
+{
 	struct node *node;
 
 	assert(title);
@@ -1121,9 +1163,8 @@
  * \param title	     the custom title to use
  * \return the node created, or NULL for failure
  */
-struct node *tree_create_URL_node(struct node *parent,
-		const char *url, const struct url_data *data,
-		const char *title) {
+struct node *tree_create_URL_node(struct node *parent, const char *url,
+		const struct url_data *data, const char *title) {
 	struct node *node;
 	struct node_element *element;
 
@@ -1159,7 +1200,8 @@
  * \return the node created, or NULL for failure
  */
 struct node *tree_create_URL_node_shared(struct node *parent,
-		const char *url, const struct url_data *data) {
+		const char *url, const struct url_data *data)
+{
 	struct node *node;
 	struct node_element *element;
 	const char *title;
@@ -1225,7 +1267,8 @@
 	element = tree_create_node_element(node, TREE_ELEMENT_VERSION);
 	if (element) {
 	  	snprintf(buffer2, 16, "TreeVersion%i", data->version);
-		snprintf(buffer, 256, messages_get("TreeVersion"), messages_get(buffer2));
+		snprintf(buffer, 256, messages_get("TreeVersion"),
+				messages_get(buffer2));
 		element->text = strdup(buffer);
 	}
 	element = tree_create_node_element(node, TREE_ELEMENT_SECURE);
@@ -1294,7 +1337,9 @@
  * \param user_type  the required user_type
  * \return the newly created element.
  */
-struct node_element *tree_create_node_element(struct node *parent, node_element_data data) {
+struct node_element *tree_create_node_element(struct node *parent,
+		node_element_data data)
+{
 	struct node_element *element;
 
 	element = calloc(sizeof(struct node_element), 1);
@@ -1313,7 +1358,8 @@
  *
  * \param tree  the tree to recalculate
  */
-void tree_recalculate_size(struct tree *tree) {
+void tree_recalculate_size(struct tree *tree)
+{
 	int width, height;
 
 	assert(tree);
@@ -1339,7 +1385,8 @@
  * \param node  the node to search sibling and children
  * \return the selected node, or NULL if multiple nodes are selected
  */
-struct node *tree_get_selected_node(struct node *node) {
+struct node *tree_get_selected_node(struct node *node)
+{
 	struct node *result = NULL;
 	struct node *temp;
 
@@ -1382,7 +1429,8 @@
 		plot.rectangle(x , y, 8, 8, 0, 0x000000, false, false);
 		plot.line(x + 2, y + 4, x + 6, y + 4, 1, 0x000000, false, false);
 		if (!node->expanded)
-			plot.line(x + 4, y + 2, x + 4, y + 6, 1, 0x000000, false, false);
+			plot.line(x + 4, y + 2, x + 4, y + 6, 1, 0x000000,
+				  	false, false);
 
 	}
 	
@@ -1528,14 +1576,15 @@
 				element->box.width += NODE_INSTEP;
 			break;
 		case NODE_ELEMENT_THUMBNAIL:
-			url_element = tree_find_element(element->parent, TREE_ELEMENT_URL);
+			url_element = tree_find_element(element->parent,
+					TREE_ELEMENT_URL);
 			if (url_element)
 				bitmap = urldb_get_thumbnail(url_element->text);
 			if (bitmap) {
 /*				if ((bitmap->width == 0) && (bitmap->height == 0))
 					frame = bitmap_get_buffer(bitmap);
-				element->box.width = bitmap->width * 2 + 2;
-				element->box.height = bitmap->height * 2 + 4;
+				element->box.width = bitmap->width * 2 + 1;
+				element->box.height = bitmap->height * 2 + 2;
 */				element->box.width = THUMBNAIL_WIDTH + 1;
 				element->box.height = THUMBNAIL_HEIGHT + 2;
 			} else {
@@ -1590,7 +1639,9 @@
 		 as a content*/
 		//assert(element->bitmap);
 			if (element->bitmap)
-				content_redraw(element->bitmap, x0, y0 + 3, 16, 16, x0, y0, x0 + 16, y0 + 16, 1, 0);
+				content_redraw(element->bitmap, x0, y0 + 3, 16,
+						16, x0, y0, x0 + 16, y0 + 16, 1,
+      						0);
 			x0 += NODE_INSTEP;
 
 			/* fall through */
@@ -1612,13 +1663,16 @@
      					strlen(element->text), bg, c);
 			break;
 		case NODE_ELEMENT_THUMBNAIL:
-			url_element = tree_find_element(element->parent, TREE_ELEMENT_URL);
+			url_element = tree_find_element(element->parent,
+					TREE_ELEMENT_URL);
 			if (url_element)
 				bitmap = urldb_get_thumbnail(url_element->text);
 			if (bitmap) {
-				frame = bitmap_get_buffer((struct bitmap *) bitmap);
+				frame = bitmap_get_buffer(
+						(struct bitmap *) bitmap);
 				if (!frame)
-					urldb_set_thumbnail(url_element->text, NULL);
+					urldb_set_thumbnail(url_element->text,
+							NULL);
 				if ((!frame) || (element->box.width == 0)) {
 					update = calloc(sizeof(struct node_update), 1);
 					if (!update)
@@ -1642,10 +1696,12 @@
        							0,
        							element->box.height - 3);
 					tree_draw_line(element->box.x,
-							element->box.y + element->box.height - 3,
+							element->box.y +
+							element->box.height - 3,
        							element->box.width - 1,
        							0);
-					tree_draw_line(element->box.x + element->box.width - 1,
+					tree_draw_line(element->box.x +
+							element->box.width - 1,
 							element->box.y,
        							0,
        							element->box.height - 3);
@@ -1729,7 +1785,8 @@
  * \param tree	   the tree to handle a click for
  * \return whether the click was handled
  */
-bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x, int y)
+bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
+		int y)
 {
 	bool furniture;
 	struct node *node;
@@ -1798,7 +1855,8 @@
 		last = node;
 		if ((last->child) && (last->expanded)) {
 			last = last->child;
-			while ((last->next) || ((last->child) && (last->expanded))) {
+			while ((last->next) ||
+					((last->child) && (last->expanded))) {
 				if (last->next)
 					last = last->next;
 				else




More information about the netsurf-commits mailing list