X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Faudio_mapping_view.cc;h=3ea0cdd1da9b72717b038ed1c6606a47f275040e;hb=6f833b0e9b4342922f5488ceaef76db567c2087f;hp=d62609d22e514392631a1db83fa3705ea5c7eaa1;hpb=5859b758e3a6e0191ce12e77b636c7def58bbc3b;p=dcpomatic.git diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc index d62609d22..3ea0cdd1d 100644 --- a/src/wx/audio_mapping_view.cc +++ b/src/wx/audio_mapping_view.cc @@ -59,10 +59,17 @@ public: void Draw (wxGrid& grid, wxGridCellAttr &, wxDC& dc, const wxRect& rect, int row, int col, bool) { +#if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9 + dc.SetPen (*wxThePenList->FindOrCreatePen (wxColour (255, 255, 255), 0, wxPENSTYLE_SOLID)); +#else + dc.SetPen (*wxThePenList->FindOrCreatePen (wxColour (255, 255, 255), 0, wxSOLID)); +#endif + dc.DrawRectangle (rect); + wxRendererNative::Get().DrawCheckBox ( &grid, dc, rect, - grid.GetCellValue (row, col) == "1" ? static_cast(wxCONTROL_CHECKED) : 0 + grid.GetCellValue (row, col) == wxT("1") ? static_cast(wxCONTROL_CHECKED) : 0 ); } @@ -84,7 +91,11 @@ AudioMappingView::AudioMappingView (wxWindow* parent) _grid = new wxGrid (this, wxID_ANY); _grid->CreateGrid (0, 7); +#if wxMINOR_VERSION == 9 _grid->HideRowLabels (); +#else + _grid->SetRowLabelSize (0); +#endif _grid->DisableDragRowSize (); _grid->DisableDragColSize (); _grid->EnableEditing (false); @@ -101,9 +112,9 @@ AudioMappingView::AudioMappingView (wxWindow* parent) _grid->AutoSize (); - wxBoxSizer* s = new wxBoxSizer (wxVERTICAL); - s->Add (_grid, 1, wxEXPAND); - SetSizerAndFit (s); + _sizer = new wxBoxSizer (wxVERTICAL); + _sizer->Add (_grid, 1, wxEXPAND | wxALL); + SetSizerAndFit (_sizer); Connect (wxID_ANY, wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler (AudioMappingView::left_click), 0, this); } @@ -115,21 +126,32 @@ AudioMappingView::left_click (wxGridEvent& ev) return; } - if (_grid->GetCellValue (ev.GetRow(), ev.GetCol()) == "1") { - _grid->SetCellValue (ev.GetRow(), ev.GetCol(), "0"); + if (_grid->GetCellValue (ev.GetRow(), ev.GetCol()) == wxT("1")) { + _grid->SetCellValue (ev.GetRow(), ev.GetCol(), wxT("0")); } else { - _grid->SetCellValue (ev.GetRow(), ev.GetCol(), "1"); + _grid->SetCellValue (ev.GetRow(), ev.GetCol(), wxT("1")); } + + AudioMapping mapping; + for (int i = 0; i < _grid->GetNumberRows(); ++i) { + for (int j = 1; j < _grid->GetNumberCols(); ++j) { + if (_grid->GetCellValue (i, j) == wxT ("1")) { + mapping.add (i, static_cast (j - 1)); + } + } + } + + Changed (mapping); } void -AudioMappingView::set_mapping (AudioMapping map) +AudioMappingView::set (AudioMapping map) { if (_grid->GetNumberRows ()) { _grid->DeleteRows (0, _grid->GetNumberRows ()); } - list content_channels = map.content_channels (); + list content_channels = map.content_channels (); _grid->InsertRows (0, content_channels.size ()); for (size_t r = 0; r < content_channels.size(); ++r) { @@ -139,18 +161,14 @@ AudioMappingView::set_mapping (AudioMapping map) } int n = 0; - for (list::iterator i = content_channels.begin(); i != content_channels.end(); ++i) { - shared_ptr ac = i->content.lock (); - assert (ac); - _grid->SetCellValue (n, 0, wxString::Format ("%s %d", std_to_wx (ac->file().filename().string()), i->index + 1)); + for (list::iterator i = content_channels.begin(); i != content_channels.end(); ++i) { + _grid->SetCellValue (n, 0, wxString::Format (wxT("%d"), *i + 1)); list const d = map.content_to_dcp (*i); for (list::const_iterator j = d.begin(); j != d.end(); ++j) { - _grid->SetCellValue (n, static_cast (*j) + 1, "1"); + _grid->SetCellValue (n, static_cast (*j) + 1, wxT("1")); } ++n; } - - _grid->AutoSize (); }