Sheet Interface

1 개요

CGUISheetInterface 클래스는 엑셀과 같은 시트(테이블) 컨트롤을 관리하는 클래스입니다.

2 셀 타입 지정 : SetCellType()

셀은 기본적으로로 Edit 컨트롤입니다. 셀을 체크박스, 콤보박스 등으로 설정할 수 있습니다.

지원되는 타입

지원되는 타입은 enum EFLSheetCellType에 정의되어 있습니다.

사용 예시

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);


위 코드의 수행 결과로 생성되는 시트는 아래와 같습니다.
Set Cell Type
Fig. Set Cell Type