]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/icon.h
fixed #if !NOPCH to be #if !defined(NOPCH)
[wxWidgets.git] / include / wx / msw / icon.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: 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#ifdef __GNUG__
16 #pragma interface "icon.h"
17#endif
18
19#include "wx/bitmap.h"
20
21// ---------------------------------------------------------------------------
22// icon data
23// ---------------------------------------------------------------------------
24class WXDLLEXPORT wxIconRefData: public wxBitmapRefData
25{
26 friend class WXDLLEXPORT wxBitmap;
27 friend class WXDLLEXPORT wxIcon;
28
29public:
30 wxIconRefData();
31 ~wxIconRefData();
32
33public:
34 WXHICON m_hIcon;
35};
36
37#define M_ICONDATA ((wxIconRefData *)m_refData)
38#define M_ICONHANDLERDATA ((wxIconRefData *)bitmap->GetRefData())
39
40// ---------------------------------------------------------------------------
41// Icon
42// ---------------------------------------------------------------------------
43class WXDLLEXPORT wxIcon : public wxBitmap
44{
45 DECLARE_DYNAMIC_CLASS(wxIcon)
46
47public:
48 wxIcon();
49
50 // Copy constructors
51 wxIcon(const wxIcon& icon) { Ref(icon); }
52
53 wxIcon(const char bits[], int width, int height);
54 wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE,
55 int desiredWidth = -1, int desiredHeight = -1);
56 ~wxIcon();
57
58 bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE,
59 int desiredWidth = -1, int desiredHeight = -1);
60
61 wxIcon& operator = (const wxIcon& icon)
62 { if (*this == icon) return (*this); Ref(icon); return *this; }
63 bool operator == (const wxIcon& icon) const
64 { return m_refData == icon.m_refData; }
65 bool operator != (const wxIcon& icon) const
66 { return m_refData != icon.m_refData; }
67
68 void SetHICON(WXHICON ico);
69 WXHICON GetHICON() const { return (M_ICONDATA ? M_ICONDATA->m_hIcon : 0); }
70
71 bool Ok() const { return (m_refData != NULL && M_ICONDATA->m_hIcon != 0) ; }
72
73 bool FreeResource(bool force = FALSE);
74};
75
76// TODO: Put these in separate, private header
77
78class WXDLLEXPORT wxICOFileHandler: public wxBitmapHandler
79{
80DECLARE_DYNAMIC_CLASS(wxICOFileHandler)
81
82public:
83 wxICOFileHandler()
84 {
85 m_name = "ICO icon file";
86 m_extension = "ico";
87 m_type = wxBITMAP_TYPE_ICO;
88 };
89
90 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
91 int desiredWidth = -1, int desiredHeight = -1);
92};
93
94class WXDLLEXPORT wxICOResourceHandler: public wxBitmapHandler
95{
96DECLARE_DYNAMIC_CLASS(wxICOResourceHandler)
97
98public:
99 wxICOResourceHandler()
100 {
101 m_name = "ICO resource";
102 m_extension = "ico";
103 m_type = wxBITMAP_TYPE_ICO_RESOURCE;
104 };
105
106 virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
107 int desiredWidth = -1, int desiredHeight = -1);
108
109};
110
111#endif
112 // _WX_ICON_H_