1 |
twoaday |
2 |
/* wptImagelist.cpp - Imagelist helper routines |
2 |
|
|
* Copyright (C) 2003 Andreas Jobs |
3 |
|
|
* Copyright (C) 2004 Timo Schulz |
4 |
|
|
* |
5 |
|
|
* This file is part of WinPT. |
6 |
|
|
* |
7 |
|
|
* WinPT is free software; you can redistribute it and/or |
8 |
|
|
* modify it under the terms of the GNU General Public License |
9 |
|
|
* as published by the Free Software Foundation; either version 2 |
10 |
|
|
* of the License, or (at your option) any later version. |
11 |
|
|
* |
12 |
|
|
* WinPT is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
|
|
* General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
19 |
|
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
|
|
*/ |
21 |
|
|
|
22 |
|
|
#include <windows.h> |
23 |
|
|
#include <commctrl.h> |
24 |
|
|
|
25 |
|
|
#include "wptTypes.h" |
26 |
|
|
#include "wptErrors.h" |
27 |
|
|
#include "wptNLS.h" |
28 |
|
|
#include "wptW32API.h" |
29 |
|
|
#include "../resource.h" |
30 |
|
|
#include "wptCommonCtl.h" |
31 |
|
|
#include "wptVersion.h" |
32 |
|
|
|
33 |
|
|
int il_map[IMAGELIST_NUMIMAGES]; |
34 |
|
|
|
35 |
|
|
|
36 |
|
|
#define replace_icon(resid) \ |
37 |
|
|
ImageList_ReplaceIcon (glob_imagelist, -1, \ |
38 |
|
|
LoadIcon (glob_hinst, MAKEINTRESOURCE (resid))) |
39 |
|
|
|
40 |
|
|
int |
41 |
|
|
imagelist_load (HWND hwnd) |
42 |
|
|
{ |
43 |
|
|
glob_imagelist = ImageList_Create (16, 16, ILC_COLOR|ILC_MASK, |
44 |
|
|
IMAGELIST_NUMIMAGES, 0); |
45 |
|
|
if (!glob_imagelist) { |
46 |
twoaday |
32 |
msg_box (hwnd, "Could not create imagelist.", _("Key Manager"), MB_ERR); |
47 |
twoaday |
2 |
return -1; |
48 |
|
|
} |
49 |
|
|
|
50 |
|
|
il_map[IMI_KEY_DELETE] = replace_icon (IDI_KEY_DELETE); |
51 |
|
|
il_map[IMI_KEY_PROPS] = replace_icon (IDI_KEY_PROPS); |
52 |
|
|
il_map[IMI_KEY_SIGN] = replace_icon (IDI_KEY_SIGN); |
53 |
|
|
il_map[IMI_KEY_IMPORT] = replace_icon (IDI_KEY_IMPORT); |
54 |
|
|
il_map[IMI_KEY_EXPORT] = replace_icon (IDI_KEY_EXPORT); |
55 |
|
|
il_map[IMI_SORT_UPARROW] = replace_icon (IDI_SORT_UPARROW); |
56 |
|
|
il_map[IMI_SORT_DOWNARROW] = replace_icon (IDI_SORT_DOWNARROW); |
57 |
|
|
/*il_map[IMI_EXIT] = replace_icon (IDI_EXIT);*/ |
58 |
|
|
return 0; |
59 |
|
|
} /* imagelist_load */ |
60 |
|
|
|
61 |
|
|
|
62 |
|
|
int |
63 |
|
|
imagelist_destroy (void) |
64 |
|
|
{ |
65 |
|
|
ImageList_Destroy (glob_imagelist); |
66 |
|
|
glob_imagelist = NULL; |
67 |
|
|
return 0; |
68 |
|
|
} /* imagelist_destroy */ |
69 |
|
|
|
70 |
|
|
|
71 |
|
|
int |
72 |
|
|
imagelist_getindex (int icon) |
73 |
|
|
{ |
74 |
|
|
if ((icon < 0) || (icon >= IMAGELIST_NUMIMAGES)) |
75 |
|
|
return -1; |
76 |
|
|
return il_map[icon]; |
77 |
twoaday |
20 |
} /* imagelist_getindex */ |