\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
-created and assigned to the {\it icon} parameter. {\it iconFile} is assigned the file name
-that contains the icon and {\it iconIndex} is assigned the index of the icon
-(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).
+If the function returns {\tt true}, the {\tt iconLoc} is filled with the
+location of the icon for this MIME type. A \helpref{wxIcon}{wxicon} may be
+created from {\it iconLoc} later.
+
+{\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
and KDE settings and thus GetIcon's success depends on availability
bool GetExtensions(wxArrayString& extensions);
bool GetMimeType(wxString *mimeType) 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 GetOpenCommand(wxString *openCmd,
const wxFileType::MessageParameters&) const
#include "wx/dynarray.h"
// fwd decls
-class WXDLLEXPORT wxIcon;
+class WXDLLEXPORT wxIconLocation;
class WXDLLEXPORT wxFileTypeImpl;
class WXDLLEXPORT wxMimeTypesManagerImpl;
wxMAILCAP_ALL = 15
};
-#define wxICON_LARGE 0
-#define wxICON_SMALL 1
-
/*
TODO: would it be more convenient to have this class?
// fill passed in array with all extensions associated with this file
// type
bool GetExtensions(wxArrayString& extensions);
- // get the icon corresponding to this file type, the name of the file
- // where the icon resides is return in iconfile if !NULL and its index
- // in this file (Win-only) is in iconIndex
- bool GetIcon(wxIcon *icon,
- wxString *iconFile = NULL,
- int *iconIndex = NULL,
- int iconSize = wxICON_LARGE) const;
+ // get the icon corresponding to this file type and of the given size
+ bool GetIcon(wxIconLocation *iconloc) const;
// get a brief file type description ("*.txt" => "text document")
bool GetDescription(wxString *desc) const;
bool GetExtensions(wxArrayString& extensions);
bool GetMimeType(wxString *mimeType) const;
bool GetMimeTypes(wxArrayString& mimeTypes) const;
- bool GetIcon(wxIcon *icon, wxString *sCommand = NULL, int *iIndex = NULL,
- int iconSize = wxICON_LARGE) const;
+ bool GetIcon(wxIconLocation *iconLoc) const;
bool GetDescription(wxString *desc) const;
bool GetOpenCommand(wxString *openCmd,
const wxFileType::MessageParameters& params) const;
bool GetMimeType(wxString *mimeType) const
{ *mimeType = m_manager->m_aTypes[m_index[0]]; return TRUE; }
bool GetMimeTypes(wxArrayString& mimeTypes) const;
- bool GetIcon(wxIcon *icon, wxString *iconFile = NULL,
- int *iconIndex = NULL) const;
+ bool GetIcon(wxIconLocation *iconLoc) const;
bool GetDescription(wxString *desc) const
{ *desc = m_manager->m_aDescriptions[m_index[0]]; return TRUE; }
#ifndef WX_PRECOMP
#include "wx/string.h"
- #if wxUSE_GUI
- #include "wx/icon.h"
- #endif
#endif //WX_PRECOMP
#include "wx/log.h"
#include "wx/file.h"
+#include "wx/iconloc.h"
#include "wx/intl.h"
#include "wx/dynarray.h"
#include "wx/confbase.h"
return m_impl->GetMimeTypes(mimeTypes);
}
-bool wxFileType::GetIcon(wxIcon *icon,
- wxString *iconFile,
- int *iconIndex,
- int iconSize) const
+bool wxFileType::GetIcon(wxIconLocation *iconLoc) const
{
if ( m_info )
{
- if ( iconFile )
- *iconFile = m_info->GetIconFile();
- if ( iconIndex )
- *iconIndex = m_info->GetIconIndex();
-
-#if wxUSE_GUI
- if ( icon && !m_info->GetIconFile().empty() )
+ if ( iconLoc )
{
- // FIXME: what about the index?
- icon->LoadFile(m_info->GetIconFile());
+ iconLoc->SetFileName(m_info->GetIconFile());
+#ifdef __WXMSW__
+ iconLoc->SetIndex(m_info->GetIconIndex());
+#endif // __WXMSW__
}
-#endif // wxUSE_GUI
return TRUE;
}
-#if defined(__WXMSW__)
- 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
+ return m_impl->GetIcon(iconLoc);
}
bool wxFileType::GetDescription(wxString *desc) const
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
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
return FALSE;
#include "wx/log.h"
#include "wx/file.h"
+#include "wx/iconloc.h"
#include "wx/intl.h"
#include "wx/dynarray.h"
#include "wx/confbase.h"
}
-bool wxFileTypeImpl::GetIcon(wxIcon *icon,
- wxString *iconFile,
- int *iconIndex,
- int iconSize) const
+bool wxFileTypeImpl::GetIcon(wxIconLocation *iconLoc) const
{
-#if wxUSE_GUI
wxString strIconKey;
strIconKey << m_strFileType << wxT("\\DefaultIcon");
strIndex = wxT("0");
}
- wxString strExpPath = wxExpandEnvVars(strFullPath);
- // here we need C based counting!
- int nIndex = wxAtoi(strIndex);
-
- HICON hIcon, hIconLarge, hIconSmall;
- 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;
+ if ( iconLoc )
+ {
+ iconLoc->SetFileName(wxExpandEnvVars(strFullPath));
- default:
- icon->SetHICON((WXHICON)hIcon);
- wxSize size = wxGetHiconSize(hIcon);
- icon->SetSize(size);
- if ( iconIndex )
- *iconIndex = nIndex;
- if ( iconFile )
- *iconFile = strFullPath;
- return TRUE;
+ iconLoc->SetIndex(wxAtoi(strIndex));
}
+
+ return TRUE;
}
}
// no such file type or no value or incorrect icon entry
-#endif // wxUSE_GUI
-
return FALSE;
}
return wxFileType::ExpandCommand(sTmp, params);
}
-bool wxFileTypeImpl::GetIcon(wxIcon *icon,
- wxString *iconFile /*= NULL */,
- int *iconIndex /*= NULL*/) const
+bool wxFileTypeImpl::GetIcon(wxIconLocation *iconLoc) const
{
-#if wxUSE_GUI
wxString sTmp;
size_t i = 0;
while ( (i < m_index.GetCount() ) && sTmp.empty() )
sTmp = m_manager->m_aIcons[m_index[i]];
i ++;
}
- if ( sTmp.empty () ) return FALSE;
-
- wxIcon icn;
-
- if (sTmp.Right(4).MakeUpper() == _T(".XPM"))
- icn = wxIcon(sTmp);
- else
- icn = wxIcon(sTmp, wxBITMAP_TYPE_ANY);
+ if ( sTmp.empty () )
+ return FALSE;
- if ( icn.Ok() )
+ if ( iconLoc )
{
- *icon = icn;
- if (iconFile) *iconFile = sTmp;
- if (iconIndex) *iconIndex = 0;
- return TRUE;
+ iconLoc->SetIconFile(sTmp);
}
-#endif // wxUSE_GUI
- return FALSE;
+ return TRUE;
}