]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/icon.h
using Run of base class
[wxWidgets.git] / include / wx / osx / icon.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/icon.h
3 // Purpose: wxIcon class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_ICON_H_
12 #define _WX_ICON_H_
13
14 #include "wx/bitmap.h"
15
16 // Icon
17 class WXDLLIMPEXP_CORE wxIcon : public wxGDIObject
18 {
19 public:
20 wxIcon();
21
22 wxIcon(const char* const* data);
23 wxIcon(const char bits[], int width , int height );
24 wxIcon(const wxString& name, wxBitmapType flags = wxICON_DEFAULT_TYPE,
25 int desiredWidth = -1, int desiredHeight = -1);
26 wxIcon(const wxIconLocation& loc)
27 {
28 LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
29 }
30
31 wxIcon(WXHICON icon, const wxSize& size);
32
33 virtual ~wxIcon();
34
35 bool LoadFile(const wxString& name, wxBitmapType flags = wxICON_DEFAULT_TYPE,
36 int desiredWidth = -1, int desiredHeight = -1);
37
38
39 // create from bitmap (which should have a mask unless it's monochrome):
40 // there shouldn't be any implicit bitmap -> icon conversion (i.e. no
41 // ctors, assignment operators...), but it's ok to have such function
42 void CopyFromBitmap(const wxBitmap& bmp);
43
44 int GetWidth() const;
45 int GetHeight() const;
46 int GetDepth() const;
47 void SetWidth(int w);
48 void SetHeight(int h);
49 void SetDepth(int d);
50 void SetOk(bool isOk);
51
52 wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
53
54 WXHICON GetHICON() const;
55
56 protected:
57 virtual wxGDIRefData *CreateGDIRefData() const;
58 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
59
60 private:
61 DECLARE_DYNAMIC_CLASS(wxIcon)
62
63 bool LoadIconFromSystemResource(const wxString& resourceName, int desiredWidth, int desiredHeight);
64 bool LoadIconFromBundleResource(const wxString& resourceName, int desiredWidth, int desiredHeight);
65 bool LoadIconFromFile(const wxString& filename, int desiredWidth, int desiredHeight);
66 bool LoadIconAsBitmap(const wxString& filename, wxBitmapType flags = wxICON_DEFAULT_TYPE, int desiredWidth = -1, int desiredHeight = -1);
67 };
68
69 class WXDLLIMPEXP_CORE wxICONResourceHandler: public wxBitmapHandler
70 {
71 public:
72 wxICONResourceHandler()
73 {
74 SetName(wxT("ICON resource"));
75 SetExtension(wxEmptyString);
76 SetType(wxBITMAP_TYPE_ICON_RESOURCE);
77 }
78
79 virtual bool LoadFile(wxBitmap *bitmap,
80 const wxString& name,
81 wxBitmapType flags,
82 int desiredWidth = -1,
83 int desiredHeight = -1);
84
85 // unhide the base class virtual
86 virtual bool LoadFile(wxBitmap *bitmap,
87 const wxString& name,
88 wxBitmapType flags)
89 { return LoadFile(bitmap, name, flags, -1, -1); }
90
91 private:
92 DECLARE_DYNAMIC_CLASS(wxICONResourceHandler)
93 };
94
95 #endif
96 // _WX_ICON_H_