From: drowe67 Date: Sat, 30 Jan 2016 09:20:27 +0000 (+0000) Subject: added a first pass dialog for plug in config X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=860288e76b13f54658b4c6d06c5ac943ef906bc2;p=freetel-svn-tracking.git added a first pass dialog for plug in config git-svn-id: https://svn.code.sf.net/p/freetel/code@2671 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/freedv-dev/src/CMakeLists.txt b/freedv-dev/src/CMakeLists.txt index 01f39750..cba792fa 100644 --- a/freedv-dev/src/CMakeLists.txt +++ b/freedv-dev/src/CMakeLists.txt @@ -3,6 +3,7 @@ set(FREEDV_SOURCES dlg_filter.cpp dlg_options.cpp dlg_ptt.cpp + dlg_plugin.cpp fdmdv2_main.cpp fdmdv2_pa_wrapper.cpp fdmdv2_plot.cpp diff --git a/freedv-dev/src/dlg_plugin.cpp b/freedv-dev/src/dlg_plugin.cpp new file mode 100644 index 00000000..5ec31ad3 --- /dev/null +++ b/freedv-dev/src/dlg_plugin.cpp @@ -0,0 +1,142 @@ +//========================================================================== +// Name: dlg_plugin.cpp +// Purpose: Subclasses dialog GUI for PlugIn Config. Creates simple +// wxWidgets dialog GUI to set a few text strings. +// Date: Jan 2016 +// Authors: David Rowe +// +// License: +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2.1, +// as published by the Free Software Foundation. This program is +// distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, see . +// +//========================================================================== + +#include "dlg_plugin.h" +#include "fdmdv2_main.h" + +#ifdef __WIN32__ +#include +#endif +#if defined(__FreeBSD__) || defined(__WXOSX__) +#include +#include +#endif + +#include + +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= +// Class PlugInDlg +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= +PlugInDlg::PlugInDlg(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style) +{ + wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); + this->SetSizer(mainSizer); + + wxStaticBoxSizer* staticBoxSizer28a = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("Param1")), 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); + + //---------------------------------------------------------------------- + // OK - Cancel - Apply + //---------------------------------------------------------------------- + + wxBoxSizer* boxSizer12 = new wxBoxSizer(wxHORIZONTAL); + + m_buttonOK = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxSize(-1,-1), 0); + m_buttonOK->SetDefault(); + boxSizer12->Add(m_buttonOK, 0, wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, 5); + + m_buttonCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize(-1,-1), 0); + boxSizer12->Add(m_buttonCancel, 0, wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, 5); + + mainSizer->Add(boxSizer12, 0, wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL, 5); + + if ( GetSizer() ) + { + GetSizer()->Fit(this); + } + Centre(wxBOTH); + + // Connect events + this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(PlugInDlg::OnInitDialog), NULL, this); + m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PlugInDlg::OnOK), NULL, this); + m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PlugInDlg::OnCancel), NULL, this); + +} + +//------------------------------------------------------------------------- +// ~PlugInDlg() +//------------------------------------------------------------------------- +PlugInDlg::~PlugInDlg() +{ + // Disconnect Events + this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(PlugInDlg::OnInitDialog), NULL, this); + m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PlugInDlg::OnOK), NULL, this); + m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PlugInDlg::OnCancel), NULL, this); +} + +//------------------------------------------------------------------------- +// OnInitDialog() +//------------------------------------------------------------------------- +void PlugInDlg::OnInitDialog(wxInitDialogEvent& event) +{ + ExchangeData(EXCHANGE_DATA_IN); +} + + +//------------------------------------------------------------------------- +// ExchangeData() +//------------------------------------------------------------------------- +void PlugInDlg::ExchangeData(int inout) +{ + wxConfigBase *pConfig = wxConfigBase::Get(); + wxString str; + + if(inout == EXCHANGE_DATA_IN) + { + m_txtCtrlPlugIn1->SetValue(wxGetApp().m_txtPlugIn1); + m_txtCtrlPlugIn2->SetValue(wxGetApp().m_txtPlugIn2); + } + 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); + pConfig->Flush(); + } + delete wxConfigBase::Set((wxConfigBase *) NULL); +} + + +//------------------------------------------------------------------------- +// OnCancel() +//------------------------------------------------------------------------- +void PlugInDlg::OnCancel(wxCommandEvent& event) +{ + this->EndModal(wxID_CANCEL); +} + +//------------------------------------------------------------------------- +// OnClose() +//------------------------------------------------------------------------- +void PlugInDlg::OnOK(wxCommandEvent& event) +{ + ExchangeData(EXCHANGE_DATA_OUT); + this->EndModal(wxID_OK); +} diff --git a/freedv-dev/src/dlg_plugin.h b/freedv-dev/src/dlg_plugin.h new file mode 100644 index 00000000..e9bcb66c --- /dev/null +++ b/freedv-dev/src/dlg_plugin.h @@ -0,0 +1,66 @@ +//========================================================================== +// Name: dlg_ptt.h +// Purpose: Subclasses dialog GUI for PTT Config. +// +// Created: May. 11, 2012 +// Authors: David Rowe, David Witten +// +// License: +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2.1, +// as published by the Free Software Foundation. This program is +// distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +// License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, see . +// +//========================================================================== +#ifndef __PLUGIN_DIALOG__ +#define __PLUGIN_DIALOG__ + +#include "fdmdv2_main.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= +// Class PlugInDlg +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= +class PlugInDlg : public wxDialog +{ + public: + PlugInDlg(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plugin Config"), 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; + /* Ok - Cance */ + + wxButton* m_buttonOK; + wxButton* m_buttonCancel; + + +protected: + + void OnOK(wxCommandEvent& event); + void OnCancel(wxCommandEvent& event); + virtual void OnInitDialog(wxInitDialogEvent& event); +}; + +#endif // __PLUGIN_DIALOG__ diff --git a/freedv-dev/src/fdmdv2_main.cpp b/freedv-dev/src/fdmdv2_main.cpp index a45414a0..3f3464a8 100644 --- a/freedv-dev/src/fdmdv2_main.cpp +++ b/freedv-dev/src/fdmdv2_main.cpp @@ -2161,6 +2161,18 @@ void MainFrame::OnToolsComCfgUI(wxUpdateUIEvent& event) event.Enable(!m_RxRunning); } +//------------------------------------------------------------------------- +// OnToolsPlugInCfg() +//------------------------------------------------------------------------- +void MainFrame::OnToolsPlugInCfg(wxCommandEvent& event) +{ + wxUnusedVar(event); + PlugInDlg *dlg = new PlugInDlg(NULL); + dlg->ShowModal(); + delete dlg; +} + + //------------------------------------------------------------------------- // OnHelpCheckUpdates() //------------------------------------------------------------------------- @@ -2184,67 +2196,16 @@ void MainFrame::OnHelpCheckUpdatesUI(wxUpdateUIEvent& event) void MainFrame::OnHelpAbout(wxCommandEvent& event) { wxUnusedVar(event); -#ifdef _USE_ABOUT_DIALOG - int rv = 0; - AboutDlg *dlg = new AboutDlg(NULL); - rv = dlg->ShowModal(); - if(rv == wxID_OK) - { - dlg->ExchangeData(EXCHANGE_DATA_OUT); - } - delete dlg; -#else - wxString svnLatestRev("Can't determine latest SVN revision."); - - // Try to determine current SVN revision from the Internet - wxURL url(wxT("http://svn.code.sf.net/p/freetel/code/freedv-dev/")); - - if(url.GetError() == wxURL_NOERR) - { - wxString htmldata; - wxInputStream *in = url.GetInputStream(); - - if(in && in->IsOk()) - { - //printf("In OK\n"); - wxStringOutputStream html_stream(&htmldata); - in->Read(html_stream); - //wxLogDebug(htmldata); - - wxString s("

