summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordivyesh purohit <div.purohit@samsung.com>2016-01-06 10:57:29 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-01-06 10:58:00 -0800
commit52e13710a3bdcfb3fcf79d6fc9212aa41b1e2e3e (patch)
treecbcccb3b5c6e576c4609384185e72e4a41ca20d8
parent7a2a98094aa278996c0f0bcfebcdbf2e005b55ca (diff)
combobox: add documentation and example
Summary: Added Documentation for Combobox Widget Signed-off-by: divyesh purohit <div.purohit@samsung.com> Test Plan: execute make doc Reviewers: shilpasingh, cedric Subscribers: rajeshps, govi Differential Revision: https://phab.enlightenment.org/D3539 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--doc/Makefile.am2
-rw-r--r--doc/examples.dox68
-rw-r--r--doc/index.doxy4
-rw-r--r--doc/widgets/Makefile.am2
-rw-r--r--doc/widgets/widget_preview_combobox.c48
-rw-r--r--src/examples/Makefile.am3
-rw-r--r--src/examples/combobox_example_01.c155
-rw-r--r--src/lib/elc_combobox.h14
8 files changed, 289 insertions, 7 deletions
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 953809c74..a4461b7c2 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -26,6 +26,7 @@ WGT_PREVIEW = \
26 clock:preview-00.png:widget_preview_clock:200:100 \ 26 clock:preview-00.png:widget_preview_clock:200:100 \
27 colorselector:preview-00.png:widget_preview_colorselector:320:300 \ 27 colorselector:preview-00.png:widget_preview_colorselector:320:300 \
28 conformant:preview-00.png:widget_preview_conformant:200:400 \ 28 conformant:preview-00.png:widget_preview_conformant:200:400 \
29 combobox:preview-00.png:widget_preview_combobox:300:300 \
29 ctxpopup:preview-00.png:widget_preview_ctxpopup:200:130 \ 30 ctxpopup:preview-00.png:widget_preview_ctxpopup:200:130 \
30 datetime:preview-00.png:widget_preview_datetime1:360:60 \ 31 datetime:preview-00.png:widget_preview_datetime1:360:60 \
31 datetime:preview-01.png:widget_preview_datetime2:200:60 \ 32 datetime:preview-01.png:widget_preview_datetime2:200:60 \
@@ -101,6 +102,7 @@ WGT_TREE = \
101 colorselector \ 102 colorselector \
102 conformant \ 103 conformant \
103 container \ 104 container \
105 combobox \
104 ctxpopup \ 106 ctxpopup \
105 datetime \ 107 datetime \
106 dayselector \ 108 dayselector \
diff --git a/doc/examples.dox b/doc/examples.dox
index 3d425b1ad..8be745e75 100644
--- a/doc/examples.dox
+++ b/doc/examples.dox
@@ -29,6 +29,8 @@
29 * 29 *
30 * @ref calendar_example_06 30 * @ref calendar_example_06
31 * 31 *
32 * @ref combobox_example_01
33 *
32 * @ref spinner_example 34 * @ref spinner_example
33 * 35 *
34 * @ref slider_example 36 * @ref slider_example
@@ -6810,3 +6812,69 @@
6810 * @example location_example_01.c 6812 * @example location_example_01.c
6811 * @example naviframe_example.c 6813 * @example naviframe_example.c
6812 */ 6814 */
6815
6816/**
6817 * @page tutorial_combobox Combobox example
6818 * @dontinclude combobox_example_01.c
6819 *
6820 * In this example we will create a combobox with 1000 items.
6821 *
6822 * We will start with the normal creation of window stuff:
6823 * @until show(bg)
6824 *
6825 * Next we will create a box.
6826 * @until show(bx)
6827 *
6828 * And now we create our combobox and set some of it's properties. We set @p win
6829 * as its parent, set a text "A Simple List" (which acts as a placeholder).
6830 * We pack the combobox in box.
6831 * @until show(combobox)
6832 *
6833 * Next we create a new genlist item class and sets its properties:
6834 * item_style as deafult , callback for text_get and set others as NULL.
6835 * @until itc->func.del = NULL;
6836
6837 * Next we will append 1000 items to the combobox, this is similar to appending
6838 * items to the genlist
6839 * @until ));
6840 *
6841 * We also set a pair of callbacks to be called whenever any item is selected or
6842 * pressed.
6843 * when the combobox is activated, dismissed, expanded :
6844 * @until _combobox_item_pressed_cb, NULL);
6845 *
6846 * And then ask that our combobox be shown and run the main loop:
6847 * @until ELM_MAIN
6848 *
6849 * We now have the callback for setting text in the each item of genlist:
6850 * @until }
6851 *
6852 * Next we have the callback which is called when the combobox is clicked:
6853 * @until }
6854 *
6855 * Next we have the callback that is called whenever an item is selected and
6856 * text of that item is set on combobox:
6857 * @until }
6858
6859 * Next we have the callback that is called whenever an item is pressed and
6860 * text of that item is set on combobox and the hover is closed:
6861 * @until }
6862 *
6863 * Next we have the callback that is called whenever an item is double-clicked
6864 * or pressing (enter|return|spacebar) on an item also the text(event_info) of that item is set on
6865 * combobox and the hover is closed:
6866 * @until }
6867
6868 * And the callback that is called when the hover,genlist are closed.
6869 * @until }
6870 *
6871 * And finally the callback is called when hover,genlist are shown.
6872 * @until }
6873 *
6874 * Our example will initially look like this:
6875 *
6876 * @image html screenshots/combobox_example_01.png
6877 * @image latex screenshots/combobox_example_01.eps width=\textwidth
6878 *
6879 * @example combobox_example_01.c
6880 */ \ No newline at end of file
diff --git a/doc/index.doxy b/doc/index.doxy
index 8a35ddb84..f20bb0a2c 100644
--- a/doc/index.doxy
+++ b/doc/index.doxy
@@ -77,6 +77,10 @@
77 * 77 *
78 * @image html img/widget/ctxpopup/preview-00.png 78 * @image html img/widget/ctxpopup/preview-00.png
79 * @image latex img/widget/ctxpopup/preview-00.eps 79 * @image latex img/widget/ctxpopup/preview-00.eps
80 * @li @ref Combobox
81 *
82 * @image html img/widget/combobox/preview-00.png
83 * @image latex img/widget/combobox/preview-00.eps
80 * @li @ref Datetime 84 * @li @ref Datetime
81 * 85 *
82 * @image html img/widget/datetime/preview-00.png 86 * @image html img/widget/datetime/preview-00.png
diff --git a/doc/widgets/Makefile.am b/doc/widgets/Makefile.am
index 5cc58f39e..df26c7572 100644
--- a/doc/widgets/Makefile.am
+++ b/doc/widgets/Makefile.am
@@ -37,6 +37,7 @@ widget_preview_check2 \
37widget_preview_check3 \ 37widget_preview_check3 \
38widget_preview_clock \ 38widget_preview_clock \
39widget_preview_colorselector \ 39widget_preview_colorselector \
40widget_preview_combobox \
40widget_preview_conformant \ 41widget_preview_conformant \
41widget_preview_ctxpopup \ 42widget_preview_ctxpopup \
42widget_preview_datetime1 \ 43widget_preview_datetime1 \
@@ -118,6 +119,7 @@ EXTRA_DIST = \
118 widget_preview_clock.c \ 119 widget_preview_clock.c \
119 widget_preview_colorselector.c \ 120 widget_preview_colorselector.c \
120 widget_preview_conformant.c \ 121 widget_preview_conformant.c \
122 widget_preview_combobox.c \
121 widget_preview_slider.c \ 123 widget_preview_slider.c \
122 widget_preview_panes.c \ 124 widget_preview_panes.c \
123 widget_preview_toolbar.c \ 125 widget_preview_toolbar.c \
diff --git a/doc/widgets/widget_preview_combobox.c b/doc/widgets/widget_preview_combobox.c
new file mode 100644
index 000000000..2cde37a5d
--- /dev/null
+++ b/doc/widgets/widget_preview_combobox.c
@@ -0,0 +1,48 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#else
4# define EINA_UNUSED
5#endif
6
7#include <Elementary.h>
8
9static char *
10gl_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
11{
12 char buf[256];
13 snprintf(buf, sizeof(buf), "Item # %i", (int)(uintptr_t)data);
14 return strdup(buf);
15}
16
17unsigned char _func(void *data);
18
19#include "widget_preview_tmpl_head.c"
20
21Evas_Object *combobox = elm_combobox_add(win);
22evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0);
23evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0);
24elm_object_part_text_set(combobox, "guide", "A long list");
25evas_object_resize(combobox, 300, 28);
26evas_object_show(combobox);
27
28Elm_Genlist_Item_Class *itc;
29itc = elm_genlist_item_class_new();
30itc->item_style = "default";
31itc->func.text_get = gl_text_get;
32itc->func.content_get = NULL;
33itc->func.state_get = NULL;
34itc->func.filter_get = NULL;
35itc->func.del = NULL;
36for (int i = 0; i < 1000; i++)
37 elm_genlist_item_append(combobox, itc, (void *)(uintptr_t)i,
38 NULL, ELM_GENLIST_ITEM_NONE, NULL,
39 (void*)(uintptr_t)(i * 10));
40ecore_timer_add(0.05, _func, combobox);
41
42#include "widget_preview_tmpl_foot.c"
43
44unsigned char _func(void *data)
45{
46 elm_combobox_hover_begin(data);
47 return 0;
48}
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am
index 112dbeb0e..24f1dd288 100644
--- a/src/examples/Makefile.am
+++ b/src/examples/Makefile.am
@@ -52,6 +52,7 @@ codegen_example.edc \
52colorselector_example_01.c \ 52colorselector_example_01.c \
53conformant_example_01.c \ 53conformant_example_01.c \
54conformant_example_02.c \ 54conformant_example_02.c \
55combobox_example_01.c \
55ctxpopup_example_01.c \ 56ctxpopup_example_01.c \
56datetime_example.c \ 57datetime_example.c \
57dayselector_example.c \ 58dayselector_example.c \
@@ -237,6 +238,7 @@ codegen_example \
237colorselector_example_01 \ 238colorselector_example_01 \
238conformant_example_01 \ 239conformant_example_01 \
239conformant_example_02 \ 240conformant_example_02 \
241combobox_example_01 \
240ctxpopup_example_01 \ 242ctxpopup_example_01 \
241datetime_example \ 243datetime_example \
242dayselector_example \ 244dayselector_example \
@@ -419,6 +421,7 @@ label_example_01:label_example_01.png:0.0 \
419theme_example_01:theme_example_01.png:0.0 \ 421theme_example_01:theme_example_01.png:0.0 \
420conformant_example_01:conformant_example_01.png:0.0 \ 422conformant_example_01:conformant_example_01.png:0.0 \
421conformant_example_02:conformant_example_02.png:0.0 \ 423conformant_example_02:conformant_example_02.png:0.0 \
424combobox_example_01:combobox_example_01.png:0.0 \
422calendar_example_01:calendar_example_01.png:0.0 \ 425calendar_example_01:calendar_example_01.png:0.0 \
423calendar_example_02:calendar_example_02.png:0.0 \ 426calendar_example_02:calendar_example_02.png:0.0 \
424calendar_example_03:calendar_example_03.png:0.0 \ 427calendar_example_03:calendar_example_03.png:0.0 \
diff --git a/src/examples/combobox_example_01.c b/src/examples/combobox_example_01.c
new file mode 100644
index 000000000..30121ba16
--- /dev/null
+++ b/src/examples/combobox_example_01.c
@@ -0,0 +1,155 @@
1//Compile with:
2//gcc -o combobox_example_01 combobox_example_01.c -g `pkg-config --cflags --libs elementary`
3
4#include <Elementary.h>
5
6static void
7_combobox_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
8 void *event_info EINA_UNUSED)
9{
10 printf("Hover button is clicked and 'clicked' callback is called.\n");
11}
12
13static void
14_combobox_selected_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
15 void *event_info)
16{
17 const char *txt = elm_object_item_text_get(event_info);
18 printf("'selected' callback is called. (selected item : %s)\n", txt);
19}
20
21static void
22_combobox_dismissed_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
23 void *event_info EINA_UNUSED)
24{
25 printf("'dismissed' callback is called.\n");
26}
27
28static void
29_combobox_expanded_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
30 void *event_info EINA_UNUSED)
31{
32 printf("'expanded' callback is called.\n");
33}
34
35static void
36_combobox_item_pressed_cb(void *data EINA_UNUSED, Evas_Object *obj,
37 void *event_info)
38{
39 const char *txt = elm_object_item_text_get(event_info);
40 printf("'item,pressed' callback is called. (selected item : %s)\n", txt);
41 elm_object_text_set(obj, txt);
42 elm_combobox_hover_end(obj);
43}
44
45static char *
46gl_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
47{
48 char buf[256];
49 snprintf(buf, sizeof(buf), "Item # %i", (int)(uintptr_t)data);
50 return strdup(buf);
51}
52
53static Evas_Object *gl_content_get(void *data EINA_UNUSED, Evas_Object *obj,
54 const char *part)
55{
56 char buf[PATH_MAX];
57 Evas_Object *ic = elm_icon_add(obj);
58 if (!strcmp(part, "elm.swallow.end"))
59 snprintf(buf, sizeof(buf), "%s/images/bubble.png", elm_app_data_dir_get());
60 else
61 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
62 elm_image_file_set(ic, buf, NULL);
63 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
64 return ic;
65}
66
67static Eina_Bool gl_state_get(void *data EINA_UNUSED,
68 Evas_Object *obj EINA_UNUSED,
69 const char *part EINA_UNUSED)
70{
71 return EINA_FALSE;
72}
73
74static Eina_Bool
75gl_filter_get(void *data, Evas_Object *obj EINA_UNUSED, void *key)
76{
77 // if the key is empty/NULL, return true for item
78 if (!strlen((char *)key)) return EINA_TRUE;
79 char buf[256];
80 snprintf(buf, sizeof(buf), "Item # %i", (int)(uintptr_t)data);
81 if (strcasestr(buf, (char *)key))
82 return EINA_TRUE;
83 // Default case should return false (item fails filter hence will be hidden)
84 return EINA_FALSE;
85}
86
87static void
88_gl_filter_finished_cb(void *data EINA_UNUSED,
89 Evas_Object *obj EINA_UNUSED,
90 void *event_info EINA_UNUSED)
91{
92 printf("Filter finished\n");
93}
94
95
96EAPI_MAIN int
97elm_main(int argc EINA_UNUSED, char **argv)
98{
99 Evas_Object *win, *bg;
100
101 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
102
103 win = elm_win_util_standard_add("combobox", "Combobox");
104 elm_win_autodel_set(win, EINA_TRUE);
105
106 bg = elm_bg_add(win);
107 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
108 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
109 elm_win_resize_object_add(win, bg);
110 evas_object_show(bg);
111
112 Evas_Object *bx = elm_box_add(win);
113 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
114 elm_win_resize_object_add(win, bx);
115 evas_object_show(bx);
116
117 Evas_Object *combobox = elm_combobox_add(win);
118 evas_object_size_hint_weight_set(combobox, EVAS_HINT_EXPAND, 0);
119 evas_object_size_hint_align_set(combobox, EVAS_HINT_FILL, 0);
120 elm_object_part_text_set(combobox, "guide", "A Simple list");
121 elm_box_pack_end(bx, combobox);
122 evas_object_show(combobox);
123
124 Elm_Genlist_Item_Class *itc;
125 itc = elm_genlist_item_class_new();
126 itc->item_style = "default";
127 itc->func.text_get = gl_text_get;
128 itc->func.content_get = NULL;
129 itc->func.state_get = gl_state_get;
130 itc->func.filter_get = gl_filter_get;
131 itc->func.del = NULL;
132
133 for (int i = 0; i < 1000; i++)
134 elm_genlist_item_append(combobox, itc, (void *)(uintptr_t)i,
135 NULL, ELM_GENLIST_ITEM_NONE, NULL,
136 (void*)(uintptr_t)(i * 10));
137 evas_object_smart_callback_add(combobox, "clicked",
138 _combobox_clicked_cb, NULL);
139 evas_object_smart_callback_add(combobox, "selected",
140 _combobox_selected_cb, NULL);
141 evas_object_smart_callback_add(combobox, "dismissed",
142 _combobox_dismissed_cb, NULL);
143 evas_object_smart_callback_add(combobox, "expanded",
144 _combobox_expanded_cb, NULL);
145 evas_object_smart_callback_add(combobox, "item,pressed",
146 _combobox_item_pressed_cb, NULL);
147
148 evas_object_resize(win, 300, 500);
149 evas_object_show(win);
150
151 elm_run();
152
153 return 0;
154}
155ELM_MAIN() \ No newline at end of file
diff --git a/src/lib/elc_combobox.h b/src/lib/elc_combobox.h
index 80e1ae42f..8237b87ef 100644
--- a/src/lib/elc_combobox.h
+++ b/src/lib/elc_combobox.h
@@ -24,15 +24,15 @@
24 * is the selected item 24 * is the selected item
25 * - @c "dismissed" - the hover is dismissed 25 * - @c "dismissed" - the hover is dismissed
26 * - @c "expanded" - This is called on clicking combobox and elm_combobox_hover_begin(). 26 * - @c "expanded" - This is called on clicking combobox and elm_combobox_hover_begin().
27 * - @c "language,changed" - the program's language changed (since 1.9) 27 * - @c "language,changed" - the program's language changed.
28 * - @c "item,focused" - When the combobox item has received focus. (since 1.10) 28 * - @c "item,pressed" - When the combobox item is pressed.
29 * - @c "item,unfocused" - When the combobox item has lost focus. (since 1.10) 29 * - @c "filter,done" - When the combobox completes the filter process.
30 * 30 *
31 * Default content parts of the combobox widget that you can use for are: 31 * Default content parts of the combobox widget that you can use are the
32 * @li "icon" - An icon of the combobox 32 * the same that you use with the @ref Button
33 * 33 *
34 * Default text parts of the combobox widget that you can use for are: 34 * Default text parts of the combobox widget that you can use are the
35 * @li "default" - A label of the combobox 35 * the same that you use with the @ref Entry
36 * 36 *
37 * Supported elm_object common APIs. 37 * Supported elm_object common APIs.
38 * @li @ref elm_object_disabled_set 38 * @li @ref elm_object_disabled_set