예제 #1
0
std::string InputBox(const std::string &msg, const std::string &init, int max, chtype out)
{
    CDialog *dialog = CreateBaseDialog(TColorPair(COLOR_GREEN, COLOR_BLUE),
                                       TColorPair(COLOR_WHITE, COLOR_BLUE), 50);
    
    CLabel *label = new CLabel(msg, false);
    label->SetMaxReqWidth(MaxW());
    dialog->AddWidget(label);
    
    CInputField *input = new CInputField(init, CInputField::STRING, max, out);
    dialog->StartPack(input, true, true, 1, 0);
    
    CButton *okbutton = new CButton(GetTranslation("OK")), *cancelbutton = new CButton(GetTranslation("Cancel"));
    dialog->AddButton(okbutton, false, false);
    dialog->AddButton(cancelbutton, false, false);

    TUI.AddGroup(dialog, true);
    
    while (dialog->Run())
        ;
    
    std::string ret;
    if (dialog->ActivatedWidget() != cancelbutton)
        ret = input->Value();
    
    delete dialog;
    
    return ret;
}
예제 #2
0
bool YesNoBox(const std::string &msg)
{
    CDialog *dialog = CreateBaseDialog(TColorPair(COLOR_GREEN, COLOR_BLUE), TColorPair(COLOR_WHITE, COLOR_BLUE),
                                       30, 0, msg);
    
    CButton *nobutton = new CButton(GetTranslation("No")), *yesbutton = new CButton(GetTranslation("Yes"));
    dialog->AddButton(yesbutton);
    dialog->AddButton(nobutton);
    
    TUI.AddGroup(dialog, true);
    
    while (dialog->Run())
        ;
    
    bool ret = (dialog->ActivatedWidget() == yesbutton);
    
    delete dialog;
    
    return ret;
}