From 9198ac12e4e2ff64a2cf65c32d576f02d54c346a Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期六, 10 一月 2026 16:50:32 +0800
Subject: [PATCH] 1.S1F3_CurrentRecipe,S6F11_RecipeChange实现。

---
 SourceCode/Bond/Servo/JobSlotGrid.cpp |  169 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 159 insertions(+), 10 deletions(-)

diff --git a/SourceCode/Bond/Servo/JobSlotGrid.cpp b/SourceCode/Bond/Servo/JobSlotGrid.cpp
index cf7df72..32243a9 100644
--- a/SourceCode/Bond/Servo/JobSlotGrid.cpp
+++ b/SourceCode/Bond/Servo/JobSlotGrid.cpp
@@ -1,5 +1,6 @@
 锘�#include "stdafx.h"
 #include "JobSlotGrid.h"
+#include "ServoMemDC.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -10,6 +11,10 @@
 BEGIN_MESSAGE_MAP(CJobSlotGrid, CWnd)
     ON_WM_PAINT()
     ON_WM_ERASEBKGND()
+    ON_WM_MOUSEMOVE()
+    ON_WM_MOUSELEAVE()
+    ON_WM_LBUTTONDOWN()
+    ON_WM_LBUTTONUP()
 END_MESSAGE_MAP()
 
 CJobSlotGrid::CJobSlotGrid() {
@@ -48,6 +53,7 @@
     m_nRows = nRows;
     m_nCols = nCols;
     m_vSlotStatus.assign(nRows, std::vector<bool>(nCols, false));
+    m_vSlotClickable.assign(nRows, std::vector<bool>(nCols, false));
 
     // 鍒濆鍖栨枃鏈暟缁�
     m_vSlotText.assign(nRows, std::vector<CString>(nCols));
@@ -130,41 +136,184 @@
     Invalidate();
 }
 
+void CJobSlotGrid::SetSlotClickable(int nRow, int nCol, bool bClickable)
+{
+    if (nRow >= 0 && nRow < m_nRows && nCol >= 0 && nCol < m_nCols) {
+        m_vSlotClickable[nRow][nCol] = bClickable;
+    }
+}
+
+bool CJobSlotGrid::IsSlotClickable(int nRow, int nCol) const
+{
+    if (nRow >= 0 && nRow < m_nRows && nCol >= 0 && nCol < m_nCols) {
+        return m_vSlotClickable[nRow][nCol];
+    }
+    return false;
+}
+
+void CJobSlotGrid::SetSlotClickCallback(SlotClickCallback fnCallback)
+{
+    m_fnSlotClickCallback = fnCallback;
+}
+
 BOOL CJobSlotGrid::OnEraseBkgnd(CDC* pDC) {
     return TRUE;
 }
 
+void CJobSlotGrid::OnMouseMove(UINT nFlags, CPoint point)
+{
+    TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_hWnd };
+    ::TrackMouseEvent(&tme);
+
+    CRect rect;
+    GetClientRect(&rect);
+    int nCellWidth = rect.Width() / m_nCols;
+    int nCellHeight = rect.Height() / m_nRows;
+
+    int nCol = point.x / nCellWidth;
+    int nRow = point.y / nCellHeight;
+
+    if (nRow != m_ptHover.y || nCol != m_ptHover.x) {
+        m_ptHover = CPoint(nCol, nRow);
+        Invalidate();
+    }
+
+    CWnd::OnMouseMove(nFlags, point);
+}
+
+void CJobSlotGrid::OnMouseLeave()
+{
+    m_ptHover = CPoint(-1, -1);
+    Invalidate();
+
+    CWnd::OnMouseLeave();
+}
+
+void CJobSlotGrid::OnLButtonDown(UINT nFlags, CPoint point)
+{
+    m_bLButtonDown = true;
+    Invalidate();
+
+    CWnd::OnLButtonDown(nFlags, point);
+}
+
+void CJobSlotGrid::OnLButtonUp(UINT nFlags, CPoint point)
+{
+    m_bLButtonDown = false;
+    Invalidate();
+
+    // 淇濇寔鍘熸湁閫昏緫涓嶅彉
+    CRect rect;
+    GetClientRect(&rect);
+    int nCellWidth = rect.Width() / m_nCols;
+    int nCellHeight = rect.Height() / m_nRows;
+
+    int nCol = point.x / nCellWidth;
+    int nRow = point.y / nCellHeight;
+
+    if (IsSlotClickable(nRow, nCol)) {
+        if (m_fnSlotClickCallback) {
+            m_fnSlotClickCallback(nRow, nCol);
+        }
+    }
+
+    CWnd::OnLButtonUp(nFlags, point);
+}
+
 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;
