| | |
| | | #include "stdafx.h" |
| | | #include "JobSlotGrid.h" |
| | | #include "ServoMemDC.h" |
| | | |
| | | #ifdef _DEBUG |
| | | #define new DEBUG_NEW |
| | |
| | | |
| | | void CJobSlotGrid::OnPaint() { |
| | | CPaintDC dc(this); |
| | | DrawGrid(&dc); |
| | | CServoMemDC memDC(&dc); |
| | | DrawGrid(&memDC); |
| | | } |
| | | |
| | | void CJobSlotGrid::DrawGrid(CDC* pDC) |
| | | { |
| | | CRect rect; |
| | | GetClientRect(&rect); |
| | | pDC->FillSolidRect(&rect, ::GetSysColor(COLOR_3DFACE)); // 安全背景色,仅内存绘制 |
| | | |
| | | if (m_nCols == 0 || m_nRows == 0) { |
| | | return; |
| | |
| | | // 选择填充颜色 |
| | | COLORREF fillColor = m_vSlotStatus[i][j] ? m_colorHasJob : m_colorNoJob; |
| | | if (IsSlotClickable(i, j)) { |
| | | if (bIsClicking) |
| | | if (bIsClicking) { |
| | | fillColor = COLOR_CLICK; |
| | | else if (bIsHover) |
| | | } |
| | | else if (bIsHover) { |
| | | fillColor = COLOR_HOVER; |
| | | } |
| | | } |
| | | |
| | | // 绘制背景(高效替代 CBrush) |
| | |
| | | // 绘制边框 |
| | | pDC->DrawEdge(&cellRect, EDGE_SUNKEN, BF_RECT); |
| | | |
| | | // 如果是可点击格子,在左上角画一个小圆点 |
| | | if (IsSlotClickable(i, j)) { |
| | | constexpr int DOT_RADIUS = 3; |
| | | int cx = cellRect.left + 5; |
| | | int cy = cellRect.top + 5; |
| | | |
| | | // 保存旧笔和刷子 |
| | | CBrush brushDot(RGB(0, 120, 215)); |
| | | CBrush* pOldBrush = pDC->SelectObject(&brushDot); |
| | | CPen penDot(PS_SOLID, 1, RGB(0, 120, 215)); |
| | | CPen* pOldPen = pDC->SelectObject(&penDot); |
| | | |
| | | // 绘制圆点 |
| | | pDC->Ellipse(cx - DOT_RADIUS, cy - DOT_RADIUS, cx + DOT_RADIUS, cy + DOT_RADIUS); |
| | | |
| | | // 恢复 |
| | | pDC->SelectObject(pOldBrush); |
| | | pDC->SelectObject(pOldPen); |
| | | } |
| | | |
| | | // 获取文字(安全) |
| | | CString strText; |
| | | if (i < m_vSlotText.size() && j < m_vSlotText[i].size()) { |