17 #define GETTEXT_DOMAIN "wesnoth-lib"
23 #include <boost/test/unit_test.hpp>
30 static void print(std::stringstream& sstr
31 ,
const std::string& queue
32 ,
const std::string&
id)
34 sstr << queue <<
':' <<
id <<
'\n';
37 template<gui2::event::ui_event E>
39 std::stringstream& sstr
43 std::bind(
print, std::ref(sstr),
"pre", widget.
id())
47 std::bind(
print, std::ref(sstr),
"child", widget.
id())
51 std::bind(
print, std::ref(sstr),
"post", widget.
id())
56 std::stringstream& sstr
60 connect_queue<gui2::event::DRAW>(sstr, widget);
61 connect_queue<gui2::event::CLOSE_WINDOW>(sstr, widget);
62 connect_queue<gui2::event::MOUSE_ENTER>(sstr, widget);
63 connect_queue<gui2::event::MOUSE_LEAVE>(sstr, widget);
64 connect_queue<gui2::event::LEFT_BUTTON_DOWN>(sstr, widget);
65 connect_queue<gui2::event::LEFT_BUTTON_UP>(sstr, widget);
66 connect_queue<gui2::event::LEFT_BUTTON_CLICK>(sstr, widget);
67 connect_queue<gui2::event::LEFT_BUTTON_DOUBLE_CLICK>(sstr, widget);
68 connect_queue<gui2::event::MIDDLE_BUTTON_DOWN>(sstr, widget);
69 connect_queue<gui2::event::MIDDLE_BUTTON_UP>(sstr, widget);
70 connect_queue<gui2::event::MIDDLE_BUTTON_CLICK>(sstr, widget);
71 connect_queue<gui2::event::MIDDLE_BUTTON_DOUBLE_CLICK>(sstr, widget);
72 connect_queue<gui2::event::RIGHT_BUTTON_DOWN>(sstr, widget);
73 connect_queue<gui2::event::RIGHT_BUTTON_UP>(sstr, widget);
74 connect_queue<gui2::event::RIGHT_BUTTON_CLICK>(sstr, widget);
75 connect_queue<gui2::event::RIGHT_BUTTON_DOUBLE_CLICK>(sstr, widget);
79 , std::unique_ptr<gui2::widget> widget
80 ,
const std::string&
id
82 ,
const unsigned column)
84 BOOST_REQUIRE_NE(widget.get(),
static_cast<gui2::widget*
>(
nullptr));
127 std::stringstream sstr;
134 auto g1 = std::make_unique<gui2::grid>(1, 1);
137 add_widget(grid, std::move(g1),
"level 1", 0, 0);
140 auto g2 = std::make_unique<gui2::grid>(1, 1);
143 add_widget(*g1_ptr, std::move(g2),
"level 2", 0, 0);
Singleton class to manage game config file caching.
void add_define(const std::string &define)
Add a entry to preproc defines map.
static config_cache & instance()
Get reference to the singleton object.
void clear_defines()
Clear stored defines map to default values.
void connect_signal(const F &func, const queue_position position=back_child)
Adds a callback to the appropriate queue based on event type.
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
static const unsigned HORIZONTAL_GROW_SEND_TO_CLIENT
static const unsigned VERTICAL_GROW_SEND_TO_CLIENT
void set_child(std::unique_ptr< widget > widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size)
Sets a child in the grid.
BOOST_AUTO_TEST_CASE(test_fire_event)
static void validate_draw(std::stringstream &sstr)
static void validate_right_button_down(std::stringstream &sstr)
static void print(std::stringstream &sstr, const std::string &queue, const std::string &id)
void connect_queue(std::stringstream &sstr, gui2::widget &widget)
static std::string set_event_order()
static void connect_signals(std::stringstream &sstr, gui2::widget &widget)
static void add_widget(gui2::grid &grid, std::unique_ptr< gui2::widget > widget, const std::string &id, const unsigned row, const unsigned column)