Exemple #1
0
/**
 * @param s: The separator to set the orientation on
 * @param o: The orientation to set on the separator
 * @return Returns no value
 * @brief Set the orientation of the separator
 */
void
ewl_separator_orientation_set(Ewl_Separator *s, Ewl_Orientation o)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(s);
        DCHECK_TYPE(s, EWL_SEPARATOR_TYPE);

        if (s->orientation == o)
                DRETURN(DLEVEL_STABLE);

        s->orientation = o;

        if (o == EWL_ORIENTATION_HORIZONTAL) {
                ewl_widget_appearance_set(EWL_WIDGET(s), "hseparator");
                ewl_object_fill_policy_set(EWL_OBJECT(s),
                                           EWL_FLAG_FILL_HFILL |
                                           EWL_FLAG_FILL_HSHRINKABLE);
        }
        else {
                ewl_widget_appearance_set(EWL_WIDGET(s), "vseparator");
                ewl_object_fill_policy_set(EWL_OBJECT(s),
                                           EWL_FLAG_FILL_VFILL |
                                           EWL_FLAG_FILL_VSHRINKABLE);
        }

        ewl_widget_configure(EWL_WIDGET(s));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Exemple #2
0
/**
 * @param b: the border container to initialize
 * @return Returns TRUE on success, FALSE on failure.
 * @brief Initialize a border container to default values
 */
int
ewl_border_init(Ewl_Border *b)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(b, FALSE);

        w = EWL_WIDGET(b);

        if (!ewl_box_init(EWL_BOX(w))) {
                DRETURN_INT(FALSE, DLEVEL_STABLE);
        }
        ewl_box_orientation_set(EWL_BOX(w), EWL_ORIENTATION_VERTICAL);
        ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_FILL);

        ewl_widget_appearance_set(EWL_WIDGET(b), EWL_BORDER_TYPE);
        ewl_widget_inherit(EWL_WIDGET(b), EWL_BORDER_TYPE);

        b->label = ewl_label_new();
        ewl_widget_internal_set(b->label, TRUE);
        ewl_container_child_append(EWL_CONTAINER(b), b->label);
        ewl_widget_show(b->label);

        b->body = ewl_vbox_new();
        ewl_widget_internal_set(b->body, TRUE);
        ewl_container_child_append(EWL_CONTAINER(b), b->body);
        ewl_widget_show(b->body);

        b->label_position = EWL_POSITION_TOP;

        ewl_container_redirect_set(EWL_CONTAINER(b), EWL_CONTAINER(b->body));

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #3
0
/**
 * @param w: the overlay to be initialized to default values and callbacks
 * @return Returns TRUE or FALSE depending on if initialization succeeds.
 * @brief initialize a overlay to default values and callbacks
 *
 * Sets the values and callbacks of a overlay @a w to their defaults.
 */
int
ewl_overlay_init(Ewl_Overlay *w)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(w, FALSE);

        /*
         * Initialize the fields of the inherited container class
         */
        if (!ewl_container_init(EWL_CONTAINER(w)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_appearance_set(EWL_WIDGET(w), EWL_OVERLAY_TYPE);
        ewl_widget_inherit(EWL_WIDGET(w), EWL_OVERLAY_TYPE);

        ewl_container_show_notify_set(EWL_CONTAINER(w),
                                        ewl_overlay_cb_child_show);
        ewl_container_resize_notify_set(EWL_CONTAINER(w),
                                        ewl_overlay_cb_child_resize);

        ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_NONE);

        /*
         * Override the default configure callbacks since the overlay
         * has special needs for placement.
         */
        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_CONFIGURE,
                             ewl_overlay_cb_configure, NULL);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #4
0
/**
 * @param s: the separator to initialize
 * @return Returns TRUE on success, FALSE on failure.
 * @brief Initialize the separator and inherited fields
 *
 * Clears the contents of the separator and stores the
 * default values.
 */
int
ewl_separator_init(Ewl_Separator *s)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(s, FALSE);

        w = EWL_WIDGET(s);
        if (!ewl_widget_init(w))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_inherit(w, EWL_SEPARATOR_TYPE);
        ewl_widget_appearance_set(EWL_WIDGET(s), "hseparator");
        ewl_object_fill_policy_set(EWL_OBJECT(s), EWL_FLAG_FILL_HFILL |
                                                  EWL_FLAG_FILL_SHRINKABLE);

        ewl_object_alignment_set(EWL_OBJECT(s), EWL_FLAG_ALIGN_LEFT);

        s->orientation = EWL_ORIENTATION_HORIZONTAL;

        ewl_widget_focusable_set(w, FALSE);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #5
