1 #include <Elementary.h>
5 * @defgroup Dayselector Dayselector
10 * Signals that you can add callbacks for are:
12 * dayselector,changed - This is called whenever the user changes the state of one of the check object.
16 typedef struct _Widget_Data Widget_Data;
22 Evas_Object *check[7];
25 static const char *widtype = NULL;
26 static void _del_hook(Evas_Object *obj);
27 //TODO:static void _del_pre_hook(Evas_Object *obj);
28 static void _theme_hook(Evas_Object *obj);
29 //static void _sizing_eval(Evas_Object* obj);
30 //static void _dayselector_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
31 //static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
34 _del_hook(Evas_Object *obj)
36 Widget_Data *wd = (Widget_Data *) elm_widget_data_get(obj);
42 _dayselector_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
48 _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
51 Widget_Data *wd = elm_widget_data_get(obj);
54 edje_object_size_min_get(wd->base, &w, &h);
55 evas_object_size_hint_min_set(obj, w * elm_scale_get(), h * elm_scale_get());
59 _check_clicked(void *data, Evas_Object *obj, void *event_info)
61 static Elm_DaySelector_Day day;
62 Widget_Data* wd = (Widget_Data*) elm_widget_data_get(data);
64 for (idx = 0; idx< 7; ++idx)
66 if (obj==wd->check[idx])
69 evas_object_smart_callback_call(data, "dayselector,changed", (void *) &day);
76 _theme_hook(Evas_Object *obj)
78 char *day_name[] = {"sun", "mon", "tue", "wed", "thu", "fri", "sat" };
81 Widget_Data* wd = (Widget_Data*) elm_widget_data_get(obj);
84 _elm_theme_object_set(obj, wd->base, "dayselector", "base", elm_widget_style_get(obj));
86 for ( idx = 0; idx < 7; ++idx )
88 sprintf(buf, "dayselector/%s_%s", elm_widget_style_get(obj), day_name[idx]);
89 elm_object_style_set(wd->check[idx], buf );
94 * Set the state of given check object.
96 * @param[in] obj Dayselector
97 * @param[in] day day user want to know.
98 * @param[in] checked state of the day. Eina_True is checked.
100 * @ingroup Dayselector
103 elm_dayselector_check_state_set(Evas_Object *obj, Elm_DaySelector_Day day, Eina_Bool checked)
105 ELM_CHECK_WIDTYPE(obj, widtype);
106 Widget_Data* wd = (Widget_Data*) elm_widget_data_get(obj);
108 elm_check_state_set(wd->check[day], checked);
112 * Get the state of given check object.
114 * @param[in] obj Dayselector
115 * @param[in] day day user want to know.
117 * @ingroup Dayselector
120 elm_dayselector_check_state_get(Evas_Object *obj, Elm_DaySelector_Day day)
122 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
123 Widget_Data* wd = (Widget_Data*) elm_widget_data_get(obj);
124 if (!wd) return EINA_FALSE;
125 return elm_check_state_get(wd->check[day]);
129 _sizing_eval(Evas_Object* obj)
132 Evas_Coord min_w, min_h, max_h;
133 Widget_Data *wd = elm_widget_data_get(obj);
136 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
137 edje_object_size_min_get(wd->base, &min_w, &min_h);
138 edje_object_size_max_get(wd->base, NULL, &max_h);
140 fprintf( stderr, "%d %d\n", w, h );
141 if (w < min_w) w = min_w;
142 if (h < min_h) h = min_h;
143 else if (h > max_h) h = max_h;
145 evas_object_resize(wd->base, w, h);
149 * Add the dayselector.
151 * @param[in] parent Parent object.
153 * @ingroup Dayselector
156 elm_dayselector_add(Evas_Object *parent)
162 char *label[] = { "S", "M", "T", "W", "T", "F", "S" };
163 char *day_name[] = { "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
164 char *style_name[] = { "dayselector/sun_first_sun",
165 "dayselector/sun_first_mon",
166 "dayselector/sun_first_tue",
167 "dayselector/sun_first_wed",
168 "dayselector/sun_first_thu",
169 "dayselector/sun_first_fri",
170 "dayselector/sun_first_sat",
172 e = evas_object_evas_get(parent);
174 wd = ELM_NEW(Widget_Data);
175 obj = elm_widget_add(e);
176 ELM_SET_WIDTYPE(widtype, "dayselector");
177 elm_widget_type_set(obj, "dayselector");
178 elm_widget_sub_object_add(parent, obj);
179 elm_widget_data_set(obj, wd);
180 elm_widget_del_hook_set(obj, _del_hook);
181 elm_widget_theme_hook_set(obj, _theme_hook);
184 wd->base = edje_object_add(e);
185 _elm_theme_object_set(obj, wd->base, "dayselector", "base", elm_widget_style_get(obj));
186 elm_object_style_set(wd->base, "dayselector");
187 elm_widget_resize_object_set(obj, wd->base);
189 for (idx=0; idx<7; ++idx)
191 wd->check[idx]=elm_check_add(wd->base);
192 elm_widget_sub_object_add(obj, wd->check[idx]);
193 evas_object_smart_callback_add(wd->check[idx], "changed", _check_clicked, obj);
194 elm_check_label_set(wd->check[idx], label[idx] );
195 edje_object_part_swallow(wd->base, day_name[idx], wd->check[idx]);
196 elm_object_style_set(wd->check[idx], style_name[idx]);
198 //evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _dayselector_resize, wd);
199 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);