]> 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 10cb368559b9f6549d72b50bd04520c0de9caafe..0005f52690322178235ca5f62d2819846b859e13 100644 (file)
@@ -9,19 +9,15 @@
 // Licence:
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-    #pragma implementation "configtoolview.cpp"
-#endif
-
-// Includes other headers for precompiled compilation
-#include "wx/wx.h"
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
 
 #ifdef __BORLANDC__
-    #pragma hdrstop
+#pragma hdrstop
 #endif
 
 #include "wx/wfstream.h"
 #endif
 
 #include "wx/wfstream.h"
-
+#include "wx/txtstrm.h"
 #include "configtoolview.h"
 #include "configtooldoc.h"
 #include "configtree.h"
 #include "configtoolview.h"
 #include "configtooldoc.h"
 #include "configtree.h"
@@ -81,31 +77,34 @@ BEGIN_EVENT_TABLE(ctConfigToolView, wxView)
     EVT_UPDATE_UI(ctID_EDIT_CUSTOM_PROPERTY, ctConfigToolView::OnUpdateEditCustomProperty)
     EVT_UPDATE_UI(ctID_DELETE_CUSTOM_PROPERTY, ctConfigToolView::OnUpdateDeleteCustomProperty)
 
     EVT_UPDATE_UI(ctID_EDIT_CUSTOM_PROPERTY, ctConfigToolView::OnUpdateEditCustomProperty)
     EVT_UPDATE_UI(ctID_DELETE_CUSTOM_PROPERTY, ctConfigToolView::OnUpdateDeleteCustomProperty)
 
-    EVT_NOTEBOOK_PAGE_CHANGED(-1, ctConfigToolView::OnTabSelect)
+    EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, ctConfigToolView::OnTabSelect)
 
     EVT_MENU(ctID_SAVE_SETUP_FILE, ctConfigToolView::OnSaveSetupFile)
     EVT_MENU(ctID_SAVE_CONFIGURE_COMMAND, ctConfigToolView::OnSaveConfigureCommand)
     EVT_UPDATE_UI(ctID_SAVE_SETUP_FILE, ctConfigToolView::OnUpdateSaveSetupFile)
     EVT_UPDATE_UI(ctID_SAVE_CONFIGURE_COMMAND, ctConfigToolView::OnUpdateSaveConfigureCommand)
 
     EVT_MENU(ctID_SAVE_SETUP_FILE, ctConfigToolView::OnSaveSetupFile)
     EVT_MENU(ctID_SAVE_CONFIGURE_COMMAND, ctConfigToolView::OnSaveConfigureCommand)
     EVT_UPDATE_UI(ctID_SAVE_SETUP_FILE, ctConfigToolView::OnUpdateSaveSetupFile)
     EVT_UPDATE_UI(ctID_SAVE_CONFIGURE_COMMAND, ctConfigToolView::OnUpdateSaveConfigureCommand)
-END_EVENT_TABLE()
 
 
-ctConfigToolView::ctConfigToolView()
-{
-}
+    EVT_MENU(wxID_FIND, ctConfigToolView::OnFind)
+    EVT_UPDATE_UI(wxID_FIND, ctConfigToolView::OnUpdateFind)
+
+    EVT_MENU(ctID_GO, ctConfigToolView::OnGo)
+    EVT_UPDATE_UI(ctID_GO, ctConfigToolView::OnUpdateGo)
+
+END_EVENT_TABLE()
 
 // What to do when a view is created. Creates actual
 // windows for displaying the view.
 bool ctConfigToolView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
 {
 
 // What to do when a view is created. Creates actual
 // windows for displaying the view.
 bool ctConfigToolView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
 {
-    wxGetApp().GetDocManager()->ActivateView(this, TRUE);
+    wxGetApp().GetDocManager()->ActivateView(this, true);
     wxGetApp().GetMainFrame()->SetDocument((ctConfigToolDoc*) doc);
     wxGetApp().GetMainFrame()->GetSetupPage()->SetDocument((ctConfigToolDoc*) doc) ;
     wxGetApp().GetMainFrame()->GetConfigurePage()->SetDocument((ctConfigToolDoc*) doc) ;
 
     wxGetApp().GetMainFrame()->SetDocument((ctConfigToolDoc*) doc);
     wxGetApp().GetMainFrame()->GetSetupPage()->SetDocument((ctConfigToolDoc*) doc) ;
     wxGetApp().GetMainFrame()->GetConfigurePage()->SetDocument((ctConfigToolDoc*) doc) ;
 
-    return TRUE;
+    return true;
 }
 
 }
 
-void ctConfigToolView::OnDraw(wxDC *dc)
+void ctConfigToolView::OnDraw(wxDC *WXUNUSED(dc))
 {
 }
 
 {
 }
 
@@ -115,11 +114,11 @@ void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
     ctConfigTreeCtrl* treeCtrl = wxGetApp().GetMainFrame()->GetConfigTreeCtrl();
     if (!treeCtrl)
         return;
     ctConfigTreeCtrl* treeCtrl = wxGetApp().GetMainFrame()->GetConfigTreeCtrl();
     if (!treeCtrl)
         return;
-    
+
     wxASSERT (doc != NULL);
     wxASSERT (doc != NULL);
-    
+
     ctConfigItem* selItem = NULL;
     ctConfigItem* selItem = NULL;
-    
+
     wxTreeItemId sel = treeCtrl->GetSelection();
     if (sel.IsOk())
     {
     wxTreeItemId sel = treeCtrl->GetSelection();
     if (sel.IsOk())
     {
@@ -127,12 +126,12 @@ void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
         if (data)
             selItem = data->GetConfigItem() ;
     }
         if (data)
             selItem = data->GetConfigItem() ;
     }
-    
+
     ctConfigToolHint* hint = (ctConfigToolHint*) hintObj;
     int hintOp = ctNoHint;
     if (hint)
         hintOp = hint->m_op;
     ctConfigToolHint* hint = (ctConfigToolHint*) hintObj;
     int hintOp = ctNoHint;
     if (hint)
         hintOp = hint->m_op;
-    
+
     switch (hintOp)
     {
     case ctInitialUpdate:
     switch (hintOp)
     {
     case ctInitialUpdate:
@@ -145,12 +144,12 @@ void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
             }
         }
         break;
             }
         }
         break;
-    case ctSelChanged:        
+    case ctSelChanged:
         {
             if (selItem)
             {
                 wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(selItem);
         {
             if (selItem)
             {
                 wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(selItem);
-            }            
+            }
         }
         break;
     case ctAllSaved:
         }
         break;
     case ctAllSaved:
@@ -169,37 +168,37 @@ void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
             treeCtrl->DeleteAllItems();
             wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(NULL);
             break;
             treeCtrl->DeleteAllItems();
             wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(NULL);
             break;
-        }        
+        }
     case ctValueChanged:
         {
             // ctConfigItem& ti = *(ctConfigItem *)hint->m_item;
             wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(selItem);
     case ctValueChanged:
         {
             // ctConfigItem& ti = *(ctConfigItem *)hint->m_item;
             wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(selItem);
-        }                      
+        }
         break;
         break;
-        
+
     default:
         break;
     }
 }
 
 // Clean up windows used for displaying the view.
     default:
         break;
     }
 }
 
 // Clean up windows used for displaying the view.
-bool ctConfigToolView::OnClose(bool deleteWindow)
+bool ctConfigToolView::OnClose(bool WXUNUSED(deleteWindow))
 {
     if (!GetDocument()->Close())
 {
     if (!GetDocument()->Close())
-        return FALSE;
+        return false;
 
     ctConfigToolHint hint(NULL, ctClear);
     GetDocument()->UpdateAllViews (NULL, & hint);
 
 
     ctConfigToolHint hint(NULL, ctClear);
     GetDocument()->UpdateAllViews (NULL, & hint);
 
-    wxGetApp().GetDocManager()->ActivateView(this, FALSE);
+    wxGetApp().GetDocManager()->ActivateView(this, false);
+
+    Activate(false);
 
 
-    Activate(FALSE);
-    
     wxGetApp().GetMainFrame()->SetDocument(NULL);
     wxGetApp().GetMainFrame()->GetSetupPage()->SetDocument(NULL) ;
     wxGetApp().GetMainFrame()->GetConfigurePage()->SetDocument(NULL) ;
 
     wxGetApp().GetMainFrame()->SetDocument(NULL);
     wxGetApp().GetMainFrame()->GetSetupPage()->SetDocument(NULL) ;
     wxGetApp().GetMainFrame()->GetConfigurePage()->SetDocument(NULL) ;
 
-    return TRUE;
+    return true;
 }
 
 void ctConfigToolView::OnChangeFilename()
 }
 
 void ctConfigToolView::OnChangeFilename()
@@ -228,12 +227,12 @@ void ctConfigToolView::OnChangeFilename()
 // General disabler
 void ctConfigToolView::OnUpdateDisable(wxUpdateUIEvent& event)
 {
 // General disabler
 void ctConfigToolView::OnUpdateDisable(wxUpdateUIEvent& event)
 {
-    event.Enable( FALSE );
+    event.Enable( false );
 }
 
 void ctConfigToolView::OnUpdateAddItem(wxUpdateUIEvent& event)
 {
 }
 
 void ctConfigToolView::OnUpdateAddItem(wxUpdateUIEvent& event)
 {
-    event.Enable( TRUE );
+    event.Enable( true );
 }
 
 /// Add item and its children to the tree
 }
 
 /// Add item and its children to the tree
