Exemplo n.º 1
0
int
main()
try
{
	fcppt::log::context log_context{
		fcppt::log::optional_level{
			fcppt::log::level::debug
		},
		fcppt::log::default_level_streams()
	};

	awl::system::object_unique_ptr const window_system(
		awl::system::create(
			log_context
		)
	);

	awl::visual::object_unique_ptr const visual(
		window_system->default_visual()
	);

	awl::window::object_unique_ptr const window(
		window_system->create_window(
			awl::window::parameters(
				*visual
			)
			.title(
				FCPPT_TEXT("awltest")
			)
			.class_name(
				FCPPT_TEXT("awltest")
			)
			.size(
				awl::window::dim(
					1024u,
					768u
				)
			)
		)
	);

	window->show();

	awl::system::event::processor &system_processor(
		window_system->processor()
	);

	return
		awl::main::loop_next(
			system_processor,
			awl::main::loop_function{
				[
					&system_processor
				](
					awl::event::base const &_event
				){
					fcppt::optional::maybe_void(
						fcppt::variant::dynamic_cast_<
							brigand::list<
								awl::window::event::resize const,
								awl::window::event::close const,
								awl::window::event::destroy const
							>,
							fcppt::cast::dynamic_fun
						>(
							_event
						),
						[
							&system_processor
						](
							auto const &_variant
						)
						{
							fcppt::variant::match(
								_variant,
								[](
									fcppt::reference<
										awl::window::event::resize const
									> const _resize
								)
								{
									fcppt::io::cout()
										<<
										FCPPT_TEXT("Resize: ")
										<<
										_resize.get().dim()
										<<
										FCPPT_TEXT('\n');
								},
								[
									&system_processor
								](
									fcppt::reference<
										awl::window::event::close const
									>
								)
								{
									fcppt::io::cout()
										<<
										FCPPT_TEXT("Close\n");

									system_processor.quit(
										awl::main::exit_success()
									);
								},
								[
									&system_processor
								](
									fcppt::reference<
										awl::window::event::destroy const
									>
								)
								{
									fcppt::io::cout()
										<<
										FCPPT_TEXT("Destroy\n");

									system_processor.quit(
										awl::main::exit_success()
									);
								}
							);
						}
					);
				}
			}
		).get();
}
catch(
	fcppt::exception const &_exception
)
{
	fcppt::io::cerr()
		<<
		_exception.string()
		<<
		FCPPT_TEXT('\n');

	return
		EXIT_FAILURE;
}
Exemplo n.º 2
0
int
main()
try
{
	awl::system::object_unique_ptr const system(
		awl::system::create()
	);

	awl::visual::object_unique_ptr const visual(
		system->default_visual()
	);

	awl::window::object_unique_ptr const window(
		system->create_window(
			awl::window::parameters(
				*visual
			)
			.class_name(
				FCPPT_TEXT("awlshow")
			)
			.size(
				awl::window::dim(
					1024,
					768
				)
			)
		)
	);

	awl::system::event::processor_unique_ptr const system_processor(
		awl::system::event::create_processor(
			*system
		)
	);

	awl::event::processor_unique_ptr const processor(
		awl::event::create_processor(
			*system,
			awl::system::event::optional_processor_ref(
				*system_processor
			)
		)
	);

	awl::window::event::processor_unique_ptr const window_processor(
		awl::window::event::create_processor(
			*window
		)
	);

	awl::event::scoped_window_processor const scoped_window_processor(
		*processor,
		*window_processor
	);

	window->show();

	fcppt::signal::scoped_connection const show_connection(
		window_processor->show_callback(
			awl::window::event::show_callback(
				[
					&system_processor
				](
					awl::window::event::show const &
				)
				{
					system_processor->quit(
						awl::main::exit_success()
					);
				}
			)
		)
	);

	while(
		system_processor->running()
	)
		processor->next();
}
catch(
	fcppt::exception const &_exception
)
{
	fcppt::io::cerr()
		<< _exception.string()
		<< FCPPT_TEXT('\n');

	return
		EXIT_FAILURE;
}