]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: imaglist.cpp | |
3 | // Purpose: wxImageList. You may wish to use the generic version. | |
fb9010ed | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
fb9010ed | 6 | // Created: 10/09/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
fb9010ed DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
fb9010ed DW |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifndef WX_PRECOMP | |
16 | #include <stdio.h> | |
17 | #include "wx/setup.h" | |
18 | #include "wx/window.h" | |
19 | #include "wx/icon.h" | |
20 | #include "wx/dc.h" | |
21 | #include "wx/string.h" | |
0e320a79 DW |
22 | #endif |
23 | ||
fb9010ed DW |
24 | #include "wx/log.h" |
25 | #include "wx/intl.h" | |
26 | ||
27 | #include "wx/os2/imaglist.h" | |
28 | #include "wx/os2/private.h" | |
0e320a79 DW |
29 | |
30 | #if !USE_SHARED_LIBRARY | |
31 | IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject) | |
32 | #endif | |
33 | ||
34 | wxImageList::wxImageList() | |
35 | { | |
fb9010ed | 36 | m_hImageList = 0; |
0e320a79 DW |
37 | } |
38 | ||
39 | wxImageList::~wxImageList() | |
40 | { | |
fb9010ed DW |
41 | if ( m_hImageList ) |
42 | return; | |
43 | // TODO: ImageList_Destroy((HIMAGELIST) m_hImageList); | |
44 | m_hImageList = 0; | |
0e320a79 DW |
45 | } |
46 | ||
0e320a79 DW |
47 | // Attributes |
48 | //////////////////////////////////////////////////////////////////////////// | |
49 | ||
50 | // Returns the number of images in the image list. | |
51 | int wxImageList::GetImageCount() const | |
52 | { | |
fb9010ed DW |
53 | // TODO:: return ImageList_GetImageCount((HIMAGELIST) m_hImageList); |
54 | return 0; | |
0e320a79 DW |
55 | } |
56 | ||
57 | // Operations | |
58 | //////////////////////////////////////////////////////////////////////////// | |
59 | ||
60 | // Creates an image list | |
61 | bool wxImageList::Create(int width, int height, bool mask, int initial) | |
62 | { | |
fb9010ed DW |
63 | UINT flags = 0; |
64 | // if ( mask ) | |
65 | // TODO flags |= ILC_MASK; | |
66 | ||
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); | |
0e320a79 DW |
70 | } |
71 | ||
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) | |
76 | { | |
fb9010ed DW |
77 | HBITMAP hBitmap1 = (HBITMAP) bitmap.GetHBITMAP(); |
78 | HBITMAP hBitmap2 = 0; | |
79 | if ( mask.Ok() ) | |
80 | hBitmap2 = (HBITMAP) mask.GetHBITMAP(); | |
81 | ||
82 | int index; // = ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmap2); | |
83 | if ( index == -1 ) | |
84 | { | |
85 | wxLogError(wxT("Couldn't add an image to the image list.")); | |
86 | } | |
87 | return index; | |
0e320a79 DW |
88 | } |
89 | ||
90 | // Adds a bitmap, using the specified colour to create the mask bitmap | |
91 | // Note that wxImageList creates new bitmaps, so you may delete | |
92 | // 'bitmap'. | |
93 | int wxImageList::Add(const wxBitmap& bitmap, const wxColour& maskColour) | |
94 | { | |
fb9010ed DW |
95 | HBITMAP hBitmap1 = (HBITMAP) bitmap.GetHBITMAP(); |
96 | //TODO: | |
97 | // COLORREF colorRef = PALETTERGB(maskColour.Red(), maskColour.Green(), maskColour.Blue()); | |
98 | // return ImageList_AddMasked((HIMAGELIST) GetHIMAGELIST(), hBitmap1, colorRef); | |
99 | return 0; | |
0e320a79 DW |
100 | } |
101 | ||
102 | // Adds a bitmap and mask from an icon. | |
103 | int wxImageList::Add(const wxIcon& icon) | |
104 | { | |
fb9010ed DW |
105 | HICON hIcon = (HICON) icon.GetHICON(); |
106 | // TODO: return ImageList_AddIcon((HIMAGELIST) GetHIMAGELIST(), hIcon); | |
107 | return 0; | |
0e320a79 DW |
108 | } |
109 | ||
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) | |
114 | { | |
fb9010ed DW |
115 | HBITMAP hBitmap1 = (HBITMAP) bitmap.GetHBITMAP(); |
116 | HBITMAP hBitmap2 = 0; | |
117 | if ( mask.Ok() ) | |
118 | hBitmap2 = (HBITMAP) mask.GetHBITMAP(); | |
119 | // TODO: return (ImageList_Replace((HIMAGELIST) GetHIMAGELIST(), index, hBitmap1, hBitmap2) != 0); | |
120 | return TRUE; | |
0e320a79 DW |
121 | } |
122 | ||
123 | // Replaces a bitmap and mask from an icon. | |
124 | bool wxImageList::Replace(int index, const wxIcon& icon) | |
125 | { | |
fb9010ed DW |
126 | HICON hIcon = (HICON) icon.GetHICON(); |
127 | // TODO: return (ImageList_ReplaceIcon((HIMAGELIST) GetHIMAGELIST(), index, hIcon) != 0); | |
128 | return FALSE; | |
0e320a79 DW |
129 | } |
130 | ||
131 | // Removes the image at the given index. | |
132 | bool wxImageList::Remove(int index) | |
133 | { | |
fb9010ed DW |
134 | // TODO return (ImageList_Remove((HIMAGELIST) GetHIMAGELIST(), index) != 0); |
135 | ||
0e320a79 DW |
136 | return FALSE; |
137 | } | |
138 | ||
fb9010ed | 139 | bool wxImageList::RemoveAll(void) |
0e320a79 | 140 | { |
fb9010ed DW |
141 | // TODO: Is this correct? |
142 | while ( GetImageCount() > 0 ) | |
143 | { | |
144 | Remove(0); | |
145 | } | |
146 | return TRUE; | |
0e320a79 DW |
147 | } |
148 | ||
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) | |
155 | { | |
fb9010ed DW |
156 | HDC hDC = (HDC) dc.GetHDC(); |
157 | if ( !hDC ) | |
0e320a79 | 158 | return FALSE; |
fb9010ed DW |
159 | |
160 | if ( solidBackground ) | |
161 | { | |
162 | wxBrush *brush = & dc.GetBackground(); | |
163 | if ( brush && brush->Ok()) | |
164 | { | |
165 | wxColour col(brush->GetColour()); | |
166 | // ImageList_SetBkColor((HIMAGELIST) GetHIMAGELIST(), | |
167 | // PALETTERGB(col.Red(), col.Green(), col.Blue())); | |
168 | } | |
169 | // else | |
170 | // ImageList_SetBkColor((HIMAGELIST) GetHIMAGELIST(), | |
171 | // CLR_NONE); | |
172 | } | |
173 | // else | |
174 | // ImageList_SetBkColor((HIMAGELIST) GetHIMAGELIST(), | |
175 | // CLR_NONE); | |
176 | ||
177 | UINT style = 0; | |
178 | /* | |
179 | if ( flags & wxIMAGELIST_DRAW_NORMAL ) | |
180 | style |= ILD_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 ) | |
186 | style |= ILD_FOCUS; | |
187 | return (ImageList_Draw((HIMAGELIST) GetHIMAGELIST(), index, hDC, | |
188 | x, y, style) != 0); | |
189 | */ | |
190 | return TRUE; | |
0e320a79 DW |
191 | } |
192 |