2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 2017 Olaf Wintermann. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
38 typedef struct UiModel UiModel;
39 typedef struct UiListCallbacks UiListCallbacks;
40 typedef struct UiListSelection UiListSelection;
42 typedef enum UiModelType {
56 * array of column types
57 * array length is the number of columns
62 * array of column titles
63 * array length is the number of columns
68 * function for translating model data to view data
69 * first argument is the pointer returned by UiList->get or UiTree->get
70 * second argument is the column index
73 void*(*getvalue)(void*, int);
75 UiBool(*candrop)(UiEvent*, UiSelection*, UiList*, int);
76 void(*drop)(UiEvent*, UiSelection*, UiList*, int);
77 UiBool(*candrag)(UiEvent*, UiList*, int);
78 void(*data_get)(UiEvent*, UiSelection*, UiList*, int);
79 void(*data_delete)(UiEvent*, UiList*, int);
82 struct UiListCallbacks {
91 ui_callback selection;
94 * userdata for all callbacks
99 struct UiListSelection {
101 * number of selected items
106 * indices of selected rows
111 UiModel* ui_model(UiContext *ctx, ...);
112 void ui_model_free(UiContext *ctx, UiModel *mi);
114 UIWIDGET ui_listview(UiObject *obj, UiList *list, ui_getvaluefunc getvalue, ui_callback f, void *udata);
115 UIWIDGET ui_listview_str(UiObject *obj, UiList *list, ui_callback f, void *udata);
116 UIWIDGET ui_listview_nv(UiObject *obj, char *listname, ui_getvaluefunc getvalue, ui_callback f, void *udata);
118 UIWIDGET ui_table(UiObject *obj, UiList *data, UiModel *model, UiListCallbacks cb);
119 UIWIDGET ui_table_nv(UiObject *obj, char *varname, UiModel *model, UiListCallbacks cb);
121 void ui_table_dragsource(UIWIDGET tablewidget, int actions, char *target0, ...);
122 void ui_table_dragsource_a(UIWIDGET tablewidget, int actions, char **targets, int nelm);
123 void ui_table_dragdest(UIWIDGET tablewidget, int actions, char *target0, ...);
124 void ui_table_dragdest_a(UIWIDGET tablewidget, int actions, char **targets, int nelm);
126 UIWIDGET ui_combobox(UiObject *obj, UiList *list, ui_getvaluefunc getvalue, ui_callback f, void *udata);
127 UIWIDGET ui_combobox_str(UiObject *obj, UiList *list, ui_callback f, void *udata);
128 UIWIDGET ui_combobox_nv(UiObject *obj, char *varname, ui_getvaluefunc getvalue, ui_callback f, void *udata);
134 #endif /* UI_TREE_H */