diff --git a/CMakeLists.txt b/CMakeLists.txt index cd4d4dd..9038704 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,6 +227,7 @@ SET (cubicsdr_sources src/CubicSDR.cpp src/AppFrame.cpp src/AppConfig.cpp + src/FrequencyDialog.cpp src/sdr/SDRThread.cpp src/sdr/SDRPostThread.cpp src/demod/DemodulatorPreThread.cpp @@ -269,6 +270,7 @@ SET (cubicsdr_headers src/CubicSDR.h src/AppFrame.h src/AppConfig.h + src/FrequencyDialog.h src/sdr/SDRThread.h src/sdr/SDRPostThread.h src/demod/DemodulatorPreThread.h diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index be24cd5..56cf539 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -13,7 +13,7 @@ #endif #include "CubicSDR.h" -#include "AppFrame.h" +#include "FrequencyDialog.h" #ifdef _OSX_APP_ #include "CoreFoundation/CoreFoundation.h" @@ -92,7 +92,7 @@ bool CubicSDR::OnInit() { t_PostSDR = new std::thread(&SDRPostThread::threadMain, sdrPostThread); t_SDR = new std::thread(&SDRThread::threadMain, sdrThread); - AppFrame *appframe = new AppFrame(); + appframe = new AppFrame(); #ifdef __APPLE__ int main_policy; @@ -271,3 +271,11 @@ int CubicSDR::getPPM() { return ppm; } + +void CubicSDR::showFrequencyInput() { + FrequencyDialog fdialog(appframe, -1, _("Set Frequency"), wxPoint(-100,-100), wxSize(320, 75 )); + + if ( fdialog.ShowModal() != wxID_OK ) { + } else { + } +} diff --git a/src/CubicSDR.h b/src/CubicSDR.h index 38975c3..dfc7e33 100644 --- a/src/CubicSDR.h +++ b/src/CubicSDR.h @@ -15,6 +15,7 @@ #include "AudioThread.h" #include "DemodulatorMgr.h" #include "AppConfig.h" +#include "AppFrame.h" #define NUM_DEMODULATORS 1 @@ -56,7 +57,10 @@ public: void setPPM(int ppm_in); int getPPM(); + void showFrequencyInput(); + private: + AppFrame *appframe; AppConfig config; PrimaryGLContext *m_glContext; std::vector devs; diff --git a/src/FrequencyDialog.cpp b/src/FrequencyDialog.cpp new file mode 100644 index 0000000..314559c --- /dev/null +++ b/src/FrequencyDialog.cpp @@ -0,0 +1,21 @@ +#include "FrequencyDialog.h" + +wxBEGIN_EVENT_TABLE(FrequencyDialog, wxDialog) wxEND_EVENT_TABLE() + +FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxString & title, const wxPoint & position, const wxSize & size, long style) : + wxDialog(parent, id, title, position, size, style) { + wxString freqStr = "105.7Mhz"; + + dialogText = new wxTextCtrl(this, -1, freqStr, wxPoint(6, 1), wxSize(size.GetWidth() - 20, size.GetHeight() - 70), wxTE_PROCESS_ENTER); + dialogText->SetFont(wxFont(20, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD)); + Connect(wxEVT_TEXT_ENTER, wxCommandEventHandler(FrequencyDialog::OnEnter)); + + SetEscapeId(wxID_CANCEL); + + Centre(); +} + +void FrequencyDialog::OnEnter(wxCommandEvent &event) { + std::cout << dialogText->GetValue().ToStdString() << std::endl; + Close(); +} diff --git a/src/FrequencyDialog.h b/src/FrequencyDialog.h new file mode 100644 index 0000000..37a83ff --- /dev/null +++ b/src/FrequencyDialog.h @@ -0,0 +1,25 @@ +#pragma once + +#include "wx/dialog.h" +#include "wx/textctrl.h" +#include "wx/string.h" +#include "wx/button.h" + + +class FrequencyDialog: public wxDialog +{ +public: + + FrequencyDialog ( wxWindow * parent, wxWindowID id, const wxString & title, + const wxPoint & pos = wxDefaultPosition, + const wxSize & size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE ); + + wxTextCtrl * dialogText; + +private: + + void OnEnter ( wxCommandEvent &event ); + + DECLARE_EVENT_TABLE() +}; diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 77cbdb9..657766d 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -299,16 +299,6 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) { wxGetApp().getDemodMgr().deleteThread(activeDemod); break; case 'S': - if (!activeDemod) { - break; - } - if (activeDemod->isSquelchEnabled()) { - activeDemod->setSquelchEnabled(false); - } else { - activeDemod->squelchAuto(); - } - break; - case WXK_SPACE: if (!activeDemod) { break; } @@ -318,6 +308,9 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) { activeDemod->setStereo(true); } break; + case WXK_SPACE: + wxGetApp().showFrequencyInput(); + break; default: event.Skip(); return; @@ -720,14 +713,14 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) { mouseTracker.setVertDragLock(true); mouseTracker.setHorizDragLock(false); - setStatusText("Click and drag to change demodulator bandwidth. D to delete, SPACE for stereo."); + setStatusText("Click and drag to change demodulator bandwidth. D to delete, S for stereo."); } else { SetCursor(wxCURSOR_SIZING); nextDragState = WF_DRAG_FREQUENCY; mouseTracker.setVertDragLock(true); mouseTracker.setHorizDragLock(false); - setStatusText("Click and drag to change demodulator frequency. D to delete, SPACE for stereo."); + setStatusText("Click and drag to change demodulator frequency. D to delete, S for stereo."); } } else { SetCursor(wxCURSOR_CROSS);