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

Diff of /trunk/Src/wptImagelist.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 327 by twoaday, Thu Jan 12 16:28:06 2006 UTC revision 328 by twoaday, Fri Sep 25 16:07:38 2009 UTC
# Line 1  Line 1 
1  /* wptImagelist.cpp - Imagelist helper routines  /* wptImagelist.cpp - Imagelist helper routines
2     *      Copyright (C) 2004, 2006, 2009 Timo Schulz
3   *      Copyright (C) 2003 Andreas Jobs   *      Copyright (C) 2003 Andreas Jobs
  *      Copyright (C) 2004, 2006 Timo Schulz  
4   *   *
5   * This file is part of WinPT.   * This file is part of WinPT.
6   *   *
# Line 13  Line 13 
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>
# Line 33  Line 29 
29  #include "wptCommonCtl.h"  #include "wptCommonCtl.h"
30  #include "wptVersion.h"  #include "wptVersion.h"
31    
 int il_map[IMAGELIST_NUMIMAGES];  
32    
33    int il_map[IMAGELIST_NUMIMAGES+2];
34    int il_map_bitmap[IMAGELIST_NUMIMAGES+2];
35    
 #define replace_icon(resid) \  
     ImageList_ReplaceIcon (glob_imagelist, -1, \  
                            LoadIcon (glob_hinst, MAKEINTRESOURCE (resid)))  
36    
37    #define replace_icon(il_ctx, resid) \
38        ImageList_ReplaceIcon ((il_ctx), -1, \
39                               LoadIcon (glob_hinst, MAKEINTRESOURCE (resid)))
40    
41  /* Load the image list with the default icons.  /* Load the image list with the default icons.
42     Return value: 0 on success.  */     Return value: 0 on success.  */
43  int  int
44  imagelist_load (HWND hwnd)  imagelist_load (HWND hwnd, HIMAGELIST *r_il)
45  {  {
46      glob_imagelist = ImageList_Create (16, 16, ILC_COLOR|ILC_MASK,      HIMAGELIST il = ImageList_Create (16, 16, ILC_COLOR|ILC_MASK,
47                                         IMAGELIST_NUMIMAGES, 0);                                        IMAGELIST_NUMIMAGES, 0);
48      if (!glob_imagelist) {      if (!il) {
49          msg_box (hwnd, "Could not create imagelist.", _("Key Manager"), MB_ERR);          msg_box (hwnd, "Could not create imagelist.", _("Key Manager"), MB_ERR);
50          return -1;          return -1;
51      }      }
52    
53      il_map[IMI_KEY_NEW]        = replace_icon (IDI_KEY_NEW);      il_map[IMI_KEY_NEW]        = replace_icon (il, IDI_KEY_NEW);
54      il_map[IMI_KEY_DELETE]     = replace_icon (IDI_KEY_DELETE);      il_map[IMI_KEY_DELETE]     = replace_icon (il, IDI_KEY_DELETE);
55      il_map[IMI_KEY_PROPS]      = replace_icon (IDI_KEY_PROPS);      il_map[IMI_KEY_PROPS]      = replace_icon (il, IDI_KEY_PROPS);
56      il_map[IMI_KEY_SIGN]       = replace_icon (IDI_KEY_SIGN);      il_map[IMI_KEY_SIGN]       = replace_icon (il, IDI_KEY_SIGN);
57      il_map[IMI_KEY_SEARCH]     = replace_icon (IDI_KEY_SEARCH);      il_map[IMI_KEY_SEARCH]     = replace_icon (il, IDI_KEY_SEARCH);
58      il_map[IMI_KEY_FILE_IMPORT]= replace_icon (IDI_KEY_FILE_IMPORT);      il_map[IMI_KEY_FILE_IMPORT]= replace_icon (il, IDI_KEY_FILE_IMPORT);
59      il_map[IMI_KEY_FILE_EXPORT]= replace_icon (IDI_KEY_FILE_EXPORT);      il_map[IMI_KEY_FILE_EXPORT]= replace_icon (il, IDI_KEY_FILE_EXPORT);
60      il_map[IMI_KEY_IMPORT]     = replace_icon (IDI_KEY_IMPORT);      il_map[IMI_KEY_IMPORT]     = replace_icon (il, IDI_KEY_IMPORT);
61      il_map[IMI_KEY_EXPORT]     = replace_icon (IDI_KEY_EXPORT);          il_map[IMI_KEY_EXPORT]     = replace_icon (il, IDI_KEY_EXPORT);    
62      il_map[IMI_SORT_UPARROW]   = replace_icon (IDI_SORT_UPARROW);      il_map[IMI_SORT_UPARROW]   = replace_icon (il, IDI_SORT_UPARROW);
63      il_map[IMI_SORT_DOWNARROW] = replace_icon (IDI_SORT_DOWNARROW);      il_map[IMI_SORT_DOWNARROW] = replace_icon (il, IDI_SORT_DOWNARROW);
64        *r_il = il;
65      return 0;      return 0;
66  }  }
67    
68    
69  /* Free image list. */  /* Free image list. */
70  int  int
71  imagelist_destroy (void)  imagelist_destroy (HIMAGELIST il)
72  {  {
73      ImageList_Destroy (glob_imagelist);      int ret = 0;
74      glob_imagelist = NULL;      if (!ImageList_Destroy (il))
75      return 0;          ret = WPTERR_GENERAL;
76        return ret;
77  }  }
78    
79    
80  /* Map an index to an icon. */  /* Map an index to an icon. */
81  int  int
82  imagelist_getindex (int icon)  imagelist_getindex (HIMAGELIST il, int icon)
83  {  {
84      if ((icon < 0) || (icon >= IMAGELIST_NUMIMAGES))      if ((icon < 0) || (icon >= IMAGELIST_NUMIMAGES))
85          return -1;          return -1;
86      return il_map[icon];      return il_map[icon];
87  }  }
88    
89    
90    int
91    b_imagelist_load (HWND hwnd, HIMAGELIST *r_il)
92    {
93        HIMAGELIST il = ImageList_Create (30, 30, ILC_COLOR8|ILC_MASK, 2, 0);
94        if (!il ) {
95            msg_box (hwnd, "Could not create imagelist.", _("Key Manager"), MB_ERR);
96            return -1;
97        }
98        
99        HBITMAP bm = LoadBitmap (glob_hinst, MAKEINTRESOURCE(IDI_KEYMISC_N_NEWKEY));
100        if (ImageList_Add (il, bm, NULL) == -1)
101            msg_box (hwnd, "Could not replace bitmap", "", MB_ERR);
102        
103        bm = LoadBitmap (glob_hinst, MAKEINTRESOURCE(IDI_KEYMISC_N_DELETE));
104        if (ImageList_Add (il, bm, NULL) == -1)
105            msg_box (hwnd, "Could not replace bitmap", "", MB_ERR);
106        
107        il_map_bitmap[IMI_KEY_NEW] = 0;
108        il_map_bitmap[IMI_KEY_DELETE] = 1;
109        *r_il = il;
110        return 0;
111    }
112    
113    
114    int
115    b_imagelist_destroy (HIMAGELIST il)
116    {
117        return imagelist_destroy (il);
118    }
119    
120    int
121    b_imagelist_getindex (HIMAGELIST il, int img)
122    {
123        return il_map_bitmap[img];
124    }

Legend:
Removed from v.327  
changed lines
  Added in v.328

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26