本文整理汇总了C++中twindow::keyboard_capture方法的典型用法代码示例。如果您正苦于以下问题:C++ twindow::keyboard_capture方法的具体用法?C++ twindow::keyboard_capture怎么用?C++ twindow::keyboard_capture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twindow
的用法示例。
在下文中一共展示了twindow::keyboard_capture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pre_show
void tdata_manage::pre_show(CVideo& /*video*/, twindow& window)
{
assert(txtFilter_);
ttext_box* filter
= find_widget<ttext_box>(&window, "txtFilter", false, true);
window.keyboard_capture(filter);
filter->set_text_changed_callback(
boost::bind(&tdata_manage::filter_text_changed, this, _1, _2));
tlistbox& list = find_widget<tlistbox>(&window, "persist_list", false);
window.keyboard_capture(&list);
#ifdef GUI2_EXPERIMENTAL_LISTBOX
connect_signal_notify_modified(list,
boost::bind(&tdata_manage::list_item_clicked,
this,
boost::ref(window)));
#else
list.set_callback_value_change(
dialog_callback<tdata_manage, &tdata_manage::list_item_clicked>);
#endif
{
cursor::setter cur(cursor::WAIT);
games_ = savegame::get_saves_list();
}
fill_game_list(window, games_);
connect_signal_mouse_left_click(
find_widget<tbutton>(&window, "clear", false),
boost::bind(&tdata_manage::delete_button_callback,
this,
boost::ref(window)));
}
示例2: pre_show
/**
* @todo This function enables the wml markup for all items, but the interface
* is a bit hacky. Especially the fiddling in the internals of the listbox is
* ugly. There needs to be a clean interface to set whether a widget has a
* markup and what kind of markup. These fixes will be post 1.6.
*/
void twml_message_::pre_show(twindow& window)
{
set_restore(true);
window.canvas(1).set_variable("portrait_image", variant(portrait_));
window.canvas(1).set_variable("portrait_mirror", variant(mirror_));
// Set the markup
tlabel& title = find_widget<tlabel>(&window, "title", false);
title.set_label(title_);
title.set_use_markup(true);
title.set_can_wrap(true);
tcontrol& message = find_widget<tcontrol>(&window, "message", false);
message.set_label(message_);
message.set_use_markup(true);
// The message label might not always be a scroll_label but the capturing
// shouldn't hurt.
window.keyboard_capture(&message);
// Find the input box related fields.
tlabel& caption = find_widget<tlabel>(&window, "input_caption", false);
ttext_box& input = find_widget<ttext_box>(&window, "input", true);
if(has_input_) {
caption.set_label(input_caption_);
caption.set_use_markup(true);
input.set_value(*input_text_);
input.set_maximum_length(input_maximum_length_);
window.keyboard_capture(&input);
window.set_click_dismiss(false);
window.set_escape_disabled(true);
} else {
caption.set_visible(twidget::tvisible::invisible);
input.set_visible(twidget::tvisible::invisible);
}
// Find the option list related fields.
tlistbox& options = find_widget<tlistbox>(&window, "input_list", true);
if(!option_list_.empty()) {
std::map<std::string, string_map> data;
BOOST_FOREACH(const twml_message_option& item, option_list_) {
// Add the data.
data["icon"]["label"] = item.image();
data["label"]["label"] = item.label();
data["label"]["use_markup"] = "true";
data["description"]["label"] = item.description();
data["description"]["use_markup"] = "true";
options.add_row(data);
}
示例3: pre_show
void tlanguage_selection::pre_show(CVideo& /*video*/, twindow& window)
{
window.set_canvas_variable("border", variant("default-border"));
tlistbox& list = find_widget<tlistbox>(&window, "language_list", false);
window.keyboard_capture(&list);
const std::vector<language_def>& languages = get_languages();
const language_def& current_language = get_language();
std::stringstream strstr;
int number = hero::number_normal_min;
BOOST_FOREACH (const language_def& lang, languages) {
string_map list_item;
std::map<std::string, string_map> list_item_item;
strstr.str("");
strstr << "hero-64/" << number << ".png";
list_item["label"] = strstr.str();
list_item_item.insert(std::make_pair("icon", list_item));
list_item["label"] = lang.language;
list_item_item.insert(std::make_pair("name", list_item));
list.add_row(list_item_item);
if (lang == current_language) {
list.select_row(list.get_item_count() - 1);
}
number ++;
}
示例4: pre_show
void tmessage::pre_show(CVideo& /*video*/, twindow& window)
{
// ***** Validate the required buttons ***** ***** ***** *****
tmessage_implementation::
init_button(window, buttons_[left_1], "left_side");
tmessage_implementation::
init_button(window, buttons_[cancel], "cancel");
tmessage_implementation::
init_button(window, buttons_[ok] ,"ok");
tmessage_implementation::
init_button(window, buttons_[right_1], "right_side");
// ***** ***** ***** ***** Set up the widgets ***** ***** ***** *****
if(!title_.empty()) {
find_widget<tlabel>(&window, "title", false).set_label(title_);
}
if(!image_.empty()) {
find_widget<timage>(&window, "image", false).set_label(image_);
}
tcontrol& label = find_widget<tcontrol>(&window, "label", false);
label.set_label(message_);
// The label might not always be a scroll_label but the capturing
// shouldn't hurt.
window.keyboard_capture(&label);
// Override the user value, to make sure it's set properly.
window.set_click_dismiss(auto_close_);
}
示例5: pre_show
void tcampaign_difficulty::pre_show(CVideo& /*video*/, twindow& window)
{
tlistbox& list = find_widget<tlistbox>(&window, "listbox", false);
window.keyboard_capture(&list);
std::map<std::string, string_map> data;
BOOST_FOREACH(const config &d, difficulties_.child_range("difficulty"))
{
data["icon"]["label"] = d["image"];
data["label"]["label"] = d["label"];
data["label"]["use_markup"] = "true";
data["description"]["label"] = d["old_markup"].to_bool() || d["description"].empty() ? d["description"]
: std::string("(") + d["description"] + std::string(")");
data["description"]["use_markup"] = "true";
list.add_row(data);
const int this_row = list.get_item_count() - 1;
if(d["default"].to_bool(false)) {
list.select_row(this_row);
}
tgrid* grid = list.get_row_grid(this_row);
assert(grid);
twidget *widget = grid->find("victory", false);
if (widget && !preferences::is_campaign_completed(campaign_id_, d["define"])) {
widget->set_visible(twidget::tvisible::hidden);
}
}
}
示例6: pre_show
void ttheme_list::pre_show(twindow& window)
{
tlistbox& list = find_widget<tlistbox>(&window, "themes", false);
window.keyboard_capture(&list);
for(const auto & t : themes_)
{
std::map<std::string, string_map> data;
string_map column;
std::string theme_name = t.name;
if(theme_name.empty()) {
theme_name = t.id;
}
column["label"] = theme_name;
data.emplace("name", column);
column["label"] = t.description;
data.emplace("description", column);
list.add_row(data);
}
if(index_ != -1 && static_cast<unsigned>(index_) < list.get_item_count()) {
list.select_row(index_);
}
index_ = -1;
}
示例7: pre_show
void tcombo_box::pre_show(CVideo& /*video*/, twindow& window)
{
window.set_canvas_variable("border", variant("default-border"));
tlabel* title = find_widget<tlabel>(&window, "title", false, true);
if (type_ == EXTRACT) {
title->set_label(_("Extract hero"));
} else {
title->set_visible(twidget::INVISIBLE);
find_widget<twidget>(&window, "ok", false, true)->set_visible(twidget::INVISIBLE);
find_widget<twidget>(&window, "cancel", false, true)->set_visible(twidget::INVISIBLE);
}
tlistbox& list = find_widget<tlistbox>(&window, "listbox", false);
window.keyboard_capture(&list);
std::map<std::string, string_map> data;
int item_index = 0;
for (std::vector<tval_str>::const_iterator it = items_.begin(); it != items_.end(); ++ it) {
const tval_str& item = *it;
data["label"]["label"] = item.str;
list.add_row(data);
item_index ++;
}
list.set_callback_value_change(dialog_callback3<tcombo_box, tlistbox, &tcombo_box::item_selected>);
if (index_ != -1) {
list.select_row(index_);
}
}
示例8: pre_show
void teditor_set_starting_position::pre_show(CVideo& /*video*/, twindow& window)
{
tlistbox& list = find_widget<tlistbox>(&window, "listbox", false);
window.keyboard_capture(&list);
std::map<std::string, string_map> data;
string_map column;
column["label"] = _("player^None");
data.insert(std::make_pair("player", column));
list.add_row(data);
for(unsigned i = 0; i < starting_positions_.size(); ++i) {
const map_location& player_pos = starting_positions_[i];
data.clear();
utils::string_map symbols;
symbols["player_number"] = str_cast(i + 1);
column["label"] = utils::interpolate_variables_into_string(_("Player $player_number"), &symbols);
data.insert(std::make_pair("player", column));
if(player_pos.valid()) {
column["label"] = (formatter() << "(" << player_pos.x + 1 << ", " << player_pos.y + 1 << ")").str();
data.insert(std::make_pair("location", column));
}
list.add_row(data);
}
list.select_row(selection_);
}
示例9: pre_show
void taddon_connect::pre_show(CVideo& /*video*/, twindow& window)
{
ttext_box* host_widget = dynamic_cast<ttext_box*>(window.find_widget("host_name", false));
VALIDATE(host_widget, missing_widget("host_name"));
host_widget->set_value(host_name_);
window.keyboard_capture(host_widget);
}
示例10: pre_show
void tgame_save::pre_show(CVideo& /*video*/, twindow& window)
{
assert(txtFilename_);
find_widget<tlabel>(&window, "lblTitle", false).set_label(title_);
txtFilename_->set_widget_value(window, filename_);
window.keyboard_capture(txtFilename_->widget(window));
}
示例11: pre_show
void tmp_cmd_wrapper::pre_show(CVideo& /*video*/, twindow& window)
{
ttext_box* message =
dynamic_cast<ttext_box*>(window.find("message", false));
if(message) {
/**
* @todo For some reason the text wrapping fails on Windows and Mac,
* this causes an exception to be thrown, which brings the user back
* to the main menu. So avoid that problem by imposing a maximum
* length (the number of letters W that fit).
*/
#if defined(_WIN32) || defined(__APPLE__)
message->set_maximum_length(18);
#endif
window.keyboard_capture(message);
}
message = dynamic_cast<ttext_box*>(window.find("reason", false));
if(message) message->set_active(preferences::is_authenticated());
message = dynamic_cast<ttext_box*>(window.find("time", false));
if(message) message->set_active(preferences::is_authenticated());
tlabel* label =
dynamic_cast<tlabel*>(window.find("user_label", false));
if(label) label->set_label(user_);
tbutton* b = dynamic_cast<tbutton*>(window.find("add_friend", false));
if(b) b->set_retval(1);
b = dynamic_cast<tbutton*>(window.find("add_ignore", false));
if(b) b->set_retval(2);
b = dynamic_cast<tbutton*>(window.find("remove", false));
if(b) b->set_retval(3);
b = dynamic_cast<tbutton*>(window.find("status", false));
if(b) {
b->set_retval(4);
b->set_active(preferences::is_authenticated());
}
b = dynamic_cast<tbutton*>(window.find("kick", false));
if(b) {
b->set_retval(5);
b->set_active(preferences::is_authenticated());
}
b = dynamic_cast<tbutton*>(window.find("ban", false));
if(b) {
b->set_retval(6);
b->set_active(preferences::is_authenticated());
}
}
示例12: pre_show
void tunit_recruit::pre_show(twindow& window)
{
tlistbox& list = find_widget<tlistbox>(&window, "recruit_list", false);
#ifdef GUI2_EXPERIMENTAL_LISTBOX
connect_signal_notify_modified(*list,
std::bind(&tunit_recruit::list_item_clicked,
*this,
std::ref(window)));
#else
list.set_callback_value_change(
dialog_callback<tunit_recruit, &tunit_recruit::list_item_clicked>);
#endif
window.keyboard_capture(&list);
connect_signal_mouse_left_click(
find_widget<tbutton>(&window, "show_help", false),
std::bind(&tunit_recruit::show_help, this, std::ref(window)));
for(const auto& recruit : recruit_list_)
{
std::map<std::string, string_map> row_data;
string_map column;
std::string image_string = recruit->image() + "~RC(" + recruit->flag_rgb() + ">"
+ team::get_side_color_index(team_.side()) + ")";
int wb_gold = 0;
if(resources::controller) {
if(const std::shared_ptr<wb::manager>& whiteb = resources::controller->get_whiteboard()) {
wb::future_map future; // So gold takes into account planned spending
wb_gold = whiteb->get_spent_gold_for(team_.side());
}
}
const bool can_afford = recruit->cost() <= team_.gold() - wb_gold;
const std::string cost_string = std::to_string(recruit->cost());
column["use_markup"] = "true";
column["label"] = image_string;
row_data.emplace("unit_image", column);
column["label"] = can_afford_unit(recruit->type_name(), can_afford);
row_data.emplace("unit_type", column);
column["label"] = can_afford_unit(cost_string, can_afford);
row_data.emplace("unit_cost", column);
list.add_row(row_data);
}
list_item_clicked(window);
}
示例13: pre_show
void tgame_load::pre_show(CVideo& /*video*/, twindow& window)
{
assert(txtFilter_);
find_widget<tminimap>(&window, "minimap", false).set_config(&cache_config_);
ttext_box* filter = find_widget<ttext_box>(
&window, "txtFilter", false, true);
window.keyboard_capture(filter);
filter->set_text_changed_callback(boost::bind(
&tgame_load::filter_text_changed, this, _1, _2));
tlistbox* list = find_widget<tlistbox>(
&window, "savegame_list", false, true);
window.keyboard_capture(list);
#ifdef GUI2_EXPERIMENTAL_LISTBOX
connect_signal_notify_modified(*list, boost::bind(
&tgame_load::list_item_clicked
, *this
, boost::ref(window)));
#else
list->set_callback_value_change(
dialog_callback<tgame_load, &tgame_load::list_item_clicked>);
#endif
{
cursor::setter cur(cursor::WAIT);
games_ = savegame::get_saves_list();
}
fill_game_list(window, games_);
connect_signal_mouse_left_click(
find_widget<tbutton>(&window, "delete", false)
, boost::bind(
&tgame_load::delete_button_callback
, this
, boost::ref(window)));
display_savegame(window);
}
示例14: pre_show
void tcore_selection::pre_show(twindow& window)
{
/***** Setup core list. *****/
tlistbox& list = find_widget<tlistbox>(&window, "core_list", false);
#ifdef GUI2_EXPERIMENTAL_LISTBOX
connect_signal_notify_modified(
list,
std::bind(&tcore_selection::core_selected,
this,
std::ref(window)));
#else
list.set_callback_value_change(
dialog_callback<tcore_selection,
&tcore_selection::core_selected>);
#endif
window.keyboard_capture(&list);
/***** Setup core details. *****/
tmulti_page& multi_page
= find_widget<tmulti_page>(&window, "core_details", false);
for(const auto & core : cores_)
{
/*** Add list item ***/
string_map list_item;
std::map<std::string, string_map> list_item_item;
list_item["label"] = core["image"];
list_item_item.insert(std::make_pair("image", list_item));
list_item["label"] = core["name"];
list_item_item.insert(std::make_pair("name", list_item));
list.add_row(list_item_item);
tgrid* grid = list.get_row_grid(list.get_item_count() - 1);
assert(grid);
/*** Add detail item ***/
string_map detail_item;
std::map<std::string, string_map> detail_page;
detail_item["label"] = core["description"];
detail_item["use_markup"] = "true";
detail_page.insert(std::make_pair("description", detail_item));
multi_page.add_page(detail_page);
}
list.select_row(choice_, true);
core_selected(window);
}
示例15: pre_show
void tmp_method_selection::pre_show(CVideo& /*video*/, twindow& window)
{
user_name_ = preferences::login();
ttext_box* user_widget = find_widget<ttext_box>(
&window, "user_name", false, true);
user_widget->set_value(user_name_);
user_widget->set_maximum_length(mp::max_login_size);
window.keyboard_capture(user_widget);
tlistbox* list = find_widget<tlistbox>(&window, "method_list", false, true);
window.add_to_keyboard_chain(list);
}