+// Is this window identifier symbol in use?
+// Let's assume that we can't have 2 names for the same integer id.
+// Therefore we can tell by the integer id whether the symbol is
+// in use.
+bool wxResourceManager::IsSymbolUsed(wxItemResource* thisResource, wxWindowID id)
+{
+ m_resourceTable.BeginFind();
+ wxNode *node;
+ while ((node = m_resourceTable.Next()))
+ {
+ wxItemResource *res = (wxItemResource *)node->Data();
+
+ wxString resType(res->GetType());
+ if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel")
+ {
+ if ((res != thisResource) && (res->GetId() == id))
+ return TRUE;
+
+ wxNode *node1 = res->GetChildren().First();
+ while (node1)
+ {
+ wxItemResource *child = (wxItemResource *)node1->Data();
+ if ((child != thisResource) && (child->GetId() == id))
+ return TRUE;
+ node1 = node1->Next();
+ }
+ }
+ }
+ return FALSE;
+}
+
+// Is this window identifier compatible with the given name? (i.e.
+// does it already exist under a different name)
+bool wxResourceManager::IsIdentifierOK(const wxString& name, wxWindowID id)
+{
+ if (m_symbolTable.SymbolExists(name))
+ {
+ int foundId = m_symbolTable.GetIdForSymbol(name);
+ if (foundId != id)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+// Change all integer ids that match oldId, to newId.
+// This is necessary if an id is changed for one resource - all resources
+// must be changed.
+void wxResourceManager::ChangeIds(int oldId, int newId)
+{
+ m_resourceTable.BeginFind();
+ wxNode *node;
+ while ((node = m_resourceTable.Next()))
+ {
+ wxItemResource *res = (wxItemResource *)node->Data();
+
+ wxString resType(res->GetType());
+ if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel")
+ {
+ if (res->GetId() == oldId)
+ res->SetId(newId);
+
+ wxNode *node1 = res->GetChildren().First();
+ while (node1)
+ {
+ wxItemResource *child = (wxItemResource *)node1->Data();
+ if (child->GetId() == oldId)
+ child->SetId(newId);
+
+ node1 = node1->Next();
+ }
+ }
+ }
+}
+
+// If any resource ids were missing (or their symbol was missing),
+// repair them i.e. give them new ids. Returns TRUE if any resource
+// needed repairing.
+bool wxResourceManager::RepairResourceIds()
+{
+ bool repaired = FALSE;
+
+ m_resourceTable.BeginFind();
+ wxNode *node;
+ while ((node = m_resourceTable.Next()))
+ {
+ wxItemResource *res = (wxItemResource *)node->Data();
+ wxString resType(res->GetType());
+ if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel")
+ {
+
+ if ( (res->GetId() == 0) || ((res->GetId() > 0) && !m_symbolTable.IdExists(res->GetId())) )
+ {
+ wxString newSymbolName;
+ int newId = GenerateWindowId("ID_DIALOG", newSymbolName) ;
+
+ if (res->GetId() == 0)
+ {
+ res->SetId(newId);
+ m_symbolTable.AddSymbol(newSymbolName, newId);
+ }
+ else
+ {
+ m_symbolTable.AddSymbol(newSymbolName, res->GetId());
+ }
+
+ repaired = TRUE;
+ }
+
+ wxNode *node1 = res->GetChildren().First();
+ while (node1)
+ {
+ wxItemResource *child = (wxItemResource *)node1->Data();
+
+ if ( (child->GetId() == 0) || ((child->GetId() > 0) && !m_symbolTable.IdExists(child->GetId())) )
+ {
+ wxString newSymbolName;
+ int newId = GenerateWindowId("ID_CONTROL", newSymbolName) ;
+
+ if (child->GetId() == 0)
+ {
+ child->SetId(newId);
+ m_symbolTable.AddSymbol(newSymbolName, newId);
+ }
+ else
+ {
+ m_symbolTable.AddSymbol(newSymbolName, child->GetId());
+ }
+
+ repaired = TRUE;
+ }
+
+ node1 = node1->Next();
+ }
+ }
+ }
+ return repaired;
+}
+
+