1370b324cSopenharmony_ci// Windows/Control/ImageList.h
2370b324cSopenharmony_ci
3370b324cSopenharmony_ci#ifndef ZIP7_INC_WINDOWS_CONTROL_IMAGE_LIST_H
4370b324cSopenharmony_ci#define ZIP7_INC_WINDOWS_CONTROL_IMAGE_LIST_H
5370b324cSopenharmony_ci
6370b324cSopenharmony_ci#include <CommCtrl.h>
7370b324cSopenharmony_ci
8370b324cSopenharmony_ci#include "../Defs.h"
9370b324cSopenharmony_ci
10370b324cSopenharmony_cinamespace NWindows {
11370b324cSopenharmony_cinamespace NControl {
12370b324cSopenharmony_ci
13370b324cSopenharmony_ciclass CImageList
14370b324cSopenharmony_ci{
15370b324cSopenharmony_ci  HIMAGELIST m_Object;
16370b324cSopenharmony_cipublic:
17370b324cSopenharmony_ci  operator HIMAGELIST() const {return m_Object; }
18370b324cSopenharmony_ci  CImageList(): m_Object(NULL) {}
19370b324cSopenharmony_ci  bool Attach(HIMAGELIST imageList)
20370b324cSopenharmony_ci  {
21370b324cSopenharmony_ci    if (imageList == NULL)
22370b324cSopenharmony_ci      return false;
23370b324cSopenharmony_ci    m_Object = imageList;
24370b324cSopenharmony_ci    return true;
25370b324cSopenharmony_ci  }
26370b324cSopenharmony_ci
27370b324cSopenharmony_ci  HIMAGELIST Detach()
28370b324cSopenharmony_ci  {
29370b324cSopenharmony_ci    HIMAGELIST imageList = m_Object;
30370b324cSopenharmony_ci    m_Object = NULL;
31370b324cSopenharmony_ci    return imageList;
32370b324cSopenharmony_ci  }
33370b324cSopenharmony_ci
34370b324cSopenharmony_ci  bool Create(int width, int height, UINT flags, int initialNumber, int grow)
35370b324cSopenharmony_ci  {
36370b324cSopenharmony_ci    HIMAGELIST a = ImageList_Create(width, height, flags,
37370b324cSopenharmony_ci      initialNumber, grow);
38370b324cSopenharmony_ci    if (a == NULL)
39370b324cSopenharmony_ci      return false;
40370b324cSopenharmony_ci    return Attach(a);
41370b324cSopenharmony_ci  }
42370b324cSopenharmony_ci
43370b324cSopenharmony_ci  bool Destroy() // DeleteImageList() in MFC
44370b324cSopenharmony_ci  {
45370b324cSopenharmony_ci    if (m_Object == NULL)
46370b324cSopenharmony_ci      return false;
47370b324cSopenharmony_ci    return BOOLToBool(ImageList_Destroy(Detach()));
48370b324cSopenharmony_ci  }
49370b324cSopenharmony_ci
50370b324cSopenharmony_ci  ~CImageList()
51370b324cSopenharmony_ci    { Destroy(); }
52370b324cSopenharmony_ci
53370b324cSopenharmony_ci  int GetImageCount() const
54370b324cSopenharmony_ci    { return ImageList_GetImageCount(m_Object); }
55370b324cSopenharmony_ci
56370b324cSopenharmony_ci  bool GetImageInfo(int index, IMAGEINFO* imageInfo) const
57370b324cSopenharmony_ci    { return BOOLToBool(ImageList_GetImageInfo(m_Object, index, imageInfo)); }
58370b324cSopenharmony_ci
59370b324cSopenharmony_ci  int Add(HBITMAP hbmImage, HBITMAP hbmMask = NULL)
60370b324cSopenharmony_ci    { return ImageList_Add(m_Object, hbmImage, hbmMask); }
61370b324cSopenharmony_ci  int AddMasked(HBITMAP hbmImage, COLORREF mask)
62370b324cSopenharmony_ci    { return ImageList_AddMasked(m_Object, hbmImage, mask); }
63370b324cSopenharmony_ci  int AddIcon(HICON icon)
64370b324cSopenharmony_ci    { return ImageList_AddIcon(m_Object, icon); }
65370b324cSopenharmony_ci  int Replace(int index, HICON icon)
66370b324cSopenharmony_ci    { return ImageList_ReplaceIcon(m_Object, index, icon); }
67370b324cSopenharmony_ci
68370b324cSopenharmony_ci  // If index is -1, the function removes all images.
69370b324cSopenharmony_ci  bool Remove(int index)
70370b324cSopenharmony_ci    { return BOOLToBool(ImageList_Remove(m_Object, index)); }
71370b324cSopenharmony_ci  bool RemoveAll()
72370b324cSopenharmony_ci    { return BOOLToBool(ImageList_RemoveAll(m_Object)); }
73370b324cSopenharmony_ci
74370b324cSopenharmony_ci  HICON ExtractIcon(int index)
75370b324cSopenharmony_ci    { return ImageList_ExtractIcon(NULL, m_Object, index); }
76370b324cSopenharmony_ci  HICON GetIcon(int index, UINT flags)
77370b324cSopenharmony_ci    { return ImageList_GetIcon(m_Object, index, flags); }
78370b324cSopenharmony_ci
79370b324cSopenharmony_ci  bool GetIconSize(int &width, int &height) const
80370b324cSopenharmony_ci    { return BOOLToBool(ImageList_GetIconSize(m_Object, &width, &height)); }
81370b324cSopenharmony_ci  bool SetIconSize(int width, int height)
82370b324cSopenharmony_ci    { return BOOLToBool(ImageList_SetIconSize(m_Object, width, height)); }
83370b324cSopenharmony_ci};
84370b324cSopenharmony_ci
85370b324cSopenharmony_ci}}
86370b324cSopenharmony_ci
87370b324cSopenharmony_ci#endif
88