void wxVListBox::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxSize clientSize = GetClientSize(); wxAutoBufferedPaintDC dc(this); // the update rectangle wxRect rectUpdate = GetUpdateClientRect(); // fill it with background colour dc.SetBackground(GetBackgroundColour()); dc.Clear(); // the bounding rectangle of the current line wxRect rectLine; rectLine.width = clientSize.x; // iterate over all visible lines const size_t lineMax = GetVisibleEnd(); for ( size_t line = GetFirstVisibleLine(); line < lineMax; line++ ) { const wxCoord hLine = OnGetLineHeight(line); rectLine.height = hLine; // and draw the ones which intersect the update rect if ( rectLine.Intersects(rectUpdate) ) { // don't allow drawing outside of the lines rectangle wxDCClipper clip(dc, rectLine); wxRect rect = rectLine; OnDrawBackground(dc, rect, line); OnDrawSeparator(dc, rect, line); rect.Deflate(m_ptMargins.x, m_ptMargins.y); OnDrawItem(dc, rect, line); } else // no intersection { if ( rectLine.GetTop() > rectUpdate.GetBottom() ) { // we are already below the update rect, no need to continue // further break; } //else: the next line may intersect the update rect } rectLine.y += hLine; } }
void CBCGPToolTipCtrl::OnPaint() { if (m_Params.m_bBallonTooltip) { CToolTipCtrl::OnPaint (); return; } CPaintDC dcPaint(this); // device context for painting CBCGPMemDC memDC (dcPaint, this); CDC* pDC = &memDC.GetDC (); CRect rect; GetClientRect (rect); CRect rectMargin; GetMargin (rectMargin); CRect rectText = rect; rectText.DeflateRect (rectMargin); rectText.DeflateRect (m_ptMargin.x, m_ptMargin.y); COLORREF clrLine = m_Params.m_clrBorder == (COLORREF)-1 ? ::GetSysColor (COLOR_INFOTEXT) : m_Params.m_clrBorder; COLORREF clrText = m_Params.m_clrText == (COLORREF)-1 ? ::GetSysColor (COLOR_INFOTEXT) : m_Params.m_clrText; //----------------- // Fill background: //----------------- OnFillBackground (pDC, rect, clrText, clrLine); CPen penLine (PS_SOLID, 1, clrLine); CPen* pOldPen = pDC->SelectObject (&penLine); //------------- // Draw border: //------------- OnDrawBorder (pDC, rect, clrLine); //----------- // Draw icon: //----------- if (m_sizeImage != CSize (0, 0) && m_Params.m_bDrawIcon) { CRect rectImage = rectText; rectImage.right = rectImage.left + m_sizeImage.cx; rectImage.bottom = rectImage.top + m_sizeImage.cy; OnDrawIcon (pDC, rectImage); rectText.left += m_sizeImage.cx + m_ptMargin.x; } pDC->SetBkMode (TRANSPARENT); pDC->SetTextColor (clrText); //------------ // Draw label: //------------ int nTextHeight = OnDrawLabel (pDC, rectText, FALSE).cy; //------------------------------ // Draw separator + description: //------------------------------ if (!m_strDescription.IsEmpty () && m_Params.m_bDrawDescription) { CRect rectDescr = rectText; rectDescr.top += nTextHeight + 3 * m_ptMargin.y / 2; if (m_Params.m_bDrawSeparator) { OnDrawSeparator (pDC, rectDescr.left, rectDescr.right, rectDescr.top - m_ptMargin.y / 2); } OnDrawDescription (pDC, rectDescr, FALSE); } pDC->SelectObject (pOldPen); }