| 62 | | SendMessageA(peer,LB_SETCURSEL,n,0); |
|---|
| 63 | | version (LOG) log.writefln("number of item is %d", |
|---|
| 64 | | SendMessageA(peer,CB_GETCOUNT,0,0)); |
|---|
| | 63 | if (n < 0) n = -1; |
|---|
| | 64 | int r = SendMessageA(peer,LB_SETCURSEL,cast(WPARAM)n,0); |
|---|
| | 65 | sysAssert(r != LB_ERR, "Unable to select ListBox item"); |
|---|
| | 66 | } |
|---|
| | 67 | |
|---|
| | 68 | int count() { |
|---|
| | 69 | return SendMessageA(peer,LB_GETCOUNT,0,0); |
|---|
| | 70 | } |
|---|
| | 71 | |
|---|
| | 72 | char[] opIndex(int i) { |
|---|
| | 73 | if (useWfuncs) { |
|---|
| | 74 | int n = SendMessageW(peer,LB_GETTEXTLEN,cast(WPARAM)i,0); |
|---|
| | 75 | if (n == LB_ERR) return null; |
|---|
| | 76 | scope str = new wchar[n+1]; |
|---|
| | 77 | n = SendMessageW(peer,LB_GETTEXT,cast(WPARAM)i,cast(LPARAM)str.ptr); |
|---|
| | 78 | if (n == LB_ERR) return null; |
|---|
| | 79 | return toUTF8(str[0..$-1]); |
|---|
| | 80 | } else { |
|---|
| | 81 | int n = SendMessageA(peer,LB_GETTEXTLEN,cast(WPARAM)i,0); |
|---|
| | 82 | if (n == LB_ERR) return null; |
|---|
| | 83 | scope str = new char[n+1]; |
|---|
| | 84 | n = SendMessageA(peer,LB_GETTEXT,cast(WPARAM)i,cast(LPARAM)str.ptr); |
|---|
| | 85 | if (n == LB_ERR) return null; |
|---|
| | 86 | return fromMBSz(str.ptr); |
|---|
| | 87 | } |
|---|
| 124 | | // GtkComboBox* box = cast(GtkComboBox*)peer; |
|---|
| 125 | | // return gtk_combo_box_get_active(box); |
|---|
| 126 | | return 0; |
|---|
| 127 | | } |
|---|
| 128 | | void selection(int n) { |
|---|
| 129 | | // GtkComboBox* box = cast(GtkComboBox*)peer; |
|---|
| 130 | | // gtk_combo_box_set_active(box,n); |
|---|
| | 147 | GtkTreeSelection* sel = gtk_tree_view_get_selection(treeView); |
|---|
| | 148 | GtkTreeIter iter; |
|---|
| | 149 | if (!gtk_tree_selection_get_selected(sel,null,&iter)) |
|---|
| | 150 | return -1; |
|---|
| | 151 | GtkTreePath* path = gtk_tree_model_get_path(model, &iter); |
|---|
| | 152 | scope(exit) gtk_tree_path_free(path); |
|---|
| | 153 | sysAssert(gtk_tree_path_get_depth(path) == 1, "gtk tree path is not 1 deep"); |
|---|
| | 154 | gint* indices = gtk_tree_path_get_indices(path); |
|---|
| | 155 | sysAssert(indices !is null, "no tree path indices"); |
|---|
| | 156 | return *indices; |
|---|
| 133 | | char[] text() { |
|---|
| 134 | | char* str; |
|---|
| 135 | | GtkTreeModel* model = gtk_tree_view_get_model(treeView); |
|---|
| 136 | | GtkTreeIter iter; |
|---|
| 137 | | if (gtk_tree_model_get_iter_first(model,&iter)) { |
|---|
| 138 | | int n = selection(); |
|---|
| 139 | | GValue* val; |
|---|
| 140 | | while (n--) { |
|---|
| 141 | | gtk_tree_model_iter_next(model,&iter); |
|---|
| 142 | | } |
|---|
| 143 | | gtk_tree_model_get_value(model,&iter,0,val); |
|---|
| 144 | | str = *(cast(char**)val); |
|---|
| 145 | | g_value_unset(val); |
|---|
| 146 | | } |
|---|
| 147 | | if (str is null) |
|---|
| 148 | | return ""; |
|---|
| 149 | | else |
|---|
| 150 | | return str[0..strlen(str)].dup; |
|---|
| | 159 | void selection(int i) { |
|---|
| | 160 | GtkTreePath* path = gtk_tree_path_new_from_indices(i,-1); |
|---|
| | 161 | sysAssert(path !is null, "invalid selection"); |
|---|
| | 162 | GtkTreeSelection* sel = gtk_tree_view_get_selection(treeView); |
|---|
| | 163 | gtk_tree_selection_select_path(sel, path); |
|---|
| | 164 | gtk_tree_path_free(path); |
|---|
| 153 | | void text(char[] s) { |
|---|
| 154 | | assert(false); |
|---|
| | 167 | int count() { |
|---|
| | 168 | return gtk_tree_model_iter_n_children(model,null); |
|---|
| | 169 | } |
|---|
| | 170 | |
|---|
| | 171 | char[] opIndex(int i) { |
|---|
| | 172 | GtkTreePath* path = gtk_tree_path_new_from_indices(i,-1); |
|---|
| | 173 | sysAssert(path !is null, "invalid index"); |
|---|
| | 174 | scope(exit) gtk_tree_path_free(path); |
|---|
| | 175 | GtkTreeIter iter; |
|---|
| | 176 | if (!gtk_tree_model_get_iter(model, &iter, path)) |
|---|
| | 177 | return null; |
|---|
| | 178 | char* str; |
|---|
| | 179 | gtk_tree_model_get(model, &iter, 0, &str, -1); |
|---|
| | 180 | scope(exit) g_free(str); |
|---|
| | 181 | return str[0..strlen(str)].dup; |
|---|