]> git.saurik.com Git - wxWidgets.git/commitdiff
GetIcon() returns wxIconLocation, not wxIcon, now
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 23 Jun 2003 13:49:24 +0000 (13:49 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 23 Jun 2003 13:49:24 +0000 (13:49 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21316 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/filetype.tex
include/wx/mac/mimetype.h
include/wx/mimetype.h
include/wx/msw/mimetype.h
include/wx/unix/mimetype.h
src/common/mimecmn.cpp
src/mac/carbon/mimetmac.cpp
src/mac/mimetmac.cpp
src/msw/mimetype.cpp
src/unix/mimetype.cpp

index 30d87dd9418f68e55232f1a72fbdd4dec2c23bb8..9cbeb4f35a7585fc3e3fadc5c3ec62f4a12bddd5 100644 (file)
@@ -152,13 +152,16 @@ function in the first place.
 
 \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
index 35e1ba7b9b81673fb2b30ba8d5a5c5e1fdb78ae4..4f71b9e045b40bbcc519241f2f0e19b22c1a4956 100644 (file)
@@ -83,7 +83,7 @@ public:
     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
index ee204f6de5ea57781e8ca39001330ac6f472fdc8..9494e1ad1683e18e8051544ffb22c189eeb2b0bd 100644 (file)
@@ -30,7 +30,7 @@
 #include "wx/dynarray.h"
 
 // fwd decls
-class WXDLLEXPORT wxIcon;
+class WXDLLEXPORT wxIconLocation;
 class WXDLLEXPORT wxFileTypeImpl;
 class WXDLLEXPORT wxMimeTypesManagerImpl;
 
@@ -46,9 +46,6 @@ enum wxMailcapStyle
     wxMAILCAP_ALL = 15
 };
 
-#define wxICON_LARGE 0
-#define wxICON_SMALL 1
-
 /*
     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
         // 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;
 
index 5170b63618e5c81301fd0d5b17df33f908a10830..a9ba9b63be29a4bd45e58da69b5368813af0a24b 100644 (file)
@@ -44,8 +44,7 @@ public:
     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;
index a15f76f8819d76c8a974a18ecdd90173f0fbde8c..3f03cf0483db648f69e626bd9b3d84aabe54c231 100644 (file)
@@ -177,8 +177,7 @@ public:
     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; }
index 9b4f0ff3fabe86d2a0086779313ff306b8ab251a..ec98e8097c923002cc62538dea22fb719b78640b 100644 (file)
 
 #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"
@@ -269,36 +267,22 @@ bool wxFileType::GetMimeTypes(wxArrayString& mimeTypes) const
     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
index 296c7a81baebad9a1b5b0f6a37569c63055fe88b..1ea83612c2d1fa9c56bf28e6c11295f07d62e609 100644 (file)
@@ -92,7 +92,7 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) 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;
index 296c7a81baebad9a1b5b0f6a37569c63055fe88b..1ea83612c2d1fa9c56bf28e6c11295f07d62e609 100644 (file)
@@ -92,7 +92,7 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) 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;
index 6f488946c587ddfc4528c1782709b25688188f7e..8e663b816b33fb4f96da391ed8341ee0640246b4 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "wx/log.h"
 #include "wx/file.h"
+#include "wx/iconloc.h"
 #include "wx/intl.h"
 #include "wx/dynarray.h"
 #include "wx/confbase.h"
@@ -334,12 +335,8 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
 }
 
 
-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");
 
@@ -364,39 +361,18 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon,
                 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;
 }
 
index 5f6157c61e63052cf71ae0014208e6cbe4ccf501..0d1b83011c5ee50e65b9f78894fb318bac4c7918 100644 (file)
@@ -1172,12 +1172,9 @@ wxString wxFileTypeImpl::GetExpandedCommand(const wxString & verb, const wxFileT
     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() )
@@ -1185,25 +1182,15 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon,
         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;
 }