]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/configtool/src/configtoolview.cpp
Removed rules for copying the Mac resource file since they are no
[wxWidgets.git] / utils / configtool / src / configtoolview.cpp
index 7401279af43cd6fa8cb93029651e4bdadd5ef6c1..59668482b398603efccdd459409abf2cf45060bd 100644 (file)
     #pragma implementation "configtoolview.h"
 #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__
-    #pragma hdrstop
+#pragma hdrstop
 #endif
 
 #include "wx/wfstream.h"
-
+#include "wx/txtstrm.h"
 #include "configtoolview.h"
 #include "configtooldoc.h"
 #include "configtree.h"
@@ -81,7 +81,7 @@ BEGIN_EVENT_TABLE(ctConfigToolView, wxView)
     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)
@@ -96,20 +96,16 @@ 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) )
 {
-    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) ;
 
-    return TRUE;
+    return true;
 }
 
 void ctConfigToolView::OnDraw(wxDC *WXUNUSED(dc))
@@ -122,11 +118,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())
     {
@@ -134,12 +130,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:
@@ -152,12 +148,12 @@ void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
             }
         }
         break;
-    case ctSelChanged:        
+    case ctSelChanged:
         {
             if (selItem)
             {
                 wxGetApp().GetMainFrame()->GetPropertyEditor()->ShowItem(selItem);
-            }            
+            }
         }
         break;
     case ctAllSaved:
@@ -176,14 +172,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;
     }
@@ -193,20 +189,20 @@ void ctConfigToolView::OnUpdate(wxView *WXUNUSED(sender), wxObject *hintObj)
 bool ctConfigToolView::OnClose(bool WXUNUSED(deleteWindow))
 {
     if (!GetDocument()->Close())
-        return FALSE;
+        return false;
 
     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) ;
 
-    return TRUE;
+    return true;
 }
 
 void ctConfigToolView::OnChangeFilename()
@@ -235,12 +231,12 @@ void ctConfigToolView::OnChangeFilename()
 // General disabler
 void ctConfigToolView::OnUpdateDisable(wxUpdateUIEvent& event)
 {
-    event.Enable( FALSE );
+    event.Enable( false );
 }
 
 void ctConfigToolView::OnUpdateAddItem(wxUpdateUIEvent& event)
 {
-    event.Enable( TRUE );
+    event.Enable( true );
 }
 
 /// Add item and its children to the tree
@@ -264,7 +260,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
         {
@@ -349,7 +345,7 @@ void ctConfigToolView::OnIconLeftDown(ctConfigTreeCtrl* treeControl, ctConfigIte
 
         item->Enable(!item->IsEnabled());
 
-        GetDocument()->Modify(TRUE);
+        GetDocument()->Modify(true);
         OnChangeFilename();
 
         SyncItem(treeControl, item);
@@ -428,9 +424,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 ;
@@ -444,7 +439,7 @@ void ctConfigToolView::AddItem(ctConfigType type, const wxString& msg)
                 parent = sel->GetParent();
                 insertBefore = sel->FindNextSibling();
             }
-            
+
             ctConfigItem* newItem = new ctConfigItem(NULL, type, name);
             newItem->InitProperties();
 
@@ -479,7 +474,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);
@@ -635,7 +630,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);
@@ -691,7 +686,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);
         }
@@ -714,7 +709,7 @@ void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& WXUNUSED(event))
     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();
@@ -731,14 +726,14 @@ void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& WXUNUSED(event))
             }
             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
-                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);
@@ -767,9 +762,9 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& WXUNUSED(event))
             wxString oldType = property->GetVariant().GetType();
             wxString oldEditorType = property->GetEditorType();
             wxArrayString oldChoices = property->GetChoices();
-            
+
             ctCustomPropertyDialog dialog(wxGetApp().GetMainFrame(),
-                -1, _("Edit custom property"));
+                wxID_ANY, _("Edit custom property"));
             dialog.SetPropertyName(oldName);
             dialog.SetPropertyType(oldType);
             dialog.SetPropertyDescription(oldDescription);
@@ -780,7 +775,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"),
@@ -790,13 +785,13 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& WXUNUSED(event))
                 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
-                        property->GetVariant() = wxVariant(wxT(""), name);
+                        property->GetVariant() = wxVariant(wxEmptyString, name);
                 }
                 if (name != oldName)
                     property->GetVariant().SetName(name);
