#include "stdafx.h" #pragma once #include #include #ifndef _AFX #include #include #endif class CCarrierSlotSelector : public CListCtrl { public: enum MaterialType { MAT_G1 = 1, MAT_G2 = 2 }; struct SlotCell { bool hasGlass = false; // ÊÇ·ñÓÐÆ¬ CString coreId; // ¹Ì¶¨ºËÐÄID£¨²»º¬Ç°×º£© int material = MAT_G1; // ½öÓ°Ïìչʾ£¨G1/G2£© bool checked = false; // ÊÇ·ñ¹´Ñ¡¼Ó¹¤ }; struct PortColumn { CString portName; // "Port 1" ... CString carrierName; // "Carrier A" ... bool allocated = false; // ÕûÁÐËø¶¨ CString allocatedBy; // Õ¼ÓÃÕß std::vector slots; // size = m_nSlots }; public: CCarrierSlotSelector(); virtual ~CCarrierSlotSelector(); // ³õʼ»¯ / ³ß´ç void InitGrid(int nPorts, int nSlots); void SetColumnWidths(int slotColWidth, int portColWidth); void SetRowHeight(int cy); // small image list ¿ØÖÆÐÐ¸ß // Íâ¹Û void SetShowMaterialToggle(BOOL bShow); BOOL GetShowMaterialToggle() const { return m_bShowMatToggle; } // Port ½Ó¿Ú int GetPortCount() const { return (int)m_ports.size(); } int GetSlotCount() const { return m_nSlots; } void SetPortInfo(int portIndex, LPCTSTR portName, LPCTSTR carrierName); void SetPortAllocated(int portIndex, BOOL allocated, LPCTSTR byName = nullptr); BOOL IsPortAllocated(int portIndex) const; // Slot ½Ó¿Ú void SetSlotGlass(int portIndex, int slotIndex, BOOL hasGlass, LPCTSTR coreId /*¿É¿Õ*/, int material /*1=G1,2=G2*/); void SetSlotChecked(int portIndex, int slotIndex, BOOL checked); BOOL GetSlotChecked(int portIndex, int slotIndex) const; int GetSlotMaterialType(int portIndex, int slotIndex) const; // 1/2 void SetSlotMaterialType(int portIndex, int slotIndex, int material, BOOL bNotify = TRUE); CString GetDisplayId(int portIndex, int slotIndex) const; // "Gx-core" »ò "¡ª" void RebuildTexts(); // ÁÐÍ·¼ÆÊý¡¢µ¥Ôª¸ñÁÙʱÎı¾ // ¹¤¾ß£ºÕûÁÐȫѡ/È«²»Ñ¡£¨Ö»Ó°Ïì hasGlass==true µÄ¸ñ×Ó£© void CheckAllInPort(int portIndex, BOOL checked, BOOL bNotify = TRUE); protected: // ÄÚ²¿Êý¾Ý BOOL m_bFirstShown = FALSE; // ×ÓÒ³ÃæÊ×´ÎÏÔʾºóÇ¿ÖÆÒ»´ÎÈ«Á¿ÖØ»æ int m_nSlots = 0; std::vector m_ports; BOOL m_bShowMatToggle = TRUE; // UI metrics int m_rowHeight = 24; int m_slotColWidth = 100; int m_portColWidth = 180; // ÐиßͼÏñÁбí CImageList m_ilRowHeight; // ÑÕÉ« COLORREF m_colBgAlt = RGB(240, 242, 245); // ½»ÌæÁÐdz»Ò COLORREF m_colBgNorm = RGB(255, 255, 255); COLORREF m_colLockBg = RGB(255, 244, 214); // Ëø¶¨Áе­»Æ // ×ÖÌå CFont m_fntText; CFont m_fntBold; CFont m_fntSmall; // ÇøÓò¼ÆËã CRect GetCheckboxRect(const CRect& cell) const; CRect GetMaterialTagRect(const CRect& cell) const; CRect GetStatusDotRect(const CRect& cell) const; // ¹¤¾ß void EnsureFonts(); void UpdateRowCount(); void DrawFlatCheckbox(CDC* pDC, const CRect& r, bool checked, bool disabled); // ±âƽ¸´Ñ¡¿ò // ֪ͨ¸¸´°¿Ú£¨WM_COMMAND ·ç¸ñ£© void NotifySelectionChanged(int port, int slot, BOOL checked); void NotifyMaterialChanged(int port, int slot, int material); protected: // MFC virtual void PreSubclassWindow() override; afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); // ¡ï ÐÂÔö£º×Ô´øË«»º³å»æÖÆ afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult); afx_msg BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); // ²¶»ñ Header ֪ͨ void OnHeaderClick(int iItem); DECLARE_MESSAGE_MAP() };