Merge branch 'hotfix-1.2' into prepare-utf8

This commit is contained in:
Jinhao 2015-12-04 23:44:11 +08:00
commit babcacd63d
28 changed files with 351 additions and 236 deletions

1
.gitignore vendored
View File

@ -40,3 +40,4 @@ CMakeCache.txt
CMakeFiles/ CMakeFiles/
cmake_install.cmake cmake_install.cmake
*.DS_Store *.DS_Store
.idea/

View File

@ -4,47 +4,16 @@
# Robert Hauck - Enable support for PNG/Freetype # Robert Hauck - Enable support for PNG/Freetype
# Qiangqiang Wu - Add biicode support # Qiangqiang Wu - Add biicode support
if(BIICODE)
# prepare BII_LIB_SRC
set(LIB_SRC ${BII_LIB_SRC})
foreach(cpp ${BII_LIB_SRC})
if(${cpp} MATCHES "/detail/(win32|linux_X11)/.+$")
list(APPEND trash_files ${cpp})
endif()
endforeach()
list(REMOVE_ITEM BII_LIB_SRC ${trash_files})
if(WIN32)
file(GLOB_RECURSE platform_files "*/detail/win32/*")
list(APPEND BII_LIB_SRC ${platform_files})
elseif(APPLE)
file(GLOB_RECURSE platform_files "*/detail/macos_X11/*")
list(APPEND BII_LIB_SRC ${platform_files})
elseif(UNIX)
file(GLOB_RECURSE platform_files "*/detail/linux_X11/*")
list(APPEND BII_LIB_SRC ${platform_files})
else()
message(FATAL_ERROR "Only Windows and Unix are supported for the moment (Mac OS is experimental)")
endif()
# set compile flags # set compile flags
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# we'll use the default config file so we can iliminate the following macro definitions
if(MSVC) # move this to the end ??
# More MSVC specific compilation flags if(BIICODE)
add_definitions(-D_SCL_SECURE_NO_WARNINGS) # prepare BII_LIB_SRC
add_definitions(-D_CRT_SECURE_NO_DEPRECATE) set(LIB_SRC ${BII_LIB_SRC})
if(MSVC14)
add_definitions(-DSTD_CODECVT_NOT_SUPPORTED)
else()
add_definitions(-DNOT_IMPLEMENTED_KEYWORD_noexcept)
endif()
endif()
add_biicode_targets() add_biicode_targets()
@ -54,69 +23,35 @@ endif()
project(nana) project(nana)
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
#Select platform automatically
if(WIN32)
add_definitions(-DNANA_WINDOWS)
add_definitions(-DPLATFORM_SPEC_HPP=<nana/detail/win32/platform_spec.hpp>)
if(MSVC14)
add_definitions(-DSTD_CODECVT_NOT_SUPPORTED)
else()
add_definitions(-DNOT_IMPLEMENTED_KEYWORD_noexcept)
endif()
#Test if it is MINGW
if(MINGW)
add_definitions(-DNANA_MINGW)
add_definitions(-DSTD_CODECVT_NOT_SUPPORTED)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.1")
option(NANA_THREAD_NOT_SUPPORTED "Use this flag if MinGW version is older than 4.8.1" ON)
endif()
endif()
if(NANA_THREAD_NOT_SUPPORTED)
add_definitions(-DSTD_THREAD_NOT_SUPPORTED)
endif()
endif()
endif()
if(APPLE)
add_definitions(-DNANA_MACOS)
add_definitions(-DNANA_X11)
add_definitions(-DPLATFORM_SPEC_HPP=<nana/detail/macos_X11/platform_spec.hpp>)
add_definitions(-DSTD_CODECVT_NOT_SUPPORTED)
include_directories(/opt/X11/include/)
elseif(UNIX)
add_definitions(-DNANA_LINUX)
add_definitions(-DNANA_X11)
add_definitions(-DPLATFORM_SPEC_HPP=<nana/detail/linux_X11/platform_spec.hpp>)
add_definitions(-DSTD_CODECVT_NOT_SUPPORTED)
endif()
#Global MSVC definitions #Global MSVC definitions
if(WIN32) if(WIN32)
if(MSVC) if(MSVC)
option(WIN32_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON) option(WIN32_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON)
# ??
if(WIN32_USE_MP) if(WIN32_USE_MP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif() endif()
# More MSVC specific compilation flags
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif(MSVC) endif(MSVC)
endif(WIN32) endif(WIN32)
#Unicode #Unicode
option(NANA_UNICODE "Use Unicode Character Set" ON) option(USE_UNICODE "Use Unicode Character Set")
if(NANA_UNICODE) if(USE_UNICODE)
add_definitions(-DNANA_UNICODE) add_definitions(-DNANA_UNICODE)
if(WIN32)
add_definitions(-DUNICODE -D_UNICODE)
endif()
endif() endif()
#Find PNG if(APPLE)
add_definitions(-DAPPLE)
include_directories(/opt/X11/include/)
elseif(UNIX)
add_definitions(-Dlinux)
endif()
if(UNIX) if(UNIX)
find_package(Freetype) find_package(Freetype)
if (FREETYPE_FOUND) if (FREETYPE_FOUND)
@ -124,30 +59,42 @@ if(UNIX)
endif() endif()
endif() endif()
option(NANA_ENABLE_PNG "Enable the use of PNG" ON) if(WIN32)
if(NANA_ENABLE_PNG) add_definitions(-DWIN32)
add_definitions(-DNANA_ENABLE_PNG) if(MINGW)
add_definitions(-DMINGW)
endif()
endif()
option(NANA_LIBPNG "Use the included libpng" ON) #Find PNG
if(NANA_LIBPNG) option(ENABLE_PNG "Enable the use of PNG")
add_definitions(-DNANA_LIBPNG) option(LIBPNG_FROM_OS "Use libpng from operating system.")
else() if(ENABLE_PNG)
add_definitions(-DNANA_ENABLE_PNG)
if(LIBPNG_FROM_OS)
find_package(PNG) find_package(PNG)
if (PNG_FOUND) if (PNG_FOUND)
include_directories( ${PNG_INCLUDE_DIRS}) include_directories( ${PNG_INCLUDE_DIRS})
add_definitions(-DUSE_LIBPNG_FROM_OS)
endif()
endif()
endif()
#Find JPEG
option(ENABLE_JPEG "Enable the use of JPEG")
option(LIBJPEG_FROM_OS "Use libjpeg from operating system.")
if(ENABLE_JPEG)
add_definitions(-DNANA_ENABLE_JPEG)
if(LIBJPEG_FROM_OS)
find_package(JPEG)
if (JPEG_FOUND)
include_directories( ${JPEG_INCLUDE_DIRS})
add_definitions(-DUSE_LIBJPEG_FROM_OS)
endif() endif()
endif() endif()
endif() endif()
#Copy our new config.hpp (with removed defines)
execute_process(COMMAND ${CMAKE_COMMAND}
-E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/nana/)
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source) set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source)
set(NANA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) set(NANA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)

