]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/icon.h
The rounded corners look really dumb at this size.
[wxWidgets.git] / include / wx / msw / icon.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/icon.h
3 // Purpose: wxIcon class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_ICON_H_
12 #define _WX_ICON_H_
13
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17
18 #include "wx/msw/gdiimage.h"
19
20 // ---------------------------------------------------------------------------
21 // icon data
22 // ---------------------------------------------------------------------------
23
24 // notice that although wxIconRefData inherits from wxBitmapRefData, it is not
25 // a valid wxBitmapRefData
26 class WXDLLIMPEXP_CORE wxIconRefData : public wxGDIImageRefData
27 {
28 public:
29 wxIconRefData() { }
30 virtual ~wxIconRefData() { Free(); }
31
32 virtual void Free();
33 };
34
35 // ---------------------------------------------------------------------------
36 // Icon
37 // ---------------------------------------------------------------------------
38
39 class WXDLLIMPEXP_CORE wxIcon : public wxGDIImage
40 {
41 public:
42 // ctors
43 // default
44 wxIcon() { }
45
46 // from raw data
47 wxIcon(const char bits[], int width, int height);
48
49 // from XPM data
50 wxIcon(const char* const* data) { CreateIconFromXpm(data); }
51 #ifdef wxNEEDS_CHARPP
52 wxIcon(char **data) { CreateIconFromXpm(const_cast<const char* const*>(data)); }
53 #endif
54 // from resource/file
55 wxIcon(const wxString& name,
56 wxBitmapType type = wxICON_DEFAULT_TYPE,
57 int desiredWidth = -1, int desiredHeight = -1);
58
59 wxIcon(const wxIconLocation& loc);
60
61 virtual ~wxIcon();
62
63 virtual bool LoadFile(const wxString& name,
64 wxBitmapType type = wxICON_DEFAULT_TYPE,
65 int desiredWidth = -1, int desiredHeight = -1);
66
67 bool CreateFromHICON(WXHICON icon);
68
69 // implementation only from now on
70 wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
71
72 void SetHICON(WXHICON icon) { SetHandle((WXHANDLE)icon); }
73 WXHICON GetHICON() const { return (WXHICON)GetHandle(); }
74
75 // create from bitmap (which should have a mask unless it's monochrome):
76 // there shouldn't be any implicit bitmap -> icon conversion (i.e. no
77 // ctors, assignment operators...), but it's ok to have such function
78 void CopyFromBitmap(const wxBitmap& bmp);
79
80 protected:
81 virtual wxGDIImageRefData *CreateData() const
82 {
83 return new wxIconRefData;
84 }
85
86 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
87
88 // create from XPM data
89 void CreateIconFromXpm(const char* const* data);
90
91 private:
92 DECLARE_DYNAMIC_CLASS(wxIcon)
93 };
94
95 #endif
96 // _WX_ICON_H_