GetIcon() returns wxIconLocation, not wxIcon, now
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21316 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -152,13 +152,16 @@ function in the first place.
|
|||||||
|
|
||||||
\membersection{wxFileType::GetIcon}\label{wxfiletypegeticon}
|
\membersection{wxFileType::GetIcon}\label{wxfiletypegeticon}
|
||||||
|
|
||||||
\func{bool}{GetIcon}{\param{wxIcon*}{ icon}, \param{wxString*}{ iconFile = NULL}, \param{int*}{ iconIndex = NULL}, \param{int}{ iconSize = wxICON\_LARGE}}
|
\func{bool}{GetIcon}{\param{wxIconLocation *}{ iconLoc}}
|
||||||
|
|
||||||
If the function returns {\tt TRUE}, the icon associated with this file type will be
|
If the function returns {\tt true}, the {\tt iconLoc} is filled with the
|
||||||
created and assigned to the {\it icon} parameter. {\it iconFile} is assigned the file name
|
location of the icon for this MIME type. A \helpref{wxIcon}{wxicon} may be
|
||||||
that contains the icon and {\it iconIndex} is assigned the index of the icon
|
created from {\it iconLoc} later.
|
||||||
(windows and unix only). A 32x32 icon is assigned if {\it iconSize} is wxICON\_LARGE
|
|
||||||
and a 16x16 icon is assigned if {\it iconSize} is wxICON\_SMALL (windows only).
|
{\bf Windows:} The function returns the icon shown by Explorer for the files of
|
||||||
|
the specified type.
|
||||||
|
|
||||||
|
{\bf Mac:} This function is not implemented and always returns {\tt false}.
|
||||||
|
|
||||||
{\bf Unix:} MIME manager gathers information about icons from GNOME
|
{\bf Unix:} MIME manager gathers information about icons from GNOME
|
||||||
and KDE settings and thus GetIcon's success depends on availability
|
and KDE settings and thus GetIcon's success depends on availability
|
||||||
|
@@ -83,7 +83,7 @@ public:
|
|||||||
bool GetExtensions(wxArrayString& extensions);
|
bool GetExtensions(wxArrayString& extensions);
|
||||||
bool GetMimeType(wxString *mimeType) const;
|
bool GetMimeType(wxString *mimeType) const;
|
||||||
bool GetMimeTypes(wxArrayString& mimeTypes) const;
|
bool GetMimeTypes(wxArrayString& mimeTypes) const;
|
||||||
bool GetIcon(wxIcon *icon, wxString *sCommand = NULL, int *iIndex = NULL) const;
|
bool GetIcon(wxIconLocation *iconLoc) const;
|
||||||
bool GetDescription(wxString *desc) const;
|
bool GetDescription(wxString *desc) const;
|
||||||
bool GetOpenCommand(wxString *openCmd,
|
bool GetOpenCommand(wxString *openCmd,
|
||||||
const wxFileType::MessageParameters&) const
|
const wxFileType::MessageParameters&) const
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
|
|
||||||
// fwd decls
|
// fwd decls
|
||||||
class WXDLLEXPORT wxIcon;
|
class WXDLLEXPORT wxIconLocation;
|
||||||
class WXDLLEXPORT wxFileTypeImpl;
|
class WXDLLEXPORT wxFileTypeImpl;
|
||||||
class WXDLLEXPORT wxMimeTypesManagerImpl;
|
class WXDLLEXPORT wxMimeTypesManagerImpl;
|
||||||
|
|
||||||
@@ -46,9 +46,6 @@ enum wxMailcapStyle
|
|||||||
wxMAILCAP_ALL = 15
|
wxMAILCAP_ALL = 15
|
||||||
};
|
};
|
||||||
|
|
||||||
#define wxICON_LARGE 0
|
|
||||||
#define wxICON_SMALL 1
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: would it be more convenient to have this class?
|
TODO: would it be more convenient to have this class?
|
||||||
|
|
||||||
@@ -212,13 +209,8 @@ public:
|
|||||||
// fill passed in array with all extensions associated with this file
|
// fill passed in array with all extensions associated with this file
|
||||||
// type
|
// type
|
||||||
bool GetExtensions(wxArrayString& extensions);
|
bool GetExtensions(wxArrayString& extensions);
|
||||||
// get the icon corresponding to this file type, the name of the file
|
// get the icon corresponding to this file type and of the given size
|
||||||
// where the icon resides is return in iconfile if !NULL and its index
|
bool GetIcon(wxIconLocation *iconloc) const;
|
||||||
// in this file (Win-only) is in iconIndex
|
|
||||||
bool GetIcon(wxIcon *icon,
|
|
||||||
wxString *iconFile = NULL,
|
|
||||||
int *iconIndex = NULL,
|
|
||||||
int iconSize = wxICON_LARGE) const;
|
|
||||||
// get a brief file type description ("*.txt" => "text document")
|
// get a brief file type description ("*.txt" => "text document")
|
||||||
bool GetDescription(wxString *desc) const;
|
bool GetDescription(wxString *desc) const;
|
||||||
|
|
||||||
|
@@ -44,8 +44,7 @@ public:
|
|||||||
bool GetExtensions(wxArrayString& extensions);
|
bool GetExtensions(wxArrayString& extensions);
|
||||||
bool GetMimeType(wxString *mimeType) const;
|
bool GetMimeType(wxString *mimeType) const;
|
||||||
bool GetMimeTypes(wxArrayString& mimeTypes) const;
|
bool GetMimeTypes(wxArrayString& mimeTypes) const;
|
||||||
bool GetIcon(wxIcon *icon, wxString *sCommand = NULL, int *iIndex = NULL,
|
bool GetIcon(wxIconLocation *iconLoc) const;
|
||||||
int iconSize = wxICON_LARGE) const;
|
|
||||||
bool GetDescription(wxString *desc) const;
|
bool GetDescription(wxString *desc) const;
|
||||||
bool GetOpenCommand(wxString *openCmd,
|
bool GetOpenCommand(wxString *openCmd,
|
||||||
const wxFileType::MessageParameters& params) const;
|
const wxFileType::MessageParameters& params) const;
|
||||||
|
@@ -177,8 +177,7 @@ public:
|
|||||||
bool GetMimeType(wxString *mimeType) const
|
bool GetMimeType(wxString *mimeType) const
|
||||||
{ *mimeType = m_manager->m_aTypes[m_index[0]]; return TRUE; }
|
{ *mimeType = m_manager->m_aTypes[m_index[0]]; return TRUE; }
|
||||||
bool GetMimeTypes(wxArrayString& mimeTypes) const;
|
bool GetMimeTypes(wxArrayString& mimeTypes) const;
|
||||||
bool GetIcon(wxIcon *icon, wxString *iconFile = NULL,
|
bool GetIcon(wxIconLocation *iconLoc) const;
|
||||||
int *iconIndex = NULL) const;
|
|
||||||
|
|
||||||
bool GetDescription(wxString *desc) const
|
bool GetDescription(wxString *desc) const
|
||||||
{ *desc = m_manager->m_aDescriptions[m_index[0]]; return TRUE; }
|
{ *desc = m_manager->m_aDescriptions[m_index[0]]; return TRUE; }
|
||||||
|
@@ -39,13 +39,11 @@
|
|||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#if wxUSE_GUI
|
|
||||||
#include "wx/icon.h"
|
|
||||||
#endif
|
|
||||||
#endif //WX_PRECOMP
|
#endif //WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/file.h"
|
#include "wx/file.h"
|
||||||
|
#include "wx/iconloc.h"
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
#include "wx/confbase.h"
|
#include "wx/confbase.h"
|
||||||
@@ -269,36 +267,22 @@ bool wxFileType::GetMimeTypes(wxArrayString& mimeTypes) const
|
|||||||
return m_impl->GetMimeTypes(mimeTypes);
|
return m_impl->GetMimeTypes(mimeTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileType::GetIcon(wxIcon *icon,
|
bool wxFileType::GetIcon(wxIconLocation *iconLoc) const
|
||||||
wxString *iconFile,
|
|
||||||
int *iconIndex,
|
|
||||||
int iconSize) const
|
|
||||||
{
|
{
|
||||||
if ( m_info )
|
if ( m_info )
|
||||||
{
|
{
|
||||||
if ( iconFile )
|
if ( iconLoc )
|
||||||
*iconFile = m_info->GetIconFile();
|
|
||||||
if ( iconIndex )
|
|
||||||
*iconIndex = m_info->GetIconIndex();
|
|
||||||
|
|
||||||
#if wxUSE_GUI
|
|
||||||
if ( icon && !m_info->GetIconFile().empty() )
|
|
||||||
{
|
{
|
||||||
// FIXME: what about the index?
|
iconLoc->SetFileName(m_info->GetIconFile());
|
||||||
icon->LoadFile(m_info->GetIconFile());
|
#ifdef __WXMSW__
|
||||||
|
iconLoc->SetIndex(m_info->GetIconIndex());
|
||||||
|
#endif // __WXMSW__
|
||||||
}
|
}
|
||||||
#endif // wxUSE_GUI
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
return m_impl->GetIcon(iconLoc);
|
||||||
return m_impl->GetIcon(icon, iconFile, iconIndex, iconSize);
|
|
||||||
#elif defined(__UNIX__)
|
|
||||||
return m_impl->GetIcon(icon, iconFile, iconIndex);
|
|
||||||
#else
|
|
||||||
return m_impl->GetIcon(icon);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileType::GetDescription(wxString *desc) const
|
bool wxFileType::GetDescription(wxString *desc) const
|
||||||
|
@@ -92,7 +92,7 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileTypeImpl::GetIcon(wxIcon *icon, wxString *sCommand, int *iIndex) const
|
bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
|
||||||
{
|
{
|
||||||
// no such file type or no value or incorrect icon entry
|
// no such file type or no value or incorrect icon entry
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@@ -92,7 +92,7 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileTypeImpl::GetIcon(wxIcon *icon, wxString *sCommand, int *iIndex) const
|
bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
|
||||||
{
|
{
|
||||||
// no such file type or no value or incorrect icon entry
|
// no such file type or no value or incorrect icon entry
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/file.h"
|
#include "wx/file.h"
|
||||||
|
#include "wx/iconloc.h"
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
#include "wx/confbase.h"
|
#include "wx/confbase.h"
|
||||||
@@ -334,12 +335,8 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wxFileTypeImpl::GetIcon(wxIcon *icon,
|
bool wxFileTypeImpl::GetIcon(wxIconLocation *iconLoc) const
|
||||||
wxString *iconFile,
|
|
||||||
int *iconIndex,
|
|
||||||
int iconSize) const
|
|
||||||
{
|
{
|
||||||
#if wxUSE_GUI
|
|
||||||
wxString strIconKey;
|
wxString strIconKey;
|
||||||
strIconKey << m_strFileType << wxT("\\DefaultIcon");
|
strIconKey << m_strFileType << wxT("\\DefaultIcon");
|
||||||
|
|
||||||
@@ -364,39 +361,18 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon,
|
|||||||
strIndex = wxT("0");
|
strIndex = wxT("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString strExpPath = wxExpandEnvVars(strFullPath);
|
if ( iconLoc )
|
||||||
// here we need C based counting!
|
{
|
||||||
int nIndex = wxAtoi(strIndex);
|
iconLoc->SetFileName(wxExpandEnvVars(strFullPath));
|
||||||
|
|
||||||
HICON hIcon, hIconLarge, hIconSmall;
|
iconLoc->SetIndex(wxAtoi(strIndex));
|
||||||
ExtractIconEx(strExpPath, nIndex, &hIconLarge, &hIconSmall, 1);
|
|
||||||
|
|
||||||
hIcon = (iconSize == wxICON_LARGE) ? hIconLarge : hIconSmall;
|
|
||||||
|
|
||||||
|
|
||||||
switch ( (int)hIcon ) {
|
|
||||||
case 0: // means no icons were found
|
|
||||||
case 1: // means no such file or it wasn't a DLL/EXE/OCX/ICO/...
|
|
||||||
wxLogDebug(wxT("incorrect registry entry '%s': no such icon."),
|
|
||||||
key.GetName().c_str());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
icon->SetHICON((WXHICON)hIcon);
|
|
||||||
wxSize size = wxGetHiconSize(hIcon);
|
|
||||||
icon->SetSize(size);
|
|
||||||
if ( iconIndex )
|
|
||||||
*iconIndex = nIndex;
|
|
||||||
if ( iconFile )
|
|
||||||
*iconFile = strFullPath;
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// no such file type or no value or incorrect icon entry
|
// no such file type or no value or incorrect icon entry
|
||||||
#endif // wxUSE_GUI
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1172,12 +1172,9 @@ wxString wxFileTypeImpl::GetExpandedCommand(const wxString & verb, const wxFileT
|
|||||||
return wxFileType::ExpandCommand(sTmp, params);
|
return wxFileType::ExpandCommand(sTmp, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFileTypeImpl::GetIcon(wxIcon *icon,
|
bool wxFileTypeImpl::GetIcon(wxIconLocation *iconLoc) const
|
||||||
wxString *iconFile /*= NULL */,
|
|
||||||
int *iconIndex /*= NULL*/) const
|
|
||||||
|
|
||||||
{
|
{
|
||||||
#if wxUSE_GUI
|
|
||||||
wxString sTmp;
|
wxString sTmp;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while ( (i < m_index.GetCount() ) && sTmp.empty() )
|
while ( (i < m_index.GetCount() ) && sTmp.empty() )
|
||||||
@@ -1185,25 +1182,15 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon,
|
|||||||
sTmp = m_manager->m_aIcons[m_index[i]];
|
sTmp = m_manager->m_aIcons[m_index[i]];
|
||||||
i ++;
|
i ++;
|
||||||
}
|
}
|
||||||
if ( sTmp.empty () ) return FALSE;
|
if ( sTmp.empty () )
|
||||||
|
|
||||||
wxIcon icn;
|
|
||||||
|
|
||||||
if (sTmp.Right(4).MakeUpper() == _T(".XPM"))
|
|
||||||
icn = wxIcon(sTmp);
|
|
||||||
else
|
|
||||||
icn = wxIcon(sTmp, wxBITMAP_TYPE_ANY);
|
|
||||||
|
|
||||||
if ( icn.Ok() )
|
|
||||||
{
|
|
||||||
*icon = icn;
|
|
||||||
if (iconFile) *iconFile = sTmp;
|
|
||||||
if (iconIndex) *iconIndex = 0;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#endif // wxUSE_GUI
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if ( iconLoc )
|
||||||
|
{
|
||||||
|
iconLoc->SetIconFile(sTmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user