]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: imaglist.h | |
3 | // Purpose: wxImageList class. Note: if your GUI doesn't have | |
4 | // an image list equivalent, you can use the generic class | |
5 | // in src/generic. | |
fb9010ed | 6 | // Author: David Webster |
0e320a79 | 7 | // Modified by: |
fb9010ed | 8 | // Created: 10/09/99 |
0e320a79 | 9 | // RCS-ID: $Id$ |
fb9010ed DW |
10 | // Copyright: (c) David Webster |
11 | // Licence: wxWindows licence | |
0e320a79 DW |
12 | ///////////////////////////////////////////////////////////////////////////// |
13 | ||
14 | #ifndef _WX_IMAGLIST_H_ | |
15 | #define _WX_IMAGLIST_H_ | |
16 | ||
0e320a79 DW |
17 | #include "wx/bitmap.h" |
18 | ||
19 | /* | |
20 | * wxImageList is used for wxListCtrl, wxTreeCtrl. These controls refer to | |
21 | * images for their items by an index into an image list. | |
22 | * A wxImageList is capable of creating images with optional masks from | |
23 | * a variety of sources - a single bitmap plus a colour to indicate the mask, | |
24 | * two bitmaps, or an icon. | |
25 | * | |
26 | */ | |
27 | ||
28 | // Flags for Draw | |
29 | #define wxIMAGELIST_DRAW_NORMAL 0x0001 | |
30 | #define wxIMAGELIST_DRAW_TRANSPARENT 0x0002 | |
31 | #define wxIMAGELIST_DRAW_SELECTED 0x0004 | |
32 | #define wxIMAGELIST_DRAW_FOCUSED 0x0008 | |
33 | ||
34 | // Flag values for Set/GetImageList | |
35 | enum { | |
36 | wxIMAGE_LIST_NORMAL, // Normal icons | |
37 | wxIMAGE_LIST_SMALL, // Small icons | |
38 | wxIMAGE_LIST_STATE // State icons: unimplemented (see WIN32 documentation) | |
39 | }; | |
40 | ||
41 | // Eventually we'll make this a reference-counted wxGDIObject. For | |
42 | // now, the app must take care of ownership issues. That is, the | |
43 | // image lists must be explicitly deleted after the control(s) that uses them | |
44 | // is (are) deleted, or when the app exits. | |
45 | class WXDLLEXPORT wxImageList: public wxObject | |
46 | { | |
47 | DECLARE_DYNAMIC_CLASS(wxImageList) | |
48 | public: | |
49 | /* | |
50 | * Public interface | |
51 | */ | |
52 | ||
53 | wxImageList(); | |
54 | ||
55 | // Creates an image list. | |
56 | // Specify the width and height of the images in the list, | |
57 | // whether there are masks associated with them (e.g. if creating images | |
58 | // from icons), and the initial size of the list. | |
59 | inline wxImageList(int width, int height, bool mask = TRUE, int initialCount = 1) | |
60 | { | |
61 | Create(width, height, mask, initialCount); | |
62 | } | |
63 | ~wxImageList(); | |
64 | ||
65 | ||
66 | // Attributes | |
67 | //////////////////////////////////////////////////////////////////////////// | |
68 | ||
69 | // Returns the number of images in the image list. | |
70 | int GetImageCount() const; | |
71 | ||
72 | // Operations | |
73 | //////////////////////////////////////////////////////////////////////////// | |
74 | ||
75 | // Creates an image list | |
76 | // width, height specify the size of the images in the list (all the same). | |
77 | // mask specifies whether the images have masks or not. | |
78 | // initialNumber is the initial number of images to reserve. | |
79 | bool Create(int width, int height, bool mask = TRUE, int initialNumber = 1); | |
80 | ||
81 | // Adds a bitmap, and optionally a mask bitmap. | |
82 | // Note that wxImageList creates *new* bitmaps, so you may delete | |
83 | // 'bitmap' and 'mask' after calling Add. | |
84 | int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap); | |
85 | ||
86 | // Adds a bitmap, using the specified colour to create the mask bitmap | |
87 | // Note that wxImageList creates *new* bitmaps, so you may delete | |
88 | // 'bitmap' after calling Add. | |
89 | int Add(const wxBitmap& bitmap, const wxColour& maskColour); | |
90 | ||
91 | // Adds a bitmap and mask from an icon. | |
92 | int Add(const wxIcon& icon); | |
93 | ||
94 | // Replaces a bitmap, optionally passing a mask bitmap. | |
95 | // Note that wxImageList creates new bitmaps, so you may delete | |
96 | // 'bitmap' and 'mask' after calling Replace. | |
97 | bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap); | |
98 | ||
0e320a79 DW |
99 | // Replaces a bitmap and mask from an icon. |
100 | // You can delete 'icon' after calling Replace. | |
101 | bool Replace(int index, const wxIcon& icon); | |
102 | ||
103 | // Removes the image at the given index. | |
104 | bool Remove(int index); | |
105 | ||
106 | // Remove all images | |
107 | bool RemoveAll(); | |
108 | ||
109 | // Draws the given image on a dc at the specified position. | |
110 | // If 'solidBackground' is TRUE, Draw sets the image list background | |
111 | // colour to the background colour of the wxDC, to speed up | |
112 | // drawing by eliminating masked drawing where possible. | |
113 | bool Draw(int index, wxDC& dc, int x, int y, | |
114 | int flags = wxIMAGELIST_DRAW_NORMAL, bool solidBackground = FALSE); | |
115 | ||
116 | /* TODO (optional?) | |
117 | wxIcon *MakeIcon(int index); | |
118 | */ | |
119 | ||
0e320a79 DW |
120 | // Implementation |
121 | //////////////////////////////////////////////////////////////////////////// | |
122 | ||
123 | // Returns the native image list handle | |
124 | inline WXHIMAGELIST GetHIMAGELIST() const { return m_hImageList; } | |
125 | ||
126 | protected: | |
127 | WXHIMAGELIST m_hImageList; | |
0e320a79 DW |
128 | }; |
129 | ||
130 | #endif | |
131 | // _WX_IMAGLIST_H_ |