From faa33817e2160c7d0eef808980d87f9a600cd8b6 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 4 Dec 2015 00:20:29 +0800 Subject: [PATCH 01/13] add insert/append/erase methods to template class tabbar --- include/nana/gui/widgets/tabbar.hpp | 76 +++++++++++++++++++++++------ source/gui/widgets/tabbar.cpp | 41 +++++++++++----- 2 files changed, 88 insertions(+), 29 deletions(-) diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index 2ed73ab4..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: @@ -140,8 +144,6 @@ namespace nana : public drawer_trigger { public: - //enum toolbox_button_t{ButtonAdd, ButtonScroll, ButtonList, ButtonClose}; //deprecated - enum class kits { add, @@ -159,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&); @@ -198,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 { @@ -270,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()); } @@ -289,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/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) From 3a04e10d697a5ce98f6f7a90ea97a560ea468f67 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Tue, 1 Dec 2015 10:30:12 +0100 Subject: [PATCH 02/13] ignore .ideas --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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/ From 4b57b76ffbcb446a090644713119c2baf9eb67eb Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Wed, 2 Dec 2015 08:39:10 +0100 Subject: [PATCH 03/13] simplify automatic project generation --- CMakeLists.txt | 99 ++++--------------- .../nana/detail/linux_X11/platform_spec.hpp | 6 ++ include/nana/detail/win32/platform_spec.hpp | 6 ++ source/detail/linux_X11/platform_spec.cpp | 7 ++ source/detail/win32/platform_spec.cpp | 6 ++ 5 files changed, 43 insertions(+), 81 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6453263..b943f95a 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") + + 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,40 +23,16 @@ 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(-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(-DPLATFORM_SPEC_HPP=) add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) endif() @@ -96,25 +41,26 @@ endif() 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) + #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() -endif() +#if(NANA_UNICODE) +# add_definitions(-DNANA_UNICODE) +# if(WIN32) +# add_definitions(-DUNICODE -D_UNICODE) +# endif() +#endif() #Find PNG if(UNIX) @@ -139,15 +85,6 @@ if(NANA_ENABLE_PNG) 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_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) 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/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index d2244430..1f17cda4 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -13,6 +13,9 @@ * * http://standards.freedesktop.org/clipboards-spec/clipboards-0.1.txt */ + +#if defined(NANA_LINUX) || defined(NANA_MACOS) + #include #include #include @@ -1411,3 +1414,7 @@ namespace detail } }//end namespace detail }//end namespace nana + + +//#if defined(NANA_LINUX) || defined(NANA_MACOS) +#endif diff --git a/source/detail/win32/platform_spec.cpp b/source/detail/win32/platform_spec.cpp index ffc6dc28..7b048aba 100644 --- a/source/detail/win32/platform_spec.cpp +++ b/source/detail/win32/platform_spec.cpp @@ -11,6 +11,9 @@ * * This file provides basis class and data structrue that required by nana */ + +#if defined(NANA_WINDOWS) + #include #include #include @@ -289,3 +292,6 @@ namespace detail } }//end namespace detail }//end namespace nana + +//#if defined(NANA_WINDOWS) +#endif \ No newline at end of file From 003b0b4041f6376ce8e4d62cd21d2dfd31fc48c8 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Wed, 2 Dec 2015 13:15:08 +0100 Subject: [PATCH 04/13] simplify automatic project generation - return config + USE_github_com_meganz_mingw_std_threads --- include/nana/config.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/nana/config.hpp b/include/nana/config.hpp index 188f7562..47ab7eac 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -41,9 +41,15 @@ #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)) + // https://github.com/meganz/mingw-std-threads + //#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED + //#define _GLIBCXX_HAS_GTHREADS + //#define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 + //#define STD_THREAD_NOT_SUPPORTED + #if ((__GNUC__ == 4) && ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 2))) //Use this flag if MinGW version is older than 4.8.1 #define STD_THREAD_NOT_SUPPORTED + #define USE_github_com_meganz_mingw_std_threads #endif #endif #elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) @@ -63,6 +69,7 @@ #endif //Here defines some flags that tell Nana what features will be supported. +//#ifndef NANA_UNICODE #define NANA_UNICODE #if defined(NANA_UNICODE) && defined(NANA_WINDOWS) From 74be76e49a890e2c3f98b5a88472bcfaf637b293 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Wed, 2 Dec 2015 13:38:22 +0100 Subject: [PATCH 05/13] MinGW workaround with USE_github_com_meganz_mingw_std_threads --- include/nana/std_condition_variable.hpp | 6 +++++- include/nana/std_mutex.hpp | 17 ++++++++++++++++- include/nana/std_thread.hpp | 8 ++++++-- source/internationalization.cpp | 18 +++++++++++++----- source/threads/pool.cpp | 3 ++- 5 files changed, 42 insertions(+), 10 deletions(-) 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/internationalization.cpp b/source/internationalization.cpp index 56bc327e..c2e47e5d 100644 --- a/source/internationalization.cpp +++ b/source/internationalization.cpp @@ -14,9 +14,16 @@ #include #include #include -#include -#include +#include // Warning:(17, 1) [unused] Unused import statement +#include // Warning:(17, 1) [unused] Unused import statement + +#if defined(STD_THREAD_NOT_SUPPORTED) +#include +#else #include +#endif + + #include namespace nana @@ -68,7 +75,7 @@ namespace nana bool escape = false; for (auto i = read_ptr_ + 1; i != end_ptr_; ++i) { - if (escape) + if (escape) // Warning:(78, 12) Condition is always false { escape = false; continue; @@ -261,8 +268,9 @@ 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); + auto & mgr = get_eval_manager(); // Warning:(271, 13) Local 'mgr' hides previous declaration + std::lock_guard lock(mgr.mutex); // Local 'lock' hides previous + mgr.table.erase(wd); }); } 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 From 221e9f662414b659a2599fcbef029f70bb161040 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Wed, 2 Dec 2015 13:40:47 +0100 Subject: [PATCH 06/13] FIX MinGW workaround bring some macro small ? --- include/nana/gui/detail/window_manager.hpp | 2 +- source/gui/detail/window_manager.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index eb56ff89..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, const nana::paint::image& big) + void window_manager::default_icon(const nana::paint::image& _small, const nana::paint::image& big) { impl_->default_icon_big = big; - impl_->default_icon_small = small; + impl_->default_icon_small = _small; } void window_manager::icon(core_window_t* wd, const paint::image& small_icon, const paint::image& big_icon) From f7f8db5337a043557b7572f89dbde691074b6b22 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Wed, 2 Dec 2015 13:42:04 +0100 Subject: [PATCH 07/13] FIX: MinGW no expose functions in std:: --- source/deploy.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/deploy.cpp b/source/deploy.cpp index d61b0dd5..817721ec 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) { From f9f70cf08b6ba48122a3b6edf1edc1fd8e5639b4 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Wed, 2 Dec 2015 13:43:19 +0100 Subject: [PATCH 08/13] Simplify CMake file --- CMakeLists.txt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b943f95a..dc1e5a90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,19 +23,6 @@ endif() project(nana) cmake_minimum_required(VERSION 2.8) -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) From 3ad8f5a64167700afc9db403345740bdcaa64b5e Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 3 Dec 2015 16:54:13 +0100 Subject: [PATCH 09/13] Simplify CMake file and config.h --- CMakeLists.txt | 53 ++++-- build/cmake/config.hpp | 18 -- .../nana/audio/detail/buffer_preparation.hpp | 2 +- include/nana/charset.hpp | 15 ++ include/nana/config.hpp | 177 +++++++++++------- include/nana/deploy.hpp | 4 +- include/nana/gui/detail/events_operation.hpp | 2 +- include/nana/gui/detail/handle_manager.hpp | 2 +- source/gui/animation.cpp | 4 +- source/gui/detail/native_window_interface.cpp | 2 +- source/gui/notifier.cpp | 2 +- source/gui/place.cpp | 4 +- source/gui/timer.cpp | 2 +- 13 files changed, 171 insertions(+), 116 deletions(-) delete mode 100644 build/cmake/config.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dc1e5a90..80465950 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,13 +4,13 @@ # 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") + 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}) @@ -33,23 +33,25 @@ if(WIN32) 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() -#endif() +if(NANA_UNICODE) + add_definitions(-DNANA_UNICODE) +endif() + +if(APPLE) + add_definitions(-DAPPLE) + include_directories(/opt/X11/include/) +elseif(UNIX) + add_definitions(-Dlinux) +endif() + + -#Find PNG if(UNIX) find_package(Freetype) if (FREETYPE_FOUND) @@ -57,21 +59,36 @@ if(UNIX) endif() endif() -option(NANA_ENABLE_PNG "Enable the use of PNG" ON) + +#Find PNG +option(NANA_ENABLE_PNG "Enable the use of PNG" OFF) +option(USE_LIBPNG_FROM_OS "Use libpng from operating system." OFF) if(NANA_ENABLE_PNG) add_definitions(-DNANA_ENABLE_PNG) - - option(NANA_LIBPNG "Use the included libpng" ON) - if(NANA_LIBPNG) - add_definitions(-DNANA_LIBPNG) - else() + if(USE_LIBPNG_FROM_OS) find_package(PNG) if (PNG_FOUND) include_directories( ${PNG_INCLUDE_DIRS}) + add_definitions(-DUSE_LIBPNG_FROM_OS) endif() endif() endif() +#Find JPEG +option(NANA_ENABLE_JPEG "Enable the use of JPEG" OFF) +option(USE_LIBJPEG_FROM_OS "Use libjpeg from operating system." OFF) +if(NANA_ENABLE_JPEG) + add_definitions(-DNANA_ENABLE_JPEG) + if(USE_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 47ab7eac..a1e068a4 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,63 +13,124 @@ #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 - // https://github.com/meganz/mingw-std-threads - //#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED - //#define _GLIBCXX_HAS_GTHREADS - //#define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 - //#define STD_THREAD_NOT_SUPPORTED - #if ((__GNUC__ == 4) && ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 2))) + // 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__) + #define NANA_MINGW //Use this flag if MinGW version is older than 4.8.1 - #define STD_THREAD_NOT_SUPPORTED - #define USE_github_com_meganz_mingw_std_threads + #if ((__GNUC__ == 4) && ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 2))) + + // ?? + #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/) + // MacOS + + // Linux: + #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 ... + + // GCC ... + #if defined(__GNU__) + #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) && (__GNUC_PATCHLEVEL__ <= 1) + + //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. +/////////////////// +//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 + + //#ifndef NANA_UNICODE +// always define NANA_UNICODE ?? it will be deprecated ?. #define NANA_UNICODE #if defined(NANA_UNICODE) && defined(NANA_WINDOWS) @@ -82,23 +143,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 b3ac88d0..e1f15d7d 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/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/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 fa3c2558..202a76d3 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/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 c31daf36..da742af5 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 From 48b622acc7a722fa0b8abf20a634521cb02af493 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 3 Dec 2015 19:33:19 +0100 Subject: [PATCH 10/13] why some variables are not set by CLion / CMake ? __GNUC__ etc. I got libnana.a, but not the test.exe, why? --- CMakeLists.txt | 26 ++++++++++++++++---------- include/nana/config.hpp | 22 +++++++++++++++------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80465950..5b65dadc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,8 +38,8 @@ endif(WIN32) #Unicode -option(NANA_UNICODE "Use Unicode Character Set" ON) -if(NANA_UNICODE) +option(USE_UNICODE "Use Unicode Character Set") +if(USE_UNICODE) add_definitions(-DNANA_UNICODE) endif() @@ -59,13 +59,19 @@ if(UNIX) endif() endif() +if(WIN32) + add_definitions(-DWIN32) + if(MINGW) + add_definitions(-DMINGW) + endif() +endif() #Find PNG -option(NANA_ENABLE_PNG "Enable the use of PNG" OFF) -option(USE_LIBPNG_FROM_OS "Use libpng from operating system." OFF) -if(NANA_ENABLE_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(USE_LIBPNG_FROM_OS) + if(LIBPNG_FROM_OS) find_package(PNG) if (PNG_FOUND) include_directories( ${PNG_INCLUDE_DIRS}) @@ -75,11 +81,11 @@ if(NANA_ENABLE_PNG) endif() #Find JPEG -option(NANA_ENABLE_JPEG "Enable the use of JPEG" OFF) -option(USE_LIBJPEG_FROM_OS "Use libjpeg from operating system." OFF) -if(NANA_ENABLE_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(USE_LIBJPEG_FROM_OS) + if(LIBJPEG_FROM_OS) find_package(JPEG) if (JPEG_FOUND) include_directories( ${JPEG_INCLUDE_DIRS}) diff --git a/include/nana/config.hpp b/include/nana/config.hpp index a1e068a4..1d7390b8 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -39,11 +39,12 @@ #endif // _MSVC // MINGW ... - #if defined(__MINGW32__) || defined(__MINGW64__) + #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 #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 @@ -69,8 +70,8 @@ // Linux: #elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) - #define NANA_LINUX 1 - #define NANA_X11 1 + //#define NANA_LINUX 1 + //#define NANA_X11 1 // end Linux @@ -86,9 +87,14 @@ // 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 @@ -123,15 +129,17 @@ //#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) + #if not defined(USE_LIBJPEG_FROM_OS) #define NANA_LIBJPEG #endif #endif -//#ifndef NANA_UNICODE + // always define NANA_UNICODE ?? it will be deprecated ?. -#define NANA_UNICODE +#ifndef NANA_UNICODE + #define NANA_UNICODE +#endif #if defined(NANA_UNICODE) && defined(NANA_WINDOWS) #ifndef _UNICODE From b8b174b1f2df269a07c2db1ed7a8b07a107e0040 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Dec 2015 10:03:52 +0100 Subject: [PATCH 11/13] FIX: un-comment Linux --- include/nana/config.hpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/nana/config.hpp b/include/nana/config.hpp index 1d7390b8..806a0fd1 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -65,14 +65,12 @@ #define NANA_MACOS 1 #define NANA_X11 1 // how to add this: include_directories(/opt/X11/include/) - // MacOS + // end MacOS - // Linux: + // 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 - + #define NANA_LINUX 1 + #define NANA_X11 1 // end Linux From a5df90f8a9ae0425eb287eab9aa00808d9f03c62 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 4 Dec 2015 23:13:22 +0800 Subject: [PATCH 12/13] remove platform preprocess check in platform_spec.cpp --- source/detail/linux_X11/platform_spec.cpp | 6 ------ source/detail/win32/platform_spec.cpp | 5 ----- source/internationalization.cpp | 12 ++++++------ 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index 1f17cda4..43fde207 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -14,8 +14,6 @@ * http://standards.freedesktop.org/clipboards-spec/clipboards-0.1.txt */ -#if defined(NANA_LINUX) || defined(NANA_MACOS) - #include #include #include @@ -1414,7 +1412,3 @@ namespace detail } }//end namespace detail }//end namespace nana - - -//#if defined(NANA_LINUX) || defined(NANA_MACOS) -#endif diff --git a/source/detail/win32/platform_spec.cpp b/source/detail/win32/platform_spec.cpp index 7b048aba..f7ac9917 100644 --- a/source/detail/win32/platform_spec.cpp +++ b/source/detail/win32/platform_spec.cpp @@ -12,8 +12,6 @@ * This file provides basis class and data structrue that required by nana */ -#if defined(NANA_WINDOWS) - #include #include #include @@ -292,6 +290,3 @@ namespace detail } }//end namespace detail }//end namespace nana - -//#if defined(NANA_WINDOWS) -#endif \ No newline at end of file diff --git a/source/internationalization.cpp b/source/internationalization.cpp index c2e47e5d..2e7367fc 100644 --- a/source/internationalization.cpp +++ b/source/internationalization.cpp @@ -14,8 +14,6 @@ #include #include #include -#include // Warning:(17, 1) [unused] Unused import statement -#include // Warning:(17, 1) [unused] Unused import statement #if defined(STD_THREAD_NOT_SUPPORTED) #include @@ -75,7 +73,7 @@ namespace nana bool escape = false; for (auto i = read_ptr_ + 1; i != end_ptr_; ++i) { - if (escape) // Warning:(78, 12) Condition is always false + if (escape) { escape = false; continue; @@ -88,6 +86,8 @@ namespace nana reach_right_quota = true; break; } + else if ('\\' == *i) + escape = true; } _m_eat_ws(); if (read_ptr_ == end_ptr_ || '"' != *read_ptr_) @@ -268,10 +268,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(); // Warning:(271, 13) Local 'mgr' hides previous declaration - std::lock_guard lock(mgr.mutex); // Local 'lock' hides previous + auto & eval_mgr = get_eval_manager(); + std::lock_guard lockgd(eval_mgr.mutex); - mgr.table.erase(wd); + eval_mgr.table.erase(wd); }); } else From 21a5e2fc2e6c10374a40c42b64efe13fd1c4e271 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 4 Dec 2015 23:21:33 +0800 Subject: [PATCH 13/13] fix i18n escape char '\\' issue --- source/internationalization.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/internationalization.cpp b/source/internationalization.cpp index 2e7367fc..a83698a9 100644 --- a/source/internationalization.cpp +++ b/source/internationalization.cpp @@ -76,17 +76,19 @@ 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) + else if ('\\' != *i) + str_ += *i; + else escape = true; } _m_eat_ws();