//--------------------------------------------------------------------------------------- void LangOptionsPanel::create_controls() { //content generated with wxFormBuilder this->SetExtraStyle( wxWS_EX_BLOCK_EVENTS ); wxBoxSizer* pMainSizer; pMainSizer = LENMUS_NEW wxBoxSizer( wxVERTICAL ); m_pTitlePannel = LENMUS_NEW wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER|wxTAB_TRAVERSAL ); wxBoxSizer* pTitleSizer; pTitleSizer = LENMUS_NEW wxBoxSizer( wxHORIZONTAL ); m_pTitle = LENMUS_NEW wxStaticText( m_pTitlePannel, wxID_ANY, _("Language preferences"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); m_pTitle->Wrap( -1 ); m_pTitle->SetFont( wxFont( 8, 74, 90, 92, false, "Tahoma" ) ); pTitleSizer->Add( m_pTitle, 0, wxALIGN_TOP|wxALL|wxADJUST_MINSIZE, 5 ); pTitleSizer->Add( 5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_pTitleIcon = LENMUS_NEW wxStaticBitmap( m_pTitlePannel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); pTitleSizer->Add( m_pTitleIcon, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_pTitlePannel->SetSizer( pTitleSizer ); m_pTitlePannel->Layout(); pTitleSizer->Fit( m_pTitlePannel ); pMainSizer->Add( m_pTitlePannel, 0, wxEXPAND|wxBOTTOM, 5 ); wxBoxSizer* pLangSizer; pLangSizer = LENMUS_NEW wxBoxSizer( wxHORIZONTAL ); m_pLang = LENMUS_NEW wxStaticText( this, wxID_ANY, _("Choose language to use:"), wxDefaultPosition, wxDefaultSize, 0 ); m_pLang->Wrap( -1 ); pLangSizer->Add( m_pLang, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5 ); wxArrayString m_pChoiceChoices; m_pChoice = LENMUS_NEW wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_pChoiceChoices, 0 ); m_pChoice->SetSelection( 0 ); pLangSizer->Add( m_pChoice, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); pMainSizer->Add( pLangSizer, 0, wxEXPAND|wxALL, 5 ); this->SetSizer( pMainSizer ); this->Layout(); }
FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, const wxString & title, const wxPoint & pos) : wxDialogWrapper(parent, id, title, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX), mAnalyst(std::make_unique<SpectrumAnalyst>()) { SetName(GetTitle()); mMouseX = 0; mMouseY = 0; mRate = 0; mDataLen = 0; p = GetActiveProject(); if (!p) return; wxArrayString algChoices; algChoices.Add(_("Spectrum")); algChoices.Add(_("Standard Autocorrelation")); algChoices.Add(_("Cuberoot Autocorrelation")); algChoices.Add(_("Enhanced Autocorrelation")); /* i18n-hint: This is a technical term, derived from the word * "spectrum". Do not translate it unless you are sure you * know the correct technical word in your language. */ algChoices.Add(_("Cepstrum")); wxArrayString sizeChoices; sizeChoices.Add(wxT("128")); sizeChoices.Add(wxT("256")); sizeChoices.Add(wxT("512")); sizeChoices.Add(wxT("1024")); sizeChoices.Add(wxT("2048")); sizeChoices.Add(wxT("4096")); sizeChoices.Add(wxT("8192")); sizeChoices.Add(wxT("16384")); sizeChoices.Add(wxT("32768")); sizeChoices.Add(wxT("65536")); wxArrayString funcChoices; for (int i = 0, cnt = NumWindowFuncs(); i < cnt; i++) { /* i18n-hint: This refers to a "window function", * such as Hann or Rectangular, used in the * Frequency analyze dialog box. */ funcChoices.Add(wxString::Format("%s window", WindowFuncName(i) ) ); } wxArrayString axisChoices; axisChoices.Add(_("Linear frequency")); axisChoices.Add(_("Log frequency")); mFreqFont = wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); mArrowCursor = std::make_unique<wxCursor>(wxCURSOR_ARROW); mCrossCursor = std::make_unique<wxCursor>(wxCURSOR_CROSS); gPrefs->Read(wxT("/FreqWindow/DrawGrid"), &mDrawGrid, true); long size; gPrefs->Read(wxT("/FreqWindow/SizeChoice"), &mSize, 3); sizeChoices[mSize].ToLong(&size); mWindowSize = size; int alg; gPrefs->Read(wxT("/FreqWindow/AlgChoice"), &alg, 0); mAlg = static_cast<SpectrumAnalyst::Algorithm>(alg); gPrefs->Read(wxT("/FreqWindow/FuncChoice"), &mFunc, 3); gPrefs->Read(wxT("/FreqWindow/AxisChoice"), &mAxis, 1); gPrefs->Read(ENV_DB_KEY, &dBRange, ENV_DB_RANGE); if(dBRange < 90.) dBRange = 90.; ShuttleGui S(this, eIsCreating); S.SetBorder(0); S.AddSpace(5); S.SetSizerProportion(1); S.StartMultiColumn(3, wxEXPAND); { S.SetStretchyCol(1); S.SetStretchyRow(0); // ------------------------------------------------------------------- // ROW 1: Freq response panel and sliders for vertical scale // ------------------------------------------------------------------- S.StartVerticalLay(2); { vRuler = safenew RulerPanel(this, wxID_ANY); vRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes vRuler->ruler.SetOrientation(wxVERTICAL); vRuler->ruler.SetRange(0.0, -dBRange); vRuler->ruler.SetFormat(Ruler::LinearDBFormat); vRuler->ruler.SetUnits(_("dB")); vRuler->ruler.SetLabelEdges(true); int w; vRuler->ruler.GetMaxSize(&w, NULL); vRuler->SetMinSize(wxSize(w, 150)); // height needed for wxGTK vRuler->SetTickColour( theTheme.Colour( clrGraphLabels )); S.AddSpace(wxDefaultCoord, 1); S.Prop(1); S.AddWindow(vRuler, wxALIGN_RIGHT | wxALIGN_TOP); S.AddSpace(wxDefaultCoord, 1); } S.EndVerticalLay(); mFreqPlot = safenew FreqPlot(this); mFreqPlot->SetMinSize(wxSize(wxDefaultCoord, FREQ_WINDOW_HEIGHT)); S.Prop(1); S.AddWindow(mFreqPlot, wxEXPAND); S.StartHorizontalLay(wxEXPAND, 0); { S.StartVerticalLay(); { mPanScroller = safenew wxScrollBar(this, FreqPanScrollerID, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL); mPanScroller->SetName(_("Scroll")); S.Prop(1); S.AddWindow(mPanScroller, wxALIGN_LEFT | wxTOP); } S.EndVerticalLay(); S.StartVerticalLay(); { wxStaticBitmap *zi = safenew wxStaticBitmap(this, wxID_ANY, wxBitmap(ZoomIn)); S.AddWindow((wxWindow *) zi, wxALIGN_CENTER); S.AddSpace(5); mZoomSlider = safenew wxSlider(this, FreqZoomSliderID, 100, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL); S.Prop(1); S.AddWindow(mZoomSlider, wxALIGN_CENTER_HORIZONTAL); mZoomSlider->SetName(_("Zoom")); S.AddSpace(5); wxStaticBitmap *zo = safenew wxStaticBitmap(this, wxID_ANY, wxBitmap(ZoomOut)); S.AddWindow((wxWindow *) zo, wxALIGN_CENTER); } S.EndVerticalLay(); S.AddSpace(5, wxDefaultCoord); } S.EndHorizontalLay(); // ------------------------------------------------------------------- // ROW 2: Frequency ruler // ------------------------------------------------------------------- S.AddSpace(1); S.StartHorizontalLay(wxEXPAND, 0); { hRuler = safenew RulerPanel(this, wxID_ANY); hRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes hRuler->ruler.SetOrientation(wxHORIZONTAL); hRuler->ruler.SetLog(true); hRuler->ruler.SetRange(10, 20000); hRuler->ruler.SetFormat(Ruler::RealFormat); hRuler->ruler.SetUnits(_("Hz")); hRuler->ruler.SetFlip(true); hRuler->ruler.SetLabelEdges(true); int h; hRuler->ruler.GetMaxSize(NULL, &h); hRuler->SetMinSize(wxSize(wxDefaultCoord, h)); hRuler->SetTickColour( theTheme.Colour( clrGraphLabels )); S.AddSpace(1, wxDefaultCoord); S.Prop(1); S.AddWindow(hRuler, wxALIGN_LEFT | wxALIGN_TOP); S.AddSpace(1, wxDefaultCoord); } S.EndHorizontalLay(); S.AddSpace(1); // ------------------------------------------------------------------- // ROW 3: Spacer // ------------------------------------------------------------------- S.AddSpace(5); S.AddSpace(5); S.AddSpace(5); // ------------------------------------------------------------------- // ROW 4: Info // ------------------------------------------------------------------- S.AddSpace(1); S.StartHorizontalLay(wxEXPAND); { S.SetSizerProportion(1); S.StartMultiColumn(6); S.SetStretchyCol(1); S.SetStretchyCol(3); { S.AddPrompt(_("Cursor:")); S.SetStyle(wxTE_READONLY); mCursorText = S.AddTextBox( {}, wxT(""), 10); S.AddPrompt(_("Peak:")); S.SetStyle(wxTE_READONLY); mPeakText = S.AddTextBox( {}, wxT(""), 10); S.AddSpace(5); mGridOnOff = S.Id(GridOnOffID).AddCheckBox(_("&Grids"), wxT("false")); mGridOnOff->SetValue(mDrawGrid); } S.EndMultiColumn(); } S.EndHorizontalLay(); S.AddSpace(1); } S.EndMultiColumn(); // ------------------------------------------------------------------- // ROW 5: Spacer // ------------------------------------------------------------------- S.AddSpace(5); S.SetBorder(2); S.SetSizerProportion(0); S.StartMultiColumn(9, wxALIGN_CENTER); { // ---------------------------------------------------------------- // ROW 6: Algorithm, Size, Export, Replot // ---------------------------------------------------------------- S.AddSpace(5); mAlgChoice = S.Id(FreqAlgChoiceID).AddChoice(_("&Algorithm:"), wxT(""), &algChoices); mAlgChoice->SetSelection(mAlg); S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); S.AddSpace(5); mSizeChoice = S.Id(FreqSizeChoiceID).AddChoice(_("&Size:"), wxT(""), &sizeChoices); mSizeChoice->SetSelection(mSize); S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); S.AddSpace(5); mExportButton = S.Id(FreqExportButtonID).AddButton(_("&Export...")); S.AddSpace(5); // ---------------------------------------------------------------- // ROW 7: Function, Axix, Grids, Close // ---------------------------------------------------------------- S.AddSpace(5); mFuncChoice = S.Id(FreqFuncChoiceID).AddChoice(_("&Function:"), wxT(""), &funcChoices); mFuncChoice->SetSelection(mFunc); S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); mFuncChoice->MoveAfterInTabOrder(mSizeChoice); S.AddSpace(5); mAxisChoice = S.Id(FreqAxisChoiceID).AddChoice(_("&Axis:"), wxT(""), &axisChoices); mAxisChoice->SetSelection(mAxis); S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); mAxisChoice->MoveAfterInTabOrder(mFuncChoice); S.AddSpace(5); mReplotButton = S.Id(ReplotButtonID).AddButton(_("&Replot...")); S.AddSpace(5); //mCloseButton = S.Id(wxID_CANCEL).AddButton(_("&Close")); //S.AddSpace(5); } S.EndMultiColumn(); S.AddStandardButtons( eHelpButton | eCloseButton ); // ------------------------------------------------------------------- // ROW 8: Spacer // ------------------------------------------------------------------- S.AddSpace(5); mProgress = safenew FreqGauge(this); //, wxID_ANY, wxST_SIZEGRIP); S.AddWindow(mProgress, wxEXPAND); // Log-frequency axis works for spectrum plots only. if (mAlg != SpectrumAnalyst::Spectrum) { mAxis = 0; mAxisChoice->Disable(); } mLogAxis = mAxis != 0; mCloseButton = reinterpret_cast<wxButton*>(FindWindowById( wxID_CANCEL )); mCloseButton->SetDefault(); mCloseButton->SetFocus(); Layout(); Fit(); // Bug 1607: Center(); SetMinSize(GetSize()); mAlgChoice->SetFocus(); #if defined(__WXGTK__) // This should be rechecked with wx3. // // The scrollbar (focus some reason) doesn't allow tabbing past it // because it can't receive focus. So, convince it otherwise. // // Unfortunately, this still doesn't let you adjust the scrollbar // from the keyboard. Near as I can tell, wxWGTK is capturing the // keyboard input, so the GTK widget doesn't see it, preventing // the normal scroll events from being generated. // // I guess the only way round it would be to handle key actions // ourselves, but we'll leave that for a future date. // gtk_widget_set_can_focus(mPanScroller->m_widget, true); #endif }