1 #include "view_selection.h" 6 for(
size_t i = 0; i < choices.size(); i++)
9 wattron(
win, A_REVERSE);
10 mvwprintw(
win, i + choice_offset_y, choice_offset_x,
"%s", choices[i].c_str());
12 wattroff(
win, A_REVERSE);
16 void ViewSelection::addChoice(std::string name, call_t call)
18 choices.push_back(name);
19 calls.push_back(call);
29 selection = (selection - 1 + choices.size()) % choices.size();
30 while(!choices[selection].length() && choices.size());
36 selection = (selection + 1) % choices.size();
37 while(!choices[selection].length() && choices.size());
45 if(getmouse(&event) == OK &&
event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
47 size_t column_start =
start_x + choice_offset_x;
48 size_t row_start =
start_y + choice_offset_y;
49 size_t mouse_x =
event.x, mouse_y =
event.y;
50 for(
size_t i = 0; i < choices.size(); i++)
51 if(choices[i].length() && mouse_y == row_start + i && mouse_x >= column_start && mouse_x < column_start + choices[i].length())
53 if(selection == i || event.bstate & BUTTON1_DOUBLE_CLICKED)
66 if(selection == choices.size() - 1)
69 ret =
calls[selection];