From 2b48fb5e4b61f1e9a0b233797f25713f69623efd Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sun, 25 Nov 2012 00:00:28 +0000 Subject: [PATCH] basic filter dialog screen working, after usual pain with sizers git-svn-id: https://svn.code.sf.net/p/freetel/code@1060 01035d8c-6547-0410-b346-abe4f91aad63 --- fdmdv2/src/dlg_filter.cpp | 81 +++++++++++++++++++++------------------ fdmdv2/src/dlg_filter.h | 8 ++-- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/fdmdv2/src/dlg_filter.cpp b/fdmdv2/src/dlg_filter.cpp index 78faa8e2..3fcd1220 100644 --- a/fdmdv2/src/dlg_filter.cpp +++ b/fdmdv2/src/dlg_filter.cpp @@ -20,7 +20,7 @@ //========================================================================== #include "dlg_filter.h" -#define SLIDER_MAX 20 +#define SLIDER_MAX 100 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= // Class FilterDlg @@ -34,36 +34,44 @@ FilterDlg::FilterDlg(wxWindow* parent, wxWindowID id, const wxString& title, con bSizer30 = new wxBoxSizer(wxVERTICAL); wxGridSizer* gSizer3; - gSizer3 = new wxGridSizer(6, 2, 0, 0); + gSizer3 = new wxGridSizer(6, 3, 0, 0); - m_staticText8 = new wxStaticText(this, wxID_ANY, _("Enable LPC Post Filter:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); - m_staticText8->Wrap(-1); - gSizer3->Add(m_staticText8, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 2); + gSizer3->Add(new wxStaticText(this, wxID_ANY, _(""))); + + m_codec2LPCPostFilterEnable = new wxCheckBox(this, wxID_ANY, _("Enable LPC Post Filter"), wxDefaultPosition,wxDefaultSize , wxCHK_2STATE); + gSizer3->Add(m_codec2LPCPostFilterEnable, 2); - m_codec2LPCPostFilterEnable = new wxCheckBox(this, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); - gSizer3->Add(m_codec2LPCPostFilterEnable, 2, wxALL|wxEXPAND, 2); + gSizer3->Add(new wxStaticText(this, wxID_ANY, _(""))); + gSizer3->Add(new wxStaticText(this, wxID_ANY, _(""))); - m_staticText9 = new wxStaticText(this, wxID_ANY, _("0-1 kHz 3dB Boost"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); - m_staticText9->Wrap(-1); - gSizer3->Add(m_staticText9, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 2); - - m_codec2LPCPostFilterBassBoost = new wxCheckBox(this, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); - gSizer3->Add(m_codec2LPCPostFilterBassBoost, 1, wxALIGN_CENTER_VERTICAL|wxALL, 2); + m_codec2LPCPostFilterBassBoost = new wxCheckBox(this, wxID_ANY, _("0-1 kHz 3dB Boost"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); + gSizer3->Add(m_codec2LPCPostFilterBassBoost, 2); + + gSizer3->Add(new wxStaticText(this, wxID_ANY, _(""))); m_staticText91 = new wxStaticText(this, wxID_ANY, _("Beta:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); m_staticText91->Wrap(-1); gSizer3->Add(m_staticText91, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 2); - m_codec2LPCPostFilterBeta = new wxSlider(this, wxID_ANY, 0, 0, SLIDER_MAX); + m_codec2LPCPostFilterBeta = new wxSlider(this, wxID_ANY, 0, 0, SLIDER_MAX, wxDefaultPosition, wxSize(155,wxDefaultCoord)); gSizer3->Add(m_codec2LPCPostFilterBeta, 1, wxALIGN_CENTER_VERTICAL|wxALL, 2); + m_staticTextBeta = new wxStaticText(this, wxID_ANY, _("0.0"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); + m_staticTextBeta->Wrap(-1); + //gSizer3->Add(m_staticTextBeta, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 2); + gSizer3->Add(m_staticTextBeta, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL); + m_staticText911 = new wxStaticText(this, wxID_ANY, _("Gamma:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); m_staticText911->Wrap(-1); - gSizer3->Add(m_staticText911, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 2); + gSizer3->Add(m_staticText911, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 2); - m_codec2LPCPostFilterGamma = new wxSlider(this, wxID_ANY, 0, 0, SLIDER_MAX); + m_codec2LPCPostFilterGamma = new wxSlider(this, wxID_ANY, 0, 0, SLIDER_MAX, wxDefaultPosition, wxSize(155,wxDefaultCoord)); gSizer3->Add(m_codec2LPCPostFilterGamma, 1, wxALIGN_CENTER_VERTICAL|wxALL, 2); + m_staticTextGamma = new wxStaticText(this, wxID_ANY, _("0.0"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); + m_staticTextGamma->Wrap(-1); + gSizer3->Add(m_staticTextGamma, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL); + bSizer30->Add(gSizer3, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 5); m_sdbSizer5 = new wxStdDialogButtonSizer(); @@ -75,8 +83,7 @@ FilterDlg::FilterDlg(wxWindow* parent, wxWindowID id, const wxString& title, con m_sdbSizer5->AddButton(m_sdbSizer5Cancel); m_sdbSizer5->Realize(); - bSizer30->Add(m_sdbSizer5, 0, wxEXPAND, 5); - + bSizer30->Add(m_sdbSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); this->SetSizer(bSizer30); this->Layout(); @@ -86,10 +93,10 @@ FilterDlg::FilterDlg(wxWindow* parent, wxWindowID id, const wxString& title, con // Connect Events this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(FilterDlg::OnInitDialog)); - //m_sdbSizer5Apply->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FilterDlg::OnApply), NULL, this); + m_codec2LPCPostFilterBeta->Connect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(FilterDlg::OnBetaScroll), NULL, this); + m_codec2LPCPostFilterGamma->Connect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(FilterDlg::OnGammaScroll), NULL, this); m_sdbSizer5Cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FilterDlg::OnCancel), NULL, this); m_sdbSizer5OK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FilterDlg::OnOK), NULL, this); - //m_listCtrlPortSelect->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler(FilterDlg::OnListItemSelected), NULL, this); } //------------------------------------------------------------------------- @@ -99,20 +106,12 @@ FilterDlg::~FilterDlg() { // Disconnect Events this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(FilterDlg::OnInitDialog)); - //m_listCtrlPortSelect->Disconnect(wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler(FilterDlg::OnListItemSelected), NULL, this); - //m_sdbSizer5Apply->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FilterDlg::OnApply), NULL, this); + m_codec2LPCPostFilterBeta->Disconnect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(FilterDlg::OnBetaScroll), NULL, this); + m_codec2LPCPostFilterGamma->Disconnect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(FilterDlg::OnGammaScroll), NULL, this); m_sdbSizer5Cancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FilterDlg::OnCancel), NULL, this); m_sdbSizer5OK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FilterDlg::OnOK), NULL, this); } -//------------------------------------------------------------------------- -// OnListItemSelected() -//------------------------------------------------------------------------- -void FilterDlg::OnListItemSelected(wxListEvent& event) -{ - // TODO: Implement OnListItemSelected -} - //------------------------------------------------------------------------- // ExchangeData() //------------------------------------------------------------------------- @@ -159,14 +158,6 @@ void FilterDlg::OnOK(wxCommandEvent& event) this->EndModal(wxID_OK); } -//------------------------------------------------------------------------- -// OnApply() -//------------------------------------------------------------------------- -void FilterDlg::OnApply(wxCommandEvent& event) -{ - ExchangeData(EXCHANGE_DATA_OUT); -} - //------------------------------------------------------------------------- // OnClose() //------------------------------------------------------------------------- @@ -183,3 +174,17 @@ void FilterDlg::OnInitDialog(wxInitDialogEvent& event) ExchangeData(EXCHANGE_DATA_IN); } +void FilterDlg::OnBetaScroll(wxScrollEvent& event) { + float beta = (float)m_codec2LPCPostFilterBeta->GetValue()/SLIDER_MAX; + wxString buf; + buf.Printf(wxT("%3.2f"), beta); + m_staticTextBeta->SetLabel(buf); +} + +void FilterDlg::OnGammaScroll(wxScrollEvent& event) { + float gamma = (float)m_codec2LPCPostFilterGamma->GetValue()/SLIDER_MAX; + wxString buf; + buf.Printf(wxT("%3.2f"), gamma); + m_staticTextGamma->SetLabel(buf); +} + diff --git a/fdmdv2/src/dlg_filter.h b/fdmdv2/src/dlg_filter.h index 2b56bcbf..d6918cc6 100644 --- a/fdmdv2/src/dlg_filter.h +++ b/fdmdv2/src/dlg_filter.h @@ -30,19 +30,19 @@ class FilterDlg : public wxDialog { public: - FilterDlg( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Filter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 399,354 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + FilterDlg( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Filter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,250 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~FilterDlg(); void ExchangeData(int inout); protected: // Handlers for events. - void OnListItemSelected(wxListEvent& event); void OnCancel(wxCommandEvent& event); void OnOK(wxCommandEvent& event); void OnClose(wxCloseEvent& event); void OnInitDialog(wxInitDialogEvent& event); - void OnApply(wxCommandEvent& event); + void OnBetaScroll(wxScrollEvent& event); + void OnGammaScroll(wxScrollEvent& event); wxStaticText* m_staticText8; wxCheckBox* m_codec2LPCPostFilterEnable; @@ -50,8 +50,10 @@ class FilterDlg : public wxDialog wxCheckBox* m_codec2LPCPostFilterBassBoost; wxStaticText* m_staticText91; wxSlider* m_codec2LPCPostFilterBeta; + wxStaticText* m_staticTextBeta; wxStaticText* m_staticText911; wxSlider* m_codec2LPCPostFilterGamma; + wxStaticText* m_staticTextGamma; wxStdDialogButtonSizer* m_sdbSizer5; wxButton* m_sdbSizer5OK; -- 2.25.1