void SelectionBar::Populate() { // This will be inherited by all children: SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL)); wxFlexGridSizer *mainSizer; wxBoxSizer *hSizer; /* we don't actually need a control yet, but we want to use it's methods * to do some look-ups, so we'll have to create one. We can't make the * look-ups static because they depend on translations which are done at * runtime */ TimeTextCtrl *ttc = new TimeTextCtrl(this, wxID_ANY, wxT(""), 0.0, mRate); wxString formatName; gPrefs->Read(wxT("/SelectionFormat"), &formatName); wxString format = ttc->GetBuiltinFormat(formatName); delete ttc; mainSizer = new wxFlexGridSizer(7, 1, 1); Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL); // // Top row (mostly labels) // mainSizer->Add(new wxStaticText(this, -1, _("Project Rate (Hz):"), // LLL: On my Ubuntu 7.04 install, the label wraps to two lines // and I could not figure out why. Thus...hackage. #if defined(__WXGTK__) wxDefaultPosition, wxSize(110, -1)), #else wxDefaultPosition, wxDefaultSize), #endif 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(5, 1); mainSizer->Add(5, 1); mainSizer->Add(new wxStaticText(this, -1, _("Selection Start:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); bool showSelectionLength = false; gPrefs->Read(wxT("/ShowSelectionLength"), &showSelectionLength); hSizer = new wxBoxSizer(wxHORIZONTAL); mRightEndButton = new wxRadioButton(this, OnEndRadioID, _("End"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); mRightEndButton->SetName(_("End")); mRightEndButton->SetValue(!showSelectionLength); hSizer->Add(mRightEndButton, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); mRightLengthButton = new wxRadioButton(this, OnLengthRadioID, _("Length")); mRightLengthButton->SetName(_("Length")); mRightLengthButton->SetValue(showSelectionLength); hSizer->Add(mRightLengthButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); #if defined(__WXMSW__) // Refer to Microsoft KB article 261192 for an explanation as // to why this is needed. We've only experienced it under Win2k // so it's probably been fixed. But, it doesn't hurt to have this // in for all versions. wxRadioButton* dummyButton = new wxRadioButton(this, wxID_ANY, _("hidden"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); dummyButton->Disable(); dummyButton->Hide(); #endif mainSizer->Add(hSizer, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); mainSizer->Add(5, 1); mainSizer->Add(new wxStaticText(this, -1, _("Audio Position:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); // // Middle row (mostly time controls) // mRateBox = new wxComboBox(this, OnRateID, wxT(""), wxDefaultPosition, wxSize(80, -1)); mRateBox->SetName(_("Project Rate (Hz):")); wxTextValidator vld(wxFILTER_INCLUDE_CHAR_LIST); vld.SetIncludes(wxArrayString(10, numbers)); mRateBox->SetValidator(vld); mRateBox->SetValue(wxString::Format(wxT("%d"), (int)mRate)); UpdateRates(); // Must be done _after_ setting value on mRateBox! // We need to capture the SetFocus and KillFocus events to set up // for keyboard capture. On Windows and GTK it's easy since the // combobox is presented as one control to hook into. mRateText = mRateBox; #if defined(__WXMAC__) // The Mac uses a standard wxTextCtrl for the edit portion and that's // the control that gets the focus events. So we have to find the // textctrl. wxWindowList kids = mRateBox->GetChildren(); for (unsigned int i = 0; i < kids.GetCount(); i++) { wxClassInfo *ci = kids[i]->GetClassInfo(); if (ci->IsKindOf(CLASSINFO(wxTextCtrl))) { mRateText = kids[i]; break; } } #endif mRateText->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); mRateText->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); mainSizer->Add(mRateBox, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(new wxStaticLine(this, -1, wxDefaultPosition, wxSize(1, toolbarSingle), wxLI_VERTICAL), 0, wxRIGHT, 5); /* i18n-hint: The snap-to mode, when enabled, means for example that selections * are always at whole second boundaries. You can't select a range 4.5s to 7.9s * because the boundaries 'snap to' the nearest whole number.*/ mSnapTo = new wxCheckBox(this, OnSnapToID, _("Snap To"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); mainSizer->Add(mSnapTo, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER | wxRIGHT, 5); mSnapTo->SetName(_("Snap To")); mSnapTo->SetValue(gPrefs->Read(wxT("/SnapTo"), 0L)!=0); #if wxUSE_TOOLTIPS mSnapTo->SetToolTip(wxString::Format(_("Snap Clicks/Selections to %s"), formatName.c_str())); #endif mSnapTo->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); mSnapTo->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); mLeftTime = new TimeTextCtrl(this, OnLeftTimeID, wxT(""), 0.0, mRate); mLeftTime->SetFormatString(format); mLeftTime->SetName(_("Selection Start:")); mLeftTime->EnableMenu(); mainSizer->Add(mLeftTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mRightTime = new TimeTextCtrl(this, OnRightTimeID, format, 0.0, mRate); mRightTime->SetName(wxString(_("Selection ")) + (showSelectionLength ? _("Length") : _("End"))); mRightTime->EnableMenu(); mainSizer->Add(mRightTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(new wxStaticLine(this, -1, wxDefaultPosition, wxSize(1, toolbarSingle), wxLI_VERTICAL), 0, wxRIGHT, 5); mAudioTime = new TimeTextCtrl(this, -1, format, 0.0, mRate); mAudioTime->SetName(_("Audio Position:")); mAudioTime->EnableMenu(); mainSizer->Add(mAudioTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); mainSizer->Layout(); Layout(); SetMinSize( GetSizer()->GetMinSize() ); }
void SelectionBar::Populate() { mLeftTime = mRightTime = mAudioTime = nullptr; // This will be inherited by all children: SetFont(wxFont( #ifdef __WXMAC__ 12 #else 9 #endif , wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); wxFlexGridSizer *mainSizer; /* we don't actually need a control yet, but we want to use it's methods * to do some look-ups, so we'll have to create one. We can't make the * look-ups static because they depend on translations which are done at * runtime */ wxString formatName = mListener ? mListener->AS_GetSelectionFormat() : wxString(wxEmptyString); Add((mainSizer = safenew wxFlexGridSizer(7, 1, 1)), 0, wxALIGN_CENTER_VERTICAL); // // Top row (mostly labels) // mainSizer->Add(safenew wxStaticText(this, -1, _("Project Rate (Hz):"), // LLL: On my Ubuntu 7.04 install, the label wraps to two lines // and I could not figure out why. Thus...hackage. #if defined(__WXGTK__) wxDefaultPosition, wxSize(110, -1)), #else wxDefaultPosition, wxDefaultSize), #endif 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(5, 1); mainSizer->Add(safenew wxStaticText(this, -1, _("Snap To:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(safenew wxStaticText(this, -1, _("Selection Start:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); bool showSelectionLength = false; gPrefs->Read(wxT("/ShowSelectionLength"), &showSelectionLength); { auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL); mRightEndButton = safenew wxRadioButton(this, OnEndRadioID, _("End"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); mRightEndButton->SetName(_("End")); mRightEndButton->SetValue(!showSelectionLength); hSizer->Add(mRightEndButton, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); mRightLengthButton = safenew wxRadioButton(this, OnLengthRadioID, _("Length")); mRightLengthButton->SetName(_("Length")); mRightLengthButton->SetValue(showSelectionLength); hSizer->Add(mRightLengthButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); #if defined(__WXMSW__) // Refer to Microsoft KB article 261192 for an explanation as // to why this is needed. We've only experienced it under Win2k // so it's probably been fixed. But, it doesn't hurt to have this // in for all versions. wxRadioButton* dummyButton = safenew wxRadioButton(this, wxID_ANY, _("hidden"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); dummyButton->Disable(); dummyButton->Hide(); #endif mainSizer->Add(hSizer.release(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); } mainSizer->Add(5, 1); mainSizer->Add(safenew wxStaticText(this, -1, _("Audio Position:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); // // Middle row (mostly time controls) // mRateBox = safenew wxComboBox(this, OnRateID, wxT(""), wxDefaultPosition, wxSize(80, -1)); mRateBox->SetName(_("Project Rate (Hz):")); wxTextValidator vld(wxFILTER_INCLUDE_CHAR_LIST); vld.SetIncludes(wxArrayString(10, numbers)); mRateBox->SetValidator(vld); mRateBox->SetValue(wxString::Format(wxT("%d"), (int)mRate)); UpdateRates(); // Must be done _after_ setting value on mRateBox! // We need to capture the SetFocus and KillFocus events to set up // for keyboard capture. On Windows and GTK it's easy since the // combobox is presented as one control to hook into. mRateText = mRateBox; #if defined(__WXMAC__) // The Mac uses a standard wxTextCtrl for the edit portion and that's // the control that gets the focus events. So we have to find the // textctrl. wxWindowList kids = mRateBox->GetChildren(); for (unsigned int i = 0; i < kids.GetCount(); i++) { wxClassInfo *ci = kids[i]->GetClassInfo(); if (ci->IsKindOf(CLASSINFO(wxTextCtrl))) { mRateText = kids[i]; break; } } #endif mRateText->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); mRateText->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); mainSizer->Add(mRateBox, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(safenew wxStaticLine(this, -1, wxDefaultPosition, wxSize(1, toolbarSingle), wxLI_VERTICAL), 0, wxRIGHT, 5); mSnapTo = safenew wxChoice(this, OnSnapToID, wxDefaultPosition, wxDefaultSize, SnapManager::GetSnapLabels()); mainSizer->Add(mSnapTo, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mSnapTo->SetName(_("Snap To")); mSnapTo->SetSelection(mListener ? mListener->AS_GetSnapTo() : SNAP_OFF); mSnapTo->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); mSnapTo->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); mLeftTime = safenew NumericTextCtrl( NumericConverter::TIME, this, OnLeftTimeID, formatName, 0.0, mRate); mLeftTime->SetName(_("Selection Start:")); mLeftTime->EnableMenu(); mainSizer->Add(mLeftTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mRightTime = safenew NumericTextCtrl( NumericConverter::TIME, this, OnRightTimeID, formatName, 0.0, mRate); mRightTime->SetName(wxString(_("Selection ")) + (showSelectionLength ? _("Length") : _("End"))); mRightTime->EnableMenu(); mainSizer->Add(mRightTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(safenew wxStaticLine(this, -1, wxDefaultPosition, wxSize(1, toolbarSingle), wxLI_VERTICAL), 0, wxRIGHT, 5); mAudioTime = safenew NumericTextCtrl( NumericConverter::TIME, this, wxID_ANY, formatName, 0.0, mRate); mAudioTime->SetName(_("Audio Position:")); mAudioTime->EnableMenu(); mainSizer->Add(mAudioTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); mainSizer->Layout(); RegenerateTooltips(); Layout(); SetMinSize( GetSizer()->GetMinSize() ); }
void SelectionBar::Populate() { int i; // This will be inherited by all children: SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL)); wxFlexGridSizer *mainSizer; wxBoxSizer *hSizer; wxString formatName = gPrefs->Read(wxT("/SelectionFormat"), wxT("")); int formatIndex = 1; /* we don't actually need a control yet, but we want to use it's methods * to do some look-ups, so we'll have to create one. We can't make the * look-ups static because they depend on translations which are done at * runtime */ /* for now we don't give this a format, we'll set that later once we've * done some other format-related housekeeping */ mLeftTime = new TimeTextCtrl(this, OnLeftTimeID, wxT(""), 0.0, mRate); for(i=0; i<mLeftTime->GetNumBuiltins(); i++) if (mLeftTime->GetBuiltinName(i) == formatName) formatIndex = i; formatName = mLeftTime->GetBuiltinName(formatIndex); wxString format = mLeftTime->GetBuiltinFormat(formatIndex); mainSizer = new wxFlexGridSizer(7, 1, 1); Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL); // // Top row (mostly labels) // mainSizer->Add(new wxStaticText(this, -1, _("Project Rate (Hz):"), // LLL: On my Ubuntu 7.04 install, the label wraps to two lines // and I could not figure out why. Thus...hackage. #if defined(__WXGTK__) wxDefaultPosition, wxSize(110, -1)), #else wxDefaultPosition, wxDefaultSize), #endif 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(5, 1); mainSizer->Add(5, 1); mainSizer->Add(new wxStaticText(this, -1, _("Selection Start:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); bool showSelectionLength = false; gPrefs->Read(wxT("/ShowSelectionLength"), &showSelectionLength); hSizer = new wxBoxSizer(wxHORIZONTAL); mRightEndButton = new wxRadioButton(this, OnEndRadioID, _("End"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); mRightEndButton->SetValue(!showSelectionLength); hSizer->Add(mRightEndButton, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); mRightLengthButton = new wxRadioButton(this, OnLengthRadioID, _("Length")); mRightLengthButton->SetValue(showSelectionLength); hSizer->Add(mRightLengthButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); #if defined(__WXMSW__) // Refer to Microsoft KB article 261192 for an explanation as // to why this is needed. We've only experienced it under Win2k // so it's probably been fixed. But, it doesn't hurt to have this // in for all versions. wxRadioButton* dummyButton = new wxRadioButton(this, wxID_ANY, _("hidden"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); dummyButton->Disable(); dummyButton->Hide(); #endif mainSizer->Add(hSizer, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); mainSizer->Add(5, 1); mainSizer->Add(new wxStaticText(this, -1, _("Audio Position:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); // // Middle row (mostly time controls) // mRateBox = new wxComboBox(this, OnRateID, wxT(""), wxDefaultPosition, wxSize(80, -1)); mRateBox->SetName(_("Project Rate (Hz):")); mRateBox->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); mRateBox->SetValue(wxString::Format(wxT("%d"), (int)mRate)); UpdateRates(); // Must be done _after_ setting value on mRateBox! // We need to capture the SetFocus and KillFocus events to set up // for keyboard capture. On Windows and GTK it's easy since the // combobox is presented as one control to hook into. wxWindow *ctrl = mRateBox; #if defined(__WXMAC__) // The Mac uses a standard wxTextCtrl for the edit portion and that's // the control that gets the focus events. So we have to find the // textctrl. wxWindowList kids = mRateBox->GetChildren(); for (unsigned int i = 0; i < kids.GetCount(); i++) { wxClassInfo *ci = kids[i]->GetClassInfo(); if (ci->IsKindOf(CLASSINFO(wxTextCtrl))) { ctrl = kids[i]; break; } } #endif ctrl->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); ctrl->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); mainSizer->Add(mRateBox, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(new wxStaticLine(this, -1, wxDefaultPosition, wxSize(1, toolbarSingle), wxLI_VERTICAL), 0, wxRIGHT, 5); mSnapTo = new wxCheckBox(this, OnSnapToID, _("Snap To"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); mainSizer->Add(mSnapTo, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER | wxRIGHT, 5); mSnapTo->SetName(_("Snap To")); mSnapTo->SetValue(gPrefs->Read(wxT("/SnapTo"), 0L)!=0); mSnapTo->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); mSnapTo->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(SelectionBar::OnFocus), NULL, this); /* we would normally be creating a new TimeTextControl here, except that we * did it near the start of the function to have an object to do look-ups on * so the only thing left to do here is to set it's format to what we now * know is correct */ mLeftTime->SetFormatString(format); mLeftTime->SetName(_("Selection Start:")); mLeftTime->EnableMenu(); mainSizer->Add(mLeftTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mRightTime = new TimeTextCtrl(this, OnRightTimeID, format, 0.0, mRate); mRightTime->SetName(wxString(_("Selection ")) + (showSelectionLength ? _("Length") : _("End"))); mRightTime->EnableMenu(); mainSizer->Add(mRightTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(new wxStaticLine(this, -1, wxDefaultPosition, wxSize(1, toolbarSingle), wxLI_VERTICAL), 0, wxRIGHT, 5); mAudioTime = new TimeTextCtrl(this, -1, format, 0.0, mRate); mAudioTime->SetName(_("Audio Position:")); mAudioTime->EnableMenu(); mainSizer->Add(mAudioTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); mainSizer->Layout(); Layout(); SetMinSize( GetSizer()->GetMinSize() ); }