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 transit_example_01_explained
16 * @ref transit_example_02_explained
18 * @ref general_functions_example_page
20 * @ref calendar_example_01
22 * @ref calendar_example_02
24 * @ref calendar_example_03
26 * @ref calendar_example_04
28 * @ref calendar_example_05
30 * @ref calendar_example_06
32 * @ref spinner_example
48 * @ref diskselector_example_01
50 * @ref diskselector_example_02
52 * @ref list_example_01
54 * @ref list_example_02
56 * @ref list_example_03
58 * @ref toolbar_example_01
60 * @ref toolbar_example_02
62 * @ref toolbar_example_03
64 * @ref segment_control_example
66 * @ref flipselector_example
68 * @ref fileselector_example
70 * @ref fileselector_button_example
72 * @ref fileselector_entry_example
74 * @ref index_example_01
76 * @ref index_example_02
78 * @ref gengrid_example
80 * @ref genlist_example_01
82 * @ref genlist_example_02
84 * @ref genlist_example_03
86 * @ref genlist_example_04
88 * @ref genlist_example_05
90 * @ref thumb_example_01
92 * @ref progressbar_example
94 * @ref slideshow_example
98 * @page bg_01_example_page elm_bg - Plain color background.
99 * @dontinclude bg_example_01.c
101 * The full code for this example can be found at @ref bg_example_01_c,
102 * in the function @c test_bg_plain. It's part of the @c elementar_test
103 * suite, and thus has the code for the three examples referenced by this
106 * This first example just sets a default background with a plain color. The
107 * first part consists of creating an Elementary window. It's the common
108 * piece of code that you'll see everywhere in Elementary: @skip elm_main
111 * Now we really create our background object, using the window object as
116 * Then we set the size hints of the background object so that it will use
117 * all space available for it, and then add it as a resize object to the
118 * window, making it visible in the end:
120 * @skip size_hint_weight_set
121 * @until resize_object_add
123 * See @ref evas_object_size_hint_weight_set and elm_win_resize_object_add()
124 * for more detailed info about these functions.
126 * The end of the example is quite simple, just setting the minimum and
127 * maximum size of the background, so the Elementary window knows that it
128 * has to have at least the minimum size. The background also won't scale to
129 * a size above its maximum. Then we resize the window and show it in the
132 * @skip set size hints
135 * And here we finish our very simple background object usage example.
139 * @page bg_02_example_page elm_bg - Image background.
140 * @dontinclude bg_example_02.c
142 * The full code for this example can be found at @ref bg_example_02_c,
143 * in the function @c test_bg_image. It's part of the @c elementar_test
144 * suite, and thus has the code for the three examples referenced by this
147 * This is the second example, and shows how to use the Elementary
148 * background object to set an image as background of your application.
150 * We start this example exactly in the same way as the previous one, even
151 * when creating the background object:
156 * Now it's the different part.
158 * Our background will have an image, that will be displayed over the
159 * background color. Before loading the image, we set the load size of the
160 * image. The load size is a hint about the size that we want the image
161 * displayed in the screen. It's not the exact size that the image will have,
162 * but usually a bit bigger. The background object can still be scaled to a
163 * size bigger than the one set here. Setting the image load size to
164 * something smaller than its real size will reduce the memory used to keep
165 * the pixmap representation of the image, and the time to load it. Here we
166 * set the load size to 20x20 pixels, but the image is loaded with a size
167 * bigger than that (since it's just a hint):
169 * @skipline load_size_set
171 * And set our background image to be centered, instead of stretched or
172 * scaled, so the effect of the elm_bg_load_size_set() can be easily
175 * @skipline option_set
177 * We need a filename to set, so we get one from the previous installed
178 * images in the @c PACKAGE_DATA_DIR, and write its full path to a buffer.
179 * Then we use this buffer to set the filename in the background object:
184 * Notice that the third argument of the elm_bg_file_set() function is @c
185 * NULL, since we are setting an image to this background. This function
186 * also supports setting an edje group as background, in which case the @c
187 * group parameter wouldn't be @c NULL, but be the name of the group
190 * Finally, we can set the size hints, add the background as a resize
191 * object, and resize the window, exactly the same thing we do in the @ref
192 * bg_01_example_page example:
197 * And this is the end of this example.
199 * This example will look like this:
201 * @image html screenshots/bg_01.png
202 * @image latex screenshots/bg_01.eps width=\textwidth
206 * @page bg_03_example_page elm_bg - Background properties.
207 * @dontinclude bg_example_03.c
209 * The full code for this example can be found at @ref bg_example_03_c, in the
210 * function @c test_bg_options, with the callbacks @c _cb_overlay_changed, @c
211 * _cb_color_changed and @c _cb_radio_changed defined in the beginning of the
212 * file. It's part of the @c elementar_test suite, and thus has the code for
213 * the three examples referenced by this documentation.
215 * This example will show the properties available for the background object,
216 * and will use of some more widgets to set them.
218 * In order to do this, we will set some callbacks for these widgets. The
219 * first is for the radio buttons that will be used to choose the option
220 * passed as argument to elm_bg_option_set():
222 * @skip _cb_radio_changed
225 * The next callback will be used when setting the overlay (using
226 * elm_bg_overlay_set()):
228 * @skip _cb_overlay_changed
232 * And the last one, used to set the color (with elm_bg_color_set()):
234 * @skip _cb_color_changed
237 * We will get back to what these functions do soon. If you want to know more
238 * about how to set these callbacks and what these widgets are, look for:
239 * @li elm_radio_add()
240 * @li elm_check_add()
241 * @li elm_spinner_add()
243 * Now going to the main function, @c test_bg_options, we have the common
244 * code with the other examples:
249 * We add a plain background to this window, so it will have the default
250 * background color behind everything:
252 * @skip bg = elm_bg_add
253 * @until evas_object_show(bg)
255 * Then we add a vertical box (elm_box_add()) that will hold the background
256 * object that we are going to play with, as well as a horizontal box that
260 * @until evas_object_show
262 * Now we add the background object that is going to be of use for our
263 * example. It is an image background, as used in @ref bg_02_example_page ,
264 * so the code should be familiar:
267 * @until evas_object_show
269 * Notice the call to elm_box_pack_end(): it will pack the background object
270 * in the end of the Elementary box declared above. Just refer to that
271 * documentation for more info.
273 * Since this Elementary background is already an image background, we are
274 * going to play with its other properties. We will change its option
275 * (CENTER, SCALE, STRETCH, TILE), its color (RGB), and add an overlay to it.
276 * For all of these properties, we are going to add widgets that will
279 * First, lets add the horizontal box that will hold these widgets:
283 * For now, just consider this @c hbox as a rectangle that will contain the
284 * widgets, and will distribute them horizontally inside its content. Then we
285 * add radio buttons that will allow us to choose the property to use with
289 * @until evas_object_show
291 * Again, I won't give details about the use of these widgets, just look for
292 * their documentation if necessary. It's enough to know for now that we are
293 * packing them in the @c hbox, setting a label for them, and the most
294 * important parts: setting its value to @c ELM_BG_OPTION_CENTER and its
295 * callback to @c _cb_radio_changed (the function defined in the beginning of
296 * this example). We do this for the next 3 radio buttons added after this
297 * one, each of them with a different value.
299 * Now taking a look at the code of the callback @c _cb_radio_changed again,
300 * it will call elm_bg_option_set() with the value set from the checked radio
301 * button, thus setting the option for this background. The background is
302 * passed as argument to the @p data parameter of this callback, and is
303 * referenced here as @c o_bg.
305 * Later we set the default value for this radio button:
307 * @skipline elm_radio_value_set
309 * Then we add a checkbox for the elm_bg_overlay_set() function:
312 * @until evas_object_show
314 * Now look at the code of the @c _cb_overlay_changed again. If the checkbox
315 * state is checked, an overlay will be added to the background. It's done by
316 * creating an Edje object, and setting it with elm_bg_overlay_set() to the
317 * background object. For information about what are and how to set Edje
318 * object, look at the Edje documentation.
320 * Finally we add a spinner object (elm_spinner_add()) to be used to select
321 * the color of our background. In its callback it's possible to see the call
322 * to elm_bg_color_set(), which will change the color of this background.
323 * This color is used by the background to fill areas where the image doesn't
324 * cover (in this case, where we have an image background). The spinner is
325 * also packed into the @c hbox :
327 * @skip elm_spinner_add
328 * @until evas_object_show
330 * Then we just have to pack the @c hbox inside the @c box, set some size
331 * hints, and show our window:
336 * Now to see this code in action, open elementary_test, and go to the "Bg
337 * Options" test. It should demonstrate what was implemented here.
341 * @page actionslider_example_page Actionslider usage
342 * @dontinclude actionslider_example_01.c
344 * For this example we are going to assume knowledge of evas smart callbacks
345 * and some basic evas object functions. Elementary is not meant to be used
346 * without evas, if you're not yet familiar with evas it probably is worth
349 * And now to the example, when using Elementary we start by including
353 * Next we define some callbacks, they all share the same signature because
354 * they are all to be used with evas_object_smart_callback_add().
355 * The first one just prints the selected label(in two different ways):
358 * This next callback is a little more interesting, it makes the selected
359 * label magnetic(except if it's the center label):
362 * This callback enables or disables the magnetic propertty of the center
366 * And finally a callback to stop the main loop when the window is closed:
369 * To be able to create our actionsliders we need to do some setup, but this
370 * isn't really relevant here, so if you want to know about that go @ref
373 * With all that boring stuff out of the way we can proceed to creating some
375 * All actionsliders are created the same way:
376 * @skipline actionslider_add
377 * Next we must choose where the indicator starts, and for this one we choose
378 * the right, and set the right as magnetic:
379 * @skipline indicator_pos_set
380 * @until magnet_pos_set
382 * We then set the labels for the left and right, passing NULL as an argument
383 * to any of the labels makes that position have no label.
386 * Furthermore we mark both left and right as enabled positions, if we didn't
387 * do this all three positions would be enabled:
390 * Having the the enabled positions we now add a smart callback to change
391 * which position is magnetic, so that only the last selected position is
395 * And finally we set our printing callback and show the actionslider:
399 * For our next actionslider we are going to do much as we did for the
400 * previous except we are going to have the center as the magnet(and not
402 * @skipline actionslider_add
403 * @skipline indicator_pos_set
406 * And another actionslider, in this one the indicator starts on the left.
407 * It has labels only in the center and right, and both bositions are
408 * magnetic. Because the left doesn't have a label and is not magnetic once
409 * the indicator leaves it can't return:
410 * @skipline actionslider_add
411 * @skipline indicator_pos_set
413 * @note The greyed out area is a @ref Styles "style".
415 * And now an actionslider with a label in the indicator, and whose magnet
416 * properties change based on what was last selected:
417 * @skipline actionslider_add
418 * @skipline indicator_pos_set
420 * @note The greyed out area is a @ref Styles "style".
422 * We are almost done, this next one is just an actionslider with all
423 * positions magnetized and having every possible label:
424 * @skipline actionslider_add
425 * @skipline indicator_pos_set
428 * And for our last actionslider we have one that turns the magnetic property
430 * @skipline actionslider_add
431 * @skipline indicator_pos_set
434 * The example will look like this:
436 * @image html screenshots/actionslider_01.png
437 * @image latex screenshots/actionslider_01.eps width=\textwidth
439 * See the full source code @ref actionslider_example_01 "here"
443 * @page transit_example_03_c elm_transit - Combined effects and options.
445 * This example shows how to apply the following transition effects:
453 * It allows you to apply more than one effect at once, and also allows to
454 * set properties like event_enabled, auto_reverse, repeat_times and
457 * @include transit_example_03.c
461 * @page transit_example_04_c elm_transit - Combined effects over two objects.
463 * This example shows how to apply the transition effects:
468 * over two objects. This kind of transition effect is used to make one
469 * object disappear and another one appear on its place.
471 * You can mix more than one effect of this type on the same objects, and the
472 * transition will apply both.
474 * @include transit_example_04.c
478 * @page transit_example_01_explained elm_transit - Basic transit usage.
479 * @dontinclude transit_example_01.c
481 * The full code for this example can be found at @ref transit_example_01_c.
483 * This example shows the simplest way of creating a transition and applying
484 * it to an object. Similarly to every other elementary example, we create a
485 * window, set its title, size, autodel property, and setup a callback to
486 * exit the program when finished:
489 * @until evas_object_resize
491 * We also add a resizeable white background to use behind our animation:
494 * @until evas_object_show
496 * And then we add a button that we will use to demonstrate the effects of
500 * @until evas_object_show(win)
502 * Notice that we are not adding the button with elm_win_resize_object_add()
503 * because we don't want the window to control the size of the button. We
504 * will use the transition to change the button size, so it could conflict
505 * with something else trying to control that size.
507 * Now, the simplest code possible to create the resize animation:
512 * As you can see, this code is very easy to understand. First, we create the
513 * transition itself with elm_transit_add(). Then we add the button to this
514 * transition with elm_transit_object_add(), which means that the transition
515 * will operate over this button. The effect that we want now is changing the
516 * object size from 100x50 to 300x150, and can be achieved by adding the
517 * resize effect with elm_transit_effect_resizing_add().
519 * Finally, we set the transition time to 5 seconds and start the transition
520 * with elm_transit_go(). If we wanted more effects applied to this
521 * button, we could add them to the same transition. See the
522 * @ref transit_example_03_c to watch many transitions being applied to an
527 * @page transit_example_02_explained elm_transit - Chained transitions.
528 * @dontinclude transit_example_02.c
530 * The full code for this example can be found at @ref transit_example_02_c.
532 * This example shows how to implement a chain of transitions. This chain is
533 * used to start a transition just after another transition ended. Similarly
534 * to every other elementary example, we create a window, set its title,
535 * size, autodel property, and setup a callback to exit the program when
539 * @until evas_object_resize
541 * We also add a resizeable white background to use behind our animation:
544 * @until evas_object_show
546 * This example will have a chain of 4 transitions, each of them applied to
547 * one button. Thus we create 4 different buttons:
550 * @until evas_object_show(bt4)
552 * Now we create a simple translation transition that will be started as soon
553 * as the program loads. It will be our first transition, and the other
554 * transitions will be started just after this transition ends:
559 * The code displayed until now has nothing different from what you have
560 * already seen in @ref transit_example_01_explained, but now comes the new
561 * part: instead of creating a second transition that will start later using
562 * a timer, we create the it normally, and use
563 * elm_transit_chain_transit_add() instead of elm_transit_go. Since we are
564 * adding it in a chain after the first transition, it will start as soon as
565 * the first transition ends:
568 * @until transit_chain_transit_add
570 * Finally we add the 2 other transitions to the chain, and run our program.
571 * It will make one transition start after the other finish, and there is the
576 * @page general_functions_example_page General (top-level) functions example
577 * @dontinclude general_funcs_example.c
579 * As told in their documentation blocks, the
580 * elm_app_compile_*_dir_set() family of functions have to be called
581 * before elm_app_info_set():
582 * @skip tell elm about
583 * @until elm_app_info_set
585 * We are here setting the fallback paths to the compiling time target
586 * paths, naturally. If you're building the example out of the
587 * project's build system, we're assuming they are the canonical ones.
589 * After the program starts, elm_app_info_set() will actually run and
590 * then you'll see an intrincasy: Elementary does the prefix lookup @b
591 * twice. This is so because of the quicklaunch infrastructure in
592 * Elementary (@ref Start), which will register a predefined prefix
593 * for possible users of the launch schema. We're not hooking into a
594 * quick launch, so this first call can't be avoided.
596 * If you ran this example from your "bindir" installation
597 * directiory, no output will emerge from these both attempts -- it
598 * will find the "magic" file there registered and set the prefixes
599 * silently. Otherwise, you could get something like:
601 WARNING: Could not determine its installed prefix for 'ELM'
602 so am falling back on the compiled in default:
604 implied by the following:
607 datadir = usr/share/elementary
608 localedir = usr/share/locale
609 Try setting the following environment variables:
610 ELM_PREFIX - points to the base prefix of install
611 or the next 4 variables
612 ELM_BIN_DIR - provide a specific binary directory
613 ELM_LIB_DIR - provide a specific library directory
614 ELM_DATA_DIR - provide a specific data directory
615 ELM_LOCALE_DIR - provide a specific locale directory
617 * if you also didn't change those environment variables (remember
618 * they are also a valid way of communicating your prefix to the
619 * binary) - this is the scenario where it fallbacks to the paths set
622 * Then, you can check the prefixes set on the standard output:
623 * @skip prefix was set to
624 * @until locale directory is
627 * @skip by using this policy
628 * @until elm_win_autodel_set
629 * we demonstrate the use of Elementary policies. The policy defining
630 * under which circunstances our application should quit automatically
631 * is set to when its last window is closed (this one has just one
632 * window, though). This will save us from having to set a callback
633 * ourselves on the window, like done in @ref bg_example_01_c "this"
634 * example. Note that we need to tell the window to delete itself's
635 * object on a request to destroy the canvas coming, with
636 * elm_win_autodel_set().
638 * What follows is some boilerplate code, creating a frame with a @b
639 * button, our object of interest, and, below, widgets to change the
640 * button's behavior and exemplify the group of functions in question.
642 * @dontinclude general_funcs_example.c
643 * We enabled the focus highlight object for this window, so that you
644 * can keep track of the current focused object better:
645 * @skip elm_win_focus_highlight_enabled_set
646 * @until evas_object_show
647 * Use the tab key to navigate through the focus chain.
649 * @dontinclude general_funcs_example.c
650 * While creating the button, we exemplify how to use Elementary's
651 * finger size information to scale our UI:
652 * @skip fprintf(stdout, "Elementary
653 * @until evas_object_show
655 * @dontinclude general_funcs_example.c
656 * The first checkbox's callback is:
659 * When unsetting the checkbox, we disable the button, which will get a new
660 * decoration (greyed out) and stop receiving events. The focus chain
661 * will also ignore it.
663 * Following, there are 2 more buttons whose actions are focus/unfocus
664 * the top button, respectively:
665 * @skip focus callback
668 * @skip unfocus callback
670 * Note the situations in which they won't take effect:
671 * - the button is not allowed to get focus or
672 * - the button is disabled
674 * The first restriction above you'll get by a second checkbox, whose
676 * @skip focus allow callback
678 * Note that the button will still get mouse events, though.
680 * Next, there's a slider controlling the button's scale:
681 * @skip scaling callback
684 * Experiment with it, so you understand the effect better. If you
685 * change its value, it will mess with the button's original size,
688 * The full code for this example can be found
689 * @ref general_functions_example_c "here".
693 * @page theme_example_01 Theme - Using extensions
695 * @dontinclude theme_example_01.c
697 * Using extensions is extremely easy, discarding the part where you have to
698 * write the theme for them.
700 * In the following example we'll be creating two buttons, one to load or
701 * unload our extension theme and one to cycle around three possible styles,
702 * one of which we created.
704 * After including our one and only header we'll jump to the callback for
705 * the buttons. First one takes care of loading or unloading our extension
706 * file, relative to the default theme set (thus the @c NULL in the
707 * functions first parameter).
708 * @skipline Elementary.h
714 * The second button, as we said before, will just switch around different
715 * styles. In this case we have three of them. The first one is our custom
716 * style, named after something very unlikely to find in the default theme.
717 * The other two styles are the standard and one more, anchor, which exists
718 * in the default and is similar to the default, except the button vanishes
719 * when the mouse is not over it.
724 * So what happens if the style switches to our custom one when the
725 * extension is loaded? Elementary falls back to the default for the
728 * And the main function, simply enough, will create the window, set the
729 * buttons and their callbacks, and just to begin with our button styled
730 * we're also loading our extension at the beginning.
734 * In this case we wanted to easily remove extensions, but all adding an
735 * extension does is tell Elementary where else it should look for themes
736 * when it can't find them in the default theme. Another way to do this
737 * is to set the theme search order using elm_theme_set(), but this requires
738 * that the developer is careful not to override any user configuration.
739 * That can be helped by adding our theme to the end of whatver is already
740 * set, like in the following snippet.
743 * snprintf(buf, sizeof(buf), "%s:./theme_example.edj", elme_theme_get(NULL);
744 * elm_theme_set(NULL, buf);
747 * If we were using overlays instead of extensions, the same thing applies,
748 * but the custom theme must be added to the front of the search path.
750 * In the end, we should be looking at something like this:
752 * @image html screenshots/theme_example_01.png
753 * @image latex screenshots/theme_example_01.eps width=\textwidth
755 * That's all. Boringly simple, and the full code in one piece can be found
756 * @ref theme_example_01.c "here".
758 * And the code for our extension is @ref theme_example.edc "here".
760 * @example theme_example_01.c
761 * @example theme_example.edc
765 * @page theme_example_02 Theme - Using overlays
767 * @dontinclude theme_example_02.c
769 * Overlays are like extensions in that you tell Elementary that some other
770 * theme contains the styles you need for your program. The difference is that
771 * they will be look in first, so they can override the default style of any
774 * There's not much to say about them that hasn't been said in our previous
775 * example about @ref theme_example_01 "extensions", so going quickly through
776 * the code we have a function to load or unload the theme, which will be
777 * called when we click any button.
778 * @skipline Elementary.h
782 * And the main function, creating the window and adding some buttons to it.
783 * We load our theme as an overlay and nothing else. Notice there's no style
784 * set for any button there, which means they should be using the default
789 * That's pretty much it. The full code is @ref theme_example_02.c "here" and
790 * the definition of the theme is the same as before, and can be found in
791 * @ref theme_example.edc "here".
793 * @example theme_example_02.c
797 * @page button_example_01 Button - Complete example
799 * @dontinclude button_example_01.c
801 * A button is simple, you click on it and something happens. That said,
802 * we'll go through an example to show in detail the button API less
805 * In the end, we'll be presented with something that looks like this:
807 * @image html screenshots/button_01.png
808 * @image latex screenshots/button_01.eps width=\textwidth
810 * The full code of the example is @ref button_example_01.c "here" and we
811 * will follow here with a rundown of it.
814 * @until Elementary.h
818 * We have several buttons to set different times for the autorepeat timeouts
819 * of the buttons that use it and a few more that we keep track of in our
820 * data struct. The mid button doesn't do much, just moves around according
821 * to what other buttons the user presses. Then four more buttons to move the
822 * central one, and we're also keeping track of the icon set in the middle
823 * button, since when this one moves, we change the icon, and when movement
824 * is finished (by releasing one of the four arrow buttons), we set back the
829 * Keeping any of those four buttons pressed will trigger their autorepeat
830 * callback, where we move the button doing some size hint magic. To
831 * understand how that works better, refer to the @ref Box documentation.
832 * Also, the first time the function is called, we change the icon in the
833 * middle button, using elm_button_icon_unset() first to keep the reference
834 * to the previous one, so we don't need to recreate it when we are done
838 * @until size_hint_align_set
841 * One more callback for the option buttons, that just sets the timeouts for
842 * the different autorepeat options.
849 * And the main function, which does some setting up of the buttons in boxes
850 * to make things work. Here we'll go through some snippets only.
852 * For the option buttons, it's just the button with its label and callback.
853 * @skip elm_button_add
854 * @until smart_callback_add
856 * For the ones that move the central button, we have no labels. There are
857 * icons instead, and the autorepeat option is toggled.
859 * @skip elm_button_add
860 * @until data.cursors.up
862 * And just to show the mid button, which doesn't have anything special.
863 * @skip data.cursors.left
864 * @skip elm_button_add
869 * @example button_example_01.c
873 * @page bubble_01_example_page elm_bubble - Simple use.
874 * @dontinclude bubble_example_01.c
876 * This example shows a bubble with all fields set(label, info, content and
877 * icon) and the selected corner changing when the bubble is clicked. To be
878 * able use a bubble we need to do some setup and create a window, for this
879 * example we are going to ignore that part of the code since it isn't
880 * relevant to the bubble.
882 * To have the selected corner change in a clockwise motion we are going to
883 * use the following callback:
888 * Here we are creating an elm_label that is going to be used as the content
890 * @skipline elm_label
892 * @note You could use any evas_object for this, we are using an elm_label
895 * Despite it's name the bubble's icon doesn't have to be an icon, it can be
896 * any evas_object. For this example we are going to make the icon a simple
900 * And finally we have the actual bubble creation and the setting of it's
901 * label, info and content:
904 * @note Because we didn't set a corner, the default("top_left") will be
907 * Now that we have our bubble all that is left is connecting the "clicked"
908 * signals to our callback:
909 * @line smart_callback
911 * This last bubble we created was very complete, so it's pertinent to show
912 * that most of that stuff is optional a bubble can be created with nothing
917 * Our example will look like this:
919 * @image html screenshots/bubble_example_01.png
920 * @image latex screenshots/bubble_example_01.eps width=\textwidth
922 * See the full source code @ref bubble_example_01.c here.
923 * @example bubble_example_01.c
927 * @page box_example_01 Box - Basic API
929 * @dontinclude button_example_01.c
931 * As a special guest tonight, we have the @ref button_example_01 "simple
932 * button example". There are plenty of boxes in it, and to make the cursor
933 * buttons that moved a central one around when pressed, we had to use a
934 * variety of values for their hints.
936 * To start, let's take a look at the handling of the central button when
937 * we were moving it around. To achieve this effect without falling back to
938 * a complete manual positioning of the @c Evas_Object in our canvas, we just
939 * put it in a box and played with its alignment within it, as seen in the
940 * following snippet of the callback for the pressed buttons.
941 * @skip evas_object_size_hint_align_get
942 * @until evas_object_size_hint_align_set
944 * Not much to it. We get the current alignment of the object and change it
945 * by just a little, depending on which button was pressed, then set it
946 * again, making sure we stay within the 0.0-1.0 range so the button moves
947 * inside the space it has, instead of disappearing under the other objects.
949 * But as useful as an example as that may have been, the usual case with boxes
950 * is to set everything at the moment they are created, like we did for
951 * everything else in our main function.
953 * The entire layout of our program is made with boxes. We have one set as the
954 * resize object for the window, which means it will always be resized with
955 * the window. The weight hints set to @c EVAS_HINT_EXPAND will tell the
956 * window that the box can grow past it's minimum size, which allows resizing
960 * @until evas_object_show
962 * Two more boxes, set to horizontal, hold the buttons to change the autorepeat
963 * configuration used by the buttons. We create each to take over all the
964 * available space horizontally, but we don't want them to grow vertically,
965 * so we keep that axis of the weight with 0.0. Then it gets packed in the
968 * @until evas_object_show
970 * The buttons in each of those boxes have nothing special, they are just packed
971 * in with their default values and the box will use their minimum size, as set
972 * by Elementary itself based on the label, icon, finger size and theme.
974 * But the buttons used to move the central one have a special disposition.
975 * The top one first, is placed right into the main box like our other smaller
976 * boxes. Set to expand horizontally and not vertically, and in this case we
977 * also tell it to fill that space, so it gets resized to take the entire
978 * width of the window.
980 * @skip elm_button_add
981 * @until evas_object_show
983 * The bottom one will be the same, but for the other two we need to use a
984 * second box set to take as much space as we have, so we can place our side
985 * buttons in place and have the big empty space where the central button will
988 * @until evas_object_show
990 * Then the buttons will have their hints inverted to the other top and bottom
991 * ones, to expand and fill vertically and keep their minimum size horizontally.
992 * @skip elm_button_add
993 * @until evas_object_show
995 * The central button takes every thing else. It will ask to be expanded in
996 * both directions, but without filling its cell. Changing its alignment by
997 * pressing the buttons will make it move around.
998 * @skip elm_button_add
999 * @until evas_object_show
1001 * To end, the rightmost button is packed in the smaller box after the central
1002 * one, and back to the main box we have the bottom button at the end.
1006 * @page box_example_02 Box - Layout transitions
1008 * @dontinclude box_example_02.c
1010 * Setting a customized layout for a box is simple once you have the layout
1011 * function, which is just like the layout function for @c Evas_Box. The new
1012 * and fancier thing we can do with Elementary is animate the transition from
1013 * one layout to the next. We'll see now how to do that through a simple
1014 * example, while also taking a look at some of the API that was left
1015 * untouched in our @ref box_example_01 "previous example".
1017 * @image html screenshots/box_example_02.png
1018 * @image latex screenshots/box_example_02.eps width=\textwidth
1020 * @skipline Elementary.h
1022 * Our application data consists of a list of layout functions, given by
1023 * @c transitions. We'll be animating through them throughout the entire run.
1024 * The box with the stuff to move around and the last layout that was set to
1025 * make things easier in the code.
1027 * @until Transitions_Data
1029 * The box starts with three buttons, clicking on any of them will take it
1030 * out of the box without deleting the object. There are also two more buttons
1031 * outside, one to add an object to the box and the other to clear it.
1032 * This is all to show how you can interact with the items in the box, add
1033 * things and even remove them, while the transitions occur.
1035 * One of the callback we'll be using creates a new button, asks the box for
1036 * the list of its children and if it's not empty, we add the new object after
1037 * the first one, otherwise just place at the end as it will not make any
1043 * The clear button is even simpler. Everything in the box will be deleted,
1044 * leaving it empty and ready to fill it up with more stuff.
1048 * And a little function to remove buttons from the box without deleting them.
1049 * This one is set for the @c clicked callback of the original buttons,
1050 * unpacking them when clicked and placing it somewhere in the screen where
1051 * they will not disturb. Once we do this, the box no longer has any control
1052 * of it, so it will be left untouched until the program ends.
1056 * If we wanted, we could just call @c evas_object_del() on the object to
1057 * destroy it. In this case, no unpack is really necessary, as the box would
1058 * be notified of a child being deleted and adjust its calculations accordingly.
1060 * The core of the program is the following function. It takes whatever
1061 * function is first on our list of layouts and together with the
1062 * @c last_layout, it creates an ::Elm_Box_Transition to use with
1063 * elm_box_layout_transition(). In here, we tell it to start from whatever
1064 * layout we last set, end with the one that was at the top of the list and
1065 * when everything is finished, call us back so we can create another
1066 * transition. Finally, move the new layout to the end of the list so we
1067 * can continue running through them until the program ends.
1071 * The main function doesn't have antyhing special. Creation of box, initial
1072 * buttons and some callback setting. The only part worth mentioning is the
1073 * initialization of our application data.
1075 * @until evas_object_box_layout_stack
1077 * We have a simple static variable, set the box, the first layout we are
1078 * using as last and create the list with the different functions to go
1081 * And in the end, we set the first layout and call the same function we went
1082 * through before to start the run of transitions.
1083 * @until _test_box_transition_change
1085 * For the full code, follow @ref box_example_02.c "here".
1087 * @example box_example_02.c
1091 * @page calendar_example_01 Calendar - Simple creation.
1092 * @dontinclude calendar_example_01.c
1094 * As a first example, let's just display a calendar in our window,
1095 * explaining all steps required to do so.
1097 * First you should declare objects we intend to use:
1098 * @skipline Evas_Object
1100 * Then a window is created, a title is set and its set to be autodeleted.
1101 * More details can be found on windows examples:
1102 * @until elm_win_autodel
1104 * Next a simple background is placed on our windows. More details on
1105 * @ref bg_01_example_page :
1106 * @until evas_object_show(bg)
1108 * Now, the exciting part, let's add the calendar with elm_calendar_add(),
1109 * passing our window object as parent.
1110 * @until evas_object_show(cal);
1112 * To conclude our example, we should show the window and run elm mainloop:
1115 * Our example will look like this:
1117 * @image html screenshots/calendar_example_01.png
1118 * @image latex screenshots/calendar_example_01.eps width=\textwidth
1120 * See the full source code @ref calendar_example_01.c here.
1121 * @example calendar_example_01.c
1125 * @page calendar_example_02 Calendar - Layout strings formatting.
1126 * @dontinclude calendar_example_02.c
1128 * In this simple example, we'll explain how to format the label displaying
1129 * month and year, and also set weekday names.
1131 * To format month and year label, we need to create a callback function
1132 * to create a string given the selected time, declared under a
1133 * <tt> struct tm </tt>.
1135 * <tt> struct tm </tt>, declared on @c time.h, is a structure composed by
1137 * @li tm_sec seconds [0,59]
1138 * @li tm_min minutes [0,59]
1139 * @li tm_hour hour [0,23]
1140 * @li tm_mday day of month [1,31]
1141 * @li tm_mon month of year [0,11]
1142 * @li tm_year years since 1900
1143 * @li tm_wday day of week [0,6] (Sunday = 0)
1144 * @li tm_yday day of year [0,365]
1145 * @li tm_isdst daylight savings flag
1146 * @note glib version has 2 additional fields.
1148 * For our function, only stuff that matters are tm_mon and tm_year.
1149 * But we don't need to access it directly, since there are nice functions
1150 * to format date and time, as @c strftime.
1151 * We will get abbreviated month (%b) and year (%y) (check strftime manpage
1152 * for more) in our example:
1153 * @skipline static char
1156 * We need to alloc the string to be returned, and calendar widget will
1157 * free it when it's not needed, what is done by @c strdup.
1158 * So let's register our callback to calendar object:
1159 * @skipline elm_calendar_format_function_set
1161 * To set weekday names, we should declare them as an array of strings:
1162 * @dontinclude calendar_example_02.c
1163 * @skipline weekdays
1166 * And finally set them to calendar:
1167 * skipline weekdays_names_set
1169 * Our example will look like this:
1171 * @image html screenshots/calendar_example_02.png
1172 * @image latex screenshots/calendar_example_02.eps width=\textwidth
1174 * See the full source code @ref calendar_example_02.c here.
1175 * @example calendar_example_02.c
1179 * @page calendar_example_03 Calendar - Years restrictions.
1180 * @dontinclude calendar_example_03.c
1182 * This example explains how to set max and min year to be displayed
1183 * by a calendar object. This means that user won't be able to
1184 * see or select a date before and after selected years.
1185 * By default, limits are 1902 and maximun value will depends
1186 * on platform architecture (year 2037 for 32 bits); You can
1187 * read more about time functions on @c ctime manpage.
1189 * Straigh to the point, to set it is enough to call
1190 * elm_calendar_min_max_year_set(). First value is minimun year, second
1191 * is maximum. If first value is negative, it won't apply limit for min
1192 * year, if the second one is negative, won't apply for max year.
1193 * Setting both to negative value will clear limits (default state):
1194 * @skipline elm_calendar_min_max_year_set
1196 * Our example will look like this:
1198 * @image html screenshots/calendar_example_03.png
1199 * @image latex screenshots/calendar_example_03.eps width=\textwidth
1201 * See the full source code @ref calendar_example_03.c here.
1202 * @example calendar_example_03.c
1206 * @page calendar_example_04 Calendar - Days selection.
1207 * @dontinclude calendar_example_04.c
1209 * It's possible to disable date selection and to select a date
1210 * from your program, and that's what we'll see on this example.
1212 * If isn't required that users could select a day on calendar,
1213 * only interacting going through months, disabling days selection
1214 * could be a good idea to avoid confusion. For that:
1215 * @skipline elm_calendar_day_selection_enabled_set
1217 * Also, regarding days selection, you could be interested to set a
1218 * date to be highlighted on calendar from your code, maybe when
1219 * a specific event happens, or after calendar creation. Let's select
1220 * two days from current day:
1221 * @dontinclude calendar_example_04.c
1222 * @skipline SECS_DAY
1223 * @skipline current_time
1224 * @until elm_calendar_selected_time_set
1226 * Our example will look like this:
1228 * @image html screenshots/calendar_example_04.png
1229 * @image latex screenshots/calendar_example_04.eps width=\textwidth
1231 * See the full source code @ref calendar_example_04.c here.
1232 * @example calendar_example_04.c
1236 * @page calendar_example_05 Calendar - Signal callback and getters.
1237 * @dontinclude calendar_example_05.c
1239 * Most of setters explained on previous examples have associated getters.
1240 * That's the subject of this example. We'll add a callback to display
1241 * all calendar information every time user interacts with the calendar.
1243 * Let's check our callback function:
1244 * @skipline static void
1245 * @until double interval;
1247 * To get selected day, we need to call elm_calendar_selected_time_get(),
1248 * but to assure nothing wrong happened, we must check for function return.
1249 * It'll return @c EINA_FALSE if fail. Otherwise we can use time set to
1250 * our structure @p stime.
1251 * @skipline elm_calendar_selected_time_get
1254 * Next we'll get information from calendar and place on declared vars:
1255 * @skipline interval
1256 * @until elm_calendar_weekdays_names_get
1258 * The only tricky part is that last line gets an array of strings
1259 * (char arrays), one for each weekday.
1261 * Then we can simple print that to stdin:
1265 * <tt> struct tm </tt> is declared on @c time.h. You can check @c ctime
1266 * manpage to read about it.
1268 * To register this callback, that will be called every time user selects
1269 * a day or goes to next or previous month, just add a callback for signal
1271 * @skipline evas_object_smart_callback_add
1273 * Our example will look like this:
1275 * @image html screenshots/calendar_example_05.png
1276 * @image latex screenshots/calendar_example_05.eps width=\textwidth
1278 * See the full source code @ref calendar_example_05.c here.
1279 * @example calendar_example_05.c
1283 * @page calendar_example_06 Calendar - Calendar marks.
1284 * @dontinclude calendar_example_06.c
1286 * On this example marks management will be explained. Functions
1287 * elm_calendar_mark_add(), elm_calendar_mark_del() and
1288 * elm_calendar_marks_clear() will be covered.
1290 * To add a mark, will be required to choose three things:
1292 * @li mark date, or start date if it will be repeated
1293 * @li mark periodicity
1295 * Style defines the kind of mark will be displayed over marked day,
1296 * on caledar. Default theme supports @b holiday and @b checked.
1297 * If more is required, is possible to set a new theme to calendar
1298 * widget using elm_object_style_set(), and use
1299 * the signal that will be used by such marks.
1301 * Date is a <tt> struct tm </tt>, as defined by @c time.h. More can
1302 * be read on @c ctime manpage.
1303 * If a date relative from current is required, this struct can be set
1305 * @skipline current_time
1306 * @until localtime_r
1308 * Or if it's an absolute date, you can just declare the struct like:
1309 * @dontinclude calendar_example_06.c
1311 * @until christmas.tm_mon
1313 * Periodicity is how frequently the mark will be displayed over the
1314 * calendar. Can be a unique mark (that don't repeat), or it can repeat
1315 * daily, weekly, monthly or annually. It's enumerated by
1316 * @c Elm_Calendar_Mark_Repeat.
1318 * So let's add some marks to our calendar. We will add christmas holiday,
1319 * set Sundays as holidays, and check current day and day after that.
1320 * @dontinclude calendar_example_06.c
1322 * @until christmas.tm_mon
1323 * @skipline current_time
1324 * @until ELM_CALENDAR_WEEKLY
1326 * We kept the return of first mark add, because we don't really won't it
1327 * to be checked, so let's remove it:
1328 * @skipline elm_calendar_mark_del
1330 * After all marks are added and removed, is required to draw them:
1331 * @skipline elm_calendar_marks_draw
1333 * Finally, to clear all marks, let's set a callback for our button:
1334 * @skipline elm_button_add
1335 * @until evas_object_show(bt);
1337 * This callback will receive our calendar object, and should clear it:
1338 * @dontinclude calendar_example_06.c
1341 * @note Remember to draw marks after clear the calendar.
1343 * Our example will look like this:
1345 * @image html screenshots/calendar_example_06.png
1346 * @image latex screenshots/calendar_example_06.eps width=\textwidth
1348 * See the full source code @ref calendar_example_06.c here.
1349 * @example calendar_example_06.c
1353 * @page spinner_example Spinner widget example
1355 * This code places seven Elementary spinner widgets on a window, each of
1356 * them exemplifying a part of the widget's API.
1358 * The first of them is the default spinner:
1359 * @dontinclude spinner_example.c
1360 * @skipline elm_spinner_add
1361 * @until evas_object_show
1362 * As you see, the defaults for a spinner are:
1364 * @li min value set to 0
1365 * @li max value set to 100
1366 * @li step value set to 1
1367 * @li label format set to "%0.f"
1369 * If another format is required, see the second spinner. It will put a text
1370 * before and after the value, and also format value to display two decimals:
1371 * @skipline format_set
1373 * The third one will use a customized step, define new minimum and maximum
1374 * values and enable wrap, so when value reaches minimum it jumps to maximum,
1375 * or jumps to minimum after maximum value is reached. Format is set to display
1377 * @skipline elm_spinner_add
1378 * @until evas_object_show
1380 * The fourth uses @c vertical style, so instead of left and right arrows,
1381 * top and bottom are displayed. Also the change interval is reduced, so
1382 * user can change value faster.
1384 * @skipline interval
1386 * In the fifth the user won't be allowed to set value directly, i.e., will
1387 * be obligate change value only using arrows:
1388 * @skipline editable
1390 * The sixth widget will receive a lot of special values, so
1391 * instead of reading numeric values, user will see labels for each one.
1392 * Also direct edition is disabled, otherwise users would see the numeric
1393 * value on edition mode. User will be able to select a month in this widget:
1394 * @skipline elm_spinner_add
1395 * @until evas_object_show
1397 * Finally the last widget will exemplify how to listen to widget's signals,
1398 * <tt> changed </tt> and <tt> delay,changed </tt>. First we need to
1399 * implement callback functions that will simply print spinner's value:
1400 * @dontinclude spinner_example.c
1407 * The first callback function should be called everytime value changes,
1408 * the second one only after user stops to increment or decrement. Try
1409 * to keep arrows pressed and check the difference.
1410 * @skip smart_callback
1411 * @skipline smart_callback
1412 * @skipline smart_callback
1414 * See the full @ref spinner_example.c "example", whose window should
1415 * look like this picture:
1417 * @image html screenshots/spinner_example.png
1418 * @image latex screenshots/spinner_example.eps width=\textwidth
1420 * See the full @ref spinner_example.c "source code" for this example.
1422 * @example spinner_example.c
1426 * @page slider_example Slider widget example
1428 * This code places seven Elementary slider widgets on a window, each of
1429 * them exemplifying a part of the widget's API.
1431 * The first of them is the default slider:
1432 * @dontinclude slider_example.c
1433 * @skipline elm_slider_add
1434 * @until evas_object_show
1436 * As you see, the defaults for a slider are:
1439 * @li no values (on indicator or unit labels)
1441 * Actually it's pretty useless this way. So let's learn how to improve it.
1443 * If some decoration is required, a label can be set, and icon before and
1444 * after the bar as well. On the second slider will add a @c home icon
1445 * and a @c folder icon at @c end.
1446 * @skipline text_set
1449 * If the bar size need to be changed, it can be done with span set function,
1450 * that doesn't accounts other widget's parts size. Also the bar can starts
1451 * with a not default value (0.0), as we done on third slider:
1452 * @skipline value_set
1453 * @skipline span_size_set
1455 * So far, users won't be able to see the slider value. If it's required,
1456 * it can be displayed in two different areas, units label or above
1459 * Let's place a units label on our widget, and also let's set minimum and
1460 * maximum value (uses 0.0 and 1.0 by default):
1461 * @skipline unit_format_set
1462 * @skipline min_max_set
1464 * If above the indicator is the place to display the value, just set it.
1465 * Also, is possible to invert a bar, as you can see:
1466 * @skipline indicator_format_set
1467 * @skipline inverted_set
1469 * But if you require to use a function a bit more customized to show the value,
1470 * is possible to registry a callback function that will be called
1471 * to display unit or indicator label. Only the value will be passed to this
1472 * function, that should return a string.
1473 * In this case, a function to free this string will be required.
1475 * Let's exemplify with indicator label on our sixth slider:
1476 * @dontinclude slider_example.c
1487 * Setting callback functions:
1488 * @skipline indicator_format_function_set
1489 * @skipline _indicator_free
1491 * Also, a slider can be displayed vertically:
1492 * @dontinclude slider_example.c
1493 * @skipline elm_slider_horizontal_set
1495 * Finally the last widget will exemplify how to listen to widget's signals,
1496 * <tt> changed </tt> and <tt> delay,changed </tt>. First we need to
1497 * implement callback functions that will simply print slider's value:
1498 * @dontinclude slider_example.c
1505 * The first callback function should be called everytime value changes,
1506 * the second one only after user stops to increment or decrement. Try
1507 * to keep arrows pressed and check the difference.
1508 * @skip smart_callback
1509 * @skipline smart_callback
1510 * @skipline smart_callback
1512 * See the full @ref slider_example.c "example", whose window should
1513 * look like this picture:
1515 * @image html screenshots/slider_example.png
1516 * @image latex screenshots/slider_example.eps width=\textwidth
1518 * See the full @ref slider_example.c "source code" for this example.
1520 * @example slider_example.c
1524 * @page panes_example Panes widget example
1526 * This code places two Elementary panes widgets on a window, one of them
1527 * displayed vertically and the other horizontally, to exemplify
1528 * a part of the widget's API. Also, all the signals emitted by this
1529 * widget will be covered.
1531 * Let's start adding a panes to our window:
1532 * @dontinclude panes_example.c
1533 * @skipline elm_panes_add
1534 * @until evas_object_show
1536 * Now we will set a content (a simple button) to the left side of our
1538 * @skipline elm_button_add
1539 * @until content_left_set
1541 * The content of the right side will be something a bit more elaborated, we'll
1542 * place another panes, displayed vertically (it's displayed horizontally
1544 * @skipline elm_panes_add
1545 * @until content_right_set
1547 * When populating a panes displayed vertically, remember that left content
1548 * will be placed at top, and right content will place at bottom. Next
1549 * we will add two buttons to exemplify that:
1550 * @skipline elm_button_add
1551 * @until content_right_set
1553 * Panes widgets emits 4 different signals, depending on users interaction
1554 * with the draggable bar. We'll add a callback function for each of them.
1556 * <tt> "clicked" signal </tt>:
1558 * Callback function that just print "Clicked" to stdin:
1559 * @dontinclude panes_example.c
1566 * @skipline static void
1569 * Also, add callback function to the panes:
1570 * @skipline "clicked"
1572 * <tt> "press" signal </tt>:
1574 * Callback function that just print "Pressed" to stdin:
1575 * @dontinclude panes_example.c
1578 * @skipline static void
1581 * Also, add callback function to the panes:
1584 * Now, let's try to make our callback functions a bit more useful:
1586 * <tt> "unpress" signal </tt>:
1588 * Suppose we want to know the size proportion of left content after
1589 * user drags the bar. We need to listen for @c unpress signal, and
1590 * get this size from our panes widget. It's done on the following
1592 * @dontinclude panes_example.c
1597 * @skipline static void
1600 * Adding the callback function to the panes:
1601 * @skipline "unpress"
1603 * <tt> "clicked,double" signal </tt>:
1605 * Now, a interesting feature that could be addded to panes widget.
1606 * Hide a content when user double click the draggable bar. It's done
1607 * using a variable to store size and content left size getter and setter
1608 * on the following function:
1609 * @dontinclude panes_example.c
1610 * @skipline static double
1617 * @skipline static void
1622 * Adding the callback function to the panes:
1623 * @skipline "clicked,double"
1626 * See the full @ref panes_example.c "example", whose window should
1627 * look like this picture:
1629 * @image html screenshots/panes_example.png
1630 * @image latex screenshots/panes_example.eps width=\textwidth
1632 * @example panes_example.c
1636 * @page clock_example Clock widget example
1638 * This code places five Elementary clock widgets on a window, each of
1639 * them exemplifying a part of the widget's API.
1641 * The first of them is the pristine clock:
1642 * @dontinclude clock_example.c
1644 * @until evas_object_show
1645 * As you see, the defaults for a clock are:
1647 * - no seconds shown
1649 * For am/pm time, see the second clock:
1650 * @dontinclude clock_example.c
1652 * @until evas_object_show
1654 * The third one will show the seconds digits, which will flip in
1655 * synchrony with system time. Note, besides, that the time itself is
1656 * @b different from the system's -- it was customly set with
1657 * elm_clock_time_set():
1658 * @dontinclude clock_example.c
1659 * @skip with seconds
1660 * @until evas_object_show
1662 * In both fourth and fifth ones, we turn on the <b>edition
1663 * mode</b>. See how you can change each of the sheets on it, and be
1664 * sure to try holding the mouse pressed over one of the sheet
1665 * arrows. The forth one also starts with a custom time set:
1666 * @dontinclude clock_example.c
1668 * @until evas_object_show
1670 * The fifth, besides editable, has only the time @b units editable,
1671 * for hours, minutes and seconds. This exemplifies
1672 * elm_clock_digit_edit_set():
1673 * @dontinclude clock_example.c
1675 * @until evas_object_show
1677 * See the full @ref clock_example.c "example", whose window should
1678 * look like this picture:
1680 * @image html screenshots/clock_example.png
1681 * @image latex screenshots/clock_example.eps width=\textwidth
1683 * See the full @ref clock_example_c "source code" for this example.
1685 * @example clock_example.c
1689 * @page mapbuf_example Mapbuf Widget Example
1691 * This code places a Elementary mapbuf widget on a window,
1692 * to exemplify part of the widget's API.
1694 * First we'll add an window with a background and a vertical box to
1695 * pack our interface elements:
1696 * @dontinclude mapbuf_example.c
1700 * Next we'll simply add the mapbuf widget to the box:
1701 * @skipline mapbuf_add
1704 * But mapbuf is a container widget, it won't do anything alone. So let's
1705 * create a table full of icons. For that we'll loop to fill each line of each
1706 * column. See @ref tutorial_table_01 "tutorial_table_01"
1707 * if you don't know how to use tables:
1708 * @skipline table_add
1712 * Finally, setting mapbuf content:
1713 * @skipline content_set
1716 * Also, would be good a horizontal box with some controls to change mapbuf
1721 * By default map is disabled. So just setting content isn't enough.
1722 * Alpha and smooth settings will be applied when map is enabled.
1723 * So we'll add a toggle for that. Everytime the map properties
1724 * are changed, map will need to be enabled again. So if you
1725 * want to play a bit with our example, remember to always enable
1726 * map again after concluding your changes.
1727 * @skipline toggle_add
1730 * We have added a callback function to this toggle, so it will enable
1732 * @dontinclude mapbuf_example.c
1738 * Let's add check boxes for alpha blending and smooth rendering:
1739 * @skipline check_add
1743 * By default, mapbuf would enable alpha blending and smooth rendering,
1744 * so we need to check boxes to be consistent with its behavior.
1746 * Callback functions look like the one added to the toggle. This way we
1747 * could enable or disable the both properties:
1748 * @dontinclude mapbuf_example.c
1757 * You'll see that disabling alpha blending will set a black rectangle below
1758 * the icons. That's the reason you only should enable that when you're sure
1759 * the mapbuf content is 100% solid.
1761 * See @ref mapbuf_example.c "mapbuf_example.c", whose window should
1762 * look like this picture:
1764 * @image html screenshots/mapbuf_example.png
1765 * @image latex screenshots/mapbuf_example.eps width=\textwidth
1767 * @example mapbuf_example.c
1771 * @page map_example_01 Map Example - Creation and Zoom
1773 * This code places a Elementary map widget on a window,
1774 * to exemplify part of the widget's API.
1776 * Let's start adding a map to our window:
1777 * @dontinclude map_example_01.c
1778 * @skipline elm_map_add
1779 * @until evas_object_show
1781 * It's enough to display a world map inside our window. But usually you'll
1782 * need to let user interact with the map. We need to place some buttons,
1783 * so the user could control the map. It's done on the followin code.
1784 * If you don't know about boxes, or buttons, check their examples,
1785 * @ref box_example_01 "Box Example 1" and
1786 * @ref button_example_01 "Button Example 1".
1787 * @skipline elm_box_add
1788 * @until _bt_zoom_fill
1790 * We are adding callback functions that will be called when the user clicks
1791 * over these buttons. Let's study such functions, starting from the function
1792 * that will zoom in the map:
1793 * @dontinclude map_example_01.c
1794 * @skipline static void
1797 * First thing done is assure zoom mode is set to manual. It's the default
1798 * mode, but the other buttons will change this, so before setting a new
1799 * zoom value, we need to change the zoom mode.
1801 * Then, we get the current zoom value, increment that, and set the new
1802 * value to the map. If it's bigger than max zoom value allowed, it will
1803 * remain on the maximum allowed, nothing bad will happen. This way we
1804 * don't need to check first if it won't be bigger than max.
1806 * Zoom out function is basically the same thing, but zoom will be decremented
1807 * instead of incremented:
1808 * @skipline static void
1811 * The "X" button, when pressed, will call a function that will
1812 * zoom the map until it fits
1813 * inside the scroll frame with no pixels outside this area:
1814 * @skipline static void
1817 * And the "#" button, will call a function that will zoom until map fills
1818 * scroll, ensuring no pixels are left unfilled:
1819 * @skipline static void
1822 * But we can also set map to show something different from default
1823 * world map, changing the zoom level and region shown. Let's pick a
1824 * wonderful city coordinates, one placed at <tt> 43 20 S, 22 90 W </tt>.
1825 * Since map uses double variables to represent latitude and longitude,
1826 * to represent north or east, we should represent it as positive values,
1827 * and south or west as negative. Also, the value will be represented as
1828 * degree.min. So, for example, our longitude <tt> 43 20 S </tt> will
1830 * by the value <tt> -43.20 </tt>. A zoom set to @c 12 should be enough
1832 * @skipline region_show
1835 * See @ref map_example_01.c "map_example_01.c" for full source,
1836 * whose window should
1837 * look like this picture:
1839 * @image html screenshots/map_example_01.png
1840 * @image latex screenshots/map_example_01.eps width=\textwidth
1842 * @example map_example_01.c
1846 * @page map_example_02 Map Example - Markers Usage
1848 * This code places a Elementary map widget on a window,
1849 * to exemplify part of the widget's API, related to markers.
1851 * We'll start this example the same way
1852 * @ref map_example_01 "Map Example 1". Adding a map with buttons to control
1853 * zoom, so if you didn't read it yet, just do it now.
1854 * @dontinclude map_example_02.c
1855 * @skipline elm_map_add
1858 * Markers can be placed over the map to represent anything we want. Let's
1859 * say we want to represent some countries and cities with markers. To add
1860 * a mark we need a marker class and also a group class.
1862 * A marker class can be created as the following code does:
1863 * @skipline marker_class_new
1866 * These lines create a new class, set a function to return the object
1867 * to be displayed inside the bubble that opens when a user clicks over
1868 * the mark, set the function to retrieve an icon to be placed inside
1869 * the marker, and defines the style of this marker. It can be @c empty
1870 * that will just show the icon, @c radio, that will place a blue circle,
1871 * and @c radio2 that will place a green circle.
1873 * The group classes can be created in a very similar way, but you won't
1874 * set callback functions to get stuff to be placed inside the bubble,
1875 * since clicking over a group marker will just get the content
1876 * of all the markers composing the group and place on this bubble.
1877 * The limit of markers to get can be set with function
1878 * elm_map_max_marker_per_group_set() but we won't need on this example.
1879 * But we can set the zoom required to display the marks that belongs
1880 * to this group class, so if the zoom is less than this value, nothing
1881 * will be show. The group marker style will be used when markers are
1882 * near each other, and the count of markers grouped will be placed
1883 * inside the group marker.
1884 * @skipline group_class_new
1885 * @until displayed_set
1887 * For marker and group classes to represent a country, the same is done:
1888 * @skipline marker_class_new
1889 * @until displayed_set
1891 * Next we'll create some markers representing cities and coutries.
1892 * We'll append them in a list, to close up them later. To create a marker
1893 * we need to pass the coordinates, marker class, group class and optionally,
1895 * @skipline marker_add
1899 * We have created a specific structure for this example to store the name
1900 * of the place and a path to a image file to represent it.
1901 * @dontinclude map_example_02.c
1903 * @until Marker_Data;
1905 * We'll create instances for each place:
1906 * @skipline argentina
1909 * Finally, on our @c main function, we ask the map to show all the markers
1910 * with the biggest zoom possible, passing the list of markers added:
1911 * @skipline list_show
1913 * Actually the zoom is not what we want, so after the download of the map
1914 * is concluded, let's set another zoom level. For this we add a callback
1915 * for @c "downloaded" signal:
1916 * @skipline callback_add
1918 * The callback function will simply set the zoom level we want and remove
1919 * the callback, otherwise it would be called all the time, after the map
1921 * @dontinclude map_example_02.c
1922 * @skipline _map_downloaded
1925 * We added two kinds of callback functions when we added the markers.
1926 * One will return the content of the bubbles, and other the icon to be
1927 * placed inside the marker.
1929 * To return an icon, all we need to do is add a elm_icon and return it:
1930 * @dontinclude map_example_02.c
1931 * @skip static Evas_Object
1933 * @skipline static Evas_Object
1936 * For the content, let's return something more elaboreate. We will return
1937 * a box with an image representing the place, and the name of this place:
1938 * @skipline static Evas_Object
1941 * See @ref map_example_02.c "map_example_02.c" for full source,
1942 * whose window should
1943 * look like this picture:
1945 * @image html screenshots/map_example_02.png
1946 * @image latex screenshots/map_example_02.eps width=\textwidth
1948 * @example map_example_02.c
1952 * @page map_example_03 Map Example - Route and Name Usage
1954 * This code places a Elementary map widget on a window,
1955 * to exemplify part of the widget's API, related routes and names.
1957 * In this example, we will suppose we need to set a route for the user
1958 * from his current point (a gps could provide us this information)
1959 * to somewhere else. So we would have coordinates of this
1960 * start point, and would like that he enters the address of his
1961 * destination in a entry, and we'll trace a route on the map.
1963 * We'll start this example the same way
1964 * @ref map_example_01 "Map Example 1". Adding a map with buttons to control
1965 * zoom, so if you didn't read it yet, just do it now. Actually there is
1966 * a change, that we're aligning buttons to the top, since we wan't a
1967 * vertical control box this time.
1968 * @dontinclude map_example_03.c
1969 * @skipline elm_map_add
1973 * Next we set the box to be vertical and change it's size, weight
1974 * and alignment, so it will occupy the top of the window, from left
1976 * @skipline horizontal_set
1979 * We'll add an entry with a preliminar address, that I know will
1980 * find a coordinate, to examplify names work. But you can try
1981 * lots of addresses. From city or country names to pubs, or whatever
1982 * you want. To try is enough to run the example, type the address and
1983 * press "Route" button. This button will call a function that will
1984 * get the typed address and find the route.
1985 * @skipline entry_add
1989 * The button pass an structure
1990 * instance we make for this example, with all the fields we'll need.
1991 * @dontinclude map_example_03.c
1992 * @skipline _Example_Data
1993 * @until example_data;
1995 * Let's initialize it's fields:
1996 * @skipline example_data.map
1997 * @until example_data.start_lat
1999 * @c map and @c entry are our elementary objects, @c route is set to @c NULL,
2000 * since we don't have one yet, and the coordinates of the start point is set
2001 * (longitude and latitude).
2003 * Also, let's show this start point at the center of the map, and set a zoom
2004 * nice enough to close it:
2005 * @skipline region_show
2008 * These lines were already explained on @ref map_example_02 "Map Example 2".
2010 * Now we'll see the "Route" button callback function:
2011 * @dontinclude map_example_03.c
2014 * @skipline static void
2017 * First we get the address string from our entry. Then we use @c name
2019 * util functions, so we could get coordinates for this address. These
2020 * functions return an #Elm_Map_Name handle for us.
2021 * Function elm_map_utils_convert_name_into_coord() will do this job for us,
2022 * but it's an assyncronous function, since it requires this
2023 * information from the server.
2025 * That's the reason we need to wait for
2026 * <tt> "name,loaded" </tt> signal. We add a callback function for this:
2027 * @dontinclude map_example_03.c
2028 * @skipline static void
2031 * This function will check if a previous route was traced, and if it was,
2032 * it will remove it. Next we'll get destination coordinates from our
2033 * @c name, and use them to add a new route.
2035 * To trace a route we need to know how the user will go through the path.
2036 * Let's suppose he'll be walking, but doesn't like to walk, so we
2037 * need to choose the shortest path intead of the route that would
2038 * made him spend less time. Coordinates of the point from where he will
2039 * start and of the destination point need to be passed as well.
2041 * Finally we'll set a color different from solid red (default), to show
2042 * our route. We set it green.
2044 * See @ref map_example_03.c "map_example_03.c" for full source,
2045 * whose window should
2046 * look like this picture:
2048 * @image html screenshots/map_example_03.png
2049 * @image latex screenshots/map_example_03.eps width=\textwidth
2051 * @example map_example_03.c
2055 * @page diskselector_example_01 Diskselector widget example
2057 * This code places 4 Elementary diskselector widgets on a window, each of
2058 * them exemplifying a part of the widget's API.
2060 * All of them will have weekdays as items, since we won't focus
2061 * on items management on this example. For an example about this subject,
2062 * check @ref diskselector_example_02.
2064 * The first of them is a default diskselector.
2065 * @dontinclude diskselector_example_01.c
2068 * @skipline elm_diskselector_add
2069 * @until evas_object_show
2071 * We are just adding the diskselector, so as you can see, defaults for it are:
2072 * @li Only 3 items visible each time.
2073 * @li Only 3 characters are displayed for labels on side positions.
2074 * @li The first added item remains centeres, i.e., it's the selected item.
2076 * To add items, we are just appending it on a loop, using function
2077 * elm_diskselector_item_append(), that will be better exaplained on
2078 * items management example.
2080 * For a circular diskselector, check the second widget. A circular
2081 * diskselector will display first item after last, and last previous to
2082 * the first one. So, as you can see, @b Sa will appears on left side
2083 * of selected @b Sunday. This property is set with
2084 * elm_diskselector_round_set().
2086 * Also, we decide to display only 2 character for side labels, instead of 3.
2087 * For this we call elm_diskselector_side_label_length_set(). As result,
2088 * we'll see @b Mo displayed instead of @b Mon, when @b Monday is on a
2091 * @skipline elm_diskselector_add
2092 * @until evas_object_show
2094 * But so far, we are only displaying 3 items at once. If more are wanted,
2095 * is enough to call elm_diskselector_display_item_num_set(), as you can
2097 * @skipline elm_diskselector_add
2098 * @until evas_object_show
2100 * @note You can't set less than 3 items to be displayed.
2102 * Finally, if a bounce effect is required, or you would like to see
2103 * scrollbars, it is possible. But, for default theme, diskselector
2104 * scrollbars will be invisible anyway.
2105 * @skipline elm_diskselector_add
2106 * @until evas_object_show
2108 * See the full @ref diskselector_example_01.c "diskselector_example_01.c"
2109 * code, whose window should look like this picture:
2111 * @image html screenshots/diskselector_example_01.png
2112 * @image latex screenshots/diskselector_example_01.eps width=\textwidth
2114 * @example diskselector_example_01.c
2118 * @page diskselector_example_02 Diskselector - Items management
2120 * This code places a Elementary diskselector widgets on a window,
2121 * along with some buttons trigerring actions on it (though its API).
2122 * It covers most of Elm_Diskselector_Item functions.
2124 * On our @c main function, we are adding a default diskselector with
2125 * 3 items. We are only setting their labels (second parameter of function
2126 * elm_diskselector_item_append):
2127 * @dontinclude diskselector_example_02.c
2128 * @skipline elm_diskselector_add
2131 * Next we are adding lots of buttons, each one for a callback function
2132 * that will realize a task covering part of diskselector items API.
2133 * Lets check the first one:
2134 * @skipline elm_button_add
2135 * @until evas_object_show
2137 * We are labeling the button with a task description with
2138 * elm_object_text_set() and setting a callback
2139 * function evas_object_smart_callback_add().
2140 * Each callback function will have the signature:
2141 * <tt> static void _task_cb(void *data, Evas_Object *obj,
2142 * void *event_info)</tt> with the function name varying for each task.
2144 * Now let's cover all of them.
2146 * <b> Appending an item: </b>
2147 * @dontinclude diskselector_example_02.c
2151 * All items are included on diskselector after last one. You @b can't
2154 * The first parameter of elm_diskselector_item_append() is the diskselector
2155 * object, that we are receiving as data on our callback function.
2156 * The second one is a label, the string that will be placed in the center
2157 * of our item. As we don't wan't icons or callback functions, we can
2158 * send NULL as third, fourth and fifth parameters.
2160 * <b> Appending an item with icon: </b>
2161 * @dontinclude diskselector_example_02.c
2162 * @skipline _add_ic_cb
2165 * If an icon is required, you can pass it as third paramenter on our
2166 * elm_diskselector_item_append() function. It will be place on the
2167 * left side of item's label, that will be shifted to right a bit.
2169 * For more details about how to create icons, look for elm_icon examples.
2171 * <b> Appending an item with callback function for selected: </b>
2172 * @dontinclude diskselector_example_02.c
2177 * To set a callback function that will be called every time an item is
2178 * selected, i.e., everytime the diskselector stops with this item in
2179 * center position, just pass the function as fourth paramenter.
2181 * <b> Appending an item with callback function for selected with data: </b>
2182 * @dontinclude diskselector_example_02.c
2183 * @skipline _sel_data_cb
2189 * If the callback function request an extra data, it can be attached to our
2190 * item passing a pointer for data as fifth parameter.
2191 * Our function _sel_data_cb will receive it as <tt> void *data </tt>.
2193 * If you want to free this data, or handle that the way you need when the
2194 * item is deleted, set a callback function for that, with
2195 * elm_diskselector_item_del_cb_set().
2197 * As you can see we check if @c it is not @c NULL after appending it.
2198 * If an error happens, we won't try to set a function for it.
2200 * <b> Deleting an item: </b>
2201 * @dontinclude diskselector_example_02.c
2206 * To delete an item we simple need to call elm_diskselector_item_del() with
2207 * a pointer for such item.
2209 * If you need, you can get selected item with
2210 * elm_diskselector_selected_item_get(), that will return a pointer for it.
2212 * <b> Unselecting an item: </b>
2213 * @dontinclude diskselector_example_02.c
2214 * @skipline _unselect_cb
2217 * To select an item, you should call elm_diskselector_item_selected_set()
2218 * passing @c EINA_TRUE, and to unselect it, @c EINA_FALSE.
2220 * If you unselect the selected item, diskselector will automatically select
2223 * <b> Printing all items: </b>
2224 * @dontinclude diskselector_example_02.c
2225 * @skipline _print_cb
2228 * <b> Clearing the diskselector: </b>
2229 * @dontinclude diskselector_example_02.c
2230 * @skipline _clear_cb
2233 * <b> Selecting the first item: </b>
2234 * @dontinclude diskselector_example_02.c
2235 * @skipline _select_first_cb
2238 * <b> Selecting the last item: </b>
2239 * @dontinclude diskselector_example_02.c
2240 * @skipline _select_last_cb
2243 * <b> Selecting the next item: </b>
2244 * @dontinclude diskselector_example_02.c
2245 * @skipline _select_next_cb
2248 * <b> Selecting the previous item: </b>
2249 * @dontinclude diskselector_example_02.c
2250 * @skipline _select_prev_cb
2253 * See the full @ref diskselector_example_02.c "diskselector_example_02.c"
2254 * code, whose window should look like this picture:
2256 * @image html screenshots/diskselector_example_02.png
2257 * @image latex screenshots/diskselector_example_02.eps width=\textwidth
2259 * @example diskselector_example_02.c
2263 * @page list_example_01 List widget example
2265 * This code places a single Elementary list widgets on a window, just
2266 * to exemplify the more simple and common use case: a list will be created
2267 * and populated with a few items.
2269 * To keep it simple, we won't show how to customize the list, for this check
2270 * @ref list_example_02. Also, we won't focus
2271 * on items management on this example. For an example about this subject,
2272 * check @ref list_example_03.
2274 * To add a list widget.
2275 * @dontinclude list_example_01.c
2276 * @skipline elm_list_add
2278 * We are just adding the list, so as you can see, defaults for it are:
2279 * @li Items are displayed vertically.
2280 * @li Only one item can be selected.
2281 * @li The list doesn't bouce.
2283 * To add items, we are just appending it on a loop, using function
2284 * elm_list_item_append(), that will be better exaplained on
2285 * items management example.
2286 * @dontinclude list_example_01.c
2290 * @skipline elm_list_item_append
2292 * After we just want to show the list. But first we need to start the widget.
2293 * It was done this way to improve widget's performance. So, always remember
2295 * @warning Call elm_list_go before showing the object
2296 * @skipline elm_list_go
2299 * See the full @ref list_example_01.c "list_example_01.c"
2300 * code, whose window should look like this picture:
2302 * @image html screenshots/list_example_01.png
2303 * @image latex screenshots/list_example_01.eps width=\textwidth
2305 * @example list_example_01.c
2309 * @page list_example_02 List widget example
2311 * This code places a single Elementary list widgets on a window,
2312 * exemplifying a part of the widget's API.
2314 * First, we will just create a simple list, as done on @ref list_example_01 :
2315 * @dontinclude list_example_02.c
2318 * @skipline elm_list_add
2319 * @until elm_list_item_append
2321 * Now, let's customize this list a bit. First we will display items
2323 * @skipline horizontal_set
2325 * Then we will choose another list mode. There are four of them, and
2326 * the default #Elm_List_Mode is #ELM_LIST_SCROLL. Let's set compress mode:
2327 * @skipline mode_set
2329 * To enable multiple items selection, we need to enable it, since only one
2330 * selected item is allowed by default:
2331 * @skipline elm_list_multi_select_set
2333 * We are not adding items with callback functions here,
2334 * since we'll explain it better on @ref list_example_03. But if the callback
2335 * need to be called everytime user clicks an item, even if already selected,
2336 * it's required to enable this behavior:
2337 * @skipline elm_list_always_select_mode_set
2339 * Finally, if a bounce effect is required, or you would like to see
2340 * scrollbars, it is possible. But, for default theme, list
2341 * scrollbars will be invisible anyway.
2342 * @skipline bounce_set
2343 * @until SCROLLER_POLICY_ON
2345 * See the full @ref list_example_02.c "list_example_02.c"
2346 * code, whose window should look like this picture:
2348 * @image html screenshots/list_example_02.png
2349 * @image latex screenshots/list_example_02.eps width=\textwidth
2351 * @example list_example_02.c
2355 * @page list_example_03 List - Items management
2357 * This code places a Elementary list widgets on a window,
2358 * along with some buttons trigerring actions on it (though its API).
2359 * It covers most of Elm_List_Item functions.
2361 * On our @c main function, we are adding a default list with
2362 * 3 items. We are only setting their labels (second parameter of function
2363 * elm_list_item_append):
2364 * @dontinclude list_example_03.c
2365 * @skipline elm_list_add
2368 * Next we are adding lots of buttons, each one for a callback function
2369 * that will realize a task covering part of list items API.
2370 * Lets check the first one:
2371 * @skipline elm_button_add
2372 * @until evas_object_show
2374 * We are labeling the button with a task description with
2375 * elm_object_text_set() and setting a callback
2376 * function evas_object_smart_callback_add().
2377 * Each callback function will have the signature:
2378 * <tt> static void _task_cb(void *data, Evas_Object *obj,
2379 * void *event_info)</tt> with the function name varying for each task.
2381 * Now let's cover all of them.
2383 * <b> Prepending an item: </b>
2384 * @dontinclude list_example_03.c
2385 * @skipline _prepend_cb
2388 * The item will be placed on the begining of the list,
2389 * i.e. it will be the first one.
2391 * The first parameter of elm_list_item_prepend() is the list
2392 * object, that we are receiving as data on our callback function.
2393 * The second one is a label, the string that will be placed in the center
2394 * of our item. As we don't wan't icons or callback functions, we can
2395 * send NULL as third, fourth, fifth and sixth parameters.
2397 * <b> Appending an item: </b>
2398 * @dontinclude list_example_03.c
2402 * Items included with append will be inserted inserted after the last one.
2404 * <b> Appending an item with icon: </b>
2405 * @dontinclude list_example_03.c
2406 * @skipline _add_ic_cb
2409 * If an icon is required, you can pass it as third paramenter on our
2410 * elm_list_item_append() function. It will be place on the
2411 * left side of item's label. If an icon is wanted on the right side,
2412 * it should be passed as fourth parameter.
2414 * For more details about how to create icons, look for elm_icon examples
2415 * @ref tutorial_icon.
2417 * <b> Appending an item with callback function for selected: </b>
2418 * @dontinclude list_example_03.c
2423 * To set a callback function that will be called every time an item is
2424 * selected, i.e., everytime the list stops with this item in
2425 * center position, just pass the function as fifth paramenter.
2427 * <b> Appending an item with callback function for selected with data: </b>
2428 * @dontinclude list_example_03.c
2429 * @skipline _sel_data_cb
2435 * If the callback function request an extra data, it can be attached to our
2436 * item passing a pointer for data as sixth parameter.
2437 * Our function _sel_data_cb will receive it as <tt> void *data </tt>.
2439 * If you want to free this data, or handle that the way you need when the
2440 * item is deleted, set a callback function for that, with
2441 * elm_list_item_del_cb_set().
2443 * As you can see we check if @c it is not @c NULL after appending it.
2444 * If an error happens, we won't try to set a function for it.
2446 * <b> Deleting an item: </b>
2447 * @dontinclude list_example_03.c
2448 * @skipline _del_cb(
2451 * To delete an item we simple need to call elm_list_item_del() with
2452 * a pointer for such item.
2454 * If you need, you can get selected item with
2455 * elm_list_selected_item_get(), that will return a pointer for it.
2457 * <b> Unselecting an item: </b>
2458 * @dontinclude list_example_03.c
2459 * @skipline _unselect_cb
2462 * To select an item, you should call elm_list_item_selected_set()
2463 * passing @c EINA_TRUE, and to unselect it, @c EINA_FALSE.
2465 * <b> Printing all items: </b>
2466 * @dontinclude list_example_03.c
2467 * @skipline _print_cb
2470 * <b> Clearing the list: </b>
2471 * @dontinclude list_example_03.c
2472 * @skipline _clear_cb
2475 * <b> Selecting the next item: </b>
2476 * @dontinclude list_example_03.c
2477 * @skipline _select_next_cb
2480 * <b> Inserting after an item: </b>
2481 * @dontinclude list_example_03.c
2482 * @skipline _insert_after_cb
2485 * <b> Selecting the previous item: </b>
2486 * @dontinclude list_example_03.c
2487 * @skipline _select_prev_cb
2490 * <b> Inserting before an item: </b>
2491 * @dontinclude list_example_03.c
2492 * @skipline _insert_before_cb
2495 * If a separator is required, just set an item as such:
2496 * @dontinclude list_example_03.c
2497 * @skipline _set_separator_cb
2500 * Also an item can be disabled, and the user won't be allowed to (un)select it:
2501 * @dontinclude list_example_03.c
2502 * @skipline _disable_cb
2505 * See the full @ref list_example_03.c "list_example_03.c"
2506 * code, whose window should look like this picture:
2508 * @image html screenshots/list_example_03.png
2509 * @image latex screenshots/list_example_03.eps width=\textwidth
2511 * @example list_example_03.c
2515 * @page toolbar_example_01 Toolbar Example - Simple Items
2517 * This code places a Elementary toolbar widget on a window,
2518 * to exemplify part of the widget's API.
2520 * Let's start adding a button to our window, that will have its text
2521 * modified depending on which item is selected. It's used just to exemplify
2522 * how to change a window content from the toolbar.
2523 * @dontinclude toolbar_example_01.c
2524 * @skipline elm_button_add
2525 * @until evas_object_show
2527 * Also, we'll need a toolbar widget, obviously:
2528 * @skipline elm_toolbar_add
2529 * @until evas_object_show
2531 * When appending an item is possible to set an icon, label, and a callback
2532 * function that will receive passed data.
2533 * @skipline _item_append
2536 * It's possible to disable items, so the user can't select then. We will
2537 * disable the third item:
2538 * @skipline _item_append
2541 * Our callbacks will just set button's label:
2542 * @dontinclude toolbar_example_01.c
2550 * By default, toolbars would display items homogeneously, so item with
2551 * long labels, like the third, will make all of them occupy a lot of space.
2552 * To avoid that, we can disable it:
2553 * @dontinclude toolbar_example_01.c
2554 * @skipline homogeneous
2556 * Another default behavior, is to add an menu item if we have more items
2557 * that would fit on toolbar size. To simply enable scroll, without menus,
2558 * it's required to change toolbar's shrink mode:
2559 * @dontinclude toolbar_example_01.c
2562 * See @ref toolbar_example_01.c "toolbar_example_01.c", whose window should
2563 * look like this picture:
2565 * @image html screenshots/toolbar_example_01.png
2566 * @image latex screenshots/toolbar_example_01.eps width=\textwidth
2568 * @example toolbar_example_01.c
2572 * @page toolbar_example_02 Toolbar Example - Items with States
2574 * This code places a Elementary toolbar widget on a window,
2575 * to exemplify part of the widget's API.
2577 * Toolbar widgets has support to items with states. Each state
2578 * can have it's own label, icon, and callback function.
2580 * Let's start populating a toolbar with some regular items.
2581 * If you don't know how to do that, see
2582 * @ref toolbar_example_01 "Toolbar Example 1".
2583 * @dontinclude toolbar_example_02.c
2584 * @skipline elm_toolbar_add
2587 * The only difference here is that we set shrink mode to #ELM_SHRINK_MODE_HIDE,
2588 * that won't display items that doesn't fit to the window.
2590 * Now, let's add an item with states. First, add the item just as any other.
2591 * @skipline elm_toolbar_item_append
2592 * @until _item_pressed
2594 * After that states can be added to this item:
2595 * @skipline state_add
2597 * @until _item_pressed
2599 * The both states and the item are using the same callback function,
2600 * that will cycle between states and unselect the item. Unseleting
2601 * is required because it won't call the callback if an user clicks
2602 * over an item already selected:
2603 * @dontinclude toolbar_example_02.c
2609 * On our example, some items are hidden
2610 * because we set the window to be small. But if an item should be displayed
2611 * anyway, is needed to set its priority to be higher than others.
2612 * Any positive value will be enough in our case. Let's force the item
2613 * with multiple states to be displayed.
2614 * @skipline priority
2616 * See @ref toolbar_example_02.c "toolbar_example_02.c", whose window should
2617 * look like this picture:
2619 * @image html screenshots/toolbar_example_02.png
2620 * @image latex screenshots/toolbar_example_02.eps width=\textwidth
2622 * @example toolbar_example_02.c
2626 * @page toolbar_example_03 Toolbar Example - Items with Menus
2628 * Toolbar widgets have support to items with menus. This kind
2629 * of item will display a menu when selected by the user.
2631 * Let's start populating a toolbar with some regular items, the same
2632 * way we started @ref toolbar_example_02 "Toolbar Example 2".
2633 * @dontinclude toolbar_example_03.c
2634 * @skipline elm_toolbar_add
2637 * The only difference is that we'll keep the default shrink mode, that
2638 * adds an item with a menu of hidden items.
2640 * So, a important thing to do is to set a parent for toolbar menus, or they
2641 * will use the toolbar as parent, and its size will be restricted to that.
2642 * @skipline parent_set
2644 * Not only items' menus will respect this parent, but also the own toolbar
2645 * menu, used to show hidden items.
2647 * Next, let's add an item set to display a menu:
2648 * @skipline elm_toolbar_item_append
2651 * Now, to add two options to this item, we can get the menu object and use
2652 * it as a regular elm_menu. See @ref tutorial_menu "Menu example" for more
2653 * about menu widget.
2654 * @skipline _menu_get
2657 * See @ref toolbar_example_03.c "toolbar_example_03.c", whose window should
2658 * look like this picture:
2660 * @image html screenshots/toolbar_example_03.png
2661 * @image latex screenshots/toolbar_example_03.eps width=\textwidth
2663 * @example toolbar_example_03.c
2667 * @page segment_control_example Segment Control Example
2669 * This code places a Elementary segment control widgets on a window,
2670 * to exemplify part of the widget's API.
2672 * Let's start adding a segment control to our window:
2673 * @dontinclude segment_control_example.c
2674 * @skipline elm_segment_control_add
2675 * @until evas_object_show
2677 * Now will add an item only with label:
2678 * @skipline item_add
2680 * Really simple. To add an item with only an icon, the icon needs to be created
2681 * first, them added with this same function:
2682 * @skipline icon_add
2685 * If an item with label and icon is required, it can be done as well. In this
2686 * case, instead of a label (or icon) centered, the item will display an icon
2687 * at left and the label at right:
2688 * @skipline icon_add
2691 * But, if you need to add some items that can have or not a label, but
2692 * want that all of them looks the same way, with icon at left, just add
2693 * an empty string label. It's done on our example to ilustrate that:
2694 * @skipline icon_add
2697 * So far, all the item were added to the last position of the widget,
2698 * but if something different is required, it can be done using another
2699 * insertion function. Let's suppose we want to put an item just before
2704 * There are two ways to delete items. Using the item handle, like:
2705 * @skipline insert_at
2708 * Or using item's index:
2709 * @skipline insert_at
2712 * To set properties of an item already added to the widget, you just need
2713 * to get the item and set icon or label, as the following code shows:
2714 * @skipline item_get
2717 * Finally, it's possible to select an item from the code, and also get
2718 * the selected item. We will select the item at the center of the widget
2719 * and print its position.
2720 * @skipline count_get
2723 * See the full @ref segment_control_example.c "example", whose window should
2724 * look like this picture:
2726 * @image html screenshots/segment_control_example.png
2727 * @image latex screenshots/segment_control_example.eps width=\textwidth
2729 * @example segment_control_example.c
2733 * @page flipselector_example Flip selector widget example
2735 * This code places an Elementary flip selector widget on a window,
2736 * along with two buttons trigerring actions on it (though its API).
2738 * The selector is being populated with the following items:
2739 * @dontinclude flipselector_example.c
2743 * Next, we create it, populating it with those items and registering
2744 * two (smart) callbacks on it:
2745 * @dontinclude flipselector_example.c
2746 * @skip fp = elm_flipselector_add
2747 * @until object_show
2749 * Those two callbacks will take place whenever one of those smart
2750 * events occur, and they will just print something to @c stdout:
2751 * @dontinclude flipselector_example.c
2752 * @skip underflow callback
2753 * @until static void
2754 * Flip the sheets on the widget while looking at the items list, in
2755 * the source code, and you'll get the idea of those events.
2757 * The two buttons below the flip selector will take the actions
2758 * described in their labels:
2759 * @dontinclude flipselector_example.c
2760 * @skip bt = elm_button_add
2761 * @until callback_add(win
2763 * @dontinclude flipselector_example.c
2764 * @skip unselect the item
2767 * Click on them to exercise those flip selector API calls. To
2768 * interact with the other parts of this API, there's a command line
2769 * interface, whose help string can be asked for with the 'h' key:
2770 * @dontinclude flipselector_example.c
2774 * The 'n' and 'p' keys will exemplify elm_flipselector_flip_next()
2775 * and elm_flipselector_flip_prev(), respectively. 'f' and 'l' account
2776 * for elm_flipselector_first_item_get() and
2777 * elm_flipselector_last_item_get(), respectively. Finally, 's' will
2778 * issue elm_flipselector_selected_item_get() on our example flip
2781 * See the full @ref flipselector_example.c "example", whose window should
2782 * look like this picture:
2784 * @image html screenshots/flipselector_example.png
2785 * @image latex screenshots/flipselector_example.eps width=\textwidth
2787 * See the full @ref flipselector_example_c "source code" for this example.
2789 * @example flipselector_example.c
2793 * @page fileselector_example File selector widget example
2795 * This code places two Elementary file selector widgets on a window.
2796 * The one on the left is layouting file system items in a @b list,
2797 * while the the other is layouting them in a @b grid.
2799 * The one having the majority of hooks of interest is on the left,
2800 * which we create as follows:
2801 * @dontinclude fileselector_example.c
2802 * @skip first file selector
2803 * @until object_show
2805 * Note that we enable custom edition of file/directory selection, via
2806 * the text entry it has on its bottom, via
2807 * elm_fileselector_is_save_set(). It starts with the list view, which
2808 * is the default, and we make it not expandable in place
2809 * (elm_fileselector_expandable_set()), so that it replaces its view's
2810 * contents with the current directory's entries each time one
2811 * navigates to a different folder. For both of file selectors we are
2812 * starting to list the contents found in the @c "/tmp" directory
2813 * (elm_fileselector_path_set()).
2815 * Note the code setting it to "grid mode" and observe the differences
2816 * in the file selector's views, in the example. We also hide the
2817 * second file selector's Ok/Cancel buttons -- since it's there just
2818 * to show the grid view (and navigation) -- via
2819 * elm_fileselector_buttons_ok_cancel_set().
2821 * The @c "done" event, which triggers the callback below
2822 * @dontinclude fileselector_example.c
2825 * will be called at the time one clicks the "Ok"/"Cancel" buttons of
2826 * the file selector (on the left). Note that it will print the path
2827 * to the current selection, if any.
2829 * The @c "selected" event, which triggers the callback below
2830 * @dontinclude fileselector_example.c
2831 * @skip bt = 'selected' cb
2833 * takes place when one selects a file (if the file selector is @b not
2834 * under folders-only mode) or when one selects a folder (when in
2835 * folders-only mode). Experiment it by selecting different file
2838 * What comes next is the code creating the three check boxes and two
2839 * buttons below the file selector in the right. They will exercise a
2840 * bunch of functions on the file selector's API, for the instance on
2841 * the left. Experiment with them, specially the buttons, to get the
2842 * difference between elm_fileselector_path_get() and
2843 * elm_fileselector_selected_get().
2845 * Finally, there's the code adding the second file selector, on the
2847 * @dontinclude fileselector_example.c
2848 * @skip second file selector
2849 * @until object_show
2851 * Pay attention to the code setting it to "grid mode" and observe the
2852 * differences in the file selector's views, in the example. We also
2853 * hide the second file selector's Ok/Cancel buttons -- since it's
2854 * there just to show the grid view (and navigation) -- via
2855 * elm_fileselector_buttons_ok_cancel_set().
2857 * See the full @ref fileselector_example.c "example", whose window
2858 * should look like this picture:
2860 * @image html screenshots/fileselector_example.png
2861 * @image latex screenshots/fileselector_example.eps width=\textwidth
2863 * See the full @ref fileselector_example_c "source code" for this example.
2865 * @example fileselector_example.c
2869 * @page fileselector_button_example File selector button widget example
2871 * This code places an Elementary file selector button widget on a
2872 * window, along with some other checkboxes and a text entry. Those
2873 * are there just as knobs on the file selector button's state and to
2874 * display information from it.
2876 * Here's how we instantiate it:
2877 * @dontinclude fileselector_button_example.c
2878 * @skip ic = elm_icon_add
2879 * @until evas_object_show
2881 * Note that we set on it both icon and label decorations. It's set to
2882 * list the contents of the @c "/tmp" directory, too, with
2883 * elm_fileselector_button_path_set(). What follows are checkboxes to
2884 * exercise some of its API funtions:
2885 * @dontinclude fileselector_button_example.c
2886 * @skip ck = elm_check_add
2887 * @until evas_object_show(en)
2889 * The checkboxes will toggle whether the file selector button's
2890 * internal file selector:
2891 * - must have an editable text entry for file names (thus, be in
2892 * "save dialog mode")
2893 * - is to be raised as an "inner window" (note it's the default
2894 * behavior) or as a dedicated window
2895 * - is to populate its view with folders only
2896 * - is to expand its folders, in its view, <b>in place</b>, and not
2897 * repainting it entirely just with the contents of a sole
2900 * The entry labeled @c "Last selection" will exercise the @c
2901 * "file,chosen" smart event coming from the file selector button:
2902 * @dontinclude fileselector_button_example.c
2904 * @until toggle inwin
2906 * Whenever you dismiss or acknowledges the file selector, after it's
2907 * raised, the @c event_info string will contain the last selection on
2908 * it (if any was made).
2910 * This is how the example, just after called, should look like:
2912 * @image html screenshots/fileselector_button_example_00.png
2913 * @image latex screenshots/fileselector_button_example_00.eps width=\textwidth
2915 * Click on the file selector button to raise its internal file
2916 * selector, which will be contained on an <b>"inner window"</b>:
2918 * @image html screenshots/fileselector_button_example_01.png
2919 * @image latex screenshots/fileselector_button_example_01.eps width=\textwidth
2921 * Toggle the "inwin mode" switch off and, if you click on the file
2922 * selector button again, you'll get @b two windows, the original one
2923 * (note the last selection there!)
2925 * @image html screenshots/fileselector_button_example_02.png
2926 * @image latex screenshots/fileselector_button_example_02.eps width=\textwidth
2928 * and the file selector's new one
2930 * @image html screenshots/fileselector_button_example_03.png
2931 * @image latex screenshots/fileselector_button_example_03.eps width=\textwidth
2933 * Play with the checkboxes to get the behavior changes on the file
2934 * selector button. The respective API calls on the widget coming from
2935 * those knobs where shown in the code already.
2937 * See the full @ref fileselector_button_example_c "source code" for
2940 * @example fileselector_button_example.c
2944 * @page fileselector_entry_example File selector entry widget example
2946 * This code places an Elementary file selector entry widget on a
2947 * window, along with some other checkboxes. Those are there just as
2948 * knobs on the file selector entry's state.
2950 * Here's how we instantiate it:
2951 * @dontinclude fileselector_entry_example.c
2952 * @skip ic = elm_icon_add
2953 * @until evas_object_show
2955 * Note that we set on it's button both icon and label
2956 * decorations. It's set to exhibit the path of (and list the contents
2957 * of, when internal file selector is launched) the @c "/tmp"
2958 * directory, also, with elm_fileselector_entry_path_set(). What
2959 * follows are checkboxes to exercise some of its API funtions:
2960 * @dontinclude fileselector_entry_example.c
2961 * @skip ck = elm_check_add
2962 * @until callback_add(fs_entry
2964 * The checkboxes will toggle whether the file selector entry's
2965 * internal file selector:
2966 * - must have an editable text entry for file names (thus, be in
2967 * "save dialog mode")
2968 * - is to be raised as an "inner window" (note it's the default
2969 * behavior) or as a dedicated window
2970 * - is to populate its view with folders only
2971 * - is to expand its folders, in its view, <b>in place</b>, and not
2972 * repainting it entirely just with the contents of a sole
2975 * Observe how the entry's text will match the string coming from the
2976 * @c "file,chosen" smart event:
2977 * @dontinclude fileselector_entry_example.c
2980 * Whenever you dismiss or acknowledges the file selector, after it's
2981 * raised, the @c event_info string will contain the last selection on
2982 * it (if any was made).
2984 * Try, also, to type in a valid system path and, then, open the file
2985 * selector's window: it will start the file browsing there, for you.
2987 * This is how the example, just after called, should look like:
2989 * @image html screenshots/fileselector_entry_example_00.png
2990 * @image latex screenshots/fileselector_entry_example_00.eps width=\textwidth
2992 * Click on the file selector entry to raise its internal file
2993 * selector, which will be contained on an <b>"inner window"</b>:
2995 * @image html screenshots/fileselector_entry_example_01.png
2996 * @image latex screenshots/fileselector_entry_example_01.eps width=\textwidth
2998 * Toggle the "inwin mode" switch off and, if you click on the file
2999 * selector entry again, you'll get @b two windows, the original one
3000 * (note the last selection there!)
3002 * @image html screenshots/fileselector_entry_example_02.png
3003 * @image latex screenshots/fileselector_entry_example_02.eps width=\textwidth
3005 * and the file selector's new one
3007 * @image html screenshots/fileselector_entry_example_03.png
3008 * @image latex screenshots/fileselector_entry_example_03.eps width=\textwidth
3010 * Play with the checkboxes to get the behavior changes on the file
3011 * selector entry. The respective API calls on the widget coming from
3012 * those knobs where shown in the code already.
3014 * See the full @ref fileselector_entry_example_c "source code" for
3017 * @example fileselector_entry_example.c
3021 * @page layout_example_01 Layout - Content, Table and Box
3023 * This example shows how one can use the @ref Layout widget to create a
3024 * customized distribution of widgets on the screen, controled by an Edje theme.
3025 * The full source code for this example can be found at @ref
3026 * layout_example_01_c.
3028 * Our custom layout is defined by a file, @ref layout_example_edc, which is an
3029 * Edje theme file. Look for the Edje documentation to understand it. For now,
3030 * it's enough to know that we describe some specific parts on this layout
3032 * @li a title text field;
3033 * @li a box container;
3034 * @li a table container;
3035 * @li and a content container.
3037 * Going straight to the code, the following snippet instantiates the layout
3040 * @dontinclude layout_example_01.c
3041 * @skip elm_layout_add
3042 * @until evas_object_show(layout)
3044 * As any other widget, we set some properties for the size calculation. But
3045 * notice on this piece of code the call to the function elm_layout_file_set().
3046 * Here is where the theme file is loaded, and particularly the specific group
3047 * from this theme file. Also notice that the theme file here is referenced as
3048 * an .edj, which is a .edc theme file compiled to its binary form. Again, look
3049 * for the Edje documentation for more information about theme files.
3051 * Next, we fetch from our theme a data string referenced by the key "title".
3052 * This data was defined in the theme, and can be used as parameters which the
3053 * program get from the specific theme that it is using. In this case, we store
3054 * the title of this window and program in the theme, as a "data" entry, just
3055 * for demonstration purposes:
3059 * This call elm_layout_data_get() is used to fetch the string based on the key,
3060 * and elm_object_text_part_set() will set the part defined in the theme as
3061 * "example/title" to contain this string. This key "example/title" has nothing
3062 * special. It's just an arbitrary convention that we are using in this example.
3063 * Every string in this example referencing a part of this theme will be of the
3064 * form "example/<something>".
3066 * Now let's start using our layout to distribute things on the window space.
3067 * Since the layout was added as a resize object to the elementary window, it
3068 * will always occupy the entire space available for this window.
3070 * The theme already has a title, and it also defines a table element which is
3071 * positioned approximately between 50% and 70% of the height of this window,
3072 * and has 100% of the width. We create some widgets (two icons, a clock and a
3073 * button) and pack them inside the table, in a distribution similar to a HTML
3076 * @until evas_object_show(bt)
3078 * Notice that we just set size hints for every object, and call the function
3079 * elm_layout_table_pack(), which does all the work. It will place the elements
3080 * in the specified row/column, with row and column span if required, and then
3081 * the object's size and position will be controled by the layout widget. It
3082 * will also respect size hints, alignments and weight properties set to these
3083 * widgets. The resulting distribution on the screen depends on the table
3084 * properties (described in the theme), the size hints set on each widget, and
3085 * on the cells of the table that are being used.
3087 * For instance, we add the two icons and the clock on the first, second and
3088 * third cells of the first row, and add the button the second row, making it
3089 * span for 3 columns (thus having the size of the entire table width). This
3090 * will result in a table that has 2 rows and 3 columns.
3092 * Now let's add some widgets to the box area of our layout. This box is around
3093 * 20% and 50% of the vertical size of the layout, and 100% of its width. The
3094 * theme defines that it will use an "horizontal flow" distribution to its
3095 * elements. Unlike the table, a box will distribute elements without knowing
3096 * about rows and columns, and the distribution function selected will take care
3097 * of putting them in row, column, both, or any other available layout. This is
3098 * also described in the Edje documentation.
3100 * This box area is similar to the @ref Box widget of elementary, with the
3101 * difference that its position and properties are controled by the theme of the
3102 * layout. It also contains more than one API to add items to it, since the
3103 * items position now is defined in terms of a list of items, not a matrix.
3104 * There's the first position (can have items added to it with
3105 * elm_layout_box_prepend()), the last position (elm_layout_box_append()), the
3106 * nth position (elm_layout_box_insert_at()) and the position right before an
3107 * element (elm_layout_box_insert_before()). We use insert_at and prepend
3108 * functions to add the first two buttons to this box, and insert_before on the
3109 * callback of each button. The callback code will be shown later, but it
3110 * basically adds a button just before the clicked button using the
3111 * elm_layout_box_insert_before() function. Here's the code for adding the first
3114 * @until evas_object_show(item)
3115 * @until evas_object_show(item)
3117 * Finally, we have an area in this layout theme, in the bottom part of it,
3118 * reserved for adding an specific widget. Differently from the 2 parts
3119 * described until now, this one can only receive one widget with the call
3120 * elm_layout_content_set(). If there was already an item on this specific part,
3121 * it will be deleted (one can use elm_layout_content_unset() in order to remove
3122 * it without deleting). An example of removing it without deleting, but
3123 * manually deleting this widget just after that, can be seen on the callback
3124 * for this button. Actually, the callback defined for this button will clean
3125 * the two other parts (deleting all of their elements) and then remove and
3126 * delete this button.
3128 * @until _swallow_btn_cb
3130 * Also notice that, for this last added button, we don't have to call
3131 * evas_object_show() on it. This is a particularity of the theme for layouts,
3132 * that will have total control over the properties like size, position,
3133 * visibility and clipping of a widget added with elm_layout_content_set().
3134 * Again, read the Edje documentation to understand this better.
3136 * Now we just put the code for the different callbacks specified for each kind
3137 * of button and make simple comments about them:
3139 * @dontinclude layout_example_01.c
3141 * @until evas_object_del(item)
3144 * The first callback is used for the button in the table, and will just remove
3145 * itself from the table with elm_layout_table_unpack(), which remove items
3146 * without deleting them, and then calling evas_object_del() on itself.
3148 * The second callback is for buttons added to the box. When clicked, these
3149 * buttons will create a new button, and add them to the same box, in the
3150 * position just before the clicked button.
3152 * And the last callback is for the button added to the "content" area. It will
3153 * clear both the table and the box, passing @c EINA_TRUE to their respective @c
3154 * clear parameters, which will imply on the items of these containers being
3157 * A screenshot of this example can be seen on:
3159 * @image html screenshots/layout_example_01.png
3160 * @image latex screenshots/layout_example_01.eps width=\textwidth
3165 * @page layout_example_02 Layout - Predefined Layout
3167 * This example shows how one can use the @ref Layout with a predefined theme
3168 * layout to add a back and next button to a simple window. The full source code
3169 * for this example can be found at @ref layout_example_02_c.
3171 * After setting up the window and background, we add the layout widget to the
3172 * window. But instead of using elm_layout_file_set() to load its theme from a
3173 * custom theme file, we can use elm_layout_theme_set() to load one of the
3174 * predefined layouts that come with elementary. Particularly on this example,
3175 * we load the them of class "layout", group "application" and style
3176 * "content-back-next" (since we want the back and next buttons).
3178 * @dontinclude layout_example_02.c
3179 * @skip elm_layout_add
3180 * @until evas_object_show(layout)
3182 * This default theme contains only a "content" area named
3183 * "elm.swallow.content", where we can add any widget (it can be even a
3184 * container widget, like a box, frame, list, or even another layout). Since we
3185 * just want to show the resulting layout, we add a simple icon to it:
3187 * @until layout_content_set
3189 * This default layout also provides some signals when the next and prev buttons
3190 * are clicked. We can register callbacks to them with the
3191 * elm_object_signal_callback_add() function:
3193 * @until elm,action,next
3195 * In the @ref layout_example_03 you can see how to send signals to the layout with
3196 * elm_object_signal_emit().
3198 * Now our callback just changes the picture being displayed when one of the
3199 * buttons are clicked:
3201 * @dontinclude layout_example_02.c
3203 * @until standard_set
3206 * It's possible to see that it gets the name of the image being shown from the
3207 * array of image names, going forward on this array when "next" is clicked and
3208 * backward when "back" is clicked.
3210 * A screenshot of this example can be seen on:
3212 * @image html screenshots/layout_example_02.png
3213 * @image latex screenshots/layout_example_02.eps width=\textwidth
3217 * @page layout_example_03 Layout - Signals and Size Changed
3219 * This example shows how one can send and receive signals to/from the layout,
3220 * and what to do when the layout theme has its size changed. The full source
3221 * code for this example can be found at @ref layout_example_03_c.
3223 * In this exmaple we will use another group from the same layout theme file
3224 * used in @ref layout_example_01. Its instanciation and loading happens in the
3227 * @dontinclude layout_example_03.c
3228 * @skip elm_layout_add
3229 * @until evas_object_show
3231 * This time we register a callback to be called whenever we receive a signal
3232 * after the end of the animation that happens in this layout:
3234 * @until signal_callback_add
3236 * We also add a button that will send signals to the layout:
3238 * @until callback_add
3240 * The callback for this button will check what type of signal it should send,
3241 * and then emit it. The code for this callback follows:
3243 * @dontinclude layout_example_03.c
3244 * @skip static Eina_Bool
3249 * As we said before, we are receiving a signal whenever the animation started
3250 * by the button click ends. This is the callback for that signal:
3254 * Notice from this callback that the elm_layout_sizing_eval() function must be
3255 * called if we want our widget to update its size after the layout theme having
3256 * changed its minimum size. This happens because the animation specified in the
3257 * theme increases the size of the content area to a value higher than the
3258 * widget size, thus requiring more space. But the elementary layout widget
3259 * has no way to know this, thus needing the elm_layout_sizing_eval() to
3260 * be called on the layout, informing that this size has changed.
3262 * A screenshot of this example can be seen on:
3264 * @image html screenshots/layout_example_03.png
3265 * @image latex screenshots/layout_example_03.eps width=\textwidth
3269 * @page tutorial_hover Hover example
3270 * @dontinclude hover_example_01.c
3272 * On this example we are going to have a button that when clicked will show our
3273 * hover widget, this hover will have content set on it's left, top, right and
3274 * middle positions. In the middle position we are placing a button that when
3275 * clicked will hide the hover. We are also going to use a non-default theme
3276 * for our hover. We won't explain the functioning of button for that see @ref
3279 * We start our example with a couple of callbacks that show and hide the data
3280 * they're given(which we'll see later on is the hover widget):
3285 * In our main function we'll do some initialization and then create 3
3286 * rectangles, one red, one green and one blue to use in our hover. We'll also
3287 * create the 2 buttons that will show and hide the hover:
3290 * With all of that squared away we can now get to the heart of the matter,
3291 * creating our hover widget, which is easy as pie:
3294 * Having created our hover we now need to set the parent and target. Which if
3295 * you recall from the function documentations are going to tell the hover which
3296 * area it should cover and where it should be centered:
3299 * Now we set the theme for our hover. We're using the popout theme which gives
3300 * our contents a white background and causes their appearance to be animated:
3303 * And finally we set the content for our positions:
3306 * So far so good? Great 'cause that's all there is too it, what is left now is
3307 * just connecting our buttons to the callbacks we defined at the beginning of
3308 * the example and run the main loop:
3311 * Our example will initially look like this:
3313 * @image html screenshots/hover_example_01.png
3314 * @image latex screenshots/hover_example_01.eps width=\textwidth
3316 * And after you click the "Show hover" button it will look like this:
3318 * @image html screenshots/hover_example_01_a.png
3319 * @image latex screenshots/hover_example_01_a.eps width=\textwidth
3321 * @example hover_example_01.c
3325 * @page tutorial_flip Flip example
3326 * @dontinclude flip_example_01.c
3328 * This example will show a flip with two rectangles on it(one blue, one
3329 * green). Our example will allow the user to choose the animation the flip
3330 * uses and to interact with it. To allow the user to choose the interaction
3331 * mode we use radio buttons, we will however not explain them, if you would
3332 * like to know more about radio buttons see @ref Radio.
3334 * We start our example with the usual setup and then create the 2 rectangles
3335 * we will use in our flip:
3336 * @until show(rect2)
3338 * The next thing to do is to create our flip and set it's front and back
3342 * The next thing we do is set the interaction mode(which the user can later
3343 * change) to the page animation:
3346 * Setting a interaction mode however is not sufficient, we also need to
3347 * choose which directions we allow interaction from, for this example we
3348 * will use all of them:
3351 * We are also going to set the hitsize to the entire flip(in all directions)
3352 * to make our flip very easy to interact with:
3355 * After that we create our radio buttons and start the main loop:
3358 * When the user clicks a radio button a function that changes the
3359 * interaction mode and animates the flip is called:
3361 * @note The elm_flip_go() call here serves no purpose other than to
3362 * ilustrate that it's possible to animate the flip programmatically.
3364 * Our example will look like this:
3366 * @image html screenshots/flip_example_01.png
3367 * @image latex screenshots/flip_example_01.eps width=\textwidth
3369 * @note Since this is an animated example the screenshot doesn't do it
3370 * justice, it is a good idea to compile it and see the animations.
3372 * @example flip_example_01.c
3376 * @page tutorial_label Label example
3377 * @dontinclude label_example_01.c
3379 * In this example we are going to create 6 labels, set some properties on
3380 * them and see what changes in appearance those properties cause.
3382 * We start with the setup code that by now you should be familiar with:
3385 * For our first label we have a moderately long text(that doesn't fit in the
3386 * label's width) so we will make it a sliding label. Since the text isn't
3387 * too long we don't need the animation to be very long, 3 seconds should
3388 * give us a nice speed:
3391 * For our second label we have the same text, but this time we aren't going
3392 * to have it slide, we're going to ellipsize it. Because we ask our label
3393 * widget to ellipsize the text it will first diminsh the fontsize so that it
3394 * can show as much of the text as possible:
3397 * For the third label we are going to ellipsize the text again, however this
3398 * time to make sure the fontsize isn't diminshed we will set a line wrap.
3399 * The wrap won't actually cause a line break because we set the label to
3403 * For our fourth label we will set line wrapping but won't set ellipsis, so
3404 * that our text will indeed be wrapped instead of ellipsized. For this label
3405 * we choose character wrap:
3408 * Just two more, for our fifth label we do the same as for the fourth
3409 * except we set the wrap to word:
3412 * And last but not least for our sixth label we set the style to "marker" and
3413 * the color to red(the default color is white which would be hard to see on
3414 * our white background):
3417 * Our example will look like this:
3419 * @image html screenshots/label_example_01.png
3420 * @image latex screenshots/label_example_01.eps width=\textwidth
3422 * @example label_example_01.c
3426 * @page tutorial_image Image example
3427 * @dontinclude image_example_01.c
3429 * This example is as simple as possible. An image object will be added to the
3430 * window over a white background, and set to be resizeable together with the
3431 * window. All the options set through the example will affect the behavior of
3434 * We start with the code for creating a window and its background, and also
3435 * add the code to write the path to the image that will be loaded:
3440 * Now we create the image object, and set that file to be loaded:
3444 * We can now go setting our options.
3446 * elm_image_no_scale_set() is used just to set this value to true (we
3447 * don't want to scale our image anyway, just resize it).
3449 * elm_image_scale_set() is used to allow the image to be resized to a size
3450 * smaller than the original one, but not to a size bigger than it.
3452 * elm_elm_image_smooth_set() will disable the smooth scaling, so the scale
3453 * algorithm used to scale the image to the new object size is going to be
3454 * faster, but with a lower quality.
3456 * elm_image_orient_set() is used to flip the image around the (1, 0) (0, 1)
3459 * elm_image_aspect_ratio_retained_set() is used to keep the original aspect
3460 * ratio of the image, even when the window is resized to another aspect ratio.
3462 * elm_image_fill_outside_set() is used to ensure that the image will fill the
3463 * entire area available to it, even if keeping the aspect ratio. The image
3464 * will overflow its width or height (any of them that is necessary) to the
3465 * object area, instead of resizing the image down until it can fit entirely in
3468 * elm_image_editable_set() is used just to cover the API, but won't affect
3469 * this example since we are not using any copy & paste property.
3471 * This is the code for setting these options:
3475 * Now some last touches in our object size hints, window and background, to
3476 * display this image properly:
3480 * This example will look like this:
3482 * @image html screenshots/image_example_01.png
3483 * @image latex screenshots/image_example_01.eps width=\textwidth
3485 * @example image_example_01.c
3489 * @page tutorial_icon Icon example
3490 * @dontinclude icon_example_01.c
3492 * This example is as simple as possible. An icon object will be added to the
3493 * window over a white background, and set to be resizeable together with the
3494 * window. All the options set through the example will affect the behavior of
3497 * We start with the code for creating a window and its background:
3502 * Now we create the icon object, and set lookup order of the icon, and choose
3507 * An intersting thing is that after setting this, it's possible to check where
3508 * in the filesystem is the theme used by this icon, and the name of the group
3513 * We can now go setting our options.
3515 * elm_icon_no_scale_set() is used just to set this value to true (we
3516 * don't want to scale our icon anyway, just resize it).
3518 * elm_icon_scale_set() is used to allow the icon to be resized to a size
3519 * smaller than the original one, but not to a size bigger than it.
3521 * elm_elm_icon_smooth_set() will disable the smooth scaling, so the scale
3522 * algorithm used to scale the icon to the new object size is going to be
3523 * faster, but with a lower quality.
3525 * elm_icon_fill_outside_set() is used to ensure that the icon will fill the
3526 * entire area available to it, even if keeping the aspect ratio. The icon
3527 * will overflow its width or height (any of them that is necessary) to the
3528 * object area, instead of resizing the icon down until it can fit entirely in
3531 * This is the code for setting these options:
3533 * @until fill_outside
3535 * However, if you try this example you may notice that this image is not being
3536 * affected by all of these options. This happens because the used icon will be
3537 * from elementary theme, and thus it has its own set of options like smooth
3538 * scaling and fill_outside options. You can change the "home" icon to use some
3539 * image (from your system) and see that then those options will be respected.
3541 * Now some last touches in our object size hints, window and background, to
3542 * display this icon properly:
3546 * This example will look like this:
3548 * @image html screenshots/icon_example_01.png
3549 * @image latex screenshots/icon_example_01.eps width=\textwidth
3551 * @example icon_example_01.c
3555 * @page tutorial_hoversel Hoversel example
3556 * @dontinclude hoversel_example_01.c
3558 * In this example we will create a hoversel with 3 items, one with a label but
3559 * no icon and two with both a label and an icon. Every item that is clicked
3560 * will be deleted, but everytime the hoversel is activated we will also add an
3561 * item. In addition our first item will print all items when clicked and our
3562 * third item will clear all items in the hoversel.
3564 * We will start with the normal creation of window stuff:
3567 * Next we will create a red rectangle to use as the icon of our hoversel:
3570 * And now we create our hoversel and set some of it's properties. We set @p win
3571 * as its parent, ask it to not be horizontal(be vertical) and give it a label
3575 * Next we will add our three items, setting a callback to be called for the
3579 * We also set a pair of callbacks to be called whenever any item is selected or
3580 * when the hoversel is activated:
3583 * And then ask that our hoversel be shown and run the main loop:
3586 * We now have the callback for our first item which prints all items in the
3590 * Next we have the callback for our third item which removes all items from the
3594 * Next we have the callback that is called whenever an item is clicked and
3595 * deletes that item:
3598 * And the callback that is called when the hoversel is activated and adds an
3599 * item to the hoversel. Note that since we allocate memory for the item we need
3600 * to know when the item dies so we can free that memory:
3603 * And finally the callback that frees the memory we allocated for items created
3604 * in the @p _add_item callback:
3607 * Our example will initially look like this:
3609 * @image html screenshots/hoversel_example_01.png
3610 * @image latex screenshots/hoversel_example_01.eps width=\textwidth
3612 * And when the hoversel is clicked it will look like this:
3614 * @image html screenshots/hoversel_example_01_a.png
3615 * @image latex screenshots/hoversel_example_01_a.eps width=\textwidth
3617 * @example hoversel_example_01.c
3621 * @page conformant_example Conformant Example.
3623 * In this example we'll explain how to create applications to work
3624 * with illume, considering space required for virtual keyboards, indicator
3627 * Illume is a module for Enlightenment that modifies the user interface
3628 * to work cleanly and nicely on a mobile device. It has support for
3629 * virtual keyboard, among other nice features.
3631 * Let's start creating a very simple window with a vertical box
3632 * with multi-line entry between two buttons.
3633 * This entry will expand filling all space on window not used by buttons.
3635 * @dontinclude conformant_example_01.c
3636 * @skipline elm_main
3639 * For information about how to create windows, boxes, buttons or entries,
3640 * look for documentation for these widgets.
3642 * It will looks fine when you don't need a virtual keyboard, as you
3643 * can see on the following image:
3645 * @image html screenshots/conformant_example_01.png
3646 * @image latex screenshots/conformant_example_01.eps width=\textwidth
3648 * But if you call a virtual keyboard, the window will resize, changing
3649 * widgets size and position. All the content will shrink.
3651 * If you don't want such behaviour, you
3652 * will need a conformant to account for space taken up by the indicator,
3653 * virtual keyboard and softkey.
3655 * In this case, using the conformant in a proper way, you will have
3656 * a window like the following:
3658 * @image html screenshots/conformant_example_02.png
3659 * @image latex screenshots/conformant_example_02.eps width=\textwidth
3661 * As you can see, it guess the space that will be required by the keyboard,
3662 * indicator and softkey bars.
3664 * So, let's study each step required to transform our initial example on
3667 * First of all, we need to set the window as an illume conformant window:
3668 * @dontinclude conformant_example_02.c
3669 * @skipline elm_win_conformant_set
3671 * Next, we'll add a conformant widget, and set it to resize with the window,
3672 * instead of the box.
3674 * @until evas_object_show
3676 * Finally, we'll set the box as conformant's content, just like this:
3677 * @skipline elm_conformant_content_set
3679 * Compare both examples code:
3680 * @ref conformant_example_01.c "conformant_example_01.c"
3681 * @ref conformant_example_02.c "conformant_example_02.c"
3683 * @example conformant_example_01.c
3684 * @example conformant_example_02.c
3688 * @page index_example_01 Index widget example 1
3690 * This code places an Elementary index widget on a window, which also
3691 * has a very long list of arbitrary strings on it. The list is
3692 * sorted alphabetically and the index will be used to index the first
3693 * items of each set of strings beginning with an alphabet letter.
3695 * Below the list are some buttons, which are there just to exercise
3696 * some index widget's API.
3698 * Here's how we instantiate it:
3699 * @dontinclude index_example_01.c
3700 * @skip elm_list_add
3701 * @until evas_object_show(d.index)
3702 * where we're showing also the list being created. Note that we issue
3703 * elm_win_resize_object_add() on the index, so that it's set to have
3704 * the whole window as its container. Then, we have to populate both
3705 * list and index widgets:
3706 * @dontinclude index_example_01.c
3707 * @skip for (i = 0; i < (sizeof(dict) / sizeof(dict[0])); i++)
3711 * The strings populating the list come from a file
3712 * @dontinclude index_example_01.c
3713 * @skip static const char *dict
3716 * We use the @c curr char variable to hold the last initial letter
3717 * seen on that ordered list of strings, so that we're able to have an
3718 * index item pointing to each list item starting a new letter
3719 * "section". Note that our index item data pointers will be the list
3720 * item handles. We are also setting a callback function to index
3721 * items deletion events:
3722 * @dontinclude index_example_01.c
3726 * There, we show you that the @c event_info pointer will contain the
3727 * item in question's data, i.e., a given list item's pointer. Because
3728 * item data is also returned in the @c data argument on
3729 * @c Evas_Smart_Cb functions, those two pointers must have the same
3730 * values. On this deletion callback, we're deleting the referred list
3731 * item too, just to exemplify that anything could be done there.
3733 * Next, we hook to two smart events of the index object:
3734 * @dontinclude index_example_01.c
3735 * @skip smart_callback_add(d.index
3736 * @until _index_selected
3737 * @dontinclude index_example_01.c
3738 * @skip "delay,changed" hook
3742 * Check that, whenever one holds the mouse pressed over a given index
3743 * letter for some time, the list beneath it will roll down to the
3744 * item pointed to by that index item. When one releases the mouse
3745 * button, the second callback takes place. There, we check that the
3746 * reported item data, on @c event_info, is the same reported by
3747 * elm_index_item_selected_get(), which gives the last selection's
3748 * data on the index widget.
3750 * The first of the three buttons that follow will call
3751 * elm_index_active_set(), thus showing the index automatically for
3752 * you, if it's not already visible, what is checked with
3753 * elm_index_active_get(). The second button will exercise @b deletion
3754 * of index item objects, by the following code:
3755 * @dontinclude index_example_01.c
3756 * @skip delete an index item
3759 * It will get the last index item selected's data and find the
3760 * respective #Elm_Index_Item handle with elm_index_item_find(). We
3761 * need the latter to query the indexing letter string from, with
3762 * elm_index_item_letter_get(). Next, comes the delition, itself,
3763 * which will also trigger the @c _index_item_del callback function,
3766 * The third button, finally, will exercise elm_index_item_clear(),
3767 * which will delete @b all of the index's items.
3769 * This is how the example program's window looks like with the index
3771 * @image html screenshots/index_example_00.png
3772 * @image latex screenshots/index_example_00.eps
3774 * When it's shown, it's like the following figure:
3775 * @image html screenshots/index_example_01.png
3776 * @image latex screenshots/index_example_01.eps
3778 * See the full @ref index_example_01_c "source code" for
3781 * @example index_example_01.c
3785 * @page index_example_02 Index widget example 2
3787 * This code places an Elementary index widget on a window, indexing
3788 * grid items. The items are placed so that their labels @b don't
3789 * follow any order, but the index itself is ordered (through
3790 * elm_index_item_sorted_insert()). This is a complement to to @ref
3791 * index_example_01 "the first example on indexes".
3793 * Here's the list of item labels to be used on the grid (in that
3795 * @dontinclude index_example_02.c
3796 * @skip static const char *items
3799 * In the interesting part of the code, here, we first instantiate the
3800 * grid (more on grids on their examples) and, after creating our
3801 * index, for each grid item we also create an index one to reference
3803 * @dontinclude index_example_02.c
3804 * @skip grid = elm_gengrid_add
3806 * @until smart_callback_add
3808 * The order in which they'll appear in the index, though, is @b
3809 * alphabetical, becase of elm_index_item_sorted_insert() usage
3810 * together with the comparing function, where we take the letters of
3811 * each index item to base our ordering on. The parameters on
3812 * @c _index_cmp have to be declared as void pointers because of the
3813 * @c Eina_Compare_Cb prototype requisition, but in this case we know
3814 * they'll be #Elm_Index_Item's:
3815 * @dontinclude index_example_02.c
3816 * @skip ordering alphabetically
3819 * The last interesting bit is the callback in the @c "delay,changed"
3820 * smart event, which will bring the given grid item to the grid's
3822 * @dontinclude index_example_02.c
3826 * Note how the grid will move kind of randomly while you move your
3827 * mouse pointer held over the index from top to bottom -- that's
3828 * because of the the random order the items have in the grid itself.
3830 * This is how the example program's window looks like:
3831 * @image html screenshots/index_example_03.png
3832 * @image latex screenshots/index_example_03.eps
3834 * See the full @ref index_example.c "source code" for
3837 * @example index_example_02.c
3841 * @page tutorial_ctxpopup Ctxpopup example
3842 * @dontinclude ctxpopup_example_01.c
3844 * In this example we have a list with two items, when either item is clicked
3845 * a ctxpopup for it will be shown. Our two ctxpopups are quite different, the
3846 * one for the first item is a vertical and it's items contain both labels and
3847 * icons, the one for the second item is horizontal and it's items have icons
3850 * We will begin examining our example code by looking at the callback we'll use
3851 * when items in the ctxpopup are clicked. It's very simple, all it does is
3852 * print the label present in the ctxpopup item:
3855 * Next we examine a function that creates ctxpopup items, it was created to
3856 * avoid repeating the same code whenever we needed to add an item to our
3857 * ctxpopup. Our function creates an icon from the standard set of icons, and
3858 * then creates the item, with the label received as an argument. We also set
3859 * the callback to be called when the item is clicked:
3862 * Finally we have the function that will create the ctxpopup for the first item
3863 * in our list. This one is somewhat more complex though, so let's go through it
3864 * in parts. First we declare our variable and add the ctxpopup:
3865 * @until ctxpopup_add
3867 * Next we create a bunch of items for our ctxpopup, marking two of them as
3868 * disabled just so we can see what that will look like:
3869 * @until disabled_set
3870 * @until disabled_set
3872 * Then we ask evas where the mouse pointer was so that we can have our ctxpopup
3873 * appear in the right place, set a maximum size for the ctxpopup, move it and
3877 * And last we mark the list item as not selected:
3880 * Our next function is the callback that will create the ctxpopup for the
3881 * second list item, it is very similar to the previous function. A couple of
3882 * interesting things to note is that we ask our ctxpopup to be horizontal, and
3883 * that we pass NULL as the label for every item:
3886 * And with all of that in place we can now get to our main function where we
3887 * create the window, the list, the list items and run the main loop:
3890 * The example will initially look like this:
3892 * @image html screenshots/ctxpopup_example_01.png
3893 * @image latex screenshots/ctxpopup_example_01.eps width=\textwidth
3895 * @note This doesn't show the ctxpopup tough, since it will only appear when
3896 * we click one of the list items.
3898 * Here is what our first ctxpopup will look like:
3900 * @image html screenshots/ctxpopup_example_01_a.png
3901 * @image latex screenshots/ctxpopup_example_01_a.eps width=\textwidth
3903 * And here the second ctxpopup:
3905 * @image html screenshots/ctxpopup_example_01_b.png
3906 * @image latex screenshots/ctxpopup_example_01_b.eps width=\textwidth
3908 * @example ctxpopup_example_01.c
3912 * @page tutorial_pager
3913 * @dontinclude pager_example_01.c
3915 * In this example we'll have a pager with 3 rectangles on it, one blue, one
3916 * green and one blue, we'll also have 1 button for each rectangle. Pressing a
3917 * button will bring the associated rectangle to the front of the pager(promote
3920 * We start our example with some run of the mill code that you've seen in other
3924 * And then we get right to creating our pager, setting a style and some basic
3928 * Well a pager without any content is not of much use, so let's create the
3929 * first of our rectangles, add it to the pager and create the button for it:
3930 * @until smart_callback
3931 * @note The only line of above code that directly relates to our pager is the
3932 * call to elm_pager_content_push().
3934 * And now we will do the same thing again twice for our next two rectangles:
3935 * @until smart_callback
3936 * @until smart_callback
3938 * Now that we haver our widgets create we can get to running the main loop:
3941 * We also have the callback that is called when any of the buttons is pressed,
3942 * this callback is receiving the rectangle in it's @p data argument, so we
3943 * check if it's already on top and if not move it there:
3946 * Our example will look like this:
3948 * @image html screenshots/pager_example_01.png
3949 * @image latex screenshots/pager_example_01.eps width=\textwidth
3950 * @note Like all examples that involve animations the screenshot doesn't do it
3951 * justice, seeing it in action is a must.
3953 * @example pager_example_01.c
3957 * @page tutorial_separator Separator example
3958 * @dontinclude separator_example_01.c
3960 * In this example we are going to pack two rectangles in a box, and have a
3961 * separator in the middle.
3963 * So we start we the window, background, box and rectangle creation, all pretty
3967 * Once we have our first rectangle in the box we create and add our separator:
3969 * @note Since our box is in horizontal mode it's a good idea to set the
3970 * separator to be horizontal too.
3972 * And now we add our second rectangle and run the main loop:
3975 * This example will look like this:
3977 * @image html screenshots/separator_example_01.png
3978 * @image latex screenshots/separator_example_01.eps width=\textwidth
3980 * @example separator_example_01.c
3984 * @page tutorial_radio Radio example
3985 * @dontinclude radio_example_01.c
3987 * In this example we will create 4 radio buttons, three of them in a group and
3988 * another one not in the group. We will also have the radios in the group
3989 * change the value of a variable directly and have then print it when the value
3990 * changes. The fourth button is in the example just to make clear that radios
3991 * outside the group don't affect the group.
3993 * We'll start with the usual includes:
3996 * And move right to declaring a static variable(the one whose value the radios
4000 * We now need to have a window and all that good stuff to be able to place our
4004 * And now we create a radio button, since this is the first button in our group
4005 * we set the group to be the radio(so we can set the other radios in the same
4006 * group). We also set the state value of this radio to 1 and the value pointer
4007 * to @p val, since val is @p 1 this has the additional effect of setting the
4008 * radio value to @p 1. For this radio we choose the default home icon:
4011 * To check that our radio buttons are working we'll add a callback to the
4012 * "changed" signal of the radio:
4013 * @until smart_callback
4015 * The creation of our second radio button is almost identical, the 2
4016 * differences worth noting are, the value of this radio 2 and that we add this
4017 * radio to the group of the first radio:
4018 * @until smart_callback
4020 * For our third callback we'll omit the icon and set the value to 3, we'll also
4021 * add it to the group of the first radio:
4022 * @until smart_callback
4024 * Our fourth callback has a value of 4, no icon and most relevantly is not a
4025 * member of the same group as the other radios:
4028 * We finally run the main loop:
4031 * And the last detail in our example is the callback that prints @p val so that
4032 * we can see that the radios are indeed changing its value:
4035 * The example will look like this:
4037 * @image html screenshots/radio_example_01.png
4038 * @image latex screenshots/radio_example_01.eps width=\textwidth
4040 * @example radio_example_01.c
4044 * @page tutorial_toggle Toggle example
4045 * @dontinclude toggle_example_01.c
4047 * In this example we'll create 2 toggle widgets. The first will have an icon
4048 * and the state names will be the default "on"/"off", it will also change the
4049 * value of a variable directly. The second won't have a icon, the state names
4050 * will be "Enabled"/"Disabled", it will start "Enabled" and it won't set the
4051 * value of a variable.
4053 * We start with the usual includes and prototype for callback which will be
4054 * implemented and detailed later on:
4057 * We then declare a static global variable(the one whose value will be changed
4058 * by the first toggle):
4061 * We now have to create our window and all that usual stuff:
4064 * The creation of a toggle is no more complicated than that of any other
4068 * For our first toggle we don't set the states labels so they will stay the
4069 * default, however we do set a label for the toggle, an icon and the variable
4070 * whose value it should change:
4073 * We also set the callback that will be called when the toggles value changes:
4074 * @until smart_callback
4076 * For our second toggle it important to note that we set the states labels,
4077 * don't set an icon or variable, but set the initial state to
4078 * EINA_TRUE("Enabled"):
4081 * For the second toggle we will use a different callback:
4082 * @until smart_callback
4084 * We then ask the main loop to start:
4087 * The callback for our first toggle will look the value of @p val and print it:
4090 * For our second callback we need to do a little bit more, since the second
4091 * toggle doesn't change the value of a variable we have to ask it what its
4095 * This example will look like this:
4097 * @image html screenshots/toggle_example_01.png
4098 * @image latex screenshots/toggle_example_01.eps width=\textwidth
4100 * @example toggle_example_01.c
4104 * @page tutorial_panel Panel example
4105 * @dontinclude panel_example_01.c
4107 * In this example will have 3 panels, one for each possible orientation. Two of
4108 * our panels will start out hidden, the third will start out expanded. For each
4109 * of the panels we will use a label as the content, it's however possible to
4110 * have any widget(including containers) as the content of panels.
4112 * We start by doing some setup, code you should be familiar with from other
4116 * And move right to creating our first panel, for this panel we are going to
4117 * choose the orientation as TOP and toggle it(tell it to hide itself):
4120 * For the second panel we choose the RIGHT orientation and explicitly set the
4124 * For our third and last panel we won't set the orientation(which means it will
4125 * use the default: LEFT):
4128 * All that is left is running the main loop:
4131 * This example will look like this;
4133 * @image html screenshots/panel_example_01.png
4134 * @image latex screenshots/panel_example_01.eps width=\textwidth
4135 * @note The buttons with arrow allow the user to hide/show the panels.
4137 * @example panel_example_01.c
4141 * @page gengrid_example Gengrid widget example
4143 * This application is a thorough exercise on the gengrid widget's
4144 * API. We place an Elementary gengrid widget on a window, with
4145 * various knobs below its viewport, each one acting on it somehow.
4147 * The code's relevant part begins at the grid's creation. After
4148 * instantiating it, we set its items sizes, so that we don't end with
4149 * items one finger size wide, only. We're setting them to fat, 150
4150 * pixel wide ones, for this example. We give it some size hints, not
4151 * to be discussed in this context and, than, we register a callback
4152 * on one of its smart events -- the one coming each time an item gets
4153 * doubly clicked. There, we just print the item handle's value.
4154 * @dontinclude gengrid_example.c
4155 * @skip grid = elm_gengrid_add
4156 * @until evas_object_sho
4157 * @dontinclude gengrid_example.c
4158 * @skip item double click callback
4161 * Before we actually start to deal with the items API, let's show
4162 * some things items will be using throughout all the code. The first
4163 * of them is a struct to be used as item data, for all of them:
4164 * @dontinclude gengrid_example.c
4165 * @skip typedef struct
4168 * That path will be used to index an image, to be swallowed into one
4169 * of the item's icon spots. The imagens themselves are distributed
4171 * @dontinclude gengrid_example.c
4172 * @skip static const char *imgs
4175 * We also have an (unique) gengrid item class we'll be using for
4176 * items in the example:
4177 * @dontinclude gengrid_example.c
4178 * @skip static Elm_Gengrid_Item_Class
4179 * @until static Elm_Gengrid_Item_Class
4180 * @dontinclude gengrid_example.c
4181 * @skip item_style =
4184 * As you see, our items will follow the default theme on gengrid
4185 * items. For the label fetching code, we return a string composed of
4186 * the item's image path:
4187 * @dontinclude gengrid_example.c
4188 * @skip label fetching callback
4191 * For item icons, we'll be populating the item default theme's two
4192 * icon spots, @c "elm.swallow.icon" and @c "elm.swallow.end". The
4193 * former will receive one of the images in our list (in the form of
4194 * a @ref bg_02_example_page "background"), while the latter will be
4195 * a check widget. Note that we prevent the check to propagate click
4196 * events, so that the user can toggle its state without messing with
4197 * the respective item's selection in the grid:
4198 * @dontinclude gengrid_example.c
4199 * @skip icon fetching callback
4200 * @until return NULL
4203 * As the default gengrid item's theme does not have parts
4204 * implementing item states, we'll be just returning false for every
4206 * @dontinclude gengrid_example.c
4207 * @skip state fetching callback
4210 * Finally, the deletion callback on gengrid items takes care of
4211 * freeing the item's label string and its data struct:
4212 * @dontinclude gengrid_example.c
4213 * @skip deletion callback
4216 * Let's move to item insertion/deletion knobs, them. They are four
4217 * buttons, above the grid's viewport, namely
4218 * - "Append" (to append an item to the grid),
4219 * - "Prepend" (to prepend an item to the grid),
4220 * - "Insert before" (to insert an item before the selection, on the
4222 * - "Insert after" (to insert an item after the selection, on the
4224 * - "Clear" (to delete all items in the grid),
4225 * - "Bring in 1st" (to make the 1st item visible, by scrolling),
4226 * - "Show last" (to directly show the last item),
4228 * which are displaced and declared in that order. We're not dealing
4229 * with the buttons' creation code (see @ref button_example_01
4230 * "a button example", for more details on it), but with their @c
4231 * "clicked" registered callbacks. For all of them, the grid's handle
4232 * is passed as @c data. The ones creating new items use a common
4233 * code, which just gives a new @c Example_Item struct, with @c path
4234 * filled with a random image in our images list:
4235 * @dontinclude gengrid_example.c
4236 * @skip new item with random path
4239 * Moreover, that ones will set a common function to be issued on the
4240 * selection of the items. There, we print the item handle's value,
4241 * along with the callback function data. The latter will be @c NULL,
4242 * always, because it's what we pass when adding all icons. By using
4243 * elm_gengrid_item_data_get(), we can have the item data back and,
4244 * with that, we're priting the item's path string. Finally, we
4245 * exemplify elm_gengrid_item_pos_get(), printing the item's position
4247 * @dontinclude gengrid_example.c
4248 * @skip item selection callback
4251 * The appending button will exercise elm_gengrid_item_append(), simply:
4252 * @dontinclude gengrid_example.c
4253 * @skip append an item
4256 * The prepending, naturally, is analogous, but exercising
4257 * elm_gengrid_item_prepend(), on its turn. The "Insert before" one
4258 * will expect an item to be selected in the grid, so that it will
4259 * insert a new item just before it:
4260 * @dontinclude gengrid_example.c
4261 * @skip "insert before" callback
4264 * The "Insert after" is analogous, just using
4265 * elm_gengrid_item_insert_after(), instead. The "Clear" button will,
4266 * as expected, just issue elm_gengrid_clear():
4267 * @dontinclude gengrid_example.c
4268 * @skip delete items
4271 * The "Bring in 1st" button is there exercise two gengrid functions
4272 * -- elm_gengrid_first_item_get() and elm_gengrid_item_bring_in().
4273 * With the former, we get a handle to the first item and, with the
4274 * latter, you'll see that the widget animatedly scrolls its view
4275 * until we can see that item:
4276 * @dontinclude gengrid_example.c
4277 * @skip bring in 1st item
4280 * The "Show last", in its turn, will use elm_gengrid_last_item_get()
4281 * and elm_gengrid_item_show(). The latter differs from
4282 * elm_gengrid_item_bring_in() in that it immediately replaces the
4283 * contents of the grid's viewport with the region containing the item
4285 * @dontinclude gengrid_example.c
4286 * @skip show last item
4289 * To change the grid's cell (items) size, we've placed a spinner,
4290 * which has the following @c "changed" smart callback:
4291 * @dontinclude gengrid_example.c
4292 * @skip change items' size
4295 * Experiment with it and see how the items are affected. The "Disable
4296 * item" button will, as the name says, disable the currently selected
4298 * @dontinclude gengrid_example.c
4299 * @skip disable selected item
4301 * Note that we also make use of elm_gengrid_item_selected_set(),
4302 * there, thus making the item unselected before we actually disable
4305 * To toggle between horizontal and vertical layouting modes on the
4306 * grid, use the "Horizontal mode" check, which will call the
4307 * respective API function on the grid:
4308 * @dontinclude gengrid_example.c
4309 * @skip change layouting mode
4312 * If you toggle the check right after that one, "Always select",
4313 * you'll notice all subsequent clicks on the @b same grid item will
4314 * still issue the selection callback on it, what is different from
4315 * when it's not checked. This is the
4316 * elm_gengrid_always_select_mode_set() behavior:
4317 * @dontinclude gengrid_example.c
4318 * @skip "always select" callback
4321 * One more check follows, "Bouncing", which will turn on/off the
4322 * bouncing animations on the grid, when one scrolls past its
4323 * borders. Experiment with scrolling the grid to get the idea, having
4324 * it turned on and off:
4325 * @dontinclude gengrid_example.c
4326 * @skip "bouncing mode" callback
4329 * The next two checks will affect items selection on the grid. The
4330 * first, "Multi-selection", will make it possible to select more the
4331 * one item on the grid. Because it wouldn't make sense to fetch for
4332 * an unique selected item on this case, we also disable two of the
4333 * buttons, which insert items relatively, if multi-selection is on:
4334 * @dontinclude gengrid_example.c
4335 * @skip multi-selection callback
4338 * Note that we also @b unselect all items in the grid, when returning
4339 * from multi-selection mode, making use of
4340 * elm_gengrid_item_selected_set().
4342 * The second check acting on selection, "No selection", is just what
4343 * its name depicts -- no selection will be allowed anymore, on the
4344 * grid, while it's on. Check it out for yourself, interacting with
4346 * @dontinclude gengrid_example.c
4347 * @skip no selection callback
4350 * We have, finally, one more line of knobs, now sliders, to change
4351 * the grids behavior. The two first will change the horizontal @b
4352 * alignment of the whole actual grid of items within the gengrid's
4354 * @dontinclude gengrid_example.c
4355 * @skip items grid horizontal alignment change
4358 * Naturally, the vertical counterpart just issues
4359 * elm_gengrid_align_set() changing the second alignment component,
4362 * The last slider will change the grid's <b>page size</b>, relative
4363 * to its own one. Try to change those values and, one manner of
4364 * observing the paging behavior, is to scroll softly and release the
4365 * mouse button, with different page sizes, at different grid
4366 * positions, while having lots of items in it -- you'll see it
4367 * snapping to page boundaries differenty, for each configuration:
4368 * @dontinclude gengrid_example.c
4369 * @skip page relative size change
4372 * This is how the example program's window looks like:
4373 * @image html screenshots/gengrid_example.png
4374 * @image latex screenshots/gengrid_example.eps width=\textwidth
4376 * Note that it starts with three items which we included at will:
4377 * @dontinclude gengrid_example.c
4378 * @skip _clicked(grid,
4379 * @until _clicked(grid,
4380 * @until _clicked(grid,
4381 * @until _clicked(grid,
4383 * See the full @ref gengrid_example_c "source code" for
4386 * @example gengrid_example.c
4389 * @page entry_example_01 Entry - Example of simple editing
4391 * As a general overview of @ref Entry we are going to write an, albeit simple,
4392 * functional editor. Although intended to show how elm_entry works, this
4393 * example also makes extensive use of several other widgets. The full code
4394 * can be found in @ref entry_example.c "entry_example.c" and in the following
4395 * lines we'll go through the parts especific to the @ref Entry widget.
4397 * The program itself is a simple editor, with a file already set to it, that
4398 * can be set to autosave or not and allows insertion of emoticons and some
4399 * formatted text. As of this writing, the capabilities of format edition in
4400 * the entry are very limited, so a lot of manual work is required to change
4403 * In any case, the program allows some changes by using the buttons on the
4404 * top of the window and returning focus back to the main entry afterwards.
4406 * @image html screenshots/entry_example.png
4407 * @image latex screenshots/entry_example.eps width=\textwidth
4409 * We'll begin by showing a few structures used throught the program. First,
4410 * the application owns data that holds the main window and the main entry
4411 * where the editting happens. Then, an auxiliar structure we'll use later
4412 * when inserting icons in our text.
4413 * @dontinclude entry_example.c
4415 * @until App_Inwin_Data
4417 * A little convenience function will insert whatever text we need in the
4418 * buffer at the current cursor's position and set focus back to this entry.
4419 * This is done mostly because clicking on any button will make them steal
4420 * focus, which makes writing text more cumbersome.
4424 * One of the buttons on the top will trigger an @ref Inwin to open and show
4425 * us several icons we can insert into the text. We'll jump over most of these
4426 * functions, but when all the options are chosen, we insert the special
4427 * markup text that will show the chosen icon in place.
4428 * @skip edje_file_collection_list_free(emos)
4430 * @until evas_object_del
4433 * As can be seen in that function, the program lets us add icons to our entry
4434 * using all the possible configurations for them. That should help to
4435 * clarify how the different combinations work out by actually seeing them
4438 * The same popup window has a page to set the settings of the chosen icon,
4439 * that is, the size and how the item will be placed within the line.
4441 * The size is done with two entries, limitted to accept numbers and a fixed
4442 * size of characters. Changing the value in this entries will update the icon
4443 * size in our struct as seen in the next two callbacks.
4448 * The rest of the options are handled with radio buttons, since only one type
4449 * of size can be used (@c size, @c absize or @c relsize) and for the vertical
4450 * sizing it needs to choose between @c ascent and @c full. Depending on which
4451 * is chosen, the @c item tag is formed accordingly as seen before.
4452 * @skip static Evas_Object
4453 * @until evas_object_show(rvascent)
4455 * The first of our entries is here. There's something worth mentioning about
4456 * the way we'll create this one. Normally, any entry regardless of whether is
4457 * single line or not, will be set to scrollable, but in this case, since we
4458 * are limitting how many characters can fit in them and we know we don't need
4459 * scrolling, we are not setting this flag. This makes the entry have virtually
4460 * no appearance on screen, other than its text. This is because an entry is
4461 * just that, a box that holds text, and in order to have some frame around it
4462 * or a background color, another widget needs to provide this. When an entry
4463 * is scrollable, the same scroller used internally does this.
4464 * We are using @ref Frame "frames" here to provide some decoration around,
4465 * then creating our entries, set them to single line, add our two filters and
4466 * the callback for when their value change.
4467 * @until _height_changed_cb
4469 * This function ends with the button that will finally call the item
4470 * into our editting string.
4473 * Then we get to the format edition. Here we can add the @c bold and
4474 * @c emphasis tags to parts of our text. There's a lot of manual work to
4475 * know what to do here, since we are not implementing an entire state manager
4476 * and the entry itself doesn't, yet, support all the needed capabilities to
4477 * make this simpler. We begin by getting the format we are using in our
4478 * function from the button pressed.
4479 * @skip aid->pager = pager;
4480 * @until sizeof(fmt_close)
4482 * Next we need to find out if we need to insert an opening or a closing tag.
4483 * For this, we store the current cursor position and create a selection
4484 * from this point until the beginning of our text, and then get the selected
4485 * text to look for any existing format tags in it. This is currently the only
4486 * way in which we can find out what formats is being used in the entry.
4490 * Once we know what tag to insert, we need a second check in the case it was
4491 * a closing tag. This is because any other closing tag that comes after would
4492 * be left dangling alone, so we need to remove it to keep the text consistent.
4495 * Finally, we clear our fake selections and return the cursor back to the
4496 * position it had at first, since there is where we want to insert our format.
4497 * @until cursor_pos_set
4499 * And finish by calling our convenience function from before, to insert the
4500 * text at the current cursor and give focus back to the entry.
4503 * A checkbox on the top of our program tells us if the text we are editing
4504 * will autosave or not. In it's @c "changed" callback we get the value from
4505 * the checkbox and call the elm_entry_autosave_set() function with it. If
4506 * autosave is set, we also call elm_entry_file_save(). This is so the internal
4507 * timer used to periodically store to disk our changes is started.
4511 * Two more functions to show some cursor playing. Whenever we double click
4512 * anywhere on our entry, we'll find what word is the cursor placed at and
4513 * select it. Likewise, for triple clicking, we select the entire line.
4515 * @until _edit_tplclick_cb
4518 * And finally, the main window of the program contains the entry where we
4519 * do all the edition and some helping widgets to change format, add icons
4520 * or change the autosave flag.
4523 * @until _image_insert_cb
4525 * And the main entry of the program. Set to scroll, by default we disable
4526 * autosave and we'll begin with a file set to it because no file selector
4527 * is being used here. The file is loaded with #ELM_TEXT_FORMAT_MARKUP_UTF8
4528 * so that any format contained in it is interpreted, otherwise the entry
4529 * would load it as just text, escaping any tags found and no format or icons
4530 * would be shown. Then we connect to the double and triple click signals
4531 * and set focus on the entry so we can start typing right away.
4534 * @example entry_example.c
4538 * @page genlist_example_01 Genlist - basic usage
4540 * This example creates a simple genlist with a small number of items and
4541 * a callback that is called whenever an item is selected. All the properties of
4542 * this genlist are the default ones. The full code for this example can be seen
4543 * at @ref genlist_example_01_c.
4545 * For the simplest list that you plan to create, it's necessary to define some
4546 * of the basic functions that are used for creating each list item, and
4547 * associating them with the "item class" for that list. The item class is just
4548 * an struct that contains pointers to the specific list item functions that are
4549 * common to all the items of the list.
4551 * Let's show it by example. Our item class is declared globally and static as
4552 * it will be the only item class that we need (we are just creating one list):
4554 * @dontinclude genlist_example_01.c
4555 * @skip static Elm_Genlist
4556 * @until static Elm_Genlist
4558 * This item class will be used for every item that we create. The only
4559 * functions that we are going to set are @c label_get and @c icon_get. As the
4560 * name suggests, they are used by the genlist to generate the label for the
4561 * respective item, and to generate icon(s) to it too. Both the label and icon
4562 * get functions can be called more than once for each item, with different @c
4563 * part parameters, which represent where in the theme of the item that label or
4564 * icon is going to be set.
4566 * The default theme for the genlist contains only one area for label, and two
4567 * areas for icon ("elm.swallow.icon" and "elm.swallow.end"). Since we just want
4568 * to set the first icon (that will be at the left side of the label), we
4569 * compare the part name given with "elm.swallow.icon". Notice that the
4570 * @c label_get function must return a strduped string, that will be freed later
4571 * automatically by the list. Here's the code for @c label_get and @c icon_get:
4573 * @until static void
4575 * We will also provide a function that will be called whenever an item is
4576 * selected in the genlist. However, this function is not part of the item
4577 * class, it will be passed for each item being added to the genlist explicitly.
4578 * Notice the similarity of the function signature with those used by @c
4579 * evas_object_smart_callback_add:
4583 * Now let's show the code used for really creating the list. Skipping
4584 * boilerplate code used for creating a window and background, the first piece
4585 * of code specific to our genlist example is setting the pointer functions of
4586 * the item class to our above defined functions:
4591 * Notice that we also choose to use the "default" style for our genlist items.
4592 * Another interesting point is that @c state_get and @c del are set to @c NULL,
4593 * since we don't need these functions now. @c del doesn't need to be used
4594 * because we don't add any data that must be freed to our items, and @c
4595 * state_get is also not used since all of our items are the same and don't need
4596 * to have different states to be used for each item. Finally we create our
4599 * @until genlist_add
4601 * Now we append several items to the list, and for all of them we need to give
4602 * the list pointer, a pointer to the item class, the data that will be used
4603 * with that item, a pointer to the parent of this item if it is in a group type
4604 * list (this is not the case so we pass @c NULL), possible flags for this item,
4605 * the callback for when the item is selected, and the data pointer that will be
4606 * given to the selected callback.
4610 * The rest of the code is also common to all the other examples, so it will be
4611 * omitted here (look at the full source code link above if you need it).
4613 * You can try to play with this example, and see the selected callback being
4614 * called whenever an item is clicked. It also already has some features enabled
4615 * by default, like vertical bounce animation when reaching the end of the list,
4616 * automatically visible/invisible scrollbar, etc. Look at the @ref
4617 * genlist_example_02 to see an example of setting these properties to the list.
4619 * The current example will look like this when running:
4621 * @image html screenshots/genlist_example_01.png
4622 * @image latex screenshots/genlist_example_01.eps width=\textwidth
4626 * @page genlist_example_02 Genlist - list setup functions
4628 * This example is very similar to the @ref genlist_example_01, but it fetch
4629 * most of the properties of the genlist and displays them on startup (thus
4630 * getting the default value for them) and then set them to some other values,
4631 * to show how to use that API. The full source code is at @ref
4632 * genlist_example_02_c.
4634 * Considering that the base code for instantiating a genlist was already
4635 * described in the previous example, we are going to focus on the new code.
4637 * Just a small difference for the @c _item_label_get function, we are going to
4638 * store the time that this function was called. This is the "realized" time,
4639 * the time when the visual representation of this item was created. This is the
4640 * code for the @c label_get function:
4642 * @dontinclude genlist_example_02.c
4644 * @until return strdup
4646 * Now let's go to the list creation and setup. First, just after creating the
4647 * list, we get most of the default properties from it, and print them on the
4651 * @until printf("\n")
4653 * We are going to change some of the properties of our list.
4655 * There's no need to call the selected callback at every click, just when the
4656 * selected item changes, thus we call elm_genlist_always_select_mode_set() with
4659 * For this list we don't want bounce animations at all, so we set both the
4660 * horizontal bounce and the vertical bounce to false with
4661 * elm_genlist_bounce_set().
4663 * We also want our list to compress items if they are wider than the list
4664 * width (thus we call elm_genlist_compress_mode_set().
4666 * The items have different width, so they are not homogeneous:
4667 * elm_genlist_homogeneous_set() is set to false.
4669 * Since the compress mode is active, the call to
4670 * elm_genlist_horizontal_mode_set() doesn't make difference, but the current
4671 * option would make the list to have at least the width of the largest item.
4673 * This list will support multiple selection, so we call
4674 * elm_genlist_multi_select_set() on it.
4676 * The option elm_genlist_height_for_width_mode_set() would allow text block to
4677 * wrap lines if the Edje part is configured with "text.min: 0 1", for example.
4678 * But since we are compressing the elements to the width of the list, this
4679 * option wouldn't take any effect.
4681 * We want the vertical scrollbar to be always displayed, and the orizontal one
4682 * to never be displayed, and set this with elm_genlist_scroller_policy_set().
4684 * The timeout to consider a longpress is set to half of a second with
4685 * elm_genlist_longpress_timeout_set().
4687 * We also change the block count to a smaller value, but that should have not
4688 * impact on performance since the number of visible items is too small. We just
4689 * increase the granularity of the block count (setting it to have at most 4
4692 * @until block_count_set
4694 * Now let's add elements to the list:
4696 * @until item_append
4699 * It's exactly the same as the previous example. The difference is on the
4700 * behavior of the list, if you try to scroll, select items and so.
4702 * In this example we also need two buttons. One of them, when clicked, will
4703 * display several status info about the current selection, the "realized"
4704 * items, the item in the middle of the screen, and the current mode and active
4705 * item of that mode for the genlist.
4707 * The other button will ask the genlist to "realize" again the items already
4708 * "realized", so their respective label_get and icon_get functions will be
4711 * These are the callbacks for both of these buttons:
4713 * @dontinclude genlist_example_02.c
4719 * Try to scroll, select some items and click on the "Show status" button.
4720 * You'll notice that not all items of the list are "realized", thus consuming
4721 * just a small amount of memory. The selected items are listed in the order
4722 * that they were selected, and the current selected item printed using
4723 * elm_genlist_selected_item_get() is the first selected item of the multiple
4726 * Now resize the window so that you can see the "realized time" of some items.
4727 * This is the time of when the label_get function was called. If you click on
4728 * the "Realize" button, all the already realized items will be rebuilt, so the
4729 * time will be updated for all of them.
4731 * The current example will look like this when running:
4733 * @image html screenshots/genlist_example_02.png
4734 * @image latex screenshots/genlist_example_02.eps width=\textwidth
4738 * @page genlist_example_03 Genlist - different width options
4740 * This example doesn't present any other feature that is not already present in
4741 * the other examples, but visually shows the difference between using the
4742 * default list options (first list of the example), setting the horizontal mode
4743 * to #ELM_LIST_LIMIT (second list), enabling compress mode (third list) and
4744 * using height_for_width option (fourth list).
4746 * The full code for this example is listed below:
4748 * @include genlist_example_03.c
4750 * And the screenshot of the running example:
4752 * @image html screenshots/genlist_example_03.png
4753 * @image latex screenshots/genlist_example_03.eps width=\textwidth
4755 * @example genlist_example_03.c
4759 * @page genlist_example_04 Genlist - items manipulation
4761 * This example is also similar ot the @ref genlist_example_01, but it
4762 * demonstrates most of the item manipulation functions. See the full source
4763 * code at @ref genlist_example_04_c.
4765 * In this example, we also will use the concept of creating groups of items in
4766 * the genlist. Each group of items is composed by a parent item (which will be
4767 * the index of the group) and several children of this item. Thus, for the
4768 * children, we declare a normal item class. But we also are going to declare a
4769 * different item class for the group index (which in practice is another type
4770 * of item in the genlist):
4772 * @dontinclude genlist_example_04.c
4773 * @skip _item_sel_cb
4778 * We will add buttons to the window, where each button provides one
4779 * functionality of the genlist item API. Each button will have a callback
4780 * attached, that will really execute this functionality. An example of these
4781 * callbacks is the next one, for the elm_genlist_item_insert_after() function:
4783 * @skip insert_before_cb
4787 * If you want ot see the other button functions, look at the full source code
4790 * Each button will be created with a function that already creates the button,
4791 * add it to an elementary box, and attach the specified callback. This is the
4792 * function that does it:
4794 * @skip genlist_item_update
4798 * In our @c elm_main function, besides the code for setting up the window, box
4799 * and background, we also initialize our two item classes:
4801 * @skip _itc.item_style
4802 * @until _itc_group.func.del
4804 * This example uses a different style for the items, the @a double_label, which
4805 * provides a text field for the item text, and another text field for a subtext.
4807 * For the group index we use the @a group_index style, which provides a
4808 * different appearance, helping to identify the end of a group and beginning of
4811 * Now, after the code for creating the list, setting up the box and other
4812 * stuff, let's add the buttons with their respective callbacks:
4815 * @until bt_top_show
4817 * The main code for adding items to the list is a bit more complex than the one
4818 * from the previous examples. We check if each item is multiple of 7, and if
4819 * so, they are group indexes (thus each group has 6 elements by default, in
4826 * Then we also check for specific items, and add callbacks to them on the
4827 * respective buttons, so we can show, bring in, etc.:
4832 * Once you understand the code from the @ref genlist_example_01, it should be
4833 * easy to understand this one too. Look at the full code, and also try to play
4834 * a bit with the buttons, adding items, bringing them to the viewport, and so.
4836 * The example will look like this when running:
4838 * @image html screenshots/genlist_example_04.png
4839 * @image latex screenshots/genlist_example_04.eps width=\textwidth
4843 * @page genlist_example_05 Genlist - working with subitems
4845 * This is probably the most complex example of elementary @ref Genlist. We
4846 * create a tree of items, using the subitems properties of the items, and keep
4847 * it in memory to be able to expand/hide subitems of an item. The full source
4848 * code can be found at @ref genlist_example_05_c
4850 * The main point is the way that Genlist manages subitems. Clicking on an
4851 * item's button to expand it won't really show its children. It will only
4852 * generate the "expand,request" signal, and the expansion must be done
4855 * In this example we want to be able to add items as subitems of another item.
4856 * If an item has any child, it must be displayed using a parent class,
4857 * otherwise it will use the normal item class.
4859 * It will be possible to delete items too. Once a tree is constructed (with
4860 * subitems of subitems), and the user clicks on the first parent (root of the
4861 * tree), the entire subtree must be hidden. However, just calling
4862 * elm_genlist_item_expanded_set(item, EINA_FALSE) won't hide them. The only
4863 * thing that happens is that the parent item will change its appearance to
4864 * represent that it's contracted. And the signal "contracted" will be emitted
4865 * from the genlist. Thus, we must call elm_genlist_item_subitems_clear() to
4866 * delete all its subitems, but still keep a way to recreate them when expanding
4867 * the parent again. That's why we are going to keep a node struct for each
4868 * item, that will be the data of the item, with the following information:
4870 * @dontinclude genlist_example_05.c
4874 * This @c Node_Data contains the value for the item, a number indicating its
4875 * level under the tree, a list of children (to be able to expand it later) and
4876 * a boolean indicating if it's a favorite item or not.
4878 * We use 3 different item classes in this example:
4880 * One for items that don't have children:
4887 * One for items that have children:
4894 * And one for items that were favorited:
4900 * The favorite item class is there just to demonstrate the
4901 * elm_genlist_item_item_class_update() function in action. It would be much
4902 * simpler to implement the favorite behavior by just changing the icon inside
4903 * the icon_get functions when the @c favorite boolean is activated.
4905 * Now we are going to declare the callbacks for the buttons that add, delete
4908 * First, a button for appending items to the list:
4910 * @until item_append
4913 * If an item is selected, a new item will be appended to the same level of that
4914 * item, but using the selected item's parent as its parent too. If no item is
4915 * selected, the new item will be appended to the root of the tree.
4917 * Then the callback for marking an item as favorite:
4919 * @until elm_genlist_item_update
4922 * This callback is very simple, it just changes the item class of the selected
4923 * item for the "favorite" one, or go back to the "item" or "parent" class
4924 * depending on that item having children or not.
4926 * Now, the most complex operation (adding a child to an item):
4928 * @until elm_genlist_item_update
4931 * This function gets the data of the selected item, create a new data (for the
4932 * item being added), and appends it to the children list of the selected item.
4934 * Then we must check if the selected item (let's call it @c item1 now) to which
4935 * the new item (called @c item2 from now on) was already a parent item too
4936 * (using the parent item class) or just a normal item (using the default item
4937 * class). In the first case, we just have to append the item to the end of the
4938 * @c item1 children list.
4940 * However, if the @c item1 didn't have any child previously, we have to change
4941 * it to a parent item now. It would be easy to just change its item class to
4942 * the parent type, but there's no way to change the item flags and make it be
4943 * of the type #ELM_GENLIST_ITEM_SUBITEMS. Thus, we have to delete it and create
4944 * a new item, and add this new item to the same position that the deleted one
4945 * was. That's the reason of the checks inside the bigger @c if.
4947 * After adding the item to the newly converted parent, we set it to not
4948 * expanded (since we don't want to show the added item immediately) and select
4949 * it again, since the original item was deleted and no item is selected at the
4952 * Finally, let's show the callback for deleting items:
4954 * @until elm_genlist_item_update
4957 * Since we have an iternal list representing each element of our tree, once we
4958 * delete an item we have to go deleting each child of that item, in our
4959 * internal list. That's why we have the function @c _clear_list, which
4960 * recursively goes freeing all the item data.
4962 * This is necessary because only when we really want to delete the item is when
4963 * we need to delete the item data. When we are just contracting the item, we
4964 * need to hide the children by deleting them, but keeping the item data.
4966 * Now there are two callbacks that will be called whenever the user clicks on
4967 * the expand/contract icon of the item. They will just request to items to be
4968 * contracted or expanded:
4970 * @until elm_genlist_item_expanded_set(
4971 * @until elm_genlist_item_expanded_set(
4974 * When the elm_genlist_item_expanded_set() function is called with @c
4975 * EINA_TRUE, the @c _expanded_cb will be called. And when this happens, the
4976 * subtree of that item must be recreated again. This is done using the internal
4977 * list stored as item data for each item. The function code follows:
4981 * Each appended item is set to contracted, so we don't have to deal with
4982 * checking if the item was contracted or expanded before its parent being
4983 * contracted. It could be easily implemented, though, by adding a flag expanded
4984 * inside the item data.
4986 * Now, the @c _contracted_cb, which is much simpler:
4990 * We just have to call elm_genlist_item_subitems_clear(), that will take care
4991 * of deleting every item, and keep the item data still stored (since we don't
4992 * have any del function set on any of our item classes).
4994 * Finally, the code inside @c elm_main is very similar to the other examples:
4999 * The example will look like this when running:
5001 * @image html screenshots/genlist_example_05.png
5002 * @image latex screenshots/genlist_example_05.eps width=\textwidth
5006 * @page thumb_example_01 Thumb - generating thumbnails.
5008 * This example shows how to create a simple thumbnail object with Elementary.
5009 * The full source code can be found at @ref thumb_example_01_c
5011 * Everything is very simple. First we need to tell elementary that we need
5012 * Ethumb to generate the thumbnails:
5014 * @dontinclude thumb_example_01.c
5015 * @skipline elm_need_ethumb
5017 * Then, after creating the window and background, we setup our client to
5018 * generate images of 160x160:
5023 * After that, we can start creating thumbnail objects. They are very similar to
5024 * image or icon objects:
5026 * @until thumb_reload
5028 * As you can see, the main different function here is elm_thumb_reload(), which
5029 * will check if the options of the Ethumb client have changed. If so, it will
5030 * re-generate the thumbnail, and show the new one.
5032 * Notice in this example that the thumbnail object is displayed on the size of
5033 * the window (320x320 pixels), but the thumbnail generated and stored has size
5034 * 160x160 pixels. That's why the picture seems upscaled.
5036 * Ideally, you will be generating thumbnails with the size that you will be
5039 * The example will look like this when running:
5041 * @image html screenshots/thumb_example_01.png
5042 * @image latex screenshots/thumb_example_01.eps width=\textwidth
5046 * @page progressbar_example Progress bar widget example
5048 * This application is a thorough example of the progress bar widget,
5049 * consisting of a window with varios progress bars, each with a given
5050 * look/style one can give to those widgets. With two auxiliary
5051 * buttons, one can start or stop a timer which will fill in the bars
5052 * in synchrony, simulating an underlying task being completed.
5054 * We create @b seven progress bars, being three of them horizontal,
5055 * three vertical and a final one under the "wheel" alternate style.
5057 * For the first one, we add a progress bar on total pristine state,
5058 * with no other call than the elm_progressbar_add() one:
5059 * @dontinclude progressbar_example.c
5060 * @skip pb with no label
5062 * See, than, that the defaults of a progress bar are:
5063 * - no primary label shown,
5064 * - unit label set to @c "%.0f %%",
5067 * The second progress bar is given a primary label, <c>"Infinite
5068 * bounce"</c>, and, besides, it's set to @b pulse. See how, after one
5069 * starts the progress timer, with the "Start" button, it animates
5070 * differently than the previous one. It won't account for the
5071 * progress, itself, and just dumbly animate a small bar within its
5073 * @dontinclude progressbar_example.c
5074 * @skip pb with label
5077 * Next, comes a progress bar with an @b icon, a primary label and a
5078 * @b custom unit label set. It's also made to grow its bar in an
5079 * @b inverted manner, so check that out during the timer's progression:
5080 * @dontinclude progressbar_example.c
5083 * Another important thing in this one is the call to
5084 * elm_progressbar_span_size_set() -- this is how we forcefully set a
5085 * minimum horizontal size to our whole window! We're not resizing it
5086 * manually, as you can see in the @ref progressbar_example_c
5089 * The next three progress bars are just variants on the ones already
5090 * shown, but now all being @b vertical. Another time we use one of
5091 * than to give the window a minimum vertical size, with
5092 * elm_progressbar_span_size_set(). To demonstrate this trick once
5093 * more, the fifth one, which is also set to pulse, has a smaller
5094 * hardcoded span size:
5095 * @dontinclude progressbar_example.c
5096 * @skip vertical pb, with pulse
5099 * We end the widget demonstration by showing a progress bar with the
5100 * special @b "wheel" progress bar style. One does @b not need to set
5101 * it to pulse, with elm_progressbar_pulse_set(), explicitly, because
5102 * its theme does not take it in account:
5103 * @dontinclude progressbar_example.c
5107 * The two buttons exercising the bars, the facto, follow:
5108 * @dontinclude progressbar_example.c
5109 * @skip elm_button_add
5110 * @until evas_object_show(bt)
5111 * @until evas_object_show(bt)
5113 * The first of the callbacks will, for the progress bars set to
5114 * pulse, start the pulsing animation at that time. For the others, a
5115 * timer callback will take care of updating the values:
5116 * @dontinclude progressbar_example.c
5117 * @skip static Eina_Bool
5122 * Finally, the callback to stop the progress timer will stop the
5123 * pulsing on the pulsing progress bars and, for the others, to delete
5124 * the timer which was acting on their values:
5125 * @dontinclude progressbar_example.c
5130 * This is how the example program's window looks like:
5131 * @image html screenshots/progressbar_example.png
5132 * @image latex screenshots/progressbar_example.eps width=\textwidth
5134 * See the full @ref progressbar_example_c "source code" for
5137 * @example progressbar_example.c
5141 * @page tutorial_notify Notify example
5142 * @dontinclude notify_example_01.c
5144 * In this example we will have 3 notifys in 3 different positions. The first of
5145 * which will dissapear after 5 seconds or when a click outside it occurs, the
5146 * second and third will not dissapear and differ from each other only in
5149 * We start our example with the usual stuff you've seen in other examples:
5152 * We now create a label to use as the content of our first notify:
5155 * Having the label we move to creating our notify, telling it to block events,
5156 * setting its timeout(to autohide it):
5159 * To have the notify dissapear when a click outside its area occur we have to
5160 * listen to its "block,clicked" signal:
5161 * @until smart_callback
5163 * Our callback will look like this:
5166 * @dontinclude notify_example_01.c
5168 * Next we create another label and another notify. Note, however, that this
5169 * time we don't set a timeout and don't have it block events. What we do is set
5170 * the orient so that this notify will appear in the bottom of its parent:
5171 * @skip smart_callback
5175 * For our third notify the only change is the orient which is now center:
5178 * Now we tell the main loop to run:
5181 * Our example will initially look like this:
5183 * @image html screenshots/notify_example_01.png
5184 * @image latex screenshots/notify_example_01.eps width=\textwidth
5186 * Once the first notify is hidden:
5188 * @image html screenshots/notify_example_01_a.png
5189 * @image latex screenshots/notify_example_01_a.eps width=\textwidth
5191 * @example notify_example_01.c
5195 * @page tutorial_frame Frame example
5196 * @dontinclude frame_example_01.c
5198 * In this example we are going to create 4 Frames with different styles and
5199 * add a rectangle of different color in each.
5201 * We start we the usual setup code:
5204 * And then create one rectangle:
5207 * To add it in our first frame, which since it doesn't have it's style
5208 * specifically set uses the default style:
5211 * And then create another rectangle:
5214 * To add it in our second frame, which uses the "pad_small" style, note that
5215 * even tough we are setting a text for this frame it won't be show, only the
5216 * default style shows the Frame's title:
5218 * @note The "pad_small", "pad_medium", "pad_large" and "pad_huge" styles are
5219 * very similar, their only difference is the size of the empty area around
5220 * the content of the frame.
5222 * And then create yet another rectangle:
5225 * To add it in our third frame, which uses the "outdent_top" style, note
5226 * that even tough we are setting a text for this frame it won't be show,
5227 * only the default style shows the Frame's title:
5230 * And then create one last rectangle:
5233 * To add it in our fourth and final frame, which uses the "outdent_bottom"
5234 * style, note that even tough we are setting a text for this frame it won't
5235 * be show, only the default style shows the Frame's title:
5238 * And now we are left with just some more setup code:
5241 * Our example will look like this:
5243 * @image html screenshots/frame_example_01.png
5244 * @image latex screenshots/frame_example_01.eps width=\textwidth
5246 * @example frame_example_01.c
5250 * @page tutorial_anchorblock_example Anchorblock/Anchorview example
5251 * This example will show both Anchorblock and @ref Anchorview,
5252 * since both are very similar and it's easier to show them once and side
5253 * by side, so the difference is more clear.
5255 * We'll show the relevant snippets of the code here, but the full example
5256 * can be found here... sorry, @ref anchorblock_example_01.c "here".
5258 * As for the actual example, it's just a simple window with an anchorblock
5259 * and an anchorview, both containing the same text. After including
5260 * Elementary.h and declaring some functions we'll need, we jump to our
5261 * elm_main (see ELM_MAIN) and create our window.
5262 * @dontinclude anchorblock_example_01.c
5267 * With the needed variables declared, we'll create the window and a box to
5268 * hold our widgets, but we don't need to go through that here.
5270 * In order to make clear where the anchorblock ends and the anchorview
5271 * begins, they'll be each inside a @ref Frame. After creating the frame,
5272 * the anchorblock follows.
5273 * @skip elm_frame_add
5274 * @until elm_frame_content_set
5276 * Nothing out of the ordinary there. What's worth mentioning is the call
5277 * to elm_anchorblock_hover_parent_set(). We are telling our widget that
5278 * when an anchor is clicked, the hover for the popup will cover the entire
5279 * window. This affects the area that will be obscured by the hover and
5280 * where clicking will dismiss it, as well as the calculations it does to
5281 * inform the best locations where to insert the popups content.
5282 * Other than that, the code is pretty standard. We also need to set our
5283 * callback for when an anchor is clicked, since it's our task to populate
5284 * the popup. There's no default for it.
5286 * The anchorview is no different, we only change a few things so it looks
5288 * @until elm_frame_content_set
5290 * Then we run, so stuff works and close our main function in the usual way.
5293 * Now, a little note. Normally you would use either one of anchorblock or
5294 * anchorview, set your one callback to clicks and do your stuff in there.
5295 * In this example, however, there are a few tricks to make it easier to
5296 * show both widgets in one go (and to save me some typing). So we have
5297 * two callbacks, one per widget, that will call a common function to do
5298 * the rest. The trick is using ::Elm_Entry_Anchorblock_Info for the
5299 * anchorview too, since both are equal, and passing a callback to use
5300 * for our buttons to end the hover, because each widget has a different
5302 * @until _anchorview_clicked_cb
5305 * The meat of our popup is in the following function. We check what kind
5306 * of menu we need to show, based on the name set to the anchor in the
5307 * markup text. If there's no type (something went wrong, no valid contact
5308 * in the address list) we are just putting a button that does nothing, but
5309 * it's perfectly reasonable to just end the hover and call it quits.
5311 * Our popup will consist of one main button in the middle of our hover,
5312 * and possibly a secondary button and a list of other options. We'll create
5313 * first our main button and check what kind of popup we need afterwards.
5316 * @until eina_stringshare_add
5319 * Each button has two callbacks, one is our hack to close the hover
5320 * properly based on which widget it belongs to, the other a simple
5321 * printf that will show the action with the anchors own data. This is
5322 * not how you would usually do it. Instead, the common case is to have
5323 * one callback for the button that will know which function to call to end
5324 * things, but since we are doing it this way it's worth noting that
5325 * smart callbacks will be called in reverse in respect to the order they
5326 * were added, and since our @c btn_end_cb will close the hover, and thus
5327 * delete our buttons, the other callback wouldn't be called if we had
5330 * After our telephone popup, there are a few others that are practically
5331 * the same, so they won't be shown here.
5333 * Once we are done with that, it's time to place our actions into our
5334 * hover. Main button goes in the middle without much questioning, and then
5335 * we see if we have a secondary button and a box of extra options.
5336 * Because I said so, secondary button goes on either side and box of
5337 * options either on top or below the main one, but to choose which
5338 * exactly, we use the hints our callback info has, which saves us from
5339 * having to do the math and see which side has more space available, with
5340 * a little special case where we delete our extra stuff if there's nowhere
5344 * @skip evas_object_smart
5345 * @until evas_object_del(box)
5349 * The example will look like this:
5351 * @image html screenshots/anchorblock_01.png
5352 * @image latex screenshots/anchorblock_01.eps width=\textwidth
5354 * @example anchorblock_example_01.c
5358 * @page tutorial_check Check example
5359 * @dontinclude check_example_01.c
5361 * This example will show 2 checkboxes, one with just a label and the second
5362 * one with both a label and an icon. This example also ilustrates how to
5363 * have the checkbox change the value of a variable and how to react to those
5366 * We will start with the usual setup code:
5369 * And now we create our first checkbox, set its label, tell it to change
5370 * the value of @p value when the checkbox stats is changed and ask to be
5371 * notified of state changes:
5374 * For our second checkbox we are going to set an icon so we need to create
5377 * @note For simplicity we are using a rectangle as icon, but any evas object
5380 * And for our second checkbox we set the label, icon and state to true:
5383 * We now do some more setup:
5386 * And finally implement the callback that will be called when the first
5387 * checkbox's state changes. This callback will use @p data to print a
5390 * @note This work because @p data is @p value(from the main function) and @p
5391 * value is changed when the checkbox is changed.
5393 * Our example will look like this:
5395 * @image html screenshots/check_example_01.png
5396 * @image latex screenshots/check_example_01.eps width=\textwidth
5398 * @example check_example_01.c
5402 * @page tutorial_colorselector Color selector example
5403 * @dontinclude colorselector_example_01.c
5405 * This example shows how to change the color of a rectangle using a color
5406 * selector. We aren't going to explain a lot of the code since it's the
5410 * Now that we have a window with background and a rectangle we can create
5411 * our color_selector and set it's initial color to fully opaque blue:
5414 * Next we tell ask to be notified whenever the color changes:
5417 * We follow that we some more run of the mill setup code:
5420 * And now get to the callback that sets the color of the rectangle:
5423 * This example will look like this:
5425 * @image html screenshots/colorselector_example_01.png
5426 * @image latex screenshots/colorselector_example_01.eps width=\textwidth
5428 * @example colorselector_example_01.c
5432 * @page slideshow_example Slideshow widget example
5434 * This application is aimed to exemplify the slideshow widget. It
5435 * consists of a window with a slideshow widget set as "resize
5436 * object", along with a control bar, in the form of a notify. Those
5437 * controls will exercise most of the slideshow's API functions.
5439 * We create the slideshow, itself, first, making it @b loop on its
5440 * image itens, when in slideshow mode:
5441 * @dontinclude slideshow_example.c
5442 * @skip slideshow = elm_slideshow_add
5443 * @until evas_object_show
5445 * Next, we define the <b>item class</b> for our slideshow
5446 * items. Slideshow images are going to be Elementary @ref Photo "photo"
5447 * widgets, here, as pointed by our @c get class
5448 * function. We'll let the Elementary infrastructure to delete those
5449 * objects for us, and, as there's no additional data attached to our
5450 * slideshow items, the @c del class function can be left undefined:
5451 * @dontinclude slideshow_example.c
5454 * @dontinclude slideshow_example.c
5457 * @dontinclude slideshow_example.c
5458 * @skip get our images to make slideshow items
5461 * We now get to populate the slideshow widget with items. Our images
5462 * are going to be some randomly chosen from the Elementary package,
5463 * nine of them. For the first eight, we insert them ordered in the
5464 * widget, by using elm_slideshow_item_sorted_insert(). The comparing
5465 * function will use the image names to sort items. The last item is
5466 * inserted at the end of the slideshow's items list, with
5467 * elm_slideshow_item_add(). We check out how that list ends with
5468 * elm_slideshow_items_get(), than:
5469 * @dontinclude slideshow_example.c
5470 * @skip static const char *img
5472 * @dontinclude slideshow_example.c
5476 * Note that we save the pointers to the first and last items in the
5477 * slideshow, for future use.
5479 * What follows is the code creating a notify, to be shown over the
5480 * slideshow's viewport, with knobs to act on it. We're not showing
5481 * that boilerplate code, but only the callbacks attached to the
5482 * interesting smart events of those knobs. The first four are
5483 * buttons, which will:
5484 * - Select the @b next item in the slideshow
5485 * - Select the @b previous item in the slideshow
5486 * - Select the @b first item in the slideshow
5487 * - Select the @b last item in the slideshow
5489 * Check out the code for those four actions, being the two last @c
5490 * data pointers the same @c first and @c last pointers we save
5491 * before, respectively:
5492 * @dontinclude slideshow_example.c
5493 * @skip jump to next
5499 * What follow are two hoversels, meant for one to change the
5500 * slideshow's @b transition and @b layout styles, respectively. We
5501 * fetch all the available transition and layout names to populate
5502 * those widgets and, when one selects any of them, we apply the
5503 * corresponding setters on the slideshow:
5504 * @dontinclude slideshow_example.c
5505 * @skip hv = elm_hoversel_add
5508 * @dontinclude slideshow_example.c
5509 * @skip transition changed
5513 * For one to change the transition @b time on the slideshow widget,
5514 * we use a spinner widget. We set it to the initial value of 3
5515 * (seconds), which will be probed by the next knob -- a button
5516 * starting the slideshow, de facto. Note that changing the transition
5517 * time while a slideshow is already happening will ajust its
5519 * @dontinclude slideshow_example.c
5520 * @skip spin = elm_spinner_add
5521 * @until evas_object_show
5522 * @dontinclude slideshow_example.c
5523 * @skip slideshow transition time has
5526 * Finally, we have two buttons which will, respectively, start and
5527 * stop the slideshow on our widget. Here are their "clicked"
5529 * @dontinclude slideshow_example.c
5530 * @skip start the show
5534 * This is how the example program's window looks like:
5535 * @image html screenshots/slideshow_example.png
5536 * @image latex screenshots/slideshow_example.eps width=\textwidth
5538 * See the full @ref slideshow_example_c "source code" for
5541 * @example slideshow_example.c
5545 * @page tutorial_photocam Photocam example
5546 * @dontinclude photocam_example_01.c
5548 * In this example we will have a photocam and a couple of buttons and slider to
5549 * control the photocam. To avoid cluttering we'll only show the parts of the
5550 * example that relate to the photocam, the full source code can be seen @ref
5551 * photocam_example_01.c "here".
5553 * Creating a photocam is as easy as creating any other widget:
5554 * @skipline elm_photocam_add
5556 * A photocam is only useful if we have a image on it, so lets set a file for it
5560 * We now set the photocam to not bounce horizontally:
5563 * And we want to know when the photocam has finished loading the image so:
5564 * @until smart_callback
5566 * The reason to know when the image is loaded is so that we can bring the
5567 * center of the image into view:
5571 * As mentioned we have 2 buttons in this example, the "Fit" one will cause
5572 * the photocam to go in to a zoom mode that makes the image fit inside the
5573 * photocam. Tough this has no effect on the image we also print what region was
5574 * being viewed before setting the zoom mode:
5576 * @note When in fit mode our slider(explained below) won't work.
5578 * The second button("Unfit") will bring the photocam back into manual zoom
5582 * Our slider controls the level of zoom of the photocam:
5584 * @note It is important to note that this only works when in manual zoom mode.
5586 * Our example will initially look like this:
5588 * @image html screenshots/photocam_example_01.png
5589 * @image latex screenshots/photocam_example_01.eps width=\textwidth
5591 * @example photocam_example_01.c
5595 * @page inwin_example_01 Inwin - General overview
5597 * Inwin is a very simple widget to show, so this example will be a very simple
5598 * one, just using all of the available API.
5600 * The program is nothing but a window with a lonely button, as shown here.
5602 * @image html screenshots/inwin_example.png
5603 * @image latex screenshots/inwin_example.eps width=\textwidth
5605 * And pressing the button makes an inwin appear.
5607 * @image html screenshots/inwin_example_a.png
5608 * @image latex screenshots/inwin_example_a.eps width=\textwidth
5610 * And the code is just as simple. We being with some global variables to keep
5611 * track of our Inwin.
5612 * @dontinclude inwin_example.c
5614 * @until current_style
5616 * And two callbacks used by the buttons the above screenshot showed. In these,
5617 * we check if @c inwin exists and execute the proper action on it. If it's not
5618 * there anymore, then we were abandoned to our luck, so we disabled ourselves.
5619 * @until _inwin_destroy
5623 * The lonely button from the beginning, when clicked, will call the following
5624 * function, which begins by checking if an inwin exists, and if it's there,
5625 * we bring it back to the front and exit from our function without any further
5629 * But if no inwin is there to show, we need to create one. First we need the
5630 * top-most window for the program, as no inwin can be created using other
5631 * objects as parents. Then we create our popup, set the next style in the list
5633 * @until current_style =
5635 * As for the content of our inwin, it's just a box with a label and some
5637 * @until _inwin_destroy
5640 * Now, all the code above shows how every object must always be set as content
5641 * for some other object, be it by setting the full content, packing it in a
5642 * box or table or working as icon for some other widget. But we didn't do
5643 * anything like that for the inwin, this one is just created and shown and
5644 * everything works. Other widgets can be used this way, but they would need
5645 * to be placed and resized manually or nothing would be shown correctly. The
5646 * inwin, however, sets itself as a children of the top-level window and will
5647 * be resized as the parent window changes too.
5649 * Another characteristic of Inwin is that when it's shown above everyone else,
5650 * it will work kind of like a modal window, blocking any other widget from
5651 * receiving events until the window is manually dismissed by pressing some
5652 * button to close it or having blocking task signalling its completion so
5653 * normal operations can be resumed. This is unlike the @ref Hover widget,
5654 * that would show its content on top of the designated target, but clicking
5655 * anywhere else would dismiss it automatically.
5657 * To illustrate that last point, when we close the main window and an inwin
5658 * is still there, we'll take out the content from the inwin and place it in
5663 * And the rest of the program doesn't have anything else related to inwin,
5664 * so it won't be shown here, but you can find it in
5665 * @ref inwin_example.c "inwin_example.c".
5667 * @example inwin_example.c
5671 * @page tutorial_scroller Scroller example
5672 * @dontinclude scroller_example_01.c
5674 * This example is very short and will illustrate one way to use a scroller.
5675 * We'll omit the declaration of the @p text variable because it's a very long
5676 * @htmlonly<a href="http://lipsum.com/">@endhtmlonly ipsum lorem
5677 * @htmlonly</a>@endhtmlonly. If you really want to see the full code, it's @ref
5678 * scroller_example_01.c "scroller_example_01.c".
5680 * We start our example by creating our window and background:
5684 * Next we create a label and set it's text to @p text(very long ipsum lorem):
5685 * @until show(label)
5687 * We then create our scroller, ask that it have the same size as the window and
5689 * @until content_set
5691 * We are now going to set a number of properties in our scroller:
5692 * @li We make it bounce horizontally but not vertically.
5693 * @li We make both scrollbars always be visible.
5694 * @li We have the events be propagated from the content to the scroller.
5695 * @li We enforce a page policy vertically(having a page be the size of the
5696 * viewport) and leave horizontal scrolling free.
5697 * @li And finally we ask the scroller to show us a region starting at 50,50 and
5698 * having a width and height of 200px.
5699 * @until region_show
5700 * @note Observant reader will note that the elm_scroller_region_show() didn't
5701 * scroll the view vertically, this is because we told the scroller to only
5702 * accept vertical scrolling in pages.
5704 * And now we're done:
5707 * Our example will look like this:
5709 * @image html screenshots/scroller_example_01.png
5710 * @image latex screenshots/scroller_example_01.eps width=\textwidth
5712 * @example scroller_example_01.c
5716 * @page tutorial_table_01
5718 * In this example we add four labels to a homogeneous table that has a padding
5719 * of 5px between cells.
5721 * The interesting bits from this example are:
5722 * @li Where we set the table as homogeneous and the padding:
5723 * @dontinclude table_example_01.c
5725 * @until homogeneous_set
5726 * @li Where we add each label to the table:
5727 * @skipline elm_table_pack
5728 * @skipline elm_table_pack
5729 * @skipline elm_table_pack
5730 * @skipline elm_table_pack
5732 * Here you can see the full source:
5733 * @include table_example_01.c
5735 * Our example will look like this:
5737 * @image html screenshots/table_example_01.png
5738 * @image latex screenshots/table_example_01.eps width=\textwidth
5740 * @example table_example_01.c
5744 * @page tutorial_table_02
5746 * For our second example we'll create a table with 4 rectangles in it. Since
5747 * our rectangles are of different sizes our table won't be homogeneous.
5749 * The interesting bits from this example are:
5750 * @li Where we set the table as not homogeneous:
5751 * @dontinclude table_example_02.c
5752 * @skipline homogeneous_set
5753 * @li Where we add each rectangle to the table:
5754 * @skipline elm_table_pack
5755 * @skipline elm_table_pack
5756 * @skipline elm_table_pack
5757 * @skipline elm_table_pack
5759 * Here you can see the full source:
5760 * @include table_example_02.c
5762 * Our example will look like this:
5764 * @image html screenshots/table_example_02.png
5765 * @image latex screenshots/table_example_02.eps width=\textwidth
5767 * @example table_example_02.c
5771 * @page tutorial_menu Menu Example
5772 * @dontinclude menu_example_01.c
5774 * This example shows how to create a menu with regular items, object items,
5775 * submenus and how to delete items from a menu. The full source for this
5776 * example is @ref menu_example_01.c "menu_example_01.c".
5778 * We'll start looking at the menu creation and how to create a very simple
5783 * For our next item we are going to add an icon:
5786 * Now we are going to add more items, but these icons are going to have a
5787 * parent, which will put them in a sub-menu. First just another item with an
5791 * Next we are going to add a button to our menu(any elm widget can be added to
5795 * We are also going to have the button delete the first item of our
5796 * sub-menu when clicked:
5797 * @until smart_callback
5798 * @dontinclude menu_example_01.c
5802 * We now add a separator and three more regular items:
5807 * We now add another item, however this time it won't go the sub-menu and it'll
5809 * @until disabled_set
5811 * To make sure that our menu is shown whenever the window is clicked(and where
5812 * clicked) we use the following callback:
5813 * @dontinclude menu_example_01.c
5818 * Our example will look like this:
5820 * @image html screenshots/menu_example_01.png
5821 * @image latex screenshots/menu_example_01.eps width=\textwidth
5823 * @example menu_example_01.c
5827 * @page win_example_01 Win - General API overview
5829 * For most users of the Elementary API, the @ref Win widget has a lot more
5830 * functions than what they need.
5832 * In general, a developer will create a window, set some content on it and
5833 * forget about it for the rest of its program's life, letting whatever
5834 * Window Manager is there to handle the window. Here, however, we are going
5835 * to show how to generally manage a window.
5837 * We'll have a bit more than the usual includes here, since part of the
5838 * example requires some low level fiddling.
5839 * @dontinclude win_example.c
5840 * @skip Elementary.h
5843 * The program then, consists of one window with two lists of buttons, each
5844 * of which operates on another two windows. One of them is a normal window,
5845 * the other has the @c override flag set so the Window Manager ignores it.
5847 * Pressing each button will call the corresponding function to act on the
5848 * corresponding window. These are pretty self explanatory, so we'll show
5849 * them in one batch.
5851 * @until elm_win_sticky_set
5854 * Next, we handle the main window closing. We have a @c "delete,request"
5855 * callback set to ask if really want to quit. If so, we end the main loop,
5856 * otherwise just delete the popup message and continue running normally.
5857 * @until _no_quit_cb
5858 * @until _no_quit_cb
5861 * The non-managed window, being completely ignored by the Window Manager,
5862 * is likely to never receive keyboard focus, even if we click on its entry
5863 * to write something. So we have a button on it that will forcefully focus
5864 * it by using some lower level functions to act directly on the X window.
5865 * Then, each time one of the window is focused, we print some message on a
5866 * console to show this more clearly.
5867 * @until _win_focused_cb
5870 * And to finalize, the main function creates a window to hold all the action
5871 * buttons and another two to show how (and what) works on each of them.
5873 * First, the main window will be a normal window, we'll enable the focus
5874 * highlight regardless of how it is configured so it's easier to navigate
5875 * the window with the keyboard. Then we hook our focus and delete callbacks
5876 * and set up the rest of the window's content.
5877 * @until evas_object_show(box)
5879 * The first of our sub-windows is the managed one. We'll create it as a
5880 * dialog, which should make the Window Manager treat it as a non-resizable
5881 * window. We are also setting the window to be auto-deleted when the close
5882 * button in the titlebar is pressed.
5883 * @until evas_object_show(o)
5885 * Now, we added an icon to the window as a resize object. We also set this
5886 * icon to not scale, and no weight size hints have been set for it. This way,
5887 * even if we hadn't created the window as a dialog, it would still not be
5888 * resizable. The window size is defined by its content, so it would never be
5889 * smaller than the smallest of its resize objects, and for it to be resizable,
5890 * all of those objects have to allow it.
5892 * Next, we add the buttons with the actions to perform on this window. Using
5893 * a macro saves us typing and makes the world a happier place.
5894 * @until WIN_ACTION(sticky)
5896 * The maximize one is likely to not work, because the Window Manager will
5897 * probably not enforce it upon a window that states its maximum size, much
5898 * less a dialog. But that can be changed by editting the example to use
5899 * #ELM_WIN_BASIC when creating the window and adding the following line to
5900 * the icon set as content
5902 * evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5905 * Lastly, the second sub-window will have it's override flag set. In it we
5906 * have a label with some text, and entry and a button. The entry can be
5907 * clicked normally to set focus on it, but whether it actually gets keyboard
5908 * input will also depend on the window getting focus, and since the window
5909 * is an override one, it will probably not gain it by normal means. The
5910 * button is there to force the focus at the X level to go to our window.
5911 * And to finish, another list of buttons with actions to perform on this
5912 * last window. Remember that most of them are requests or hints for the
5913 * Window Manager, so they are likely to do nothing on this window.
5914 * Similarly, there won't be any way to move it or resize it, because we
5915 * haven't implemented that kind of control on this example and that's
5916 * something controlled by Window Managers on windows they are tracking, which
5917 * is not the case with this one.
5920 * The full code listing of this example can be found at
5921 * @ref win_example.c "win_example.c".
5923 * @example win_example.c
5927 * @page bg_example_01_c bg_example_01.c
5928 * @include bg_example_01.c
5929 * @example bg_example_01.c
5933 * @page bg_example_02_c bg_example_02.c
5934 * @include bg_example_02.c
5935 * @example bg_example_02.c
5939 * @page bg_example_03_c bg_example_03.c
5940 * @include bg_example_03.c
5941 * @example bg_example_03.c
5945 * @page actionslider_example_01 Actionslider example
5946 * @include actionslider_example_01.c
5947 * @example actionslider_example_01.c
5951 * @page animator_example_01_c Animator example 01
5952 * @include animator_example_01.c
5953 * @example animator_example_01.c
5957 * @page transit_example_01_c Transit example 1
5958 * @include transit_example_01.c
5959 * @example transit_example_01.c
5963 * @page transit_example_02_c Transit example 2
5964 * @include transit_example_02.c
5965 * @example transit_example_02.c
5969 * @page general_functions_example_c General (top-level) functions example
5970 * @include general_funcs_example.c
5971 * @example general_funcs_example.c
5975 * @page clock_example_c Clock example
5976 * @include clock_example.c
5977 * @example clock_example.c
5981 * @page flipselector_example_c Flipselector example
5982 * @include flipselector_example.c
5983 * @example flipselector_example.c
5987 * @page fileselector_example_c Fileselector example
5988 * @include fileselector_example.c
5989 * @example fileselector_example.c
5993 * @page fileselector_button_example_c Fileselector button example
5994 * @include fileselector_button_example.c
5995 * @example fileselector_button_example.c
5999 * @page fileselector_entry_example_c Fileselector entry example
6000 * @include fileselector_entry_example.c
6001 * @example fileselector_entry_example.c
6005 * @page index_example_01_c Index example
6006 * @include index_example_01.c
6007 * @example index_example_01.c
6011 * @page index_example_02_c Index example
6012 * @include index_example_02.c
6013 * @example index_example_02.c
6017 * @page layout_example_01_c layout_example_01.c
6018 * @include layout_example_01.c
6019 * @example layout_example_01.c
6023 * @page layout_example_02_c layout_example_02.c
6024 * @include layout_example_02.c
6025 * @example layout_example_02.c
6029 * @page layout_example_03_c layout_example_03.c
6030 * @include layout_example_03.c
6031 * @example layout_example_03.c
6035 * @page layout_example_edc An example of layout theme file
6037 * This theme file contains two groups. Each of them is a different theme, and
6038 * can be used by an Elementary Layout widget. A theme can be used more than
6039 * once by many different Elementary Layout widgets too.
6041 * @include layout_example.edc
6042 * @example layout_example.edc
6046 * @page gengrid_example_c Gengrid example
6047 * @include gengrid_example.c
6048 * @example gengrid_example.c
6052 * @page genlist_example_01_c genlist_example_01.c
6053 * @include genlist_example_01.c
6054 * @example genlist_example_01.c
6058 * @page genlist_example_02_c genlist_example_02.c
6059 * @include genlist_example_02.c
6060 * @example genlist_example_02.c
6064 * @page genlist_example_04_c genlist_example_04.c
6065 * @include genlist_example_04.c
6066 * @example genlist_example_04.c
6070 * @page genlist_example_05_c genlist_example_05.c
6071 * @include genlist_example_05.c
6072 * @example genlist_example_05.c
6076 * @page thumb_example_01_c thumb_example_01.c
6077 * @include thumb_example_01.c
6078 * @example thumb_example_01.c
6082 * @page progressbar_example_c Progress bar example
6083 * @include progressbar_example.c
6084 * @example progressbar_example.c
6088 * @page slideshow_example_c Slideshow example
6089 * @include slideshow_example.c
6090 * @example slideshow_example.c