]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/icon.h
no message
[wxWidgets.git] / include / wx / msw / icon.h
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$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_ICON_H_
13 #define _WX_ICON_H_
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
47 wxIcon(const char bits[], int width, int height);
48 wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE,
49 int desiredWidth = -1, int desiredHeight = -1);
50 ~wxIcon(void);
51
52 bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE,
53 int desiredWidth = -1, int desiredHeight = -1);
54
55 inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; }
56 inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; }
57 inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; }
58
59 void SetHICON(WXHICON ico);
60 inline WXHICON GetHICON(void) const { return (M_ICONDATA ? M_ICONDATA->m_hIcon : 0); }
61
62 virtual bool Ok(void) const { return (m_refData != NULL && M_ICONDATA->m_hIcon) ; }
63
64 bool FreeResource(bool force = FALSE);
65 };
66
67 // TODO: Put these in separate, private header
68
69 class WXDLLEXPORT wxICOFileHandler: public wxBitmapHandler
70 {
71 DECLARE_DYNAMIC_CLASS(wxICOFileHandler)
72 public:
73 inline wxICOFileHandler(void)
74 {
75 m_name = "ICO icon file";
76 m_extension = "ico";
77 m_type = wxBITMAP_TYPE_ICO;
78 };
79
80 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
81 int desiredWidth = -1, int desiredHeight = -1);
82 };
83
84 class WXDLLEXPORT wxICOResourceHandler: public wxBitmapHandler
85 {
86 DECLARE_DYNAMIC_CLASS(wxICOResourceHandler)
87 public:
88 inline wxICOResourceHandler(void)
89 {
90 m_name = "ICO resource";
91 m_extension = "ico";
92 m_type = wxBITMAP_TYPE_ICO_RESOURCE;
93 };
94
95 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
96 int desiredWidth = -1, int desiredHeight = -1);
97
98 };
99
100 #endif
101 // _WX_ICON_H_