2 * @page Examples Examples
4 * Here is a page with Elementary examples.
6 * @ref bg_01_example_page
8 * @ref bg_02_example_page
10 * @ref bg_03_example_page
12 * @ref actionslider_example_page
14 * @ref elm_animator_example_page_01
16 * @ref transit_example_01_explained
18 * @ref transit_example_02_explained
20 * @ref general_functions_example_page
22 * @ref calendar_example_01
24 * @ref calendar_example_02
26 * @ref calendar_example_03
28 * @ref calendar_example_04
30 * @ref calendar_example_05
32 * @ref calendar_example_06
34 * @ref spinner_example
42 * @ref diskselector_example_01
44 * @ref diskselector_example_02
46 * @ref list_example_01
48 * @ref list_example_02
50 * @ref list_example_03
52 * @ref flipselector_example
54 * @ref fileselector_example
56 * @ref fileselector_button_example
58 * @ref fileselector_entry_example
60 * @ref index_example_01
62 * @ref index_example_02
64 * @ref gengrid_example
66 * @ref genlist_example_01
68 * @ref genlist_example_02
70 * @ref progressbar_example
74 * @page bg_01_example_page elm_bg - Plain color background.
75 * @dontinclude bg_example_01.c
77 * The full code for this example can be found at @ref bg_example_01_c,
78 * in the function @c test_bg_plain. It's part of the @c elementar_test
79 * suite, and thus has the code for the three examples referenced by this
82 * This first example just sets a default background with a plain color. The
83 * first part consists of creating an Elementary window. It's the common
84 * piece of code that you'll see everywhere in Elementary: @skip elm_main
87 * Now we really create our background object, using the window object as
92 * Then we set the size hints of the background object so that it will use
93 * all space available for it, and then add it as a resize object to the
94 * window, making it visible in the end:
96 * @skip size_hint_weight_set
97 * @until resize_object_add
99 * See @ref evas_object_size_hint_weight_set and elm_win_resize_object_add()
100 * for more detailed info about these functions.
102 * The end of the example is quite simple, just setting the minimum and
103 * maximum size of the background, so the Elementary window knows that it
104 * has to have at least the minimum size. The background also won't scale to
105 * a size above its maximum. Then we resize the window and show it in the
108 * @skip set size hints
111 * And here we finish our very simple background object usage example.
115 * @page bg_02_example_page elm_bg - Image background.
116 * @dontinclude bg_example_02.c
118 * The full code for this example can be found at @ref bg_example_02_c,
119 * in the function @c test_bg_image. It's part of the @c elementar_test
120 * suite, and thus has the code for the three examples referenced by this
123 * This is the second example, and shows how to use the Elementary
124 * background object to set an image as background of your application.
126 * We start this example exactly in the same way as the previous one, even
127 * when creating the background object:
132 * Now it's the different part.
134 * Our background will have an image, that will be displayed over the
135 * background color. Before loading the image, we set the load size of the
136 * image. The load size is a hint about the size that we want the image
137 * displayed in the screen. It's not the exact size that the image will have,
138 * but usually a bit bigger. The background object can still be scaled to a
139 * size bigger than the one set here. Setting the image load size to
140 * something smaller than its real size will reduce the memory used to keep
141 * the pixmap representation of the image, and the time to load it. Here we
142 * set the load size to 20x20 pixels, but the image is loaded with a size
143 * bigger than that (since it's just a hint):
145 * @skipline load_size_set
147 * And set our background image to be centered, instead of stretched or
148 * scaled, so the effect of the elm_bg_load_size_set() can be easily
151 * @skipline option_set
153 * We need a filename to set, so we get one from the previous installed
154 * images in the @c PACKAGE_DATA_DIR, and write its full path to a buffer.
155 * Then we use this buffer to set the filename in the background object:
160 * Notice that the third argument of the elm_bg_file_set() function is @c
161 * NULL, since we are setting an image to this background. This function
162 * also supports setting an edje group as background, in which case the @c
163 * group parameter wouldn't be @c NULL, but be the name of the group
166 * Finally, we can set the size hints, add the background as a resize
167 * object, and resize the window, exactly the same thing we do in the @ref
168 * bg_01_example_page example:
173 * And this is the end of this example.
175 * This example will look like this:
177 * @image html screenshots/bg_01.png
178 * @image latex screenshots/bg_01.eps width=\textwidth
182 * @page bg_03_example_page elm_bg - Background properties.
183 * @dontinclude bg_example_03.c
185 * The full code for this example can be found at @ref bg_example_03_c, in the
186 * function @c test_bg_options, with the callbacks @c _cb_overlay_changed, @c
187 * _cb_color_changed and @c _cb_radio_changed defined in the beginning of the
188 * file. It's part of the @c elementar_test suite, and thus has the code for
189 * the three examples referenced by this documentation.
191 * This example will show the properties available for the background object,
192 * and will use of some more widgets to set them.
194 * In order to do this, we will set some callbacks for these widgets. The
195 * first is for the radio buttons that will be used to choose the option
196 * passed as argument to elm_bg_option_set():
198 * @skip _cb_radio_changed
201 * The next callback will be used when setting the overlay (using
202 * elm_bg_overlay_set()):
204 * @skip _cb_overlay_changed
208 * And the last one, used to set the color (with elm_bg_color_set()):
210 * @skip _cb_color_changed
213 * We will get back to what these functions do soon. If you want to know more
214 * about how to set these callbacks and what these widgets are, look for:
215 * @li elm_radio_add()
216 * @li elm_check_add()
217 * @li elm_spinner_add()
219 * Now going to the main function, @c test_bg_options, we have the common
220 * code with the other examples:
225 * We add a plain background to this window, so it will have the default
226 * background color behind everything:
228 * @skip bg = elm_bg_add
229 * @until evas_object_show(bg)
231 * Then we add a vertical box (elm_box_add()) that will hold the background
232 * object that we are going to play with, as well as a horizontal box that
236 * @until evas_object_show
238 * Now we add the background object that is going to be of use for our
239 * example. It is an image background, as used in @ref bg_02_example_page ,
240 * so the code should be familiar:
243 * @until evas_object_show
245 * Notice the call to elm_box_pack_end(): it will pack the background object
246 * in the end of the Elementary box declared above. Just refer to that
247 * documentation for more info.
249 * Since this Elementary background is already an image background, we are
250 * going to play with its other properties. We will change its option
251 * (CENTER, SCALE, STRETCH, TILE), its color (RGB), and add an overlay to it.
252 * For all of these properties, we are going to add widgets that will
255 * First, lets add the horizontal box that will hold these widgets:
259 * For now, just consider this @c hbox as a rectangle that will contain the
260 * widgets, and will distribute them horizontally inside its content. Then we
261 * add radio buttons that will allow us to choose the property to use with
265 * @until evas_object_show
267 * Again, I won't give details about the use of these widgets, just look for
268 * their documentation if necessary. It's enough to know for now that we are
269 * packing them in the @c hbox, setting a label for them, and the most
270 * important parts: setting its value to @c ELM_BG_OPTION_CENTER and its
271 * callback to @c _cb_radio_changed (the function defined in the beginning of
272 * this example). We do this for the next 3 radio buttons added after this
273 * one, each of them with a different value.
275 * Now taking a look at the code of the callback @c _cb_radio_changed again,
276 * it will call elm_bg_option_set() with the value set from the checked radio
277 * button, thus setting the option for this background. The background is
278 * passed as argument to the @p data parameter of this callback, and is
279 * referenced here as @c o_bg.
281 * Later we set the default value for this radio button:
283 * @skipline elm_radio_value_set
285 * Then we add a checkbox for the elm_bg_overlay_set() function:
288 * @until evas_object_show
290 * Now look at the code of the @c _cb_overlay_changed again. If the checkbox
291 * state is checked, an overlay will be added to the background. It's done by
292 * creating an Edje object, and setting it with elm_bg_overlay_set() to the
293 * background object. For information about what are and how to set Edje
294 * object, look at the Edje documentation.
296 * Finally we add a spinner object (elm_spinner_add()) to be used to select
297 * the color of our background. In its callback it's possible to see the call
298 * to elm_bg_color_set(), which will change the color of this background.
299 * This color is used by the background to fill areas where the image doesn't
300 * cover (in this case, where we have an image background). The spinner is
301 * also packed into the @c hbox :
303 * @skip elm_spinner_add
304 * @until evas_object_show
306 * Then we just have to pack the @c hbox inside the @c box, set some size
307 * hints, and show our window:
312 * Now to see this code in action, open elementary_test, and go to the "Bg
313 * Options" test. It should demonstrate what was implemented here.
317 * @page actionslider_example_page Actionslider usage
318 * @dontinclude actionslider_example_01.c
320 * For this example we are going to assume knowledge of evas smart callbacks
321 * and some basic evas object functions. Elementary is not meant to be used
322 * without evas, if you're not yet familiar with evas it probably is worth
325 * And now to the example, when using Elementary we start by including
329 * Next we define some callbacks, they all share the same signature because
330 * they are all to be used with evas_object_smart_callback_add().
331 * The first one just prints the selected label(in two different ways):
334 * This next callback is a little more interesting, it makes the selected
335 * label magnetic(except if it's the center label):
338 * This callback enables or disables the magnetic propertty of the center
342 * And finally a callback to stop the main loop when the window is closed:
345 * To be able to create our actionsliders we need to do some setup, but this
346 * isn't really relevant here, so if you want to know about that go @ref
349 * With all that boring stuff out of the way we can proceed to creating some
351 * All actionsliders are created the same way:
352 * @skipline actionslider_add
353 * Next we must choose where the indicator starts, and for this one we choose
354 * the right, and set the right as magnetic:
355 * @skipline indicator_pos_set
356 * @until magnet_pos_set
358 * We then set the labels for the left and right, passing NULL as an argument
359 * to any of the labels makes that position have no label.
362 * Furthermore we mark both left and right as enabled positions, if we didn't
363 * do this all three positions would be enabled:
366 * Having the the enabled positions we now add a smart callback to change
367 * which position is magnetic, so that only the last selected position is
371 * And finally we set our printing callback and show the actionslider:
375 * For our next actionslider we are going to do much as we did for the
376 * previous except we are going to have the center as the magnet(and not
378 * @skipline actionslider_add
379 * @skipline indicator_pos_set
382 * And another actionslider, in this one the indicator starts on the left.
383 * It has labels only in the center and right, and both bositions are
384 * magnetic. Because the left doesn't have a label and is not magnetic once
385 * the indicator leaves it can't return:
386 * @skipline actionslider_add
387 * @skipline indicator_pos_set
389 * @note The greyed out area is a @ref Styles "style".
391 * And now an actionslider with a label in the indicator, and whose magnet
392 * properties change based on what was last selected:
393 * @skipline actionslider_add
394 * @skipline indicator_pos_set
396 * @note The greyed out area is a @ref Styles "style".
398 * We are almost done, this next one is just an actionslider with all
399 * positions magnetized and having every possible label:
400 * @skipline actionslider_add
401 * @skipline indicator_pos_set
404 * And for our last actionslider we have one that turns the magnetic property
406 * @skipline actionslider_add
407 * @skipline indicator_pos_set
410 * The example will look like this:
412 * @image html screenshots/actionslider_01.png
413 * @image latex screenshots/actionslider_01.eps width=\textwidth
415 * See the full source code @ref actionslider_example_01 "here"
419 * @page elm_animator_example_page_01 Animator usage
420 * @dontinclude animator_example_01.c
422 * For this example we will be using a bit of evas, you could animate a
423 * elementary widget in much the same way, but to keep things simple we use
424 * an evas_object_rectangle.
426 * As every other example we start with our include and a simple callback to
427 * exit the app when the window is closed:
431 * This next callback is the one that actually creates our animation, it
432 * changes the size, position and color of a rectangle given to it in @a
436 * Next we have a callback that prints a string, nothing special:
439 * This next callback is a little more interesting, it has a state variable
440 * to know if the animation is currently paused or running, and it toogles
441 * the state of the animation accordingly:
446 * Finally we have a callback to stop the animation:
449 * As with every example we need to do a bit of setup before we can actually
450 * use an animation, but for the purposes of this example that's not relevant
451 * so let's just skip to the good stuff, creating an animator:
452 * @skipline animator_add
453 * @note Since elm_animator is not a widget we can give it a NULL parent.
455 * Now that we have an elm_animator we set it's duration to 1 second:
458 * We would also like our animation to be reversible, so:
461 * We also set our animation to repeat as many times as possible, which will
462 * mean that _end_cb will only be called after UINT_MAX * 2 seconds(UINT_MAX
463 * for the animation running forward and UNIT_MAX for the animation running
467 * To add some fun to our animation we will use the IN_OUT curve style:
470 * To actually animate anything we need an operation callback:
471 * @line operation_callback
473 * Even though we set our animation to repeat for a very long time we are
474 * going to set a end callback to it:
475 * @line completion_callback
476 * @note Notice that stoping the animation with the stop button will not make
479 * Now that we have fully set up our animator we can tell it to start
483 * There's a bit more of code that doesn't really matter to use so we skip
484 * right down to our last interesting point:
485 * @skipline animator_del
486 * @note Because we created our animator with no parent we need to delete it
489 * The example should look like this:
491 * @image html screenshots/animator_example_01.png
492 * @image latex screenshots/animator_example_01.eps width=\textwidth
494 * @image html screenshots/animator_example_02.png
495 * @image latex screenshots/animator_example_02.eps width=\textwidth
497 * @image html screenshots/animator_example_03.png
498 * @image latex screenshots/animator_example_03.eps width=\textwidth
500 * The full source code for this example can be found @ref
501 * animator_example_01_c "here"
505 * @page transit_example_03_c elm_transit - Combined effects and options.
507 * This example shows how to apply the following transition effects:
515 * It allows you to apply more than one effect at once, and also allows to
516 * set properties like event_enabled, auto_reverse, repeat_times and
519 * @include transit_example_03.c
523 * @page transit_example_04_c elm_transit - Combined effects over two objects.
525 * This example shows how to apply the transition effects:
530 * over two objects. This kind of transition effect is used to make one
531 * object disappear and another one appear on its place.
533 * You can mix more than one effect of this type on the same objects, and the
534 * transition will apply both.
536 * @include transit_example_04.c
540 * @page transit_example_01_explained elm_transit - Basic transit usage.
541 * @dontinclude transit_example_01.c
543 * The full code for this example can be found at @ref transit_example_01_c.
545 * This example shows the simplest way of creating a transition and applying
546 * it to an object. Similarly to every other elementary example, we create a
547 * window, set its title, size, autodel property, and setup a callback to
548 * exit the program when finished:
551 * @until evas_object_resize
553 * We also add a resizeable white background to use behind our animation:
556 * @until evas_object_show
558 * And then we add a button that we will use to demonstrate the effects of
562 * @until evas_object_show(win)
564 * Notice that we are not adding the button with elm_win_resize_object_add()
565 * because we don't want the window to control the size of the button. We
566 * will use the transition to change the button size, so it could conflict
567 * with something else trying to control that size.
569 * Now, the simplest code possible to create the resize animation:
574 * As you can see, this code is very easy to understand. First, we create the
575 * transition itself with elm_transit_add(). Then we add the button to this
576 * transition with elm_transit_object_add(), which means that the transition
577 * will operate over this button. The effect that we want now is changing the
578 * object size from 100x50 to 300x150, and can be achieved by adding the
579 * resize effect with elm_transit_effect_resizing_add().
581 * Finally, we set the transition time to 5 seconds and start the transition
582 * with elm_transit_go(). If we wanted more effects applied to this
583 * button, we could add them to the same transition. See the
584 * @ref transit_example_03_c to watch many transitions being applied to an
589 * @page transit_example_02_explained elm_transit - Chained transitions.
590 * @dontinclude transit_example_02.c
592 * The full code for this example can be found at @ref transit_example_02_c.
594 * This example shows how to implement a chain of transitions. This chain is
595 * used to start a transition just after another transition ended. Similarly
596 * to every other elementary example, we create a window, set its title,
597 * size, autodel property, and setup a callback to exit the program when
601 * @until evas_object_resize
603 * We also add a resizeable white background to use behind our animation:
606 * @until evas_object_show
608 * This example will have a chain of 4 transitions, each of them applied to
609 * one button. Thus we create 4 different buttons:
612 * @until evas_object_show(bt4)
614 * Now we create a simple translation transition that will be started as soon
615 * as the program loads. It will be our first transition, and the other
616 * transitions will be started just after this transition ends:
621 * The code displayed until now has nothing different from what you have
622 * already seen in @ref transit_example_01_explained, but now comes the new
623 * part: instead of creating a second transition that will start later using
624 * a timer, we create the it normally, and use
625 * elm_transit_chain_transit_add() instead of elm_transit_go. Since we are
626 * adding it in a chain after the first transition, it will start as soon as
627 * the first transition ends:
630 * @until transit_chain_transit_add
632 * Finally we add the 2 other transitions to the chain, and run our program.
633 * It will make one transition start after the other finish, and there is the
638 * @page general_functions_example_page General (top-level) functions example
639 * @dontinclude general_funcs_example.c
641 * As told in their documentation blocks, the
642 * elm_app_compile_*_dir_set() family of functions have to be called
643 * before elm_app_info_set():
644 * @skip tell elm about
645 * @until elm_app_info_set
647 * We are here setting the fallback paths to the compiling time target
648 * paths, naturally. If you're building the example out of the
649 * project's build system, we're assuming they are the canonical ones.
651 * After the program starts, elm_app_info_set() will actually run and
652 * then you'll see an intrincasy: Elementary does the prefix lookup @b
653 * twice. This is so because of the quicklaunch infrastructure in
654 * Elementary (@ref Start), which will register a predefined prefix
655 * for possible users of the launch schema. We're not hooking into a
656 * quick launch, so this first call can't be avoided.
658 * If you ran this example from your "bindir" installation
659 * directiory, no output will emerge from these both attempts -- it
660 * will find the "magic" file there registered and set the prefixes
661 * silently. Otherwise, you could get something like:
663 WARNING: Could not determine its installed prefix for 'ELM'
664 so am falling back on the compiled in default:
666 implied by the following:
669 datadir = usr/share/elementary
670 localedir = usr/share/locale
671 Try setting the following environment variables:
672 ELM_PREFIX - points to the base prefix of install
673 or the next 4 variables
674 ELM_BIN_DIR - provide a specific binary directory
675 ELM_LIB_DIR - provide a specific library directory
676 ELM_DATA_DIR - provide a specific data directory
677 ELM_LOCALE_DIR - provide a specific locale directory
679 * if you also didn't change those environment variables (remember
680 * they are also a valid way of communicating your prefix to the
681 * binary) - this is the scenario where it fallbacks to the paths set
684 * Then, you can check the prefixes set on the standard output:
685 * @skip prefix was set to
686 * @until locale directory is
689 * @skip by using this policy
690 * @until elm_win_autodel_set
691 * we demonstrate the use of Elementary policies. The policy defining
692 * under which circunstances our application should quit automatically
693 * is set to when its last window is closed (this one has just one
694 * window, though). This will save us from having to set a callback
695 * ourselves on the window, like done in @ref bg_example_01_c "this"
696 * example. Note that we need to tell the window to delete itself's
697 * object on a request to destroy the canvas coming, with
698 * elm_win_autodel_set().
700 * What follows is some boilerplate code, creating a frame with a @b
701 * button, our object of interest, and, below, widgets to change the
702 * button's behavior and exemplify the group of functions in question.
704 * @dontinclude general_funcs_example.c
705 * We enabled the focus highlight object for this window, so that you
706 * can keep track of the current focused object better:
707 * @skip elm_win_focus_highlight_enabled_set
708 * @until evas_object_show
709 * Use the tab key to navigate through the focus chain.
711 * @dontinclude general_funcs_example.c
712 * While creating the button, we exemplify how to use Elementary's
713 * finger size information to scale our UI:
714 * @skip fprintf(stdout, "Elementary
715 * @until evas_object_show
717 * @dontinclude general_funcs_example.c
718 * The first checkbox's callback is:
721 * When unsetting the checkbox, we disable the button, which will get a new
722 * decoration (greyed out) and stop receiving events. The focus chain
723 * will also ignore it.
725 * Following, there are 2 more buttons whose actions are focus/unfocus
726 * the top button, respectively:
727 * @skip focus callback
730 * @skip unfocus callback
732 * Note the situations in which they won't take effect:
733 * - the button is not allowed to get focus or
734 * - the button is disabled
736 * The first restriction above you'll get by a second checkbox, whose
738 * @skip focus allow callback
740 * Note that the button will still get mouse events, though.
742 * Next, there's a slider controlling the button's scale:
743 * @skip scaling callback
746 * Experiment with it, so you understand the effect better. If you
747 * change its value, it will mess with the button's original size,
750 * The full code for this example can be found
751 * @ref general_functions_example_c "here".
755 * @page theme_example_01 Theme - Using extensions
757 * @dontinclude theme_example_01.c
759 * Using extensions is extremely easy, discarding the part where you have to
760 * write the theme for them.
762 * In the following example we'll be creating two buttons, one to load or
763 * unload our extension theme and one to cycle around three possible styles,
764 * one of which we created.
766 * After including our one and only header we'll jump to the callback for
767 * the buttons. First one takes care of loading or unloading our extension
768 * file, relative to the default theme set (thus the @c NULL in the
769 * functions first parameter).
770 * @skipline Elementary.h
776 * The second button, as we said before, will just switch around different
777 * styles. In this case we have three of them. The first one is our custom
778 * style, named after something very unlikely to find in the default theme.
779 * The other two styles are the standard and one more, anchor, which exists
780 * in the default and is similar to the default, except the button vanishes
781 * when the mouse is not over it.
786 * So what happens if the style switches to our custom one when the
787 * extension is loaded? Elementary falls back to the default for the
790 * And the main function, simply enough, will create the window, set the
791 * buttons and their callbacks, and just to begin with our button styled
792 * we're also loading our extension at the beginning.
796 * In this case we wanted to easily remove extensions, but all adding an
797 * extension does is tell Elementary where else it should look for themes
798 * when it can't find them in the default theme. Another way to do this
799 * is to set the theme search order using elm_theme_set(), but this requires
800 * that the developer is careful not to override any user configuration.
801 * That can be helped by adding our theme to the end of whatver is already
802 * set, like in the following snippet.
805 * snprintf(buf, sizeof(buf), "%s:./theme_example.edj", elme_theme_get(NULL);
806 * elm_theme_set(NULL, buf);
809 * If we were using overlays instead of extensions, the same thing applies,
810 * but the custom theme must be added to the front of the search path.
812 * In the end, we should be looking at something like this:
814 * @image html screenshots/theme_example_01.png
815 * @image latex screenshots/theme_example_01.eps width=\textwidth
817 * That's all. Boringly simple, and the full code in one piece can be found
818 * @ref theme_example_01.c "here".
820 * And the code for our extension is @ref theme_example.edc "here".
822 * @example theme_example_01.c
823 * @example theme_example.edc
827 * @page theme_example_02 Theme - Using overlays
829 * @dontinclude theme_example_02.c
831 * Overlays are like extensions in that you tell Elementary that some other
832 * theme contains the styles you need for your program. The difference is that
833 * they will be look in first, so they can override the default style of any
836 * There's not much to say about them that hasn't been said in our previous
837 * example about @ref theme_example_01 "extensions", so going quickly through
838 * the code we have a function to load or unload the theme, which will be
839 * called when we click any button.
840 * @skipline Elementary.h
844 * And the main function, creating the window and adding some buttons to it.
845 * We load our theme as an overlay and nothing else. Notice there's no style
846 * set for any button there, which means they should be using the default
851 * That's pretty much it. The full code is @ref theme_example_02.c "here" and
852 * the definition of the theme is the same as before, and can be found in
853 * @ref theme_example.edc "here".
855 * @example theme_example_02.c
859 * @page button_example_01 Button - Complete example
861 * @dontinclude button_example_01.c
863 * A button is simple, you click on it and something happens. That said,
864 * we'll go through an example to show in detail the button API less
867 * In the end, we'll be presented with something that looks like this:
869 * @image html screenshots/button_01.png
870 * @image latex screenshots/button_01.eps width=\textwidth
872 * The full code of the example is @ref button_example_01.c "here" and we
873 * will follow here with a rundown of it.
876 * @until Elementary.h
880 * We have several buttons to set different times for the autorepeat timeouts
881 * of the buttons that use it and a few more that we keep track of in our
882 * data struct. The mid button doesn't do much, just moves around according
883 * to what other buttons the user presses. Then four more buttons to move the
884 * central one, and we're also keeping track of the icon set in the middle
885 * button, since when this one moves, we change the icon, and when movement
886 * is finished (by releasing one of the four arrow buttons), we set back the
891 * Keeping any of those four buttons pressed will trigger their autorepeat
892 * callback, where we move the button doing some size hint magic. To
893 * understand how that works better, refer to the @ref Box documentation.
894 * Also, the first time the function is called, we change the icon in the
895 * middle button, using elm_button_icon_unset() first to keep the reference
896 * to the previous one, so we don't need to recreate it when we are done
900 * @until size_hint_align_set
903 * One more callback for the option buttons, that just sets the timeouts for
904 * the different autorepeat options.
911 * And the main function, which does some setting up of the buttons in boxes
912 * to make things work. Here we'll go through some snippets only.
914 * For the option buttons, it's just the button with its label and callback.
915 * @skip elm_button_add
916 * @until smart_callback_add
918 * For the ones that move the central button, we have no labels. There are
919 * icons instead, and the autorepeat option is toggled.
921 * @skip elm_button_add
922 * @until data.cursors.up
924 * And just to show the mid button, which doesn't have anything special.
925 * @skip data.cursors.left
926 * @skip elm_button_add
931 * @example button_example_01.c
935 * @page bubble_01_example_page elm_bubble - Simple use.
936 * @dontinclude bubble_example_01.c
938 * This example shows a bubble with all fields set(label, info, content and
939 * icon) and the selected corner changing when the bubble is clicked. To be
940 * able use a bubble we need to do some setup and create a window, for this
941 * example we are going to ignore that part of the code since it isn't
942 * relevant to the bubble.
944 * To have the selected corner change in a clockwise motion we are going to
945 * use the following callback:
950 * Here we are creating an elm_label that is going to be used as the content
952 * @skipline elm_label
954 * @note You could use any evas_object for this, we are using an elm_label
957 * Despite it's name the bubble's icon doesn't have to be an icon, it can be
958 * any evas_object. For this example we are going to make the icon a simple
962 * And finally we have the actual bubble creation and the setting of it's
963 * label, info and content:
966 * @note Because we didn't set a corner, the default("top_left") will be
969 * Now that we have our bubble all that is left is connecting the "clicked"
970 * signals to our callback:
971 * @line smart_callback
973 * This last bubble we created was very complete, so it's pertinent to show
974 * that most of that stuff is optional a bubble can be created with nothing
979 * Our example will look like this:
981 * @image html screenshots/bubble_example_01.png
982 * @image latex screenshots/bubble_example_01.eps width=\textwidth
984 * See the full source code @ref bubble_example_01.c here.
985 * @example bubble_example_01.c
989 * @page box_example_01 Box - Basic API
991 * @dontinclude button_example_01.c
993 * As a special guest tonight, we have the @ref button_example_01 "simple
994 * button example". There are plenty of boxes in it, and to make the cursor
995 * buttons that moved a central one around when pressed, we had to use a
996 * variety of values for their hints.
998 * To start, let's take a look at the handling of the central button when
999 * we were moving it around. To achieve this effect without falling back to
1000 * a complete manual positioning of the @c Evas_Object in our canvas, we just
1001 * put it in a box and played with its alignment within it, as seen in the
1002 * following snippet of the callback for the pressed buttons.
1003 * @skip evas_object_size_hint_align_get
1004 * @until evas_object_size_hint_align_set
1006 * Not much to it. We get the current alignment of the object and change it
1007 * by just a little, depending on which button was pressed, then set it
1008 * again, making sure we stay within the 0.0-1.0 range so the button moves
1009 * inside the space it has, instead of disappearing under the other objects.
1011 * But as useful as an example as that may have been, the usual case with boxes
1012 * is to set everything at the moment they are created, like we did for
1013 * everything else in our main function.
1015 * The entire layout of our program is made with boxes. We have one set as the
1016 * resize object for the window, which means it will always be resized with
1017 * the window. The weight hints set to @c EVAS_HINT_EXPAND will tell the
1018 * window that the box can grow past it's minimum size, which allows resizing
1022 * @until evas_object_show
1024 * Two more boxes, set to horizontal, hold the buttons to change the autorepeat
1025 * configuration used by the buttons. We create each to take over all the
1026 * available space horizontally, but we don't want them to grow vertically,
1027 * so we keep that axis of the weight with 0.0. Then it gets packed in the
1030 * @until evas_object_show
1032 * The buttons in each of those boxes have nothing special, they are just packed
1033 * in with their default values and the box will use their minimum size, as set
1034 * by Elementary itself based on the label, icon, finger size and theme.
1036 * But the buttons used to move the central one have a special disposition.
1037 * The top one first, is placed right into the main box like our other smaller
1038 * boxes. Set to expand horizontally and not vertically, and in this case we
1039 * also tell it to fill that space, so it gets resized to take the entire
1040 * width of the window.
1042 * @skip elm_button_add
1043 * @until evas_object_show
1045 * The bottom one will be the same, but for the other two we need to use a
1046 * second box set to take as much space as we have, so we can place our side
1047 * buttons in place and have the big empty space where the central button will
1050 * @until evas_object_show
1052 * Then the buttons will have their hints inverted to the other top and bottom
1053 * ones, to expand and fill vertically and keep their minimum size horizontally.
1054 * @skip elm_button_add
1055 * @until evas_object_show
1057 * The central button takes every thing else. It will ask to be expanded in
1058 * both directions, but without filling its cell. Changing its alignment by
1059 * pressing the buttons will make it move around.
1060 * @skip elm_button_add
1061 * @until evas_object_show
1063 * To end, the rightmost button is packed in the smaller box after the central
1064 * one, and back to the main box we have the bottom button at the end.
1068 * @page box_example_02 Box - Layout transitions
1070 * @dontinclude box_example_02.c
1072 * Setting a customized layout for a box is simple once you have the layout
1073 * function, which is just like the layout function for @c Evas_Box. The new
1074 * and fancier thing we can do with Elementary is animate the transition from
1075 * one layout to the next. We'll see now how to do that through a simple
1076 * example, while also taking a look at some of the API that was left
1077 * untouched in our @ref box_example_01 "previous example".
1079 * @image html screenshots/box_example_02.png
1080 * @image latex screenshots/box_example_02.eps width=\textwidth
1082 * @skipline Elementary.h
1084 * Our application data consists of a list of layout functions, given by
1085 * @c transitions. We'll be animating through them throughout the entire run.
1086 * The box with the stuff to move around and the last layout that was set to
1087 * make things easier in the code.
1089 * @until Transitions_Data
1091 * The box starts with three buttons, clicking on any of them will take it
1092 * out of the box without deleting the object. There are also two more buttons
1093 * outside, one to add an object to the box and the other to clear it.
1094 * This is all to show how you can interact with the items in the box, add
1095 * things and even remove them, while the transitions occur.
1097 * One of the callback we'll be using creates a new button, asks the box for
1098 * the list of its children and if it's not empty, we add the new object after
1099 * the first one, otherwise just place at the end as it will not make any
1105 * The clear button is even simpler. Everything in the box will be deleted,
1106 * leaving it empty and ready to fill it up with more stuff.
1110 * And a little function to remove buttons from the box without deleting them.
1111 * This one is set for the @c clicked callback of the original buttons,
1112 * unpacking them when clicked and placing it somewhere in the screen where
1113 * they will not disturb. Once we do this, the box no longer has any control
1114 * of it, so it will be left untouched until the program ends.
1118 * If we wanted, we could just call @c evas_object_del() on the object to
1119 * destroy it. In this case, no unpack is really necessary, as the box would
1120 * be notified of a child being deleted and adjust its calculations accordingly.
1122 * The core of the program is the following function. It takes whatever
1123 * function is first on our list of layouts and together with the
1124 * @c last_layout, it creates an ::Elm_Box_Transition to use with
1125 * elm_box_layout_transition(). In here, we tell it to start from whatever
1126 * layout we last set, end with the one that was at the top of the list and
1127 * when everything is finished, call us back so we can create another
1128 * transition. Finally, move the new layout to the end of the list so we
1129 * can continue running through them until the program ends.
1133 * The main function doesn't have antyhing special. Creation of box, initial
1134 * buttons and some callback setting. The only part worth mentioning is the
1135 * initialization of our application data.
1137 * @until evas_object_box_layout_stack
1139 * We have a simple static variable, set the box, the first layout we are
1140 * using as last and create the list with the different functions to go
1143 * And in the end, we set the first layout and call the same function we went
1144 * through before to start the run of transitions.
1145 * @until _test_box_transition_change
1147 * For the full code, follow @ref box_example_02.c "here".
1149 * @example box_example_02.c
1153 * @page calendar_example_01 Calendar - Simple creation.
1154 * @dontinclude calendar_example_01.c
1156 * As a first example, let's just display a calendar in our window,
1157 * explaining all steps required to do so.
1159 * First you should declare objects we intend to use:
1160 * @skipline Evas_Object
1162 * Then a window is created, a title is set and its set to be autodeleted.
1163 * More details can be found on windows examples:
1164 * @until elm_win_autodel
1166 * Next a simple background is placed on our windows. More details on
1167 * @ref bg_01_example_page:
1168 * @until evas_object_show(bg)
1170 * Now, the exciting part, let's add the calendar with elm_calendar_add(),
1171 * passing our window object as parent.
1172 * @until evas_object_show(cal);
1174 * To conclude our example, we should show the window and run elm mainloop:
1177 * Our example will look like this:
1179 * @image html screenshots/calendar_example_01.png
1180 * @image latex screenshots/calendar_example_01.eps width=\textwidth
1182 * See the full source code @ref calendar_example_01.c here.
1183 * @example calendar_example_01.c
1187 * @page calendar_example_02 Calendar - Layout strings formatting.
1188 * @dontinclude calendar_example_02.c
1190 * In this simple example, we'll explain how to format the label displaying
1191 * month and year, and also set weekday names.
1193 * To format month and year label, we need to create a callback function
1194 * to create a string given the selected time, declared under a
1195 * <tt> struct tm </tt>.
1197 * <tt> struct tm </tt>, declared on @c time.h, is a structure composed by
1199 * @li tm_sec seconds [0,59]
1200 * @li tm_min minutes [0,59]
1201 * @li tm_hour hour [0,23]
1202 * @li tm_mday day of month [1,31]
1203 * @li tm_mon month of year [0,11]
1204 * @li tm_year years since 1900
1205 * @li tm_wday day of week [0,6] (Sunday = 0)
1206 * @li tm_yday day of year [0,365]
1207 * @li tm_isdst daylight savings flag
1208 * @note glib version has 2 additional fields.
1210 * For our function, only stuff that matters are tm_mon and tm_year.
1211 * But we don't need to access it directly, since there are nice functions
1212 * to format date and time, as @c strftime.
1213 * We will get abbreviated month (%b) and year (%y) (check strftime manpage
1214 * for more) in our example:
1215 * @skipline static char
1218 * We need to alloc the string to be returned, and calendar widget will
1219 * free it when it's not needed, what is done by @c strdup.
1220 * So let's register our callback to calendar object:
1221 * @skipline elm_calendar_format_function_set
1223 * To set weekday names, we should declare them as an array of strings:
1224 * @dontinclude calendar_example_02.c
1225 * @skipline weekdays
1228 * And finally set them to calendar:
1229 * skipline weekdays_names_set
1231 * Our example will look like this:
1233 * @image html screenshots/calendar_example_02.png
1234 * @image latex screenshots/calendar_example_02.eps width=\textwidth
1236 * See the full source code @ref calendar_example_02.c here.
1237 * @example calendar_example_02.c
1241 * @page calendar_example_03 Calendar - Years restrictions.
1242 * @dontinclude calendar_example_03.c
1244 * This example explains how to set max and min year to be displayed
1245 * by a calendar object. This means that user won't be able to
1246 * see or select a date before and after selected years.
1247 * By default, limits are 1902 and maximun value will depends
1248 * on platform architecture (year 2037 for 32 bits); You can
1249 * read more about time functions on @c ctime manpage.
1251 * Straigh to the point, to set it is enough to call
1252 * elm_calendar_min_max_year_set(). First value is minimun year, second
1253 * is maximum. If first value is negative, it won't apply limit for min
1254 * year, if the second one is negative, won't apply for max year.
1255 * Setting both to negative value will clear limits (default state):
1256 * @skipline elm_calendar_min_max_year_set
1258 * Our example will look like this:
1260 * @image html screenshots/calendar_example_03.png
1261 * @image latex screenshots/calendar_example_03.eps width=\textwidth
1263 * See the full source code @ref calendar_example_03.c here.
1264 * @example calendar_example_03.c
1268 * @page calendar_example_04 Calendar - Days selection.
1269 * @dontinclude calendar_example_04.c
1271 * It's possible to disable date selection and to select a date
1272 * from your program, and that's what we'll see on this example.
1274 * If isn't required that users could select a day on calendar,
1275 * only interacting going through months, disabling days selection
1276 * could be a good idea to avoid confusion. For that:
1277 * @skipline elm_calendar_day_selection_enabled_set
1279 * Also, regarding days selection, you could be interested to set a
1280 * date to be highlighted on calendar from your code, maybe when
1281 * a specific event happens, or after calendar creation. Let's select
1282 * two days from current day:
1283 * @dontinclude calendar_example_04.c
1284 * @skipline SECS_DAY
1285 * @skipline current_time
1286 * @until elm_calendar_selected_time_set
1288 * Our example will look like this:
1290 * @image html screenshots/calendar_example_04.png
1291 * @image latex screenshots/calendar_example_04.eps width=\textwidth
1293 * See the full source code @ref calendar_example_04.c here.
1294 * @example calendar_example_04.c
1298 * @page calendar_example_05 Calendar - Signal callback and getters.
1299 * @dontinclude calendar_example_05.c
1301 * Most of setters explained on previous examples have associated getters.
1302 * That's the subject of this example. We'll add a callback to display
1303 * all calendar information every time user interacts with the calendar.
1305 * Let's check our callback function:
1306 * @skipline static void
1307 * @until double interval;
1309 * To get selected day, we need to call elm_calendar_selected_time_get(),
1310 * but to assure nothing wrong happened, we must check for function return.
1311 * It'll return @c EINA_FALSE if fail. Otherwise we can use time set to
1312 * our structure @p stime.
1313 * @skipline elm_calendar_selected_time_get
1316 * Next we'll get information from calendar and place on declared vars:
1317 * @skipline interval
1318 * @until elm_calendar_weekdays_names_get
1320 * The only tricky part is that last line gets an array of strings
1321 * (char arrays), one for each weekday.
1323 * Then we can simple print that to stdin:
1327 * <tt> struct tm </tt> is declared on @c time.h. You can check @c ctime
1328 * manpage to read about it.
1330 * To register this callback, that will be called every time user selects
1331 * a day or goes to next or previous month, just add a callback for signal
1333 * @skipline evas_object_smart_callback_add
1335 * Our example will look like this:
1337 * @image html screenshots/calendar_example_05.png
1338 * @image latex screenshots/calendar_example_05.eps width=\textwidth
1340 * See the full source code @ref calendar_example_05.c here.
1341 * @example calendar_example_05.c
1345 * @page calendar_example_06 Calendar - Calendar marks.
1346 * @dontinclude calendar_example_06.c
1348 * On this example marks management will be explained. Functions
1349 * elm_calendar_mark_add(), elm_calendar_mark_del() and
1350 * elm_calendar_marks_clear() will be covered.
1352 * To add a mark, will be required to choose three things:
1354 * @li mark date, or start date if it will be repeated
1355 * @li mark periodicity
1357 * Style defines the kind of mark will be displayed over marked day,
1358 * on caledar. Default theme supports @b holiday and @b checked.
1359 * If more is required, is possible to set a new theme to calendar
1360 * widget using elm_object_style_set(), and use
1361 * the signal that will be used by such marks.
1363 * Date is a <tt> struct tm </tt>, as defined by @c time.h. More can
1364 * be read on @c ctime manpage.
1365 * If a date relative from current is required, this struct can be set
1367 * @skipline current_time
1368 * @until localtime_r
1370 * Or if it's an absolute date, you can just declare the struct like:
1371 * @dontinclude calendar_example_06.c
1373 * @until christmas.tm_mon
1375 * Periodicity is how frequently the mark will be displayed over the
1376 * calendar. Can be a unique mark (that don't repeat), or it can repeat
1377 * daily, weekly, monthly or annually. It's enumerated by
1378 * @c Elm_Calendar_Mark_Repeat.
1380 * So let's add some marks to our calendar. We will add christmas holiday,
1381 * set Sundays as holidays, and check current day and day after that.
1382 * @dontinclude calendar_example_06.c
1384 * @until christmas.tm_mon
1385 * @skipline current_time
1386 * @until ELM_CALENDAR_WEEKLY
1388 * We kept the return of first mark add, because we don't really won't it
1389 * to be checked, so let's remove it:
1390 * @skipline elm_calendar_mark_del
1392 * After all marks are added and removed, is required to draw them:
1393 * @skipline elm_calendar_marks_draw
1395 * Finally, to clear all marks, let's set a callback for our button:
1396 * @skipline elm_button_add
1397 * @until evas_object_show(bt);
1399 * This callback will receive our calendar object, and should clear it:
1400 * @dontinclude calendar_example_06.c
1403 * @note Remember to draw marks after clear the calendar.
1405 * Our example will look like this:
1407 * @image html screenshots/calendar_example_06.png
1408 * @image latex screenshots/calendar_example_06.eps width=\textwidth
1410 * See the full source code @ref calendar_example_06.c here.
1411 * @example calendar_example_06.c
1415 * @page spinner_example Spinner widget example
1417 * This code places seven Elementary spinner widgets on a window, each of
1418 * them exemplifying a part of the widget's API.
1420 * The first of them is the default spinner:
1421 * @dontinclude spinner_example.c
1422 * @skipline elm_spinner_add
1423 * @until evas_object_show
1424 * As you see, the defaults for a spinner are:
1426 * @li min value set to 0
1427 * @li max value set to 100
1428 * @li step value set to 1
1429 * @li label format set to "%0.f"
1431 * If another format is required, see the second spinner. It will put a text
1432 * before and after the value, and also format value to display two decimals:
1433 * @skipline format_set
1435 * The third one will use a customized step, define new minimum and maximum
1436 * values and enable wrap, so when value reaches minimum it jumps to maximum,
1437 * or jumps to minimum after maximum value is reached. Format is set to display
1439 * @skipline elm_spinner_add
1440 * @until evas_object_show
1442 * The fourth uses @c vertical style, so instead of left and right arrows,
1443 * top and bottom are displayed. Also the change interval is reduced, so
1444 * user can change value faster.
1446 * @skipline interval
1448 * In the fifth the user won't be allowed to set value directly, i.e., will
1449 * be obligate change value only using arrows:
1450 * @skipline editable
1452 * The sixth widget will receive a lot of special values, so
1453 * instead of reading numeric values, user will see labels for each one.
1454 * Also direct edition is disabled, otherwise users would see the numeric
1455 * value on edition mode. User will be able to select a month in this widget:
1456 * @skipline elm_spinner_add
1457 * @until evas_object_show
1459 * Finally the last widget will exemplify how to listen to widget's signals,
1460 * <tt> changed </tt> and <tt> delay,changed </tt>. First we need to
1461 * implement callback functions that will simply print spinner's value:
1462 * @dontinclude spinner_example.c
1469 * The first callback function should be called everytime value changes,
1470 * the second one only after user stops to increment or decrement. Try
1471 * to keep arrows pressed and check the difference.
1472 * @skip smart_callback
1473 * @skipline smart_callback
1474 * @skipline smart_callback
1476 * See the full @ref spinner_example.c "example", whose window should
1477 * look like this picture:
1479 * @image html screenshots/spinner_example.png
1480 * @image latex screenshots/spinner_example.eps width=\textwidth
1482 * See the full @ref spinner_example_c "source code" for this example.
1484 * @example spinner_example.c
1488 * @page slider_example Slider widget example
1490 * This code places seven Elementary slider widgets on a window, each of
1491 * them exemplifying a part of the widget's API.
1493 * The first of them is the default slider:
1494 * @dontinclude slider_example.c
1495 * @skipline elm_slider_add
1496 * @until evas_object_show
1498 * As you see, the defaults for a slider are:
1501 * @li no values (on indicator or unit labels)
1503 * Actually it's pretty useless this way. So let's learn how to improve it.
1505 * If some decoration is required, a label can be set, and icon before and
1506 * after the bar as well. On the second slider will add a @c home icon
1507 * and a @c folder icon at @c end.
1508 * @skipline text_set
1511 * If the bar size need to be changed, it can be done with span set function,
1512 * that doesn't accounts other widget's parts size. Also the bar can starts
1513 * with a not default value (0.0), as we done on third slider:
1514 * @skipline value_set
1515 * @skipline span_size_set
1517 * So far, users won't be able to see the slider value. If it's required,
1518 * it can be displayed in two different areas, units label or above
1521 * Let's place a units label on our widget, and also let's set minimum and
1522 * maximum value (uses 0.0 and 1.0 by default):
1523 * @skipline unit_format_set
1524 * @skipline min_max_set
1526 * If above the indicator is the place to display the value, just set it.
1527 * Also, is possible to invert a bar, as you can see:
1528 * @skipline indicator_format_set
1529 * @skipline inverted_set
1531 * But if you require to use a function a bit more customized to show the value,
1532 * is possible to registry a callback function that will be called
1533 * to display unit or indicator label. Only the value will be passed to this
1534 * function, that should return a string.
1535 * In this case, a function to free this string will be required.
1537 * Let's exemplify with indicator label on our sixth slider:
1538 * @dontinclude slider_example.c
1549 * Setting callback functions:
1550 * @skipline indicator_format_function_set
1551 * @skipline _indicator_free
1553 * Also, a slider can be displayed vertically:
1554 * @dontinclude slider_example.c
1555 * @skipline elm_slider_horizontal_set
1557 * Finally the last widget will exemplify how to listen to widget's signals,
1558 * <tt> changed </tt> and <tt> delay,changed </tt>. First we need to
1559 * implement callback functions that will simply print slider's value:
1560 * @dontinclude slider_example.c
1567 * The first callback function should be called everytime value changes,
1568 * the second one only after user stops to increment or decrement. Try
1569 * to keep arrows pressed and check the difference.
1570 * @skip smart_callback
1571 * @skipline smart_callback
1572 * @skipline smart_callback
1574 * See the full @ref slider_example.c "example", whose window should
1575 * look like this picture:
1577 * @image html screenshots/slider_example.png
1578 * @image latex screenshots/slider_example.eps width=\textwidth
1580 * See the full @ref slider_example_c "source code" for this example.
1582 * @example slider_example.c
1586 * @page panes_example Panes widget example
1588 * This code places two Elementary panes widgets on a window, one of them
1589 * displayed vertically and the other horizontally, to exemplify
1590 * a part of the widget's API. Also, all the signals emitted by this
1591 * widget will be covered.
1593 * Let's start adding a panes to our window:
1594 * @dontinclude panes_example.c
1595 * @skipline elm_panes_add
1596 * @until evas_object_show
1598 * Now we will set a content (a simple button) to the left side of our
1600 * @skipline elm_button_add
1601 * @until content_left_set
1603 * The content of the right side will be something a bit more elaborated, we'll
1604 * place another panes, displayed vertically (it's displayed horizontally
1606 * @skipline elm_panes_add
1607 * @until content_right_set
1609 * When populating a panes displayed vertically, remember that left content
1610 * will be placed at top, and right content will place at bottom. Next
1611 * we will add two buttons to exemplify that:
1612 * @skipline elm_button_add
1613 * @until content_right_set
1615 * Panes widgets emits 4 different signals, depending on users interaction
1616 * with the draggable bar. We'll add a callback function for each of them.
1618 * <tt> "clicked" signal </tt>:
1620 * Callback function that just print "Clicked" to stdin:
1621 * @dontinclude panes_example.c
1628 * @skipline static void
1631 * Also, add callback function to the panes:
1632 * @skipline "clicked"
1634 * <tt> "press" signal </tt>:
1636 * Callback function that just print "Pressed" to stdin:
1637 * @dontinclude panes_example.c
1640 * @skipline static void
1643 * Also, add callback function to the panes:
1646 * Now, let's try to make our callback functions a bit more useful:
1648 * <tt> "unpress" signal </tt>:
1650 * Suppose we want to know the size proportion of left content after
1651 * user drags the bar. We need to listen for @c unpress signal, and
1652 * get this size from our panes widget. It's done on the following
1654 * @dontinclude panes_example.c
1659 * @skipline static void
1662 * Adding the callback function to the panes:
1663 * @skipline "unpress"
1665 * <tt> "clicked,double" signal </tt>:
1667 * Now, a interesting feature that could be addded to panes widget.
1668 * Hide a content when user double click the draggable bar. It's done
1669 * using a variable to store size and content left size getter and setter
1670 * on the following function:
1671 * @dontinclude panes_example.c
1672 * @skipline static double
1679 * @skipline static void
1684 * Adding the callback function to the panes:
1685 * @skipline "clicked,double"
1688 * See the full @ref panes_example.c "example", whose window should
1689 * look like this picture:
1691 * @image html screenshots/panes_example.png
1692 * @image latex screenshots/panes_example.eps width=\textwidth
1694 * @example panes_example.c
1698 * @page clock_example Clock widget example
1700 * This code places five Elementary clock widgets on a window, each of
1701 * them exemplifying a part of the widget's API.
1703 * The first of them is the pristine clock:
1704 * @dontinclude clock_example.c
1706 * @until evas_object_show
1707 * As you see, the defaults for a clock are:
1709 * - no seconds shown
1711 * For am/pm time, see the second clock:
1712 * @dontinclude clock_example.c
1714 * @until evas_object_show
1716 * The third one will show the seconds digits, which will flip in
1717 * synchrony with system time. Note, besides, that the time itself is
1718 * @b different from the system's -- it was customly set with
1719 * elm_clock_time_set():
1720 * @dontinclude clock_example.c
1721 * @skip with seconds
1722 * @until evas_object_show
1724 * In both fourth and fifth ones, we turn on the <b>edition
1725 * mode</b>. See how you can change each of the sheets on it, and be
1726 * sure to try holding the mouse pressed over one of the sheet
1727 * arrows. The forth one also starts with a custom time set:
1728 * @dontinclude clock_example.c
1730 * @until evas_object_show
1732 * The fifth, besides editable, has only the time @b units editable,
1733 * for hours, minutes and seconds. This exemplifies
1734 * elm_clock_digit_edit_set():
1735 * @dontinclude clock_example.c
1737 * @until evas_object_show
1739 * See the full @ref clock_example.c "example", whose window should
1740 * look like this picture:
1742 * @image html screenshots/clock_example.png
1743 * @image latex screenshots/clock_example.eps width=\textwidth
1745 * See the full @ref clock_example_c "source code" for this example.
1747 * @example clock_example.c
1751 * @page diskselector_example_01 Diskselector widget example
1753 * This code places 4 Elementary diskselector widgets on a window, each of
1754 * them exemplifying a part of the widget's API.
1756 * All of them will have weekdays as items, since we won't focus
1757 * on items management on this example. For an example about this subject,
1758 * check @ref diskselector_example_02.
1760 * The first of them is a default diskselector.
1761 * @dontinclude diskselector_example_01.c
1764 * @skipline elm_diskselector_add
1765 * @until evas_object_show
1767 * We are just adding the diskselector, so as you can see, defaults for it are:
1768 * @li Only 3 items visible each time.
1769 * @li Only 3 characters are displayed for labels on side positions.
1770 * @li The first added item remains centeres, i.e., it's the selected item.
1772 * To add items, we are just appending it on a loop, using function
1773 * elm_diskselector_item_append(), that will be better exaplained on
1774 * items management example.
1776 * For a circular diskselector, check the second widget. A circular
1777 * diskselector will display first item after last, and last previous to
1778 * the first one. So, as you can see, @b Sa will appears on left side
1779 * of selected @b Sunday. This property is set with
1780 * elm_diskselector_round_set().
1782 * Also, we decide to display only 2 character for side labels, instead of 3.
1783 * For this we call elm_diskselector_side_label_length_set(). As result,
1784 * we'll see @b Mo displayed instead of @b Mon, when @b Monday is on a
1787 * @skipline elm_diskselector_add
1788 * @until evas_object_show
1790 * But so far, we are only displaying 3 items at once. If more are wanted,
1791 * is enough to call elm_diskselector_display_item_num_set(), as you can
1793 * @skipline elm_diskselector_add
1794 * @until evas_object_show
1796 * @note You can't set less than 3 items to be displayed.
1798 * Finally, if a bounce effect is required, or you would like to see
1799 * scrollbars, it is possible. But, for default theme, diskselector
1800 * scrollbars will be invisible anyway.
1801 * @skipline elm_diskselector_add
1802 * @until evas_object_show
1804 * See the full @ref diskselector_example_01.c "diskselector_example_01.c"
1805 * code, whose window should look like this picture:
1807 * @image html screenshots/diskselector_example_01.png
1808 * @image latex screenshots/diskselector_example_01.eps width=\textwidth
1810 * @example diskselector_example_01.c
1814 * @page diskselector_example_02 Diskselector - Items management
1816 * This code places a Elementary diskselector widgets on a window,
1817 * along with some buttons trigerring actions on it (though its API).
1818 * It covers most of Elm_Diskselector_Item functions.
1820 * On our @c main function, we are adding a default diskselector with
1821 * 3 items. We are only setting their labels (second parameter of function
1822 * elm_diskselector_item_append):
1823 * @dontinclude diskselector_example_02.c
1824 * @skipline elm_diskselector_add
1827 * Next we are adding lots of buttons, each one for a callback function
1828 * that will realize a task covering part of diskselector items API.
1829 * Lets check the first one:
1830 * @skipline elm_button_add
1831 * @until evas_object_show
1833 * We are labeling the button with a task description with
1834 * elm_object_text_set() and setting a callback
1835 * function evas_object_smart_callback_add().
1836 * Each callback function will have the signature:
1837 * <tt> static void _task_cb(void *data, Evas_Object *obj,
1838 * void *event_info)</tt> with the function name varying for each task.
1840 * Now let's cover all of them.
1842 * <b> Appending an item: </b>
1843 * @dontinclude diskselector_example_02.c
1847 * All items are included on diskselector after last one. You @b can't
1850 * The first parameter of elm_diskselector_item_append() is the diskselector
1851 * object, that we are receiving as data on our callback function.
1852 * The second one is a label, the string that will be placed in the center
1853 * of our item. As we don't wan't icons or callback functions, we can
1854 * send NULL as third, fourth and fifth parameters.
1856 * <b> Appending an item with icon: </b>
1857 * @dontinclude diskselector_example_02.c
1858 * @skipline _add_ic_cb
1861 * If an icon is required, you can pass it as third paramenter on our
1862 * elm_diskselector_item_append() function. It will be place on the
1863 * left side of item's label, that will be shifted to right a bit.
1865 * For more details about how to create icons, look for elm_icon examples.
1867 * <b> Appending an item with callback function for selected: </b>
1868 * @dontinclude diskselector_example_02.c
1873 * To set a callback function that will be called every time an item is
1874 * selected, i.e., everytime the diskselector stops with this item in
1875 * center position, just pass the function as fourth paramenter.
1877 * <b> Appending an item with callback function for selected with data: </b>
1878 * @dontinclude diskselector_example_02.c
1879 * @skipline _sel_data_cb
1885 * If the callback function request an extra data, it can be attached to our
1886 * item passing a pointer for data as fifth parameter.
1887 * Our function _sel_data_cb will receive it as <tt> void *data </tt>.
1889 * If you want to free this data, or handle that the way you need when the
1890 * item is deleted, set a callback function for that, with
1891 * elm_diskselector_item_del_cb_set().
1893 * As you can see we check if @c it is not @c NULL after appending it.
1894 * If an error happens, we won't try to set a function for it.
1896 * <b> Deleting an item: </b>
1897 * @dontinclude diskselector_example_02.c
1902 * To delete an item we simple need to call elm_diskselector_item_del() with
1903 * a pointer for such item.
1905 * If you need, you can get selected item with
1906 * elm_diskselector_selected_item_get(), that will return a pointer for it.
1908 * <b> Unselecting an item: </b>
1909 * @dontinclude diskselector_example_02.c
1910 * @skipline _unselect_cb
1913 * To select an item, you should call elm_diskselector_item_selected_set()
1914 * passing @c EINA_TRUE, and to unselect it, @c EINA_FALSE.
1916 * If you unselect the selected item, diskselector will automatically select
1919 * <b> Printing all items: </b>
1920 * @dontinclude diskselector_example_02.c
1921 * @skipline _print_cb
1924 * <b> Clearing the diskselector: </b>
1925 * @dontinclude diskselector_example_02.c
1926 * @skipline _clear_cb
1929 * <b> Selecting the first item: </b>
1930 * @dontinclude diskselector_example_02.c
1931 * @skipline _select_first_cb
1934 * <b> Selecting the last item: </b>
1935 * @dontinclude diskselector_example_02.c
1936 * @skipline _select_last_cb
1939 * <b> Selecting the next item: </b>
1940 * @dontinclude diskselector_example_02.c
1941 * @skipline _select_next_cb
1944 * <b> Selecting the previous item: </b>
1945 * @dontinclude diskselector_example_02.c
1946 * @skipline _select_prev_cb
1949 * See the full @ref diskselector_example_02.c "diskselector_example_02.c"
1950 * code, whose window should look like this picture:
1952 * @image html screenshots/diskselector_example_02.png
1953 * @image latex screenshots/diskselector_example_02.eps width=\textwidth
1955 * @example diskselector_example_02.c
1959 * @page list_example_01 List widget example
1961 * This code places a single Elementary list widgets on a window, just
1962 * to exemplify the more simple and common use case: a list will be created
1963 * and populated with a few items.
1965 * To keep it simple, we won't show how to customize the list, for this check
1966 * @ref list_example_02. Also, we won't focus
1967 * on items management on this example. For an example about this subject,
1968 * check @ref list_example_03.
1970 * To add a list widget.
1971 * @dontinclude list_example_01.c
1972 * @skipline elm_list_add
1974 * We are just adding the list, so as you can see, defaults for it are:
1975 * @li Items are displayed vertically.
1976 * @li Only one item can be selected.
1977 * @li The list doesn't bouce.
1979 * To add items, we are just appending it on a loop, using function
1980 * elm_list_item_append(), that will be better exaplained on
1981 * items management example.
1982 * @dontinclude list_example_01.c
1986 * @skipline elm_list_item_append
1988 * After we just want to show the list. But first we need to start the widget.
1989 * It was done this way to improve widget's performance. So, always remember
1991 * @warning Call elm_list_go before showing the object
1992 * @skipline elm_list_go
1995 * See the full @ref list_example_01.c "list_example_01.c"
1996 * code, whose window should look like this picture:
1998 * @image html screenshots/list_example_01.png
1999 * @image latex screenshots/list_example_01.eps width=\textwidth
2001 * @example list_example_01.c
2005 * @page list_example_02 List widget example
2007 * This code places a single Elementary list widgets on a window,
2008 * exemplifying a part of the widget's API.
2010 * First, we will just create a simple list, as done on @ref list_example_01 :
2011 * @dontinclude list_example_02.c
2014 * @skipline elm_list_add
2015 * @until elm_list_item_append
2017 * Now, let's customize this list a bit. First we will display items
2019 * @skipline horizontal_set
2021 * Then we will choose another list mode. There are four of them, and
2022 * the default #Elm_List_Mode is #ELM_LIST_SCROLL. Let's set compress mode:
2023 * @skipline mode_set
2025 * To enable multiple items selection, we need to enable it, since only one
2026 * selected item is allowed by default:
2027 * @skipline elm_list_multi_select_set
2029 * We are not adding items with callback functions here,
2030 * since we'll explain it better on @ref list_example_03. But if the callback
2031 * need to be called everytime user clicks an item, even if already selected,
2032 * it's required to enable this behavior:
2033 * @skipline elm_list_always_select_mode_set
2035 * Finally, if a bounce effect is required, or you would like to see
2036 * scrollbars, it is possible. But, for default theme, list
2037 * scrollbars will be invisible anyway.
2038 * @skipline bounce_set
2039 * @until SCROLLER_POLICY_ON
2041 * See the full @ref list_example_02.c "list_example_02.c"
2042 * code, whose window should look like this picture:
2044 * @image html screenshots/list_example_02.png
2045 * @image latex screenshots/list_example_02.eps width=\textwidth
2047 * @example list_example_02.c
2051 * @page list_example_03 List - Items management
2053 * This code places a Elementary list widgets on a window,
2054 * along with some buttons trigerring actions on it (though its API).
2055 * It covers most of Elm_List_Item functions.
2057 * On our @c main function, we are adding a default list with
2058 * 3 items. We are only setting their labels (second parameter of function
2059 * elm_list_item_append):
2060 * @dontinclude list_example_03.c
2061 * @skipline elm_list_add
2064 * Next we are adding lots of buttons, each one for a callback function
2065 * that will realize a task covering part of list items API.
2066 * Lets check the first one:
2067 * @skipline elm_button_add
2068 * @until evas_object_show
2070 * We are labeling the button with a task description with
2071 * elm_object_text_set() and setting a callback
2072 * function evas_object_smart_callback_add().
2073 * Each callback function will have the signature:
2074 * <tt> static void _task_cb(void *data, Evas_Object *obj,
2075 * void *event_info)</tt> with the function name varying for each task.
2077 * Now let's cover all of them.
2079 * <b> Prepending an item: </b>
2080 * @dontinclude list_example_03.c
2081 * @skipline _prepend_cb
2084 * The item will be placed on the begining of the list,
2085 * i.e. it will be the first one.
2087 * The first parameter of elm_list_item_prepend() is the list
2088 * object, that we are receiving as data on our callback function.
2089 * The second one is a label, the string that will be placed in the center
2090 * of our item. As we don't wan't icons or callback functions, we can
2091 * send NULL as third, fourth, fifth and sixth parameters.
2093 * <b> Appending an item: </b>
2094 * @dontinclude list_example_03.c
2098 * Items included with append will be inserted inserted after the last one.
2100 * <b> Appending an item with icon: </b>
2101 * @dontinclude list_example_03.c
2102 * @skipline _add_ic_cb
2105 * If an icon is required, you can pass it as third paramenter on our
2106 * elm_list_item_append() function. It will be place on the
2107 * left side of item's label. If an icon is wanted on the right side,
2108 * it should be passed as fourth parameter.
2110 * For more details about how to create icons, look for elm_icon examples
2111 * @ref tutorial_icon.
2113 * <b> Appending an item with callback function for selected: </b>
2114 * @dontinclude list_example_03.c
2119 * To set a callback function that will be called every time an item is
2120 * selected, i.e., everytime the list stops with this item in
2121 * center position, just pass the function as fifth paramenter.
2123 * <b> Appending an item with callback function for selected with data: </b>
2124 * @dontinclude list_example_03.c
2125 * @skipline _sel_data_cb
2131 * If the callback function request an extra data, it can be attached to our
2132 * item passing a pointer for data as sixth parameter.
2133 * Our function _sel_data_cb will receive it as <tt> void *data </tt>.
2135 * If you want to free this data, or handle that the way you need when the
2136 * item is deleted, set a callback function for that, with
2137 * elm_list_item_del_cb_set().
2139 * As you can see we check if @c it is not @c NULL after appending it.
2140 * If an error happens, we won't try to set a function for it.
2142 * <b> Deleting an item: </b>
2143 * @dontinclude list_example_03.c
2144 * @skipline _del_cb(
2147 * To delete an item we simple need to call elm_list_item_del() with
2148 * a pointer for such item.
2150 * If you need, you can get selected item with
2151 * elm_list_selected_item_get(), that will return a pointer for it.
2153 * <b> Unselecting an item: </b>
2154 * @dontinclude list_example_03.c
2155 * @skipline _unselect_cb
2158 * To select an item, you should call elm_list_item_selected_set()
2159 * passing @c EINA_TRUE, and to unselect it, @c EINA_FALSE.
2161 * <b> Printing all items: </b>
2162 * @dontinclude list_example_03.c
2163 * @skipline _print_cb
2166 * <b> Clearing the list: </b>
2167 * @dontinclude list_example_03.c
2168 * @skipline _clear_cb
2171 * <b> Selecting the next item: </b>
2172 * @dontinclude list_example_03.c
2173 * @skipline _select_next_cb
2176 * <b> Inserting after an item: </b>
2177 * @dontinclude list_example_03.c
2178 * @skipline _insert_after_cb
2181 * <b> Selecting the previous item: </b>
2182 * @dontinclude list_example_03.c
2183 * @skipline _select_prev_cb
2186 * <b> Inserting before an item: </b>
2187 * @dontinclude list_example_03.c
2188 * @skipline _insert_before_cb
2191 * If a separator is required, just set an item as such:
2192 * @dontinclude list_example_03.c
2193 * @skipline _set_separator_cb
2196 * Also an item can be disabled, and the user won't be allowed to (un)select it:
2197 * @dontinclude list_example_03.c
2198 * @skipline _disable_cb
2201 * See the full @ref list_example_03.c "list_example_03.c"
2202 * code, whose window should look like this picture:
2204 * @image html screenshots/list_example_03.png
2205 * @image latex screenshots/list_example_03.eps width=\textwidth
2207 * @example list_example_03.c
2211 * @page flipselector_example Flip selector widget example
2213 * This code places an Elementary flip selector widget on a window,
2214 * along with two buttons trigerring actions on it (though its API).
2216 * The selector is being populated with the following items:
2217 * @dontinclude flipselector_example.c
2221 * Next, we create it, populating it with those items and registering
2222 * two (smart) callbacks on it:
2223 * @dontinclude flipselector_example.c
2224 * @skip fp = elm_flipselector_add
2225 * @until object_show
2227 * Those two callbacks will take place whenever one of those smart
2228 * events occur, and they will just print something to @c stdout:
2229 * @dontinclude flipselector_example.c
2230 * @skip underflow callback
2231 * @until static void
2232 * Flip the sheets on the widget while looking at the items list, in
2233 * the source code, and you'll get the idea of those events.
2235 * The two buttons below the flip selector will take the actions
2236 * described in their labels:
2237 * @dontinclude flipselector_example.c
2238 * @skip bt = elm_button_add
2239 * @until callback_add(win
2241 * @dontinclude flipselector_example.c
2242 * @skip unselect the item
2245 * Click on them to exercise those flip selector API calls. To
2246 * interact with the other parts of this API, there's a command line
2247 * interface, whose help string can be asked for with the 'h' key:
2248 * @dontinclude flipselector_example.c
2252 * The 'n' and 'p' keys will exemplify elm_flipselector_flip_next()
2253 * and elm_flipselector_flip_prev(), respectively. 'f' and 'l' account
2254 * for elm_flipselector_first_item_get() and
2255 * elm_flipselector_last_item_get(), respectively. Finally, 's' will
2256 * issue elm_flipselector_selected_item_get() on our example flip
2259 * See the full @ref flipselector_example.c "example", whose window should
2260 * look like this picture:
2262 * @image html screenshots/flipselector_example.png
2263 * @image latex screenshots/flipselector_example.eps width=\textwidth
2265 * See the full @ref flipselector_example_c "source code" for this example.
2267 * @example flipselector_example.c
2271 * @page fileselector_example File selector widget example
2273 * This code places two Elementary file selector widgets on a window.
2274 * The one on the left is layouting file system items in a @b list,
2275 * while the the other is layouting them in a @b grid.
2277 * The one having the majority of hooks of interest is on the left,
2278 * which we create as follows:
2279 * @dontinclude fileselector_example.c
2280 * @skip first file selector
2281 * @until object_show
2283 * Note that we enable custom edition of file/directory selection, via
2284 * the text entry it has on its bottom, via
2285 * elm_fileselector_is_save_set(). It starts with the list view, which
2286 * is the default, and we make it not expandable in place
2287 * (elm_fileselector_expandable_set()), so that it replaces its view's
2288 * contents with the current directory's entries each time one
2289 * navigates to a different folder. For both of file selectors we are
2290 * starting to list the contents found in the @c "/tmp" directory
2291 * (elm_fileselector_path_set()).
2293 * Note the code setting it to "grid mode" and observe the differences
2294 * in the file selector's views, in the example. We also hide the
2295 * second file selector's Ok/Cancel buttons -- since it's there just
2296 * to show the grid view (and navigation) -- via
2297 * elm_fileselector_buttons_ok_cancel_set().
2299 * The @c "done" event, which triggers the callback below
2300 * @dontinclude fileselector_example.c
2303 * will be called at the time one clicks the "Ok"/"Cancel" buttons of
2304 * the file selector (on the left). Note that it will print the path
2305 * to the current selection, if any.
2307 * The @c "selected" event, which triggers the callback below
2308 * @dontinclude fileselector_example.c
2309 * @skip bt = 'selected' cb
2311 * takes place when one selects a file (if the file selector is @b not
2312 * under folders-only mode) or when one selects a folder (when in
2313 * folders-only mode). Experiment it by selecting different file
2316 * What comes next is the code creating the three check boxes and two
2317 * buttons below the file selector in the right. They will exercise a
2318 * bunch of functions on the file selector's API, for the instance on
2319 * the left. Experiment with them, specially the buttons, to get the
2320 * difference between elm_fileselector_path_get() and
2321 * elm_fileselector_selected_get().
2323 * Finally, there's the code adding the second file selector, on the
2325 * @dontinclude fileselector_example.c
2326 * @skip second file selector
2327 * @until object_show
2329 * Pay attention to the code setting it to "grid mode" and observe the
2330 * differences in the file selector's views, in the example. We also
2331 * hide the second file selector's Ok/Cancel buttons -- since it's
2332 * there just to show the grid view (and navigation) -- via
2333 * elm_fileselector_buttons_ok_cancel_set().
2335 * See the full @ref fileselector_example.c "example", whose window
2336 * should look like this picture:
2338 * @image html screenshots/fileselector_example.png
2339 * @image latex screenshots/fileselector_example.eps width=\textwidth
2341 * See the full @ref fileselector_example_c "source code" for this example.
2343 * @example fileselector_example.c
2347 * @page fileselector_button_example File selector button widget example
2349 * This code places an Elementary file selector button widget on a
2350 * window, along with some other checkboxes and a text entry. Those
2351 * are there just as knobs on the file selector button's state and to
2352 * display information from it.
2354 * Here's how we instantiate it:
2355 * @dontinclude fileselector_button_example.c
2356 * @skip ic = elm_icon_add
2357 * @until evas_object_show
2359 * Note that we set on it both icon and label decorations. It's set to
2360 * list the contents of the @c "/tmp" directory, too, with
2361 * elm_fileselector_button_path_set(). What follows are checkboxes to
2362 * exercise some of its API funtions:
2363 * @dontinclude fileselector_button_example.c
2364 * @skip ck = elm_check_add
2365 * @until evas_object_show(en)
2367 * The checkboxes will toggle whether the file selector button's
2368 * internal file selector:
2369 * - must have an editable text entry for file names (thus, be in
2370 * "save dialog mode")
2371 * - is to be raised as an "inner window" (note it's the default
2372 * behavior) or as a dedicated window
2373 * - is to populate its view with folders only
2374 * - is to expand its folders, in its view, <b>in place</b>, and not
2375 * repainting it entirely just with the contents of a sole
2378 * The entry labeled @c "Last selection" will exercise the @c
2379 * "file,chosen" smart event coming from the file selector button:
2380 * @dontinclude fileselector_button_example.c
2382 * @until toggle inwin
2384 * Whenever you dismiss or acknowledges the file selector, after it's
2385 * raised, the @c event_info string will contain the last selection on
2386 * it (if any was made).
2388 * This is how the example, just after called, should look like:
2390 * @image html screenshots/fileselector_button_example_00.png
2391 * @image latex screenshots/fileselector_button_example_00.eps width=\textwidth
2393 * Click on the file selector button to raise its internal file
2394 * selector, which will be contained on an <b>"inner window"</b>:
2396 * @image html screenshots/fileselector_button_example_01.png
2397 * @image latex screenshots/fileselector_button_example_01.eps width=\textwidth
2399 * Toggle the "inwin mode" switch off and, if you click on the file
2400 * selector button again, you'll get @b two windows, the original one
2401 * (note the last selection there!)
2403 * @image html screenshots/fileselector_button_example_02.png
2404 * @image latex screenshots/fileselector_button_example_02.eps width=\textwidth
2406 * and the file selector's new one
2408 * @image html screenshots/fileselector_button_example_03.png
2409 * @image latex screenshots/fileselector_button_example_03.eps width=\textwidth
2411 * Play with the checkboxes to get the behavior changes on the file
2412 * selector button. The respective API calls on the widget coming from
2413 * those knobs where shown in the code already.
2415 * See the full @ref fileselector_button_example_c "source code" for
2418 * @example fileselector_button_example.c
2422 * @page fileselector_entry_example File selector entry widget example
2424 * This code places an Elementary file selector entry widget on a
2425 * window, along with some other checkboxes. Those are there just as
2426 * knobs on the file selector entry's state.
2428 * Here's how we instantiate it:
2429 * @dontinclude fileselector_entry_example.c
2430 * @skip ic = elm_icon_add
2431 * @until evas_object_show
2433 * Note that we set on it's button both icon and label
2434 * decorations. It's set to exhibit the path of (and list the contents
2435 * of, when internal file selector is launched) the @c "/tmp"
2436 * directory, also, with elm_fileselector_entry_path_set(). What
2437 * follows are checkboxes to exercise some of its API funtions:
2438 * @dontinclude fileselector_entry_example.c
2439 * @skip ck = elm_check_add
2440 * @until callback_add(fs_entry
2442 * The checkboxes will toggle whether the file selector entry's
2443 * internal file selector:
2444 * - must have an editable text entry for file names (thus, be in
2445 * "save dialog mode")
2446 * - is to be raised as an "inner window" (note it's the default
2447 * behavior) or as a dedicated window
2448 * - is to populate its view with folders only
2449 * - is to expand its folders, in its view, <b>in place</b>, and not
2450 * repainting it entirely just with the contents of a sole
2453 * Observe how the entry's text will match the string coming from the
2454 * @c "file,chosen" smart event:
2455 * @dontinclude fileselector_entry_example.c
2458 * Whenever you dismiss or acknowledges the file selector, after it's
2459 * raised, the @c event_info string will contain the last selection on
2460 * it (if any was made).
2462 * Try, also, to type in a valid system path and, then, open the file
2463 * selector's window: it will start the file browsing there, for you.
2465 * This is how the example, just after called, should look like:
2467 * @image html screenshots/fileselector_entry_example_00.png
2468 * @image latex screenshots/fileselector_entry_example_00.eps width=\textwidth
2470 * Click on the file selector entry to raise its internal file
2471 * selector, which will be contained on an <b>"inner window"</b>:
2473 * @image html screenshots/fileselector_entry_example_01.png
2474 * @image latex screenshots/fileselector_entry_example_01.eps width=\textwidth
2476 * Toggle the "inwin mode" switch off and, if you click on the file
2477 * selector entry again, you'll get @b two windows, the original one
2478 * (note the last selection there!)
2480 * @image html screenshots/fileselector_entry_example_02.png
2481 * @image latex screenshots/fileselector_entry_example_02.eps width=\textwidth
2483 * and the file selector's new one
2485 * @image html screenshots/fileselector_entry_example_03.png
2486 * @image latex screenshots/fileselector_entry_example_03.eps width=\textwidth
2488 * Play with the checkboxes to get the behavior changes on the file
2489 * selector entry. The respective API calls on the widget coming from
2490 * those knobs where shown in the code already.
2492 * See the full @ref fileselector_entry_example_c "source code" for
2495 * @example fileselector_entry_example.c
2499 * @page layout_example_01 Layout - Content, Table and Box
2501 * This example shows how one can use the @ref Layout widget to create a
2502 * customized distribution of widgets on the screen, controled by an Edje theme.
2503 * The full source code for this example can be found at @ref
2504 * layout_example_01_c.
2506 * Our custom layout is defined by a file, @ref layout_example_edc, which is an
2507 * Edje theme file. Look for the Edje documentation to understand it. For now,
2508 * it's enough to know that we describe some specific parts on this layout
2510 * @li a title text field;
2511 * @li a box container;
2512 * @li a table container;
2513 * @li and a content container.
2515 * Going straight to the code, the following snippet instantiates the layout
2518 * @dontinclude layout_example_01.c
2519 * @skip elm_layout_add
2520 * @until evas_object_show(layout)
2522 * As any other widget, we set some properties for the size calculation. But
2523 * notice on this piece of code the call to the function elm_layout_file_set().
2524 * Here is where the theme file is loaded, and particularly the specific group
2525 * from this theme file. Also notice that the theme file here is referenced as
2526 * an .edj, which is a .edc theme file compiled to its binary form. Again, look
2527 * for the Edje documentation for more information about theme files.
2529 * Next, we fetch from our theme a data string referenced by the key "title".
2530 * This data was defined in the theme, and can be used as parameters which the
2531 * program get from the specific theme that it is using. In this case, we store
2532 * the title of this window and program in the theme, as a "data" entry, just
2533 * for demonstration purposes:
2537 * This call elm_layout_data_get() is used to fetch the string based on the key,
2538 * and elm_object_text_part_set() will set the part defined in the theme as
2539 * "example/title" to contain this string. This key "example/title" has nothing
2540 * special. It's just an arbitrary convention that we are using in this example.
2541 * Every string in this example referencing a part of this theme will be of the
2542 * form "example/<something>".
2544 * Now let's start using our layout to distribute things on the window space.
2545 * Since the layout was added as a resize object to the elementary window, it
2546 * will always occupy the entire space available for this window.
2548 * The theme already has a title, and it also defines a table element which is
2549 * positioned approximately between 50% and 70% of the height of this window,
2550 * and has 100% of the width. We create some widgets (two icons, a clock and a
2551 * button) and pack them inside the table, in a distribution similar to a HTML
2554 * @until evas_object_show(bt)
2556 * Notice that we just set size hints for every object, and call the function
2557 * elm_layout_table_pack(), which does all the work. It will place the elements
2558 * in the specified row/column, with row and column span if required, and then
2559 * the object's size and position will be controled by the layout widget. It
2560 * will also respect size hints, alignments and weight properties set to these
2561 * widgets. The resulting distribution on the screen depends on the table
2562 * properties (described in the theme), the size hints set on each widget, and
2563 * on the cells of the table that are being used.
2565 * For instance, we add the two icons and the clock on the first, second and
2566 * third cells of the first row, and add the button the second row, making it
2567 * span for 3 columns (thus having the size of the entire table width). This
2568 * will result in a table that has 2 rows and 3 columns.
2570 * Now let's add some widgets to the box area of our layout. This box is around
2571 * 20% and 50% of the vertical size of the layout, and 100% of its width. The
2572 * theme defines that it will use an "horizontal flow" distribution to its
2573 * elements. Unlike the table, a box will distribute elements without knowing
2574 * about rows and columns, and the distribution function selected will take care
2575 * of putting them in row, column, both, or any other available layout. This is
2576 * also described in the Edje documentation.
2578 * This box area is similar to the @ref Box widget of elementary, with the
2579 * difference that its position and properties are controled by the theme of the
2580 * layout. It also contains more than one API to add items to it, since the
2581 * items position now is defined in terms of a list of items, not a matrix.
2582 * There's the first position (can have items added to it with
2583 * elm_layout_box_prepend()), the last position (elm_layout_box_append()), the
2584 * nth position (elm_layout_box_insert_at()) and the position right before an
2585 * element (elm_layout_box_insert_before()). We use insert_at and prepend
2586 * functions to add the first two buttons to this box, and insert_before on the
2587 * callback of each button. The callback code will be shown later, but it
2588 * basically adds a button just before the clicked button using the
2589 * elm_layout_box_insert_before() function. Here's the code for adding the first
2592 * @until evas_object_show(item)
2593 * @until evas_object_show(item)
2595 * Finally, we have an area in this layout theme, in the bottom part of it,
2596 * reserved for adding an specific widget. Differently from the 2 parts
2597 * described until now, this one can only receive one widget with the call
2598 * elm_layout_content_set(). If there was already an item on this specific part,
2599 * it will be deleted (one can use elm_layout_content_unset() in order to remove
2600 * it without deleting). An example of removing it without deleting, but
2601 * manually deleting this widget just after that, can be seen on the callback
2602 * for this button. Actually, the callback defined for this button will clean
2603 * the two other parts (deleting all of their elements) and then remove and
2604 * delete this button.
2606 * @until _swallow_btn_cb
2608 * Also notice that, for this last added button, we don't have to call
2609 * evas_object_show() on it. This is a particularity of the theme for layouts,
2610 * that will have total control over the properties like size, position,
2611 * visibility and clipping of a widget added with elm_layout_content_set().
2612 * Again, read the Edje documentation to understand this better.
2614 * Now we just put the code for the different callbacks specified for each kind
2615 * of button and make simple comments about them:
2617 * @dontinclude layout_example_01.c
2619 * @until evas_object_del(item)
2622 * The first callback is used for the button in the table, and will just remove
2623 * itself from the table with elm_layout_table_unpack(), which remove items
2624 * without deleting them, and then calling evas_object_del() on itself.
2626 * The second callback is for buttons added to the box. When clicked, these
2627 * buttons will create a new button, and add them to the same box, in the
2628 * position just before the clicked button.
2630 * And the last callback is for the button added to the "content" area. It will
2631 * clear both the table and the box, passing @c EINA_TRUE to their respective @c
2632 * clear parameters, which will imply on the items of these containers being
2635 * A screenshot of this example can be seen on:
2637 * @image html screenshots/layout_example_01.png
2638 * @image latex screenshots/layout_example_01.eps width=\textwidth
2643 * @page layout_example_02 Layout - Predefined Layout
2645 * This example shows how one can use the @ref Layout with a predefined theme
2646 * layout to add a back and next button to a simple window. The full source code
2647 * for this example can be found at @ref layout_example_02_c.
2649 * After setting up the window and background, we add the layout widget to the
2650 * window. But instead of using elm_layout_file_set() to load its theme from a
2651 * custom theme file, we can use elm_layout_theme_set() to load one of the
2652 * predefined layouts that come with elementary. Particularly on this example,
2653 * we load the them of class "layout", group "application" and style
2654 * "content-back-next" (since we want the back and next buttons).
2656 * @dontinclude layout_example_02.c
2657 * @skip elm_layout_add
2658 * @until evas_object_show(layout)
2660 * This default theme contains only a "content" area named
2661 * "elm.swallow.content", where we can add any widget (it can be even a
2662 * container widget, like a box, frame, list, or even another layout). Since we
2663 * just want to show the resulting layout, we add a simple icon to it:
2665 * @until layout_content_set
2667 * This default layout also provides some signals when the next and prev buttons
2668 * are clicked. We can register callbacks to them with the
2669 * elm_object_signal_callback_add() function:
2671 * @until elm,action,next
2673 * In the @ref layout_example_03 you can see how to send signals to the layout with
2674 * elm_object_signal_emit().
2676 * Now our callback just changes the picture being displayed when one of the
2677 * buttons are clicked:
2679 * @dontinclude layout_example_02.c
2681 * @until standard_set
2684 * It's possible to see that it gets the name of the image being shown from the
2685 * array of image names, going forward on this array when "next" is clicked and
2686 * backward when "back" is clicked.
2688 * A screenshot of this example can be seen on:
2690 * @image html screenshots/layout_example_02.png
2691 * @image latex screenshots/layout_example_02.eps width=\textwidth
2695 * @page layout_example_03 Layout - Signals and Size Changed
2697 * This example shows how one can send and receive signals to/from the layout,
2698 * and what to do when the layout theme has its size changed. The full source
2699 * code for this example can be found at @ref layout_example_03_c.
2701 * In this exmaple we will use another group from the same layout theme file
2702 * used in @ref layout_example_01. Its instanciation and loading happens in the
2705 * @dontinclude layout_example_03.c
2706 * @skip elm_layout_add
2707 * @until evas_object_show
2709 * This time we register a callback to be called whenever we receive a signal
2710 * after the end of the animation that happens in this layout:
2712 * @until signal_callback_add
2714 * We also add a button that will send signals to the layout:
2716 * @until callback_add
2718 * The callback for this button will check what type of signal it should send,
2719 * and then emit it. The code for this callback follows:
2721 * @dontinclude layout_exmaple_03.c
2722 * @skip static Eina_Bool
2727 * As we said before, we are receiving a signal whenever the animation started
2728 * by the button click ends. This is the callback for that signal:
2732 * Notice from this callback that the elm_layout_sizing_eval() function must be
2733 * called if we want our widget to update its size after the layout theme having
2734 * changed its minimum size. This happens because the animation specified in the
2735 * theme increases the size of the content area to a value higher than the
2736 * widget size, thus requiring more space. But the elementary layout widget
2737 * has no way to know this, thus needing the elm_layout_sizing_eval() to
2738 * be called on the layout, informing that this size has changed.
2740 * A screenshot of this example can be seen on:
2742 * @image html screenshots/layout_example_03.png
2743 * @image latex screenshots/layout_example_03.eps width=\textwidth
2747 * @page tutorial_hover Hover example
2748 * @dontinclude hover_example_01.c
2750 * On this example we are going to have a button that when clicked will show our
2751 * hover widget, this hover will have content set on it's left, top, right and
2752 * middle positions. In the middle position we are placing a button that when
2753 * clicked will hide the hover. We are also going to use a non-default theme
2754 * for our hover. We won't explain the functioning of button for that see @ref
2757 * We start our example with a couple of callbacks that show and hide the data
2758 * they're given(which we'll see later on is the hover widget):
2763 * In our main function we'll do some initialization and then create 3
2764 * rectangles, one red, one green and one blue to use in our hover. We'll also
2765 * create the 2 buttons that will show and hide the hover:
2768 * With all of that squared away we can now get to the heart of the matter,
2769 * creating our hover widget, which is easy as pie:
2772 * Having created our hover we now need to set the parent and target. Which if
2773 * you recall from the function documentations are going to tell the hover which
2774 * area it should cover and where it should be centered:
2777 * Now we set the theme for our hover. We're using the popout theme which gives
2778 * our contents a white background and causes their appearance to be animated:
2781 * And finally we set the content for our positions:
2784 * So far so good? Great 'cause that's all there is too it, what is left now is
2785 * just connecting our buttons to the callbacks we defined at the beginning of
2786 * the example and run the main loop:
2789 * Our example will initially look like this:
2791 * @image html screenshots/hover_example_01.png
2792 * @image latex screenshots/hover_example_01.eps width=\textwidth
2794 * And after you click the "Show hover" button it will look like this:
2796 * @image html screenshots/hover_example_01_a.png
2797 * @image latex screenshots/hover_example_01_a.eps width=\textwidth
2799 * @example hover_example_01.c
2803 * @page tutorial_flip Flip example
2804 * @dontinclude flip_example_01.c
2806 * This example will show a flip with two rectangles on it(one blue, one
2807 * green). Our example will allow the user to choose the animation the flip
2808 * uses and to interact with it. To allow the user to choose the interaction
2809 * mode we use radio buttons, we will however not explain them, if you would
2810 * like to know more about radio buttons see @ref radio.
2812 * We start our example with the usual setup and then create the 2 rectangles
2813 * we will use in our flip:
2814 * @until show(rect2)
2816 * The next thing to do is to create our flip and set it's front and back
2820 * The next thing we do is set the interaction mode(which the user can later
2821 * change) to the page animation:
2824 * Setting a interaction mode however is not sufficient, we also need to
2825 * choose which directions we allow interaction from, for this example we
2826 * will use all of them:
2829 * We are also going to set the hitsize to the entire flip(in all directions)
2830 * to make our flip very easy to interact with:
2833 * After that we create our radio buttons and start the main loop:
2836 * When the user clicks a radio button a function that changes the
2837 * interaction mode and animates the flip is called:
2839 * @note The elm_flip_go() call here serves no purpose other than to
2840 * ilustrate that it's possible to animate the flip programmatically.
2842 * Our example will look like this:
2844 * @image html screenshots/flip_example_01.png
2845 * @image latex screenshots/flip_example_01.eps width=\textwidth
2847 * @note Since this is an animated example the screenshot doesn't do it
2848 * justice, it is a good idea to compile it and see the animations.
2850 * @example flip_example_01.c
2854 * @page tutorial_label Label example
2855 * @dontinclude label_example_01.c
2857 * In this example we are going to create 6 labels, set some properties on
2858 * them and see what changes in appearance those properties cause.
2860 * We start with the setup code that by now you should be familiar with:
2863 * For our first label we have a moderately long text(that doesn't fit in the
2864 * label's width) so we will make it a sliding label. Since the text isn't
2865 * too long we don't need the animation to be very long, 3 seconds should
2866 * give us a nice speed:
2869 * For our second label we have the same text, but this time we aren't going
2870 * to have it slide, we're going to ellipsize it. Because we ask our label
2871 * widget to ellipsize the text it will first diminsh the fontsize so that it
2872 * can show as much of the text as possible:
2875 * For the third label we are going to ellipsize the text again, however this
2876 * time to make sure the fontsize isn't diminshed we will set a line wrap.
2877 * The wrap won't actually cause a line break because we set the label to
2881 * For our fourth label we will set line wrapping but won't set ellipsis, so
2882 * that our text will indeed be wrapped instead of ellipsized. For this label
2883 * we choose character wrap:
2886 * Just two more, for our fifth label we do the same as for the fourth
2887 * except we set the wrap to word:
2890 * And last but not least for our sixth label we set the style to "marker" and
2891 * the color to red(the default color is white which would be hard to see on
2892 * our white background):
2895 * Our example will look like this:
2897 * @image html screenshots/label_example_01.png
2898 * @image latex screenshots/label_example_01.eps width=\textwidth
2900 * @example label_example_01.c
2904 * @page tutorial_image Image example
2905 * @dontinclude image_example_01.c
2907 * This example is as simple as possible. An image object will be added to the
2908 * window over a white background, and set to be resizeable together with the
2909 * window. All the options set through the example will affect the behavior of
2912 * We start with the code for creating a window and its background, and also
2913 * add the code to write the path to the image that will be loaded:
2918 * Now we create the image object, and set that file to be loaded:
2922 * We can now go setting our options.
2924 * elm_image_no_scale_set() is used just to set this value to true (we
2925 * don't want to scale our image anyway, just resize it).
2927 * elm_image_scale_set() is used to allow the image to be resized to a size
2928 * smaller than the original one, but not to a size bigger than it.
2930 * elm_elm_image_smooth_set() will disable the smooth scaling, so the scale
2931 * algorithm used to scale the image to the new object size is going to be
2932 * faster, but with a lower quality.
2934 * elm_image_orient_set() is used to flip the image around the (1, 0) (0, 1)
2937 * elm_image_aspect_ratio_retained_set() is used to keep the original aspect
2938 * ratio of the image, even when the window is resized to another aspect ratio.
2940 * elm_image_fill_outside_set() is used to ensure that the image will fill the
2941 * entire area available to it, even if keeping the aspect ratio. The image
2942 * will overflow its width or height (any of them that is necessary) to the
2943 * object area, instead of resizing the image down until it can fit entirely in
2946 * elm_image_editable_set() is used just to cover the API, but won't affect
2947 * this example since we are not using any copy & paste property.
2949 * This is the code for setting these options:
2953 * Now some last touches in our object size hints, window and background, to
2954 * display this image properly:
2958 * This example will look like this:
2960 * @image html screenshots/image_example_01.png
2961 * @image latex screenshots/image_example_01.eps width=\textwidth
2963 * @example image_example_01.c
2967 * @page tutorial_icon Icon example
2968 * @dontinclude icon_example_01.c
2970 * This example is as simple as possible. An icon object will be added to the
2971 * window over a white background, and set to be resizeable together with the
2972 * window. All the options set through the example will affect the behavior of
2975 * We start with the code for creating a window and its background:
2980 * Now we create the icon object, and set lookup order of the icon, and choose
2985 * An intersting thing is that after setting this, it's possible to check where
2986 * in the filesystem is the theme used by this icon, and the name of the group
2991 * We can now go setting our options.
2993 * elm_icon_no_scale_set() is used just to set this value to true (we
2994 * don't want to scale our icon anyway, just resize it).
2996 * elm_icon_scale_set() is used to allow the icon to be resized to a size
2997 * smaller than the original one, but not to a size bigger than it.
2999 * elm_elm_icon_smooth_set() will disable the smooth scaling, so the scale
3000 * algorithm used to scale the icon to the new object size is going to be
3001 * faster, but with a lower quality.
3003 * elm_icon_fill_outside_set() is used to ensure that the icon will fill the
3004 * entire area available to it, even if keeping the aspect ratio. The icon
3005 * will overflow its width or height (any of them that is necessary) to the
3006 * object area, instead of resizing the icon down until it can fit entirely in
3009 * This is the code for setting these options:
3011 * @until fill_outside
3013 * However, if you try this example you may notice that this image is not being
3014 * affected by all of these options. This happens because the used icon will be
3015 * from elementary theme, and thus it has its own set of options like smooth
3016 * scaling and fill_outside options. You can change the "home" icon to use some
3017 * image (from your system) and see that then those options will be respected.
3019 * Now some last touches in our object size hints, window and background, to
3020 * display this icon properly:
3024 * This example will look like this:
3026 * @image html screenshots/icon_example_01.png
3027 * @image latex screenshots/icon_example_01.eps width=\textwidth
3029 * @example icon_example_01.c
3033 * @page tutorial_hoversel Hoversel example
3034 * @dontinclude hoversel_example_01.c
3036 * In this example we will create a hoversel with 3 items, one with a label but
3037 * no icon and two with both a label and an icon. Every item that is clicked
3038 * will be deleted, but everytime the hoversel is activated we will also add an
3039 * item. In addition our first item will print all items when clicked and our
3040 * third item will clear all items in the hoversel.
3042 * We will start with the normal creation of window stuff:
3045 * Next we will create a red rectangle to use as the icon of our hoversel:
3048 * And now we create our hoversel and set some of it's properties. We set @p win
3049 * as its parent, ask it to not be horizontal(be vertical) and give it a label
3053 * Next we will add our three items, setting a callback to be called for the
3057 * We also set a pair of callbacks to be called whenever any item is selected or
3058 * when the hoversel is activated:
3061 * And then ask that our hoversel be shown and run the main loop:
3064 * We now have the callback for our first item which prints all items in the
3068 * Next we have the callback for our third item which removes all items from the
3072 * Next we have the callback that is called whenever an item is clicked and
3073 * deletes that item:
3076 * And the callback that is called when the hoversel is activated and adds an
3077 * item to the hoversel. Note that since we allocate memory for the item we need
3078 * to know when the item dies so we can free that memory:
3081 * And finally the callback that frees the memory we allocated for items created
3082 * in the @p _add_item callback:
3085 * Our example will initially look like this:
3087 * @image html screenshots/hoversel_example_01.png
3088 * @image latex screenshots/hoversel_example_01.eps width=\textwidth
3090 * And when the hoversel is clicked it will look like this:
3092 * @image html screenshots/hoversel_example_01_a.png
3093 * @image latex screenshots/hoversel_example_01_a.eps width=\textwidth
3095 * @example hoversel_example_01.c
3099 * @page conformant_example Conformant Example.
3101 * In this example we'll explain how to create applications to work
3102 * with illume, considering space required for virtual keyboards, indicator
3105 * Illume is a module for Enlightenment that modifies the user interface
3106 * to work cleanly and nicely on a mobile device. It has support for
3107 * virtual keyboard, among other nice features.
3109 * Let's start creating a very simple window with a vertical box
3110 * with multi-line entry between two buttons.
3111 * This entry will expand filling all space on window not used by buttons.
3113 * @dontinclude conformant_example_01.c
3114 * @skipline elm_main
3117 * For information about how to create windows, boxes, buttons or entries,
3118 * look for documentation for these widgets.
3120 * It will looks fine when you don't need a virtual keyboard, as you
3121 * can see on the following image:
3123 * @image html screenshots/conformant_example_01.png
3124 * @image latex screenshots/conformant_example_01.eps width=\textwidth
3126 * But if you call a virtual keyboard, the window will resize, changing
3127 * widgets size and position. All the content will shrink.
3129 * If you don't want such behaviour, you
3130 * will need a conformant to account for space taken up by the indicator,
3131 * virtual keyboard and softkey.
3133 * In this case, using the conformant in a proper way, you will have
3134 * a window like the following:
3136 * @image html screenshots/conformant_example_02.png
3137 * @image latex screenshots/conformant_example_02.eps width=\textwidth
3139 * As you can see, it guess the space that will be required by the keyboard,
3140 * indicator and softkey bars.
3142 * So, let's study each step required to transform our initial example on
3145 * First of all, we need to set the window as an illume conformant window:
3146 * @dontinclude conformant_example_02.c
3147 * @skipline elm_win_conformant_set
3149 * Next, we'll add a conformant widget, and set it to resize with the window,
3150 * instead of the box.
3152 * @until evas_object_show
3154 * Finally, we'll set the box as conformant's content, just like this:
3155 * @skipline elm_conformant_content_set
3157 * Compare both examples code:
3158 * @ref conformant_example_01.c "conformant_example_01.c"
3159 * @ref conformant_example_02.c "conformant_example_02.c"
3161 * @example conformant_example_01.c
3162 * @example conformant_example_02.c
3166 * @page index_example_01 Index widget example 1
3168 * This code places an Elementary index widget on a window, which also
3169 * has a very long list of arbitrary strings on it. The list is
3170 * sorted alphabetically and the index will be used to index the first
3171 * items of each set of strings beginning with an alphabet letter.
3173 * Below the list are some buttons, which are there just to exercise
3174 * some index widget's API.
3176 * Here's how we instantiate it:
3177 * @dontinclude index_example_01.c
3178 * @skip elm_list_add
3179 * @until evas_object_show(d.index)
3180 * where we're showing also the list being created. Note that we issue
3181 * elm_win_resize_object_add() on the index, so that it's set to have
3182 * the whole window as its container. Then, we have to populate both
3183 * list and index widgets:
3184 * @dontinclude index_example_01.c
3185 * @skip for (i = 0; i < (sizeof(dict) / sizeof(dict[0])); i++)
3189 * The strings populating the list come from a file
3190 * @dontinclude index_example_01.c
3191 * @skip static const char *dict
3194 * We use the @c curr char variable to hold the last initial letter
3195 * seen on that ordered list of strings, so that we're able to have an
3196 * index item pointing to each list item starting a new letter
3197 * "section". Note that our index item data pointers will be the list
3198 * item handles. We are also setting a callback function to index
3199 * items deletion events:
3200 * @dontinclude index_example_01.c
3204 * There, we show you that the @c event_info pointer will contain the
3205 * item in question's data, i.e., a given list item's pointer. Because
3206 * item data is also returned in the @c data argument on
3207 * @c Evas_Smart_Cb functions, those two pointers must have the same
3208 * values. On this deletion callback, we're deleting the referred list
3209 * item too, just to exemplify that anything could be done there.
3211 * Next, we hook to two smart events of the index object:
3212 * @dontinclude index_example_01.c
3213 * @skip smart_callback_add(d.index
3214 * @until _index_selected
3215 * @dontinclude index_example_01.c
3216 * @skip "delay,changed" hook
3220 * Check that, whenever one holds the mouse pressed over a given index
3221 * letter for some time, the list beneath it will roll down to the
3222 * item pointed to by that index item. When one releases the mouse
3223 * button, the second callback takes place. There, we check that the
3224 * reported item data, on @c event_info, is the same reported by
3225 * elm_index_item_selected_get(), which gives the last selection's
3226 * data on the index widget.
3228 * The first of the three buttons that follow will call
3229 * elm_index_active_set(), thus showing the index automatically for
3230 * you, if it's not already visible, what is checked with
3231 * elm_index_active_get(). The second button will exercise @b deletion
3232 * of index item objects, by the following code:
3233 * @dontinclude index_example_01.c
3234 * @skip delete an index item
3237 * It will get the last index item selected's data and find the
3238 * respective #Elm_Index_Item handle with elm_index_item_find(). We
3239 * need the latter to query the indexing letter string from, with
3240 * elm_index_item_letter_get(). Next, comes the delition, itself,
3241 * which will also trigger the @c _index_item_del callback function,
3244 * The third button, finally, will exercise elm_index_item_clear(),
3245 * which will delete @b all of the index's items.
3247 * This is how the example program's window looks like with the index
3249 * @image html screenshots/index_example_00.png
3250 * @image latex screenshots/index_example_00.eps
3252 * When it's shown, it's like the following figure:
3253 * @image html screenshots/index_example_01.png
3254 * @image latex screenshots/index_example_01.eps
3256 * See the full @ref index_example_01_c "source code" for
3259 * @example index_example_01.c
3263 * @page index_example_02 Index widget example 2
3265 * This code places an Elementary index widget on a window, indexing
3266 * grid items. The items are placed so that their labels @b don't
3267 * follow any order, but the index itself is ordered (through
3268 * elm_index_item_sorted_insert()). This is a complement to to @ref
3269 * index_example_01 "the first example on indexes".
3271 * Here's the list of item labels to be used on the grid (in that
3273 * @dontinclude index_example_02.c
3274 * @skip static const char *items
3277 * In the interesting part of the code, here, we first instantiate the
3278 * grid (more on grids on their examples) and, after creating our
3279 * index, for each grid item we also create an index one to reference
3281 * @dontinclude index_example_02.c
3282 * @skip grid = elm_gengrid_add
3284 * @until smart_callback_add
3286 * The order in which they'll appear in the index, though, is @b
3287 * alphabetical, becase of elm_index_item_sorted_insert() usage
3288 * together with the comparing function, where we take the letters of
3289 * each index item to base our ordering on. The parameters on
3290 * @c _index_cmp have to be declared as void pointers because of the
3291 * @c Eina_Compare_Cb prototype requisition, but in this case we know
3292 * they'll be #Elm_Index_Item's:
3293 * @dontinclude index_example_02.c
3294 * @skip ordering alphabetically
3297 * The last interesting bit is the callback in the @c "delay,changed"
3298 * smart event, which will bring the given grid item to the grid's
3300 * @dontinclude index_example_02.c
3304 * Note how the grid will move kind of randomly while you move your
3305 * mouse pointer held over the index from top to bottom -- that's
3306 * because of the the random order the items have in the grid itself.
3308 * This is how the example program's window looks like:
3309 * @image html screenshots/index_example_03.png
3310 * @image latex screenshots/index_example_03.eps
3312 * See the full @ref index_example_c "source code" for
3315 * @example index_example_02.c
3319 * @page tutorial_ctxpopup Ctxpopup example
3320 * @dontinclude ctxpopup_example_01.c
3322 * In this example we have a list with two items, when either item is clicked
3323 * a ctxpopup for it will be shown. Our two ctxpopups are quite different, the
3324 * one for the first item is a vertical and it's items contain both labels and
3325 * icons, the one for the second item is horizontal and it's items have icons
3328 * We will begin examining our example code by looking at the callback we'll use
3329 * when items in the ctxpopup are clicked. It's very simple, all it does is
3330 * print the label present in the ctxpopup item:
3333 * Next we examine a function that creates ctxpopup items, it was created to
3334 * avoid repeating the same code whenever we needed to add an item to our
3335 * ctxpopup. Our function creates an icon from the standard set of icons, and
3336 * then creates the item, with the label received as an argument. We also set
3337 * the callback to be called when the item is clicked:
3340 * Finally we have the function that will create the ctxpopup for the first item
3341 * in our list. This one is somewhat more complex though, so let's go through it
3342 * in parts. First we declare our variable and add the ctxpopup:
3343 * @until ctxpopup_add
3345 * Next we create a bunch of items for our ctxpopup, marking two of them as
3346 * disabled just so we can see what that will look like:
3347 * @until disabled_set
3348 * @until disabled_set
3350 * Then we ask evas where the mouse pointer was so that we can have our ctxpopup
3351 * appear in the right place, set a maximum size for the ctxpopup, move it and
3355 * And last we mark the list item as not selected:
3358 * Our next function is the callback that will create the ctxpopup for the
3359 * second list item, it is very similar to the previous function. A couple of
3360 * interesting things to note is that we ask our ctxpopup to be horizontal, and
3361 * that we pass NULL as the label for every item:
3364 * And with all of that in place we can now get to our main function where we
3365 * create the window, the list, the list items and run the main loop:
3368 * The example will initially look like this:
3370 * @image html screenshots/ctxpopup_example_01.png
3371 * @image latex screenshots/ctxpopup_example_01.eps width=\textwidth
3373 * @note This doesn't show the ctxpopup tough, since it will only appear when
3374 * we click one of the list items.
3376 * Here is what our first ctxpopup will look like:
3378 * @image html screenshots/ctxpopup_example_01_a.png
3379 * @image latex screenshots/ctxpopup_example_01_a.eps width=\textwidth
3381 * And here the second ctxpopup:
3383 * @image html screenshots/ctxpopup_example_01_b.png
3384 * @image latex screenshots/ctxpopup_example_01_b.eps width=\textwidth
3386 * @example ctxpopup_example_01.c
3390 * @page tutorial_pager
3391 * @dontinclude pager_example_01.c
3393 * In this example we'll have a pager with 3 rectangles on it, one blue, one
3394 * green and one blue, we'll also have 1 button for each rectangle. Pressing a
3395 * button will bring the associated rectangle to the front of the pager(promote
3398 * We start our example with some run of the mill code that you've seen in other
3402 * And then we get right to creating our pager, setting a style and some basic
3406 * Well a pager without any content is not of much use, so let's create the
3407 * first of our rectangles, add it to the pager and create the button for it:
3408 * @until smart_callback
3409 * @note The only line of above code that directly relates to our pager is the
3410 * call to elm_pager_content_push().
3412 * And now we will do the same thing again twice for our next two rectangles:
3413 * @until smart_callback
3414 * @until smart_callback
3416 * Now that we haver our widgets create we can get to running the main loop:
3419 * We also have the callback that is called when any of the buttons is pressed,
3420 * this callback is receiving the rectangle in it's @p data argument, so we
3421 * check if it's already on top and if not move it there:
3424 * Our example will look like this:
3426 * @image html screenshots/pager_example_01.png
3427 * @image latex screenshots/pager_example_01.eps width=\textwidth
3428 * @note Like all examples that involve animations the screenshot doesn't do it
3429 * justice, seeing it in action is a must.
3431 * @example pager_example_01.c
3435 * @page tutorial_separator Separator example
3436 * @dontinclude separator_example_01.c
3438 * In this example we are going to pack two rectangles in a box, and have a
3439 * separator in the middle.
3441 * So we start we the window, background, box and rectangle creation, all pretty
3445 * Once we have our first rectangle in the box we create and add our separator:
3447 * @note Since our box is in horizontal mode it's a good idea to set the
3448 * separator to be horizontal too.
3450 * And now we add our second rectangle and run the main loop:
3453 * This example will look like this:
3455 * @image html screenshots/separator_example_01.png
3456 * @image eps screenshots/separator_example_01.eps width=\textwidth
3458 * @example separator_example_01.c
3462 * @page tutorial_radio Radio example
3463 * @dontinclude radio_example_01.c
3465 * In this example we will create 4 radio buttons, three of them in a group and
3466 * another one not in the group. We will also have the radios in the group
3467 * change the value of a variable directly and have then print it when the value
3468 * changes. The fourth button is in the example just to make clear that radios
3469 * outside the group don't affect the group.
3471 * We'll start with the usual includes:
3474 * And move right to declaring a static variable(the one whose value the radios
3478 * We now need to have a window and all that good stuff to be able to place our
3482 * And now we create a radio button, since this is the first button in our group
3483 * we set the group to be the radio(so we can set the other radios in the same
3484 * group). We also set the state value of this radio to 1 and the value pointer
3485 * to @p val, since val is @p 1 this has the additional effect of setting the
3486 * radio value to @p 1. For this radio we choose the default home icon:
3489 * To check that our radio buttons are working we'll add a callback to the
3490 * "changed" signal of the radio:
3491 * @until smart_callback
3493 * The creation of our second radio button is almost identical, the 2
3494 * differences worth noting are, the value of this radio 2 and that we add this
3495 * radio to the group of the first radio:
3496 * @until smart_callback
3498 * For our third callback we'll omit the icon and set the value to 3, we'll also
3499 * add it to the group of the first radio:
3500 * @until smart_callback
3502 * Our fourth callback has a value of 4, no icon and most relevantly is not a
3503 * member of the same group as the other radios:
3506 * We finally run the main loop:
3509 * And the last detail in our example is the callback that prints @p val so that
3510 * we can see that the radios are indeed changing its value:
3513 * The example will look like this:
3515 * @image html screenshots/radio_example_01.png
3516 * @image latex screenshots/radio_example_01.epx width=\textwidth
3518 * @example radio_example_01.c
3522 * @page tutorial_toggle Toggle example
3523 * @dontinclude toggle_example_01.c
3525 * In this example we'll create 2 toggle widgets. The first will have an icon
3526 * and the state names will be the default "on"/"off", it will also change the
3527 * value of a variable directly. The second won't have a icon, the state names
3528 * will be "Enabled"/"Disabled", it will start "Enabled" and it won't set the
3529 * value of a variable.
3531 * We start with the usual includes and prototype for callback which will be
3532 * implemented and detailed later on:
3535 * We then declare a static global variable(the one whose value will be changed
3536 * by the first toggle):
3539 * We now have to create our window and all that usual stuff:
3542 * The creation of a toggle is no more complicated than that of any other
3546 * For our first toggle we don't set the states labels so they will stay the
3547 * default, however we do set a label for the toggle, an icon and the variable
3548 * whose value it should change:
3551 * We also set the callback that will be called when the toggles value changes:
3552 * @until smart_callback
3554 * For our second toggle it important to note that we set the states labels,
3555 * don't set an icon or variable, but set the initial state to
3556 * EINA_TRUE("Enabled"):
3559 * For the second toggle we will use a different callback:
3560 * @until smart_callback
3562 * We then ask the main loop to start:
3565 * The callback for our first toggle will look the value of @p val and print it:
3568 * For our second callback we need to do a little bit more, since the second
3569 * toggle doesn't change the value of a variable we have to ask it what its
3573 * This example will look like this:
3575 * @image html screenshots/toggle_example_01.png
3576 * @image latex screenshots/toggle_example_01.eps width=\textwidth
3578 * @example toggle_example_01.c
3582 * @page tutorial_panel Panel example
3583 * @dontinclude panel_example_01.c
3585 * In this example will have 3 panels, one for each possible orientation. Two of
3586 * our panels will start out hidden, the third will start out expanded. For each
3587 * of the panels we will use a label as the content, it's however possible to
3588 * have any widget(including containers) as the content of panels.
3590 * We start by doing some setup, code you should be familiar with from other
3594 * And move right to creating our first panel, for this panel we are going to
3595 * choose the orientation as TOP and toggle it(tell it to hide itself):
3598 * For the second panel we choose the RIGHT orientation and explicitly set the
3602 * For our third and last panel we won't set the orientation(which means it will
3603 * use the default: LEFT):
3606 * All that is left is running the main loop:
3609 * This example will look like this;
3611 * @image html screenshots/panel_example_01.png
3612 * @image latex screenshots/panel_example_01.epx width=\textwidth
3613 * @note The buttons with arrow allow the user to hide/show the panels.
3615 * @example panel_example_01.c
3619 * @page gengrid_example Gengrid widget example
3621 * This application is a thorough exercise on the gengrid widget's
3622 * API. We place an Elementary gengrid widget on a window, with
3623 * various knobs below its viewport, each one acting on it somehow.
3625 * The code's relevant part begins at the grid's creation. After
3626 * instantiating it, we set its items sizes, so that we don't end with
3627 * items one finger size wide, only. We're setting them to fat, 150
3628 * pixel wide ones, for this example. We give it some size hints, not
3629 * to be discussed in this context and, than, we register a callback
3630 * on one of its smart events -- the one coming each time an item gets
3631 * doubly clicked. There, we just print the item handle's value.
3632 * @dontinclude gengrid_example.c
3633 * @skip grid = elm_gengrid_add
3634 * @until evas_object_sho
3635 * @dontinclude gengrid_example.c
3636 * @skip item double click callback
3639 * Before we actually start to deal with the items API, let's show
3640 * some things items will be using throughout all the code. The first
3641 * of them is a struct to be used as item data, for all of them:
3642 * @dontinclude gengrid_example.c
3643 * @skip typedef struct
3646 * That path will be used to index an image, to be swallowed into one
3647 * of the item's icon spots. The imagens themselves are distributed
3649 * @dontinclude gengrid_example.c
3650 * @skip static const char *imgs
3653 * We also have an (unique) gengrid item class we'll be using for
3654 * items in the example:
3655 * @dontinclude gengrid_example.c
3656 * @skip static Elm_Gengrid_Item_Class
3657 * @until static Elm_Gengrid_Item_Class
3658 * @dontinclude gengrid_example.c
3659 * @skip item_style =
3662 * As you see, our items will follow the default theme on gengrid
3663 * items. For the label fetching code, we return a string composed of
3664 * the item's image path:
3665 * @dontinclude gengrid_example.c
3666 * @skip label fetching callback
3669 * For item icons, we'll be populating the item default theme's two
3670 * icon spots, @c "elm.swallow.icon" and @c "elm.swallow.end". The
3671 * former will receive one of the images in our list (in the form of
3672 * a @ref bg_02_example_page "background"), while the latter will be
3673 * a check widget. Note that we prevent the check to propagate click
3674 * events, so that the user can toggle its state without messing with
3675 * the respective item's selection in the grid:
3676 * @dontinclude gengrid_example.c
3677 * @skip icon fetching callback
3678 * @until return NULL
3681 * As the default gengrid item's theme does not have parts
3682 * implementing item states, we'll be just returning false for every
3684 * @dontinclude gengrid_example.c
3685 * @skip state fetching callback
3688 * Finally, the deletion callback on gengrid items takes care of
3689 * freeing the item's label string and its data struct:
3690 * @dontinclude gengrid_example.c
3691 * @skip deletion callback
3694 * Let's move to item insertion/deletion knobs, them. They are four
3695 * buttons, above the grid's viewport, namely
3696 * - "Append" (to append an item to the grid),
3697 * - "Prepend" (to prepend an item to the grid),
3698 * - "Insert before" (to insert an item before the selection, on the
3700 * - "Insert after" (to insert an item after the selection, on the
3702 * - "Clear" (to delete all items in the grid),
3703 * - "Bring in 1st" (to make the 1st item visible, by scrolling),
3704 * - "Show last" (to directly show the last item),
3706 * which are displaced and declared in that order. We're not dealing
3707 * with the buttons' creation code (see @ref button_example_01
3708 * "a button example", for more details on it), but with their @c
3709 * "clicked" registered callbacks. For all of them, the grid's handle
3710 * is passed as @c data. The ones creating new items use a common
3711 * code, which just gives a new @c Example_Item struct, with @c path
3712 * filled with a random image in our images list:
3713 * @dontinclude gengrid_example.c
3714 * @skip new item with random path
3717 * Moreover, that ones will set a common function to be issued on the
3718 * selection of the items. There, we print the item handle's value,
3719 * along with the callback function data. The latter will be @c NULL,
3720 * always, because it's what we pass when adding all icons. By using
3721 * elm_gengrid_item_data_get(), we can have the item data back and,
3722 * with that, we're priting the item's path string. Finally, we
3723 * exemplify elm_gengrid_item_pos_get(), printing the item's position
3725 * @dontinclude gengrid_example.c
3726 * @skip item selection callback
3729 * The appending button will exercise elm_gengrid_item_append(), simply:
3730 * @dontinclude gengrid_example.c
3731 * @skip append an item
3734 * The prepending, naturally, is analogous, but exercising
3735 * elm_gengrid_item_prepend(), on its turn. The "Insert before" one
3736 * will expect an item to be selected in the grid, so that it will
3737 * insert a new item just before it:
3738 * @dontinclude gengrid_example.c
3739 * @skip "insert before" callback
3742 * The "Insert after" is analogous, just using
3743 * elm_gengrid_item_insert_after(), instead. The "Clear" button will,
3744 * as expected, just issue elm_gengrid_clear():
3745 * @dontinclude gengrid_example.c
3746 * @skip delete items
3749 * The "Bring in 1st" button is there exercise two gengrid functions
3750 * -- elm_gengrid_first_item_get() and elm_gengrid_item_bring_in().
3751 * With the former, we get a handle to the first item and, with the
3752 * latter, you'll see that the widget animatedly scrolls its view
3753 * until we can see that item:
3754 * @dontinclude gengrid_example.c
3755 * @skip bring in 1st item
3758 * The "Show last", in its turn, will use elm_gengrid_last_item_get()
3759 * and elm_gengrid_item_show(). The latter differs from
3760 * elm_gengrid_item_bring_in() in that it immediately replaces the
3761 * contents of the grid's viewport with the region containing the item
3763 * @dontinclude gengrid_example.c
3764 * @skip show last item
3767 * To change the grid's cell (items) size, we've placed a spinner,
3768 * which has the following @c "changed" smart callback:
3769 * @dontinclude gengrid_example.c
3770 * @skip change items' size
3773 * Experiment with it and see how the items are affected. The "Disable
3774 * item" button will, as the name says, disable the currently selected
3776 * @dontinclude gengrid_example.c
3777 * @skip disable selected item
3779 * Note that we also make use of elm_gengrid_item_selected_set(),
3780 * there, thus making the item unselected before we actually disable
3783 * To toggle between horizontal and vertical layouting modes on the
3784 * grid, use the "Horizontal mode" check, which will call the
3785 * respective API function on the grid:
3786 * @dontinclude gengrid_example.c
3787 * @skip change layouting mode
3790 * If you toggle the check right after that one, "Always select",
3791 * you'll notice all subsequent clicks on the @b same grid item will
3792 * still issue the selection callback on it, what is different from
3793 * when it's not checked. This is the
3794 * elm_gengrid_always_select_mode_set() behavior:
3795 * @dontinclude gengrid_example.c
3796 * @skip "always select" callback
3799 * One more check follows, "Bouncing", which will turn on/off the
3800 * bouncing animations on the grid, when one scrolls past its
3801 * borders. Experiment with scrolling the grid to get the idea, having
3802 * it turned on and off:
3803 * @dontinclude gengrid_example.c
3804 * @skip "bouncing mode" callback
3807 * The next two checks will affect items selection on the grid. The
3808 * first, "Multi-selection", will make it possible to select more the
3809 * one item on the grid. Because it wouldn't make sense to fetch for
3810 * an unique selected item on this case, we also disable two of the
3811 * buttons, which insert items relatively, if multi-selection is on:
3812 * @dontinclude gengrid_example.c
3813 * @skip multi-selection callback
3816 * Note that we also @b unselect all items in the grid, when returning
3817 * from multi-selection mode, making use of
3818 * elm_gengrid_item_selected_set().
3820 * The second check acting on selection, "No selection", is just what
3821 * its name depicts -- no selection will be allowed anymore, on the
3822 * grid, while it's on. Check it out for yourself, interacting with
3824 * @dontinclude gengrid_example.c
3825 * @skip no selection callback
3828 * We have, finally, one more line of knobs, now sliders, to change
3829 * the grids behavior. The two first will change the horizontal @b
3830 * alignment of the whole actual grid of items within the gengrid's
3832 * @dontinclude gengrid_example.c
3833 * @skip items grid horizontal alignment change
3836 * Naturally, the vertical counterpart just issues
3837 * elm_gengrid_align_set() changing the second alignment component,
3840 * The last slider will change the grid's <b>page size</b>, relative
3841 * to its own one. Try to change those values and, one manner of
3842 * observing the paging behavior, is to scroll softly and release the
3843 * mouse button, with different page sizes, at different grid
3844 * positions, while having lots of items in it -- you'll see it
3845 * snapping to page boundaries differenty, for each configuration:
3846 * @dontinclude gengrid_example.c
3847 * @skip page relative size change
3850 * This is how the example program's window looks like:
3851 * @image html screenshots/gengrid_example.png
3852 * @image latex screenshots/gengrid_example.eps width=\textwidth
3854 * Note that it starts with three items which we included at will:
3855 * @dontinclude gengrid_example.c
3856 * @skip _clicked(grid,
3857 * @until _clicked(grid,
3858 * @until _clicked(grid,
3859 * @until _clicked(grid,
3861 * See the full @ref gengrid_example_c "source code" for
3864 * @example gengrid_example.c
3867 * @page entry_example_01 Entry - Example of simple editing
3869 * As a general overview of @ref Entry we are going to write an, albeit simple,
3870 * functional editor. Although intended to show how elm_entry works, this
3871 * example also makes extensive use of several other widgets. The full code
3872 * can be found in @ref entry_example.c "entry_example.c" and in the following
3873 * lines we'll go through the parts especific to the @ref Entry widget.
3875 * The program itself is a simple editor, with a file already set to it, that
3876 * can be set to autosave or not and allows insertion of emoticons and some
3877 * formatted text. As of this writing, the capabilities of format edition in
3878 * the entry are very limited, so a lot of manual work is required to change
3881 * In any case, the program allows some changes by using the buttons on the
3882 * top of the window and returning focus back to the main entry afterwards.
3884 * @image html screenshots/entry_example.png
3885 * @image latex screenshots/entry_example.eps width=\textwidth
3887 * We'll begin by showing a few structures used throught the program. First,
3888 * the application owns data that holds the main window and the main entry
3889 * where the editting happens. Then, an auxiliar structure we'll use later
3890 * when inserting icons in our text.
3891 * @dontinclude entry_example.c
3893 * @until App_Inwin_Data
3895 * A little convenience function will insert whatever text we need in the
3896 * buffer at the current cursor's position and set focus back to this entry.
3897 * This is done mostly because clicking on any button will make them steal
3898 * focus, which makes writing text more cumbersome.
3902 * One of the buttons on the top will trigger an @ref Inwin to open and show
3903 * us several icons we can insert into the text. We'll jump over most of these
3904 * functions, but when all the options are chosen, we insert the special
3905 * markup text that will show the chosen icon in place.
3906 * @skip edje_file_collection_list_free(emos)
3908 * @until evas_object_del
3911 * As can be seen in that function, the program lets us add icons to our entry
3912 * using all the possible configurations for them. That should help to
3913 * clarify how the different combinations work out by actually seeing them
3916 * The same popup window has a page to set the settings of the chosen icon,
3917 * that is, the size and how the item will be placed within the line.
3919 * The size is done with two entries, limitted to accept numbers and a fixed
3920 * size of characters. Changing the value in this entries will update the icon
3921 * size in our struct as seen in the next two callbacks.
3926 * The rest of the options are handled with radio buttons, since only one type
3927 * of size can be used (@c size, @c absize or @c relsize) and for the vertical
3928 * sizing it needs to choose between @c ascent and @c full. Depending on which
3929 * is chosen, the @c item tag is formed accordingly as seen before.
3930 * @skip static Evas_Object
3931 * @until evas_object_show(rvascent)
3933 * The first of our entries is here. There's something worth mentioning about
3934 * the way we'll create this one. Normally, any entry regardless of whether is
3935 * single line or not, will be set to scrollable, but in this case, since we
3936 * are limitting how many characters can fit in them and we know we don't need
3937 * scrolling, we are not setting this flag. This makes the entry have virtually
3938 * no appearance on screen, other than its text. This is because an entry is
3939 * just that, a box that holds text, and in order to have some frame around it
3940 * or a background color, another widget needs to provide this. When an entry
3941 * is scrollable, the same scroller used internally does this.
3942 * We are using @ref Frame "frames" here to provide some decoration around,
3943 * then creating our entries, set them to single line, add our two filters and
3944 * the callback for when their value change.
3945 * @until _height_changed_cb
3947 * This function ends with the button that will finally call the item
3948 * into our editting string.
3951 * Then we get to the format edition. Here we can add the @c bold and
3952 * @c emphasis tags to parts of our text. There's a lot of manual work to
3953 * know what to do here, since we are not implementing an entire state manager
3954 * and the entry itself doesn't, yet, support all the needed capabilities to
3955 * make this simpler. We begin by getting the format we are using in our
3956 * function from the button pressed.
3957 * @skip aid->pager = pager;
3958 * @until sizeof(fmt_close)
3960 * Next we need to find out if we need to insert an opening or a closing tag.
3961 * For this, we store the current cursor position and create a selection
3962 * from this point until the beginning of our text, and then get the selected
3963 * text to look for any existing format tags in it. This is currently the only
3964 * way in which we can find out what formats is being used in the entry.
3968 * Once we know what tag to insert, we need a second check in the case it was
3969 * a closing tag. This is because any other closing tag that comes after would
3970 * be left dangling alone, so we need to remove it to keep the text consistent.
3973 * Finally, we clear our fake selections and return the cursor back to the
3974 * position it had at first, since there is where we want to insert our format.
3975 * @until cursor_pos_set
3977 * And finish by calling our convenience function from before, to insert the
3978 * text at the current cursor and give focus back to the entry.
3981 * A checkbox on the top of our program tells us if the text we are editing
3982 * will autosave or not. In it's @c "changed" callback we get the value from
3983 * the checkbox and call the elm_entry_autosave_set() function with it. If
3984 * autosave is set, we also call elm_entry_file_save(). This is so the internal
3985 * timer used to periodically store to disk our changes is started.
3989 * Two more functions to show some cursor playing. Whenever we double click
3990 * anywhere on our entry, we'll find what word is the cursor placed at and
3991 * select it. Likewise, for triple clicking, we select the entire line.
3993 * @until _edit_tplclick_cb
3996 * And finally, the main window of the program contains the entry where we
3997 * do all the edition and some helping widgets to change format, add icons
3998 * or change the autosave flag.
4001 * @until _image_insert_cb
4003 * And the main entry of the program. Set to scroll, by default we disable
4004 * autosave and we'll begin with a file set to it because no file selector
4005 * is being used here. The file is loaded with #ELM_TEXT_FORMAT_MARKUP_UTF8
4006 * so that any format contained in it is interpreted, otherwise the entry
4007 * would load it as just text, escaping any tags found and no format or icons
4008 * would be shown. Then we connect to the double and triple click signals
4009 * and set focus on the entry so we can start typing right away.
4012 * @example entry_example.c
4016 * @page genlist_example_01
4018 * This example creates a simple genlist with a small number of items and
4019 * a callback that is called whenever an item is selected. All the properties of
4020 * this genlist are the default ones. The full code for this example can be seen
4021 * at @ref genlist_example_01_c.
4023 * For the simplest list that you plan to create, it's necessary to define some
4024 * of the basic functions that are used for creating each list item, and
4025 * associating them with the "item class" for that list. The item class is just
4026 * an struct that contains pointers to the specific list item functions that are
4027 * common to all the items of the list.
4029 * Let's show it by example. Our item class is declared globally and static as
4030 * it will be the only item class that we need (we are just creating one list):
4032 * @dontinclude genlist_example_01.c
4033 * @skip static Elm_Genlist
4034 * @until static Elm_Genlist
4036 * This item class will be used for every item that we create. The only
4037 * functions that we are going to set are @c label_get and @c icon_get. As the
4038 * name suggests, they are used by the genlist to generate the label for the
4039 * respective item, and to generate icon(s) to it too. Both the label and icon
4040 * get functions can be called more than once for each item, with different @c
4041 * part parameters, which represent where in the theme of the item that label or
4042 * icon is going to be set.
4044 * The default theme for the genlist contains only one area for label, and two
4045 * areas for icon ("elm.swallow.icon" and "elm.swallow.end"). Since we just want
4046 * to set the first icon (that will be at the left side of the label), we
4047 * compare the part name given with "elm.swallow.icon". Notice that the
4048 * @c label_get function must return a strduped string, that will be freed later
4049 * automatically by the list. Here's the code for @c label_get and @c icon_get:
4051 * @until static void
4053 * We will also provide a function that will be called whenever an item is
4054 * selected in the genlist. However, this function is not part of the item
4055 * class, it will be passed for each item being added to the genlist explicitly.
4056 * Notice the similarity of the function signature with those used by @c
4057 * evas_object_smart_callback_add:
4061 * Now let's show the code used for really creating the list. Skipping
4062 * boilerplate code used for creating a window and background, the first piece
4063 * of code specific to our genlist example is setting the pointer functions of
4064 * the item class to our above defined functions:
4069 * Notice that we also choose to use the "default" style for our genlist items.
4070 * Another interesting point is that @c state_get and @c del are set to @c NULL,
4071 * since we don't need these functions now. @c del doesn't need to be used
4072 * because we don't add any data that must be freed to our items, and @c
4073 * state_get is also not used since all of our items are the same and don't need
4074 * to have different states to be used for each item. Finally we create our
4077 * @until genlist_add
4079 * Now we append several items to the list, and for all of them we need to give
4080 * the list pointer, a pointer to the item class, the data that will be used
4081 * with that item, a pointer to the parent of this item if it is in a group type
4082 * list (this is not the case so we pass @c NULL), possible flags for this item,
4083 * the callback for when the item is selected, and the data pointer that will be
4084 * given to the selected callback.
4088 * The rest of the code is also common to all the other examples, so it will be
4089 * omitted here (look at the full source code link above if you need it).
4091 * You can try to play with this example, and see the selected callback being
4092 * called whenever an item is clicked. It also already has some features enabled
4093 * by default, like vertical bounce animation when reaching the end of the list,
4094 * automatically visible/invisible scrollbar, etc. Look at the @ref
4095 * genlist_example_02 to see an example of setting these properties to the list.
4097 * The current example will look like this when running:
4099 * @image html screenshots/genlist_example_01.png
4100 * @image latex screenshots/genlistexample_01.eps width=\textwidth
4104 * @page genlist_example_02
4106 * This example is very similar to the @ref genlist_example_01, but it fetch
4107 * most of the properties of the genlist and displays them on startup (thus
4108 * getting the default value for them) and then set them to some other values,
4109 * to show how to use that API. The full source code is at @ref
4110 * genlist_example_02_c.
4112 * Considering that the base code for instantiating a genlist was already
4113 * described in the previous example, we are going to focus on the new code.
4115 * Just a small difference for the @c _item_label_get function, we are going to
4116 * store the time that this function was called. This is the "realized" time,
4117 * the time when the visual representation of this item was created. This is the
4118 * code for the @c label_get function:
4120 * @dontinclude genlist_example_02.c
4122 * @until return strdup
4124 * Now let's go to the list creation and setup. First, just after creating the
4125 * list, we get most of the default properties from it, and print them on the
4129 * @until printf("\n")
4131 * We are going to change some of the properties of our list.
4133 * There's no need to call the selected callback at every click, just when the
4134 * selected item changes, thus we call elm_genlist_always_select_mode_set() with
4137 * For this list we don't want bounce animations at all, so we set both the
4138 * horizontal bounce and the vertical bounce to false with
4139 * elm_genlist_bounce_set().
4141 * We also want our list to compress items if they are wider than the list
4142 * width (thus we call elm_genlist_compress_mode_set().
4144 * The items have different width, so they are not homogeneous:
4145 * elm_genlist_homogeneous_set() is set to false.
4147 * Since the compress mode is active, the call to
4148 * elm_genlist_horizontal_mode_set() doesn't make difference, but the current
4149 * option would make the list to have at least the width of the largest item.
4151 * This list will support multiple selection, so we call
4152 * elm_genlist_multi_select_set() on it.
4154 * The option elm_genlist_height_for_width_mode_set() would allow text block to
4155 * wrap lines if the Edje part is configured with "text.min: 0 1", for example.
4156 * But since we are compressing the elements to the width of the list, this
4157 * option wouldn't take any effect.
4159 * We want the vertical scrollbar to be always displayed, and the orizontal one
4160 * to never be displayed, and set this with elm_genlist_scroller_policy_set().
4162 * The timeout to consider a longpress is set to half of a second with
4163 * elm_genlist_longpress_timeout_set().
4165 * We also change the block count to a smaller value, but that should have not
4166 * impact on performance since the number of visible items is too small. We just
4167 * increase the granularity of the block count (setting it to have at most 4
4170 * @until block_count_set
4172 * Now let's add elements to the list:
4174 * @until item_append
4177 * It's exactly the same as the previous example. The difference is on the
4178 * behavior of the list, if you try to scroll, select items and so.
4180 * In this example we also need two buttons. One of them, when clicked, will
4181 * display several status info about the current selection, the "realized"
4182 * items, the item in the middle of the screen, and the current mode and active
4183 * item of that mode for the genlist.
4185 * The other button will ask the genlist to "realize" again the items already
4186 * "realized", so their respective label_get and icon_get functions will be
4189 * These are the callbacks for both of these buttons:
4191 * @dontinclude genlist_example_02.c
4197 * Try to scroll, select some items and click on the "Show status" button.
4198 * You'll notice that not all items of the list are "realized", thus consuming
4199 * just a small amount of memory. The selected items are listed in the order
4200 * that they were selected, and the current selected item printed using
4201 * elm_genlist_selected_item_get() is the first selected item of the multiple
4204 * Now resize the window so that you can see the "realized time" of some items.
4205 * This is the time of when the label_get function was called. If you click on
4206 * the "Realize" button, all the already realized items will be rebuilt, so the
4207 * time will be updated for all of them.
4209 * The current example will look like this when running:
4211 * @image html screenshots/genlist_example_02.png
4212 * @image latex screenshots/genlistexample_02.eps width=\textwidth
4216 * @page progressbar_example Progress bar widget example
4218 * This application is a thorough example of the progress bar widget,
4219 * consisting of a window with varios progress bars, each with a given
4220 * look/style one can give to those widgets. With two auxiliary
4221 * buttons, one can start or stop a timer which will fill in the bars
4222 * in synchrony, simulating an underlying task being completed.
4224 * We create @b seven progress bars, being three of them horizontal,
4225 * three vertical and a final one under the "wheel" alternate style.
4227 * For the first one, we add a progress bar on total pristine state,
4228 * with no other call than the elm_progressbar_add() one:
4229 * @dontinclude progressbar_example.c
4230 * @skip pb with no label
4232 * See, than, that the defaults of a progress bar are:
4233 * - no primary label shown,
4234 * - unit label set to @c "%.0f %%",
4237 * The second progress bar is given a primary label, <c>"Infinite
4238 * bounce"</c>, and, besides, it's set to @b pulse. See how, after one
4239 * starts the progress timer, with the "Start" button, it animates
4240 * differently than the previous one. It won't account for the
4241 * progress, itself, and just dumbly animate a small bar within its
4243 * @dontinclude progressbar_example.c
4244 * @skip pb with label
4247 * Next, comes a progress bar with an @b icon, a primary label and a
4248 * @b custom unit label set. It's also made to grow its bar in an
4249 * @b inverted manner, so check that out during the timer's progression:
4250 * @dontinclude progressbar_example.c
4253 * Another important thing in this one is the call to
4254 * elm_progressbar_span_size_set() -- this is how we forcefully set a
4255 * minimum horizontal size to our whole window! We're not resizing it
4256 * manually, as you can see in the @ref progressbar_example_c
4259 * The next three progress bars are just variants on the ones already
4260 * shown, but now all being @b vertical. Another time we use one of
4261 * than to give the window a minimum vertical size, with
4262 * elm_progressbar_span_size_set(). To demonstrate this trick once
4263 * more, the fifth one, which is also set to pulse, has a smaller
4264 * hardcoded span size:
4265 * @dontinclude progressbar_example.c
4266 * @skip vertical pb, with pulse
4269 * We end the widget demonstration by showing a progress bar with the
4270 * special @b "wheel" progress bar style. One does @b not need to set
4271 * it to pulse, with elm_progressbar_pulse_set(), explicitly, because
4272 * its theme does not take it in account:
4273 * @dontinclude progressbar_example.c
4277 * The two buttons exercising the bars, the facto, follow:
4278 * @dontinclude progressbar_example.c
4279 * @skip elm_button_add
4280 * @until evas_object_show(bt)
4281 * @until evas_object_show(bt)
4283 * The first of the callbacks will, for the progress bars set to
4284 * pulse, start the pulsing animation at that time. For the others, a
4285 * timer callback will take care of updating the values:
4286 * @dontinclude progressbar_example.c
4287 * @skip static Eina_Bool
4292 * Finally, the callback to stop the progress timer will stop the
4293 * pulsing on the pulsing progress bars and, for the others, to delete
4294 * the timer which was acting on their values:
4295 * @dontinclude progressbar_example.c
4300 * This is how the example program's window looks like:
4301 * @image html screenshots/progressbar_example.png
4302 * @image latex screenshots/progressbar_example.eps width=\textwidth
4304 * See the full @ref progressbar_example_c "source code" for
4307 * @example progressbar_example.c
4311 * @page tutorial_notify Notify example
4312 * @dontinclude notify_example_01.c
4314 * In this example we will have 3 notifys in 3 different positions. The first of
4315 * which will dissapear after 5 seconds or when a click outside it occurs, the
4316 * second and third will not dissapear and differ from each other only in
4319 * We start our example with the usual stuff you've seen in other examples:
4322 * We now create a label to use as the content of our first notify:
4325 * Having the label we move to creating our notify, telling it to block events,
4326 * setting its timeout(to autohide it):
4329 * To have the notify dissapear when a click outside its area occur we have to
4330 * listen to its "block,clicked" signal:
4331 * @until smart_callback
4333 * Our callback will look like this:
4336 * @dontinclude notify_example_01.c
4338 * Next we create another label and another notify. Note, however, that this
4339 * time we don't set a timeout and don't have it block events. What we do is set
4340 * the orient so that this notify will appear in the bottom of its parent:
4341 * @skip smart_callback
4345 * For our third notify the only change is the orient which is now center:
4348 * Now we tell the main loop to run:
4351 * Our example will initially look like this:
4353 * @image html screenshots/notify_example_01.png
4354 * @image latex screenshots/notify_example_01.eps width=\textwidth
4356 * Once the first notify is hidden:
4358 * @image html screenshots/notify_example_01_a.png
4359 * @image latex screenshots/notify_example_01_a.eps width=\textwidth
4361 * @example notify_example_01.c
4365 * @page bg_example_01_c bg_example_01.c
4366 * @include bg_example_01.c
4367 * @example bg_example_01.c
4371 * @page bg_example_02_c bg_example_02.c
4372 * @include bg_example_02.c
4373 * @example bg_example_02.c
4377 * @page bg_example_03_c bg_example_03.c
4378 * @include bg_example_03.c
4379 * @example bg_example_03.c
4383 * @page actionslider_example_01 Actionslider example
4384 * @include actionslider_example_01.c
4385 * @example actionslider_example_01.c
4389 * @page animator_example_01_c Animator example 01
4390 * @include animator_example_01.c
4391 * @example animator_example_01.c
4395 * @page transit_example_01_c Transit example 1
4396 * @include transit_example_01.c
4397 * @example transit_example_01.c
4401 * @page transit_example_02_c Transit example 2
4402 * @include transit_example_02.c
4403 * @example transit_example_02.c
4407 * @page general_functions_example_c General (top-level) functions example
4408 * @include general_funcs_example.c
4409 * @example general_funcs_example.c
4413 * @page clock_example_c Clock example
4414 * @include clock_example.c
4415 * @example clock_example.c
4419 * @page flipselector_example_c Flipselector example
4420 * @include flipselector_example.c
4421 * @example flipselector_example.c
4425 * @page fileselector_example_c Fileselector example
4426 * @include fileselector_example.c
4427 * @example fileselector_example.c
4431 * @page fileselector_button_example_c Fileselector button example
4432 * @include fileselector_button_example.c
4433 * @example fileselector_button_example.c
4437 * @page fileselector_entry_example_c Fileselector entry example
4438 * @include fileselector_entry_example.c
4439 * @example fileselector_entry_example.c
4443 * @page index_example_01_c Index example
4444 * @include index_example_01.c
4445 * @example index_example_01.c
4449 * @page index_example_02_c Index example
4450 * @include index_example_02.c
4451 * @example index_example_02.c
4455 * @page layout_example_01_c layout_example_01.c
4456 * @include layout_example_01.c
4457 * @example layout_example_01.c
4461 * @page layout_example_02_c layout_example_02.c
4462 * @include layout_example_02.c
4463 * @example layout_example_02.c
4467 * @page layout_example_03_c layout_example_03.c
4468 * @include layout_example_03.c
4469 * @example layout_example_03.c
4473 * @page layout_example_edc An example of layout theme file
4475 * This theme file contains two groups. Each of them is a different theme, and
4476 * can be used by an Elementary Layout widget. A theme can be used more than
4477 * once by many different Elementary Layout widgets too.
4479 * @include layout_example.edc
4480 * @example layout_example.edc
4483 * @page gengrid_example_c Gengrid example
4484 * @include gengrid_example.c
4485 * @example gengrid_example.c
4489 * @page genlist_example_01_c genlist_example_01.c
4490 * @include genlist_example_01.c
4491 * @example genlist_example_01.c
4495 * @page genlist_example_02_c genlist_example_02.c
4496 * @include genlist_example_02.c
4497 * @example genlist_example_02.c
4501 * @page progressbar_example_c Progress bar example
4502 * @include progressbar_example.c
4503 * @example progressbar_example.c