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