]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/icon.h
adding a more extensive version to arrive at the impl when given a native control...
[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 // 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 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/msw/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 WXDLLIMPEXP_CORE 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 WXDLLIMPEXP_CORE wxIcon : public wxGDIImage
41 {
42 public:
43 // ctors
44 // default
45 wxIcon() { }
46
47 // from raw data
48 wxIcon(const char bits[], int width, int height);
49
50 // from XPM data
51 wxIcon(const char* const* data) { CreateIconFromXpm(data); }
52 #ifdef wxNEEDS_CHARPP
53 wxIcon(char **data) { CreateIconFromXpm(const_cast<const char* const*>(data)); }
54 #endif
55 // from resource/file
56 wxIcon(const wxString& name,
57 wxBitmapType type = wxICON_DEFAULT_TYPE,
58 int desiredWidth = -1, int desiredHeight = -1);
59
60 wxIcon(const wxIconLocation& loc);
61
62 virtual ~wxIcon();
63
64 virtual bool LoadFile(const wxString& name,
65 wxBitmapType type = wxICON_DEFAULT_TYPE,
66 int desiredWidth = -1, int desiredHeight = -1);
67
68 bool CreateFromHICON(WXHICON icon);
69
70 // implementation only from now on
71 wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
72
73 void SetHICON(WXHICON icon) { SetHandle((WXHANDLE)icon); }
74 WXHICON GetHICON() const { return (WXHICON)GetHandle(); }
75
76 // create from bitmap (which should have a mask unless it's monochrome):
77 // there shouldn't be any implicit bitmap -> icon conversion (i.e. no
78 // ctors, assignment operators...), but it's ok to have such function
79 void CopyFromBitmap(const wxBitmap& bmp);
80
81 protected:
82 virtual wxGDIImageRefData *CreateData() const
83 {
84 return new wxIconRefData;
85 }
86
87 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
88
89 // create from XPM data
90 void CreateIconFromXpm(const char* const* data);
91
92 private:
93 DECLARE_DYNAMIC_CLASS(wxIcon)
94 };
95
96 #endif
97 // _WX_ICON_H_