0
/**
 * @param n: The Ewl_Notebook widget to initialize
 * @return Returns TRUE on success or NULL on failure.
 * @brief Initialize a notebook to default values and callbacks
 */
int
ewl_notebook_init(Ewl_Notebook *n)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(n, FALSE);

        if (!ewl_box_init(EWL_BOX(n)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_box_orientation_set(EWL_BOX(n), EWL_ORIENTATION_VERTICAL);

        ewl_widget_appearance_set(EWL_WIDGET(n), EWL_NOTEBOOK_TYPE);
        ewl_widget_inherit(EWL_WIDGET(n), EWL_NOTEBOOK_TYPE);

        n->tabbar_position = EWL_POSITION_TOP;

        n->body.tabbar = ewl_hbox_new();
        ewl_container_child_append(EWL_CONTAINER(n), n->body.tabbar);
        ewl_object_fill_policy_set(EWL_OBJECT(n->body.tabbar),
                                EWL_FLAG_FILL_NONE);
        ewl_object_alignment_set(EWL_OBJECT(n->body.tabbar),
                                                EWL_FLAG_ALIGN_CENTER);
        ewl_widget_internal_set(n->body.tabbar, TRUE);
        ewl_widget_appearance_set(n->body.tabbar, "top/tabbar");
        ewl_widget_show(n->body.tabbar);

        n->body.pages = ewl_vbox_new();
        ewl_object_fill_policy_set(EWL_OBJECT(n->body.pages),
                                   EWL_FLAG_FILL_ALL);
        ewl_container_child_append(EWL_CONTAINER(n), n->body.pages);
        ewl_widget_internal_set(n->body.pages, TRUE);
        ewl_widget_layer_priority_set(n->body.pages, -1);
        ewl_widget_appearance_set(n->body.pages, "pages");
        ewl_widget_show(n->body.pages);

        ewl_container_redirect_set(EWL_CONTAINER(n),
                                        EWL_CONTAINER(n->body.pages));

        ewl_container_show_notify_set(EWL_CONTAINER(n->body.pages),
                                        ewl_notebook_cb_child_show);
        ewl_container_hide_notify_set(EWL_CONTAINER(n->body.pages),
                                        ewl_notebook_cb_child_hide);
        ewl_container_add_notify_set(EWL_CONTAINER(n->body.pages),
                                        ewl_notebook_cb_child_add);
        ewl_container_remove_notify_set(EWL_CONTAINER(n->body.pages),
                                        ewl_notebook_cb_child_remove);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #6
0
/**
 * @param t: the toolbar to initialize
 * @return Returns TRUE on success, FALSE on failure.
 * @brief Initialize the toolbar and inherited fields
 *
 * Clears the contents of the toolbar and stores the
 * default values.
 */
int
ewl_toolbar_init(Ewl_Toolbar *t)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(t, FALSE);

        w = EWL_WIDGET(t);
        if (!ewl_menubar_init(EWL_MENUBAR(t)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_inherit(w, EWL_TOOLBAR_TYPE);
        ewl_widget_appearance_set(w, "htoolbar");

        ewl_object_fill_policy_set(EWL_OBJECT(t), EWL_FLAG_FILL_HFILL |
                                                  EWL_FLAG_FILL_SHRINKABLE);
        ewl_object_alignment_set(EWL_OBJECT(t), EWL_FLAG_ALIGN_LEFT |
                                                        EWL_FLAG_ALIGN_TOP);

        ewl_container_add_notify_set(EWL_CONTAINER(EWL_MENUBAR(t)->inner_box),
                                        ewl_toolbar_cb_child_add);
        t->hidden = EWL_ICON_PART_NONE;

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #7
0
/**
 * @param menu: the menu to work with
 * @return Returns no value
 * @brief Expand the popup portion of the menu
 */
void
ewl_menu_expand(Ewl_Menu *menu)
{
        Ewl_Menu_Item *item;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(menu);
        DCHECK_TYPE(menu, EWL_MENU_TYPE);

        item = EWL_MENU_ITEM(menu);

        /* nothing to do if the popup is already visible */
        if (VISIBLE(menu->popup))
                DRETURN(DLEVEL_STABLE);

        ewl_widget_show(menu->popup);
        ewl_window_raise(EWL_WINDOW(menu->popup));

        if (item->inmenu) {
                Ewl_Context_Menu *cm;

                cm = EWL_CONTEXT_MENU(item->inmenu);
                cm->open_menu = EWL_WIDGET(menu);
        }
        else
                ewl_widget_focus_send(menu->popup);

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Exemple #8
0
/**
 * @param sp: The Ewl_Spectrum to set the hsv value into
 * @param h: The hue to set
 * @param s: The saturation to set
 * @param v: The value to set
 * @return Returns no value
 * @brief Set the HSV values for the spectrum
 */
void
ewl_spectrum_hsv_set(Ewl_Spectrum *sp, double h, double s, double v)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(sp);
        DCHECK_TYPE(sp, EWL_SPECTRUM_TYPE);

        sp->hsv.h = h;
        sp->hsv.s = s;
        sp->hsv.v = v;

        if (sp->hsv.h > 360) sp->hsv.h = 360.0;
        if (sp->hsv.h <= 0) sp->hsv.h = 360.0;

        if (sp->hsv.s > 1.0) sp->hsv.s = 1.0;
        if (sp->hsv.s < 0.0) sp->hsv.s = 0.0;

        if (sp->hsv.v > 1.0) sp->hsv.v = 1.0;
        if (sp->hsv.v < 0.0) sp->hsv.v = 0.0;

        ewl_spectrum_rgb_from_hsv(sp);
        sp->dirty = TRUE;
        ewl_widget_configure(EWL_WIDGET(sp));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Exemple #9
0
/**
 * @param p: the popup to initialize
 * @return Returns TRUE on success, FALSE on failure.
 * @brief Initialize the popup and inherited fields
 *
 * Clears the contents of the popup and stores the
 * default values.
 */
int
ewl_popup_init(Ewl_Popup *p)
{
        Ewl_Widget *w;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(p, FALSE);

        w = EWL_WIDGET(p);
        if (!ewl_window_init(EWL_WINDOW(w)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_inherit(w, EWL_POPUP_TYPE);
        ewl_widget_appearance_set(w, EWL_POPUP_TYPE);
        ewl_object_fill_policy_set(EWL_OBJECT(p), EWL_FLAG_FILL_NONE);

        ewl_window_override_set(EWL_WINDOW(p), TRUE);

        ewl_container_show_notify_set(EWL_CONTAINER(p),
                                        ewl_popup_cb_child_show);
        ewl_container_resize_notify_set(EWL_CONTAINER(p),
                                        ewl_popup_cb_child_resize);

        /*
         * add the callbacks
         */
        ewl_callback_append(w, EWL_CALLBACK_SHOW, ewl_popup_cb_show, NULL);
        ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_popup_cb_show, NULL);
        ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE, ewl_popup_cb_mouse_move,
                                                                        NULL);
        ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_popup_cb_destroy,
                                                                        NULL);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #10
0
/**
 * @param win: window to set transient
 * @param forwin: the window to be transient for
 * @return Returns no value.
 * @brief Sets a window to be transient for another window.
 */
void
ewl_window_transient_for(Ewl_Window *win, Ewl_Window *forwin)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(win);
        DCHECK_TYPE(win, EWL_WINDOW_TYPE);
        DCHECK_TYPE(forwin, EWL_WINDOW_TYPE);

        win->transient.ewl = forwin;
        win->flags &= ~EWL_WINDOW_TRANSIENT_FOREIGN;

        /* if there is no forwin remove the transient for state
         * and update the window, if it already exists */
        if (!forwin) {
                win->flags &= ~EWL_WINDOW_TRANSIENT;
                if (win->window)
                        ewl_engine_window_transient_for(win);

                DRETURN(DLEVEL_STABLE);
        }

        win->flags |= EWL_WINDOW_TRANSIENT;

        if (win->window) {
                if (forwin->window)
                        ewl_engine_window_transient_for(win);
                else
                        ewl_callback_append(EWL_WIDGET(forwin),
                                            EWL_CALLBACK_REALIZE,
                                            ewl_window_cb_realize_parent,
                                            win);
        }

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Exemple #11
0
/**
 * @internal
 * @param c: The container to work with
 * @param w: The widget to work with
 * @return Returns no value
 * @brief The child add callback
 */
void
ewl_notebook_cb_child_add(Ewl_Container *c, Ewl_Widget *w)
{
        Ewl_Notebook *n;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(c);
        DCHECK_PARAM_PTR(w);
        DCHECK_TYPE(c, EWL_CONTAINER_TYPE);
        DCHECK_TYPE(w, EWL_WIDGET_TYPE);

        n = EWL_NOTEBOOK(EWL_WIDGET(c)->parent);

        /* stick a null tab in there so that it at least shows up */
        ewl_notebook_page_tab_widget_set(n, w, NULL);

        /* we have no current page, make it this one */
        if (!n->cur_page)
        {
                ewl_notebook_visible_page_set(n, w);
                ewl_widget_show(w);
        }

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Exemple #12
0
/**
 * @param t: The toolbar to set the orientation on
 * @param o: The orientation to set on the toolbar
 * @return Returns no value
 * @brief Set the orientation of the toolbar
 */
void
ewl_toolbar_orientation_set(Ewl_Toolbar *t, Ewl_Orientation o)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(t);
        DCHECK_TYPE(t, EWL_TOOLBAR_TYPE);

        ewl_menubar_orientation_set(EWL_MENUBAR(t), o);
        if (o == EWL_ORIENTATION_HORIZONTAL)
                ewl_widget_appearance_set(EWL_WIDGET(t), "htoolbar");
        else
                ewl_widget_appearance_set(EWL_WIDGET(t), "vtoolbar");

        ewl_widget_configure(EWL_WIDGET(t));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Exemple #13
0
/**
 * @return Returns pointer to new popup widget on success, NULL on failure.
 * @brief Allocate a new popup widget
 */
Ewl_Widget *
ewl_popup_new(void)
{
        Ewl_Popup  *p;

        DENTER_FUNCTION(DLEVEL_STABLE);

        p = NEW(Ewl_Popup, 1);
        if (!p)
                DRETURN_PTR(NULL, DLEVEL_STABLE);

        if (!ewl_popup_init(p)) {
                ewl_widget_destroy(EWL_WIDGET(p));
                p = NULL;
        }

        DRETURN_PTR(EWL_WIDGET(p), DLEVEL_STABLE);
}
Exemple #14
0
/**
 * @return Returns a pointer to a new dvi widget on success, NULL on failure.
 * @brief Load an dvi widget with specified dvi contents
 */
Ewl_Widget *
ewl_dvi_new(void)
{
        Ewl_Dvi *dvi;

        DENTER_FUNCTION(DLEVEL_STABLE);

        dvi = NEW(Ewl_Dvi, 1);
        if (!dvi)
                DRETURN_PTR(NULL, DLEVEL_STABLE);

        if (!ewl_dvi_init(dvi)) {
                ewl_widget_destroy(EWL_WIDGET(dvi));
                dvi = NULL;
        }

        DRETURN_PTR(EWL_WIDGET(dvi), DLEVEL_STABLE);
}
Exemple #15
0
/**
 * @return Returns a pointer to a new pdf widget on success, NULL on failure.
 * @brief Load an pdf widget with specified pdf contents
 */
Ewl_Widget *
ewl_pdf_new(void)
{
        Ewl_Pdf *pdf;

        DENTER_FUNCTION(DLEVEL_STABLE);

        pdf = NEW(Ewl_Pdf, 1);
        if (!pdf)
                DRETURN_PTR(NULL, DLEVEL_STABLE);

        if (!ewl_pdf_init(pdf)) {
                ewl_widget_destroy(EWL_WIDGET(pdf));
                pdf = NULL;
        }

        DRETURN_PTR(EWL_WIDGET(pdf), DLEVEL_STABLE);
}
Exemple #16
0
/**
 * @return Returns a pointer to a new menu on success, NULL on failure.
 * @brief Create a new internal menu
 */
Ewl_Widget *
ewl_menu_new(void)
{
        Ewl_Menu *menu;

        DENTER_FUNCTION(DLEVEL_STABLE);

        menu = NEW(Ewl_Menu, 1);
        if (!menu)
                DRETURN_PTR(NULL, DLEVEL_STABLE);

        if (!ewl_menu_init(menu)) {
                ewl_widget_destroy(EWL_WIDGET(menu));
                menu = NULL;
        }

        DRETURN_PTR(EWL_WIDGET(menu), DLEVEL_STABLE);
}
Exemple #17
0
/**
 * @return Returns pointer to new separator widget on success, NULL on failure.
 * @brief Allocate a new separator widget with default (horizontal) orientation
 */
Ewl_Widget *
ewl_separator_new(void)
{
        Ewl_Separator  *s;

        DENTER_FUNCTION(DLEVEL_STABLE);

        s = NEW(Ewl_Separator, 1);
        if (!s)
                DRETURN_PTR(NULL, DLEVEL_STABLE);

        if (!ewl_separator_init(s)) {
                ewl_widget_destroy(EWL_WIDGET(s));
                s = NULL;
        }

        DRETURN_PTR(EWL_WIDGET(s), DLEVEL_STABLE);
}
Exemple #18
0
/**
 * @return Returns pointer to new toolbar widget on success, NULL on failure.
 * @brief Allocate a new toolbar widget with default (horizontal) orientation
 */
Ewl_Widget *
ewl_toolbar_new(void)
{
        Ewl_Toolbar  *t;

        DENTER_FUNCTION(DLEVEL_STABLE);

        t = NEW(Ewl_Toolbar, 1);
        if (!t)
                DRETURN_PTR(NULL, DLEVEL_STABLE);

        if (!ewl_toolbar_init(t)) {
                ewl_widget_destroy(EWL_WIDGET(t));
                t = NULL;
        }

        DRETURN_PTR(EWL_WIDGET(t), DLEVEL_STABLE);
}
Exemple #19
0
/**
 * @return Returns a new overlay container on success, or NULL on failure.
 * @brief Allocate and initialize a new overlay container
 */
Ewl_Widget *
ewl_overlay_new(void)
{
        Ewl_Overlay *w;

        DENTER_FUNCTION(DLEVEL_STABLE);

        w = NEW(Ewl_Overlay, 1);
        if (!w)
                DRETURN_PTR(NULL, DLEVEL_STABLE);

        if (!ewl_overlay_init(w)) {
                ewl_widget_destroy(EWL_WIDGET(w));
                w = NULL;
        }

        DRETURN_PTR(EWL_WIDGET(w), DLEVEL_STABLE);
}
Exemple #20
0
/**
 * @return Returns a pointer to a new ps widget on success, NULL on failure.
 * @brief Create a ps widget
 */
Ewl_Widget *
ewl_ps_new(void)
{
        Ewl_Ps *ps;

        DENTER_FUNCTION(DLEVEL_STABLE);

        ps = NEW(Ewl_Ps, 1);
        if (!ps)
                DRETURN_PTR(NULL, DLEVEL_STABLE);

        if (!ewl_ps_init(ps)) {
                ewl_widget_destroy(EWL_WIDGET(ps));
                ps = NULL;
        }

        DRETURN_PTR(EWL_WIDGET(ps), DLEVEL_STABLE);
}
Exemple #21
0
/**
 * @param b: The Ewl_Border to set the label position on
 * @param pos: The Ewl_Position to set on for the label.
 * @return Returns no value.
 * @brief Sets the position of the label in the border container
 */
void
ewl_border_label_position_set(Ewl_Border *b, Ewl_Position pos)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(b);
        DCHECK_TYPE(b, EWL_BORDER_TYPE);

        if (b->label_position == pos) 
                DRETURN(DLEVEL_STABLE);

        b->label_position = pos;
        switch (b->label_position) {
                case EWL_POSITION_LEFT:
                case EWL_POSITION_RIGHT:
                        ewl_box_orientation_set(EWL_BOX(b),
                                                EWL_ORIENTATION_HORIZONTAL);
                        break;

                case EWL_POSITION_TOP:
                case EWL_POSITION_BOTTOM:
                default:
                        ewl_box_orientation_set(EWL_BOX(b),
                                                EWL_ORIENTATION_VERTICAL);
                        break;
        }
        ewl_widget_appearance_set(EWL_WIDGET(b), EWL_BORDER_TYPE);

        /* need to remove the redirect so the label gets added back into the
         * border and not into the body. We put the redirect back on after
         */
        ewl_container_redirect_set(EWL_CONTAINER(b), NULL);
        ewl_container_child_remove(EWL_CONTAINER(b), b->label);

        if ((b->label_position == EWL_POSITION_LEFT)
                        || (b->label_position == EWL_POSITION_TOP))
                ewl_container_child_prepend(EWL_CONTAINER(b), b->label);
        else
                ewl_container_child_append(EWL_CONTAINER(b), b->label);

        ewl_container_redirect_set(EWL_CONTAINER(b), EWL_CONTAINER(b->body));
        ewl_widget_configure(EWL_WIDGET(b));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Exemple #22
0
/**
 * @return Returns a new border container on success, NULL on failure.
 * @brief Allocate and initialize a new border container
 */
Ewl_Widget *
ewl_border_new(void)
{
        Ewl_Border *b;

        DENTER_FUNCTION(DLEVEL_STABLE);

        b = NEW(Ewl_Border, 1);
        if (!b) {
                DRETURN_PTR(NULL, DLEVEL_STABLE);
        }

        if (!ewl_border_init(b)) {
                ewl_widget_destroy(EWL_WIDGET(b));
                b = NULL;
        }

        DRETURN_PTR(EWL_WIDGET(b), DLEVEL_STABLE);
}
Exemple #23
0
/**
 * @return Returns a pointer to a new icondialog on success, NULL on failure.
 * @brief Create a new internal icondialog
 */
Ewl_Widget *
ewl_icondialog_new(void)
{
        Ewl_Icondialog *d;

        DENTER_FUNCTION(DLEVEL_STABLE);

        d = NEW(Ewl_Icondialog, 1);
        if (!d) {
                DRETURN_PTR(NULL, DLEVEL_STABLE);
        }

        if (!ewl_icondialog_init(d)) {
                ewl_widget_destroy(EWL_WIDGET(d));
                d = NULL;
        }

        DRETURN_PTR(EWL_WIDGET(d), DLEVEL_STABLE);
}
Exemple #24
0
/**
 * @param menu: the menu to initialize
 * @return Returns no value.
 * @brief Initialize an internal menu to starting values
 */
int
ewl_menu_init(Ewl_Menu *menu)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(menu, FALSE);

        /*
         * Initialize the defaults of the inherited fields.
         */
        if (!ewl_menu_item_init(EWL_MENU_ITEM(menu)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_appearance_set(EWL_WIDGET(menu), "menu_container");
        ewl_widget_inherit(EWL_WIDGET(menu), EWL_MENU_TYPE);

        /*
         * add the callbacks
         */
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_MOUSE_MOVE,
                            ewl_menu_cb_mouse_move, NULL);
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_FOCUS_IN,
                            ewl_menu_cb_expand, NULL);
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_CLICKED,
                            ewl_menu_cb_expand, NULL);
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_CONFIGURE,
                            ewl_menu_cb_configure, NULL);
        ewl_callback_prepend(EWL_WIDGET(menu), EWL_CALLBACK_DESTROY,
                                ewl_menu_cb_destroy, NULL);

        /*
         * Create the popup menu portion of the widget.
         */
        menu->popup = ewl_context_menu_new();
        ewl_popup_follow_set(EWL_POPUP(menu->popup), EWL_WIDGET(menu));
        ewl_popup_type_set(EWL_POPUP(menu->popup),
                                        EWL_POPUP_TYPE_MENU_VERTICAL);
        ewl_widget_internal_set(menu->popup, TRUE);
        ewl_widget_appearance_set(EWL_WIDGET(menu->popup), EWL_MENU_TYPE);

        /* redirect the menu container to the popup menu */
        ewl_container_redirect_set(EWL_CONTAINER(menu),
                                        EWL_CONTAINER(menu->popup));
        ewl_callback_prepend(menu->popup, EWL_CALLBACK_DESTROY,
                                ewl_menu_cb_popup_destroy, menu);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #25
0
/**
 * @param w: the window to be initialized to default values and callbacks
 * @return Returns TRUE or FALSE depending on if initialization succeeds.
 * @brief Initialize a window to default values and callbacks
 *
 * Sets the values and callbacks of a window @a w to their defaults.
 */
int
ewl_window_init(Ewl_Window *w)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(w, FALSE);

        /*
         * Initialize the fields of the inherited container class
         */
        if (!ewl_embed_init(EWL_EMBED(w)))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        ewl_widget_appearance_set(EWL_WIDGET(w), EWL_WINDOW_TYPE);
        ewl_widget_inherit(EWL_WIDGET(w), EWL_WINDOW_TYPE);
        ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_FILL);
        ewl_embed_render_set(EWL_EMBED(w), TRUE);

        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_REALIZE,
                             ewl_window_cb_realize, NULL);
        ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_REALIZE,
                             ewl_window_cb_postrealize, NULL);
        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_UNREALIZE,
                             ewl_window_cb_unrealize, NULL);
        ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_SHOW,
                            ewl_window_cb_show, NULL);
        ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_EXPOSE,
                            ewl_window_cb_expose, NULL);
        ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_HIDE,
                            ewl_window_cb_hide, NULL);
        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_DESTROY,
                             ewl_window_cb_destroy, NULL);
        /*
         * Override the default configure callbacks since the window
         * has special needs for placement.
         */
        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_CONFIGURE,
                             ewl_window_cb_configure, NULL);

        ecore_list_append(ewl_window_list, w);

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #26
0
/**
 * @param dvi: the dvi widget to change the displayed dvi
 * @param filename: the path to the new dvi to be displayed by @a dvi
 * @return Returns no value.
 * @brief Change the dvi file displayed by an dvi widget
 *
 * Set the dvi displayed by @a dvi to the one found at the path @a filename. If an
 * edje is used, a minimum size should be specified in the edje or the code.
 */
