]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
6d167489 | 2 | // Name: wx/msw/icon.h |
2bda0e17 KB |
3 | // Purpose: wxIcon class |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
c793fa87 | 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__ | |
c793fa87 | 16 | #pragma interface "icon.h" |
2bda0e17 KB |
17 | #endif |
18 | ||
6d167489 VZ |
19 | // ---------------------------------------------------------------------------- |
20 | // headers | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
23 | // compatible (even if incorrect) behaviour by default: derive wxIcon from | |
24 | // wxBitmap | |
25 | #ifndef wxICON_IS_BITMAP | |
26 | #define wxICON_IS_BITMAP 1 | |
27 | #endif | |
28 | ||
29 | #if wxICON_IS_BITMAP | |
30 | #include "wx/bitmap.h" | |
31 | ||
32 | #define wxIconRefDataBase wxBitmapRefData | |
33 | #define wxIconBase wxBitmap | |
34 | #else | |
35 | #include "wx/msw/gdiimage.h" | |
36 | ||
37 | #define wxIconRefDataBase wxGDIImageRefData | |
38 | #define wxIconBase wxGDIImage | |
39 | #endif | |
2bda0e17 | 40 | |
c793fa87 VZ |
41 | // --------------------------------------------------------------------------- |
42 | // icon data | |
43 | // --------------------------------------------------------------------------- | |
c793fa87 | 44 | |
6d167489 VZ |
45 | // notice that although wxIconRefData inherits from wxBitmapRefData, it is not |
46 | // a valid wxBitmapRefData | |
47 | class WXDLLEXPORT wxIconRefData : public wxIconRefDataBase | |
48 | { | |
2bda0e17 | 49 | public: |
6d167489 VZ |
50 | wxIconRefData() { } |
51 | virtual ~wxIconRefData() { Free(); } | |
2bda0e17 | 52 | |
6d167489 | 53 | virtual void Free(); |
2bda0e17 KB |
54 | }; |
55 | ||
c793fa87 | 56 | // --------------------------------------------------------------------------- |
2bda0e17 | 57 | // Icon |
c793fa87 | 58 | // --------------------------------------------------------------------------- |
2bda0e17 | 59 | |
6d167489 VZ |
60 | class WXDLLEXPORT wxIcon : public wxIconBase |
61 | { | |
2bda0e17 | 62 | public: |
4b7f2165 VZ |
63 | // ctors |
64 | // default | |
65 | wxIcon() { } | |
2bda0e17 | 66 | |
4b7f2165 | 67 | // copy |
c793fa87 | 68 | wxIcon(const wxIcon& icon) { Ref(icon); } |
2bda0e17 | 69 | |
4b7f2165 | 70 | // from raw data |
c793fa87 | 71 | wxIcon(const char bits[], int width, int height); |
4b7f2165 VZ |
72 | // from XPM data |
73 | wxIcon(const char **data) { CreateIconFromXpm(data); } | |
74 | wxIcon(char **data) { CreateIconFromXpm((const char **)data); } | |
75 | // from resource/file | |
6d167489 VZ |
76 | wxIcon(const wxString& name, |
77 | long type = wxBITMAP_TYPE_ICO_RESOURCE, | |
c793fa87 | 78 | int desiredWidth = -1, int desiredHeight = -1); |
4b7f2165 | 79 | |
6d167489 | 80 | virtual ~wxIcon(); |
2bda0e17 | 81 | |
6d167489 VZ |
82 | virtual bool LoadFile(const wxString& name, |
83 | long type = wxBITMAP_TYPE_ICO_RESOURCE, | |
84 | int desiredWidth = -1, int desiredHeight = -1); | |
2bda0e17 | 85 | |
c793fa87 | 86 | wxIcon& operator = (const wxIcon& icon) |
6d167489 | 87 | { if ( *this != icon ) Ref(icon); return *this; } |
c793fa87 VZ |
88 | bool operator == (const wxIcon& icon) const |
89 | { return m_refData == icon.m_refData; } | |
90 | bool operator != (const wxIcon& icon) const | |
91 | { return m_refData != icon.m_refData; } | |
2bda0e17 | 92 | |
6d167489 | 93 | wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; } |
2bda0e17 | 94 | |
6d167489 VZ |
95 | void SetHICON(WXHICON icon) { SetHandle((WXHANDLE)icon); } |
96 | WXHICON GetHICON() const { return (WXHICON)GetHandle(); } | |
2bda0e17 | 97 | |
6d167489 VZ |
98 | protected: |
99 | virtual wxGDIImageRefData *CreateData() const | |
c793fa87 | 100 | { |
6d167489 VZ |
101 | return new wxIconRefData; |
102 | } | |
2bda0e17 | 103 | |
4b7f2165 VZ |
104 | // create from XPM data |
105 | void CreateIconFromXpm(const char **data); | |
106 | ||
107 | // create from bitmap (which should have a mask unless it's monochrome) | |
108 | void CopyFromBitmap(const wxBitmap& bmp); | |
109 | ||
6d167489 VZ |
110 | private: |
111 | DECLARE_DYNAMIC_CLASS(wxIcon) | |
2bda0e17 KB |
112 | }; |
113 | ||
114 | #endif | |
bbcdf8bc | 115 | // _WX_ICON_H_ |