/////////////////////////////////////////////////////////////////////////////
-// Name: icon.h
+// Name: wx/msw/icon.h
// Purpose: wxIcon class
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ICON_H_
#define _WX_ICON_H_
#ifdef __GNUG__
-#pragma interface "icon.h"
+ #pragma interface "icon.h"
#endif
-#include "wx/bitmap.h"
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxIconRefData: public wxBitmapRefData
-{
- friend class WXDLLEXPORT wxBitmap;
- friend class WXDLLEXPORT wxIcon;
-public:
- wxIconRefData(void);
- ~wxIconRefData(void);
+// compatible (even if incorrect) behaviour by default: derive wxIcon from
+// wxBitmap
+#ifndef wxICON_IS_BITMAP
+ #define wxICON_IS_BITMAP 1
+#endif
-public:
- WXHICON m_hIcon;
-};
+#if wxICON_IS_BITMAP
+ #include "wx/bitmap.h"
-#define M_ICONDATA ((wxIconRefData *)m_refData)
-#define M_ICONHANDLERDATA ((wxIconRefData *)bitmap->GetRefData())
+ #define wxIconRefDataBase wxBitmapRefData
+ #define wxIconBase wxBitmap
+#else
+ #include "wx/msw/gdiimage.h"
-// Icon
-class WXDLLEXPORT wxIcon: public wxBitmap
-{
- DECLARE_DYNAMIC_CLASS(wxIcon)
+ #define wxIconRefDataBase wxGDIImageRefData
+ #define wxIconBase wxGDIImage
+#endif
-public:
- wxIcon(void);
+// ---------------------------------------------------------------------------
+// icon data
+// ---------------------------------------------------------------------------
- // Copy constructors
- inline wxIcon(const wxIcon& icon) { Ref(icon); }
+// notice that although wxIconRefData inherits from wxBitmapRefData, it is not
+// a valid wxBitmapRefData
+class WXDLLEXPORT wxIconRefData : public wxIconRefDataBase
+{
+public:
+ wxIconRefData() { }
+ virtual ~wxIconRefData() { Free(); }
- wxIcon(const char bits[], int width, int height);
- wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE,
- int desiredWidth = -1, int desiredHeight = -1);
- ~wxIcon(void);
+ virtual void Free();
+};
- bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE,
- int desiredWidth = -1, int desiredHeight = -1);
+// ---------------------------------------------------------------------------
+// Icon
+// ---------------------------------------------------------------------------
- inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; }
- inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; }
- inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; }
+class WXDLLEXPORT wxIcon : public wxIconBase
+{
+public:
+ wxIcon();
- void SetHICON(WXHICON ico);
- inline WXHICON GetHICON(void) const { return (M_ICONDATA ? M_ICONDATA->m_hIcon : 0); }
+ // Copy constructors
+ wxIcon(const wxIcon& icon) { Ref(icon); }
- virtual bool Ok(void) const { return (m_refData != NULL && M_ICONDATA->m_hIcon) ; }
+ wxIcon(const char bits[], int width, int height);
+ wxIcon(const wxString& name,
+ long type = wxBITMAP_TYPE_ICO_RESOURCE,
+ int desiredWidth = -1, int desiredHeight = -1);
+ virtual ~wxIcon();
- bool FreeResource(bool force = FALSE);
-};
+ virtual bool LoadFile(const wxString& name,
+ long type = wxBITMAP_TYPE_ICO_RESOURCE,
+ int desiredWidth = -1, int desiredHeight = -1);
-// TODO: Put these in separate, private header
+ wxIcon& operator = (const wxIcon& icon)
+ { if ( *this != icon ) Ref(icon); return *this; }
+ bool operator == (const wxIcon& icon) const
+ { return m_refData == icon.m_refData; }
+ bool operator != (const wxIcon& icon) const
+ { return m_refData != icon.m_refData; }
-class WXDLLEXPORT wxICOFileHandler: public wxBitmapHandler
-{
- DECLARE_DYNAMIC_CLASS(wxICOFileHandler)
-public:
- inline wxICOFileHandler(void)
- {
- m_name = "ICO icon file";
- m_extension = "ico";
- m_type = wxBITMAP_TYPE_ICO;
- };
-
- virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth = -1, int desiredHeight = -1);
-};
+ wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
-class WXDLLEXPORT wxICOResourceHandler: public wxBitmapHandler
-{
- DECLARE_DYNAMIC_CLASS(wxICOResourceHandler)
-public:
- inline wxICOResourceHandler(void)
- {
- m_name = "ICO resource";
- m_extension = "ico";
- m_type = wxBITMAP_TYPE_ICO_RESOURCE;
- };
+ void SetHICON(WXHICON icon) { SetHandle((WXHANDLE)icon); }
+ WXHICON GetHICON() const { return (WXHICON)GetHandle(); }
- virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth = -1, int desiredHeight = -1);
+protected:
+ virtual wxGDIImageRefData *CreateData() const
+ {
+ return new wxIconRefData;
+ }
+private:
+ DECLARE_DYNAMIC_CLASS(wxIcon)
};
#endif