int
ewl_dvi_file_set(Ewl_Dvi *dvi, const char *filename)
{
        Ewl_Widget *w;
        Ewl_Embed *emb;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(dvi, FALSE);
        DCHECK_TYPE(dvi, EWL_DVI_TYPE);

        w = EWL_WIDGET(dvi);
        emb = ewl_embed_widget_find(w);

        if (!filename || (filename[0] == '\0'))
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        if (dvi->filename != filename) {
                IF_FREE(dvi->filename);
        }

        if (dvi->dvi_page) {
                edvi_page_delete(dvi->dvi_page);
                dvi->dvi_page = NULL;
        }

        if (dvi->dvi_document) {
                edvi_document_delete(dvi->dvi_document);
                dvi->dvi_document = NULL;
        }

        dvi->filename = strdup(filename);

        /*
         * Load the new dvi if widget has been realized
         */

        dvi->dvi_document = edvi_document_new(dvi->filename, dvi->dvi_device, dvi->dvi_property);
        if (!dvi->dvi_document)
                DRETURN_INT(FALSE, DLEVEL_STABLE);

        dvi->dvi_page = edvi_page_new(dvi->dvi_document);
        if (!dvi->dvi_page) {
                edvi_document_delete(dvi->dvi_document);
                dvi->dvi_document = NULL;
                DRETURN_INT(FALSE, DLEVEL_STABLE);
        }

        if (REALIZED(w)) {
                ewl_widget_obscure(w);
                ewl_widget_reveal(w);
        }

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #27
0
/**
 * @param sp: The Ewl_Spectrum to set the type on
 * @param type: The type to set the spectrum too
 * @return Returns no value
 * @brief Set the type of the spectrum
 */
void
ewl_spectrum_type_set(Ewl_Spectrum *sp, Ewl_Spectrum_Type type)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(sp);
        DCHECK_TYPE(sp, EWL_SPECTRUM_TYPE);

        sp->type = type;
        ewl_widget_configure(EWL_WIDGET(sp));

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Exemple #28
0
/**
 * @internal
 * @param c: The container to work with
 * @param w: The widget to work with
 * @param rem_idx: UNUSED
 * @return Returns no value
 * @brief The child remove callback
 */
void
ewl_notebook_cb_child_remove(Ewl_Container *c, Ewl_Widget *w, int idx)
{
        Ewl_Widget *t;
        Ewl_Notebook *n;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(c);
        DCHECK_PARAM_PTR(w);
        DCHECK_TYPE(c, EWL_CONTAINER_TYPE);
        DCHECK_TYPE(w, EWL_WIDGET_TYPE);

        n = EWL_NOTEBOOK(EWL_WIDGET(c)->parent);

        /* we still have a tab, delete it */
        t = ewl_attach_widget_association_get(w);
        if (t)
                ewl_widget_destroy(t);


        /* change visible pages if needed */
        if (w == n->cur_page)
        {
                Ewl_Widget *page, *new_tab;
                int count;

                count = ewl_container_child_count_get(
                                                EWL_CONTAINER(n->body.tabbar));

                if (count <= 0)
                        n->cur_page = NULL;
                else
                {
                        /* make sure we aren't off the end of the list */
                        if (idx >= count) idx = count - 1;

                        new_tab = ewl_container_child_get(
                                        EWL_CONTAINER(n->body.tabbar), idx);

                        if (new_tab)
                        {
                                page = ewl_attach_widget_association_get(
                                                                new_tab);
                                if (page)
                                        ewl_notebook_visible_page_set(
                                                        EWL_NOTEBOOK(n), page);
                        }
                }

        }

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Exemple #29
0
/**
 * @param e: The Ewl_Entry to set the editable status of
 * @param editable: The value to set for the editable flag
 * @return Returns no value
 * @brief Set if the entry is editable or not
 */
void
ewl_entry_editable_set(Ewl_Entry *e, unsigned int editable)
{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(e);
        DCHECK_TYPE(e, EWL_ENTRY_TYPE);

        if (e->editable == !!editable)
                DRETURN(DLEVEL_STABLE);

        e->editable = !!editable;

        if (e->editable)
        {
                ewl_callback_append(EWL_WIDGET(e), EWL_CALLBACK_KEY_DOWN,
                                                ewl_entry_cb_key_down, NULL);

                if (ewl_widget_state_has(EWL_WIDGET(e), EWL_STATE_FOCUSED))
                        ewl_widget_show(e->cursor);

                ewl_widget_state_add(EWL_WIDGET(e), EWL_STATE_ON);
        }
        else
        {
                ewl_callback_del(EWL_WIDGET(e), EWL_CALLBACK_KEY_DOWN,
                                                ewl_entry_cb_key_down);

                if (ewl_widget_state_has(EWL_WIDGET(e), EWL_STATE_FOCUSED))
                        ewl_widget_hide(e->cursor);

                ewl_widget_state_remove(EWL_WIDGET(e), EWL_STATE_ON);
        }

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
static int
create_test(Ewl_Container *box)
{
        Ewl_Widget *overlay;
        Ewl_Widget *img;
        Ewl_Widget *hist;

        overlay = ewl_overlay_new();
        ewl_container_child_append(EWL_CONTAINER(box), overlay);
        ewl_object_fill_policy_set(EWL_OBJECT(overlay), EWL_FLAG_FILL_ALL);
         ewl_callback_append(EWL_WIDGET(overlay), EWL_CALLBACK_CONFIGURE,
                        ewl_histogram_test_cb_configure, NULL);
        ewl_widget_show(overlay);

        img = ewl_image_new();
        ewl_image_file_path_set(EWL_IMAGE(img),
                                ewl_test_image_get("entrance.png"));
        ewl_image_proportional_set(EWL_IMAGE(img), TRUE);
        ewl_container_child_append(EWL_CONTAINER(overlay), img);
        ewl_object_fill_policy_set(EWL_OBJECT(img), EWL_FLAG_FILL_ALL);
        ewl_widget_show(img);

        hist = ewl_histogram_new();
        ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_Y);
        ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(img));
        ewl_container_child_append(EWL_CONTAINER(overlay), hist);
        ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
        ewl_widget_show(hist);

        hist = ewl_histogram_new();
        ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_R);
        ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(img));
        ewl_container_child_append(EWL_CONTAINER(overlay), hist);
        ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
        ewl_widget_show(hist);

        hist = ewl_histogram_new();
        ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_G);
        ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(img));
        ewl_container_child_append(EWL_CONTAINER(overlay), hist);
        ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
        ewl_widget_show(hist);

        hist = ewl_histogram_new();
        ewl_histogram_channel_set(EWL_HISTOGRAM(hist), EWL_HISTOGRAM_CHANNEL_B);
        ewl_histogram_image_set(EWL_HISTOGRAM(hist), EWL_IMAGE(img));
        ewl_container_child_append(EWL_CONTAINER(overlay), hist);
        ewl_object_fill_policy_set(EWL_OBJECT(hist), EWL_FLAG_FILL_ALL);
        ewl_widget_show(hist);

        return 1;
}