void BkgroundUI::drawPolyRegion(__in RECT &rc) { CCustomPaintDC paintDC(m_hwnd, RGB(255, 0, 0), 2); HDC hPaintDC = paintDC.getDC(); Ellipse(hPaintDC, rc.left, rc.top, rc.right, rc.bottom); }
void thBarViewCtrl::OnPaint(wxPaintEvent &event) { wxPaintDC paintDC(this); wxMemoryDC memDC; memDC.SelectObject(dbw.m_bmp); paintDC.Blit(0, 0, m_rcClient.width, m_rcClient.height, &memDC, 0, 0); }
void CGdiTool::OnPaint() { CPaintDC paintDC(mpParent); Gdiplus::Graphics graphics(paintDC.GetSafeHdc()); CRect rc = paintDC.m_ps.rcPaint; graphics.Clear(Gdiplus::Color::Gray); }
void BkgroundUI::drawRect(__in RECT &rc) { CCustomPaintDC paintDC(m_hwnd, RGB(255, 0, 0), 2); HDC hPaintDC = paintDC.getDC(); Rectangle(hPaintDC, rc.left + 1, rc.top + 1, rc.right, rc.bottom); }
// // EvPaint member function responds to WM_PAINT messages // void TPlayWindow::EvPaint() { TPaintDC paintDC(HWindow); paintDC.SetBkColor(RGB(196, 196, 196)); // TMidi-Titel paintDC.TextOut(5, 5, MidiTitle); // ZeitSkala if ( MidiLength < 60000 ) paintDC.TextOut(160, 20, "Seconds:", 8); else paintDC.TextOut(160, 20, "Minutes:", 8); paintDC.TextOut(50, 22, "0", 1); char buffer[10]; if ( !MidiLength ) strcpy(buffer, "Unknown"); if ( MidiLength < 60000 ) wsprintf(buffer, "%ld.%02ld", MidiLength/1000, (MidiLength%1000)/10); else wsprintf(buffer, "%ld:%02ld.%02ld", MidiLength/60000, (MidiLength%60000)/1000, (MidiLength%1000)/10); paintDC.TextOut(315, 22, buffer, strlen(buffer)); }
void CMDIChild::OnPaint() { CPaintDC paintDC(this); CRect rcClient = ::GetClientRect(this); CPen pen(PS_SOLID, 1, ::GetSysColor(COLOR_BTNSHADOW)); CPen* pOldPen = paintDC.SelectObject(&pen); if (!m_bNavHidden) { paintDC.MoveTo(0, 0); paintDC.LineTo(m_rcSplitter.left, 0); paintDC.MoveTo(m_rcSplitter.right, 0); paintDC.LineTo(rcClient.right, 0); paintDC.MoveTo(m_rcSplitter.left, 0); paintDC.LineTo(m_rcSplitter.left, rcClient.bottom); paintDC.MoveTo(m_rcSplitter.right - 1, 0); paintDC.LineTo(m_rcSplitter.right - 1, rcClient.bottom); CRect rcSplitterBody = m_rcSplitter; rcSplitterBody.DeflateRect(1, 0, 1, 0); paintDC.FillSolidRect(rcSplitterBody, ::GetSysColor(COLOR_BTNFACE)); } else { paintDC.MoveTo(0, 0); paintDC.LineTo(rcClient.right, 0); } paintDC.SelectObject(pOldPen); }
void CMainFrame::OnPaint() { CPaintDC paintDC(this); CDC memDC; memDC.CreateCompatibleDC(&paintDC); memDC.SelectObject(m_pBitmap); // paintDC.BitBlt(0,0,665,740,&memDC,0,0,SRCCOPY); //640,480&&&&&//932,711 paintDC.BitBlt(0,0,1005,740,&memDC,0,0,SRCCOPY); }
afx_msg void CMainWnd::OnPaint() { CPaintDC paintDC(this); CBitmap pic; pic.LoadBitmapW(IDB_BITMAP2); CDC dcTemp; dcTemp.CreateCompatibleDC(&paintDC); dcTemp.SelectObject(pic); GetDC()->BitBlt(0, 0, 100, 100, &dcTemp, 0, 0, SRCCOPY); }
afx_msg void CMainWin::OnPaint() { CPaintDC paintDC(this); paintDC.TextOut(500, 50, TEXT("Лабораторная работа №2")); paintDC.TextOut(630, 220, " RED"); paintDC.TextOut(630, 290, "GREEN"); paintDC.TextOut(630, 360, " BLUE"); CRect elipse(300, 200, 500, 400); CBrush Paint; Paint.CreateSolidBrush(RGB(red, green, blue)); paintDC.SelectObject(Paint); paintDC.Ellipse(elipse); }
void AboutGameDialog::OnPaint() { if (m_coverBitmap.GetBits() != NULL) { CPaintDC paintDC(this); CDC memDC; memDC.CreateCompatibleDC(&paintDC); CDibSection::SelectDibSection(memDC,&m_coverBitmap); paintDC.BitBlt( m_coverRect.left,m_coverRect.top,m_coverRect.Width(),m_coverRect.Height(), &memDC,0,0,SRCCOPY); } else Default(); }
void WinEDA_DrawPanel::OnPaint(wxPaintEvent & event) /***************************************************/ { wxPaintDC paintDC(this); EDA_Rect tmp; wxRect PaintClipBox; wxPoint org; PrepareGraphicContext(&paintDC); tmp = m_ClipBox; org = m_ClipBox.GetOrigin(); wxRegionIterator upd(GetUpdateRegion()); // get the update rect list while ( upd ) { PaintClipBox = upd.GetRect(); upd++; PaintClipBox.x += org.x; PaintClipBox.y += org.y; #ifdef WX_ZOOM m_ClipBox.m_Pos.x = PaintClipBox.x * GetZoom(); m_ClipBox.m_Pos.y = PaintClipBox.y * GetZoom(); m_ClipBox.m_Size.x = PaintClipBox.m_Size.x * GetZoom(); m_ClipBox.m_Size.y = PaintClipBox.m_Size.y * GetZoom(); PaintClipBox = m_ClipBox; #else m_ClipBox.SetX(PaintClipBox.GetX()); m_ClipBox.SetY(PaintClipBox.GetY()); m_ClipBox.SetWidth(PaintClipBox.GetWidth()); m_ClipBox.SetHeight(PaintClipBox.GetHeight()); #endif wxDCClipper * dcclip = new wxDCClipper(paintDC, PaintClipBox); ReDraw(&paintDC, TRUE); delete dcclip; } m_ClipBox = tmp; }
/** * This is called when the control is repainted. */ /*afx_msg*/ void ChunkWatchControl::OnPaint() { ScopedDogWatch dogWatchScope(s_chunkWatchPaint); // The extents of the control: CRect fullExtents; GetClientRect(fullExtents); // The drawing contexts: CPaintDC paintDC(this); controls::MemDCScope memDCScope(memDC_, paintDC, &fullExtents); memDC_.FillSolidRect(fullExtents, ::GetSysColor(COLOR_BTNFACE)); // Calculate the drawing area: getDrawConstants(); // Draw the details: if ((drawOptions_ & DRAW_PROJECTVIEW) != 0) drawProject (memDC_); if ((drawOptions_ & DRAW_CHUNKS ) != 0) drawChunks (memDC_); if ((drawOptions_ & DRAW_UNLOADABLE ) != 0) drawUnloadable(memDC_); if ((drawOptions_ & DRAW_WORKING ) != 0) drawWorking (memDC_); if ((drawOptions_ & DRAW_GRID ) != 0) drawGrid (memDC_); if ((drawOptions_ & DRAW_USERPOS ) != 0) drawArrow (memDC_); if ((drawOptions_ & DRAW_FRUSTUM ) != 0) drawFrustum (memDC_); // Draw the outsides: memDC_.Draw3dRect ( extents_, // around the tiles itself CLR_BORDER, CLR_BORDER ); memDC_.Draw3dRect ( fullExtents, ::GetSysColor(COLOR_3DHILIGHT), ::GetSysColor(COLOR_3DSHADOW ) ); }
/****************************************************************************** * CreateMyDC */ void CreateMyDC(CDC **dc, CBitmap **newBitmap, CBitmap **origBitmap, int bitCount) { CPaintDC paintDC(activeView); // creat dc *dc = new CDC; (*dc)->CreateCompatibleDC(&paintDC); // Prepare DC (*dc)->SetMapMode(MM_ISOTROPIC); (*dc)->SetWindowOrg(0, 0); (*dc)->SetWindowExt(1, -1); (*dc)->SetViewportOrg(round(-doc->getSettings().getXmin() * scaleFactor), round(doc->getSettings().getYmax() * scaleFactor)); (*dc)->SetViewportExt(1, 1); // create bitmap CreateMyBitmap(*dc, newBitmap, bitCount); // select bitmap into DC *origBitmap = (*dc)->SelectObject(*newBitmap); }
void EffectAutoDuckPanel::OnPaint(wxPaintEvent & WXUNUSED(evt)) { int clientWidth, clientHeight; GetSize(&clientWidth, &clientHeight); if (!mBackgroundBitmap || mBackgroundBitmap->GetWidth() != clientWidth || mBackgroundBitmap->GetHeight() != clientHeight) { if (mBackgroundBitmap) delete mBackgroundBitmap; mBackgroundBitmap = new wxBitmap(clientWidth, clientHeight); } wxMemoryDC dc; dc.SelectObject(*mBackgroundBitmap); dc.SetBrush(*wxWHITE_BRUSH); dc.SetPen(*wxBLACK_PEN); dc.DrawRectangle(0, 0, clientWidth, clientHeight); dc.SetFont(wxFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); dc.SetTextForeground(*wxBLACK); dc.SetTextBackground(*wxWHITE); double duckAmountDb = 0; double innerFadeDownLen = 0; double innerFadeUpLen = 0; double outerFadeDownLen = 0; double outerFadeUpLen = 0; mEffect->mDuckAmountDbBox->GetValue().ToDouble(&duckAmountDb); mEffect->mInnerFadeDownLenBox->GetValue().ToDouble(&innerFadeDownLen); mEffect->mInnerFadeUpLenBox->GetValue().ToDouble(&innerFadeUpLen); mEffect->mOuterFadeDownLenBox->GetValue().ToDouble(&outerFadeDownLen); mEffect->mOuterFadeUpLenBox->GetValue().ToDouble(&outerFadeUpLen); if (innerFadeDownLen < MIN_InnerFadeDownLen || innerFadeDownLen > MAX_InnerFadeDownLen || innerFadeUpLen < MIN_InnerFadeUpLen || innerFadeUpLen > MAX_InnerFadeUpLen || outerFadeDownLen < MIN_OuterFadeDownLen || outerFadeDownLen > MAX_OuterFadeDownLen || outerFadeUpLen < MIN_OuterFadeUpLen || outerFadeUpLen > MAX_OuterFadeUpLen || duckAmountDb < MIN_DuckAmountDb || duckAmountDb > MAX_DuckAmountDb) { // values are out of range, no preview available wxString message = wxString::Format(_("Preview not available")); int textWidth = 0, textHeight = 0; dc.GetTextExtent(message, &textWidth, &textHeight); dc.DrawText(message, (clientWidth - textWidth) / 2, (clientHeight - textHeight) / 2); ResetControlPoints(); } else { // draw preview dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.SetPen(wxPen(theTheme.Colour(clrGraphLines), 3, wxSOLID)); wxPoint points[6]; points[0].x = 10; points[0].y = DUCK_AMOUNT_START; points[1].x = FADE_DOWN_START - (int)(outerFadeDownLen * FADE_SCALE); points[1].y = DUCK_AMOUNT_START; points[2].x = FADE_DOWN_START + (int)(innerFadeDownLen * FADE_SCALE); points[2].y = DUCK_AMOUNT_START - (int)(duckAmountDb * DUCK_AMOUNT_SCALE); points[3].x = FADE_UP_START - (int)(innerFadeUpLen * FADE_SCALE); points[3].y = DUCK_AMOUNT_START - (int)(duckAmountDb * DUCK_AMOUNT_SCALE); points[4].x = FADE_UP_START + (int)(outerFadeUpLen * FADE_SCALE); points[4].y = DUCK_AMOUNT_START; points[5].x = clientWidth - 10; points[5].y = DUCK_AMOUNT_START; dc.DrawLines(6, points); dc.SetPen(wxPen(*wxBLACK, 1, wxDOT)); AColor::Line(dc, FADE_DOWN_START, 10, FADE_DOWN_START, clientHeight - 10); AColor::Line(dc, FADE_UP_START, 10, FADE_UP_START, clientHeight - 10); dc.SetPen(AColor::envelopePen); dc.SetBrush(*wxWHITE_BRUSH); mControlPoints[outerFadeDown] = points[1]; mControlPoints[innerFadeDown] = points[2]; mControlPoints[innerFadeUp] = points[3]; mControlPoints[outerFadeUp] = points[4]; mControlPoints[duckAmount] = wxPoint( (points[2].x + points[3].x) / 2, points[2].y); for (int i = 0; i < AUTO_DUCK_PANEL_NUM_CONTROL_POINTS; i++) { EControlPoint cp = (EControlPoint)i; int digits; float value; if (cp == innerFadeDown) { value = innerFadeDownLen; digits = 2; } else if (cp == innerFadeUp) { value = innerFadeUpLen; digits = 2; } else if (cp == outerFadeDown) { value = outerFadeDownLen; digits = 2; } else if (cp == outerFadeUp) { value = outerFadeUpLen; digits = 2; } else { value = duckAmountDb; digits = 1; } wxString valueStr = Internat::ToDisplayString(value, digits); valueStr += wxT(" "); if (cp == duckAmount) /* i18n-hint: short form of 'decibels'.*/ valueStr += _("dB"); else /* i18n-hint: short form of 'seconds'.*/ valueStr += _("s"); int textWidth = 0, textHeight = 0; GetTextExtent(valueStr, &textWidth, &textHeight); int textPosX = mControlPoints[i].x - textWidth / 2; int textPosY = mControlPoints[i].y; if (cp == duckAmount || cp == outerFadeDown || cp == outerFadeUp) textPosY -= TEXT_DISTANCE + textHeight; else textPosY += TEXT_DISTANCE; dc.DrawText(valueStr, textPosX, textPosY); dc.DrawEllipse(mControlPoints[i].x - 3, mControlPoints[i].y - 3, 6, 6); } } // copy background buffer to paint dc wxPaintDC paintDC(this); paintDC.Blit(0, 0, clientWidth, clientHeight, &dc, 0, 0); // clean up: necessary to free resources on Windows dc.SetPen(wxNullPen); dc.SetBrush(wxNullBrush); dc.SetFont(wxNullFont); dc.SelectObject(wxNullBitmap); }
void CProgressCtrlEx::OnPaint() { CPaintDC paintDC(this); int nMin = 0; int nMax = 0; GetRange(nMin, nMax); ASSERT(nMin <= nMax); int nPos = GetPos(); ASSERT(nPos >= nMin && nPos <= nMax); DWORD dwStyle = GetStyle(); BOOL bVertical = FALSE; if (dwStyle & PBS_VERTICAL) { bVertical = TRUE; } CDC dc; dc.CreateCompatibleDC(&paintDC); ASSERT(dc.GetSafeHdc()); CRect rect; GetClientRect(&rect); CBitmap bmp; bmp.CreateCompatibleBitmap(&paintDC, rect.Width(), rect.Height()); ASSERT(bmp.GetSafeHandle()); CBitmap* pOldBitmap = (CBitmap*)dc.SelectObject(&bmp); CFont* pOldFont = NULL; CWnd* pParent = GetParent(); ASSERT(pParent); CFont* pFont = pParent->GetFont(); ASSERT(pFont); if (bVertical) { if (NULL == m_font.GetSafeHandle()) { LOGFONT lf = { 0 }; pFont->GetLogFont(&lf); lf.lfEscapement = 900; m_font.CreateFontIndirect(&lf); } ASSERT(m_font.GetSafeHandle()); pOldFont = (CFont*)dc.SelectObject(&m_font); } else { pOldFont = (CFont*)dc.SelectObject(pFont); } double dPercent = (double)(nPos - nMin) / ((double)(nMax - nMin)); dc.DrawEdge(rect, EDGE_SUNKEN, BF_RECT | BF_FLAT); CRect rc(rect); rc.DeflateRect(CSize(2, 2)); dc.FillSolidRect(&rc, m_clrBarBkColor); CString strText(_T("")); GetWindowText(strText); if (m_bShowPercent) { strText.AppendFormat(_T("%d%% "), static_cast<int>((dPercent * 100.0) + 0.5)); } dc.SetBkMode(TRANSPARENT); dc.SetTextColor(m_clrTextColor); CPoint pt(0, 0); CSize size = dc.GetOutputTextExtent(strText); if (!bVertical) { switch (m_AlignText) { case ALIGN_LEFT: pt.x = rc.left; break; case ALIGN_RIGHT: pt.x = rc.right - size.cx; break; case ALIGN_CENTER: default: pt.x = rc.left + (rc.Width() - size.cx) / 2; break; } pt.y = rc.top + (rc.Height() - size.cy) / 2; CRect rcPos(rc); rcPos.right = rcPos.left + (int)(dPercent * rcPos.Width()); dc.FillSolidRect(rcPos, m_clrBarColor); dc.SetTextColor(m_clrTextColor); dc.ExtTextOut(pt.x, pt.y, ETO_OPAQUE, rcPos, strText, NULL); dc.SetTextColor(m_clrTextBkColor); dc.ExtTextOut(pt.x, pt.y, ETO_CLIPPED, &rcPos, strText, NULL); } else { switch (m_AlignText) { case ALIGN_LEFT: pt.y = rc.bottom; break; case ALIGN_RIGHT: pt.y = rc.top + size.cx; break; case ALIGN_CENTER: default: pt.y = rc.bottom - (rc.Height() - size.cx) / 2; break; } pt.x = rc.left + (rc.Width() - size.cy) / 2; CRect rcPos(rc); rcPos.top = rcPos.bottom - (int)(dPercent * rcPos.Height()); dc.FillSolidRect(rcPos, m_clrBarColor); dc.SetTextColor(m_clrTextColor); dc.ExtTextOut(pt.x, pt.y, ETO_OPAQUE, rcPos, strText, NULL); dc.SetTextColor(m_clrTextBkColor); dc.ExtTextOut(pt.x, pt.y, ETO_CLIPPED, &rcPos, strText, NULL); } paintDC.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY); dc.SelectObject(pOldFont); dc.SelectObject(pOldBitmap); bmp.DeleteObject(); dc.DeleteDC(); }
void wxFlatButton::OnPaint(wxPaintEvent& event) { wxUnusedVar(event); wxAutoBufferedPaintDC paintDC(this); wxGCDC gdc; GetGCDC(paintDC, gdc); wxRect clientRect = GetClientRect(); // Draw the background gdc.SetPen(GetBarBgColour(m_theme)); gdc.SetBrush(GetBarBgColour(m_theme)); gdc.DrawRectangle(clientRect); switch(m_state) { case kStateHover: { if(!IsChecked()) { // Hover gdc.SetBrush(GetBgHoverColour()); gdc.SetPen(m_penHoverOuterColour); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); clientRect.Deflate(1); gdc.SetBrush(*wxTRANSPARENT_BRUSH); gdc.SetPen(m_penHoverColourInner); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); // gdc.SetPen(m_penHoverColourInner); // gdc.DrawLine(clientRect.GetBottomLeft(), clientRect.GetTopLeft()); // gdc.DrawLine(clientRect.GetTopLeft(), clientRect.GetTopRight()); // // gdc.SetPen(m_penHoverOuterColour); // gdc.DrawLine(clientRect.GetTopRight(), clientRect.GetBottomRight()); // gdc.DrawLine(clientRect.GetBottomRight(), clientRect.GetBottomLeft()); } break; } case kStateNormal: { // do nothing gdc.SetBrush(GetBgColour()); gdc.SetPen(GetPenNormalColour()); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); break; } case kStatePressed: { // Pressed gdc.SetBrush(GetBgPressedColour()); gdc.SetPen(GetPenPressedColour()); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); // gdc.SetBrush(GetBgPressedColour()); // gdc.DrawRectangle(clientRect); // // gdc.SetPen(m_penHoverOuterColour); // gdc.DrawLine(clientRect.GetBottomLeft(), clientRect.GetTopLeft()); // gdc.DrawLine(clientRect.GetTopLeft(), clientRect.GetTopRight()); // // gdc.SetPen(m_penHoverColourInner); // gdc.DrawLine(clientRect.GetTopRight(), clientRect.GetBottomRight()); // gdc.DrawLine(clientRect.GetBottomRight(), clientRect.GetBottomLeft()); break; } } // Draw text gdc.SetFont(GetTextFont()); if(!IsEnabled()) { gdc.SetTextForeground(GetTextColourDisabled()); gdc.DrawLabel( m_text, m_bmpDisabled, clientRect, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL, m_accelIndex); } else { gdc.SetTextForeground(GetTextColour()); gdc.DrawLabel(m_text, m_bmp, clientRect, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL, m_accelIndex); } }
void wxFlatButton::OnPaint(wxPaintEvent& event) { wxUnusedVar(event); wxAutoBufferedPaintDC paintDC(this); PrepareDC(paintDC); wxGCDC gdc; GetGCDC(paintDC, gdc); wxRect clientRect = GetClientRect(); // Draw the background gdc.SetPen(GetBarBgColour(m_theme)); gdc.SetBrush(GetBarBgColour(m_theme)); gdc.DrawRectangle(clientRect); switch(m_state) { case kStateHover: { // do nothing gdc.SetBrush(GetBgColour()); gdc.SetPen(GetPenNormalColour()); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); break; } case kStateNormal: { break; } case kStatePressed: { // Pressed gdc.SetBrush(GetBgPressedColour()); gdc.SetPen(GetPenPressedColour()); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); break; } } // Draw text gdc.SetFont(GetTextFont()); wxColour textColour = IsEnabled() ? GetTextColour() : GetTextColourDisabled(); wxBitmap bmp = IsEnabled() ? m_bmp : m_bmpDisabled; wxCoord textY; wxCoord bmpY; wxCoord totalLen = 0; const int spacer = 2; if(bmp.IsOk()) { // we got a bitmap totalLen += bmp.GetScaledWidth(); } wxSize textSize; if(!m_text.IsEmpty()) { textSize = gdc.GetTextExtent(m_text); totalLen += spacer; totalLen += textSize.x; } wxCoord offset = (clientRect.GetWidth() - totalLen) / 2; bmpY = (clientRect.GetHeight() - bmp.GetScaledHeight()) / 2; textY = (clientRect.GetHeight() - textSize.y) / 2; if(bmp.IsOk()) { gdc.DrawBitmap(bmp, offset, bmpY); offset += bmp.GetScaledWidth(); offset += spacer; } if(!m_text.IsEmpty()) { gdc.DrawText(m_text, offset, textY); offset += textSize.x; offset += spacer; } }
void CMyToolBar::OnPaint() { // Do nothing, but we still must create a paint DC in this handler, // otherwise Windows goes crazy. CPaintDC paintDC(this); }