+ wxArrayString stringArray;
+
+ wxString filename;
+ bool ok = dir.GetFirst(& filename, wxT("*.wxr"));
+ while (ok)
+ {
+ stringArray.Add(filename);
+
+ ok = dir.GetNext(& filename);
+ }
+
+ // Pop up a progress dialog
+ wxProgressDialog progressDialog(wxT("Converting WXR files"), wxT("Converting files..."));
+
+ size_t i;
+ for (i = 0; i < stringArray.Count(); i++)
+ {
+ progressDialog.Update((int) (100.0 * ((double) i / (double) stringArray.Count())));
+
+ filename = stringArray[i];
+ wxString oldPath = oldWXRPath + wxString(wxFILE_SEP_PATH) + filename;
+ wxString newPath = newWXRPath + wxString(wxFILE_SEP_PATH) + filename;
+
+ DoConvertWXR(oldPath, newPath);
+ }
+
+ wxString msg;
+ msg.Printf(wxT("Dialog Editor inserted %d labels."), gs_LabelInsertionCount);
+ wxMessageBox(msg);
+
+ return TRUE;
+}
+
+bool wxResourceManager::DoConvertWXR(const wxString& oldPath, const wxString& newPath)
+{
+
+ if (!Clear(TRUE, FALSE))
+ return FALSE;
+
+ m_symbolTable.AddStandardSymbols();
+
+ if (!m_resourceTable.ParseResourceFile(oldPath))
+ {
+ wxString msg;
+ msg.Printf(wxT("Could not read file %s"), (const char*) oldPath);
+ wxMessageBox(msg, "Resource file load error", wxOK | wxICON_EXCLAMATION);
+ return FALSE;
+ }
+ m_currentFilename = oldPath;
+
+ //SetFrameTitle(m_currentFilename);
+
+ //UpdateResourceList();
+
+ // Construct include filename from this file
+ m_symbolFilename = m_currentFilename;
+
+ wxStripExtension(m_symbolFilename);
+ m_symbolFilename += wxT(".h");
+
+ if (!m_symbolTable.ReadIncludeFile(m_symbolFilename))
+ {
+ }
+ else
+ {
+ // Set the id counter to the last known id
+ m_symbolIdCounter = m_symbolTable.FindHighestId();
+ }
+
+ // Now check in case some (or all) resources don't have resource ids, or they
+ // don't match the .h file, or something of that nature.
+ bool altered = RepairResourceIds();
+
+ // Do any necessary changes to the resources
+ m_resourceTable.BeginFind();
+ wxNode *node;
+ while ((node = m_resourceTable.Next()))
+ {
+ wxItemResource *res = (wxItemResource *)node->Data();
+ ChangeOldToNewResource(NULL, res);
+ }
+
+ // Change the filename before saving
+
+ m_currentFilename = newPath;
+ m_symbolFilename = m_currentFilename;
+ wxStripExtension(m_symbolFilename);
+ m_symbolFilename += wxT(".h");
+
+ Modify(TRUE);
+
+ Save();
+
+ Clear(TRUE, TRUE);
+
+ return TRUE;
+
+}
+
+bool wxResourceManager::ChangeOldToNewResource(wxItemResource* parent, wxItemResource* res)
+{
+ // Change these according to your needs
+
+ // Change all fonts to use system defaults for fonts, colours etc.
+ static bool s_useSystemDefaultsAlways = FALSE; // TRUE;
+
+ // Increase dialog height by this amount (wxWin 2 uses dialog client size now)
+ static int s_increaseDialogSize = -18;
+
+ // How many points to decrease the font sizes by, since
+ // wxWin 2 fonts are larger in Windows
+ static int s_decreaseFontSize = 3;
+
+ wxString itemType(res->GetType());
+
+ wxFont font = res->GetFont();
+
+ if ((s_decreaseFontSize) > 0 && font.Ok())
+ {
+ wxFont newFont = wxFont(font.GetPointSize() - s_decreaseFontSize,
+ font.GetFamily(), font.GetStyle(), font.GetWeight(),
+ font.GetUnderlined(), font.GetFaceName());
+ res->SetFont(newFont);
+ }
+
+ if (itemType == wxT("wxDialogBox") || itemType == wxT("wxDialog") || itemType == wxT("wxPanel"))
+ {
+ if (itemType == wxT("wxDialogBox"))
+ res->SetType(wxT("wxDialog"));
+
+ if (itemType == wxT("wxDialogBox") || itemType == wxT("wxDialog"))
+ {
+ // Only change the height if it has a caption, i.e. it's going to be
+ // used as a proper dialog and not a panel
+ if (res->GetStyle() & wxCAPTION)
+ res->SetSize(res->GetX(), res->GetY(), res->GetWidth(), res->GetHeight() + s_increaseDialogSize );
+ }
+
+ if (s_useSystemDefaultsAlways)
+ res->SetResourceStyle(res->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS);
+
+ if (res->GetValue1())
+ res->SetStyle(res->GetStyle() | wxDIALOG_MODAL);
+
+ wxNode *node = res->GetChildren().First();
+ while (node)
+ {
+ wxItemResource *child = (wxItemResource *)node->Data();
+
+ ChangeOldToNewResource(res, child);
+ node = node->Next();
+ }
+ }
+ else if (itemType == wxT("wxMessage"))
+ {
+ // Figure out if this is a bitmap or text message
+ if (res->GetValue4().IsEmpty())
+ res->SetType(wxT("wxStaticText"));
+ else
+ res->SetType(wxT("wxStaticBitmap"));
+ }
+ else if (itemType == wxT("wxButton"))
+ {
+ // Figure out if this is a bitmap or text message
+ if (res->GetValue4().IsEmpty())
+ {
+ }
+ else
+ res->SetType(wxT("wxBitmapButton"));
+ }
+ else if (itemType == wxT("wxGroupBox"))
+ {
+ res->SetType(wxT("wxStaticBox"));
+ }
+ else if (itemType == wxT("wxText"))
+ {
+ res->SetType(wxT("wxTextCtrl"));
+ }
+ else if (itemType == wxT("wxMultiText"))
+ {
+ res->SetType(wxT("wxTextCtrl"));
+ res->SetStyle(res->GetStyle() | wxTE_MULTILINE);
+ }
+
+ itemType = res->GetType();
+
+ if (!res->GetTitle().IsEmpty() &&
+ (itemType == wxT("wxTextCtrl") || itemType == wxT("wxChoice") ||
+ itemType == wxT("wxComboBox") || itemType == wxT("wxGauge") ||
+ itemType == wxT("wxListBox")))
+ {
+ // Insert a label control resource, adjusting the size of this
+ // resource accordingly.
+ InsertLabelResource(parent, res);
+ }
+
+ return TRUE;