X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a756f210019dd5b51331b7181c816d3882146a30..1a19e369fbce12ce4d8097fc08609a436748a6ed:/src/common/resource.cpp diff --git a/src/common/resource.cpp b/src/common/resource.cpp index a6446d9710..92785ac35a 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -5,8 +5,8 @@ // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -119,23 +119,25 @@ void wxCleanUpResourceSystem() delete[] wxResourceBuffer; } +#if 0 void wxLogWarning(char *msg) { wxMessageBox(msg, _("Warning"), wxOK); } +#endif IMPLEMENT_DYNAMIC_CLASS(wxItemResource, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable) wxItemResource::wxItemResource() { - m_itemType = ""; - m_title = ""; - m_name = ""; + m_itemType = wxT(""); + m_title = wxT(""); + m_name = wxT(""); m_windowStyle = 0; m_x = m_y = m_width = m_height = 0; m_value1 = m_value2 = m_value3 = m_value5 = 0; - m_value4 = ""; + m_value4 = wxT(""); m_windowId = 0; m_exStyle = 0; } @@ -216,7 +218,7 @@ bool wxResourceTable::DeleteResource(const wxString& name) bool wxResourceTable::ParseResourceFile( wxInputStream *is ) { wxExprDatabase db; - int len = is->StreamSize() ; + int len = is->GetSize() ; bool eof = FALSE; while ( is->TellI() + 10 < len) // it's a hack because the streams dont support EOF @@ -230,7 +232,7 @@ bool wxResourceTable::ParseResourceFile(const wxString& filename) { wxExprDatabase db; - FILE *fd = wxFopen(filename, _T("r")); + FILE *fd = wxFopen(filename, wxT("r")); if (!fd) return FALSE; bool eof = FALSE; @@ -335,7 +337,14 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c ((wxItemResource*) childResource)->SetBitmap(bitmap); } if (!bitmap.Ok()) - bitmap.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE); +#if defined(__WXPM__) + // + // OS/2 uses integer id's to access resources, not file name strings + // + bitmap.LoadFile(wxCROSS_BITMAP, wxBITMAP_TYPE_BMP_RESOURCE); +#else + bitmap.LoadFile(wxT("cross_bmp"), wxBITMAP_TYPE_BMP_RESOURCE); +#endif control = new wxBitmapButton(parent, id, bitmap, pos, size, childResource->GetStyle() | wxBU_AUTODRAW, wxDefaultValidator, childResource->GetName()); } @@ -360,7 +369,7 @@ wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* c #ifdef __WXMSW__ // Use a default bitmap if (!bitmap.Ok()) - bitmap.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE); + bitmap.LoadFile(wxT("cross_bmp"), wxBITMAP_TYPE_BMP_RESOURCE); #endif if (bitmap.Ok()) @@ -1484,8 +1493,8 @@ wxFont wxResourceInterpretFontSpec(wxExpr *expr) if (faceNameExpr) faceName = faceNameExpr->StringValue(); - wxFont font(point, family, style, weight, (underline != 0), faceName); - return font; + return *wxTheFontList->FindOrCreateFont(point, family, style, weight, + (underline != 0), faceName); } // Separate file for the remainder of this, for BC++/Win16 @@ -2049,7 +2058,7 @@ wxChar* wxResourceParseWord(wxChar*s, int *i) struct wxResourceBitListStruct { - wxChar *word; + const wxChar *word; long bits; }; @@ -2477,7 +2486,11 @@ wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table } default: { +#if defined(__WXPM__) + return wxNullBitmap; +#else return wxBitmap(name, (wxBitmapType)bitmapType); +#endif } } #ifndef __WXGTK__ @@ -2634,7 +2647,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) } default: { -#ifdef __WXGTK__ +#if defined( __WXGTK__ ) || defined( __WXMOTIF__ ) wxLogWarning(_("Icon resource specification %s not found."), (const wxChar*) resource); break; #else @@ -2724,6 +2737,15 @@ bool wxResourceParseData(const wxString& resource, wxResourceTable *table) return table->ParseResourceData(resource); } +bool wxResourceParseData(const char* resource, wxResourceTable *table) +{ + wxString str(resource, wxConvLibc); + if (!table) + table = wxDefaultResourceTable; + + return table->ParseResourceData(str); +} + bool wxResourceParseFile(const wxString& filename, wxResourceTable *table) { if (!table) @@ -2787,7 +2809,7 @@ bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table) if (!table) table = wxDefaultResourceTable; - FILE *fd = wxFopen(f, _T("r")); + FILE *fd = wxFopen(f, wxT("r")); if (!fd) { return FALSE; @@ -3089,6 +3111,15 @@ bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxR return TRUE; } +bool wxResourceParseString(const wxString& s, wxResourceTable *table) +{ +#if wxUSE_UNICODE + return wxResourceParseString( (char*)s.mb_str().data() ); +#else + return wxResourceParseString( (char*)s.c_str() ); +#endif +} + bool wxResourceParseString(char *s, wxResourceTable *table) { if (!table)