Calendar - Simple creation with Javascript Binding

As a first example, let's just display a calendar in our window, explaining all steps required to do so.

The first part consists of including the necessary modules and for this we'll use the Node.js require() function. In this example, we are working solely with elm module.

efl = require('efl');

Next step is creating an Elementary window with Win_Standard without a parent, which is the type used for all of our examples. Here we also set the title that will appear at the top of our window and then the autohide state for it.

The autohide works automatically handling "delete,request" signals when set to true, hidding the window, instead of destroying it.

Now, the exciting part, let's create the calendar with the JS binding method, passing our window object as parent.

To better understand, the function size_hint_weight_set for JS bindings originated from C bindings function evas_object_size_hint_weight_set, that is EFL Evas type function. With this function we set the hints for an object's weight. The parameters are:

This is not a size enforcement in any way, it's just a hint that should be used whenever appropriate.

This is a hint on how a container object should resize a given child within its area.

Containers may adhere to the simpler logic of just expanding the child object's dimensions to fit its own or the complete one of taking each child's weight hint as real weights to how much of its size to allocate for them in each axis. A container is supposed to, after normalizing the weights of its children (with weight hints), distribute the space it has to layout them by those factors – most weighted children get larger in this process than the least ones.

Note
Default weight hint values are 0.0, for both axis.

Now we add the calendar as a resize-object to win informing that when the size of the win changes so should the calendar's size. And finally we make our calendar and window visibles.

Our example will look like this:

calendar_example_01.png

See the full source code calendar_example_01.js here.