]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/imaglist.h
mention which files should be changed when adding a new library in a few places where...
[wxWidgets.git] / include / wx / msw / imaglist.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
f6bcfd97 2// Name: wx/msw/imaglist.h
2bda0e17
KB
3// Purpose: wxImageList class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
59af881e 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_IMAGLIST_H_
13#define _WX_IMAGLIST_H_
2bda0e17 14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
2bda0e17
KB
16#pragma interface "imaglist.h"
17#endif
18
19#include "wx/bitmap.h"
20
21/*
22 * wxImageList is used for wxListCtrl, wxTreeCtrl. These controls refer to
23 * images for their items by an index into an image list.
24 * A wxImageList is capable of creating images with optional masks from
25 * a variety of sources - a single bitmap plus a colour to indicate the mask,
26 * two bitmaps, or an icon.
27 *
28 * Image lists can also create and draw images used for drag and drop functionality.
29 * This is not yet implemented in wxImageList. We need to discuss a generic API
30 * for doing drag and drop and see whether it ties in with the Win95 view of it.
31 * See below for candidate functions and an explanation of how they might be
32 * used.
33 */
34
35// Flags for Draw
36#define wxIMAGELIST_DRAW_NORMAL 0x0001
37#define wxIMAGELIST_DRAW_TRANSPARENT 0x0002
38#define wxIMAGELIST_DRAW_SELECTED 0x0004
39#define wxIMAGELIST_DRAW_FOCUSED 0x0008
40
41// Flag values for Set/GetImageList
42enum {
43 wxIMAGE_LIST_NORMAL, // Normal icons
44 wxIMAGE_LIST_SMALL, // Small icons
45 wxIMAGE_LIST_STATE // State icons: unimplemented (see WIN32 documentation)
46};
47
48// Eventually we'll make this a reference-counted wxGDIObject. For
49// now, the app must take care of ownership issues. That is, the
50// image lists must be explicitly deleted after the control(s) that uses them
51// is (are) deleted, or when the app exits.
f6bcfd97 52class WXDLLEXPORT wxImageList : public wxObject
2bda0e17 53{
f6bcfd97 54public:
2bda0e17
KB
55 /*
56 * Public interface
57 */
58
f6bcfd97 59 wxImageList();
2bda0e17
KB
60
61 // Creates an image list.
62 // Specify the width and height of the images in the list,
63 // whether there are masks associated with them (e.g. if creating images
64 // from icons), and the initial size of the list.
59af881e 65 wxImageList(int width, int height, bool mask = true, int initialCount = 1)
2bda0e17
KB
66 {
67 Create(width, height, mask, initialCount);
68 }
f6bcfd97 69 ~wxImageList();
2bda0e17
KB
70
71
72 // Attributes
73 ////////////////////////////////////////////////////////////////////////////
74
75 // Returns the number of images in the image list.
f6bcfd97
BP
76 int GetImageCount() const;
77
78 // Returns the size (same for all images) of the images in the list
79 bool GetSize(int index, int &width, int &height) const;
2bda0e17
KB
80
81 // Operations
82 ////////////////////////////////////////////////////////////////////////////
83
84 // Creates an image list
85 // width, height specify the size of the images in the list (all the same).
86 // mask specifies whether the images have masks or not.
87 // initialNumber is the initial number of images to reserve.
59af881e 88 bool Create(int width, int height, bool mask = true, int initialNumber = 1);
2bda0e17
KB
89
90 // Adds a bitmap, and optionally a mask bitmap.
91 // Note that wxImageList creates *new* bitmaps, so you may delete
92 // 'bitmap' and 'mask' after calling Add.
93 int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
94
95 // Adds a bitmap, using the specified colour to create the mask bitmap
96 // Note that wxImageList creates *new* bitmaps, so you may delete
97 // 'bitmap' after calling Add.
98 int Add(const wxBitmap& bitmap, const wxColour& maskColour);
99
100 // Adds a bitmap and mask from an icon.
101 int Add(const wxIcon& icon);
102
103 // Replaces a bitmap, optionally passing a mask bitmap.
104 // Note that wxImageList creates new bitmaps, so you may delete
105 // 'bitmap' and 'mask' after calling Replace.
debe6624 106 bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
2bda0e17
KB
107
108/* Not supported by Win95
109 // Replacing a bitmap, using the specified colour to create the mask bitmap
110 // Note that wxImageList creates new bitmaps, so you may delete
111 // 'bitmap'.
debe6624 112 bool Replace(int index, const wxBitmap& bitmap, const wxColour& maskColour);
2bda0e17
KB
113*/
114
115 // Replaces a bitmap and mask from an icon.
116 // You can delete 'icon' after calling Replace.
debe6624 117 bool Replace(int index, const wxIcon& icon);
2bda0e17
KB
118
119 // Removes the image at the given index.
debe6624 120 bool Remove(int index);
2bda0e17
KB
121
122 // Remove all images
f6bcfd97 123 bool RemoveAll();
2bda0e17
KB
124
125 // Draws the given image on a dc at the specified position.
59af881e 126 // If 'solidBackground' is true, Draw sets the image list background
2bda0e17
KB
127 // colour to the background colour of the wxDC, to speed up
128 // drawing by eliminating masked drawing where possible.
debe6624 129 bool Draw(int index, wxDC& dc, int x, int y,
f6bcfd97 130 int flags = wxIMAGELIST_DRAW_NORMAL,
59af881e 131 bool solidBackground = false);
2bda0e17 132
49bf4e3e
JS
133 // Get a bitmap
134 wxBitmap GetBitmap(int index) const;
135
136 // Get an icon
137 wxIcon GetIcon(int index) const;
138
2bda0e17
KB
139 // TODO: miscellaneous functionality
140/*
debe6624
JS
141 wxIcon *MakeIcon(int index);
142 bool SetOverlayImage(int index, int overlayMask);
2bda0e17
KB
143
144*/
145
146 // TODO: Drag-and-drop related functionality.
147
148#if 0
149 // Creates a new drag image by combining the given image (typically a mouse cursor image)
150 // with the current drag image.
debe6624 151 bool SetDragCursorImage(int index, const wxPoint& hotSpot);
2bda0e17
KB
152
153 // If successful, returns a pointer to the temporary image list that is used for dragging;
154 // otherwise, NULL.
155 // dragPos: receives the current drag position.
156 // hotSpot: receives the offset of the drag image relative to the drag position.
157 static wxImageList *GetDragImageList(wxPoint& dragPos, wxPoint& hotSpot);
158
159 // Call this function to begin dragging an image. This function creates a temporary image list
160 // that is used for dragging. The image combines the specified image and its mask with the
161 // current cursor. In response to subsequent mouse move messages, you can move the drag image
162 // by using the DragMove member function. To end the drag operation, you can use the EndDrag
163 // member function.
debe6624 164 bool BeginDrag(int index, const wxPoint& hotSpot);
2bda0e17
KB
165
166 // Ends a drag operation.
f6bcfd97 167 bool EndDrag();
2bda0e17
KB
168
169 // Call this function to move the image that is being dragged during a drag-and-drop operation.
170 // This function is typically called in response to a mouse move message. To begin a drag
171 // operation, use the BeginDrag member function.
172 static bool DragMove(const wxPoint& point);
173
174 // During a drag operation, locks updates to the window specified by lockWindow and displays
175 // the drag image at the position specified by point.
176 // The coordinates are relative to the window's upper left corner, so you must compensate
177 // for the widths of window elements, such as the border, title bar, and menu bar, when
178 // specifying the coordinates.
179 // If lockWindow is NULL, this function draws the image in the display context associated
180 // with the desktop window, and coordinates are relative to the upper left corner of the screen.
181 // This function locks all other updates to the given window during the drag operation.
182 // If you need to do any drawing during a drag operation, such as highlighting the target
183 // of a drag-and-drop operation, you can temporarily hide the dragged image by using the
184 // wxImageList::DragLeave function.
185
186 // lockWindow: pointer to the window that owns the drag image.
187 // point: position at which to display the drag image. Coordinates are relative to the
188 // upper left corner of the window (not the client area).
189
190 static bool DragEnter( wxWindow *lockWindow, const wxPoint& point );
191
192 // Unlocks the window specified by pWndLock and hides the drag image, allowing the
193 // window to be updated.
194 static bool DragLeave( wxWindow *lockWindow );
195
196 /* Here's roughly how you'd use these functions if implemented in this Win95-like way:
197
198 1) Starting to drag:
199
59af881e 200 wxImageList *dragImageList = new wxImageList(16, 16, true);
2bda0e17
KB
201 dragImageList->Add(myDragImage); // Provide an image to combine with the current cursor
202 dragImageList->BeginDrag(0, wxPoint(0, 0));
59af881e 203 wxShowCursor(false); // wxShowCursor not yet implemented in wxWin
2bda0e17
KB
204 myWindow->CaptureMouse();
205
206 2) Dragging:
207
208 // Called within mouse move event. Could also use dragImageList instead of assuming
209 // these are static functions.
210 // These two functions could possibly be combined into one, since DragEnter is
211 // a bit obscure.
212 wxImageList::DragMove(wxPoint(x, y)); // x, y are current cursor position
213 wxImageList::DragEnter(NULL, wxPoint(x, y)); // NULL assumes dragging across whole screen
214
215 3) Finishing dragging:
216
217 dragImageList->EndDrag();
218 myWindow->ReleaseMouse();
59af881e 219 wxShowCursor(true);
2bda0e17
KB
220*/
221
222#endif
223
224 // Implementation
225 ////////////////////////////////////////////////////////////////////////////
226
227 // Returns the native image list handle
f6bcfd97 228 WXHIMAGELIST GetHIMAGELIST() const { return m_hImageList; }
2bda0e17
KB
229
230protected:
231 WXHIMAGELIST m_hImageList;
f6bcfd97
BP
232
233 DECLARE_DYNAMIC_CLASS(wxImageList)
2bda0e17
KB
234};
235
236#endif
bbcdf8bc 237 // _WX_IMAGLIST_H_