CMakeLists.txt: --------------------------- Until now build with boost::filesystem was completely broken, since cmake exported definitions with wrong name prefixes, and nana always defaulted to internal filesystem implementation. After fixing the boost definitions, a number of errors came up due to incompatibility of boost::filesystem with nana and std filesystems. This commit tries to fix them all. filesystem.cpp, filesystem.hpp, filebox.cpp: -------------------------------------------- boost::filesystem doesn't have a file_time_type, so declared it in the filesystem.hpp header. boost::filesystem::last_write_time has a return type std::time_t unlike the other two implementations of this function in nana and std, so added ifdef to convert the result to file_time_type. fixed build on gcc-4.9, since it doesn't have a std::put_time function, included <nana/stdc++.hpp> in that case. boost::filesystem::file_type types have different names than std::experimental::filesystem::file_type types, fixed it by creating an enum class file_type with the same type names as in std::experimental::filesystem::file_type. This fix requires static_cast from functions results to internal file_type, since boost file_type and std file_type a different enum classes. changed switch to if, bacause old gcc fails on converting enum class members to int. stdc++.hpp: ----------- added ifndef guards to prevent errors on multiple includes of this header. wvl.cpp: -------- added boost/chrono.hpp include for the cases when std::thread is not available. travis: ------- added boost system, thread, chrono libs to install, they are needed for the nana-demo to compile.
		
			
				
	
	
		
			105 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
 *	Nana GUI Library Definition
 | 
						|
 *	Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
 | 
						|
 *
 | 
						|
 *	Distributed under the Boost Software License, Version 1.0. 
 | 
						|
 *	(See accompanying file LICENSE_1_0.txt or copy at 
 | 
						|
 *	http://www.boost.org/LICENSE_1_0.txt)
 | 
						|
 *
 | 
						|
 *	@file: nana/gui/wvl.cpp
 | 
						|
 *	@description:
 | 
						|
 *		the file contains the files required for running of Nana.GUI 
 | 
						|
 */
 | 
						|
 | 
						|
#include <nana/gui/wvl.hpp>
 | 
						|
#include <nana/gui/detail/bedrock.hpp>
 | 
						|
#include <nana/std_thread.hpp>
 | 
						|
#include <iostream> 
 | 
						|
 | 
						|
#ifdef STD_THREAD_NOT_SUPPORTED
 | 
						|
#	include <boost/chrono.hpp>
 | 
						|
#else
 | 
						|
#	include <chrono>
 | 
						|
#endif
 | 
						|
 | 
						|
//#define NANA_AUTOMATIC_GUI_TESTING
 | 
						|
namespace nana
 | 
						|
{
 | 
						|
	namespace detail
 | 
						|
	{
 | 
						|
		void form_loader_private::insert_form(::nana::widget* p)
 | 
						|
		{
 | 
						|
			bedrock::instance().manage_form_loader(reinterpret_cast<basic_window*>(p->handle()), true);
 | 
						|
		}
 | 
						|
	}
 | 
						|
 | 
						|
#ifdef NANA_AUTOMATIC_GUI_TESTING
 | 
						|
 | 
						|
	void click(widget& w)
 | 
						|
	{
 | 
						|
		std::cout << "Automatically clicking widget "<<w.caption()<<":\n";
 | 
						|
		arg_click arg;
 | 
						|
		arg.window_handle = w.handle();
 | 
						|
		w.events().click.emit(arg, w.handle());
 | 
						|
	}
 | 
						|
 | 
						|
	/// in seconds
 | 
						|
	void Wait(unsigned wait)
 | 
						|
	{
 | 
						|
		if (!wait) return;
 | 
						|
		std::cout << "waiting " << wait << " sec...\n";
 | 
						|
#	ifdef STD_THREAD_NOT_SUPPORTED
 | 
						|
		boost::this_thread::sleep_for(boost::chrono::seconds{ wait });
 | 
						|
#	else
 | 
						|
		std::this_thread::sleep_for(std::chrono::seconds{ wait });
 | 
						|
#	endif
 | 
						|
	}
 | 
						|
 | 
						|
	void pump()
 | 
						|
	{
 | 
						|
		internal_scope_guard lock;
 | 
						|
		detail::bedrock::instance().pump_event(nullptr, false);
 | 
						|
	}
 | 
						|
 | 
						|
 | 
						|
	void exec(
 | 
						|
		unsigned wait,         // = 1,      ///< for the GUI to be constructed, in seconds  
 | 
						|
		unsigned wait_end,     // = 1,      ///< for the GUI to be destructed, in seconds
 | 
						|
		std::function<void()>f // = {}      ///< emit events to mimics user actions and may asert results
 | 
						|
	)
 | 
						|
	{
 | 
						|
			
 | 
						|
	    std::cout << "Will wait " << wait << " sec...\n";
 | 
						|
 | 
						|
	    std::thread t([wait, &f, wait_end]()
 | 
						|
			{ 
 | 
						|
				Wait( wait );
 | 
						|
				std::cout << "running... \n"  ;
 | 
						|
				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 << "Now again ";
 | 
						|
				Wait(wait_end);
 | 
						|
				std::cout << "Done... Now API::exit all ...\n";
 | 
						|
				API::exit_all();   
 | 
						|
			});		
 | 
						|
 | 
						|
		pump();
 | 
						|
		if (t.joinable())
 | 
						|
			t.join();
 | 
						|
	}
 | 
						|
#else
 | 
						|
	void exec()
 | 
						|
	{
 | 
						|
		internal_scope_guard lock;
 | 
						|
		detail::bedrock::instance().pump_event(nullptr, false);
 | 
						|
	}
 | 
						|
#endif
 | 
						|
}//end namespace nana
 |