// Licence:
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "configtoolview.h"
#endif
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()
ctConfigToolView::ctConfigToolView()
return TRUE;
}
-void ctConfigToolView::OnDraw(wxDC *dc)
+void ctConfigToolView::OnDraw(wxDC *WXUNUSED(dc))
{
}
}
// Clean up windows used for displaying the view.
-bool ctConfigToolView::OnClose(bool deleteWindow)
+bool ctConfigToolView::OnClose(bool WXUNUSED(deleteWindow))
{
if (!GetDocument()->Close())
return FALSE;
SyncItem(treeControl, item);
wxList considered;
- item->PropagateChange(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();
+ }
}
}
}
/// Add a checkbox item
-void ctConfigToolView::OnAddCheckBoxItem(wxCommandEvent& event)
+void ctConfigToolView::OnAddCheckBoxItem(wxCommandEvent& WXUNUSED(event))
{
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
-void ctConfigToolView::OnAddGroupItem(wxCommandEvent& event)
+void ctConfigToolView::OnAddGroupItem(wxCommandEvent& WXUNUSED(event))
{
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
-void ctConfigToolView::OnAddRadioGroupItem(wxCommandEvent& event)
+void ctConfigToolView::OnAddRadioGroupItem(wxCommandEvent& WXUNUSED(event))
{
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"));
}
}
/// Delete an item
-void ctConfigToolView::OnDeleteItem(wxCommandEvent& event)
+void ctConfigToolView::OnDeleteItem(wxCommandEvent& WXUNUSED(event))
{
ctConfigItem* sel = GetSelection();
if (sel)
}
/// Rename an item
-void ctConfigToolView::OnRenameItem(wxCommandEvent& event)
+void ctConfigToolView::OnRenameItem(wxCommandEvent& WXUNUSED(event))
{
ctConfigItem* sel = GetSelection();
if (sel)
}
/// Copy an item to the clipboard
-void ctConfigToolView::OnCopy(wxCommandEvent& event)
+void ctConfigToolView::OnCopy(wxCommandEvent& WXUNUSED(event))
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
}
/// 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();
}
/// 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();
}
/// 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();
}
/// 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();
}
/// 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();
}
/// 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();
}
/// 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();
}
/// Item help
-void ctConfigToolView::OnItemHelp(wxCommandEvent& event)
+void ctConfigToolView::OnItemHelp(wxCommandEvent& WXUNUSED(event))
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
if ( doc && GetSelection() )
}
/// Add a custom property
-void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& event)
+void ctConfigToolView::OnAddCustomProperty(wxCommandEvent& WXUNUSED(event))
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
}
/// Edit a custom property
-void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& event)
+void ctConfigToolView::OnEditCustomProperty(wxCommandEvent& WXUNUSED(event))
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
}
/// Delete a custom property
-void ctConfigToolView::OnDeleteCustomProperty(wxCommandEvent& event)
+void ctConfigToolView::OnDeleteCustomProperty(wxCommandEvent& WXUNUSED(event))
{
ctConfigToolDoc* doc = (ctConfigToolDoc*) GetDocument();
ctConfigItem* sel = GetSelection();
}
}
-void ctConfigToolView::OnSaveSetupFile(wxCommandEvent& event)
+void ctConfigToolView::OnSaveSetupFile(wxCommandEvent& WXUNUSED(event))
{
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.IsEmpty())
+ path = doc->GetFrameworkDir(FALSE);
wxString wildcard = _T("Header files (*.h)|*.h|All files (*.*)|*.*");
wxFileDialog dialog(wxTheApp->GetTopWindow(),
if (dialog.ShowModal() == wxID_OK)
{
wxString fullPath = dialog.GetPath();
-
- // TODO: save last saved path in settings.
+ wxGetApp().GetSettings().m_lastSetupSaveDir = wxPathOnly(fullPath);
wxFileOutputStream stream(fullPath);
if (!stream.Ok())
}
}
-void ctConfigToolView::OnSaveConfigureCommand(wxCommandEvent& event)
+void ctConfigToolView::OnSaveConfigureCommand(wxCommandEvent& WXUNUSED(event))
{
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.IsEmpty())
+ path = doc->GetFrameworkDir(FALSE);
wxString wildcard = _T("Shell script files (*.sh)|*.sh|All files (*.*)|*.*");
wxFileDialog dialog(wxTheApp->GetTopWindow(),
if (dialog.ShowModal() == wxID_OK)
{
wxString fullPath = dialog.GetPath();
-
- // TODO: save last saved path in settings.
+ wxGetApp().GetSettings().m_lastSetupSaveDir = wxPathOnly(fullPath);
wxFileOutputStream stream(fullPath);
if (!stream.Ok())
}
/// Find text
-void ctConfigToolView::OnFind(wxCommandEvent& event)
+void ctConfigToolView::OnFind(wxCommandEvent& WXUNUSED(event))
{
ctFindReplaceDialog* dialog = wxGetApp().GetMainFrame()->GetFindDialog();
if (dialog)
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.IsEmpty())
+ {
+ 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.IsEmpty());
+}
+
//----------------------------------------------------------------------------
// ctFindReplaceDialog
//----------------------------------------------------------------------------