-
Notifications
You must be signed in to change notification settings - Fork 8
/
dialog.cpp
57 lines (54 loc) · 1.07 KB
/
dialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "dialog.hpp"
#include <sstream>
Dialog::Dialog(const std::wstring &message, Answers answers):
message_(message),
answers_(answers)
{
std::wostringstream tmp;
tmp << message;
bool first = true;
if ((answers_ & Yes) != 0)
{
if (first)
tmp << L" (";
else
tmp << L"/";
tmp << L"y";
first = false;
}
if ((answers_ & No) != 0)
{
if (first)
tmp << L"(";
else
tmp << L"/";
tmp << L"n";
first = false;
}
if ((answers_ & Cancel) != 0)
{
if (first)
tmp << L"(";
else
tmp << L"/";
tmp << L"c";
first = false;
}
if (!first)
tmp << L"): ";
buffer_.push_back(tmp.str());
}
std::wstring Dialog::preInsert(Coord &, const std::wstring &value)
{
if ((answers_ & Yes) != 0 && value.find(L'y') != std::wstring::npos)
result(Yes);
if ((answers_ & No) != 0 && value.find(L'n') != std::wstring::npos)
result(No);
if ((answers_ & Cancel) != 0 && value.find(L'c') != std::wstring::npos)
result(Cancel);
return L"";
}
int Dialog::preBackspace(Coord &, int)
{
return 0;
}