Update frequency dialog to support bandwidth entry
This commit is contained in:
parent
8dc2e6cacc
commit
8c7d2576ad
|
@ -13,7 +13,6 @@
|
|||
#endif
|
||||
|
||||
#include "CubicSDR.h"
|
||||
#include "FrequencyDialog.h"
|
||||
|
||||
#ifdef _OSX_APP_
|
||||
#include "CoreFoundation/CoreFoundation.h"
|
||||
|
@ -389,8 +388,25 @@ int CubicSDR::getPPM() {
|
|||
}
|
||||
|
||||
|
||||
void CubicSDR::showFrequencyInput() {
|
||||
FrequencyDialog fdialog(appframe, -1, demodMgr.getActiveDemodulator()?_("Set Demodulator Frequency"):_("Set Center Frequency"), demodMgr.getActiveDemodulator(), wxPoint(-100,-100), wxSize(320, 75 ));
|
||||
void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode) {
|
||||
const wxString demodTitle("Set Demodulator Frequency");
|
||||
const wxString freqTitle("Set Center Frequency");
|
||||
const wxString bwTitle("Set Demodulator Bandwidth");
|
||||
|
||||
wxString title;
|
||||
|
||||
switch (targetMode) {
|
||||
case FrequencyDialog::FDIALOG_TARGET_DEFAULT:
|
||||
title = demodMgr.getActiveDemodulator()?demodTitle:freqTitle;
|
||||
break;
|
||||
case FrequencyDialog::FDIALOG_TARGET_BANDWIDTH:
|
||||
title = bwTitle;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
FrequencyDialog fdialog(appframe, -1, title, demodMgr.getActiveDemodulator(), wxPoint(-100,-100), wxSize(320, 75 ), wxDEFAULT_DIALOG_STYLE, targetMode);
|
||||
fdialog.ShowModal();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "DemodulatorMgr.h"
|
||||
#include "AppConfig.h"
|
||||
#include "AppFrame.h"
|
||||
#include "FrequencyDialog.h"
|
||||
|
||||
#include "ScopeVisualProcessor.h"
|
||||
#include "SpectrumVisualProcessor.h"
|
||||
|
@ -77,7 +78,7 @@ public:
|
|||
void setPPM(int ppm_in);
|
||||
int getPPM();
|
||||
|
||||
void showFrequencyInput();
|
||||
void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT);
|
||||
|
||||
private:
|
||||
AppFrame *appframe;
|
||||
|
|
|
@ -10,15 +10,22 @@ EVT_CHAR_HOOK(FrequencyDialog::OnChar)
|
|||
wxEND_EVENT_TABLE()
|
||||
|
||||
FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxString & title, DemodulatorInstance *demod, const wxPoint & position,
|
||||
const wxSize & size, long style) :
|
||||
const wxSize & size, long style, FrequencyDialogTarget targetMode) :
|
||||
wxDialog(parent, id, title, position, size, style) {
|
||||
wxString freqStr;
|
||||
activeDemod = demod;
|
||||
this->targetMode = targetMode;
|
||||
|
||||
if (activeDemod) {
|
||||
freqStr = frequencyToStr(activeDemod->getFrequency());
|
||||
} else {
|
||||
freqStr = frequencyToStr(wxGetApp().getFrequency());
|
||||
if (targetMode == FDIALOG_TARGET_DEFAULT) {
|
||||
if (activeDemod) {
|
||||
freqStr = frequencyToStr(activeDemod->getFrequency());
|
||||
} else {
|
||||
freqStr = frequencyToStr(wxGetApp().getFrequency());
|
||||
}
|
||||
}
|
||||
|
||||
if (targetMode == FDIALOG_TARGET_BANDWIDTH) {
|
||||
freqStr = frequencyToStr(wxGetApp().getDemodMgr().getLastBandwidth());
|
||||
}
|
||||
|
||||
dialogText = new wxTextCtrl(this, wxID_FREQ_INPUT, freqStr, wxPoint(6, 1), wxSize(size.GetWidth() - 20, size.GetHeight() - 70),
|
||||
|
@ -109,14 +116,23 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) {
|
|||
case WXK_NUMPAD_ENTER:
|
||||
// Do Stuff
|
||||
freq = strToFrequency(dialogText->GetValue().ToStdString());
|
||||
if (activeDemod) {
|
||||
activeDemod->setTracking(true);
|
||||
activeDemod->setFollow(true);
|
||||
activeDemod->setFrequency(freq);
|
||||
activeDemod->updateLabel(freq);
|
||||
} else {
|
||||
wxGetApp().setFrequency(freq);
|
||||
}
|
||||
if (targetMode == FDIALOG_TARGET_DEFAULT) {
|
||||
if (activeDemod) {
|
||||
activeDemod->setTracking(true);
|
||||
activeDemod->setFollow(true);
|
||||
activeDemod->setFrequency(freq);
|
||||
activeDemod->updateLabel(freq);
|
||||
} else {
|
||||
wxGetApp().setFrequency(freq);
|
||||
}
|
||||
}
|
||||
if (targetMode == FDIALOG_TARGET_BANDWIDTH) {
|
||||
if (activeDemod) {
|
||||
activeDemod->setBandwidth(freq);
|
||||
} else {
|
||||
wxGetApp().getDemodMgr().setLastBandwidth(freq);
|
||||
}
|
||||
}
|
||||
Close();
|
||||
break;
|
||||
case WXK_ESCAPE:
|
||||
|
|
|
@ -11,12 +11,13 @@
|
|||
class FrequencyDialog: public wxDialog
|
||||
{
|
||||
public:
|
||||
|
||||
typedef enum FrequencyDialogTarget { FDIALOG_TARGET_DEFAULT, FDIALOG_TARGET_CENTERFREQ, FDIALOG_TARGET_FREQ, FDIALOG_TARGET_BANDWIDTH } FrequencyDialogTarget;
|
||||
FrequencyDialog ( wxWindow * parent, wxWindowID id, const wxString & title,
|
||||
DemodulatorInstance *demod = NULL,
|
||||
const wxPoint & pos = wxDefaultPosition,
|
||||
const wxSize & size = wxDefaultSize,
|
||||
long style = wxDEFAULT_DIALOG_STYLE );
|
||||
long style = wxDEFAULT_DIALOG_STYLE,
|
||||
FrequencyDialogTarget targetMode = FDIALOG_TARGET_DEFAULT);
|
||||
|
||||
wxTextCtrl * dialogText;
|
||||
|
||||
|
@ -28,5 +29,6 @@ private:
|
|||
void OnEnter ( wxCommandEvent &event );
|
||||
void OnChar ( wxKeyEvent &event );
|
||||
std::string& filterChars(std::string& s, const std::string& allowed);
|
||||
FrequencyDialogTarget targetMode;
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
|
|
@ -407,8 +407,12 @@ void TuningCanvas::setHelpTip(std::string tip) {
|
|||
void TuningCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
InteractiveCanvas::OnKeyDown(event);
|
||||
|
||||
if (event.GetKeyCode() == WXK_SPACE && (hoverState == TUNING_HOVER_CENTER || hoverState == TUNING_HOVER_FREQ)) {
|
||||
wxGetApp().showFrequencyInput();
|
||||
if (event.GetKeyCode() == WXK_SPACE) {
|
||||
if (hoverState == TUNING_HOVER_CENTER || hoverState == TUNING_HOVER_FREQ) {
|
||||
wxGetApp().showFrequencyInput(FrequencyDialog::FDIALOG_TARGET_DEFAULT);
|
||||
} else if (hoverState == TUNING_HOVER_BW) {
|
||||
wxGetApp().showFrequencyInput(FrequencyDialog::FDIALOG_TARGET_BANDWIDTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue