exit_all
This commit is contained in:
@@ -143,9 +143,17 @@ namespace API
|
|||||||
};
|
};
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
|
|
||||||
void exit();
|
void exit(); ///< close all windows in current thread
|
||||||
|
void exit_all(); ///< close all windows
|
||||||
|
|
||||||
std::string transform_shortkey_text(std::string text, wchar_t &shortkey, std::string::size_type *skpos);
|
/// @brief Searchs whether the text contains a '&' and removes the character for transforming.
|
||||||
|
/// If the text contains more than one '&' charachers, the others are ignored. e.g
|
||||||
|
/// text = "&&a&bcd&ef", the result should be "&abcdef", shortkey = 'b', and pos = 2.
|
||||||
|
std::string transform_shortkey_text
|
||||||
|
( std::string text, ///< the text is transformed
|
||||||
|
wchar_t &shortkey, ///< the character which indicates a short key.
|
||||||
|
std::string::size_type *skpos ///< retrives the shortkey position if it is not a null_ptr;
|
||||||
|
);
|
||||||
bool register_shortkey(window, unsigned long);
|
bool register_shortkey(window, unsigned long);
|
||||||
void unregister_shortkey(window);
|
void unregister_shortkey(window);
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "msgbox.hpp"
|
#include "msgbox.hpp"
|
||||||
#include "place.hpp"
|
#include "place.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ namespace API
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
//exit
|
|
||||||
//close all windows in current thread
|
//close all windows in current thread
|
||||||
void exit()
|
void exit()
|
||||||
{
|
{
|
||||||
@@ -363,6 +363,42 @@ namespace API
|
|||||||
interface_type::close_window(i);
|
interface_type::close_window(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//close all windows
|
||||||
|
void exit_all()
|
||||||
|
{
|
||||||
|
std::vector<basic_window*> v;
|
||||||
|
|
||||||
|
internal_scope_guard lock;
|
||||||
|
restrict::wd_manager().all_handles(v);
|
||||||
|
if (v.size())
|
||||||
|
{
|
||||||
|
std::vector<native_window_type> roots;
|
||||||
|
native_window_type root = nullptr;
|
||||||
|
//unsigned tid = nana::system::this_thread_id();
|
||||||
|
for (auto wd : v)
|
||||||
|
{
|
||||||
|
if (/*(wd->thread_id == tid) &&*/ (wd->root != root))
|
||||||
|
{
|
||||||
|
root = wd->root;
|
||||||
|
bool exists = false;
|
||||||
|
for (auto i = roots.cbegin(); i != roots.cend(); ++i)
|
||||||
|
{
|
||||||
|
if (*i == root)
|
||||||
|
{
|
||||||
|
exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
roots.push_back(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto i : roots)
|
||||||
|
interface_type::close_window(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//transform_shortkey_text
|
//transform_shortkey_text
|
||||||
//@brief: This function searchs whether the text contains a '&' and removes the character for transforming.
|
//@brief: This function searchs whether the text contains a '&' and removes the character for transforming.
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ namespace nana
|
|||||||
|
|
||||||
void click(widget& w)
|
void click(widget& w)
|
||||||
{
|
{
|
||||||
|
std::cout << "Automatically clicking widget "<<w.caption()<<":\n";
|
||||||
arg_click arg;
|
arg_click arg;
|
||||||
arg.window_handle = w.handle();
|
arg.window_handle = w.handle();
|
||||||
w.events().click.emit(arg);
|
w.events().click.emit(arg);
|
||||||
@@ -37,8 +38,9 @@ namespace nana
|
|||||||
/// in seconds
|
/// in seconds
|
||||||
void Wait(unsigned wait)
|
void Wait(unsigned wait)
|
||||||
{
|
{
|
||||||
if (wait)
|
if (!wait) return;
|
||||||
std::this_thread::sleep_for(std::chrono::seconds{ wait });
|
std::cout << "waiting " << wait << " sec...\n";
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds{ wait });
|
||||||
}
|
}
|
||||||
|
|
||||||
void pump()
|
void pump()
|
||||||
@@ -57,23 +59,31 @@ namespace nana
|
|||||||
//if (!wait)
|
//if (!wait)
|
||||||
// wait = 1;
|
// wait = 1;
|
||||||
//if (!main_form && !f)
|
//if (!main_form && !f)
|
||||||
// f = []() {API::exit(); };
|
// f = []() {API::exit_all(); };
|
||||||
|
|
||||||
std::cout << "Will wait " << wait << " sec...\n";
|
std::cout << "Will wait " << wait << " sec...\n";
|
||||||
std::thread t([wait, &f, wait_end, main_form]()
|
std::thread t([wait, &f, wait_end, main_form]()
|
||||||
{ if (wait)
|
{ if (wait)
|
||||||
{
|
{
|
||||||
std::cout << "Waiting " << wait << " sec...\n";
|
|
||||||
Wait( wait );
|
Wait( wait );
|
||||||
std::cout << "running... \n" ;
|
std::cout << "running... \n" ;
|
||||||
if (f) f();
|
if (f)
|
||||||
|
{
|
||||||
|
f();
|
||||||
|
std::cout << "\nCongratulations, this was not trivial !" << std::endl;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
std::cout << "\nJust a trivial test." << std::endl;
|
||||||
|
}
|
||||||
std::cout << "Done... \n";
|
std::cout << "Done... \n";
|
||||||
std::cout << "Now waiting anothers " << wait_end << " sec...\n";
|
std::cout << "Now again ";
|
||||||
Wait(wait_end);
|
Wait(wait_end);
|
||||||
std::cout << "Done... \n";
|
std::cout << "Done... Now closing the main form...\n";
|
||||||
if (main_form)
|
/*if (main_form)
|
||||||
main_form->close();
|
main_form->close();*/
|
||||||
API::exit(); // why not works?
|
std::cout << "Closed... Now API::exit ...\n";
|
||||||
|
API::exit_all(); // why not works?
|
||||||
|
std::cout << "Done... Upps - this had not to appear !! \n";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pump();
|
pump();
|
||||||
|
|||||||
Reference in New Issue
Block a user