-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <pwd.h>
-#include <grp.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "wx/generic/home.xpm"
-#include "wx/generic/listview.xpm"
-#include "wx/generic/repview.xpm"
-#include "wx/generic/new_dir.xpm"
-#include "wx/generic/dir_up.xpm"
-
-/* XPM */
-static char * folder_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
-// ----------------------------------------------------------------------------
-
-class wxFileIconEntry : public wxObject
-{
- public:
- wxFileIconEntry(int i) { id = i; }
-
- int id;
-};
-
-
-class wxFileIconsTable
-{
- public:
-
- wxFileIconsTable();
-
- int GetIconID(const wxString& extension);
- wxImageList *GetImageList() { return &m_ImageList; }
-
- protected:
- wxImageList m_ImageList;
- wxHashTable m_HashTable;
- wxMimeTypesManager m_Mime;
-};
-
-static wxFileIconsTable *g_IconsTable = NULL;
-
-
-wxFileIconsTable::wxFileIconsTable() :
- m_ImageList(16, 16),
- m_HashTable(wxKEY_STRING),
- m_Mime()
-{
- m_HashTable.DeleteContents(TRUE);
- m_ImageList.Add(wxBitmap(folder_xpm));
-}
-
-
-
-static wxBitmap CreateAntialiasedBitmap(const wxImage& img)
-{
- wxImage small(16, 16);
- unsigned char *p1, *p2, *ps;
- unsigned char mr = img.GetMaskRed(), mg = img.GetMaskGreen(), mb = img.GetMaskBlue();
-
- unsigned x, y;
- unsigned sr, sg, sb, smask;
-
- p1 = img.GetData(), p2 = img.GetData() + 3 * 32, ps = small.GetData();
- small.SetMaskColour(mr, mr, mr);
-
- for (y = 0; y < 16; y++)
- {
- for (x = 0; x < 16; x++)
- {
- sr = sg = sb = smask = 0;
- if (p1[0] != mr || p1[1] != mg || p1[2] != mb)
- sr += p1[0], sg += p1[1], sb += p1[2];
- else smask++;
- p1 += 3;
- if (p1[0] != mr || p1[1] != mg || p1[2] != mb)
- sr += p1[0], sg += p1[1], sb += p1[2];
- else smask++;
- p1 += 3;
- if (p2[0] != mr || p2[1] != mg || p2[2] != mb)
- sr += p2[0], sg += p2[1], sb += p2[2];
- else smask++;
- p2 += 3;
- if (p2[0] != mr || p2[1] != mg || p2[2] != mb)
- sr += p2[0], sg += p2[1], sb += p2[2];
- else smask++;
- p2 += 3;
-
- if (smask > 2)
- ps[0] = ps[1] = ps[2] = mr;
- else
- ps[0] = sr >> 2, ps[1] = sg >> 2, ps[2] = sb >> 2;
- ps += 3;
- }
- p1 += 32 * 3, p2 += 32 * 3;
- }
-
- return small.ConvertToBitmap();
-}
-
-
-int wxFileIconsTable::GetIconID(const wxString& extension)
-{
- wxFileIconEntry *entry = (wxFileIconEntry*) m_HashTable.Get(extension);
-
- if (entry) return (entry -> id);
-
- wxFileType *ft = m_Mime.GetFileTypeFromExtension(extension);
- wxIcon ic;
- if (ft == NULL || (!ft -> GetIcon(&ic)))
- {
- int newid = GetIconID(wxT("txt"));
- m_HashTable.Put(extension, new wxFileIconEntry(newid));
- return newid;
- }
- wxImage img(ic);
- delete ft;
-
- int id = m_ImageList.GetImageCount();
- if (img.GetWidth() == 16 && img.GetHeight() == 16)
- m_ImageList.Add(img.ConvertToBitmap());
- else
- {
- if (img.GetWidth() != 32 || img.GetHeight() != 32)
- img.Rescale(32, 32);
- m_ImageList.Add(CreateAntialiasedBitmap(img));
- }
- m_HashTable.Put(extension, new wxFileIconEntry(id));
- return id;
-}
-
-
-
-// ----------------------------------------------------------------------------
-// private functions
-// ----------------------------------------------------------------------------