diff --git a/.gitignore b/.gitignore index 5c5fac64..53eee01b 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ CMakeCache.txt CMakeFiles/ cmake_install.cmake *.DS_Store +.idea/ diff --git a/CMakeLists.txt b/CMakeLists.txt index a6453263..5b65dadc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,48 +4,17 @@ # Robert Hauck - Enable support for PNG/Freetype # Qiangqiang Wu - Add biicode support +# set compile flags +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") + + +# move this to the end ?? 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 - 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") - - # we'll use the default config file so we can iliminate the following macro definitions - if(MSVC) - # More MSVC specific compilation flags - add_definitions(-D_SCL_SECURE_NO_WARNINGS) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - if(MSVC14) - add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) - else() - add_definitions(-DNOT_IMPLEMENTED_KEYWORD_noexcept) - endif() - endif() - add_biicode_targets() return() @@ -54,69 +23,35 @@ endif() project(nana) cmake_minimum_required(VERSION 2.8) -#Select platform automatically -if(WIN32) - add_definitions(-DNANA_WINDOWS) - add_definitions(-DPLATFORM_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=) - 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=) - add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) -endif() - #Global MSVC definitions if(WIN32) if(MSVC) option(WIN32_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON) + # ?? if(WIN32_USE_MP) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") endif() - # More MSVC specific compilation flags - add_definitions(-D_SCL_SECURE_NO_WARNINGS) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) endif(MSVC) endif(WIN32) #Unicode -option(NANA_UNICODE "Use Unicode Character Set" ON) -if(NANA_UNICODE) - add_definitions(-DNANA_UNICODE) - if(WIN32) - add_definitions(-DUNICODE -D_UNICODE) - endif() +option(USE_UNICODE "Use Unicode Character Set") +if(USE_UNICODE) + add_definitions(-DNANA_UNICODE) endif() -#Find PNG +if(APPLE) + add_definitions(-DAPPLE) + include_directories(/opt/X11/include/) +elseif(UNIX) + add_definitions(-Dlinux) +endif() + + + if(UNIX) find_package(Freetype) if (FREETYPE_FOUND) @@ -124,30 +59,42 @@ if(UNIX) endif() endif() -option(NANA_ENABLE_PNG "Enable the use of PNG" ON) -if(NANA_ENABLE_PNG) - add_definitions(-DNANA_ENABLE_PNG) +if(WIN32) + add_definitions(-DWIN32) + if(MINGW) + add_definitions(-DMINGW) + endif() +endif() - option(NANA_LIBPNG "Use the included libpng" ON) - if(NANA_LIBPNG) - add_definitions(-DNANA_LIBPNG) - else() +#Find PNG +option(ENABLE_PNG "Enable the use of PNG") +option(LIBPNG_FROM_OS "Use libpng from operating system.") +if(ENABLE_PNG) + add_definitions(-DNANA_ENABLE_PNG) + if(LIBPNG_FROM_OS) find_package(PNG) if (PNG_FOUND) include_directories( ${PNG_INCLUDE_DIRS}) + add_definitions(-DUSE_LIBPNG_FROM_OS) 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") +#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() + + set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source) set(NANA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) diff --git a/build/cmake/config.hpp b/build/cmake/config.hpp deleted file mode 100644 index 08527a55..00000000 --- a/build/cmake/config.hpp +++ /dev/null @@ -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 diff --git a/include/nana/audio/detail/buffer_preparation.hpp b/include/nana/audio/detail/buffer_preparation.hpp index fdffc91c..c3e03d71 100644 --- a/include/nana/audio/detail/buffer_preparation.hpp +++ b/include/nana/audio/detail/buffer_preparation.hpp @@ -3,7 +3,7 @@ #include #include -#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) +#if defined(STD_THREAD_NOT_SUPPORTED) #include #include #include diff --git a/include/nana/charset.hpp b/include/nana/charset.hpp index 9e109b65..6c36159b 100644 --- a/include/nana/charset.hpp +++ b/include/nana/charset.hpp @@ -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 #define NANA_CHARSET_HPP #include @@ -13,6 +27,7 @@ namespace nana { class charset_encoding_interface; } + /// An intelligent charset class for character code conversion. class charset { diff --git a/include/nana/config.hpp b/include/nana/config.hpp index 188f7562..806a0fd1 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -1,7 +1,7 @@ -/* +/** * Nana Configuration * 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. * (See accompanying file LICENSE_1_0.txt or copy at @@ -13,57 +13,131 @@ #ifndef NANA_CONFIG_HPP #define NANA_CONFIG_HPP -#if defined(_MSC_VER) - #define _SCL_SECURE_NO_WARNINGS - #define _CRT_SECURE_NO_DEPRECATE - #pragma warning(disable : 4996) +// Select platform ...... - #if (_MSC_VER < 1900) - // is this a good idea? - #define NOT_IMPLEMENTED_KEYWORD_noexcept - #endif // _MSC_VER < 1900 - #if (_MSC_VER == 1900) - // google: break any code that tries to use codecvt or codecvt. - // google: It appears the C++ libs haven't been compiled with native char16_t/char32_t support. - // google: Those definitions are for codecvt::id, codecvt::id and codecvt::id respectively. - // However, the codecvt::id and codecvt::id definitions aren't there, and indeed, if you look at locale0.cpp in the CRT source code you'll see they're not defined at all. - // google: That's a known issue, tracked by an active bug (DevDiv#1060849). We were able to update the STL's headers in response to char16_t/char32_t, but we still need to update the separately compiled sources. - #define STD_CODECVT_NOT_SUPPORTED - #endif // _MSC_VER == 1900 -#endif // _MSVC + // Windows: + #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -//Select platform automatically -#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -//Windows: - #define NANA_WINDOWS 1 + #define NANA_WINDOWS 1 - //Test if it is MINGW - #if defined(__MINGW32__) || defined(__MINGW64__) - #define NANA_MINGW - #define STD_CODECVT_NOT_SUPPORTED - #if (__GNUC__ == 4) && ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 1)) + // compilers in Windows... + + // MSVC++ versions + #if defined(_MSC_VER) + #define _SCL_SECURE_NO_WARNNGS + #define _CRT_SECURE_NO_DEPRECATE + #pragma warning(disable : 4996) + + #if (_MSC_VER == 1900) + // google: break any code that tries to use codecvt or codecvt. + // google: It appears the C++ libs haven't been compiled with native char16_t/char32_t support. + // google: Those definitions are for codecvt::id, codecvt::id and codecvt::id respectively. + // However, the codecvt::id and codecvt::id definitions aren't there, and indeed, if you look at locale0.cpp in the CRT source code you'll see they're not defined at all. + // google: That's a known issue, tracked by an active bug (DevDiv#1060849). We were able to update the STL's headers in response to char16_t/char32_t, but we still need to update the separately compiled sources. + #define STD_CODECVT_NOT_SUPPORTED + #endif // _MSC_VER == 1900 + #endif // _MSVC + + // MINGW ... + #if defined(__MINGW32__) || defined(__MINGW64__) || defined(MINGW) + #define NANA_MINGW + //#define STD_THREAD_NOT_SUPPORTED // don't works? why? where __GNUC__, etc. are set? by CLion ?? //Use this flag if MinGW version is older than 4.8.1 - #define STD_THREAD_NOT_SUPPORTED + #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 USE_github_com_meganz_mingw_std_threads + + #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) + #define NANA_LINUX 1 + #define NANA_X11 1 + // end Linux + + + #else + # static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)"); + #endif // Select platform + + #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) + // don't works? + + //GCC 4.7.0 does not implement the 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 + + //Implement workarounds for GCC/MinGW which version is below 4.8.2 + #define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED #endif - #endif -#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) -//Linux: - #define NANA_LINUX 1 - #define NANA_X11 1 - #define STD_CODECVT_NOT_SUPPORTED -#else -# static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)"); -#endif + #endif // GCC +// End compilers ... -#if defined(NANA_MINGW) || defined(NANA_LINUX) - #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) && (__GNUC_PATCHLEVEL__ <= 1) - //Some functions which are specified in 21.5 Numeric conversions in Strings library have not yet implemented - #define STD_NUMERIC_CONVERSIONS_NOT_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 -//Here defines some flags that tell Nana what features will be supported. -#define NANA_UNICODE +/////////////////// +//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 +#endif #if defined(NANA_UNICODE) && defined(NANA_WINDOWS) #ifndef _UNICODE @@ -75,23 +149,5 @@ #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 diff --git a/include/nana/deploy.hpp b/include/nana/deploy.hpp index 088f8be5..8e1e83d8 100644 --- a/include/nana/deploy.hpp +++ b/include/nana/deploy.hpp @@ -19,9 +19,7 @@ #include #include -#if defined(NANA_LINUX) || defined(NANA_MACOS) -#undef NANA_WINDOWS -#endif + //Implement workarounds for GCC/MinGW which version is below 4.8.2 #if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED) diff --git a/include/nana/detail/linux_X11/platform_spec.hpp b/include/nana/detail/linux_X11/platform_spec.hpp index 461517f9..0a013ed6 100644 --- a/include/nana/detail/linux_X11/platform_spec.hpp +++ b/include/nana/detail/linux_X11/platform_spec.hpp @@ -13,6 +13,8 @@ * This file should not be included by any header files. */ +#if defined(NANA_LINUX) || defined(NANA_MACOS) + #ifndef NANA_DETAIL_PLATFORM_SPEC_HPP #define NANA_DETAIL_PLATFORM_SPEC_HPP @@ -323,5 +325,9 @@ namespace detail }//end namespace nana +// .h ward +#endif + +//#if defined(NANA_LINUX) || defined(NANA_MACOS) #endif diff --git a/include/nana/detail/win32/platform_spec.hpp b/include/nana/detail/win32/platform_spec.hpp index b0b90fad..b129406b 100644 --- a/include/nana/detail/win32/platform_spec.hpp +++ b/include/nana/detail/win32/platform_spec.hpp @@ -12,6 +12,7 @@ * This file provides basis class and data structrue that required by nana * This file should not be included by any header files. */ +#if defined(NANA_WINDOWS) #ifndef NANA_DETAIL_PLATFORM_SPEC_HPP #define NANA_DETAIL_PLATFORM_SPEC_HPP @@ -198,4 +199,9 @@ namespace detail }//end namespace detail }//end namespace nana + +// .h ward +#endif + +//#if defined(NANA_WINDOWS) #endif diff --git a/include/nana/gui/detail/events_operation.hpp b/include/nana/gui/detail/events_operation.hpp index 08a98b48..78f5c432 100644 --- a/include/nana/gui/detail/events_operation.hpp +++ b/include/nana/gui/detail/events_operation.hpp @@ -5,7 +5,7 @@ #include #include -#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) +#if defined(STD_THREAD_NOT_SUPPORTED) #include #else #include diff --git a/include/nana/gui/detail/handle_manager.hpp b/include/nana/gui/detail/handle_manager.hpp index 91ac70f1..7e8f670d 100644 --- a/include/nana/gui/detail/handle_manager.hpp +++ b/include/nana/gui/detail/handle_manager.hpp @@ -17,7 +17,7 @@ #include #include -#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) +#if defined(STD_THREAD_NOT_SUPPORTED) #include #else #include diff --git a/include/nana/gui/detail/window_manager.hpp b/include/nana/gui/detail/window_manager.hpp index c8229df6..b04c32dc 100644 --- a/include/nana/gui/detail/window_manager.hpp +++ b/include/nana/gui/detail/window_manager.hpp @@ -106,7 +106,7 @@ namespace detail //@brief: Delete window handle, the handle type must be a root and a frame. 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); //show diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index a491cdf2..2b7193cf 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -40,7 +40,9 @@ namespace nana : arg_tabbar({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 @@ -51,11 +53,11 @@ namespace nana struct tabbar_events : public general_events { - typedef T value_type; + using value_type = T; basic_event> added; basic_event> activated; - basic_event> removed; + basic_event> removed; }; class event_agent_interface @@ -64,7 +66,7 @@ namespace nana virtual ~event_agent_interface() = default; virtual void added(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 @@ -98,7 +100,7 @@ namespace nana : public event_agent_interface { public: - typedef ::nana::arg_tabbar arg_tabbar; + using arg_tabbar = ::nana::arg_tabbar; event_agent(::nana::tabbar& tb, DrawerTrigger & dtr) : tabbar_(tb), drawer_trigger_(dtr) @@ -119,14 +121,16 @@ namespace nana 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) { ::nana::arg_tabbar_removed arg(tabbar_, tabbar_[pos]); tabbar_.events().removed.emit(arg); + close_attach = arg.close_attach_window; return arg.remove; } + close_attach = true; return true; } private: @@ -157,10 +161,11 @@ namespace nana const pat::cloneable & ext_renderer() const; void ext_renderer(const pat::cloneable&); 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; 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_image(size_t, const nana::paint::image&); void text(std::size_t, const nana::string&); @@ -196,7 +201,7 @@ namespace nana struct button_close{}; ///< The type identifies the close button of the tabbar's toolbox. //This template class is deprecated, it will be removed in 1.3 - /// A template class identifies the buttons of the tabbar's toolbox. Refer to notes for more details. + /// A template class identifies the buttons of the tabbar's toolbox. Refer to notes for more details. template struct button_container { @@ -268,7 +273,7 @@ namespace nana void close_fly(bool fly) /// Draw or not a close button in each tab. { - if(this->get_drawer_trigger().close_fly(fly)) + if (this->get_drawer_trigger().close_fly(fly)) API::refresh_window(this->handle()); } @@ -287,16 +292,57 @@ namespace nana 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(); - t.push_back(text, value_type()); + this->append(static_cast(nana::charset(text, nana::unicode::utf8)), attach_wd); + } + + 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); } + 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(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. { - 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) diff --git a/include/nana/std_condition_variable.hpp b/include/nana/std_condition_variable.hpp index 72399b59..0c9813fc 100644 --- a/include/nana/std_condition_variable.hpp +++ b/include/nana/std_condition_variable.hpp @@ -3,10 +3,14 @@ #include #if defined(STD_THREAD_NOT_SUPPORTED) +#if defined(USE_github_com_meganz_mingw_std_threads) + #include +#else #include namespace std { 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 diff --git a/include/nana/std_mutex.hpp b/include/nana/std_mutex.hpp index 9fdebfc6..5eb6528a 100644 --- a/include/nana/std_mutex.hpp +++ b/include/nana/std_mutex.hpp @@ -3,6 +3,20 @@ #include #if defined(STD_THREAD_NOT_SUPPORTED) + +#if defined(USE_github_com_meganz_mingw_std_threads) +#include +#include +#include +#include +#include +#include +#include +// http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno.h#L53 +#define EPROTO 71 /* Protocol error */ +#include +#include +#else #include #include #include @@ -18,5 +32,6 @@ namespace std typedef boost::mutex 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 diff --git a/include/nana/std_thread.hpp b/include/nana/std_thread.hpp index 572193ac..321b3728 100644 --- a/include/nana/std_thread.hpp +++ b/include/nana/std_thread.hpp @@ -3,11 +3,15 @@ #include #if defined(STD_THREAD_NOT_SUPPORTED) + +#if defined(USE_github_com_meganz_mingw_std_threads) +#include +#else #include namespace std { typedef boost::thread thread; } -#endif - +#endif // (USE_github_com_meganz_mingw_std_threads) +#endif // (STD_THREAD_NOT_SUPPORTED) #endif // NANA_STD_THREAD_HPP diff --git a/source/deploy.cpp b/source/deploy.cpp index 3c3b540d..4086fc1d 100644 --- a/source/deploy.cpp +++ b/source/deploy.cpp @@ -61,6 +61,13 @@ namespace std *pos = (std::size_t)(end - sptr); 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) { diff --git a/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index d2244430..43fde207 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -13,6 +13,7 @@ * * http://standards.freedesktop.org/clipboards-spec/clipboards-0.1.txt */ + #include #include #include diff --git a/source/detail/win32/platform_spec.cpp b/source/detail/win32/platform_spec.cpp index 6693e9ea..5fc3f40f 100644 --- a/source/detail/win32/platform_spec.cpp +++ b/source/detail/win32/platform_spec.cpp @@ -11,6 +11,7 @@ * * This file provides basis class and data structrue that required by nana */ + #include #include #include diff --git a/source/gui/animation.cpp b/source/gui/animation.cpp index 4b1c8e59..a82702e6 100644 --- a/source/gui/animation.cpp +++ b/source/gui/animation.cpp @@ -21,7 +21,7 @@ #include #include -#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) +#if defined(STD_THREAD_NOT_SUPPORTED) #include #include #include @@ -29,7 +29,7 @@ #include #include #include -#endif //NANA_MINGW +#endif // STD_THREAD_NOT_SUPPORTED namespace nana { diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index 8fbcabe1..74dbeba1 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -14,7 +14,7 @@ #include #include #if defined(NANA_WINDOWS) - #if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) + #if defined(STD_THREAD_NOT_SUPPORTED) #include #else #include diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index 93b3bf2d..909cf193 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -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_small = small_icon; + impl_->default_icon_big = big; + impl_->default_icon_small = _small; } void window_manager::icon(core_window_t* wd, const paint::image& small_icon, const paint::image& big_icon) diff --git a/source/gui/notifier.cpp b/source/gui/notifier.cpp index b9577bdb..242b0334 100644 --- a/source/gui/notifier.cpp +++ b/source/gui/notifier.cpp @@ -20,7 +20,7 @@ #include #include -#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) +#if defined(STD_THREAD_NOT_SUPPORTED) #include #else #include diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 9eff87ea..6c200c8d 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -95,13 +95,13 @@ namespace nana std::string pos_str() const { -#ifdef NANA_MINGW +#ifdef UNDEFINED_to_string std::stringstream ss; ss< #include -#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) +#if defined(STD_THREAD_NOT_SUPPORTED) #include #else #include diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index c0acd9f3..d2a8cb2a 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -30,6 +30,12 @@ namespace nana ::nana::color bgcolor; ::nana::color fgcolor; + + item_t() = default; + + item_t(nana::string&& text, any && value) + : text(std::move(text)), value(std::move(value)) + {} }; class def_renderer @@ -414,13 +420,13 @@ namespace nana 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; - m.text = text; - m.value = value; - list_.push_back(m); - activate(static_cast(list_.size() - 1)); + if (pos >= list_.size()) + pos = list_.size(); + + list_.emplace(iterator_at(pos), std::move(text), std::move(value)); + this->activate(pos); render(); } @@ -433,9 +439,13 @@ namespace nana { 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)) { - API::show_window(iterator_at(pos)->relative, false); + if (close_attach) + API::close_window(iterator_at(pos)->relative); + else + API::show_window(iterator_at(pos)->relative, false); list_.erase(iterator_at(pos)); _m_adjust(); @@ -593,7 +603,7 @@ namespace nana return basis_.active; } - void relate(std::size_t pos, window wd) + void attach(std::size_t pos, window wd) { if(pos < list_.size()) { @@ -1152,9 +1162,9 @@ namespace nana 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 @@ -1167,9 +1177,14 @@ namespace nana 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) diff --git a/source/internationalization.cpp b/source/internationalization.cpp index 142b9003..1210826e 100644 --- a/source/internationalization.cpp +++ b/source/internationalization.cpp @@ -14,9 +14,14 @@ #include #include #include -#include -#include + +#if defined(STD_THREAD_NOT_SUPPORTED) +#include +#else #include +#endif + + #include namespace nana @@ -71,16 +76,20 @@ namespace nana if (escape) { escape = false; + str_ += *i; continue; } if ('"' == *i) { - str_.append(read_ptr_ + 1, i - read_ptr_ - 1); read_ptr_ = i + 1; reach_right_quota = true; break; } + else if ('\\' != *i) + str_ += *i; + else + escape = true; } _m_eat_ws(); if (read_ptr_ == end_ptr_ || '"' != *read_ptr_) @@ -261,9 +270,10 @@ namespace nana { auto result = mgr.table.emplace(wd, std::move(eval)); result.first->second.destroy = nana::API::events(wd).destroy([wd]{ - auto & mgr = get_eval_manager(); - std::lock_guard lock(mgr.mutex); - mgr.table.erase(wd); + auto & eval_mgr = get_eval_manager(); + std::lock_guard lockgd(eval_mgr.mutex); + + eval_mgr.table.erase(wd); }); } else diff --git a/source/threads/pool.cpp b/source/threads/pool.cpp index aa9bd461..d15180d5 100644 --- a/source/threads/pool.cpp +++ b/source/threads/pool.cpp @@ -17,8 +17,9 @@ #include #if defined(STD_THREAD_NOT_SUPPORTED) - #include #include + #include + #else #include #include