3#include <cgv/utils/tokenizer.h>
5#include <cgv/gui/application.h>
6#include <cgv/signal/rebind.h>
24int question(
const std::string& _question,
const std::vector<std::string>& answers,
int default_answer)
30 return d->question(_question,answers,default_answer);
34int question(
const std::string& _question,
const std::string& answers,
int default_answer)
40 std::vector<std::string> answer_strings;
41 std::vector<int> answer_values;
43 std::vector<token> tokens;
46 for (
unsigned i=0; i<tokens.size(); ++i) {
47 std::vector<token> toks;
50 if (toks.size() > 0) {
51 answer_strings.push_back(
to_string(toks[0]));
55 answer_values.push_back(idx);
58 return answer_values[d->question(_question,answer_strings,default_answer)];
61bool query(
const std::string&
question, std::string& text,
bool password)
67 return d->query(
question,text,password);
81 D->set(
"group", group_type);
85dialog::dialog(
int w,
int h,
const std::string& title,
const std::string& group_type)
90 D->set(
"group", group_type);
96 return D->get_inner_group();
102 if (!ok_label.empty())
103 cgv::signal::connect_copy(
group()->add_button(ok_label,
"w=75",
" ")->click, cgv::signal::rebind(set_true_and_hide, cgv::signal::_c(&result), cgv::signal::_c(&(*D))));
104 if (!cancel_label.empty())
105 cgv::signal::connect_copy(
group()->add_button(cancel_label,
"w=75",
"\n")->click, cgv::signal::rebind(&(*D), &
cgv::gui::window::hide));
113 D->set(
"H",
group()->get<int>(
"H"));
115 D->set(
"hotspot",
true);
reference counted pointer, which can work together with types that are derived from ref_counted,...
bool empty() const
check if pointer is not yet set
static window_ptr create_window(int w, int h, const std::string &title, const std::string &window_type="viewer")
create a window of the given type, where all gui implementations must support the type "viewer"
cgv::gui::gui_group_ptr group()
return the gui group to which new elements are to be add
void add_std_buttons(const std::string &ok_label="ok", const std::string &cancel_label="")
add buttons for ok and or cancel
dialog(const std::string &title, const std::string &group_type="align_group")
create from title and adjust size according to content
bool exec()
execute modal dialog and freeze all other windows
gui independent window class
virtual void hide()=0
hide the window
the tokenizer allows to split text into tokens in a convenient way.
tokenizer & set_ws(const std::string &ws)
set the list of white spaces, that separate tokens and are skipped
gui_driver_ptr get_gui_driver()
return the currently registered gui driver or an empty pointer if non has been registered
void message(const std::string &_message)
tell the user something with a message box
int question(const std::string &_question, const std::vector< std::string > &answers, int default_answer)
ask the user with question to select one of the answers, where default_answer specifies index of defa...
bool query(const std::string &question, std::string &text, bool password)
query the user for a text, where the second parameter is the default text as well as the returned tex...
namespace that holds tools that dont fit any other namespace
std::string to_string(const std::string &v, unsigned int w, unsigned int p, bool)
specialization of conversion from string to strings
bool is_integer(const char *begin, const char *end, int &value)
check if the text range (begin,end( defines an integer value. If yes, store the value in the passed r...
Helper functions to process strings.