]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/msw/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 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
16 | #pragma interface "icon.h" | |
17 | #endif | |
18 | ||
19 | // ---------------------------------------------------------------------------- | |
20 | // headers | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
23 | #include "wx/msw/gdiimage.h" | |
24 | ||
25 | // --------------------------------------------------------------------------- | |
26 | // icon data | |
27 | // --------------------------------------------------------------------------- | |
28 | ||
29 | // notice that although wxIconRefData inherits from wxBitmapRefData, it is not | |
30 | // a valid wxBitmapRefData | |
31 | class WXDLLEXPORT wxIconRefData : public wxGDIImageRefData | |
32 | { | |
33 | public: | |
34 | wxIconRefData() { } | |
35 | virtual ~wxIconRefData() { Free(); } | |
36 | ||
37 | virtual void Free(); | |
38 | }; | |
39 | ||
40 | // --------------------------------------------------------------------------- | |
41 | // Icon | |
42 | // --------------------------------------------------------------------------- | |
43 | ||
44 | class WXDLLEXPORT wxIcon : public wxGDIImage | |
45 | { | |
46 | public: | |
47 | // ctors | |
48 | // default | |
49 | wxIcon() { } | |
50 | ||
51 | // copy | |
52 | wxIcon(const wxIcon& icon) : wxGDIImage(icon) { Ref(icon); } | |
53 | ||
54 | // from raw data | |
55 | wxIcon(const char bits[], int width, int height); | |
56 | ||
57 | // from XPM data | |
58 | wxIcon(const char **data) { CreateIconFromXpm(data); } | |
59 | ||
60 | wxIcon(char **data) { CreateIconFromXpm((const char **)data); } | |
61 | ||
62 | // from resource/file | |
63 | wxIcon(const wxString& name, | |
64 | long type = wxBITMAP_TYPE_ICO_RESOURCE, | |
65 | int desiredWidth = -1, int desiredHeight = -1); | |
66 | ||
67 | wxIcon(const wxIconLocation& loc); | |
68 | ||
69 | virtual ~wxIcon(); | |
70 | ||
71 | virtual bool LoadFile(const wxString& name, | |
72 | long type = wxBITMAP_TYPE_ICO_RESOURCE, | |
73 | int desiredWidth = -1, int desiredHeight = -1); | |
74 | ||
75 | wxIcon& operator = (const wxIcon& icon) | |
76 | { if ( *this != icon ) Ref(icon); return *this; } | |
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; } | |
81 | ||
82 | // implementation only from now on | |
83 | wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; } | |
84 | ||
85 | void SetHICON(WXHICON icon) { SetHandle((WXHANDLE)icon); } | |
86 | WXHICON GetHICON() const { return (WXHICON)GetHandle(); } | |
87 | ||
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 | ||
93 | protected: | |
94 | virtual wxGDIImageRefData *CreateData() const | |
95 | { | |
96 | return new wxIconRefData; | |
97 | } | |
98 | ||
99 | virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; | |
100 | ||
101 | // create from XPM data | |
102 | void CreateIconFromXpm(const char **data); | |
103 | ||
104 | private: | |
105 | DECLARE_DYNAMIC_CLASS(wxIcon) | |
106 | }; | |
107 | ||
108 | #endif | |
109 | // _WX_ICON_H_ |