View File

@ -1,18 +0,0 @@
/*
* Nana Configuration
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 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/config.hpp
*/
#ifndef NANA_CONFIG_HPP
#define NANA_CONFIG_HPP
//All defines have been moved to the CMakelists.txt in the root directory.
#endif //NANA_CONFIG_HPP

View File

@ -3,7 +3,7 @@
#include <nana/deploy.hpp> #include <nana/deploy.hpp>
#include <nana/audio/detail/audio_stream.hpp> #include <nana/audio/detail/audio_stream.hpp>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_thread.hpp> #include <nana/std_thread.hpp>
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#include <nana/std_condition_variable.hpp> #include <nana/std_condition_variable.hpp>

View File

@ -1,3 +1,17 @@
/**
* The charset Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 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/charset.hpp
*
*
*/
#ifndef NANA_CHARSET_HPP #ifndef NANA_CHARSET_HPP
#define NANA_CHARSET_HPP #define NANA_CHARSET_HPP
#include <string> #include <string>
@ -13,6 +27,7 @@ namespace nana
{ {
class charset_encoding_interface; class charset_encoding_interface;
} }
/// An intelligent charset class for character code conversion. /// An intelligent charset class for character code conversion.
class charset class charset
{ {

View File

@ -1,7 +1,7 @@
/* /**
* Nana Configuration * Nana Configuration
* Nana C++ Library(http://www.nanapro.org) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -13,15 +13,21 @@
#ifndef NANA_CONFIG_HPP #ifndef NANA_CONFIG_HPP
#define NANA_CONFIG_HPP #define NANA_CONFIG_HPP
// Select platform ......
// Windows:
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#define NANA_WINDOWS 1
// compilers in Windows...
// MSVC++ versions
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define _SCL_SECURE_NO_WARNINGS #define _SCL_SECURE_NO_WARNNGS
#define _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE
#pragma warning(disable : 4996) #pragma warning(disable : 4996)
#if (_MSC_VER < 1900)
// is this a good idea?
#define NOT_IMPLEMENTED_KEYWORD_noexcept
#endif // _MSC_VER < 1900
#if (_MSC_VER == 1900) #if (_MSC_VER == 1900)
// google: break any code that tries to use codecvt<char16_t> or codecvt<char32_t>. // google: break any code that tries to use codecvt<char16_t> or codecvt<char32_t>.
// google: It appears the C++ libs haven't been compiled with native char16_t/char32_t support. // google: It appears the C++ libs haven't been compiled with native char16_t/char32_t support.
@ -32,38 +38,106 @@
#endif // _MSC_VER == 1900 #endif // _MSC_VER == 1900
#endif // _MSVC #endif // _MSVC
//Select platform automatically // MINGW ...
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) #if defined(__MINGW32__) || defined(__MINGW64__) || defined(MINGW)
//Windows:
#define NANA_WINDOWS 1
//Test if it is MINGW
#if defined(__MINGW32__) || defined(__MINGW64__)
#define NANA_MINGW #define NANA_MINGW
#define STD_CODECVT_NOT_SUPPORTED //#define STD_THREAD_NOT_SUPPORTED // don't works? why? where __GNUC__, etc. are set? by CLion ??
#if (__GNUC__ == 4) && ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 1))
//Use this flag if MinGW version is older than 4.8.1 //Use this flag if MinGW version is older than 4.8.1
#if ((__GNUC__ == 4) && ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 2)))
// don't works? why? where __GNUC__, etc. are set? by CLion ??
// ??
#define UNDEFINED_to_string
// https://github.com/meganz/mingw-std-threads
#define STD_THREAD_NOT_SUPPORTED #define STD_THREAD_NOT_SUPPORTED
#define USE_github_com_meganz_mingw_std_threads
#endif #endif
#endif
#endif // MINGW
// end Windows
// MacOS: who define APPLE ??
//#define APPLE
#elif defined(APPLE)
#define NANA_MACOS 1
#define NANA_X11 1
// how to add this: include_directories(/opt/X11/include/)
// end MacOS
// Linux: (not sure about __GNU__ ??)
#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) #elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC)
//Linux:
#define NANA_LINUX 1 #define NANA_LINUX 1
#define NANA_X11 1 #define NANA_X11 1
#define STD_CODECVT_NOT_SUPPORTED // end Linux
#else #else
# static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)"); # static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
#endif #endif // Select platform
#if defined(NANA_MINGW) || defined(NANA_LINUX) #if defined(NANA_LINUX) || defined(NANA_MACOS)
#undef NANA_WINDOWS
#endif
// End Select platform ......
// compilers ...
// temp
//#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED // don't works?
//#define STD_CODECVT_NOT_SUPPORTED
// GCC ...
#if defined(__GNU__)
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) && (__GNUC_PATCHLEVEL__ <= 1) #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) && (__GNUC_PATCHLEVEL__ <= 1)
// don't works?
//GCC 4.7.0 does not implement the <codecvt> and codecvt_utfx classes ??
#define STD_CODECVT_NOT_SUPPORTED
//Some functions which are specified in 21.5 Numeric conversions in Strings library have not yet implemented //Some functions which are specified in 21.5 Numeric conversions in Strings library have not yet implemented
//Implement workarounds for GCC/MinGW which version is below 4.8.2
#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED #define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED
#endif #endif
#endif #endif // GCC
// End compilers ...
// Here defines some flags that tell Nana what features will be supported. // Here defines some flags that tell Nana what features will be supported.
///////////////////
//Support for PNG
// Define the NANA_ENABLE_PNG to enable the support of PNG.
//
//#define NANA_ENABLE_PNG //!
//#define USE_LIBPNG_FROM_OS // Un-Comment it to use libpng from operating system.
#if defined(NANA_ENABLE_PNG)
#if not defined(USE_LIBPNG_FROM_OS)
#define NANA_LIBPNG
#endif
#endif
///////////////////
//Support for JPEG
// Define the NANA_ENABLE_JPEG to enable the support of JPEG.
//
//#define NANA_ENABLE_JPEG //!
//#define USE_LIBJPEG_FROM_OS // Un-Comment it to use libjpeg from operating system.
#if defined(NANA_ENABLE_JPEG)
#if not defined(USE_LIBJPEG_FROM_OS)
#define NANA_LIBJPEG
#endif
#endif
// always define NANA_UNICODE ?? it will be deprecated ?.
#ifndef NANA_UNICODE
#define NANA_UNICODE #define NANA_UNICODE
#endif
#if defined(NANA_UNICODE) && defined(NANA_WINDOWS) #if defined(NANA_UNICODE) && defined(NANA_WINDOWS)
#ifndef _UNICODE #ifndef _UNICODE
@ -75,23 +149,5 @@
#endif #endif
#endif #endif
///////////////////
//Support for PNG
// Define the NANA_ENABLE_PNG to enable the support of PNG.
//
//#define NANA_ENABLE_PNG //!
#if defined(NANA_ENABLE_PNG)
#define NANA_LIBPNG //Comment it to use libpng from operating system.
#endif
///////////////////
//Support for JPEG
// Define the NANA_ENABLE_JPEG to enable the support of JPEG.
//
//#define NANA_ENABLE_JPEG //!
#if defined(NANA_ENABLE_JPEG)
#define NANA_LIBJPEG //Comment this whole line to use libjpeg from operating system.
#endif
#endif //NANA_CONFIG_HPP #endif //NANA_CONFIG_HPP

View File

@ -19,9 +19,7 @@
#include <nana/config.hpp> #include <nana/config.hpp>
#include <nana/charset.hpp> #include <nana/charset.hpp>
#if defined(NANA_LINUX) || defined(NANA_MACOS)
#undef NANA_WINDOWS
#endif
//Implement workarounds for GCC/MinGW which version is below 4.8.2 //Implement workarounds for GCC/MinGW which version is below 4.8.2
#if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED) #if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED)

View File

@ -13,6 +13,8 @@
* This file should not be included by any header files. * This file should not be included by any header files.
*/ */
#if defined(NANA_LINUX) || defined(NANA_MACOS)
#ifndef NANA_DETAIL_PLATFORM_SPEC_HPP #ifndef NANA_DETAIL_PLATFORM_SPEC_HPP
#define NANA_DETAIL_PLATFORM_SPEC_HPP #define NANA_DETAIL_PLATFORM_SPEC_HPP
@ -323,5 +325,9 @@ namespace detail
}//end namespace nana }//end namespace nana
// .h ward
#endif
//#if defined(NANA_LINUX) || defined(NANA_MACOS)
#endif #endif

View File

@ -12,6 +12,7 @@
* This file provides basis class and data structrue that required by nana * This file provides basis class and data structrue that required by nana
* This file should not be included by any header files. * This file should not be included by any header files.
*/ */
#if defined(NANA_WINDOWS)
#ifndef NANA_DETAIL_PLATFORM_SPEC_HPP #ifndef NANA_DETAIL_PLATFORM_SPEC_HPP
#define NANA_DETAIL_PLATFORM_SPEC_HPP #define NANA_DETAIL_PLATFORM_SPEC_HPP
@ -198,4 +199,9 @@ namespace detail
}//end namespace detail }//end namespace detail
}//end namespace nana }//end namespace nana
// .h ward
#endif
//#if defined(NANA_WINDOWS)
#endif #endif

