added default icons for binary and unknown filetype
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5501 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -54,36 +54,9 @@
|
|||||||
#include "wx/generic/repview.xpm"
|
#include "wx/generic/repview.xpm"
|
||||||
#include "wx/generic/new_dir.xpm"
|
#include "wx/generic/new_dir.xpm"
|
||||||
#include "wx/generic/dir_up.xpm"
|
#include "wx/generic/dir_up.xpm"
|
||||||
|
#include "wx/generic/folder.xpm"
|
||||||
/* XPM */
|
#include "wx/generic/deffile.xpm"
|
||||||
static char * folder_xpm[] = {
|
#include "wx/generic/exefile.xpm"
|
||||||
/* width height ncolors chars_per_pixel */
|
|
||||||
"16 16 6 1",
|
|
||||||
/* colors */
|
|
||||||
" s None c None",
|
|
||||||
". c #000000",
|
|
||||||
"+ c #c0c0c0",
|
|
||||||
"@ c #808080",
|
|
||||||
"# c #ffff00",
|
|
||||||
"$ c #ffffff",
|
|
||||||
/* pixels */
|
|
||||||
" ",
|
|
||||||
" @@@@@ ",
|
|
||||||
" @#+#+#@ ",
|
|
||||||
" @#+#+#+#@@@@@@ ",
|
|
||||||
" @$$$$$$$$$$$$@.",
|
|
||||||
" @$#+#+#+#+#+#@.",
|
|
||||||
" @$+#+#+#+#+#+@.",
|
|
||||||
" @$#+#+#+#+#+#@.",
|
|
||||||
" @$+#+#+#+#+#+@.",
|
|
||||||
" @$#+#+#+#+#+#@.",
|
|
||||||
" @$+#+#+#+#+#+@.",
|
|
||||||
" @$#+#+#+#+#+#@.",
|
|
||||||
" @@@@@@@@@@@@@@.",
|
|
||||||
" ..............",
|
|
||||||
" ",
|
|
||||||
" "};
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// private classes - icons list management
|
// private classes - icons list management
|
||||||
@@ -104,7 +77,7 @@ class wxFileIconsTable
|
|||||||
|
|
||||||
wxFileIconsTable();
|
wxFileIconsTable();
|
||||||
|
|
||||||
int GetIconID(const wxString& extension);
|
int GetIconID(const wxString& extension, const wxString& mime = wxEmptyString);
|
||||||
wxImageList *GetImageList() { return &m_ImageList; }
|
wxImageList *GetImageList() { return &m_ImageList; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -115,6 +88,9 @@ class wxFileIconsTable
|
|||||||
|
|
||||||
static wxFileIconsTable *g_IconsTable = NULL;
|
static wxFileIconsTable *g_IconsTable = NULL;
|
||||||
|
|
||||||
|
#define FI_FOLDER 0
|
||||||
|
#define FI_UNKNOWN 1
|
||||||
|
#define FI_EXECUTABLE 2
|
||||||
|
|
||||||
wxFileIconsTable::wxFileIconsTable() :
|
wxFileIconsTable::wxFileIconsTable() :
|
||||||
m_ImageList(16, 16),
|
m_ImageList(16, 16),
|
||||||
@@ -122,7 +98,17 @@ wxFileIconsTable::wxFileIconsTable() :
|
|||||||
m_Mime()
|
m_Mime()
|
||||||
{
|
{
|
||||||
m_HashTable.DeleteContents(TRUE);
|
m_HashTable.DeleteContents(TRUE);
|
||||||
m_ImageList.Add(wxBitmap(folder_xpm));
|
m_ImageList.Add(wxBitmap(folder_xpm)); // FI_FOLDER
|
||||||
|
m_ImageList.Add(wxBitmap(deffile_xpm)); // FI_UNKNOWN
|
||||||
|
if (GetIconID(wxEmptyString, _T("application/x-executable")) == FI_UNKNOWN)
|
||||||
|
{ // FI_EXECUTABLE
|
||||||
|
m_ImageList.Add(wxBitmap(exefile_xpm));
|
||||||
|
m_HashTable.Delete(_T("exe"));
|
||||||
|
m_HashTable.Put(_T("exe"), new wxFileIconEntry(FI_EXECUTABLE));
|
||||||
|
}
|
||||||
|
/* else put into list by GetIconID
|
||||||
|
(KDE defines application/x-executable for *.exe and has nice icon)
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -131,7 +117,9 @@ static wxBitmap CreateAntialiasedBitmap(const wxImage& img)
|
|||||||
{
|
{
|
||||||
wxImage small(16, 16);
|
wxImage small(16, 16);
|
||||||
unsigned char *p1, *p2, *ps;
|
unsigned char *p1, *p2, *ps;
|
||||||
unsigned char mr = img.GetMaskRed(), mg = img.GetMaskGreen(), mb = img.GetMaskBlue();
|
unsigned char mr = img.GetMaskRed(),
|
||||||
|
mg = img.GetMaskGreen(),
|
||||||
|
mb = img.GetMaskBlue();
|
||||||
|
|
||||||
unsigned x, y;
|
unsigned x, y;
|
||||||
unsigned sr, sg, sb, smask;
|
unsigned sr, sg, sb, smask;
|
||||||
@@ -174,17 +162,21 @@ static wxBitmap CreateAntialiasedBitmap(const wxImage& img)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wxFileIconsTable::GetIconID(const wxString& extension)
|
int wxFileIconsTable::GetIconID(const wxString& extension, const wxString& mime)
|
||||||
{
|
{
|
||||||
|
if (!extension.IsEmpty())
|
||||||
|
{
|
||||||
wxFileIconEntry *entry = (wxFileIconEntry*) m_HashTable.Get(extension);
|
wxFileIconEntry *entry = (wxFileIconEntry*) m_HashTable.Get(extension);
|
||||||
|
|
||||||
if (entry) return (entry -> id);
|
if (entry) return (entry -> id);
|
||||||
|
}
|
||||||
|
|
||||||
wxFileType *ft = m_Mime.GetFileTypeFromExtension(extension);
|
wxFileType *ft = (mime.IsEmpty()) ?
|
||||||
|
m_Mime.GetFileTypeFromExtension(extension) :
|
||||||
|
m_Mime.GetFileTypeFromMimeType(mime);
|
||||||
wxIcon ic;
|
wxIcon ic;
|
||||||
if (ft == NULL || (!ft -> GetIcon(&ic)))
|
if (ft == NULL || (!ft -> GetIcon(&ic)))
|
||||||
{
|
{
|
||||||
int newid = GetIconID(wxT("txt"));
|
int newid = FI_UNKNOWN;
|
||||||
m_HashTable.Put(extension, new wxFileIconEntry(newid));
|
m_HashTable.Put(extension, new wxFileIconEntry(newid));
|
||||||
return newid;
|
return newid;
|
||||||
}
|
}
|
||||||
@@ -383,11 +375,13 @@ void wxFileData::MakeItem( wxListItem &item )
|
|||||||
if (IsDir()) item.SetTextColour(*wxBLUE);
|
if (IsDir()) item.SetTextColour(*wxBLUE);
|
||||||
|
|
||||||
if (IsDir())
|
if (IsDir())
|
||||||
item.m_image = 0;
|
item.m_image = FI_FOLDER;
|
||||||
|
else if (IsExe())
|
||||||
|
item.m_image = FI_EXECUTABLE;
|
||||||
else if (m_name.Find(wxT('.')) != wxNOT_FOUND)
|
else if (m_name.Find(wxT('.')) != wxNOT_FOUND)
|
||||||
item.m_image = g_IconsTable -> GetIconID(m_name.AfterLast(wxT('.')));
|
item.m_image = g_IconsTable -> GetIconID(m_name.AfterLast(wxT('.')));
|
||||||
else
|
else
|
||||||
item.m_image = -1;
|
item.m_image = FI_UNKNOWN;
|
||||||
|
|
||||||
if (IsLink())
|
if (IsLink())
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user