]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/icon.h
*** empty log message ***
[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 #include "wx/bitmap.h"
16
17 class WXDLLEXPORT wxIconRefData: public wxBitmapRefData
18 {
19 friend class WXDLLEXPORT wxBitmap;
20 friend class WXDLLEXPORT wxIcon;
21 public:
22 wxIconRefData();
23 ~wxIconRefData();
24
25 public:
26 WXHICON m_hIcon;
27 };
28
29 #define M_ICONDATA ((wxIconRefData *)m_refData)
30 #define M_ICONHANDLERDATA ((wxIconRefData *)bitmap->GetRefData())
31
32 // Icon
33 class WXDLLEXPORT wxIcon: public wxBitmap
34 {
35 DECLARE_DYNAMIC_CLASS(wxIcon)
36
37 public:
38 wxIcon();
39
40 // Copy constructors
41 inline wxIcon(const wxIcon& icon) { Ref(icon); }
42
43 wxIcon(const char bits[], int width, int height);
44 wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE,
45 int desiredWidth = -1, int desiredHeight = -1);
46 ~wxIcon();
47
48 bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE,
49 int desiredWidth = -1, int desiredHeight = -1);
50
51 inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; }
52 inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; }
53 inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; }
54
55 void SetHICON(WXHICON ico);
56 inline WXHICON GetHICON() const { return (M_ICONDATA ? M_ICONDATA->m_hIcon : 0); }
57
58 virtual bool Ok() const { return (m_refData != NULL) ; }
59 private:
60 // supress virtual function hiding warning
61 virtual bool LoadFile( const wxString& name
62 ,long type = wxBITMAP_TYPE_BMP_RESOURCE
63 )
64 { return(wxBitmap::LoadFile(name, type)); };
65 };
66
67 // Example handlers. TODO: write your own handlers for relevant types.
68
69 class WXDLLEXPORT wxICOFileHandler: public wxBitmapHandler
70 {
71 DECLARE_DYNAMIC_CLASS(wxICOFileHandler)
72 public:
73 inline wxICOFileHandler()
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()
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_
102