View File

@ -5,7 +5,7 @@
#include <unordered_set> #include <unordered_set>
#include <unordered_map> #include <unordered_map>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#else #else
#include <mutex> #include <mutex>

View File

@ -17,7 +17,7 @@
#include <nana/traits.hpp> #include <nana/traits.hpp>
#include <nana/config.hpp> #include <nana/config.hpp>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#else #else
#include <mutex> #include <mutex>

View File

@ -106,7 +106,7 @@ namespace detail
//@brief: Delete window handle, the handle type must be a root and a frame. //@brief: Delete window handle, the handle type must be a root and a frame.
void destroy_handle(core_window_t*); void destroy_handle(core_window_t*);
void default_icon(const paint::image& small_icon, const paint::image& big_icon); void default_icon(const paint::image& _small_icon, const paint::image& big_icon);
void icon(core_window_t*, const paint::image& small_icon, const paint::image& big_icon); void icon(core_window_t*, const paint::image& small_icon, const paint::image& big_icon);
//show //show

View File

@ -40,7 +40,9 @@ namespace nana
: arg_tabbar<T>({wdg, v}) : arg_tabbar<T>({wdg, v})
{} {}
bool remove = true; bool remove = true; ///< determines whether to remove the item
bool close_attach_window = true; ///< determines whether to close the attached window. It is ignored if remove is false
}; };
namespace drawerbase namespace drawerbase
@ -51,11 +53,11 @@ namespace nana
struct tabbar_events struct tabbar_events
: public general_events : public general_events
{ {
typedef T value_type; using value_type = T;
basic_event<arg_tabbar<value_type>> added; basic_event<arg_tabbar<value_type>> added;
basic_event<arg_tabbar<value_type>> activated; basic_event<arg_tabbar<value_type>> activated;
basic_event<arg_tabbar<value_type>> removed; basic_event<arg_tabbar_removed<value_type>> removed;
}; };
class event_agent_interface class event_agent_interface
@ -64,7 +66,7 @@ namespace nana
virtual ~event_agent_interface() = default; virtual ~event_agent_interface() = default;
virtual void added(std::size_t) = 0; virtual void added(std::size_t) = 0;
virtual void activated(std::size_t) = 0; virtual void activated(std::size_t) = 0;
virtual bool removed(std::size_t) = 0; virtual bool removed(std::size_t, bool & close_attached) = 0;
}; };
class item_renderer class item_renderer
@ -98,7 +100,7 @@ namespace nana
: public event_agent_interface : public event_agent_interface
{ {
public: public:
typedef ::nana::arg_tabbar<T> arg_tabbar; using arg_tabbar = ::nana::arg_tabbar<T>;
event_agent(::nana::tabbar<T>& tb, DrawerTrigger & dtr) event_agent(::nana::tabbar<T>& tb, DrawerTrigger & dtr)
: tabbar_(tb), drawer_trigger_(dtr) : tabbar_(tb), drawer_trigger_(dtr)
@ -119,14 +121,16 @@ namespace nana
tabbar_.events().activated.emit(arg_tabbar({ tabbar_, tabbar_[pos]})); tabbar_.events().activated.emit(arg_tabbar({ tabbar_, tabbar_[pos]}));
} }
bool removed(std::size_t pos) override bool removed(std::size_t pos, bool & close_attach) override
{ {
if (pos != npos) if (pos != npos)
{ {
::nana::arg_tabbar_removed<T> arg(tabbar_, tabbar_[pos]); ::nana::arg_tabbar_removed<T> arg(tabbar_, tabbar_[pos]);
tabbar_.events().removed.emit(arg); tabbar_.events().removed.emit(arg);
close_attach = arg.close_attach_window;
return arg.remove; return arg.remove;
} }
close_attach = true;
return true; return true;
} }
private: private:
@ -157,10 +161,11 @@ namespace nana
const pat::cloneable<item_renderer> & ext_renderer() const; const pat::cloneable<item_renderer> & ext_renderer() const;
void ext_renderer(const pat::cloneable<item_renderer>&); void ext_renderer(const pat::cloneable<item_renderer>&);
void set_event_agent(event_agent_interface*); void set_event_agent(event_agent_interface*);
void push_back(const nana::string&, const nana::any&); void insert(std::size_t, nana::string&&, nana::any&&);
std::size_t length() const; std::size_t length() const;
bool close_fly(bool); bool close_fly(bool);
void relate(size_t, window); void attach(std::size_t, window);
void erase(std::size_t);
void tab_color(std::size_t, bool is_bgcolor, const ::nana::color&); void tab_color(std::size_t, bool is_bgcolor, const ::nana::color&);
void tab_image(size_t, const nana::paint::image&); void tab_image(size_t, const nana::paint::image&);
void text(std::size_t, const nana::string&); void text(std::size_t, const nana::string&);
@ -287,16 +292,57 @@ namespace nana
return this->get_drawer_trigger().length(); return this->get_drawer_trigger().length();
} }
void push_back(const nana::string& text) /// Append a new item. void append(const std::string& text, window attach_wd, value_type value = {})
{ {
auto & t = this->get_drawer_trigger(); this->append(static_cast<std::wstring>(nana::charset(text, nana::unicode::utf8)), attach_wd);
t.push_back(text, value_type()); }
void append(const std::wstring& text, window attach_wd, value_type value = {})
{
this->get_drawer_trigger().insert(::nana::npos, std::wstring(text), std::move(value));
if (attach_wd)
{
auto pos = this->get_drawer_trigger().length();
relate(pos, attach_wd);
}
API::update_window(*this); API::update_window(*this);
} }
void push_back(nana::string text) /// Append a new item.
{
this->get_drawer_trigger().insert(::nana::npos, std::move(text), value_type());
API::update_window(*this);
}
void insert(std::size_t pos, const std::string& text, const value_type& value = {})
{
this->insert(pos, static_cast<std::wstring>(nana::charset(text, nana::unicode::utf8)), value);
}
void insert(std::size_t pos, const std::wstring& text, const value_type& value = {})
{
if (pos > length())
throw std::out_of_range("tabbar::insert invalid position");
this->get_drawer_trigger().insert(pos, std::wstring(text), value_type(value));
API::update_window(*this);
}
//deprecated from 1.2.1, removed from 1.3
void relate(std::size_t pos, window wd) /// Binds a window to an item specified by pos, if the item is selected, shows the window, otherwise, hides it. void relate(std::size_t pos, window wd) /// Binds a window to an item specified by pos, if the item is selected, shows the window, otherwise, hides it.
{ {
this->get_drawer_trigger().relate(pos, wd); this->get_drawer_trigger().attach(pos, wd);
}
void attach(std::size_t pos, window wd)
{
this->get_drawer_trigger().attach(pos, wd);
}
void erase(std::size_t pos)
{
this->get_drawer_trigger().erase(pos);
} }
void tab_bgcolor(std::size_t i, const ::nana::color& clr) void tab_bgcolor(std::size_t i, const ::nana::color& clr)

