author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年11月09日 14:11:57 +0100 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年11月09日 14:11:57 +0100 |
commit | 018813c6e5f2b1d7e1809cde0ebae790d57aa3fd (patch) | |
tree | 09f2712a8572eeb9de45dc63df5c45d43baa6007 /agg-plot | |
parent | 096abfe85cc5b961e943fa5970aac4f0dbbda5ab (diff) | |
download | gsl-shell-018813c6e5f2b1d7e1809cde0ebae790d57aa3fd.tar.gz |
-rw-r--r-- | agg-plot/lua-plot.cpp | 23 | ||||
-rw-r--r-- | agg-plot/window.cpp | 31 | ||||
-rw-r--r-- | agg-plot/window.h | 1 | ||||
-rw-r--r-- | agg-plot/window_hooks.h | 1 |
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp index 1999f7cc..42961d46 100644 --- a/agg-plot/lua-plot.cpp +++ b/agg-plot/lua-plot.cpp @@ -494,11 +494,24 @@ plot_flush (lua_State *L) int plot_show (lua_State *L) { - lua_pushcfunction (L, app_window_hooks->attach); - (*app_window_hooks->create)(L); - lua_pushvalue (L, 1); - lua_pushstring (L, ""); - lua_call (L, 3, 0); + /* create a window without shouwing it */ + lua_pushcfunction(L, app_window_hooks->create); + lua_pushstring(L, "."); + lua_pushboolean(L, 1); + lua_call(L, 2, 1); + + /* attach the plot to the window */ + lua_pushcfunction(L, app_window_hooks->attach); + lua_pushvalue(L, 2); + lua_pushvalue(L, 1); + lua_pushstring(L, ""); + lua_call(L, 3, 0); + + /* show the window */ + lua_pushcfunction(L, app_window_hooks->show); + lua_pushvalue(L, 2); + lua_call(L, 1, 0); + return 0; } diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp index 3868de85..3114f430 100644 --- a/agg-plot/window.cpp +++ b/agg-plot/window.cpp @@ -19,7 +19,6 @@ extern "C" { __BEGIN_DECLS -static int window_show (lua_State *L); static int window_free (lua_State *L); static int window_split (lua_State *L); static int window_save_svg (lua_State *L); @@ -406,17 +405,22 @@ void window::start (lua_State *L, gslshell::ret_status& st) } } -int -window_new (lua_State *L) +static void +show_window(lua_State* L, window* win) { - window *win = push_new_object<window>(L, GS_WINDOW, global_state); - const char *spec = lua_tostring (L, 1); - gslshell::ret_status st; win->start(L, st); if (st.error_msg()) - return luaL_error (L, "%s (reported during %s)", st.error_msg(), st.context()); + luaL_error (L, "%s (reported during %s)", st.error_msg(), st.context()); +} + +int +window_new (lua_State *L) +{ + window *win = push_new_object<window>(L, GS_WINDOW, global_state); + const char *spec = lua_tostring (L, 1); + int defer_show = lua_toboolean(L, 2); if (spec) { @@ -424,6 +428,11 @@ window_new (lua_State *L) return luaL_error(L, "invalid layout specification"); } + if (!defer_show) + { + show_window(L, win); + } + return 1; } @@ -431,13 +440,7 @@ int window_show (lua_State *L) { window *win = object_check<window>(L, 1, GS_WINDOW); - - gslshell::ret_status st; - win->start(L, st); - - if (st.error_msg()) - return luaL_error (L, "%s (reported during %s)", st.error_msg(), st.context()); - + show_window(L, win); return 0; } diff --git a/agg-plot/window.h b/agg-plot/window.h index c93d407f..63c26d3e 100644 --- a/agg-plot/window.h +++ b/agg-plot/window.h @@ -15,6 +15,7 @@ extern int window_save_slot_image (lua_State *L); extern int window_restore_slot_image (lua_State *L); extern int window_update (lua_State *L); extern int window_new (lua_State *L); +extern int window_show (lua_State *L); extern int window_attach (lua_State *L); extern int window_close (lua_State *L); extern int window_close_wait (lua_State *L); diff --git a/agg-plot/window_hooks.h b/agg-plot/window_hooks.h index 58c6ce33..180c4dcb 100644 --- a/agg-plot/window_hooks.h +++ b/agg-plot/window_hooks.h @@ -9,6 +9,7 @@ __BEGIN_DECLS struct window_hooks { int (*create)(lua_State* L); + int (*show)(lua_State* L); int (*attach)(lua_State* L); int (*update)(lua_State* L); int (*refresh)(lua_State* L); |