void CMenuElementUI::DoPaint(HDC hDC, const RECT& rcPaint) { if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return; if(m_bDrawLine) { RECT rcLine = { m_rcItem.left + m_rcLinePadding.left, m_rcItem.top + m_cxyFixed.cy/2, m_rcItem.right - m_rcLinePadding.right, m_rcItem.top + m_cxyFixed.cy/2 }; CRenderEngine::DrawLine(hDC, rcLine, 1, m_dwLineColor); } else { CMenuElementUI::DrawItemBk(hDC, m_rcItem); DrawItemText(hDC, m_rcItem); DrawItemIcon(hDC, m_rcItem); DrawItemExpland(hDC, m_rcItem); for (int i = 0; i < GetCount(); ++i) { if (GetItemAt(i)->GetInterface(_T("MenuElement")) == NULL) GetItemAt(i)->DoPaint(hDC, rcPaint); } } }
void TTreeView::DoDrawView(XRect) { XRect r,s,t; long len; long x,y; long h; long i; short lh,lt; short it; TableDrawRecord tr,te; long b; short at; XGDraw draw(this); draw.SetFont(XGFont::LoadFont(1)); fDrawFlag = true; fUpdateFlag = false; // Clear the update flag as I'm updated /* * Get the drawing parameters so I know where to draw */ r = GetContentRect(); GetScrollParams(&x,&y,&h); x *= h; len = (r.bottom - r.top + h - 1) / h; len += y; if (len > fLength) len = fLength; lh = draw.GetFontHeight(); // lh == line height lt = (h-1-lh)/2; // lt == line top (of label) it = (h-17)/2; // it == icon top (for 16x16 icon) at = (h-13)/2; // at == arrow top /* * Iterate through drawing the whole mess */ draw.EraseRect(r); draw.SetForeColor(KXGColorBtnFace); // a light gray value for (i = y; i < len; i++) { fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr); if (1 || tr.inset > 0) { for (b = i-1; b >= y; b--) { fDrawList.GetMemory(b*sizeof(te),sizeof(te),&te); if (te.inset <= tr.inset) break; } t.left = 22 * (tr.inset) - x; t.right = t.left + 22; t.bottom = (i - y) * h; t.top = (b - y + 1) * h; if (b >= y) { if (te.inset == tr.inset) { if (te.entry->child == NULL) { t.top -= h; } else { t.top -= h - at - 12; } } } if (tr.inset > 0) { draw.MoveTo(t.left+8,t.top); if (tr.entry->child || tr.entry->fChildDefer) { /* * Has children; draw to icon */ draw.LineTo(t.left+8,t.bottom+at); draw.MoveTo(t.left+14,t.bottom+h/2); } else { /* * No children, draw to middle */ draw.LineTo(t.left+8,t.bottom+h/2); } draw.LineTo(t.left+22,t.bottom+h/2); } else { if (tr.entry->child || tr.entry->fChildDefer) { draw.MoveTo(t.left+14,t.bottom+h/2); draw.LineTo(t.left+22,t.bottom+h/2); } } if (tr.entry->child || tr.entry->fChildDefer) { s = t; s.top = t.bottom + at; s.bottom = t.top + 12; s.left = t.left + 2; s.right = s.left + 12; DrawDropIcon(draw,s,tr.entry->fOpen); } } } /* * Draw the text of these things. */ draw.SetForeColor(KXGColorBlack); // text (black) for (i = y; i < len; i++) { fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr); if (tr.entry->icon) { /* * Draw icon label */ s.left = 22 * (tr.inset+1) - x; s.right = s.left + 16; s.top = (i - y) * h + it; s.bottom = s.top + 16; DrawItemIcon(draw,s,tr.entry->icon); /* * Draw label */ r.top = (i - y) * h + lt; r.bottom = r.top + lh; r.left = 22 * (tr.inset+1) - x + 16; DrawItem(draw,r,IsSelected((uint32)tr.entry),(uint32)tr.entry); } else { /* * Draw label */ r.top = (i - y) * h + lt; r.bottom = r.top + lh; r.left = 22 * (tr.inset+1) - x; DrawItem(draw,r,IsSelected((uint32)tr.entry),(uint32)tr.entry); } } r = GetContentRect(); r.top = (i - y) * h; if (r.top < r.bottom) draw.EraseRect(r); // erase bottom of view }