#include "Resource.h"

class HCNewSubcategoryDialog {
    CStatic* pCategoryLabel;
    CEdit* pSubcategoryName;
    CEdit* pQuestion;
    string subcategoryName, question, categoryName;
public:
    enum {NAMESIZELIMIT=80, QUESTIONSIZELIMIT=200};
    HCNewSubcategoryDialog(string categoryName)
        :categoryName(categoryName){}
    void onInitDialog(CWnd *pWnd) {
        pCategoryLabel = 
            (CStatic *) (pWnd->GetDlgItem(IDC_CATEGORY_LABEL));
        pSubcategoryName = 
            (CEdit*)(pWnd->GetDlgItem(IDC_EDIT_SUBCATEGORY));
        pQuestion = (CEdit*)(pWnd->GetDlgItem(IDC_EDIT_QUESTION));
        pCategoryLabel->SetWindowText(
            ("Category: " + categoryName).c_str());
    }
    string getSubcategory() { return subcategoryName; }
    string getQuestion() { return question; }
    void onDestroy() {
        char buffer[QUESTIONSIZELIMIT+1];
        pSubcategoryName->GetWindowText(
            (LPTSTR)buffer,NAMESIZELIMIT);
        subcategoryName = buffer;
        pQuestion->GetWindowText(
            (LPTSTR)buffer,QUESTIONSIZELIMIT);
        question = buffer;
    }
};
