Enlightenment CVS committal
Author : dj2
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src
Modified Files:
Ewl.h.in ewl_border.c ewl_border.h
Log Message:
- make the border code use the box code
- allow the tabs to be positioned and aligned
- put the _text calls into the header
- add a destroy callback to delete the label and body on destroy
- add a border test case
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/Ewl.h.in,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- Ewl.h.in 11 Nov 2004 05:56:33 -0000 1.8
+++ Ewl.h.in 9 Dec 2004 01:43:33 -0000 1.9
@@ -308,8 +308,8 @@
#include <ewl_misc.h>
-#include <ewl_border.h>
#include <ewl_box.h>
+#include <ewl_border.h>
#include <ewl_cell.h>
#include <ewl_row.h>
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_border.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_border.c 20 Aug 2004 16:35:10 -0000 1.5
+++ ewl_border.c 9 Dec 2004 01:43:34 -0000 1.6
@@ -12,8 +12,9 @@
DENTER_FUNCTION(DLEVEL_STABLE);
b = NEW(Ewl_Border, 1);
- if (!b)
- return NULL;
+ if (!b) {
+ DRETURN_PTR(NULL, DLEVEL_STABLE);
+ }
ewl_border_init(b, label);
@@ -35,31 +36,28 @@
w = EWL_WIDGET(b);
- if (!ewl_container_init(EWL_CONTAINER(w), "border"))
+ if (!ewl_box_init(EWL_BOX(w), EWL_ORIENTATION_VERTICAL)) {
DRETURN_INT(FALSE, DLEVEL_STABLE);
-
- ewl_container_show_notify_set(EWL_CONTAINER(w),
- ewl_border_child_size_cb);
- ewl_container_resize_notify_set(EWL_CONTAINER(w),
-
(Ewl_Child_Resize)ewl_border_child_size_cb);
-
+ }
ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_FILL);
b->label = ewl_text_new(label);
+ ewl_widget_internal_set(b->label, TRUE);
ewl_container_child_append(EWL_CONTAINER(b), b->label);
ewl_widget_show(b->label);
- b->box = ewl_vbox_new();
- ewl_container_child_append(EWL_CONTAINER(b), b->box);
- ewl_widget_show(b->box);
+ b->body = ewl_vbox_new();
+ ewl_widget_internal_set(b->body, TRUE);
+ ewl_container_child_append(EWL_CONTAINER(b), b->body);
+ ewl_widget_show(b->body);
- ewl_container_redirect_set(EWL_CONTAINER(b), EWL_CONTAINER(b->box));
+ b->label_position = EWL_POSITION_LEFT;
- /*
- * Attach necessary callback mechanisms
- */
- ewl_callback_append(w, EWL_CALLBACK_CONFIGURE,
- ewl_border_configure_cb, NULL);
+ ewl_container_redirect_set(EWL_CONTAINER(b), EWL_CONTAINER(b->body));
+ ewl_widget_appearance_set(EWL_WIDGET(b), "border");
+
+ ewl_callback_append(EWL_WIDGET(b), EWL_CALLBACK_DESTROY,
+ ewl_border_destroy_cb, NULL);
DRETURN_INT(TRUE, DLEVEL_STABLE);
}
@@ -99,39 +97,115 @@
DRETURN_PTR(ewl_text_text_get(EWL_TEXT(b->label)), DLEVEL_STABLE);
}
-/*
- * Layout the text and box within the border widget.
+/**
+ * @param b: The Ewl_Border to set the label position on
+ * @param pos: The Ewl_Position to set on for the label.
+ * @return Returns no value.
+ * @brief Sets the position of the lable in the border container
*/
-void ewl_border_configure_cb(Ewl_Widget * w, void *ev_data, void *user_data)
+void
+ewl_border_label_position_set(Ewl_Border *b, Ewl_Position pos)
{
- Ewl_Border *b;
- int yy, hh;
-
DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("b", b);
- b = EWL_BORDER(w);
- ewl_object_place(EWL_OBJECT(b->label), CURRENT_X(w),
- CURRENT_Y(w), CURRENT_W(b), CURRENT_H(b));
- hh = ewl_object_current_h_get(EWL_OBJECT(w));
- yy = CURRENT_Y(w) + hh;
- hh = CURRENT_H(w) - hh;
+ if (b->label_position == pos) {
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+ }
+
+ b->label_position = pos;
+ switch (b->label_position) {
+ case EWL_POSITION_LEFT:
+ case EWL_POSITION_RIGHT:
+ ewl_box_orientation_set(EWL_BOX(b),
+ EWL_ORIENTATION_HORIZONTAL);
+ break;
+
+ case EWL_POSITION_TOP:
+ case EWL_POSITION_BOTTOM:
+ default:
+ ewl_box_orientation_set(EWL_BOX(b),
+ EWL_ORIENTATION_VERTICAL);
+ break;
+ }
+ ewl_container_child_remove(EWL_CONTAINER(b), b->label);
+
+ /* need to remove the redirect so the label gets added back into the
+ * border and not into the body. We put the redirect back on after
+ */
+ ewl_container_redirect_set(EWL_CONTAINER(b), NULL);
+ if ((b->label_position == EWL_POSITION_LEFT)
+ || (b->label_position == EWL_POSITION_TOP))
+ ewl_container_child_prepend(EWL_CONTAINER(b), b->label);
+ else
+ ewl_container_child_append(EWL_CONTAINER(b), b->label);
- ewl_object_place(EWL_OBJECT(b->box), CURRENT_X(w), yy, CURRENT_W(w),
- hh);
+ ewl_container_redirect_set(EWL_CONTAINER(b), EWL_CONTAINER(b->body));
+ ewl_widget_configure(EWL_WIDGET(b));
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
-void
-ewl_border_child_size_cb(Ewl_Container * c, Ewl_Widget * w)
+/**
+ * @param b: The Ewl_Border to get the label position from
+ * @return Returns the Ewl_Position setting of the label on this border
+ */
+Ewl_Position
+ewl_border_label_position_get(Ewl_Border *b)
{
- Ewl_Border *b;
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR_RET("b", b, EWL_POSITION_LEFT);
+ DRETURN_INT(b->label_position, DLEVEL_STABLE);
+}
+
+/**
+ * @param b: The Ewl_Border to set the alignment on
+ * @param align: The alignment to set on the label
+ * @return Retruns no value
+ * @brief alters the alignment setting of the label on the border
+ */
+void
+ewl_border_label_alignment_set(Ewl_Border *b, unsigned int align)
+{
DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("b", b);
- b = EWL_BORDER(c);
- ewl_container_largest_prefer(c, EWL_ORIENTATION_HORIZONTAL);
- ewl_container_sum_prefer(c, EWL_ORIENTATION_VERTICAL);
+ ewl_object_alignment_set(EWL_OBJECT(b->label), align);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
+
+/**
+ * @param b: The Ewl_Border to get the alignment from
+ * @return Returns the alignment of the label for the border.
+ * @brief Retruns the alignment setting of the label for this border container
+ */
+unsigned int
+ewl_border_label_alignment_get(Ewl_Border *b)
+{
+ unsigned int align;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+
+ align = ewl_object_alignment_get(EWL_OBJECT(b->label));
+
+ DRETURN_INT(align, DLEVEL_STABLE);
+}
+
+void
+ewl_border_destroy_cb(Ewl_Widget *w, void *ev_data, void *user_data)
+{
+ Ewl_Border *b;
+
+ b = EWL_BORDER(w);
+
+ if (b->label)
+ ewl_widget_destroy(b->label);
+
+ if (b->body)
+ ewl_widget_destroy(b->body);
+}
+
+
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_border.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_border.h 3 May 2004 05:46:12 -0000 1.2
+++ ewl_border.h 9 Dec 2004 01:43:34 -0000 1.3
@@ -31,19 +31,30 @@
*/
struct Ewl_Border
{
- Ewl_Container container; /**< Inherit from Ewl_Container */
+ Ewl_Box box; /**< Inherit from Ewl_Box */
Ewl_Widget *label; /**< Text label for the border */
- Ewl_Widget *box; /**< Box for holding children */
- unsigned int flags; /**< Flags for placing the label */
+ Ewl_Widget *body; /**< Box for holding children */
+ Ewl_Position label_position; /**< Flags for placing the label */
};
Ewl_Widget *ewl_border_new(char *label);
int ewl_border_init(Ewl_Border * b, char *label);
+void ewl_border_text_set(Ewl_Border * b, char *t);
+char *ewl_border_text_get(Ewl_Border * b);
+
+void ewl_border_label_position_set(Ewl_Border *b, Ewl_Position pos);
+Ewl_Position ewl_border_label_position_get(Ewl_Border *b);
+
+void ewl_border_label_alignment_set(Ewl_Border *b,
+ unsigned int align);
+unsigned int ewl_border_label_alignment_get(Ewl_Border *b);
+
/*
* Internally used callbacks.
*/
-void ewl_border_child_size_cb(Ewl_Container *c, Ewl_Widget * w);
-void ewl_border_configure_cb(Ewl_Widget * w, void *ev_data, void *user_data);
+void ewl_border_destroy_cb(Ewl_Widget *w, void *ev_data,
+ void *user_data);
#endif /* __EWL_BORDER_H__ */
+
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs