Ewl_Combo: A Simple Combo Box
Detailed Description
Defines a combo box used internally. The contents on the box are not drawn outside of the Evas.
- Remarks:
- Inherits from Ewl_MVC.
Tutorial
The Ewl_Combo widget is based on a Model/View/Controller design. Before you can use the combo you need to setup your startting data structure, your model and your view. Once everything is created if you want to change your data all you have to do is tell the combo that it's data is dirty and it will redisplay the combo box.
model = ewl_model_new(); ewl_model_data_fetch_set(model, combo_test_data_fetch); ewl_model_data_count_set(model, combo_test_data_count_get); view = ewl_view_new(); ewl_view_constructor_set(view, ewl_label_new); ewl_view_assign_set(view, EWL_VIEW_ASSIGN(ewl_label_text_set)); ewl_view_header_fetch_set(view, combo_test_data_header_fetch); combo = ewl_combo_new(); ewl_callback_append(combo, EWL_CALLBACK_VALUE_CHANGED, combo_value_changed, NULL); ewl_mvc_model_set(EWL_MVC(combo), model); ewl_mvc_view_set(EWL_MVC(combo), view); ewl_mvc_data_set(EWL_MVC(combo), data); ewl_widget_show(combo);
If you have a custom widget you wish to display you can set your own functions into the view to draw your widget. In this case we just want a simple label displayed.
The data header is optional and will be displayed at the top of your combo. In the case where the combo is editable it will use the header as the normal display. In this case you are responsible for creating and populating the widget.
static Ewl_Widget *combo_test_data_header_fetch(void *data, unsigned int col); static void *combo_test_data_fetch(void *data, unsigned int row, unsigned int col); static unsigned int combo_test_data_count_get(void *data);
The three model functions are responsible for getting the information from your model as needed. Each time the combo needs another row of data it will call the data_fetch function. The col parameter is unused by the combo box. The count_get function is responsible for returning a count of the number of items in your data structure. Each of these three functions receive a void *data param. This is your data as set into the combo box so you shouldn't need to create a global pointer to the data.
- Note:
- If you set the combo to editable, with ewl_combo_editable set then instead of using the model/view to get the data we will query the view for the header. It is then up to the app to do what they will with the header to make it 'editable'. In most cases, this will mean packing an entry into there with the value from the data. In this case you will need to attach a EWL_CALLBACK_VALUE_CHANGED callback to the entry and handle its value change yourself. The combo won't know about any changed values in the entry and will always have the value from the data.
Data Structures | |
struct | Ewl_Combo |
Inherits from the Ewl_MVC widget to provide a combo widget. More... | |
struct | Ewl_Combo_Cell |
Inherits from Ewl_Cell and is used internally for the combo box. More... | |
Defines | |
#define | EWL_COMBO(combo) ((Ewl_Combo *) combo) |
#define | EWL_COMBO_CELL(c) ((Ewl_Combo_Cell *)c) |
#define | EWL_COMBO_CELL_IS(w) (ewl_widget_type_is(EWL_WIDGET(w), EWL_COMBO_CELL_TYPE)) |
#define | EWL_COMBO_CELL_TYPE "combo_cell" |
#define | EWL_COMBO_IS(w) (ewl_widget_type_is(EWL_WIDGET(w), EWL_COMBO_TYPE)) |
#define | EWL_COMBO_TYPE "combo" |
Typedefs | |
typedef struct Ewl_Combo | Ewl_Combo |
typedef struct Ewl_Combo_Cell | Ewl_Combo_Cell |
Functions | |
void | ewl_combo_cb_decrement_clicked (Ewl_Widget *w, void *ev, void *data) |
void | ewl_combo_cb_popup_hide (Ewl_Widget *w, void *ev, void *data) |
Ewl_Combo * | ewl_combo_cell_combo_get (Ewl_Combo_Cell *c) |
void | ewl_combo_cell_combo_set (Ewl_Combo_Cell *c, Ewl_Combo *combo) |
void * | ewl_combo_cell_data_get (Ewl_Combo_Cell *c) |
void | ewl_combo_cell_data_set (Ewl_Combo_Cell *c, void *mvc_data) |
int | ewl_combo_cell_init (Ewl_Combo_Cell *c) |
Initializes a combo cell to default values. | |
const Ewl_Model * | ewl_combo_cell_model_get (Ewl_Combo_Cell *c) |
void | ewl_combo_cell_model_set (Ewl_Combo_Cell *c, const Ewl_Model *model) |
Ewl_Widget * | ewl_combo_cell_new (void) |
Create a new combo cell. | |
unsigned int | ewl_combo_editable_get (Ewl_Combo *combo) |
Retrieves the editable status of the combo. | |
void | ewl_combo_editable_set (Ewl_Combo *combo, unsigned int editable) |
This will set if the displayed data in the combo is editable. | |
int | ewl_combo_init (Ewl_Combo *combo) |
Initializes a combo to default values. | |
Ewl_Widget * | ewl_combo_new (void) |
Create a new combo box. | |
void | ewl_combo_popup_container_set (Ewl_Combo *combo, Ewl_Container *c) |
unsigned int | ewl_combo_scrollable_get (Ewl_Combo *combo) |
Retrieves the scrollable status of the combo. | |
void | ewl_combo_scrollable_set (Ewl_Combo *combo, unsigned int scrollable) |
Define Documentation
#define EWL_COMBO | ( | combo | ) | ((Ewl_Combo *) combo) |
Typecasts a pointer to an Ewl_Combo pointer.
Referenced by ewl_combo_cb_popup_hide(), and ewl_filepicker_init().
#define EWL_COMBO_CELL | ( | c | ) | ((Ewl_Combo_Cell *)c) |
The type name for the Ewl_Combo_Cell widget
Typecasts a pointer to an Ewl_Combo_Cell pointer
Referenced by ewl_combo_cell_cb_clicked().
#define EWL_COMBO_CELL_IS | ( | w | ) | (ewl_widget_type_is(EWL_WIDGET(w), EWL_COMBO_CELL_TYPE)) |
Returns TRUE if the widget is an Ewl_Combo_Cell, FALSE otherwise
#define EWL_COMBO_CELL_TYPE "combo_cell" |
#define EWL_COMBO_IS | ( | w | ) | (ewl_widget_type_is(EWL_WIDGET(w), EWL_COMBO_TYPE)) |
Returns TRUE if the widget is an Ewl_Combo, FALSE otherwise
#define EWL_COMBO_TYPE "combo" |
- Widget Theme Keys:
- /combo/file
- Widget Theme Keys:
- /combo/group
Referenced by ewl_combo_cb_decrement_clicked(), ewl_combo_cb_popup_hide(), ewl_combo_cell_combo_set(), ewl_combo_editable_get(), ewl_combo_editable_set(), ewl_combo_init(), ewl_combo_popup_container_set(), ewl_combo_scrollable_get(), ewl_combo_scrollable_set(), and ewl_combo_submenu_new().
Typedef Documentation
A simple internal combo box, it is limited to drawing within the current evas.
typedef struct Ewl_Combo_Cell Ewl_Combo_Cell |
Typedef for the Ewl_Combo_Cell struct
Function Documentation
void ewl_combo_cb_decrement_clicked | ( | Ewl_Widget * | w, | |
void * | ev, | |||
void * | data | |||
) |
References button, DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, DRETURN, EWL_COMBO_TYPE, EWL_CONTAINER, ewl_container_reset(), EWL_MVC, ewl_mvc_data_get(), ewl_mvc_dirty_get(), ewl_mvc_dirty_set(), ewl_mvc_model_get(), ewl_mvc_view_get(), EWL_STATE_PERSISTENT, EWL_WIDGET, ewl_widget_focus_send(), ewl_widget_show(), ewl_widget_state_set(), EWL_WINDOW, ewl_window_raise(), and popup.
Referenced by ewl_combo_init().
void ewl_combo_cb_popup_hide | ( | Ewl_Widget * | w, | |
void * | ev, | |||
void * | data | |||
) |
References button, DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, EWL_COMBO, EWL_COMBO_TYPE, EWL_STATE_PERSISTENT, EWL_WIDGET, and ewl_widget_state_set().
Referenced by ewl_combo_init().
Ewl_Combo* ewl_combo_cell_combo_get | ( | Ewl_Combo_Cell * | cell | ) |
- Parameters:
-
cell,: The Ewl_Combo to use
- Returns:
- Returns the parent combo of the cell
References Ewl_Combo_Cell::combo, DCHECK_PARAM_PTR_RET, DCHECK_TYPE_RET, DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_PTR, and EWL_COMBO_CELL_TYPE.
Referenced by ewl_combo_cell_cb_clicked().
void ewl_combo_cell_combo_set | ( | Ewl_Combo_Cell * | cell, | |
Ewl_Combo * | combo | |||
) |
- Parameters:
-
cell,: The Ewl_Combo_Cell to use combo,: the parent combo widget
- Returns:
- Returns no value
References Ewl_Combo_Cell::combo, DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, EWL_COMBO_CELL_TYPE, and EWL_COMBO_TYPE.
void* ewl_combo_cell_data_get | ( | Ewl_Combo_Cell * | cell | ) |
- Parameters:
-
cell,: The Ewl_Combo to use
- Returns:
- Returns the model of the cell
References DCHECK_PARAM_PTR_RET, DCHECK_TYPE_RET, DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_PTR, EWL_COMBO_CELL_TYPE, and Ewl_Combo_Cell::mvc_data.
Referenced by ewl_combo_cell_cb_clicked().
void ewl_combo_cell_data_set | ( | Ewl_Combo_Cell * | cell, | |
void * | mvc_data | |||
) |
- Parameters:
-
cell,: The Ewl_Combo_Cell to use mvc_data,: the data for the cell
- Returns:
- Returns no value
References DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, EWL_COMBO_CELL_TYPE, and Ewl_Combo_Cell::mvc_data.
int ewl_combo_cell_init | ( | Ewl_Combo_Cell * | cell | ) |
Initializes a combo cell to default values.
- Parameters:
-
cell,: The Ewl_Combo_Cell to initialize
- Returns:
- Returns TRUE on success or FALSE on failure
References DCHECK_PARAM_PTR_RET, DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_INT, ewl_callback_append(), EWL_CALLBACK_CLICKED, EWL_CELL, ewl_cell_init(), ewl_combo_cell_cb_clicked(), EWL_COMBO_CELL_TYPE, EWL_FLAG_FILL_HFILL, EWL_OBJECT, ewl_object_fill_policy_set(), EWL_WIDGET, ewl_widget_appearance_set(), and ewl_widget_inherit().
Referenced by ewl_combo_cell_new().
const Ewl_Model* ewl_combo_cell_model_get | ( | Ewl_Combo_Cell * | cell | ) |
- Parameters:
-
cell,: The Ewl_Combo to use
- Returns:
- Returns the model of the cell
References DCHECK_PARAM_PTR_RET, DCHECK_TYPE_RET, DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_PTR, EWL_COMBO_CELL_TYPE, and Ewl_Combo_Cell::model.
Referenced by ewl_combo_cell_cb_clicked().
void ewl_combo_cell_model_set | ( | Ewl_Combo_Cell * | cell, | |
const Ewl_Model * | model | |||
) |
- Parameters:
-
cell,: The Ewl_Combo_Cell to use model,: the model for the cell
- Returns:
- Returns no value
References DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, EWL_COMBO_CELL_TYPE, and Ewl_Combo_Cell::model.
Ewl_Widget* ewl_combo_cell_new | ( | void | ) |
Create a new combo cell.
- Returns:
- Returns a pointer to a new combo cell on success, NULL on failure.
References DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_PTR, ewl_combo_cell_init(), EWL_WIDGET, ewl_widget_destroy(), and NEW.
unsigned int ewl_combo_editable_get | ( | Ewl_Combo * | combo | ) |
Retrieves the editable status of the combo.
- Parameters:
-
combo,: The Ewl_Combo to use
- Returns:
- Returns the editable status of the combo
References DCHECK_PARAM_PTR_RET, DCHECK_TYPE_RET, DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_INT, editable, and EWL_COMBO_TYPE.
void ewl_combo_editable_set | ( | Ewl_Combo * | combo, | |
unsigned int | editable | |||
) |
This will set if the displayed data in the combo is editable.
- Parameters:
-
combo,: The Ewl_Combo to use editable,: Set if the combo is editable or not
- Returns:
- Returns no value If the editable flag is set to TRUE then the combo will always request the header as the item to display. If it is FALSE then the combo will use the selected widget as the display.
References DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, DRETURN, editable, EWL_COMBO_TYPE, and EWL_MVC.
Referenced by ewl_filepicker_init().
int ewl_combo_init | ( | Ewl_Combo * | combo | ) |
Initializes a combo to default values.
- Parameters:
-
combo,: The Ewl_Combo to initialize
- Returns:
- Returns TRUE on success or FALSE on failure
References button, DCHECK_PARAM_PTR_RET, DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_INT, EWL_BOX, ewl_box_orientation_set(), ewl_button_new(), ewl_callback_append(), EWL_CALLBACK_CLICKED, EWL_CALLBACK_HIDE, ewl_combo_cb_decrement_clicked(), ewl_combo_cb_popup_hide(), EWL_COMBO_TYPE, EWL_CONTAINER, ewl_container_child_append(), ewl_context_menu_new(), EWL_FLAG_ALIGN_LEFT, EWL_FLAG_ALIGN_RIGHT, EWL_FLAG_ALIGN_TOP, EWL_FLAG_FILL_HFILL, EWL_FLAG_FILL_NONE, EWL_MVC, ewl_mvc_init(), ewl_mvc_selected_change_cb_set(), EWL_OBJECT, ewl_object_alignment_set(), ewl_object_fill_policy_set(), EWL_ORIENTATION_HORIZONTAL, EWL_POPUP, ewl_popup_fit_to_follow_set(), ewl_popup_follow_set(), EWL_POPUP_TYPE, EWL_POPUP_TYPE_MENU_VERTICAL, ewl_popup_type_set(), EWL_WIDGET, ewl_widget_appearance_set(), ewl_widget_inherit(), ewl_widget_internal_set(), ewl_widget_show(), EWL_WINDOW, ewl_window_keyboard_grab_set(), ewl_window_pointer_grab_set(), and popup.
Referenced by ewl_combo_new().
Ewl_Widget* ewl_combo_new | ( | void | ) |
Create a new combo box.
- Returns:
- Returns a pointer to a new combo on success, NULL on failure.
References DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_PTR, ewl_combo_init(), EWL_WIDGET, ewl_widget_destroy(), and NEW.
Referenced by ewl_filepicker_init().
void ewl_combo_popup_container_set | ( | Ewl_Combo * | combo, | |
Ewl_Container * | c | |||
) |
- Parameters:
-
combo,: The Ewl_Combo to use c,: The Container to use in the popup
- Returns:
- Returns no value
References DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, EWL_COMBO_TYPE, EWL_CONTAINER_TYPE, EWL_CONTEXT_MENU, ewl_context_menu_container_set(), popup, and scrollable.
unsigned int ewl_combo_scrollable_get | ( | Ewl_Combo * | combo | ) |
Retrieves the scrollable status of the combo.
- Parameters:
-
combo,: The Ewl_Combo to use
- Returns:
- Returns the scrollable status of the combo
References DCHECK_PARAM_PTR_RET, DCHECK_TYPE_RET, DENTER_FUNCTION, DLEVEL_STABLE, DRETURN_INT, EWL_COMBO_TYPE, and scrollable.
void ewl_combo_scrollable_set | ( | Ewl_Combo * | combo, | |
unsigned int | scrollable | |||
) |
- Parameters:
-
combo,: The Ewl_Combo to use scrollable,: Set if the combo is scrollable or not
- Returns:
- Returns no value
References DCHECK_PARAM_PTR, DCHECK_TYPE, DENTER_FUNCTION, DLEAVE_FUNCTION, DLEVEL_STABLE, DRETURN, EWL_COMBO_TYPE, EWL_CONTAINER, EWL_CONTEXT_MENU, ewl_context_menu_container_set(), EWL_FLAG_FILL_HFILL, EWL_FLAG_FILL_SHRINK, EWL_OBJECT, ewl_object_fill_policy_set(), ewl_object_maximum_h_set(), ewl_scrollpane_new(), ewl_theme_data_int_get(), EWL_WIDGET, ewl_widget_show(), popup, and scrollable.