GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate() : context(0), mswDCStateID(0), gtkCurrentClipRgn(wxRegion()), gtkPaintClipRgn(wxRegion()) { }
MaxRegion * bmx_wxregion_createwithbitmap(MaxBitmap * bmp, MaxColour * colour, int tolerance) { wxRegion r; if (colour) { r = wxRegion(bmp->Bitmap(), colour->Colour(), tolerance); } else { r = wxRegion(bmp->Bitmap()); } return new MaxRegion(r); }
bool wxSkinWindow::SetShape(const wxBitmap& img) { wxRegion region; region = wxRegion(img); return SetShape(region); }
wxNonOwnedWindowShapeImpl(wxNonOwnedWindow* win, const wxGraphicsPath& path) : m_win(win), m_path(path) { // Create the region corresponding to this path and set it as windows // shape. wxScopedPtr<wxGraphicsContext> context(wxGraphicsContext::Create(win)); Region gr(static_cast<GraphicsPath*>(m_path.GetNativePath())); win->SetShape( wxRegion( gr.GetHRGN(static_cast<Graphics*>(context->GetNativeContext())) ) ); // Connect to the paint event to draw the border. // // TODO: Do this only optionally? m_win->Connect ( wxEVT_PAINT, wxPaintEventHandler(wxNonOwnedWindowShapeImpl::OnPaint), NULL, this ); }
void wxWindowMGL::HandlePaint(MGLDevCtx *dc) { if ( IsFrozen() ) { // Don't paint anything if the window is frozen. m_refreshAfterThaw = true; return; } #if wxDEBUG_LEVEL >= 2 // FIXME_MGL -- debugging stuff, to be removed! static int debugPaintEvents = -1; if ( debugPaintEvents == -1 ) debugPaintEvents = wxGetEnv(wxT("WXMGL_DEBUG_PAINT_EVENTS"), NULL); if ( debugPaintEvents ) { dc->setColorRGB(255,0,255); dc->fillRect(-1000,-1000,2000,2000); wxMilliSleep(50); } #endif // wxDEBUG_LEVEL >= 2 MGLRegion clip; dc->getClipRegion(clip); m_updateRegion = wxRegion(clip); m_paintMGLDC = dc; #if wxUSE_CARET // must hide caret temporarily, otherwise we'd get rendering artifacts wxCaret *caret = GetCaret(); if ( caret ) caret->Hide(); #endif // wxUSE_CARET if ( m_eraseBackground != 0 ) { wxWindowDC dc((wxWindow*)this); wxEraseEvent eventEr(m_windowId, &dc); eventEr.SetEventObject(this); HandleWindowEvent(eventEr); } m_eraseBackground = -1; wxNcPaintEvent eventNc(GetId()); eventNc.SetEventObject(this); HandleWindowEvent(eventNc); wxPaintEvent eventPt(GetId()); eventPt.SetEventObject(this); HandleWindowEvent(eventPt); #if wxUSE_CARET if ( caret ) caret->Show(); #endif // wxUSE_CARET m_paintMGLDC = NULL; m_updateRegion.Clear(); }
Void CAdjustNode::OffSetEx(Int32 sdwX, Int32 sdwY) { _NodePoint.x += sdwX; _NodePoint.y += sdwY; _NodeRegion = wxRegion(_NodePoint.x - NODE_REGION_SIZE/2, _NodePoint.y - NODE_REGION_SIZE/2, NODE_REGION_SIZE, NODE_REGION_SIZE); }
void DispLoading::onEraseBG( wxEraseEvent& event ) { wxDC *dc = event.GetDC(); if (!m_imgHandle.getImg() || !m_imgHandle->IsOk()) { dc->SetTextForeground(wxColor(0,0,0)); dc->Clear(); return; } int h = GetSize().GetHeight(); int w = GetSize().GetWidth(); int iw = m_imgHandle->GetSize().GetWidth(); //size 7 const int l_start = 0; const int l_width = 2; //size 6 const int m_start = 2; const int m_width = 15; //size 7 with 1 pix gap const int r_start = 17; const int r_width = 2; wxBitmap tmpBmp(w, h); wxMemoryDC tmpDC(tmpBmp); tmpDC.SetBrush(wxBrush(wxColor(255,0,255))); tmpDC.SetPen( wxPen(wxColor(255,0,255),1) ); tmpDC.DrawRectangle(0,0,w,h); wxImage scaled = m_imgHandle->Scale(iw, h); if (scaled.IsOk()) { wxBitmap left = wxBitmap(scaled.GetSubImage( wxRect(l_start,0,l_width,h)) ); wxBitmap right = wxBitmap(scaled.GetSubImage( wxRect(r_start,0,r_width,h)) ); wxBitmap center(w-(l_width+r_width),h); wxColor c(255,0,255); gcImage::tileImg(center, wxBitmap(scaled.GetSubImage( wxRect(m_start,0,m_width,h)) ), &c); tmpDC.DrawBitmap(left, l_start,0,true); tmpDC.DrawBitmap(center, m_start,0,true); tmpDC.DrawBitmap(right, w-r_width,0,true); } tmpDC.SelectObject(wxNullBitmap); dc->DrawBitmap(tmpBmp, 0,0, true); wxRegion region = wxRegion(tmpBmp, wxColor(255,0,255), 1); SetShape(region, this); }
bool wxSkinWindow::SetShape(const wxImage& imgorg) { wxImage img = imgorg; wxRegion region; if(img.HasAlpha()) img.ConvertAlphaToMask(); region = wxRegion(wxBitmap(img)); return SetShape(region); }
void wxWindow::DoDrawBorder(wxDC& dc, const wxRect& rect) { // draw outline unless the update region is enitrely inside it in which // case we don't need to do it #if 0 // doesn't seem to work, why? if ( wxRegion(rect).Contains(GetUpdateRegion().GetBox()) != wxInRegion ) #endif { m_renderer->DrawBorder(dc, GetBorder(), rect, GetStateFlags()); } }
wxRegion Rotation::trRectToRegion(const RealRect& r) const { if (is_straight(angle)) { return trRectToBB(r).toRect(); } else { wxPoint points[4] = {trPixel(RealPoint(r.left(), r.top() )) ,trPixel(RealPoint(r.left(), r.bottom())) ,trPixel(RealPoint(r.right(), r.bottom())) ,trPixel(RealPoint(r.right(), r.top() )) }; return wxRegion(4,points); } }
void wxQtDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { // Special case: Empty region -> DestroyClippingRegion() if ( width == 0 && height == 0 ) { DestroyClippingRegion(); } else { if ( width < 0 ) { width = -width; x -= width - 1; } if ( height < 0 ) { height = -height; y -= height - 1; } if (m_qtPainter->isActive()) { // Set QPainter clipping (intersection if not the first one) m_qtPainter->setClipRect( x, y, width, height, m_clipping ? Qt::IntersectClip : Qt::ReplaceClip ); } // Set internal state for getters /* Note: Qt states that QPainter::clipRegion() may be slow, so we * keep the region manually, which should be faster */ if ( !m_clipping || m_clippingRegion.IsEmpty() ) { int dcwidth, dcheight; DoGetSize(&dcwidth, &dcheight); m_clippingRegion = wxRegion(0, 0, dcwidth, dcheight); } m_clippingRegion.Intersect( wxRect(x, y, width, height) ); wxRect clipRect = m_clippingRegion.GetBox(); m_clipX1 = clipRect.GetLeft(); m_clipX2 = clipRect.GetRight() + 1; m_clipY1 = clipRect.GetTop(); m_clipY2 = clipRect.GetBottom() + 1; m_clipping = true; } }
Void CAdjustNode::OffSet(Int32 sdwX, Int32 sdwY) { _NodePoint.x += sdwX; _NodePoint.y += sdwY; _NodeRegion = wxRegion(_NodePoint.x - NODE_REGION_SIZE/2, _NodePoint.y - NODE_REGION_SIZE/2, NODE_REGION_SIZE, NODE_REGION_SIZE); if(_AdjustNodeType == ADJUST_X) { _pNode1->OffSet(sdwX, 0); _pNode2->OffSet(sdwX, 0); } else { _pNode1->OffSet(0, sdwY); _pNode2->OffSet(0, sdwY); } }
void gcStaticLine::onPaint( wxPaintEvent& event ) { wxPaintDC dc(this); if (!m_imgHR.getImg() || !m_imgHR->IsOk()) { dc.SetTextForeground(wxColor(25,25,25)); dc.Clear(); return; } int h = GetSize().GetHeight(); int w = GetSize().GetWidth(); #ifdef WIN32 // unused AFAIK int ih = m_imgHR->GetSize().GetHeight(); #endif int iw = m_imgHR->GetSize().GetWidth(); wxBitmap tmpBmp(w, h); wxMemoryDC tmpDC(tmpBmp); tmpDC.SetBrush(wxBrush(wxColor(255,0,255))); tmpDC.SetPen( wxPen(wxColor(255,0,255),1) ); tmpDC.DrawRectangle(0,0,w,h); wxImage scaled = m_imgHR->Scale(iw, h); wxBitmap left = GetGCThemeManager()->getSprite(scaled, "horizontal_rule", "Left"); wxBitmap right = GetGCThemeManager()->getSprite(scaled, "horizontal_rule", "Right"); wxBitmap centerImg = GetGCThemeManager()->getSprite(scaled, "horizontal_rule", "Center"); wxBitmap center(w-(left.GetWidth()+right.GetWidth()),h); wxColor c(255,0,255); gcImage::tileImg(center, centerImg, &c); tmpDC.DrawBitmap(left, 0,0,true); tmpDC.DrawBitmap(center, left.GetWidth(),0,true); tmpDC.DrawBitmap(right, w-right.GetWidth(),0,true); tmpDC.SelectObject(wxNullBitmap); dc.DrawBitmap(tmpBmp, 0,0, true); wxRegion region = wxRegion(tmpBmp, wxColor(255,0,255), 1); SetShape(region, this); }
bool wxNonOwnedWindow::DoSetPathShape(const wxGraphicsPath& path) { m_shapePath = path; // Convert the path to wxRegion by rendering the path on a window-sized // bitmap, creating a mask from it and finally creating the region from // this mask. wxBitmap bmp(GetSize()); { wxMemoryDC dc(bmp); dc.SetBackground(*wxBLACK); dc.Clear(); wxScopedPtr<wxGraphicsContext> context(wxGraphicsContext::Create(dc)); context->SetBrush(*wxWHITE); context->FillPath(m_shapePath); } bmp.SetMask(new wxMask(bmp, *wxBLACK)); return DoSetRegionShape(wxRegion(bmp)); }
wxBitmap ocpnFloatingCompassWindow::CreateBmp() { wxString gpsIconName; ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle(); // In order to draw a horizontal compass window when the toolbar is vertical, we // need to save away the sizes and backgrounds for the two icons. static wxBitmap compassBg, gpsBg; static wxSize toolsize; static int topmargin, leftmargin, radius; if( ! compassBg.IsOk() ) { int orient = style->GetOrientation(); style->SetOrientation( wxTB_HORIZONTAL ); if( style->HasBackground() ) { compassBg = style->GetNormalBG(); style->DrawToolbarLineStart( compassBg ); gpsBg = style->GetNormalBG(); style->DrawToolbarLineEnd( gpsBg ); } leftmargin = style->GetLeftMargin(); topmargin = style->GetTopMargin(); toolsize = style->GetToolSize(); toolsize.x *= 2; radius = style->GetToolbarCornerRadius(); if( orient ) style->SetOrientation( wxTB_VERTICAL ); } bool b_need_refresh = false; if( bGPSValid ) { if( g_bSatValid ) { gpsIconName = _T("gps3Bar"); if( g_SatsInView <= 8 ) gpsIconName = _T("gps2Bar"); if( g_SatsInView <= 4 ) gpsIconName = _T("gps1Bar"); if( g_SatsInView < 0 ) gpsIconName = _T("gpsGry"); } else gpsIconName = _T("gpsGrn"); } else gpsIconName = _T("gpsRed"); if( m_lastgpsIconName != gpsIconName ) b_need_refresh = true; double rose_angle = -999.; if( ( fabs( cc1->GetVPRotation() ) > .01 ) || ( fabs( cc1->GetVPSkew() ) > .01 ) ) { rose_angle = -cc1->GetVPRotation(); if( !g_bCourseUp && !g_bskew_comp ) rose_angle = -cc1->GetVPRotation() - cc1->GetVPSkew(); b_need_refresh = true; } else rose_angle = 0.; if( fabs( m_rose_angle - rose_angle ) > .001 ) b_need_refresh = true; if( b_need_refresh ) { wxBitmap StatBmp; StatBmp.Create( ( _img_compass.GetWidth() + _img_gpsRed.GetWidth() ) + style->GetLeftMargin() * 2 + style->GetToolSeparation(), _img_compass.GetHeight() + style->GetTopMargin() + style->GetBottomMargin() ); if( StatBmp.IsOk() ) { wxMemoryDC mdc; mdc.SelectObject( StatBmp ); mdc.SetBackground( wxBrush( GetGlobalColor( _T("GREY2") ), wxSOLID ) ); mdc.Clear(); mdc.SetPen( wxPen( GetGlobalColor( _T("UITX1") ), 1 ) ); mdc.SetBrush( wxBrush( GetGlobalColor( _T("UITX1") ), wxTRANSPARENT ) ); mdc.DrawRoundedRectangle( 0, 0, StatBmp.GetWidth(), StatBmp.GetHeight(), style->GetToolbarCornerRadius() ); wxPoint offset( style->GetLeftMargin(), style->GetTopMargin() ); // Build Compass Rose, rotated... wxBitmap BMPRose; wxPoint after_rotate; if( g_bCourseUp ) BMPRose = style->GetIcon( _T("CompassRose") ); else BMPRose = style->GetIcon( _T("CompassRoseBlue") ); if( ( fabs( cc1->GetVPRotation() ) > .01 ) || ( fabs( cc1->GetVPSkew() ) > .01 ) ) { wxPoint rot_ctr( BMPRose.GetWidth() / 2, BMPRose.GetHeight() / 2 ); wxImage rose_img = BMPRose.ConvertToImage(); wxImage rot_image = rose_img.Rotate( rose_angle, rot_ctr, true, &after_rotate ); BMPRose = wxBitmap( rot_image ).GetSubBitmap( wxRect( -after_rotate.x, -after_rotate.y, BMPRose.GetWidth(), BMPRose.GetHeight()) ); } wxBitmap iconBm; if( style->HasBackground() ) { iconBm = MergeBitmaps( compassBg, BMPRose, wxSize( 0, 0 ) ); } else { iconBm = BMPRose; } mdc.DrawBitmap( iconBm, offset ); offset.x += iconBm.GetWidth(); m_rose_angle = rose_angle; if( style->HasBackground() ) { iconBm = MergeBitmaps( gpsBg, style->GetIcon( gpsIconName ), wxSize( 0, 0 ) ); } else { iconBm = style->GetIcon( gpsIconName ); } mdc.DrawBitmap( iconBm, offset ); mdc.SelectObject( wxNullBitmap ); m_lastgpsIconName = gpsIconName; } if( style->marginsInvisible ) { m_MaskBmp = wxBitmap( StatBmp.GetWidth(), StatBmp.GetHeight() ); wxMemoryDC sdc( m_MaskBmp ); sdc.SetBackground( *wxWHITE_BRUSH ); sdc.Clear(); sdc.SetBrush( *wxBLACK_BRUSH ); sdc.SetPen( *wxBLACK_PEN ); sdc.DrawRoundedRectangle( wxPoint( leftmargin, topmargin ), toolsize, radius ); sdc.SelectObject( wxNullBitmap ); SetShape( wxRegion( m_MaskBmp, *wxWHITE, 0 ) ); } return StatBmp; } else return wxNullBitmap; }
void PianoWin::OnPaint( wxPaintEvent& event ) { ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle(); int width, height; GetClientSize( &width, &height ); wxPaintDC dc( this ); wxBitmap shape = wxBitmap( width, height ); wxMemoryDC shapeDc( shape ); shapeDc.SetBackground( *wxBLACK_BRUSH); shapeDc.SetBrush( *wxWHITE_BRUSH); shapeDc.SetPen( *wxWHITE_PEN); shapeDc.Clear(); dc.SetBackground( m_backBrush ); dc.Clear(); // Create the Piano Keys int nKeys = m_key_array.GetCount(); if( nKeys ) { wxPen ppPen( GetGlobalColor( _T("CHBLK") ), 1, wxSOLID ); dc.SetPen( ppPen ); dc.SetBrush( m_tBrush ); for( int i = 0; i < nKeys; i++ ) { int key_db_index = m_key_array.Item( i ); if( -1 == key_db_index ) continue; if( ChartData->GetDBChartType( m_key_array.Item( i ) ) == CHART_TYPE_S57 ) { dc.SetBrush( m_vBrush ); for( unsigned int ino = 0; ino < m_active_index_array.GetCount(); ino++ ) { if( m_active_index_array.Item( ino ) == key_db_index ) // chart is in the active list dc.SetBrush( m_svBrush ); } } else if( ChartData->GetDBChartType( m_key_array.Item( i ) ) == CHART_TYPE_CM93 ) { dc.SetBrush( m_cBrush ); for( unsigned int ino = 0; ino < m_active_index_array.GetCount(); ino++ ) { if( m_active_index_array.Item( ino ) == key_db_index ) // chart is in the active list dc.SetBrush( m_scBrush ); } } else if( ChartData->GetDBChartType( m_key_array.Item( i ) ) == CHART_TYPE_CM93COMP ) { dc.SetBrush( m_cBrush ); for( unsigned int ino = 0; ino < m_active_index_array.GetCount(); ino++ ) { if( m_active_index_array.Item( ino ) == key_db_index ) // chart is in the active list dc.SetBrush( m_scBrush ); } } else { dc.SetBrush( m_tBrush ); for( unsigned int ino = 0; ino < m_active_index_array.GetCount(); ino++ ) { if( m_active_index_array.Item( ino ) == key_db_index ) // chart is in the active list dc.SetBrush( m_slBrush ); } } // Check to see if this box appears in the sub_light array // If so, add a crosshatch pattern to the brush for( unsigned int ino = 0; ino < m_sublite_index_array.GetCount(); ino++ ) { if( m_sublite_index_array.Item( ino ) == key_db_index ) // chart is in the sublite list { wxBrush ebrush( dc.GetBrush().GetColour(), wxCROSSDIAG_HATCH ); // dc.SetBrush(ebrush); } } wxRect box = KeyRegion.Item( i ).GetBox(); if( m_brounded ) { dc.DrawRoundedRectangle( box.x, box.y, box.width, box.height, 4 ); shapeDc.DrawRoundedRectangle( box.x, box.y, box.width, box.height, 4 ); } else { dc.DrawRectangle( box ); shapeDc.DrawRectangle( box ); } for( unsigned int ino = 0; ino < m_sublite_index_array.GetCount(); ino++ ) { if( m_sublite_index_array.Item( ino ) == key_db_index ) { // chart is in the sublite list dc.SetBrush( dc.GetBackground() ); int w = 3; dc.DrawRoundedRectangle( box.x + w, box.y + w, box.width - ( 2 * w ), box.height - ( 2 * w ), 3 ); } } // Look in the current noshow array for this index for( unsigned int ino = 0; ino < m_noshow_index_array.GetCount(); ino++ ) { if( m_noshow_index_array.Item( ino ) == key_db_index ) { // chart is in the noshow list if( m_pInVizIconBmp && m_pInVizIconBmp->IsOk() ) dc.DrawBitmap( ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pInVizIconBmp ), box.x + 4, box.y + 3, false ); break; } } // Look in the current skew array for this index for( unsigned int ino = 0; ino < m_skew_index_array.GetCount(); ino++ ) { if( m_skew_index_array.Item( ino ) == key_db_index ) { // chart is in the list if( m_pSkewIconBmp && m_pSkewIconBmp->IsOk() ) dc.DrawBitmap( ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pSkewIconBmp ), box.x + box.width - m_pSkewIconBmp->GetWidth() - 4, box.y + 2, false ); break; } } // Look in the current tmerc array for this index for( unsigned int ino = 0; ino < m_tmerc_index_array.GetCount(); ino++ ) { if( m_tmerc_index_array.Item( ino ) == key_db_index ) { // chart is in the list if( m_pTmercIconBmp && m_pTmercIconBmp->IsOk() ) dc.DrawBitmap( ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pTmercIconBmp ), box.x + box.width - m_pTmercIconBmp->GetWidth() - 4, box.y + 2, false ); break; } } // Look in the current poly array for this index for( unsigned int ino = 0; ino < m_poly_index_array.GetCount(); ino++ ) { if( m_poly_index_array.Item( ino ) == key_db_index ) { // chart is in the list if( m_pPolyIconBmp && m_pPolyIconBmp->IsOk() ) dc.DrawBitmap( ConvertTo24Bit( dc.GetBrush().GetColour(), *m_pPolyIconBmp ), box.x + box.width - m_pPolyIconBmp->GetWidth() - 4, box.y + 2, false ); break; } } } #ifndef __WXMAC__ if( style->chartStatusWindowTransparent ) ((wxDialog*) GetParent())->SetShape( wxRegion( shape, *wxBLACK, 0 ) ); } else { // SetShape() with a completely empty shape doesn't work, and leaving the shape // but hiding the window causes artifacts when dragging in GL mode on MSW. // The best solution found so far is to show just a single pixel, this is less // disturbing than flashing piano keys when dragging. (wxWidgets 2.8) if( style->chartStatusWindowTransparent ) ((wxDialog*) GetParent())->SetShape( wxRegion( wxRect(0,0,1,1) ) ); } #else }
void gcImageControl::doPaint(wxDC* dc) { wxSize sz = GetSize(); dc->SetBackgroundMode(wxTRANSPARENT); if (!m_imgHandle.getImg() || !m_imgHandle->IsOk()) { dc->SetTextForeground(wxColor(0,0,0)); dc->Clear(); return; } if (m_bClearBG) { const wxWindow *win = UseBgCol() ? this : GetParent(); dc->SetBrush(win->GetBackgroundColour()); dc->SetPen(*wxTRANSPARENT_PEN); dc->DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight()); } if (m_uiXPro == 0 || m_uiYPro == 0) { wxBitmap temp(sz.GetWidth(), sz.GetHeight()); if (m_bTile) gcImage::tileImg(temp, wxBitmap(*m_imgHandle.getImg())); else temp = wxBitmap(m_imgHandle->Scale(sz.GetWidth(), sz.GetHeight(), wxIMAGE_QUALITY_HIGH)); dc->DrawBitmap(temp, 0, 0, true); if (m_bTransEnabled && m_imgHandle->HasMask()) { wxRegion region = wxRegion(temp); SetShape(region, this); if (m_bStoreRegion) m_Region = region; } } else { uint32 h = sz.GetWidth() * m_uiYPro / m_uiXPro; uint32 w = sz.GetHeight() * m_uiXPro / m_uiYPro; uint32 x=0; uint32 y=0; if (!m_bClearBG) { dc->SetPen(wxPen(GetBackgroundColour(),1)); dc->SetBrush(wxBrush(GetBackgroundColour())); } if (h < (uint32)sz.GetHeight()) { y = (sz.GetHeight()-h)/2; w = sz.GetWidth(); if (!m_bClearBG) { dc->DrawRectangle(0, 0, w, y); dc->DrawRectangle(0, sz.GetHeight()-y, w, y); } } else { x = (sz.GetWidth()-w)/2; h = sz.GetHeight(); if (!m_bClearBG) { dc->DrawRectangle(0, 0, x, h); dc->DrawRectangle(sz.GetWidth()-x, 0, x, h); } } wxBitmap temp(m_imgHandle->Scale(w, h, wxIMAGE_QUALITY_HIGH)); wxMemoryDC memDC; memDC.SelectObject(temp); dc->Blit(x, y, // Draw at (100, 100) w, h, // Draw full bitmap &memDC, // Draw from memDC 0, 0, // Draw from bitmap origin wxCOPY, // Logical operation true); // Take mask into account memDC.SelectObject(wxNullBitmap); } }
virtual void doPaint(wxDC* dc) { if (!m_imgHandle.getImg() || !m_imgHandle->IsOk()) { dc->SetTextForeground(wxColor(0,0,0)); dc->Clear(); return; } dc->SetFont(GetFont()); dc->SetTextBackground(GetBackgroundColour()); if (m_bHovering) dc->SetTextForeground(m_colHover); else if (m_bSelected) dc->SetTextForeground(m_colSelected); else dc->SetTextForeground(m_colNormal); int h = GetSize().GetHeight(); int w = GetSize().GetWidth(); int iw = m_imgHandle->GetSize().GetWidth(); wxBitmap tmpBmp(w, h); wxMemoryDC tmpDC(tmpBmp); tmpDC.SetBrush(wxBrush(wxColor(255,0,255))); tmpDC.SetPen( wxPen(wxColor(255,0,255),1) ); tmpDC.DrawRectangle(0,0,w,h); wxImage scaled = m_imgHandle->Scale(iw, h); wxBitmap left; wxBitmap right; wxBitmap centerImg = GetGCThemeManager()->getSprite(scaled, "playlist_button", "fill"); if (m_uiPos == LEFT) { left = GetGCThemeManager()->getSprite(scaled, "playlist_button", "left"); } else { left = GetGCThemeManager()->getSprite(scaled, "playlist_button", "fill"); } if (m_uiPos == RIGHT) { right = GetGCThemeManager()->getSprite(scaled, "playlist_button", "right"); } else { right = GetGCThemeManager()->getSprite(scaled, "playlist_button", "seperator"); } wxBitmap center(w-(left.GetWidth()+right.GetWidth()),h); wxColor c(255,0,255); gcImage::tileImg(center, centerImg, &c); tmpDC.DrawBitmap(left, 0,0,true); tmpDC.DrawBitmap(center, left.GetWidth(),0,true); tmpDC.DrawBitmap(right, w-right.GetWidth(),0,true); tmpDC.SelectObject(wxNullBitmap); dc->DrawBitmap(tmpBmp, 0,0, true); if (m_bTransEnabled) { wxRegion region = wxRegion(tmpBmp, wxColor(255,0,255), 1); SetShape(region, this); } wxString lab = GetLabel(); long x = (w - dc->GetTextExtent(lab).GetWidth())/2; long y = (h - dc->GetTextExtent(lab).GetHeight())/2; dc->DrawText(lab, x, y); }
//-------------------------------------------------------------------------- // void wxPLDevDC::ProcessString( PLStream* pls, EscText* args ) // // This is the main function which processes the unicode text strings. // Font size, rotation and color are set, width and height of the // text string is determined and then the string is drawn to the canvas. //-------------------------------------------------------------------------- void wxPLDevDC::ProcessString( PLStream* pls, EscText* args ) { // Check that we got unicode, warning message and return if not if ( args->unicode_array_len == 0 ) { printf( "Non unicode string passed to the wxWidgets driver, ignoring\n" ); return; } // Check that unicode string isn't longer then the max we allow if ( args->unicode_array_len >= 500 ) { printf( "Sorry, the wxWidgets drivers only handles strings of length < %d\n", 500 ); return; } // Calculate the font size (in pixels) fontSize = pls->chrht * VIRTUAL_PIXELS_PER_MM / scaley * 1.3; // Use PLplot core routine to get the corners of the clipping rectangle PLINT rcx[4], rcy[4]; difilt_clip( rcx, rcy ); wxPoint cpoints[4]; for ( int i = 0; i < 4; i++ ) { cpoints[i].x = rcx[i] / scalex; cpoints[i].y = height - rcy[i] / scaley; } wxDCClipper clip( *m_dc, wxRegion( 4, cpoints ) ); // calculate rotation of text plRotationShear( args->xform, &rotation, &shear, &stride ); rotation -= pls->diorot * M_PI / 2.0; cos_rot = cos( rotation ); sin_rot = sin( rotation ); // Set font color m_dc->SetTextForeground( wxColour( pls->curcolor.r, pls->curcolor.g, pls->curcolor.b ) ); m_dc->SetTextBackground( wxColour( pls->curcolor.r, pls->curcolor.g, pls->curcolor.b ) ); PLUNICODE *lineStart = args->unicode_array; int lineLen = 0; bool lineFeed = false; bool carriageReturn = false; wxCoord paraHeight = 0; // Get the curent font fontScale = 1.0; yOffset = 0.0; plgfci( &fci ); PSSetFont( fci ); while ( lineStart != args->unicode_array + args->unicode_array_len ) { while ( lineStart + lineLen != args->unicode_array + args->unicode_array_len && *( lineStart + lineLen ) != (PLUNICODE) '\n' ) { lineLen++; } //set line feed for the beginning of this line and //carriage return for the end lineFeed = carriageReturn; carriageReturn = lineStart + lineLen != args->unicode_array + args->unicode_array_len && *( lineStart + lineLen ) == (PLUNICODE) ( '\n' ); if ( lineFeed ) paraHeight += textHeight + subscriptDepth; //remember the text parameters so they can be restored double startingFontScale = fontScale; double startingYOffset = yOffset; PLUNICODE startingFci = fci; // determine extent of text posX = args->x / scalex; posY = args->y / scaley; PSDrawText( lineStart, lineLen, false ); if ( lineFeed && superscriptHeight > textHeight ) paraHeight += superscriptHeight - textHeight; // actually draw text, resetting the font first fontScale = startingFontScale; yOffset = startingYOffset; fci = startingFci; PSSetFont( fci ); posX = (PLINT) ( args->x / scalex - ( args->just * textWidth ) * cos_rot - ( 0.5 * textHeight - paraHeight * lineSpacing ) * sin_rot ); //move to set alignment posY = (PLINT) ( args->y / scaley - ( args->just * textWidth ) * sin_rot + ( 0.5 * textHeight - paraHeight * lineSpacing ) * cos_rot ); PSDrawText( lineStart, lineLen, true ); //draw text lineStart += lineLen; if ( carriageReturn ) lineStart++; lineLen = 0; } //posX = args->x; //posY = args->y; //PSDrawText( args->unicode_array, args->unicode_array_len, false ); //posX = (PLINT) ( args->x - ( ( args->just * textWidth ) * cos_rot + ( 0.5 * textHeight ) * sin_rot ) * scalex ); //posY = (PLINT) ( args->y - ( ( args->just * textWidth ) * sin_rot - ( 0.5 * textHeight ) * cos_rot ) * scaley ); //PSDrawText( args->unicode_array, args->unicode_array_len, true ); AddtoClipRegion( 0, 0, width, height ); }