// Licence:
/////////////////////////////////////////////////////////////////////////////
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "configtooldoc.h"
-#endif
-
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#endif
#include "wx/textfile.h"
+#include "wx/txtstrm.h"
#include "wx/wfstream.h"
#include "wx/config.h"
#include "configtooldoc.h"
{
if (!IsModified() && m_savedYet) return true;
- bool ret = (m_documentFile == wxT("") || !m_savedYet) ?
+ bool ret = (m_documentFile.empty() || !m_savedYet) ?
SaveAs() :
OnSaveDocument(m_documentFile);
if ( ret )
//rootItem->InitProperties();
rootItem->GetProperties().AddProperty(
new ctProperty(
- wxT("The item description."),
- wxVariant(wxT(""), wxT("description")),
- wxT("multiline")));
+ wxT("The item description."),
+ wxVariant(wxEmptyString, wxT("description")),
+ wxT("multiline")));
rootItem->SetPropertyString(_T("description"),
_T("<B>This is the top-level configuration item.</B>"));
// 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");
{
wxRemoveFile(backupFilename);
}
-
+
// Copy the old file to the .bak
if (leaveBackup)
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();
/// 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("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
stream << wxT("<settings xmlns=\"http://www.wxwidgets.org/wxs\" version=\"2.5.0.1\">");
- DoSave(m_topItem, stream, 1);
+ DoSave(m_topItem, osFile, 1);
stream << wxT("\n</settings>\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;
indent ++;
- OutputIndentation(stream, indent*2);
+ OutputIndentation(osFile, indent*2);
if (item->IsActive())
stream << wxT("<active>1</active>");
else
stream << wxT("<active>0</active>");
- OutputIndentation(stream, indent*2);
+ OutputIndentation(osFile, indent*2);
if (item->IsEnabled())
stream << wxT("<enabled>1</enabled>");
else
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\"");
stream << wxT(" choices=\"") << choices << wxT("\"");
}
}
-
+
stream << wxT(">");
stream << ctEscapeHTMLCharacters(prop->GetVariant().GetString()) ;
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("</setting>");
return true;
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)
wxString type(wxT("string"));
wxString choices;
wxString editorType(wxT("string"));
- wxString description(wxT(""));
+ wxString description;
childTag->GetAttributeValue(type, wxT("type"));
childTag->GetAttributeValue(type, wxT("editor-type"));
childTag->GetAttributeValue(type, wxT("choices"));
else if (type == wxT("long"))
prop->GetVariant() = wxVariant((long) 0, name);
else
- prop->GetVariant() = wxVariant(wxT(""), name);
+ prop->GetVariant() = wxVariant(wxEmptyString, name);
prop->SetDescription(description);
prop->SetCustom(true);
prop->SetEditorType(editorType);
// 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());
{
str << wxT(" ") << configureCommand;
}
- }
+ }
}
}
#ifdef __WXMSW__
if (makeUnix)
path.Replace(wxT("\\"), wxT("/"));
+#else
+ wxUnusedVar(makeUnix);
#endif
}
return path;
// This will delete the old clipboard contents, if any.
doc->SetClipboardItem(newItem);
-
+
m_parent = m_activeState->GetParent();
m_insertBefore = m_activeState->FindNextSibling();
wxGetApp().GetMainFrame()->GetDocument()->SetTopItem(NULL);
}
*/
-
+
Clear();
}
}
*/
}
-
-