]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/icon.h
fix memory leak in Freeze
[wxWidgets.git] / include / wx / os2 / icon.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: icon.h
3 // Purpose: wxIcon class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/09/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_ICON_H_
13 #define _WX_ICON_H_
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/bitmap.h"
20 #include "wx/os2/gdiimage.h"
21
22 #define wxIconRefDataBase wxGDIImageRefData
23 #define wxIconBase wxGDIImage
24
25 class WXDLLEXPORT wxIconRefData: public wxIconRefDataBase
26 {
27 public:
28 wxIconRefData() { };
29 virtual ~wxIconRefData() { Free(); }
30
31 virtual void Free();
32 }; // end of
33
34 // ---------------------------------------------------------------------------
35 // Icon
36 // ---------------------------------------------------------------------------
37
38 class WXDLLEXPORT wxIcon: public wxIconBase
39 {
40 public:
41 wxIcon();
42
43 wxIcon( const char bits[]
44 ,int nWidth
45 ,int nHeight
46 );
47 inline wxIcon(const char** ppData) { CreateIconFromXpm(ppData); }
48 inline wxIcon(char** ppData) { CreateIconFromXpm((const char**)ppData); }
49 wxIcon( const wxString& rName
50 ,long lFlags = wxBITMAP_TYPE_ICO_RESOURCE
51 ,int nDesiredWidth = -1
52 ,int nDesiredHeight = -1
53 );
54 wxIcon(const wxIconLocation& loc)
55 {
56 LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICO);
57 }
58
59 virtual ~wxIcon();
60
61 bool LoadFile( const wxString& rName
62 ,long lFlags = wxBITMAP_TYPE_ICO_RESOURCE
63 ,int nDesiredWidth = -1
64 ,int nDesiredHeight = -1
65 );
66
67 inline bool operator == (const wxIcon& rIcon) const
68 { return m_refData == rIcon.m_refData; }
69 inline bool operator != (const wxIcon& rIcon) const
70 { return m_refData != rIcon.m_refData; }
71
72 wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
73
74 inline void SetHICON(WXHICON hIcon) { SetHandle((WXHANDLE)hIcon); }
75 inline WXHICON GetHICON() const { return (WXHICON)GetHandle(); }
76 inline bool IsXpm(void) const { return m_bIsXpm; };
77 inline const wxBitmap& GetXpmSrc(void) const { return m_vXpmSrc; }
78
79 void CopyFromBitmap(const wxBitmap& rBmp);
80 protected:
81 virtual wxGDIImageRefData* CreateData() const
82 {
83 return new wxIconRefData;
84 }
85 void CreateIconFromXpm(const char **ppData);
86
87 private:
88 bool m_bIsXpm;
89 wxBitmap m_vXpmSrc;
90
91 DECLARE_DYNAMIC_CLASS(wxIcon)
92 };
93
94 #endif
95 // _WX_ICON_H_