tsimple_item_selector: Allow to hide the Cancel button

This commit is contained in:
Ignacio R. Morelle 2010-11-29 12:13:05 +00:00
parent 8f9a8764a1
commit bc00c708a2
2 changed files with 14 additions and 3 deletions

View file

@ -38,6 +38,7 @@ tsimple_item_selector::tsimple_item_selector(const std::string& title, const std
, msg_(message)
, markup_title_(title_uses_markup)
, markup_msg_(message_uses_markup)
, single_button_(false)
, items_(items)
, ok_label_()
, cancel_label_()
@ -73,12 +74,19 @@ void tsimple_item_selector::pre_show(CVideo& /*video*/, twindow& window)
index_ = -1;
tbutton& button_ok = find_widget<tbutton>(&window, "ok", false);
tbutton& button_cancel = find_widget<tbutton>(&window, "cancel", false);
if(!ok_label_.empty()) {
find_widget<tbutton>(&window, "ok", false).set_label(ok_label_);
button_ok.set_label(ok_label_);
}
if(!cancel_label_.empty()) {
find_widget<tbutton>(&window, "cancel", false).set_label(cancel_label_);
button_cancel.set_label(cancel_label_);
}
if(single_button_) {
button_cancel.set_visible(gui2::twidget::INVISIBLE);
}
}

View file

@ -44,11 +44,14 @@ public:
void set_cancel_label(const std::string& s) { cancel_label_ = s; }
const std::string& cancel_label() const { return cancel_label_; }
void set_single_button(bool value) { single_button_ = value; }
bool single_button() const { return single_button_; }
private:
int index_;
std::string title_, msg_;
bool markup_title_, markup_msg_;
bool markup_title_, markup_msg_, single_button_;
list_type items_;
std::string ok_label_, cancel_label_;