void wxQtDCImpl::SetBrush(const wxBrush& brush) { m_brush = brush; if (brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) { // Use a monochrome mask: use foreground color for the mask QBrush b(brush.GetHandle()); b.setColor(m_textForegroundColour.GetHandle()); b.setTexture(b.texture().mask()); m_qtPainter->setBrush(b); } else if (brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { //Don't use the mask QBrush b(brush.GetHandle()); QPixmap p = b.texture(); p.setMask(QBitmap()); b.setTexture(p); m_qtPainter->setBrush(b); } else { m_qtPainter->setBrush(brush.GetHandle()); } ApplyRasterColourOp(); }
void wxGraphicsContext::SetBrush( const wxBrush& brush ) { if ( !brush.Ok() || brush.GetStyle() == wxTRANSPARENT ) SetBrush( wxNullGraphicsBrush ); else SetBrush( CreateBrush( brush ) ); }
/***************************************************** ** ** PdfPainter --- setBrush ** ******************************************************/ void PdfPainter::setBrush( const wxBrush &b ) { // TODO howto scale width und height if ( b.GetStyle() == wxSTIPPLE ) { wxImage image; wxBitmap *bitmap = b.GetStipple(); if ( bitmap && bitmap->IsOk()) { image = bitmap->ConvertToImage(); double width = image.GetWidth() / 3; double height = image.GetHeight() / 3; // setup a hash value for the image wxString s = createImageHash( &image ); pdf->AddPattern( s, image, width, height ); drawmode = wxPDF_STYLE_FILL; pdf->SetFillPattern( s ); pdf->SetDrawPattern( s ); } } else if ( b.GetStyle() != wxTRANSPARENT && b.GetColour().IsOk() ) setBrushColor( b.GetColour() ); else { drawmode = wxPDF_STYLE_DRAW; } }
wxBrush &GetGreyBrush(wxBrush &brush) { static wxBrush b; wxColour c; b = brush; c = MakeColourGrey(brush.GetColour()); b.SetColour(c); return b; }
void wxGenericBrush::Set( const wxBrush &brush ) { wxCHECK_RET(Ok() && brush.Ok(), wxT("Invalid generic brush")); SetColour(brush.GetColour()); M_GBRUSHDATA->m_style = brush.GetStyle(); wxBitmap* stipple = brush.GetStipple(); if (stipple && stipple->Ok()) M_GBRUSHDATA->m_stipple = *stipple; }
void wxQtDCImpl::SetBackground(const wxBrush& brush) { m_backgroundBrush = brush; if (m_qtPainter->isActive()) m_qtPainter->setBackground(brush.GetHandle()); }
bool wxGenericBrush::IsSameAs(const wxBrush& brush) const { wxCHECK_MSG(Ok() && brush.Ok(), 1, wxT("Invalid generic brush")); wxGenericBrush gB(brush); gB.GetGenericColour().SetAlpha(M_GBRUSHDATA->m_colour.GetAlpha()); return IsSameAs(gB); }
void wxDC::SetBackground(const wxBrush& brush) { wxCHECK_RET( Ok(), wxT("invalid dc") ); if (!brush.Ok()) return; m_backgroundBrush = brush; }
void ocpnDC::SetBackground( const wxBrush &brush ) { if( dc ) dc->SetBackground( brush ); else { #ifdef ocpnUSE_GL glcanvas->SetBackgroundColour( brush.GetColour() ); #endif } }
void StateEvaluationTreePanel::drawIndicatorAtArea(wxDC &DC, IndicatorStyle const &Style, wxCoord X, wxCoord Y, wxCoord W, wxCoord H) { auto const Kind = Style.GetKind(); auto const FG = Style.GetForeground(); wxPen const PrevPen = DC.GetPen(); wxBrush const PrevBrush = DC.GetBrush(); switch (Kind) { case IndicatorStyle::EKind::Plain: DC.SetPen(wxPen{FG, Settings.PenWidth}); DC.DrawLine(X, Y+H, X+W, Y+H); break; case IndicatorStyle::EKind::Box: DC.SetPen(wxPen{FG, Settings.PenWidth}); DC.DrawRectangle(X, Y, W, H); break; case IndicatorStyle::EKind::StraightBox: // Many DCs don't support alpha at all, so manually calculate an alpha // against the background colour. auto const BG = PrevBrush.GetColour(); double const Alpha = (double)Style.GetAlpha() / 255; double const OutlineAlpha = (double)Style.GetOutlineAlpha() / 255; DC.SetPen(wxPen{ wxColour(wxColour::AlphaBlend(FG.Red(), BG.Red(), OutlineAlpha), wxColour::AlphaBlend(FG.Green(), BG.Green(), OutlineAlpha), wxColour::AlphaBlend(FG.Blue(), BG.Blue(), OutlineAlpha)), Settings.PenWidth}); DC.SetBrush(wxBrush{ wxColour(wxColour::AlphaBlend(FG.Red(), BG.Red(), Alpha), wxColour::AlphaBlend(FG.Green(), BG.Green(), Alpha), wxColour::AlphaBlend(FG.Blue(), BG.Blue(), Alpha))}); DC.DrawRectangle(X, Y, W, H); break; } DC.SetPen(PrevPen); DC.SetBrush(PrevBrush); }
//--------------------------------------------------------------------------- void wxPagedWindow::DrawPaperBar( twTabInfo& tab, int x, int y, wxBrush& brush, wxPen& pen, wxDC& dc ) { wxPoint poly[4]; // draw organizer-style paper outlet poly[0].x = x - mTabTrianGap; poly[0].y = y; poly[1].x = x + mTabTrianGap; poly[1].y = y + tab.mDims.y-1; poly[2].x = x + tab.mDims.x - mTabTrianGap; poly[2].y = y + tab.mDims.y-1; poly[3].x = x + tab.mDims.x + mTabTrianGap; poly[3].y = y; dc.SetPen( pen ); dc.SetBrush( brush ); dc.DrawPolygon( 4, poly ); long w,h; // set select default font of the window into it's device context //dc.SetFont( GetLabelingFont() ); dc.SetTextBackground( brush.GetColour() ); dc.GetTextExtent(tab.mText, &w, &h ); if ( tab.HasImg() ) { wxMemoryDC tmpDc; tmpDc.SelectObject( tab.GetImg() ); dc.Blit( x + mTitleHorizGap, y + ( tab.mDims.y - tab.ImgHeight() ) / 2, tab.ImgWidth(), tab.ImgHeight(), &tmpDc, 0, 0, wxCOPY ); } if ( tab.HasText() ) { int tx = x + mTitleHorizGap + tab.ImgWidth() + tab.ImageToTxtGap(mImageTextGap); dc.DrawText( tab.GetText(), tx, y + ( tab.mDims.y - h ) / 2 ); } } // wxPagedWindow::DrawPaperBar()
bool SjOscStar::Draw(wxDC& dc, const wxSize& clientSize, double rot, wxPen& pen, wxBrush& brush) { double xfloat, yfloat; int x, y, hh, vv; int d, intensity; m_z -= 2; if( m_z < -63 ) { m_z = STAR_DEPTH; m_doDraw = !m_exitRequest; } hh = (m_x*64)/(64+m_z); vv = (m_y*64)/(64+m_z); // check position x = hh + 500; y = vv + 500; if( x < -300 || x > 1300 || y < -300 || y > 1300 ) { m_z = STAR_DEPTH; m_doDraw = !m_exitRequest; hh = (m_x*64)/(64+m_z); vv = (m_y*64)/(64+m_z); } // calculate position xfloat = (hh*cos(rot))-(vv*sin(rot)); yfloat = (hh*sin(rot))+(vv*cos(rot)); x = (int)xfloat + 500; y = (int)yfloat + 500; // use star? if( !m_doDraw ) { if( m_exitRequest || x < 450 || x > 550 || y < 450 || y > 550 ) { return FALSE; } else { m_doDraw = TRUE; } } // map star position to client size, keep aspect ratio d = clientSize.x; if( clientSize.y > d ) { d = clientSize.y; } if( d == 0 ) { d = 10; } x = (x * d) / 1000 - (d-clientSize.x)/2; y = (y * d) / 1000 - (d-clientSize.y)/2; // calculate size d = (STAR_DEPTH-m_z) / (38400/d); if( d == 0 ) d = 1; // calculate light intensity intensity = STAR_DEPTH-m_z; intensity = 55 + ((intensity * 200) / STAR_DEPTH); //if( intensity < light ) intensity = light + 10; if( intensity < 0 ) intensity = 0; if( intensity > 255 ) intensity = 255; // draw star if( d==1 ) { pen.SetColour(intensity, intensity, intensity); dc.SetPen(pen); dc.DrawPoint(x, y); } else { dc.SetPen(*wxTRANSPARENT_PEN); brush.SetColour(intensity, intensity, intensity); dc.SetBrush(brush); dc.DrawRectangle(x, y, d, d); } return TRUE; }
void SjOscWindow::OnTimer(wxTimerEvent&) { SJ_FORCE_IN_HERE_ONLY_ONCE; if( m_oscModule ) { // volume stuff long volume, maxVolume = 1; bool volumeBeat; // other objects long i; bool titleChanged, forceOscAnim, forceSpectrAnim; wxString newTitle; // get data g_mainFrame->m_player.GetVisData(m_bufferStart, m_sampleCount*SJ_WW_CH*SJ_WW_BYTERES, 0); // get window client size, correct offscreen DC if needed wxSize clientSize = m_oscModule->m_oscWindow->GetClientSize(); if( clientSize.x != m_offscreenBitmap.GetWidth() || clientSize.y != m_offscreenBitmap.GetHeight() ) { m_offscreenBitmap.Create(clientSize.x, clientSize.y); m_offscreenDc.SelectObject(m_offscreenBitmap); } // calculate the points for the lines, collect volume m_oscilloscope->Calc(clientSize, m_bufferStart, volume); if( m_oscModule->m_showFlags&SJ_OSC_SHOW_SPECTRUM ) { m_spectrum->Calc(clientSize, m_bufferStart); } // get data that are shared between the threads { titleChanged = m_oscModule->m_titleChanged; m_oscModule->m_titleChanged = FALSE; if( titleChanged ) { newTitle = m_oscModule->m_trackName; if( newTitle.IsEmpty() ) { newTitle = SJ_PROGRAM_NAME; } else if( !m_oscModule->m_leadArtistName.IsEmpty() ) { newTitle.Prepend(m_oscModule->m_leadArtistName + wxT(" - ")); } } forceOscAnim = m_oscModule->m_forceOscAnim; m_oscModule->m_forceOscAnim = FALSE; forceSpectrAnim = m_oscModule->m_forceSpectrAnim; m_oscModule->m_forceSpectrAnim = FALSE; } // calculate volume, volume is theoretically max. 255, normally lesser if( titleChanged ) { maxVolume = 1; } if( volume > maxVolume ) { maxVolume = volume; } volumeBeat = (volume > maxVolume/2); // erase screen m_offscreenDc.SetPen(*wxTRANSPARENT_PEN); { // blue gradient background #define BG_STEPS 88 int rowH = (clientSize.y/BG_STEPS)+1; for( i = 0; i < BG_STEPS; i++ ) { m_bgBrush.SetColour(0, 0, i); m_offscreenDc.SetBrush(m_bgBrush); m_offscreenDc.DrawRectangle(0, i*rowH, clientSize.x, rowH); } } // draw text (very background) { m_offscreenDc.SetBackgroundMode(wxTRANSPARENT); m_offscreenDc.SetTextForeground(m_textColour); m_title->Draw(m_offscreenDc, clientSize, titleChanged, newTitle); } // draw figures (they lay in backgroud) if( m_oscModule->m_showFlags&SJ_OSC_SHOW_FIGURES ) { long bgLight = 100; // draw hands (optional) m_hands->Draw(m_offscreenDc, clientSize, volume, bgLight, titleChanged); // draw rotor (optional) m_rotor->Draw(m_offscreenDc, clientSize, m_starfield->IsRunning(), titleChanged, volume, bgLight); // draw firework (optional) m_firework->Draw(m_offscreenDc, clientSize, titleChanged, m_starfield->IsRunning(), volumeBeat, bgLight); } // draw starfield (optional) m_starfield->Draw(m_offscreenDc, clientSize, false, titleChanged, (m_oscModule->m_showFlags&SJ_OSC_SHOW_STARFIELD)!=0); // draw spectrum and/or oscilloscope (for both, the spectrum lays over the oscillosope) m_offscreenDc.SetPen(m_fgPen); if( m_oscModule->m_showFlags&SJ_OSC_SHOW_OSC ) { m_oscilloscope->Draw(m_offscreenDc, forceOscAnim); } if( m_oscModule->m_showFlags&SJ_OSC_SHOW_SPECTRUM ) { m_spectrum->Draw(m_offscreenDc, volumeBeat, (m_oscModule->m_showFlags&SJ_OSC_SHOW_FIGURES)? true : false, forceSpectrAnim); } // draw offscreen bitmap to screen wxClientDC dc(this); dc.Blit(0, 0, m_offscreenBitmap.GetWidth(), m_offscreenBitmap.GetHeight(), &m_offscreenDc, 0, 0); } }
void ThemeBase::SetBrushColour( wxBrush & Brush, int iIndex ) { wxASSERT( iIndex >= 0 ); Brush.SetColour( Colour( iIndex )); }
void ocpnDC::SetBackground( const wxBrush &brush ) { if( dc ) dc->SetBackground( brush ); else glcanvas->SetBackgroundColour( brush.GetColour() ); }
wxString xsBrushPropIO::ToString(wxBrush value) { return wxString::Format(wxT("%s %d"), xsColourPropIO::ToString(value.GetColour()).c_str(), value.GetStyle()); }
static void SetColor(unsigned char color[4], const wxBrush &brush) { const wxColour &c = brush.GetColour(); color[0] = c.Red(), color[1] = c.Green(), color[2] = c.Blue(), color[3] = 255; }
virtual void SetBrush(const wxBrush& brush) override { wxBrush newbrush = brush; newbrush.SetColour(PivotColour(brush.GetColour())); wxMirrorDC::SetBrush(newbrush); }
static void LINKAGEMODE wxImageFloodFill(wxImage *image, wxCoord x, wxCoord y, const wxBrush & fillBrush, const wxColour& testColour, int style) { /* A diamond flood-fill using a circular queue system. Each pixel surrounding the current pixel is added to the queue if it meets the criteria, then is retrieved in its turn. Code originally based on http://www.drawit.co.nz/Developers.htm, with explicit permission to use this for wxWidgets granted by Andrew Empson (no copyright claimed) */ int width = image->GetWidth(); int height = image->GetHeight(); //Draw using a pen made from the current brush colour //Potentially allows us to use patterned flood fills in future code wxColour fillColour = fillBrush.GetColour(); unsigned char r = fillColour.Red(); unsigned char g = fillColour.Green(); unsigned char b = fillColour.Blue(); //initial test : if (style == wxFLOOD_SURFACE) { //if wxFLOOD_SURFACE, if fill colour is same as required, we don't do anything if ( image->GetRed(x,y) != r || image->GetGreen(x,y) != g || image->GetBlue (x,y) != b ) { //prepare memory for queue //queue save, start, read size_t *qs, *qst, *qr; //queue size (physical) long qSz= height * width * 2; qst = new size_t [qSz]; //temporary x and y locations int xt, yt; for (int i=0; i < qSz; i++) qst[i] = 0; // start queue qs=qr=qst; *qs=xt=x; qs++; *qs=yt=y; qs++; image->SetRGB(xt,yt,r,g,b); //Main queue loop while(qr!=qs) { //Add new members to queue //Above current pixel if(MatchPixel(image,xt,yt-1,width,height,testColour)) { *qs=xt; qs++; *qs=yt-1; qs++; image->SetRGB(xt,yt-1,r,g,b); //Loop back to beginning of queue if(qs>=(qst+qSz)) qs=qst; } //Below current pixel if(MatchPixel(image,xt,yt+1,width,height,testColour)) { *qs=xt; qs++; *qs=yt+1; qs++; image->SetRGB(xt,yt+1,r,g,b); if(qs>=(qst+qSz)) qs=qst; } //Left of current pixel if(MatchPixel(image,xt-1,yt,width,height,testColour)) { *qs=xt-1; qs++; *qs=yt; qs++; image->SetRGB(xt-1,yt,r,g,b); if(qs>=(qst+qSz)) qs=qst; } //Right of current pixel if(MatchPixel(image,xt+1,yt,width,height,testColour)) { *qs=xt+1; qs++; *qs=yt; qs++; image->SetRGB(xt+1,yt,r,g,b); if(qs>=(qst+qSz)) qs=qst; } //Retrieve current queue member qr+=2; //Loop back to the beginning if(qr>=(qst+qSz)) qr=qst; xt=*qr; yt=*(qr+1); //Go Back to beginning of loop } delete[] qst; } } else { //style is wxFLOOD_BORDER // fill up to testColor border - if already testColour don't do anything if ( image->GetRed(x,y) != testColour.Red() || image->GetGreen(x,y) != testColour.Green() || image->GetBlue(x,y) != testColour.Blue() ) { //prepare memory for queue //queue save, start, read size_t *qs, *qst, *qr; //queue size (physical) long qSz= height * width * 2; qst = new size_t [qSz]; //temporary x and y locations int xt, yt; for (int i=0; i < qSz; i++) qst[i] = 0; // start queue qs=qr=qst; *qs=xt=x; qs++; *qs=yt=y; qs++; image->SetRGB(xt,yt,r,g,b); //Main queue loop while (qr!=qs) { //Add new members to queue //Above current pixel if(!MatchBoundaryPixel(image,xt,yt-1,width,height,fillColour,testColour)) { *qs=xt; qs++; *qs=yt-1; qs++; image->SetRGB(xt,yt-1,r,g,b); //Loop back to beginning of queue if(qs>=(qst+qSz)) qs=qst; } //Below current pixel if(!MatchBoundaryPixel(image,xt,yt+1,width,height,fillColour,testColour)) { *qs=xt; qs++; *qs=yt+1; qs++; image->SetRGB(xt,yt+1,r,g,b); if(qs>=(qst+qSz)) qs=qst; } //Left of current pixel if(!MatchBoundaryPixel(image,xt-1,yt,width,height,fillColour,testColour)) { *qs=xt-1; qs++; *qs=yt; qs++; image->SetRGB(xt-1,yt,r,g,b); if(qs>=(qst+qSz)) qs=qst; } //Right of current pixel if(!MatchBoundaryPixel(image,xt+1,yt,width,height,fillColour,testColour)) { *qs=xt+1; qs++; *qs=yt; qs++; image->SetRGB(xt+1,yt,r,g,b); if(qs>=(qst+qSz)) qs=qst; } //Retrieve current queue member qr+=2; //Loop back to the beginning if(qr>=(qst+qSz)) qr=qst; xt=*qr; yt=*(qr+1); //Go Back to beginning of loop } delete[] qst; } } //all done, }
void wxDC::SetBrush(const wxBrush& brush) { m_brush = brush.Ok() ? brush : DEFAULT_BRUSH; }