Download

Support

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 Ewl_Combo Ewl_Combo
typedef 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_Comboewl_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_Modelewl_combo_cell_model_get (Ewl_Combo_Cell *c)
void ewl_combo_cell_model_set (Ewl_Combo_Cell *c, const Ewl_Model *model)
Ewl_Widgetewl_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_Widgetewl_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.

#define EWL_COMBO_CELL (  )     ((Ewl_Combo_Cell *)c)

The type name for the Ewl_Combo_Cell widget

#define EWL_COMBO_CELL_IS (  )     (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 (  )     (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"

The type name for the Ewl_Combo widget


Typedef Documentation

typedef struct Ewl_Combo Ewl_Combo

A simple internal combo box, it is limited to drawing within the current evas.

Typedef for the Ewl_Combo_Cell struct


Function Documentation

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 cell  ) 

Parameters:
cell,: The Ewl_Combo to use
Returns:
Returns the parent combo of the cell

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

void* ewl_combo_cell_data_get ( Ewl_Combo_Cell cell  ) 

Parameters:
cell,: The Ewl_Combo to use
Returns:
Returns the model of the cell

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

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

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

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

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.

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

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.

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

Ewl_Widget* ewl_combo_new ( void   ) 

Create a new combo box.

Returns:
Returns a pointer to a new combo on success, NULL on failure.

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

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

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
On true, this functions set the combo to use a scrollpane to view the widget inside of it. The maximal size of it is set by a theme defined value.


Copyright © Enlightenment.org

Enlightened Widget Library Documentation Generated: Sun Sep 27 01:49:46 2009