]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/configtool/src/configtoolview.cpp
Fixes tex2rtf to search for files on current folder too. This is basically to test...
[wxWidgets.git] / utils / configtool / src / configtoolview.cpp
index 4d1760e81b099b97533ff640654d7892c88b94f4..0005f52690322178235ca5f62d2819846b859e13 100644 (file)
@@ -9,10 +9,6 @@
 // Licence:
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "configtoolview.h"
-#endif
-
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
@@ -21,6 +17,7 @@
 #endif
 
 #include "wx/wfstream.h"
+#include "wx/txtstrm.h"
 #include "configtoolview.h"
 #include "configtooldoc.h"
 #include "configtree.h"
@@ -95,10 +92,6 @@ BEGIN_EVENT_TABLE(ctConfigToolView, wxView)
 
 END_EVENT_TABLE()
 
-ctConfigToolView::ctConfigToolView()
-{
-}
-
 // What to do when a view is created. Creates actual
 // windows for displaying the view.
 bool ctConfigToolView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
@@ -121,11 +114,11 @@ void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
     ctConfigTreeCtrl* treeCtrl = wxGetApp().GetMainFrame()->GetConfigTreeCtrl();
     if (!treeCtrl)
         return;
-    
+
     wxASSERT (doc != NULL);
-    
+
     ctConfigItem* selItem = NULL;
-    
+
     wxTreeItemId sel = treeCtrl->GetSelection();
     if (sel.IsOk())
     {
@@ -133,12 +126,12 @@ void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
         if (data)
             selItem = data->GetConfigItem() ;
     }
-    
+
     ctConfigToolHint* hint = (ctConfigToolHint*) hintObj;
     int hintOp = ctNoHint;
     if (hint)
         hintOp = hint->m_op;
-    
+
     switch (hintOp)
     {
     case ctInitialUpdate:
@@ -151,12 +144,12 @@ void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
             }
         }
         break;
-    case ctSelChanged:        
+    case ctSelChanged:
         {
             if (selItem)
             {
                 wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(selItem);
-            }            
+            }
         }
         break;
     case ctAllSaved:
@@ -175,14 +168,14 @@ void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
             treeCtrl->DeleteAllItems();
             wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(NULL);
             break;
-        }        
+        }
     case ctValueChanged:
         {
             // ctConfigItem& ti = *(ctConfigItem *)hint->m_item;
             wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(selItem);
-        }        
+        }
         break;
-        
+
     default:
         break;
     }
@@ -200,7 +193,7 @@ bool ctConfigToolView::OnClose(bool WXUNUSED(deleteWindow))
     wxGetApp().GetDocManager()->ActivateView(this, false);
 
     Activate(false);
-    
+
     wxGetApp().GetMainFrame()->SetDocument(NULL);
     wxGetApp().GetMainFrame()->GetSetupPage()->SetDocument(NULL) ;
     wxGetApp().GetMainFrame()->GetConfigurePage()->SetDocument(NULL) ;
