1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "icon.h"
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
23 #include "wx/msw/gdiimage.h"
25 // ---------------------------------------------------------------------------
27 // ---------------------------------------------------------------------------
29 // notice that although wxIconRefData inherits from wxBitmapRefData, it is not
30 // a valid wxBitmapRefData
31 class WXDLLEXPORT wxIconRefData
: public wxGDIImageRefData
35 virtual ~wxIconRefData() { Free(); }
40 // ---------------------------------------------------------------------------
42 // ---------------------------------------------------------------------------
44 class WXDLLEXPORT wxIcon
: public wxGDIImage
52 wxIcon(const wxIcon
& icon
) { Ref(icon
); }
55 wxIcon(const char bits
[], int width
, int height
);
57 #ifndef __DIGITALMARS__
58 wxIcon(const char **data
) { CreateIconFromXpm(data
); }
60 wxIcon(char **data
) { CreateIconFromXpm((const char **)data
); }
62 wxIcon(const wxString
& name
,
63 long type
= wxBITMAP_TYPE_ICO_RESOURCE
,
64 int desiredWidth
= -1, int desiredHeight
= -1);
68 virtual bool LoadFile(const wxString
& name
,
69 long type
= wxBITMAP_TYPE_ICO_RESOURCE
,
70 int desiredWidth
= -1, int desiredHeight
= -1);
72 wxIcon
& operator = (const wxIcon
& icon
)
73 { if ( *this != icon
) Ref(icon
); return *this; }
74 bool operator == (const wxIcon
& icon
) const
75 { return m_refData
== icon
.m_refData
; }
76 bool operator != (const wxIcon
& icon
) const
77 { return m_refData
!= icon
.m_refData
; }
79 // implementation only from now on
80 wxIconRefData
*GetIconData() const { return (wxIconRefData
*)m_refData
; }
82 void SetHICON(WXHICON icon
) { SetHandle((WXHANDLE
)icon
); }
83 WXHICON
GetHICON() const { return (WXHICON
)GetHandle(); }
85 // create from bitmap (which should have a mask unless it's monochrome):
86 // there shouldn't be any implicit bitmap -> icon conversion (i.e. no
87 // ctors, assignment operators...), but it's ok to have such function
88 void CopyFromBitmap(const wxBitmap
& bmp
);
91 virtual wxGDIImageRefData
*CreateData() const
93 return new wxIconRefData
;
96 // create from XPM data
97 void CreateIconFromXpm(const char **data
);
100 DECLARE_DYNAMIC_CLASS(wxIcon
)