/[winpt]/trunk/Src/wptImagelist.cpp
ViewVC logotype

Contents of /trunk/Src/wptImagelist.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 333 - (show annotations)
Tue Oct 13 10:51:21 2009 UTC (15 years, 4 months ago) by twoaday
File size: 2613 byte(s)


1 /* wptImagelist.cpp - Key Manager Imagelist
2 * Copyright (C) 2004, 2006, 2009 Timo Schulz
3 * Copyright (C) 2003 Andreas Jobs
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 #ifdef HAVE_CONFIG_H
18 #include <config.h>
19 #endif
20
21 #include <windows.h>
22 #include <commctrl.h>
23
24 #include "wptTypes.h"
25 #include "wptErrors.h"
26 #include "wptNLS.h"
27 #include "wptW32API.h"
28 #include "resource.h"
29 #include "wptCommonCtl.h"
30 #include "wptVersion.h"
31
32
33 int kl_il_map[IMAGELIST_NUMIMAGES+2];
34
35 #define replace_icon(il_ctx, resid) \
36 ImageList_ReplaceIcon ((il_ctx), -1, \
37 LoadIcon (glob_hinst, MAKEINTRESOURCE (resid)))
38
39 /* Load the image list with the default icons.
40 Return value: 0 on success. */
41 int
42 km_imagelist_load (HWND hwnd, HIMAGELIST *r_il)
43 {
44 HIMAGELIST il = ImageList_Create (16, 16, ILC_COLOR|ILC_MASK,
45 IMAGELIST_NUMIMAGES, 0);
46 if (!il) {
47 msg_box (hwnd, "Could not create imagelist.", _("Key Manager"), MB_ERR);
48 return -1;
49 }
50
51 kl_il_map[IMI_KEY_NEW] = replace_icon (il, IDI_KEY_NEW);
52 kl_il_map[IMI_KEY_DELETE] = replace_icon (il, IDI_KEY_DELETE);
53 kl_il_map[IMI_KEY_PROPS] = replace_icon (il, IDI_KEY_PROPS);
54 kl_il_map[IMI_KEY_SIGN] = replace_icon (il, IDI_KEY_SIGN);
55 kl_il_map[IMI_KEY_SEARCH] = replace_icon (il, IDI_KEY_SEARCH);
56 kl_il_map[IMI_KEY_FILE_IMPORT]= replace_icon (il, IDI_KEY_FILE_IMPORT);
57 kl_il_map[IMI_KEY_FILE_EXPORT]= replace_icon (il, IDI_KEY_FILE_EXPORT);
58 kl_il_map[IMI_KEY_IMPORT] = replace_icon (il, IDI_KEY_IMPORT);
59 kl_il_map[IMI_KEY_EXPORT] = replace_icon (il, IDI_KEY_EXPORT);
60 kl_il_map[IMI_SORT_UPARROW] = replace_icon (il, IDI_SORT_UPARROW);
61 kl_il_map[IMI_SORT_DOWNARROW] = replace_icon (il, IDI_SORT_DOWNARROW);
62 *r_il = il;
63 return 0;
64 }
65
66
67 /* Free image list. */
68 int
69 km_imagelist_destroy (HIMAGELIST il)
70 {
71 int ret = 0;
72 if (!ImageList_Destroy (il))
73 ret = WPTERR_GENERAL;
74 return ret;
75 }
76
77
78 /* Map an index to an icon. */
79 int
80 km_imagelist_getindex (HIMAGELIST il, int icon)
81 {
82 if ((icon < 0) || (icon >= IMAGELIST_NUMIMAGES))
83 return -1;
84 return kl_il_map[icon];
85 }

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26