2
* @page Examples-cxx Examples with C++ Bindings.
4
* Here is a list of Elementary C++ Examples.
6
* @ref bg_cxx_example_01
8
* @ref bg_cxx_example_02
10
* @ref bubble_cxx_example_01
12
* @ref button_cxx_example_00
14
* @ref button_cxx_example_01
16
* @ref calendar_cxx_example_01
18
* @ref calendar_cxx_example_02
20
* @ref calendar_cxx_example_03
22
* @ref calendar_cxx_example_04
24
* @ref calendar_cxx_example_05
26
* @ref clock_cxx_example
28
* @ref datetime_cxx_example
30
* @ref glview_cxx_example_01
32
* @ref hoversel_cxx_example_01
34
* @ref icon_cxx_example_01
36
* @ref menu_cxx_example_01
38
* @ref popup_cxx_example_01
40
* @ref radio_cxx_example_01
42
* @ref separator_cxx_example_01
44
* @ref slider_cxx_example
46
* @ref spinner_cxx_example
48
* @ref table_cxx_example_01
50
* @ref table_cxx_example_02
52
* @ref thumb_cxx_example_01
57
* @page lambda Lambda Functions with Elementary - C++11
59
* With this tutorial we'll give you a better view of how the lambda
60
* function can and will be constantly use in the C++ bindings. For a
61
* more broad approach you should do a little web research.
63
* The syntax adopted for these examples:
65
* @c [capture] @c (parameters) @c {body}
67
* @a capture: Determinate how and if the capture occurs. Possible
68
* indicators, two or more should be intercalated by commas:
70
* @li [ ] - Capture nothing
72
* @li [&] - Capture variables by reference
74
* @li [=] - Capture variables by copy
76
* @li [&a, b] - Capture <b> only @a a </b> by reference and <b> only
79
* @li [&, a] - Capture variables by reference and <b> only @a a </b>
82
* @li [this] - Capture @c this pointer by copy
84
* @a parameters: List of parameters necessary for each specific
87
* @a body: Function body
89
* Let's start with a more simple lambda and later a more complex one,
90
* all extracted from elementary examples:
92
* <b>First Example</b> - @ref button_cxx_example_00 :
94
* @image html screenshots/button_cxx_example_00.png
95
* @image latex screenshots/button_cxx_example_00.eps width=\textwidth
97
* @dontinclude button_cxx_example_00.cc
102
* In this example we use a @a lambda function for elm::button
103
* btn that will be called when that button is clicked in
104
* callback_clicked_add( on_click ). This lambda will then ask to exit
105
* Elementary's main loop with @a elm_exit(). If this call is issued,
106
* it will flag the main loop to cease processing and return back to
107
* its parent function, usually your elm_main() function.
109
* Now let's analize the sintax used for this lambda:
111
* With @a [] we are signaling that we don't want to capture any
112
* variables and with @a () we are indicating that this lambda doesn't
113
* need parameters to work as it should. Now the important part of this
114
* function it's the @a body represented by @a {} where we are applying
115
* elm_exit() everytime this lambda is called.
117
* In this case we are using @a std::bind to bind the parameters of
118
* our lambda function to return as @a std::function object to
119
* on_click which was declare as auto.
121
* For this example with std::bind we simplified our work simply
122
* because we didn't have to search in the code or documentation of
123
* Elementary to look for the parameters and/or values that the
124
* callback_clicked_add requires of the function we are adding.
126
* <b>Second Example</b> - @ref hoversel_cxx_example_01 :
128
* @image html screenshots/hoversel_cxx_example_01.png
129
* @image latex screenshots/hoverse_cxx_example_01.eps width=\textwidth
131
* @dontinclude hoversel_cxx_example_01.cc
135
* In this example we use a @a lambda function for @a hoversel that
136
* will be called when that hoversel is clicked in
137
* callback_clicked_add( add_item ). This lambda will then add an item
138
* to heversel, note that since we allocate memory for the item we
139
* need to know when the item dies so we can free that memory.
141
* Now let's analize the sintax used for this lambda:
143
* @li @a [] : signaling that we don't want to capture any
146
* @li @a (::elm::hoversel obj ) : indicating that this lambda needs
147
* the parameter @p obj to work as it should. Bbecause we are only
148
* adding the parameter we need instead of all the parameters this
149
* callback requires we need to use placeholders in std::bind,
150
* indicating the place that @obj should occupy in our
151
* callback_clicked_add.
153
* When the function object returned by bind is called, an argument
154
* with placeholder _1 is replaced by the first argument in the call,
155
* _2 is replaced by the second argument in the call, and so on.
157
* @li @a body represented by @a {} where we are adding ervery
158
* function and local variables that will be needed.
160
* In this case we are using @a std::bind to bind the parameters of
161
* our lambda function to return as @a std::function object to
162
* add_item which was declare as auto.
164
* @see Consult all examples from elementary with C++ Bindings @ref
165
* Examples-cxx "here"
169
* @page bg_cxx_example_01 elm::bg - Plain color background with C++ binding
170
* @dontinclude bg_cxx_example_01.cc
172
* This example just sets a default background with a plain color.
174
* The first part consists of including the headers. In this case we
175
* are only working with the Elementary C++ binding and thus we need
176
* only to include him.
178
* @skipline Elementary.hh
180
* @attention If necessary the C and/or the C++ headers should be
181
* include here as well.
183
* Now we need to actually start the code and set the elm_policy,
184
* which defines for a given policy group/identifier a new policy's
185
* value, respectively. In this example the only policy we need to
186
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
188
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
191
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
192
* application's last window is closed;
194
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
195
* application's last window is hidden;
198
* @until elm_policy_set
200
* As you can see, the policy we chose was to quit when the last win
201
* is hidden as opposed to examples with the C bindings where we
202
* perpetually set it to quit when last win was closed. This changed
203
* was necessary because in C++ binding as the elm mainloop stop
204
* running all object are destroyed, references are unreferenced and
205
* events are stopped at ELM_MAIN().
207
* @see For more details consult elm_policy_set
209
* Next step is creating an Elementary window, where win calls a
210
* constructor and sets the type of the win to ELM_WIN_BASIC
211
* (Elm_Win_Type), which is the indicated type for most of our
212
* examples. Here we also set the title that will appear at the top of
213
* our window and then the autohide state for it.
215
* The autohide works similarly to @p autodel, automatically handling
216
* "delete,request" signals when set to @p true, with the difference
217
* that it will hide the window, instead of destroying it.
219
* It is specially designed to work together with @p
220
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
221
* Elementary's main loop when all the windows are hidden.
224
* @until autohide_set
226
* @note @p autodel and @a autohide are not mutually exclusive. The
227
* window will be destructed if both autodel and autohide is set to @p
228
* EINA_TRUE or @p true.
230
* Now we construct the elm background and for this we use the C++
231
* method below, setting it's parent.
233
* @skipline ::elm::bg
235
* To better understand, the function @c size_hint_weight_set for C++
236
* bindings originated from C bindings function
237
* evas_object_size_hint_weight_set, that is EFL Evas type function.
238
* With this function we set the hints for an object's weight. The
241
* @li x - Nonnegative double value to use as horizontal weight hint.
243
* @li y - Nonnegative double value to use as vertical weight hint.
245
* This is not a size enforcement in any way, it's just a hint that
246
* should be used whenever appropriate. This is a hint on how a
247
* container object should resize a given child within its area.
249
* Containers may adhere to the simpler logic of just expanding the
250
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
251
* helper weight macro in the EFL Evas Documentation) or the complete
252
* one of taking each child's weight hint as real weights to how much
253
* of its size to allocate for them in each axis. A container is
254
* supposed to, after normalizing the weights of its children (with
255
* weight hints), distribute the space it has to layout them by those
256
* factors – most weighted children get larger in this process than
259
* @skipline weight_set
261
* @note Default weight hint values are 0.0, for both axis.
263
* Now we add the background as a resize_object to win informing that
264
* when the size of the win changes so should the background's
265
* size. And finally we make it visible.
268
* @until visibility_set
270
* @remarks If a color it's not setted the default color will be used.
272
* Now we set the size for the window, making it visible in the end.
275
* @until visibility_set
277
* Finally we just have to start the elm mainloop, starting to handle
278
* events and drawing operations.
283
* The full code for this example can be found at @ref
284
* bg_cxx_example_01.cc .
286
* @example bg_cxx_example_01.cc
290
* @page bg_cxx_example_02 elm::bg - Image background using C++ binding
291
* @dontinclude bg_cxx_example_02.cc
293
* This is the second background example and shows how to use the
294
* Elementary background object to set an image as background of your
297
* The first part consists of including the headers. In this case we
298
* are only working with the Elementary C++ binding and thus we need
299
* only to include him.
301
* @skipline Elementary.hh
303
* @attention If necessary the C and/or the C++ headers should be
304
* include here as well.
306
* Now we need to actually start the code and set the elm_policy,
307
* which defines for a given policy group/identifier a new policy's
308
* value, respectively. In this example the only policy we need to
309
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
311
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
314
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
315
* application's last window is closed;
317
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
318
* application's last window is hidden;
321
* @until elm_policy_set
323
* As you can see, the policy we chose was to quit when the last win
324
* is hidden as opposed to examples with the C bindings where we
325
* perpetually set it to quit when last win was closed. This changed
326
* was necessary because in C++ binding as the elm mainloop stop
327
* running all object are destroyed, references are unreferenced and
328
* events are stopped at ELM_MAIN().
330
* @see For more details consult elm_policy_set
332
* Next step is creating an Elementary window, where win calls a
333
* constructor and sets the type of the win to ELM_WIN_BASIC
334
* (Elm_Win_Type), which is the indicated type for most of our
335
* examples. Here we also set the title that will appear at the top of
336
* our window and then the autohide state for it.
338
* The autohide works similarly to @p autodel, automatically handling
339
* "delete,request" signals when set to @p true, with the difference
340
* that it will hide the window, instead of destroying it.
342
* It is specially designed to work together with @p
343
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
344
* Elementary's main loop when all the windows are hidden.
347
* @until autohide_set
349
* @note @p autodel and @a autohide are not mutually exclusive. The
350
* window will be destructed if both autodel and autohide is set to @p
351
* EINA_TRUE or @p true.
353
* Our background will have an image, that will be displayed over the
356
* To do so, first we set the directory and archive for the image. And
357
* create the background that will display it.
359
* @skip elm_app_info_set
362
* Before loading this image, we set the load size of the image. The
363
* load size is a hint about the size that we want the image displayed
364
* in the screen. It's not the exact size that the image will have,
365
* but usually a bit bigger. The background object can still be scaled
366
* to a size bigger than the one set here. Setting the image load size
367
* to something smaller than its real size will reduce the memory used
368
* to keep the pixmap representation of the image, and the time to
369
* load it. Here we set the load size to 20x20 pixels, but the image
370
* is loaded with a size bigger than that (since it's just a hint):
372
* @skipline load_size_set
374
* And set our background image to be centered, instead of stretched
375
* or scaled, so the effect of the load_size_set() can be easily
378
* @skipline option_set
380
* We need a filename to set, so we get one from the previous
381
* installed images in the @c PACKAGE_DATA_DIR, and write its full
382
* path to a std::stringstream. Then we use this stringstream to set
383
* the file name in the background object:
385
* @skip std::stringstream
388
* Notice that the second argument of the file_set() function is @c
389
* nullptr, since we are setting an image to this background. This
390
* function also supports setting an Eet file as background, in which
391
* case the @c key parameter wouldn't be @c nullptr, but be the name
392
* of the Eet key instead.
394
* To better understand, the function @c size_hint_weight_set for C++
395
* bindings originated from C bindings function
396
* evas_object_size_hint_weight_set, that is EFL Evas type function.
397
* With this function we set the hints for an object's weight. The
400
* @li x - Nonnegative double value to use as horizontal weight hint.
402
* @li y - Nonnegative double value to use as vertical weight hint.
404
* This is not a size enforcement in any way, it's just a hint that
405
* should be used whenever appropriate.
407
* This is a hint on how a container object should resize a given
408
* child within its area.
410
* Containers may adhere to the simpler logic of just expanding the
411
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
412
* helper weight macro in the EFL Evas Documentation) or the complete
413
* one of taking each child's weight hint as real weights to how much
414
* of its size to allocate for them in each axis. A container is
415
* supposed to, after normalizing the weights of its children (with
416
* weight hints), distribute the space it has to layout them by those
417
* factors – most weighted children get larger in this process than
420
* @skipline weight_set
422
* @note Default weight hint values are 0.0, for both axis.
424
* Now we add the background as a resize_object to win informing that
425
* when the size of the win changes so should the background's
426
* size. And finally we make background.
431
* Now we only have to set the size for our window and make it
435
* @until visibility_set
437
* Finally we just have to start the elm mainloop, starting to handle
438
* events and drawing operations.
443
* The full code for this example can be found at @ref
444
* bg_cxx_example_02.cc .
446
* This example will look like this:
448
* @image html screenshots/bg_cxx_example_02.png
449
* @image latex screenshots/bg_cxx_example_02.eps width=\textwidth
450
* @example bg_cxx_example_02.cc
454
* @page bubble_cxx_example_01 elm::bubble - Simple use with C++ binding
455
* @dontinclude bubble_cxx_example_01.cc
457
* This example shows a bubble with all fields set - label, info,
458
* content and icon - and the selected corner changing when the bubble
461
* The first part consists of including the headers. In this case we
462
* are working with the Elementary and Evas C++ bindings and thus we
463
* need only to include them.
468
* @attention If necessary the C and/or the C++ headers should be
469
* include here as well.
471
* Now we need to actually start the code and set the elm_policy,
472
* which defines for a given policy group/identifier a new policy's
473
* value, respectively. In this example the only policy we need to
474
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
476
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
479
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
480
* application's last window is closed;
482
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
483
* application's last window is hidden;
486
* @until elm_policy_set
488
* As you can see, the policy we chose was to quit when the last win
489
* is hidden as opposed to examples with the C bindings where we
490
* perpetually set it to quit when last win was closed. This changed
491
* was necessary because in C++ binding as the elm mainloop stop
492
* running all object are destroyed, references are unreferenced and
493
* events are stopped at ELM_MAIN().
495
* @see For more details consult elm_policy_set
497
* Next step is creating an Elementary window, where win calls a
498
* constructor and sets the type of the win to ELM_WIN_BASIC
499
* (Elm_Win_Type), which is the indicated type for most of our
500
* examples. Here we also set the title that will appear at the top of
501
* our window and then the autohide state for it.
503
* The autohide works similarly to @p autodel, automatically handling
504
* "delete,request" signals when set to @p true, with the difference
505
* that it will hide the window, instead of destroying it.
507
* It is specially designed to work together with @p
508
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
509
* Elementary's main loop when all the windows are hidden.
512
* @until autohide_set
514
* @note @p autodel and @a autohide are not mutually exclusive. The
515
* window will be destructed if both autodel and autohide is set to @p
516
* EINA_TRUE or @p true.
518
* Now we construct the elm background using the C++ method below,
519
* setting it's parent.
523
* To better understand, the function @c size_hint_weight_set for C++
524
* bindings originated from C bindings function
525
* evas_object_size_hint_weight_set, that is EFL Evas type function.
526
* With this function we set the hints for an object's weight.
528
* The parameters are:
530
* @li x - Nonnegative double value to use as horizontal weight hint.
532
* @li y - Nonnegative double value to use as vertical weight hint.
534
* This is not a size enforcement in any way, it's just a hint that
535
* should be used whenever appropriate.
537
* This is a hint on how a container object should resize a given
538
* child within its area.
540
* Containers may adhere to the simpler logic of just expanding the
541
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
542
* helper weight macro in the EFL Evas Documentation) or the complete
543
* one of taking each child's weight hint as real weights to how much
544
* of its size to allocate for them in each axis. A container is
545
* supposed to, after normalizing the weights of its children (with
546
* weight hints), distribute the space it has to layout them by those
547
* factors – most weighted children get larger in this process than
550
* @skipline weight_set
552
* @note Default weight hint values are 0.0, for both axis.
554
* Now we add the background as a resize_object to win informing that
555
* when the size of the win changes so should the background's
556
* size. And finally we make it visible.
559
* @until visibility_set
561
* @note If a color it's not setted the standard color will be used.
563
* Here we are creating an elm::label that is going to be used as the
564
* content for our bubble:
567
* @until visibility_set
569
* Despite it's name the bubble's icon in this case it's actually
570
* evas::rectangle, that we set it's color to blue and at the end make
573
* @skip evas::rectangle
574
* @until visibility_set
576
* And finally we have the actual bubble creation and the setting of
577
* it's label, info and content:
580
* @until visibility_set
582
* @remark Because we didn't set a corner, the default "top_left" will be used.
584
* To have the selected corner change in a clockwise motion we are going to
585
* use the following callback using lambda:
590
* @see To learn more about consult @ref lambda.
592
* Now that we have our bubble and callback all that is left is adding our
593
* lambda as a clicked callback:
595
* @line callback_clicked_add
597
* This last bubble we created was very complete, so it's pertinent to show
598
* that most of that stuff is optional a bubble can be created with nothing
602
* @until bubble2.visibility_set
604
* Now we only have to set the size for our window and make it
608
* @until visibility_set
610
* And finally, start the elm mainloop, starting to handle events and
611
* drawing operations.
616
* Our example will look like this:
618
* @image html screenshots/bubble_cxx_example_01.png
619
* @image latex screenshots/bubble_cxx_example_01.eps width=\textwidth
621
* @see Full source code @ref bubble_cxx_example_01.cc .
623
* @example bubble_cxx_example_01.cc
627
* @page button_cxx_example_00 Button - Hello, Button!
628
* @dontinclude button_cxx_example_00.cc
630
* Keeping the tradition, this is a simple "Hello, World" button
631
* example. We will show how to create a button and associate an
632
* action to be performed when you click on it.
634
* The first part consists of including the headers. In this case we
635
* are only working with the Elementary C++ binding and thus we need
636
* only to include him.
638
* @skipline Elementary.hh
640
* @attention If necessary the C and/or the C++ headers should be
641
* include here as well.
643
* Now we need to actually start the code and set the elm_policy,
644
* which defines for a given policy group/identifier a new policy's
645
* value, respectively. In this example the only policy we need to
646
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
648
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
651
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
652
* application's last window is closed;
654
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
655
* application's last window is hidden;
658
* @until elm_policy_set
660
* As you can see, the policy we chose was to quit when the last win
661
* is hidden as opposed to examples with the C bindings where we
662
* perpetually set it to quit when last win was closed. This changed
663
* was necessary because in C++ binding as the elm mainloop stop
664
* running all object are destroyed, references are unreferenced and
665
* events are stopped at ELM_MAIN().
667
* @see For more details consult elm_policy_set
669
* Next step is creating an Elementary window, where win calls a
670
* constructor and sets the type of the win to ELM_WIN_BASIC
671
* (Elm_Win_Type), which is the indicated type for most of our
672
* examples. Here we also set the title that will appear at the top of
673
* our window and then the autohide state for it.
675
* The autohide works similarly to @p autodel, automatically handling
676
* "delete,request" signals when set to @p true, with the difference
677
* that it will hide the window, instead of destroying it.
679
* It is specially designed to work together with @p
680
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
681
* Elementary's main loop when all the windows are hidden.
684
* @until autohide_set
686
* @note @p autodel and @a autohide are not mutually exclusive. The
687
* window will be destructed if both autodel and autohide is set to @p
688
* EINA_TRUE or @p true.
690
* Now we construct the elm background and for this we use the C++
691
* method below, setting it's parent.
693
* @skipline ::elm::bg
695
* The function @c size_hint_weight_set for C++ bindings originated
696
* from C bindings function evas_object_size_hint_weight_set, that is
697
* EFL Evas type function. With this function we set the hints for an
698
* object's weight. The parameters are:
700
* @li x - Nonnegative double value to use as horizontal weight hint.
702
* @li y - Nonnegative double value to use as vertical weight hint.
704
* This is not a size enforcement in any way, it's just a hint that
705
* should be used whenever appropriate. This is a hint on how a
706
* container object should resize a given child within its area.
708
* Containers may adhere to the simpler logic of just expanding the
709
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
710
* helper weight macro in the EFL Evas Documentation) or the complete
711
* one of taking each child's weight hint as real weights to how much
712
* of its size to allocate for them in each axis. A container is
713
* supposed to, after normalizing the weights of its children (with
714
* weight hints), distribute the space it has to layout them by those
715
* factors – most weighted children get larger in this process than
718
* @skipline weight_set
720
* @note Default weight hint values are 0.0, for both axis.
722
* Now we add the background as a resize_object to win informing that
723
* when the size of the win changes so should the background's
724
* size. And finally we make it visible.
727
* @until visibility_set
729
* @remarks If a color it's not setted the default color will be used.
731
* There is only one button on this interface. We need to create this
732
* button with the C++ method, set the text to be displayed, the size,
733
* position and the size hint for weight.
738
* For alignment we'll use the function @c size_hint_align_set for C++
739
* bindings originated from C bindings function
740
* evas_object_size_hint_align_set, that is EFL Evas type
741
* function. With this function we set the hints for an object's
742
* alignment. The parameters are:
744
* @li x - Double, ranging from 0.0 to 1.0 or with the special value
745
* EVAS_HINT_FILL, to use as horizontal alignment hint.
747
* @li y - Double, ranging from 0.0 to 1.0 or with the special value
748
* EVAS_HINT_FILL, to use as vertical alignment hint.
750
* These are hints on how to align an object inside the boundaries of
751
* a container/manager. Accepted values are in the 0.0 to 1.0 range,
752
* with the special value EVAS_HINT_FILL used to specify "justify" or
753
* "fill" by some users. In this case, maximum size hints should be
754
* enforced with higher priority, if they are set. Also, any padding
755
* hint set on objects should add up to the alignment space on the
756
* final scene composition.
758
* For the horizontal component, 0.0 means to the left, 1.0 means to
759
* the right. Analogously, for the vertical component, 0.0 to the top,
760
* 1.0 means to the bottom.
762
* This is not a size enforcement in any way, it's just a hint that
763
* should be used whenever appropriate.
767
* @note Default alignment hint values are 0.5, for both axis.
769
* Continuing with our button we make it visible.
771
* @skipline visibility
773
* This button performs a basic action: close the application. This
774
* behavior is described by on_click() which is a lambda function,
775
* that interrupt the program invoking elm_exit(). The lambda function
776
* on_click is the added as a clicked callback to btn.
781
* @see For more details consult @ref lambda
783
* Now we set the size for the window, making it visible in the end:
786
* @until visibility_set
788
* Finally we just have to start the elm mainloop, starting to handle
789
* events and drawing operations.
794
* The full code for this example can be found at @ref
795
* button_cxx_example_00.cc .
797
* This example will look like this:
798
* @image html screenshots/button_cxx_example_00.png
799
* @image latex screenshots/button_cxx_example_00.eps width=\textwidth
800
* @example button_cxx_example_00.cc
804
* @page button_cxx_example_01 Button - Complete example
805
* @dontinclude button_cxx_example_01.cc
807
* A button is simple, you click on it and something happens. That said,
808
* we'll go through an example to show in detail the button API less
811
* The first part consists of including the headers. In this case we
812
* are only working with the Elementary C++ binding and thus we need
813
* only to include him.
815
* @skipline Elementary.hh
817
* @attention If necessary the C and/or the C++ headers should be
818
* include here as well.
820
* Now we need to actually start the code and set the elm_policy,
821
* which defines for a given policy group/identifier a new policy's
822
* value, respectively. In this example the only policy we need to
823
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
825
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
828
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
829
* application's last window is closed;
831
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
832
* application's last window is hidden;
835
* @until elm_policy_set
837
* As you can see, the policy we chose was to quit when the last win
838
* is hidden as opposed to examples with the C bindings where we
839
* perpetually set it to quit when last win was closed. This changed
840
* was necessary because in C++ binding as the elm mainloop stop
841
* running all object are destroyed, references are unreferenced and
842
* events are stopped at ELM_MAIN().
844
* @see For more details consult elm_policy_set
846
* Next step is creating an Elementary window, in this example we use
847
* the C++ binding method with the elm_win_util_standard_add that is a
848
* elm_win_legacy function, better explained below. And then we set
849
* the autohide state for it.
851
* @p elm_win_util_standard_add (const char *name, const char *tittle)
852
* Adds a window object with standard setup.
855
* @li @p name - The name of the window;
857
* @li @p title - The title for the window.
859
* This creates a window but also puts in a standard background with
860
* @p elm_bg_add(), as well as setting the window title to @p
861
* title. The window type created is of type @c ELM_WIN_BASIC, with
862
* the @c NULL as the parent widget. Returns the created object or @c
865
* The autohide works similarly to @p autodel, automatically handling
866
* "delete,request" signals when set to @p true, with the difference
867
* that it will hide the window, instead of destroying it.
869
* It is specially designed to work together with @p
870
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
871
* Elementary's main loop when all the windows are hidden.
874
* @until autohide_set
876
* @note @p autodel and @a autohide are not mutually exclusive. The
877
* window will be destructed if both autodel and autohide is set to @p
878
* EINA_TRUE or @p true.
880
* In this example we'll have several buttons that will be arranged in
881
* two boxes that will be inserted in a bigger box. One of the smaller
882
* boxes will contain a set of buttons that will set different times
883
* for the autorepeat timeouts of the buttons that will be contained in
884
* the other smaller box.
886
* For all this to work, we will construct the three smaller boxes and
887
* all the button that will be needed. The smaller boxes will be then
888
* packed in the bigger one.
890
* In this part we'll create our directional buttons, that we'll be
891
* added in the third smaller box, this is necessary for our callback
897
* Now let's create our bigger box using the C++ method and setting
898
* it's parent as win.
902
* The function @c size_hint_weight_set for C++ bindings originated
903
* from C bindings function evas_object_size_hint_weight_set, that is
904
* EFL Evas type function. With this function we set the hints for an
905
* object's weight. The parameters are:
907
* @li x - Nonnegative double value to use as horizontal weight hint.
909
* @li y - Nonnegative double value to use as vertical weight hint.
911
* This is not a size enforcement in any way, it's just a hint that
912
* should be used whenever appropriate. This is a hint on how a
913
* container object should resize a given child within its area.
915
* Containers may adhere to the simpler logic of just expanding the
916
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
917
* helper weight macro in the EFL Evas Documentation) or the complete
918
* one of taking each child's weight hint as real weights to how much
919
* of its size to allocate for them in each axis. A container is
920
* supposed to, after normalizing the weights of its children (with
921
* weight hints), distribute the space it has to layout them by those
922
* factors – most weighted children get larger in this process than
925
* @skipline weight_set
927
* @note Default weight hint values are 0.0, for both axis.
929
* Now we add the box as a resize_object to win informing that when
930
* the size of the win changes so should the box's size. And finally
931
* we make it visible.
934
* @until visibility_set
936
* Creating our initial box, again using the C++ method, in this case
937
* we want the arrangement of the objects, that this box will contain,
938
* to be displayed horizontally and fot this we will set horizontal to
939
* @p true, vertical by default.
944
* Again we'll set the size hint for weight, but in this box we will
945
* set the packing method to include this box inside the bigger one.
947
* When using the elm box the packing method of the subobj - box in
948
* this case - should be defined. There are four possible methods:
950
* @li @c pack_start(subobj_) - Add an object to the beginning of the
951
* pack list. Pack @c subobj_ into the box obj, placing it first in
952
* the list of children objects. The actual position the object will
953
* get on screen depends on the layout used. If no custom layout is
954
* set, it will be at the top or left, depending if the box is
955
* vertical or horizontal, respectively.
957
* @li @c pack_end(subobj_) - Add an object at the end of the pack
958
* list. Pack @c subobj_ into the box obj, placing it last in the list
959
* of children objects. The actual position the object will get on
960
* screen depends on the layout used. If no custom layout is set, it
961
* will be at the bottom or right, depending if the box is vertical or
962
* horizontal, respectively.
964
* @li @c pack_before(subobj_, before_) - Adds an object to the box
965
* before the indicated object. This will add the @c subobj_ to the
966
* box indicated before the object indicated with @c before_. If
967
* before is not already in the box, results are undefined. Before
968
* means either to the left of the indicated object or above it
969
* depending on orientation.
971
* @li @c pack_after(subobj_, after_) - Adds an object to the box
972
* after the indicated object. This will add the @c subobj_ to the box
973
* indicated after the object indicated with @c after_. If after is
974
* not already in the box, results are undefined. After means either
975
* to the right of the indicated object or below it depending on
978
* In this and most examples we use pack_end by choice and
979
* practicality. In this part of the code we also make calendar
985
* Now let's start creating the buttons that will be included in this
986
* first small box, this will contain the initial timeout button.
988
* We'll use again the C++ method to create this button, set a text,
989
* packing method for btn and finally make it visible.
994
* In this part we'll use Lambda type function that will be added in
995
* the clicked callback for all buttons in the first smaller box,
996
* that'll identify the current initial and gap to be use in the
997
* autorepeat timeout that will move the central button.
1002
* @note To learn more about Lambda Function and its use in Elementary
1003
* consult @ref lambda.
1005
* The second and third button will also set the initial timeout but
1006
* with different values.
1009
* @until btn3.callback
1011
* Now for our gap timeout buttons will create our second smaller box,
1012
* the same way with the initial box, we'll use the C++ method, set to
1013
* be horizontal, set the size hint weight, choose the packing method
1014
* and set the visibility to true.
1019
* For our gap buttons we'll again, use the C++ method, set the texts
1020
* with the different values for gap, choose the packing method, set
1021
* the visibility and the clicked callback.
1024
* @until btn6.callback
1026
* Now we'll give our directional buttons more options so that it will
1027
* visible and also have all the caracteristics that is require.
1029
* For the up button, we'll set to @p true the autorepeat,
1030
* autorepeat_initial_timeout, autoreapet_gap_timeout, the size hints
1031
* for weight and alignment, choose our packing method and making out
1032
* up button visible.
1037
* For this directional buttons we'll have a different repeated
1038
* callback that will insure the timeouts of our middle button in the
1039
* gap and initial timeout that is current setted.
1044
* For our second callback, we'll detail the release of our
1045
* directional buttons.
1050
* Finishing our up button, we'll create an icon, that'll will be the
1051
* standard "arrow_up".
1056
* This last box, will content all the directional buttons and the
1057
* middle button. As before, we use the C++ method, horizontal set,
1058
* weight and align hints, chose the packing method and make it
1064
* Now we'll create all the directional and middle buttons, the same as we did with the up button,
1065
* changing only the icon.
1068
* @until down.content
1070
* Now we set the size for the window, making it visible in the end:
1073
* @until visibility_set
1075
* Finally we just have to start the elm mainloop, starting to handle
1076
* events and drawing operations.
1081
* The full code for this example can be found at @ref
1082
* button_cxx_example_01.cc .
1084
* This example will look like this:
1085
* @image html screenshots/button_cxx_example_01.png
1086
* @image latex screenshots/button_cxx_example_01.eps width=\textwidth
1087
* @example button_cxx_example_01.cc
1091
* @page calendar_cxx_example_01 Calendar - Simple creation with C++ binding
1092
* @dontinclude calendar_cxx_example_01.cc
1094
* As a first example, let's just display a calendar in our window,
1095
* explaining all steps required to do so.
1097
* The first part consists of including the headers. In this case we
1098
* are only working with the Elementary C++ binding and thus we need
1099
* only to include him.
1101
* @skipline Elementary.hh
1103
* @attention If necessary the C and/or the C++ headers should be
1104
* include here as well.
1106
* Now we need to actually start the code and set the elm_policy,
1107
* which defines for a given policy group/identifier a new policy's
1108
* value, respectively. In this example the only policy we need to
1109
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
1111
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
1114
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
1115
* application's last window is closed;
1117
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
1118
* application's last window is hidden;
1121
* @until elm_policy_set
1123
* As you can see, the policy we chose was to quit when the last win
1124
* is hidden as opposed to examples with the C bindings where we
1125
* perpetually set it to quit when last win was closed. This changed
1126
* was necessary because in C++ binding as the elm mainloop stop
1127
* running all object are destroyed, references are unreferenced and
1128
* events are stopped at ELM_MAIN().
1130
* @see For more details consult elm_policy_set
1132
* Next step is creating an Elementary window, in this example we use
1133
* the C++ binding method with the elm_win_util_standard_add that is a
1134
* elm_win_legacy function, better explained below. And then we set
1135
* the autohide state for it.
1137
* @p elm_win_util_standard_add (const char *name, const char *tittle)
1138
* Adds a window object with standard setup.
1141
* @li @p name - The name of the window;
1143
* @li @p title - The title for the window.
1145
* This creates a window but also puts in a standard background with
1146
* @p elm_bg_add(), as well as setting the window title to @p
1147
* title. The window type created is of type @c ELM_WIN_BASIC, with
1148
* the @c NULL as the parent widget. Returns the created object or @c
1151
* The autohide works similarly to @p autodel, automatically handling
1152
* "delete,request" signals when set to @p true, with the difference
1153
* that it will hide the window, instead of destroying it.
1155
* It is specially designed to work together with @p
1156
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
1157
* Elementary's main loop when all the windows are hidden.
1160
* @until autohide_set
1162
* @note @p autodel and @a autohide are not mutually exclusive. The
1163
* window will be destructed if both autodel and autohide is set to @p
1164
* EINA_TRUE or @p true.
1166
* Now, the exciting part, let's create the calendar with the C++
1167
* binding method, passing our window object as parent.
1169
* @skipline elm::calendar
1171
* The function @c size_hint_weight_set for C++ bindings originated
1172
* from C bindings function evas_object_size_hint_weight_set, that is
1173
* EFL Evas type function. With this function we set the hints for an
1174
* object's weight. The parameters are:
1176
* @li x - Nonnegative double value to use as horizontal weight hint.
1178
* @li y - Nonnegative double value to use as vertical weight hint.
1180
* This is not a size enforcement in any way, it's just a hint that
1181
* should be used whenever appropriate. This is a hint on how a
1182
* container object should resize a given child within its area.
1184
* Containers may adhere to the simpler logic of just expanding the
1185
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
1186
* helper weight macro in the EFL Evas Documentation) or the complete
1187
* one of taking each child's weight hint as real weights to how much
1188
* of its size to allocate for them in each axis. A container is
1189
* supposed to, after normalizing the weights of its children (with
1190
* weight hints), distribute the space it has to layout them by those
1191
* factors – most weighted children get larger in this process than
1194
* @skipline weight_set
1196
* @note Default weight hint values are 0.0, for both axis.
1198
* Now we add the calendar as a resize-object to win informing that
1199
* when the size of the win changes so should the calendar's
1200
* size. And finally we make it visible.
1205
* Finally we just have to start the elm mainloop, starting to handle
1206
* events and drawing operations.
1211
* Our example will look like this:
1213
* @image html screenshots/calendar_cxx_example_01.png
1215
* @image latex screenshots/calendar_cxx_example_01.eps width=\textwidth
1217
* See the full source code @ref calendar_cxx_example_01.cc here.
1219
* @example calendar_cxx_example_01.cc
1223
* @page calendar_cxx_example_02 Calendar - Layout strings formatting with C++ binding
1224
* @dontinclude calendar_cxx_example_02.cc
1226
* In this simple example, we'll explain how to format the labels
1227
* displaying month and year, and also set weekday names.
1229
* The first part consists of including the headers. In this case we
1230
* are only working with the Elementary C++ binding and thus we need
1231
* only to include him.
1233
* @skipline Elementary.hh
1235
* @attention If necessary the C and/or the C++ headers should be
1236
* include here as well.
1238
* Now we will jump to the actual code and later explain the function
1239
* to make this tutorial more didactical.
1241
* We must set the elm_policy, which defines for a given policy
1242
* group/identifier a new policy's value, respectively. In this
1243
* example the only policy we need to set a value for is @c
1244
* ELM_POLICY_QUIT, possibles values for it are:
1246
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
1249
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
1250
* application's last window is closed;
1252
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
1253
* application's last window is hidden;
1256
* @until elm_policy_set
1258
* As you can see, the policy we chose was to quit when the last win
1259
* is hidden as opposed to examples with the C bindings where we
1260
* perpetually set it to quit when last win was closed. This changed
1261
* was necessary because in C++ binding as the elm mainloop stop
1262
* running all object are destroyed, references are unreferenced and
1263
* events are stopped at ELM_MAIN().
1265
* @see For more details consult elm_policy_set
1267
* Next step is creating an Elementary window, in this example we use
1268
* the C++ binding method with the elm_win_util_standard_add that is a
1269
* elm_win_legacy function, better explained below. And then we set
1270
* the autohide state for it.
1272
* @p elm_win_util_standard_add (const char *name, const char *tittle)
1273
* Adds a window object with standard setup.
1276
* @li @p name - The name of the window;
1278
* @li @p title - The title for the window.
1280
* This creates a window but also puts in a standard background with
1281
* @p elm_bg_add(), as well as setting the window title to @p
1282
* title. The window type created is of type @c ELM_WIN_BASIC, with
1283
* the @c NULL as the parent widget. Returns the created object or @c
1286
* The autohide works similarly to @p autodel, automatically handling
1287
* "delete,request" signals when set to @p true, with the difference
1288
* that it will hide the window, instead of destroying it.
1290
* It is specially designed to work together with @p
1291
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
1292
* Elementary's main loop when all the windows are hidden.
1295
* @until autohide_set
1297
* @note @p autodel and @a autohide are not mutually exclusive. The
1298
* window will be destructed if both autodel and autohide is set to @p
1299
* EINA_TRUE or @p true.
1301
* Now let's create the calendar with the C++ binding method, passing
1302
* our window object as parent.
1304
* @skipline elm::calendar
1306
* The function @c size_hint_weight_set for C++ bindings originated
1307
* from C bindings function evas_object_size_hint_weight_set, that is
1308
* EFL Evas type function. With this function we set the hints for an
1309
* object's weight. The parameters are:
1311
* @li x - Nonnegative double value to use as horizontal weight hint.
1313
* @li y - Nonnegative double value to use as vertical weight hint.
1315
* This is not a size enforcement in any way, it's just a hint that
1316
* should be used whenever appropriate. This is a hint on how a
1317
* container object should resize a given child within its area.
1319
* Containers may adhere to the simpler logic of just expanding the
1320
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
1321
* helper weight macro in the EFL Evas Documentation) or the complete
1322
* one of taking each child's weight hint as real weights to how much
1323
* of its size to allocate for them in each axis. A container is
1324
* supposed to, after normalizing the weights of its children (with
1325
* weight hints), distribute the space it has to layout them by those
1326
* factors – most weighted children get larger in this process than
1329
* @skipline weight_set
1331
* @note Default weight hint values are 0.0, for both axis.
1333
* Now we add the calendar as a resize-object to win informing that
1334
* when the size of the win changes so should the calendar's
1339
* To format month and year labels, we need to create a callback
1340
* function to create a string given the selected time, declared under
1341
* a <tt> struct tm </tt>.
1343
* <tt> struct tm </tt>, declared on @c time.h, is a structure
1344
* composed by nine integers:
1346
* @li <tt> tm_sec seconds [0,59] </tt>
1347
* @li <tt> tm_min minutes [0,59] </tt>
1348
* @li <tt> tm_hour hour [0,23] </tt>
1349
* @li <tt> tm_mday day of month [1,31] </tt>
1350
* @li <tt> tm_mon month of year [0,11] </tt>
1351
* @li <tt> tm_year years since 1900 </tt>
1352
* @li <tt> tm_wday day of week [0,6] (Sunday = 0) </tt>
1353
* @li <tt> tm_yday day of year [0,365] </tt>
1354
* @li <tt> tm_isdst daylight savings flag </tt>
1356
* @note Glib version has 2 additional fields.
1358
* For our function @p _format_month_year , only stuff that matters
1359
* are <tt>tm_mon</tt> and <tt>tm_year</tt>. But we don't need to
1360
* access it directly, since there are nice functions to format date
1361
* and time, as @c strftime.
1363
* We will get abbreviated month (%b) and year (%y) (check strftime
1364
* manpage for more) in our example:
1366
* @dontinclude calendar_cxx_example_02.cc
1370
* We need to alloc the string to be returned, and calendar widget
1371
* will free it when it's not needed, what is done by @c strdup.
1373
* So let's register our callback to calendar object:
1375
* @skipline format_function_set
1377
* To set weekday names, we should declare them as an array of
1380
* @dontinclude calendar_cxx_example_02.cc
1384
* And then set them to calendar:
1385
* @skipline weekdays_names_set
1387
* Finally we just have to make the calendar and window visible and
1388
* then start the elm mainloop, starting to handle events and drawing
1394
* Our example will look like this:
1396
* @image html screenshots/calendar_cxx_example_02.png
1397
* @image latex screenshots/calendar_cxx_example_02.eps width=\textwidth
1399
* See the full source code @ref calendar_cxx_example_02.cc here.
1400
* @example calendar_cxx_example_02.cc
1404
* @page calendar_cxx_example_03 Calendar - Years restrictions with C++ binding
1405
* @dontinclude calendar_cxx_example_03.cc
1407
* This example explains how to set max and min year to be displayed
1408
* by a calendar object. This means that user won't be able to see or
1409
* select a date before and after selected years. By default, limits
1410
* are 1902 and maximum value will depends on platform architecture
1411
* (year 2037 for 32 bits); You can read more about time functions on
1414
* The first part consists of including the headers. In this case we
1415
* are only working with the Elementary C++ binding and thus we need
1416
* only to include him.
1418
* @skipline Elementary.hh
1420
* @attention If necessary the C and/or the C++ headers should be
1421
* include here as well.
1423
* Now we need to actually start the code and set the elm_policy,
1424
* which defines for a given policy group/identifier a new policy's
1425
* value, respectively. In this example the only policy we need to set
1426
* a value for is @c ELM_POLICY_QUIT, possibles values for it are:
1427
* function to make this tutorial more didactical.
1429
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
1432
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
1433
* application's last window is closed;
1435
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
1436
* application's last window is hidden;
1439
* @until elm_policy_set
1441
* As you can see, the policy we chose was to quit when the last win
1442
* is hidden as opposed to examples with the C bindings where we
1443
* perpetually set it to quit when last win was closed. This changed
1444
* was necessary because in C++ binding as the elm mainloop stop
1445
* running all object are destroyed, references are unreferenced and
1446
* events are stopped at ELM_MAIN().
1448
* @see For more details consult elm_policy_set
1450
* Next step is creating an elementary window, in this example we use
1451
* the C++ binding method with the elm_win_util_standard_add that is a
1452
* elm_win_legacy function, better explained below. And then we set
1453
* the autohide state for it.
1455
* @p elm_win_util_standard_add (const char *name, const char *tittle)
1456
* Adds a window object with standard setup.
1459
* @li @p name - The name of the window;
1461
* @li @p title - The title for the window.
1463
* This creates a window but also puts in a standard background with
1464
* @p elm_bg_add(), as well as setting the window title to @p
1465
* title. The window type created is of type @c ELM_WIN_BASIC, with
1466
* the @c NULL as the parent widget. Returns the created object or @c
1469
* The autohide works similarly to @p autodel, automatically handling
1470
* "delete,request" signals when set to @p true, with the difference
1471
* that it will hide the window, instead of destroying it.
1473
* It is specially designed to work together with @p
1474
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
1475
* Elementary's main loop when all the windows are hidden.
1478
* @until autohide_set
1480
* @note @p autodel and @a autohide are not mutually exclusive. The
1481
* window will be destructed if both autodel and autohide is set to @p
1482
* EINA_TRUE or @p true.
1484
* Now let's create the calendar with the C++ binding method, passing
1485
* our window object as parent.
1487
* @skipline elm::calendar
1489
* The function @c size_hint_weight_set for C++ bindings originated
1490
* from C bindings function evas_object_size_hint_weight_set, that is
1491
* EFL Evas type function. With this function we set the hints for an
1492
* object's weight. The parameters are:
1494
* @li x - Nonnegative double value to use as horizontal weight hint.
1496
* @li y - Nonnegative double value to use as vertical weight hint.
1498
* This is not a size enforcement in any way, it's just a hint that
1499
* should be used whenever appropriate. This is a hint on how a
1500
* container object should resize a given child within its area.
1502
* Containers may adhere to the simpler logic of just expanding the
1503
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
1504
* helper weight macro in the EFL Evas Documentation) or the complete
1505
* one of taking each child's weight hint as real weights to how much
1506
* of its size to allocate for them in each axis. A container is
1507
* supposed to, after normalizing the weights of its children (with
1508
* weight hints), distribute the space it has to layout them by those
1509
* factors – most weighted children get larger in this process than
1512
* @skipline weight_set
1514
* @note Default weight hint values are 0.0, for both axis.
1516
* Now we add the calendar as a resize-object to win informing that
1517
* when the size of the win changes so should the calendar's
1522
* Straigh to the point, to set it is enough to call
1523
* min_max_year_set(). First value is minimum year, second is
1524
* maximum. If first value is negative, it won't apply limit for min
1525
* year, if the second one is negative, won't apply for max year.
1526
* Setting both to negative value will clear limits (default state):
1528
* @skipline min_max_year_set
1530
* Finally we just have to make the calendar and window visible and
1531
* then start the elm mainloop, starting to handle events and drawing
1537
* Our example will look like this:
1539
* @image html screenshots/calendar_cxx_example_03.png
1540
* @image latex screenshots/calendar_cxx_example_03.eps width=\textwidth
1542
* See the full source code @ref calendar_cxx_example_03.cc here.
1544
* @example calendar_cxx_example_03.cc
1548
* @page calendar_cxx_example_04 Calendar - Days selection with C++ binding.
1549
* @dontinclude calendar_cxx_example_04.cc
1551
* It's possible to disable date selection and to select a date
1552
* from your program, and that's what we'll see on this example.
1554
* The first part consists of including the headers. In this case we
1555
* are only working with the Elementary C++ binding and thus we need
1556
* only to include him.
1558
* @skipline Elementary.hh
1560
* @attention If necessary the C and/or the C++ headers should be
1561
* include here as well.
1563
* Now we need to actually start the code and set the elm_policy,
1564
* which defines for a given policy group/identifier a new policy's
1565
* value, respectively. In this example the only policy we need to set
1566
* a value for is @c ELM_POLICY_QUIT, possibles values for it are:
1568
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
1571
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
1572
* application's last window is closed;
1574
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
1575
* application's last window is hidden;
1578
* @until elm_policy_set
1580
* As you can see, the policy we chose was to quit when the last win
1581
* is hidden as opposed to examples with the C bindings where we
1582
* perpetually set it to quit when last win was closed. This changed
1583
* was necessary because in C++ binding as the elm mainloop stop
1584
* running all object are destroyed, references are unreferenced and
1585
* events are stopped at ELM_MAIN().
1587
* @see For more details consult elm_policy_set
1589
* Next step is creating an elementary window, in this example we use
1590
* the C++ binding method with the elm_win_util_standard_add that is a
1591
* elm_win_legacy function, better explained below. And then we set
1592
* the autohide state for it.
1594
* @p elm_win_util_standard_add (const char *name, const char *tittle)
1595
* Adds a window object with standard setup.
1598
* @li @p name - The name of the window;
1600
* @li @p title - The title for the window.
1602
* This creates a window but also puts in a standard background with
1603
* @p elm_bg_add(), as well as setting the window title to @p
1604
* title. The window type created is of type @c ELM_WIN_BASIC, with
1605
* the @c NULL as the parent widget. Returns the created object or @c
1608
* The autohide works similarly to @p autodel, automatically handling
1609
* "delete,request" signals when set to @p true, with the difference
1610
* that it will hide the window, instead of destroying it.
1612
* It is specially designed to work together with @p
1613
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
1614
* Elementary's main loop when all the windows are hidden.
1617
* @until autohide_set
1619
* @note @p autodel and @a autohide are not mutually exclusive. The
1620
* window will be destructed if both autodel and autohide is set to @p
1621
* EINA_TRUE or @p true.
1623
* In this example we'll need to use a elm::box to layout the two
1624
* calendars that'll be created. A box arranges objects in a linear
1625
* fashion, governed by a layout function that defines the details of
1626
* this arrangement. The box will use an internal function
1627
* to set the layout to a single row, vertical by default.
1629
* Now let's create the box with the C++ binding method, passing
1630
* our window object as parent.
1632
* @skipline elm::box
1634
* The function @c size_hint_weight_set for C++ bindings originated
1635
* from C bindings function evas_object_size_hint_weight_set, that is
1636
* EFL Evas type function. With this function we set the hints for an
1637
* object's weight. The parameters are:
1639
* @li x - Nonnegative double value to use as horizontal weight hint.
1641
* @li y - Nonnegative double value to use as vertical weight hint.
1643
* This is not a size enforcement in any way, it's just a hint that
1644
* should be used whenever appropriate. This is a hint on how a
1645
* container object should resize a given child within its area.
1647
* Containers may adhere to the simpler logic of just expanding the
1648
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
1649
* helper weight macro in the EFL Evas Documentation) or the complete
1650
* one of taking each child's weight hint as real weights to how much
1651
* of its size to allocate for them in each axis. A container is
1652
* supposed to, after normalizing the weights of its children (with
1653
* weight hints), distribute the space it has to layout them by those
1654
* factors – most weighted children get larger in this process than
1657
* @skipline weight_set
1659
* @note Default weight hint values are 0.0, for both axis.
1661
* Now we add the box as a resize-object to win informing that when
1662
* the size of the win changes so should the box's size. Remember
1663
* always to set the box visibility to true.
1668
* Now let's create the calendar with the C++ binding method, passing
1669
* our window object as parent. The function size_hint_weight_set
1670
* works with calendar the same way as with box, for more, search
1673
* @skip elm::calendar
1676
* The function @c size_hint_align_set for C++ bindings originated
1677
* from C bindings function evas_object_size_hint_align_set, that is
1678
* EFL Evas type function. With this function we set the hints for an
1679
* object's alignment. The parameters are:
1681
* @li x - Double, ranging from 0.0 to 1.0 or with the special value
1682
* EVAS_HINT_FILL, to use as horizontal alignment hint.
1684
* @li y - Double, ranging from 0.0 to 1.0 or with the special value
1685
* EVAS_HINT_FILL, to use as vertical alignment hint.
1687
* These are hints on how to align an object inside the boundaries of
1688
* a container/manager. Accepted values are in the 0.0 to 1.0 range,
1689
* with the special value EVAS_HINT_FILL used to specify "justify" or
1690
* "fill" by some users. In this case, maximum size hints should be
1691
* enforced with higher priority, if they are set. Also, any padding
1692
* hint set on objects should add up to the alignment space on the
1693
* final scene composition.
1695
* For the horizontal component, 0.0 means to the left, 1.0 means to
1696
* the right. Analogously, for the vertical component, 0.0 to the top,
1697
* 1.0 means to the bottom.
1699
* This is not a size enforcement in any way, it's just a hint that
1700
* should be used whenever appropriate.
1702
* @note Default alignment hint values are 0.5, for both axis.
1704
* @skipline align_set
1706
* If isn't required that users could select a day on calendar, only
1707
* interacting going through months, disabling days selection could be
1708
* a good idea to avoid confusion. For that:
1710
* @skipline select_mode_set
1712
* When using the elm box the packing method of the subobj - calendar
1713
* in this case - should be defined. There are four possible methods:
1715
* @li @c pack_start(subobj_) - Add an object to the beginning of the
1716
* pack list. Pack @c subobj_ into the box obj, placing it first in
1717
* the list of children objects. The actual position the object will
1718
* get on screen depends on the layout used. If no custom layout is
1719
* set, it will be at the top or left, depending if the box is
1720
* vertical or horizontal, respectively.
1722
* @li @c pack_end(subobj_) - Add an object at the end of the pack
1723
* list. Pack @c subobj_ into the box obj, placing it last in the list
1724
* of children objects. The actual position the object will get on
1725
* screen depends on the layout used. If no custom layout is set, it
1726
* will be at the bottom or right, depending if the box is vertical or
1727
* horizontal, respectively.
1729
* @li @c pack_before(subobj_, before_) - Adds an object to the box
1730
* before the indicated object. This will add the @c subobj_ to the
1731
* box indicated before the object indicated with @c before_. If
1732
* before is not already in the box, results are undefined. Before
1733
* means either to the left of the indicated object or above it
1734
* depending on orientation.
1736
* @li @c pack_after(subobj_, after_) - Adds an object to the box
1737
* after the indicated object. This will add the @c subobj_ to the box
1738
* indicated after the object indicated with @c after_. If after is
1739
* not already in the box, results are undefined. After means either
1740
* to the right of the indicated object or below it depending on
1743
* In this and most examples we use pack_end by choice and
1744
* practicality. In this part of the code we also make calendar
1750
* Also, regarding days selection, you could be interested to set a
1751
* date to be highlighted on calendar from your code, maybe when a
1752
* specific event happens or after calendar creation. As @c time
1753
* output is in seconds, we define the number of seconds contained
1754
* within a day as a constant:
1756
* @dontinclude calendar_cxx_example_04.cc
1757
* @skipline SECS_DAY
1759
* As with the first calendar, we'll also construct cal2, set it's
1760
* hint_weight and hint_align, make cal2 visible and choose the
1768
* Now let's select two days from current day:
1770
* @dontinclude calendar_cxx_example_04.cc
1772
* @until selected_time_set
1774
* Finally we just have to make window visible and then start the elm
1775
* mainloop, starting to handle events and drawing operations.
1780
* Our example will look like this:
1782
* @image html screenshots/calendar_cxx_example_04.png
1783
* @image latex screenshots/calendar_cxx_example_04.eps width=\textwidth
1785
* See the full source code @ref calendar_cxx_example_04.cc here.
1786
* @example calendar_cxx_example_04.cc
1790
* @page calendar_cxx_example_05 Calendar - Signal callback and getters with C++ binding.
1791
* @dontinclude calendar_cxx_example_05.cc
1793
* Most of setters explained on previous examples have associated
1794
* getters. That's the subject of this example. We'll add a callback
1795
* to display all calendar information every time user interacts with
1796
* the calendar. To be more didatical we'll start with the basics.
1798
* The first part consists of including the headers. In this case we
1799
* are only working with the Elementary C++ binding and thus we need
1800
* only to include him.
1802
* @skipline Elementary.hh
1804
* @attention If necessary the C and/or the C++ headers should be
1805
* included here as well.
1807
* Now we need to actually start the code and set the elm_policy,
1808
* which defines for a given policy group/identifier a new policy's
1809
* value, respectively. In this example the only policy we need to set
1810
* a value for is @c ELM_POLICY_QUIT, possibles values for it are:
1811
* function to make this tutorial more didactical.
1813
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
1816
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
1817
* application's last window is closed;
1819
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
1820
* application's last window is hidden;
1823
* @until elm_policy_set
1825
* As you can see, the policy we chose was to quit when the last win
1826
* is hidden as opposed to examples with the C bindings where we
1827
* perpetually set it to quit when last win was closed. This changed
1828
* was necessary because in C++ binding as the elm mainloop stop
1829
* running all object are destroyed, references are unreferenced and
1830
* events are stopped at ELM_MAIN().
1832
* @see For more details consult elm_policy_set
1834
* Next step is creating an elementary window, in this example we use
1835
* the C++ binding method with the elm_win_util_standard_add that is a
1836
* elm_win_legacy function, better explained below. And then we set
1837
* the autohide state for it.
1839
* @p elm_win_util_standard_add (const char *name, const char *tittle)
1840
* Adds a window object with standard setup.
1843
* @li @p name - The name of the window;
1845
* @li @p title - The title for the window.
1847
* This creates a window but also puts in a standard background with
1848
* @p elm_bg_add(), as well as setting the window title to @p
1849
* title. The window type created is of type @c ELM_WIN_BASIC, with
1850
* the @c NULL as the parent widget. Returns the created object or @c
1853
* The autohide works similarly to @p autodel, automatically handling
1854
* "delete,request" signals when set to @p true, with the difference
1855
* that it will hide the window, instead of destroying it.
1857
* It is specially designed to work together with @p
1858
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
1859
* Elementary's main loop when all the windows are hidden.
1862
* @until autohide_set
1864
* @note @p autodel and @a autohide are not mutually exclusive. The
1865
* window will be destructed if both autodel and autohide is set to @p
1866
* EINA_TRUE or @p true.
1868
* Now let's create the calendar with the C++ binding method, passing
1869
* our window object as parent.
1871
* @skipline elm::calendar
1873
* The function @c size_hint_weight_set for C++ bindings originated
1874
* from C bindings function evas_object_size_hint_weight_set, that is
1875
* EFL Evas type function. With this function we set the hints for an
1876
* object's weight. The parameters are:
1878
* @li x - Nonnegative double value to use as horizontal weight hint.
1880
* @li y - Nonnegative double value to use as vertical weight hint.
1882
* This is not a size enforcement in any way, it's just a hint that
1883
* should be used whenever appropriate. This is a hint on how a
1884
* container object should resize a given child within its area.
1886
* Containers may adhere to the simpler logic of just expanding the
1887
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
1888
* helper weight macro in the EFL Evas Documentation) or the complete
1889
* one of taking each child's weight hint as real weights to how much
1890
* of its size to allocate for them in each axis. A container is
1891
* supposed to, after normalizing the weights of its children (with
1892
* weight hints), distribute the space it has to layout them by those
1893
* factors – most weighted children get larger in this process than
1896
* @skipline weight_set
1898
* @note Default weight hint values are 0.0, for both axis.
1900
* Now we add the calendar as a resize-object to win informing that
1901
* when the size of the win changes so should the calendar's
1904
* Let's check our callback function, type lambda:
1905
* @skip print_cal_info
1906
* @until double interval;
1908
* To learn more about consult @ref lambda.
1910
* To get selected day, we need to call selected_time_get(), but to
1911
* assure nothing wrong happened, we must check for function return.
1912
* It'll return @c EINA_FALSE if fail. Otherwise we can use time set
1913
* to our structure @p stime.
1915
* @skip selected_time_get
1918
* Next we'll get information from calendar and place on declared
1922
* @until weekdays_names_get
1924
* The only tricky part is that last line gets an array of strings
1925
* (char arrays), one for each weekday.
1927
* Then we can simple print that with std::cout and finish the lambda
1931
* @until std::placeholders::_1
1933
* <tt> struct tm </tt> is declared on @c time.h. You can check @c
1934
* ctime manpage to read about it.
1936
* To register this callback, that will be called every time user
1937
* selects a day or goes to next or previous month, just add a
1938
* callback for signal @b changed.
1940
* @skipline callback_changed_add
1942
* Finally we just have to make calendar and window visibles and then
1943
* start the elm mainloop, starting to handle events and drawing
1949
* Our example will look like this:
1951
* @image html screenshots/calendar_cxx_example_05.png
1952
* @image latex screenshots/calendar_cxx_example_05.eps width=\textwidth
1954
* See the full source code @ref calendar_cxx_example_05.cc here.
1955
* @example calendar_cxx_example_05.cc
1959
* @page clock_cxx_example Clock widget example wit C++ binding.
1960
* @dontinclude clock_cxx_example.cc
1962
* This code places five Elementary clock widgets on a window, each of
1963
* them exemplifying a part of the widget's API. Before explaining
1964
* each clock to be more didatical let's start with the basics.
1966
* The first part consists of including the headers. In this
1967
* case we are only working with the Elementary C++ binding and thus
1968
* we need only to include him.
1970
* @skipline Elementary.hh
1972
* @attention If necessary the C and/or the C++ headers should be
1973
* include here as well.
1975
* Now we need to actually start the code and set the elm_policy,
1976
* which defines for a given policy group/identifier a new policy's
1977
* value, respectively. In this example the only policy we need to
1978
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
1980
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
1983
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
1984
* application's last window is closed;
1986
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
1987
* application's last window is hidden;
1990
* @until elm_policy_set
1992
* As you can see, the policy we chose was to quit when the last win
1993
* is hidden as opposed to examples with the C bindings where we
1994
* perpetually set it to quit when last win was closed. This changed
1995
* was necessary because in C++ binding as the elm mainloop stop
1996
* running all object are destroyed, references are unreferenced and
1997
* events are stopped at ELM_MAIN().
1999
* @see For more details consult elm_policy_set
2001
* Next step is creating an Elementary window, in this example we use
2002
* the C++ binding method with the elm_win_util_standard_add that is a
2003
* elm_win_legacy function, better explained below. And then we set
2004
* the autohide state for it.
2006
* @p elm_win_util_standard_add (const char *name, const char *tittle)
2007
* Adds a window object with standard setup.
2010
* @li @p name - The name of the window;
2012
* @li @p title - The title for the window.
2014
* This creates a window but also puts in a standard background with
2015
* @p elm_bg_add(), as well as setting the window title to @p
2016
* title. The window type created is of type @c ELM_WIN_BASIC, with
2017
* the @c NULL as the parent widget. Returns the created object or @c
2020
* And we also set the autohide state for win, autohide works
2021
* similarly to @p autodel, automatically handling "delete,request"
2022
* signals when set to @p true, with the difference that it will hide
2023
* the window, instead of destroying it.
2025
* It is specially designed to work together with @p
2026
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
2027
* Elementary's main loop when all the windows are hidden.
2030
* @until autohide_set
2032
* @note @p autodel and @a autohide are not mutually exclusive. The
2033
* window will be destructed if both autodel and autohide is set to @p
2034
* EINA_TRUE or @p true.
2036
* @see For more details consult elm::win::autohide_set().
2038
* A box arranges objects in a linear fashion, governed by a layout
2039
* function that defines the details of this arrangement. The box will
2040
* use an internal function to set the layout to a single row,
2041
* vertical by default.
2043
* Now let's create the box with the C++ binding method, passing our
2044
* window object as parent.
2046
* @skipline elm::box
2048
* To better understand, the function @c size_hint_weight_set for C++
2049
* bindings originated from C bindings function
2050
* evas_object_size_hint_weight_set, that is EFL Evas type function.
2051
* With this function we set the hints for an object's weight. The
2054
* @li x - Nonnegative double value to use as horizontal weight hint.
2056
* @li y - Nonnegative double value to use as vertical weight hint.
2058
* This is not a size enforcement in any way, it's just a hint that
2059
* should be used whenever appropriate. This is a hint on how a
2060
* container object should resize a given child within its area.
2062
* Containers may adhere to the simpler logic of just expanding the
2063
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
2064
* helper weight macro in the EFL Evas Documentation) or the complete
2065
* one of taking each child's weight hint as real weights to how much
2066
* of its size to allocate for them in each axis. A container is
2067
* supposed to, after normalizing the weights of its children (with
2068
* weight hints), distribute the space it has to layout them by those
2069
* factors – most weighted children get larger in this process than
2072
* @skipline weight_set
2074
* @note Default weight hint values are 0.0, for both axis.
2076
* Then we add the box as a resize-object to win informing that when
2077
* the size of the win changes so should the box's size. Remember
2078
* always to set the box visibility to true.
2083
* We create each clock with the C++ binding method, passing our
2084
* window object as parent. The first of them is the pristine clock,
2085
* using the defaults for a clock, which are military time with no
2090
* When using the elm::box the packing method of the subobj - clock
2091
* in this case - should be defined. There are four possible methods:
2093
* @li @c pack_start(subobj_) - Add an object to the beginning of the
2094
* pack list. Pack @c subobj_ into the box obj, placing it first in
2095
* the list of children objects. The actual position the object will
2096
* get on screen depends on the layout used. If no custom layout is
2097
* set, it will be at the top or left, depending if the box is
2098
* vertical or horizontal, respectively.
2100
* @li @c pack_end(subobj_) - Add an object at the end of the pack
2101
* list. Pack @c subobj_ into the box obj, placing it last in the list
2102
* of children objects. The actual position the object will get on
2103
* screen depends on the layout used. If no custom layout is set, it
2104
* will be at the bottom or right, depending if the box is vertical or
2105
* horizontal, respectively.
2107
* @li @c pack_before(subobj_, before_) - Adds an object to the box
2108
* before the indicated object. This will add the @c subobj_ to the
2109
* box indicated before the object indicated with @c before_. If
2110
* before is not already in the box, results are undefined. Before
2111
* means either to the left of the indicated object or above it
2112
* depending on orientation.
2114
* @li @c pack_after(subobj_, after_) - Adds an object to the box
2115
* after the indicated object. This will add the @c subobj_ to the box
2116
* indicated after the object indicated with @c after_. If after is
2117
* not already in the box, results are undefined. After means either
2118
* to the right of the indicated object or below it depending on
2121
* In this and most examples we use pack_end by choice and
2122
* practicality. In this part of the code we also make clock
2128
* The second clock shows the am/pm time, that we also create with
2129
* the C++ binding method, passing our window object as
2130
* parent. Setting show_am_pm to true and again choosing the packing
2131
* method and making clock visible.
2136
* The third one will show the seconds digits, which will flip in
2137
* synchrony with system time. Note, besides, that the time itself is
2138
* @b different from the system's -- it was customly set with
2144
* In both fourth and fifth ones, we turn on the <b>edition
2145
* mode</b>. See how you can change each of the sheets on it, and be
2146
* sure to try holding the mouse pressed over one of the sheet
2147
* arrows. The forth one also starts with a custom time set:
2152
* The fifth, besides editable, has only the time @b units editable,
2153
* for hours, minutes and seconds. This exemplifies edit_mode_set():
2158
* Finally we just have to make our window visible and then run the
2159
* elm mainloop, starting to handle events and drawing operations.
2164
* See the full @ref clock_cxx_example.cc, whose window should look
2165
* like this picture:
2167
* @image html screenshots/clock_cxx_example.png
2168
* @image latex screenshots/clock_cxx_example.eps width=\textwidth
2169
* @example clock_cxx_example.cc
2173
* @page datetime_cxx_example Datetime Example with C++ binding
2174
* @dontinclude datetime_cxx_example.cc
2176
* This example places three Elementary Datetime widgets on a window,
2177
* each of them exemplifying the widget's different usage.
2179
* The first part consists of including the headers. In this
2180
* case we are only working with the Elementary C++ binding and thus
2181
* we need only to include him.
2183
* @skipline Elementary.hh
2185
* @attention If necessary the C and/or the C++ headers should be
2186
* include here as well.
2188
* Now we need to actually start the code and set the elm_policy,
2189
* which defines for a given policy group/identifier a new policy's
2190
* value, respectively. In this example the only policy we need to
2191
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
2193
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
2196
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
2197
* application's last window is closed;
2199
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
2200
* application's last window is hidden;
2203
* @until elm_policy_set
2205
* As you can see, the policy we chose was to quit when the last win
2206
* is hidden as opposed to examples with the C bindings where we
2207
* perpetually set it to quit when last win was closed. This changed
2208
* was necessary because in C++ binding as the elm mainloop stop
2209
* running all object are destroyed, references are unreferenced and
2210
* events are stopped at ELM_MAIN().
2212
* @see For more details consult elm_policy_set
2214
* Next step is creating an Elementary window, where win calls a
2215
* constructor and sets the type of the win to ELM_WIN_BASIC
2216
* (Elm_Win_Type), which is the indicated type for most of our
2217
* examples. Here we also set the title that will appear at the top of
2218
* our window and then the autohide state for win.
2220
* The autohide works similarly to @p autodel, automatically handling
2221
* "delete,request" signals when set to @p true, with the difference
2222
* that it will hide the window, instead of destroying it.
2224
* It is specially designed to work together with @p
2225
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
2226
* Elementary's main loop when all the windows are hidden.
2229
* @until autohide_set
2231
* @note @p autodel and @a autohide are not mutually exclusive. The
2232
* window will be destructed if both autodel and autohide is set to @p
2233
* EINA_TRUE or @p true.
2235
* Now we construct the elm background and for this we use the C++
2236
* method below, setting it's parent.
2238
* @skipline ::elm::bg
2240
* To better understand, the function @c size_hint_weight_set for C++
2241
* bindings originated from C bindings function
2242
* evas_object_size_hint_weight_set, that is EFL Evas type function.
2243
* With this function we set the hints for an object's weight. The
2246
* @li x - Nonnegative double value to use as horizontal weight hint.
2248
* @li y - Nonnegative double value to use as vertical weight hint.
2250
* This is not a size enforcement in any way, it's just a hint that
2251
* should be used whenever appropriate. This is a hint on how a
2252
* container object should resize a given child within its area.
2254
* Containers may adhere to the simpler logic of just expanding the
2255
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
2256
* helper weight macro in the EFL Evas Documentation) or the complete
2257
* one of taking each child's weight hint as real weights to how much
2258
* of its size to allocate for them in each axis. A container is
2259
* supposed to, after normalizing the weights of its children (with
2260
* weight hints), distribute the space it has to layout them by those
2261
* factors – most weighted children get larger in this process than
2264
* @skipline weight_set
2266
* @note Default weight hint values are 0.0, for both axis.
2268
* Now we add the background as a resize_object to win informing that
2269
* when the size of the win changes so should the background's
2270
* size. And finally we make it visible.
2273
* @until visibility_set
2275
* @remarks If a color it's not setted the default color will be used.
2277
* A box arranges objects in a linear fashion, governed by a layout
2278
* function that defines the details of this arrangement. The box will
2279
* use an internal function to set the layout to a single row,
2280
* vertical by default.
2282
* Now let's create the box with the C++ binding method, passing our
2283
* window object as parent. Using Evas weight_set function again to
2284
* hint on how a container object should resize a given child within
2287
* @skipline elm::box
2290
* Then we add the box as a resize-object to win informing that when
2291
* the size of the win changes so should the box's size. Remember
2292
* always to set the box visibility to true.
2297
* The first of them is <b>"only Date display"</b>. We will create it
2298
* using the C++ method below. The weight hint works with datetime the
2299
* same as it did with background and box.
2304
* Now we have to The function @c size_hint_align_set for C++ bindings
2305
* originated from C bindings function
2306
* evas_object_size_hint_align_set, that is EFL Evas type
2307
* function. With this function we set the hints for an object's
2308
* alignment. The parameters are:
2310
* @li x - Double, ranging from 0.0 to 1.0 or with the special value
2311
* EVAS_HINT_FILL, to use as horizontal alignment hint.
2313
* @li y - Double, ranging from 0.0 to 1.0 or with the special value
2314
* EVAS_HINT_FILL, to use as vertical alignment hint.
2316
* These are hints on how to align an object inside the boundaries of
2317
* a container/manager. Accepted values are in the 0.0 to 1.0 range,
2318
* with the special value EVAS_HINT_FILL used to specify "justify" or
2319
* "fill" by some users. In this case, maximum size hints should be
2320
* enforced with higher priority, if they are set. Also, any padding
2321
* hint set on objects should add up to the alignment space on the
2322
* final scene composition.
2324
* For the horizontal component, 0.0 means to the left, 1.0 means to
2325
* the right. Analogously, for the vertical component, 0.0 to the top,
2326
* 1.0 means to the bottom.
2328
* This is not a size enforcement in any way, it's just a hint that
2329
* should be used whenever appropriate.
2333
* @note Default alignment hint values are 0.5, for both axis.
2335
* An important feature for the datetime is the setting of what we
2336
* want it to display. We can achieve that by using:
2338
* @p field_visible_set ( Elm_Datetime_Field_Type fieldtype_, bool
2343
* @li @p fieldtype_: type of the field, supports 6 fields:
2345
* @p ELM_DATETIME_YEAR: Indicates Year field.
2347
* @p ELM_DATETIME_MONTH: Indicates Month field.
2349
* @p ELM_DATETIME_DATE: Indicates Date field.
2351
* @p ELM_DATETIME_HOUR: Indicates Hour field,
2353
* @p ELM_DATETIME_MINUTE: Indicates Minute field.
2355
* @p ELM_DATETIME_AMPM: Indicates AM/PM field.
2357
* @li @p visible_: @p true field can be visible, @p false otherwise.
2359
* @attention Setting this API True does not ensure that the field is
2360
* visible, apart from this, the field's format must be present in
2361
* Datetime overall format. If a field's visibility is set to False
2362
* then it won't appear even though its format is present in overall
2363
* format. So if and only if this API is set true and the
2364
* corresponding field's format is present in Datetime format, the
2367
* @note By default the field visibility is set to @p true.
2369
* For this first datetime we are setting the HOUR, MINUTE and AM/PM
2370
* to not be visible, doing this we'll display in our datetime the
2371
* year, month and date.
2373
* @note Hour format 12hr(1-12) or 24hr(0-23) display can be selected
2374
* by setting the corresponding user format. The corresponding Month
2375
* and AM/PM strings are displayed according to the system’s language
2381
* When using the elm box the packing method of the subobj - datetime
2382
* in this case - should be defined. There are four possible methods:
2384
* @li @c pack_start(subobj_) - Add an object to the beginning of the
2385
* pack list. Pack @c subobj_ into the box obj, placing it first in
2386
* the list of children objects. The actual position the object will
2387
* get on screen depends on the layout used. If no custom layout is
2388
* set, it will be at the top or left, depending if the box is
2389
* vertical or horizontal, respectively.
2391
* @li @c pack_end(subobj_) - Add an object at the end of the pack
2392
* list. Pack @c subobj_ into the box obj, placing it last in the list
2393
* of children objects. The actual position the object will get on
2394
* screen depends on the layout used. If no custom layout is set, it
2395
* will be at the bottom or right, depending if the box is vertical or
2396
* horizontal, respectively.
2398
* @li @c pack_before(subobj_, before_) - Adds an object to the box
2399
* before the indicated object. This will add the @c subobj_ to the
2400
* box indicated before the object indicated with @c before_. If
2401
* before is not already in the box, results are undefined. Before
2402
* means either to the left of the indicated object or above it
2403
* depending on orientation.
2405
* @li @c pack_after(subobj_, after_) - Adds an object to the box
2406
* after the indicated object. This will add the @c subobj_ to the box
2407
* indicated after the object indicated with @c after_. If after is
2408
* not already in the box, results are undefined. After means either
2409
* to the right of the indicated object or below it depending on
2412
* In this and most examples we use pack_end by choice and
2413
* practicality. In this part of the code we also make datetime
2419
* For our second datetime, we'll also set the size hints weight and
2420
* align, but in this case, the fields YEAR, MONTH and DATE will be not
2421
* visible, and thus displaying in our datetime the hour, minute and
2422
* AM/PM. Finally we choose it's packing method and set the visibility
2423
* of datetime to @p true.
2428
* For our third and last datetime, we setted the weight and align as
2429
* before, chose our packing method and made it visible. Note that in
2430
* this case we didn't exclude any type of field leaving all visible.
2435
* And finally, we set our win's visibility and start the elm
2436
* mainloop, starting to handle events and drawing operations.
2441
* See the full @ref datetime_cxx_example.cc .
2443
* This example should look like:
2445
* @image html screenshots/datetime_cxx_example.png
2446
* @image latex screenshots/datetime_cxx_example.eps width=\textwidth
2448
* @example datetime_cxx_example.cc
2452
* @page glview_cxx_example_01 Glview example with C++ Binding
2453
* @dontinclude glview_cxx_example_01.cc
2455
* In this example we'll illustrate how to use Glview and it's
2458
* The first part consists of including the headers. In this case we
2459
* need to include @p Elementary.hh, @p Evas_GL.h and @p stdio.h.
2461
*@li @p Elementary.hh: library for Elementary with support for C++
2464
*@li @p Evas_GL.h: has functions that are used to do OpenGL rendering
2465
* on Evas, Evas allows us to use OpenGL to render to specially set up
2466
* image objects, which act as render target surfaces.
2468
*@li @p stdio.h is a C library with functions tha perform
2469
* Input/Output operations.
2471
* @skip Elementary.hh
2474
* Continuing with the code, at this point we create a GL related
2477
*@li @p Evas_GL_API that is the structure type of the Evas GL API object
2478
* that contains the GL APIs to be used in Evas GL.
2480
*@li @p GLuint one of the pre-defined types of OpenGL which is a unsigned binary integer.
2482
*@li @p int AKA @p int.
2487
* Here we're simply initializing a type float, that we named red.
2491
* In this example we'll need a type C helper function to load shaders
2492
* from a shader source.
2497
* Inside this function we create the shader objectand load/compile
2501
* @until return shader;
2503
* Completing our load shader function.
2507
* This example will also need a function to initialize the shader and
2513
* In this function we load the vertex/fragment shaders, create the
2514
* program object and finish our function.
2520
* We need the following callbacks:
2522
* @li initialize callback: that get called once for
2529
* @li delete callback: gets called when glview is deleted;
2535
* @li resize callback: gets called every time object is resized;
2540
* @li draw callback: is where all the main GL rendering happens.
2543
* @until COLOR_BUFFER
2545
* Inside this callback, we'll draw a triangle.
2550
* Still inside as an option we are going to flush the GL pipeline and
2556
* We create @p _anim to notify that glview has changed so it can
2562
* Now that we finished with the GL preparations, we'll start the main
2563
* code and initialize our GLData pointer object to NULL and run a
2564
* check just in case.
2569
* Let's set the elm_policy, which defines for a given policy
2570
* group/identifier a new policy's value, respectively. In this
2571
* example the only policy we need to set a value for is @c
2572
* ELM_POLICY_QUIT, possibles values for it are:
2574
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
2577
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
2578
* application's last window is closed;
2580
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
2581
* application's last window is hidden;
2583
* @skipline elm_policy_set
2585
* As you can see, the policy we chose was to quit when the last win
2586
* is hidden as opposed to examples with the C bindings where we
2587
* perpetually set it to quit when last win was closed. This changed
2588
* was necessary because in C++ binding as the elm mainloop stop
2589
* running all object are destroyed, references are unreferenced and
2590
* events are stopped at ELM_MAIN().
2592
* @see For more details consult elm_policy_set
2594
* Next step is creating an elementary window, in this example we use
2595
* the C++ binding method with the elm_win_util_standard_add that is a
2596
* elm_win_legacy function, better explained below. And then we set
2597
* the autohide state for it.
2599
* @p elm_win_util_standard_add (const char *name, const char *tittle)
2600
* Adds a window object with standard setup.
2603
* @li @p name - The name of the window;
2605
* @li @p title - The title for the window.
2607
* This creates a window but also puts in a standard background with
2608
* @p elm_bg_add(), as well as setting the window title to @p
2609
* title. The window type created is of type @c ELM_WIN_BASIC, with
2610
* the @c NULL as the parent widget. Returns the created object or @c
2613
* The autohide works similarly to @p autodel, automatically handling
2614
* "delete,request" signals when set to @p true, with the difference
2615
* that it will hide the window, instead of destroying it.
2617
* It is specially designed to work together with @p
2618
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
2619
* Elementary's main loop when all the windows are hidden.
2622
* @until autohide_set
2624
* @note @p autodel and @a autohide are not mutually exclusive. The
2625
* window will be destructed if both autodel and autohide is set to @p
2626
* EINA_TRUE or @p true.
2628
* Now let's create a box with the C++ binding method, passing our
2629
* window object as parent, we'll use this box to contain our glview
2634
* To better understand, the function @c size_hint_weight_set for C++
2635
* bindings originated from C bindings function
2636
* evas_object_size_hint_weight_set, that is EFL Evas type function.
2637
* With this function we set the hints for an object's weight. The
2640
* @li x - Nonnegative double value to use as horizontal weight hint.
2642
* @li y - Nonnegative double value to use as vertical weight hint.
2644
* This is not a size enforcement in any way, it's just a hint that
2645
* should be used whenever appropriate. This is a hint on how a
2646
* container object should resize a given child within its area.
2648
* Containers may adhere to the simpler logic of just expanding the
2649
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
2650
* helper weight macro in the EFL Evas Documentation) or the complete
2651
* one of taking each child's weight hint as real weights to how much
2652
* of its size to allocate for them in each axis. A container is
2653
* supposed to, after normalizing the weights of its children (with
2654
* weight hints), distribute the space it has to layout them by those
2655
* factors – most weighted children get larger in this process than
2658
* @skipline weight_set
2660
* @note Default weight hint values are 0.0, for both axis.
2662
* Then we add the box as a resize-object to win informing that when
2663
* the size of the win changes so should the box's size. Remember
2664
* always to set the box visibility to true.
2669
* In this part we'll create a new elm glview, using the C++ method,
2670
* in this case it requires that we set @p Evas_GL_Context_Version
2671
* with the version_constructor. @p Evas_GL_Context_Version is a
2672
* enumeration that defines the available OpenGL ES version numbers,
2673
* it can be used to create OpenGL-ES 1.1 contexts.
2678
* The function size_hint_weight_set works with glview the same way as
2679
* with box, for more, search above.
2681
* The function @c size_hint_align_set for C++ bindings originated
2682
* from C bindings function evas_object_size_hint_align_set, that is
2683
* EFL Evas type function. With this function we set the hints for an
2684
* object's alignment. The parameters are:
2686
* @li x - Double, ranging from 0.0 to 1.0 or with the special value
2687
* EVAS_HINT_FILL, to use as horizontal alignment hint.
2689
* @li y - Double, ranging from 0.0 to 1.0 or with the special value
2690
* EVAS_HINT_FILL, to use as vertical alignment hint.
2692
* These are hints on how to align an object inside the boundaries of
2693
* a container/manager. Accepted values are in the 0.0 to 1.0 range,
2694
* with the special value EVAS_HINT_FILL used to specify "justify" or
2695
* "fill" by some users. In this case, maximum size hints should be
2696
* enforced with higher priority, if they are set. Also, any padding
2697
* hint set on objects should add up to the alignment space on the
2698
* final scene composition.
2700
* For the horizontal component, 0.0 means to the left, 1.0 means to
2701
* the right. Analogously, for the vertical component, 0.0 to the top,
2702
* 1.0 means to the bottom.
2704
* This is not a size enforcement in any way, it's just a hint that
2705
* should be used whenever appropriate.
2707
* @note Default alignment hint values are 0.5, for both axis.
2709
* @skipline align_set
2711
* Mode is simply for supporting alpha, depth buffering and stencil
2717
* Resize policy tells glview what to do with the surface when it
2718
* resizes. ELM_VIEW_RESIZE_POLICY_RECREATE will tell it to destroy
2719
* the current surface and recreate it to the new size.
2723
* Render policy tells glview how it would like glview to render gl
2724
* code. ELM_GLVIEW_RENDER_POLICY_ON_DEMAND will have the gl calls
2725
* called in the pixel_get callback, which only gets called if the
2726
* object is visible, hence ON_DEMAND. ALWAYS mode renders it despite
2727
* the visibility of the object.
2731
* Now we'll register our callbacks.
2736
* When using the elm box the packing method of the subobj - glview in
2737
* this case - should be defined. There are four possible methods:
2739
* @li @c pack_start(subobj_) - Add an object to the beginning of the
2740
* pack list. Pack @c subobj_ into the box obj, placing it first in
2741
* the list of children objects. The actual position the object will
2742
* get on screen depends on the layout used. If no custom layout is
2743
* set, it will be at the top or left, depending if the box is
2744
* vertical or horizontal, respectively.
2746
* @li @c pack_end(subobj_) - Add an object at the end of the pack
2747
* list. Pack @c subobj_ into the box obj, placing it last in the list
2748
* of children objects. The actual position the object will get on
2749
* screen depends on the layout used. If no custom layout is set, it
2750
* will be at the bottom or right, depending if the box is vertical or
2751
* horizontal, respectively.
2753
* @li @c pack_before(subobj_, before_) - Adds an object to the box
2754
* before the indicated object. This will add the @c subobj_ to the
2755
* box indicated before the object indicated with @c before_. If
2756
* before is not already in the box, results are undefined. Before
2757
* means either to the left of the indicated object or above it
2758
* depending on orientation.
2760
* @li @c pack_after(subobj_, after_) - Adds an object to the box
2761
* after the indicated object. This will add the @c subobj_ to the box
2762
* indicated after the object indicated with @c after_. If after is
2763
* not already in the box, results are undefined. After means either
2764
* to the right of the indicated object or below it depending on
2767
* In this and most examples we use pack_end by choice and
2768
* practicality, in this part of the code we also make glview visible
2774
* For a simple demonstration of the animation we'll have to use
2775
* ecore::animator. As long as tou trigger an update on the image via
2776
* @p changed_set() it will be updated.
2781
* If you delete gl, this animator will keep running trying to access
2782
* gl so it's better to delete this animator with
2783
* ecore_animator_del(), as seen inside the lambda function.
2785
* @skipline callback_del
2787
* @note To learn more about Lambda Function and its use in Elementary
2788
* consult @ref lambda.
2790
* We're going to add a "OK" button to end the program. First step is
2791
* to create it using the C++ method, setting it's parent.
2795
* Second, set the text, alignment and weight hints, the hints work
2796
* the same as with box and glview.
2801
* Pack our button in the same box as glview and set the visibility for
2807
* As a final step for our button, we are going to add a clicked
2808
* callback, using again Lambda Type Function.
2812
* @note To learn more about Lambda Function and its use in Elementary
2813
* consult @ref lambda.
2815
* Now we only have to set the size for our window and make it
2819
* @until visibility_set
2821
* And finally, start the elm mainloop, starting to handle events and
2822
* drawing operations.
2827
* See full code for this example @ref glview_cxx_example_01.cc "here" .
2829
* @example glview_cxx_example_01.cc
2833
* @page hoversel_cxx_example_01 Hoversel example with C++ Binding
2834
* @dontinclude hoversel_cxx_example_01.cc
2836
* In this example we'll create a hoversel with 3 items, one with a
2837
* label but no icon and two with both a label and an icon. Every item
2838
* that is clicked will be deleted, but everytime the hoversel is
2839
* activated we will also add an item. In addition our first item will
2840
* print all items when clicked and our third item will clear all
2841
* items in the hoversel.
2843
* The first part consists of including the headers. We'll include @p
2844
* Elementary.hh, @p Eina.hh and @p Evas.hh, that are C++ bindings
2845
* that are needed in this example.
2850
* Before our main code we'll need the following callbacks:
2852
*@li @p _print_items: callback for our first item which prints all
2853
* items in the hoversel.
2857
*@li @p _free: callback that frees the allocated memory.
2861
* Starting the main code and initializing Eina C++ Lybrary, always
2862
* initiate Eina when included.
2867
* Now let's set the elm_policy, which defines for a given policy
2868
* group/identifier a new policy's value, respectively. In this
2869
* example the only policy we need to set a value for is @c
2870
* ELM_POLICY_QUIT, possibles values for it are:
2872
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
2875
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
2876
* application's last window is closed;
2878
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
2879
* application's last window is hidden;
2881
* @skipline elm_policy_set
2883
* As you can see, the policy we chose was to quit when the last win
2884
* is hidden as opposed to examples with the C bindings where we
2885
* perpetually set it to quit when last win was closed. This changed
2886
* was necessary because in C++ binding as the elm mainloop stop
2887
* running all object are destroyed, references are unreferenced and
2888
* events are stopped at ELM_MAIN().
2890
* @see For more details consult elm_policy_set
2892
* Next step is creating an elementary window, in this example we use
2893
* the C++ binding method with the elm_win_util_standard_add that is a
2894
* elm_win_legacy function, better explained below. And then we set
2895
* the autohide state for it.
2897
* @p elm_win_util_standard_add (const char *name, const char *tittle)
2898
* Adds a window object with standard setup.
2901
* @li @p name - The name of the window;
2903
* @li @p title - The title for the window.
2905
* This creates a window but also puts in a standard background with
2906
* @p elm_bg_add(), as well as setting the window title to @p
2907
* title. The window type created is of type @c ELM_WIN_BASIC, with
2908
* the @c NULL as the parent widget. Returns the created object or @c
2911
* The autohide works similarly to @p autodel, automatically handling
2912
* "delete,request" signals when set to @p true, with the difference
2913
* that it will hide the window, instead of destroying it.
2915
* It is specially designed to work together with @p
2916
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
2917
* Elementary's main loop when all the windows are hidden.
2920
* @until autohide_set
2922
* @note @p autodel and @a autohide are not mutually exclusive. The
2923
* window will be destructed if both autodel and autohide is set to @p
2924
* EINA_TRUE or @p true.
2926
* Next we'll create a red evas::rectangle to use as the icon of our
2927
* hoversel, for thus using the C++ method, setting the color and
2928
* making it visible.
2933
* And now we create our hoversel and set some of it's properties. We
2934
* set @p win as its parent, set it to be vertical and give it a label
2935
* and content, that will work as icon:
2940
* Next we will add callbacks to be called for the first and third:
2945
* We also set a pair of callbacks to be called whenever any item is
2946
* selected or when the hoversel is activated, for this we'll use
2947
* Lambda type function, @p add_item is called when the hoversel is
2948
* activated and adds an item to the hoversel. Note that since we
2949
* allocate memory for the item we need to know when the item dies so
2950
* we can free that memory.
2955
* @see For more on Lambda check @ref lambda "here"
2957
* Finishing with hoversel we set its size, position and make it
2963
* In our second hoversel we'll add a button and for this we need
2964
* create it using C++ method, set a text, add a callback for when
2965
* button is clicked. This callback is type Lambda, it will clear
2966
* hoversel when clicked.
2971
* Concluding our button options, we will set the size, position and
2977
* Now we set the size for the window, making it visible in the end:
2980
* @until visibility_set
2982
* Finally we just have to start the elm mainloop, starting to handle
2983
* events and drawing operations.
2988
* Our example will look like this:
2990
* @image html screenshots/hoversel_cxx_example_01.png
2991
* @image latex screenshots/hoversel_cxx_example_01.eps width=\textwidth
2993
* @example hoversel_cxx_example_01.cc
2997
* @page icon_cxx_example_01 Icon Example with C++ binding
2998
* @dontinclude icon_cxx_example_01.cc
3000
* This example is as simple as possible. An icon object will be added
3001
* to the window over a blank background, and set to be resizable
3002
* together with the window. All the options set through the example
3003
* will affect the behavior of this icon.
3005
* The first part consists of including the headers. In this case we
3006
* are only working with the Elementary C++ binding and thus we need
3007
* only to include him.
3009
* @skipline Elementary.hh
3011
* @attention If necessary the C and/or the C++ headers should be
3012
* include here as well.
3014
* Now we need to actually start the code and set the elm_policy,
3015
* which defines for a given policy group/identifier a new policy's
3016
* value, respectively. In this example the only policy we need to set
3017
* a value for is @c ELM_POLICY_QUIT, possibles values for it are:
3019
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
3022
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
3023
* application's last window is closed;
3025
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
3026
* application's last window is hidden;
3029
* @until elm_policy_set
3031
* As you can see, the policy we chose was to quit when the last win
3032
* is hidden as opposed to examples with the C bindings where we
3033
* perpetually set it to quit when last win was closed. This changed
3034
* was necessary because in C++ binding as the elm mainloop stop
3035
* running all object are destroyed, references are unreferenced and
3036
* events are stopped at ELM_MAIN().
3038
* @see For more details consult elm_policy_set
3040
* Next step is creating an elementary window, in this example we use
3041
* the C++ binding method with the elm_win_util_standard_add that is a
3042
* elm_win_legacy function, better explained below. And then we set
3043
* the autohide state for it.
3045
* @p elm_win_util_standard_add (const char *name, const char *tittle)
3046
* Adds a window object with standard setup.
3049
* @li @p name - The name of the window;
3051
* @li @p title - The title for the window.
3053
* This creates a window but also puts in a standard background with
3054
* @p elm_bg_add(), as well as setting the window title to @p
3055
* title. The window type created is of type @c ELM_WIN_BASIC, with
3056
* the @c NULL as the parent widget. Returns the created object or @c
3059
* The autohide works similarly to @p autodel, automatically handling
3060
* "delete,request" signals when set to @p true, with the difference
3061
* that it will hide the window, instead of destroying it.
3063
* It is specially designed to work together with @p
3064
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
3065
* Elementary's main loop when all the windows are hidden.
3068
* @until autohide_set
3070
* @note @p autodel and @a autohide are not mutually exclusive. The
3071
* window will be destructed if both autodel and autohide is set to @p
3072
* EINA_TRUE or @p true.
3074
* Now we construct the elm icon and for this we use the C++ method
3075
* below, setting it's parent. An icon object is used to display
3076
* standard icon images ("delete", "edit", "arrows", etc.) or images
3077
* coming from a custom file (PNG, JPG, EDJE, etc.), on icon contexts.
3079
* @skipline ::elm::icon
3081
* The icon image requested can be in the Elementary theme in use, or
3082
* in the freedesktop.org theme paths. It's possible to set the order
3083
* of preference from where an image will be fetched and for that
3084
* we'll use the function @ order_lookup_set(order_) that will be use
3085
* by standard_set. Possibles values for @p order_ are:
3087
* @li @p ELM_ICON_LOOKUP_FDO_THEME: icon look up order is freedesktop
3090
* @li @p ELM_ICON_LOOKUP_THEME_FDO: icon look up order is theme then
3093
* @li @p ELM_ICON_LOOKUP_FDO: icon look up order is only freedesktop;
3095
* @li @p ELM_ICON_LOOKUP_THEME: icon look up order is only theme;
3099
* Now that we setted the order value we can set the standard "home"
3100
* icon, chosen for this example.
3102
* @skipline standard
3104
* An interesting thing is that after setting this, it's possible to
3105
* check where in the filesystem is the theme used by this icon, and
3106
* the name of the group used, using file_get.
3111
* We can also get the name of the standard icon that we setted
3117
* We can now go setting our options.
3119
* no_scale_set() is used just to set this value to true as we don't
3120
* actually want to scale our icon, just resize it.
3122
* resizable_set() is used to allow the icon to be resized to a size
3123
* smaller than the original one, but not to a size bigger than it.
3125
* smooth_set() will disable the smooth scaling, so the scale
3126
* algorithm used to scale the icon to the new object size is going to
3127
* be faster, but with a lower quality.
3129
* fill_outside_set() is used to ensure that the icon will fill the
3130
* entire area available to it, even if keeping the aspect ratio. The
3131
* icon will overflow its width or height (any of them that is
3132
* necessary) to the object area, instead of resizing the icon down
3133
* until it can fit entirely in this area.
3135
* This is the code for setting these options:
3137
* @until fill_outside
3139
* However, if you try this example you may notice that this image is
3140
* not being affected by all of these options. This happens because
3141
* the used icon will be from elementary theme, and thus it has its
3142
* own set of options like smooth scaling and fill_outside
3143
* options. You can change the "home" icon to use some image (from
3144
* your system) and see that then those options will be respected.
3146
* To better understand, the function @c size_hint_weight_set for C++
3147
* bindings originated from C bindings function
3148
* evas_object_size_hint_weight_set, that is EFL Evas type function.
3149
* With this function we set the hints for an object's weight. The
3152
* @li x - Nonnegative double value to use as horizontal weight hint.
3154
* @li y - Nonnegative double value to use as vertical weight hint.
3156
* This is not a size enforcement in any way, it's just a hint that
3157
* should be used whenever appropriate.
3159
* This is a hint on how a container object should resize a given
3160
* child within its area.
3162
* Containers may adhere to the simpler logic of just expanding the
3163
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
3164
* helper weight macro in the EFL Evas Documentation) or the complete
3165
* one of taking each child's weight hint as real weights to how much
3166
* of its size to allocate for them in each axis. A container is
3167
* supposed to, after normalizing the weights of its children (with
3168
* weight hints), distribute the space it has to layout them by those
3169
* factors – most weighted children get larger in this process than
3172
* @skipline weight_set
3174
* @note Default weight hint values are 0.0, for both axis.
3176
* Now we add the icon as a resize_object to win informing that
3177
* when the size of the win changes so should the icon's
3178
* size. And finally we make icon visible.
3180
* Now we set the size for the window, making it visible in the end:
3183
* @until visibility_set
3185
* Finally we just have to start the elm mainloop, starting to handle
3186
* events and drawing operations.
3191
* The full code for this example can be found at @ref icon_cxx_example_01.cc
3193
* This example will look like this:
3195
* @image html screenshots/icon_cxx_example_01.png
3196
* @image latex screenshots/icon_cxx_example_01.eps width=\textwidth
3198
* @example icon_cxx_example_01.cc
3202
* @page menu_cxx_example_01 Menu Example with C++ Binding
3203
* @dontinclude menu_cxx_example_01.cc
3205
* This example shows how to create a menu with regular items, object
3206
* items, submenus and how to delete items from a menu.
3208
* The first part consists of including the headers. We'll include @p
3209
* Elementary.hh, @p Eina.hh and @p Evas.hh, that are C++ bindings
3210
* that are needed in this example.
3215
* Starting the main code and initializing Eina C++ Lybrary, always
3216
* initiate Eina when included. We'll also initialize a couple of
3222
* Now let's set the elm_policy, which defines for a given policy
3223
* group/identifier a new policy's value, respectively. In this
3224
* example the only policy we need to set a value for is @c
3225
* ELM_POLICY_QUIT, possibles values for it are:
3227
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
3230
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
3231
* application's last window is closed;
3233
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
3234
* application's last window is hidden;
3236
* @skipline elm_policy_set
3238
* As you can see, the policy we chose was to quit when the last win
3239
* is hidden as opposed to examples with the C bindings where we
3240
* perpetually set it to quit when last win was closed. This changed
3241
* was necessary because in C++ binding as the elm mainloop stop
3242
* running all object are destroyed, references are unreferenced and
3243
* events are stopped at ELM_MAIN().
3245
* @see For more details consult elm_policy_set
3247
* Next step is creating an elementary window, in this example we use
3248
* the C++ binding method with the elm_win_util_standard_add that is a
3249
* elm_win_legacy function, better explained below. And then we set
3250
* the autohide state for it.
3252
* @p elm_win_util_standard_add (const char *name, const char *tittle)
3253
* Adds a window object with standard setup.
3256
* @li @p name - The name of the window;
3258
* @li @p title - The title for the window.
3260
* This creates a window but also puts in a standard background with
3261
* @p elm_bg_add(), as well as setting the window title to @p
3262
* title. The window type created is of type @c ELM_WIN_BASIC, with
3263
* the @c NULL as the parent widget. Returns the created object or @c
3266
* The autohide works similarly to @p autodel, automatically handling
3267
* "delete,request" signals when set to @p true, with the difference
3268
* that it will hide the window, instead of destroying it.
3270
* It is specially designed to work together with @p
3271
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
3272
* Elementary's main loop when all the windows are hidden.
3275
* @until autohide_set
3277
* @note @p autodel and @a autohide are not mutually exclusive. The
3278
* window will be destructed if both autodel and autohide is set to @p
3279
* EINA_TRUE or @p true.
3281
* Next we'll create a evas::rectangle to use as the icon of our menu
3282
* for thus using the C++ method, adding our rect as a resize-object
3283
* to win informing that when the size of the win changes so should
3289
* We'll also set, for rect, the hint for it's minimum size, it's
3290
* color and making it visible.
3295
* Creating the menu using the C++ method, setting it's parent and
3296
* adding an item to this menu. We are going to add more items, but
3297
* these icons are going to have a parent, which will put them in a
3303
* We'll add a button to a menu_item, where this button will delete
3304
* the first item of our sub-menu when clicked, we'll do this
3305
* using @p elm_object_item_content_set().
3308
* @until content_set
3310
* Now, for the callback that will be used in this button we're use
3311
* lambda type function and then add as clicked callback to button.
3316
* @see To learn more about consult @ref lambda.
3318
* We now add a separator and three more regular items:
3324
* We now add another item, however this time it won't go the sub-menu
3325
* and it'll be disabled:
3327
* @until disabled_set
3329
* To make sure that our menu is shown whenever the window is
3330
* clicked, we use the following callback, also lambda:
3335
* Finally. we just make menu visible, set a size for our window
3336
* making it visible and then start the elm mainloop, starting to
3337
* handle events and drawing operations.
3342
* Our example will look like this:
3344
* @image html screenshots/menu_cxx_example_01.png
3345
* @image latex screenshots/menu_cxx_example_01.eps width=\textwidth
3347
* @example menu_cxx_example_01.cc
3351
* @page popup_cxx_example_01 Popup example with C++ Binding
3352
* @dontinclude popup_cxx_example_01.cc
3354
* The first part consists of including the headers. In this
3355
* case we are only working with the Elementary C++ binding and thus
3356
* we need only to include him.
3358
* @skipline Elementary.hh
3360
* @attention If necessary the C and/or the C++ headers should be
3361
* include here as well.
3363
* Now we need to actually start the code and set the elm_policy,
3364
* which defines for a given policy group/identifier a new policy's
3365
* value, respectively. In this example the only policy we need to
3366
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
3368
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
3371
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
3372
* application's last window is closed;
3374
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
3375
* application's last window is hidden;
3378
* @until elm_policy_set
3380
* As you can see, the policy we chose was to quit when the last win
3381
* is hidden as opposed to examples with the C bindings where we
3382
* perpetually set it to quit when last win was closed. This changed
3383
* was necessary because in C++ binding as the elm mainloop stop
3384
* running all object are destroyed, references are unreferenced and
3385
* events are stopped at ELM_MAIN().
3387
* @see For more details consult elm_policy_set
3389
* Next step is creating an Elementary window, in this example we use
3390
* the C++ binding method with the elm_win_util_standard_add that is a
3391
* elm_win_legacy function, better explained below. And then we set
3392
* the autohide state for it.
3394
* @p elm_win_util_standard_add (const char *name, const char *tittle)
3395
* Adds a window object with standard setup.
3399
* @li @p name - The name of the window;
3401
* @li @p title - The title for the window.
3403
* This creates a window but also puts in a standard background with
3404
* @p elm_bg_add(), as well as setting the window title to @p
3405
* title. The window type created is of type @c ELM_WIN_BASIC, with
3406
* the @c NULL as the parent widget. Returns the created object or @c
3409
* The autohide works similarly to @p autodel, automatically handling
3410
* "delete,request" signals when set to @p true, with the difference
3411
* that it will hide the window, instead of destroying it.
3413
* It is specially designed to work together with @p
3414
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
3415
* Elementary's main loop when all the windows are hidden.
3418
* @until autohide_set
3420
* @note @p autodel and @a autohide are not mutually exclusive. The
3421
* window will be destructed if both autodel and autohide is set to @p
3422
* EINA_TRUE or @p true.
3424
* Now let's create the label with the C++ binding method, passing our
3425
* window object as parent. We'll also set to this label the text that
3426
* we'll use later on the popup.
3431
* Using the same method we'll create our popup passing our window
3432
* object as parent. We'll also set the timeout to 3.0 seconds, label
3433
* as content, the title and visibility true for our popup.
3438
* Our popup will hide every time the lambda type function is called.
3439
* The lambda function get the popup object by reference and set it's
3440
* visibility to false, making it invisible. In this example we are
3441
* using @a std::bind to bind the parameters of our lambda function to
3442
* return as @a std::function object to popup_hide which was declare
3448
* To learn more consult @ref lambda.
3450
* In this example we'll add the popup_hide in the timeout callback
3451
* and the block_clicked callback. This results in hiding the popup in
3452
* maximum of 3.0 seconds or when the popup block is clicked.
3457
* Finally we just have to make our window visible and set it's size,
3458
* then run the elm mainloop, starting to handle events and drawing
3464
* This example will initially look like this:
3466
* @image html screenshots/popup_cxx_example_01.png
3467
* @image latex screenshots/popup_cxx_example_01.eps width=\textwidth
3469
* Once the popup is hidden after timeout:
3471
* @image html screenshots/popup_cxx_example_01_a.png
3472
* @image latex screenshots/popup_cxx_example_01_a.eps width=\textwidth
3474
* @example popup_cxx_example_01.cc
3478
* @page radio_cxx_example_01 Radio example with C++ Binding
3479
* @dontinclude radio_cxx_example_01.cc
3481
* In this example we will create 4 radios, and add them to the same
3482
* group. We will also have the radios in the group change the value
3483
* of a variable directly and have then print it when the value
3486
* The first part consists of including the headers. In this
3487
* case we are only working with the Elementary C++ binding and thus
3488
* we need only to include him.
3490
* @skipline Elementary.hh
3492
* @attention If necessary the C and/or the C++ headers should be
3493
* include here as well.
3495
* Now we need to actually start the code and set the elm_policy,
3496
* which defines for a given policy group/identifier a new policy's
3497
* value, respectively. In this example the only policy we need to
3498
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
3500
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
3503
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
3504
* application's last window is closed;
3506
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
3507
* application's last window is hidden;
3510
* @until elm_policy_set
3512
* As you can see, the policy we chose was to quit when the last win
3513
* is hidden as opposed to examples with the C bindings where we
3514
* perpetually set it to quit when last win was closed. This changed
3515
* was necessary because in C++ binding as the elm mainloop stop
3516
* running all object are destroyed, references are unreferenced and
3517
* events are stopped at ELM_MAIN().
3519
* @see For more details consult elm_policy_set
3521
* And move right to declaring a static variable, the one whose value
3522
* the radios will change:
3526
* Next step is creating an Elementary window, in this example we use
3527
* the C++ binding method with the elm_win_util_standard_add that is a
3528
* elm_win_legacy function, better explained below. And then we set
3529
* the autohide state for it.
3531
* @p elm_win_util_standard_add (const char *name, const char *tittle)
3532
* Adds a window object with standard setup.
3536
* @li @p name - The name of the window;
3538
* @li @p title - The title for the window.
3540
* This creates a window but also puts in a standard background with
3541
* @p elm_bg_add(), as well as setting the window title to @p
3542
* title. The window type created is of type @c ELM_WIN_BASIC, with
3543
* the @c NULL as the parent widget. Returns the created object or @c
3546
* The autohide works similarly to @p autodel, automatically handling
3547
* "delete,request" signals when set to @p true, with the difference
3548
* that it will hide the window, instead of destroying it.
3550
* It is specially designed to work together with @p
3551
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
3552
* Elementary's main loop when all the windows are hidden.
3555
* @until autohide_set
3557
* @note @p autodel and @a autohide are not mutually exclusive. The
3558
* window will be destructed if both autodel and autohide is set to @p
3559
* EINA_TRUE or @p true.
3561
* A box arranges objects in a linear fashion, governed by a layout
3562
* function that defines the details of this arrangement. The box will
3563
* use an internal function to set the layout to a single row,
3564
* vertical by default.
3566
* Now let's create the box with the C++ binding method, passing our
3567
* window object as parent and then setting box's layout as
3570
* @skipline elm::box
3573
* To better understand, the function @c size_hint_weight_set for C++
3574
* bindings originated from C bindings function
3575
* evas_object_size_hint_weight_set, that is EFL Evas type function.
3576
* With this function we set the hints for an object's weight. The
3579
* @li x - Nonnegative double value to use as horizontal weight hint.
3581
* @li y - Nonnegative double value to use as vertical weight hint.
3583
* This is not a size enforcement in any way, it's just a hint that
3584
* should be used whenever appropriate. This is a hint on how a
3585
* container object should resize a given child within its area.
3587
* Containers may adhere to the simpler logic of just expanding the
3588
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
3589
* helper weight macro in the EFL Evas Documentation) or the complete
3590
* one of taking each child's weight hint as real weights to how much
3591
* of its size to allocate for them in each axis. A container is
3592
* supposed to, after normalizing the weights of its children (with
3593
* weight hints), distribute the space it has to layout them by those
3594
* factors – most weighted children get larger in this process than
3597
* @skipline weight_set
3599
* @note Default weight hint values are 0.0, for both axis.
3601
* Now we add the box as a resize_object to win informing that when
3602
* the size of the win changes so should the box's size. And finally
3603
* we make it visible.
3606
* @until visibility_set
3608
* Radio is a widget that allows for one or more options to be
3609
* displayed and have the user choose only one of them. It contains an
3610
* indicator, an optional label and an optional icon object. While
3611
* it's possible to have a group of only one radio they, are normally
3612
* used in groups of 2 or more.
3614
* We will create the box with the C++ binding method, passing our
3615
* window object as parent and then setting box's layout as
3618
* And now we create a radio with the C++ binding method, passing our
3619
* window object as parent. Since this is the first radio in our group
3620
* we set the group to be the radio, so we can set the other radios in
3626
* We also set the text, then state value of this radio to 1 and
3627
* the value pointer to @p val, since val is @p 1 this has the
3628
* additional effect of setting the radio value to @p 1.
3633
* For this radio we choose the standard home icon, the icon will be
3634
* created with the same method and setting the icon as content of
3640
* When using the elm::box the packing method of the subobj - radio
3641
* in this case - should be defined. There are four possible methods:
3643
* @li @c pack_start(subobj_) - Add an object to the beginning of the
3644
* pack list. Pack @c subobj_ into the box obj, placing it first in
3645
* the list of children objects. The actual position the object will
3646
* get on screen depends on the layout used. If no custom layout is
3647
* set, it will be at the top or left, depending if the box is
3648
* vertical or horizontal, respectively.
3650
* @li @c pack_end(subobj_) - Add an object at the end of the pack
3651
* list. Pack @c subobj_ into the box obj, placing it last in the list
3652
* of children objects. The actual position the object will get on
3653
* screen depends on the layout used. If no custom layout is set, it
3654
* will be at the bottom or right, depending if the box is vertical or
3655
* horizontal, respectively.
3657
* @li @c pack_before(subobj_, before_) - Adds an object to the box
3658
* before the indicated object. This will add the @c subobj_ to the
3659
* box indicated before the object indicated with @c before_. If
3660
* before is not already in the box, results are undefined. Before
3661
* means either to the left of the indicated object or above it
3662
* depending on orientation.
3664
* @li @c pack_after(subobj_, after_) - Adds an object to the box
3665
* after the indicated object. This will add the @c subobj_ to the box
3666
* indicated after the object indicated with @c after_. If after is
3667
* not already in the box, results are undefined. After means either
3668
* to the right of the indicated object or below it depending on
3671
* In this and most examples we use pack_end by choice and
3674
* @skipline pack_end
3676
* The function size_hint_weight_set works with radio the same way
3677
* as with box, as above.
3679
* @skipline weight_set
3681
* The function @c size_hint_align_set for C++ bindings originated
3682
* from C bindings function evas_object_size_hint_align_set, that is
3683
* EFL Evas type function. With this function we set the hints for an
3684
* object's alignment. The parameters are:
3686
* @li x - Double, ranging from 0.0 to 1.0 or with the special value
3687
* EVAS_HINT_FILL, to use as horizontal alignment hint.
3689
* @li y - Double, ranging from 0.0 to 1.0 or with the special value
3690
* EVAS_HINT_FILL, to use as vertical alignment hint.
3692
* These are hints on how to align an object inside the boundaries of
3693
* a container/manager. Accepted values are in the 0.0 to 1.0 range,
3694
* with the special value EVAS_HINT_FILL used to specify "justify" or
3695
* "fill" by some users. In this case, maximum size hints should be
3696
* enforced with higher priority, if they are set. Also, any padding
3697
* hint set on objects should add up to the alignment space on the
3698
* final scene composition.
3700
* For the horizontal component, 0.0 means to the left, 1.0 means to
3701
* the right. Analogously, for the vertical component, 0.0 to the top,
3702
* 1.0 means to the bottom.
3704
* This is not a size enforcement in any way, it's just a hint that
3705
* should be used whenever appropriate.
3707
* @skipline align_set
3709
* @note Default alignment hint values are 0.5, for both axis.
3711
* To end the settings of radio we'll make it visible and with our
3712
* lambda type function we output the current value of @p val. In this
3713
* example we are using @a std::bind to bind the parameters of our
3714
* lambda function to return as @a std::function object to @p cb_val
3715
* which was declare as @p auto. Now we just have to add @p cb_val as
3716
* changed radio callback of our radio.
3721
* @see To learn more consult @ref lambda.
3723
* The creation of our second radio is almost identical, using the
3724
* same method we create radio2 passing win as parent. We also set the
3725
* text, then state value of this radio to 2 and the value pointer to
3726
* @p val. This radio will be added in the same group as the first
3732
* Then we set the standard file icon, the icon will be created with
3733
* the same method and then set the icon as content of radio.
3738
* As before, we set packing method of radio2 in the box, the weight,
3739
* alignment and visibility of radio2. Then add cb_val as callback
3740
* when the radio changes.
3745
* For our third and fourth radios we'll omit the icon and set the
3746
* value to 3 and 4, respectively, we'll also add them to the group of
3750
* @until radio4.callback
3752
* Finally we just have to make our window visible and set it's size,
3753
* then run the elm mainloop, starting to handle events and drawing
3759
* The full code for this example can be found at @ref radio_cxx_example_01.cc
3761
* The example will look like this:
3763
* @image html screenshots/radio_cxx_example_01.png
3764
* @image latex screenshots/radio_cxx_example_01.eps width=\textwidth
3766
* @example radio_cxx_example_01.cc
3770
* @page separator_cxx_example_01 Separator with C++ Binding
3771
* @dontinclude separator_cxx_example_01.cc
3773
* Separator is a very thin object used to separate other objects,
3774
* which can be vertical or horizontal.
3776
* This example shows how to create a window and separate in two
3777
* parts, each one will be filled with a background color to show the
3778
* division. The @a separator is used to visually mark the division
3779
* between two parts.
3781
* The first part consists of including the headers. In this case we
3782
* are only working with the Elementary and Evas C++ bindings.
3784
* @skip Elementary.hh
3787
* @attention If necessary the C and/or the C++ headers should be
3788
* include here as well.
3790
* Now we need to actually start the code and set the elm_policy,
3791
* which defines for a given policy group/identifier a new policy's
3792
* value, respectively. In this example the only policy we need to
3793
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
3795
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
3798
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
3799
* application's last window is closed;
3801
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
3802
* application's last window is hidden;
3804
* @n @skip EAPI_MAIN int
3805
* @until elm_policy_set
3807
* As you can see, the policy we chose was to quit when the last win
3808
* is hidden as opposed to examples with the C bindings where we
3809
* perpetually set it to quit when last win was closed. This changed
3810
* was necessary because in C++ binding as the elm mainloop stop
3811
* running all object are destroyed, references are unreferenced and
3812
* events at ELM_MAIN() because of this. ??
3814
* @see elm_policy_set()
3816
* Next step is creating an Elementary window, where win calls a
3817
* constructor and sets the type of the win to ELM_WIN_BASIC
3818
* (Elm_Win_Type), which is the indicated type for most of our
3819
* examples. Here we also set the title that will appear at the top of
3820
* our window and then the autohide state for it.
3822
* The autohide works similarly to @p autodel, automatically handling
3823
* "delete,request" signals when set to @p true, with the difference
3824
* that it will hide the window, instead of destroying it.
3826
* It is specially designed to work together with @p
3827
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
3828
* Elementary's main loop when all the windows are hidden.
3831
* @until autohide_set
3833
* @note @p autodel and @a autohide are not mutually exclusive. The
3834
* window will be destructed if both autodel and autohide is set to @p
3835
* EINA_TRUE or @p true.
3837
* Now let's create the background with the C++ binding method, passing
3838
* our window as parent.
3842
* The function @c size_hint_weight_set for C++ bindings originated
3843
* from C bindings function evas_object_size_hint_weight_set, that is
3844
* EFL Evas type function. With this function we set the hints for an
3845
* object's weight. The parameters are:
3847
* @li x - Nonnegative double value to use as horizontal weight hint.
3849
* @li y - Nonnegative double value to use as vertical weight hint.
3851
* This is not a size enforcement in any way, it's just a hint that
3852
* should be used whenever appropriate. This is a hint on how a
3853
* container object should resize a given child within its area.
3855
* Containers may adhere to the simpler logic of just expanding the
3856
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
3857
* helper weight macro in the EFL Evas Documentation) or the complete
3858
* one of taking each child's weight hint as real weights to how much
3859
* of its size to allocate for them in each axis. A container is
3860
* supposed to, after normalizing the weights of its children (with
3861
* weight hints), distribute the space it has to layout them by those
3862
* factors – most weighted children get larger in this process than
3865
* @skipline weight_set
3867
* @note Default weight hint values are 0.0, for both axis.
3869
* Now we add the background as a resize-object to win informing that
3870
* when the size of the win changes so should the background's size
3871
* and setting it's visibility. You can change the background's color
3872
* using color_set, if not, the default color will be used.
3875
* @until visibility_set
3877
* To put a box in the window we also need to set it's parent. By
3878
* default, box object arranges their contents vertically from top to
3879
* bottom. By calling this function with horizontal as @a true, the
3880
* box will become horizontal, arranging contents from left to right.
3885
* The value that we set EFL Evas function size_hint_weight_set
3886
* expands the box to cover all win's area and adding it as a
3887
* resize_object to win informing that when the size of the win
3888
* changes so should the box's size. In the end we make the box
3894
* Now we create a retangle, like before, we just need to setting it's
3895
* parent. After created, we set the color to show the difference
3896
* between the next rectangle and define the minimun size of each side
3897
* by using size_hint_min_set(minimum width, minimum height).
3902
* As in the background, the value we set EFL Evas function
3903
* size_hint_weight_set expands the background to cover all area
3904
* defined in size_hint_min_set. We also need to expand the rectangle
3905
* to fill the area if the win's size change, if not, win can change
3906
* it's size and the rectangle will only fill it's own previous area.
3910
* The function @c size_hint_align_set for C++ bindings originated
3911
* from C bindings function evas_object_size_hint_align_set, that is
3912
* EFL Evas type function. With this function we set the hints for an
3913
* object's alignment. The parameters are:
3915
* @li x - Double, ranging from 0.0 to 1.0 or with the special value
3916
* EVAS_HINT_FILL, to use as horizontal alignment hint.
3918
* @li y - Double, ranging from 0.0 to 1.0 or with the special value
3919
* EVAS_HINT_FILL, to use as vertical alignment hint.
3921
* These are hints on how to align an object inside the boundaries of
3922
* a container/manager. Accepted values are in the 0.0 to 1.0 range,
3923
* with the special value EVAS_HINT_FILL used to specify "justify" or
3924
* "fill" by some users. In this case, maximum size hints should be
3925
* enforced with higher priority, if they are set. Also, any padding
3926
* hint set on objects should add up to the alignment space on the
3927
* final scene composition.
3929
* For the horizontal component, 0.0 means to the left, 1.0 means to
3930
* the right. Analogously, for the vertical component, 0.0 to the top,
3931
* 1.0 means to the bottom.
3933
* This is not a size enforcement in any way, it's just a hint that
3934
* should be used whenever appropriate.
3936
* @skipline align_set
3938
* @note Default alignment hint values are 0.5, for both axis.
3940
* Now we only need to set the visibility of the rectangle and add our
3941
* retangle to box with the packing method of the subobj - rectangle
3942
* in this case. There are four possible methods:
3944
* @li @c pack_start(subobj_) - Add an object to the beginning of the
3945
* pack list. Pack @c subobj_ into the box obj, placing it first in
3946
* the list of children objects. The actual position the object will
3947
* get on screen depends on the layout used. If no custom layout is
3948
* set, it will be at the top or left, depending if the box is
3949
* vertical or horizontal, respectively.
3951
* @li @c pack_end(subobj_) - Add an object at the end of the pack
3952
* list. Pack @c subobj_ into the box obj, placing it last in the list
3953
* of children objects. The actual position the object will get on
3954
* screen depends on the layout used. If no custom layout is set, it
3955
* will be at the bottom or right, depending if the box is vertical or
3956
* horizontal, respectively.
3958
* @li @c pack_before(subobj_, before_) - Adds an object to the box
3959
* before the indicated object. This will add the @c subobj_ to the
3960
* box indicated before the object indicated with @c before_. If
3961
* before is not already in the box, results are undefined. Before
3962
* means either to the left of the indicated object or above it
3963
* depending on orientation.
3965
* @li @c pack_after(subobj_, after_) - Adds an object to the box
3966
* after the indicated object. This will add the @c subobj_ to the box
3967
* indicated after the object indicated with @c after_. If after is
3968
* not already in the box, results are undefined. After means either
3969
* to the right of the indicated object or below it depending on
3972
* In this and most examples we use pack_end by choice and
3973
* practicality. In this part of the code we also make rectangle
3979
* Once we have our first rectangle in the box we create and add our
3980
* separator. Using the same approach, we setting it's parent. Since
3981
* our box is in horizontal mode it's a good idea to set the separator
3982
* to be horizontal too. Finishing with the visibility and packing
3985
* @skip elm::separator
3988
* After all this, we just need to create another rectangle, setting
3989
* the color, size hints, make rect2 visible and packing in the
3990
* box. Don't forget to set the win's visibility as true.
3993
* @until win.visibility
3995
* Finally we just have to start the elm mainloop, starting to handle
3996
* events and drawing operations.
4001
* The full code for this example can be found at @ref separator_cxx_example_01.cc .
4003
* This example will look like:
4005
* @image html screenshots/separator_cxx_example_01.png
4006
* @image latex screenshots/separator_cxx_example_01.eps width=\textwidth
4008
* @example separator_cxx_example_01.cc
4012
* @page slider_cxx_example Slider widget example with C++ Binding
4013
* @dontinclude slider_cxx_example.cc
4015
* This code places seven Elementary slider widgets on a window, each of
4016
* them exemplifying a part of the widget's API.
4018
* The first part consists of including the headers. In this
4019
* case we are only working with the Elementary C++ binding and thus
4020
* we need only to include him.
4022
* @skipline Elementary.hh
4024
* @attention If necessary the C and/or the C++ headers should be
4025
* include here as well.
4027
* Now we need to actually start the code and set the elm_policy,
4028
* which defines for a given policy group/identifier a new policy's
4029
* value, respectively. In this example the only policy we need to
4030
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
4032
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
4035
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
4036
* application's last window is closed;
4038
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
4039
* application's last window is hidden;
4042
* @until elm_policy_set
4044
* As you can see, the policy we chose was to quit when the last win
4045
* is hidden as opposed to examples with the C bindings where we
4046
* perpetually set it to quit when last win was closed. This changed
4047
* was necessary because in C++ binding as the elm mainloop stop
4048
* running all object are destroyed, references are unreferenced and
4049
* events are stopped at ELM_MAIN().
4051
* @see For more details consult elm_policy_set
4053
* Next step is creating an Elementary window, in this example we use
4054
* the C++ binding method with the elm_win_util_standard_add that is a
4055
* elm_win_legacy function, better explained below. And then we set
4056
* the autohide state for it.
4058
* @p elm_win_util_standard_add (const char *name, const char *tittle)
4059
* Adds a window object with standard setup.
4063
* @li @p name - The name of the window;
4065
* @li @p title - The title for the window.
4067
* This creates a window but also puts in a standard background with
4068
* @p elm_bg_add(), as well as setting the window title to @p
4069
* title. The window type created is of type @c ELM_WIN_BASIC, with
4070
* the @c NULL as the parent widget. Returns the created object or @c
4073
* The autohide works similarly to @p autodel, automatically handling
4074
* "delete,request" signals when set to @p true, with the difference
4075
* that it will hide the window, instead of destroying it.
4077
* It is specially designed to work together with @p
4078
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
4079
* Elementary's main loop when all the windows are hidden.
4082
* @until autohide_set
4084
* @note @p autodel and @a autohide are not mutually exclusive. The
4085
* window will be destructed if both autodel and autohide is set to @p
4086
* EINA_TRUE or @p true.
4088
* Now let's create a box with the C++ binding method, passing our
4089
* window object as parent, we'll use this box to contain our slider
4094
* To better understand, the function @c size_hint_weight_set for C++
4095
* bindings originated from C bindings function
4096
* evas_object_size_hint_weight_set, that is EFL Evas type function.
4097
* With this function we set the hints for an object's weight. The
4100
* @li x - Nonnegative double value to use as horizontal weight hint.
4102
* @li y - Nonnegative double value to use as vertical weight hint.
4104
* This is not a size enforcement in any way, it's just a hint that
4105
* should be used whenever appropriate. This is a hint on how a
4106
* container object should resize a given child within its area.
4108
* Containers may adhere to the simpler logic of just expanding the
4109
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
4110
* helper weight macro in the EFL Evas Documentation) or the complete
4111
* one of taking each child's weight hint as real weights to how much
4112
* of its size to allocate for them in each axis. A container is
4113
* supposed to, after normalizing the weights of its children (with
4114
* weight hints), distribute the space it has to layout them by those
4115
* factors – most weighted children get larger in this process than
4118
* @skipline weight_set
4120
* @note Default weight hint values are 0.0, for both axis.
4122
* Then we add the box as a resize-object to win informing that when
4123
* the size of the win changes so should the box's size. Remember
4124
* always to set the box visibility to true.
4129
* Now we'll create our slider, using the C++ binding method and set
4130
* it's size hint that works with slider the same way as with box, for
4131
* more, look above. This is the default slider.
4136
* The function @c size_hint_align_set for C++ bindings originated
4137
* from C bindings function evas_object_size_hint_align_set, that is
4138
* EFL Evas type function. With this function we set the hints for an
4139
* object's alignment. The parameters are:
4141
* @li x - Double, ranging from 0.0 to 1.0 or with the special value
4142
* EVAS_HINT_FILL, to use as horizontal alignment hint.
4144
* @li y - Double, ranging from 0.0 to 1.0 or with the special value
4145
* EVAS_HINT_FILL, to use as vertical alignment hint.
4147
* These are hints on how to align an object inside the boundaries of
4148
* a container/manager. Accepted values are in the 0.0 to 1.0 range,
4149
* with the special value EVAS_HINT_FILL used to specify "justify" or
4150
* "fill" by some users. In this case, maximum size hints should be
4151
* enforced with higher priority, if they are set. Also, any padding
4152
* hint set on objects should add up to the alignment space on the
4153
* final scene composition.
4155
* For the horizontal component, 0.0 means to the left, 1.0 means to
4156
* the right. Analogously, for the vertical component, 0.0 to the top,
4157
* 1.0 means to the bottom.
4159
* This is not a size enforcement in any way, it's just a hint that
4160
* should be used whenever appropriate.
4164
* @note Default alignment hint values are 0.5, for both axis.
4166
* When using the elm box the packing method of the subobj - slider
4167
* in this case - should be defined. There are four possible methods:
4169
* @li @c pack_start(subobj_) - Add an object to the beginning of the
4170
* pack list. Pack @c subobj_ into the box obj, placing it first in
4171
* the list of children objects. The actual position the object will
4172
* get on screen depends on the layout used. If no custom layout is
4173
* set, it will be at the top or left, depending if the box is
4174
* vertical or horizontal, respectively.
4176
* @li @c pack_end(subobj_) - Add an object at the end of the pack
4177
* list. Pack @c subobj_ into the box obj, placing it last in the list
4178
* of children objects. The actual position the object will get on
4179
* screen depends on the layout used. If no custom layout is set, it
4180
* will be at the bottom or right, depending if the box is vertical or
4181
* horizontal, respectively.
4183
* @li @c pack_before(subobj_, before_) - Adds an object to the box
4184
* before the indicated object. This will add the @c subobj_ to the
4185
* box indicated before the object indicated with @c before_. If
4186
* before is not already in the box, results are undefined. Before
4187
* means either to the left of the indicated object or above it
4188
* depending on orientation.
4190
* @li @c pack_after(subobj_, after_) - Adds an object to the box
4191
* after the indicated object. This will add the @c subobj_ to the box
4192
* indicated after the object indicated with @c after_. If after is
4193
* not already in the box, results are undefined. After means either
4194
* to the right of the indicated object or below it depending on
4197
* In this and most examples we use pack_end by choice and
4198
* practicality, in this part of the code we also make slider visible.
4203
* As you see, the defaults for a slider are:
4206
* @li no values on indicator or unit labels
4208
* Actually it's pretty useless this way. So let's learn how to
4211
* Creating the second slider, the difference being that we set a text
4217
* Creating the first icon as standard "home" and not resizable and
4218
* finally add icon as content for the second slider.
4223
* Our second icon is the standard "folder", also not resizable and
4224
* with add it also to the second slider.
4229
* The same as before, the size hints weight, align will be setted and
4230
* the packing method for the second slider. Also making it visible.
4235
* If the bar size need to be changed, it can be done with span set function,
4236
* that doesn't accounts other widget's parts size. Also the bar can starts
4237
* with a not default value (0.0), as we done on third slider:
4242
* So far, users won't be able to see the slider value. If it's required,
4243
* it can be displayed in two different areas, units label or above
4246
* Let's place a units label on our widget, and also let's set minimum and
4247
* maximum value, by default it uses 0.0 and 1.0:
4252
* If above the indicator is the place to display the value, just set
4253
* it. Also, is possible to invert a bar, as you can see:
4258
* But if you require to use a function a bit more customized to show
4259
* the value, is possible to registry a callback function that will be
4260
* called to display unit or indicator label. For this we suggest you
4261
* use a lambda type function.
4266
* In this case, a function to free this will be required, also a
4271
* @see To learn more consult @ref lambda.
4273
* Now we add our two labdas as indicators for our sixth slider and
4274
* set the hints, packing method and visibility for our slider.
4279
* For our seventh slider we'll show that slider can also be displayed
4285
* Finally the last slider will exemplify how to listen to slider's
4286
* signals, <tt> changed </tt> and <tt> delay,changed </tt>. First we
4287
* need to implement callback functions that will simply print
4288
* slider's value, using lambda again:
4294
* The first callback function should be called everytime value changes,
4295
* the second one only after user stops to increment or decrement. Try
4296
* to keep arrows pressed and check the difference.
4299
* @until callback_delay
4301
* Finally we just have to make our window visible. Then run the elm
4302
* mainloop, starting to handle events and drawing operations.
4307
* See the full @ref slider_cxx_example.cc "example", whose window should
4308
* look like this picture:
4310
* @image html screenshots/slider_cxx_example.png
4311
* @image latex screenshots/slider_cxx_example.eps width=\textwidth
4313
* @example slider_cxx_example.cc
4317
* @page spinner_cxx_example Spinner widget example with C++ Binding
4318
* @dontinclude spinner_cxx_example.cc
4320
* This code places seven Elementary spinner widgets on a window, each of
4321
* them exemplifying a part of the widget's API.
4323
* The first part consists of including the headers. In this
4324
* case we are only working with the Elementary C++ binding and thus
4325
* we need only to include him.
4327
* @skipline Elementary.hh
4329
* @attention If necessary the C and/or the C++ headers should be
4330
* include here as well.
4332
* Now we need to actually start the code and set the elm_policy,
4333
* which defines for a given policy group/identifier a new policy's
4334
* value, respectively. In this example the only policy we need to
4335
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
4337
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
4340
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
4341
* application's last window is closed;
4343
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
4344
* application's last window is hidden;
4347
* @until elm_policy_set
4349
* As you can see, the policy we chose was to quit when the last win
4350
* is hidden as opposed to examples with the C bindings where we
4351
* perpetually set it to quit when last win was closed. This changed
4352
* was necessary because in C++ binding as the elm mainloop stop
4353
* running all object are destroyed, references are unreferenced and
4354
* events are stopped at ELM_MAIN().
4356
* @see For more details consult elm_policy_set
4358
* Next step is creating an Elementary window, in this example we use
4359
* the C++ binding method with the elm_win_util_standard_add that is a
4360
* elm_win_legacy function, better explained below. And then we set
4361
* the autohide state for it.
4363
* @p elm_win_util_standard_add (const char *name, const char *tittle)
4364
* Adds a window object with standard setup.
4368
* @li @p name - The name of the window;
4370
* @li @p title - The title for the window.
4372
* This creates a window but also puts in a standard background with
4373
* @p elm_bg_add(), as well as setting the window title to @p
4374
* title. The window type created is of type @c ELM_WIN_BASIC, with
4375
* the @c NULL as the parent widget. Returns the created object or @c
4378
* The autohide works similarly to @p autodel, automatically handling
4379
* "delete,request" signals when set to @p true, with the difference
4380
* that it will hide the window, instead of destroying it.
4382
* It is specially designed to work together with @p
4383
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
4384
* Elementary's main loop when all the windows are hidden.
4387
* @until autohide_set
4389
* @note @p autodel and @a autohide are not mutually exclusive. The
4390
* window will be destructed if both autodel and autohide is set to @p
4391
* EINA_TRUE or @p true.
4393
* A box arranges objects in a linear fashion, governed by a layout
4394
* function that defines the details of this arrangement. The box will
4395
* use an internal function to set the layout to a single row,
4396
* vertical by default.
4398
* Now let's create the box with the C++ binding method, passing our
4399
* window object as parent.
4401
* @skipline elm::box
4403
* To better understand, the function @c size_hint_weight_set for C++
4404
* bindings originated from C bindings function
4405
* evas_object_size_hint_weight_set, that is EFL Evas type function.
4406
* With this function we set the hints for an object's weight. The
4409
* @li x - Nonnegative double value to use as horizontal weight hint.
4411
* @li y - Nonnegative double value to use as vertical weight hint.
4413
* This is not a size enforcement in any way, it's just a hint that
4414
* should be used whenever appropriate. This is a hint on how a
4415
* container object should resize a given child within its area.
4417
* Containers may adhere to the simpler logic of just expanding the
4418
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
4419
* helper weight macro in the EFL Evas Documentation) or the complete
4420
* one of taking each child's weight hint as real weights to how much
4421
* of its size to allocate for them in each axis. A container is
4422
* supposed to, after normalizing the weights of its children (with
4423
* weight hints), distribute the space it has to layout them by those
4424
* factors – most weighted children get larger in this process than
4427
* @skipline weight_set
4429
* @note Default weight hint values are 0.0, for both axis.
4431
* Now we add the box as a resize_object to win informing that
4432
* when the size of the win changes so should the box's
4433
* size. And finally we make it visible.
4436
* @until visibility_set
4438
* Now we create our spinner with the C++ method, this first one will
4439
* the default spinner.
4443
* As you see, the defaults for a spinner are:
4447
* @li min value set to 0
4449
* @li max value set to 100
4451
* @li step value set to 1
4453
* @li label format set to "%0.f"
4455
* The function size_hint_weight_set works with spinner the same way
4456
* as with box, as seem above.
4458
* @skipline weight_set
4460
* The function @c size_hint_align_set for C++ bindings originated
4461
* from C bindings function evas_object_size_hint_align_set, that is
4462
* EFL Evas type function. With this function we set the hints for an
4463
* object's alignment. The parameters are:
4465
* @li x - Double, ranging from 0.0 to 1.0 or with the special value
4466
* EVAS_HINT_FILL, to use as horizontal alignment hint.
4468
* @li y - Double, ranging from 0.0 to 1.0 or with the special value
4469
* EVAS_HINT_FILL, to use as vertical alignment hint.
4471
* These are hints on how to align an object inside the boundaries of
4472
* a container/manager. Accepted values are in the 0.0 to 1.0 range,
4473
* with the special value EVAS_HINT_FILL used to specify "justify" or
4474
* "fill" by some users. In this case, maximum size hints should be
4475
* enforced with higher priority, if they are set. Also, any padding
4476
* hint set on objects should add up to the alignment space on the
4477
* final scene composition.
4479
* For the horizontal component, 0.0 means to the left, 1.0 means to
4480
* the right. Analogously, for the vertical component, 0.0 to the top,
4481
* 1.0 means to the bottom.
4483
* This is not a size enforcement in any way, it's just a hint that
4484
* should be used whenever appropriate.
4486
* @skipline align_set
4488
* @note Default alignment hint values are 0.5, for both axis.
4490
* When using the elm::box the packing method of the subobj - spinner
4491
* in this case - should be defined. There are four possible methods:
4493
* @li @c pack_start(subobj_) - Add an object to the beginning of the
4494
* pack list. Pack @c subobj_ into the box obj, placing it first in
4495
* the list of children objects. The actual position the object will
4496
* get on screen depends on the layout used. If no custom layout is
4497
* set, it will be at the top or left, depending if the box is
4498
* vertical or horizontal, respectively.
4500
* @li @c pack_end(subobj_) - Add an object at the end of the pack
4501
* list. Pack @c subobj_ into the box obj, placing it last in the list
4502
* of children objects. The actual position the object will get on
4503
* screen depends on the layout used. If no custom layout is set, it
4504
* will be at the bottom or right, depending if the box is vertical or
4505
* horizontal, respectively.
4507
* @li @c pack_before(subobj_, before_) - Adds an object to the box
4508
* before the indicated object. This will add the @c subobj_ to the
4509
* box indicated before the object indicated with @c before_. If
4510
* before is not already in the box, results are undefined. Before
4511
* means either to the left of the indicated object or above it
4512
* depending on orientation.
4514
* @li @c pack_after(subobj_, after_) - Adds an object to the box
4515
* after the indicated object. This will add the @c subobj_ to the box
4516
* indicated after the object indicated with @c after_. If after is
4517
* not already in the box, results are undefined. After means either
4518
* to the right of the indicated object or below it depending on
4521
* In this and most examples we use pack_end by choice and
4522
* practicality. In this part of the code we also make spinner
4528
* In our second spinner we are altering the format. It will put a
4529
* text before and after the value, and also format value to display
4530
* two decimals. As with the first spinner, we create the second with
4531
* the same C++ method, set the alignment and the weight, choose the
4532
* packing method and make it visible.
4537
* The third one will use a customized step, define new minimum and maximum
4538
* values and enable wrap, so when value reaches minimum it jumps to maximum,
4539
* or jumps to minimum after maximum value is reached. Format is set to display
4545
* The fourth uses @c vertical style, so instead of left and right arrows,
4546
* top and bottom are displayed. Also the change interval is reduced, so
4547
* user can change value faster.
4552
* In the fifth the user won't be allowed to set value directly, i.e., will
4553
* be obligate change value only using arrows:
4558
* The sixth widget will receive a lot of special values, so
4559
* instead of reading numeric values, user will see labels for each one.
4560
* Also direct edition is disabled, otherwise users would see the numeric
4561
* value on edition mode. User will be able to select a month in this widget:
4566
* Finally the last widget will exemplify how to listen to widget's
4567
* signals, <tt> changed </tt> and <tt> delay_changed </tt>.
4569
* We start the same way as previously, creating spinner, setting
4570
* alignment and weight, choosing the packing method, making it
4571
* visible and editable.
4576
* Our spinner will output it's value or delay value every time the
4577
* std::function object is called. In this example we are using @a
4578
* std::bind to bind the parameters of each lambda function, that
4579
* captures sp7 by reference and then get it's value or delay value to
4580
* finally output it.
4582
* The first function changed, that was declare as auto, will output
4583
* the new value. For this we need to add it to the
4584
* @p callback_changed
4589
* The second function changed, that was also declare as auto, will
4590
* output the new delay value. For this we need to add it to the @p
4591
* callback_delay_changed.
4596
* To learn more consult @ref lambda.
4598
* The first callback function should be called everytime value
4599
* changes, the second one only after user stops to increment or
4600
* decrement. Try to keep arrows pressed and check the difference.
4602
* Finally we just have to make our window visible. Then run the elm
4603
* mainloop, starting to handle events and drawing operations.
4608
* See the full code for this example at @ref spinner_cxx_example.cc .
4610
* This example will look like this:
4612
* @image html screenshots/spinner_cxx_example.png
4613
* @image latex screenshots/spinner_cxx_example.eps width=\textwidth
4614
* @example spinner_cxx_example.cc
4618
* @page table_cxx_example_01 Table Example with C++ binding - Homogeneous
4619
* @dontinclude table_cxx_example_01.cc
4621
* In this example we add four labels to a homogeneous table that has a padding
4622
* of 5px between cells.
4624
* The first part consists of including the headers. In this
4625
* case we are only working with the Elementary C++ binding and thus
4626
* we need only to include him.
4628
* @skipline Elementary.hh
4630
* @attention If necessary the C and/or the C++ headers should be
4631
* include here as well.
4633
* Now we need to actually start the code and set the elm_policy,
4634
* which defines for a given policy group/identifier a new policy's
4635
* value, respectively. In this example the only policy we need to
4636
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
4638
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
4641
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
4642
* application's last window is closed;
4644
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
4645
* application's last window is hidden;
4648
* @until elm_policy_set
4650
* As you can see, the policy we chose was to quit when the last win
4651
* is hidden as opposed to examples with the C bindings where we
4652
* perpetually set it to quit when last win was closed. This changed
4653
* was necessary because in C++ binding as the elm mainloop stop
4654
* running all object are destroyed, references are unreferenced and
4655
* events are stopped at ELM_MAIN().
4657
* @see For more details consult elm_policy_set
4659
* Next step is creating an Elementary window, in this example we use
4660
* the C++ binding method with the elm_win_util_standard_add that is a
4661
* elm_win_legacy function, better explained below. And then we set
4662
* the autohide state for it.
4664
* @p elm_win_util_standard_add (const char *name, const char *tittle)
4665
* Adds a window object with standard setup.
4668
* @li @p name - The name of the window;
4670
* @li @p title - The title for the window.
4672
* This creates a window but also puts in a standard background with
4673
* @p elm_bg_add(), as well as setting the window title to @p
4674
* title. The window type created is of type @c ELM_WIN_BASIC, with
4675
* the @c NULL as the parent widget. Returns the created object or @c
4678
* And we also set the autohide state for win, autohide works
4679
* similarly to @p autodel, automatically handling "delete,request"
4680
* signals when set to @p true, with the difference that it will hide
4681
* the window, instead of destroying it.
4683
* It is specially designed to work together with @p
4684
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
4685
* Elementary's main loop when all the windows are hidden.
4688
* @until autohide_set
4690
* @note @p autodel and @a autohide are not mutually exclusive. The
4691
* window will be destructed if both autodel and autohide is set to @p
4692
* EINA_TRUE or @p true.
4694
* Now we construct the elm table and for this we use the C++ method
4695
* below, setting it's parent.
4697
* @skipline ::elm::table
4699
* We then add table as a resize_object to win informing that when the
4700
* size of the win changes so should the box's size and make it
4706
* Next step is to set the padding, in this case 5px and as we chosen
4707
* for this example homogeneous_set to true.
4710
* @until homogeneous
4712
* We'll create for each cell on this table a simple elm_lable, using
4713
* the C++ method below, setting it's parent. Set the text for the
4714
* labels and make each visible. The parameters for packing the labels
4715
* in our table will be better explain below.
4720
* When using pack in our table we are adding a child to a packing
4721
* location of the table. The parameters are:
4723
* pack (evas::object @a subobj,
4729
* @li subobj - The subobject to be added to the table
4731
* @li column - Column number
4733
* @li row - Row number
4735
* @li colspan - Number of columns that the subobj will occupy
4737
* @li rowspan - Number of rows that the subobj will occupy
4739
* @note All positioning inside the table is relative to rows and
4740
* columns, so a value of 0 for @a column and @a row, means the top
4741
* left cell of the table. And for example, value of 2 for @a colspan and @a
4742
* rowspan indicates that the subobj will occupy two columns and two rows,
4743
* thus occupying 4 cells in total.
4745
* Finally we just have to make our window visible. Then run the elm
4746
* mainloop, starting to handle events and drawing operations.
4751
* @See Full code for this example: @ref table_cxx_example_01.cc .
4753
* Our example will look like this:
4755
* @image html screenshots/table_cxx_example_01.png
4756
* @image latex screenshots/table_cxx_example_01.eps width=\textwidth
4757
* @example table_cxx_example_01.cc
4761
* @page table_cxx_example_02 Table Example with C++ binding - Heterogeneous
4762
* @dontinclude table_cxx_example_02.cc
4764
* For our second example we'll create a table with 4 rectangles in
4765
* it. Since our rectangles are of different sizes our table won't be
4768
* The first part consists of including the headers. In this
4769
* case we are only working with the Elementary C++ binding and thus
4770
* we need only to include him.
4772
* @skipline Elementary.hh
4774
* @attention If necessary the C and/or the C++ headers should be
4775
* include here as well.
4777
* Now we need to actually start the code and set the elm_policy,
4778
* which defines for a given policy group/identifier a new policy's
4779
* value, respectively. In this example the only policy we need to
4780
* set a value for is @c ELM_POLICY_QUIT, possibles values for it are:
4782
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
4785
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
4786
* application's last window is closed;
4788
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
4789
* application's last window is hidden;
4792
* @until elm_policy_set
4794
* As you can see, the policy we chose was to quit when the last win
4795
* is hidden as opposed to examples with the C bindings where we
4796
* perpetually set it to quit when last win was closed. This changed
4797
* was necessary because in C++ binding as the elm mainloop stop
4798
* running all object are destroyed, references are unreferenced and
4799
* events are stopped at ELM_MAIN().
4801
* @see For more details consult elm_policy_set
4803
* Next step is creating an Elementary window, in this example we use
4804
* the C++ binding method with the elm_win_util_standard_add that is a
4805
* elm_win_legacy function, better explained below. And then we set
4806
* the autohide state for it.
4808
* @p elm_win_util_standard_add (const char *name, const char *tittle)
4809
* Adds a window object with standard setup.
4812
* @li @p name - The name of the window;
4814
* @li @p title - The title for the window.
4816
* This creates a window but also puts in a standard background with
4817
* @p elm_bg_add(), as well as setting the window title to @p
4818
* title. The window type created is of type @c ELM_WIN_BASIC, with
4819
* the @c NULL as the parent widget. Returns the created object or @c
4822
* And we also set the autohide state for win, autohide works
4823
* similarly to @p autodel, automatically handling "delete,request"
4824
* signals when set to @p true, with the difference that it will hide
4825
* the window, instead of destroying it.
4827
* It is specially designed to work together with @p
4828
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
4829
* Elementary's main loop when all the windows are hidden.
4832
* @until autohide_set
4834
* @note @p autodel and @a autohide are not mutually exclusive. The
4835
* window will be destructed if both autodel and autohide is set to @p
4836
* EINA_TRUE or @p true.
4838
* Now we construct the elm table and for this we use the C++ method
4839
* below, passing windows as it's parent.
4841
* @skipline ::elm::table
4843
* We then add table as a resize_object to win informing that when the
4844
* size of the win changes so should the table's size and make it
4845
* visible. The last configuration for table is to set homogeneous as
4849
* @until homogeneous
4851
* For each cell of this table we are going to create a unique @p
4852
* evas::rectangle, each with different colors and sizes.
4854
* Let's see a snip of the code on how we constructed our rectangles
4855
* and setted the colors.
4869
* For each rectangle we also setted the size_hint_min that hints for
4870
* an object's minimum size. This is not a size enforcement in any
4871
* way, it's just a hint that should be used whenever appropriate.
4873
* @dontinclude table_cxx_example_02.cc
4874
* @skipline size_hint
4876
* @skipline size_hint
4878
* @skipline size_hint
4880
* @skipline size_hint
4882
* When using pack in our table we are adding a child to a packing
4883
* location of the table. The parameters are:
4885
* pack (evas::object @a subobj,
4891
* @li subobj - The subobject to be added to the table
4893
* @li column - Column number
4895
* @li row - Row number
4897
* @li colspan - Number of columns that the subobj will occupy
4899
* @li rowspan - Number of rows that the subobj will occupy
4901
* @note All positioning inside the table is relative to rows and
4902
* columns, so a value of 0 for @a column and @a row, means the top
4903
* left cell of the table. And for example, value of 2 for @a colspan
4904
* and @a rowspan indicates that the subobj will occupy two column
4905
* and two rows, thus occupying 4 cells in total.
4907
* So for each rectangle we are setting a specific location and how
4908
* many cells it's occupying, better seem below:
4910
* @dontinclude table_cxx_example_02.cc
4919
* Finally we just have to make our window visible. Then run the elm
4920
* mainloop, starting to handle events and drawing operations.
4925
* @See Full code for this example: @ref table_cxx_example_02.cc .
4927
* Our example will look like this:
4929
* @image html screenshots/table_cxx_example_02.png
4930
* @image latex screenshots/table_cxx_example_02.eps width=\textwidth
4932
* @example table_cxx_example_02.cc
4936
* @page thumb_cxx_example_01 Thumb - Generating thumbnails with C++ Binding
4937
* @dontinclude thumb_cxx_example_01.cc
4939
* This example shows how to create a simple thumbnail object with
4940
* Elementary C++ Binding.
4942
* The first part consists of including the headers. In this case we
4943
* need Elementary C++ binding, iostream and sstream libraries.
4945
* @skip Elementary.hh
4948
* @attention All necessary Enlightenment, Elementary, C and/or C++
4949
* headers should be include here as well.
4951
* Starting the main code and telling elementary that we need Ethumb
4952
* to generate the thumbnails:
4955
* @until elm_need_ethumb
4957
* Then, we use app_info_set to access the image that we are using for
4962
* Now let's set the elm_policy, which defines for a given policy
4963
* group/identifier a new policy's value, respectively. In this
4964
* example the only policy we need to set a value for is @c
4965
* ELM_POLICY_QUIT, possibles values for it are:
4967
* @li @p ELM_POLICY_QUIT_NONE: Never quit the application
4970
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
4971
* application's last window is closed;
4973
* @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
4974
* application's last window is hidden;
4976
* @skipline elm_policy_set
4978
* As you can see, the policy we chose was to quit when the last win
4979
* is hidden as opposed to examples with the C bindings where we
4980
* perpetually set it to quit when last win was closed. This changed
4981
* was necessary because in C++ binding as the elm mainloop stop
4982
* running all object are destroyed, references are unreferenced and
4983
* events are stopped at ELM_MAIN().
4985
* @see For more details consult elm_policy_set
4987
* Next step is creating an elementary window, in this example we use
4988
* the C++ binding method with the elm_win_util_standard_add that is a
4989
* elm_win_legacy function, better explained below. And then we set
4990
* the autohide state for it.
4992
* @p elm_win_util_standard_add (const char *name, const char *tittle)
4993
* Adds a window object with standard setup.
4996
* @li @p name - The name of the window;
4998
* @li @p title - The title for the window.
5000
* This creates a window but also puts in a standard background with
5001
* @p elm_bg_add(), as well as setting the window title to @p
5002
* title. The window type created is of type @c ELM_WIN_BASIC, with
5003
* the @c NULL as the parent widget. Returns the created object or @c
5006
* The autohide works similarly to @p autodel, automatically handling
5007
* "delete,request" signals when set to @p true, with the difference
5008
* that it will hide the window, instead of destroying it.
5010
* It is specially designed to work together with @p
5011
* ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
5012
* Elementary's main loop when all the windows are hidden.
5015
* @until autohide_set
5017
* @note @p autodel and @a autohide are not mutually exclusive. The
5018
* window will be destructed if both autodel and autohide is set to @p
5019
* EINA_TRUE or @p true.
5021
* Creating our thumb and setting it's parent, using C++ method.
5025
* For our callbacks we are using lambda type functions to create
5026
* then, note that all three only show a message, for when our thumb
5027
* generation is starting, stoping and it's return error.
5030
* @until generate_error
5032
* @note To learn more about Lambda Function and its use in Elementary
5033
* consult @ref lambda.
5035
* Continuing with our thumb, we'll set a size, set it to not be
5036
* editable, set the file and after that, we can start creating
5037
* thumbnail objects. They are very similar to image or icon objects:
5042
* As you can see, the main different function here is reload(), which
5043
* will check if the options of the Ethumb client have changed. If so,
5044
* it will re-generate the thumbnail, and show the new one.
5046
* Notice in this example that the thumbnail object is displayed on
5047
* the size of the window (320x320 pixels), but the thumbnail
5048
* generated and stored has size 160x160 pixels. That's why the
5049
* picture seems upscaled.
5051
* Ideally, you will be generating thumbnails with the size that you
5052
* will be using them.
5054
* Finishing with thumb we set the weight hint. To better understand,
5055
* the function @c size_hint_weight_set for C++ bindings originated
5056
* from C bindings function evas_object_size_hint_weight_set, that is
5057
* EFL Evas type function. With this function we set the hints for an
5059
* The parameters are:
5061
* @li x - Nonnegative double value to use as horizontal weight hint.
5063
* @li y - Nonnegative double value to use as vertical weight hint.
5065
* This is not a size enforcement in any way, it's just a hint that
5066
* should be used whenever appropriate. This is a hint on how a
5067
* container object should resize a given child within its area.
5069
* Containers may adhere to the simpler logic of just expanding the
5070
* child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
5071
* helper weight macro in the EFL Evas Documentation) or the complete
5072
* one of taking each child's weight hint as real weights to how much
5073
* of its size to allocate for them in each axis. A container is
5074
* supposed to, after normalizing the weights of its children (with
5075
* weight hints), distribute the space it has to layout them by those
5076
* factors – most weighted children get larger in this process than
5079
* @skipline weight_set
5081
* @note Default weight hint values are 0.0, for both axis.
5083
* Then we add the thumb as a resize-object to win informing that when
5084
* the size of the win changes so should the thumb's size. Remember
5085
* always to set the thumb visibility to true.
5090
* Now we only have to set the size for our window and make it
5094
* @until visibility_set
5096
* And finally, start the elm mainloop, starting to handle events and
5097
* drawing operations.
5102
* The full source code can be found at @ref thumb_cxx_example_01.cc
5104
* @image latex screenshots/thumb_cxx_example_01.eps width=\textwidth
5105
* @example thumb_cxx_example_01.cc