00001
00002 #ifndef EWL_MVC_H
00003 #define EWL_MVC_H
00004
00005 #include "ewl_box.h"
00006 #include "ewl_model.h"
00007 #include "ewl_view.h"
00008
00025 #define EWL_MVC_TYPE "mvc"
00026
00031 #define EWL_MVC_IS(w) (ewl_widget_type_is(EWL_WIDGET(w), EWL_MVC_TYPE))
00032
00037 #define EWL_SELECTION(x) ((Ewl_Selection *)x)
00038
00042 typedef struct Ewl_Selection Ewl_Selection;
00043
00047 struct Ewl_Selection
00048 {
00049 Ewl_Selection_Type type;
00050 const Ewl_Model *model;
00052 void *highlight;
00053 void *data;
00054 };
00055
00060 #define EWL_SELECTION_IDX(x) ((Ewl_Selection_Idx *)x)
00061
00065 typedef struct Ewl_Selection_Idx Ewl_Selection_Idx;
00066
00070 struct Ewl_Selection_Idx
00071 {
00072 Ewl_Selection sel;
00074 unsigned int row;
00075 unsigned int column;
00076 };
00077
00082 #define EWL_SELECTION_RANGE(x) ((Ewl_Selection_Range *)x)
00083
00087 typedef struct Ewl_Selection_Range Ewl_Selection_Range;
00088
00092 struct Ewl_Selection_Range
00093 {
00094 Ewl_Selection sel;
00096 struct
00097 {
00098 unsigned int row;
00099 unsigned int column;
00100 } start,
00101 end;
00102 };
00103
00107 typedef struct Ewl_MVC Ewl_MVC;
00108
00113 #define EWL_MVC(mvc) ((Ewl_MVC *)mvc)
00114
00118 struct Ewl_MVC
00119 {
00120 Ewl_Box box;
00122 void *data;
00123 const Ewl_View *view;
00124 const Ewl_Model *model;
00126 void *private_data;
00128 struct {
00129 void (*view_change)(Ewl_MVC *mvc);
00130 void (*selected_change)(Ewl_MVC *mvc);
00131 } cb;
00133 Ecore_List *selected;
00135 Ewl_Selection_Mode selection_mode;
00136 unsigned char dirty:1;
00137 };
00138
00143 extern unsigned int EWL_CALLBACK_MVC_CLICKED;
00144
00145 int ewl_mvc_init(Ewl_MVC *mvc);
00146
00147 void ewl_mvc_view_set(Ewl_MVC *mvc, const Ewl_View *view);
00148 const Ewl_View *ewl_mvc_view_get(Ewl_MVC *mvc);
00149
00150 void ewl_mvc_model_set(Ewl_MVC *mvc, const Ewl_Model *model);
00151 const Ewl_Model *ewl_mvc_model_get(Ewl_MVC *mvc);
00152
00153 void ewl_mvc_data_set(Ewl_MVC *mvc, void *data);
00154 void *ewl_mvc_data_get(Ewl_MVC *mvc);
00155
00156 void ewl_mvc_dirty_set(Ewl_MVC *mvc, unsigned int dirty);
00157 unsigned int ewl_mvc_dirty_get(Ewl_MVC *mvc);
00158
00159 void ewl_mvc_private_data_set(Ewl_MVC *mvc, void *data);
00160 void *ewl_mvc_private_data_get(Ewl_MVC *mvc);
00161
00162 void ewl_mvc_selection_mode_set(Ewl_MVC *mvc,
00163 Ewl_Selection_Mode mode);
00164 Ewl_Selection_Mode ewl_mvc_selection_mode_get(Ewl_MVC *mvc);
00165
00166 void ewl_mvc_selected_clear(Ewl_MVC *mvc);
00167
00168 void ewl_mvc_selected_list_set(Ewl_MVC *mvc,
00169 Ecore_List *list);
00170 Ecore_List *ewl_mvc_selected_list_get(Ewl_MVC *mvc);
00171
00172 void ewl_mvc_selected_range_add(Ewl_MVC *mvc,
00173 const Ewl_Model * model,
00174 void *data, unsigned int srow,
00175 unsigned int scolumn,
00176 unsigned int erow,
00177 unsigned int ecolumn);
00178
00179 void ewl_mvc_selected_set(Ewl_MVC *mvc,
00180 const Ewl_Model *model,
00181 void *data, unsigned int row,
00182 unsigned int column);
00183 void ewl_mvc_selected_add(Ewl_MVC *mvc,
00184 const Ewl_Model *model,
00185 void *data, unsigned int row,
00186 unsigned int column);
00187 Ewl_Selection_Idx *ewl_mvc_selected_get(Ewl_MVC *mvc);
00188 void ewl_mvc_selected_rm(Ewl_MVC *mvc, void *data,
00189 unsigned int row,
00190 unsigned int column);
00191
00192 unsigned int ewl_mvc_selected_count_get(Ewl_MVC *mvc);
00193 unsigned int ewl_mvc_selected_is(Ewl_MVC *mvc, void *data,
00194 unsigned int row,
00195 unsigned int column);
00196
00197 Ewl_Selection *ewl_mvc_selection_index_new(const Ewl_Model *model,
00198 void *data,
00199 unsigned int row,
00200 unsigned int column);
00201 Ewl_Selection *ewl_mvc_selection_range_new(const Ewl_Model *model,
00202 void *data, unsigned int srow,
00203 unsigned int scolumn,
00204 unsigned int erow,
00205 unsigned int ecolumn);
00206
00207 void ewl_mvc_highlight(Ewl_MVC *mvc, Ewl_Container *c,
00208 Ewl_Widget *(*widget)(Ewl_MVC *mvc,
00209 void *data, unsigned int row,
00210 unsigned int column));
00211
00212
00213
00214
00215 void ewl_mvc_view_change_cb_set(Ewl_MVC *mvc, void (*cb)(Ewl_MVC *mvc));
00216 void ewl_mvc_selected_change_cb_set(Ewl_MVC *mvc, void (*cb)(Ewl_MVC *mvc));
00217
00218 void ewl_mvc_cb_destroy(Ewl_Widget *w, void *ev, void *data);
00219 void ewl_mvc_cb_data_unref(Ewl_Widget *w, void *ev, void *data);
00220 void ewl_mvc_cb_clicked_single(Ewl_Widget *w, void *ev, void *data);
00221 void ewl_mvc_cb_clicked_multi(Ewl_Widget *w, void *ev, void *data);
00222
00227 #endif
00228