]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/generic/imaglist.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
6 | // Id: | |
7 | // Copyright: (c) 1998 Robert Roebling and Julian Smart | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef __IMAGELISTH_G__ | |
12 | #define __IMAGELISTH_G__ | |
13 | ||
14 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
15 | #pragma interface "imaglist.h" | |
16 | #endif | |
17 | ||
18 | #include "wx/defs.h" | |
19 | #include "wx/list.h" | |
20 | ||
21 | class WXDLLEXPORT wxDC; | |
22 | class WXDLLEXPORT wxBitmap; | |
23 | class WXDLLEXPORT wxColour; | |
24 | ||
25 | /* | |
26 | * wxImageList is used for wxListCtrl, wxTreeCtrl. These controls refer to | |
27 | * images for their items by an index into an image list. | |
28 | * A wxImageList is capable of creating images with optional masks from | |
29 | * a variety of sources - a single bitmap plus a colour to indicate the mask, | |
30 | * two bitmaps, or an icon. | |
31 | * | |
32 | * Image lists can also create and draw images used for drag and drop functionality. | |
33 | * This is not yet implemented in wxImageList. We need to discuss a generic API | |
34 | * for doing drag and drop and see whether it ties in with the Win95 view of it. | |
35 | * See below for candidate functions and an explanation of how they might be | |
36 | * used. | |
37 | */ | |
38 | ||
39 | #if !defined(wxIMAGELIST_DRAW_NORMAL) | |
40 | ||
41 | // Flags for Draw | |
42 | #define wxIMAGELIST_DRAW_NORMAL 0x0001 | |
43 | #define wxIMAGELIST_DRAW_TRANSPARENT 0x0002 | |
44 | #define wxIMAGELIST_DRAW_SELECTED 0x0004 | |
45 | #define wxIMAGELIST_DRAW_FOCUSED 0x0008 | |
46 | ||
47 | // Flag values for Set/GetImageList | |
48 | enum { | |
49 | wxIMAGE_LIST_NORMAL, // Normal icons | |
50 | wxIMAGE_LIST_SMALL, // Small icons | |
51 | wxIMAGE_LIST_STATE // State icons: unimplemented (see WIN32 documentation) | |
52 | }; | |
53 | ||
54 | #endif | |
55 | ||
56 | class WXDLLEXPORT wxGenericImageList: public wxObject | |
57 | { | |
58 | public: | |
59 | wxGenericImageList() { m_width = m_height = 0; } | |
60 | wxGenericImageList( int width, int height, bool mask = true, int initialCount = 1 ); | |
61 | ~wxGenericImageList(); | |
62 | bool Create( int width, int height, bool mask = true, int initialCount = 1 ); | |
63 | bool Create(); | |
64 | ||
65 | virtual int GetImageCount() const; | |
66 | virtual bool GetSize( int index, int &width, int &height ) const; | |
67 | ||
68 | int Add( const wxBitmap& bitmap ); | |
69 | int Add( const wxBitmap& bitmap, const wxBitmap& mask ); | |
70 | int Add( const wxBitmap& bitmap, const wxColour& maskColour ); | |
71 | const wxBitmap *GetBitmap(int index) const; | |
72 | bool Replace( int index, const wxBitmap &bitmap ); | |
73 | bool Remove( int index ); | |
74 | bool RemoveAll(); | |
75 | ||
76 | virtual bool Draw(int index, wxDC& dc, int x, int y, | |
77 | int flags = wxIMAGELIST_DRAW_NORMAL, | |
78 | bool solidBackground = false); | |
79 | ||
80 | private: | |
81 | wxList m_images; | |
82 | ||
83 | int m_width; | |
84 | int m_height; | |
85 | ||
86 | DECLARE_DYNAMIC_CLASS(wxGenericImageList) | |
87 | }; | |
88 | ||
89 | #if !defined(__WXMSW__) || defined(__WXUNIVERSAL__) | |
90 | /* | |
91 | * wxImageList has to be a real class or we have problems with | |
92 | * the run-time information. | |
93 | */ | |
94 | ||
95 | class WXDLLEXPORT wxImageList: public wxGenericImageList | |
96 | { | |
97 | DECLARE_DYNAMIC_CLASS(wxImageList) | |
98 | ||
99 | public: | |
100 | wxImageList() {} | |
101 | ||
102 | wxImageList( int width, int height, bool mask = true, int initialCount = 1 ) | |
103 | : wxGenericImageList(width, height, mask, initialCount) | |
104 | { | |
105 | } | |
106 | }; | |
107 | #endif // !__WXMSW__ || __WXUNIVERSAL__ | |
108 | ||
109 | #endif // __IMAGELISTH_G__ | |
110 |