X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/78d14f80e9a72041ede52c30d912ec5cef21b1b3..81f256328c32766ebf9fca0a97b03bb53e24bc6b:/src/xrc/xmlres.cpp diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 6e59b5aa9e..86c25e8d0c 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: xmlres.cpp -// Purpose: XML resources +// Purpose: XRC resources // Author: Vaclav Slavik // Created: 2000/03/05 // RCS-ID: $Id$ @@ -83,8 +83,8 @@ bool wxXmlResource::Load(const wxString& filemask) while (!!fnd) { #if wxUSE_FILESYSTEM - if (filemask.Lower().Matches("*.zip") || - filemask.Lower().Matches("*.rsc")) + if (filemask.Lower().Matches(wxT("*.zip")) || + filemask.Lower().Matches(wxT("*.rsc"))) { rt = rt && Load(fnd + wxT("#zip:*.xmb")); rt = rt && Load(fnd + wxT("#zip:*.xrc")); @@ -210,7 +210,7 @@ bool wxXmlResource::AttachUnknownControl(const wxString& name, } -void wxXmlResource::ProcessPlatformProperty(wxXmlNode *node) +static void ProcessPlatformProperty(wxXmlNode *node) { wxString s; bool isok; @@ -245,14 +245,17 @@ void wxXmlResource::ProcessPlatformProperty(wxXmlNode *node) } if (isok) + { ProcessPlatformProperty(c); + c = c->GetNext(); + } else { node->RemoveChild(c); + wxXmlNode *c2 = c->GetNext(); delete c; + c = c2; } - - c = c->GetNext(); } } @@ -307,7 +310,7 @@ void wxXmlResource::UpdateResources() } else if (m_data[i].Doc->GetRoot()->GetName() != wxT("resource")) { - wxLogError(_("Invalid XML resource '%s': doesn't have root node 'resource'."), m_data[i].File.c_str()); + wxLogError(_("Invalid XRC resource '%s': doesn't have root node 'resource'."), m_data[i].File.c_str()); wxDELETE(m_data[i].Doc); } else @@ -365,7 +368,7 @@ wxXmlNode *wxXmlResource::FindResource(const wxString& name, const wxString& cla } } - wxLogError(_("XML resource '%s' (class '%s') not found!"), + wxLogError(_("XRC resource '%s' (class '%s') not found!"), name.c_str(), classname.c_str()); return NULL; } @@ -496,7 +499,7 @@ wxString wxXmlResourceHandler::GetText(const wxString& param) const wxChar *dt; wxChar amp_char; - // VS: First version of XML resources used $ instead of & (which is illegal in XML), + // VS: First version of XRC resources used $ instead of & (which is illegal in XML), // but later I realized that '_' fits this purpose much better (because // &File means "File with F underlined"). if (m_resource->CompareVersion(2,3,0,1) < 0) @@ -569,7 +572,7 @@ int wxXmlResourceHandler::GetID() stdID(wxID_DEFAULT); stdID(wxID_MORE); stdID(wxID_SETUP); stdID(wxID_RESET); stdID(wxID_HELP_CONTEXT); #undef stdID - else return XMLID(sid.c_str()); + else return wxXmlResource::GetXMLID(sid); } @@ -598,7 +601,7 @@ wxColour wxXmlResourceHandler::GetColour(const wxString& param) if (v.Length() != 7 || v[0u] != wxT('#') || wxSscanf(v.c_str(), wxT("#%lX"), &tmp) != 1) { - wxLogError(_("XML resource: Incorrect colour specification '%s' for property '%s'."), + wxLogError(_("XRC resource: Incorrect colour specification '%s' for property '%s'."), v.c_str(), param.c_str()); return wxNullColour; } @@ -618,7 +621,7 @@ wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, wxSize size) wxFSFile *fsfile = GetCurFileSystem().OpenFile(name); if (fsfile == NULL) { - wxLogError(_("XML resource: Cannot create bitmap from '%s'."), param.mb_str()); + wxLogError(_("XRC resource: Cannot create bitmap from '%s'."), param.c_str()); return wxNullBitmap; } wxImage img(*(fsfile->GetStream())); @@ -628,7 +631,7 @@ wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, wxSize size) #endif if (!img.Ok()) { - wxLogError(_("XML resource: Cannot create bitmap from '%s'."), param.mb_str()); + wxLogError(_("XRC resource: Cannot create bitmap from '%s'."), param.c_str()); return wxNullBitmap; } if (!(size == wxDefaultSize)) img.Rescale(size.x, size.y); @@ -708,7 +711,7 @@ wxSize wxXmlResourceHandler::GetSize(const wxString& param) if (!s.BeforeFirst(wxT(',')).ToLong(&sx) || !s.AfterLast(wxT(',')).ToLong(&sy)) { - wxLogError(_("Cannot parse coordinates from '%s'."), s.mb_str()); + wxLogError(_("Cannot parse coordinates from '%s'."), s.c_str()); return wxDefaultSize; } @@ -749,7 +752,7 @@ wxCoord wxXmlResourceHandler::GetDimension(const wxString& param, wxCoord defaul if (!s.ToLong(&sx)) { - wxLogError(_("Cannot parse dimension from '%s'."), s.mb_str()); + wxLogError(_("Cannot parse dimension from '%s'."), s.c_str()); return defaultv; } @@ -775,7 +778,7 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param) wxXmlNode *font_node = GetParamNode(param); if (font_node == NULL) { - wxLogError(_("Cannot find font node '%s'."), param.mb_str()); + wxLogError(_("Cannot find font node '%s'."), param.c_str()); return wxNullFont; } @@ -805,8 +808,10 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param) wxString encoding = GetParamValue(wxT("encoding")); wxFontMapper mapper; wxFontEncoding enc = wxFONTENCODING_DEFAULT; - if (!encoding.IsEmpty()) enc = mapper.CharsetToEncoding(encoding); - if (enc == wxFONTENCODING_SYSTEM) enc = wxFONTENCODING_SYSTEM; + if (!encoding.IsEmpty()) + enc = mapper.CharsetToEncoding(encoding); + if (enc == wxFONTENCODING_SYSTEM) + enc = wxFONTENCODING_DEFAULT; wxString faces = GetParamValue(wxT("face")); wxString facename = wxEmptyString; @@ -904,26 +909,26 @@ void wxXmlResourceHandler::CreateChildrenPrivately(wxObject *parent, wxXmlNode * struct XMLID_record { int id; - char *key; + wxChar *key; XMLID_record *next; }; static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL}; -/*static*/ int wxXmlResource::GetXMLID(const char *str_id) +/*static*/ int wxXmlResource::GetXMLID(const wxChar *str_id) { static int XMLID_LastID = wxID_HIGHEST; int index = 0; - for (const char *c = str_id; *c != '\0'; c++) index += (int)*c; + for (const wxChar *c = str_id; *c != wxT('\0'); c++) index += (int)*c; index %= XMLID_TABLE_SIZE; XMLID_record *oldrec = NULL; int matchcnt = 0; for (XMLID_record *rec = XMLID_Records[index]; rec; rec = rec->next) { - if (strcmp(rec->key, str_id) == 0) + if (wxStrcmp(rec->key, str_id) == 0) { return rec->id; } @@ -935,7 +940,7 @@ static XMLID_record *XMLID_Records[XMLID_TABLE_SIZE] = {NULL}; &XMLID_Records[index] : &oldrec->next; *rec_var = new XMLID_record; (*rec_var)->id = ++XMLID_LastID; - (*rec_var)->key = strdup(str_id); + (*rec_var)->key = wxStrdup(str_id); (*rec_var)->next = NULL; return (*rec_var)->id; @@ -947,7 +952,7 @@ static void CleanXMLID_Record(XMLID_record *rec) if (rec) { CleanXMLID_Record(rec->next); - free (rec->key); + free(rec->key); delete rec; } }