]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: icon.h | |
3 | // Purpose: wxIcon class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc JS |
8 | // Copyright: (c) Julian Smart |
9 | // Licence: wxWindows licence | |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_ICON_H_ |
13 | #define _WX_ICON_H_ | |
2bda0e17 KB |
14 | |
15 | #ifdef __GNUG__ | |
16 | #pragma interface "icon.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/bitmap.h" | |
20 | ||
21 | class WXDLLEXPORT wxIconRefData: public wxBitmapRefData | |
22 | { | |
23 | friend class WXDLLEXPORT wxBitmap; | |
24 | friend class WXDLLEXPORT wxIcon; | |
25 | public: | |
26 | wxIconRefData(void); | |
27 | ~wxIconRefData(void); | |
28 | ||
29 | public: | |
30 | WXHICON m_hIcon; | |
31 | }; | |
32 | ||
33 | #define M_ICONDATA ((wxIconRefData *)m_refData) | |
34 | #define M_ICONHANDLERDATA ((wxIconRefData *)bitmap->GetRefData()) | |
35 | ||
36 | // Icon | |
37 | class WXDLLEXPORT wxIcon: public wxBitmap | |
38 | { | |
39 | DECLARE_DYNAMIC_CLASS(wxIcon) | |
40 | ||
41 | public: | |
42 | wxIcon(void); | |
43 | ||
44 | // Copy constructors | |
45 | inline wxIcon(const wxIcon& icon) { Ref(icon); } | |
46 | inline wxIcon(const wxIcon* icon) { /* UnRef(); */ if (icon) Ref(*icon); } | |
47 | ||
debe6624 JS |
48 | wxIcon(const char bits[], int width, int height); |
49 | wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE, | |
2bda0e17 KB |
50 | int desiredWidth = -1, int desiredHeight = -1); |
51 | ~wxIcon(void); | |
52 | ||
debe6624 | 53 | bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE, |
2bda0e17 KB |
54 | int desiredWidth = -1, int desiredHeight = -1); |
55 | ||
56 | inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; } | |
57 | inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; } | |
58 | inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; } | |
59 | ||
60 | void SetHICON(WXHICON ico); | |
61 | inline WXHICON GetHICON(void) const { return (M_ICONDATA ? M_ICONDATA->m_hIcon : 0); } | |
62 | ||
63 | virtual bool Ok(void) const { return (m_refData != NULL && M_ICONDATA->m_hIcon) ; } | |
64 | ||
65 | bool FreeResource(bool force = FALSE); | |
66 | }; | |
67 | ||
68 | // TODO: Put these in separate, private header | |
69 | ||
70 | class WXDLLEXPORT wxICOFileHandler: public wxBitmapHandler | |
71 | { | |
72 | DECLARE_DYNAMIC_CLASS(wxICOFileHandler) | |
73 | public: | |
74 | inline wxICOFileHandler(void) | |
75 | { | |
76 | m_name = "ICO icon file"; | |
77 | m_extension = "ico"; | |
78 | m_type = wxBITMAP_TYPE_ICO; | |
79 | }; | |
80 | ||
debe6624 | 81 | virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, |
2bda0e17 KB |
82 | int desiredWidth = -1, int desiredHeight = -1); |
83 | }; | |
84 | ||
85 | class WXDLLEXPORT wxICOResourceHandler: public wxBitmapHandler | |
86 | { | |
87 | DECLARE_DYNAMIC_CLASS(wxICOResourceHandler) | |
88 | public: | |
89 | inline wxICOResourceHandler(void) | |
90 | { | |
91 | m_name = "ICO resource"; | |
92 | m_extension = "ico"; | |
93 | m_type = wxBITMAP_TYPE_ICO_RESOURCE; | |
94 | }; | |
95 | ||
debe6624 | 96 | virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, |
2bda0e17 KB |
97 | int desiredWidth = -1, int desiredHeight = -1); |
98 | ||
99 | }; | |
100 | ||
101 | #endif | |
bbcdf8bc | 102 | // _WX_ICON_H_ |