@@ -257,7 +256,7 @@ void ctConfigToolView::SyncItem(ctConfigTreeCtrl* treeControl, ctConfigItem* ite
     {
         if (!item->GetParent())
         {
     {
         if (!item->GetParent())
         {
-            item->SetTreeItem(treeControl->AddRoot(_(""), -1, -1, new ctTreeItemData(item)));
+            item->SetTreeItem(treeControl->AddRoot(wxEmptyString, -1, -1, new ctTreeItemData(item)));
         }
         else
         {
         }
         else
         {
@@ -342,17 +341,23 @@ void ctConfigToolView::OnIconLeftDown(ctConfigTreeCtrl* treeControl, ctConfigIte
 
         item->Enable(!item->IsEnabled());
 
 
         item->Enable(!item->IsEnabled());
 
-        GetDocument()->Modify(TRUE);
+        GetDocument()->Modify(true);
         OnChangeFilename();
 
         SyncItem(treeControl, item);
 
         wxList considered;
         OnChangeFilename();
 
         SyncItem(treeControl, item);
 
         wxList considered;
-        item->PropagateChange(considered);
         if ((item->GetType() == ctTypeBoolRadio || item->GetType() == ctTypeRadioGroup) && item->IsEnabled())
         {
             item->PropagateRadioButton(considered);
         }
         if ((item->GetType() == ctTypeBoolRadio || item->GetType() == ctTypeRadioGroup) && item->IsEnabled())
         {
             item->PropagateRadioButton(considered);
         }
+        item->PropagateChange(considered);
+
+        // Update the setup.h and configure text
+        if (wxGetApp().GetMainFrame()->GetMainNotebook()->GetSelection() > 0)
+        {
+            RegenerateSetup();
+        }
     }
 }
 
     }
 }
 
@@ -374,37 +379,37 @@ ctConfigItem* ctConfigToolView::GetSelection()
 }
 
 /// Add a checkbox item
 }
 
 /// Add a checkbox item
-void ctConfigToolView::OnAddCheckBoxItem(wxCommandEvent& event)
+void ctConfigToolView::OnAddCheckBoxItem(wxCommandEvent& WXUNUSED(event))
 {
     AddItem(ctTypeBoolCheck, _("New checkbox item"));
 }
 
 /// Add a radiobutton item
 {
     AddItem(ctTypeBoolCheck, _("New checkbox item"));
 }
 
 /// Add a radiobutton item
-void ctConfigToolView::OnAddRadioButtonItem(wxCommandEvent& event)
+void ctConfigToolView::OnAddRadioButtonItem(wxCommandEvent& WXUNUSED(event))
 {
     AddItem(ctTypeBoolRadio, _("New radio button item"));
 }
 
 /// Add a group item
 {
     AddItem(ctTypeBoolRadio, _("New radio button item"));
 }
 
 /// Add a group item
-void ctConfigToolView::OnAddGroupItem(wxCommandEvent& event)
+void ctConfigToolView::OnAddGroupItem(wxCommandEvent& WXUNUSED(event))
 {
     AddItem(ctTypeGroup, _("New group item"));
 }
 
 /// Add a group option item
 {
     AddItem(ctTypeGroup, _("New group item"));
 }
 
 /// Add a group option item
-void ctConfigToolView::OnAddCheckGroupItem(wxCommandEvent& event)
+void ctConfigToolView::OnAddCheckGroupItem(wxCommandEvent& WXUNUSED(event))
 {
     AddItem(ctTypeCheckGroup, _("New check group item"));
 }
 
 /// Add a group option item
 {
     AddItem(ctTypeCheckGroup, _("New check group item"));
 }
 
 /// Add a group option item
-void ctConfigToolView::OnAddRadioGroupItem(wxCommandEvent& event)
+void ctConfigToolView::OnAddRadioGroupItem(wxCommandEvent& WXUNUSED(event))
 {
     AddItem(ctTypeRadioGroup, _("New radio group item"));
 }
 
 /// Add a string item
 {
     AddItem(ctTypeRadioGroup, _("New radio group item"));
 }
 
 /// Add a string item
-void ctConfigToolView::OnAddStringItem(wxCommandEvent& event)
+void ctConfigToolView::OnAddStringItem(wxCommandEvent& WXUNUSED(event))
 {
     AddItem(ctTypeString, _("New string item"));
 }
 {
     AddItem(ctTypeString, _("New string item"));
 }
@@ -415,9 +420,8 @@ void ctConfigToolView::AddItem(ctConfigType type, const wxString& msg)
     ctConfigItem* sel = GetSelection();
     if (sel)
     {
     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 ;
         {
             ctConfigItem* parent ;
             ctConfigItem* insertBefore ;
@@ -431,7 +435,7 @@ void ctConfigToolView::AddItem(ctConfigType type, const wxString& msg)
                 parent = sel->GetParent();
                 insertBefore = sel->FindNextSibling();
             }
                 parent = sel->GetParent();
                 insertBefore = sel->FindNextSibling();
             }
-            
+
             ctConfigItem* newItem = new ctConfigItem(NULL, type, name);
             newItem->InitProperties();
 
             ctConfigItem* newItem = new ctConfigItem(NULL, type, name);
             newItem->InitProperties();
 
