1 |
/* wptImagelist.cpp - Imagelist helper routines |
/* wptImagelist.cpp - Key Manager Imagelist |
2 |
* Copyright (C) 2004, 2006, 2009 Timo Schulz |
* Copyright (C) 2004, 2006, 2009 Timo Schulz |
3 |
* Copyright (C) 2003 Andreas Jobs |
* Copyright (C) 2003 Andreas Jobs |
4 |
* |
* |
30 |
#include "wptVersion.h" |
#include "wptVersion.h" |
31 |
|
|
32 |
|
|
33 |
int il_map[IMAGELIST_NUMIMAGES+2]; |
int kl_il_map[IMAGELIST_NUMIMAGES+2]; |
|
int il_map_bitmap[IMAGELIST_NUMIMAGES+2]; |
|
|
|
|
34 |
|
|
35 |
#define replace_icon(il_ctx, resid) \ |
#define replace_icon(il_ctx, resid) \ |
36 |
ImageList_ReplaceIcon ((il_ctx), -1, \ |
ImageList_ReplaceIcon ((il_ctx), -1, \ |
39 |
/* Load the image list with the default icons. |
/* Load the image list with the default icons. |
40 |
Return value: 0 on success. */ |
Return value: 0 on success. */ |
41 |
int |
int |
42 |
imagelist_load (HWND hwnd, HIMAGELIST *r_il) |
km_imagelist_load (HWND hwnd, HIMAGELIST *r_il) |
43 |
{ |
{ |
44 |
HIMAGELIST il = ImageList_Create (16, 16, ILC_COLOR|ILC_MASK, |
HIMAGELIST il = ImageList_Create (16, 16, ILC_COLOR|ILC_MASK, |
45 |
IMAGELIST_NUMIMAGES, 0); |
IMAGELIST_NUMIMAGES, 0); |
48 |
return -1; |
return -1; |
49 |
} |
} |
50 |
|
|
51 |
il_map[IMI_KEY_NEW] = replace_icon (il, IDI_KEY_NEW); |
kl_il_map[IMI_KEY_NEW] = replace_icon (il, IDI_KEY_NEW); |
52 |
il_map[IMI_KEY_DELETE] = replace_icon (il, IDI_KEY_DELETE); |
kl_il_map[IMI_KEY_DELETE] = replace_icon (il, IDI_KEY_DELETE); |
53 |
il_map[IMI_KEY_PROPS] = replace_icon (il, IDI_KEY_PROPS); |
kl_il_map[IMI_KEY_PROPS] = replace_icon (il, IDI_KEY_PROPS); |
54 |
il_map[IMI_KEY_SIGN] = replace_icon (il, IDI_KEY_SIGN); |
kl_il_map[IMI_KEY_SIGN] = replace_icon (il, IDI_KEY_SIGN); |
55 |
il_map[IMI_KEY_SEARCH] = replace_icon (il, IDI_KEY_SEARCH); |
kl_il_map[IMI_KEY_SEARCH] = replace_icon (il, IDI_KEY_SEARCH); |
56 |
il_map[IMI_KEY_FILE_IMPORT]= replace_icon (il, IDI_KEY_FILE_IMPORT); |
kl_il_map[IMI_KEY_FILE_IMPORT]= replace_icon (il, IDI_KEY_FILE_IMPORT); |
57 |
il_map[IMI_KEY_FILE_EXPORT]= replace_icon (il, IDI_KEY_FILE_EXPORT); |
kl_il_map[IMI_KEY_FILE_EXPORT]= replace_icon (il, IDI_KEY_FILE_EXPORT); |
58 |
il_map[IMI_KEY_IMPORT] = replace_icon (il, IDI_KEY_IMPORT); |
kl_il_map[IMI_KEY_IMPORT] = replace_icon (il, IDI_KEY_IMPORT); |
59 |
il_map[IMI_KEY_EXPORT] = replace_icon (il, IDI_KEY_EXPORT); |
kl_il_map[IMI_KEY_EXPORT] = replace_icon (il, IDI_KEY_EXPORT); |
60 |
il_map[IMI_SORT_UPARROW] = replace_icon (il, IDI_SORT_UPARROW); |
kl_il_map[IMI_SORT_UPARROW] = replace_icon (il, IDI_SORT_UPARROW); |
61 |
il_map[IMI_SORT_DOWNARROW] = replace_icon (il, IDI_SORT_DOWNARROW); |
kl_il_map[IMI_SORT_DOWNARROW] = replace_icon (il, IDI_SORT_DOWNARROW); |
62 |
*r_il = il; |
*r_il = il; |
63 |
return 0; |
return 0; |
64 |
} |
} |
66 |
|
|
67 |
/* Free image list. */ |
/* Free image list. */ |
68 |
int |
int |
69 |
imagelist_destroy (HIMAGELIST il) |
km_imagelist_destroy (HIMAGELIST il) |
70 |
{ |
{ |
71 |
int ret = 0; |
int ret = 0; |
72 |
if (!ImageList_Destroy (il)) |
if (!ImageList_Destroy (il)) |
77 |
|
|
78 |
/* Map an index to an icon. */ |
/* Map an index to an icon. */ |
79 |
int |
int |
80 |
imagelist_getindex (HIMAGELIST il, int icon) |
km_imagelist_getindex (HIMAGELIST il, int icon) |
81 |
{ |
{ |
82 |
if ((icon < 0) || (icon >= IMAGELIST_NUMIMAGES)) |
if ((icon < 0) || (icon >= IMAGELIST_NUMIMAGES)) |
83 |
return -1; |
return -1; |
84 |
return il_map[icon]; |
return kl_il_map[icon]; |
|
} |
|
|
|
|
|
|
|
|
int |
|
|
b_imagelist_load (HWND hwnd, HIMAGELIST *r_il) |
|
|
{ |
|
|
HIMAGELIST il = ImageList_Create (30, 30, ILC_COLOR8|ILC_MASK, 2, 0); |
|
|
if (!il ) { |
|
|
msg_box (hwnd, "Could not create imagelist.", _("Key Manager"), MB_ERR); |
|
|
return -1; |
|
|
} |
|
|
|
|
|
HBITMAP bm = LoadBitmap (glob_hinst, MAKEINTRESOURCE(IDI_KEYMISC_N_NEWKEY)); |
|
|
if (ImageList_Add (il, bm, NULL) == -1) |
|
|
msg_box (hwnd, "Could not replace bitmap", "", MB_ERR); |
|
|
|
|
|
bm = LoadBitmap (glob_hinst, MAKEINTRESOURCE(IDI_KEYMISC_N_DELETE)); |
|
|
if (ImageList_Add (il, bm, NULL) == -1) |
|
|
msg_box (hwnd, "Could not replace bitmap", "", MB_ERR); |
|
|
|
|
|
il_map_bitmap[IMI_KEY_NEW] = 0; |
|
|
il_map_bitmap[IMI_KEY_DELETE] = 1; |
|
|
*r_il = il; |
|
|
return 0; |
|
|
} |
|
|
|
|
|
|
|
|
int |
|
|
b_imagelist_destroy (HIMAGELIST il) |
|
|
{ |
|
|
return imagelist_destroy (il); |
|
|
} |
|
|
|
|
|
int |
|
|
b_imagelist_getindex (HIMAGELIST il, int img) |
|
|
{ |
|
|
return il_map_bitmap[img]; |
|
85 |
} |
} |