1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1999-11-24 12:30:56 +00:00
|
|
|
// Name: wx/msw/icon.h
|
1998-05-20 14:12:05 +00:00
|
|
|
// Purpose: wxIcon class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
1998-08-07 23:52:45 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 14:56:36 +00:00
|
|
|
// Licence: wxWidgets licence
|
1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 23:52:45 +00:00
|
|
|
#ifndef _WX_ICON_H_
|
|
|
|
#define _WX_ICON_H_
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2003-08-09 12:38:21 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-02-23 22:57:19 +00:00
|
|
|
#pragma interface "icon.h"
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
|
|
|
|
1999-11-24 12:30:56 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-01-25 13:06:00 +00:00
|
|
|
#include "wx/msw/gdiimage.h"
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-02-23 22:57:19 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// icon data
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
1999-11-24 12:30:56 +00:00
|
|
|
// notice that although wxIconRefData inherits from wxBitmapRefData, it is not
|
|
|
|
// a valid wxBitmapRefData
|
2003-01-25 13:06:00 +00:00
|
|
|
class WXDLLEXPORT wxIconRefData : public wxGDIImageRefData
|
1999-11-24 12:30:56 +00:00
|
|
|
{
|
1998-05-20 14:12:05 +00:00
|
|
|
public:
|
1999-11-24 12:30:56 +00:00
|
|
|
wxIconRefData() { }
|
|
|
|
virtual ~wxIconRefData() { Free(); }
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-11-24 12:30:56 +00:00
|
|
|
virtual void Free();
|
1998-05-20 14:12:05 +00:00
|
|
|
};
|
|
|
|
|
1999-02-23 22:57:19 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
1998-05-20 14:12:05 +00:00
|
|
|
// Icon
|
1999-02-23 22:57:19 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2003-01-25 13:06:00 +00:00
|
|
|
class WXDLLEXPORT wxIcon : public wxGDIImage
|
1999-11-24 12:30:56 +00:00
|
|
|
{
|
1998-05-20 14:12:05 +00:00
|
|
|
public:
|
2000-01-21 21:38:51 +00:00
|
|
|
// ctors
|
|
|
|
// default
|
|
|
|
wxIcon() { }
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2000-01-21 21:38:51 +00:00
|
|
|
// copy
|
1999-02-23 22:57:19 +00:00
|
|
|
wxIcon(const wxIcon& icon) { Ref(icon); }
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2000-01-21 21:38:51 +00:00
|
|
|
// from raw data
|
1999-02-23 22:57:19 +00:00
|
|
|
wxIcon(const char bits[], int width, int height);
|
2003-06-21 13:39:40 +00:00
|
|
|
|
2000-01-21 21:38:51 +00:00
|
|
|
// from XPM data
|
|
|
|
wxIcon(const char **data) { CreateIconFromXpm(data); }
|
2003-05-02 12:16:28 +00:00
|
|
|
|
2000-01-21 21:38:51 +00:00
|
|
|
wxIcon(char **data) { CreateIconFromXpm((const char **)data); }
|
2003-06-21 13:39:40 +00:00
|
|
|
|
2000-01-21 21:38:51 +00:00
|
|
|
// from resource/file
|
1999-11-24 12:30:56 +00:00
|
|
|
wxIcon(const wxString& name,
|
|
|
|
long type = wxBITMAP_TYPE_ICO_RESOURCE,
|
1999-02-23 22:57:19 +00:00
|
|
|
int desiredWidth = -1, int desiredHeight = -1);
|
2000-01-21 21:38:51 +00:00
|
|
|
|
2003-06-21 13:39:40 +00:00
|
|
|
wxIcon(const wxIconLocation& loc);
|
|
|
|
|
1999-11-24 12:30:56 +00:00
|
|
|
virtual ~wxIcon();
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-11-24 12:30:56 +00:00
|
|
|
virtual bool LoadFile(const wxString& name,
|
|
|
|
long type = wxBITMAP_TYPE_ICO_RESOURCE,
|
|
|
|
int desiredWidth = -1, int desiredHeight = -1);
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-02-23 22:57:19 +00:00
|
|
|
wxIcon& operator = (const wxIcon& icon)
|
1999-11-24 12:30:56 +00:00
|
|
|
{ if ( *this != icon ) Ref(icon); return *this; }
|
1999-02-23 22:57:19 +00:00
|
|
|
bool operator == (const wxIcon& icon) const
|
|
|
|
{ return m_refData == icon.m_refData; }
|
|
|
|
bool operator != (const wxIcon& icon) const
|
|
|
|
{ return m_refData != icon.m_refData; }
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2000-02-02 00:52:06 +00:00
|
|
|
// implementation only from now on
|
1999-11-24 12:30:56 +00:00
|
|
|
wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-11-24 12:30:56 +00:00
|
|
|
void SetHICON(WXHICON icon) { SetHandle((WXHANDLE)icon); }
|
|
|
|
WXHICON GetHICON() const { return (WXHICON)GetHandle(); }
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2000-02-02 00:52:06 +00:00
|
|
|
// create from bitmap (which should have a mask unless it's monochrome):
|
|
|
|
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
|
|
|
|
// ctors, assignment operators...), but it's ok to have such function
|
|
|
|
void CopyFromBitmap(const wxBitmap& bmp);
|
|
|
|
|
1999-11-24 12:30:56 +00:00
|
|
|
protected:
|
|
|
|
virtual wxGDIImageRefData *CreateData() const
|
1999-02-23 22:57:19 +00:00
|
|
|
{
|
1999-11-24 12:30:56 +00:00
|
|
|
return new wxIconRefData;
|
|
|
|
}
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2000-01-21 21:38:51 +00:00
|
|
|
// create from XPM data
|
|
|
|
void CreateIconFromXpm(const char **data);
|
|
|
|
|
1999-11-24 12:30:56 +00:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxIcon)
|
1998-05-20 14:12:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-08-07 23:52:45 +00:00
|
|
|
// _WX_ICON_H_
|