diff --git a/.travis.yml b/.travis.yml index 82e8fd42..e0b80b04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,8 +43,12 @@ matrix: - llvm-toolchain-precise before_install: + # donwload nana-demo first + # we are in: 'user'/nana/ - cd .. - - git clone --depth=1 --branch=hotfix https://github.com/qPCR4vir/nana-demo.git nana-demo + # we are in: 'user'/ + - git clone --depth=1 --branch=master https://github.com/qPCR4vir/nana-demo.git nana-demo + # now we have 'user'/nana-demo, 'user'/nana/ and we are in: 'user'/ - export PATH="$HOME/bin:$PATH" - wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.12/cmake-3.12.0-rc3-Linux-x86_64.sh || true - chmod -R +x /tmp/tools @@ -53,27 +57,29 @@ install: - /tmp/tools/cmake --prefix="$HOME" --exclude-subdir before_script : - # we have: qPCR4vir/nana/../nana-demo and now we are in: qPCR4vir/nana/ our executable tests will access: ../nana-demo/Examples/*.bmp etc.(need to be in parallel with nana-demo/Examples) - #- cd ../nana-demo - - mkdir demo-build + - mkdir demo-build - cd demo-build + # now we have 'user'/nana-demo, 'user'/nana/ , 'user'/demo-build/ and we are in: 'user'/demo-build/ services: - - # travis don't have a physical monitor. We need to install an emulator: https://docs.travis-ci.com/user/gui-and-headless-browsers/ + # travis don't have a physical monitor. We need to install an emulator: + # https://docs.travis-ci.com/user/gui-and-headless-browsers/ - xvfb script: - cmake -G"Unix Makefiles" ../nana-demo -DCMAKE_INSTALL_PREFIX=.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_INSTALL=OFF - make install + # we have installed in 'user'/ ('user'/demo-build/..), and cmake created 'user'/nana-test/ # todo: separate resources from sources (a directory for images) - ls + # we were still in: 'user'/demo-build/ - cd ../nana-test/bin - - ls + - ls -lh - ./a_group_impl - ./animate-bmp - ./audio_player - ./background-effects - #- ./calculator # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1159 + - ./calculator # COOL !!! https://travis-ci.org/qPCR4vir/nana/builds/621103509#L924 - ./categ - ./clicked - ./decore @@ -81,48 +87,45 @@ script: - ./drag-button - ./draw - ./file_explorer - #- ./example_menu # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1348 + - ./example_menu # OK ! https://travis-ci.org/qPCR4vir/nana/builds/621103509#L1022 - ./example_listbox - #- ./example_combox # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1378 + - ./example_combox # OK ! https://travis-ci.org/qPCR4vir/nana/builds/621103509#L1044 - ./example.button - #- ./filebox-txt # https://travis-ci.org/qPCR4vir/nana/jobs/140250744#L1393 - - ./folder_tree - #- ./folder_tree_nana # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1408 - #- ./folder_tree_std # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1421 + # - ./filebox-txt # https://travis-ci.org/qPCR4vir/nana/builds/621103509#L1068 + - ./folder_tree_nana # todo failed https://travis-ci.org/qPCR4vir/nana/builds/621116812#L1193 + - ./folder_tree_std # todo failed https://travis-ci.org/qPCR4vir/nana/builds/621116812#L1200 - ./framework_design_1 - ./framework_design_2 - ./framework_design_3 - ./group - ./HelloWord - #- ./helloword_quit # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1572 - #- ./inputbox # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1585 + - ./helloword_quit # ok + - ./inputbox # ok - ./label_listener - ./lambda_event.Cpp11 - ./listbox_inline_widget - ./listbox_Resolver - ./loader_1 - #- ./loader_2 # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1732 + - ./loader_2 # ok - ./mbox - ./main - ./menu_debug - #- ./modal_form # https://travis-ci.org/qPCR4vir/nana/jobs/140250744#L1736 - #- ./MontiHall # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1775 - #- ./helloworld_demo # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1786 - #- ./notepad # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1799 - - ./menu_debug - - ./menu_popuper - #- ./modal_form # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1846 - #- ./widget_show2 # https://travis-ci.org/qPCR4vir/nana/jobs/140245437#L1730 - #- ./widget_show # https://travis-ci.org/qPCR4vir/nana/jobs/140245437#L1740 + - ./modal_form # ok + - ./MontiHall # ok + - ./helloworld_demo # ok + - ./notepad # ok !! + - ./menu_popuper + - ./widget_show2 # ok !! + - ./widget_show # ok !! - ./place_login - ./png - #- ./screen # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1909 - - ./stretch_image - #- ./threading # https://travis-ci.org/qPCR4vir/nana/jobs/140245437#L1826 ? - #- ./thread-pool # https://travis-ci.org/qPCR4vir/nana/jobs/140247564#L1782 - - ./various_events - #- ./window-dragger # https://travis-ci.org/qPCR4vir/nana/jobs/140245438#L1820 - - ./windows-subclassing + - ./screen # ok + - ./stretch_image - ./textbox_line_number + - ./threading # ok + - ./thread-pool # ok + - ./various_events + - ./window-dragger # ok + - ./windows-subclassing diff --git a/CMakeLists.txt b/CMakeLists.txt index a7d0167a..d0b3e008 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ project(nana VERSION 1.7.2 add_library(nana) add_library(nana::nana ALIAS nana) target_compile_features(nana PUBLIC cxx_std_17) +# set(CMAKE_CXX_STANDARD 17) # need after cxx_std_14 or cxx_std_17 ?? target_compile_features(nana diff --git a/build/cmake/select_filesystem.cmake b/build/cmake/select_filesystem.cmake index a4729484..8b2acf1d 100644 --- a/build/cmake/select_filesystem.cmake +++ b/build/cmake/select_filesystem.cmake @@ -1,12 +1,12 @@ # The ISO C++ File System Technical Specification (ISO-TS, or STD) was optional. # http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf # It is part of c++17. -# The library may be not available or working correctly in the std library you use. As a workaround we may try -# to "implement" it (ab)using Boost (almost compatible) +# The library may be not available or working correctly in the std library you use. +# As a workaround we will use Nana own partial, but functional implementation. +# You may opt to try to "implement" the std filesystem it (ab)using Boost (almost compatible) # http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm -# or you can choose to use the (partial, but functional) implementation provided by nana. -# If you include the file or -# the selected option will be inlined by nana into std::filesystem +# By ncluding the file or +# the selected option is inlined by nana into std::filesystem. # By default Nana will try to use the STD. If STD is not available Nana own implementation will be used. # You can change that default if you change one of the following # (please don't define more than one of the _XX_FORCE options): @@ -55,8 +55,6 @@ else() endif() check_include_file_cxx (filesystem NANA_HAVE_FILESYSTEM) - check_include_file_cxx (experimental/filesystem NANA_HAVE_EXP_FILESYSTEM) - if (NANA_HAVE_FILESYSTEM) message (STATUS "C++ Filesystem header: ") set (TEST_FS_LIB ON) @@ -67,21 +65,24 @@ else() std::filesystem::path p{\"\tmp/\"}; throw std::filesystem::filesystem_error(\"Empty file name!\", std::make_error_code(std::errc::invalid_argument)); }") - elseif (NANA_HAVE_EXP_FILESYSTEM) - message (STATUS "C++ Filesystem header: ") - set (TEST_FS_LIB ON) - set (CXXSTD_FS_TEST_SOURCE - "#include - int main() - { - std::experimental::filesystem::path p{\"/tmp/\"}; - throw std::experimental::filesystem::filesystem_error(\"Empty file name!\", std::make_error_code(std::errc::invalid_argument)); - }") - else () - message (WARNING "No std::filesystem include file found: nana::filesystem will be used. - Set NANA_CMAKE_NANA_FILESYSTEM_FORCE to ON to avoid this warning.") - target_compile_definitions(nana PUBLIC STD_FILESYSTEM_NOT_SUPPORTED) - set (TEST_FS_LIB OFF) + else() + check_include_file_cxx (experimental/filesystem NANA_HAVE_EXP_FILESYSTEM) + if (NANA_HAVE_EXP_FILESYSTEM) + message (STATUS "C++ Filesystem header: ") + set (TEST_FS_LIB ON) + set (CXXSTD_FS_TEST_SOURCE + "#include + int main() + { + std::experimental::filesystem::path p{\"/tmp/\"}; + throw std::experimental::filesystem::filesystem_error(\"Empty file name!\", std::make_error_code(std::errc::invalid_argument)); + }") + else () + message (WARNING "No std::filesystem include file found: nana::filesystem will be used. + Set NANA_CMAKE_NANA_FILESYSTEM_FORCE to ON to avoid this warning.") + target_compile_definitions(nana PUBLIC STD_FILESYSTEM_NOT_SUPPORTED) + set (TEST_FS_LIB OFF) + endif () endif () if (TEST_FS_LIB) @@ -94,56 +95,84 @@ else() set (CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH}) set (CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS}) set (CMAKE_REQUIRED_FLAGS_ORIGINAL ${CMAKE_REQUIRED_FLAGS}) - - set (CXXSTD_TEST_SOURCE - "#if !defined (__cplusplus) || (__cplusplus < 201703L) - #error NOCXX17 - #endif - int main() {}") - - check_cxx_source_compiles ("${CXXSTD_TEST_SOURCE}" CXX17_BUILTIN) - - if (CXX17_BUILTIN) - message (STATUS "C++ Standard-17 support: builtin") - else () - set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL} -std=c++17") - check_cxx_source_compiles ("${CXXSTD_TEST_SOURCE}" CXX17_FLAG) - if (CXX17_FLAG) - message (STATUS "C++ Standard-17 support: via -std=c++17") - else () - message (WARNING "nana requires C++17??, but your compiler does not support it.") - endif () - endif () - set (CMAKE_REQUIRED_LIBRARIES_ORIGINAL ${CMAKE_REQUIRED_LIBRARIES}) - check_cxx_source_compiles ("${CXXSTD_TEST_SOURCE}" C++17FS_FLAG) - if (C++17FS_FLAG) + # c++: builtin + set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL}") + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL}) + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXXBuiltIn_FS_BuiltIn) + if (CXXBuiltIn_FS_BuiltIn) message (STATUS "C++ Filesystem library: builtin") - else () - set (C++17FS_LIB "") - foreach (_LIB stdc++fs) - set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} ${_LIB}) - check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" C++17FS_LIB-l${_LIB}) - message (STATUS "C++ Filesystem library: testing -l${_LIB}") - if (C++17FS_LIB-l${_LIB}) - target_link_libraries (nana PUBLIC ${_LIB}) - message (STATUS "C++ Filesystem library: via -l${_LIB}") - set (C++17FS_LIB ${_LIB}) - break () - endif () - set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL}) - endforeach () + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} stdc++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXXBuiltIn_FS_stdcppfs) + if (CXXBuiltIn_FS_stdcppfs) + message (STATUS "C++ Filesystem library: stdc++fs") + target_link_libraries (nana PUBLIC stdc++fs) + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} c++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXXBuiltIn_FS_cppfs) + if (CXXBuiltIn_FS_cppfs) + message (STATUS "C++ Filesystem library: c++fs") + target_link_libraries (nana PUBLIC c++fs) + else() - if (C++17FS_LIB) - message (STATUS "C++ Filesystem library: via -l${C++17FS_LIB}") - else () - message (WARNING "No std::filesystem library found: nana::filesystem will be used. - Set NANA_CMAKE_NANA_FILESYSTEM_FORCE to ON to avoid this warning.") - target_compile_definitions(nana PUBLIC STD_FILESYSTEM_NOT_SUPPORTED) - endif () + # c++: -std=c++17 + set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL} -std=c++17") + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL}) + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std__cpp17_FS_BuiltIn) + if (CXX_std__cpp17_FS_BuiltIn) + message (STATUS "C++: -std=c++17; Filesystem library: builtin") + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} stdc++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std__cpp17_FS_stdcppfs) + if (CXX_std__cpp17_FS_stdcppfs) + message (STATUS "C++: -std=c++17; Filesystem library: stdc++fs") + target_link_libraries (nana PUBLIC stdc++fs) + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} c++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std__cpp17_FS_cppfs) + if (CXX_std__cpp17_FS_cppfs) + message (STATUS "C++: -std=c++17; Filesystem library: c++fs") + target_link_libraries (nana PUBLIC c++fs) + else() + + # c++: /std:c++17 + set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL} /std:c++17") + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL}) + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std_cpp17_FS_BuiltIn) + if (CXX_std_cpp17_FS_BuiltIn) + message (STATUS "C++: /std:c++17; Filesystem library: builtin") + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} stdc++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std_cpp17_FS_stdcppfs) + if (CXX_std_cpp17_FS_stdcppfs) + message (STATUS "C++: /std:c++17; Filesystem library: stdc++fs") + target_link_libraries (nana PUBLIC stdc++fs) + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} c++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std_cpp17_FS_cppfs) + if (CXX_std_cpp17_FS_cppfs) + message (STATUS "C++: /std:c++17; Filesystem library: c++fs") + target_link_libraries (nana PUBLIC c++fs) + + else () + message (WARNING "No std::filesystem library found: nana::filesystem will be used. + Set NANA_CMAKE_NANA_FILESYSTEM_FORCE to ON to avoid this warning.") + target_compile_definitions(nana PUBLIC STD_FILESYSTEM_NOT_SUPPORTED) + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL}) endif () - endif () -endif() + endif () + endif () + endif () + endif () + endif () + endif () + endif () + endif () + + endif (TEST_FS_LIB) +endif () + diff --git a/build/cmake/shared_libs.cmake b/build/cmake/shared_libs.cmake index 85e4a706..a158317d 100644 --- a/build/cmake/shared_libs.cmake +++ b/build/cmake/shared_libs.cmake @@ -39,8 +39,8 @@ endif() if(NANA_STATIC_STDLIB) target_link_libraries(nana PUBLIC - $<$:-static-libgcc> - $<$:-static-libstdc++> + $<$:-static-libgcc -static-libstdc++> + $<$:-static-libgcc -static-libstdc++> ) endif() diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index 9c463521..c35e161b 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -395,7 +395,7 @@ namespace API /// Blocks the execution and other windows' messages until the specified window is closed. void modal_window(window); - /// Blocks the execution until the specified window is closesd. + /// Blocks the execution until the specified window is closed. void wait_for(window); color fgcolor(window); diff --git a/include/nana/gui/widgets/button.hpp b/include/nana/gui/widgets/button.hpp index 5dc4b9b4..f67d2718 100644 --- a/include/nana/gui/widgets/button.hpp +++ b/include/nana/gui/widgets/button.hpp @@ -87,10 +87,10 @@ namespace nana{ typedef widget_object base_type; public: button(); - button(window, bool visible); - button(window, const ::std::string& caption, bool visible = true); - button(window, const char* caption, bool visible = true); - button(window, const nana::rectangle& = rectangle(), bool visible = true); + button(window parent, bool visible); + button(window parent, const ::std::string& caption, bool visible = true); + button(window parent, const char* caption, bool visible = true); + button(window parent, const nana::rectangle& = rectangle(), bool visible = true); /// Shows an icon in front of caption /** diff --git a/include/nana/gui/widgets/form.hpp b/include/nana/gui/widgets/form.hpp index 65f4572e..652bd9ce 100644 --- a/include/nana/gui/widgets/form.hpp +++ b/include/nana/gui/widgets/form.hpp @@ -1,13 +1,13 @@ /** * A Form Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * - * @file: nana/gui/widgets/form.hpp + * @file nana/gui/widgets/form.hpp */ #ifndef NANA_GUI_WIDGET_FORM_HPP @@ -42,7 +42,7 @@ namespace nana //place methods place & get_place(); - void div(const char* div_text); + void div(std::string div_text); place::field_reference operator[](const char* field_name); void collocate() noexcept; private: @@ -51,23 +51,30 @@ namespace nana }//end namespace form }//end namespace drawerbase - /// \brief Pop-up window. Is different from other window widgets: its default constructor creates the window. + /// The form widget represents a popup window. + /// + /// Overall it is a root widget (\see: Overview of widgets) which attaches the OS/Windowing system's native window. + /// It is different from other window widgets in that its default constructor creates the window. /// \see nana::appearance class form : public drawerbase::form::form_base { public: + /// helper template class for creating the appearance of the form. using appear = ::nana::appear; - /// Creates a window at the point and size specified by rect, and with the specified appearance. Creates a form owned by the desktop. - form(const rectangle& = API::make_center(300, 200), const appearance& = {}); //Default constructor - form(const form&, const ::nana::size& = { 300, 200 }, const appearance& = {}); //Copy constructor - form(window, const ::nana::size& = { 300, 200 }, const appearance& = {}); - /// Creates a window at the point and size specified by rect, with the specified appearance. This window is always floating above its owner. - form(window, const rectangle&, const appearance& = {}); + /// Creates a window form owned by the desktop, at the point and size specified by rect, and with the specified appearance. + explicit form(const rectangle& = API::make_center(300, 200), const appearance& = {}); //Default constructor + /// Creates a window always floating above its owner at the point and size specified by rect, with the specified appearance. This window is always floating above its owner. + explicit form(window owner, const ::nana::size& = { 300, 200 }, const appearance& = {}); + explicit form(window owner, const rectangle&, const appearance& = {}); + form(const form&, const ::nana::size& = { 300, 200 }, const appearance& = {}); //Copy constructor - void modality() const; - void wait_for_this(); + /// Blocks the execution and other windows' messages until this window is closed. + void modality() const; + + /// Blocks the execution until this window is closed. + void wait_for_this(); void keyboard_accelerator(const accel_key&, const std::function& fn); }; diff --git a/source/gui/widgets/form.cpp b/source/gui/widgets/form.cpp index 9414a07b..1a2814cc 100644 --- a/source/gui/widgets/form.cpp +++ b/source/gui/widgets/form.cpp @@ -39,7 +39,7 @@ namespace nana place & form_base::get_place() { if (this->empty()) - throw std::runtime_error("form::get_plac: the form has destroyed."); + throw std::runtime_error("form::get_place(): the form has been destroyed."); if (!place_) place_.reset(new place{ *this }); @@ -47,9 +47,9 @@ namespace nana return *place_; } - void form_base::div(const char* div_text) + void form_base::div(std::string div_text) { - get_place().div(div_text); + get_place().div(std::move(div_text)); } place::field_reference form_base::operator[](const char* field_name) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 1439964b..d9561985 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2909,7 +2909,7 @@ namespace nana //es_header::column member functions void es_header::column::_m_refresh() noexcept { - ess_->update(true); + ess_->update(false); } size_type es_header::column::position(bool disp_order) const noexcept diff --git a/source/paint/image.cpp b/source/paint/image.cpp index 857c31f7..389ed68e 100644 --- a/source/paint/image.cpp +++ b/source/paint/image.cpp @@ -1,4 +1,4 @@ -/* +/** * Paint Image Implementation * Nana C++ Library(http://www.nanapro.org) * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) @@ -7,9 +7,8 @@ * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * - * @file: nana/paint/image.cpp - * @contributors: - * nabijaczleweli(pr#106) + * @file nana/paint/image.cpp + * @contributors nabijaczleweli(pr#106) */ #include