+void wxXmlResource::ProcessPlatformProperty(wxXmlNode *node)
+{
+ wxString s;
+ bool isok;
+
+ wxXmlNode *c = node->GetChildren();
+ while (c)
+ {
+ isok = FALSE;
+ if (!c->GetPropVal(_T("platform"), &s))
+ isok = TRUE;
+ else
+ {
+ wxStringTokenizer tkn(s, " |");
+
+ while (tkn.HasMoreTokens())
+ {
+ s = tkn.GetNextToken();
+ if (
+#ifdef __WXMSW__
+ s == wxString(_T("win"))
+#elif defined(__UNIX__)
+ s == wxString(_T("unix"))
+#elif defined(__MAC__)
+ s == wxString(_T("mac"))
+#elif defined(__OS2__)
+ s == wxString(_T("os2"))
+#else
+ FALSE
+#endif
+ ) isok = TRUE;
+ }
+ }
+
+ if (isok)
+ ProcessPlatformProperty(c);
+ else
+ {
+ node->RemoveChild(c);
+ delete c;
+ }
+
+ c = c->GetNext();
+ }
+}
+
+
+
void wxXmlResource::UpdateResources()
{
bool modif;
if (m_Data[i].Doc->GetRoot()->GetName() != _T("resource"))
wxLogError(_("Invalid XML resource '%s': doesn't have root node 'resource'."), m_Data[i].File.c_str());
+ ProcessPlatformProperty(m_Data[i].Doc->GetRoot());
+
# if wxUSE_FILESYSTEM
delete file;
# else
if ( node->GetType() == wxXML_ELEMENT_NODE &&
(!type || node->GetName() == type) &&
node->GetPropVal(wxT("name"), &dummy) &&
- dummy == name &&
- wxXmlResourceHandler::CheckPlatform(node))
+ dummy == name)
return node;
}
wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent, wxObject *instance)
{
- if (!CheckPlatform(node)) return NULL;
-
wxXmlNode *myNode = m_Node;
wxObject *myParent = m_Parent, *myInstance = m_Instance;
wxWindow *myParentAW = m_ParentAsWindow, *myInstanceAW = m_InstanceAsWindow;
}
-
-/*static*/ bool wxXmlResourceHandler::CheckPlatform(wxXmlNode *node)
-{
- wxString s;
- if (!node->GetPropVal(_T("platform"), &s)) return TRUE;
-#ifdef __WXMSW__
- return s == wxString(_T("win"));
-#elif defined(__UNIX__)
- return s == wxString(_T("unix"));
-#elif defined(__MAC__)
- return s == wxString(_T("mac"));
-#elif defined(__OS2__)
- return s == wxString(_T("os2"));
-#else
- wxLogWarning(_("You're running the application on unknown platform, check for platfrom '%s' failed."), s.mb_str());
- return TRUE; // unknown platform
-#endif
-}
-
-
void wxXmlResourceHandler::AddStyle(const wxString& name, int value)
{
m_StyleNames.Add(name);
wxSize wxXmlResourceHandler::GetSize(const wxString& param)
{
wxString s = GetParamValue(param);
- if (!s) s = _T("-1,-1");
+ if (s.IsEmpty()) s = _T("-1,-1");
bool is_dlg;
long sx, sy;
#define XMLID_TABLE_SIZE 1024
+
struct XMLID_record
{
int id;
- const char *key;
+ char *key;
XMLID_record *next;
};
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) return rec->id;
+ if (strcmp(rec->key, str_id) == 0)
+ {
+#ifdef DEBUG_XMLID_HASH
+ printf("XMLID: matched '%s' (%ith item)\n", rec->key, matchcnt);
+#endif
+ return rec->id;
+ }
+ matchcnt++;
oldrec = rec;
}
&XMLID_Records[index] : &oldrec->next;
*rec_var = new XMLID_record;
(*rec_var)->id = ++XMLID_LastID;
- (*rec_var)->key = str_id;
+ (*rec_var)->key = strdup(str_id);
(*rec_var)->next = NULL;
+#ifdef DEBUG_XMLID_HASH
+ printf("XMLID: new key for '%s': %i at %i (%ith item)\n",
+ (*rec_var)->key, (*rec_var)->id, index, matchcnt);
+#endif
return (*rec_var)->id;
}
{
if (rec)
{
+#ifdef DEBUG_XMLID_HASH
+ printf("XMLID: clearing '%s'\n", rec->key);
+#endif
CleanXMLID_Record(rec->next);
+ free (rec->key);
delete rec;
}
}