we need our own imaglist implementation because in wxmac wxIcon does not inherit from wxBitmap anymore
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33143 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#if defined(__WIN32__) && !defined(__WXUNIVERSAL__)
|
#if defined(__WIN32__) && !defined(__WXUNIVERSAL__)
|
||||||
#include "wx/msw/imaglist.h"
|
#include "wx/msw/imaglist.h"
|
||||||
|
#elif defined(__WXMAC_CARBON__)
|
||||||
|
#include "wx/mac/imaglist.h"
|
||||||
#else
|
#else
|
||||||
#include "wx/generic/imaglist.h"
|
#include "wx/generic/imaglist.h"
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,13 +1,10 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: imaglist.h
|
// Name: imaglist.h
|
||||||
// Purpose: wxImageList class. Note: if your GUI doesn't have
|
// Purpose:
|
||||||
// an image list equivalent, you can use the generic class
|
// Author: Robert Roebling, Stefan Csomor
|
||||||
// in src/generic.
|
// Created: 01/02/97
|
||||||
// Author: Stefan Csomor
|
// Id:
|
||||||
// Modified by:
|
// Copyright: (c) 1998 Robert Roebling and Julian Smart
|
||||||
// Created: 1998-01-01
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) Stefan Csomor
|
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -18,7 +15,13 @@
|
|||||||
#pragma interface "imaglist.h"
|
#pragma interface "imaglist.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/bitmap.h"
|
#include "wx/defs.h"
|
||||||
|
#include "wx/list.h"
|
||||||
|
#include "wx/icon.h"
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxDC;
|
||||||
|
class WXDLLEXPORT wxBitmap;
|
||||||
|
class WXDLLEXPORT wxColour;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wxImageList is used for wxListCtrl, wxTreeCtrl. These controls refer to
|
* wxImageList is used for wxListCtrl, wxTreeCtrl. These controls refer to
|
||||||
@@ -27,8 +30,15 @@
|
|||||||
* a variety of sources - a single bitmap plus a colour to indicate the mask,
|
* a variety of sources - a single bitmap plus a colour to indicate the mask,
|
||||||
* two bitmaps, or an icon.
|
* two bitmaps, or an icon.
|
||||||
*
|
*
|
||||||
|
* Image lists can also create and draw images used for drag and drop functionality.
|
||||||
|
* This is not yet implemented in wxImageList. We need to discuss a generic API
|
||||||
|
* for doing drag and drop and see whether it ties in with the Win95 view of it.
|
||||||
|
* See below for candidate functions and an explanation of how they might be
|
||||||
|
* used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(wxIMAGELIST_DRAW_NORMAL)
|
||||||
|
|
||||||
// Flags for Draw
|
// Flags for Draw
|
||||||
#define wxIMAGELIST_DRAW_NORMAL 0x0001
|
#define wxIMAGELIST_DRAW_NORMAL 0x0001
|
||||||
#define wxIMAGELIST_DRAW_TRANSPARENT 0x0002
|
#define wxIMAGELIST_DRAW_TRANSPARENT 0x0002
|
||||||
@@ -42,106 +52,43 @@ enum {
|
|||||||
wxIMAGE_LIST_STATE // State icons: unimplemented (see WIN32 documentation)
|
wxIMAGE_LIST_STATE // State icons: unimplemented (see WIN32 documentation)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Eventually we'll make this a reference-counted wxGDIObject. For
|
#endif
|
||||||
// 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.
|
|
||||||
class WXDLLEXPORT wxImageList: public wxObject
|
class WXDLLEXPORT wxImageList: public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxImageList)
|
public:
|
||||||
public:
|
wxImageList() { m_width = m_height = 0; }
|
||||||
/*
|
wxImageList( int width, int height, bool mask = true, int initialCount = 1 );
|
||||||
* Public interface
|
~wxImageList();
|
||||||
*/
|
bool Create( int width, int height, bool mask = true, int initialCount = 1 );
|
||||||
|
bool Create();
|
||||||
wxImageList();
|
|
||||||
|
virtual int GetImageCount() const;
|
||||||
// Creates an image list.
|
virtual bool GetSize( int index, int &width, int &height ) const;
|
||||||
// Specify the width and height of the images in the list,
|
|
||||||
// whether there are masks associated with them (e.g. if creating images
|
int Add( const wxIcon& bitmap );
|
||||||
// from icons), and the initial size of the list.
|
int Add( const wxBitmap& bitmap );
|
||||||
inline wxImageList(int width, int height, bool mask = TRUE, int initialCount = 1)
|
int Add( const wxBitmap& bitmap, const wxBitmap& mask );
|
||||||
{
|
int Add( const wxBitmap& bitmap, const wxColour& maskColour );
|
||||||
Create(width, height, mask, initialCount);
|
wxBitmap GetBitmap(int index) const;
|
||||||
}
|
wxIcon GetIcon(int index) const;
|
||||||
~wxImageList();
|
bool Replace( int index, const wxIcon &bitmap );
|
||||||
|
bool Replace( int index, const wxBitmap &bitmap );
|
||||||
|
bool Remove( int index );
|
||||||
// Attributes
|
bool RemoveAll();
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
virtual bool Draw(int index, wxDC& dc, int x, int y,
|
||||||
// Returns the number of images in the image list.
|
int flags = wxIMAGELIST_DRAW_NORMAL,
|
||||||
int GetImageCount() const;
|
bool solidBackground = false);
|
||||||
|
|
||||||
bool GetSize(int index, int&width, int &height) const;
|
private:
|
||||||
|
wxList m_images;
|
||||||
// Operations
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
int m_width;
|
||||||
|
int m_height;
|
||||||
// Creates an image list
|
|
||||||
// width, height specify the size of the images in the list (all the same).
|
DECLARE_DYNAMIC_CLASS(wxImageList)
|
||||||
// mask specifies whether the images have masks or not.
|
|
||||||
// initialNumber is the initial number of images to reserve.
|
|
||||||
bool Create(int width, int height, bool mask = TRUE, int initialNumber = 1);
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
|
|
||||||
|
|
||||||
/* 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'.
|
|
||||||
bool Replace(int index, const wxBitmap& bitmap, const wxColour& maskColour);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Replaces a bitmap and mask from an icon.
|
|
||||||
// You can delete 'icon' after calling Replace.
|
|
||||||
bool Replace(int index, const wxIcon& icon);
|
|
||||||
|
|
||||||
// Removes the image at the given index.
|
|
||||||
bool Remove(int index);
|
|
||||||
|
|
||||||
// Remove all images
|
|
||||||
bool RemoveAll();
|
|
||||||
|
|
||||||
// Draws the given image on a dc at the specified position.
|
|
||||||
// If 'solidBackground' is TRUE, Draw sets the image list background
|
|
||||||
// colour to the background colour of the wxDC, to speed up
|
|
||||||
// drawing by eliminating masked drawing where possible.
|
|
||||||
bool Draw(int index, wxDC& dc, int x, int y,
|
|
||||||
int flags = wxIMAGELIST_DRAW_NORMAL, bool solidBackground = FALSE);
|
|
||||||
|
|
||||||
/* TODO (optional?)
|
|
||||||
wxIcon *MakeIcon(int index);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* TODO
|
|
||||||
// Implementation
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Returns the native image list handle
|
|
||||||
inline WXHIMAGELIST GetHIMAGELIST() const { return m_hImageList; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
WXHIMAGELIST m_hImageList;
|
|
||||||
*/
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _WX_IMAGLIST_H_
|
||||||
// _WX_IMAGLIST_H_
|
|
||||||
|
Reference in New Issue
Block a user