MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / FrequencyDialog

Method FrequencyDialog

src/FrequencyDialog.cpp:16–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14wxEND_EVENT_TABLE()
15
16FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxString & title, DemodulatorInstancePtr demod, const wxPoint & /*position*/,
17 const wxSize & /*size*/, long style, FrequencyDialogTarget targetMode, wxString initString) :
18 wxDialog(parent, id, title, wxDefaultPosition, wxDefaultSize, style) {
19 wxString freqStr;
20
21 activeDemod = demod;
22
23 this->targetMode = targetMode;
24 this->initialString = initString;
25
26 if (targetMode == FDIALOG_TARGET_DEFAULT) {
27 if (activeDemod) {
28 freqStr = frequencyToStr(activeDemod->getFrequency());
29 } else {
30 freqStr = frequencyToStr(wxGetApp().getFrequency());
31 }
32 }
33
34 if (targetMode == FDIALOG_TARGET_BANDWIDTH) {
35 std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType();
36 if (lastDemodType == "USB" || lastDemodType == "LSB") {
37 freqStr = frequencyToStr(wxGetApp().getDemodMgr().getLastBandwidth()/2);
38 } else {
39 freqStr = frequencyToStr(wxGetApp().getDemodMgr().getLastBandwidth());
40 }
41 }
42
43 if (targetMode == FDIALOG_TARGET_WATERFALL_LPS) {
44 freqStr = std::to_string(wxGetApp().getAppFrame()->getWaterfallDataThread()->getLinesPerSecond());
45 }
46
47 if (targetMode == FDIALOG_TARGET_SPECTRUM_AVG) {
48 freqStr = std::to_string(wxGetApp().getSpectrumProcessor()->getFFTAverageRate());
49 }
50
51 if (targetMode == FDIALOG_TARGET_GAIN) {
52 if (!wxGetApp().getActiveGainEntry().empty()) {
53 freqStr = std::to_string((int)wxGetApp().getGain(wxGetApp().getActiveGainEntry()));
54 }
55 }
56 dialogText = new wxTextCtrl(this, wxID_FREQ_INPUT, freqStr, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
57 dialogText->SetFont(wxFont(15, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
58
59 // Set the textControl width to the [title + 100%] or the [content +100%],
60 // whichever's the greater.
61 int textCtrlX = dialogText->GetTextExtent(freqStr).GetWidth();
62 int initTextCtrlX = dialogText->GetTextExtent(initString).GetWidth();
63 int titleX = this->GetTextExtent(title).GetWidth();
64 dialogText->SetMinSize(wxSize(max(int(2.0 * titleX), int(2.0 * std::max(textCtrlX, initTextCtrlX))), -1));
65
66 auto* dialogsizer = new wxBoxSizer(wxALL);
67 dialogsizer->Add(dialogText, wxSizerFlags(1).Expand().Border(wxALL, 5));
68 SetSizerAndFit(dialogsizer);
69 Centre();
70
71 if (!initString.empty() && initString.length() == 1) {
72 dialogText->SetValue(initString);
73 dialogText->SetSelection(2, 2);

Callers

nothing calls this directly

Calls 15

frequencyToStrFunction · 0.85
getDemodulatorTypeMethod · 0.80
getLastBandwidthMethod · 0.80
getAppFrameMethod · 0.80
getFFTAverageRateMethod · 0.80
getSpectrumProcessorMethod · 0.80
getActiveGainEntryMethod · 0.80
AddMethod · 0.80
getFrequencyMethod · 0.45
getLinesPerSecondMethod · 0.45

Tested by

no test coverage detected