Enlightenment CVS committal
Author : dj2
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src/lib
Modified Files:
ewl_datepicker.c ewl_datepicker.h
Log Message:
- rename Ewl_DatePicker to Ewl_Datepicker
- make sure we have an embed before trying to query it's size
- reformat and rearrange
- add typechecking and debug macros as needed
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_datepicker.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_datepicker.c 23 Oct 2005 16:05:37 -0000 1.5
+++ ewl_datepicker.c 23 Oct 2005 18:12:26 -0000 1.6
@@ -3,129 +3,183 @@
#include "ewl_macros.h"
#include "ewl_private.h"
+static void ewl_datepicker_calendar_position_set(Ewl_Datepicker *dp);
+static void ewl_datepicker_dropdown_cb(Ewl_Widget *w, void *ev_data,
+ void *user_data);
+
/**
- * @return Returns NULL on failure, a new Ewl_DatePicker on success
- * @brief Creates a new Ewl_DatePicker
+ * @return Returns NULL on failure, a new Ewl_Datepicker on success
+ * @brief Creates a new Ewl_Datepicker
*/
-Ewl_Widget *ewl_datepicker_new() {
- Ewl_DatePicker* ib;
- DENTER_FUNCTION (DLEVEL_STABLE);
+Ewl_Widget *
+ewl_datepicker_new(void)
+{
+ Ewl_Datepicker *ib;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
- ib = NEW(Ewl_DatePicker, 1);
+ ib = NEW(Ewl_Datepicker, 1);
if (!ib) {
DRETURN_PTR(NULL, DLEVEL_STABLE);
}
if (!ewl_datepicker_init(ib)) {
- DWARNING("Failed datepicker init...\n");
- FREE(ib);
+ ewl_widget_destroy(EWL_WIDGET(ib));
ib = NULL;
}
DRETURN_PTR(EWL_WIDGET(ib), DLEVEL_STABLE);
}
-void ewl_datepicker_calendar_position_set(Ewl_DatePicker* dp) {
- int x,y;
- int sx,sy;
- Ewl_Embed* emb;
+/**
+ * @param db: The Ewl_Datepicker to initialize
+ * @return Returns TRUE on success or FALSE on failure
+ */
+int
+ewl_datepicker_init(Ewl_Datepicker *dp)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR_RET("dp", dp, FALSE);
- /* Get the position of the parent */
- emb = ewl_embed_widget_find(EWL_WIDGET(dp));
- ewl_window_position_get(EWL_WINDOW(emb), &x,&y);
- ewl_object_current_size_get(EWL_OBJECT(dp), &sx,&sy);
- ewl_window_move(EWL_WINDOW(dp->calendar_window), x+(sx/4),y+sy+3);
+ if (!ewl_text_init(EWL_TEXT(dp)))
+ DRETURN_INT(FALSE, DLEVEL_STABLE);
-}
+ ewl_text_text_set(EWL_TEXT(dp), "Date Test");
-void
-ewl_datepicker_destroy_cb (Ewl_Widget *w, void *ev_data __UNUSED__,
- void *user_data __UNUSED__) {
- Ewl_DatePicker* dp = EWL_DATEPICKER(w);
- ewl_widget_destroy(dp->calendar_window);
- ewl_widget_destroy(dp->calendar);
-}
+ /* Init ewl setup */
+ ewl_widget_appearance_set(EWL_WIDGET(dp), "datepicker");
+ ewl_widget_inherit(EWL_WIDGET(dp), "datepicker");
+
+ dp->calendar_window = ewl_window_new();
+ ewl_object_custom_size_set(EWL_OBJECT(dp->calendar_window), 159, 170);
+ ewl_object_fill_policy_set(EWL_OBJECT(dp->calendar_window),
+ EWL_FLAG_FILL_FILL);
+ ewl_widget_layer_set(dp->calendar_window, 1000);
+ ewl_window_borderless_set(EWL_WINDOW(dp->calendar_window));
+
+ dp->calendar = ewl_calendar_new();
+ ewl_container_child_append(EWL_CONTAINER(dp->calendar_window),
+ dp->calendar);
+ ewl_callback_append(EWL_WIDGET(dp->calendar),
+ EWL_CALLBACK_VALUE_CHANGED,
+ ewl_datepicker_value_changed_cb, dp);
+ ewl_widget_show(dp->calendar);
-void
-ewl_datepicker_dropdown(Ewl_Widget *w, void *ev_data __UNUSED__,
- void *user_data __UNUSED__) {
-
- Ewl_DatePicker *dp = EWL_DATEPICKER(w);
- /*printf("Drop down..\n");*/
- ewl_widget_show(dp->calendar_window);
- ewl_window_raise(EWL_WINDOW(dp->calendar_window));
ewl_datepicker_calendar_position_set(dp);
+
+ ewl_callback_prepend(EWL_WIDGET(dp), EWL_CALLBACK_DESTROY,
+ ewl_datepicker_destroy_cb, dp);
+ ewl_callback_append(EWL_WIDGET(dp), EWL_CALLBACK_CONFIGURE,
+ ewl_datepicker_configure_cb, NULL);
+ ewl_callback_append(EWL_WIDGET(dp), EWL_CALLBACK_MOUSE_DOWN,
+ ewl_datepicker_dropdown_cb, NULL);
+ ewl_callback_call(EWL_WIDGET(dp->calendar), EWL_CALLBACK_VALUE_CHANGED);
- //ewl_container_child_append(EWL_CONTAINER(dp), dp->calendar_window);
+ DRETURN_INT(TRUE, DLEVEL_STABLE);
+}
+void
+ewl_datepicker_destroy_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
+ void *user_data __UNUSED__)
+{
+ Ewl_Datepicker *dp;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
+ dp = EWL_DATEPICKER(w);
+ ewl_widget_destroy(dp->calendar_window);
+ ewl_widget_destroy(dp->calendar);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
}
void
ewl_datepicker_configure_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
- void *user_data __UNUSED__) {
+ void *user_data __UNUSED__)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
+
ewl_datepicker_calendar_position_set(EWL_DATEPICKER(w));
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
}
void
ewl_datepicker_value_changed_cb(Ewl_Widget *w __UNUSED__, void *ev_data
__UNUSED__,
- void *user_data) {
+ void *user_data)
+{
static char date[1024];
- Ewl_DatePicker* dp = EWL_DATEPICKER(user_data);
+ Ewl_Datepicker* dp;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("user_data", user_data);
+
+ dp = EWL_DATEPICKER(user_data);
ewl_widget_hide(dp->calendar_window);
ewl_calendar_ascii_time_get(EWL_CALENDAR(dp->calendar), date);
ewl_text_text_set(EWL_TEXT(dp), date);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
}
-void ewl_datepicker_realize_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
- void *user_data __UNUSED__) {
+void
+ewl_datepicker_realize_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
+ void *user_data __UNUSED__)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
+
ewl_datepicker_calendar_position_set(EWL_DATEPICKER(w));
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
}
-int ewl_datepicker_init(Ewl_DatePicker* dp) {
- Ewl_Widget* w ;
-
- w = EWL_WIDGET(dp);
-
- if (!ewl_text_init(EWL_TEXT(dp)))
- DRETURN_INT(FALSE, DLEVEL_STABLE);
+static void
+ewl_datepicker_calendar_position_set(Ewl_Datepicker *dp)
+{
+ int x, y;
+ int sx, sy;
+ Ewl_Embed *emb;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("dp", dp);
+ DCHECK_TYPE("dp", dp, "datepicker");
- ewl_text_text_set(EWL_TEXT(dp), "Date Test");
+ /* Get the position of the parent */
+ emb = ewl_embed_widget_find(EWL_WIDGET(dp));
+ if (emb) {
+ ewl_window_position_get(EWL_WINDOW(emb), &x, &y);
+ ewl_object_current_size_get(EWL_OBJECT(dp), &sx, &sy);
+ ewl_window_move(EWL_WINDOW(dp->calendar_window), x + (sx / 4),
+ y + sy + 3);
+ }
- /* Init ewl setup */
- ewl_widget_appearance_set(EWL_WIDGET(w), "datepicker");
- ewl_widget_inherit(EWL_WIDGET(w), "datepicker");
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
- ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN,
ewl_datepicker_dropdown, NULL);
- dp->calendar = NULL;
- dp->calendar_window = NULL;
-
-
- dp->calendar_window = ewl_window_new();
- dp->calendar = ewl_calendar_new();
- ewl_object_custom_size_set(EWL_OBJECT(dp->calendar_window), 159, 170);
- ewl_object_fill_policy_set(EWL_OBJECT(dp->calendar_window),
EWL_FLAG_FILL_FILL);
- ewl_container_child_append(EWL_CONTAINER(dp->calendar_window),
dp->calendar);
- ewl_window_borderless_set(EWL_WINDOW(dp->calendar_window));
- /*ewl_widget_internal_set(dp->calendar_window, TRUE);*/
- ewl_widget_layer_set(dp->calendar_window, 1000);
+static void
+ewl_datepicker_dropdown_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
+ void *user_data __UNUSED__)
+{
+ Ewl_Datepicker *dp;
- ewl_callback_append(EWL_WIDGET(dp), EWL_CALLBACK_CONFIGURE,
- ewl_datepicker_configure_cb, NULL);
- ewl_widget_show(dp->calendar);
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
+ dp = EWL_DATEPICKER(w);
+ ewl_widget_show(dp->calendar_window);
+ ewl_window_raise(EWL_WINDOW(dp->calendar_window));
ewl_datepicker_calendar_position_set(dp);
- /*ewl_widget_show(dp->calendar_window);
- ewl_widget_hide(dp->calendar_window);*/
- ewl_callback_append(EWL_WIDGET(dp->calendar),
EWL_CALLBACK_VALUE_CHANGED, ewl_datepicker_value_changed_cb, dp);
- ewl_callback_append(EWL_WIDGET(dp), EWL_CALLBACK_DESTROY,
ewl_datepicker_destroy_cb, dp);
- ewl_callback_call(EWL_WIDGET(dp->calendar), EWL_CALLBACK_VALUE_CHANGED);
-
-
- DRETURN_INT(TRUE, DLEVEL_STABLE);
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_datepicker.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ewl_datepicker.h 9 Oct 2005 05:18:39 -0000 1.2
+++ ewl_datepicker.h 23 Oct 2005 18:12:26 -0000 1.3
@@ -1,12 +1,10 @@
#ifndef __EWL_DATEPICKER_H__
#define __EWL_DATEPICKER_H__
-
-
/**
* @file ewl_datepicker.h
- * @defgroup Ewl_DatePicker datepicker: The EWL Datepicker widget
- * @brief Defines the Ewl_DatePicker class,
+ * @defgroup Ewl_Datepicker datepicker: The EWL Datepicker widget
+ * @brief Defines the Ewl_Datepicker class,
*
*/
@@ -15,21 +13,20 @@
* @themekey /datepicker/group
*/
-
-typedef struct Ewl_DatePicker Ewl_DatePicker;
+typedef struct Ewl_Datepicker Ewl_Datepicker;
/**
* @def EWL_DATEPICKER(datepicker)
- * Typecast a pointer to an Ewl_DatePicker pointer
+ * Typecast a pointer to an Ewl_Datepicker pointer
*/
-#define EWL_DATEPICKER(datepicker) ((Ewl_DatePicker *) datepicker)
+#define EWL_DATEPICKER(datepicker) ((Ewl_Datepicker *) datepicker)
/**
- * @struct Ewl_DatePicker
+ * @struct Ewl_Datepicker
* Inherits from an Ewl_Text
*
*/
-struct Ewl_DatePicker
+struct Ewl_Datepicker
{
Ewl_Text text; /**< Inherit from Ewl_Text */
@@ -38,9 +35,19 @@
};
-
Ewl_Widget *ewl_datepicker_new(void);
-int ewl_datepicker_init(Ewl_DatePicker* datepicker);
+int ewl_datepicker_init(Ewl_Datepicker* datepicker);
+/*
+ * Internally used callbacks, override at your risk
+ */
+void ewl_datepicker_destroy_cb(Ewl_Widget *w, void *ev_data,
+ void *user_data);
+void ewl_datepicker_configure_cb(Ewl_Widget *w, void *ev_data,
+ void *user_data);
+void ewl_datepicker_value_changed_cb(Ewl_Widget *w, void *ev_data,
+ void *user_data);
+void ewl_datepicker_realize_cb(Ewl_Widget *w, void *ev_data,
+ void *user_data);
#endif
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs