\input http.tex
\input icon.tex
\input iconbndl.tex
+\input iconloc.tex
\input iconevt.tex
\input idleevt.tex
\input image.tex
Loads an icon from a file or resource.
+\func{}{wxIcon}{\param{const wxIconLocation\& }{loc}}
+
+Loads an icon from the specified \helpref{location}{wxiconlocation}.
+
\wxheading{Parameters}
\docparam{bits}{Specifies an array of pixel values.}
\docparam{name}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
Its meaning is determined by the {\it flags} parameter.}
+\docparam{loc}{The object describing the location of the native icon, see
+\helpref{wxIconLocation}{wxiconlocation}.}
+
\docparam{type}{May be one of the following:
\twocolwidtha{5cm}
--- /dev/null
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Name: iconloc.tex
+%% Purpose: wxIconLocation documentation
+%% Author: Vadim Zeitlin
+%% Modified by:
+%% Created: 21.06.03
+%% RCS-ID: $Id$
+%% Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
+%% License: wxWindows license
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\section{\class{wxIconLocation}}\label{wxiconlocation}
+
+wxIconLocation is a tiny class describing the location of an (external, i.e.
+not embedded into the application resources) icon. For most platforms it simply
+contains the file name but under some others (notably Windows) the same file
+may contain multiple icons and so this class also stores the index of the icon
+inside the file.
+
+In any case, its details should be of no interest to the application code and
+most of them are not even documented here (on purpose) as it is only meant to
+be used as an opaque class: the application may get the object of this class
+from somewhere and the only reasonable thing to do with it later is to create
+a \helpref{wxIcon}{wxicon} from it.
+
+\wxheading{Derived from}
+
+None.
+
+\wxheading{Include files}
+
+<wx/iconloc.h>
+
+\wxheading{See also}
+
+\wxheading{wxIcon}{wxicon}, \helpref{wxFileType::GetIcon()}{wxfiletypegeticon}
+
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+\membersection{wxIconLocation::IsOk}\label{wxiconlocationisok}
+
+\constfunc{bool}{IsOk}{\void}
+
+Returns {\tt true} if the object is valid, i.e. was properly initialized, and
+{\tt false} otherwise.
+
/////////////////////////////////////////////////////////////////////////////
-// Name: icon.h
+// Name: wx/cocoa/icon.h
// Purpose: wxIcon class
// Author: AUTHOR
// Modified by:
wxIcon(const char bits[], int width , int height );
wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE,
int desiredWidth = -1, int desiredHeight = -1);
+ wxIcon(const wxIconLocation& loc)
+ {
+ LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
+ }
~wxIcon();
bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ ,
int desiredWidth /* = -1 */ , int desiredHeight = -1);
bool LoadFile(const wxString& name ,wxBitmapType flags = wxBITMAP_TYPE_ICON_RESOURCE )
- { return LoadFile( name , flags , -1 , -1 ) ; }
+ { return LoadFile( name , flags , -1 , -1 ) ; }
+
+ 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 !(*this == 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; }
-
// 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
}
wxIcon( char **bits, int width=-1, int height=-1 );
+ wxIcon(const wxIconLocation& loc)
+ : wxBitmap(loc.GetFileName(), wxBITMAP_TYPE_XPM)
+ {
+ }
+
wxIcon& operator=(const wxIcon& icon);
bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; }
bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
}
wxIcon( char **bits, int width=-1, int height=-1 );
+ wxIcon(const wxIconLocation& loc)
+ : wxBitmap(loc.GetFileName(), wxBITMAP_TYPE_XPM)
+ {
+ }
+
wxIcon& operator=(const wxIcon& icon);
bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; }
bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
#ifndef _WX_ICON_H_BASE_
#define _WX_ICON_H_BASE_
-/* Commenting out since duplicated in gdicmn.h
-// this is for Unix (i.e. now for anything other than MSW)
-#undef wxICON
-#define wxICON(icon_name) wxIcon(icon_name##_xpm)
-*/
+#include "wx/iconloc.h"
#if defined(__WXMSW__)
#include "wx/msw/icon.h"
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: wx/iconloc.h
+// Purpose: declaration of wxIconLocation class
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 21.06.2003
+// RCS-ID: $Id$
+// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_ICONLOC_H_
+#define _WX_ICONLOC_H_
+
+#include "wx/string.h"
+
+// ----------------------------------------------------------------------------
+// wxIconLocation: describes the location of an icon
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxIconLocationBase
+{
+public:
+ // ctor takes the name of the file where the icon is
+ wxEXPLICIT wxIconLocationBase(const wxString& file) : m_filename(file) { }
+
+ // default copy ctor, assignment operator and dtor are ok
+
+
+ // returns true if this object is valid/initialized
+ bool IsOk() const { return !m_filename.empty(); }
+
+ // set/get the icon file name
+ void SetFileName(const wxString& file) { m_filename = file; }
+ const wxString& GetFileName() const { return m_filename; }
+
+private:
+ wxString m_filename;
+};
+
+// under MSW the same file may contain several icons so we also store the
+// index of the icon
+#if defined(__WXMSW__)
+
+class WXDLLEXPORT wxIconLocation : public wxIconLocationBase
+{
+public:
+ // ctor takes the name of the file where the icon is and the icons index in
+ // the file
+ wxEXPLICIT wxIconLocation(const wxString& file, int num = 0);
+
+ // set/get the icon index
+ void SetIndex(int num) { m_index = num; }
+ int GetIndex() const { return m_index; }
+
+private:
+ int m_index;
+};
+
+inline
+wxIconLocation::wxIconLocation(const wxString& file, int num)
+ : wxIconLocationBase(file)
+{
+ SetIndex(num);
+}
+
+#else // !MSW
+
+typedef wxIconLocationBase wxIconLocation;
+
+#endif // platform
+
+#endif // _WX_ICONLOC_H_
+
// Icon
class WXDLLEXPORT wxIcon: public wxBitmap
{
- DECLARE_DYNAMIC_CLASS(wxIcon)
-
public:
wxIcon();
wxIcon(char **data);
wxIcon(const char bits[], int width , int height );
wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE,
- int desiredWidth = -1, int desiredHeight = -1);
+ int desiredWidth = -1, int desiredHeight = -1);
+ wxIcon(const wxIconLocation& loc)
+ {
+ LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
+ }
~wxIcon();
bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ ,
int desiredWidth /* = -1 */ , int desiredHeight = -1);
bool LoadFile(const wxString& name ,wxBitmapType flags = wxBITMAP_TYPE_ICON_RESOURCE )
- { return LoadFile( name , flags , -1 , -1 ) ; }
+ { return LoadFile( name , flags , -1 , -1 ) ; }
+
+ 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 !(*this == 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; }
-
// 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);
+
+ DECLARE_DYNAMIC_CLASS(wxIcon)
};
/*
wxIcon(const wxString& filename, int type = wxBITMAP_TYPE_ICO_RESOURCE,
int WXUNUSED(desiredWidth)=-1, int WXUNUSED(desiredHeight)=-1 ) :
wxBitmap(filename, (wxBitmapType)type) {}
-
- wxIcon& operator = (const wxIcon& icon);
- inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; }
- inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; }
+
+ wxIcon(const wxIconLocation& loc)
+ : wxBitmap(loc.GetFileName(), wxBITMAP_TYPE_ICO)
+ {
+ }
+
+ wxIcon& operator=(const wxIcon& icon);
+ bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; }
+ bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
// 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);
-
+
private:
DECLARE_DYNAMIC_CLASS(wxIcon)
};
#include "wx/bitmap.h"
// Icon
-class WXDLLEXPORT wxIcon: public wxBitmap
+class WXDLLEXPORT wxIcon : public wxBitmap
{
- DECLARE_DYNAMIC_CLASS(wxIcon);
-
public:
wxIcon();
wxIcon(char **data);
wxIcon(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_XPM,
- int desiredWidth = -1, int desiredHeight = -1);
+ int desiredWidth = -1, int desiredHeight = -1)
+ {
+ LoadFile(name, type, desiredWidth, desiredHeight);
+ }
+
+ wxIcon(const wxIconLocation& loc)
+ {
+ LoadFile(loc.GetFileName());
+ }
+
~wxIcon();
bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_XPM,
- int desiredWidth = -1, int desiredHeight = -1);
+ int desiredWidth = -1, int desiredHeight = -1);
// 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);
- inline wxIcon& operator = (const wxIcon& icon)
- { if (*this == icon) return (*this); Ref(icon); return *this; }
- inline bool operator == (const wxIcon& icon) const
+ wxIcon& operator = (const wxIcon& icon)
+ { if (this != &icon) Ref(icon); return *this; }
+ bool operator == (const wxIcon& icon) const
{ return m_refData == icon.m_refData; }
- inline bool operator != (const wxIcon& icon) const
- { return m_refData != icon.m_refData; }
+ bool operator != (const wxIcon& icon) const
+ { return !(*this == icon); }
+
+
+ DECLARE_DYNAMIC_CLASS(wxIcon);
};
#endif // _WX_ICON_H_
// from raw data
wxIcon(const char bits[], int width, int height);
+
// from XPM data
wxIcon(const char **data) { CreateIconFromXpm(data); }
wxIcon(char **data) { CreateIconFromXpm((const char **)data); }
+
// from resource/file
wxIcon(const wxString& name,
long type = wxBITMAP_TYPE_ICO_RESOURCE,
int desiredWidth = -1, int desiredHeight = -1);
+ wxIcon(const wxIconLocation& loc);
+
virtual ~wxIcon();
virtual bool LoadFile(const wxString& name,
,int nDesiredWidth = -1
,int nDesiredHeight = -1
);
+ wxIcon(const wxIconLocation& loc)
+ {
+ LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICO);
+ }
+
~wxIcon();
bool LoadFile( const wxString& rName
}
wxIcon( char **bits, int width=-1, int height=-1 );
- wxIcon& operator = (const wxIcon& icon);
- inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; }
- inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; }
+ wxIcon(const wxIconLocation& loc)
+ : wxBitmap(loc.GetFileName(), wxBITMAP_TYPE_XPM)
+ {
+ }
+
+ wxIcon& operator=(const wxIcon& icon);
+ bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; }
+ bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
// create from bitmap (which should have a mask unless it's monochrome):
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
(void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
}
-wxIcon::wxIcon(const wxString& icon_file, wxBitmapType type,
- int desiredWidth, int desiredHeight)
-
-{
- LoadFile(icon_file, type, desiredWidth, desiredHeight);
-}
-
void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
{
wxIcon *icon = (wxIcon*)(&bmp);
LoadFile(iconfile, flags, desiredWidth, desiredHeight);
}
+wxIcon::wxIcon(const wxIconLocation& loc)
+{
+ // wxICOFileHandler accepts names in the format "filename;index"
+ wxString fullname = loc.GetFileName();
+ if ( loc.GetIndex() )
+ {
+ fullname << _T(';') << loc.GetIndex();
+ }
+ //else: 0 is default
+
+ LoadFile(fullname);
+}
+
wxIcon::~wxIcon()
{
}