1 |
/* wptListView.cpp - Dynamic list view control |
/* wptListView.cpp - Dynamic list view control |
2 |
* Copyright (C) 2000-2006 Timo Schulz |
* Copyright (C) 2000-2007, 2009 Timo Schulz |
3 |
* Copyright (C) 2004 Andreas Jobs |
* Copyright (C) 2004 Andreas Jobs |
4 |
* |
* |
5 |
* This file is part of WinPT. |
* This file is part of WinPT. |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
* General Public License for more details. |
* General Public License for more details. |
|
* |
|
|
* You should have received a copy of the GNU General Public License |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
16 |
*/ |
*/ |
|
|
|
17 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
18 |
#include <config.h> |
#include <config.h> |
19 |
#endif |
#endif |
199 |
|
|
200 |
|
|
201 |
int |
int |
202 |
listview_count_items( listview_ctrl_t ctx, int curr_sel ) |
listview_count_items (listview_ctrl_t ctx, int curr_sel) |
203 |
{ |
{ |
204 |
int n; |
int n; |
205 |
|
|
320 |
void |
void |
321 |
listview_set_chkbox_style (listview_ctrl_t ctx) |
listview_set_chkbox_style (listview_ctrl_t ctx) |
322 |
{ |
{ |
323 |
ListView_SetExtendedListViewStyle (ctx->ctrl, LVS_EX_CHECKBOXES); |
DWORD flag = LVS_EX_CHECKBOXES; |
324 |
|
DWORD style; |
325 |
|
style = ListView_GetExtendedListViewStyle (ctx->ctrl)|flag; |
326 |
|
ListView_SetExtendedListViewStyle (ctx->ctrl, style); |
327 |
ctx->ext_chkbox = 1; |
ctx->ext_chkbox = 1; |
328 |
} |
} |
329 |
|
|
331 |
/* Use extended style to select the entire row. */ |
/* Use extended style to select the entire row. */ |
332 |
void |
void |
333 |
listview_set_ext_style (listview_ctrl_t ctx) |
listview_set_ext_style (listview_ctrl_t ctx) |
334 |
{ |
{ |
335 |
ListView_SetExtendedListViewStyle (ctx->ctrl, LVS_EX_FULLROWSELECT); |
DWORD flag = LVS_EX_FULLROWSELECT; |
336 |
|
DWORD style; |
337 |
|
style = ListView_GetExtendedListViewStyle (ctx->ctrl)|flag; |
338 |
|
ListView_SetExtendedListViewStyle (ctx->ctrl, style); |
339 |
} |
} |
340 |
|
|
341 |
|
|
342 |
|
void |
343 |
|
listview_set_grid_style (listview_ctrl_t ctx) |
344 |
|
{ |
345 |
|
DWORD flag = LVS_EX_GRIDLINES; |
346 |
|
DWORD style; |
347 |
|
style = ListView_GetExtendedListViewStyle (ctx->ctrl)|flag; |
348 |
|
ListView_SetExtendedListViewStyle (ctx->ctrl, style); |
349 |
|
} |
350 |
|
|
351 |
int |
int |
352 |
listview_set_column_order( listview_ctrl_t ctx, int *array ) |
listview_set_column_order (listview_ctrl_t ctx, int *array) |
353 |
{ |
{ |
354 |
return ListView_SetColumnOrderArray( ctx->ctrl, ctx->cols, array ); |
return ListView_SetColumnOrderArray (ctx->ctrl, ctx->cols, array); |
355 |
} |
} |
356 |
|
|
357 |
|
|
358 |
void |
void |
359 |
listview_select_all (listview_ctrl_t ctx) |
listview_select_all (listview_ctrl_t ctx) |
360 |
{ |
{ |
361 |
ListView_SetItemState( ctx->ctrl, -1, LVIS_SELECTED, LVIS_SELECTED ); |
ListView_SetItemState (ctx->ctrl, -1, LVIS_SELECTED, LVIS_SELECTED); |
362 |
} |
} |
363 |
|
|
364 |
|
|
384 |
|
|
385 |
if (oldpos == -1) |
if (oldpos == -1) |
386 |
oldpos = 0; |
oldpos = 0; |
|
//log_box ("debug", 0, "oldpos=%d newpos=%d diff=%d", |
|
|
//oldpos, newpos, newpos-oldpos); |
|
387 |
ListView_Scroll (ctx->ctrl, 0, (newpos-oldpos)*size); |
ListView_Scroll (ctx->ctrl, 0, (newpos-oldpos)*size); |
388 |
} |
} |
389 |
|
|
397 |
/* We assume the first column contains text. */ |
/* We assume the first column contains text. */ |
398 |
n = listview_count_items (ctx, 0); |
n = listview_count_items (ctx, 0); |
399 |
for (i = 0; i < n; i++) { |
for (i = 0; i < n; i++) { |
400 |
listview_get_item_text (ctx, i, 0, buf, sizeof (buf)-1); |
listview_get_item_text (ctx, i, 0, buf, DIM (buf)-1); |
401 |
if (stristr (buf, str)) { |
if (stristr (buf, str)) { |
402 |
fnd = 1; |
fnd = 1; |
403 |
break; |
break; |
440 |
HICON *ico, DWORD nicons) |
HICON *ico, DWORD nicons) |
441 |
{ |
{ |
442 |
HIMAGELIST hil; |
HIMAGELIST hil; |
|
DWORD i; |
|
443 |
|
|
444 |
if (cx <= 0 || cy <= 0) |
if (cx <= 0 || cy <= 0) |
445 |
cx = cy = 16; /* default size. */ |
cx = cy = 16; /* default size. */ |
446 |
|
|
447 |
hil = ImageList_Create (cx, cy, ILC_COLOR8|ILC_MASK, nicons, 1); |
hil = ImageList_Create (cx, cy, ILC_COLOR8|ILC_MASK, nicons, 1); |
448 |
ImageList_SetBkColor (hil, CLR_NONE); |
ImageList_SetBkColor (hil, CLR_NONE); |
449 |
for (i=0; i < nicons; i++) |
for (DWORD i=0; i < nicons; i++) |
450 |
ImageList_AddIcon (hil, ico[i]); |
ImageList_AddIcon (hil, ico[i]); |
451 |
ListView_SetImageList (ctx->ctrl, hil, LVSIL_SMALL); |
(void)ListView_SetImageList (ctx->ctrl, hil, LVSIL_SMALL); |
452 |
} |
} |