/** * @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); }
Ewl_Widget * widget_new( char *name ) { Ewler_Widget *w; if( !name ) return NULL; w = spec_new( name ); if( !w || !w->w ) return NULL; w->selected = false; ewl_callback_append(w->w, EWL_CALLBACK_REALIZE, realize, w); ewl_callback_append(w->w, EWL_CALLBACK_CONFIGURE, configure, w); ewl_widget_show(w->w); w->bg = ewl_vbox_new(); w->bg->data = ecore_hash_new(ecore_str_hash, ecore_str_compare); ewl_widget_appearance_set(w->bg, "select_bg"); ewl_theme_data_str_set(w->bg, "/select_bg/file", EWLER_EET); ewl_theme_data_str_set(w->bg, "/select_bg/group", "select_bg"); ewl_object_fill_policy_set(EWL_OBJECT(w->bg), EWL_FLAG_FILL_NONE); ewl_widget_data_set(w->bg, "EWLER_WIDGET", w); ewl_container_child_append(EWL_CONTAINER(w->bg), w->w); ewl_widget_show(w->bg); w->fg = ewl_vbox_new(); w->fg->data = ecore_hash_new(ecore_str_hash, ecore_str_compare); ewl_widget_appearance_set(w->fg, "select_fg"); ewl_theme_data_str_set(w->fg, "/select_fg/file", EWLER_EET); ewl_theme_data_str_set(w->fg, "/select_fg/group", "select_fg"); ewl_callback_append(w->fg, EWL_CALLBACK_CONFIGURE, fg_configure, w); ewl_callback_append(w->fg, EWL_CALLBACK_REALIZE, fg_realize, w); ewl_callback_append(w->fg, EWL_CALLBACK_FOCUS_IN, fg_mouse_in, w); ewl_callback_append(w->fg, EWL_CALLBACK_FOCUS_OUT, fg_mouse_out, w); ewl_callback_append(w->fg, EWL_CALLBACK_MOUSE_DOWN, fg_mouse_down, w); ewl_callback_append(w->fg, EWL_CALLBACK_MOUSE_UP, fg_mouse_up, w); ewl_callback_append(w->fg, EWL_CALLBACK_MOUSE_MOVE, fg_mouse_move, w); ewl_callback_append(w->fg, EWL_CALLBACK_DESTROY, widget_destroy, w); ewl_object_fill_policy_set(EWL_OBJECT(w->fg), EWL_FLAG_FILL_NONE); ewl_widget_data_set(w->fg, "EWLER_WIDGET", w); ewl_container_child_append(EWL_CONTAINER(w->fg), w->bg); ewl_widget_show(w->fg); w->selectable = true; w->configured = false; return w->fg; }
/** * @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); }
/** * @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); }
/** * @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); }
/** * @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); }
/** * @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); }
/** * @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); }
/** * @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); }
/** * @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); }
/** * @param sp: The Ewl_Spectrum to init * @return Returns TRUE on success or FALSE on failure * @brief Initializes an Ewl_Specturm widget to default values */ int ewl_spectrum_init(Ewl_Spectrum *sp) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(sp, FALSE); if (!ewl_container_init(EWL_CONTAINER(sp))) { DRETURN_INT(FALSE, DLEVEL_STABLE); } ewl_widget_appearance_set(EWL_WIDGET(sp), EWL_SPECTRUM_TYPE); ewl_widget_inherit(EWL_WIDGET(sp), EWL_SPECTRUM_TYPE); ewl_object_fill_policy_set(EWL_OBJECT(sp), EWL_FLAG_FILL_FILL); ewl_container_callback_intercept(EWL_CONTAINER(sp), EWL_CALLBACK_MOUSE_MOVE); ewl_container_callback_intercept(EWL_CONTAINER(sp), EWL_CALLBACK_MOUSE_DOWN); ewl_container_callback_intercept(EWL_CONTAINER(sp), EWL_CALLBACK_MOUSE_UP); ewl_callback_append(EWL_WIDGET(sp), EWL_CALLBACK_MOUSE_DOWN, ewl_spectrum_cb_mouse_down, NULL); ewl_callback_append(EWL_WIDGET(sp), EWL_CALLBACK_MOUSE_UP, ewl_spectrum_cb_mouse_up, NULL); sp->type = EWL_SPECTRUM_TYPE_SQUARE; /* create the canvas */ sp->canvas = ewl_image_new(); ewl_container_child_append(EWL_CONTAINER(sp), sp->canvas); ewl_object_fill_policy_set(EWL_OBJECT(sp->canvas), EWL_FLAG_FILL_FILL); ewl_widget_internal_set(sp->canvas, TRUE); ewl_callback_append(EWL_WIDGET(sp->canvas), EWL_CALLBACK_REVEAL, ewl_spectrum_canvas_cb_reveal, sp); ewl_widget_show(sp->canvas); /* create the cross hairs to draw on the spectrum */ sp->cross_hairs.horizontal = ewl_hseparator_new(); ewl_container_child_append(EWL_CONTAINER(sp), sp->cross_hairs.horizontal); ewl_widget_internal_set(sp->cross_hairs.horizontal, TRUE); ewl_widget_layer_priority_set(sp->cross_hairs.horizontal, 1); sp->cross_hairs.vertical = ewl_vseparator_new(); ewl_container_child_append(EWL_CONTAINER(sp), sp->cross_hairs.vertical); ewl_widget_internal_set(sp->cross_hairs.vertical, TRUE); ewl_widget_layer_priority_set(sp->cross_hairs.vertical, 1); ewl_callback_append(EWL_WIDGET(sp), EWL_CALLBACK_CONFIGURE, ewl_spectrum_cb_configure, NULL); ewl_spectrum_rgb_set(sp, 255, 255, 255); DRETURN_INT(TRUE, DLEVEL_STABLE); }
/** * @return Returns a new password widget on success, NULL on failure. * @brief Allocate and initialize a new password widget * * A password widget is an entry with a set obscure character. The default is a * star (*) */ Ewl_Widget * ewl_password_new(void) { Ewl_Widget *e; DENTER_FUNCTION(DLEVEL_STABLE); e = ewl_entry_new(); ewl_widget_appearance_set(e, "password/"EWL_ENTRY_TYPE); ewl_text_obscure_set(EWL_TEXT(e), "*"); DRETURN_PTR(e, DLEVEL_STABLE); }
/** * @param pdf the pdf widget to initialize * @return Returns no value. * @brief Initialize an pdf widget to default values and callbacks * * Sets the fields and callbacks of @a pdf to their default values. */ int ewl_pdf_init(Ewl_Pdf *pdf) { Ewl_Widget *w; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(pdf, FALSE); if (!epdf_init()) DRETURN_INT(FALSE, DLEVEL_STABLE); w = EWL_WIDGET(pdf); if (!ewl_widget_init(w)) DRETURN_INT(FALSE, DLEVEL_STABLE); ewl_widget_appearance_set(w, EWL_PDF_TYPE); ewl_widget_inherit(w, EWL_PDF_TYPE); ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_NONE); /* * Append necessary callbacks. */ ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_pdf_configure_cb, NULL); ewl_callback_append(w, EWL_CALLBACK_REVEAL, ewl_pdf_reveal_cb, NULL); ewl_callback_append(w, EWL_CALLBACK_OBSCURE, ewl_pdf_obscure_cb, NULL); ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_pdf_destroy_cb, NULL); pdf->filename = NULL; pdf->pdf_document = NULL; pdf->pdf_page = NULL; pdf->pdf_index = NULL; pdf->dirty = 1; pdf->search.o = NULL; pdf->search.text = NULL; pdf->search.list = NULL; pdf->search.page = -1; pdf->search.is_case_sensitive = FALSE; pdf->search.is_circular = FALSE; DRETURN_INT(TRUE, DLEVEL_STABLE); }
/** * @param n: The Ewl_Notebook to set the tab into * @param page: The page to associate the tab with * @param tab: The contents of the tab * @return Returns no value. * @brief Set the widget to use as the tab for the page @p page to widget @p tab */ void ewl_notebook_page_tab_widget_set(Ewl_Notebook *n, Ewl_Widget *page, Ewl_Widget *tab) { Ewl_Widget *t; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(n); DCHECK_PARAM_PTR(page); DCHECK_TYPE(n, EWL_NOTEBOOK_TYPE); DCHECK_TYPE(page, EWL_WIDGET_TYPE); if (!tab) { tab = ewl_label_new(); ewl_widget_show(tab); } t = ewl_attach_widget_association_get(page); if (!t) { int idx = 0; t = ewl_hbox_new(); ewl_widget_appearance_set(t, "tab"); ewl_attach_widget_association_set(page, t); ewl_attach_widget_association_set(t, page); ewl_widget_show(t); ewl_callback_append(t, EWL_CALLBACK_CLICKED, ewl_notebook_cb_tab_clicked, n); idx = ewl_container_child_index_get(EWL_CONTAINER(n), page); ewl_container_child_insert(EWL_CONTAINER(n->body.tabbar), t, idx); } else ewl_container_reset(EWL_CONTAINER(t)); /* if this is the current page set it's tab to selected */ if (n->cur_page == page) ewl_widget_state_add(t, EWL_STATE_SELECTED); ewl_container_child_append(EWL_CONTAINER(t), tab); DLEAVE_FUNCTION(DLEVEL_STABLE); }
/** * @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); }
/** * @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); }
/** * @param dialog: the icondialog to initialize. * @return Return TRUE on success, FALSE otherwise. * @brief Initialize an internal icondialog to starting values */ int ewl_icondialog_init(Ewl_Icondialog *dialog) { Ewl_Widget *w; Ewl_Widget *box; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(dialog, FALSE); w = EWL_WIDGET(dialog); if (!ewl_dialog_init(EWL_DIALOG(dialog))) { DRETURN_INT(FALSE, DLEVEL_STABLE); } ewl_widget_appearance_set(w, EWL_ICONDIALOG_TYPE); ewl_widget_inherit(w, EWL_ICONDIALOG_TYPE); /* get the parent vbox */ box = dialog->dialog.vbox; /* we need a hbox */ ewl_box_orientation_set(EWL_BOX(box), EWL_ORIENTATION_HORIZONTAL); /* * Setup a vertical box for the displayed window contents. */ dialog->vbox = ewl_vbox_new(); if (!dialog->vbox) { DRETURN_INT(FALSE, DLEVEL_STABLE); } ewl_container_child_append(EWL_CONTAINER(box), dialog->vbox); ewl_widget_internal_set(dialog->vbox, TRUE); ewl_object_fill_policy_set(EWL_OBJECT(dialog->vbox), EWL_FLAG_FILL_ALL); ewl_widget_show(dialog->vbox); ewl_container_redirect_set(EWL_CONTAINER(box), EWL_CONTAINER(dialog->vbox)); DRETURN_INT(TRUE, DLEVEL_STABLE); }
/** * @param dvi: the dvi widget to initialize * @return Returns no value. * @brief Initialize an dvi widget to default values and callbacks * * Sets the fields and callbacks of @a dvi to their default * values. The property EDVI_PROPERTY_DELAYED_FONT_OPEN is set by * default. */ int ewl_dvi_init(Ewl_Dvi *dvi) { Ewl_Widget *w; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(dvi, FALSE); w = EWL_WIDGET(dvi); if (!ewl_widget_init(w)) DRETURN_INT(FALSE, DLEVEL_STABLE); ewl_widget_appearance_set(w, EWL_DVI_TYPE); ewl_widget_inherit(w, EWL_DVI_TYPE); /* * Append necessary callbacks. */ ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_dvi_configure_cb, NULL); ewl_callback_append(w, EWL_CALLBACK_REVEAL, ewl_dvi_reveal_cb, NULL); ewl_callback_append(w, EWL_CALLBACK_OBSCURE, ewl_dvi_obscure_cb, NULL); ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_dvi_destroy_cb, NULL); dvi->filename = NULL; dvi->dvi_device = edvi_device_new (edvi_dpi_get(), edvi_dpi_get()); dvi->dvi_property = edvi_property_new(); edvi_property_property_set (dvi->dvi_property, EDVI_PROPERTY_DELAYED_FONT_OPEN); dvi->dvi_document = NULL; dvi->dvi_page = NULL; dvi->dirty = 1; DRETURN_INT(TRUE, DLEVEL_STABLE); }
/** * @param ps: the ps widget to initialize * @return Returns no value. * @brief Initialize an ps widget to default values and callbacks * * Sets the fields and callbacks of @a ps to their default * values. */ int ewl_ps_init(Ewl_Ps *ps) { Ewl_Widget *w; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(ps, FALSE); w = EWL_WIDGET(ps); if (!ewl_widget_init(w)) DRETURN_INT(FALSE, DLEVEL_STABLE); ewl_widget_appearance_set(w, EWL_PS_TYPE); ewl_widget_inherit(w, EWL_PS_TYPE); /* * Append necessary callbacks. */ ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_ps_configure_cb, NULL); ewl_callback_append(w, EWL_CALLBACK_REVEAL, ewl_ps_reveal_cb, NULL); ewl_callback_append(w, EWL_CALLBACK_OBSCURE, ewl_ps_obscure_cb, NULL); ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_ps_destroy_cb, NULL); ps->filename = NULL; ps->ps_document = NULL; ps->ps_page = NULL; ps->dirty = 1; DRETURN_INT(TRUE, DLEVEL_STABLE); }
/** * @param e: The Ewl_Entry to initialize * @return Returns TRUE on success or FALSE on failure * @brief Initializes an Ewl_Entry widget to default values */ int ewl_entry_init(Ewl_Entry *e) { const char *text_types[] = { "UTF8_STRING", "text/plain", NULL }; Ewl_Widget *w; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(e, FALSE); w = EWL_WIDGET(e); if (!ewl_text_init(EWL_TEXT(e))) DRETURN_INT(FALSE, DLEVEL_STABLE); ewl_widget_inherit(w, EWL_ENTRY_TYPE); ewl_widget_appearance_set(w, EWL_ENTRY_TYPE); ewl_widget_focusable_set(EWL_WIDGET(e), TRUE); ewl_object_fill_policy_set(EWL_OBJECT(e), EWL_FLAG_FILL_HSHRINK | EWL_FLAG_FILL_HFILL); ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_FOCUS_IN); ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_FOCUS_OUT); ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_DND_POSITION); ewl_container_callback_intercept(EWL_CONTAINER(w), EWL_CALLBACK_DND_DATA_RECEIVED); /* setup the cursor */ e->cursor = ewl_entry_cursor_new(e); ewl_container_child_append(EWL_CONTAINER(e), e->cursor); ewl_widget_internal_set(e->cursor, TRUE); ewl_object_fill_policy_set(EWL_OBJECT(e->cursor), EWL_FLAG_FILL_VFILL); /* Set the pointer */ ewl_attach_mouse_cursor_set(EWL_WIDGET(e), EWL_MOUSE_CURSOR_XTERM); /* this has to be called after the cursor is created as it will try * to show the cursor */ ewl_entry_multiline_set(e, FALSE); ewl_entry_editable_set(e, TRUE); ewl_text_selectable_set(EWL_TEXT(e), TRUE); ewl_dnd_accepted_types_set(EWL_WIDGET(e), text_types); /* setup callbacks */ ewl_callback_append(w, EWL_CALLBACK_FOCUS_IN, ewl_entry_cb_focus_in, NULL); ewl_callback_append(w, EWL_CALLBACK_FOCUS_OUT, ewl_entry_cb_focus_out, NULL); ewl_callback_prepend(w, EWL_CALLBACK_CONFIGURE, ewl_entry_cb_configure, NULL); ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN, ewl_entry_cb_mouse_down, NULL); ewl_callback_append(w, EWL_CALLBACK_MOUSE_UP, ewl_entry_cb_mouse_up, NULL); ewl_callback_append(w, EWL_CALLBACK_WIDGET_DISABLE, ewl_entry_cb_disable, NULL); ewl_callback_append(w, EWL_CALLBACK_WIDGET_ENABLE, ewl_entry_cb_enable, NULL); ewl_callback_append(w, EWL_CALLBACK_DND_POSITION, ewl_entry_cb_dnd_position, NULL); ewl_callback_append(w, EWL_CALLBACK_DND_DATA_RECEIVED, ewl_entry_cb_dnd_data, NULL); DRETURN_INT(TRUE, DLEVEL_STABLE); }
/** * @param n: The Ewl_Notebook to set the tabbar position of * @param pos: The Ewl_Position to put the tabbar in * @return Returns no value. * @brief Set the position of the tabbar in the notebook widget */ void ewl_notebook_tabbar_position_set(Ewl_Notebook *n, Ewl_Position pos) { int t, pw, ph; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(n); DCHECK_TYPE(n, "notebook"); if (n->tabbar_position == pos) DRETURN(DLEVEL_STABLE); n->tabbar_position = pos; switch(pos) { case EWL_POSITION_LEFT: case EWL_POSITION_RIGHT: ewl_box_orientation_set(EWL_BOX(n), EWL_ORIENTATION_HORIZONTAL); ewl_box_orientation_set(EWL_BOX(n->body.tabbar), EWL_ORIENTATION_VERTICAL); t = ewl_object_preferred_w_get(EWL_OBJECT(n->body.tabbar)); ewl_object_preferred_size_get(EWL_OBJECT(n->body.pages), &pw, &ph); ewl_object_preferred_inner_size_set(EWL_OBJECT(n), t + pw, ph); break; case EWL_POSITION_TOP: case EWL_POSITION_BOTTOM: default: ewl_box_orientation_set(EWL_BOX(n), EWL_ORIENTATION_VERTICAL); ewl_box_orientation_set(EWL_BOX(n->body.tabbar), EWL_ORIENTATION_HORIZONTAL); t = ewl_object_preferred_h_get(EWL_OBJECT(n->body.tabbar)); ewl_object_preferred_size_get(EWL_OBJECT(n->body.pages), &pw, &ph); ewl_object_preferred_inner_size_set(EWL_OBJECT(n), pw, ph + t); break; } switch (pos) { case EWL_POSITION_LEFT: ewl_widget_appearance_set(n->body.tabbar, "left/tabbar"); break; case EWL_POSITION_RIGHT: ewl_widget_appearance_set(n->body.tabbar, "right/tabbar"); break; case EWL_POSITION_TOP: ewl_widget_appearance_set(n->body.tabbar, "top/tabbar"); break; case EWL_POSITION_BOTTOM: ewl_widget_appearance_set(n->body.tabbar, "bottom/tabbar"); break; } ewl_container_child_remove(EWL_CONTAINER(n), n->body.tabbar); /* remove the redirect so we can stick the tabbar back in */ ewl_container_redirect_set(EWL_CONTAINER(n), NULL); if ((n->tabbar_position == EWL_POSITION_RIGHT) || (n->tabbar_position == EWL_POSITION_BOTTOM)) ewl_container_child_append(EWL_CONTAINER(n), n->body.tabbar); else if ((n->tabbar_position == EWL_POSITION_LEFT) || (n->tabbar_position == EWL_POSITION_TOP)) ewl_container_child_prepend(EWL_CONTAINER(n), n->body.tabbar); ewl_container_redirect_set(EWL_CONTAINER(n), EWL_CONTAINER(n->body.pages)); DLEAVE_FUNCTION(DLEVEL_STABLE); }