1998-05-20 10:12:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-07-15 15:51:35 -04:00
|
|
|
// Name: wx/msw/imaglist.h
|
1998-05-20 10:12:05 -04:00
|
|
|
// Purpose: wxImageList class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
1998-08-07 19:52:45 -04:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-08-27 14:59:37 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:12:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 19:52:45 -04:00
|
|
|
#ifndef _WX_IMAGLIST_H_
|
|
|
|
#define _WX_IMAGLIST_H_
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
#include "wx/bitmap.h"
|
|
|
|
|
|
|
|
// Eventually we'll make this a reference-counted wxGDIObject. For
|
|
|
|
// now, the app must take care of ownership issues. That is, the
|
|
|
|
// image lists must be explicitly deleted after the control(s) that uses them
|
|
|
|
// is (are) deleted, or when the app exits.
|
2000-07-15 15:51:35 -04:00
|
|
|
class WXDLLEXPORT wxImageList : public wxObject
|
1998-05-20 10:12:05 -04:00
|
|
|
{
|
2000-07-15 15:51:35 -04:00
|
|
|
public:
|
1998-05-20 10:12:05 -04:00
|
|
|
/*
|
|
|
|
* Public interface
|
|
|
|
*/
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
wxImageList();
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
// Creates an image list.
|
|
|
|
// Specify the width and height of the images in the list,
|
|
|
|
// whether there are masks associated with them (e.g. if creating images
|
|
|
|
// from icons), and the initial size of the list.
|
2004-08-27 14:59:37 -04:00
|
|
|
wxImageList(int width, int height, bool mask = true, int initialCount = 1)
|
1998-05-20 10:12:05 -04:00
|
|
|
{
|
|
|
|
Create(width, height, mask, initialCount);
|
|
|
|
}
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxImageList();
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
// Attributes
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Returns the number of images in the image list.
|
2000-07-15 15:51:35 -04:00
|
|
|
int GetImageCount() const;
|
|
|
|
|
|
|
|
// Returns the size (same for all images) of the images in the list
|
|
|
|
bool GetSize(int index, int &width, int &height) const;
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
// Operations
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Creates an image list
|
|
|
|
// width, height specify the size of the images in the list (all the same).
|
|
|
|
// mask specifies whether the images have masks or not.
|
|
|
|
// initialNumber is the initial number of images to reserve.
|
2004-08-27 14:59:37 -04:00
|
|
|
bool Create(int width, int height, bool mask = true, int initialNumber = 1);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
// Adds a bitmap, and optionally a mask bitmap.
|
|
|
|
// Note that wxImageList creates *new* bitmaps, so you may delete
|
|
|
|
// 'bitmap' and 'mask' after calling Add.
|
|
|
|
int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
|
|
|
|
|
|
|
|
// Adds a bitmap, using the specified colour to create the mask bitmap
|
|
|
|
// Note that wxImageList creates *new* bitmaps, so you may delete
|
|
|
|
// 'bitmap' after calling Add.
|
|
|
|
int Add(const wxBitmap& bitmap, const wxColour& maskColour);
|
|
|
|
|
|
|
|
// Adds a bitmap and mask from an icon.
|
|
|
|
int Add(const wxIcon& icon);
|
|
|
|
|
|
|
|
// Replaces a bitmap, optionally passing a mask bitmap.
|
|
|
|
// Note that wxImageList creates new bitmaps, so you may delete
|
|
|
|
// 'bitmap' and 'mask' after calling Replace.
|
1998-07-04 11:17:59 -04:00
|
|
|
bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
/* Not supported by Win95
|
|
|
|
// Replacing a bitmap, using the specified colour to create the mask bitmap
|
|
|
|
// Note that wxImageList creates new bitmaps, so you may delete
|
|
|
|
// 'bitmap'.
|
1998-07-04 11:17:59 -04:00
|
|
|
bool Replace(int index, const wxBitmap& bitmap, const wxColour& maskColour);
|
1998-05-20 10:12:05 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
// Replaces a bitmap and mask from an icon.
|
|
|
|
// You can delete 'icon' after calling Replace.
|
1998-07-04 11:17:59 -04:00
|
|
|
bool Replace(int index, const wxIcon& icon);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
// Removes the image at the given index.
|
1998-07-04 11:17:59 -04:00
|
|
|
bool Remove(int index);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
// Remove all images
|
2000-07-15 15:51:35 -04:00
|
|
|
bool RemoveAll();
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
// Draws the given image on a dc at the specified position.
|
2004-08-27 14:59:37 -04:00
|
|
|
// If 'solidBackground' is true, Draw sets the image list background
|
1998-05-20 10:12:05 -04:00
|
|
|
// colour to the background colour of the wxDC, to speed up
|
|
|
|
// drawing by eliminating masked drawing where possible.
|
1998-07-04 11:17:59 -04:00
|
|
|
bool Draw(int index, wxDC& dc, int x, int y,
|
2000-07-15 15:51:35 -04:00
|
|
|
int flags = wxIMAGELIST_DRAW_NORMAL,
|
2004-08-27 14:59:37 -04:00
|
|
|
bool solidBackground = false);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2005-02-27 05:36:58 -05:00
|
|
|
// Get a bitmap
|
|
|
|
wxBitmap GetBitmap(int index) const;
|
|
|
|
|
|
|
|
// Get an icon
|
|
|
|
wxIcon GetIcon(int index) const;
|
|
|
|
|
1998-05-20 10:12:05 -04:00
|
|
|
// TODO: miscellaneous functionality
|
|
|
|
/*
|
1998-07-04 11:17:59 -04:00
|
|
|
wxIcon *MakeIcon(int index);
|
|
|
|
bool SetOverlayImage(int index, int overlayMask);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TODO: Drag-and-drop related functionality.
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// Creates a new drag image by combining the given image (typically a mouse cursor image)
|
|
|
|
// with the current drag image.
|
1998-07-04 11:17:59 -04:00
|
|
|
bool SetDragCursorImage(int index, const wxPoint& hotSpot);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
// If successful, returns a pointer to the temporary image list that is used for dragging;
|
|
|
|
// otherwise, NULL.
|
|
|
|
// dragPos: receives the current drag position.
|
|
|
|
// hotSpot: receives the offset of the drag image relative to the drag position.
|
|
|
|
static wxImageList *GetDragImageList(wxPoint& dragPos, wxPoint& hotSpot);
|
|
|
|
|
|
|
|
// Call this function to begin dragging an image. This function creates a temporary image list
|
|
|
|
// that is used for dragging. The image combines the specified image and its mask with the
|
|
|
|
// current cursor. In response to subsequent mouse move messages, you can move the drag image
|
|
|
|
// by using the DragMove member function. To end the drag operation, you can use the EndDrag
|
|
|
|
// member function.
|
1998-07-04 11:17:59 -04:00
|
|
|
bool BeginDrag(int index, const wxPoint& hotSpot);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
// Ends a drag operation.
|
2000-07-15 15:51:35 -04:00
|
|
|
bool EndDrag();
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
// Call this function to move the image that is being dragged during a drag-and-drop operation.
|
|
|
|
// This function is typically called in response to a mouse move message. To begin a drag
|
|
|
|
// operation, use the BeginDrag member function.
|
|
|
|
static bool DragMove(const wxPoint& point);
|
|
|
|
|
|
|
|
// During a drag operation, locks updates to the window specified by lockWindow and displays
|
|
|
|
// the drag image at the position specified by point.
|
|
|
|
// The coordinates are relative to the window's upper left corner, so you must compensate
|
|
|
|
// for the widths of window elements, such as the border, title bar, and menu bar, when
|
|
|
|
// specifying the coordinates.
|
|
|
|
// If lockWindow is NULL, this function draws the image in the display context associated
|
|
|
|
// with the desktop window, and coordinates are relative to the upper left corner of the screen.
|
|
|
|
// This function locks all other updates to the given window during the drag operation.
|
|
|
|
// If you need to do any drawing during a drag operation, such as highlighting the target
|
|
|
|
// of a drag-and-drop operation, you can temporarily hide the dragged image by using the
|
|
|
|
// wxImageList::DragLeave function.
|
|
|
|
|
|
|
|
// lockWindow: pointer to the window that owns the drag image.
|
|
|
|
// point: position at which to display the drag image. Coordinates are relative to the
|
|
|
|
// upper left corner of the window (not the client area).
|
|
|
|
|
|
|
|
static bool DragEnter( wxWindow *lockWindow, const wxPoint& point );
|
|
|
|
|
|
|
|
// Unlocks the window specified by pWndLock and hides the drag image, allowing the
|
|
|
|
// window to be updated.
|
|
|
|
static bool DragLeave( wxWindow *lockWindow );
|
|
|
|
|
|
|
|
/* Here's roughly how you'd use these functions if implemented in this Win95-like way:
|
|
|
|
|
|
|
|
1) Starting to drag:
|
|
|
|
|
2004-08-27 14:59:37 -04:00
|
|
|
wxImageList *dragImageList = new wxImageList(16, 16, true);
|
1998-05-20 10:12:05 -04:00
|
|
|
dragImageList->Add(myDragImage); // Provide an image to combine with the current cursor
|
|
|
|
dragImageList->BeginDrag(0, wxPoint(0, 0));
|
2004-08-27 14:59:37 -04:00
|
|
|
wxShowCursor(false); // wxShowCursor not yet implemented in wxWin
|
1998-05-20 10:12:05 -04:00
|
|
|
myWindow->CaptureMouse();
|
|
|
|
|
|
|
|
2) Dragging:
|
|
|
|
|
|
|
|
// Called within mouse move event. Could also use dragImageList instead of assuming
|
|
|
|
// these are static functions.
|
|
|
|
// These two functions could possibly be combined into one, since DragEnter is
|
|
|
|
// a bit obscure.
|
|
|
|
wxImageList::DragMove(wxPoint(x, y)); // x, y are current cursor position
|
|
|
|
wxImageList::DragEnter(NULL, wxPoint(x, y)); // NULL assumes dragging across whole screen
|
|
|
|
|
|
|
|
3) Finishing dragging:
|
|
|
|
|
|
|
|
dragImageList->EndDrag();
|
|
|
|
myWindow->ReleaseMouse();
|
2004-08-27 14:59:37 -04:00
|
|
|
wxShowCursor(true);
|
1998-05-20 10:12:05 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Implementation
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Returns the native image list handle
|
2000-07-15 15:51:35 -04:00
|
|
|
WXHIMAGELIST GetHIMAGELIST() const { return m_hImageList; }
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
WXHIMAGELIST m_hImageList;
|
2000-07-15 15:51:35 -04:00
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxImageList)
|
1998-05-20 10:12:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-08-07 19:52:45 -04:00
|
|
|
// _WX_IMAGLIST_H_
|