bulding up plugin-defined parameter names, compiles and running OK. Next step persis...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 30 Jan 2016 22:22:27 +0000 (22:22 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 30 Jan 2016 22:22:27 +0000 (22:22 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2673 01035d8c-6547-0410-b346-abe4f91aad63

freedv-dev/src/dlg_plugin.cpp
freedv-dev/src/dlg_plugin.h
freedv-dev/src/fdmdv2_main.cpp
freedv-dev/src/fdmdv2_main.h

index 1e243ee3f535ef7b7029e74960fd0ddab1b3e151..0b1e47c3f0e7fe84a3a09c7646e174c2543c2abe 100644 (file)
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
 // 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; i<m_numParam; i++) {
+        m_paramName[i] = paramName[i];
+        wxStaticBoxSizer* staticBoxSizer28a = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, m_paramName[i]), wxVERTICAL);
+        m_txtCtrlParam[i]= new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300,-1), 0);
+        staticBoxSizer28a->Add(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; i<m_numParam; i++) {
+            m_txtCtrlParam[i]->SetValue(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; i<m_numParam; i++) {
+          wxGetApp().m_txtPlugInParam[i] = m_txtCtrlParam[i]->GetValue();
+          pConfig->Write(wxT("/PlugIn/" + m_name + "/" + m_paramName[i]), wxGetApp().m_txtPlugInParam[i]);
+        }
         pConfig->Flush();
     }
     delete wxConfigBase::Set((wxConfigBase *) NULL);
index 0f072655146848c7b5181972fd3e0c50f79ad55c..72efc7bb30b514c049b0116a276de4c848bb9c9e 100644 (file)
 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:
index 00a41f26b119d994881d3d6cead181eac74e2f66..9666786c3128ec812cf2be18c9cae432c2756b42 100644 (file)
@@ -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;
 }
index 2f649035ed11d9dc28ee7cd351b3246730269fb6..acd99a68ce2050722cd7810fc0cedb02b253c576 100644 (file)
@@ -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();