@@ -263,7 +256,7 @@ void ctConfigToolView::SyncItem(ctConfigTreeCtrl* treeControl, ctConfigItem* ite
     {
         if (!item->GetParent())
         {
-            item->SetTreeItem(treeControl->AddRoot(_(""), -1, -1, new ctTreeItemData(item)));
+            item->SetTreeItem(treeControl->AddRoot(wxEmptyString, -1, -1, new ctTreeItemData(item)));
         }
         else
         {
@@ -427,9 +420,8 @@ void ctConfigToolView::AddItem(ctConfigType type, const wxString& msg)
     ctConfigItem* sel = GetSelection();
     if (sel)
     {
-        wxString name = wxGetTextFromUser(_("Please enter a name for the new item."),
-            msg, wxT(""));
-        if (!name.IsEmpty())
+        wxString name = wxGetTextFromUser(_("Please enter a name for the new item."), msg);
+        if (!name.empty())
         {
             ctConfigItem* parent ;
             ctConfigItem* insertBefore ;
@@ -443,7 +435,7 @@ void ctConfigToolView::AddItem(ctConfigType type, const wxString& msg)
                 parent = sel->GetParent();
                 insertBefore = sel->FindNextSibling();
             }
-            
+
             ctConfigItem* newItem = new ctConfigItem(NULL, type, name);
             newItem->InitProperties();
 
@@ -478,7 +470,7 @@ void ctConfigToolView::OnRenameItem(wxCommandEvent& WXUNUSED(event))
     {
         wxString name = wxGetTextFromUser(_("Please enter a new name for the item."),
             _("Rename item"), sel->GetName());
-        if (!name.IsEmpty())
+        if (!name.empty())
         {
             sel->SetName(name);
             SyncItem(wxGetApp().GetMainFrame()->GetConfigTreeCtrl(), sel);
@@ -634,7 +626,7 @@ void ctConfigToolView::OnContextPasteAsChild(wxCommandEvent& WXUNUSED(event))
         {
             ctConfigItem* parent = sel;
             ctConfigItem* insertBefore = NULL;
-            
+
             ctConfigItem* newItem = doc->GetClipboardItem()->DeepClone();
             ctConfigCommand* cmd = new ctConfigCommand(wxT("Paste Config Item"), ctCMD_PASTE,
                 NULL, newItem, parent, insertBefore);
@@ -690,7 +682,7 @@ void ctConfigToolView::OnItemHelp(wxCommandEvent& WXUNUSED(event))
     if ( doc && GetSelection() )
     {
         wxString helpTopic = GetSelection()->GetPropertyString(wxT("help-topic"));
-        if (!helpTopic.IsEmpty())
+        if (!helpTopic.empty())
         {
             wxGetApp().GetReferenceHelpController().DisplaySection(helpTopic);
         }
@@ -736,7 +728,7 @@ void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& WXUNUSED(event))
             else if (type == wxT("long"))
                 property->GetVariant() = wxVariant((long) 0, name);
             else
-                property->GetVariant() = wxVariant(wxT(""), name);
+                property->GetVariant() = wxVariant(wxEmptyString, name);
             property->SetCustom(true);
             property->SetDescription(descr);
             property->SetChoices(choices);
@@ -766,7 +758,7 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& WXUNUSED(event))
             wxString oldType = property->GetVariant().GetType();
             wxString oldEditorType = property->GetEditorType();
             wxArrayString oldChoices = property->GetChoices();
-            
+
             ctCustomPropertyDialog dialog(wxGetApp().GetMainFrame(),
                 wxID_ANY, _("Edit custom property"));
             dialog.SetPropertyName(oldName);
@@ -779,7 +771,7 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& WXUNUSED(event))
                 wxString editorType = dialog.GetEditorType();
                 wxArrayString choices = dialog.GetChoices();
                 wxString descr = dialog.GetPropertyDescription();
-                
+
                 if (name != oldName && sel->GetProperties().FindProperty(name))
                 {
                     wxMessageBox(_("Sorry, this name already exists."), _T("Add custom property"),
@@ -795,7 +787,7 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& WXUNUSED(event))
                     else if (type == wxT("long"))
                         property->GetVariant() = wxVariant((long) 0, name);
                     else
-                        property->GetVariant() = wxVariant(wxT(""), name);
+                        property->GetVariant() = wxVariant(wxEmptyString, name);
                 }
                 if (name != oldName)
                     property->GetVariant().SetName(name);
@@ -813,7 +805,7 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& WXUNUSED(event))
 
                 if (descr != oldDescription)
                     property->SetDescription(descr);
-                
+
                 editor->ShowItem(sel);
                 OnChangeFilename();
             }
@@ -914,29 +906,30 @@ void ctConfigToolView::OnSaveSetupFile(wxCommandEvent& WXUNUSED(event))
 
     wxString filename = _T("setup.h");
     wxString path = wxGetApp().GetSettings().m_lastSetupSaveDir;
-    if (path.IsEmpty())
+    if (path.empty())
         path = doc->GetFrameworkDir(false);
     wxString wildcard = _T("Header files (*.h)|*.h|All files (*.*)|*.*");
-    
+
     wxFileDialog dialog(wxTheApp->GetTopWindow(),
         _("Save Setup File As"),
         path, filename ,
-        wildcard, wxSAVE|wxOVERWRITE_PROMPT);
-    
+        wildcard, wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
+
     if (dialog.ShowModal() == wxID_OK)
     {
         wxString fullPath = dialog.GetPath();
         wxGetApp().GetSettings().m_lastSetupSaveDir = wxPathOnly(fullPath);
 
-        wxFileOutputStream stream(fullPath);
-        if (!stream.Ok())
+        wxFileOutputStream osFile(fullPath);
+        if (!osFile.Ok())
         {
             wxMessageBox(_("Sorry, could not save this file."), _("Save Setup File"), wxICON_EXCLAMATION|wxOK);
             return;
         }
 
+        wxTextOutputStream stream(osFile);
         stream << setupStr;
-    }    
+    }
 }
 
 void ctConfigToolView::OnSaveConfigureCommand(wxCommandEvent& WXUNUSED(event))
@@ -946,29 +939,30 @@ void ctConfigToolView::OnSaveConfigureCommand(wxCommandEvent& WXUNUSED(event))
 
     wxString filename = _T("configurewx.sh");
     wxString path = wxGetApp().GetSettings().m_lastSetupSaveDir;
-    if (path.IsEmpty())
+    if (path.empty())
         path = doc->GetFrameworkDir(false);
     wxString wildcard = _T("Shell script files (*.sh)|*.sh|All files (*.*)|*.*");
-    
+
     wxFileDialog dialog(wxTheApp->GetTopWindow(),
         _("Save Configure Command File As"),
         path, filename ,
-        wildcard, wxSAVE|wxOVERWRITE_PROMPT);
-    
+        wildcard, wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
+
     if (dialog.ShowModal() == wxID_OK)
     {
         wxString fullPath = dialog.GetPath();
         wxGetApp().GetSettings().m_lastSetupSaveDir = wxPathOnly(fullPath);
 
-        wxFileOutputStream stream(fullPath);
-        if (!stream.Ok())
+        wxFileOutputStream osFile(fullPath);
+        if (!osFile.Ok())
         {
             wxMessageBox(_("Sorry, could not save this file."), _("Save Configure Command File"), wxICON_EXCLAMATION|wxOK);
             return;
         }
 
+        wxTextOutputStream stream(osFile);
         stream << configureStr;
-    }    
+    }
 }
 
 void ctConfigToolView::OnUpdateSaveSetupFile(wxUpdateUIEvent& event)
@@ -1018,7 +1012,7 @@ void ctConfigToolView::OnGo(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     wxString path = wxGetApp().GetSettings().m_lastSetupSaveDir;
-    if (!path.IsEmpty())
+    if (!path.empty())
     {
         if (wxGetApp().GetSettings().m_defaultFileKind == wxT("Setup file"))
         {
@@ -1079,7 +1073,7 @@ void ctConfigToolView::OnGo(wxCommandEvent& WXUNUSED(event))
 void ctConfigToolView::OnUpdateGo(wxUpdateUIEvent& event)
 {
     wxString path = wxGetApp().GetSettings().m_lastSetupSaveDir;
-    event.Enable(!path.IsEmpty());
+    event.Enable(!path.empty());
 }
 
 //----------------------------------------------------------------------------
@@ -1136,7 +1130,7 @@ bool ctFindReplaceDialog::DoFind(const wxString& textToFind, bool matchCase, boo
             return false;
     }
 
-    if (!sm_currentItem.IsEmpty())
+    if (!sm_currentItem.empty())
     {
         currentItem = doc->GetTopItem()->FindItem(sm_currentItem);
     }