当前位置: 首页>>代码示例>>C++>>正文


C++ twindow::find方法代码示例

本文整理汇总了C++中twindow::find方法的典型用法代码示例。如果您正苦于以下问题:C++ twindow::find方法的具体用法?C++ twindow::find怎么用?C++ twindow::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twindow的用法示例。


在下文中一共展示了twindow::find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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());
	}

}
开发者ID:aelthwin,项目名称:Battle-for-Wesnoth--Zombie-Edition,代码行数:56,代码来源:mp_cmd_wrapper.cpp

示例2: post_show

void tmp_cmd_wrapper::post_show(twindow& window)
{
	ttext_box* message =
		dynamic_cast<ttext_box*>(window.find("message", false));
	message_ = message ? message_ = message->get_value() : "";

	ttext_box* reason =
		dynamic_cast<ttext_box*>(window.find("reason", false));
	reason_ = reason ? reason_ = reason->get_value() : "";

	ttext_box* time =
		dynamic_cast<ttext_box*>(window.find("time", false));
	time_ = time ? time_ = time->get_value() : "";

}
开发者ID:aelthwin,项目名称:Battle-for-Wesnoth--Zombie-Edition,代码行数:15,代码来源:mp_cmd_wrapper.cpp

示例3: init_fields

void tdialog::init_fields(twindow& window)
{
	for(auto field : fields_)
	{
		field->attach_to_window(window);
		field->widget_init(window);
	}

	if(!focus_.empty()) {
		if(twidget* widget = window.find(focus_, false)) {
			window.keyboard_capture(widget);
		}
	}
}
开发者ID:aquileia,项目名称:wesnoth,代码行数:14,代码来源:dialog.cpp

示例4: pre_show

void tlobby_player_info::pre_show(CVideo& /*video*/, twindow& window)
{
	relation_ = find_widget<tlabel>(&window, "relation_info", false, true);
	GUI2_EASY_BUTTON_CALLBACK(start_whisper, tlobby_player_info);

	GUI2_EASY_BUTTON_CALLBACK(add_to_friends, tlobby_player_info);
	GUI2_EASY_BUTTON_CALLBACK(add_to_ignores, tlobby_player_info);
	GUI2_EASY_BUTTON_CALLBACK(remove_from_list, tlobby_player_info);
	add_to_friends_ = add_to_friends_btn;
	add_to_ignores_ = add_to_ignores_btn;
	remove_from_list_ = remove_from_list_btn;

	GUI2_EASY_BUTTON_CALLBACK(check_status, tlobby_player_info);
	GUI2_EASY_BUTTON_CALLBACK(kick, tlobby_player_info);
	GUI2_EASY_BUTTON_CALLBACK(kick_ban, tlobby_player_info);

	find_widget<tlabel>(&window, "player_name", false)
			.set_label(info_.name);

	std::stringstream loc;
	const game_info* game = lobby_info_.get_game_by_id(info_.game_id);
	if (game != NULL) {
		loc << _("In game:") << " " << game->name << " ";
		if (info_.observing) {
			loc << _("(observing)");
		} else {
			loc << _("(playing)");
		}
	} else {
		loc << _("In lobby");
	}

	find_widget<tlabel>(&window, "location_info", false).set_label(loc.str());

	update_relation(window);

	if (!preferences::is_authenticated()) {
		twidget* aw = window.find("admin", false);
		aw->set_visible(twidget::INVISIBLE);
	}
}
开发者ID:Alexander--,项目名称:Wesnoth-1.8-for-Android,代码行数:41,代码来源:lobby_player_info.cpp

示例5: widget_set_enabled

	/**
	 * Enables a widget.
	 *
	 * @param window              The window containing the widget.
	 * @param enable              If true enables the widget, disables
	 *                            otherwise.
	 * @param sync                If the state is changed do we need to
	 *                            synchronize. Upon disabling, write the value
	 *                            of the widget in the variable value_. Upon
	 *                            enabling write the value of value_ in the
	 *                            widget.
	 */
	void widget_set_enabled(twindow& window, const bool enable, const bool sync)
	{
		tcontrol* widget = dynamic_cast<tcontrol*>(window.find(id(), false));

		if(!widget) {
			return;
		}

		const bool widget_state = widget->get_active();
		if(widget_state == enable) {
			return;
		}

		if(sync) {
			if(enable) {
				widget_restore(window);
			} else {
				widget_save(window);
			}
		}

		widget->set_active(enable);
	}
开发者ID:niegenug,项目名称:wesnoth,代码行数:35,代码来源:field.hpp

示例6: pre_show

void tlobby_player_info::pre_show(twindow& window)
{
	relation_ = find_widget<tlabel>(&window, "relation_info", false, true);
	connect_signal_mouse_left_click(
			find_widget<tbutton>(&window, "start_whisper", false),
			std::bind(&tlobby_player_info::start_whisper_button_callback,
						this,
						std::ref(window)));

	add_to_friends_ = &find_widget<tbutton>(&window, "add_to_friends", false);
	connect_signal_mouse_left_click(
			*add_to_friends_,
			std::bind(&tlobby_player_info::add_to_friends_button_callback,
						this,
						std::ref(window)));

	add_to_ignores_ = &find_widget<tbutton>(&window, "add_to_ignores", false);
	connect_signal_mouse_left_click(
			*add_to_ignores_,
			std::bind(&tlobby_player_info::add_to_ignores_button_callback,
						this,
						std::ref(window)));

	remove_from_list_
			= &find_widget<tbutton>(&window, "remove_from_list", false);
	connect_signal_mouse_left_click(
			*remove_from_list_,
			std::bind(&tlobby_player_info::remove_from_list_button_callback,
						this,
						std::ref(window)));

	connect_signal_mouse_left_click(
			find_widget<tbutton>(&window, "check_status", false),
			std::bind(&tlobby_player_info::check_status_button_callback,
						this,
						std::ref(window)));

	connect_signal_mouse_left_click(
			find_widget<tbutton>(&window, "kick", false),
			std::bind(&tlobby_player_info::kick_button_callback,
						this,
						std::ref(window)));

	connect_signal_mouse_left_click(
			find_widget<tbutton>(&window, "kick_ban", false),
			std::bind(&tlobby_player_info::kick_ban_button_callback,
						this,
						std::ref(window)));

	find_widget<tlabel>(&window, "player_name", false).set_label(info_.name);

	std::stringstream loc;
	const game_info* game = lobby_info_.get_game_by_id(info_.game_id);
	if(game != nullptr) {
		loc << _("In game:") << " " << game->name << " ";
		if(info_.observing) {
			loc << _("(observing)");
		} else {
			loc << _("(playing)");
		}
	} else {
		loc << _("In lobby");
	}

	find_widget<tlabel>(&window, "location_info", false).set_label(loc.str());

	update_relation(window);

	if(!preferences::is_authenticated()) {
		twidget* aw = window.find("admin", false);
		aw->set_visible(twidget::tvisible::invisible);
	}
}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:73,代码来源:player_info.cpp


注:本文中的twindow::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。