43 const tk::Queue<ResourceString>& TK_Choices
47 tk::Queue<ResourceString>::Iterator it = TK_Choices.GetIterator();
48 for (
int i_ElementsToSkip = I_Choice;
49 (i_ElementsToSkip >= 0) && TK_Choices.IsValid(it);
52 if (i_ElementsToSkip == 0)
54 return TK_Choices.GetAt(it);
58 TK_Choices.MoveNext(it);
69 Choice::Choice(
const int I_DefaultChoice,
const tk::Queue<ResourceString>& TK_Choices)
71 m_iDefaultChoice(I_DefaultChoice), m_tkChoices(TK_Choices), m_eLang(
ResourceString::LANG_EN)
76 :
Line(CLI_ParentContext, tk::
String(10), -1, -1),
77 m_iDefaultChoice(I_DefaultChoice), m_tkChoices(TK_Choices), m_eLang(
ResourceString::LANG_EN)
89 tk::Queue<int> tk_Near(10);
90 for ( tk::Queue<ResourceString>::Iterator it = m_tkChoices.GetIterator();
91 m_tkChoices.IsValid(it);
92 m_tkChoices.MoveNext(it), i_Choice++)
94 const tk::String str_Choice = m_tkChoices.GetAt(it).GetString(m_eLang);
97 if (str_Line == str_Choice)
103 if (str_Line.ToUpper() == str_Choice.SubString(0, str_Line.GetLength()).ToUpper())
105 tk_Near.AddTail(i_Choice);
110 if (tk_Near.GetCount() == 1)
112 return tk_Near.GetHead();
125 return Choice2Str(i_Choice, m_tkChoices);
139 Line::SetLine(Choice2Str(m_iDefaultChoice, m_tkChoices).GetString(m_eLang),
false,
true);
156 MoveChoice(-1, m_tkChoices.GetCount() / 10);
159 MoveChoice(1, m_tkChoices.GetCount() / 10);
178 void Choice::MoveChoice(
const int I_Way,
const unsigned int UI_Increment)
180 const int i_Increment = I_Way * (int) ((UI_Increment == 0) ? 1 : UI_Increment);
189 else if (i_Choice + i_Increment < 0)
198 Line::SetLine(Choice2Str(0, m_tkChoices).GetString(m_eLang),
false,
true);
200 else if (i_Choice + i_Increment >= (
int) m_tkChoices.GetCount())
204 if (i_Choice >= ((
int) m_tkChoices.GetCount()) - 1)
209 Line::SetLine(Choice2Str(m_tkChoices.GetCount() - 1, m_tkChoices).GetString(m_eLang),
false,
true);
Main namespace of the CLI library.
const tk::String GetLine(void) const
Line retrieval.
Simple line user interface object.
void SetLine(const tk::String &TK_Line, const bool B_NewLine, const bool B_CleanOnTyping)
Protected line setter for child classes.
const ResourceString::LANG GetLang(void) const
Language access.
#define CLI_NS_END(__ns)
End a namespace definition.
void EndControl(const bool B_ExecResult)
Method to call by child classes in order to end the control execution.
const ResourceString GetstrChoice(void) const
Choice retrieval in its string form.
CmdLineEdition class definition.
void Beep(void)
Sends a beep signal.
CLI library default pre-compiled header.
#define CLI_NS_BEGIN(__ns)
Begin a namespace definition.
Choice(const int I_DefaultChoice, const tk::Queue< ResourceString > &TK_Choices)
Top execution context constructor.
virtual void OnKey(const KEY E_KeyCode)
Handler called on character input.
const int GetChoice(void) const
Choice retrieval.
virtual void OnKey(const KEY E_KeyCode)
Handler called on character input.
virtual ~Choice(void)
Destructor.
virtual void ResetToDefault(void)
Handler called when default value is required to be restored.