2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: icon.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxIcon
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
In wxIcon context this value means: "use the screen depth".
|
|
|
|
*/
|
|
|
|
#define wxICON_SCREEN_DEPTH (-1)
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxIcon
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
An icon is a small rectangular bitmap usually used for denoting a minimized
|
|
|
|
application.
|
|
|
|
|
|
|
|
It differs from a wxBitmap in always having a mask associated with it for
|
|
|
|
transparent drawing. On some platforms, icons and bitmaps are implemented
|
|
|
|
identically, since there is no real distinction between a wxBitmap with a
|
|
|
|
mask and an icon; and there is no specific icon format on some platforms
|
|
|
|
(X-based applications usually standardize on XPMs for small bitmaps and icons).
|
|
|
|
However, some platforms (such as Windows) make the distinction, so a
|
|
|
|
separate class is provided.
|
|
|
|
|
|
|
|
@remarks
|
|
|
|
It is usually desirable to associate a pertinent icon with a frame.
|
|
|
|
Icons can also be used for other purposes, for example with wxTreeCtrl and wxListCtrl.
|
|
|
|
Icons have different formats on different platforms therefore separate icons
|
|
|
|
will usually be created for the different environments.
|
|
|
|
Platform-specific methods for creating a wxIcon structure are catered for,
|
|
|
|
and this is an occasion where conditional compilation will probably be required.
|
|
|
|
Note that a new icon must be created for every time the icon is to be used
|
|
|
|
for a new window. In Windows, the icon will not be reloaded if it has already
|
|
|
|
been used.
|
|
|
|
An icon allocated to a frame will be deleted when the frame is deleted.
|
|
|
|
For more information please see @ref overview_bitmap.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{gdi}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@stdobjects
|
2008-04-06 11:28:55 -04:00
|
|
|
::wxNullIcon
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
@see @ref overview_bitmap, @ref overview_bitmap_supportedformats,
|
|
|
|
wxDC::DrawIcon, wxCursor
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxIcon : public wxBitmap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-09-21 16:03:14 -04:00
|
|
|
Default ctor.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
Constructs an icon object with no data; an assignment or another member
|
|
|
|
function such as LoadFile() must be called subsequently.
|
|
|
|
*/
|
|
|
|
wxIcon();
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
/**
|
|
|
|
Copy ctor.
|
|
|
|
*/
|
|
|
|
wxIcon(const wxIcon& icon);
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
/*
|
|
|
|
Creates an icon from the given data, which can be of arbitrary type.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
wxIcon(void* data, int type, int width, int height, int depth = -1);
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
NOTE: this ctor is not implemented by all ports, is somewhat useless
|
|
|
|
without further description of the "data" supported formats and
|
|
|
|
uses 'int type' instead of wxBitmapType, so don't document it.
|
|
|
|
*/
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
/**
|
|
|
|
Creates an icon from an array of bits.
|
|
|
|
You should only use this function for monochrome bitmaps (depth 1) in
|
|
|
|
portable programs: in this case the bits parameter should contain an XBM image.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
For other bit depths, the behaviour is platform dependent: under Windows,
|
|
|
|
the data is passed without any changes to the underlying CreateBitmap() API.
|
|
|
|
Under other platforms, only monochrome bitmaps may be created using this
|
|
|
|
constructor and wxImage should be used for creating colour bitmaps from
|
|
|
|
static data.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
@param bits
|
|
|
|
Specifies an array of pixel values.
|
|
|
|
@param width
|
|
|
|
Specifies the width of the bitmap.
|
|
|
|
@param height
|
|
|
|
Specifies the height of the bitmap.
|
|
|
|
@param depth
|
|
|
|
Specifies the depth of the bitmap.
|
|
|
|
If this is omitted, then a value of 1 (monochrome bitmap) is used.
|
|
|
|
*/
|
|
|
|
wxIcon(const char bits[], int width, int height, int depth = 1);
|
2008-03-20 09:45:17 -04:00
|
|
|
|
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
/**
|
|
|
|
Creates a new icon. A depth of ::wxICON_SCREEN_DEPTH indicates the
|
|
|
|
depth of the current screen or visual.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
Some platforms only support 1 for monochrome and ::wxICON_SCREEN_DEPTH for
|
|
|
|
the current colour setting.
|
|
|
|
*/
|
|
|
|
wxIcon(int width, int height, int depth = wxICON_SCREEN_DEPTH);
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
/**
|
|
|
|
Creates a bitmap from XPM data.
|
|
|
|
To use this constructor, you must first include an XPM file.
|
|
|
|
For example, assuming that the file mybitmap.xpm contains an XPM array
|
|
|
|
of character pointers called @e mybitmap:
|
|
|
|
|
|
|
|
@code
|
|
|
|
#include "mybitmap.xpm"
|
|
|
|
...
|
|
|
|
wxIcon *icon = new wxIcon(mybitmap);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
A macro, wxICON, is available which creates an icon using an XPM on
|
|
|
|
the appropriate platform, or an icon resource on Windows.
|
|
|
|
|
|
|
|
@code
|
|
|
|
wxIcon icon(wxICON(mondrian));
|
|
|
|
|
|
|
|
// Equivalent to:
|
|
|
|
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
|
|
|
wxIcon icon(mondrian_xpm);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__WXMSW__)
|
|
|
|
wxIcon icon("mondrian");
|
|
|
|
#endif
|
|
|
|
@endcode
|
|
|
|
*/
|
|
|
|
wxIcon(const char* const* bits);
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
/**
|
|
|
|
Loads an icon from a file or resource.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
@param name
|
|
|
|
This can refer to a resource name or a filename under MS Windows and X.
|
|
|
|
Its meaning is determined by the @a type parameter.
|
|
|
|
@param type
|
|
|
|
May be one of the ::wxBitmapType values and indicates which type of
|
|
|
|
bitmap should be loaded. See the note in the class detailed description.
|
|
|
|
Note that the wxICON_DEFAULT_TYPE constant has different value under
|
|
|
|
different wxWidgets ports. See the icon.h header for the value it takes
|
|
|
|
for a specific port.
|
|
|
|
@param desiredWidth
|
|
|
|
Specifies the desired width of the icon. This parameter only has
|
|
|
|
an effect in Windows where icon resources can contain several icons
|
|
|
|
of different sizes.
|
|
|
|
@param desiredHeight
|
|
|
|
Specifies the desired height of the icon. This parameter only has
|
|
|
|
an effect in Windows where icon resources can contain several icons
|
|
|
|
of different sizes.
|
|
|
|
|
|
|
|
@see LoadFile()
|
|
|
|
*/
|
|
|
|
wxIcon(const wxString& name, wxBitmapType type = wxICON_DEFAULT_TYPE,
|
|
|
|
int desiredWidth = -1, int desiredHeight = -1);
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
/**
|
|
|
|
Loads an icon from the specified location.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxIcon(const wxIconLocation& loc);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
2008-09-21 16:03:14 -04:00
|
|
|
See @ref overview_refcount_destruct for more info.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
If the application omits to delete the icon explicitly, the icon will be
|
|
|
|
destroyed automatically by wxWidgets when the application exits.
|
2008-09-21 16:03:14 -04:00
|
|
|
|
|
|
|
@warning
|
2008-03-08 08:52:38 -05:00
|
|
|
Do not delete an icon that is selected into a memory device context.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxIcon();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-21 16:03:14 -04:00
|
|
|
Copies @a bmp bitmap to this icon.
|
|
|
|
Under MS Windows the bitmap must have mask colour set.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-09-21 16:03:14 -04:00
|
|
|
@see LoadFile()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void CopyFromBitmap(const wxBitmap& bmp);
|
|
|
|
|
|
|
|
/**
|
2008-09-21 16:03:14 -04:00
|
|
|
Gets the colour depth of the icon.
|
|
|
|
A value of 1 indicates a monochrome icon.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetDepth() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the height of the icon in pixels.
|
2008-09-21 16:03:14 -04:00
|
|
|
|
|
|
|
@see GetWidth()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetHeight() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the width of the icon in pixels.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetHeight()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetWidth() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if icon data is present.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Loads an icon from a file or resource.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Either a filename or a Windows resource name.
|
2008-09-21 16:03:14 -04:00
|
|
|
The meaning of name is determined by the @a type parameter.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2008-09-21 16:03:14 -04:00
|
|
|
One of the ::wxBitmapType values; see the note in the class
|
|
|
|
detailed description.
|
|
|
|
Note that the wxICON_DEFAULT_TYPE constant has different value under
|
|
|
|
different wxWidgets ports. See the icon.h header for the value it takes
|
|
|
|
for a specific port.
|
|
|
|
@param desiredWidth
|
|
|
|
Specifies the desired width of the icon. This parameter only has
|
|
|
|
an effect in Windows where icon resources can contain several icons
|
|
|
|
of different sizes.
|
|
|
|
@param desiredHeight
|
|
|
|
Specifies the desired height of the icon. This parameter only has
|
|
|
|
an effect in Windows where icon resources can contain several icons
|
|
|
|
of different sizes.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the operation succeeded, @false otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-21 16:03:14 -04:00
|
|
|
bool LoadFile(const wxString& name, wxBitmapType type = wxICON_DEFAULT_TYPE,
|
|
|
|
int desiredWidth = -1, int desiredHeight = -1);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the depth member (does not affect the icon data).
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param depth
|
2008-03-09 08:33:59 -04:00
|
|
|
Icon depth.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetDepth(int depth);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the height member (does not affect the icon data).
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param height
|
2008-03-09 08:33:59 -04:00
|
|
|
Icon height in pixels.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetHeight(int height);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the width member (does not affect the icon data).
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param width
|
2008-03-09 08:33:59 -04:00
|
|
|
Icon width in pixels.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetWidth(int width);
|
|
|
|
|
|
|
|
/**
|
2008-09-21 16:03:14 -04:00
|
|
|
Assignment operator, using @ref overview_refcount.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param icon
|
2008-03-09 08:33:59 -04:00
|
|
|
Icon to assign.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxIcon operator =(const wxIcon& icon);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
|
|
|
/**
|
2008-04-06 11:28:55 -04:00
|
|
|
An empty wxIcon.
|
2008-03-10 11:24:38 -04:00
|
|
|
*/
|
|
|
|
wxIcon wxNullIcon;
|
|
|
|
|
|
|
|
|