View File

@ -3,10 +3,14 @@
#include <nana/config.hpp> #include <nana/config.hpp>
#if defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#if defined(USE_github_com_meganz_mingw_std_threads)
#include <mingw.condition_variable.h>
#else
#include <boost/thread/condition_variable.hpp> #include <boost/thread/condition_variable.hpp>
namespace std namespace std
{ {
typedef boost::condition_variable condition_variable; typedef boost::condition_variable condition_variable;
} }
#endif #endif // (USE_github_com_meganz_mingw_std_threads)
#endif // (STD_THREAD_NOT_SUPPORTED)
#endif // NANA_STD_CONDITION_VARIABLE_HPP #endif // NANA_STD_CONDITION_VARIABLE_HPP

View File

@ -3,6 +3,20 @@
#include <nana/config.hpp> #include <nana/config.hpp>
#if defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#if defined(USE_github_com_meganz_mingw_std_threads)
#include <windows.h>
#include <mutex>
#include <condition_variable>
#include <thread>
#include <pthread.h>
#include <errno.h>
#include <cstdio>
// http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno.h#L53
#define EPROTO 71 /* Protocol error */
#include <mingw.thread.h>
#include <mingw.mutex.h>
#else
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp> #include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/locks.hpp> #include <boost/thread/locks.hpp>
@ -18,5 +32,6 @@ namespace std
typedef boost::mutex mutex; typedef boost::mutex mutex;
typedef boost::recursive_mutex recursive_mutex; typedef boost::recursive_mutex recursive_mutex;
} }
#endif #endif // (USE_github_com_meganz_mingw_std_threads)
#endif // (STD_THREAD_NOT_SUPPORTED)
#endif // NANA_STD_MUTEX_HPP #endif // NANA_STD_MUTEX_HPP

