/* * DialogCtlColor: Handle CTLCOLOR messages for dialog boxes. */ HBRUSH DialogCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type) { switch (type) { case CTLCOLOR_EDIT: SelectPalette(hdc, hPal, FALSE); SetTextColor(hdc, GetColor(COLOR_EDITFGD)); SetBkColor(hdc, GetColor(COLOR_EDITBGD)); return GetBrush(COLOR_EDITBGD); case CTLCOLOR_LISTBOX: SelectPalette(hdc, hPal, FALSE); SetTextColor(hdc, GetColor(COLOR_LISTFGD)); SetBkColor(hdc, GetColor(COLOR_LISTBGD)); return GetBrush(COLOR_LISTBGD); case CTLCOLOR_SCROLLBAR: return (HBRUSH) FALSE; default: SelectPalette(hdc, hPal, FALSE); /* All others--dialog, static, buttons, etc. */ // Removed for CTL3D // SetTextColor(hdc, GetColor(COLOR_DIALOGFGD)); // SetBkColor(hdc, GetColor(COLOR_DIALOGBGD)); // return GetBrush(COLOR_DIALOGBGD); return (HBRUSH) FALSE; } }
void BrushCmd::Execute () { BrushVar* brVar = (BrushVar*) GetEditor()->GetState("BrushVar"); if (brVar != nil) { brVar->SetBrush(GetBrush()); } Command::Execute(); }
void CDrawContext::SelectBrush( COLORREF cr ) { if( !m_bBrushSelected || cr != m_crCurrentBrush ) { VAPI( ::SelectObject( m_hdc, GetBrush( cr ) ) ); m_crCurrentBrush = cr; m_bBrushSelected = true; } }
/* * MailCtlColor: Set color of various sections of mail dialogs. */ HBRUSH MailCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type) { if (type == CTLCOLOR_EDIT) { SetTextColor(hdc, GetColor(COLOR_MAILFGD)); SetBkColor(hdc, GetColor(COLOR_MAILBGD)); return GetBrush(COLOR_MAILBGD); } return DialogCtlColor(hwnd, hdc, hwndChild, type); }
/* * MainCtlColor: Handle CTLCOLOR messages for main window. */ HBRUSH MainCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type) { switch (type) { case CTLCOLOR_EDIT: SelectPalette(hdc, hPal, FALSE); SetTextColor(hdc, GetColor(COLOR_MAINEDITFGD)); SetBkColor(hdc, GetColor(COLOR_MAINEDITBGD)); return GetBrush(COLOR_MAINEDITBGD); case CTLCOLOR_SCROLLBAR: /* Don't color scrollbars */ //return (HBRUSH) FALSE; return (HBRUSH) GetStockObject( BLACK_BRUSH ); // xxx default: SelectPalette(hdc, hPal, FALSE); SetTextColor(hdc, GetColor(COLOR_FGD)); SetBkColor(hdc, GetColor(COLOR_BGD)); return GetBrush(COLOR_BGD); } }
void MyTriangle::Paint(const HDC& hdc) const { HBRUSH hBrush = CreateSolidBrush(GetBrush()); HPEN hPen = CreatePen(PS_SOLID, 1, GetPen()); HBRUSH hBrushOld = (HBRUSH)SelectObject(hdc, hBrush); SelectObject(hdc, hPen); Polygon(hdc, poly, 3); DeleteObject(hBrush); DeleteObject(hPen); }
void BitmapGraphic::Write (ostream& out) { Catalog* catalog = unidraw->GetCatalog(); catalog->WriteBgFilled(BgFilled(), out); catalog->WriteBrush(GetBrush(), out); catalog->WriteColor(GetFgColor(), out); catalog->WriteColor(GetBgColor(), out); catalog->WriteFont(GetFont(), out); catalog->WritePattern(GetPattern(), out); catalog->WriteTransformer(GetTransformer(), out); catalog->WriteString(_fg_name, out); }
void ACanvasSkia::_SetPaint_Fill() { ABrush* br = GetBrush(); m_Paint.setStyle(SkPaint::kFill_Style); if( br->GetType() == BrushTypeSolidColor ) { ASolidBrush* sb = (ASolidBrush *)br; m_Paint.setColor(toSkColor(sb->GetColor())); } else if( br->GetType() == BrushTypeLinearGradient ) { SkPoint pts[2]; ALinearGradientBrush* lgb = (ALinearGradientBrush*)br; SkRect rx = ToSkRect( lgb->GetRect() ); pts[0].set( rx.fLeft,rx.fTop ); if( lgb->IsVert() ) pts[1].set( rx.fLeft,rx.fBottom ); else pts[1].set( rx.fRight,rx.fTop ); SkColor colors[2]; colors[0] = toSkColor( lgb->GetStartColor() ); colors[1] = toSkColor( lgb->GetEndColor() ); SkScalar pos[2]; pos[0] = SkScalar(0.0); pos[1] = SkScalar(1.0); SkShader* pShader = SkGradientShader::CreateLinear(pts,colors,pos,2,SkShader::kClamp_TileMode); m_Paint.setShader(pShader)->unref(); } else if( br->GetType() == BrushTypeRadialGradient ) { ARadialBrush* rb = (ARadialBrush*)br; SkPoint ptCenter; APoint ptCenter0 = rb->GetCenter(); ptCenter.set( SkIntToScalar(ptCenter0.x),SkIntToScalar(ptCenter0.y) ); SkScalar nRadius = SkIntToScalar( rb->GetRadius() ); SkColor colors[2]; colors[0] = toSkColor( rb->GetStartColor() ); colors[1] = toSkColor( rb->GetEndColor() ); SkScalar pos[2]; pos[0] = SkScalar(0.0); pos[1] = SkScalar(1.0); SkShader* pShader = SkGradientShader::CreateRadial(ptCenter,nRadius,colors,pos,2,SkShader::kClamp_TileMode); m_Paint.setShader(pShader)->unref(); } }
ATOM Window::Register(HINSTANCE hinst) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)Window::s_WinProc; wcex.cbClsExtra = GetClassExtra(); wcex.cbWndExtra = GetWinExtra(); wcex.hInstance = hinst; wcex.hIcon = GetIcon(); wcex.hCursor = GetCursor(); wcex.hbrBackground = GetBrush(); wcex.lpszMenuName = GetMenu(); wcex.lpszClassName = ClassName(); wcex.hIconSm = GetSmallIcon(); return RegisterClassEx(&wcex); }
void ocpnDC::StrokeCircle( wxCoord x, wxCoord y, wxCoord radius ) { #if wxUSE_GRAPHICS_CONTEXT if( pgc ) { wxGraphicsPath gpath = pgc->CreatePath(); gpath.AddCircle( x, y, radius ); pgc->SetPen( GetPen() ); pgc->SetBrush( GetBrush() ); pgc->DrawPath( gpath ); // keep dc dirty box up-to-date dc->CalcBoundingBox( x + radius + 2, y + radius + 2 ); dc->CalcBoundingBox( x - radius - 2, y - radius - 2 ); } else #endif DrawCircle( x, y, radius ); }
void wxDCBase::DoDrawEllipticArcRot( wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea, double angle ) { wxList list; CalculateEllipticPoints( &list, x, y, w, h, sa, ea ); Rotate( &list, angle, wxPoint( x+w/2, y+h/2 ) ); // Add center (for polygon/pie) list.Append( (wxObject*) new wxPoint( x+w/2, y+h/2 ) ); // copy list into array and delete list elements int n = list.Number(); wxPoint *points = new wxPoint[n]; int i = 0; wxNode* node = 0; for ( node = list.First(); node; node = node->Next(), i++ ) { wxPoint *point = (wxPoint *)node->Data(); points[i].x = point->x; points[i].y = point->y; delete point; } // first draw the pie without pen, if necessary if( GetBrush() != *wxTRANSPARENT_BRUSH ) { wxPen tempPen( GetPen() ); SetPen( *wxTRANSPARENT_PEN ); DoDrawPolygon( n, points, 0, 0 ); SetPen( tempPen ); } // then draw the arc without brush, if necessary if( GetPen() != *wxTRANSPARENT_PEN ) { // without center DoDrawLines( n-1, points, 0, 0 ); } delete [] points; } // DrawEllipticArcRot
void ocpnDC::StrokePolygon( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) { #if wxUSE_GRAPHICS_CONTEXT if( pgc ) { wxGraphicsPath gpath = pgc->CreatePath(); gpath.MoveToPoint( points[0].x + xoffset, points[0].y + yoffset ); for( int i = 1; i < n; i++ ) gpath.AddLineToPoint( points[i].x + xoffset, points[i].y + yoffset ); gpath.AddLineToPoint( points[0].x + xoffset, points[0].y + yoffset ); pgc->SetPen( GetPen() ); pgc->SetBrush( GetBrush() ); pgc->DrawPath( gpath ); for( int i = 0; i < n; i++ ) dc->CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset ); } else #endif DrawPolygon( n, points, xoffset, yoffset ); }
Bool WINAPI EventRedraw(HDC main_hdc) { PAINTSTRUCT ps; HDC hdc; int height; RECT r; /* Redraw background */ hdc = BeginPaint(cinfo->hMain, &ps); FillRect(hdc, &ps.rcPaint, GetBrush(COLOR_BGD)); SelectPalette(hdc, cinfo->hPal, FALSE); /* Draw bitmap */ GetClientRect(cinfo->hMain, &r); height = min(bm_height, r.bottom - button_height); if (hTitleDC != NULL) BitBlt(hdc, bm_origin.x, bm_origin.y, bm_width, height, hTitleDC, 0, 0, SRCCOPY); EndPaint(cinfo->hMain, &ps); return True; }
void MainExpose(HWND hwnd) { PAINTSTRUCT ps; HDC hdc; switch (state) { case STATE_OFFLINE: OfflineExpose(hwnd); break; case STATE_GAME: GameExpose(hwnd); break; default: /* Redraw background */ hdc = BeginPaint(hwnd, &ps); FillRect(hdc, &ps.rcPaint, GetBrush(COLOR_BGD)); EndPaint(hwnd, &ps); break; } }
void GCanvas::DrawRoundRect(ARect r,int dx,int dy) { GetBrush()->SetStyle(BS_NULL); Flush(); ::RoundRect(m_hDC,r.left,r.top,r.right,r.bottom,dx,dy); }
void BrushCmd::Write (ostream& out) { Command::Write(out); unidraw->GetCatalog()->WriteBrush(GetBrush(), out); }
void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea) { /* Draws an arc of an ellipse. The current pen is used for drawing the arc and the current brush is used for drawing the pie. x and y specify the x and y coordinates of the upper-left corner of the rectangle that contains the ellipse. width and height specify the width and height of the rectangle that contains the ellipse. start and end specify the start and end of the arc relative to the three-o'clock position from the center of the rectangle. Angles are specified in degrees (360 is a complete circle). Positive values mean counter-clockwise motion. If start is equal to end, a complete ellipse will be drawn. */ //radius double rx = w / 2.0; double ry = h / 2.0; // center double xc = x + rx; double yc = y + ry; // start and end coords double xs, ys, xe, ye; xs = xc + rx * cos (wxDegToRad(sa)); xe = xc + rx * cos (wxDegToRad(ea)); ys = yc - ry * sin (wxDegToRad(sa)); ye = yc - ry * sin (wxDegToRad(ea)); // svg arcs have 0 degrees at 12-o'clock instead of 3-o'clock double start = (sa - 90); if (start < 0) start += 360; while (abs(start) > 360) start -= (start / abs(start)) * 360; double end = (ea - 90); if (end < 0) end += 360; while (abs(end) > 360) end -= (end / abs(end)) * 360; // svg arcs are in clockwise direction, reverse angle double angle = end - start; if (angle <= 0) angle += 360; int fArc = angle > 180 ? 1 : 0; // flag for large or small arc int fSweep = 0; // flag for sweep always 0 wxString arcPath; if (angle == 360) { // Drawing full circle fails with default arc. Draw two half arcs instead. fArc = 1; arcPath = wxString::Format(wxS(" <path d=\"M%s %s a%s %s 0 %d %d %s %s a%s %s 0 %d %d %s %s"), NumStr(x), NumStr(y + ry), NumStr(rx), NumStr(ry), fArc, fSweep, NumStr( rx * 2), NumStr(0), NumStr(rx), NumStr(ry), fArc, fSweep, NumStr(-rx * 2), NumStr(0)); } else { arcPath = wxString::Format(wxS(" <path d=\"M%s %s A%s %s 0 %d %d %s %s"), NumStr(xs), NumStr(ys), NumStr(rx), NumStr(ry), fArc, fSweep, NumStr(xe), NumStr(ye)); } // Workaround so SVG does not draw an extra line from the centre of the drawn arc // to the start point of the arc. // First draw the arc with the current brush, without a border, // then draw the border without filling the arc. if (GetBrush().GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { wxDCPenChanger setTransp(*GetOwner(), *wxTRANSPARENT_PEN); NewGraphicsIfNeeded(); wxString arcFill = arcPath; arcFill += wxString::Format(wxS(" L%s %s z"), NumStr(xc), NumStr(yc)); arcFill += wxS("\"/>\n"); write(arcFill); } wxDCBrushChanger setTransp(*GetOwner(), *wxTRANSPARENT_BRUSH); NewGraphicsIfNeeded(); wxString arcLine = arcPath + wxS("\"/>\n"); write(arcLine); }
Command* BrushCmd::Copy () { Command* copy = new BrushCmd(CopyControlInfo(), GetBrush()); InitCopy(copy); return copy; }
void PadGraphic::concatGS (Graphic* g1, Graphic* g2, Graphic* dest) { Graphic::concatGS(g1, g2, dest); dest->SetBrush(GetBrush()); }
//virtual void PSVGEllipseElement::Render4(CHTMRenderContext* pC, Graphics::Bitmap* pBitmap, Gui::RenderContext* renderContext, double scaleX, double scaleY, bool bOffscreen, bool bDrawBehaviors) { SVGEllipseElement* psvgElement = static_cast<SVGEllipseElement*>(m_pNode); double fillOpacity = m_computedFillOpacity; double strokeOpacity = m_computedStrokeOpacity; Gui::Brush* fillBrush = GetBrush(renderContext, &m_computedFill, m_pFillElement, fillOpacity, scaleX, scaleY); Gui::Brush* strokeBrush = GetBrush(renderContext, &m_computedStroke, m_pStrokeElement, strokeOpacity, scaleX, scaleY); if (fillBrush) { renderContext->FillEllipse(m_computedCx, m_computedCy, m_computedRx, m_computedRy, fillBrush); } if (strokeBrush) { float strokeWidth = m_computedStrokeWidth; renderContext->DrawEllipse(m_computedCx, m_computedCy, m_computedRx, m_computedRy, strokeBrush, strokeWidth); } #if 0 D2D1_ELLIPSE ellipse; ellipse.point.x = m_computedCx; ellipse.point.y = m_computedCy; ellipse.radiusX = m_computedRx; ellipse.radiusY = m_computedRy; if (fillBrush) { renderContext->GetRT()->m_spRT->FillEllipse(ellipse, fillBrush); fillBrush->Release(); } if (strokeBrush) { // LDraw::Pen* pPen = GetPen(pStrokeBrush); float strokeWidth = m_computedStrokeWidth; ID2D1StrokeStyle* strokeStyle = NULL; renderContext->GetRT()->m_spRT->DrawEllipse(ellipse, strokeBrush, strokeWidth, strokeStyle); strokeBrush->Release(); } #endif return; #if 0 SVGEllipseElement* psvgElement = static_cast<SVGEllipseElement*>(m_pNode); pGraphics->SetSmoothingMode(LDraw::SmoothingModeAntiAlias/*pGraphics->GetSmoothingMode()*/); // __release<LDraw::GraphicsPathF> GraphicsPathF = new LDraw::GraphicsPathF; // GraphicsPathF->AddEllipse(float(m_bounds.X), float(m_bounds.Y), float(m_bounds.Width), float(m_bounds.Height)); //DrawPathSegList(seglist, &GraphicsPathF, NULL); double fillOpacity = m_computedFillOpacity; double strokeOpacity = m_computedStrokeOpacity; if (!bOffscreen) { fillOpacity *= m_computedOpacity; strokeOpacity *= m_computedOpacity; } LDraw::Brush* pFillBrush = GetBrush(&m_computedFill, m_pFillElement, fillOpacity, scaleX, scaleY); LDraw::Brush* pStrokeBrush = GetBrush(&m_computedStroke, m_pStrokeElement, strokeOpacity, scaleX, scaleY); if (pFillBrush != NULL) { pGraphics->FillEllipse(pFillBrush, float(m_bounds.X), float(m_bounds.Y), float(m_bounds.Width), float(m_bounds.Height)); } if (pStrokeBrush != NULL) { LDraw::Pen* pPen = GetPen(pStrokeBrush); if (pPen != NULL) { pGraphics->DrawEllipse(pPen, float(m_bounds.X), float(m_bounds.Y), float(m_bounds.Width), float(m_bounds.Height)); } } #endif }
#undef IMPLGETINFO #define IMPLGET(T, Name, Type, TYPE, v, def, ret) \ T CUIGlobals::Get##Name(UI##TYPE ui##v) \ { \ UI##TYPE##INFO *v = Get##Type##Info(ui##v); \ if (!v) \ return def; \ return ret; \ } IMPLGET(HGDIOBJ, Font, Element, ELEMENT, e, NULL, GetFont(e->eFont)) IMPLGET(HGDIOBJ, Font, Font, FONT, f, NULL, f->hFont) IMPLGET(HGDIOBJ, Brush, Element, ELEMENT, e, NULL, GetBrush(e->eBrush)) IMPLGET(HGDIOBJ, Brush, Brush, BRUSH, b, NULL, b->hBrush) IMPLGET(HGDIOBJ, Pen, Element, ELEMENT, e, NULL, GetPen(e->ePen)) IMPLGET(HGDIOBJ, Pen, Brush, BRUSH, b, NULL, b->hPen) IMPLGET(HGDIOBJ, Pen, Pen, PEN, p, NULL, p->hPen) IMPLGET(COLORREF, BrushColor, Element, ELEMENT, e, RGB(255, 127, 127), GetColor(e->eBrush)) IMPLGET(COLORREF, PenColor, Element, ELEMENT, e, RGB(255, 127, 127), GetColor(e->ePen)) IMPLGET(COLORREF, TextColor, Element, ELEMENT, e, RGB(255, 127, 127), GetColor(e->eText)) IMPLGET(COLORREF, BkColor, Element, ELEMENT, e, RGB(255, 127, 127), GetColor(e->eBk)) IMPLGET(COLORREF, Color, Brush, BRUSH, b, RGB(255, 127, 127), GetColor(b->eColor)) IMPLGET(COLORREF, Color, Pen, PEN, p, RGB(255, 127, 127), GetColor(p->eColor)) IMPLGET(COLORREF, Color, Color, COLOR, c, RGB(255, 127, 127), c->rgb) #undef IMPLGET
void FileIconDrawGlass::Frame(HDC hdc, const RECT &rc, eColorList eColor) { FrameRect(hdc, &rc, GetBrush(eColor)); }
void FileIconDrawNormal::Fill(HDC hdc, const RECT &rc, eColorList eColor) { FillRect(hdc, &rc, GetBrush(eColor)); }
void CDrawContext::FillRect( const CRect &rc, COLORREF cr ) { VAPI( ::FillRect( m_hdc, &rc, GetBrush( cr ) ) ); }
void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) { /* Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1) and ending at (x2, y2). The current pen is used for the outline and the current brush for filling the shape. The arc is drawn in an anticlockwise direction from the start point to the end point. Might be better described as Pie drawing */ NewGraphicsIfNeeded(); wxString s; // we need the radius of the circle which has two estimates double r1 = sqrt ( double( (x1-xc)*(x1-xc) ) + double( (y1-yc)*(y1-yc) ) ); double r2 = sqrt ( double( (x2-xc)*(x2-xc) ) + double( (y2-yc)*(y2-yc) ) ); wxASSERT_MSG( (fabs ( r2-r1 ) <= 3), wxS("wxSVGFileDC::DoDrawArc Error in getting radii of circle")); if ( fabs ( r2-r1 ) > 3 ) //pixels { s = wxS("<!--- wxSVGFileDC::DoDrawArc Error in getting radii of circle -->\n"); write(s); } double theta1 = atan2((double)(yc - y1), (double)(x1 - xc)); if (theta1 < 0) theta1 = theta1 + M_PI * 2; double theta2 = atan2((double)(yc - y2), (double)(x2 - xc)); if (theta2 < 0) theta2 = theta2 + M_PI * 2; if (theta2 < theta1) theta2 = theta2 + M_PI * 2; int fArc; // flag for large or small arc 0 means less than 180 degrees if (fabs(theta2 - theta1) > M_PI) fArc = 1; else fArc = 0; int fSweep = 0; // flag for sweep always 0 if (x1 == x2 && y1 == y2) { // drawing full circle fails with default arc. Draw two half arcs instead. s = wxString::Format(wxS(" <path d=\"M%d %d a%s %s 0 %d %d %s %s a%s %s 0 %d %d %s %s"), x1, y1, NumStr(r1), NumStr(r2), fArc, fSweep, NumStr( r1 * 2), NumStr(0), NumStr(r1), NumStr(r2), fArc, fSweep, NumStr(-r1 * 2), NumStr(0)); } else { // comply to wxDC specs by drawing closing line if brush is not transparent wxString line; if (GetBrush().GetStyle() != wxBRUSHSTYLE_TRANSPARENT) line = wxString::Format(wxS("L%d %d z"), xc, yc); s = wxString::Format(wxS(" <path d=\"M%d %d A%s %s 0 %d %d %d %d %s"), x1, y1, NumStr(r1), NumStr(r2), fArc, fSweep, x2, y2, line); } s += wxS("\"/>\n"); write(s); }