* Here you have the full-source of the code:
* @include ecore_evas_callbacks.c
* @example ecore_evas_callbacks.c
- */
\ No newline at end of file
+ */
+
+/**
+ * @page Ecore_Evas_Window_Sizes_Example_c @c Ecore_Evas window sizes
+ *
+ * On this example, we show you how to deal with @c Ecore_Evas window
+ * size hints, which are implemented <b>per Evas engine</b>.
+ *
+ * We start by defining an initial size for our window and, after
+ * creating it, adding a background white rectangle and a text object
+ * to it, to be used to display the current window's sizes, at any
+ * given time:
+ * @dontinclude ecore_evas_window_sizes_example.c
+ * @skip define WIDTH
+ * @until define
+ * @until define
+ * @dontinclude ecore_evas_window_sizes_example.c
+ * @skip evas_init
+ * @until show(bg)
+ * @dontinclude ecore_evas_window_sizes_example.c
+ * @skip text =
+ * @until main_loop_begin
+ * @dontinclude ecore_evas_window_sizes_example.c
+ * @skip to inform
+ * @until }
+ *
+ * The program has a command line interface, responding to the
+ * following keys:
+ * @dontinclude ecore_evas_window_sizes_example.c
+ * @skip commands
+ * @until ;
+ *
+ * Use the @c 'm' key to impose a minimum size of half the initial
+ * ones on our window. Test it by trying to resize it to smaller sizes
+ * than that:
+ * @dontinclude ecore_evas_window_sizes_example.c
+ * @skip keyname, "m"
+ * @until }
+ * @until }
+ * @until }
+ *
+ * The @c 'x' key will, in turn, set a maximum size on our window --
+ * to two times our initial size. Test it by trying to resize the
+ * window to bigger sizes than that:
+ * @dontinclude ecore_evas_window_sizes_example.c
+ * @skip keyname, "x"
+ * @until }
+ * @until }
+ * @until }
+ *
+ * Window base sizes will override any minimum sizes set, so try it
+ * with the @c 'b' key. It will set a base size of two times the
+ * initial one:
+ * @dontinclude ecore_evas_window_sizes_example.c
+ * @skip keyname, "b"
+ * @until }
+ * @until }
+ * @until }
+ *
+ * Finally, there's a key to impose a "step size" on our window, of 40
+ * pixels. With than on (@c 's' key), you'll see the window will
+ * always be bound to @b multiples of that size, for dimensions on
+ * both axis:
+ * @skip keyname, "s"
+ * @until }
+ * @until }
+ * @until }
+ *
+ * The full example follows.
+ *
+ * @include ecore_evas_window_sizes_example.c
+ * @example ecore_evas_window_sizes_example.c
+ */
ecore_pipe_simple_example.c \
ecore_pipe_gstreamer_example.c \
ecore_thread_example.c \
- ecore_evas_callbacks.c
+ ecore_evas_callbacks.c \
+ ecore_evas_window_sizes_example.c
EXTRA_DIST = $(SRCS)
ecore_con_server_http_example \
ecore_con_client_simple_example \
ecore_thread_example \
- ecore_evas_callbacks
+ ecore_evas_callbacks \
+ ecore_evas_window_sizes_example
ecore_animator_example_LDADD = $(ECOREBASELDADD) @EVAS_LIBS@ $(top_builddir)/src/lib/ecore_evas/libecore_evas.la
ecore_con_lookup_example_LDADD = $(ECOREBASELDADD) $(top_builddir)/src/lib/ecore_con/libecore_con.la
ecore_con_server_simple_example_LDADD = $(ECOREBASELDADD) $(top_builddir)/src/lib/ecore_con/libecore_con.la
ecore_con_server_http_example_LDADD = $(ECOREBASELDADD) $(top_builddir)/src/lib/ecore_con/libecore_con.la
ecore_con_client_simple_example_LDADD = $(ECOREBASELDADD) $(top_builddir)/src/lib/ecore_con/libecore_con.la
+ecore_evas_window_sizes_example_LDADD = $(ECOREBASELDADD) @EVAS_LIBS@ $(top_builddir)/src/lib/ecore_evas/libecore_evas.la
endif
--- /dev/null
+/**
+ * Simple @c Ecore_Evas example illustrating how to deal with window
+ * sizes
+ *
+ * You'll need at least one engine built for it (excluding the buffer
+ * one). See stdout/stderr for output.
+ *
+ * @verbatim
+ * gcc -o evas-smart-object evas-smart-object.c `pkg-config --libs --cflags evas ecore ecore-evas`
+ * @endverbatim
+ */
+
+#ifdef HAVE_CONFIG_H
+
+#include "config.h"
+#else
+#define __UNUSED__
+#endif
+
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+
+#define WIDTH (300)
+#define HEIGHT (300)
+
+static Ecore_Evas *ee;
+static Evas_Object *text, *bg;
+static Eina_Bool min_set = EINA_FALSE;
+static Eina_Bool max_set = EINA_FALSE;
+static Eina_Bool base_set = EINA_FALSE;
+static Eina_Bool step_set = EINA_FALSE;
+
+static const char commands[] = \
+ "commands are:\n"
+ "\tm - impose a minumum size to the window\n"
+ "\tx - impose a maximum size to the window\n"
+ "\tb - impose a base size to the window\n"
+ "\ts - impose a step size (different than 1 px) to the window\n"
+ "\th - print help\n";
+
+/* to inform current window's size */
+static void
+_canvas_resize_cb(Ecore_Evas *ee)
+{
+ int w, h;
+ char buf[1024];
+
+ ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
+ snprintf(buf, sizeof(buf), "%d x %d", w, h);
+ evas_object_text_text_set(text, buf);
+ evas_object_move(text, (w - 150) / 2, (h - 50) / 2);
+
+ evas_object_resize(bg, w, h);
+}
+
+static void
+_on_destroy(Ecore_Evas *ee __UNUSED__)
+{
+ ecore_main_loop_quit();
+}
+
+static void
+_on_keydown(void *data __UNUSED__,
+ Evas *evas __UNUSED__,
+ Evas_Object *o __UNUSED__,
+ void *einfo)
+{
+ Evas_Event_Key_Down *ev = einfo;
+
+ if (strcmp(ev->keyname, "h") == 0) /* print help */
+ {
+ fprintf(stdout, commands);
+ return;
+ }
+
+ if (strcmp(ev->keyname, "m") == 0) /* impose a minimum size on the window */
+ {
+ min_set = !min_set;
+
+ if (min_set)
+ {
+ ecore_evas_size_min_set(ee, WIDTH / 2, HEIGHT / 2);
+ fprintf(stdout, "Imposing a minimum size of %d x %d\n",
+ WIDTH / 2, HEIGHT / 2);
+ }
+ else
+ {
+ ecore_evas_size_min_set(ee, 0, 0);
+ fprintf(stdout, "Taking off minimum size restriction from the"
+ " window\n");
+ }
+ return;
+ }
+
+ if (strcmp(ev->keyname, "x") == 0) /* impose a maximum size on the window */
+ {
+ max_set = !max_set;
+
+ if (max_set)
+ {
+ ecore_evas_size_max_set(ee, WIDTH * 2, HEIGHT * 2);
+ fprintf(stdout, "Imposing a maximum size of %d x %d\n",
+ WIDTH * 2, HEIGHT * 2);
+ }
+ else
+ {
+ ecore_evas_size_max_set(ee, 0, 0);
+ fprintf(stdout, "Taking off maximum size restriction from the"
+ " window\n");
+ }
+ return;
+ }
+
+ if (strcmp(ev->keyname, "b") == 0) /* impose a base size on the window */
+ {
+ base_set = !base_set;
+
+ if (base_set)
+ {
+ ecore_evas_size_base_set(ee, WIDTH * 2, HEIGHT * 2);
+ fprintf(stdout, "Imposing a base size of %d x %d\n",
+ WIDTH * 2, HEIGHT * 2);
+ }
+ else
+ {
+ ecore_evas_size_base_set(ee, 0, 0);
+ fprintf(stdout, "Taking off base size restriction from the"
+ " window\n");
+ }
+ return;
+ }
+
+ if (strcmp(ev->keyname, "s") == 0) /* impose a step size on the window */
+ {
+ step_set = !step_set;
+
+ if (step_set)
+ {
+ ecore_evas_size_step_set(ee, 40, 40);
+ fprintf(stdout, "Imposing a step size of %d x %d\n", 40, 40);
+ }
+ else
+ {
+ ecore_evas_size_step_set(ee, 0, 0);
+ fprintf(stdout, "Taking off step size restriction from the"
+ " window\n");
+ }
+ return;
+ }
+}
+
+int
+main(void)
+{
+ Evas *evas;
+
+ if (!ecore_evas_init())
+ return EXIT_FAILURE;
+
+ /* this will give you a window with an Evas canvas under the first
+ * engine available */
+ ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
+ if (!ee) goto error;
+
+ ecore_evas_callback_delete_request_set(ee, _on_destroy);
+ ecore_evas_title_set(ee, "Ecore_Evas window sizes example");
+ ecore_evas_callback_resize_set(ee, _canvas_resize_cb);
+ ecore_evas_show(ee);
+
+ evas = ecore_evas_get(ee);
+
+ bg = evas_object_rectangle_add(evas);
+ evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
+ evas_object_move(bg, 0, 0); /* at canvas' origin */
+ evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
+ evas_object_show(bg);
+
+ evas_object_focus_set(bg, EINA_TRUE);
+ evas_object_event_callback_add(
+ bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
+
+ text = evas_object_text_add(evas);
+ evas_object_color_set(text, 0, 0, 0, 255);
+ evas_object_resize(text, 150, 50);
+ evas_object_text_font_set(text, "Sans", 20);
+ evas_object_show(text);
+
+ _canvas_resize_cb(ee);
+ fprintf(stdout, commands);
+ ecore_main_loop_begin();
+
+ ecore_evas_free(ee);
+ ecore_evas_shutdown();
+
+ return 0;
+
+error:
+ fprintf(stderr, "You got to have at least one Evas engine built"
+ " and linked up to ecore-evas for this example to run"
+ " properly.\n");
+ ecore_evas_shutdown();
+ return -1;
+}
+
extern "C" {
#endif
+/**
+ * @defgroup Ecore_Evas_Group Ecore_Evas wrapper/helper set of functions
+ *
+ * This is a list of examples of these functions:
+ * - @ref Ecore_Evas_Window_Sizes_Example_c
+ * @{
+ */
+
/* these are dummy and just tell u what API levels ecore_evas supports - not if
* the actual support is compiled in. you need to query for that separately.
*/
EAPI const char *ecore_evas_title_get(const Ecore_Evas *ee);
EAPI void ecore_evas_name_class_set(Ecore_Evas *ee, const char *n, const char *c);
EAPI void ecore_evas_name_class_get(const Ecore_Evas *ee, const char **n, const char **c);
+
+/**
+ * Set the minimum size of a given @c Ecore_Evas window
+ *
+ * @param ee An @c Ecore_Evas window's handle
+ * @param w The minimum width
+ * @param h The minimum height
+ *
+ * This function sets the minimum size of @p ee to be @p w x @p h.
+ * One won't be able to resize that window to dimensions smaller than
+ * the ones set.
+ *
+ * @note When base sizes are set, via ecore_evas_size_base_set(),
+ * they'll be used to calculate a window's minimum size, instead of
+ * those set by this function.
+ *
+ * @see ecore_evas_size_min_get()
+ */
EAPI void ecore_evas_size_min_set(Ecore_Evas *ee, int w, int h);
+
+/**
+ * Get the minimum size set for a given @c Ecore_Evas window
+ *
+ * @param ee An @c Ecore_Evas window's handle
+ * @param w A pointer to an int to place the minimum width in.
+ * @param h A pointer to an int to place the minimum height in.
+ *
+ * @note Use @c NULL pointers on the size components you're not
+ * interested in: they'll be ignored by the function.
+ *
+ * @see ecore_evas_size_min_set() for more details
+ */
EAPI void ecore_evas_size_min_get(const Ecore_Evas *ee, int *w, int *h);
+
+/**
+ * Set the maximum size of a given @c Ecore_Evas window
+ *
+ * @param ee An @c Ecore_Evas window's handle
+ * @param w The maximum width
+ * @param h The maximum height
+ *
+ * This function sets the maximum size of @p ee to be @p w x @p h.
+ * One won't be able to resize that window to dimensions bigger than
+ * the ones set.
+ *
+ * @see ecore_evas_size_max_get()
+ */
EAPI void ecore_evas_size_max_set(Ecore_Evas *ee, int w, int h);
+
+/**
+ * Get the maximum size set for a given @c Ecore_Evas window
+ *
+ * @param ee An @c Ecore_Evas window's handle
+ * @param w A pointer to an int to place the maximum width in.
+ * @param h A pointer to an int to place the maximum height in.
+ *
+ * @note Use @c NULL pointers on the size components you're not
+ * interested in: they'll be ignored by the function.
+ *
+ * @see ecore_evas_size_max_set() for more details
+ */
EAPI void ecore_evas_size_max_get(const Ecore_Evas *ee, int *w, int *h);
+
+/**
+ * Set the base size for a given @c Ecore_Evas window
+ *
+ * @param ee An @c Ecore_Evas window's handle
+ * @param w The base width
+ * @param h The base height
+ *
+ * This function sets the @b base size of @p ee to be @p w x @p h.
+ * When base sizes are set, they'll be used to calculate a window's
+ * @b minimum size, instead of those set by ecore_evas_size_min_get().
+ *
+ * @see ecore_evas_size_base_get()
+ */
EAPI void ecore_evas_size_base_set(Ecore_Evas *ee, int w, int h);
+
+/**
+ * Get the base size set for a given @c Ecore_Evas window
+ *
+ * @param ee An @c Ecore_Evas window's handle
+ * @param w A pointer to an int to place the base width in.
+ * @param h A pointer to an int to place the base height in.
+ *
+ * @note Use @c NULL pointers on the size components you're not
+ * interested in: they'll be ignored by the function.
+ *
+ * @see ecore_evas_size_base_set() for more details
+ */
EAPI void ecore_evas_size_base_get(const Ecore_Evas *ee, int *w, int *h);
+
+/**
+ * Set the "size step" for a given @c Ecore_Evas window
+ *
+ * @param ee An @c Ecore_Evas window's handle
+ * @param w The step width
+ * @param h The step height
+ *
+ * This function sets the size steps of @p ee to be @p w x @p h. This
+ * limits the size of this @cEcore_Evas window to be @b always an
+ * integer multiple of the step size, for each axis.
+ */
EAPI void ecore_evas_size_step_set(Ecore_Evas *ee, int w, int h);
+
+/**
+ * Get the "size step" set for a given @c Ecore_Evas window
+ *
+ * @param ee An @c Ecore_Evas window's handle
+ * @param w A pointer to an int to place the step width in.
+ * @param h A pointer to an int to place the step height in.
+ *
+ * @note Use @c NULL pointers on the size components you're not
+ * interested in: they'll be ignored by the function.
+ *
+ * @see ecore_evas_size_base_set() for more details
+ */
EAPI void ecore_evas_size_step_get(const Ecore_Evas *ee, int *w, int *h);
+
EAPI void ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y);
EAPI void ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y);
EAPI void ecore_evas_cursor_get(const Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y);
EAPI void ecore_evas_x11_shape_input_reset(Ecore_Evas *ee);
EAPI void ecore_evas_x11_shape_input_apply(Ecore_Evas *ee);
+/**
+ * @}
+ */
+
#ifdef __cplusplus
}
#endif
if (c) *c = ee->prop.clas;
}
-/**
- * Set the min size of an Ecore_Evas' window
- * @param ee The Ecore_Evas to set
- * @param w The minimum width
- * @param h The minimum height
- *
- * This function sets the minimum size of @p ee to @p w x @p h.
- */
EAPI void
ecore_evas_size_min_set(Ecore_Evas *ee, int w, int h)
{
}
}
-/**
- * Get the min size of an Ecore_Evas' window
- * @param ee The Ecore_Evas to set
- * @param w A pointer to an int to place the min width in.
- * @param h A pointer to an int to place the min height in.
- *
- * This function puts the minimum size of @p ee into @p w and @p h.
- */
EAPI void
ecore_evas_size_min_get(const Ecore_Evas *ee, int *w, int *h)
{
}
}
-/**
- * Set the max size of an Ecore_Evas' window
- * @param ee The Ecore_Evas to set
- * @param w The maximum width
- * @param h The maximum height
- *
- * This function sets the maximum size of @p ee to @p w x @p h.
- */
EAPI void
ecore_evas_size_max_set(Ecore_Evas *ee, int w, int h)
{
}
}
-/**
- * Get the max size of an Ecore_Evas' window
- * @param ee The Ecore_Evas to set
- * @param w A pointer to an int to place the max width in.
- * @param h A pointer to an int to place the max height in.
- *
- * This function puts the maximum size of @p ee into @p w and @p h.
- */
EAPI void
ecore_evas_size_max_get(const Ecore_Evas *ee, int *w, int *h)
{
}
}
-/**
- * Set the base size of an Ecore_Evas' window
- * @param ee The Ecore_Evas to set
- * @param w The base width
- * @param h The base height
- *
- * This function sets the base size of @p ee to @p w x @p h.
- */
EAPI void
ecore_evas_size_base_set(Ecore_Evas *ee, int w, int h)
{
}
}
-/**
- * Get the base size of an Ecore_Evas' window
- * @param ee The Ecore_Evas to set
- * @param w A pointer to an int to place the base width in.
- * @param h A pointer to an int to place the base height in.
- *
- * This function puts the base size of @p ee into @p w and @p h.
- */
EAPI void
ecore_evas_size_base_get(const Ecore_Evas *ee, int *w, int *h)
{
}
}
-/**
- * Set the step size of an Ecore_Evas
- * @param ee The Ecore_Evas to set
- * @param w The step width
- * @param h The step height
- *
- * This function sets the step size of @p ee to @p w x @p h. This limits the
- * size of an Ecore_Evas to always being an integer multiple of the step size.
- */
EAPI void
ecore_evas_size_step_set(Ecore_Evas *ee, int w, int h)
{
}
}
-/**
- * Get the step size of an Ecore_Evas' window
- * @param ee The Ecore_Evas to set
- * @param w A pointer to an int to place the step width in.
- * @param h A pointer to an int to place the step height in.
- *
- * This function puts the step size of @p ee into @p w and @p h.
- */
EAPI void
ecore_evas_size_step_get(const Ecore_Evas *ee, int *w, int *h)
{