/////////////////////////////////////////////////////////////////////////////
// Name:        utils.h
// Purpose:     Miscellaneous utilities
// Author:      Alex Thuering
// Created:	23.10.2003
// RCS-ID:      $Id: utils.h,v 1.3 2008/02/24 09:49:38 ntalex Exp $
// Copyright:   (c) Alex Thuering
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef WXVILLALIB_UTILS_H
#define WXVILLALIB_UTILS_H

#include <wx/wx.h>
#include <wx/log.h>
#include <wx/mstream.h>

#if defined(DEBUG) || defined(__WXDEBUG__)
#define wxLogTraceE(msg)\
 wxLogMessage(wxString(_T("%s:%d: trace: ")) + msg, __TFILE__, __LINE__)
#else
#define wxLogTraceE
#endif

wxString wxGetAppPath();
void wxSetAppPath(wxString value);

wxString wxFindDataDirectory(wxString dir);
wxString wxFindDataFile(wxString filename);

#define wxBITMAP_FROM_MEMORY(name) wxGetBitmapFromMemory(name##_png, sizeof(name##_png))

inline wxBitmap wxGetBitmapFromMemory(const unsigned char *data, int length) {
   wxMemoryInputStream is(data, length);
   return wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1);
}

#define wxICON_FROM_MEMORY(name) wxGetIconFromMemory(name##_png, sizeof(name##_png))

inline wxIcon wxGetIconFromMemory(const unsigned char *data, int length) {
   wxIcon icon;
   icon.CopyFromBitmap(wxGetBitmapFromMemory(data, length));
   return icon;
}

#endif // WXVILLALIB_UTILS_H
