]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/imaglist.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxImageList. You may wish to use the generic version.
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
18 #include "wx/window.h"
21 #include "wx/string.h"
27 #include "wx/os2/imaglist.h"
28 #include "wx/os2/private.h"
30 #if !USE_SHARED_LIBRARY
31 IMPLEMENT_DYNAMIC_CLASS(wxImageList
, wxObject
)
34 wxImageList::wxImageList()
39 wxImageList::~wxImageList()
43 // TODO: ImageList_Destroy((HIMAGELIST) m_hImageList);
48 ////////////////////////////////////////////////////////////////////////////
50 // Returns the number of images in the image list.
51 int wxImageList::GetImageCount() const
53 // TODO:: return ImageList_GetImageCount((HIMAGELIST) m_hImageList);
58 ////////////////////////////////////////////////////////////////////////////
60 // Creates an image list
61 bool wxImageList::Create(int width
, int height
, bool mask
, int initial
)
65 // TODO flags |= ILC_MASK;
67 // Grow by 1, I guess this is reasonable behaviour most of the time
68 // m_hImageList = (WXHIMAGELIST) ImageList_Create(width, height, flags, initial, 1);
69 return (m_hImageList
!= 0);
72 // Adds a bitmap, and optionally a mask bitmap.
73 // Note that wxImageList creates new bitmaps, so you may delete
74 // 'bitmap' and 'mask'.
75 int wxImageList::Add(const wxBitmap
& bitmap
, const wxBitmap
& mask
)
77 HBITMAP hBitmap1
= (HBITMAP
) bitmap
.GetHBITMAP();
80 hBitmap2
= (HBITMAP
) mask
.GetHBITMAP();
82 int index
; // = ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmap2);
85 wxLogError(wxT("Couldn't add an image to the image list."));
90 // Adds a bitmap, using the specified colour to create the mask bitmap
91 // Note that wxImageList creates new bitmaps, so you may delete
93 int wxImageList::Add(const wxBitmap
& bitmap
, const wxColour
& maskColour
)
95 HBITMAP hBitmap1
= (HBITMAP
) bitmap
.GetHBITMAP();
97 // COLORREF colorRef = PALETTERGB(maskColour.Red(), maskColour.Green(), maskColour.Blue());
98 // return ImageList_AddMasked((HIMAGELIST) GetHIMAGELIST(), hBitmap1, colorRef);
102 // Adds a bitmap and mask from an icon.
103 int wxImageList::Add(const wxIcon
& icon
)
105 HICON hIcon
= (HICON
) icon
.GetHICON();
106 // TODO: return ImageList_AddIcon((HIMAGELIST) GetHIMAGELIST(), hIcon);
110 // Replaces a bitmap, optionally passing a mask bitmap.
111 // Note that wxImageList creates new bitmaps, so you may delete
112 // 'bitmap' and 'mask'.
113 bool wxImageList::Replace(int index
, const wxBitmap
& bitmap
, const wxBitmap
& mask
)
115 HBITMAP hBitmap1
= (HBITMAP
) bitmap
.GetHBITMAP();
116 HBITMAP hBitmap2
= 0;
118 hBitmap2
= (HBITMAP
) mask
.GetHBITMAP();
119 // TODO: return (ImageList_Replace((HIMAGELIST) GetHIMAGELIST(), index, hBitmap1, hBitmap2) != 0);
123 // Replaces a bitmap and mask from an icon.
124 bool wxImageList::Replace(int index
, const wxIcon
& icon
)
126 HICON hIcon
= (HICON
) icon
.GetHICON();
127 // TODO: return (ImageList_ReplaceIcon((HIMAGELIST) GetHIMAGELIST(), index, hIcon) != 0);
131 // Removes the image at the given index.
132 bool wxImageList::Remove(int index
)
134 // TODO return (ImageList_Remove((HIMAGELIST) GetHIMAGELIST(), index) != 0);
139 bool wxImageList::RemoveAll(void)
141 // TODO: Is this correct?
142 while ( GetImageCount() > 0 )
149 // Draws the given image on a dc at the specified position.
150 // If 'solidBackground' is TRUE, Draw sets the image list background
151 // colour to the background colour of the wxDC, to speed up
152 // drawing by eliminating masked drawing where possible.
153 bool wxImageList::Draw(int index
, wxDC
& dc
, int x
, int y
,
154 int flags
, bool solidBackground
)
156 HDC hDC
= (HDC
) dc
.GetHDC();
160 if ( solidBackground
)
162 wxBrush
*brush
= & dc
.GetBackground();
163 if ( brush
&& brush
->Ok())
165 wxColour
col(brush
->GetColour());
166 // ImageList_SetBkColor((HIMAGELIST) GetHIMAGELIST(),
167 // PALETTERGB(col.Red(), col.Green(), col.Blue()));
170 // ImageList_SetBkColor((HIMAGELIST) GetHIMAGELIST(),
174 // ImageList_SetBkColor((HIMAGELIST) GetHIMAGELIST(),
179 if ( flags & wxIMAGELIST_DRAW_NORMAL )
181 if ( flags & wxIMAGELIST_DRAW_TRANSPARENT )
182 style |= ILD_TRANSPARENT;
183 if ( flags & wxIMAGELIST_DRAW_SELECTED )
184 style |= ILD_SELECTED;
185 if ( flags & wxIMAGELIST_DRAW_FOCUSED )
187 return (ImageList_Draw((HIMAGELIST) GetHIMAGELIST(), index, hDC,