@@ -443,13 +447,14 @@ void ctConfigToolView::AddItem(ctConfigType type, const wxString& msg)
 }
 
 /// Delete an item
 }
 
 /// Delete an item
-void ctConfigToolView::OnDeleteItem(wxCommandEvent& event)
+void ctConfigToolView::OnDeleteItem(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigItem* sel = GetSelection();
     if (sel)
     {
 {
     ctConfigItem* sel = GetSelection();
     if (sel)
     {
+        wxString name(sel->GetName());
         wxString msg;
         wxString msg;
-        msg.Printf(_("Delete %s?"), sel->GetName());
+        msg.Printf(_("Delete %s?"), (const wxChar*) name);
         if (wxYES == wxMessageBox(msg, _("Delete item"), wxICON_QUESTION|wxYES_NO))
         {
             wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->Delete(sel->GetTreeItemId());
         if (wxYES == wxMessageBox(msg, _("Delete item"), wxICON_QUESTION|wxYES_NO))
         {
             wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->Delete(sel->GetTreeItemId());
@@ -458,14 +463,14 @@ void ctConfigToolView::OnDeleteItem(wxCommandEvent& event)
 }
 
 /// Rename an item
 }
 
 /// Rename an item
-void ctConfigToolView::OnRenameItem(wxCommandEvent& event)
+void ctConfigToolView::OnRenameItem(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigItem* sel = GetSelection();
     if (sel)
     {
         wxString name = wxGetTextFromUser(_("Please enter a new name for the item."),
             _("Rename item"), sel->GetName());
 {
     ctConfigItem* sel = GetSelection();
     if (sel)
     {
         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);
         {
             sel->SetName(name);
             SyncItem(wxGetApp().GetMainFrame()->GetConfigTreeCtrl(), sel);
@@ -477,7 +482,7 @@ void ctConfigToolView::OnRenameItem(wxCommandEvent& event)
 }
 
 /// Copy an item to the clipboard
 }
 
 /// Copy an item to the clipboard
-void ctConfigToolView::OnCopy(wxCommandEvent& event)
+void ctConfigToolView::OnCopy(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
@@ -488,7 +493,7 @@ void ctConfigToolView::OnCopy(wxCommandEvent& event)
 }
 
 /// Copy an item to the clipboard and cut the item
 }
 
 /// Copy an item to the clipboard and cut the item
-void ctConfigToolView::OnCut(wxCommandEvent& event)
+void ctConfigToolView::OnCut(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
@@ -503,7 +508,7 @@ void ctConfigToolView::OnCut(wxCommandEvent& event)
 }
 
 /// Paste an item from the clipboard to the tree
 }
 
 /// Paste an item from the clipboard to the tree
-void ctConfigToolView::OnPaste(wxCommandEvent& event)
+void ctConfigToolView::OnPaste(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
@@ -551,7 +556,7 @@ void ctConfigToolView::OnUpdatePaste(wxUpdateUIEvent& event)
 }
 
 /// Copy an item to the clipboard
 }
 
 /// Copy an item to the clipboard
-void ctConfigToolView::OnContextCopy(wxCommandEvent& event)
+void ctConfigToolView::OnContextCopy(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
@@ -562,7 +567,7 @@ void ctConfigToolView::OnContextCopy(wxCommandEvent& event)
 }
 
 /// Copy an item to the clipboard and cut the item
 }
 
 /// Copy an item to the clipboard and cut the item
-void ctConfigToolView::OnContextCut(wxCommandEvent& event)
+void ctConfigToolView::OnContextCut(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
@@ -577,7 +582,7 @@ void ctConfigToolView::OnContextCut(wxCommandEvent& event)
 }
 
 /// Paste an item from the clipboard to the tree
 }
 
 /// Paste an item from the clipboard to the tree
-void ctConfigToolView::OnContextPasteBefore(wxCommandEvent& event)
+void ctConfigToolView::OnContextPasteBefore(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
@@ -594,7 +599,7 @@ void ctConfigToolView::OnContextPasteBefore(wxCommandEvent& event)
 }
 
 /// Paste an item from the clipboard to the tree
 }
 
 /// Paste an item from the clipboard to the tree
-void ctConfigToolView::OnContextPasteAfter(wxCommandEvent& event)
+void ctConfigToolView::OnContextPasteAfter(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
@@ -611,7 +616,7 @@ void ctConfigToolView::OnContextPasteAfter(wxCommandEvent& event)
 }
 
 /// Paste an item from the clipboard to the tree
 }
 
 /// Paste an item from the clipboard to the tree