+    }
+
+    // 璁$畻鏍煎瓙灏哄
     int nCellWidth = rect.Width() / m_nCols;
     int nCellHeight = rect.Height() / m_nRows;
+
+    // 瀛椾綋璁剧疆
     CFont* pOldFont = pDC->SelectObject(&m_fontText);
+    pDC->SetBkMode(TRANSPARENT);
+    pDC->SetTextColor(RGB(0, 0, 0));
+
+    // 瀹氫箟棰滆壊甯搁噺
+    constexpr COLORREF COLOR_HOVER = RGB(200, 230, 255);
+    constexpr COLORREF COLOR_CLICK = RGB(0, 120, 215);
 
     for (int i = 0; i < m_nRows; ++i) {
         for (int j = 0; j < m_nCols; ++j) {
             CRect cellRect(j * nCellWidth, i * nCellHeight, (j + 1) * nCellWidth, (i + 1) * nCellHeight);
 
-            // 鑳屾櫙
-            CBrush* pBrush = m_vSlotStatus[i][j] ? &m_brushHasJob : &m_brushNoJob;
-            pDC->FillRect(&cellRect, pBrush);
+            // 鍒ゆ柇鐘舵�侊細鎮仠 / 鎸変笅
+            bool bIsHover = (m_ptHover.x == j && m_ptHover.y == i);
+            bool bIsClicking = bIsHover && m_bLButtonDown;
 
-            // 杈规
+            // 閫夋嫨濉厖棰滆壊
+            COLORREF fillColor = m_vSlotStatus[i][j] ? m_colorHasJob : m_colorNoJob;
+            if (IsSlotClickable(i, j)) {
+                if (bIsClicking) {
+                    fillColor = COLOR_CLICK;
+                }
+                else if (bIsHover) {
+                    fillColor = COLOR_HOVER;
+                }
+            }
+
+            // 缁樺埗鑳屾櫙锛堥珮鏁堟浛浠� CBrush锛�
+            pDC->FillSolidRect(&cellRect, fillColor);
+
+            // 缁樺埗杈规
             pDC->DrawEdge(&cellRect, EDGE_SUNKEN, BF_RECT);
 
-            // 鏂囧瓧锛堝眳涓級
-            pDC->SetBkMode(TRANSPARENT);
-            pDC->SetTextColor(RGB(0, 0, 0));
-            pDC->DrawText(m_vSlotText[i][j], &cellRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
+            // 濡傛灉鏄彲鐐瑰嚮鏍煎瓙锛屽湪宸︿笂瑙掔敾涓�涓皬鍦嗙偣
+            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()) {
+                strText = m_vSlotText[i][j];
+            }
+
+            if (!strText.IsEmpty()) {
+                // 鍏堣绠楁枃瀛楅珮搴︼紙鏀寔鎹㈣锛�
+                CRect calcRect = cellRect;
+                pDC->DrawText(strText, &calcRect, DT_CENTER | DT_WORDBREAK | DT_NOPREFIX | DT_CALCRECT);
+
+                // 閲嶆柊璁惧畾灞呬腑缁樺埗鍖哄煙
+                CRect textRect = cellRect;
+                textRect.top += (cellRect.Height() - calcRect.Height()) / 2;
+
+                // 瀹為檯缁樺埗鏂囧瓧
+                pDC->DrawText(strText, &textRect, DT_CENTER | DT_WORDBREAK | DT_NOPREFIX);
+            }
         }
     }
 
     pDC->SelectObject(pOldFont);
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3