void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, double aScalar, const wxString &aFilename, const wxString &aSheetLayer, COLOR4D aColor ) { if( !m_showBorderAndTitleBlock ) return; const PAGE_INFO& pageInfo = GetPageSettings(); wxSize pageSize = pageInfo.GetSizeMils(); // if not printing, draw the page limits: if( !aScreen->m_IsPrinting && m_showPageLimits ) { GRSetDrawMode( aDC, GR_COPY ); GRRect( m_canvas->GetClipBox(), aDC, 0, 0, pageSize.x * aScalar, pageSize.y * aScalar, aLineWidth, m_drawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); } TITLE_BLOCK t_block = GetTitleBlock(); COLOR4D color = ( aColor != COLOR4D::UNSPECIFIED ) ? aColor : COLOR4D( RED ); wxPoint origin = aDC->GetDeviceOrigin(); if( aScreen->m_IsPrinting && origin.y > 0 ) { aDC->SetDeviceOrigin( 0, 0 ); aDC->SetAxisOrientation( true, false ); } DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo, GetScreenDesc(), aFilename, t_block, aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aLineWidth, aScalar, color, aSheetLayer ); if( aScreen->m_IsPrinting && origin.y > 0 ) { aDC->SetDeviceOrigin( origin.x, origin.y ); aDC->SetAxisOrientation( true, true ); } }
void PageControl::Paint(Graphics *gfx, int offX, int offY) { #if 0 // for testing mouse move, paint a blue circle at current cursor position if ((-1 != cursorX) && (-1 != cursorY)) { SolidBrush br(Color(180, 0, 0, 255)); int x = offX + cursorX; int y = offY + cursorY; Rect r(RectForCircle(x, y, 10)); gfx->FillEllipse(&br, r); } #endif CachedStyle *s = cachedStyle; Rect r(offX, offY, pos.Width, pos.Height); Brush *br = BrushFromColorData(s->bgColor, r); gfx->FillRectangle(br, r); if (!page) return; // during resize the page we currently show might be bigger than // our area. To avoid drawing outside our area we clip Region origClipRegion; gfx->GetClip(&origClipRegion); r.X += s->padding.left; r.Y += s->padding.top; r.Width -= (s->padding.left + s->padding.right); r.Height -= (s->padding.top + s->padding.bottom); r.Inflate(1,0); gfx->SetClip(r, CombineModeReplace); // TODO: support changing the text color to gRenderCache.colorRange[0] // or GetSysColor(COLOR_WINDOWTEXT) if gGlobalPrefs.useSysColors DrawPageLayout(gfx, &page->instructions, (REAL)r.X, (REAL)r.Y, IsDebugPaint()); gfx->SetClip(&origClipRegion, CombineModeReplace); }
void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() { int lyWidth, lyHeight; wxSize clamped_layout_size( Clamp( MIN_PAGE_SIZE, m_layout_size.x, m_maxPageSizeMils.x ), Clamp( MIN_PAGE_SIZE, m_layout_size.y, m_maxPageSizeMils.y ) ); double lyRatio = clamped_layout_size.x < clamped_layout_size.y ? (double) clamped_layout_size.y / clamped_layout_size.x : (double) clamped_layout_size.x / clamped_layout_size.y; if( clamped_layout_size.x < clamped_layout_size.y ) { lyHeight = MAX_PAGE_EXAMPLE_SIZE; lyWidth = KiROUND( (double) lyHeight / lyRatio ); } else { lyWidth = MAX_PAGE_EXAMPLE_SIZE; lyHeight = KiROUND( (double) lyWidth / lyRatio ); } if( m_page_bitmap ) { m_PageLayoutExampleBitmap->SetBitmap( wxNullBitmap ); delete m_page_bitmap; } m_page_bitmap = new wxBitmap( lyWidth + 1, lyHeight + 1 ); if( m_page_bitmap->IsOk() ) { double scaleW = (double) lyWidth / clamped_layout_size.x; double scaleH = (double) lyHeight / clamped_layout_size.y; // Prepare DC. wxSize example_size( lyWidth + 1, lyHeight + 1 ); wxMemoryDC memDC; memDC.SelectObject( *m_page_bitmap ); memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size ); memDC.Clear(); memDC.SetUserScale( scaleW, scaleH ); // Get logical page size and margins. PAGE_INFO pageDUMMY; // Get page type int idx = m_paperSizeComboBox->GetSelection(); if( idx < 0 ) idx = 0; wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' ); bool portrait = clamped_layout_size.x < clamped_layout_size.y; pageDUMMY.SetType( pageFmtName, portrait ); if( m_customFmt ) { pageDUMMY.SetWidthMils( clamped_layout_size.x ); pageDUMMY.SetHeightMils( clamped_layout_size.y ); } // Draw layout preview. wxString emptyString; GRResetPenAndBrush( &memDC ); WORKSHEET_LAYOUT::SetAltInstance( m_pagelayout ); GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, WHITE, WHITE ); DrawPageLayout( &memDC, NULL, pageDUMMY, emptyString, emptyString, m_tb, m_screen->m_NumberOfScreens, m_screen->m_ScreenNumber, 1, 1, DARKGRAY, RED ); memDC.SelectObject( wxNullBitmap ); m_PageLayoutExampleBitmap->SetBitmap( *m_page_bitmap ); WORKSHEET_LAYOUT::SetAltInstance( NULL ); // Refresh the dialog. Layout(); Refresh(); } }