void CAnsiWnd::OnPaint() { CPaintDC dc(this); // device context for painting CRect rect; GetClientRect(&rect); CRgn rgn; rgn.CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom); dc.SelectClipRgn(&rgn); int ScrollIndex = GetScrollPos(SB_VERT); POSITION pos = m_strList.FindIndex(ScrollIndex+m_nPageSize); ASSERT(pos); rect.top = rect.bottom-pDoc->m_nYsize; int i = 0; dc.SetBkMode(OPAQUE); CFont* pOldFont = dc.SelectObject(&pDoc->m_fntText); while ( pos && i++ <= m_nPageSize) { CString str = m_strList.GetPrev(pos); if ( dc.RectVisible(&rect) ) DrawWithANSI(&dc, rect, &str, m_nPageSize - i); rect.top -= pDoc->m_nYsize; rect.bottom -= pDoc->m_nYsize; } dc.SelectObject(pOldFont); }
void CSmcView::OnDraw(CDC* pDC) { CSmcDoc* pDoc = GetDocument(); CRect rect; GetClientRect(&rect); CRgn rgn; rgn.CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom); pDC->SelectClipRgn(&rgn); int ScrollIndex = GetScrollPos(SB_VERT); POSITION pos = m_strList.FindIndex(ScrollIndex+m_nPageSize); ASSERT(pos); rect.top = rect.bottom-pDoc->m_nYsize; int i = 0; pDC->SetBkMode(OPAQUE); CFont* pOldFont = pDC->SelectObject(&pDoc->m_fntText); while ( pos && i++ <= m_nPageSize) { CString str = m_strList.GetPrev(pos); if ( pDC->RectVisible(&rect) ) DrawWithANSI(pDC, rect, &str, m_nPageSize - i); rect.top -= pDoc->m_nYsize; rect.bottom -= pDoc->m_nYsize; } pDC->SelectObject(pOldFont); }
void CAnsiWnd::RedrawOneLine(CDC* pDC, int LineNum) // Absolute number of line { int Pos = GetScrollPos(SB_VERT); if ( LineNum > Pos+m_nPageSize ) return; CRect rect; GetClientRect(&rect); int Y = rect.bottom - (Pos+m_nPageSize-LineNum+1)*pDoc->m_nYsize; POSITION pos = m_strList.FindIndex(LineNum); ASSERT(pos); CString str = m_strList.GetAt(pos); rect.top = Y; rect.bottom = rect.top+pDoc->m_nYsize; DrawWithANSI(pDC, rect, &str); }
void CAnsiWnd::OnPaint() { CPaintDC dc(this); // device context for painting CRect rect; GetClientRect(&rect); CRgn rgn; rgn.CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom); dc.SelectClipRgn(&rgn); int ScrollIndex = GetScrollPos(SB_VERT); int last_line = min(ScrollIndex + m_nPageSize, nScrollSize - 1); POSITION pos = m_strList.FindIndex(last_line); ASSERT(pos); dc.SetBkMode(OPAQUE); CFont* pOldFont = dc.SelectObject(&pDoc->m_fntText); int top = rect.top; m_LineCountsList.clear(); for(int n_line = 0, total_lines = 0; pos && total_lines <= m_nPageSize; n_line++) { CString str = m_strList.GetPrev(pos); int length = LengthWithoutANSI((const wchar_t*)str); int lines = pDoc->m_bLineWrap ? NumOfLines(length, m_nLineWidth) : 1; if (lines <= 0) //nothing can be drawn lines++; m_LineCountsList.push_back(lines); total_lines += lines; rect.top = rect.bottom - pDoc->m_nYsize * lines; if ( dc.RectVisible(&rect) ) DrawWithANSI(&dc, rect, &str, m_nPageSize - n_line - 1); rect.bottom = rect.top; if (rect.bottom <= top) break; } dc.SelectObject(pOldFont); }