Sheet Interface
1 개요
CGUISheetInterface
클래스는 엑셀과 같은 시트(테이블) 컨트롤을 관리하는 클래스입니다.
2 셀 타입 지정 : SetCellType()
셀은 기본적으로로 Edit 컨트롤입니다. 셀을 체크박스, 콤보박스 등으로 설정할 수 있습니다.
지원되는 타입
지원되는 타입은 enum EFLSheetCellType
에 정의되어 있습니다.
- EFLSheetCellType_Base : 기본 셀 (Edit) 유형
- EFLSheetCellType_Check : 체크박스 셀
- EFLSheetCellType_Check_NoText : 체크박스 셀(텍스트 없이 체크 박스만 있는 셀)
- EFLSheetCellType_Combobox : 콤보박스 셀
- EFLSheetCellType_Color : 색상 선택 셀
- EFLSheetCellType_DateTime : 날짜 및 시간 선택 셀
- EFLSheetCellType_Numeric : 숫자 입력 셀
- EFLSheetCellType_Button : 버튼 셀
- EFLSheetCellType_ButtonReorder_Up : 열(row) 순서 변경 버튼(up 방향)
- EFLSheetCellType_ButtonReorder_Down : 열(row) 순서 변경 버튼(down 방향)
사용 예시
CGUISheetInterface* m_pSheetInterface = new CGUISheetInterface;
CRect rtClient(0, 0, 400, 300);
m_pSheetInterface->CreateSheet(rtClient, this); // `this` is CWnd
enum ECol
{
ECol_No = 0,
ECol_Name,
ECol_Check,
ECol_Check_NoText,
ECol_ComboBox,
ECol_Color,
ECol_DateTime,
ECol_Numeric,
ECol_Button,
ECol_ButtonReorder_Up,
ECol_ButtonReorder_Down,
ECol_Count,
};
CFLArray<CFLString<wchar_t>> flaHeader;
flaHeader.Reserve(ECol_Count);
flaHeader.PushBack(L"No.");
flaHeader.PushBack(L"Name");
flaHeader.PushBack(L"Check");
flaHeader.PushBack(L"Check_NoText");
flaHeader.PushBack(L"ComboBox");
flaHeader.PushBack(L"Color");
flaHeader.PushBack(L"DateTime");
flaHeader.PushBack(L"Numeric");
flaHeader.PushBack(L"Button");
flaHeader.PushBack(L"");
flaHeader.PushBack(L"");
m_pSheetInterface->SetHeader(flaHeader);
CFLArray<CFLArray<CFLString<wchar_t>>> flaData;
for(int32_t i = 0; i < 5; ++i)
{
flaData.PushBack(CFLArray<CFLString<wchar_t>>());
CFLArray<CFLString<wchar_t>>& fla = flaData.Back();
fla.Reserve(ECol_Count);
// No.
fla.PushBack(CFLString<wchar_t>().Format(L"%d", i));
// Name
fla.PushBack(CFLString<wchar_t>().Format(L"Item %d", i));
// Check
fla.PushBack(L"Checked");
// Check_NoText
fla.PushBack(L"Checked");
// ComboBox
fla.PushBack(L"Normal");
// ColorPicker
fla.PushBack(L"0");
// DateTime
fla.PushBack(L"2025-01-01");
// Numeric
fla.PushBack(CFLString<wchar_t>().Format(L"%d", i));
// Button
fla.PushBack(CFLString<wchar_t>().Format(L"Button %d", i));
// ButtonReorder_Up
fla.PushBack(L"");
// ButtonReorder_Down
fla.PushBack(L"");
}
m_pSheetInterface->ClearData();
m_pSheetInterface->SetData(flaData);
m_pSheetInterface->SetFixedColumnCount(1);
m_pSheetInterface->SetTitle(L"Typed Sheet");
for(int32_t i = 1; i <= 5; ++i)
{
m_pSheetInterface->SetCellType(i, ECol_Check, EFLSheetCellType_Check);
m_pSheetInterface->SetCellType(i, ECol_Check_NoText, EFLSheetCellType_Check_NoText);
m_pSheetInterface->SetCellType(i, ECol_ComboBox, EFLSheetCellType_Combobox);
m_pSheetInterface->SetCellType(i, ECol_Color, EFLSheetCellType_Color);
m_pSheetInterface->SetCellType(i, ECol_DateTime, EFLSheetCellType_DateTime);
m_pSheetInterface->SetCellType(i, ECol_Numeric, EFLSheetCellType_Numeric);
m_pSheetInterface->SetCellType(i, ECol_Button, EFLSheetCellType_Button);
m_pSheetInterface->SetCellType(i, ECol_ButtonReorder_Up, EFLSheetCellType_ButtonReorder_Up);
m_pSheetInterface->SetCellType(i, ECol_ButtonReorder_Down, EFLSheetCellType_ButtonReorder_Down);
// ComboBox
m_pSheetInterface->AddComboBoxString(i, ECol_ComboBox, L"Normal");
m_pSheetInterface->AddComboBoxString(i, ECol_ComboBox, L"Weight");
// Button
m_pSheetInterface->SetButtonCellClickProcedure(i, ECol_Button, [&]()->void { AfxMessageBox(L"Button Clicked"); });
}
m_pSheetInterface->SetColumnWidth(ECol_ButtonReorder_Up, 25);
m_pSheetInterface->SetColumnWidth(ECol_ButtonReorder_Down, 25);
위 코드의 수행 결과로 생성되는 시트는 아래와 같습니다.