@@ -810,11 +805,11 @@ void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& WXUNUSED(event))
                 if (name != oldName)
                     property->GetVariant().SetName(name);
 
-                property->SetCustom(TRUE);
+                property->SetCustom(true);
 
                 if (descr != oldDescription)
                     property->SetDescription(descr);
-                
+
                 editor->ShowItem(sel);
                 OnChangeFilename();
             }
@@ -915,29 +910,30 @@ void ctConfigToolView::OnSaveSetupFile(wxCommandEvent& WXUNUSED(event))
 
     wxString filename = _T("setup.h");
     wxString path = wxGetApp().GetSettings().m_lastSetupSaveDir;
-    if (path.IsEmpty())
-        path = doc->GetFrameworkDir(FALSE);
+    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);
-    
+
     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))
@@ -947,39 +943,40 @@ void ctConfigToolView::OnSaveConfigureCommand(wxCommandEvent& WXUNUSED(event))
 
     wxString filename = _T("configurewx.sh");
     wxString path = wxGetApp().GetSettings().m_lastSetupSaveDir;
-    if (path.IsEmpty())
-        path = doc->GetFrameworkDir(FALSE);
+    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);
-    
+
     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)
 {
-    event.Enable(TRUE);
+    event.Enable(true);
 }
 
 void ctConfigToolView::OnUpdateSaveConfigureCommand(wxUpdateUIEvent& event)
 {
-    event.Enable(TRUE);
+    event.Enable(true);
 }
 
 /// Find text
@@ -1004,14 +1001,14 @@ void ctConfigToolView::OnFind(wxCommandEvent& WXUNUSED(event))
         ctFindReplaceDialog::sm_findData.SetFlags(flags);
 
         dialog = new ctFindReplaceDialog(wxGetApp().GetMainFrame(), caption, style);
-        dialog->Show(TRUE);
+        dialog->Show(true);
     }
 }
 
 /// Update find text
 void ctConfigToolView::OnUpdateFind(wxUpdateUIEvent& event)
 {
-    event.Enable(TRUE);
+    event.Enable(true);
 }
 
 /// Save default file type
@@ -1019,7 +1016,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"))
         {
@@ -1080,7 +1077,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());
 }
 
 //----------------------------------------------------------------------------
@@ -1088,9 +1085,9 @@ void ctConfigToolView::OnUpdateGo(wxUpdateUIEvent& event)
 //----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(ctFindReplaceDialog, wxFindReplaceDialog)
-    EVT_FIND(-1, ctFindReplaceDialog::OnFind)
-    EVT_FIND_NEXT(-1, ctFindReplaceDialog::OnFind)
-    EVT_FIND_CLOSE(-1, ctFindReplaceDialog::OnClose)
+    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;
@@ -1125,7 +1122,7 @@ bool ctFindReplaceDialog::DoFind(const wxString& textToFind, bool matchCase, boo
 {
     ctConfigToolDoc* doc = wxGetApp().GetMainFrame()->GetDocument();
     if (!doc)
-        return FALSE;
+        return false;
     ctConfigToolView* view = (ctConfigToolView*) doc->GetFirstView();
 
     ctConfigItem* currentItem = NULL;
@@ -1134,10 +1131,10 @@ bool ctFindReplaceDialog::DoFind(const wxString& textToFind, bool matchCase, boo
     {
         focusItem = doc->GetTopItem();
         if (!focusItem)
-            return FALSE;
+            return false;
     }
 
-    if (!sm_currentItem.IsEmpty())
+    if (!sm_currentItem.empty())
     {
         currentItem = doc->GetTopItem()->FindItem(sm_currentItem);
     }
@@ -1151,14 +1148,14 @@ bool ctFindReplaceDialog::DoFind(const wxString& textToFind, bool matchCase, boo
     {
         sm_currentItem = currentItem->GetName();
         wxGetApp().GetMainFrame()->GetConfigTreeCtrl()->SelectItem(currentItem->GetTreeItemId());
-        return TRUE;
+        return true;
     }
     else
     {
         sm_currentItem = wxEmptyString;
     }
 
-    return FALSE;
+    return false;
 }
 
 ctConfigItem* ctFindReplaceDialog::FindNextItem(ctConfigToolDoc* doc,