void FancyTextPanel::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); PrepareDC(dc); wxSize virtSize = GetVirtualSize(); dc.Clear(); dc.DrawRectangle(wxRect(wxPoint(0, 0), virtSize)); DrawCont(dc, m_print_continuity, wxRect(wxPoint(0, 0), virtSize), m_landscape); }
void DrawForPrintingHelper(wxDC& dc, const CalChartConfiguration& config, const CalChartDoc& show, const CC_sheet& sheet, unsigned ref, bool landscape) { // set up everything to be restored after we print SaveAndRestore_DeviceOrigin orig_dev(dc); SaveAndRestore_UserScale orig_scale(dc); SaveAndRestore_Font orig_font(dc); // get the page dimensions int pageW, pageH; dc.GetSize(&pageW, &pageH); dc.Clear(); dc.SetLogicalFunction(wxCOPY); // Print the field: // create a field for drawing: const auto pts = sheet.GetPoints(); auto boundingBox = GetMarcherBoundingBox(pts); auto mode = CreateFieldForPrinting(Coord2Int(boundingBox.first.x), Coord2Int(boundingBox.second.x), landscape); // set the origin and scaling for drawing the field dc.SetDeviceOrigin(kFieldBorderOffset*pageW, kFieldTop*pageH); auto scale = (pageW-2*kFieldBorderOffset*pageW)/(double)mode->Size().x; dc.SetUserScale(scale, scale); // draw the field. DrawMode(dc, config, *mode, ShowMode_kPrinting); wxFont *pointLabelFont = wxTheFontList->FindOrCreateFont((int)Float2Coord(config.Get_DotRatio() * config.Get_NumRatio()), wxSWISS, wxNORMAL, wxNORMAL); dc.SetFont(*pointLabelFont); for (auto i = 0u; i < pts.size(); i++) { const auto point = pts.at(i); const auto pos = point.GetPos(ref) + mode->Offset(); dc.SetBrush(*wxBLACK_BRUSH); DrawPointHelper(dc, config, pos, point, show.GetPointLabel(i)); } // now reset everything to draw the rest of the text dc.SetDeviceOrigin(Int2Coord(0), Int2Coord(0)); dc.SetBrush(*wxTRANSPARENT_BRUSH); // set the page for drawing: dc.GetSize(&pageW, &pageH); if (landscape) { dc.SetUserScale(pageW/kSizeXLandscape, pageH/kSizeYLandscape); pageW = kSizeXLandscape; pageH = kSizeYLandscape; } else { dc.SetUserScale(pageW/kSizeX, pageH/kSizeY); pageW = kSizeX; pageH = kSizeY; } // draw the header dc.SetFont(*wxTheFontList->FindOrCreateFont(16, wxROMAN, wxNORMAL, wxBOLD)); dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1, wxSOLID)); DrawCenteredText(dc, kHeader, wxPoint(pageW*kHeaderLocation[landscape][0], pageH*kHeaderLocation[landscape][1])); DrawCenteredText(dc, sheet.GetNumber(), wxPoint(pageW*kUpperNumberPosition[landscape][0], pageH*kUpperNumberPosition[landscape][1])); DrawCenteredText(dc, sheet.GetNumber(), wxPoint(pageW*kLowerNumberPosition[landscape][0], pageH*kLowerNumberPosition[landscape][1])); dc.DrawRectangle(pageW*kLowerNumberBox[landscape][0], pageH*kLowerNumberBox[landscape][1], pageW*kLowerNumberBox[landscape][2], pageH*kLowerNumberBox[landscape][3]); dc.SetFont(*wxTheFontList->FindOrCreateFont(8, wxSWISS, wxNORMAL, wxNORMAL)); DrawLineOverText(dc, kMusicLabel, wxPoint(pageW*kMusicLabelPosition[landscape][0], pageH*kMusicLabelPosition[landscape][1]), pageW*kMusicLabelPosition[landscape][2]); DrawLineOverText(dc, kFormationLabel, wxPoint(pageW*kFormationLabelPosition[landscape][0], pageH*kFormationLabelPosition[landscape][1]), pageW*kFormationLabelPosition[landscape][2]); DrawLineOverText(dc, kGameLabel, wxPoint(pageW*kGameLabelPosition[landscape][0], pageH*kGameLabelPosition[landscape][1]), pageW*kGameLabelPosition[landscape][2]); DrawLineOverText(dc, kPageLabel, wxPoint(pageW*kPageLabelPosition[landscape][0], pageH*kPageLabelPosition[landscape][1]), pageW*kPageLabelPosition[landscape][2]); DrawCenteredText(dc, kSideLabel, wxPoint(pageW*kSideLabelPosition[landscape][0], pageH*kSideLabelPosition[landscape][1])); // draw arrows DrawCenteredText(dc, kUpperSouthLabel, wxPoint(pageW*kUpperSouthPosition[landscape][0], pageH*kUpperSouthPosition[landscape][1])); DrawArrow(dc, wxPoint(pageW*kUpperSouthArrow[landscape][0], pageH*kUpperSouthArrow[landscape][1]), pageW*kUpperSouthArrow[landscape][2], false); DrawCenteredText(dc, kUpperNorthLabel, wxPoint(pageW*kUpperNorthPosition[landscape][0], pageH*kUpperNorthPosition[landscape][1])); DrawArrow(dc, wxPoint(pageW*kUpperNorthArrow[landscape][0], pageH*kUpperNorthArrow[landscape][1]), pageW*kUpperNorthArrow[landscape][2], true); DrawCenteredText(dc, kLowerSouthLabel, wxPoint(pageW*kLowerSouthPosition[landscape][0], pageH*kLowerSouthPosition[landscape][1])); DrawArrow(dc, wxPoint(pageW*kLowerSouthArrow[landscape][0], pageH*kLowerSouthArrow[landscape][1]), pageW*kLowerSouthArrow[landscape][2], false); DrawCenteredText(dc, kLowerNorthLabel, wxPoint(pageW*kLowerNorthPosition[landscape][0], pageH*kLowerNorthPosition[landscape][1])); DrawArrow(dc, wxPoint(pageW*kLowerNorthArrow[landscape][0], pageH*kLowerNorthArrow[landscape][1]), pageW*kLowerNorthArrow[landscape][2], true); DrawCont(dc, sheet.GetPrintableContinuity(), wxRect(wxPoint(10, pageH*kContinuityStart[landscape]), wxSize(pageW-20, pageH-pageH*kContinuityStart[landscape])), landscape); }