1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // compatible (even if incorrect) behaviour by default: derive wxIcon from
21 #ifndef wxICON_IS_BITMAP
22 #define wxICON_IS_BITMAP 1
26 #include "wx/bitmap.h"
28 #define wxIconRefDataBase wxBitmapRefData
29 #define wxIconBase wxBitmap
31 #include "wx/os2/gdiimage.h"
33 #define wxIconRefDataBase wxGDIImageRefData
34 #define wxIconBase wxGDIImage
37 class WXDLLEXPORT wxIconRefData
: public wxIconRefDataBase
41 virtual ~wxIconRefData() { Free(); }
46 // ---------------------------------------------------------------------------
48 // ---------------------------------------------------------------------------
50 class WXDLLEXPORT wxIcon
: public wxIconBase
56 inline wxIcon(const wxIcon
& icon
) { Ref(icon
); }
58 wxIcon( const char bits
[]
62 inline wxIcon(const char** ppData
) { CreateIconFromXpm(ppData
); }
63 inline wxIcon(char** ppData
) { CreateIconFromXpm((const char**)ppData
); }
64 wxIcon( const wxString
& rName
65 ,long lFlags
= wxBITMAP_TYPE_ICO_RESOURCE
66 ,int nDesiredWidth
= -1
67 ,int nDesiredHeight
= -1
71 bool LoadFile( const wxString
& rName
72 ,long lFlags
= wxBITMAP_TYPE_ICO_RESOURCE
73 ,int nDesiredWidth
= -1
74 ,int nDesiredHeight
= -1
77 inline wxIcon
& operator = (const wxIcon
& rIcon
)
78 { if (*this != rIcon
) Ref(rIcon
); return *this; }
79 inline bool operator == (const wxIcon
& rIcon
)
80 { return m_refData
== rIcon
.m_refData
; }
81 inline bool operator != (const wxIcon
& rIcon
)
82 { return m_refData
!= rIcon
.m_refData
; }
84 wxIconRefData
*GetIconData() const { return (wxIconRefData
*)m_refData
; }
86 inline void SetHICON(WXHICON hIcon
) { SetHandle((WXHANDLE
)hIcon
); }
87 inline WXHICON
GetHICON() const { return (WXHICON
)GetHandle(); }
89 void CopyFromBitmap(const wxBitmap
& rBmp
);
91 virtual wxGDIImageRefData
* CreateData() const
93 return new wxIconRefData
;
95 void CreateIconFromXpm(const char **ppData
);
98 DECLARE_DYNAMIC_CLASS(wxIcon
)