added wxIconLocation; minor fixes to wxIcon on some platforms
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21279 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
75f7af39d1
commit
aaf7ab431b
@ -157,6 +157,7 @@
|
||||
\input http.tex
|
||||
\input icon.tex
|
||||
\input iconbndl.tex
|
||||
\input iconloc.tex
|
||||
\input iconevt.tex
|
||||
\input idleevt.tex
|
||||
\input image.tex
|
||||
|
@ -85,6 +85,10 @@ Creates an icon from XPM data.
|
||||
|
||||
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.}
|
||||
@ -107,6 +111,9 @@ screen is used.}
|
||||
\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}
|
||||
|
47
docs/latex/wx/iconloc.tex
Normal file
47
docs/latex/wx/iconloc.tex
Normal file
@ -0,0 +1,47 @@
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% 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.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: icon.h
|
||||
// Name: wx/cocoa/icon.h
|
||||
// Purpose: wxIcon class
|
||||
// Author: AUTHOR
|
||||
// Modified by:
|
||||
@ -36,17 +36,22 @@ public:
|
||||
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
|
||||
|
@ -45,6 +45,11 @@ public:
|
||||
}
|
||||
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); }
|
||||
|
@ -45,6 +45,11 @@ public:
|
||||
}
|
||||
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); }
|
||||
|
@ -1,11 +1,7 @@
|
||||
#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"
|
||||
|
74
include/wx/iconloc.h
Normal file
74
include/wx/iconloc.h
Normal file
@ -0,0 +1,74 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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_
|
||||
|
@ -21,8 +21,6 @@
|
||||
// Icon
|
||||
class WXDLLEXPORT wxIcon: public wxBitmap
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxIcon)
|
||||
|
||||
public:
|
||||
wxIcon();
|
||||
|
||||
@ -35,22 +33,29 @@ public:
|
||||
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)
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -42,16 +42,21 @@ public:
|
||||
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)
|
||||
};
|
||||
|
@ -19,10 +19,8 @@
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
// Icon
|
||||
class WXDLLEXPORT wxIcon: public wxBitmap
|
||||
class WXDLLEXPORT wxIcon : public wxBitmap
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxIcon);
|
||||
|
||||
public:
|
||||
wxIcon();
|
||||
|
||||
@ -37,23 +35,35 @@ public:
|
||||
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_
|
||||
|
@ -53,15 +53,19 @@ public:
|
||||
|
||||
// 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,
|
||||
|
@ -66,6 +66,11 @@ public:
|
||||
,int nDesiredWidth = -1
|
||||
,int nDesiredHeight = -1
|
||||
);
|
||||
wxIcon(const wxIconLocation& loc)
|
||||
{
|
||||
LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICO);
|
||||
}
|
||||
|
||||
~wxIcon();
|
||||
|
||||
bool LoadFile( const wxString& rName
|
||||
|
@ -38,9 +38,14 @@ public:
|
||||
}
|
||||
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
|
||||
|
@ -42,13 +42,6 @@ wxIcon::wxIcon(const char **data)
|
||||
(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);
|
||||
|
@ -85,6 +85,19 @@ wxIcon::wxIcon(const wxString& iconfile,
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user