-void ctConfigToolView::OnContextPasteAsChild(wxCommandEvent& event)
+void ctConfigToolView::OnContextPasteAsChild(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->GetContextItem();
@@ -621,7 +626,7 @@ void ctConfigToolView::OnContextPasteAsChild(wxCommandEvent& event)
         {
             ctConfigItem* parent = sel;
             ctConfigItem* insertBefore = NULL;
         {
             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);
             ctConfigItem* newItem = doc->GetClipboardItem()->DeepClone();
             ctConfigCommand* cmd = new ctConfigCommand(wxT("Paste Config Item"), ctCMD_PASTE,
                 NULL, newItem, parent, insertBefore);
@@ -671,13 +676,13 @@ void ctConfigToolView::OnUpdateContextPasteAsChild(wxUpdateUIEvent& event)
 }
 
 /// Item help
 }
 
 /// Item help
-void ctConfigToolView::OnItemHelp(wxCommandEvent& event)
+void ctConfigToolView::OnItemHelp(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     if ( doc && GetSelection() )
     {
         wxString helpTopic = GetSelection()->GetPropertyString(wxT("help-topic"));
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     if ( doc && GetSelection() )
     {
         wxString helpTopic = GetSelection()->GetPropertyString(wxT("help-topic"));
-        if (!helpTopic.IsEmpty())
+        if (!helpTopic.empty())
         {
             wxGetApp().GetReferenceHelpController().DisplaySection(helpTopic);
         }
         {
             wxGetApp().GetReferenceHelpController().DisplaySection(helpTopic);
         }
@@ -692,7 +697,7 @@ void ctConfigToolView::OnUpdateItemHelp(wxUpdateUIEvent& event)
 }
 
 /// Add a custom property
 }
 
 /// Add a custom property
-void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& event)
+void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
@@ -700,7 +705,7 @@ void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& event)
     if (doc && sel && editor)
     {
         ctCustomPropertyDialog dialog(wxGetApp().GetMainFrame(),
     if (doc && sel && editor)
     {
         ctCustomPropertyDialog dialog(wxGetApp().GetMainFrame(),
-            -1, _("Add a custom property"));
+            wxID_ANY, _("Add a custom property"));
         if (dialog.ShowModal() == wxID_OK)
         {
             wxString name = dialog.GetPropertyName();
         if (dialog.ShowModal() == wxID_OK)
         {
             wxString name = dialog.GetPropertyName();
@@ -717,14 +722,14 @@ void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& event)
             }
             ctProperty* property = new ctProperty;
             if (type == wxT("bool"))
             }
             ctProperty* property = new ctProperty;
             if (type == wxT("bool"))
-                property->GetVariant() = wxVariant((bool) FALSE, name);
+                property->GetVariant() = wxVariant(false, name);
             else if (type == wxT("double"))
                 property->GetVariant() = wxVariant((double) 0.0, name);
             else if (type == wxT("long"))
                 property->GetVariant() = wxVariant((long) 0, name);
             else
             else if (type == wxT("double"))
                 property->GetVariant() = wxVariant((double) 0.0, name);
             else if (type == wxT("long"))
                 property->GetVariant() = wxVariant((long) 0, name);
             else
-                property->GetVariant() = wxVariant(wxT(""), name);
-            property->SetCustom(TRUE);
+                property->GetVariant() = wxVariant(wxEmptyString, name);
+            property->SetCustom(true);
             property->SetDescription(descr);
             property->SetChoices(choices);
             property->SetEditorType(editorType);
             property->SetDescription(descr);
             property->SetChoices(choices);
             property->SetEditorType(editorType);
@@ -737,7 +742,7 @@ void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& event)
 }
 
 /// Edit a custom property
 }
 
 /// Edit a custom property
-void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& event)
+void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
@@ -753,9 +758,9 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& event)
             wxString oldType = property->GetVariant().GetType();
             wxString oldEditorType = property->GetEditorType();
             wxArrayString oldChoices = property->GetChoices();
             wxString oldType = property->GetVariant().GetType();
             wxString oldEditorType = property->GetEditorType();
             wxArrayString oldChoices = property->GetChoices();
-            
+
             ctCustomPropertyDialog dialog(wxGetApp().GetMainFrame(),
             ctCustomPropertyDialog dialog(wxGetApp().GetMainFrame(),
-                -1, _("Edit custom property"));
+                wxID_ANY, _("Edit custom property"));
             dialog.SetPropertyName(oldName);
             dialog.SetPropertyType(oldType);
             dialog.SetPropertyDescription(oldDescription);
             dialog.SetPropertyName(oldName);
             dialog.SetPropertyType(oldType);
             dialog.SetPropertyDescription(oldDescription);
