void MenuEditorItem::Paint(CDC& dc, CRect& rect) { switch( m_type) { case 0 : // menu PaintMenu(dc,rect); break; case 1: // popup PaintPopup(dc,rect); break; case 2 : // separator PaintSeparator(dc,rect); break; } }
void CToolBarClass::PaintPane(const PaintDC& dc, const RECT& rcTB, PaneInfo* p, int x, int y) { if (!p || (p->nCount < 1) || (p->nTotalWidth < 1) || !p->pTool) { _ASSERTE(!(!p || (p->nCount < 1) || (p->nTotalWidth < 1) || !p->pTool)); return; } HBITMAP hOld = NULL; if (p->hBmp) { mh_PaneDC = CreateCompatibleDC(dc.hDC); hOld = (HBITMAP)SelectObject(mh_PaneDC, p->hBmp); } p->rcPane.left = x; p->rcPane.top = y; p->rcPane.bottom = y + mn_ToolHeight; x += mn_PaddingWidth; for (int t = 0; t < p->nCount; t++) { if (p->pTool[t].nFlags & TIS_SEPARATOR) { PaintSeparator(dc, rcTB, x, y, mn_ToolHeight); x += mn_SeparatorWidth + mn_PaddingWidth; } else { PaintTool(dc, rcTB, p, p->pTool+t, x, y); x += (p->pTool[t].rcBmp.right - p->pTool[t].rcBmp.left + 1) + mn_PaddingWidth + ((p->pTool[t].nFlags & TIS_DROPDOWN) ? mn_DropArrowWidth : 0); } } p->rcPane.right = x; if (hOld) SelectObject(mh_PaneDC, hOld); DeleteDC(mh_PaneDC); mh_PaneDC = NULL; }
void CToolBarClass::Paint(const PaintDC& dc, const RECT& rcTB) { if (!dc.hDC) return; _ASSERTE(gpConEmu->isMainThread()); int nWidth = 0; int nMaxWidth = rcTB.right - rcTB.left + 1; if (nMaxWidth < 2) return; TODO("Toolbars otherwhere of tabs?"); mb_Aero = (gpConEmu->DrawType() >= fdt_Aero); EnterCriticalSection(&m_CS); BOOL lbShown = FALSE; //mh_LitePen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT)); //mh_DarkPen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)); mh_LitePen = CreatePen(PS_SOLID, 1, RGB(122,177,232)); mh_HoverBrush = CreateSolidBrush(RGB(213,231,248)); mh_CheckedBrush = CreateSolidBrush(RGB(184,216,249)); HPEN hOldPen = (HPEN)SelectObject(dc.hDC, mh_LitePen); HPEN hOldBrush = (HPEN)SelectObject(dc.hDC, mh_HoverBrush); #ifdef DEBUG_SHOW_RECT FillRect(dc.hDC, &rcTB, (HBRUSH)GetStockObject(WHITE_BRUSH)); //MoveToEx(hdc, rcTB.left-1, rcTB.top-1, NULL); //LineTo(hdc, rcTB.right+1, rcTB.top-1); //LineTo(hdc, rcTB.right+1, rcTB.bottom+1); //LineTo(hdc, rcTB.left-1, rcTB.bottom+1); //LineTo(hdc, rcTB.left-1, rcTB.top-1); #endif for (INT_PTR i = 0; i < m_Panels.size(); i++) { if ((nWidth + mn_SeparatorWidth) > nMaxWidth) break; // больше некуда PaneInfo* pane = m_Panels[i]; if (!pane->nCount || !pane->nTotalWidth || !pane->pTool || !(pane->nStyles & TIS_VISIBLE)) { pane->bVisible = FALSE; continue; } BOOL lbFit = ((nWidth + (lbShown ? mn_SeparatorWidth : 0) + pane->nTotalWidth) <= nMaxWidth); if (lbFit) { if (lbShown) { PaintSeparator(dc, rcTB, rcTB.left+nWidth, rcTB.top, mn_ToolHeight); nWidth += mn_SeparatorWidth; } else { lbShown = TRUE; } pane->bVisible = TRUE; PaintPane(dc, rcTB, pane, rcTB.left+nWidth, rcTB.top); nWidth += pane->nTotalWidth; } else { pane->bVisible = FALSE; } //nWidth += mn_PaddingWidth; // ??? } SelectObject(dc.hDC, hOldPen); SelectObject(dc.hDC, hOldBrush); //SelectObject(hdc, hOldPen); //DeleteObject(mh_DarkPen); //mh_DarkPen = NULL; DeleteObject(mh_LitePen); mh_LitePen = NULL; DeleteObject(mh_HoverBrush); mh_HoverBrush = NULL; DeleteObject(mh_CheckedBrush); mh_CheckedBrush = NULL; LeaveCriticalSection(&m_CS); }