Added the elm_win_util_dialog_add() API function

This new @feature is just a convenient way to create dialogs, It
mimic the elm_win_util_standard_add() function but crete a
standard dialog, with background and the parent set.

WinDialog test changed to use the new function.
This commit is contained in:
Davide Andreoli 2015-01-03 14:13:35 +01:00
parent 62ef7d3465
commit d4f5df772d
3 changed files with 49 additions and 11 deletions

View File

@ -6,19 +6,14 @@
void
test_win_dialog(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *win, *bg, *bt;
Evas_Object *win, *bt;
Evas_Object *parent = data;
win = elm_win_add(data, "window-dialog", ELM_WIN_DIALOG_BASIC);
elm_win_title_set(win, "Window Dialog");
win = elm_win_util_dialog_add(parent, "window-dia", "Dialog Window");
elm_win_autodel_set(win, EINA_TRUE);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
bt = elm_button_add(win);
elm_object_text_set(bt, "OK");
elm_object_text_set(bt, "This is a dialog window");
evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bt);

View File

@ -3594,8 +3594,7 @@ _elm_win_trap_data_get(Eo *obj EINA_UNUSED, Elm_Win_Data *pd)
EAPI Evas_Object *
elm_win_util_standard_add(const char *name,
const char *title)
elm_win_util_standard_add(const char *name, const char *title)
{
Evas_Object *win, *bg;
@ -3616,6 +3615,28 @@ elm_win_util_standard_add(const char *name,
return win;
}
EAPI Evas_Object *
elm_win_util_dialog_add(Evas_Object *parent, const char *name, const char *title)
{
Evas_Object *win, *bg;
win = elm_win_add(parent, name, ELM_WIN_DIALOG_BASIC);
if (!win) return NULL;
elm_win_title_set(win, title);
bg = elm_bg_add(win);
if (!bg)
{
evas_object_del(win);
return NULL;
}
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
return win;
}
EOLIAN static void
_elm_win_resize_object_add(Eo *obj, Elm_Win_Data *sd, Evas_Object *subobj)
{

View File

@ -35,6 +35,28 @@ EAPI Evas_Object *elm_win_add(Evas_Object *parent, const char *name, El
*/
EAPI Evas_Object *elm_win_util_standard_add(const char *name, const char *title);
/**
* Adds a window object with dialog setup
*
* @param parent The parent window
* @param name The name of the window
* @param title The title for the window
*
* This creates a window like elm_win_add() but also puts in a standard
* background with elm_bg_add(), as well as setting the window title to
* @p title. The window type created is of type ELM_WIN_DIALOG_BASIC.
* This tipe of window will be handled in special mode by window managers
* with regards of it's @p parent window.
*
* @return The created object, or @c NULL on failure
*
* @see elm_win_add()
*
* @ingroup Win
* @since 1.13
*/
EAPI Evas_Object *elm_win_util_dialog_add(Evas_Object *parent, const char *name, const char *title);
/**
* Set the floating mode of a window.
*