From 5c7ad6d52b2862915e58d97a626bcc8490307425 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sat, 30 Jan 2016 22:22:27 +0000 Subject: [PATCH] bulding up plugin-defined parameter names, compiles and running OK. Next step persistant storage git-svn-id: https://svn.code.sf.net/p/freetel/code@2673 01035d8c-6547-0410-b346-abe4f91aad63 --- freedv-dev/src/dlg_plugin.cpp | 36 +++++++++++++++++++--------------- freedv-dev/src/dlg_plugin.h | 15 +++++++------- freedv-dev/src/fdmdv2_main.cpp | 8 ++++---- freedv-dev/src/fdmdv2_main.h | 7 +++---- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/freedv-dev/src/dlg_plugin.cpp b/freedv-dev/src/dlg_plugin.cpp index 1e243ee3..0b1e47c3 100644 --- a/freedv-dev/src/dlg_plugin.cpp +++ b/freedv-dev/src/dlg_plugin.cpp @@ -36,21 +36,23 @@ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= // Class PlugInDlg //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= -PlugInDlg::PlugInDlg(const wxString& title, int numParams, wxString params[], wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style) +PlugInDlg::PlugInDlg(const wxString& title, int numParam, wxString paramName[], wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style) { + m_name = title; + m_numParam = numParam; + assert(m_numParam <= PLUGIN_MAX_PARAMS); wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); this->SetSizer(mainSizer); - wxStaticBoxSizer* staticBoxSizer28a = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, params[0]), wxVERTICAL); - m_txtCtrlPlugIn1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300,-1), 0); - staticBoxSizer28a->Add(m_txtCtrlPlugIn1, 0, 0, 5); - mainSizer->Add(staticBoxSizer28a, 0, wxEXPAND, 5); - - wxStaticBoxSizer* staticBoxSizer28b = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("Param2")), wxVERTICAL); - m_txtCtrlPlugIn2 = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300,-1), 0); - staticBoxSizer28b->Add(m_txtCtrlPlugIn2, 0, 0, 5); - mainSizer->Add(staticBoxSizer28b, 0, wxEXPAND, 5); + int i; + for (i=0; iAdd(m_txtCtrlParam[i], 0, 0, 5); + mainSizer->Add(staticBoxSizer28a, 0, wxEXPAND, 5); + } //---------------------------------------------------------------------- // OK - Cancel - Apply @@ -107,18 +109,20 @@ void PlugInDlg::ExchangeData(int inout) { wxConfigBase *pConfig = wxConfigBase::Get(); wxString str; + int i; if(inout == EXCHANGE_DATA_IN) { - m_txtCtrlPlugIn1->SetValue(wxGetApp().m_txtPlugIn1); - m_txtCtrlPlugIn2->SetValue(wxGetApp().m_txtPlugIn2); + for (i=0; iSetValue(wxGetApp().m_txtPlugInParam[i]); + } } if(inout == EXCHANGE_DATA_OUT) { - wxGetApp().m_txtPlugIn1 = m_txtCtrlPlugIn1->GetValue(); - pConfig->Write(wxT("/PlugIn/txt1"), wxGetApp().m_txtPlugIn1); - wxGetApp().m_txtPlugIn2 = m_txtCtrlPlugIn2->GetValue(); - pConfig->Write(wxT("/PlugIn/txt2"), wxGetApp().m_txtPlugIn2); + for (i=0; iGetValue(); + pConfig->Write(wxT("/PlugIn/" + m_name + "/" + m_paramName[i]), wxGetApp().m_txtPlugInParam[i]); + } pConfig->Flush(); } delete wxConfigBase::Set((wxConfigBase *) NULL); diff --git a/freedv-dev/src/dlg_plugin.h b/freedv-dev/src/dlg_plugin.h index 0f072655..72efc7bb 100644 --- a/freedv-dev/src/dlg_plugin.h +++ b/freedv-dev/src/dlg_plugin.h @@ -41,19 +41,18 @@ class PlugInDlg : public wxDialog { public: - PlugInDlg(const wxString& title = _("PTT Config"), int numParams = 0, wxString params[]=NULL, wxWindow* parent=NULL, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(450,300), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER); + PlugInDlg(const wxString& title = _("PTT Config"), int numParam = 0, wxString paramNames[]=NULL, wxWindow* parent=NULL, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(450,300), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER); virtual ~PlugInDlg(); void ExchangeData(int inout); protected: - wxTextCtrl *m_txtCtrlPlugIn1; - wxTextCtrl *m_txtCtrlPlugIn2; - wxTextCtrl *m_txtCtrlPlugIn3; + wxString m_name; + int m_numParam; + wxString m_paramName[PLUGIN_MAX_PARAMS]; - /* Ok - Cancel */ - - wxButton* m_buttonOK; - wxButton* m_buttonCancel; + wxTextCtrl* m_txtCtrlParam[PLUGIN_MAX_PARAMS]; + wxButton* m_buttonOK; + wxButton* m_buttonCancel; protected: diff --git a/freedv-dev/src/fdmdv2_main.cpp b/freedv-dev/src/fdmdv2_main.cpp index 00a41f26..9666786c 100644 --- a/freedv-dev/src/fdmdv2_main.cpp +++ b/freedv-dev/src/fdmdv2_main.cpp @@ -529,9 +529,9 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) m_plugIn = true; m_plugInName = "MyModem"; - m_numPlugInParams = 2; - m_plugInParams[0] = "Symbol Rate"; - m_plugInParams[1] = "Num Tones"; + m_numPlugInParam = 2; + m_plugInParamName[0] = "Symbol Rate"; + m_plugInParamName[1] = "Num Tones"; } //------------------------------------------------------------------------- @@ -2175,7 +2175,7 @@ void MainFrame::OnToolsComCfgUI(wxUpdateUIEvent& event) void MainFrame::OnToolsPlugInCfg(wxCommandEvent& event) { wxUnusedVar(event); - PlugInDlg *dlg = new PlugInDlg(m_plugInName, m_numPlugInParams, m_plugInParams); + PlugInDlg *dlg = new PlugInDlg(m_plugInName, m_numPlugInParam, m_plugInParamName); dlg->ShowModal(); delete dlg; } diff --git a/freedv-dev/src/fdmdv2_main.h b/freedv-dev/src/fdmdv2_main.h index 2f649035..acd99a68 100644 --- a/freedv-dev/src/fdmdv2_main.h +++ b/freedv-dev/src/fdmdv2_main.h @@ -271,8 +271,7 @@ class MainApp : public wxApp // Plugins ----------------------------------- - wxString m_txtPlugIn1; - wxString m_txtPlugIn2; + wxString m_txtPlugInParam[PLUGIN_MAX_PARAMS]; // misc @@ -583,8 +582,8 @@ class MainFrame : public TopFrame bool m_plugIn; wxString m_plugInName; - int m_numPlugInParams; - wxString m_plugInParams[PLUGIN_MAX_PARAMS]; + int m_numPlugInParam; + wxString m_plugInParamName[PLUGIN_MAX_PARAMS]; }; void txRxProcessing(); -- 2.25.1