]>
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 | ||
c781807d | 23 | #include "wx/msw/gdiimage.h" |
2bda0e17 | 24 | |
c793fa87 VZ |
25 | // --------------------------------------------------------------------------- |
26 | // icon data | |
27 | // --------------------------------------------------------------------------- | |
c793fa87 | 28 | |
6d167489 VZ |
29 | // notice that although wxIconRefData inherits from wxBitmapRefData, it is not |
30 | // a valid wxBitmapRefData | |
c781807d | 31 | class WXDLLEXPORT wxIconRefData : public wxGDIImageRefData |
6d167489 | 32 | { |
2bda0e17 | 33 | public: |
6d167489 VZ |
34 | wxIconRefData() { } |
35 | virtual ~wxIconRefData() { Free(); } | |
2bda0e17 | 36 | |
6d167489 | 37 | virtual void Free(); |
2bda0e17 KB |
38 | }; |
39 | ||
c793fa87 | 40 | // --------------------------------------------------------------------------- |
2bda0e17 | 41 | // Icon |
c793fa87 | 42 | // --------------------------------------------------------------------------- |
2bda0e17 | 43 | |
c781807d | 44 | class WXDLLEXPORT wxIcon : public wxGDIImage |
6d167489 | 45 | { |
2bda0e17 | 46 | public: |
4b7f2165 VZ |
47 | // ctors |
48 | // default | |
49 | wxIcon() { } | |
2bda0e17 | 50 | |
4b7f2165 | 51 | // copy |
c793fa87 | 52 | wxIcon(const wxIcon& icon) { Ref(icon); } |
2bda0e17 | 53 | |
4b7f2165 | 54 | // from raw data |
c793fa87 | 55 | wxIcon(const char bits[], int width, int height); |
aaf7ab43 | 56 | |
4b7f2165 VZ |
57 | // from XPM data |
58 | wxIcon(const char **data) { CreateIconFromXpm(data); } | |
7581faf6 | 59 | |
4b7f2165 | 60 | wxIcon(char **data) { CreateIconFromXpm((const char **)data); } |
aaf7ab43 | 61 | |
4b7f2165 | 62 | // from resource/file |
6d167489 VZ |
63 | wxIcon(const wxString& name, |
64 | long type = wxBITMAP_TYPE_ICO_RESOURCE, | |
c793fa87 | 65 | int desiredWidth = -1, int desiredHeight = -1); |
4b7f2165 | 66 | |
aaf7ab43 VZ |
67 | wxIcon(const wxIconLocation& loc); |
68 | ||
6d167489 | 69 | virtual ~wxIcon(); |
2bda0e17 | 70 | |
6d167489 VZ |
71 | virtual bool LoadFile(const wxString& name, |
72 | long type = wxBITMAP_TYPE_ICO_RESOURCE, | |
73 | int desiredWidth = -1, int desiredHeight = -1); | |
2bda0e17 | 74 | |
c793fa87 | 75 | wxIcon& operator = (const wxIcon& icon) |
6d167489 | 76 | { if ( *this != icon ) Ref(icon); return *this; } |
c793fa87 VZ |
77 | bool operator == (const wxIcon& icon) const |
78 | { return m_refData == icon.m_refData; } | |
79 | bool operator != (const wxIcon& icon) const | |
80 | { return m_refData != icon.m_refData; } | |
2bda0e17 | 81 | |
4004f41e | 82 | // implementation only from now on |
6d167489 | 83 | wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; } |
2bda0e17 | 84 | |
6d167489 VZ |
85 | void SetHICON(WXHICON icon) { SetHandle((WXHANDLE)icon); } |
86 | WXHICON GetHICON() const { return (WXHICON)GetHandle(); } | |
2bda0e17 | 87 | |
4004f41e VZ |
88 | // create from bitmap (which should have a mask unless it's monochrome): |
89 | // there shouldn't be any implicit bitmap -> icon conversion (i.e. no | |
90 | // ctors, assignment operators...), but it's ok to have such function | |
91 | void CopyFromBitmap(const wxBitmap& bmp); | |
92 | ||
6d167489 VZ |
93 | protected: |
94 | virtual wxGDIImageRefData *CreateData() const | |
c793fa87 | 95 | { |
6d167489 VZ |
96 | return new wxIconRefData; |
97 | } | |
2bda0e17 | 98 | |
4b7f2165 VZ |
99 | // create from XPM data |
100 | void CreateIconFromXpm(const char **data); | |
101 | ||
6d167489 VZ |
102 | private: |
103 | DECLARE_DYNAMIC_CLASS(wxIcon) | |
2bda0e17 KB |
104 | }; |
105 | ||
106 | #endif | |
bbcdf8bc | 107 | // _WX_ICON_H_ |