1998-05-20 10:12:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1999-11-24 07:30:56 -05:00
|
|
|
// Name: wx/msw/icon.h
|
1998-05-20 10:12:05 -04:00
|
|
|
// Purpose: wxIcon class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
1998-08-07 19:52:45 -04:00
|
|
|
// Copyright: (c) Julian Smart
|
1999-02-23 17:57:19 -05:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:12:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 19:52:45 -04:00
|
|
|
#ifndef _WX_ICON_H_
|
|
|
|
#define _WX_ICON_H_
|
1998-05-20 10:12:05 -04:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
1999-02-23 17:57:19 -05:00
|
|
|
#pragma interface "icon.h"
|
1998-05-20 10:12:05 -04:00
|
|
|
#endif
|
|
|
|
|
1999-11-24 07:30:56 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// compatible (even if incorrect) behaviour by default: derive wxIcon from
|
|
|
|
// wxBitmap
|
|
|
|
#ifndef wxICON_IS_BITMAP
|
|
|
|
#define wxICON_IS_BITMAP 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if wxICON_IS_BITMAP
|
|
|
|
#include "wx/bitmap.h"
|
|
|
|
|
|
|
|
#define wxIconRefDataBase wxBitmapRefData
|
|
|
|
#define wxIconBase wxBitmap
|
|
|
|
#else
|
|
|
|
#include "wx/msw/gdiimage.h"
|
|
|
|
|
|
|
|
#define wxIconRefDataBase wxGDIImageRefData
|
|
|
|
#define wxIconBase wxGDIImage
|
|
|
|
#endif
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-02-23 17:57:19 -05:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// icon data
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
1999-11-24 07:30:56 -05:00
|
|
|
// notice that although wxIconRefData inherits from wxBitmapRefData, it is not
|
|
|
|
// a valid wxBitmapRefData
|
|
|
|
class WXDLLEXPORT wxIconRefData : public wxIconRefDataBase
|
|
|
|
{
|
1998-05-20 10:12:05 -04:00
|
|
|
public:
|
1999-11-24 07:30:56 -05:00
|
|
|
wxIconRefData() { }
|
|
|
|
virtual ~wxIconRefData() { Free(); }
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-11-24 07:30:56 -05:00
|
|
|
virtual void Free();
|
1998-05-20 10:12:05 -04:00
|
|
|
};
|
|
|
|
|
1999-02-23 17:57:19 -05:00
|
|
|
// ---------------------------------------------------------------------------
|
1998-05-20 10:12:05 -04:00
|
|
|
// Icon
|
1999-02-23 17:57:19 -05:00
|
|
|
// ---------------------------------------------------------------------------
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-11-24 07:30:56 -05:00
|
|
|
class WXDLLEXPORT wxIcon : public wxIconBase
|
|
|
|
{
|
1998-05-20 10:12:05 -04:00
|
|
|
public:
|
2000-01-21 16:38:51 -05:00
|
|
|
// ctors
|
|
|
|
// default
|
|
|
|
wxIcon() { }
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-01-21 16:38:51 -05:00
|
|
|
// copy
|
1999-02-23 17:57:19 -05:00
|
|
|
wxIcon(const wxIcon& icon) { Ref(icon); }
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-01-21 16:38:51 -05:00
|
|
|
// from raw data
|
1999-02-23 17:57:19 -05:00
|
|
|
wxIcon(const char bits[], int width, int height);
|
2000-01-21 16:38:51 -05:00
|
|
|
// from XPM data
|
|
|
|
wxIcon(const char **data) { CreateIconFromXpm(data); }
|
|
|
|
wxIcon(char **data) { CreateIconFromXpm((const char **)data); }
|
|
|
|
// from resource/file
|
1999-11-24 07:30:56 -05:00
|
|
|
wxIcon(const wxString& name,
|
|
|
|
long type = wxBITMAP_TYPE_ICO_RESOURCE,
|
1999-02-23 17:57:19 -05:00
|
|
|
int desiredWidth = -1, int desiredHeight = -1);
|
2000-01-21 16:38:51 -05:00
|
|
|
|
1999-11-24 07:30:56 -05:00
|
|
|
virtual ~wxIcon();
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-11-24 07:30:56 -05:00
|
|
|
virtual bool LoadFile(const wxString& name,
|
|
|
|
long type = wxBITMAP_TYPE_ICO_RESOURCE,
|
|
|
|
int desiredWidth = -1, int desiredHeight = -1);
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-02-23 17:57:19 -05:00
|
|
|
wxIcon& operator = (const wxIcon& icon)
|
1999-11-24 07:30:56 -05:00
|
|
|
{ if ( *this != icon ) Ref(icon); return *this; }
|
1999-02-23 17:57:19 -05: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 10:12:05 -04:00
|
|
|
|
2000-02-01 19:52:06 -05:00
|
|
|
// implementation only from now on
|
1999-11-24 07:30:56 -05:00
|
|
|
wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
|
1998-05-20 10:12:05 -04:00
|
|
|
|
1999-11-24 07:30:56 -05:00
|
|
|
void SetHICON(WXHICON icon) { SetHandle((WXHANDLE)icon); }
|
|
|
|
WXHICON GetHICON() const { return (WXHICON)GetHandle(); }
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-02-01 19:52:06 -05: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 07:30:56 -05:00
|
|
|
protected:
|
|
|
|
virtual wxGDIImageRefData *CreateData() const
|
1999-02-23 17:57:19 -05:00
|
|
|
{
|
1999-11-24 07:30:56 -05:00
|
|
|
return new wxIconRefData;
|
|
|
|
}
|
1998-05-20 10:12:05 -04:00
|
|
|
|
2000-01-21 16:38:51 -05:00
|
|
|
// create from XPM data
|
|
|
|
void CreateIconFromXpm(const char **data);
|
|
|
|
|
1999-11-24 07:30:56 -05:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxIcon)
|
1998-05-20 10:12:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-08-07 19:52:45 -04:00
|
|
|
// _WX_ICON_H_
|