View File

@ -3,11 +3,15 @@
#include <nana/config.hpp> #include <nana/config.hpp>
#if defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#if defined(USE_github_com_meganz_mingw_std_threads)
#include <mingw.thread.h>
#else
#include <boost/thread.hpp> #include <boost/thread.hpp>
namespace std namespace std
{ {
typedef boost::thread thread; typedef boost::thread thread;
} }
#endif #endif // (USE_github_com_meganz_mingw_std_threads)
#endif // (STD_THREAD_NOT_SUPPORTED)
#endif // NANA_STD_THREAD_HPP #endif // NANA_STD_THREAD_HPP

View File

@ -61,6 +61,13 @@ namespace std
*pos = (std::size_t)(end - sptr); *pos = (std::size_t)(end - sptr);
return ((int)result); return ((int)result);
} }
using ::strtof;
using ::strtold;
using ::wcstold;
using ::strtoll;
using ::wcstoll;
using ::strtoull;
using ::wcstoull;
float stof(const std::string& str, std::size_t * pos) float stof(const std::string& str, std::size_t * pos)
{ {

View File

@ -13,6 +13,7 @@
* *
* http://standards.freedesktop.org/clipboards-spec/clipboards-0.1.txt * http://standards.freedesktop.org/clipboards-spec/clipboards-0.1.txt
*/ */
#include <nana/detail/platform_spec_selector.hpp> #include <nana/detail/platform_spec_selector.hpp>
#include <X11/Xlocale.h> #include <X11/Xlocale.h>
#include <locale> #include <locale>

View File

@ -11,6 +11,7 @@
* *
* This file provides basis class and data structrue that required by nana * This file provides basis class and data structrue that required by nana
*/ */
#include <nana/detail/platform_spec_selector.hpp> #include <nana/detail/platform_spec_selector.hpp>
#include <shellapi.h> #include <shellapi.h>
#include <stdexcept> #include <stdexcept>

View File

@ -21,7 +21,7 @@
#include <map> #include <map>
#include <algorithm> #include <algorithm>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_thread.hpp> #include <nana/std_thread.hpp>
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#include <nana/std_condition_variable.hpp> #include <nana/std_condition_variable.hpp>
@ -29,7 +29,7 @@
#include <mutex> #include <mutex>
#include <condition_variable> #include <condition_variable>
#include <thread> #include <thread>
#endif //NANA_MINGW #endif // STD_THREAD_NOT_SUPPORTED
namespace nana namespace nana
{ {

View File

@ -14,7 +14,7 @@
#include <nana/gui/detail/native_window_interface.hpp> #include <nana/gui/detail/native_window_interface.hpp>
#include <nana/gui/screen.hpp> #include <nana/gui/screen.hpp>
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#else #else
#include <mutex> #include <mutex>

View File

@ -463,10 +463,10 @@ namespace detail
} }
} }
void window_manager::default_icon(const nana::paint::image& small_icon, const nana::paint::image& big_icon) void window_manager::default_icon(const nana::paint::image& _small, const nana::paint::image& big)
{ {
impl_->default_icon_big = big_icon; impl_->default_icon_big = big;
impl_->default_icon_small = small_icon; impl_->default_icon_small = _small;
} }
void window_manager::icon(core_window_t* wd, const paint::image& small_icon, const paint::image& big_icon) void window_manager::icon(core_window_t* wd, const paint::image& small_icon, const paint::image& big_icon)

