diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 255dc6a..4051537 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -483,7 +483,7 @@ ModeSelectorCanvas *AppFrame::makeModemAdvSelectorPanel(wxPanel *parent, const w #ifdef USE_HAMLIB wxMenu *AppFrame::makeRigMenu() { - wxMenu *pMenu = new wxMenu; + auto *pMenu = new wxMenu; rigEnableMenuItem = pMenu->AppendCheckItem(wxID_RIG_TOGGLE, wxT("Enable Rig")); @@ -501,20 +501,37 @@ wxMenu *AppFrame::makeRigMenu() { rigFollowModemMenuItem = pMenu->AppendCheckItem(wxID_RIG_FOLLOW_MODEM, wxT("Track Modem")); rigFollowModemMenuItem->Check(wxGetApp().getConfig()->getRigFollowModem()); - wxMenu *rigModelMenu = new wxMenu; + auto *rigModelMenu = new wxMenu; RigList &rl = RigThread::enumerate(); - numRigs = rl.size(); + + std::map mfgCount; + std::map mfgMenu; + for (auto ri : rl) { + mfgCount[ri->mfg_name]++; + } int modelMenuId = wxID_RIG_MODEL_BASE; - for (auto ri = rl.begin(); ri != rl.end(); ri++) { - string modelString((*ri)->mfg_name); + + for (auto ri : rl) { + string modelString(ri->mfg_name); modelString.append(" "); - modelString.append((*ri)->model_name); + modelString.append(ri->model_name); - rigModelMenuItems[(*ri)->rig_model] = rigModelMenu->AppendRadioItem(modelMenuId, modelString, wxT("Description?")); + wxMenu *parentMenu = nullptr; - if (rigModel == (*ri)->rig_model) { - rigModelMenuItems[(*ri)->rig_model]->Check(true); + if (mfgCount[ri->mfg_name] > 1) { + if (mfgMenu.find(ri->mfg_name) == mfgMenu.end()) { + rigModelMenu->AppendSubMenu(mfgMenu[ri->mfg_name] = new wxMenu(), ri->mfg_name); + } + parentMenu = mfgMenu[ri->mfg_name]; + } else { + parentMenu = rigModelMenu; + } + + rigModelMenuItems[ri->rig_model] = parentMenu->AppendCheckItem(modelMenuId, modelString, ri->copyright); + + if (rigModel == ri->rig_model) { + rigModelMenuItems[ri->rig_model]->Check(true); } modelMenuId++; @@ -522,7 +539,7 @@ wxMenu *AppFrame::makeRigMenu() { pMenu->AppendSubMenu(rigModelMenu, wxT("Model")); - wxMenu *rigSerialMenu = new wxMenu; + auto *rigSerialMenu = new wxMenu; rigSerialRates.push_back(1200); rigSerialRates.push_back(2400); @@ -536,15 +553,15 @@ wxMenu *AppFrame::makeRigMenu() { rigSerialRates.push_back(256000); int rateMenuId = wxID_RIG_SERIAL_BASE; - for (auto rate_i = rigSerialRates.begin(); rate_i != rigSerialRates.end(); rate_i++) { + for (auto rate_i : rigSerialRates) { string rateString; - rateString.append(std::to_string((*rate_i))); + rateString.append(std::to_string(rate_i)); rateString.append(" baud"); - rigSerialMenuItems[(*rate_i)] = rigSerialMenu->AppendRadioItem(rateMenuId, rateString, wxT("Description?")); + rigSerialMenuItems[rate_i] = rigSerialMenu->AppendRadioItem(rateMenuId, rateString, wxT("Description?")); - if (rigSerialRate == (*rate_i)) { - rigSerialMenuItems[(*rate_i)]->Check(true); + if (rigSerialRate == rate_i) { + rigSerialMenuItems[rate_i]->Check(true); } rateMenuId++; @@ -1822,12 +1839,16 @@ bool AppFrame::actionOnMenuRig(wxCommandEvent &event) { bool resetRig = false; if (event.GetId() >= wxID_RIG_MODEL_BASE && event.GetId() < wxID_RIG_MODEL_BASE + numRigs) { + int rigIdx = event.GetId() - wxID_RIG_MODEL_BASE; + RigList &rl = RigThread::enumerate(); rigModel = rl[rigIdx]->rig_model; + if (devInfo != nullptr) { std::string deviceId = devInfo->getDeviceId(); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(deviceId); + rigSDRIF = devConfig->getRigIF(rigModel); if (rigSDRIF) { wxGetApp().lockFrequency(rigSDRIF); @@ -1837,9 +1858,15 @@ bool AppFrame::actionOnMenuRig(wxCommandEvent &event) { } else { wxGetApp().unlockFrequency(); } - resetRig = true; + resetRig = true; bManaged = true; + + for (auto ri : rigModelMenuItems) { + ri.second->Check(false); + } + + rigModelMenuItems[rigModel]->Check(true); } int rigSerialIdMax = wxID_RIG_SERIAL_BASE + rigSerialRates.size(); diff --git a/src/forms/Dialog/PortSelectorDialog.fbp b/src/forms/Dialog/PortSelectorDialog.fbp index 4637dbf..19f26a4 100644 --- a/src/forms/Dialog/PortSelectorDialog.fbp +++ b/src/forms/Dialog/PortSelectorDialog.fbp @@ -1,8 +1,8 @@ - + - + C++ 1 source_name @@ -14,11 +14,12 @@ PortSelectorDialogBase 1000 none + 0 PortSelectorDialog - + . - + 1 1 1 @@ -29,151 +30,93 @@ 0 wxAUI_MGR_DEFAULT - + wxBOTH - + 1 1 impl_virtual - - - + + + 0 wxID_ANY - - + + 300,200 PortSelectorDialogBase - - 304,197 - wxDEFAULT_DIALOG_STYLE - + + 320,260 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + Select Port - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + dlgSizer wxVERTICAL none 5 - wxEXPAND|wxALL + wxALIGN_CENTER|wxTOP 0 1 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Select a detected port or enter your own - + 0 + 0 - - + + 0 - + 1 m_staticText1 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -185,538 +128,360 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 - + 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - + + 0 - + 1 m_portList 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - + + + + onListSelect - - - - - - - - - - - - - - 5 wxEXPAND - 1 + 0 -1,30 bSizer3 wxHORIZONTAL none - + 5 - wxALL|wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Port - + 0 + 0 - - + + 0 - + 1 m_staticText2 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - - + 5 - wxEXPAND|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxALL 1 - + 1 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - - - + + + 0 - + 1 m_portSelection 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + 5 - wxEXPAND | wxALL + wxEXPAND 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_buttonPanel - 1 - - - protected - 1 - - Resizable - 1 - - - 0 - - - - wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - bSizer2 - wxHORIZONTAL - none - - 5 - wxALL|wxALIGN_BOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Cancel - - 0 - - - 0 - - 1 - m_cancelButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onCancelButton - - - - - - - - - - - - - - - - - - - - - - - - + + + bSizer2 + wxHORIZONTAL + none + + 5 + wxALL|wxALIGN_BOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Cancel + + 0 + + 0 + + + 0 + + 1 + m_cancelButton + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onCancelButton - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 - - 5 - wxALL|wxALIGN_BOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - OK - - 0 - - - 0 - - 1 - m_okButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onOKButton - - - - - - - - - - - - - - - - - - - - - - - - + + + 5 + wxALL|wxALIGN_BOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + OK + + 0 + + 0 + + + 0 + + 1 + m_okButton + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onOKButton diff --git a/src/forms/Dialog/PortSelectorDialogBase.cpp b/src/forms/Dialog/PortSelectorDialogBase.cpp index 605c59e..ac63ada 100644 --- a/src/forms/Dialog/PortSelectorDialogBase.cpp +++ b/src/forms/Dialog/PortSelectorDialogBase.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 8 2018) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -11,57 +11,53 @@ PortSelectorDialogBase::PortSelectorDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) { - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - + this->SetSizeHints( wxSize( 300,200 ), wxDefaultSize ); + wxBoxSizer* dlgSizer; dlgSizer = new wxBoxSizer( wxVERTICAL ); - + m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("Select a detected port or enter your own"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1->Wrap( -1 ); - dlgSizer->Add( m_staticText1, 0, wxEXPAND|wxALL, 5 ); - - m_portList = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + dlgSizer->Add( m_staticText1, 0, wxALIGN_CENTER|wxTOP, 5 ); + + m_portList = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); dlgSizer->Add( m_portList, 1, wxALL|wxEXPAND, 5 ); - + wxBoxSizer* bSizer3; bSizer3 = new wxBoxSizer( wxHORIZONTAL ); - - bSizer3->SetMinSize( wxSize( -1,30 ) ); + + bSizer3->SetMinSize( wxSize( -1,30 ) ); m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("Port"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText2->Wrap( -1 ); - bSizer3->Add( m_staticText2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - + bSizer3->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + m_portSelection = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer3->Add( m_portSelection, 1, wxEXPAND|wxRIGHT, 5 ); - - - dlgSizer->Add( bSizer3, 1, wxEXPAND, 5 ); - - m_buttonPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + bSizer3->Add( m_portSelection, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + + dlgSizer->Add( bSizer3, 0, wxEXPAND, 5 ); + wxBoxSizer* bSizer2; bSizer2 = new wxBoxSizer( wxHORIZONTAL ); - - m_cancelButton = new wxButton( m_buttonPanel, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + + m_cancelButton = new wxButton( this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer2->Add( m_cancelButton, 0, wxALL|wxALIGN_BOTTOM, 5 ); - - + + bSizer2->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_okButton = new wxButton( m_buttonPanel, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 ); + + m_okButton = new wxButton( this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer2->Add( m_okButton, 0, wxALL|wxALIGN_BOTTOM, 5 ); - - - m_buttonPanel->SetSizer( bSizer2 ); - m_buttonPanel->Layout(); - bSizer2->Fit( m_buttonPanel ); - dlgSizer->Add( m_buttonPanel, 0, wxEXPAND | wxALL, 5 ); - - + + + dlgSizer->Add( bSizer2, 0, wxEXPAND, 5 ); + + this->SetSizer( dlgSizer ); this->Layout(); - + this->Centre( wxBOTH ); - + // Connect Events m_portList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( PortSelectorDialogBase::onListSelect ), NULL, this ); m_cancelButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PortSelectorDialogBase::onCancelButton ), NULL, this ); @@ -74,5 +70,5 @@ PortSelectorDialogBase::~PortSelectorDialogBase() m_portList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( PortSelectorDialogBase::onListSelect ), NULL, this ); m_cancelButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PortSelectorDialogBase::onCancelButton ), NULL, this ); m_okButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PortSelectorDialogBase::onOKButton ), NULL, this ); - + } diff --git a/src/forms/Dialog/PortSelectorDialogBase.h b/src/forms/Dialog/PortSelectorDialogBase.h index b3b6652..4841b7d 100644 --- a/src/forms/Dialog/PortSelectorDialogBase.h +++ b/src/forms/Dialog/PortSelectorDialogBase.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 8 2018) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __PORTSELECTORDIALOGBASE_H__ -#define __PORTSELECTORDIALOGBASE_H__ +#pragma once #include #include @@ -23,7 +22,6 @@ #include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -32,30 +30,28 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PortSelectorDialogBase /////////////////////////////////////////////////////////////////////////////// -class PortSelectorDialogBase : public wxDialog +class PortSelectorDialogBase : public wxDialog { private: - + protected: wxStaticText* m_staticText1; wxListBox* m_portList; wxStaticText* m_staticText2; wxTextCtrl* m_portSelection; - wxPanel* m_buttonPanel; wxButton* m_cancelButton; wxButton* m_okButton; - + // Virtual event handlers, overide them in your derived class virtual void onListSelect( wxCommandEvent& event ) { event.Skip(); } virtual void onCancelButton( wxCommandEvent& event ) { event.Skip(); } virtual void onOKButton( wxCommandEvent& event ) { event.Skip(); } - - + + public: - - PortSelectorDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Select Port"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 304,197 ), long style = wxDEFAULT_DIALOG_STYLE ); + + PortSelectorDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Select Port"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 320,260 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~PortSelectorDialogBase(); - + }; -#endif //__PORTSELECTORDIALOGBASE_H__