X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4fe30bceff0445f540e639d2b6d3977d56b34020..8d3261f9d950b23bcbab74a48572b07c4cfa1c16:/utils/configtool/src/configtooldoc.cpp
diff --git a/utils/configtool/src/configtooldoc.cpp b/utils/configtool/src/configtooldoc.cpp
index 6e7a276271..7754ba4ced 100644
--- a/utils/configtool/src/configtooldoc.cpp
+++ b/utils/configtool/src/configtooldoc.cpp
@@ -13,23 +13,25 @@
#pragma implementation "configtooldoc.h"
#endif
-#include "wx/wx.h"
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
-#include "wx/config.h"
-#include "wx/textfile.h"
+#ifndef WX_PRECOMP
+
#include "wx/process.h"
#include "wx/mimetype.h"
#include "wx/process.h"
-#include "wx/wfstream.h"
-#ifdef __BORLANDC__
-#pragma hdrstop
#endif
+#include "wx/textfile.h"
+#include "wx/txtstrm.h"
+#include "wx/wfstream.h"
+#include "wx/config.h"
#include "configtooldoc.h"
#include "configtoolview.h"
#include "configtree.h"
@@ -174,7 +176,7 @@ bool ctConfigToolDoc::OnSaveDocument(const wxString& filename)
// This is the backup filename
wxString backupFilename(filename);
backupFilename += wxT(".bak");
-
+
// This is the temporary copy of the backup
wxString tempFilename(filename);
tempFilename += wxT(".tmp");
@@ -192,7 +194,7 @@ bool ctConfigToolDoc::OnSaveDocument(const wxString& filename)
{
wxRemoveFile(backupFilename);
}
-
+
// Copy the old file to the .bak
if (leaveBackup)
@@ -211,13 +213,13 @@ bool ctConfigToolDoc::OnSaveDocument(const wxString& filename)
if (wxFileExists(filename))
wxRemoveFile(filename);
}
-
+
// Finally, copy the temporary file to the proper filename
if (!wxRenameFile(tempFilename, filename))
{
wxCopyFile(tempFilename, filename);
wxRemoveFile(tempFilename);
- }
+ }
Modify(false);
((ctConfigToolView*)GetFirstView())->OnChangeFilename();
@@ -261,32 +263,36 @@ bool ctConfigToolDoc::OnOpenDocument(const wxString& filename)
/// Save the settings file
bool ctConfigToolDoc::DoSave(const wxString& filename)
{
- wxFileOutputStream stream(filename);
- if (!stream.Ok())
+ wxFileOutputStream osFile(filename);
+ if (!osFile.Ok())
return false;
+ wxTextOutputStream stream(osFile);
+
stream << wxT("\n");
stream << wxT("");
- DoSave(m_topItem, stream, 1);
+ DoSave(m_topItem, osFile, 1);
stream << wxT("\n\n");
return true;
}
-inline static void OutputIndentation(wxOutputStream& stream, int indent)
+inline static void OutputIndentation(wxOutputStream& osFile, int indent)
{
+ wxTextOutputStream stream(osFile);
wxString str = wxT("\n");
for (int i = 0; i < indent; i++)
- str << wxT(' ') << wxT(' ');
+ str << wxT(" ");
stream << str ;
}
/// Recursive helper function for file saving
-bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& stream, int indent)
+bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& osFile, int indent)
{
- OutputIndentation(stream, indent*2);
+ OutputIndentation(osFile, indent*2);
+ wxTextOutputStream stream(osFile);
wxString name(item->GetName());
wxString s;
@@ -312,25 +318,25 @@ bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& stream, int ind
indent ++;
- OutputIndentation(stream, indent*2);
+ OutputIndentation(osFile, indent*2);
if (item->IsActive())
stream << wxT("1");
else
stream << wxT("0");
- OutputIndentation(stream, indent*2);
+ OutputIndentation(osFile, indent*2);
if (item->IsEnabled())
stream << wxT("1");
else
stream << wxT("0");
// Output properties
- wxNode* node = item->GetProperties().GetList().GetFirst();
+ wxObjectList::compatibility_iterator node = item->GetProperties().GetList().GetFirst();
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
- OutputIndentation(stream, indent*2);
+ OutputIndentation(osFile, indent*2);
stream << wxT("<") << prop->GetName() ;
-
+
if (prop->IsCustom())
{
stream << wxT(" custom=\"true\"");
@@ -344,7 +350,7 @@ bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& stream, int ind
stream << wxT(" choices=\"") << choices << wxT("\"");
}
}
-
+
stream << wxT(">");
stream << ctEscapeHTMLCharacters(prop->GetVariant().GetString()) ;
@@ -358,14 +364,14 @@ bool ctConfigToolDoc::DoSave(ctConfigItem* item, wxOutputStream& stream, int ind
while (node)
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
- DoSave(child, stream, indent);
+ DoSave(child, osFile, indent);
node = node->GetNext();
}
indent --;
- OutputIndentation(stream, indent*2);
+ OutputIndentation(osFile, indent*2);
stream << wxT("");
return true;
@@ -399,10 +405,10 @@ bool ctConfigToolDoc::DoOpen(const wxString& filename)
static bool GetHtmlBoolValue(const wxString& value)
{
- if (value == wxT("true") || value == wxT("TRUE") || value == wxT("1"))
+ if (value.IsSameAs(wxT("true"),false) || value == wxT("1"))
return true;
- else
- return false;
+ else
+ return false;
}
static int GetHtmlIntegerValue(const wxString& value)
@@ -547,11 +553,14 @@ bool ctConfigToolDoc::DoOpen(wxSimpleHtmlTag* tag, ctConfigItem* parent)
/// Clear dependencies
void ctConfigToolDoc::ClearDependencies(ctConfigItem* item)
{
- if (!item)
+ if (!item) {
item = GetTopItem();
+ if (!item)
+ return;
+ }
item->GetDependents().Clear();
- for ( wxNode* node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
+ for ( wxObjectList::compatibility_iterator node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
ClearDependencies(child);
@@ -568,6 +577,9 @@ void ctConfigToolDoc::RefreshDependencies()
/// Refresh dependencies
void ctConfigToolDoc::RefreshDependencies(ctConfigItem* item)
{
+ if (item==NULL)
+ return;
+
wxArrayString requiresArr;
wxString requires = item->GetPropertyString(wxT("requires"));
wxString precludes = item->GetPropertyString(wxT("precludes"));
@@ -595,7 +607,7 @@ void ctConfigToolDoc::RefreshDependencies(ctConfigItem* item)
// parent is a check or radio group.
ctConfigItem* parent = item->GetParent();
if (parent &&
- (parent->GetType() == ctTypeCheckGroup ||
+ (parent->GetType() == ctTypeCheckGroup ||
parent->GetType() == ctTypeRadioGroup))
requiresArr.Add(parent->GetName());
@@ -616,7 +628,7 @@ void ctConfigToolDoc::RefreshDependencies(ctConfigItem* item)
otherItem->GetDependents().Append(item);
}
}
- for ( wxNode* node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
+ for ( wxObjectList::compatibility_iterator node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
RefreshDependencies(child);
@@ -665,7 +677,7 @@ void ctConfigToolDoc::GenerateSetup(ctConfigItem* item, wxString& str)
}
}
- for ( wxNode* node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
+ for ( wxObjectList::compatibility_iterator node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
GenerateSetup(child, str);
@@ -695,7 +707,7 @@ wxString ctConfigToolDoc::GenerateConfigureCommand()
ctConfigItem* platformsFolder = GetTopItem()->FindItem(wxT("Target"));
if (platformsFolder)
{
- for ( wxNode* node = platformsFolder->GetChildren().GetFirst(); node; node = node->GetNext() )
+ for ( wxObjectList::compatibility_iterator node = platformsFolder->GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
if (child->GetType() == ctTypeBoolRadio && child->IsEnabled())
@@ -765,11 +777,11 @@ void ctConfigToolDoc::GenerateConfigureCommand(ctConfigItem* item, wxString& str
{
str << wxT(" ") << configureCommand;
}
- }
+ }
}
}
- for ( wxNode* node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
+ for ( wxObjectList::compatibility_iterator node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfigItem* child = (ctConfigItem*) node->GetData();
GenerateConfigureCommand(child, str);
@@ -784,7 +796,8 @@ wxString ctConfigToolDoc::GetFrameworkDir(bool makeUnix)
{
// Should probably allow other variables
// to be used, and maybe expand variables within m_frameworkDir
- path = wxGetenv(wxT("WXWIN"));
+ wxString pathEnv(wxGetenv(wxT("WXWIN")));
+ path = pathEnv;
#ifdef __WXMSW__
if (makeUnix)
path.Replace(wxT("\\"), wxT("/"));
@@ -828,7 +841,7 @@ ctConfigItem* ctConfigToolDoc::FindNextSibling(ctConfigItem* item)
{
if (item->GetParent())
{
- wxNode* node = item->GetParent()->GetChildren().Member(item);
+ wxObjectList::compatibility_iterator node = item->GetParent()->GetChildren().Member(item);
if (node && node->GetNext())
{
ctConfigItem* nextItem = (ctConfigItem*) node->GetNext()->GetData();
@@ -906,7 +919,7 @@ bool ctConfigCommand::DoAndUndo(bool doCmd)
// This will delete the old clipboard contents, if any.
doc->SetClipboardItem(newItem);
-
+
m_parent = m_activeState->GetParent();
m_insertBefore = m_activeState->FindNextSibling();
@@ -1010,7 +1023,7 @@ bool ctConfigCommand::DoAndUndo(bool doCmd)
// Apply only those that need applying
// (those properties in activeState that are not in propsTemp)
- wxNode* node = m_activeState->GetProperties().GetList().GetFirst();
+ wxObjectList::compatibility_iterator node = m_activeState->GetProperties().GetList().GetFirst();
while (node)
{
ctProperty* prop = (ctProperty*) node->GetData();
@@ -1074,7 +1087,7 @@ ctConfiguration::~ctConfiguration()
wxGetApp().GetMainFrame()->GetDocument()->SetTopItem(NULL);
}
*/
-
+
Clear();
}
@@ -1088,10 +1101,10 @@ void ctConfiguration::operator= (const ctConfiguration& configuration)
/// Clear children
void ctConfiguration::Clear()
{
- wxNode* node = m_children.GetFirst();
+ wxObjectList::compatibility_iterator node = m_children.GetFirst();
while (node)
{
- wxNode* next = node->GetNext();
+ wxObjectList::compatibility_iterator next = node->GetNext();
ctConfiguration* child = (ctConfiguration*) node->GetData();
// This should delete 'node' too, assuming
@@ -1153,7 +1166,7 @@ ctConfiguration* ctConfiguration::FindConfiguration(const wxString& name)
if (GetName() == name)
return this;
- for ( wxNode* node = GetChildren().GetFirst(); node; node = node->GetNext() )
+ for ( wxObjectList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfiguration* child = (ctConfiguration*) node->GetData();
ctConfiguration* found = child->FindConfiguration(name);
@@ -1168,7 +1181,7 @@ ctConfiguration* ctConfiguration::FindNextSibling()
{
if (!GetParent())
return NULL;
- wxNode* node = GetParent()->GetChildren().Member(this);
+ wxObjectList::compatibility_iterator node = GetParent()->GetChildren().Member(this);
if (node && node->GetNext())
{
return (ctConfiguration*) node->GetNext()->GetData();
@@ -1181,7 +1194,7 @@ ctConfiguration* ctConfiguration::FindPreviousSibling()
{
if (!GetParent())
return NULL;
- wxNode* node = GetParent()->GetChildren().Member(this);
+ wxObjectList::compatibility_iterator node = GetParent()->GetChildren().Member(this);
if (node && node->GetPrevious())
{
return (ctConfiguration*) node->GetPrevious()->GetData();
@@ -1194,7 +1207,7 @@ ctConfiguration* ctConfiguration::DeepClone()
{
ctConfiguration* newItem = Clone();
- for ( wxNode* node = GetChildren().GetFirst(); node; node = node->GetNext() )
+ for ( wxObjectList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() )
{
ctConfiguration* child = (ctConfiguration*) node->GetData();
ctConfiguration* newChild = child->DeepClone();
@@ -1242,5 +1255,3 @@ void ctConfiguration::DetachFromTree()
}
*/
}
-
-