1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: icon.h
|
|
|
|
// Purpose: wxIcon class
|
1999-10-10 14:36:14 -04:00
|
|
|
// Author: David Webster
|
1999-07-29 01:11:30 -04:00
|
|
|
// Modified by:
|
1999-10-10 14:36:14 -04:00
|
|
|
// Created: 10/09/99
|
1999-07-29 01:11:30 -04:00
|
|
|
// RCS-ID: $Id$
|
1999-10-10 14:36:14 -04:00
|
|
|
// Copyright: (c) David Webster
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_ICON_H_
|
|
|
|
#define _WX_ICON_H_
|
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// compatible (even if incorrect) behaviour by default: derive wxIcon from
|
|
|
|
// wxBitmap
|
|
|
|
#ifndef wxICON_IS_BITMAP
|
|
|
|
#define wxICON_IS_BITMAP 1
|
|
|
|
#endif
|
1999-07-29 01:11:30 -04:00
|
|
|
|
2002-05-06 17:47:16 -04:00
|
|
|
#include "wx/bitmap.h"
|
1999-12-03 00:03:55 -05:00
|
|
|
#if wxICON_IS_BITMAP
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
#define wxIconRefDataBase wxBitmapRefData
|
|
|
|
#define wxIconBase wxBitmap
|
|
|
|
#else
|
|
|
|
#include "wx/os2/gdiimage.h"
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
#define wxIconRefDataBase wxGDIImageRefData
|
|
|
|
#define wxIconBase wxGDIImage
|
|
|
|
#endif
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
class WXDLLEXPORT wxIconRefData: public wxIconRefDataBase
|
1999-07-29 01:11:30 -04:00
|
|
|
{
|
|
|
|
public:
|
1999-12-03 00:03:55 -05:00
|
|
|
wxIconRefData() { };
|
2000-02-27 23:40:52 -05:00
|
|
|
virtual ~wxIconRefData() { Free(); }
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
virtual void Free();
|
2000-02-27 23:40:52 -05:00
|
|
|
}; // end of
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Icon
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxIcon: public wxIconBase
|
1999-07-29 01:11:30 -04:00
|
|
|
{
|
|
|
|
public:
|
1999-12-03 00:03:55 -05:00
|
|
|
wxIcon();
|
|
|
|
|
|
|
|
// Copy constructors
|
|
|
|
inline wxIcon(const wxIcon& icon) { Ref(icon); }
|
|
|
|
|
|
|
|
wxIcon( const char bits[]
|
|
|
|
,int nWidth
|
|
|
|
,int nHeight
|
|
|
|
);
|
2001-01-29 00:46:06 -05:00
|
|
|
inline wxIcon(const char** ppData) { CreateIconFromXpm(ppData); }
|
|
|
|
inline wxIcon(char** ppData) { CreateIconFromXpm((const char**)ppData); }
|
1999-12-03 00:03:55 -05:00
|
|
|
wxIcon( const wxString& rName
|
|
|
|
,long lFlags = wxBITMAP_TYPE_ICO_RESOURCE
|
|
|
|
,int nDesiredWidth = -1
|
|
|
|
,int nDesiredHeight = -1
|
|
|
|
);
|
2003-06-21 09:39:40 -04:00
|
|
|
wxIcon(const wxIconLocation& loc)
|
|
|
|
{
|
|
|
|
LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICO);
|
|
|
|
}
|
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
~wxIcon();
|
|
|
|
|
|
|
|
bool LoadFile( const wxString& rName
|
|
|
|
,long lFlags = wxBITMAP_TYPE_ICO_RESOURCE
|
|
|
|
,int nDesiredWidth = -1
|
|
|
|
,int nDesiredHeight = -1
|
|
|
|
);
|
|
|
|
|
|
|
|
inline wxIcon& operator = (const wxIcon& rIcon)
|
2000-03-09 16:06:48 -05:00
|
|
|
{ if (*this != rIcon) Ref(rIcon); return *this; }
|
2004-05-09 13:30:57 -04:00
|
|
|
inline bool operator == (const wxIcon& rIcon) const
|
1999-12-03 00:03:55 -05:00
|
|
|
{ return m_refData == rIcon.m_refData; }
|
2004-05-09 13:30:57 -04:00
|
|
|
inline bool operator != (const wxIcon& rIcon) const
|
1999-12-03 00:03:55 -05:00
|
|
|
{ return m_refData != rIcon.m_refData; }
|
|
|
|
|
|
|
|
wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
|
|
|
|
|
|
|
|
inline void SetHICON(WXHICON hIcon) { SetHandle((WXHANDLE)hIcon); }
|
|
|
|
inline WXHICON GetHICON() const { return (WXHICON)GetHandle(); }
|
2002-05-06 17:47:16 -04:00
|
|
|
inline bool IsXpm(void) const { return m_bIsXpm; };
|
|
|
|
inline const wxBitmap& GetXpmSrc(void) const { return m_vXpmSrc; }
|
1999-12-03 00:03:55 -05:00
|
|
|
|
2001-01-29 00:46:06 -05:00
|
|
|
void CopyFromBitmap(const wxBitmap& rBmp);
|
1999-12-03 00:03:55 -05:00
|
|
|
protected:
|
|
|
|
virtual wxGDIImageRefData* CreateData() const
|
|
|
|
{
|
|
|
|
return new wxIconRefData;
|
|
|
|
}
|
2001-01-29 00:46:06 -05:00
|
|
|
void CreateIconFromXpm(const char **ppData);
|
1999-07-29 01:11:30 -04:00
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
private:
|
2002-05-06 17:47:16 -04:00
|
|
|
bool m_bIsXpm;
|
|
|
|
wxBitmap m_vXpmSrc;
|
|
|
|
|
1999-12-03 00:03:55 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxIcon)
|
1999-07-29 01:11:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_ICON_H_
|