]>
Commit | Line | Data |
---|---|---|
ffecfa5a JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/palmos/icon.h | |
3 | // Purpose: wxIcon class | |
e1d63b79 | 4 | // Author: William Osborne - minimal working wxPalmOS port |
ffecfa5a JS |
5 | // Modified by: |
6 | // Created: 10/13/04 | |
e1d63b79 | 7 | // RCS-ID: $Id$ |
ffecfa5a JS |
8 | // Copyright: (c) William Osborne |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_ICON_H_ | |
13 | #define _WX_ICON_H_ | |
14 | ||
ffecfa5a JS |
15 | // ---------------------------------------------------------------------------- |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/palmos/gdiimage.h" | |
20 | ||
21 | // --------------------------------------------------------------------------- | |
22 | // icon data | |
23 | // --------------------------------------------------------------------------- | |
24 | ||
25 | // notice that although wxIconRefData inherits from wxBitmapRefData, it is not | |
26 | // a valid wxBitmapRefData | |
27 | class WXDLLEXPORT wxIconRefData : public wxGDIImageRefData | |
28 | { | |
29 | public: | |
30 | wxIconRefData() { } | |
31 | virtual ~wxIconRefData() { Free(); } | |
32 | ||
33 | virtual void Free(); | |
34 | }; | |
35 | ||
36 | // --------------------------------------------------------------------------- | |
37 | // Icon | |
38 | // --------------------------------------------------------------------------- | |
39 | ||
40 | class WXDLLEXPORT wxIcon : public wxGDIImage | |
41 | { | |
42 | public: | |
43 | // ctors | |
44 | // default | |
45 | wxIcon() { } | |
46 | ||
47 | // copy | |
48 | wxIcon(const wxIcon& icon) { Ref(icon); } | |
49 | ||
50 | // from raw data | |
51 | wxIcon(const char bits[], int width, int height); | |
52 | ||
53 | // from XPM data | |
54 | wxIcon(const char **data) { CreateIconFromXpm(data); } | |
55 | ||
56 | wxIcon(char **data) { CreateIconFromXpm((const char **)data); } | |
57 | ||
58 | // from resource/file | |
59 | wxIcon(const wxString& name, | |
60 | long type = wxBITMAP_TYPE_ICO_RESOURCE, | |
61 | int desiredWidth = -1, int desiredHeight = -1); | |
62 | ||
63 | wxIcon(const wxIconLocation& loc); | |
64 | ||
65 | virtual ~wxIcon(); | |
66 | ||
67 | virtual bool LoadFile(const wxString& name, | |
68 | long type = wxBITMAP_TYPE_ICO_RESOURCE, | |
69 | int desiredWidth = -1, int desiredHeight = -1); | |
70 | ||
71 | wxIcon& operator = (const wxIcon& icon) | |
72 | { if ( *this != icon ) Ref(icon); return *this; } | |
73 | bool operator == (const wxIcon& icon) const | |
74 | { return m_refData == icon.m_refData; } | |
75 | bool operator != (const wxIcon& icon) const | |
76 | { return m_refData != icon.m_refData; } | |
77 | ||
78 | // implementation only from now on | |
79 | wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; } | |
80 | ||
81 | void SetHICON(WXHICON icon) { SetHandle((WXHANDLE)icon); } | |
82 | WXHICON GetHICON() const { return (WXHICON)GetHandle(); } | |
83 | ||
84 | // create from bitmap (which should have a mask unless it's monochrome): | |
85 | // there shouldn't be any implicit bitmap -> icon conversion (i.e. no | |
86 | // ctors, assignment operators...), but it's ok to have such function | |
87 | void CopyFromBitmap(const wxBitmap& bmp); | |
88 | ||
89 | protected: | |
90 | virtual wxGDIImageRefData *CreateData() const | |
91 | { | |
92 | return new wxIconRefData; | |
93 | } | |
94 | ||
95 | // create from XPM data | |
96 | void CreateIconFromXpm(const char **data); | |
97 | ||
98 | private: | |
99 | DECLARE_DYNAMIC_CLASS(wxIcon) | |
100 | }; | |
101 | ||
102 | #endif | |
103 | // _WX_ICON_H_ |