p/freetel/code - Revision "); - int startIndex = htmldata.find(s) + s.Length(); - int endIndex = htmldata.find(wxT(": /fdmdv2

")); - svnLatestRev = wxT("Latest svn revision: ") + htmldata.SubString(startIndex, endIndex-1); - //printf("startIndex: %d endIndex: %d\n", startIndex, endIndex); - } - delete in; - } - wxString msg; msg.Printf( wxT("FreeDV %s\n\n") - wxT("Open Source Narrow Band Digital Voice over Radio\n\n") + wxT("Open Source Digital Voice\n\n") wxT("For Help and Support visit: http://freedv.org\n\n") - wxT("How much have you spent on Ham gear this year? How did it compare to FreeDV? ") - wxT("FreeDV repesents an open and free future for digital voice over Ham Radio. ") - wxT("Please help by donating just $10 here: http://freedv.org\n\n") - wxT("GNU Public License V2.1\n\n") wxT("Copyright (c) David Witten KD0EAG and David Rowe VK5DGR\n\n") - wxT("svn revision: %s\n") + svnLatestRev, FREEDV_VERSION, SVN_REVISION); + wxT("svn revision: %s\n"), FREEDV_VERSION, SVN_REVISION); wxMessageBox(msg, wxT("About"), wxOK | wxICON_INFORMATION, this); - -#endif // _USE_ABOUT_DIALOG -#ifdef USE_SIMPLE_ABOUT_DIALOG - wxUnusedVar(event); - wxAboutDialogInfo info; - info.SetCopyright(_("HAMLib Test")); - info.SetLicence(_("GPL v2 or later")); - info.SetDescription(_("Short description goes here")); - ::wxAboutBox(info); -#endif // USE_SIMPLE_ABOUT_DIALOG - } @@ -2983,9 +2944,9 @@ void MainFrame::processTxtEvent(char event[]) { // if we found a match, lets run the replace regexp and issue the system command wxString event_str_rep = event_str; - + if (re.Replace(&event_str_rep, regexp_replace) != 0) { - //printf(" found match!\n"); + fprintf(stderr, " found match! event_str: %s\n", (const char *)event_str.c_str()); found_match = true; bool enableSystem = false; @@ -2996,7 +2957,7 @@ void MainFrame::processTxtEvent(char event[]) { if (spamTimer[rule].IsRunning()) { enableSystem = false; - //printf(" spam timer running\n"); + fprintf(stderr, " spam timer running\n"); } const char *event_out = event_str_rep.ToUTF8(); diff --git a/freedv-dev/src/fdmdv2_main.h b/freedv-dev/src/fdmdv2_main.h index 42a0b2bd..94e127ec 100644 --- a/freedv-dev/src/fdmdv2_main.h +++ b/freedv-dev/src/fdmdv2_main.h @@ -85,6 +85,7 @@ #include "varicode.h" #include "sox_biquad.h" #include "comp_prim.h" +#include "dlg_plugin.h" #define _USE_TIMER 1 #define _USE_ONIDLE 1 @@ -268,6 +269,11 @@ class MainApp : public wxApp bool loadConfig(); bool saveConfig(); + // Plugins ----------------------------------- + + wxString m_txtPlugIn1; + wxString m_txtPlugIn2; + // misc bool m_testFrames; @@ -495,6 +501,8 @@ class MainFrame : public TopFrame void OnToolsOptions(wxCommandEvent& event); void OnToolsOptionsUI(wxUpdateUIEvent& event); + void OnToolsPlugInCfg( wxCommandEvent& event ); + void OnPlayFileToMicIn( wxCommandEvent& event ); void StopPlayFileToMicIn(void); void OnRecFileFromRadio( wxCommandEvent& event ); diff --git a/freedv-dev/src/topFrame.cpp b/freedv-dev/src/topFrame.cpp index 1bd7d4e8..514d8949 100644 --- a/freedv-dev/src/topFrame.cpp +++ b/freedv-dev/src/topFrame.cpp @@ -68,6 +68,10 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const m_menuItemFilter = new wxMenuItem(tools, wxID_ANY, wxString(_("&Filter")) , wxEmptyString, wxITEM_NORMAL); tools->Append(m_menuItemFilter); + wxMenuItem* m_menuItemPlugIn; + m_menuItemPlugIn = new wxMenuItem(tools, wxID_ANY, wxString(_("PlugIn Config")) , wxEmptyString, wxITEM_NORMAL); + tools->Append(m_menuItemPlugIn); + wxMenuItem* m_menuItemPlayFileToMicIn; m_menuItemPlayFileToMicIn = new wxMenuItem(tools, wxID_ANY, wxString(_("Start/Stop Play File - Mic In")) , wxEmptyString, wxITEM_NORMAL); g_playFileToMicInEventId = m_menuItemPlayFileToMicIn->GetId(); @@ -471,6 +475,8 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const this->Connect(m_menuItemOptions->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnToolsOptions)); this->Connect(m_menuItemOptions->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler(TopFrame::OnToolsOptionsUI)); + this->Connect(m_menuItemPlugIn->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnToolsPlugInCfg)); + this->Connect(m_menuItemPlayFileToMicIn->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnPlayFileToMicIn)); this->Connect(m_menuItemRecFileFromRadio->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnRecFileFromRadio)); this->Connect(m_menuItemPlayFileFromRadio->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnPlayFileFromRadio)); @@ -528,6 +534,8 @@ TopFrame::~TopFrame() this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnToolsOptions)); this->Disconnect(wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(TopFrame::OnToolsOptionsUI)); + this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnToolsPlugInCfg)); + this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnPlayFileToMicIn)); this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnRecFileFromRadio)); this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnPlayFileFromRadio)); diff --git a/freedv-dev/src/topFrame.h b/freedv-dev/src/topFrame.h index 9d29053c..2cfe7291 100644 --- a/freedv-dev/src/topFrame.h +++ b/freedv-dev/src/topFrame.h @@ -125,6 +125,9 @@ class TopFrame : public wxFrame virtual void OnToolsFilter( wxCommandEvent& event ) { event.Skip(); } virtual void OnToolsFilterUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnToolsOptions( wxCommandEvent& event ) { event.Skip(); } + + virtual void OnToolsPlugInCfg( wxCommandEvent& event ) { event.Skip(); } + virtual void OnToolsUDP( wxCommandEvent& event ) { event.Skip(); } virtual void OnToolsOptionsUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnToolsComCfg( wxCommandEvent& event ) { event.Skip(); }