X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/08a092f9f4de6c80a2d43d4072c379ac84e6cc2f..31907d03078c41ac09b2ff36267e980c57410f72:/src/common/resource.cpp?ds=sidebyside diff --git a/src/common/resource.cpp b/src/common/resource.cpp index 6a5dcf6401..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) @@ -3145,33 +3176,37 @@ bool wxWindowBase::LoadFromResource(wxWindow *parent, const wxString& resourceNa int height = resource->GetHeight(); wxString name = resource->GetName(); - if (IsKindOf(CLASSINFO(wxDialog))) + // this is used for loading wxWizard pages from WXR + if ( parent != this ) { - wxDialog *dialogBox = (wxDialog *)this; - long modalStyle = isModal ? wxDIALOG_MODAL : 0; - if (!dialogBox->Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name)) - return FALSE; + if (IsKindOf(CLASSINFO(wxDialog))) + { + wxDialog *dialogBox = (wxDialog *)this; + long modalStyle = isModal ? wxDIALOG_MODAL : 0; + if (!dialogBox->Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name)) + return FALSE; - // Only reset the client size if we know we're not going to do it again below. - if ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == 0) - dialogBox->SetClientSize(width, height); - } - else if (IsKindOf(CLASSINFO(wxPanel))) - { - wxPanel* panel = (wxPanel *)this; - if (!panel->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle | wxTAB_TRAVERSAL, name)) - return FALSE; - } - else - { - if (!((wxWindow *)this)->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) - return FALSE; + // Only reset the client size if we know we're not going to do it again below. + if ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == 0) + dialogBox->SetClientSize(width, height); + } + else if (IsKindOf(CLASSINFO(wxPanel))) + { + wxPanel* panel = (wxPanel *)this; + if (!panel->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle | wxTAB_TRAVERSAL, name)) + return FALSE; + } + else + { + if (!((wxWindow *)this)->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name)) + return FALSE; + } } if ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0) { // No need to do this since it's done in wxPanel or wxDialog constructor. - // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + // SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); } else { @@ -3183,9 +3218,9 @@ bool wxWindowBase::LoadFromResource(wxWindow *parent, const wxString& resourceNa // Should have some kind of font at this point if (!GetFont().Ok()) - SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); if (!GetBackgroundColour().Ok()) - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); // Only when we've created the window and set the font can we set the correct size, // if based on dialog units.