47 #include <type_traits> 56 #define ERR_LUA LOG_STREAM(err, log_scripting_lua) 79 int v = wp->
show(
true, 0);
102 throw std::invalid_argument(
"negative index");
104 int n = list->get_item_count();
107 throw std::invalid_argument(
"index out of range");
111 list->add_row(dummy);
114 w = list->get_row_grid(v - 1);
115 }
else if(
gui2::multi_page* multi_page = dynamic_cast<gui2::multi_page*>(w)) {
118 throw std::invalid_argument(
"negative index");
120 int n = multi_page->get_page_count();
123 throw std::invalid_argument(
"index out of range");
127 multi_page->add_page(dummy);
130 w = &multi_page->page_grid(v - 1);
131 }
else if(
gui2::tree_view* tree_view = dynamic_cast<gui2::tree_view*>(w)) {
136 throw std::invalid_argument(
"negative index");
140 throw std::invalid_argument(
"index out of range");
146 w = tvn.
find(m,
false);
152 throw std::invalid_argument(
"negative index");
154 int n = tree_view_node->count_children();
156 throw std::invalid_argument(
"index out of range");
158 w = &tree_view_node->get_child_at(v - 1);
162 w = tree_view_node->
find(m,
false);
168 throw std::invalid_argument(
"negative index");
170 int n = stacked_widget->get_layer_count();
172 throw std::invalid_argument(
"index out of range");
174 w = stacked_widget->get_layer_grid(v - 1);
177 w = stacked_widget->
find(m,
false);
182 throw std::invalid_argument(
"expected a string");
184 w = w->
find(m,
false);
187 throw std::invalid_argument(
"widget not found");
218 for(
int i = 0;
i < number; ++
i) {
238 list->remove_row(pos, number);
239 }
else if(
gui2::multi_page* multi_page = dynamic_cast<gui2::multi_page*>(w)) {
240 multi_page->remove_page(pos, number);
241 }
else if(
gui2::tree_view* tree_view = dynamic_cast<gui2::tree_view*>(w)) {
242 remove_treeview_node(tree_view->get_root_node(), pos, number);
244 remove_treeview_node(*tree_view_node, pos, number);
257 ERR_LUA <<
"widget was deleted\n";
262 ERR_LUA <<
"cannot find window in widget callback\n";
281 throw std::invalid_argument(
"the widget has no window assigned");
294 c->connect_click_handler(std::bind(&dialog_callback, L, wp,
"callback"));
295 }
else if( dynamic_cast<gui2::selectable_item*>(w)) {
297 }
else if(dynamic_cast<gui2::integer_selector*>(w)) {
299 }
else if(dynamic_cast<gui2::listbox*>(w)) {
301 }
else if(dynamic_cast<gui2::tree_view*>(w)) {
327 if(i < 1 || static_cast<unsigned>(i) > cv.size()) {
332 cv[i - 1].set_cfg(cfg);
345 wd->keyboard_capture(w);
366 static const std::map<std::string, string_map> data;
369 res = &twn->add_child(node_type, data, insert_pos);
371 res = &tw->get_root_node().add_child(node_type, data, insert_pos);
373 res = &
mp->add_page(node_type, insert_pos, data);
393 static const std::map<std::string, string_map> data;
396 res = &lb->add_row(data);
421 auto& lk = lua_kernel_base::get_lua_kernel<lua_kernel_base>(L);
422 lk.add_log(
"Adding widgets module...\n");
423 static luaL_Reg const gui_callbacks[] = {
435 {
nullptr,
nullptr },
#define lua_isnoneornil(L, n)
std::map< std::string, t_string > string_map
Key Type Default Description window_width unsigned 0 Width of the application window.
LUA_API int lua_gettop(lua_State *L)
Tmust inherit enable_lua_ptr<T>
#define lua_tointeger(L, i)
void lua_push(lua_State *L, const T &val)
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
Definitions for the interface to Wesnoth Markup Language (WML).
std::pair< tree_view_node::ptr_t, int > remove_node(tree_view_node *node)
Removes the given node as a child of its parent node.
std::size_t count_children() const
The number of children in this widget.
Main entry points of multiplayer mode.
LUALIB_API int luaL_argerror(lua_State *L, int arg, const char *extramsg)
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification_function &signal)
Connects a signal handler for getting a notification upon modification.
void remove_from_window_stack(window *window)
Removes a entry from the open_window_stack list.
This file contains the canvas object which is the part where the widgets draw (temporally) images on...
A tree view is a control that holds several items of the same or different types. ...
int show(const bool restore=true, const unsigned auto_close_timeout=0)
Shows the window.
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int arg)
tree_view_node & get_child_at(int index)
config luaW_checkconfig(lua_State *L, int index)
Converts an optional table or vconfig to a config object.
#define lua_tostring(L, i)
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUA_API int lua_isnumber(lua_State *L, int idx)
#define lua_call(L, n, r)
tree_view & get_tree_view()
A multi page is a control that contains several 'pages' of which only one is visible.
Standard logging facilities (interface).
std::unique_ptr< window > build(const builder_window::window_resolution &definition)
Builds a window.
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
A config object defines a single node in a WML file, with access to child nodes.
static map_location::DIRECTION n
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
base class of top level items, the only item which needs to store the final canvases to draw on...
std::vector< window * > open_window_stack
Keeps track of any open windows of any type (modal, non-modal, or tooltip) in the order in which they...
#define luaL_checkstring(L, n)