From 73a5352796fac3a17d4d2d5fc6a73884dba15233 Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Wed, 11 Feb 2015 13:23:01 +0100 Subject: [PATCH 01/10] fix for libpng --- build/cmake/CMakeLists.txt => CMakeLists.txt | 20 +++++++- build/cmake/config.hpp | 50 ++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) rename build/cmake/CMakeLists.txt => CMakeLists.txt (78%) create mode 100644 build/cmake/config.hpp diff --git a/build/cmake/CMakeLists.txt b/CMakeLists.txt similarity index 78% rename from build/cmake/CMakeLists.txt rename to CMakeLists.txt index e04ee417..8bdb64e4 100644 --- a/build/cmake/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,24 @@ project(nana) cmake_minimum_required(VERSION 2.8) -string(REGEX REPLACE "/[^/]*$" "" CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}) -string(REGEX REPLACE "/[^/]*$" "" CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}) + +option(NANA_ENABLE_PNG "Enable the use of PNG" ON) +if(NANA_ENABLE_PNG) + add_definitions(-DNANA_ENABLE_PNG) +endif() + +option(NANA_LIBPNG "Use the system installed libpng" OFF) +if(NANA_LIBPNG) + find_package(PNG) + if (PNG_FOUND) + include_directories( ${PNG_INCLUDE_DIRS}) + add_definitions(-DNANA_LIBPNG) + endif() +endif() + +#copy our new config.hpp (with removed PNG defines) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/build/cmake/config.hpp ${CMAKE_SOURCE_DIR}/include/nana/) + 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 new file mode 100644 index 00000000..1436e7dc --- /dev/null +++ b/build/cmake/config.hpp @@ -0,0 +1,50 @@ +/* + * 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 + +//Select platform automatically +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +//Windows: + #define NANA_WINDOWS 1 + #define PLATFORM_SPEC_HPP + + //Test if it is MINGW + #if defined(__MINGW32__) + #define NANA_MINGW + #define STD_CODECVT_NOT_SUPPORTED + //#define STD_THREAD_NOT_SUPPORTED //Use this flag if MinGW version is older than 4.8.1 + #endif +#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) +//Linux: + #define NANA_LINUX 1 + #define NANA_X11 1 + #define PLATFORM_SPEC_HPP + #define STD_CODECVT_NOT_SUPPORTED +#endif + +//Here defines some flags that tell Nana what features will be supported. + +#define NANA_UNICODE + +#if defined(NANA_UNICODE) && defined(NANA_WINDOWS) + #ifndef _UNICODE + #define _UNICODE + #endif + + #ifndef UNICODE + #define UNICODE + #endif +#endif + +#endif //NANA_CONFIG_HPP From 5afe02cdd457a76666e39d9e3f198f085fc8131b Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Wed, 11 Feb 2015 13:32:27 +0100 Subject: [PATCH 02/10] wrong defines --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bdb64e4..2ce5400c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,12 +10,13 @@ if(NANA_ENABLE_PNG) add_definitions(-DNANA_ENABLE_PNG) endif() -option(NANA_LIBPNG "Use the system installed libpng" OFF) +option(NANA_LIBPNG "Use the included libpng" ON) if(NANA_LIBPNG) + add_definitions(-DNANA_LIBPNG) +else() find_package(PNG) if (PNG_FOUND) include_directories( ${PNG_INCLUDE_DIRS}) - add_definitions(-DNANA_LIBPNG) endif() endif() From 68caee5c2b57f8a80f7d5159d6bed632d22297bf Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Wed, 11 Feb 2015 13:48:59 +0100 Subject: [PATCH 03/10] fix for linux build (Fedora 21) --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ce5400c..3834f2a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,10 @@ project(nana) cmake_minimum_required(VERSION 2.8) +#find dependencies +if(UNIX) + find_package(Freetype) +endif() option(NANA_ENABLE_PNG "Enable the use of PNG" ON) if(NANA_ENABLE_PNG) From 0464e8e5d71196f176a43088fc72beb4e8ff3b20 Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Wed, 11 Feb 2015 13:57:48 +0100 Subject: [PATCH 04/10] missing include --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3834f2a1..ccca4c4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,9 @@ cmake_minimum_required(VERSION 2.8) #find dependencies if(UNIX) find_package(Freetype) + if (FREETYPE_FOUND) + include_directories( ${FREETYPE_INCLUDE_DIRS}) + endif() endif() option(NANA_ENABLE_PNG "Enable the use of PNG" ON) From 0fa61b0c955ee218340340549484ffcb8510ecc0 Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Wed, 11 Feb 2015 14:02:55 +0100 Subject: [PATCH 05/10] make libpng only selectable when using png --- CMakeLists.txt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccca4c4c..c85b7303 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,18 +15,20 @@ endif() option(NANA_ENABLE_PNG "Enable the use of PNG" ON) if(NANA_ENABLE_PNG) add_definitions(-DNANA_ENABLE_PNG) -endif() -option(NANA_LIBPNG "Use the included libpng" ON) -if(NANA_LIBPNG) - add_definitions(-DNANA_LIBPNG) -else() - find_package(PNG) - if (PNG_FOUND) - include_directories( ${PNG_INCLUDE_DIRS}) + option(NANA_LIBPNG "Use the included libpng" ON) + if(NANA_LIBPNG) + add_definitions(-DNANA_LIBPNG) + else() + find_package(PNG) + if (PNG_FOUND) + include_directories( ${PNG_INCLUDE_DIRS}) + endif() endif() endif() + + #copy our new config.hpp (with removed PNG defines) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/build/cmake/config.hpp ${CMAKE_SOURCE_DIR}/include/nana/) From c417f15b03ee1aa37a97432069d84d1f25cc1b23 Mon Sep 17 00:00:00 2001 From: cnjinhao Date: Thu, 12 Feb 2015 02:45:16 +0800 Subject: [PATCH 06/10] add contributor information --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c85b7303..1bef6aa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ # CMake configuration for Nana -# Author: ierofant(https://github.com/ierofant) +# Author: Andrew Kornilov(https://github.com/ierofant) +# Contributor: +# Robert Hauck - Enable support for PNG/Freetype project(nana) cmake_minimum_required(VERSION 2.8) From b755c24804544e1c3f267b476cbc55b6c76b1d30 Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Tue, 17 Feb 2015 10:47:49 +0100 Subject: [PATCH 07/10] - Disable annoying VS warnings - Option to enable multiprocessor build on VS - Move all options to CMake: - Unicode - Platform specs --- CMakeLists.txt | 53 ++++++++++++++++++++++++++++++++++++++++-- build/cmake/config.hpp | 34 +-------------------------- 2 files changed, 52 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c85b7303..5eaf24ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,56 @@ project(nana) cmake_minimum_required(VERSION 2.8) -#find dependencies + +#Select platform automatically +if(WIN32) + add_definitions(-DNANA_WINDOWS) + add_definitions(-DPLATFORM_SPEC_HPP=) + + #Test if it is MINGW + if(MINGW) + add_definitions(-DNANA_MINGW) + add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) + option(NANA_THREAD_NOT_SUPPORTED "Use this flag if MinGW version is older than 4.8.1" ON) + if(NANA_THREAD_NOT_SUPPORTED) + add_definitions(-DSTD_THREAD_NOT_SUPPORTED) + endif() + endif() +endif() +if(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() +endif() + + +#Find PNG if(UNIX) find_package(Freetype) if (FREETYPE_FOUND) @@ -29,7 +78,7 @@ endif() -#copy our new config.hpp (with removed PNG defines) +#Copy our new config.hpp (with removed defines) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/build/cmake/config.hpp ${CMAKE_SOURCE_DIR}/include/nana/) diff --git a/build/cmake/config.hpp b/build/cmake/config.hpp index 1436e7dc..08527a55 100644 --- a/build/cmake/config.hpp +++ b/build/cmake/config.hpp @@ -13,38 +13,6 @@ #ifndef NANA_CONFIG_HPP #define NANA_CONFIG_HPP -//Select platform automatically -#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -//Windows: - #define NANA_WINDOWS 1 - #define PLATFORM_SPEC_HPP - - //Test if it is MINGW - #if defined(__MINGW32__) - #define NANA_MINGW - #define STD_CODECVT_NOT_SUPPORTED - //#define STD_THREAD_NOT_SUPPORTED //Use this flag if MinGW version is older than 4.8.1 - #endif -#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) -//Linux: - #define NANA_LINUX 1 - #define NANA_X11 1 - #define PLATFORM_SPEC_HPP - #define STD_CODECVT_NOT_SUPPORTED -#endif - -//Here defines some flags that tell Nana what features will be supported. - -#define NANA_UNICODE - -#if defined(NANA_UNICODE) && defined(NANA_WINDOWS) - #ifndef _UNICODE - #define _UNICODE - #endif - - #ifndef UNICODE - #define UNICODE - #endif -#endif +//All defines have been moved to the CMakelists.txt in the root directory. #endif //NANA_CONFIG_HPP From aa179dbfd9d3a63ec596e38aecd3526a299b14ba Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 25 Feb 2015 17:18:13 +0800 Subject: [PATCH 08/10] fix slider knob precision issue --- source/gui/widgets/slider.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/source/gui/widgets/slider.cpp b/source/gui/widgets/slider.cpp index e0ca0442..23af12a4 100644 --- a/source/gui/widgets/slider.cpp +++ b/source/gui/widgets/slider.cpp @@ -198,12 +198,12 @@ namespace nana unsigned vcur() const { - return attr_.vcur; + return static_cast(attr_.vcur); } void resize() { - this->_m_mk_slider_pos_by_value(); + _m_mk_slider_pos_by_value(); attr_.adorn_pos = attr_.pos; } @@ -338,16 +338,18 @@ namespace nana unsigned move_step(bool forward) { - unsigned cmpvalue = attr_.vcur; + unsigned cmpvalue = static_cast(attr_.vcur); + auto value = cmpvalue; if(forward) { - if(attr_.vcur) - --attr_.vcur; + if (value) + --value; } - else if(attr_.vcur < attr_.vmax) - ++attr_.vcur; + else if (value < attr_.vmax) + ++value; - if(cmpvalue != attr_.vcur) + attr_.vcur = value; + if (cmpvalue != value) { _m_mk_slider_pos_by_value(); draw(); @@ -436,32 +438,29 @@ namespace nana return static_cast(_m_scale() * attr_.vcur / attr_.vmax); } - unsigned _m_mk_slider_value_by_pos() + void _m_mk_slider_value_by_pos() { if(_m_scale()) { - auto cmpvalue = attr_.vcur; - attr_.vcur = static_cast(attr_.pos * attr_.vmax / _m_scale()); - if (cmpvalue != attr_.vcur) + auto cmpvalue = static_cast(attr_.vcur); + attr_.vcur = (attr_.pos * attr_.vmax / _m_scale()); + if (cmpvalue != static_cast(attr_.vcur)) _m_emit_value_changed(); } - return attr_.vcur; } - int _m_mk_slider_pos_by_value() + void _m_mk_slider_pos_by_value() { attr_.pos = double(_m_scale()) * attr_.vcur / attr_.vmax; if(slider_state_.trace == slider_state_.TraceNone) attr_.adorn_pos = attr_.pos; - - return static_cast(attr_.pos); } unsigned _m_value_by_pos(double pos) const { if(_m_scale()) - return static_cast(pos * attr_.vmax / _m_scale()); + return static_cast(pos * attr_.vmax / _m_scale()); return 0; } @@ -548,7 +547,7 @@ namespace nana style dir; unsigned border; unsigned vmax; - unsigned vcur; + double vcur; double pos; bool is_draw_adorn; double adorn_pos; From 0d8daca12f25af0b4ca7e550a534c34a3579445d Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 25 Feb 2015 18:18:33 +0800 Subject: [PATCH 09/10] fix intercept of system key to respone Alt+F4 --- source/gui/detail/win32/bedrock.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/gui/detail/win32/bedrock.cpp b/source/gui/detail/win32/bedrock.cpp index 36c50e69..7ffb056a 100644 --- a/source/gui/detail/win32/bedrock.cpp +++ b/source/gui/detail/win32/bedrock.cpp @@ -1342,6 +1342,7 @@ namespace detail else if(brock.get_menu()) brock.remove_menu(); } + def_window_proc = true; break; case WM_SYSKEYUP: if(brock.set_keyboard_shortkey(false) == false) @@ -1358,6 +1359,7 @@ namespace detail brock.emit(event_code::key_release, msgwnd, arg, true, &context); } } + def_window_proc = true; break; case WM_KEYDOWN: if(msgwnd->flags.enabled) From d3d46705f32334af171c2778a424a6efbfd64d55 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 26 Feb 2015 00:37:49 +0800 Subject: [PATCH 10/10] stop intercepting the WM_SYSCHAR keys --- source/gui/detail/win32/bedrock.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/gui/detail/win32/bedrock.cpp b/source/gui/detail/win32/bedrock.cpp index 7ffb056a..9e41c349 100644 --- a/source/gui/detail/win32/bedrock.cpp +++ b/source/gui/detail/win32/bedrock.cpp @@ -1322,6 +1322,7 @@ namespace detail arg.ignore = false; brock.emit(event_code::shortkey, msgwnd, arg, true, &context); } + def_window_proc = true; break; case WM_SYSKEYDOWN: if(brock.whether_keyboard_shortkey() == false)