@@ -766,7 +771,7 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& event)
                 wxString editorType = dialog.GetEditorType();
                 wxArrayString choices = dialog.GetChoices();
                 wxString descr = dialog.GetPropertyDescription();
                 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"),
                 if (name != oldName && sel->GetProperties().FindProperty(name))
                 {
                     wxMessageBox(_("Sorry, this name already exists."), _T("Add custom property"),
@@ -776,13 +781,13 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& event)
                 if (type != oldType)
                 {
                     if (type == wxT("bool"))
                 if (type != oldType)
                 {
                     if (type == wxT("bool"))
-                        property->GetVariant() = wxVariant((bool) FALSE, name);
+                        property->GetVariant() = wxVariant(false, name);
                     else if (type == wxT("double"))
                         property->GetVariant() = wxVariant((double) 0.0, name);
                     else if (type == wxT("long"))
                         property->GetVariant() = wxVariant((long) 0, name);
                     else
                     else if (type == wxT("double"))
                         property->GetVariant() = wxVariant((double) 0.0, name);
                     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);
                 }
                 if (name != oldName)
                     property->GetVariant().SetName(name);
@@ -796,11 +801,11 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& event)
                 if (name != oldName)
                     property->GetVariant().SetName(name);
 
                 if (name != oldName)
                     property->GetVariant().SetName(name);
 
-                property->SetCustom(TRUE);
+                property->SetCustom(true);
 
                 if (descr != oldDescription)
                     property->SetDescription(descr);
 
                 if (descr != oldDescription)
                     property->SetDescription(descr);
-                
+
                 editor->ShowItem(sel);
                 OnChangeFilename();
             }
                 editor->ShowItem(sel);
                 OnChangeFilename();
             }
@@ -809,7 +814,7 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& event)
 }
 
 /// Delete a custom property
 }
 
 /// Delete a custom property
-void ctConfigToolView::OnDeleteCustomProperty(wxCommandEvent& event)
+void ctConfigToolView::OnDeleteCustomProperty(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     ctConfigItem* sel = GetSelection();
@@ -894,74 +899,336 @@ void ctConfigToolView::OnTabSelect(wxNotebookEvent& event)
     }
 }
 
     }
 }
 
-void ctConfigToolView::OnSaveSetupFile(wxCommandEvent& event)
+void ctConfigToolView::OnSaveSetupFile(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     wxString setupStr = doc->GenerateSetup();
 
     wxString filename = _T("setup.h");
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     wxString setupStr = doc->GenerateSetup();
 
     wxString filename = _T("setup.h");
-    wxString path = doc->GetFrameworkDir(FALSE);
+    wxString path = wxGetApp().GetSettings().m_lastSetupSaveDir;
+    if (path.empty())
+        path = doc->GetFrameworkDir(false);
     wxString wildcard = _T("Header files (*.h)|*.h|All files (*.*)|*.*");
     wxString wildcard = _T("Header files (*.h)|*.h|All files (*.*)|*.*");
-    
+
     wxFileDialog dialog(wxTheApp->GetTopWindow(),
         _("Save Setup File As"),
         path, filename ,
     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();
     if (dialog.ShowModal() == wxID_OK)
     {
         wxString fullPath = dialog.GetPath();
+        wxGetApp().GetSettings().m_lastSetupSaveDir = wxPathOnly(fullPath);
 
 
-        // TODO: save last saved path in settings.
-
-        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;
         }
 
         {
             wxMessageBox(_("Sorry, could not save this file."), _("Save Setup File"), wxICON_EXCLAMATION|wxOK);
             return;
         }
 
+        wxTextOutputStream stream(osFile);
         stream << setupStr;
         stream << setupStr;
-    }    
+    }
 }
 
 }
 
