void CEditDlgPolygon::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) { int which = lpDrawItemStruct->itemID; CDC dc; dc.Attach( lpDrawItemStruct->hDC ); if (which != -1) { COLORREF clrBackground = GetSysColor(lpDrawItemStruct->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW); COLORREF oldBackground = dc.SetBkColor(clrBackground); // Draw the background box CBrush theBrush(clrBackground); CBrush *oldBrush = dc.SelectObject(&theBrush); CPen *oldPen = (CPen *)(dc.SelectStockObject(NULL_PEN)); dc.Rectangle(&(lpDrawItemStruct->rcItem)); CPen thePen(PenStyles[which],1,lpDrawItemStruct->itemState & ODS_SELECTED ? RGB(255,255,255) : RGB(0,0,0)); dc.SelectObject(&thePen); int y = lpDrawItemStruct->rcItem.top + (lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top)/2; int width = (lpDrawItemStruct->rcItem.right - lpDrawItemStruct->rcItem.left)-6; dc.MoveTo(3,y); dc.LineTo(width,y); // Restore the dc to it's old state dc.SelectObject(oldPen); dc.SelectObject(oldBrush); dc.SetBkColor(oldBackground); } // If the item has the focus, draw focus rectangle if (lpDrawItemStruct->itemState & ODS_FOCUS) DrawFocusRect(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem); dc.Detach(); // DON'T: CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct); }
void CFileEditCtrl::DrawButton(int nButtonState) { ASSERT (IsWindow(this)); // if the control is disabled, ensure the button is drawn disabled if (GetStyle() & WS_DISABLED) nButtonState = BTN_DISABLED; // Draw the button in the specified state (Up, Down, or Disabled) CWindowDC DC(this); // get the DC for drawing CBrush theBrush(GetSysColor(COLOR_3DFACE)); // the colour of the button background CBrush *pOldBrush = DC.SelectObject(&theBrush); if (nButtonState == BTN_DOWN) // Draw button as down { // draw the border CPen thePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)); CPen *pOldPen = DC.SelectObject(&thePen); DC.Rectangle(&m_rcButtonArea); DC.SelectObject(pOldPen); thePen.DeleteObject(); // draw the dots DrawDots (&DC, GetSysColor(COLOR_BTNTEXT), 1); } else // draw button as up { CPen thePen(PS_SOLID, 1, GetSysColor(COLOR_3DFACE)); CPen *pOldPen = DC.SelectObject(&thePen); DC.Rectangle(&m_rcButtonArea); DC.SelectObject(pOldPen); thePen.DeleteObject(); // draw the border DC.DrawEdge(&m_rcButtonArea, EDGE_RAISED, BF_RECT); // draw the dots if (nButtonState == BTN_DISABLED) { DrawDots (&DC, GetSysColor(COLOR_3DHILIGHT), 1); DrawDots (&DC, GetSysColor(COLOR_GRAYTEXT)); } else if (nButtonState == BTN_UP) DrawDots (&DC, GetSysColor(COLOR_BTNTEXT)); else ASSERT (FALSE); // Invalid nButtonState } DC.SelectObject(pOldBrush); theBrush.DeleteObject(); // update m_nButtonState m_nButtonState = nButtonState; }
void PrimitivePainter::drawBackground(QPainterPath* R, QPainter* thePainter, qreal PixelPerM) const { if (!DrawBackground && !ForegroundFill) return; thePainter->setPen(Qt::NoPen); if (DrawBackground) { qreal WW = PixelPerM*BackgroundScale+BackgroundOffset; if (WW >= 0) { QPen thePen(BackgroundColor,WW); thePen.setCapStyle(CAPSTYLE); thePen.setJoinStyle(JOINSTYLE); ////thePainter->strokePath(R->getPath(),thePen); thePainter->setPen(thePen); } } if (ForegroundFill && (R->elementCount() > 2)) { thePainter->setBrush(ForegroundFillFillColor); } else thePainter->setBrush(Qt::NoBrush); thePainter->drawPath(*R); }
void BackgroundStyleLayer::draw(Way* R) { const FeaturePainter* paintsel = R->getPainter(r->thePixelPerM); if (paintsel) { paintsel->drawBackground(R, r->thePainter, r); } else if (!TEST_RENDERER_RFLAGS(RendererOptions::UnstyledHidden)) // if (/*!globalZoom(r->theProjection) && */!R->hasPainter()) //FIXME Untagged roads level of zoom? { QPen thePen(QColor(0,0,0),1); r->thePainter->setBrush(Qt::NoBrush); if (R->layer()->classType() == Layer::ImageLayerType && M_PREFS->getUseShapefileForBackground()) { thePen = QPen(QColor(0xc0,0xc0,0xc0),1); if (M_PREFS->getBackgroundOverwriteStyle() || !M_STYLE->getGlobalPainter().getDrawBackground()) r->thePainter->setBrush(M_PREFS->getBgColor()); else r->thePainter->setBrush(QBrush(M_STYLE->getGlobalPainter().getBackgroundColor())); } else { if (r->thePixelPerM < M_PREFS->getRegionalZoom()) thePen = QPen(QColor(0x77,0x77,0x77),1); } r->thePainter->setPen(thePen); R->getLock(); r->thePainter->drawPath(r->theTransform.map(R->getPath())); R->releaseLock(); } }
void PrimitivePainter::drawForeground(QPainterPath* R, QPainter* thePainter, qreal PixelPerM) const { if (!DrawForeground) return; qreal WW = 0.0; WW = PixelPerM*ForegroundScale+ForegroundOffset; if (WW < 0) return; QPen thePen(ForegroundColor,WW); thePen.setCapStyle(CAPSTYLE); thePen.setJoinStyle(JOINSTYLE); if (ForegroundDashSet) { QVector<qreal> Pattern; Pattern << ForegroundDash << ForegroundWhite; thePen.setDashPattern(Pattern); } thePainter->setPen(thePen); thePainter->setBrush(Qt::NoBrush); thePainter->drawPath(*R); }
/******************************************************************************** * Whenever the mouse moves. We need to track the path of each stroke * ********************************************************************************/ void CWhiteBoardView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CStroke* pCurStroke = GetDocument()->m_pCurStroke; // Are we drawing? if (bIsDrawing) { // Prepare a DC CClientDC theDC(this); OnPrepareDC(&theDC); // Convert the point to Logical coords due to possible mangling (from scrolling) theDC.DPtoLP(&point); // Move the graphics position to the previous point theDC.MoveTo(mCurPoint); // Create the stroke's pen for drawing CPen thePen(PS_SOLID,pCurStroke->mStrokeSize,pCurStroke->mStrokeColor); CPen* pOldPen = theDC.SelectObject(&thePen); // Draw a line to the current mouse position theDC.LineTo(point); // Restore the old pen theDC.SelectObject(pOldPen); // Set the new current point mCurPoint = point; // If the current stroke isn't NULL (which it shouldn't be when drawing) // add the new point to the end of it's path if (pCurStroke != NULL) pCurStroke->m_PointList.AddTail( new CPoint(point) ); } // Call the base class implementation CScrollView::OnMouseMove(nFlags, point); }
void CFileEditCtrl::DrawDots(CDC *pDC, COLORREF CR, int nOffset /* = 0 */) { // draw the dots on the button int width = m_rcButtonArea.Width(); // width of the button div_t divt = div (width, 4); int delta = divt.quot; // space between dots int left = m_rcButtonArea.left + width / 2 - delta - (divt.rem ? 0 : 1); // left side of first dot width = width / 10; // width and height of one dot int top = m_rcButtonArea.Height() / 2 - width / 2 + 1; // top of dots left += nOffset; // draw dots shifted? ( for button pressed ) top += nOffset; // draw the dots if (width < 2) { pDC->SetPixel(left, top, CR); left += delta; pDC->SetPixel(left, top, CR); left += delta; pDC->SetPixel(left, top, CR); } else { CPen thePen(PS_SOLID, 1, CR); // set the dot colour CPen *pOldPen = pDC->SelectObject(&thePen); CBrush theBrush(CR); CBrush *pOldBrush = pDC->SelectObject(&theBrush); pDC->Ellipse(left, top, left + width, top + width); left += delta; pDC->Ellipse(left, top, left + width, top + width); left += delta; pDC->Ellipse(left, top, left + width, top + width); pDC->SelectObject(pOldBrush); // reset the DC theBrush.DeleteObject(); pDC->SelectObject(pOldPen); thePen.DeleteObject(); } }
void PrimitivePainter::drawTouchup(QPainterPath* R, QPainter* thePainter, qreal PixelPerM) const { if (DrawTouchup) { qreal WW = PixelPerM*TouchupScale+TouchupOffset; if (WW > 0) { QPen thePen(TouchupColor,WW); thePen.setCapStyle(CAPSTYLE); thePen.setJoinStyle(JOINSTYLE); if (TouchupDashSet) { QVector<qreal> Pattern; Pattern << TouchupDash << TouchupWhite; thePen.setDashPattern(Pattern); } thePainter->strokePath(*R, thePen); } } // if (DrawTrafficDirectionMarks) // { // Feature::TrafficDirectionType TT = trafficDirection(R); // if ( (TT != Feature::UnknownDirection) || (theView->renderOptions().arrowOptions == RendererOptions::ArrowsAlways) ) // { // qreal theWidth = theView->pixelPerM()*R->widthOf()-4; // if (theWidth > 8) // theWidth = 8; // qreal DistFromCenter = 2*(theWidth+4); // if (theWidth > 0) // { // if ( theView->renderOptions().arrowOptions == RendererOptions::ArrowsAlways ) // thePainter->setPen(QPen(QColor(255,0,0), 2)); // else // thePainter->setPen(QPen(QColor(0,0,255), 2)); // for (int i=1; i<R->size(); ++i) // { // QPointF FromF(theView->transform().map(theView->projection().project(R->getNode(i-1)))); // QPointF ToF(theView->transform().map(theView->projection().project(R->getNode(i)))); // if (distance(FromF,ToF) > (DistFromCenter*2+4)) // { // QPoint H(FromF.toPoint()+ToF.toPoint()); // H *= 0.5; // if (!theView->rect().contains(H)) // continue; // qreal A = angle(FromF-ToF); // QPoint T(qRound(DistFromCenter*cos(A)),qRound(DistFromCenter*sin(A))); // QPoint V1(qRound(theWidth*cos(A+M_PI/6)),qRound(theWidth*sin(A+M_PI/6))); // QPoint V2(qRound(theWidth*cos(A-M_PI/6)),qRound(theWidth*sin(A-M_PI/6))); // if ( (TT == Feature::OtherWay) || (TT == Feature::BothWays) ) // { // thePainter->drawLine(H+T,H+T-V1); // thePainter->drawLine(H+T,H+T-V2); // } // if ( (TT == Feature::OneWay) || (TT == Feature::BothWays) ) // { // thePainter->drawLine(H-T,H-T+V1); // thePainter->drawLine(H-T,H-T+V2); // } // else // { // if ( theView->renderOptions().arrowOptions == RendererOptions::ArrowsAlways ) // { // thePainter->drawLine(H-T,H-T+V1); // thePainter->drawLine(H-T,H-T+V2); // } // } // } // } // } // } // } }