From 67edfab862a9105fecee10627d3ae947f0eedf12 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 24 Nov 2015 23:00:43 -0500 Subject: [PATCH] Show/Hide modem properties when available --- src/AppFrame.cpp | 2 ++ src/ModemProperties.cpp | 22 +++++++++++++++++++--- src/ModemProperties.h | 4 +++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 98106a2..fd584f9 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -96,6 +96,7 @@ AppFrame::AppFrame() : modemPropertiesUpdated.store(false); modemProps = new ModemProperties(demodPanel, wxID_ANY); + modemProps->Hide(); demodTray->Add(modemProps, 15, wxEXPAND | wxALL, 0); #endif @@ -1052,6 +1053,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) { if (modemPropertiesUpdated.load()) { modemProps->initProperties(newModemArgs); modemPropertiesUpdated.store(false); + demodTray->Layout(); } // waterfallCanvas->processInputQueue(); // waterfallCanvas->Refresh(); diff --git a/src/ModemProperties.cpp b/src/ModemProperties.cpp index 7dc579b..c679e3d 100644 --- a/src/ModemProperties.cpp +++ b/src/ModemProperties.cpp @@ -5,8 +5,6 @@ ModemProperties::ModemProperties(wxWindow *parent, wxWindowID winid, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxPanel(parent, winid, pos, size, style, name) { m_propertyGrid = new wxPropertyGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxPG_DEFAULT_STYLE); - - wxBoxSizer* bSizer; bSizer = new wxBoxSizer( wxVERTICAL ); @@ -15,6 +13,11 @@ ModemProperties::ModemProperties(wxWindow *parent, wxWindowID winid, this->SetSizer(bSizer); m_propertyGrid->Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( ModemProperties::OnChange ), NULL, this ); + this->Connect( wxEVT_SHOW, wxShowEventHandler( ModemProperties::OnShow ), NULL, this ); +} + +void ModemProperties::OnShow(wxShowEvent &event) { + m_propertyGrid->FitColumns(); } ModemProperties::~ModemProperties() { @@ -23,8 +26,19 @@ ModemProperties::~ModemProperties() { void ModemProperties::initProperties(ModemArgInfoList newArgs) { args = newArgs; - + m_propertyGrid->Clear(); + + if (newArgs.size() == 0) { + Hide(); + return; + } else { + Show(); + } + + bSizer->Layout(); + Layout(); + m_propertyGrid->Append(new wxPropertyCategory("Modem Settings")); ModemArgInfoList::const_iterator args_i; @@ -33,6 +47,8 @@ void ModemProperties::initProperties(ModemArgInfoList newArgs) { ModemArgInfo arg = (*args_i); props[arg.key] = addArgInfoProperty(m_propertyGrid, arg); } + + m_propertyGrid->FitColumns(); } wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgInfo arg) { diff --git a/src/ModemProperties.h b/src/ModemProperties.h index 453a102..5a101c0 100644 --- a/src/ModemProperties.h +++ b/src/ModemProperties.h @@ -25,7 +25,9 @@ private: wxPGProperty *addArgInfoProperty(wxPropertyGrid *pg, ModemArgInfo arg); std::string readProperty(std::string); void OnChange(wxPropertyGridEvent &event); - + void OnShow(wxShowEvent &event); + + wxBoxSizer* bSizer; wxPropertyGrid* m_propertyGrid; ModemArgInfoList args; std::map props;