-void ctConfigToolView::OnSaveConfigureCommand(wxCommandEvent& event)
+void ctConfigToolView::OnSaveConfigureCommand(wxCommandEvent& WXUNUSED(event))
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     wxString configureStr = doc->GenerateConfigureCommand();
 
     wxString filename = _T("configurewx.sh");
 {
     ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
     wxString configureStr = doc->GenerateConfigureCommand();
 
     wxString filename = _T("configurewx.sh");
-    wxString path = doc->GetFrameworkDir(FALSE);
+    wxString path = wxGetApp().GetSettings().m_lastSetupSaveDir;
+    if (path.empty())
+        path = doc->GetFrameworkDir(false);
     wxString wildcard = _T("Shell script files (*.sh)|*.sh|All files (*.*)|*.*");
     wxString wildcard = _T("Shell script files (*.sh)|*.sh|All files (*.*)|*.*");
-    
+
     wxFileDialog dialog(wxTheApp->GetTopWindow(),
         _("Save Configure Command File As"),
         path, filename ,
     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();
     if (dialog.ShowModal() == wxID_OK)
     {
         wxString fullPath = dialog.GetPath();
+        wxGetApp().GetSettings().m_lastSetupSaveDir = wxPathOnly(fullPath);
 
 
-        // TODO: save last saved path in settings.
-
-        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;
         }
 
         {
             wxMessageBox(_("Sorry, could not save this file."), _("Save Configure Command File"), wxICON_EXCLAMATION|wxOK);
             return;
         }
 
+        wxTextOutputStream stream(osFile);
         stream << configureStr;
         stream << configureStr;
-    }    
+    }
 }
 
 void ctConfigToolView::OnUpdateSaveSetupFile(wxUpdateUIEvent& event)
 {
 }
 
 void ctConfigToolView::OnUpdateSaveSetupFile(wxUpdateUIEvent& event)
 {
-    event.Enable(TRUE);
+    event.Enable(true);
 }
 
 void ctConfigToolView::OnUpdateSaveConfigureCommand(wxUpdateUIEvent& event)
 {
 }
 
 void ctConfigToolView::OnUpdateSaveConfigureCommand(wxUpdateUIEvent& event)
 {
-    event.Enable(TRUE);
+    event.Enable(true);
+}
+
+/// Find text
+void ctConfigToolView::OnFind(wxCommandEvent& WXUNUSED(event))
+{
+    ctFindReplaceDialog* dialog = wxGetApp().GetMainFrame()->GetFindDialog();
+    if (dialog)
+    {
+        dialog->Raise();
+    }
+
+    if (!dialog)
+    {
+        int style = wxFR_NOUPDOWN;
+        wxString caption(wxT("Find text in settings"));
+        int flags = wxFR_DOWN;
+        if (wxGetApp().GetSettings().m_matchCase)
+            flags|=wxFR_MATCHCASE;
+        if (wxGetApp().GetSettings().m_matchWholeWord)
+            flags|=wxFR_WHOLEWORD;
+
+        ctFindReplaceDialog::sm_findData.SetFlags(flags);
+
+        dialog = new ctFindReplaceDialog(wxGetApp().GetMainFrame(), caption, style);
+        dialog->Show(true);
+    }
+}
+
+/// Update find text
+void ctConfigToolView::OnUpdateFind(wxUpdateUIEvent& event)
+{
+    event.Enable(true);
+}
+
+/// Save default file type
+void ctConfigToolView::OnGo(wxCommandEvent& WXUNUSED(event))
+{
+    ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
+    wxString path = wxGetApp().GetSettings().m_lastSetupSaveDir;
+    if (!path.empty())
+    {
+        if (wxGetApp().GetSettings().m_defaultFileKind == wxT("Setup file"))
+        {
+            // setup.h
+            wxString setupStr = doc->GenerateSetup();
+
+            wxString fullPath = path + wxFILE_SEP_PATH + wxT("setup.h");
+            if (wxFileExists(fullPath))
+            {
+                wxString msg;
+                msg.Printf(wxT("Overwrite existing file %s?"), (const wxChar*) fullPath);
+                int ans = wxMessageBox(msg, _("Save Setup File"), wxICON_QUESTION|wxYES_NO|wxCANCEL);
+                if (ans == wxCANCEL)
+                    return;
+                if (ans == wxNO)
+                    return;
+            }
+            wxFileOutputStream stream(fullPath);
+            if (!stream.Ok())
+            {
+                wxMessageBox(_("Sorry, could not save this file."), _("Save Setup File"), wxICON_EXCLAMATION|wxOK);
+                return;
+            }
+            stream << setupStr;
+        }
+        else if (wxGetApp().GetSettings().m_defaultFileKind == wxT("Configure script"))
+        {
+            // configurewx.sh
+            wxString configureStr = doc->GenerateConfigureCommand();
+
+            wxString fullPath = path + wxFILE_SEP_PATH + wxT("configurewx.sh");
+            if (wxFileExists(fullPath))
+            {
+                wxString msg;
+                msg.Printf(wxT("Overwrite existing file %s?"), (const wxChar*) fullPath);
+                int ans = wxMessageBox(msg, _("Save Configure Script"), wxICON_QUESTION|wxYES_NO|wxCANCEL);
+                if (ans == wxCANCEL)
+                    return;
+                if (ans == wxNO)
+                    return;
+            }
+            wxFileOutputStream stream(fullPath);
+            if (!stream.Ok())
+            {
+                wxMessageBox(_("Sorry, could not save this file."), _("Save Configure Script"), wxICON_EXCLAMATION|wxOK);
+                return;
+            }
+            stream << configureStr;
+        }
+        else
+        {
+            wxMessageBox(wxT("Unrecognised default file type."));
+        }
+    }
+}
+
+/// Update
+void ctConfigToolView::OnUpdateGo(wxUpdateUIEvent& event)
+{
+    wxString path = wxGetApp().GetSettings().m_lastSetupSaveDir;
+    event.Enable(!path.empty());
+}
+
+//----------------------------------------------------------------------------
+// ctFindReplaceDialog
+//----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(ctFindReplaceDialog, wxFindReplaceDialog)
+    EVT_FIND(wxID_ANY, ctFindReplaceDialog::OnFind)
+    EVT_FIND_NEXT(wxID_ANY, ctFindReplaceDialog::OnFind)
+    EVT_FIND_CLOSE(wxID_ANY, ctFindReplaceDialog::OnClose)
+END_EVENT_TABLE()
+
+wxFindReplaceData ctFindReplaceDialog::sm_findData;
+wxString ctFindReplaceDialog::sm_currentItem = wxEmptyString;
+
+ctFindReplaceDialog::ctFindReplaceDialog( wxWindow *parent, const wxString& title,
+        long style):
+    wxFindReplaceDialog( parent, & sm_findData, title, style )
+{
+    sm_currentItem = wxEmptyString;
+
+    if (parent)
+        ((ctMainFrame*) parent)->SetFindDialog(this);
+}
+
+void ctFindReplaceDialog::OnFind(wxFindDialogEvent& event)
+{
+    wxString textToFind = event.GetFindString();
+    bool matchCase = ((event.GetFlags() & wxFR_MATCHCASE) != 0);
+    bool wholeWord = ((event.GetFlags() & wxFR_WHOLEWORD) != 0);
+
+    wxGetApp().GetSettings().m_matchCase = matchCase;
+    wxGetApp().GetSettings().m_matchWholeWord = wholeWord;
+
+    if (!DoFind(textToFind, matchCase, wholeWord))
+    {
+        wxMessageBox(wxT("No more matches."), wxT("Search"), wxOK|wxICON_INFORMATION, this);
+    }
+}
+
+bool ctFindReplaceDialog::DoFind(const wxString& textToFind, bool matchCase, bool wholeWord, bool wrap)
+{
+    ctConfigToolDoc* doc = wxGetApp().GetMainFrame()->GetDocument();
+    if (!doc)
+        return false;
+    ctConfigToolView* view = (ctConfigToolView*) doc->GetFirstView();
+
+    ctConfigItem* currentItem = NULL;
+    ctConfigItem* focusItem = view->GetSelection();
+    if (!focusItem)
+    {
+        focusItem = doc->GetTopItem();
+        if (!focusItem)
+            return false;
+    }
+
+    if (!sm_currentItem.empty())
+    {
+        currentItem = doc->GetTopItem()->FindItem(sm_currentItem);
+    }
+
+    // If we were at this item last time, skip the first one.
+    bool skipFirstItem = (currentItem == focusItem);
+    currentItem = FindNextItem(doc, currentItem, textToFind, matchCase, wholeWord, wrap,
+        skipFirstItem);
+
+    if (currentItem)
+    {
+        sm_currentItem = currentItem->GetName();
+        wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->SelectItem(currentItem->GetTreeItemId());
+        return true;
+    }
+    else
+    {
+        sm_currentItem = wxEmptyString;
+    }
+
+    return false;
+}
+
+ctConfigItem* ctFindReplaceDialog::FindNextItem(ctConfigToolDoc* doc,
+                                                      ctConfigItem* item,
+                                                      const wxString& text,
+                                                      bool matchCase,
+                                                      bool matchWordOnly,
+                                                      bool wrap,
+                                                      bool skipFirst)
+{
+    ctConfigItem* firstInDoc = NULL;
+
+    wxString text2(text);
+    if (!matchCase)
+        text2.MakeLower();
+
+    ctConfigItem* found = NULL;
+    ctConfigItem* next = item;
+
+    int i = 0;
+    do
+    {
+        // If starting the search from beginning, we can now
+        // set the value of 'item' in the 2nd iteration without immediately
+        // dropping out of the while loop because card == next
+        if (!item && (i > 0))
+            item = firstInDoc;
+
+        // We might want to start from this item if skipFirst is false.
+        if ((i == 0) && !skipFirst && next)
+        {
+        }
+        else
+            next = doc->FindNextItem(next, wrap);
+
+        // Save to be used in iteration 2
+        if ((i == 0) && !item)
+            firstInDoc = next;
+
+        if (next)
+        {
+            wxString str(next->GetName());
+            wxString description(next->GetPropertyString(wxT("description")));
+            wxString notes(next->GetPropertyString(wxT("notes")));
+            if (!matchCase)
+            {
+                str.MakeLower();
+                description.MakeLower();
+                notes.MakeLower();
+            }
+            if (ctMatchString(str, text2, matchWordOnly) ||
+                ctMatchString(description, text2, matchWordOnly) ||
+                ctMatchString(notes, text2, matchWordOnly))
+            {
+                found = next;
+            }
+        }
+        else
+            break; // Didn't find an item at all
+
+        i ++;
+    }
+    while (!found && item != next);
+
+    if (item == found && !firstInDoc)
+        return NULL;
+    else
+        return found;
+}
+
+void ctFindReplaceDialog::OnClose(wxFindDialogEvent& event)
+{
+    bool matchCase = ((event.GetFlags() & wxFR_MATCHCASE) != 0);
+    bool wholeWord = ((event.GetFlags() & wxFR_WHOLEWORD) != 0);
+    wxGetApp().GetSettings().m_matchCase = matchCase;
+    wxGetApp().GetSettings().m_matchWholeWord = wholeWord;
+
+    this->Destroy();
+    ((ctMainFrame*) GetParent())->SetFindDialog(NULL);
 }
 }