34 |
#include "wptTypes.h" |
#include "wptTypes.h" |
35 |
#include "wptGPG.h" |
#include "wptGPG.h" |
36 |
#include "wptKeylist.h" |
#include "wptKeylist.h" |
37 |
|
#include "wptUTF8.h" |
38 |
#include "resource.h" |
#include "resource.h" |
39 |
|
|
40 |
|
|
68 |
if (ctx->hil) |
if (ctx->hil) |
69 |
ImageList_Destroy (ctx->hil); |
ImageList_Destroy (ctx->hil); |
70 |
delete ctx; |
delete ctx; |
71 |
} /* listview_release */ |
} |
72 |
|
|
73 |
|
|
74 |
|
int |
75 |
|
listview_set_column_width (listview_ctrl_t ctx, int col, int width) |
76 |
|
{ |
77 |
|
LVCOLUMN lvc; |
78 |
|
|
79 |
|
memset (&lvc, 0, sizeof (lvc)); |
80 |
|
lvc.mask = LVCF_WIDTH; |
81 |
|
lvc.cx = width; |
82 |
|
ListView_SetColumn (ctx->ctrl, col, &lvc); |
83 |
|
return 0; |
84 |
|
} |
85 |
|
|
86 |
|
|
87 |
int |
int |
100 |
rc = 1; |
rc = 1; |
101 |
ctx->cols++; |
ctx->cols++; |
102 |
return rc; |
return rc; |
103 |
} /* listview_add_column */ |
} |
104 |
|
|
105 |
|
|
106 |
int |
int |
132 |
rc = 1; |
rc = 1; |
133 |
ctx->items++; |
ctx->items++; |
134 |
return rc; |
return rc; |
135 |
} /* listview_add_item */ |
} |
136 |
|
|
137 |
|
|
138 |
int |
int |
168 |
rc = 1; |
rc = 1; |
169 |
ctx->items++; |
ctx->items++; |
170 |
return rc; |
return rc; |
171 |
} /* listview_add_item2 */ |
} |
172 |
|
|
173 |
|
|
174 |
void* |
void* |
199 |
|
|
200 |
|
|
201 |
void |
void |
202 |
listview_add_sub_item( listview_ctrl_t ctx, int pos, int col, const char *text ) |
listview_add_sub_item (listview_ctrl_t ctx, int pos, int col, const char *text) |
203 |
{ |
{ |
204 |
ListView_SetItemText( ctx->ctrl, pos, col, (char *)text ); |
ListView_SetItemText (ctx->ctrl, pos, col, (char*)text); |
205 |
} /* listview_add_sub_item */ |
} |
206 |
|
|
207 |
|
|
208 |
int |
int |
213 |
n = curr_sel? ListView_GetSelectedCount( ctx->ctrl ) : |
n = curr_sel? ListView_GetSelectedCount( ctx->ctrl ) : |
214 |
ListView_GetItemCount( ctx->ctrl ); |
ListView_GetItemCount( ctx->ctrl ); |
215 |
return n; |
return n; |
216 |
} /* listview_count_items */ |
} |
217 |
|
|
218 |
|
|
219 |
int |
int |
262 |
} |
} |
263 |
|
|
264 |
|
|
265 |
|
/* Return the index of the selected item. |
266 |
|
Support both selections and checkboxes. */ |
267 |
|
int |
268 |
|
listview_get_selected_item (listview_ctrl_t lv) |
269 |
|
{ |
270 |
|
int pos, i; |
271 |
|
|
272 |
|
pos = listview_get_curr_pos (lv); |
273 |
|
if (pos != -1) |
274 |
|
return pos; |
275 |
|
for (i=0; i < listview_count_items (lv, 0); i++) { |
276 |
|
if (listview_get_item_state (lv, i)) |
277 |
|
return i; |
278 |
|
} |
279 |
|
return -1; |
280 |
|
} |
281 |
|
|
282 |
|
|
283 |
/* Return if the given element is selected or if the ext |
/* Return if the given element is selected or if the ext |
284 |
style is used, if the checkbox is activated. */ |
style is used, if the checkbox is activated. */ |
285 |
int |
int |
337 |
IMI_SORT_DOWNARROW : IMI_SORT_UPARROW); |
IMI_SORT_DOWNARROW : IMI_SORT_UPARROW); |
338 |
Header_SetItem (hheader, idx, &hdi); |
Header_SetItem (hheader, idx, &hdi); |
339 |
return 0; |
return 0; |
340 |
} /* listview_sort_items */ |
} |
341 |
|
|
342 |
|
|
343 |
int |
int |
344 |
listview_get_curr_pos( listview_ctrl_t ctx ) |
listview_get_curr_pos( listview_ctrl_t ctx ) |
345 |
{ |
{ |
346 |
return ListView_GetNextItem( ctx->ctrl, -1, LVNI_SELECTED ); |
return ListView_GetNextItem( ctx->ctrl, -1, LVNI_SELECTED ); |
347 |
} /* listview_get_curr_pos */ |
} |
348 |
|
|
349 |
|
|
350 |
int |
int |
358 |
} |
} |
359 |
ListView_GetItemText (ctx->ctrl, pos, col, text, maxbytes); |
ListView_GetItemText (ctx->ctrl, pos, col, text, maxbytes); |
360 |
return 0; |
return 0; |
361 |
} /* listview_get_item_text */ |
} |
362 |
|
|
363 |
|
|
364 |
/* Use extended style with checkboxes for each item. */ |
/* Use extended style with checkboxes for each item. */ |
382 |
listview_set_column_order( listview_ctrl_t ctx, int *array ) |
listview_set_column_order( listview_ctrl_t ctx, int *array ) |
383 |
{ |
{ |
384 |
return ListView_SetColumnOrderArray( ctx->ctrl, ctx->cols, array ); |
return ListView_SetColumnOrderArray( ctx->ctrl, ctx->cols, array ); |
385 |
} /* listview_set_column_order */ |
} |
386 |
|
|
387 |
|
|
388 |
void |
void |
389 |
listview_select_all (listview_ctrl_t ctx) |
listview_select_all (listview_ctrl_t ctx) |
390 |
{ |
{ |
391 |
ListView_SetItemState( ctx->ctrl, -1, LVIS_SELECTED, LVIS_SELECTED ); |
ListView_SetItemState( ctx->ctrl, -1, LVIS_SELECTED, LVIS_SELECTED ); |
392 |
} /* listview_select_all */ |
} |
393 |
|
|
394 |
|
|
395 |
void |
void |
442 |
|
|
443 |
|
|
444 |
void |
void |
445 |
listview_set_image_list (listview_ctrl_t ctx, HICON *ico, DWORD nicons) |
listview_set_image_list (listview_ctrl_t ctx, int cx, int cy, |
446 |
|
HICON *ico, DWORD nicons) |
447 |
{ |
{ |
448 |
HIMAGELIST hil; |
HIMAGELIST hil; |
449 |
DWORD i; |
DWORD i; |
450 |
|
|
451 |
hil = ImageList_Create (16, 16, ILC_COLOR8|ILC_MASK, nicons, 1); |
if (cx == 0 || cy == 0) |
452 |
|
cx = cy = 16; |
453 |
|
|
454 |
|
hil = ImageList_Create (cx, cy, ILC_COLOR8|ILC_MASK, nicons, 1); |
455 |
ImageList_SetBkColor (hil, CLR_NONE); |
ImageList_SetBkColor (hil, CLR_NONE); |
456 |
for (i=0; i < nicons; i++) |
for (i=0; i < nicons; i++) |
457 |
ImageList_AddIcon (hil, ico[i]); |
ImageList_AddIcon (hil, ico[i]); |
458 |
ListView_SetImageList (ctx->ctrl, hil, LVSIL_SMALL); |
ListView_SetImageList (ctx->ctrl, hil, LVSIL_SMALL); |
459 |
} |
} |
|
|
|