initial checkin of C++ port (in progress)

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@2 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-01 14:08:07 +00:00
parent f5c0071da6
commit ddfb1a5089
56 changed files with 8781 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <gui/util.hpp>
#include <util/error.hpp>
#include <wx/mstream.h>
// ----------------------------------------------------------------------------- : DC related
/// Fill a DC with a single color
void clearDC(DC& dc, const wxBrush& brush) {
wxSize size = dc.GetSize();
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(brush);
dc.DrawRectangle(0, 0, size.GetWidth(), size.GetHeight());
}
// ----------------------------------------------------------------------------- : Image related
Image loadResourceImage(String name) {
#ifdef __WXMSW__
// Load resource
// based on wxLoadUserResource
// The image can be in an IMAGE resource, in any file format
HRSRC hResource = ::FindResource(wxGetInstance(), name, _("IMAGE"));
if ( hResource == 0 ) throw InternalError(_("Resource not found: ") + name);
HGLOBAL hData = ::LoadResource(wxGetInstance(), hResource);
if ( hData == 0 ) throw InternalError(_("Resource not an image: ") + name);
char* data = (char *)::LockResource(hData);
if ( !data ) throw InternalError(_("Resource cannot be locked: ") + name);
int len = ::SizeofResource(wxGetInstance(), hResource);
wxMemoryInputStream stream(data, len);
return wxImage(stream);
#endif
}