summaryrefslogtreecommitdiffstats
path: root/curses/curseschoicebutton.C
blob: be607d4055812ea160ef1112d53e9397b1f5b288 (plain)
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
/*
** Copyright 2002, Double Precision Inc.
**
** See COPYING for distribution information.
*/

#include "curses_config.h"
#include "curseschoicebutton.H"

using namespace std;

CursesChoiceButton::CursesChoiceButton(CursesContainer *parent)
	: CursesButton(parent, ""),
	  selectedOption(0)
{
}

void CursesChoiceButton::setOptions(const vector<string> &optionListArg,
				    size_t initialOption)
{
	optionList=optionListArg;
	selectedOption=initialOption;
	setText(optionListArg[selectedOption]);
}

CursesChoiceButton::~CursesChoiceButton()
{
}

void CursesChoiceButton::clicked()
{
	if (optionList.size() > 0)
	{
		selectedOption = (selectedOption+1) % optionList.size();
		setText(optionList[selectedOption]);
	}
}