-void
-AudioMappingView::sized (wxSizeEvent& ev)
-{
- setup_sizes ();
- ev.Skip ();
-}
-
-void
-AudioMappingView::setup_sizes ()
-{
- int const top_height = 24;
-
- _grid->AutoSize ();
- _left_labels->SetMinSize (wxSize (LEFT_WIDTH, _grid->GetSize().GetHeight()));
- /* Allow it to scroll */
- _left_labels->SetVirtualSize (1024, 1024);
- _top_labels->SetMinSize (wxSize (_grid->GetSize().GetWidth() + LEFT_WIDTH, top_height));
- /* Allow it to scroll */
- _top_labels->SetVirtualSize (1024, 1024);
- /* Try to make the _top_labels 'actual' size respect the minimum we just set */
- _top_labels->Fit ();
- _left_labels->Refresh ();
- _top_labels->Refresh ();
-
- int x, y;
- _grid->GetScrollPixelsPerUnit (&x, &y);
- _top_labels->SetScrollRate (x, 0);
- _left_labels->SetScrollRate (0, y);
-}
-
-void
-AudioMappingView::paint_left_labels ()
-{
- wxPaintDC dc (_left_labels);
-
- wxGraphicsContext* gc = wxGraphicsContext::Create (dc);
- if (!gc) {
- return;
- }
-
- int sx, sy;
- _left_labels->GetViewStart (&sx, &sy);
- int rx, ry;
- _grid->GetScrollPixelsPerUnit (&rx, &ry);
- gc->Translate (0, -sy * ry);
-
- wxSize const size = dc.GetSize();
- int const half = size.GetWidth() / 2;
-
- gc->SetPen (wxPen (wxColour (0, 0, 0)));
- gc->SetAntialiasMode (wxANTIALIAS_DEFAULT);
-
- wxGraphicsPath lines = gc->CreatePath();
-
- vector<pair<int, int> >::const_iterator i = _input_group_positions.begin();
- if (i != _input_group_positions.end()) {
- lines.MoveToPoint (half, i->first);
- lines.AddLineToPoint (size.GetWidth(), i->first);
- }
-
- vector<Group>::const_iterator j = _input_groups.begin();
- while (i != _input_group_positions.end() && j != _input_groups.end()) {
-
- dc.SetClippingRegion (0, i->first + 2, size.GetWidth(), i->second - 4);
-
- dc.SetFont (*wxSWISS_FONT);
- wxCoord label_width;
- wxCoord label_height;
- dc.GetTextExtent (std_to_wx (j->name), &label_width, &label_height);
-
- dc.DrawRotatedText (
- j->name,
- half + (half - label_height) / 2,
- min (i->second, (i->second + i->first + label_width) / 2),
- 90
- );
-
- dc.DestroyClippingRegion ();
-
- lines.MoveToPoint (half, i->second);
- lines.AddLineToPoint (size.GetWidth(), i->second);
-
- gc->StrokePath (lines);
-
- ++i;
- ++j;
- }
-
- /* Overall label */
- dc.SetFont (wxSWISS_FONT->Bold());
- wxCoord overall_label_width;
- wxCoord overall_label_height;
- dc.GetTextExtent (_("Content"), &overall_label_width, &overall_label_height);
- dc.DrawRotatedText (
- _("Content"),
- (half - overall_label_height) / 2,
- min (size.GetHeight(), (size.GetHeight() + _grid->GetColLabelSize() + overall_label_width) / 2),
- 90
- );
-
- delete gc;
-}
-
-void
-AudioMappingView::paint_top_labels ()
-{
- wxPaintDC dc (_top_labels);
- if (_grid->GetNumberCols() == 0) {
- return;
- }
-
- wxGraphicsContext* gc = wxGraphicsContext::Create (dc);
- if (!gc) {
- return;
- }
-
- int sx, sy;
- _top_labels->GetViewStart (&sx, &sy);
- int rx, ry;
- _grid->GetScrollPixelsPerUnit (&rx, &ry);
- int toff = sx * rx;
- gc->Translate (-toff, 0);
-
- wxSize const size = dc.GetSize();
-
- gc->SetAntialiasMode (wxANTIALIAS_DEFAULT);
-
- dc.SetFont (wxSWISS_FONT->Bold());
- wxCoord label_width;
- wxCoord label_height;
- dc.GetTextExtent (_("DCP"), &label_width, &label_height);
-
- dc.DrawText (_("DCP"), (size.GetWidth() + _grid->GetColSize(0) + LEFT_WIDTH - label_width) / 2 - toff, (size.GetHeight() - label_height) / 2);
-
- gc->SetPen (wxPen (wxColour (0, 0, 0)));
- wxGraphicsPath lines = gc->CreatePath();
-
- int lhs = LEFT_WIDTH + _grid->GetColSize(0) - 1;
- if (toff < (lhs - LEFT_WIDTH)) {
- lines.MoveToPoint (lhs, 0);
- lines.AddLineToPoint (lhs, size.GetHeight());
- }
-
- wxGridSizesInfo si = _grid->GetColSizes();
- int total = 0;
- for (int i = 0; i < _grid->GetNumberCols(); ++i) {
- total += si.GetSize (i);
- }
- lines.MoveToPoint (LEFT_WIDTH + total, 0);
- lines.AddLineToPoint (LEFT_WIDTH + total, size.GetHeight());
-
- gc->StrokePath (lines);
-
- delete gc;
-}
-