| ¶Ô±ÈÐÂÎļþ |
| | |
| | | // PortConfigurationDlg.cpp: å®ç°æä»¶ |
| | | // |
| | | |
| | | #include "stdafx.h" |
| | | #include "Servo.h" |
| | | #include "afxdialogex.h" |
| | | #include "PortConfigurationDlg.h" |
| | | #include "NewCellTypes/GridCellCheck.h" |
| | | #include "NewCellTypes/GridCellCombo.h" |
| | | #include "NewCellTypes/GridCellNumeric.h" |
| | | |
| | | |
| | | // CPortConfigurationDlg å¯¹è¯æ¡ |
| | | |
| | | IMPLEMENT_DYNAMIC(CPortConfigurationDlg, CDialogEx) |
| | | |
| | | CPortConfigurationDlg::CPortConfigurationDlg(CWnd* pParent /*=nullptr*/) |
| | | : CDialogEx(IDD_DIALOG_PORT_CONFIGURATION, pParent) |
| | | { |
| | | |
| | | } |
| | | |
| | | CPortConfigurationDlg::~CPortConfigurationDlg() |
| | | { |
| | | } |
| | | |
| | | void CPortConfigurationDlg::InitGrid() |
| | | { |
| | | if (m_wndGrid.GetSafeHwnd() == NULL) { |
| | | return; |
| | | } |
| | | |
| | | const int nCols = 3; |
| | | const int nFixRows = 1; |
| | | const int nRows = 9; |
| | | |
| | | int nColIdx = 0; |
| | | m_wndGrid.DeleteAllItems(); |
| | | m_wndGrid.SetVirtualMode(FALSE); |
| | | |
| | | // è®¾ç½®æ ·å¼é¢è² |
| | | m_wndGrid.GetDefaultCell(TRUE, FALSE)->SetBackClr(g_nGridFixCellColor); |
| | | m_wndGrid.GetDefaultCell(FALSE, TRUE)->SetBackClr(g_nGridFixCellColor); |
| | | m_wndGrid.GetDefaultCell(FALSE, FALSE)->SetBackClr(g_nGridCellColor); |
| | | m_wndGrid.SetFixedTextColor(g_nGridFixFontColor); |
| | | |
| | | // è¡åæ°é |
| | | m_wndGrid.SetRowCount(nRows); |
| | | m_wndGrid.SetColumnCount(nCols); |
| | | m_wndGrid.SetFixedRowCount(nFixRows); |
| | | m_wndGrid.SetFixedColumnCount(0); |
| | | |
| | | // 设置å宽 |
| | | m_wndGrid.SetColumnWidth(nColIdx, 50); |
| | | m_wndGrid.SetItemText(0, nColIdx++, _T("Slot ID")); |
| | | m_wndGrid.SetColumnWidth(nColIdx, 150); |
| | | m_wndGrid.SetItemText(0, nColIdx++, _T("EQ Recipe")); |
| | | m_wndGrid.SetColumnWidth(nColIdx, 150); |
| | | m_wndGrid.SetItemText(0, nColIdx++, _T("Panel ID")); |
| | | m_wndGrid.SetColumnWidth(nColIdx, 60); |
| | | m_wndGrid.SetItemText(0, nColIdx++, _T("å¯ç¨")); |
| | | |
| | | // 设置è¡ä¸ºæ ·å¼ |
| | | m_wndGrid.SetFixedRowSelection(FALSE); |
| | | m_wndGrid.SetFixedColumnSelection(FALSE); |
| | | m_wndGrid.SetEditable(TRUE); |
| | | m_wndGrid.SetRowResize(FALSE); |
| | | m_wndGrid.SetColumnResize(TRUE); |
| | | m_wndGrid.SetListMode(TRUE); |
| | | m_wndGrid.EnableSelection(TRUE); |
| | | m_wndGrid.SetSingleRowSelection(TRUE); |
| | | m_wndGrid.ExpandColumnsToFit(TRUE); |
| | | m_wndGrid.ExpandLastColumn(); |
| | | |
| | | // èªå¨è®¡ç®å¹¶è®¾ç½®æ¯è¡é«åº¦ |
| | | CRect rcClient; |
| | | m_wndGrid.GetClientRect(&rcClient); |
| | | int nAvailableHeight = rcClient.Height(); |
| | | int nEachRowHeight = max(24, nAvailableHeight / nRows); |
| | | |
| | | for (int i = 0; i < nRows; ++i) { |
| | | m_wndGrid.SetRowHeight(i, nEachRowHeight); |
| | | } |
| | | |
| | | FillGrid(); |
| | | } |
| | | |
| | | void CPortConfigurationDlg::FillGrid() |
| | | { |
| | | //CStringArray recipeOptions; |
| | | //recipeOptions.Add(_T("Recipe A")); |
| | | //recipeOptions.Add(_T("Recipe B")); |
| | | //recipeOptions.Add(_T("Recipe C")); |
| | | |
| | | for (int i = 1; i < 9; ++i) { |
| | | CString strIndex; |
| | | strIndex.Format(_T("%d"), i); |
| | | m_wndGrid.SetItemText(i, 0, strIndex); |
| | | m_wndGrid.SetItemState(i, 0, GVIS_READONLY); |
| | | |
| | | // EQ Recipe - ComboBox |
| | | //if (m_wndGrid.SetCellType(i, 1, RUNTIME_CLASS(CGridCellCombo))) { |
| | | // CGridCellCombo* pCell = static_cast<CGridCellCombo*>(m_wndGrid.GetCell(i, 1)); |
| | | // pCell->SetOptions(recipeOptions); |
| | | // pCell->SetStyle(CBS_DROPDOWNLIST); |
| | | //} |
| | | //m_wndGrid.SetItemText(i, 1, recipeOptions[0]); |
| | | |
| | | // Panel ID - å¯ç¼è¾ |
| | | m_wndGrid.SetItemText(i, 1, _T("")); |
| | | |
| | | // Checkbox |
| | | m_wndGrid.SetCellType(i, 2, RUNTIME_CLASS(CGridCellCheck)); |
| | | CGridCellCheck* pCheck = static_cast<CGridCellCheck*>(m_wndGrid.GetCell(i, 2)); |
| | | if (pCheck) { |
| | | pCheck->SetCheck(FALSE); |
| | | } |
| | | } |
| | | |
| | | m_wndGrid.Invalidate(); |
| | | m_wndGrid.UpdateWindow(); |
| | | } |
| | | |
| | | void CPortConfigurationDlg::DoDataExchange(CDataExchange* pDX) |
| | | { |
| | | DDX_Control(pDX, IDC_GRID_PANEL_RECIPE, m_wndGrid); |
| | | CDialogEx::DoDataExchange(pDX); |
| | | } |
| | | |
| | | |
| | | BEGIN_MESSAGE_MAP(CPortConfigurationDlg, CDialogEx) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | | // CPortConfigurationDlg æ¶æ¯å¤çç¨åº |
| | | |
| | | BOOL CPortConfigurationDlg::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | |
| | | // TODO: 卿¤æ·»å é¢å¤çåå§å |
| | | InitGrid(); |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | | // å¼å¸¸: OCX 屿§é¡µåºè¿å FALSE |
| | | } |