// **************************************************************************** // // Function Name: RPsd3RuledLineGraphic::GetOutlinePath( ) // // Description: Compute and return the path the encompases the path of this graphic // // Returns: nothing // // Exceptions: None // // **************************************************************************** // BOOLEAN RPsd3RuledLineGraphic::GetOutlinePath( RPath& path, const RRealSize& size, const R2dTransform& transform ) { R2dTransform rLineTransform = transform; RRealSize rLineSize = size; if (!m_fHorizontal) { rLineSize.m_dx = size.m_dy; rLineSize.m_dy = size.m_dx; rLineTransform.PreRotateAboutOrigin(::DegreesToRadians(-90.0)); rLineTransform.PreTranslate(0.0, -rLineSize.m_dy); } Render( NULL, &path, rLineSize, rLineTransform, RIntRect(0,0,0,0), RColor(kBlack) ); return TRUE; }
////////////////////////////////////////////////////////////////////////////// // // void ExportGraphicComponent( RComponentView* pComponentView, RMBCString *pInitialDir ) // // export a graphic to file from a component view // ////////////////////////////////////////////////////////////////////////////// void ExportGraphicComponent( RComponentView* pComponentView, RMBCString *pInitialDir /*=NULL*/) { RImageLibrary rLibrary ; CArray<int, int> arrFileFormats ; // // Build the export file filter list... // CString strFilter, str ; for (int i = 0; i < kNumFormats - 1; i++) { if (rLibrary.IsFormatSupported( (EImageFormat) kImageExportFilters[i][0] )) { str.LoadString( kImageExportFilters[i][1] ) ; strFilter += str ; arrFileFormats.Add( kImageExportFilters[i][0] ) ; } } TpsAssert( kImageExportFilters[i][0] == kImageFormatXRX, "Invalid export format!" ) ; str.LoadString( kImageExportFilters[i][1] ) ; strFilter += str ; strFilter += "|" ; arrFileFormats.Add( kImageExportFilters[i][0] ) ; // // Create and execute the dialog... // RExportGraphicDlg dlg( pComponentView, strFilter ) ; // Load in the dialog title string CString strTitle ; strTitle.LoadString( STRING_EXPORT_IMAGE_DIALOG_TITLE ) ; dlg.m_ofn.lpstrTitle = (LPCTSTR) strTitle ; if( pInitialDir ) { dlg.m_ofn.lpstrInitialDir = (LPCTSTR)*pInitialDir; } if (IDOK == dlg.DoModal()) { RMBCString strPathName = dlg.GetPathName() ; RIntSize szImageSize = dlg.GetSize() ; _nFilterIndex = dlg.m_ofn.nFilterIndex ; EImageFormat eFormat = (EImageFormat) arrFileFormats[dlg.m_ofn.nFilterIndex - 1] ; RRealSize pictureSize = pComponentView->GetReferenceSize() ; try { if (kImageFormatXRX == eFormat) { RRealSize outputSize( szImageSize.m_dx, szImageSize.m_dy ) ; // = pictureSize ; RRealSize screenDPI = ::GetScreenDPI() ; RVectorImage vectorImage ; vectorImage.SetSuggestedWidthInInches( ::PixelsToInches( outputSize.m_dx, (uLONG) screenDPI.m_dx ) ) ; vectorImage.SetSuggestedHeightInInches( ::PixelsToInches( outputSize.m_dy, (uLONG) screenDPI.m_dy ) ) ; // Create an offscreen drawing surface and set the picture ROffscreenDrawingSurface drawingSurface; drawingSurface.SetImage( &vectorImage ); R2dTransform transform ; // Scale to the device DPI RRealSize deviceDPI = drawingSurface.GetDPI( ); transform.PreScale( (YFloatType) deviceDPI.m_dx / screenDPI.m_dy, (YFloatType) deviceDPI.m_dy / screenDPI.m_dy ); transform.PreScale( outputSize.m_dx / pictureSize.m_dx, outputSize.m_dy / pictureSize.m_dy ) ; // Render the component RRealRect outputRect( pictureSize ) ; pComponentView->Render( drawingSurface, transform, outputRect ) ; drawingSurface.ReleaseImage( ); rLibrary.ExportImage( vectorImage, strPathName, kImageFormatXRX ) ; if (rLibrary.GetLastException() != kNoError) { throw rLibrary.GetLastException() ; } } // if (XRX) else { // Check for a image interface RImageInterface* pInterface = (RImageInterface *) pComponentView->GetInterface( kImageInterfaceId ) ; if (pInterface) { pInterface->Export( strPathName, eFormat ) ; delete pInterface ; } else { // Initialize the new bitmap at a bit depth of 24 RBitmapImage image ; image.Initialize( szImageSize.m_dx, szImageSize.m_dy, 24 ) ; ROffscreenDrawingSurface dsMem ; dsMem.SetImage( &image ) ; R2dTransform transform ; transform.PreScale( szImageSize.m_dx / pictureSize.m_dx, szImageSize.m_dy / pictureSize.m_dy ) ; // Render the component dsMem.SetFillColor( RSolidColor( kWhite ) ) ; dsMem.FillRectangle( RRealRect( pictureSize ), transform ) ; pComponentView->Render( dsMem, transform, RIntRect( RIntSize( pictureSize.m_dx, pictureSize.m_dy ) ) ) ; dsMem.ReleaseImage() ; rLibrary.ExportImage( image, strPathName, eFormat ) ; } if (rLibrary.GetLastException() != kNoError) { throw rLibrary.GetLastException() ; } } // else } // try catch( YException e) { ReportException( e ) ; } } // if (IDOK) }
void RWinColorPalette::OnPaint( ) { CPaintDC dc( this ); RDcDrawingSurface ds; ds.Initialize( (HDC) dc ) ; CRect rcWindow; GetClientRect( rcWindow ); RIntRect rcClient( rcWindow ); RBitmapImage& biPalette = GetPaletteBitmapImage(); biPalette.LockImage( ); biPalette.Render( ds, rcClient ); biPalette.UnlockImage( ); ds.DetachDCs(); CClientDC dcClient( this ); ds.Initialize( (HDC) dcClient ) ; RColor crOldFill = ds.GetFillColor(); RColor crOldPen = ds.GetPenColor(); if (m_ptSelected.m_x >= 0 && m_ptSelected.m_y >= 0) { // // Draw selected cell RIntRect rcSelected( m_ptSelected.m_x + 1, m_ptSelected.m_y + 1, m_ptSelected.m_x + kCellSize.m_dx - 1, m_ptSelected.m_y + kCellSize.m_dy - 1 ); RSolidColor crBlack( kBlack ); RSolidColor crHilight( GetSysColor( COLOR_BTNHILIGHT ) ); ds.Draw3dRect( rcSelected, crBlack, crHilight ); RSolidColor crShadow( GetSysColor( COLOR_BTNSHADOW ) ); rcSelected.m_Top -= 1; rcSelected.m_Left -= 1; ds.Draw3dRect( rcSelected, crShadow, crHilight ); if (GetFocus() == this) { RSolidColor rSolid = GetSysColor( COLOR_HIGHLIGHT ); RColor rSelected( rSolid ); rcSelected.Inflate( RIntSize( 1, 1 ), RIntSize( 2, 2 ) ); ds.SetPenColor( RColor( rSelected ) ); ds.FrameRectangle( rcSelected ); } } if (m_crHilited != (COLORREF) -1L) { // Draw color chip m_rcColorChip = RIntRect( m_ptHilited.m_x, m_ptHilited.m_y, m_ptHilited.m_x + 2 * kCellSize.m_dx, m_ptHilited.m_y + 2 * kCellSize.m_dy ); YIntDimension xOffset( 2 * kCellSize.m_dx ); YIntDimension yOffset( 2 * kCellSize.m_dy ); if (m_rcColorChip.m_Right + xOffset > rcWindow.right) { xOffset = -3 * kCellSize.m_dx; } if (m_rcColorChip.m_Bottom + yOffset > rcWindow.bottom) { yOffset = -3 * kCellSize.m_dy; } m_rcColorChip.Offset( RIntSize( xOffset, yOffset ) ); RColor crFill = RSolidColor( m_crHilited ); RColor crPen = RSolidColor( kWhite ); ds.SetPenColor( crPen ); ds.SetFillColor( crFill ); ds.FillRectangle( m_rcColorChip ); ds.FrameRectangle( m_rcColorChip ); } else { m_rcColorChip = RIntRect( 0, 0, 1, 1 ); } ds.SetPenColor( crOldPen ); ds.SetFillColor( crOldFill ); ds.DetachDCs(); }
// **************************************************************************** // // Function Name: RGpDrawingSurface::RestoreDefaults() // // Description: Restores the default drawing surface attributes // // Returns: Nothing // // Exceptions: None // // **************************************************************************** // void RGpDrawingSurface::RestoreDefaults() { RDrawingSurface::RestoreDefaults( ); // reset clip region SetClipRect( RIntRect( -16384, -16384, 16384, 16384 ) ); }