View File

@ -20,7 +20,7 @@
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#else #else
#include <mutex> #include <mutex>

View File

@ -95,13 +95,13 @@ namespace nana
std::string pos_str() const std::string pos_str() const
{ {
#ifdef NANA_MINGW #ifdef UNDEFINED_to_string
std::stringstream ss; std::stringstream ss;
ss<<pos(); ss<<pos();
return ss.str(); return ss.str();
#else #else
return std::to_string(pos()); return std::to_string(pos());
#endif // NANA_MINGW #endif // UNDEFINED_to_string
} }
token read() token read()

View File

@ -19,7 +19,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#else #else
#include <mutex> #include <mutex>

View File

@ -30,6 +30,12 @@ namespace nana
::nana::color bgcolor; ::nana::color bgcolor;
::nana::color fgcolor; ::nana::color fgcolor;
item_t() = default;
item_t(nana::string&& text, any && value)
: text(std::move(text)), value(std::move(value))
{}
}; };
class def_renderer class def_renderer
@ -414,13 +420,13 @@ namespace nana
evt_agent_ = evt; evt_agent_ = evt;
} }
void push_back(const nana::string& text, const nana::any & value) void insert(std::size_t pos, nana::string&& text, nana::any&& value)
{ {
item_t m; if (pos >= list_.size())
m.text = text; pos = list_.size();
m.value = value;
list_.push_back(m); list_.emplace(iterator_at(pos), std::move(text), std::move(value));
activate(static_cast<size_t>(list_.size() - 1)); this->activate(pos);
render(); render();
} }
@ -433,8 +439,12 @@ namespace nana
{ {
if(pos < list_.size()) if(pos < list_.size())
{ {
if ((nullptr == evt_agent_) || evt_agent_->removed(pos)) bool close_attach = true;
if ((nullptr == evt_agent_) || evt_agent_->removed(pos, close_attach))
{ {
if (close_attach)
API::close_window(iterator_at(pos)->relative);
else
API::show_window(iterator_at(pos)->relative, false); API::show_window(iterator_at(pos)->relative, false);
list_.erase(iterator_at(pos)); list_.erase(iterator_at(pos));
_m_adjust(); _m_adjust();
@ -593,7 +603,7 @@ namespace nana
return basis_.active; return basis_.active;
} }
void relate(std::size_t pos, window wd) void attach(std::size_t pos, window wd)
{ {
if(pos < list_.size()) if(pos < list_.size())
{ {
@ -1152,9 +1162,9 @@ namespace nana
layouter_->event_agent(evt); layouter_->event_agent(evt);
} }
void trigger::push_back(const nana::string& text, const nana::any& value) void trigger::insert(std::size_t pos, nana::string&& text, nana::any&& value)
{ {
layouter_->push_back(text, value); layouter_->insert(pos, std::move(text), std::move(value));
} }
std::size_t trigger::length() const std::size_t trigger::length() const
@ -1167,9 +1177,14 @@ namespace nana
return layouter_->toolbox_object().close_fly(fly); return layouter_->toolbox_object().close_fly(fly);
} }
void trigger::relate(std::size_t i, window wd) void trigger::attach(std::size_t pos, window wd)
{ {
layouter_->relate(i, wd); layouter_->attach(pos, wd);
}
void trigger::erase(std::size_t pos)
{
layouter_->erase(pos);
} }
void trigger::tab_color(std::size_t i, bool is_bgcolor, const ::nana::color& clr) void trigger::tab_color(std::size_t i, bool is_bgcolor, const ::nana::color& clr)

View File

@ -14,9 +14,14 @@
#include <nana/gui/widgets/widget.hpp> #include <nana/gui/widgets/widget.hpp>
#include <unordered_map> #include <unordered_map>
#include <fstream> #include <fstream>
#include <sstream>
#include <memory> #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp>
#else
#include <mutex> #include <mutex>
#endif
#include <map> #include <map>
namespace nana namespace nana
@ -71,16 +76,20 @@ namespace nana
if (escape) if (escape)
{ {
escape = false; escape = false;
str_ += *i;
continue; continue;
} }
if ('"' == *i) if ('"' == *i)
{ {
str_.append(read_ptr_ + 1, i - read_ptr_ - 1);
read_ptr_ = i + 1; read_ptr_ = i + 1;
reach_right_quota = true; reach_right_quota = true;
break; break;
} }
else if ('\\' != *i)
str_ += *i;
else
escape = true;
} }
_m_eat_ws(); _m_eat_ws();
if (read_ptr_ == end_ptr_ || '"' != *read_ptr_) if (read_ptr_ == end_ptr_ || '"' != *read_ptr_)
@ -261,9 +270,10 @@ namespace nana
{ {
auto result = mgr.table.emplace(wd, std::move(eval)); auto result = mgr.table.emplace(wd, std::move(eval));
result.first->second.destroy = nana::API::events(wd).destroy([wd]{ result.first->second.destroy = nana::API::events(wd).destroy([wd]{
auto & mgr = get_eval_manager(); auto & eval_mgr = get_eval_manager();
std::lock_guard<std::recursive_mutex> lock(mgr.mutex); std::lock_guard<std::recursive_mutex> lockgd(eval_mgr.mutex);
mgr.table.erase(wd);
eval_mgr.table.erase(wd);
}); });
} }
else else

View File

@ -17,8 +17,9 @@
#include <vector> #include <vector>
#if defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_condition_variable.hpp>
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#include <nana/std_condition_variable.hpp>
#else #else
#include <condition_variable> #include <condition_variable>
#include <mutex> #include <mutex>