Merge branch 'develop'
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -24,6 +24,7 @@ build/makefile-bkl/*
|
|||||||
*.ilk
|
*.ilk
|
||||||
*.log
|
*.log
|
||||||
[Bb]in
|
[Bb]in
|
||||||
|
[Bb]in/
|
||||||
[Dd]ebug*/
|
[Dd]ebug*/
|
||||||
*.lib
|
*.lib
|
||||||
*.a
|
*.a
|
||||||
|
|||||||
93
.travis.yml
93
.travis.yml
@@ -34,6 +34,7 @@ matrix:
|
|||||||
- alsa-oss
|
- alsa-oss
|
||||||
- libx11-dev
|
- libx11-dev
|
||||||
- libxft-dev
|
- libxft-dev
|
||||||
|
- libboost-filesystem-dev
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ matrix:
|
|||||||
- llvm-toolchain-precise
|
- llvm-toolchain-precise
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- git clone --depth=50 --branch=master https://github.com/qPCR4vir/nana-demo.git nana-demo
|
- git clone --depth=1 --branch=develop https://github.com/qPCR4vir/nana-demo.git ../nana-demo
|
||||||
- export PATH="$HOME/bin:$PATH"
|
- export PATH="$HOME/bin:$PATH"
|
||||||
- mkdir ~/bin
|
- mkdir ~/bin
|
||||||
- wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.4/cmake-3.4.0-rc3-Linux-x86_64.sh || true
|
- wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.4/cmake-3.4.0-rc3-Linux-x86_64.sh || true
|
||||||
@@ -65,10 +66,92 @@ install:
|
|||||||
- /tmp/tools/cmake --prefix="$HOME" --exclude-subdir
|
- /tmp/tools/cmake --prefix="$HOME" --exclude-subdir
|
||||||
|
|
||||||
before_script :
|
before_script :
|
||||||
- mkdir bld
|
# travis don't have a physical monitor. We need to install an emulator: https://docs.travis-ci.com/user/gui-and-headless-browsers/
|
||||||
- cd bld
|
- "export DISPLAY=:99.0"
|
||||||
|
- "sh -e /etc/init.d/xvfb start"
|
||||||
|
- sleep 3 # give xvfb some time to start
|
||||||
|
# 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 ../nana_lib
|
||||||
|
- mkdir ../nana_demo_bin
|
||||||
|
- cd ../nana_lib
|
||||||
|
- mkdir bin
|
||||||
|
- cd bin
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cmake -G"Unix Makefiles" .. -DENABLE_JPEG=ON -DENABLE_PNG=OFF -DBUILD_NANA_DEMOS=ON -DENABLE_AUDIO=OFF
|
# Installing: the static "nana lib" will be in DESTDIR/CMAKE_INSTALL_PREFIX/lib/
|
||||||
|
# and the includes files "nana" in DESTDIR/CMAKE_INSTALL_PREFIX/include/
|
||||||
|
# we are in "... nana/../nana_lib/bin/" we need "../../nana" to get the CMakeList.txt of nana.
|
||||||
|
# Thus, make install will put the nana.lib in "... nana/../nana_lib/lib/"
|
||||||
|
# and the includes in "... nana/../nana_lib/include/"
|
||||||
|
- cmake -G"Unix Makefiles" ../../nana -DCMAKE_INSTALL_PREFIX=.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_BOOST_FILESYSTEM_FORCE=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON
|
||||||
|
- make install
|
||||||
|
- ls
|
||||||
|
- cd ..
|
||||||
|
- ls
|
||||||
|
- cd ..
|
||||||
|
- ls
|
||||||
|
- cd nana_demo_bin
|
||||||
|
- cmake -G"Unix Makefiles" ../nana-demo -DCMAKE_INSTALL_PREFIX=.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_BOOST_FILESYSTEM_FORCE=OFF -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON
|
||||||
|
- make install
|
||||||
|
# todo: separate resources from sources (a directory for images)
|
||||||
|
- ls
|
||||||
|
- cd ../bin
|
||||||
|
- ls
|
||||||
|
- ./a_group_impl
|
||||||
|
- ./animate-bmp
|
||||||
|
- ./audio_player
|
||||||
|
- ./background-effects
|
||||||
|
#- ./calculator # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1159
|
||||||
|
- ./categ
|
||||||
|
- ./clicked
|
||||||
|
- ./decore
|
||||||
|
- ./dock
|
||||||
|
- ./drag-button
|
||||||
|
- ./draw
|
||||||
|
- ./file_explorer
|
||||||
|
#- ./example_menu # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1348
|
||||||
|
- ./example_listbox
|
||||||
|
#- ./example_combox # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1378
|
||||||
|
- ./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
|
||||||
|
- ./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
|
||||||
|
- ./label_listener
|
||||||
|
- ./lambda_event.Cpp11
|
||||||
|
- ./listbox_inline_widget
|
||||||
|
- ./listbox_Resolver
|
||||||
|
- ./loader_1
|
||||||
|
#- ./loader_2 # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1732
|
||||||
|
- ./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
|
||||||
|
- ./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
|
||||||
|
- ./textbox_line_number
|
||||||
|
|
||||||
|
|
||||||
- make
|
|
||||||
|
|||||||
493
CMakeLists.txt
493
CMakeLists.txt
@@ -1,68 +1,71 @@
|
|||||||
# CMake configuration for Nana
|
# CMake configuration for Nana
|
||||||
# Author: Andrew Kornilov(https://github.com/ierofant)
|
# Author: Andrew Kornilov(https://github.com/ierofant)
|
||||||
# Contributor:
|
# Contributors:
|
||||||
|
# Jinhao
|
||||||
# Robert Hauck - Enable support for PNG/Freetype
|
# Robert Hauck - Enable support for PNG/Freetype
|
||||||
# Qiangqiang Wu - Add biicode support
|
# Qiangqiang Wu - Add biicode support
|
||||||
# Ariel Vina-Rodriguez (qPCR4vir)
|
# Ariel Vina-Rodriguez (qPCR4vir)
|
||||||
|
#
|
||||||
|
# Nana uses some build systems: MS-VS solution, MAKE, bakefile, codeblock, etc. manually optimized.
|
||||||
|
# In the future CMake could be the prefered, and maybe will be used to generate the others and the central nana repo
|
||||||
|
# will distribute all of them. But by now CMake is just one of them and all the other distributed build system
|
||||||
|
# files/projects are manually write. This current CMakeList.txt reflect this fact and that is why we don't
|
||||||
|
# generate here configurated *.h files or explicitly enumerate the sources files: anyway this CM-list
|
||||||
|
# will be "touched" to force a re-run of cmake.
|
||||||
|
|
||||||
#https://cmake.org/cmake-tutorial/
|
#https://cmake.org/cmake-tutorial/
|
||||||
#https://cmake.org/cmake/help/v3.3/module/CMakeDependentOption.html?highlight=cmakedependentoption
|
#https://cmake.org/cmake/help/v3.3/module/CMakeDependentOption.html?highlight=cmakedependentoption
|
||||||
# use CACHE FORCE or set(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ ON) or delete CMakecache.txt or the entirely build dir
|
# use CACHE FORCE or set(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ ON) or delete CMakecache.txt or the entirely build dir
|
||||||
# if your changes don't execute
|
# if your changes don't execute
|
||||||
option(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF)
|
# It seems that project() defines essential system variables like CMAKE_FIND_LIBRARY_PREFIXES.
|
||||||
option(ENABLE_PNG "Enable the use of PNG" OFF)
|
# https://bbs.archlinux.org/viewtopic.php?id=84967
|
||||||
option(LIBPNG_FROM_OS "Use libpng from operating system." ON)
|
|
||||||
option(ENABLE_JPEG "Enable the use of JPEG" OFF)
|
project(nana)
|
||||||
option(LIBJPEG_FROM_OS "Use libjpeg from operating system." ON)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
option(ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF)
|
|
||||||
option(CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." OFF)
|
option(NANA_CMAKE_INSTALL_INCLUDES "Install nana includes when compile the library" ON)
|
||||||
option(CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." ON)
|
option(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF)
|
||||||
option(BUILD_NANA_DEMOS "Build all the demos form the nana_demo repository." OFF)
|
option(NANA_CMAKE_ENABLE_PNG "Enable the use of PNG" OFF)
|
||||||
# The ISO C++ File System Technical Specification is optional.
|
option(NANA_CMAKE_LIBPNG_FROM_OS "Use libpng from operating system." ON)
|
||||||
|
option(NANA_CMAKE_ENABLE_JPEG "Enable the use of JPEG" OFF)
|
||||||
|
option(NANA_CMAKE_LIBJPEG_FROM_OS "Use libjpeg from operating system." ON)
|
||||||
|
option(NANA_CMAKE_ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF)
|
||||||
|
option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." ON)
|
||||||
|
option(NANA_CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." OFF)
|
||||||
|
option(NANA_CMAKE_AUTOMATIC_GUI_TESTING "Activate automatic GUI testing?" OFF)
|
||||||
|
|
||||||
|
# The ISO C++ File System Technical Specification (ISO-TS, or STD) is optional.
|
||||||
# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
|
# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
|
||||||
# This is not a workaround, but an user option.
|
# This is not a workaround, but an user option.
|
||||||
# The library maybe available in the std library in use or from Boost (almost compatible)
|
# The library maybe available in the std library in use or from Boost (almost compatible)
|
||||||
# http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm
|
# 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.
|
# or you can choose to use the (partial, but functional) implementation provided by nana.
|
||||||
# If you include the file <nana/filesystem/filesystem_selector.hpp>
|
# If you include the file <nana/filesystem/filesystem.hpp> or <nana/filesystem/filesystem_ext.hpp>
|
||||||
# The selected option will be set by nana into std::experimental::filesystem
|
# the selected option will be set by nana into std::experimental::filesystem
|
||||||
# By default Nana will use the ISO TS if available, or nana if not.
|
# By default Nana will try to use the STD. If STD is not available and NANA_CMAKE_FIND_BOOST_FILESYSTEM
|
||||||
# Boost will be use only if you change one of the following:
|
# is set to ON nana will try to use boost if available. Nana own implementation will be use if none of
|
||||||
option(CMAKE_BOOST_FILESYSTEM_AVAILABLE "Is Boost filesystem available?" OFF)
|
# the previus were selected or available.
|
||||||
option(NANA_BOOST_FILESYSTEM_PREFERRED "Is Boost filesystem preferred over nana?" OFF)
|
# You can change that default if you change one of the following
|
||||||
option(CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if available (over ISO)?" OFF)
|
# (please don't define more than one of the _XX_FORCE options):
|
||||||
option(CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT "Where to find <boost/filesystem.hpp>?" "../")
|
option(NANA_CMAKE_FIND_BOOST_FILESYSTEM "Search: Is Boost filesystem available?" OFF)
|
||||||
option(CMAKE_BOOST_FILESYSTEM_LIB "Flag for the compiler to link: " "-lboost/fs")
|
option(NANA_CMAKE_NANA_FILESYSTEM_FORCE "Force nana filesystem over ISO and boost?" OFF)
|
||||||
|
option(NANA_CMAKE_STD_FILESYSTEM_FORCE "Use of STD filesystem?(a compilation error will ocurre if not available)" OFF)
|
||||||
|
option(NANA_CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if available (over STD)?" OFF)
|
||||||
|
|
||||||
set(NANA_LINKS)
|
########### Compatibility with CMake 3.1
|
||||||
|
|
||||||
if (CMAKE_BOOST_FILESYSTEM_AVAILABLE)
|
|
||||||
if (CMAKE_BOOST_FILESYSTEM_PREFERED OR CMAKE_BOOST_FILESYSTEM_FORCE)
|
|
||||||
add_definitions(-DNANA_BOOST_FILESYSTEM_AVAILABLE)
|
|
||||||
if (CMAKE_BOOST_FILESYSTEM_FORCE)
|
|
||||||
add_definitions(-DNANA_BOOST_FILESYSTEM_FORCE)
|
|
||||||
else()
|
|
||||||
add_definitions(-DNANA_BOOST_FILESYSTEM_PREFERED)
|
|
||||||
endif()
|
|
||||||
include_directories("${CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}")
|
|
||||||
list(APPEND NANA_LINKS "${CMAKE_BOOST_FILESYSTEM_LIB}")
|
|
||||||
endif (CMAKE_BOOST_FILESYSTEM_PREFERED OR CMAKE_BOOST_FILESYSTEM_FORCE)
|
|
||||||
endif (CMAKE_BOOST_FILESYSTEM_AVAILABLE)
|
|
||||||
|
|
||||||
project(nana)
|
|
||||||
cmake_minimum_required(VERSION 2.8)
|
|
||||||
|
|
||||||
# Compatibility with CMake 3.1
|
|
||||||
if(POLICY CMP0054)
|
if(POLICY CMP0054)
|
||||||
# http://www.cmake.org/cmake/help/v3.1/policy/CMP0054.html
|
# http://www.cmake.org/cmake/help/v3.1/policy/CMP0054.html
|
||||||
cmake_policy(SET CMP0054 OLD)
|
cmake_policy(SET CMP0054 OLD)
|
||||||
endif()
|
endif()
|
||||||
|
if(POLICY CMP0004) # ignore leading space
|
||||||
|
# http://www.cmake.org/cmake/help/v3.0/policy/CMP0004.html
|
||||||
|
cmake_policy(SET CMP0004 OLD)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_definitions(-DNANA_IGNORE_CONF)
|
########### OS
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_definitions(-DWIN32)
|
add_definitions(-DWIN32)
|
||||||
set(BUILD_FreeMe ON) #"Build FreeMe only on Windows."
|
|
||||||
#Global MSVC definitions. You may prefer the hand-tuned sln and projects from the nana repository.
|
#Global MSVC definitions. You may prefer the hand-tuned sln and projects from the nana repository.
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
option(WIN32_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON)
|
option(WIN32_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON)
|
||||||
@@ -73,325 +76,219 @@ if(WIN32)
|
|||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
if(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
if(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
|
add_definitions(-DSTD_THREAD_NOT_SUPPORTED)
|
||||||
add_definitions(-DNANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
add_definitions(-DNANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
endif(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
endif(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
endif(MINGW)
|
endif(MINGW)
|
||||||
elseif(WIN32)
|
|
||||||
set(BUILD_FreeMe OFF)
|
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
add_definitions(-DAPPLE)
|
add_definitions(-DAPPLE)
|
||||||
include_directories(/opt/X11/include/)
|
include_directories(/opt/X11/include/)
|
||||||
list(APPEND NANA_LINKS -L/opt/X11/lib/ -liconv)
|
set(NANA_LINKS "${NANA_LINKS} -L/opt/X11/lib/ -liconv")
|
||||||
set(ENABLE_AUDIO OFF)
|
set(ENABLE_AUDIO OFF)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
add_definitions(-Dlinux)
|
add_definitions(-Dlinux)
|
||||||
message("added -D linux")
|
message("added -D linux")
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
list(APPEND NANA_LINKS -lX11 )
|
set(NANA_LINKS "${NANA_LINKS} -lX11")
|
||||||
find_package(Freetype)
|
find_package(Freetype)
|
||||||
if (FREETYPE_FOUND)
|
if (FREETYPE_FOUND)
|
||||||
include_directories( ${FREETYPE_INCLUDE_DIRS})
|
include_directories( ${FREETYPE_INCLUDE_DIRS})
|
||||||
list(APPEND NANA_LINKS -lXft )
|
set(NANA_LINKS "${NANA_LINKS} -lXft")
|
||||||
endif(FREETYPE_FOUND)
|
endif(FREETYPE_FOUND)
|
||||||
endif(UNIX)
|
endif(UNIX)
|
||||||
|
|
||||||
|
|
||||||
|
########### Compilers
|
||||||
|
#
|
||||||
|
# Using gcc: gcc 4.8 don't support C++14 and make_unique. You may want to update at least to 4.9.
|
||||||
|
# In Windows, the gcc which come with CLion was 4.8 from MinGW. You may want to install MinGW-w64 from the
|
||||||
|
# TDM-GCC Compiler Suite for Windows which will update you to gcc 5.1.
|
||||||
|
# gcc 5.3 and 5.4 include filesytem, but you need to add the link flag: -lstdc++fs
|
||||||
|
#
|
||||||
|
# see at end of: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Clang || GNU
|
||||||
|
|
||||||
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 -Wall -g") # Clang
|
||||||
|
|
||||||
|
else ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -g") # GNU
|
||||||
|
|
||||||
|
endif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||||
|
|
||||||
|
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||||
|
|
||||||
|
# enable static linkage # GNU || CLang not MinGW
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW
|
||||||
|
# set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -pthread")
|
||||||
|
set(NANA_LINKS "${NANA_LINKS} -static-libgcc -static-libstdc++ -pthread")
|
||||||
|
# message("Setting NANA_LINKS to -static-libgcc -static-libstdc++ -pthread or ${NANA_LINKS}")
|
||||||
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
|
||||||
|
# IS_GNUCXX < 5.3
|
||||||
|
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
|
||||||
|
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++fs") # IS_GNUCXX 5.3 or more
|
||||||
|
set(NANA_LINKS "${NANA_LINKS} -lstdc++fs")
|
||||||
|
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
|
||||||
|
|
||||||
|
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW
|
||||||
|
|
||||||
|
|
||||||
|
if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # APPLE Clang
|
||||||
|
# set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libstdc++")
|
||||||
|
set(NANA_LINKS "${NANA_LINKS} -stdlib=libstdc++")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
############# Optional libraries
|
||||||
|
|
||||||
# Find PNG
|
# Find PNG
|
||||||
if(ENABLE_PNG)
|
if(NANA_CMAKE_ENABLE_PNG)
|
||||||
add_definitions(-DNANA_ENABLE_PNG)
|
add_definitions(-DNANA_ENABLE_PNG)
|
||||||
#set(NANA_PNG_LIB "png")
|
set(NANA_LINKS "${NANA_LINKS} -lpng")
|
||||||
list(APPEND NANA_LINKS -lpng )
|
if(NANA_CMAKE_LIBPNG_FROM_OS)
|
||||||
if(LIBPNG_FROM_OS)
|
|
||||||
find_package(PNG)
|
find_package(PNG)
|
||||||
if (PNG_FOUND)
|
if (PNG_FOUND)
|
||||||
include_directories( ${PNG_INCLUDE_DIRS})
|
include_directories( ${PNG_INCLUDE_DIRS})
|
||||||
add_definitions(-DUSE_LIBPNG_FROM_OS)
|
add_definitions(-DUSE_LIBPNG_FROM_OS)
|
||||||
endif(PNG_FOUND)
|
endif(PNG_FOUND)
|
||||||
endif(LIBPNG_FROM_OS)
|
endif(NANA_CMAKE_LIBPNG_FROM_OS)
|
||||||
endif(ENABLE_PNG)
|
endif(NANA_CMAKE_ENABLE_PNG)
|
||||||
|
|
||||||
# Find JPEG
|
# Find JPEG
|
||||||
if(ENABLE_JPEG)
|
if(NANA_CMAKE_ENABLE_JPEG)
|
||||||
add_definitions(-DNANA_ENABLE_JPEG)
|
add_definitions(-DNANA_ENABLE_JPEG)
|
||||||
#set(NANA_JPEG_LIB "jpeg")
|
set(NANA_LINKS "${NANA_LINKS} -ljpeg")
|
||||||
list(APPEND NANA_LINKS -ljpeg )
|
if(NANA_CMAKE_LIBJPEG_FROM_OS)
|
||||||
if(LIBJPEG_FROM_OS)
|
|
||||||
find_package(JPEG)
|
find_package(JPEG)
|
||||||
if (JPEG_FOUND)
|
if (JPEG_FOUND)
|
||||||
include_directories( ${JPEG_INCLUDE_DIRS})
|
include_directories( ${JPEG_INCLUDE_DIRS})
|
||||||
add_definitions(-DUSE_LIBJPEG_FROM_OS)
|
add_definitions(-DUSE_LIBJPEG_FROM_OS)
|
||||||
endif(JPEG_FOUND)
|
endif(JPEG_FOUND)
|
||||||
endif(LIBJPEG_FROM_OS)
|
endif(NANA_CMAKE_LIBJPEG_FROM_OS)
|
||||||
endif(ENABLE_JPEG)
|
endif(NANA_CMAKE_ENABLE_JPEG)
|
||||||
|
|
||||||
if(ENABLE_AUDIO)
|
# Find ASOUND
|
||||||
|
if(NANA_CMAKE_ENABLE_AUDIO)
|
||||||
add_definitions(-DNANA_ENABLE_AUDIO)
|
add_definitions(-DNANA_ENABLE_AUDIO)
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
find_package(ASOUND)
|
find_package(ASOUND)
|
||||||
if (ASOUND_FOUND)
|
if (ASOUND_FOUND)
|
||||||
include_directories( ${ASOUND_INCLUDE_DIRS})
|
include_directories( ${ASOUND_INCLUDE_DIRS})
|
||||||
list(APPEND NANA_LINKS -lasound )
|
set(NANA_LINKS "${NANA_LINKS} -lasound")
|
||||||
else(ASOUND_FOUND)
|
else(ASOUND_FOUND)
|
||||||
message(FATAL_ERROR "libasound is not found")
|
message(FATAL_ERROR "libasound is not found")
|
||||||
endif(ASOUND_FOUND)
|
endif(ASOUND_FOUND)
|
||||||
endif(UNIX)
|
endif(UNIX)
|
||||||
endif(ENABLE_AUDIO)
|
endif(NANA_CMAKE_ENABLE_AUDIO)
|
||||||
|
|
||||||
#Unicode
|
# Find/Select filesystem
|
||||||
if(CMAKE_VERBOSE_PREPROCESSOR)
|
if (NANA_CMAKE_NANA_FILESYSTEM_FORCE)
|
||||||
|
add_definitions(-DNANA_FILESYSTEM_FORCE)
|
||||||
|
elseif (NANA_CMAKE_STD_FILESYSTEM_FORCE)
|
||||||
|
add_definitions(-DSTD_FILESYSTEM_FORCE)
|
||||||
|
elseif (NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||||
|
if (NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||||
|
add_definitions(-DNANA_BOOST_FILESYSTEM_FORCE)
|
||||||
|
endif(NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||||
|
# https://cmake.org/cmake/help/git-master/module/FindBoost.html
|
||||||
|
# Implicit dependencies such as Boost::filesystem requiring Boost::system will be automatically detected and satisfied,
|
||||||
|
# even if system is not specified when using find_package and if Boost::system is not added to target_link_libraries.
|
||||||
|
# If using Boost::thread, then Thread::Thread will also be added automatically.
|
||||||
|
find_package(Boost COMPONENTS filesystem)
|
||||||
|
if (Boost_FOUND)
|
||||||
|
add_definitions(-DNANA_BOOST_FILESYSTEM_AVAILABLE)
|
||||||
|
include_directories(SYSTEM "${Boost_INCLUDE_DIR}")
|
||||||
|
set(NANA_LINKS "${NANA_LINKS} ${Boost_LIBRARIES}") ###### FIRST !!!!!!!!!!!!!!!!! add is not first
|
||||||
|
endif (Boost_FOUND)
|
||||||
|
set(Boost_USE_STATIC_LIBS ON)
|
||||||
|
set(Boost_USE_STATIC_RUNTIME ON) # ??
|
||||||
|
endif (NANA_CMAKE_NANA_FILESYSTEM_FORCE)
|
||||||
|
|
||||||
|
|
||||||
|
######## Nana options
|
||||||
|
|
||||||
|
add_definitions(-DNANA_IGNORE_CONF)
|
||||||
|
if(NANA_CMAKE_VERBOSE_PREPROCESSOR)
|
||||||
add_definitions(-DVERBOSE_PREPROCESSOR)
|
add_definitions(-DVERBOSE_PREPROCESSOR)
|
||||||
endif(CMAKE_VERBOSE_PREPROCESSOR)
|
endif(NANA_CMAKE_VERBOSE_PREPROCESSOR)
|
||||||
|
if(NANA_CMAKE_AUTOMATIC_GUI_TESTING)
|
||||||
|
add_definitions(-DNANA_AUTOMATIC_GUI_TESTING)
|
||||||
|
enable_testing ()
|
||||||
|
endif(NANA_CMAKE_AUTOMATIC_GUI_TESTING)
|
||||||
|
|
||||||
|
|
||||||
|
####################### Main setting of Nana sources, targets and install
|
||||||
|
|
||||||
set(NANA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source)
|
set(NANA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source)
|
||||||
set(NANA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
set(NANA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
# collect all source sub-directories in a list to avoid duplication here
|
||||||
|
set(NANA_SOURCE_SUBDIRS /.
|
||||||
|
/detail
|
||||||
|
/filesystem
|
||||||
|
/gui
|
||||||
|
/gui/detail
|
||||||
|
/gui/widgets
|
||||||
|
/gui/widgets/skeletons
|
||||||
|
/paint
|
||||||
|
/paint/detail
|
||||||
|
/system
|
||||||
|
/threads )
|
||||||
|
if(NANA_CMAKE_ENABLE_AUDIO)
|
||||||
|
list(APPEND NANA_SOURCE_SUBDIRS
|
||||||
|
/audio
|
||||||
|
/audio/detail )
|
||||||
|
endif(NANA_CMAKE_ENABLE_AUDIO)
|
||||||
|
# collect all source files in the source-sub-dir
|
||||||
|
# To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library
|
||||||
|
# and Use SOURCE_GROUP if all your sources are in the same directory
|
||||||
|
foreach(subdir ${NANA_SOURCE_SUBDIRS})
|
||||||
|
aux_source_directory(${NANA_SOURCE_DIR}${subdir} sources)
|
||||||
|
# message("Subir: ${subdir}") # message("Files: ${sources}")
|
||||||
|
endforeach(subdir ${NANA_SOURCE_SUBDIRS})
|
||||||
|
|
||||||
include_directories(${NANA_INCLUDE_DIR})
|
include_directories(${NANA_INCLUDE_DIR})
|
||||||
aux_source_directory(${NANA_SOURCE_DIR} NANA_SOURCE)
|
add_library(${PROJECT_NAME} ${sources} )
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/detail NANA_DETAIL_SOURCE)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/filesystem NANA_FILESYSTEM_SOURCE)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/gui NANA_GUI_SOURCE)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/gui/detail NANA_GUI_DETAIL_SOURCE)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/gui/widgets NANA_GUI_WIDGETS_SOURCE)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/gui/widgets/skeletons NANA_GUI_WIDGETS_SKELETONS_SOURCE)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/paint NANA_PAINT_SOURCE)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/paint/detail NANA_PAINT_DETAIL_SOURCE)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/system NANA_SYSTEM_SOURCE)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/threads NANA_THREADS_SOURCE)
|
|
||||||
if(ENABLE_AUDIO)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/audio NANA_AUDIO_SOURCE)
|
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/audio/detail NANA_AUDIO_DETAIL_SOURCE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library
|
|
||||||
#and Use SOURCE_GROUP if all your sources are in the same directory
|
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} ${NANA_SOURCE}
|
|
||||||
${NANA_DETAIL_SOURCE}
|
|
||||||
${NANA_FILESYSTEM_SOURCE}
|
|
||||||
${NANA_AUDIO_SOURCE}
|
|
||||||
${NANA_AUDIO_DETAIL_SOURCE}
|
|
||||||
${NANA_GUI_SOURCE}
|
|
||||||
${NANA_GUI_DETAIL_SOURCE}
|
|
||||||
${NANA_GUI_WIDGETS_SOURCE}
|
|
||||||
${NANA_GUI_WIDGETS_SKELETONS_SOURCE}
|
|
||||||
${NANA_PAINT_SOURCE}
|
|
||||||
${NANA_PAINT_DETAIL_SOURCE}
|
|
||||||
${NANA_SYSTEM_SOURCE}
|
|
||||||
${NANA_THREADS_SOURCE})
|
|
||||||
|
|
||||||
#Headers: use INCLUDE_DIRECTORIES
|
|
||||||
# Libraries: use FIND_LIBRARY and link with the result of it (try to avoid LINK_DIRECTORIES
|
|
||||||
target_link_libraries(${PROJECT_NAME} ${NANA_LINKS})
|
target_link_libraries(${PROJECT_NAME} ${NANA_LINKS})
|
||||||
|
|
||||||
|
# Headers: use INCLUDE_DIRECTORIES
|
||||||
|
# Libraries: use FIND_LIBRARY and link with the result of it (try to avoid LINK_DIRECTORIES)
|
||||||
|
|
||||||
install(TARGETS ${PROJECT_NAME}
|
# Installing: the static "nana lib" will be in DESTDIR/CMAKE_INSTALL_PREFIX/lib/
|
||||||
ARCHIVE DESTINATION lib
|
# and the includes files "include/nana/" in DESTDIR/CMAKE_INSTALL_PREFIX/include/nana/
|
||||||
|
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib
|
||||||
LIBRARY DESTINATION lib)
|
LIBRARY DESTINATION lib)
|
||||||
# ??
|
message("The compiled Nana library will be installed in ${CMAKE_INSTALL_PREFIX}/lib")
|
||||||
|
# Install the include directories too.
|
||||||
|
if(NANA_CMAKE_INSTALL_INCLUDES)
|
||||||
install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include )
|
install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include )
|
||||||
|
message("The Nana include files will be installed in ${CMAKE_INSTALL_PREFIX}/include")
|
||||||
|
endif(NANA_CMAKE_INSTALL_INCLUDES)
|
||||||
|
|
||||||
set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 )
|
set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 )
|
||||||
|
|
||||||
|
# Just for information:
|
||||||
# TODO: move this nana-demo section to the nana demo repository, and here only include that cmake file
|
|
||||||
|
|
||||||
if (BUILD_NANA_DEMOS)
|
|
||||||
set (CMAKE_INSTALL_PREFIX ${DEMO_BIN})
|
|
||||||
set(DEMO_BIN ${NANA_SOURCE_DIR}../nana-demo/bin)
|
|
||||||
set(CMAKE_INSTALL_PREFIX )
|
|
||||||
|
|
||||||
add_executable(calculator ../nana-demo/calculator.cpp)
|
|
||||||
set_property( TARGET calculator PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(calculator ${PROJECT_NAME} )
|
|
||||||
install(TARGETS calculator RUNTIME DESTINATION &{DEMO_BIN})
|
|
||||||
|
|
||||||
if (BUILD_FreeMe)
|
|
||||||
add_executable(FreeMe ../nana-demo/FreeMe.cpp)
|
|
||||||
set_property( TARGET FreeMe PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(FreeMe ${PROJECT_NAME} )
|
|
||||||
install(TARGETS FreeMe RUNTIME DESTINATION &{DEMO_BIN})
|
|
||||||
endif (BUILD_FreeMe)
|
|
||||||
|
|
||||||
add_executable(notepad ../nana-demo/notepad.cpp)
|
|
||||||
set_property( TARGET notepad PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(notepad ${PROJECT_NAME} )
|
|
||||||
install(TARGETS notepad RUNTIME DESTINATION &{DEMO_BIN})
|
|
||||||
|
|
||||||
add_executable(widget_show ../nana-demo/widget_show.cpp)
|
|
||||||
set_property( TARGET widget_show PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(widget_show ${PROJECT_NAME})
|
|
||||||
install(TARGETS widget_show RUNTIME DESTINATION &{DEMO_BIN})
|
|
||||||
|
|
||||||
add_executable(widget_show2 ../nana-demo/widget_show2.cpp)
|
|
||||||
set_property( TARGET widget_show2 PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(widget_show2 ${PROJECT_NAME})
|
|
||||||
install(TARGETS widget_show2 RUNTIME DESTINATION &{DEMO_BIN})
|
|
||||||
|
|
||||||
if (OFF) # temporal: we need to adapt the use of filesystem to nana v1.03 (no file iterator)
|
|
||||||
|
|
||||||
add_executable(file_explorer ../nana-demo/file_explorer.cpp)
|
|
||||||
set_property( TARGET file_explorer PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(file_explorer ${PROJECT_NAME} )
|
|
||||||
install(TARGETS file_explorer RUNTIME DESTINATION &{DEMO_BIN})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
endif(OFF)
|
|
||||||
|
|
||||||
add_executable(a_group_impl ../nana-demo/Examples/a_group_impl.cpp)
|
|
||||||
set_property( TARGET a_group_impl PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(a_group_impl ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(animate-bmp ../nana-demo/Examples/animate-bmp.cpp)
|
|
||||||
set_property( TARGET animate-bmp PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(animate-bmp ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(background-effects ../nana-demo/Examples/background-effects.cpp)
|
|
||||||
set_property( TARGET background-effects PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(background-effects ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(categ ../nana-demo/Examples/categ.cpp)
|
|
||||||
set_property( TARGET categ PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(categ ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(clicked ../nana-demo/Examples/clicked.cpp)
|
|
||||||
set_property( TARGET clicked PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(clicked ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(decore ../nana-demo/Examples/decore.cpp)
|
|
||||||
set_property( TARGET decore PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(decore ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(dock ../nana-demo/Examples/dock.cpp)
|
|
||||||
set_property( TARGET dock PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(dock ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(drag-button ../nana-demo/Examples/drag-button.cpp)
|
|
||||||
set_property( TARGET drag-button PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(drag-button ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(draw ../nana-demo/Examples/draw.cpp)
|
|
||||||
set_property( TARGET draw PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(draw ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(example_combox ../nana-demo/Examples/example_combox.cpp)
|
|
||||||
set_property( TARGET example_combox PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(example_combox ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(example_listbox ../nana-demo/Examples/example_listbox.cpp)
|
|
||||||
set_property( TARGET example_listbox PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(example_listbox ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(example_menu ../nana-demo/Examples/example_menu.cpp)
|
|
||||||
set_property( TARGET example_menu PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(example_menu ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(filebox-txt ../nana-demo/Examples/filebox-txt.cpp)
|
|
||||||
set_property( TARGET filebox-txt PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(filebox-txt ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(folder_tree ../nana-demo/Examples/folder_tree.cpp)
|
|
||||||
set_property( TARGET folder_tree PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(folder_tree ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(folder_tree_nana ../nana-demo/Examples/folder_tree_nana.cpp)
|
|
||||||
set_property( TARGET folder_tree_nana PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(folder_tree_nana ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(folder_tree_std ../nana-demo/Examples/folder_tree_std.cpp)
|
|
||||||
set_property( TARGET folder_tree_std PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(folder_tree_std ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(listbox_Resolver ../nana-demo/Examples/listbox_Resolver.cpp)
|
|
||||||
set_property( TARGET listbox_Resolver PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(listbox_Resolver ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(framework_design_2 ../nana-demo/Examples/framework_design_2.cpp)
|
|
||||||
set_property( TARGET framework_design_2 PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(framework_design_2 ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(framework_design_3 ../nana-demo/Examples/framework_design_3.cpp)
|
|
||||||
set_property( TARGET framework_design_3 PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(framework_design_3 ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(group ../nana-demo/Examples/group.cpp)
|
|
||||||
set_property( TARGET group PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(group ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(HelloWord ../nana-demo/Examples/HelloWord.cpp)
|
|
||||||
set_property( TARGET HelloWord PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(HelloWord ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(listbox_inline_widget ../nana-demo/Examples/listbox_inline_widget.cpp)
|
|
||||||
set_property( TARGET listbox_inline_widget PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(listbox_inline_widget ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(inputbox ../nana-demo/Examples/inputbox.cpp)
|
|
||||||
set_property( TARGET inputbox PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(inputbox ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(label_listener ../nana-demo/Examples/label_listener.cpp)
|
|
||||||
set_property( TARGET label_listener PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(label_listener ${PROJECT_NAME})
|
|
||||||
|
|
||||||
add_executable(lambda_event.Cpp11 ../nana-demo/Examples/lambda_event.Cpp11.cpp)
|
|
||||||
set_property( TARGET lambda_event.Cpp11 PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(lambda_event.Cpp11 ${PROJECT_NAME})
|
|
||||||
|
|
||||||
if (ENABLE_AUDIO)
|
|
||||||
add_executable(audio_player ../nana-demo/Examples/audio_player.cpp)
|
|
||||||
set_property( TARGET audio_player PROPERTY CXX_STANDARD 14 )
|
|
||||||
target_link_libraries(audio_player ${PROJECT_NAME} )
|
|
||||||
endif(ENABLE_AUDIO)
|
|
||||||
|
|
||||||
# TODO: make it automatic to select each demo and example and build each.
|
|
||||||
#set(NANA_DEMOS_DIR ${CMAKE_SOURCE_DIR}/../nana-demo)
|
|
||||||
#set(NANA_EXAMPLES_DIR ${CMAKE_SOURCE_DIR}/../Examples/nana-demo/)
|
|
||||||
# https://cmake.org/cmake/help/v3.3/command/file.html?highlight=glob#file
|
|
||||||
#file( GLOB_RECURSE DEMO_SOURCES RELATIVE ../nana-demo *.cpp )
|
|
||||||
|
|
||||||
#foreach( demofile ${DEMO_SOURCES} )
|
|
||||||
# string( REPLACE ".cpp" "" demoname ${demofile} )
|
|
||||||
# add_executable( ${demoname} ${demofile} )
|
|
||||||
# set_property( TARGET ${demoname} PROPERTY CXX_STANDARD 14 )
|
|
||||||
# target_link_libraries(${demoname} ${PROJECT_NAME} )# X11 Xft ${NANA_JPEG_LIB} ${NANA_PNG_LIB})
|
|
||||||
#endforeach( demofile ${DEMO_SOURCES} )
|
|
||||||
|
|
||||||
endif(BUILD_NANA_DEMOS)
|
|
||||||
|
|
||||||
|
|
||||||
# set compile flags
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall")
|
|
||||||
else("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall")
|
|
||||||
endif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
||||||
|
|
||||||
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
||||||
|
|
||||||
# enable static linkage
|
|
||||||
if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND NOT MINGW)
|
|
||||||
#set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -pthread")
|
|
||||||
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libstdc++")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID})
|
message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID})
|
||||||
message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG})
|
message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG})
|
||||||
message ( "CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS})
|
|
||||||
message ( "CMAKE_COMPILER_IS_GNUCXX= " ${CMAKE_COMPILER_IS_GNUCXX})
|
message ( "CMAKE_COMPILER_IS_GNUCXX= " ${CMAKE_COMPILER_IS_GNUCXX})
|
||||||
|
message ( "CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS})
|
||||||
message ( "CMAKE_EXE_LINKER_FLAGS = " ${CMAKE_EXE_LINKER_FLAGS})
|
message ( "CMAKE_EXE_LINKER_FLAGS = " ${CMAKE_EXE_LINKER_FLAGS})
|
||||||
|
message ( "CMAKE_STATIC_LINKER_FLAGS=" ${CMAKE_STATIC_LINKER_FLAGS})
|
||||||
message ( "NANA_LINKS = " ${NANA_LINKS})
|
message ( "NANA_LINKS = " ${NANA_LINKS})
|
||||||
message ( "ENABLE_AUDIO = " ${ENABLE_AUDIO})
|
message ( "DESTDIR = " ${DESTDIR})
|
||||||
|
message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX})
|
||||||
|
message ( "NANA_INCLUDE_DIR = " ${NANA_INCLUDE_DIR})
|
||||||
|
message ( "CMAKE_CURRENT_SOURCE_DIR= " ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
message ( "NANA_CMAKE_ENABLE_AUDIO = " ${NANA_CMAKE_ENABLE_AUDIO})
|
||||||
|
message ( "NANA_CMAKE_FIND_BOOST_FILESYSTEM = " ${NANA_CMAKE_FIND_BOOST_FILESYSTEM})
|
||||||
|
message ( "NANA_CMAKE_BOOST_FILESYSTEM_FORCE = " ${NANA_CMAKE_BOOST_FILESYSTEM_FORCE})
|
||||||
|
message ( "NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT = " ${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT})
|
||||||
|
message ( "NANA_CMAKE_BOOST_FILESYSTEM_LIB = " ${NANA_CMAKE_BOOST_FILESYSTEM_LIB})
|
||||||
|
message ( "NANA_CMAKE_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_AUTOMATIC_GUI_TESTING})
|
||||||
|
message ( "NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# Nana C++ Library
|
# Nana C++ Library
|
||||||
[Linux (gcc 5, including demos) ](https://travis-ci.org/cnjinhao/nana)
|
[Linux (gcc 5.4.0 and 4.9.2)](https://travis-ci.org/cnjinhao/nana) including [(nana-demos)](https://github.com/qPCR4vir/nana-demo)
|
||||||
|
|
||||||
[Windows (VC2015) ](https://ci.appveyor.com/project/qPCR4vir/nana)
|
[Windows (Microsoft (R) Build Engine version 14.0.24720.0) ](https://ci.appveyor.com/project/qPCR4vir/nana)
|
||||||
|
|
||||||
[](LICENSE_1_0.txt)
|
[](LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
|
||||||
Nana is a C++ library designed to allow developers to easily create cross-platform GUI applications with modern C++11 style, currently it can work on Linux(X11) and Windows. The nana repository contains the entire source of library, you can browse the source code and submit your pull request for contributing.
|
Nana is a C++ library designed to allow developers to easily create cross-platform GUI applications with modern C++11 style. Currently it can work on Linux(X11) and Windows. The [nana repository](https://github.com/cnjinhao/nana) contains the entire source of the library. You can browse the source code and submit your pull request for contributing.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ The best way to get help with Nana library is by visiting http://nanapro.org/hel
|
|||||||
|
|
||||||
## Sending a Pull Request ?
|
## Sending a Pull Request ?
|
||||||
|
|
||||||
This project is encourage you to contribute it through sending a pull request! There is a simple rule, please **don't** directly commit your contributions to the **master** branch. According to your commits, please choose the **hotfixes** branch or the **develop** branch. Thank you!
|
This project encourage you to contribute through sending a pull request! There is a simple rule: please **don't** directly commit your contributions to the **master** branch. According to your commits, please choose the **hotfixes** branch or the **develop** branch. Thank you!
|
||||||
|
|
||||||
## Introduction to the Repository
|
## Introduction to the Repository
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +1,53 @@
|
|||||||
#Nana C++ Library
|
#Nana C++ Library
|
||||||
#
|
#
|
||||||
#Makefile created by Jinhao(cnjinhao@hotmail.com)
|
#Makefile created by sarrow104(sarrow104@gmail.com)
|
||||||
|
|
||||||
GCC = g++
|
GCC = g++
|
||||||
INCROOT = ../../include
|
INCROOT = ../../include
|
||||||
SRCROOT = ../../source
|
SRCROOT = ../../source
|
||||||
EXTRLIB = ../../extrlib
|
EXTRLIB = ../../extrlib
|
||||||
NANA_INC= $(INCROOT)/nana
|
NANA_INC= $(INCROOT)/nana
|
||||||
|
OUTROOT = out
|
||||||
|
#CXXFLAGS= -g -std=c++11 -Wall
|
||||||
|
CXXFLAGS= -g -fexceptions -std=c++11 -Wall -Wextra -Wunused-variable -Wfatal-errors
|
||||||
|
|
||||||
INCS = -I$(INCROOT) -I/usr/include/freetype2 -I$(EXTRLIB)
|
INCS = -I$(INCROOT) -I/usr/include/freetype2 -I$(EXTRLIB)
|
||||||
|
|
||||||
BIN = libnana.a
|
BIN = libnana.a
|
||||||
|
|
||||||
SRC_NANA = $(wildcard $(SRCROOT)/*.cpp)
|
TARGET = ../bin/$(BIN)
|
||||||
SRC_DETAIL = $(wildcard $(SRCROOT)/detail/*.cpp)
|
|
||||||
SRC_FILESYSTEM = $(wildcard $(SRCROOT)/filesystem/*.cpp)
|
|
||||||
SRC_AUDIO = $(wildcard $(SRCROOT)/audio/*.cpp)
|
|
||||||
SRC_AUDIO_DETAIL = $(wildcard $(SRCROOT)/audio/detail/*.cpp)
|
|
||||||
SRC_GUI = $(wildcard $(SRCROOT)/gui/*.cpp)
|
|
||||||
SRC_GUI_DETAIL = $(wildcard $(SRCROOT)/gui/detail/*.cpp)
|
|
||||||
SRC_GUI_WIDGETS = $(wildcard $(SRCROOT)/gui/widgets/*.cpp)
|
|
||||||
SRC_GUI_WIDGETS_SKELETONS = $(wildcard $(SRCROOT)/gui/widgets/skeletons/*.cpp)
|
|
||||||
SRC_PAINT = $(wildcard $(SRCROOT)/paint/*.cpp)
|
|
||||||
SRC_PAINT_DETAIL = $(wildcard $(SRCROOT)/paint/detail/*.cpp)
|
|
||||||
SRC_SYSTEM = $(wildcard $(SRCROOT)/system/*.cpp)
|
|
||||||
SRC_THREADS= $(wildcard $(SRCROOT)/threads/*.cpp)
|
|
||||||
|
|
||||||
SOURCES = $(SRC_NANA) $(SRC_DETAIL) $(SRC_FILESYSTEM) $(SRC_AUDIO) $(SRC_AUDIO_DETAIL) $(SRC_GUI) $(SRC_GUI_DETAIL) $(SRC_GUI_WIDGETS) $(SRC_GUI_WIDGETS_SKELETONS) $(SRC_PAINT) $(SRC_PAINT_DETAIL) $(SRC_SYSTEM) $(SRC_THREADS)
|
.PHONY: all clean install print
|
||||||
|
|
||||||
LINKOBJ = $(SOURCES:.cpp=.o)
|
all: $(TARGET)
|
||||||
|
|
||||||
$(BIN): $(LINKOBJ)
|
define walk
|
||||||
ar r ../bin/$(BIN) $(LINKOBJ)
|
$(wildcard $(1)) $(foreach e, $(wildcard $(1)/*), $(call walk, $(e)))
|
||||||
ranlib ../bin/$(BIN)
|
endef
|
||||||
|
|
||||||
.cpp.o:
|
SRCFILES := $(filter %.cpp,$(patsubst ./%,%,$(filter-out .,$(call walk, $(SRCROOT)))))
|
||||||
$(GCC) -g -c $< -o $@ $(INCS) -std=c++11 -Wall
|
|
||||||
|
LINKOBJ = $(patsubst $(SRCROOT)/%.cpp,$(OUTROOT)/objs/%.o,$(SRCFILES))
|
||||||
|
|
||||||
|
print:
|
||||||
|
@echo $(LINKOBJ)
|
||||||
|
|
||||||
|
$(TARGET): $(LINKOBJ)
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
ar rus $@ $?
|
||||||
|
ranlib $@
|
||||||
|
|
||||||
|
$(OUTROOT)/objs/%.o: $(SRCROOT)/%.cpp
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
$(GCC) -o $@ -c $< $(INCS) $(CXXFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(LINKOBJ)
|
rm -f $(LINKOBJ)
|
||||||
rm -f ../bin/$(BIN)
|
rm -f $(TARGET)
|
||||||
|
|
||||||
|
install:
|
||||||
|
@mkdir -p $(INSTALL_PREFIX)/include
|
||||||
|
@mkdir -p $(INSTALL_PREFIX)/bin
|
||||||
|
@mkdir -p $(INSTALL_PREFIX)/lib
|
||||||
|
cp -rfl $(INCROOT)/* $(INSTALL_PREFIX)/include
|
||||||
|
cp -rfl $(TARGET) $(INSTALL_PREFIX)/lib/
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
Building Nana C++ Library
|
# Building Nana C++ Library directly with make
|
||||||
requires:
|
If you are using make directly, it require:
|
||||||
X11, pthread, Xpm, rt, dl, freetype2, Xft, fontconfig, ALSA
|
X11, pthread, Xpm, rt, dl, freetype2, Xft, fontconfig, ALSA
|
||||||
|
|
||||||
Writing a makefile for creating applications with Nana C++ Library
|
Example of writing a makefile for creating applications with Nana C++ Library
|
||||||
-------------------
|
-------------------
|
||||||
```
|
```
|
||||||
GCC = g++
|
GCC = g++
|
||||||
|
|||||||
@@ -49,6 +49,9 @@
|
|||||||
<Filter Include="Source Files\paint\detail">
|
<Filter Include="Source Files\paint\detail">
|
||||||
<UniqueIdentifier>{53feb93f-2b86-4bf5-b2f3-f60ef1bbbf76}</UniqueIdentifier>
|
<UniqueIdentifier>{53feb93f-2b86-4bf5-b2f3-f60ef1bbbf76}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Header Files\filesystem">
|
||||||
|
<UniqueIdentifier>{6caffbf6-c023-4dbf-ba69-cdb49feddb5d}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\source\any.cpp">
|
<ClCompile Include="..\..\source\any.cpp">
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
You can download the precompiled external libraries at http://sourceforge.net/projects/nanapro/files/extrlib/
|
You can download the precompiled external libraries at http://sourceforge.net/projects/nanapro/files/extrlib/
|
||||||
Extract the ZIP file to the directory nana/extrlib. Then modify the marco switch defined in nana/include/config.hpp header file and rebuild the nana library.
|
Extract the ZIP file to the directory nana/extrlib. Then modify the marco switch defined in nana/include/config.hpp header file and rebuild the nana library.
|
||||||
|
|
||||||
|
A method to configure the 3rd party libraries
|
||||||
|
https://github.com/cnjinhao/nana/wiki/Configuration-of-Third-Party-Libraries-for-Nana
|
||||||
|
|
||||||
|
|
||||||
您可以下载预先编译的外部程序库,下载地址http://sourceforge.net/projects/nanapro/files/extrlib/
|
您可以下载预先编译的外部程序库,下载地址http://sourceforge.net/projects/nanapro/files/extrlib/
|
||||||
将ZIP文件释放到nana/extrlib目录。然后修改nana/include/config.hpp文件中对应的标志,重新编译Nana库即可。
|
将ZIP文件释放到nana/extrlib目录。然后修改nana/include/config.hpp文件中对应的标志,重新编译Nana库即可。
|
||||||
|
|
||||||
|
配置第三方库的方法
|
||||||
|
https://github.com/cnjinhao/nana/wiki/Configuration-of-Third-Party-Libraries-for-Nana
|
||||||
@@ -150,7 +150,7 @@ namespace nana
|
|||||||
if (!operand)
|
if (!operand)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto holder = dynamic_cast<any::holder<Value>*>(operand->content_);
|
auto holder = dynamic_cast<any::holder<typename std::decay<Value>::type>*>(operand->content_);
|
||||||
return (holder ? &holder->value : nullptr);
|
return (holder ? &holder->value : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#ifndef NANA_AUDIO_PLAYER_HPP
|
#ifndef NANA_AUDIO_PLAYER_HPP
|
||||||
#define NANA_AUDIO_PLAYER_HPP
|
#define NANA_AUDIO_PLAYER_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
|
|
||||||
#ifdef NANA_ENABLE_AUDIO
|
#ifdef NANA_ENABLE_AUDIO
|
||||||
@@ -31,4 +31,7 @@ namespace nana{ namespace audio
|
|||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
#endif //NANA_ENABLE_AUDIO
|
#endif //NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -83,7 +84,7 @@ namespace nana
|
|||||||
|
|
||||||
enum class mouse_action
|
enum class mouse_action
|
||||||
{
|
{
|
||||||
begin, normal = begin, over, pressed, end
|
begin, normal = begin, hovered, pressed, end
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class element_state
|
enum class element_state
|
||||||
@@ -336,67 +337,100 @@ namespace nana
|
|||||||
|
|
||||||
bool operator==(const color& other) const;
|
bool operator==(const color& other) const;
|
||||||
bool operator!=(const color& other) const;
|
bool operator!=(const color& other) const;
|
||||||
|
|
||||||
|
friend color operator+(const color&, const color&);
|
||||||
private:
|
private:
|
||||||
double r_;
|
double r_{ 0.0 };
|
||||||
double g_;
|
double g_{ 0.0 };
|
||||||
double b_;
|
double b_{ 0.0 };
|
||||||
double a_{ 0.0 }; //invisible
|
double a_{ 0.0 }; //invisible
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
struct rectangle;
|
struct basic_point
|
||||||
|
|
||||||
struct point
|
|
||||||
{
|
{
|
||||||
point();
|
//typedef-names
|
||||||
point(int x, int y);
|
using value_type = T;
|
||||||
point(const rectangle&);
|
|
||||||
|
|
||||||
point& operator=(const rectangle&);
|
//data member
|
||||||
bool operator==(const point&) const;
|
value_type x{};
|
||||||
bool operator!=(const point&) const;
|
value_type y{};
|
||||||
bool operator<(const point&) const;
|
|
||||||
bool operator<=(const point&) const;
|
|
||||||
bool operator>(const point&) const;
|
|
||||||
bool operator>=(const point&) const;
|
|
||||||
|
|
||||||
point operator-(const point&) const;
|
//member functions
|
||||||
point operator+(const point&) const;
|
basic_point() = default;
|
||||||
point& operator-=(const point&);
|
|
||||||
point& operator+=(const point&);
|
|
||||||
|
|
||||||
int x;
|
basic_point(value_type x, value_type y)
|
||||||
int y;
|
: x{ x }, y{y}
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool operator==(const basic_point& other) const noexcept
|
||||||
|
{
|
||||||
|
return (x == other.x && y == other.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const basic_point& other) const noexcept
|
||||||
|
{
|
||||||
|
return (x != other.x || y != other.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<(const basic_point& other) const noexcept
|
||||||
|
{
|
||||||
|
return ((y < other.y) || (y == other.y && x < other.x));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<=(const basic_point& other) const noexcept
|
||||||
|
{
|
||||||
|
return ((y < other.y) || (y == other.y && x <= other.x));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator>(const basic_point& other) const noexcept
|
||||||
|
{
|
||||||
|
return ((y > other.y) || (y == other.y && x > other.x));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator>=(const basic_point& other) const noexcept
|
||||||
|
{
|
||||||
|
return ((y > other.y) || (y == other.y && x >= other.x));
|
||||||
|
}
|
||||||
|
|
||||||
|
basic_point operator-(const basic_point& other) const noexcept
|
||||||
|
{
|
||||||
|
return{ x - other.x, y - other.y };
|
||||||
|
}
|
||||||
|
|
||||||
|
basic_point operator+(const basic_point& other) const noexcept
|
||||||
|
{
|
||||||
|
return{ x + other.x, y + other.y };
|
||||||
|
}
|
||||||
|
|
||||||
|
basic_point& operator-=(const basic_point& other) noexcept
|
||||||
|
{
|
||||||
|
x -= other.x;
|
||||||
|
y -= other.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
basic_point& operator+=(const basic_point& other) noexcept
|
||||||
|
{
|
||||||
|
x += other.x;
|
||||||
|
y += other.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct upoint
|
using point = basic_point<int>;
|
||||||
{
|
using upoint = basic_point<unsigned>;
|
||||||
typedef unsigned value_type;
|
|
||||||
|
|
||||||
upoint();
|
|
||||||
upoint(value_type x, value_type y);
|
|
||||||
bool operator==(const upoint&) const;
|
|
||||||
bool operator!=(const upoint&) const;
|
|
||||||
bool operator<(const upoint&) const;
|
|
||||||
bool operator<=(const upoint&) const;
|
|
||||||
bool operator>(const upoint&) const;
|
|
||||||
bool operator>=(const upoint&) const;
|
|
||||||
|
|
||||||
value_type x;
|
|
||||||
value_type y;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct size
|
struct size
|
||||||
{
|
{
|
||||||
using value_type = unsigned;
|
using value_type = unsigned;
|
||||||
size();
|
size();
|
||||||
size(value_type width, value_type height);
|
size(value_type width, value_type height);
|
||||||
size(const rectangle&);
|
|
||||||
|
|
||||||
size& operator=(const rectangle&);
|
|
||||||
|
|
||||||
bool empty() const; ///< true if width * height == 0
|
bool empty() const; ///< true if width * height == 0
|
||||||
bool is_hit(const point&) const; ///< Assume it is a rectangle at (0,0), and check whether a specified position is in the rectange.
|
bool is_hit(const point&) const; ///< Assume it is a rectangle at (0,0), and check whether a specified position is in the rectange.
|
||||||
|
size& shift();
|
||||||
|
|
||||||
bool operator==(const size& rhs) const;
|
bool operator==(const size& rhs) const;
|
||||||
bool operator!=(const size& rhs) const;
|
bool operator!=(const size& rhs) const;
|
||||||
size operator+(const size&) const;
|
size operator+(const size&) const;
|
||||||
@@ -415,11 +449,11 @@ namespace nana
|
|||||||
bool operator==(const rectangle& rhs) const;
|
bool operator==(const rectangle& rhs) const;
|
||||||
bool operator!=(const rectangle& rhs) const;
|
bool operator!=(const rectangle& rhs) const;
|
||||||
|
|
||||||
rectangle& operator=(const point&);
|
point position() const noexcept;
|
||||||
rectangle& operator=(const size&);
|
rectangle& position(const point&) noexcept;
|
||||||
|
|
||||||
rectangle& set_pos(const point&);
|
size dimension() const noexcept;
|
||||||
rectangle& set_size(const size&);
|
rectangle& dimension(const size&) noexcept;
|
||||||
|
|
||||||
rectangle& pare_off(int pixels); ///<Pares the specified pixels off the rectangle. It's equal to x += pixels; y + pixels; width -= (pixels << 1); height -= (pixels << 1);
|
rectangle& pare_off(int pixels); ///<Pares the specified pixels off the rectangle. It's equal to x += pixels; y + pixels; width -= (pixels << 1); height -= (pixels << 1);
|
||||||
|
|
||||||
@@ -427,7 +461,8 @@ namespace nana
|
|||||||
int bottom() const;
|
int bottom() const;
|
||||||
bool is_hit(int x, int y) const;
|
bool is_hit(int x, int y) const;
|
||||||
bool is_hit(const point& pos) const;
|
bool is_hit(const point& pos) const;
|
||||||
bool empty() const; ///< true if width * height == 0
|
bool empty() const; ///< true if width * height == 0.
|
||||||
|
rectangle& shift(); ///< Swap position x and y, size width and height.
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
@@ -484,7 +519,7 @@ namespace nana
|
|||||||
southeast
|
southeast
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,9 +31,13 @@
|
|||||||
* - _SCL_SECURE_NO_WARNNGS, _CRT_SECURE_NO_DEPRECATE (VC)
|
* - _SCL_SECURE_NO_WARNNGS, _CRT_SECURE_NO_DEPRECATE (VC)
|
||||||
* - STD_CODECVT_NOT_SUPPORTED (VC RC, <codecvt> is a known issue on libstdc++, it works on libc++)
|
* - STD_CODECVT_NOT_SUPPORTED (VC RC, <codecvt> is a known issue on libstdc++, it works on libc++)
|
||||||
* - STD_THREAD_NOT_SUPPORTED (GCC < 4.8.1)
|
* - STD_THREAD_NOT_SUPPORTED (GCC < 4.8.1)
|
||||||
|
* - STD_put_time_NOT_SUPPORTED (GCC < 5)
|
||||||
* - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
|
* - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
|
||||||
* - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
|
* - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
|
||||||
* - STD_TO_STRING_NOT_SUPPORTED (MinGW with GCC < 4.8)
|
* - STD_TO_STRING_NOT_SUPPORTED (MinGW with GCC < 4.8)
|
||||||
|
* - STD_FILESYSTEM_NOT_SUPPORTED (GCC < 5.3) ....
|
||||||
|
* - CXX_NO_INLINE_NAMESPACE (Visual C++ < 2015)
|
||||||
|
* - STD_MAKE_UNIQUE_NOT_SUPPORTED (GCC < 4.9)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NANA_CXX_DEFINES_INCLUDED
|
#ifndef NANA_CXX_DEFINES_INCLUDED
|
||||||
@@ -42,14 +46,20 @@
|
|||||||
|
|
||||||
//C++ language
|
//C++ language
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# undef STD_FILESYSTEM_NOT_SUPPORTED
|
|
||||||
# if (_MSC_VER < 1900)
|
# if (_MSC_VER < 1900)
|
||||||
|
# //About std.experimental.filesystem.
|
||||||
|
# //Through VC2013 has provided <filesystem>, but all the names are given in namespace std. It's hard to alias these names into std::experimental,
|
||||||
|
# //So Nana use nana.filesystem implement instead for VC2013
|
||||||
|
#
|
||||||
# //Nana defines some macros for lack of support of keywords
|
# //Nana defines some macros for lack of support of keywords
|
||||||
# define _ALLOW_KEYWORD_MACROS
|
# define _ALLOW_KEYWORD_MACROS
|
||||||
#
|
#
|
||||||
# define CXX_NO_INLINE_NAMESPACE //no support of C++11 inline namespace until Visual C++ 2015
|
# define CXX_NO_INLINE_NAMESPACE //no support of C++11 inline namespace until Visual C++ 2015
|
||||||
# define noexcept //no support of noexcept until Visual C++ 2015
|
# define noexcept //no support of noexcept until Visual C++ 2015
|
||||||
# define constexpr //no support of constexpr until Visual C++ 2015
|
|
||||||
|
# define constexpr const //no support of constexpr until Visual C++ 2015 ? const ??
|
||||||
|
# else
|
||||||
|
# undef STD_FILESYSTEM_NOT_SUPPORTED
|
||||||
# endif
|
# endif
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
|
# if (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
|
||||||
@@ -76,7 +86,7 @@
|
|||||||
#define NANA_LINUX
|
#define NANA_LINUX
|
||||||
#define NANA_X11
|
#define NANA_X11
|
||||||
#else
|
#else
|
||||||
# static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
|
static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Define a symbol for POSIX operating system.
|
//Define a symbol for POSIX operating system.
|
||||||
@@ -108,10 +118,11 @@
|
|||||||
//<codecvt> is a known issue on libstdc++, it works on libc++
|
//<codecvt> is a known issue on libstdc++, it works on libc++
|
||||||
#define STD_CODECVT_NOT_SUPPORTED
|
#define STD_CODECVT_NOT_SUPPORTED
|
||||||
|
|
||||||
|
#if !defined(__cpp_lib_make_unique) || (__cpp_lib_make_unique != 201304)
|
||||||
#ifndef STD_MAKE_UNIQUE_NOT_SUPPORTED
|
#ifndef STD_MAKE_UNIQUE_NOT_SUPPORTED
|
||||||
#define STD_MAKE_UNIQUE_NOT_SUPPORTED
|
#define STD_MAKE_UNIQUE_NOT_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -133,8 +144,14 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if ((__GNUC__ < 5) )
|
||||||
|
# define STD_put_time_NOT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ((__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3 ) ) )
|
#if ((__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3 ) ) )
|
||||||
# undef STD_FILESYSTEM_NOT_SUPPORTED
|
# undef STD_FILESYSTEM_NOT_SUPPORTED
|
||||||
|
/// \todo define the namespace ????
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (__GNUC__ == 4)
|
#if (__GNUC__ == 4)
|
||||||
@@ -147,9 +164,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(NANA_MINGW)
|
#if defined(NANA_MINGW)
|
||||||
//It's a knonwn issue under MinGW
|
#ifndef __MINGW64_VERSION_MAJOR
|
||||||
|
//It's a knonwn issue under MinGW(except MinGW-W64)
|
||||||
#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED
|
#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (__GNUC_MINOR__ < 8)
|
#if (__GNUC_MINOR__ < 8)
|
||||||
//introduce to_string/to_wstring workaround for lack of stdlib definitions
|
//introduce to_string/to_wstring workaround for lack of stdlib definitions
|
||||||
@@ -177,7 +196,7 @@
|
|||||||
|
|
||||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0061r0.html
|
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0061r0.html
|
||||||
|
|
||||||
# if __cpp_lib_experimental_filesystem
|
#if defined(__cpp_lib_experimental_filesystem) && (__cpp_lib_experimental_filesystem == 201406)
|
||||||
# undef STD_FILESYSTEM_NOT_SUPPORTED
|
# undef STD_FILESYSTEM_NOT_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,31 @@ namespace nana
|
|||||||
class charset_encoding_interface;
|
class charset_encoding_interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An intelligent charset class for character code conversion.
|
/*!\class charset
|
||||||
|
\brief An intelligent charset class for character code conversion.
|
||||||
|
Example:
|
||||||
|
1. A UTF-8 string from the socket.
|
||||||
|
|
||||||
|
int len = ::recv(sd, buf, buflen, 0);
|
||||||
|
textbox.caption(nana::charset(std::string(buf, len), nana::unicode::utf8));
|
||||||
|
|
||||||
|
2. Send the string in text to the socket as UTF-8.
|
||||||
|
|
||||||
|
std::string utf8str = nana::charset(textbox.caption()).to_bytes(nana::unicode::utf8);
|
||||||
|
::send(sd, utf8str.c_str(), utf8str.size(), 0);
|
||||||
|
|
||||||
|
3, Convert a string to the specified multi-byte character code.
|
||||||
|
|
||||||
|
// Convert to a multibytes string through default system language.
|
||||||
|
std::string mbstr = nana::charset(a_wstring);
|
||||||
|
|
||||||
|
// If the default system language is English and convert
|
||||||
|
// a Chinese unicode string to multibytes string through GB2312
|
||||||
|
std::setlocale(LC_CTYPE, "zh_CN.GB2312");
|
||||||
|
//set::setlocale(LC_CTYPE, ".936"); call it in Windows
|
||||||
|
std::string mbstr = nana::charset(a_wstring_with_chinese);
|
||||||
|
|
||||||
|
*/
|
||||||
class charset
|
class charset
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -74,27 +98,3 @@ namespace nana
|
|||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!\class charset
|
|
||||||
|
|
||||||
Example
|
|
||||||
1. A UTF-8 string from the socket.
|
|
||||||
|
|
||||||
int len = ::recv(sd, buf, buflen, 0);
|
|
||||||
textbox.caption(nana::charset(std::string(buf, len), nana::unicode::utf8));
|
|
||||||
|
|
||||||
2. Send the string in text to the socket as UTF-8.
|
|
||||||
|
|
||||||
std::string utf8str = nana::charset(textbox.caption()).to_bytes(nana::unicode::utf8);
|
|
||||||
::send(sd, utf8str.c_str(), utf8str.size(), 0);
|
|
||||||
|
|
||||||
3, Convert a string to the specified multi-byte character code.
|
|
||||||
|
|
||||||
//Convert to a multibytes string through default system language.
|
|
||||||
std::string mbstr = nana::charset(a_wstring);
|
|
||||||
//If the default system language is English and convert
|
|
||||||
//a Chinese unicode string to multibytes string through GB2312
|
|
||||||
std::setlocale(LC_CTYPE, "zh_CN.GB2312");
|
|
||||||
//set::setlocale(LC_CTYPE, ".936"); call it in Windows
|
|
||||||
std::string mbstr = nana::charset(a_wstring_with_chinese);
|
|
||||||
|
|
||||||
*/
|
|
||||||
@@ -25,7 +25,11 @@
|
|||||||
|
|
||||||
#include "c++defines.hpp"
|
#include "c++defines.hpp"
|
||||||
|
|
||||||
//The basic configurations are ignored when NANA_IGNORE_CONF is defined.
|
//This marco is defined since 1.4 and until 1.5 for deprecating frame widget.
|
||||||
|
//This marco and class frame will be removed in version 1.5
|
||||||
|
#define WIDGET_FRAME_DEPRECATED
|
||||||
|
|
||||||
|
//The following basic configurations are ignored when NANA_IGNORE_CONF is defined.
|
||||||
//The NANA_IGNORE_CONF may be specified by CMake generated makefile.
|
//The NANA_IGNORE_CONF may be specified by CMake generated makefile.
|
||||||
#ifndef NANA_IGNORE_CONF
|
#ifndef NANA_IGNORE_CONF
|
||||||
|
|
||||||
@@ -39,20 +43,30 @@
|
|||||||
// https://github.com/meganz/mingw-std-threads
|
// https://github.com/meganz/mingw-std-threads
|
||||||
//#define NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ
|
//#define NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ
|
||||||
|
|
||||||
////////////////////////////
|
//# The ISO C++ File System Technical Specification(ISO - TS, or STD) is optional.
|
||||||
// The ISO C++ File System Technical Specification is optional.
|
//# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
|
||||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf
|
//# This is not a workaround, but an user option.
|
||||||
// This is not a workaround, but an user option.
|
//# The library maybe available in the std library in use or from Boost(almost compatible)
|
||||||
// The library maybe available in the std library in use or from Boost (almost compatible)
|
//# http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm
|
||||||
// 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.
|
||||||
// or you can choose to use the (partial, but functional) implementation provided by nana.
|
//# If you include the file <nana/filesystem/filesystem.hpp>
|
||||||
// If you include the file <nana/filesystem/filesystem_selector.hpp>
|
//# the selected option will be set by nana into std::experimental::filesystem
|
||||||
// The selected option will be set by nana into std::experimental::filesystem
|
//# By default Nana will try to use the STD.If not available will try
|
||||||
// By default Nana will use the ISO TS if available, or nana if not.
|
//# to use boost if available.Nana own implementation will be use only none of them are available.
|
||||||
// Boost will be use only if you change one of the following (set the includes and link correspondly):
|
//# You can change that default if you change one of the following
|
||||||
//#define NANA_BOOST_FILESYSTEM_AVAILABLE // "Is Boost filesystem available?"
|
//# (please don't define more than one of the _XX_FORCE options):
|
||||||
//#define NANA_BOOST_FILESYSTEM_PREFERRED // "Is Boost filesystem preferred over nana?"
|
//
|
||||||
//#define NANA_BOOST_FILESYSTEM_FORCE // "Force use of Boost filesystem if available (over ISO)?
|
//#define BOOST_FILESYSTEM_AVAILABLE // "Is Boost filesystem available?"
|
||||||
|
//#define BOOST_FILESYSTEM_FORCE // "Force use of Boost filesystem if available (over ISO and nana)
|
||||||
|
//#define STD_FILESYSTEM_FORCE // "Use of STD filesystem?(a compilation error will ocurre if not available)" OFF)
|
||||||
|
//#define NANA_FILESYSTEM_FORCE // "Force nana filesystem over ISO and boost?" OFF)
|
||||||
|
//
|
||||||
|
// Make sure you (cmake?) provide the following where correspond (please find the correct values):
|
||||||
|
// set CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT "Where to find <boost/filesystem.hpp>?" "../")
|
||||||
|
// set CMAKE_BOOST_FILESYSTEM_LIB "Flag for the compiler to link: " "-lboost/fs")
|
||||||
|
// include_directories CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT
|
||||||
|
// APPEND flag LINKS CMAKE_BOOST_FILESYSTEM_LIB
|
||||||
|
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Support of PCM playback
|
// Support of PCM playback
|
||||||
@@ -83,12 +97,22 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
///////////////////
|
||||||
|
// Support for NANA_AUTOMATIC_GUI_TESTING
|
||||||
|
// Will cause the program to self-test the GUI. A default automatic GUI test
|
||||||
|
// will be added to all programs which don't have yet one defined. This default test will simple
|
||||||
|
// wait 10 sec. (time to construct, show and execute the GUI) and then exit normally.
|
||||||
|
//
|
||||||
|
//#define NANA_AUTOMATIC_GUI_TESTING
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(VERBOSE_PREPROCESSOR)
|
#if !defined(VERBOSE_PREPROCESSOR)
|
||||||
//#define VERBOSE_PREPROCESSOR
|
//#define VERBOSE_PREPROCESSOR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(STOP_VERBOSE_PREPROCESSOR)
|
#if !defined(STOP_VERBOSE_PREPROCESSOR)
|
||||||
#define STOP_VERBOSE_PREPROCESSOR
|
//#define STOP_VERBOSE_PREPROCESSOR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // NANA_IGNORE_CONFIG
|
#endif // NANA_IGNORE_CONFIG
|
||||||
|
|||||||
@@ -14,11 +14,10 @@
|
|||||||
|
|
||||||
#ifndef NANA_DEPLOY_HPP
|
#ifndef NANA_DEPLOY_HPP
|
||||||
#define NANA_DEPLOY_HPP
|
#define NANA_DEPLOY_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include <nana/config.hpp>
|
#include <nana/config.hpp>
|
||||||
#if defined(VERBOSE_PREPROCESSOR)
|
|
||||||
#include <nana/verbose_preprocessor.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <nana/charset.hpp>
|
#include <nana/charset.hpp>
|
||||||
@@ -92,14 +91,57 @@ namespace std
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef STD_put_time_NOT_SUPPORTED
|
||||||
|
#include <ctime>
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
//Workaround for no implemenation of std::put_time in gcc < 5.
|
||||||
|
/* std unspecified return type */
|
||||||
|
//template< class CharT, class RTSTR >// let fail for CharT != char / wchar_t
|
||||||
|
//RTSTR put_time(const std::tm* tmb, const CharT* fmt);
|
||||||
|
|
||||||
|
//template< >
|
||||||
|
std::string put_time/*<char, std::string>*/(const std::tm* tmb, const char* fmt);
|
||||||
|
|
||||||
|
//Defined in header <ctime>
|
||||||
|
// std::size_t strftime(char* str, std::size_t count, const char* format, const std::tm* time);
|
||||||
|
//template<>
|
||||||
|
//std::wstring put_time<wchar_t, std::wstring>(const std::tm* tmb, const wchar_t* fmt);
|
||||||
|
}
|
||||||
|
#endif // STD_put_time_NOT_SUPPORTED
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
/// move to *.h ??
|
||||||
|
struct utf8_Error : std::runtime_error
|
||||||
|
{
|
||||||
|
static bool use_throw; ///< def { true }; use carefully - it is a global variable !! \todo initialize from a #define ?
|
||||||
|
|
||||||
|
using std::runtime_error::runtime_error;
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# if (_MSC_VER < 1900)
|
||||||
|
//A workaround for lack support of C++11 inheriting constructors for VC2013
|
||||||
|
explicit utf8_Error(const std::string& msg);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void emit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Checks whether a specified text is utf8 encoding
|
/// Checks whether a specified text is utf8 encoding
|
||||||
bool is_utf8(const char* str, unsigned len);
|
bool is_utf8(const char* str, std::size_t len);
|
||||||
void throw_not_utf8(const std::string& text);
|
void throw_not_utf8(const std::string& text);
|
||||||
void throw_not_utf8(const char*, unsigned len);
|
void throw_not_utf8(const char*, std::size_t len);
|
||||||
void throw_not_utf8(const char*);
|
void throw_not_utf8(const char*);
|
||||||
|
|
||||||
|
/// this text needed change, it needed review ??
|
||||||
|
bool review_utf8(const std::string& text);
|
||||||
|
|
||||||
|
/// this text needed change, it needed review ??
|
||||||
|
bool review_utf8(std::string& text);
|
||||||
|
|
||||||
const std::string& to_utf8(const std::string&);
|
const std::string& to_utf8(const std::string&);
|
||||||
std::string to_utf8(const std::wstring&);
|
std::string to_utf8(const std::wstring&);
|
||||||
|
|
||||||
@@ -190,5 +232,5 @@ namespace std {
|
|||||||
make_unique(Args&&...) = delete;
|
make_unique(Args&&...) = delete;
|
||||||
}
|
}
|
||||||
#endif //STD_make_unique_NOT_SUPPORTED
|
#endif //STD_make_unique_NOT_SUPPORTED
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif //NANA_MACROS_HPP
|
#endif //NANA_DEPLOY_HPP
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
#ifndef NANA_DETAIL_PLATFORM_SPEC_HPP
|
#ifndef NANA_DETAIL_PLATFORM_SPEC_HPP
|
||||||
#define NANA_DETAIL_PLATFORM_SPEC_HPP
|
#define NANA_DETAIL_PLATFORM_SPEC_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -60,6 +62,8 @@ namespace detail
|
|||||||
|
|
||||||
class charset_conv
|
class charset_conv
|
||||||
{
|
{
|
||||||
|
charset_conv(const charset_conv&) = delete;
|
||||||
|
charset_conv& operator=(const charset_conv*) = delete;
|
||||||
public:
|
public:
|
||||||
charset_conv(const char* tocode, const char* fromcode);
|
charset_conv(const char* tocode, const char* fromcode);
|
||||||
~charset_conv();
|
~charset_conv();
|
||||||
@@ -118,6 +122,9 @@ namespace detail
|
|||||||
void update_color();
|
void update_color();
|
||||||
void update_text_color();
|
void update_text_color();
|
||||||
private:
|
private:
|
||||||
|
drawable_impl_type(const drawable_impl_type&) = delete;
|
||||||
|
drawable_impl_type& operator=(const drawable_impl_type&) = delete;
|
||||||
|
|
||||||
unsigned current_color_{ 0xFFFFFF };
|
unsigned current_color_{ 0xFFFFFF };
|
||||||
unsigned color_{ 0xFFFFFFFF };
|
unsigned color_{ 0xFFFFFFFF };
|
||||||
unsigned text_color_{ 0xFFFFFFFF };
|
unsigned text_color_{ 0xFFFFFFFF };
|
||||||
@@ -197,6 +204,8 @@ namespace detail
|
|||||||
typedef ::nana::event_code event_code;
|
typedef ::nana::event_code event_code;
|
||||||
typedef ::nana::native_window_type native_window_type;
|
typedef ::nana::native_window_type native_window_type;
|
||||||
|
|
||||||
|
platform_spec(const platform_spec&) = delete;
|
||||||
|
platform_spec& operator=(const platform_spec&) = delete;
|
||||||
|
|
||||||
platform_spec();
|
platform_spec();
|
||||||
~platform_spec();
|
~platform_spec();
|
||||||
@@ -327,6 +336,7 @@ namespace detail
|
|||||||
|
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
// .h ward
|
// .h ward
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
/*
|
/**
|
||||||
* Selector of Platform Specification
|
* Selector of Platform Specification
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/detail/platform_spec_selector.hpp
|
* @file nana/detail/platform_spec_selector.hpp
|
||||||
*
|
*
|
||||||
* Selects the proper platform_spec header file for the current platform
|
* @brief Selects the proper platform_spec header file for the current platform
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nana/config.hpp>
|
#include <nana/config.hpp>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Platform Specification Implementation
|
* Platform Specification Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -63,17 +64,27 @@ namespace detail
|
|||||||
bool forced;
|
bool forced;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct arg_affinity_execute
|
||||||
|
{
|
||||||
|
const std::function<void()> * function_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
tray = 0x501,
|
tray = 0x501,
|
||||||
|
|
||||||
async_activate,
|
async_activate,
|
||||||
async_set_focus,
|
async_set_focus,
|
||||||
map_thread_root_buffer,
|
remote_flush_surface,
|
||||||
remote_thread_destroy_window,
|
remote_thread_destroy_window,
|
||||||
remote_thread_move_window,
|
remote_thread_move_window,
|
||||||
operate_caret, //wParam: 1=Destroy, 2=SetPos
|
operate_caret, //wParam: 1=Destroy, 2=SetPos
|
||||||
remote_thread_set_window_pos,
|
remote_thread_set_window_pos,
|
||||||
remote_thread_set_window_text,
|
remote_thread_set_window_text,
|
||||||
|
|
||||||
|
//Execute a function in a thread with is associated with a specified native window
|
||||||
|
affinity_execute,
|
||||||
|
|
||||||
user,
|
user,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -142,6 +153,9 @@ namespace detail
|
|||||||
unsigned whitespace_pixels;
|
unsigned whitespace_pixels;
|
||||||
}string;
|
}string;
|
||||||
|
|
||||||
|
drawable_impl_type(const drawable_impl_type&) = delete;
|
||||||
|
drawable_impl_type& operator=(const drawable_impl_type&) = delete;
|
||||||
|
|
||||||
drawable_impl_type();
|
drawable_impl_type();
|
||||||
~drawable_impl_type();
|
~drawable_impl_type();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/**
|
||||||
* A ISO C++ filesystem Implementation
|
* A ISO C++ filesystem Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
@@ -7,17 +7,17 @@
|
|||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/filesystem/filesystem.hpp
|
* @file nana/filesystem/filesystem.hpp
|
||||||
* Modiffied by Ariel Vina-Rodriguez:
|
* @author Ariel Vina-Rodriguez, Jinhao
|
||||||
* Now mimic std::experimental::filesystem::v1 (boost v3)
|
* @brief Mimic std::experimental::filesystem::v1 (boost v3)
|
||||||
* and need VC2015 or a C++11 compiler. With a few correction will be compiler by VC2013
|
* and need VC2015 or a C++11 compiler. With a few correction can be compiler by VC2013
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf --- last pdf of std draft N4100 <filesystem> 2014-07-04
|
||||||
// http://en.cppreference.com/w/cpp/experimental/fs
|
// http://en.cppreference.com/w/cpp/experimental/fs
|
||||||
// http://cpprocks.com/introduction-to-tr2-filesystem-library-in-vs2012/ --- TR2 filesystem in VS2012
|
// http://cpprocks.com/introduction-to-tr2-filesystem-library-in-vs2012/ --- TR2 filesystem in VS2012
|
||||||
// https://msdn.microsoft.com/en-us/library/hh874694%28v=vs.140%29.aspx --- C++ 14, the <filesystem> header VS2015
|
// https://msdn.microsoft.com/en-us/library/hh874694%28v=vs.140%29.aspx --- C++ 14, the <filesystem> header VS2015
|
||||||
// https://msdn.microsoft.com/en-us/library/hh874694%28v=vs.120%29.aspx --- <filesystem> header VS2013
|
// https://msdn.microsoft.com/en-us/library/hh874694%28v=vs.120%29.aspx --- <filesystem> header VS2013
|
||||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf --- last pdf of std draft N4100 2014-07-04
|
|
||||||
// http://cplusplus.github.io/filesystem-ts/working-draft.html --- in html format
|
// http://cplusplus.github.io/filesystem-ts/working-draft.html --- in html format
|
||||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4099.html --- in html format
|
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4099.html --- in html format
|
||||||
// http://article.gmane.org/gmane.comp.lib.boost.devel/256220 --- The filesystem TS unanimously approved by ISO.
|
// http://article.gmane.org/gmane.comp.lib.boost.devel/256220 --- The filesystem TS unanimously approved by ISO.
|
||||||
@@ -29,6 +29,54 @@
|
|||||||
|
|
||||||
#ifndef NANA_FILESYSTEM_HPP
|
#ifndef NANA_FILESYSTEM_HPP
|
||||||
#define NANA_FILESYSTEM_HPP
|
#define NANA_FILESYSTEM_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
|
//Filesystem Selection
|
||||||
|
#include <nana/config.hpp>
|
||||||
|
|
||||||
|
#if defined(NANA_USING_NANA_FILESYSTEM) || defined(NANA_USING_STD_FILESYSTEM) || defined(NANA_USING_BOOST_FILESYSTEM)
|
||||||
|
#undef NANA_USING_NANA_FILESYSTEM
|
||||||
|
#undef NANA_USING_STD_FILESYSTEM
|
||||||
|
#undef NANA_USING_BOOST_FILESYSTEM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define NANA_USING_NANA_FILESYSTEM 0
|
||||||
|
#define NANA_USING_STD_FILESYSTEM 0
|
||||||
|
#define NANA_USING_BOOST_FILESYSTEM 0
|
||||||
|
|
||||||
|
#if (defined(NANA_FILESYSTEM_FORCE) || ( (defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(BOOST_FILESYSTEM_AVAILABLE)) && !(defined(BOOST_FILESYSTEM_FORCE) || defined(STD_FILESYSTEM_FORCE)) ) )
|
||||||
|
|
||||||
|
#undef NANA_USING_NANA_FILESYSTEM
|
||||||
|
#define NANA_USING_NANA_FILESYSTEM 1
|
||||||
|
|
||||||
|
#elif (defined(BOOST_FILESYSTEM_AVAILABLE) && ( defined(BOOST_FILESYSTEM_FORCE) || ( defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(STD_FILESYSTEM_FORCE) ) ))
|
||||||
|
|
||||||
|
#undef NANA_USING_BOOST_FILESYSTEM
|
||||||
|
#define NANA_USING_BOOST_FILESYSTEM 1
|
||||||
|
# include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
// add boost::filesystem into std::experimental::filesystem
|
||||||
|
namespace std {
|
||||||
|
namespace experimental {
|
||||||
|
namespace filesystem {
|
||||||
|
using namespace boost::filesystem;
|
||||||
|
} // filesystem
|
||||||
|
} // experimental
|
||||||
|
} // std
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#undef NANA_USING_STD_FILESYSTEM
|
||||||
|
#define NANA_USING_STD_FILESYSTEM 1
|
||||||
|
# include <experimental/filesystem>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __cpp_lib_experimental_filesystem
|
||||||
|
# define __cpp_lib_experimental_filesystem 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NANA_USING_NANA_FILESYSTEM
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@@ -40,17 +88,13 @@
|
|||||||
|
|
||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
|
|
||||||
// namespace std { namespace experimental { namespace filesystem { inline namespace v1 {
|
namespace nana { namespace experimental { namespace filesystem
|
||||||
|
{
|
||||||
namespace nana { namespace experimental {
|
|
||||||
|
|
||||||
#ifndef CXX_NO_INLINE_NAMESPACE
|
#ifndef CXX_NO_INLINE_NAMESPACE
|
||||||
inline namespace v1
|
inline namespace v1
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
enum class file_type
|
enum class file_type
|
||||||
{
|
{
|
||||||
none = 0, ///< has not been determined or an error occurred while trying to determine
|
none = 0, ///< has not been determined or an error occurred while trying to determine
|
||||||
@@ -82,7 +126,7 @@ namespace filesystem
|
|||||||
uintmax_t available;
|
uintmax_t available;
|
||||||
};
|
};
|
||||||
|
|
||||||
using file_time_type = std::chrono::time_point<std::chrono::system_clock>;// trivial-clock> ;
|
using file_time_type = std::chrono::time_point<std::chrono::system_clock>; ///< trivial-clock> ;
|
||||||
|
|
||||||
class file_status
|
class file_status
|
||||||
{
|
{
|
||||||
@@ -116,7 +160,7 @@ namespace filesystem
|
|||||||
public:
|
public:
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
using value_type = wchar_t;
|
using value_type = wchar_t;
|
||||||
const static value_type preferred_separator = '\\';
|
const static value_type preferred_separator = L'\\';
|
||||||
#else
|
#else
|
||||||
using value_type = char;
|
using value_type = char;
|
||||||
const static value_type preferred_separator = '/';
|
const static value_type preferred_separator = '/';
|
||||||
@@ -131,23 +175,41 @@ namespace filesystem
|
|||||||
_m_assign(source);
|
_m_assign(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modifiers
|
||||||
|
//void clear() noexcept;
|
||||||
|
path& make_preferred();
|
||||||
|
path& remove_filename();
|
||||||
|
//path& replace_filename(const path& replacement);
|
||||||
|
//path& replace_extension(const path& replacement = path());
|
||||||
|
//void swap(path& rhs) noexcept;
|
||||||
|
|
||||||
|
// decomposition
|
||||||
|
//path root_name() const;
|
||||||
|
//path root_directory() const;
|
||||||
|
//path root_path() const;
|
||||||
|
//path relative_path() const;
|
||||||
|
path parent_path() const;
|
||||||
|
path filename() const;
|
||||||
|
//path stem() const;
|
||||||
|
path extension() const;
|
||||||
|
|
||||||
|
// query
|
||||||
|
bool empty() const noexcept;
|
||||||
|
//bool has_root_name() const;
|
||||||
|
//bool has_root_directory() const;
|
||||||
|
//bool has_root_path() const;
|
||||||
|
//bool has_relative_path() const;
|
||||||
|
bool has_parent_path() const { return !parent_path().string().empty(); }; // temp;;
|
||||||
|
bool has_filename() const { return !filename().string().empty(); }; // temp;
|
||||||
|
//bool has_stem() const;
|
||||||
|
bool has_extension() const { return !extension().string().empty(); }; // temp
|
||||||
|
//bool is_absolute() const;
|
||||||
|
//bool is_relative() const;
|
||||||
|
|
||||||
int compare(const path& other) const;
|
int compare(const path& other) const;
|
||||||
|
|
||||||
bool empty() const;
|
|
||||||
path extension() const;
|
|
||||||
|
|
||||||
path parent_path() const;
|
|
||||||
file_type what() const;
|
file_type what() const;
|
||||||
|
|
||||||
//decomposition
|
|
||||||
path filename() const;
|
|
||||||
|
|
||||||
//modifiers
|
|
||||||
path& remove_filename();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const value_type*c_str() const;
|
const value_type*c_str() const;
|
||||||
const string_type& native() const;
|
const string_type& native() const;
|
||||||
operator string_type() const;
|
operator string_type() const;
|
||||||
@@ -203,8 +265,9 @@ namespace filesystem
|
|||||||
filesystem_error(const std::string& msg, const path& path1, std::error_code err);
|
filesystem_error(const std::string& msg, const path& path1, std::error_code err);
|
||||||
filesystem_error(const std::string& msg, const path& path1, const path& path2, std::error_code err);
|
filesystem_error(const std::string& msg, const path& path1, const path& path2, std::error_code err);
|
||||||
|
|
||||||
const path& path1() const; //noexcept
|
const path& path1() const noexcept;
|
||||||
const path& path2() const; //noexcept
|
const path& path2() const noexcept;
|
||||||
|
// const char* what() const noexcept;
|
||||||
private:
|
private:
|
||||||
path path1_;
|
path path1_;
|
||||||
path path2_;
|
path path2_;
|
||||||
@@ -215,47 +278,37 @@ namespace filesystem
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
directory_entry() = default;
|
directory_entry() = default;
|
||||||
explicit directory_entry(const path&);
|
explicit directory_entry(const ::nana::experimental::filesystem::path&);
|
||||||
|
|
||||||
//modifiers
|
//modifiers
|
||||||
void assign(const path&);
|
void assign(const ::nana::experimental::filesystem::path&);
|
||||||
void replace_filename(const path&);
|
void replace_filename(const ::nana::experimental::filesystem::path&);
|
||||||
|
|
||||||
//observers
|
//observers
|
||||||
file_status status() const;
|
file_status status() const;
|
||||||
operator const filesystem::path&() const;
|
operator const filesystem::path&() const { return path_; };
|
||||||
const filesystem::path& path() const;
|
const filesystem::path& path() const;
|
||||||
private:
|
private:
|
||||||
filesystem::path path_;
|
::nana::experimental::filesystem::path path_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// an iterator for a sequence of directory_entry elements representing the files in a directory, not an recursive_directory_iterator
|
/// InputIterator that iterate over the sequence of directory_entry elements representing the files in a directory, not an recursive_directory_iterator
|
||||||
//template<typename FileInfo>
|
|
||||||
class directory_iterator :public std::iterator<std::input_iterator_tag, directory_entry>
|
class directory_iterator :public std::iterator<std::input_iterator_tag, directory_entry>
|
||||||
{
|
{
|
||||||
using find_handle = void*;
|
using find_handle = void*;
|
||||||
public:
|
public:
|
||||||
using value_type = directory_entry ;
|
|
||||||
typedef ptrdiff_t difference_type;
|
|
||||||
typedef const directory_entry* pointer;
|
|
||||||
typedef const directory_entry& reference;
|
|
||||||
typedef std::input_iterator_tag iterator_category;
|
|
||||||
|
|
||||||
directory_iterator();
|
directory_iterator() noexcept;
|
||||||
directory_iterator(const path& file_path);
|
explicit directory_iterator(const path& dir);
|
||||||
|
|
||||||
const value_type& operator*() const;
|
const value_type& operator*() const;
|
||||||
const value_type* operator->() const;
|
const value_type* operator->() const;
|
||||||
|
|
||||||
directory_iterator& operator++();
|
directory_iterator& operator++();
|
||||||
directory_iterator operator++(int);
|
directory_iterator operator++(int); ///< extention
|
||||||
|
|
||||||
bool equal(const directory_iterator& x) const;
|
bool equal(const directory_iterator& x) const;
|
||||||
|
|
||||||
// enable directory_iterator range-based for statements
|
|
||||||
directory_iterator begin();
|
|
||||||
directory_iterator end();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename Char>
|
template<typename Char>
|
||||||
static bool _m_ignore(const Char * p)
|
static bool _m_ignore(const Char * p)
|
||||||
@@ -275,6 +328,16 @@ namespace filesystem
|
|||||||
find_handle handle_{nullptr};
|
find_handle handle_{nullptr};
|
||||||
value_type value_;
|
value_type value_;
|
||||||
};
|
};
|
||||||
|
/// enable directory_iterator range-based for statements
|
||||||
|
inline directory_iterator begin( directory_iterator iter) noexcept
|
||||||
|
{
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline directory_iterator end( const directory_iterator&) noexcept
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//class recursive_directory_iterator;
|
//class recursive_directory_iterator;
|
||||||
@@ -301,15 +364,23 @@ namespace filesystem
|
|||||||
std::uintmax_t file_size(const path& p);
|
std::uintmax_t file_size(const path& p);
|
||||||
//uintmax_t file_size(const path& p, error_code& ec) noexcept;
|
//uintmax_t file_size(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
inline bool is_directory(file_status s) { return s.type() == file_type::directory ;}
|
inline bool is_directory(file_status s) noexcept
|
||||||
|
{ return s.type() == file_type::directory ;}
|
||||||
|
|
||||||
bool is_directory(const path& p);
|
bool is_directory(const path& p);
|
||||||
inline bool is_directory(const directory_entry& d)
|
|
||||||
{
|
|
||||||
return is_directory(d.status());
|
|
||||||
}
|
|
||||||
//bool is_directory(const path& p, error_code& ec) noexcept;
|
//bool is_directory(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
//bool is_regular_file(file_status s) noexcept;
|
inline bool is_regular_file(file_status s) noexcept
|
||||||
|
{
|
||||||
|
return s.type() == file_type::regular;
|
||||||
|
}
|
||||||
|
inline bool is_regular_file(const path& p)
|
||||||
|
{
|
||||||
|
return is_regular_file(status(p));
|
||||||
|
}
|
||||||
|
// bool is_regular_file(const path& p, error_code& ec) noexcept;
|
||||||
|
// Returns: is_regular_file(status(p, ec)).Returns false if an error occurs.
|
||||||
|
|
||||||
inline bool is_empty(const path& p)
|
inline bool is_empty(const path& p)
|
||||||
{
|
{
|
||||||
@@ -330,16 +401,19 @@ namespace filesystem
|
|||||||
bool create_directory(const path& p, const path& attributes);
|
bool create_directory(const path& p, const path& attributes);
|
||||||
//bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
|
//bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
|
||||||
|
|
||||||
bool modified_file_time(const path& p, struct tm&);
|
|
||||||
|
|
||||||
path path_user();
|
/// The time of last data modification of p, determined as if by the value of the POSIX
|
||||||
|
/// stat structure member st_mtime obtained as if by POSIX stat().
|
||||||
|
file_time_type last_write_time(const path& p);
|
||||||
|
/// returns file_time_type::min() if an error occurs
|
||||||
|
//file_time_type last_write_time(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
|
|
||||||
path current_path();
|
path current_path();
|
||||||
//path current_path(error_code& ec);
|
//path current_path(error_code& ec);
|
||||||
void current_path(const path& p);
|
void current_path(const path& p); ///< chdir
|
||||||
//void current_path(const path& p, error_code& ec) noexcept;
|
//void current_path(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
|
|
||||||
bool remove(const path& p);
|
bool remove(const path& p);
|
||||||
bool remove(const path& p, std::error_code& ec); // noexcept;
|
bool remove(const path& p, std::error_code& ec); // noexcept;
|
||||||
|
|
||||||
@@ -381,4 +455,21 @@ namespace filesystem
|
|||||||
//namespace filesystem = experimental::filesystem;
|
//namespace filesystem = experimental::filesystem;
|
||||||
} //end namespace nana
|
} //end namespace nana
|
||||||
|
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
namespace experimental {
|
||||||
|
namespace filesystem {
|
||||||
|
|
||||||
|
# ifdef CXX_NO_INLINE_NAMESPACE
|
||||||
|
using namespace nana::experimental::filesystem;
|
||||||
|
# else
|
||||||
|
using namespace nana::experimental::filesystem::v1;
|
||||||
# endif
|
# endif
|
||||||
|
} // filesystem
|
||||||
|
} // experimental
|
||||||
|
} // std
|
||||||
|
|
||||||
|
#endif //NANA_USING_NANA_FILESYSTEM
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
#endif //NANA_FILESYSTEM_HPP
|
||||||
|
|||||||
129
include/nana/filesystem/filesystem_ext.hpp
Normal file
129
include/nana/filesystem/filesystem_ext.hpp
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/**
|
||||||
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
|
* Copyright(C) 2003-2016 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\filesystem\filesystem_ext.hpp
|
||||||
|
* @autor by Ariel Vina-Rodriguez:
|
||||||
|
* @brief Some convenient extensions to the filesystem library.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NANA_FILESYSTEM_EXT_HPP
|
||||||
|
#define NANA_FILESYSTEM_EXT_HPP
|
||||||
|
|
||||||
|
#include <nana/filesystem/filesystem.hpp>
|
||||||
|
|
||||||
|
namespace nana
|
||||||
|
{
|
||||||
|
namespace filesystem_ext
|
||||||
|
{
|
||||||
|
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
constexpr auto def_root = "C:";
|
||||||
|
constexpr auto def_rootstr = "C:\\";
|
||||||
|
constexpr auto def_rootname = "Local Drive(C:)";
|
||||||
|
#elif defined(NANA_LINUX)
|
||||||
|
constexpr auto def_root = "/";
|
||||||
|
constexpr auto def_rootstr = "/";
|
||||||
|
constexpr auto def_rootname = "Root/";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::experimental::filesystem::path path_user(); ///< extention ?
|
||||||
|
|
||||||
|
inline bool is_directory(const std::experimental::filesystem::directory_entry& dir) noexcept
|
||||||
|
{
|
||||||
|
return is_directory(dir.status());
|
||||||
|
}
|
||||||
|
|
||||||
|
//template<class DI> // DI = directory_iterator from std, boost, or nana : return directory_entry
|
||||||
|
class directory_only_iterator : public std::experimental::filesystem::directory_iterator
|
||||||
|
{
|
||||||
|
using directory_iterator = std::experimental::filesystem::directory_iterator;
|
||||||
|
|
||||||
|
directory_only_iterator& find_first()
|
||||||
|
{
|
||||||
|
auto end = directory_only_iterator{};
|
||||||
|
while (*this != end)
|
||||||
|
{
|
||||||
|
if (is_directory((**this).status()))
|
||||||
|
return *this;
|
||||||
|
this->directory_iterator::operator++();
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
directory_only_iterator() = default;
|
||||||
|
|
||||||
|
template <typename Arg, typename... Args>
|
||||||
|
directory_only_iterator(Arg&& arg, Args&&... args) : directory_iterator(arg, std::forward<Args>(args)...)
|
||||||
|
{
|
||||||
|
find_first();
|
||||||
|
}
|
||||||
|
|
||||||
|
directory_only_iterator& operator++()
|
||||||
|
{
|
||||||
|
this->directory_iterator::operator++();
|
||||||
|
return find_first();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline directory_only_iterator begin(directory_only_iterator iter) noexcept
|
||||||
|
{
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline directory_only_iterator end(const directory_only_iterator&) noexcept
|
||||||
|
{
|
||||||
|
return{};
|
||||||
|
}
|
||||||
|
|
||||||
|
//template<class DI> // DI = directory_iterator from std, boost, or nana : value_type directory_entry
|
||||||
|
class regular_file_only_iterator : public std::experimental::filesystem::directory_iterator
|
||||||
|
{
|
||||||
|
using directory_iterator = std::experimental::filesystem::directory_iterator;
|
||||||
|
regular_file_only_iterator& find_first()
|
||||||
|
{
|
||||||
|
while (((*this) != directory_iterator{}) && !is_regular_file((**this).status()))
|
||||||
|
this->directory_iterator::operator++();
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
regular_file_only_iterator() = default;
|
||||||
|
|
||||||
|
template <typename Arg, typename... Args>
|
||||||
|
regular_file_only_iterator(Arg&& arg, Args&&... args) : directory_iterator(std::forward<Arg>(arg), std::forward<Args>(args)...)
|
||||||
|
{
|
||||||
|
find_first();
|
||||||
|
}
|
||||||
|
|
||||||
|
regular_file_only_iterator& operator++()
|
||||||
|
{
|
||||||
|
this->directory_iterator::operator++();
|
||||||
|
return find_first();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline regular_file_only_iterator begin(regular_file_only_iterator iter) noexcept
|
||||||
|
{
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline regular_file_only_iterator end(const regular_file_only_iterator&) noexcept
|
||||||
|
{
|
||||||
|
return{};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string pretty_file_size(const std::experimental::filesystem::path& path);
|
||||||
|
|
||||||
|
std::string pretty_file_date(const std::experimental::filesystem::path& path);
|
||||||
|
|
||||||
|
bool modified_file_time(const std::experimental::filesystem::path& p, struct tm&); ///< extention ?
|
||||||
|
|
||||||
|
} // filesystem_ext
|
||||||
|
} // nana
|
||||||
|
|
||||||
|
#endif //NANA_FILESYSTEM_EXT_HPP
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_ANIMATION_HPP
|
#ifndef NANA_GUI_ANIMATION_HPP
|
||||||
#define NANA_GUI_ANIMATION_HPP
|
#define NANA_GUI_ANIMATION_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include <nana/paint/image.hpp>
|
#include <nana/paint/image.hpp>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -82,4 +82,5 @@ namespace nana
|
|||||||
impl * impl_;
|
impl * impl_;
|
||||||
};
|
};
|
||||||
} //end namespace nana
|
} //end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif //NANA_GUI_ANIMATION_HPP
|
#endif //NANA_GUI_ANIMATION_HPP
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
/*
|
/**
|
||||||
|
* \file basis.hpp
|
||||||
|
* \brief This file provides basis class and data structures required by the GUI
|
||||||
|
*
|
||||||
* Basis Implementation
|
* Basis Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/gui/basis.hpp
|
|
||||||
*
|
|
||||||
* This file provides basis class and data structrue that required by gui
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NANA_GUI_BASIS_HPP
|
#ifndef NANA_GUI_BASIS_HPP
|
||||||
#define NANA_GUI_BASIS_HPP
|
#define NANA_GUI_BASIS_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include "../basic_types.hpp"
|
#include "../basic_types.hpp"
|
||||||
#include "../traits.hpp" //metacomp::fixed_type_set
|
#include "../traits.hpp" //metacomp::fixed_type_set
|
||||||
|
|
||||||
@@ -54,14 +56,18 @@ namespace nana
|
|||||||
super,
|
super,
|
||||||
widget = 0x1,
|
widget = 0x1,
|
||||||
lite_widget = 0x3,
|
lite_widget = 0x3,
|
||||||
root = 0x5,
|
root = 0x5
|
||||||
frame = 0x9
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
|
,frame = 0x9
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
//wait for constexpr
|
//wait for constexpr
|
||||||
struct widget_tag{ static const flags value = flags::widget; };
|
struct widget_tag{ static const flags value = flags::widget; };
|
||||||
struct lite_widget_tag : widget_tag{ static const flags value = flags::lite_widget;};
|
struct lite_widget_tag : public widget_tag{ static const flags value = flags::lite_widget; };
|
||||||
struct root_tag : widget_tag{ static const flags value = flags::root; };
|
struct root_tag : public widget_tag{ static const flags value = flags::root; };
|
||||||
struct frame_tag: widget_tag{ static const flags value = flags::frame; };
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
|
struct frame_tag : public widget_tag{ static const flags value = flags::frame; };
|
||||||
|
#endif
|
||||||
}// end namespace category
|
}// end namespace category
|
||||||
|
|
||||||
using native_window_type = detail::native_window_handle_impl*;
|
using native_window_type = detail::native_window_handle_impl*;
|
||||||
@@ -95,6 +101,7 @@ namespace nana
|
|||||||
undo = substitute,
|
undo = substitute,
|
||||||
|
|
||||||
//System Code for OS
|
//System Code for OS
|
||||||
|
os_tab = 0x09,
|
||||||
os_shift = 0x10,
|
os_shift = 0x10,
|
||||||
os_ctrl = 0x11,
|
os_ctrl = 0x11,
|
||||||
os_pageup = 0x21, os_pagedown,
|
os_pageup = 0x21, os_pagedown,
|
||||||
@@ -151,7 +158,25 @@ namespace nana
|
|||||||
appearance();
|
appearance();
|
||||||
appearance(bool has_decoration, bool taskbar, bool floating, bool no_activate, bool min, bool max, bool sizable);
|
appearance(bool has_decoration, bool taskbar, bool floating, bool no_activate, bool min, bool max, bool sizable);
|
||||||
};
|
};
|
||||||
/// Provided to generate an appearance object with better readability and understandability
|
|
||||||
|
|
||||||
|
/** @brief Provided to generate an appearance object with better readability and understandability
|
||||||
|
|
||||||
|
A window has an appearance. This appearance can be specified when a window is being created.
|
||||||
|
To determine the appearance of a window there is a structure named nana::appearance with
|
||||||
|
a bool member for each feature with can be included or excluded in the "apereance" of the windows form.
|
||||||
|
But in practical development is hard to describe the style of the appearance using the struct nana::appearance.
|
||||||
|
If a form would to be defined without min/max button and sizable border, then
|
||||||
|
|
||||||
|
\code{.CPP}
|
||||||
|
nana::form form(x, y, width, height, nana::appearance(false, false, false, true, false));
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
This piece of code may be confusing because of the 5 parameters of the constructor of `nana::form`. So the library provides a helper class for making it easy.
|
||||||
|
For better readability and understandability Nana provides three templates classes to generate an appearance object:
|
||||||
|
nana::appear::decorate, nana::appear::bald and nana::appear::optional. Each provide an operator
|
||||||
|
that return a corresponding nana::appearance with predefined values.
|
||||||
|
*/
|
||||||
struct appear
|
struct appear
|
||||||
{
|
{
|
||||||
struct minimize{};
|
struct minimize{};
|
||||||
@@ -160,7 +185,20 @@ namespace nana
|
|||||||
struct taskbar{};
|
struct taskbar{};
|
||||||
struct floating{};
|
struct floating{};
|
||||||
struct no_activate{};
|
struct no_activate{};
|
||||||
/// Create an appearance of a window with "decoration"
|
|
||||||
|
/** @brief Create an appearance of a window with "decoration" in non-client area, such as title bar
|
||||||
|
*
|
||||||
|
* We can create a form without min/max button and sizable border like this:
|
||||||
|
* \code{.CPP}
|
||||||
|
* using nana::appear;
|
||||||
|
* nana::form form(x, y, width, height, appear::decorate<appear::taskbar>());
|
||||||
|
* \endcode
|
||||||
|
* The appearance created by appear::decorate<>() has a titlebar and borders that are draw by the
|
||||||
|
* platform- window manager. If a window needs a minimize button, it should be:
|
||||||
|
* \code{.CPP}
|
||||||
|
* appear::decorate<appear::minimize, appear::taskbar>()
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
template< typename Minimize = null_type,
|
template< typename Minimize = null_type,
|
||||||
typename Maximize = null_type,
|
typename Maximize = null_type,
|
||||||
typename Sizable = null_type,
|
typename Sizable = null_type,
|
||||||
@@ -181,7 +219,8 @@ namespace nana
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/// Create an appearance of a window without "decoration"
|
|
||||||
|
/// Create an appearance of a window without "decoration" with no titlebar and no 3D-look borders.
|
||||||
template < typename Taskbar = null_type,
|
template < typename Taskbar = null_type,
|
||||||
typename Floating = null_type,
|
typename Floating = null_type,
|
||||||
typename NoActive = null_type,
|
typename NoActive = null_type,
|
||||||
@@ -225,5 +264,39 @@ namespace nana
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};//end namespace apper
|
};//end namespace apper
|
||||||
|
|
||||||
|
/// Interface for caret operations
|
||||||
|
class caret_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~caret_interface() = default;
|
||||||
|
|
||||||
|
virtual void disable_throw() noexcept = 0;
|
||||||
|
|
||||||
|
virtual void effective_range(const rectangle& range) = 0;
|
||||||
|
|
||||||
|
virtual void position(const point& pos) = 0;
|
||||||
|
virtual point position() const = 0;
|
||||||
|
|
||||||
|
virtual void dimension(const size& size) = 0;
|
||||||
|
virtual size dimension() const = 0;
|
||||||
|
|
||||||
|
virtual void visible(bool visibility) = 0;
|
||||||
|
virtual bool visible() const = 0;
|
||||||
|
};//end class caret_interface
|
||||||
|
|
||||||
|
namespace parameters
|
||||||
|
{
|
||||||
|
/// The system-wide parameters for mouse wheel
|
||||||
|
struct mouse_wheel
|
||||||
|
{
|
||||||
|
unsigned lines; ///< The number of lines to scroll when the vertical mouse wheel is moved.
|
||||||
|
unsigned characters; ///< The number of characters to scroll when the horizontal mouse wheel is moved.
|
||||||
|
|
||||||
|
mouse_wheel();
|
||||||
|
};
|
||||||
|
}
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/**
|
||||||
* A Basic Window Widget Definition
|
* A Basic Window Widget Definition
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
@@ -7,14 +7,16 @@
|
|||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/gui/detail/basic_window.hpp
|
* @file nana/gui/detail/basic_window.hpp
|
||||||
|
* @brief A Basic Window Widget Definition
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NANA_GUI_DETAIL_BASIC_WINDOW_HPP
|
#ifndef NANA_GUI_DETAIL_BASIC_WINDOW_HPP
|
||||||
#define NANA_GUI_DETAIL_BASIC_WINDOW_HPP
|
#define NANA_GUI_DETAIL_BASIC_WINDOW_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include "drawer.hpp"
|
#include "drawer.hpp"
|
||||||
#include "events_holder.hpp"
|
#include "events_holder.hpp"
|
||||||
#include "widget_colors.hpp"
|
#include "widget_geometrics.hpp"
|
||||||
#include "widget_notifier_interface.hpp"
|
#include "widget_notifier_interface.hpp"
|
||||||
#include <nana/basic_types.hpp>
|
#include <nana/basic_types.hpp>
|
||||||
#include <nana/system/platform.hpp>
|
#include <nana/system/platform.hpp>
|
||||||
@@ -30,47 +32,52 @@ namespace detail
|
|||||||
invisible, visible, displayed
|
invisible, visible, displayed
|
||||||
};
|
};
|
||||||
|
|
||||||
class caret_descriptor
|
class caret
|
||||||
|
: public caret_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef basic_window core_window_t;
|
caret(basic_window* owner, const size& size);
|
||||||
|
~caret();
|
||||||
|
|
||||||
caret_descriptor(core_window_t*, unsigned width, unsigned height);
|
void activate(bool activity);
|
||||||
~caret_descriptor();
|
basic_window* owner() const noexcept;
|
||||||
void set_active(bool);
|
|
||||||
core_window_t* window() const;
|
|
||||||
void position(int x, int y);
|
|
||||||
void effective_range(::nana::rectangle);
|
|
||||||
::nana::point position() const;
|
|
||||||
void visible(bool isshow);
|
|
||||||
bool visible() const;
|
|
||||||
::nana::size size() const;
|
|
||||||
void size(const ::nana::size&);
|
|
||||||
void update();
|
void update();
|
||||||
private:
|
public:
|
||||||
core_window_t* wd_;
|
//Implement caret_interface functions
|
||||||
::nana::point point_;
|
|
||||||
::nana::size size_;
|
|
||||||
::nana::size paint_size_;
|
|
||||||
visible_state visible_state_;
|
|
||||||
bool out_of_range_;
|
|
||||||
::nana::rectangle effective_range_;
|
|
||||||
};//end class caret_descriptor
|
|
||||||
|
|
||||||
//tab_type
|
//This function is useless for class caret, see caret_proxy.
|
||||||
//@brief: Define some constant about tab category, these flags can be combine with operator |
|
void disable_throw() noexcept override;
|
||||||
|
void effective_range(const rectangle& r) override;
|
||||||
|
void position(const point& pos) override;
|
||||||
|
nana::point position() const override;
|
||||||
|
size dimension() const override;
|
||||||
|
void dimension(const size& s);
|
||||||
|
void visible(bool visibility) override;
|
||||||
|
bool visible() const override;
|
||||||
|
private:
|
||||||
|
basic_window * owner_;
|
||||||
|
point position_;
|
||||||
|
size size_;
|
||||||
|
size visual_size_;
|
||||||
|
visible_state visibility_{ visible_state::invisible };
|
||||||
|
bool out_of_range_{ false };
|
||||||
|
rectangle effect_range_;
|
||||||
|
};//end class caret
|
||||||
|
|
||||||
|
|
||||||
|
/// Define some constant about tab category, these flags can be combine with operator |
|
||||||
struct tab_type
|
struct tab_type
|
||||||
{
|
{
|
||||||
enum t
|
enum t
|
||||||
{
|
{
|
||||||
none, //process by nana
|
none, ///< process by nana
|
||||||
tabstop, //move to the next tabstop window
|
tabstop, ///< move to the next tabstop window
|
||||||
eating, //process by current window
|
eating, ///< process by current window
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//struct basic_window
|
|
||||||
//@brief: a window data structure descriptor
|
/// a window data structure descriptor
|
||||||
struct basic_window
|
struct basic_window
|
||||||
: public events_holder
|
: public events_holder
|
||||||
{
|
{
|
||||||
@@ -87,8 +94,7 @@ namespace detail
|
|||||||
bool rendered;
|
bool rendered;
|
||||||
};
|
};
|
||||||
|
|
||||||
//basic_window
|
/// constructor for the root window
|
||||||
//@brief: constructor for the root window
|
|
||||||
basic_window(basic_window* owner, std::unique_ptr<widget_notifier_interface>&&, category::root_tag**);
|
basic_window(basic_window* owner, std::unique_ptr<widget_notifier_interface>&&, category::root_tag**);
|
||||||
|
|
||||||
template<typename Category>
|
template<typename Category>
|
||||||
@@ -105,23 +111,26 @@ namespace detail
|
|||||||
|
|
||||||
~basic_window();
|
~basic_window();
|
||||||
|
|
||||||
//bind_native_window
|
/// bind a native window and baisc_window
|
||||||
//@brief: bind a native window and baisc_window
|
|
||||||
void bind_native_window(native_window_type, unsigned width, unsigned height, unsigned extra_width, unsigned extra_height, paint::graphics&);
|
void bind_native_window(native_window_type, unsigned width, unsigned height, unsigned extra_width, unsigned extra_height, paint::graphics&);
|
||||||
|
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
void frame_window(native_window_type);
|
void frame_window(native_window_type);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool is_ancestor_of(const basic_window* wd) const;
|
bool is_ancestor_of(const basic_window* wd) const;
|
||||||
bool visible_parents() const;
|
bool visible_parents() const;
|
||||||
bool displayed() const;
|
bool displayed() const;
|
||||||
bool belong_to_lazy() const;
|
bool belong_to_lazy() const;
|
||||||
const basic_window * child_caret() const; //Returns a child which owns a caret
|
const basic_window * child_caret() const; ///< Returns the child which owns the caret
|
||||||
|
|
||||||
bool is_draw_through() const; ///< Determines whether it is a draw-through window.
|
bool is_draw_through() const; ///< Determines whether it is a draw-through window.
|
||||||
|
|
||||||
basic_window * seek_non_lite_widget_ancestor() const;
|
basic_window * seek_non_lite_widget_ancestor() const;
|
||||||
|
|
||||||
|
void set_action(mouse_action);
|
||||||
public:
|
public:
|
||||||
//Override event_holder
|
/// Override event_holder
|
||||||
bool set_events(const std::shared_ptr<general_events>&) override;
|
bool set_events(const std::shared_ptr<general_events>&) override;
|
||||||
general_events * get_events() const override;
|
general_events * get_events() const override;
|
||||||
private:
|
private:
|
||||||
@@ -131,7 +140,7 @@ namespace detail
|
|||||||
#if defined(NANA_LINUX) || defined(NANA_MACOS)
|
#if defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||||
point pos_native;
|
point pos_native;
|
||||||
#endif
|
#endif
|
||||||
point pos_root; //coordinate for root window
|
point pos_root; ///< coordinates of the root window
|
||||||
point pos_owner;
|
point pos_owner;
|
||||||
size dimension;
|
size dimension;
|
||||||
::nana::size min_track_size;
|
::nana::size min_track_size;
|
||||||
@@ -146,9 +155,9 @@ namespace detail
|
|||||||
basic_window *owner;
|
basic_window *owner;
|
||||||
|
|
||||||
native_string_type title;
|
native_string_type title;
|
||||||
::nana::detail::drawer drawer; //Self Drawer with owen graphics
|
::nana::detail::drawer drawer; ///< Self Drawer with owen graphics
|
||||||
basic_window* root_widget; //A pointer refers to the root basic window, if the window is a root, the pointer refers to itself.
|
basic_window* root_widget; ///< A pointer refers to the root basic window, if the window is a root, the pointer refers to itself.
|
||||||
paint::graphics* root_graph; //Refer to the root buffer graphics
|
paint::graphics* root_graph; ///< Refer to the root buffer graphics
|
||||||
cursor predef_cursor;
|
cursor predef_cursor;
|
||||||
std::unique_ptr<widget_notifier_interface> widget_notifier;
|
std::unique_ptr<widget_notifier_interface> widget_notifier;
|
||||||
|
|
||||||
@@ -156,30 +165,33 @@ namespace detail
|
|||||||
{
|
{
|
||||||
bool enabled :1;
|
bool enabled :1;
|
||||||
bool dbl_click :1;
|
bool dbl_click :1;
|
||||||
bool captured :1; //if mouse button is down, it always receive mouse move even the mouse is out of its rectangle
|
bool captured :1; ///< if mouse button is down, it always receive mouse move even the mouse is out of its rectangle
|
||||||
bool modal :1;
|
bool modal :1;
|
||||||
bool take_active:1; //If take_active is false, other.active_window still keeps the focus.
|
bool take_active:1; ///< If take_active is false, other.active_window still keeps the focus.
|
||||||
bool refreshing :1;
|
bool refreshing :1;
|
||||||
bool destroying :1;
|
bool destroying :1;
|
||||||
bool dropable :1; //Whether the window has make mouse_drop event.
|
bool dropable :1; ///< Whether the window has make mouse_drop event.
|
||||||
bool fullscreen :1; //When the window is maximizing whether it fit for fullscreen.
|
bool fullscreen :1; ///< When the window is maximizing whether it fit for fullscreen.
|
||||||
bool borderless :1;
|
bool borderless :1;
|
||||||
bool make_bground_declared : 1; //explicitly make bground for bground effects
|
bool make_bground_declared : 1; ///< explicitly make bground for bground effects
|
||||||
bool ignore_menubar_focus : 1; //A flag indicates whether the menubar sets the focus.
|
bool ignore_menubar_focus : 1; ///< A flag indicates whether the menubar sets the focus.
|
||||||
bool ignore_mouse_focus : 1; //A flag indicates whether the widget accepts focus when clicking on it
|
bool ignore_mouse_focus : 1; ///< A flag indicates whether the widget accepts focus when clicking on it
|
||||||
bool space_click_enabled : 1; //A flag indicates whether enable mouse_down/click/mouse_up when pressing and releasing whitespace key.
|
bool space_click_enabled : 1; ///< A flag indicates whether enable mouse_down/click/mouse_up when pressing and releasing whitespace key.
|
||||||
unsigned Reserved :18;
|
unsigned Reserved :18;
|
||||||
unsigned char tab; //indicate a window that can receive the keyboard TAB
|
unsigned char tab; ///< indicate a window that can receive the keyboard TAB
|
||||||
mouse_action action;
|
mouse_action action;
|
||||||
|
mouse_action action_before;
|
||||||
}flags;
|
}flags;
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
caret_descriptor* caret;
|
|
||||||
std::shared_ptr<general_events> events_ptr;
|
|
||||||
}together;
|
|
||||||
|
|
||||||
widget_colors* scheme{ nullptr };
|
struct annex_components
|
||||||
|
{
|
||||||
|
caret* caret_ptr{ nullptr };
|
||||||
|
|
||||||
|
//The following pointers refer to the widget's object.
|
||||||
|
std::shared_ptr<general_events> events_ptr;
|
||||||
|
widget_geometrics* scheme{ nullptr };
|
||||||
|
}annex;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@@ -190,15 +202,19 @@ namespace detail
|
|||||||
|
|
||||||
struct other_tag
|
struct other_tag
|
||||||
{
|
{
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
struct attr_frame_tag
|
struct attr_frame_tag
|
||||||
{
|
{
|
||||||
native_window_type container{nullptr};
|
native_window_type container{nullptr};
|
||||||
std::vector<native_window_type> attach;
|
std::vector<native_window_type> attach;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct attr_root_tag
|
struct attr_root_tag
|
||||||
{
|
{
|
||||||
container frames; //initialization is null, it will be created while creating a frame widget. Refer to WindowManager::create_frame
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
|
container frames; ///< initialization is null, it will be created while creating a frame widget. Refer to WindowManager::create_frame
|
||||||
|
#endif
|
||||||
container tabstop;
|
container tabstop;
|
||||||
std::vector<edge_nimbus_action> effects_edge_nimbus;
|
std::vector<edge_nimbus_action> effects_edge_nimbus;
|
||||||
basic_window* focus{nullptr};
|
basic_window* focus{nullptr};
|
||||||
@@ -210,32 +226,35 @@ namespace detail
|
|||||||
cursor state_cursor{nana::cursor::arrow};
|
cursor state_cursor{nana::cursor::arrow};
|
||||||
basic_window* state_cursor_window{ nullptr };
|
basic_window* state_cursor_window{ nullptr };
|
||||||
|
|
||||||
std::function<void()> draw_through; // A draw through renderer for root widgets.
|
std::function<void()> draw_through; ///< A draw through renderer for root widgets.
|
||||||
};
|
};
|
||||||
|
|
||||||
const category::flags category;
|
const category::flags category;
|
||||||
basic_window *active_window; //if flags.take_active is false, the active_window still keeps the focus,
|
basic_window *active_window; ///< if flags.take_active is false, the active_window still keeps the focus,
|
||||||
//if the active_window is null, the parent of this window keeps focus.
|
///< if the active_window is null, the parent of this window keeps focus.
|
||||||
paint::graphics glass_buffer; //if effect.bground is avaiable. Refer to window_layout::make_bground.
|
paint::graphics glass_buffer; ///< if effect.bground is avaiable. Refer to window_layout::make_bground.
|
||||||
update_state upd_state;
|
update_state upd_state;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
attr_root_tag * root;
|
attr_root_tag * root;
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
attr_frame_tag * frame;
|
attr_frame_tag * frame;
|
||||||
|
#endif
|
||||||
}attribute;
|
}attribute;
|
||||||
|
|
||||||
other_tag(category::flags);
|
other_tag(category::flags);
|
||||||
~other_tag();
|
~other_tag();
|
||||||
}other;
|
}other;
|
||||||
|
|
||||||
native_window_type root; //root Window handle
|
native_window_type root; ///< root Window handle
|
||||||
unsigned thread_id; //the identifier of the thread that created the window.
|
unsigned thread_id; ///< the identifier of the thread that created the window.
|
||||||
unsigned index;
|
unsigned index;
|
||||||
container children;
|
container children;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
/*
|
/**
|
||||||
* A Bedrock Implementation
|
* A Bedrock Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/gui/detail/bedrock.hpp
|
* @file nana/gui/detail/bedrock.hpp
|
||||||
|
*
|
||||||
|
* @brief A Bedrock Implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NANA_GUI_DETAIL_BEDROCK_HPP
|
#ifndef NANA_GUI_DETAIL_BEDROCK_HPP
|
||||||
#define NANA_GUI_DETAIL_BEDROCK_HPP
|
#define NANA_GUI_DETAIL_BEDROCK_HPP
|
||||||
#include "general_events.hpp"
|
#include "general_events.hpp"
|
||||||
#include "color_schemes.hpp"
|
#include "color_schemes.hpp"
|
||||||
#include "internal_scope_guard.hpp"
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -26,12 +27,14 @@ namespace detail
|
|||||||
struct basic_window;
|
struct basic_window;
|
||||||
class window_manager;
|
class window_manager;
|
||||||
|
|
||||||
//class bedrock
|
|
||||||
//@brief: bedrock is a fundamental core component, it provides a abstract to the OS platform
|
/// @brief fundamental core component, it provides an abstraction to the OS platform and some basic functions.
|
||||||
// and some basic functions.
|
|
||||||
class bedrock
|
class bedrock
|
||||||
{
|
{
|
||||||
bedrock();
|
bedrock();
|
||||||
|
|
||||||
|
bedrock(const bedrock&) = delete;
|
||||||
|
bedrock& operator=(const bedrock&) = delete;
|
||||||
public:
|
public:
|
||||||
using core_window_t = basic_window;
|
using core_window_t = basic_window;
|
||||||
|
|
||||||
@@ -41,14 +44,13 @@ namespace detail
|
|||||||
|
|
||||||
~bedrock();
|
~bedrock();
|
||||||
void pump_event(window, bool is_modal);
|
void pump_event(window, bool is_modal);
|
||||||
void map_thread_root_buffer(core_window_t*, bool forced, const rectangle* update_area = nullptr);
|
void flush_surface(core_window_t*, bool forced, const rectangle* update_area = nullptr);
|
||||||
static int inc_window(unsigned tid = 0);
|
static int inc_window(unsigned tid = 0);
|
||||||
thread_context* open_thread_context(unsigned tid = 0);
|
thread_context* open_thread_context(unsigned tid = 0);
|
||||||
thread_context* get_thread_context(unsigned tid = 0);
|
thread_context* get_thread_context(unsigned tid = 0);
|
||||||
void remove_thread_context(unsigned tid = 0);
|
void remove_thread_context(unsigned tid = 0);
|
||||||
static bedrock& instance();
|
static bedrock& instance();
|
||||||
|
|
||||||
::nana::category::flags category(core_window_t*);
|
|
||||||
core_window_t* focus();
|
core_window_t* focus();
|
||||||
|
|
||||||
void set_menubar_taken(core_window_t*);
|
void set_menubar_taken(core_window_t*);
|
||||||
@@ -62,8 +64,9 @@ namespace detail
|
|||||||
void erase_menu(bool try_destroy);
|
void erase_menu(bool try_destroy);
|
||||||
|
|
||||||
void get_key_state(arg_keyboard&);
|
void get_key_state(arg_keyboard&);
|
||||||
bool set_keyboard_shortkey(bool yes);
|
|
||||||
bool whether_keyboard_shortkey() const;
|
bool shortkey_occurred(bool status);
|
||||||
|
bool shortkey_occurred() const;
|
||||||
|
|
||||||
element_store& get_element_store() const;
|
element_store& get_element_store() const;
|
||||||
void map_through_widgets(core_window_t*, native_drawable_type);
|
void map_through_widgets(core_window_t*, native_drawable_type);
|
||||||
@@ -71,6 +74,7 @@ namespace detail
|
|||||||
void event_expose(core_window_t *, bool exposed);
|
void event_expose(core_window_t *, bool exposed);
|
||||||
void event_move(core_window_t*, int x, int y);
|
void event_move(core_window_t*, int x, int y);
|
||||||
bool event_msleave(core_window_t*);
|
bool event_msleave(core_window_t*);
|
||||||
|
void event_focus_changed(core_window_t* root_wd, native_window_type receiver, bool getting);
|
||||||
void thread_context_destroy(core_window_t*);
|
void thread_context_destroy(core_window_t*);
|
||||||
void thread_context_lazy_refresh();
|
void thread_context_lazy_refresh();
|
||||||
void update_cursor(core_window_t*);
|
void update_cursor(core_window_t*);
|
||||||
@@ -78,16 +82,13 @@ namespace detail
|
|||||||
void define_state_cursor(core_window_t*, nana::cursor, thread_context*);
|
void define_state_cursor(core_window_t*, nana::cursor, thread_context*);
|
||||||
void undefine_state_cursor(core_window_t*, thread_context*);
|
void undefine_state_cursor(core_window_t*, thread_context*);
|
||||||
|
|
||||||
widget_colors& get_scheme_template(scheme_factory_base&&);
|
color_schemes& scheme();
|
||||||
widget_colors* make_scheme(scheme_factory_base&&);
|
|
||||||
|
|
||||||
events_operation& evt_operation();
|
events_operation& evt_operation();
|
||||||
window_manager& wd_manager();
|
window_manager& wd_manager();
|
||||||
|
|
||||||
void manage_form_loader(core_window_t*, bool insert_or_remove);
|
void manage_form_loader(core_window_t*, bool insert_or_remove);
|
||||||
public:
|
public:
|
||||||
bool emit(event_code, core_window_t*, const event_arg&, bool ask_update, thread_context*);
|
bool emit(event_code, core_window_t*, const event_arg&, bool ask_update, thread_context*);
|
||||||
bool emit_drawer(event_code, core_window_t*, const event_arg&, thread_context*);
|
|
||||||
private:
|
private:
|
||||||
void _m_emit_core(event_code, core_window_t*, bool draw_only, const event_arg&);
|
void _m_emit_core(event_code, core_window_t*, bool draw_only, const event_arg&);
|
||||||
void _m_event_filter(event_code, core_window_t*, thread_context*);
|
void _m_event_filter(event_code, core_window_t*, thread_context*);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef NANA_DETAIL_BEDROCK_PI_DATA_HPP
|
#ifndef NANA_DETAIL_BEDROCK_PI_DATA_HPP
|
||||||
#define NANA_DETAIL_BEDROCK_PI_DATA_HPP
|
#define NANA_DETAIL_BEDROCK_PI_DATA_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include <nana/gui/detail/bedrock.hpp>
|
#include <nana/gui/detail/bedrock.hpp>
|
||||||
#include "color_schemes.hpp"
|
#include "color_schemes.hpp"
|
||||||
#include "events_operation.hpp"
|
#include "events_operation.hpp"
|
||||||
@@ -17,7 +19,20 @@ namespace nana
|
|||||||
events_operation evt_operation;
|
events_operation evt_operation;
|
||||||
window_manager wd_manager;
|
window_manager wd_manager;
|
||||||
std::set<core_window_t*> auto_form_set;
|
std::set<core_window_t*> auto_form_set;
|
||||||
|
bool shortkey_occurred{ false };
|
||||||
|
|
||||||
|
struct menu_rep
|
||||||
|
{
|
||||||
|
core_window_t* taken_window{ nullptr };
|
||||||
|
bool delay_restore{ false };
|
||||||
|
native_window_type window{ nullptr };
|
||||||
|
native_window_type owner{ nullptr };
|
||||||
|
bool has_keyboard{ false };
|
||||||
|
}menu;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Color Schemes
|
* Color Schemes
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -13,26 +13,27 @@
|
|||||||
#ifndef NANA_DETAIL_COLOR_SCHEMES_HPP
|
#ifndef NANA_DETAIL_COLOR_SCHEMES_HPP
|
||||||
#define NANA_DETAIL_COLOR_SCHEMES_HPP
|
#define NANA_DETAIL_COLOR_SCHEMES_HPP
|
||||||
|
|
||||||
#include "widget_colors.hpp"
|
#include "widget_geometrics.hpp"
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class scheme_factory_base
|
class scheme_factory_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct factory_identifier{};
|
struct factory_identifier{};
|
||||||
virtual ~scheme_factory_base() = default;
|
virtual ~scheme_factory_interface() = default;
|
||||||
|
|
||||||
virtual factory_identifier* get_id() const = 0;
|
virtual factory_identifier* get_id() const = 0;
|
||||||
virtual widget_colors* create() = 0;
|
virtual widget_geometrics* create() = 0;
|
||||||
virtual widget_colors* create(widget_colors&) = 0;
|
virtual widget_geometrics* create(widget_geometrics&) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<typename Scheme>
|
template<typename Scheme>
|
||||||
class scheme_factory
|
class scheme_factory
|
||||||
: public scheme_factory_base
|
: public scheme_factory_interface
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
factory_identifier* get_id() const override
|
factory_identifier* get_id() const override
|
||||||
@@ -40,12 +41,12 @@ namespace nana
|
|||||||
return &fid_;
|
return &fid_;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget_colors* create() override
|
widget_geometrics* create() override
|
||||||
{
|
{
|
||||||
return (new Scheme);
|
return (new Scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
widget_colors* create(widget_colors& other) override
|
widget_geometrics* create(widget_geometrics& other) override
|
||||||
{
|
{
|
||||||
return (new Scheme(static_cast<Scheme&>(other)));
|
return (new Scheme(static_cast<Scheme&>(other)));
|
||||||
}
|
}
|
||||||
@@ -54,7 +55,7 @@ namespace nana
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename Scheme>
|
template<typename Scheme>
|
||||||
scheme_factory_base::factory_identifier scheme_factory<Scheme>::fid_;
|
scheme_factory_interface::factory_identifier scheme_factory<Scheme>::fid_;
|
||||||
|
|
||||||
class color_schemes
|
class color_schemes
|
||||||
{
|
{
|
||||||
@@ -64,13 +65,13 @@ namespace nana
|
|||||||
color_schemes& operator=(const color_schemes&) = delete;
|
color_schemes& operator=(const color_schemes&) = delete;
|
||||||
color_schemes& operator=(color_schemes&&) = delete;
|
color_schemes& operator=(color_schemes&&) = delete;
|
||||||
public:
|
public:
|
||||||
using scheme = widget_colors;
|
using scheme = widget_geometrics;
|
||||||
|
|
||||||
color_schemes();
|
color_schemes();
|
||||||
~color_schemes();
|
~color_schemes();
|
||||||
|
|
||||||
scheme& scheme_template(scheme_factory_base&&);
|
scheme& scheme_template(scheme_factory_interface&&);
|
||||||
scheme* create(scheme_factory_base&&);
|
scheme* create(scheme_factory_interface&&);
|
||||||
private:
|
private:
|
||||||
implement * impl_;
|
implement * impl_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#ifndef NANA_GUI_DETAIL_DRAWER_HPP
|
#ifndef NANA_GUI_DETAIL_DRAWER_HPP
|
||||||
#define NANA_GUI_DETAIL_DRAWER_HPP
|
#define NANA_GUI_DETAIL_DRAWER_HPP
|
||||||
|
|
||||||
#include <vector>
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include "general_events.hpp"
|
#include "general_events.hpp"
|
||||||
#include <nana/paint/graphics.hpp>
|
#include <nana/paint/graphics.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -28,14 +28,23 @@ namespace nana
|
|||||||
}
|
}
|
||||||
|
|
||||||
class drawer_trigger
|
class drawer_trigger
|
||||||
: ::nana::noncopyable, ::nana::nonmovable
|
|
||||||
{
|
{
|
||||||
friend class detail::drawer;
|
friend class detail::drawer;
|
||||||
|
|
||||||
|
//Noncopyable
|
||||||
|
drawer_trigger(const drawer_trigger&) = delete;
|
||||||
|
drawer_trigger& operator=(const drawer_trigger&) = delete;
|
||||||
|
|
||||||
|
//Nonmovable
|
||||||
|
drawer_trigger(drawer_trigger&&) = delete;
|
||||||
|
drawer_trigger& operator=(drawer_trigger&&) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using widget_reference = widget&;
|
using widget_reference = widget&;
|
||||||
using graph_reference = paint::graphics&;
|
using graph_reference = paint::graphics&;
|
||||||
|
|
||||||
virtual ~drawer_trigger();
|
drawer_trigger() = default;
|
||||||
|
virtual ~drawer_trigger() = default;
|
||||||
virtual void attached(widget_reference, graph_reference); //none-const
|
virtual void attached(widget_reference, graph_reference); //none-const
|
||||||
virtual void detached(); //none-const
|
virtual void detached(); //none-const
|
||||||
|
|
||||||
@@ -72,21 +81,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
struct basic_window;
|
struct basic_window;
|
||||||
|
|
||||||
namespace dynamic_drawing
|
|
||||||
{
|
|
||||||
//declaration
|
|
||||||
class object;
|
|
||||||
}
|
|
||||||
|
|
||||||
//@brief: Every window has a drawer, the drawer holds a drawer_trigger for
|
//@brief: Every window has a drawer, the drawer holds a drawer_trigger for
|
||||||
// a widget.
|
// a widget.
|
||||||
class drawer
|
class drawer
|
||||||
: nana::noncopyable, nana::nonmovable
|
: nana::noncopyable, nana::nonmovable
|
||||||
{
|
{
|
||||||
enum{
|
|
||||||
event_size = static_cast<int>(event_code::end)
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class method_state
|
enum class method_state
|
||||||
{
|
{
|
||||||
pending,
|
pending,
|
||||||
@@ -94,6 +93,7 @@ namespace nana
|
|||||||
not_overrided
|
not_overrided
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
|
drawer();
|
||||||
~drawer();
|
~drawer();
|
||||||
|
|
||||||
void bind(basic_window*);
|
void bind(basic_window*);
|
||||||
@@ -126,48 +126,48 @@ namespace nana
|
|||||||
void* draw(std::function<void(paint::graphics&)> &&, bool diehard);
|
void* draw(std::function<void(paint::graphics&)> &&, bool diehard);
|
||||||
void erase(void* diehard);
|
void erase(void* diehard);
|
||||||
private:
|
private:
|
||||||
void _m_bground_pre();
|
void _m_effect_bground(bool before);
|
||||||
void _m_bground_end();
|
|
||||||
void _m_draw_dynamic_drawing_object();
|
|
||||||
bool _m_lazy_decleared() const;
|
bool _m_lazy_decleared() const;
|
||||||
|
method_state& _m_mth_state(int pos);
|
||||||
|
|
||||||
template<typename Arg, typename Mfptr>
|
template<typename Arg, typename Mfptr>
|
||||||
void _m_emit(event_code evt_code, const Arg& arg, Mfptr mfptr)
|
void _m_emit(event_code evt_code, const Arg& arg, Mfptr mfptr)
|
||||||
{
|
{
|
||||||
const int pos = static_cast<int>(evt_code);
|
const int pos = static_cast<int>(evt_code);
|
||||||
if (realizer_ && (method_state::not_overrided != mth_state_[pos]))
|
|
||||||
{
|
|
||||||
_m_bground_pre();
|
|
||||||
|
|
||||||
if (method_state::pending == mth_state_[pos])
|
auto realizer = this->realizer();
|
||||||
|
auto & mth_state = _m_mth_state(pos);
|
||||||
|
|
||||||
|
if (realizer && (method_state::not_overrided != mth_state))
|
||||||
{
|
{
|
||||||
(realizer_->*mfptr)(graphics, arg);
|
_m_effect_bground(true);
|
||||||
|
|
||||||
|
if (method_state::pending == mth_state)
|
||||||
|
{
|
||||||
|
(realizer->*mfptr)(graphics, arg);
|
||||||
|
|
||||||
//Check realizer, when the window is closed in that event handler, the drawer will be
|
//Check realizer, when the window is closed in that event handler, the drawer will be
|
||||||
//detached and realizer will be a nullptr
|
//detached and realizer will be a nullptr
|
||||||
if(realizer_)
|
if (realizer)
|
||||||
mth_state_[pos] = (realizer_->_m_overrided(evt_code) ? method_state::overrided : method_state::not_overrided);
|
mth_state = (realizer->_m_overrided(evt_code) ? method_state::overrided : method_state::not_overrided);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
(realizer_->*mfptr)(graphics, arg);
|
(realizer->*mfptr)(graphics, arg);
|
||||||
|
|
||||||
if (_m_lazy_decleared())
|
if (_m_lazy_decleared())
|
||||||
{
|
_m_effect_bground(false);
|
||||||
_m_draw_dynamic_drawing_object();
|
|
||||||
_m_bground_end();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
nana::paint::graphics graphics;
|
nana::paint::graphics graphics;
|
||||||
private:
|
private:
|
||||||
basic_window* core_window_{nullptr};
|
struct data_implement;
|
||||||
drawer_trigger* realizer_{nullptr};
|
|
||||||
std::vector<dynamic_drawing::object*> dynamic_drawing_objects_;
|
data_implement * const data_impl_;
|
||||||
bool refreshing_{false};
|
|
||||||
method_state mth_state_[event_size];
|
|
||||||
};
|
};
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace nana{
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned weight() const
|
constexpr unsigned weight() const
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@@ -122,22 +122,37 @@ namespace nana{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rectangle wd_r{ wd->pos_root, wd->dimension };
|
||||||
|
wd_r.pare_off(-static_cast<int>(this->weight()));
|
||||||
//Render
|
//Render
|
||||||
for (auto & rd : rd_set)
|
for (auto & rd : rd_set)
|
||||||
_m_render_edge_nimbus(rd.second, rd.first);
|
{
|
||||||
|
auto other_wd = rd.second;
|
||||||
|
|
||||||
|
if (other_wd != wd)
|
||||||
|
{
|
||||||
|
rectangle other_r{ other_wd->pos_root, other_wd->dimension };
|
||||||
|
other_r.pare_off(-static_cast<int>(this->weight()));
|
||||||
|
if (!overlapped(wd_r, other_r))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_m_render_edge_nimbus(other_wd, rd.first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
static bool _m_edge_nimbus(core_window_t * focused_wd, core_window_t * wd)
|
static bool _m_edge_nimbus(core_window_t * focused_wd, core_window_t * wd)
|
||||||
{
|
{
|
||||||
if((focused_wd == wd) && (static_cast<unsigned>(wd->effect.edge_nimbus) & static_cast<unsigned>(effects::edge_nimbus::active)))
|
if((focused_wd == wd) && (static_cast<unsigned>(wd->effect.edge_nimbus) & static_cast<unsigned>(effects::edge_nimbus::active)))
|
||||||
return true;
|
return true;
|
||||||
else if((static_cast<unsigned>(wd->effect.edge_nimbus) & static_cast<unsigned>(effects::edge_nimbus::over)) && (wd->flags.action == mouse_action::over))
|
else if((static_cast<unsigned>(wd->effect.edge_nimbus) & static_cast<unsigned>(effects::edge_nimbus::over)) && (wd->flags.action == mouse_action::hovered))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _m_render_edge_nimbus(core_window_t* wd, const nana::rectangle & visual)
|
void _m_render_edge_nimbus(core_window_t* wd, const nana::rectangle & visual)
|
||||||
{
|
{
|
||||||
|
wd->flags.action_before = wd->flags.action;
|
||||||
|
|
||||||
auto r = visual;
|
auto r = visual;
|
||||||
r.pare_off(-static_cast<int>(weight()));
|
r.pare_off(-static_cast<int>(weight()));
|
||||||
rectangle good_r;
|
rectangle good_r;
|
||||||
@@ -159,12 +174,12 @@ namespace nana{
|
|||||||
good_r.x = good_r.y = 1;
|
good_r.x = good_r.y = 1;
|
||||||
good_r.width = r.width - 2;
|
good_r.width = r.width - 2;
|
||||||
good_r.height = r.height - 2;
|
good_r.height = r.height - 2;
|
||||||
pixbuf.rectangle(good_r, wd->scheme->activated.get_color(), 0.95, false);
|
pixbuf.rectangle(good_r, wd->annex.scheme->activated.get_color(), 0.95, false);
|
||||||
|
|
||||||
good_r.x = good_r.y = 0;
|
good_r.x = good_r.y = 0;
|
||||||
good_r.width = r.width;
|
good_r.width = r.width;
|
||||||
good_r.height = r.height;
|
good_r.height = r.height;
|
||||||
pixbuf.rectangle(good_r, wd->scheme->activated.get_color(), 0.4, false);
|
pixbuf.rectangle(good_r, wd->annex.scheme->activated.get_color(), 0.4, false);
|
||||||
|
|
||||||
pixbuf.pixel(0, 0, px0);
|
pixbuf.pixel(0, 0, px0);
|
||||||
pixbuf.pixel(r.width - 1, 0, px1);
|
pixbuf.pixel(r.width - 1, 0, px1);
|
||||||
|
|||||||
@@ -15,9 +15,13 @@
|
|||||||
|
|
||||||
#include <nana/gui/element.hpp>
|
#include <nana/gui/element.hpp>
|
||||||
#include <nana/pat/cloneable.hpp>
|
#include <nana/pat/cloneable.hpp>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
@@ -48,5 +52,6 @@ namespace detail
|
|||||||
};
|
};
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}
|
}
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <nana/gui/detail/general_events.hpp>
|
#include <nana/gui/detail/general_events.hpp>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#if defined(STD_THREAD_NOT_SUPPORTED)
|
#if defined(STD_THREAD_NOT_SUPPORTED)
|
||||||
#include <nana/std_mutex.hpp>
|
#include <nana/std_mutex.hpp>
|
||||||
@@ -18,15 +17,12 @@ namespace nana
|
|||||||
class events_operation
|
class events_operation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void make(window, const std::shared_ptr<general_events> &);
|
|
||||||
void umake(window);
|
|
||||||
void register_evt(event_handle);
|
void register_evt(event_handle);
|
||||||
void cancel(event_handle);
|
void cancel(event_handle);
|
||||||
void erase(event_handle);
|
void erase(event_handle);
|
||||||
private:
|
private:
|
||||||
std::recursive_mutex mutex_;
|
std::recursive_mutex mutex_;
|
||||||
std::unordered_set<event_handle> handles_;
|
std::unordered_set<event_handle> handles_;
|
||||||
std::unordered_map<window, std::shared_ptr<general_events>> evt_table_;
|
|
||||||
};
|
};
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|||||||
@@ -12,18 +12,22 @@
|
|||||||
#ifndef NANA_DETAIL_GENERAL_EVENTS_HPP
|
#ifndef NANA_DETAIL_GENERAL_EVENTS_HPP
|
||||||
#define NANA_DETAIL_GENERAL_EVENTS_HPP
|
#define NANA_DETAIL_GENERAL_EVENTS_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include <nana/gui/basis.hpp>
|
#include <nana/gui/basis.hpp>
|
||||||
#include "event_code.hpp"
|
#include "event_code.hpp"
|
||||||
#include "internal_scope_guard.hpp"
|
#include "internal_scope_guard.hpp"
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
bool check_window(window);
|
||||||
|
void events_operation_register(event_handle);
|
||||||
|
|
||||||
class event_interface
|
class event_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -38,11 +42,51 @@ namespace nana
|
|||||||
virtual event_interface* get_event() const = 0;
|
virtual event_interface* get_event() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void events_operation_register(event_handle);
|
|
||||||
void events_operation_cancel(event_handle);
|
struct docker_base
|
||||||
|
: public docker_interface
|
||||||
|
{
|
||||||
|
event_interface * event_ptr;
|
||||||
|
bool flag_deleted{ false };
|
||||||
|
const bool unignorable;
|
||||||
|
|
||||||
|
docker_base(event_interface*, bool unignorable_flag);
|
||||||
|
|
||||||
|
detail::event_interface * get_event() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class event_base
|
||||||
|
: public detail::event_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~event_base();
|
||||||
|
|
||||||
|
std::size_t length() const;
|
||||||
|
void clear() noexcept;
|
||||||
|
|
||||||
|
void remove(event_handle evt) override;
|
||||||
|
protected:
|
||||||
|
//class emit_counter is a RAII helper for emitting count
|
||||||
|
//It is used for avoiding a try{}catch block which is required for some finial works when
|
||||||
|
//event handlers throw exceptions. Precondition event_base.dockers_ != nullptr.
|
||||||
|
class emit_counter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
emit_counter(event_base*);
|
||||||
|
~emit_counter();
|
||||||
|
private:
|
||||||
|
event_base * const evt_;
|
||||||
|
};
|
||||||
|
|
||||||
|
event_handle _m_emplace(detail::docker_interface*, bool in_front);
|
||||||
|
protected:
|
||||||
|
unsigned emitting_count_{ 0 };
|
||||||
|
bool deleted_flags_{ false };
|
||||||
|
std::vector<detail::docker_interface*> * dockers_{ nullptr };
|
||||||
|
};
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
|
|
||||||
/// base clase for all event argument types
|
/// base class for all event argument types
|
||||||
class event_arg
|
class event_arg
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -57,87 +101,44 @@ namespace nana
|
|||||||
|
|
||||||
struct general_events;
|
struct general_events;
|
||||||
|
|
||||||
/// the type of the members of general_events
|
/** @brief the type of the members of general_events.
|
||||||
|
*
|
||||||
|
* It connect the functions to be called as response to the event and manages that chain of responses
|
||||||
|
* It is a functor, that get called to connect a "normal" response function, with normal "priority".
|
||||||
|
* If a response function need another priority (unignorable or called first) it will need to be connected with
|
||||||
|
* the specific connect function not with the operator()
|
||||||
|
* It also permit to "emit" that event, calling all the active responders.
|
||||||
|
*/
|
||||||
template<typename Arg>
|
template<typename Arg>
|
||||||
class basic_event : public detail::event_interface
|
class basic_event : public detail::event_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using arg_reference = const typename std::remove_reference<Arg>::type &;
|
using arg_reference = const typename std::remove_reference<Arg>::type &;
|
||||||
private:
|
private:
|
||||||
struct docker
|
struct docker
|
||||||
: public detail::docker_interface
|
: public detail::docker_base
|
||||||
{
|
{
|
||||||
basic_event * const event_ptr;
|
/// the callback/response function taking the typed argument
|
||||||
std::function<void(arg_reference)> invoke;
|
std::function<void(arg_reference)> invoke;
|
||||||
|
|
||||||
bool flag_deleted{ false };
|
docker(basic_event * evt, std::function<void(arg_reference)> && ivk, bool unignorable_flag)
|
||||||
bool unignorable{false};
|
: docker_base(evt, unignorable_flag), invoke(std::move(ivk))
|
||||||
|
|
||||||
docker(basic_event * s, std::function<void(arg_reference)> && ivk, bool unignorable_flag)
|
|
||||||
: event_ptr(s), invoke(std::move(ivk)), unignorable(unignorable_flag)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
docker(basic_event * s, const std::function<void(arg_reference)> & ivk, bool unignorable_flag)
|
docker(basic_event * evt, const std::function<void(arg_reference)> & ivk, bool unignorable_flag)
|
||||||
: event_ptr(s), invoke(ivk), unignorable(unignorable_flag)
|
: docker_base(evt, unignorable_flag), invoke(ivk)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~docker()
|
|
||||||
{
|
|
||||||
detail::events_operation_cancel(reinterpret_cast<event_handle>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
detail::event_interface * get_event() const override
|
|
||||||
{
|
|
||||||
return event_ptr;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//class emit_counter is a RAII helper for emitting count
|
|
||||||
//It is used for avoiding a try{}catch block which is required for some finial works when
|
|
||||||
//event handlers throw exceptions.
|
|
||||||
class emit_counter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
emit_counter(basic_event* evt)
|
|
||||||
: evt_{evt}
|
|
||||||
{
|
|
||||||
++evt->emitting_count_;
|
|
||||||
}
|
|
||||||
|
|
||||||
~emit_counter()
|
|
||||||
{
|
|
||||||
if ((0 == --evt_->emitting_count_) && evt_->deleted_flags_)
|
|
||||||
{
|
|
||||||
evt_->deleted_flags_ = false;
|
|
||||||
for (auto i = evt_->dockers_->begin(); i != evt_->dockers_->end();)
|
|
||||||
{
|
|
||||||
if (static_cast<docker*>(i->get())->flag_deleted)
|
|
||||||
i = evt_->dockers_->erase(i);
|
|
||||||
else
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
basic_event * const evt_;
|
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
/// It will get called firstly, because it is set at the beginning of the chain.
|
/// Creates an event handler at the beginning of event chain
|
||||||
template<typename Function>
|
template<typename Function>
|
||||||
event_handle connect_front(Function && fn)
|
event_handle connect_front(Function && fn)
|
||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
|
||||||
if (nullptr == dockers_)
|
|
||||||
dockers_.reset(new std::vector<std::unique_ptr<detail::docker_interface>>);
|
|
||||||
|
|
||||||
using prototype = typename std::remove_reference<Function>::type;
|
using prototype = typename std::remove_reference<Function>::type;
|
||||||
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
return _m_emplace(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false), true);
|
||||||
auto evt = reinterpret_cast<event_handle>(dck.get());
|
|
||||||
dockers_->emplace(dockers_->begin(), std::move(dck));
|
|
||||||
detail::events_operation_register(evt);
|
|
||||||
return evt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// It will not get called if stop_propagation() was called.
|
||||||
event_handle connect(void (*fn)(arg_reference))
|
event_handle connect(void (*fn)(arg_reference))
|
||||||
{
|
{
|
||||||
return connect([fn](arg_reference arg){
|
return connect([fn](arg_reference arg){
|
||||||
@@ -145,20 +146,12 @@ namespace nana
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// It will not get called if stop_propagation() was called.
|
/// It will not get called if stop_propagation() was called, because it is set at the end of the chain..
|
||||||
template<typename Function>
|
template<typename Function>
|
||||||
event_handle connect(Function && fn)
|
event_handle connect(Function && fn)
|
||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
|
||||||
if (nullptr == dockers_)
|
|
||||||
dockers_.reset(new std::vector<std::unique_ptr<detail::docker_interface>>);
|
|
||||||
|
|
||||||
using prototype = typename std::remove_reference<Function>::type;
|
using prototype = typename std::remove_reference<Function>::type;
|
||||||
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
return _m_emplace(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false), false);
|
||||||
auto evt = reinterpret_cast<event_handle>(dck.get());
|
|
||||||
dockers_->emplace_back(std::move(dck));
|
|
||||||
detail::events_operation_register(evt);
|
|
||||||
return evt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// It will not get called if stop_propagation() was called.
|
/// It will not get called if stop_propagation() was called.
|
||||||
@@ -172,28 +165,12 @@ namespace nana
|
|||||||
template<typename Function>
|
template<typename Function>
|
||||||
event_handle connect_unignorable(Function && fn, bool in_front = false)
|
event_handle connect_unignorable(Function && fn, bool in_front = false)
|
||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
|
||||||
if (nullptr == dockers_)
|
|
||||||
dockers_.reset(new std::vector<std::unique_ptr<detail::docker_interface>>);
|
|
||||||
|
|
||||||
using prototype = typename std::remove_reference<Function>::type;
|
using prototype = typename std::remove_reference<Function>::type;
|
||||||
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), true));
|
|
||||||
auto evt = reinterpret_cast<event_handle>(dck.get());
|
return _m_emplace(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), true), in_front);
|
||||||
if (in_front)
|
|
||||||
dockers_->emplace(dockers_->begin(), std::move(dck));
|
|
||||||
else
|
|
||||||
dockers_->emplace_back(std::move(dck));
|
|
||||||
detail::events_operation_register(evt);
|
|
||||||
return evt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t length() const
|
void emit(arg_reference& arg, window window_handle)
|
||||||
{
|
|
||||||
internal_scope_guard lock;
|
|
||||||
return (nullptr == dockers_ ? 0 : dockers_->size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void emit(arg_reference& arg)
|
|
||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
if (nullptr == dockers_)
|
if (nullptr == dockers_)
|
||||||
@@ -201,62 +178,37 @@ namespace nana
|
|||||||
|
|
||||||
emit_counter ec(this);
|
emit_counter ec(this);
|
||||||
|
|
||||||
auto& dockers = *dockers_;
|
|
||||||
const auto dockers_len = dockers.size();
|
|
||||||
|
|
||||||
//The dockers may resize when a new event handler is created by a calling handler.
|
//The dockers may resize when a new event handler is created by a calling handler.
|
||||||
//Traverses with position can avaid crash error which caused by a iterator which becomes invalid.
|
//Traverses with position can avaid crash error which caused by a iterator which becomes invalid.
|
||||||
for (std::size_t pos = 0; pos < dockers_len; ++pos)
|
|
||||||
|
auto i = dockers_->data();
|
||||||
|
auto const end = i + dockers_->size();
|
||||||
|
|
||||||
|
for (; i != end; ++i)
|
||||||
{
|
{
|
||||||
auto docker_ptr = static_cast<docker*>(dockers[pos].get());
|
if (static_cast<docker*>(*i)->flag_deleted)
|
||||||
if (docker_ptr->flag_deleted)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
docker_ptr->invoke(arg);
|
static_cast<docker*>(*i)->invoke(arg);
|
||||||
|
|
||||||
|
if (window_handle && (!detail::check_window(window_handle)))
|
||||||
|
break;
|
||||||
|
|
||||||
if (arg.propagation_stopped())
|
if (arg.propagation_stopped())
|
||||||
{
|
{
|
||||||
for (++pos; pos < dockers_len; ++pos)
|
for (++i; i != end; ++i)
|
||||||
{
|
{
|
||||||
auto docker_ptr = static_cast<docker*>(dockers[pos].get());
|
if (!static_cast<docker*>(*i)->unignorable || static_cast<docker*>(*i)->flag_deleted)
|
||||||
if (!docker_ptr->unignorable || docker_ptr->flag_deleted)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
docker_ptr->invoke(arg);
|
static_cast<docker*>(*i)->invoke(arg);
|
||||||
}
|
if (window_handle && (!detail::check_window(window_handle)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear()
|
|
||||||
{
|
|
||||||
internal_scope_guard lock;
|
|
||||||
if (dockers_)
|
|
||||||
dockers_.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void remove(event_handle evt) override
|
|
||||||
{
|
|
||||||
internal_scope_guard lock;
|
|
||||||
if (dockers_)
|
|
||||||
{
|
|
||||||
for (auto i = dockers_->begin(), end = dockers_->end(); i != end; ++i)
|
|
||||||
{
|
|
||||||
if (reinterpret_cast<detail::docker_interface*>(evt) == i->get())
|
|
||||||
{
|
|
||||||
//Checks whether this event is working now.
|
|
||||||
if (emitting_count_ > 1)
|
|
||||||
{
|
|
||||||
static_cast<docker*>(i->get())->flag_deleted = true;
|
|
||||||
deleted_flags_ = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
dockers_->erase(i);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
template<typename Fn, bool IsBind>
|
template<typename Fn, bool IsBind>
|
||||||
struct factory
|
struct factory
|
||||||
@@ -294,11 +246,6 @@ namespace nana
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::function<void(arg_reference)> build_second(fn_type&& fn, void(fn_type::*)(arg_reference))
|
|
||||||
{
|
|
||||||
return std::move(fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Tfn, typename Ret>
|
template<typename Tfn, typename Ret>
|
||||||
static std::function<void(arg_reference)> build_second(Tfn&& fn, Ret(fn_type::*)()const)
|
static std::function<void(arg_reference)> build_second(Tfn&& fn, Ret(fn_type::*)()const)
|
||||||
{
|
{
|
||||||
@@ -308,11 +255,36 @@ namespace nana
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::function<void(arg_reference)> build_second(fn_type&& fn, void(fn_type::*)(arg_reference))
|
||||||
|
{
|
||||||
|
return std::move(fn);
|
||||||
|
}
|
||||||
|
|
||||||
static std::function<void(arg_reference)> build_second(fn_type&& fn, void(fn_type::*)(arg_reference) const)
|
static std::function<void(arg_reference)> build_second(fn_type&& fn, void(fn_type::*)(arg_reference) const)
|
||||||
{
|
{
|
||||||
return std::move(fn);
|
return std::move(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::function<void(arg_reference)> build_second(fn_type& fn, void(fn_type::*)(arg_reference))
|
||||||
|
{
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::function<void(arg_reference)> build_second(fn_type& fn, void(fn_type::*)(arg_reference) const)
|
||||||
|
{
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::function<void(arg_reference)> build_second(const fn_type& fn, void(fn_type::*)(arg_reference))
|
||||||
|
{
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::function<void(arg_reference)> build_second(const fn_type& fn, void(fn_type::*)(arg_reference) const)
|
||||||
|
{
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Tfn, typename Ret, typename Arg2>
|
template<typename Tfn, typename Ret, typename Arg2>
|
||||||
static std::function<void(arg_reference)> build_second(Tfn&& fn, Ret(fn_type::*)(Arg2))
|
static std::function<void(arg_reference)> build_second(Tfn&& fn, Ret(fn_type::*)(Arg2))
|
||||||
{
|
{
|
||||||
@@ -413,26 +385,22 @@ namespace nana
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private:
|
|
||||||
unsigned emitting_count_{ 0 };
|
|
||||||
bool deleted_flags_{ false };
|
|
||||||
std::unique_ptr<std::vector<std::unique_ptr<detail::docker_interface>>> dockers_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct arg_mouse
|
struct arg_mouse
|
||||||
: public event_arg
|
: public event_arg
|
||||||
{
|
{
|
||||||
event_code evt_code; ///<
|
event_code evt_code; ///< what kind of mouse event?
|
||||||
::nana::window window_handle; ///< A handle to the event window
|
::nana::window window_handle; ///< A handle to the event window
|
||||||
::nana::point pos; ///< cursor position in the event window
|
::nana::point pos; ///< cursor position in the event window
|
||||||
::nana::mouse button; ///< indicates a button which triggers the event
|
::nana::mouse button; ///< indicates a button which triggers the event
|
||||||
|
|
||||||
bool left_button; ///< mouse left button is pressed?
|
bool left_button; ///< true if mouse left button is pressed
|
||||||
bool mid_button; ///< mouse middle button is pressed?
|
bool mid_button; ///< true if mouse middle button is pressed
|
||||||
bool right_button; ///< mouse right button is pressed?
|
bool right_button; ///< true if mouse right button is pressed
|
||||||
bool alt; ///< keyboard alt is pressed?
|
bool alt; ///< true if keyboard alt is pressed
|
||||||
bool shift; ///< keyboard Shift is pressed?
|
bool shift; ///< true if keyboard Shift is pressed
|
||||||
bool ctrl; ///< keyboard Ctrl is pressed?
|
bool ctrl; ///< true if keyboard Ctrl is pressed
|
||||||
|
|
||||||
/// Checks if left button is operated,
|
/// Checks if left button is operated,
|
||||||
bool is_left_button() const
|
bool is_left_button() const
|
||||||
@@ -441,7 +409,8 @@ namespace nana
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// in arg_wheel event_code is event_code::mouse_wheel
|
/// \brief in arg_wheel event_code is event_code::mouse_wheel
|
||||||
|
|
||||||
/// The type arg_wheel is derived from arg_mouse, a handler
|
/// The type arg_wheel is derived from arg_mouse, a handler
|
||||||
/// with prototype void(const arg_mouse&) can be set for mouse_wheel.
|
/// with prototype void(const arg_mouse&) can be set for mouse_wheel.
|
||||||
struct arg_wheel : public arg_mouse
|
struct arg_wheel : public arg_mouse
|
||||||
@@ -471,9 +440,18 @@ namespace nana
|
|||||||
|
|
||||||
struct arg_focus : public event_arg
|
struct arg_focus : public event_arg
|
||||||
{
|
{
|
||||||
|
/// A constant to indicate how keyboard focus emitted.
|
||||||
|
enum class reason
|
||||||
|
{
|
||||||
|
general, ///< the focus is received by OS native window manager.
|
||||||
|
tabstop, ///< the focus is received by pressing tab.
|
||||||
|
mouse_press ///< the focus is received by pressing a mouse button.
|
||||||
|
};
|
||||||
|
|
||||||
::nana::window window_handle; ///< A handle to the event window
|
::nana::window window_handle; ///< A handle to the event window
|
||||||
::nana::native_window_type receiver; ///< it is a native window handle, and specified which window receives focus
|
::nana::native_window_type receiver; ///< it is a native window handle, and specified which window receives focus
|
||||||
bool getting; ///< the window received focus?
|
bool getting; ///< the window received focus?
|
||||||
|
reason focus_reason; ///< determines how the widget receives keyboard focus, it is ignored when 'getting' is equal to false
|
||||||
};
|
};
|
||||||
|
|
||||||
struct arg_keyboard : public event_arg
|
struct arg_keyboard : public event_arg
|
||||||
@@ -481,7 +459,7 @@ namespace nana
|
|||||||
event_code evt_code; ///< it is event_code::key_press in current event
|
event_code evt_code; ///< it is event_code::key_press in current event
|
||||||
::nana::window window_handle; ///< A handle to the event window
|
::nana::window window_handle; ///< A handle to the event window
|
||||||
mutable wchar_t key; ///< the key corresponding to the key pressed
|
mutable wchar_t key; ///< the key corresponding to the key pressed
|
||||||
mutable bool ignore; ///< this member is not used
|
mutable bool ignore; ///< this member is only available for key_char event, set 'true' to ignore the input.
|
||||||
bool ctrl; ///< keyboard Ctrl is pressed?
|
bool ctrl; ///< keyboard Ctrl is pressed?
|
||||||
bool shift; ///< keyboard Shift is pressed
|
bool shift; ///< keyboard Shift is pressed
|
||||||
};
|
};
|
||||||
@@ -518,11 +496,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
::nana::window window_handle; ///< A handle to the event window
|
::nana::window window_handle; ///< A handle to the event window
|
||||||
};
|
};
|
||||||
|
/// a higher level event argument than just mouse down
|
||||||
struct arg_click : public event_arg
|
struct arg_click : public event_arg
|
||||||
{
|
{
|
||||||
::nana::window window_handle; ///< A handle to the event window
|
::nana::window window_handle; ///< A handle to the event window
|
||||||
const arg_mouse* mouse_args; ///< If it is not null, it refers to the mouse arguments for click event emitted by mouse, nullptr otherwise.
|
const arg_mouse* mouse_args{}; ///< If it is not null, it refers to the mouse arguments for click event emitted by mouse, nullptr otherwise.
|
||||||
};
|
};
|
||||||
|
|
||||||
/// provides some fundamental events that every widget owns.
|
/// provides some fundamental events that every widget owns.
|
||||||
@@ -562,4 +540,6 @@ namespace nana
|
|||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -171,7 +173,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
is_queue<std::is_same<cond_type, nana::null_type>::value, std::vector<handle_type> >::erase(handle, queue_);
|
is_queue<std::is_same<cond_type, nana::null_type>::value, std::vector<handle_type> >::erase(handle, queue_);
|
||||||
cacher_.insert(handle, false);
|
cacher_.insert(handle, false);
|
||||||
trash_.emplace_back(i->first, i->second);
|
trash_.push_back(*i);
|
||||||
holder_.erase(i);
|
holder_.erase(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,4 +290,6 @@ namespace nana
|
|||||||
};//end class handle_manager
|
};//end class handle_manager
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}// end namespace nana
|
}// end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#ifndef NANA_GUI_INNER_FWD_IMPLEMENT_HPP
|
#ifndef NANA_GUI_INNER_FWD_IMPLEMENT_HPP
|
||||||
#define NANA_GUI_INNER_FWD_IMPLEMENT_HPP
|
#define NANA_GUI_INNER_FWD_IMPLEMENT_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include "inner_fwd.hpp"
|
#include "inner_fwd.hpp"
|
||||||
#include "basic_window.hpp"
|
#include "basic_window.hpp"
|
||||||
#include "../../paint/graphics.hpp"
|
#include "../../paint/graphics.hpp"
|
||||||
@@ -111,20 +112,19 @@ namespace nana{
|
|||||||
|
|
||||||
struct root_misc
|
struct root_misc
|
||||||
{
|
{
|
||||||
typedef basic_window core_window_t;
|
basic_window * window;
|
||||||
|
|
||||||
core_window_t * window;
|
|
||||||
nana::paint::graphics root_graph;
|
nana::paint::graphics root_graph;
|
||||||
shortkey_container shortkeys;
|
shortkey_container shortkeys;
|
||||||
|
|
||||||
struct condition_tag
|
struct condition_rep
|
||||||
{
|
{
|
||||||
core_window_t* pressed{nullptr}; //The handle to a window which has been pressed by pressing left button of mouse.
|
bool ignore_tab{ false }; //ignore tab when the focus is changed by TAB key.
|
||||||
core_window_t* pressed_by_space{ nullptr }; //The handle to a window which has been pressed by pressing spacebar.
|
basic_window* pressed{ nullptr }; //The handle to a window which has been pressed by mouse left button.
|
||||||
core_window_t* hovered{nullptr}; //the latest window that mouse moved
|
basic_window* pressed_by_space{ nullptr }; //The handle to a window which has been pressed by SPACEBAR key.
|
||||||
|
basic_window* hovered{ nullptr }; //the latest window that mouse moved
|
||||||
}condition;
|
}condition;
|
||||||
|
|
||||||
root_misc(core_window_t * wd, unsigned width, unsigned height)
|
root_misc(basic_window * wd, unsigned width, unsigned height)
|
||||||
: window(wd),
|
: window(wd),
|
||||||
root_graph({ width, height })
|
root_graph({ width, height })
|
||||||
{}
|
{}
|
||||||
@@ -172,4 +172,7 @@ namespace nana{
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif //NANA_GUI_INNER_FWD_IMPLEMENT_HPP
|
#endif //NANA_GUI_INNER_FWD_IMPLEMENT_HPP
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Forward Declaration of Internal Scope Guard
|
* Forward Declaration of Internal Scope Guard
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -26,6 +26,18 @@ namespace nana
|
|||||||
internal_scope_guard();
|
internal_scope_guard();
|
||||||
~internal_scope_guard();
|
~internal_scope_guard();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class internal_revert_guard
|
||||||
|
{
|
||||||
|
internal_revert_guard(const internal_revert_guard&) = delete;
|
||||||
|
internal_revert_guard(internal_revert_guard&&) = delete;
|
||||||
|
|
||||||
|
internal_revert_guard& operator=(const internal_revert_guard&) = delete;
|
||||||
|
internal_revert_guard& operator=(internal_revert_guard&&) = delete;
|
||||||
|
public:
|
||||||
|
internal_revert_guard();
|
||||||
|
~internal_revert_guard();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Platform Implementation
|
* Platform Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -36,6 +36,9 @@ namespace detail
|
|||||||
|
|
||||||
using native_string_type = ::nana::detail::native_string_type;
|
using native_string_type = ::nana::detail::native_string_type;
|
||||||
|
|
||||||
|
//Execute a function in a thread which is associated with the specified native window.
|
||||||
|
static void affinity_execute(native_window_type, const std::function<void()>&);
|
||||||
|
|
||||||
static nana::size primary_monitor_size();
|
static nana::size primary_monitor_size();
|
||||||
static rectangle screen_area_from_point(const point&);
|
static rectangle screen_area_from_point(const point&);
|
||||||
static window_result create_window(native_window_type, bool nested, const rectangle&, const appearance&);
|
static window_result create_window(native_window_type, bool nested, const rectangle&, const appearance&);
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Color Schemes
|
* Widget Geometrics
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/gui/widget_colors.hpp
|
* @file: nana/gui/widget_geometrics.hpp
|
||||||
* @description:
|
* @description:
|
||||||
*/
|
*/
|
||||||
#ifndef NANA_DETAIL_WIDGET_COLORS_HPP
|
#ifndef NANA_DETAIL_WIDGET_GEOMETRICS_HPP
|
||||||
#define NANA_DETAIL_WIDGET_COLORS_HPP
|
#define NANA_DETAIL_WIDGET_GEOMETRICS_HPP
|
||||||
|
|
||||||
#include <nana/gui/basis.hpp>
|
#include <nana/gui/basis.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -33,9 +33,9 @@ namespace nana
|
|||||||
std::shared_ptr<color> color_;
|
std::shared_ptr<color> color_;
|
||||||
};//end namespace color_proxy
|
};//end namespace color_proxy
|
||||||
|
|
||||||
struct widget_colors
|
struct widget_geometrics
|
||||||
{
|
{
|
||||||
virtual ~widget_colors() = default;
|
virtual ~widget_geometrics() = default;
|
||||||
|
|
||||||
color_proxy activated{ static_cast<color_rgb>(0x60C8FD) };
|
color_proxy activated{ static_cast<color_rgb>(0x60C8FD) };
|
||||||
color_proxy background{colors::button_face};
|
color_proxy background{colors::button_face};
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_DETAIL_WINDOW_LAYOUT_HPP
|
#ifndef NANA_GUI_DETAIL_WINDOW_LAYOUT_HPP
|
||||||
#define NANA_GUI_DETAIL_WINDOW_LAYOUT_HPP
|
#define NANA_GUI_DETAIL_WINDOW_LAYOUT_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include <nana/gui/basis.hpp>
|
#include <nana/gui/basis.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -84,5 +85,7 @@ namespace detail
|
|||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif //NANA_GUI_DETAIL_WINDOW_LAYOUT_HPP
|
#endif //NANA_GUI_DETAIL_WINDOW_LAYOUT_HPP
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/**
|
||||||
* Window Manager Implementation
|
* Window Manager Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -10,14 +10,16 @@
|
|||||||
* @file: nana/gui/detail/window_manager.hpp
|
* @file: nana/gui/detail/window_manager.hpp
|
||||||
*
|
*
|
||||||
* <Knowledge: 1, 2007-8-17, "Difference between destroy and destroy_handle">
|
* <Knowledge: 1, 2007-8-17, "Difference between destroy and destroy_handle">
|
||||||
* destroy method destroys a window handle and the handles of its children, but it doesn't delete the handle which type is a root window or a frame
|
* destroy method destroys a window handle and the handles of its children, but it doesn't delete the handle which type is a root window
|
||||||
* destroy_handle method just destroys the handle which type is a root window or a frame
|
* destroy_handle method just destroys the handle which type is a root window
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NANA_GUI_DETAIL_WINDOW_MANAGER_HPP
|
#ifndef NANA_GUI_DETAIL_WINDOW_MANAGER_HPP
|
||||||
#define NANA_GUI_DETAIL_WINDOW_MANAGER_HPP
|
#define NANA_GUI_DETAIL_WINDOW_MANAGER_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "window_layout.hpp"
|
#include "window_layout.hpp"
|
||||||
#include "event_code.hpp"
|
#include "event_code.hpp"
|
||||||
@@ -92,10 +94,12 @@ namespace detail
|
|||||||
|
|
||||||
core_window_t* create_root(core_window_t*, bool nested, rectangle, const appearance&, widget*);
|
core_window_t* create_root(core_window_t*, bool nested, rectangle, const appearance&, widget*);
|
||||||
core_window_t* create_widget(core_window_t*, const rectangle&, bool is_lite, widget*);
|
core_window_t* create_widget(core_window_t*, const rectangle&, bool is_lite, widget*);
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
core_window_t* create_frame(core_window_t*, const rectangle&, widget*);
|
core_window_t* create_frame(core_window_t*, const rectangle&, widget*);
|
||||||
|
|
||||||
bool insert_frame(core_window_t* frame, native_window);
|
bool insert_frame(core_window_t* frame, native_window);
|
||||||
bool insert_frame(core_window_t* frame, core_window_t*);
|
bool insert_frame(core_window_t* frame, core_window_t*);
|
||||||
|
#endif
|
||||||
void close(core_window_t*);
|
void close(core_window_t*);
|
||||||
|
|
||||||
//destroy
|
//destroy
|
||||||
@@ -104,13 +108,13 @@ namespace detail
|
|||||||
|
|
||||||
//destroy_handle
|
//destroy_handle
|
||||||
//@brief: Delete window handle, the handle type must be a root and a frame.
|
//@brief: Delete window handle, the handle type must be a root and a frame.
|
||||||
|
|
||||||
|
// Deletes a window whose category type is a root type or a frame type.
|
||||||
void destroy_handle(core_window_t*);
|
void destroy_handle(core_window_t*);
|
||||||
|
|
||||||
void default_icon(const paint::image& _small_icon, const paint::image& big_icon);
|
void default_icon(const paint::image& _small_icon, const paint::image& big_icon);
|
||||||
void icon(core_window_t*, const paint::image& small_icon, const paint::image& big_icon);
|
void icon(core_window_t*, const paint::image& small_icon, const paint::image& big_icon);
|
||||||
|
|
||||||
//show
|
|
||||||
//@brief: show or hide a window
|
|
||||||
bool show(core_window_t* wd, bool visible);
|
bool show(core_window_t* wd, bool visible);
|
||||||
|
|
||||||
core_window_t* find_window(native_window_type root, int x, int y);
|
core_window_t* find_window(native_window_type root, int x, int y);
|
||||||
@@ -129,20 +133,20 @@ namespace detail
|
|||||||
bool update(core_window_t*, bool redraw, bool force, const rectangle* update_area = nullptr);
|
bool update(core_window_t*, bool redraw, bool force, const rectangle* update_area = nullptr);
|
||||||
void refresh_tree(core_window_t*);
|
void refresh_tree(core_window_t*);
|
||||||
|
|
||||||
bool do_lazy_refresh(core_window_t*, bool force_copy_to_screen);
|
bool do_lazy_refresh(core_window_t*, bool force_copy_to_screen, bool refresh_tree = false);
|
||||||
|
|
||||||
bool get_graphics(core_window_t*, nana::paint::graphics&);
|
bool get_graphics(core_window_t*, nana::paint::graphics&);
|
||||||
bool get_visual_rectangle(core_window_t*, nana::rectangle&);
|
bool get_visual_rectangle(core_window_t*, nana::rectangle&);
|
||||||
|
|
||||||
std::vector<core_window_t*> get_children(core_window_t*) const;
|
std::vector<core_window_t*> get_children(core_window_t*) const;
|
||||||
bool set_parent(core_window_t* wd, core_window_t* new_parent);
|
bool set_parent(core_window_t* wd, core_window_t* new_parent);
|
||||||
core_window_t* set_focus(core_window_t*, bool root_has_been_focused);
|
core_window_t* set_focus(core_window_t*, bool root_has_been_focused, arg_focus::reason);
|
||||||
|
|
||||||
core_window_t* capture_redirect(core_window_t*);
|
core_window_t* capture_redirect(core_window_t*);
|
||||||
void capture_ignore_children(bool ignore);
|
|
||||||
bool capture_window_entered(int root_x, int root_y, bool& prev);
|
bool capture_window_entered(int root_x, int root_y, bool& prev);
|
||||||
core_window_t * capture_window() const;
|
core_window_t * capture_window() const;
|
||||||
core_window_t* capture_window(core_window_t*, bool value);
|
void capture_window(core_window_t*, bool capture, bool ignore_children_if_captured);
|
||||||
|
|
||||||
void enable_tabstop(core_window_t*);
|
void enable_tabstop(core_window_t*);
|
||||||
core_window_t* tabstop(core_window_t*, bool forward) const; //forward means move to next in logic.
|
core_window_t* tabstop(core_window_t*, bool forward) const; //forward means move to next in logic.
|
||||||
@@ -195,4 +199,7 @@ namespace detail
|
|||||||
};//end class window_manager
|
};//end class window_manager
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_DRAGGER_HPP
|
#ifndef NANA_GUI_DRAGGER_HPP
|
||||||
#define NANA_GUI_DRAGGER_HPP
|
#define NANA_GUI_DRAGGER_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include "basis.hpp"
|
#include "basis.hpp"
|
||||||
#include "../basic_types.hpp"
|
#include "../basic_types.hpp"
|
||||||
#include "../traits.hpp"
|
#include "../traits.hpp"
|
||||||
@@ -44,4 +45,5 @@ namespace nana
|
|||||||
dragger_impl_t * impl_;
|
dragger_impl_t * impl_;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef NANA_GUI_DRAWING_HPP
|
#ifndef NANA_GUI_DRAWING_HPP
|
||||||
#define NANA_GUI_DRAWING_HPP
|
#define NANA_GUI_DRAWING_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include "widgets/widget.hpp"
|
#include "widgets/widget.hpp"
|
||||||
#include "../traits.hpp"
|
#include "../traits.hpp"
|
||||||
namespace nana
|
namespace nana
|
||||||
@@ -46,4 +48,6 @@ namespace nana
|
|||||||
window handle_;
|
window handle_;
|
||||||
};//end class drawing
|
};//end class drawing
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Elements of GUI Gadgets
|
* Elements of GUI Gadgets
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
#ifndef NANA_GUI_ELEMENT_HPP
|
#ifndef NANA_GUI_ELEMENT_HPP
|
||||||
#define NANA_GUI_ELEMENT_HPP
|
#define NANA_GUI_ELEMENT_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include <nana/paint/graphics.hpp>
|
#include <nana/paint/graphics.hpp>
|
||||||
#include <nana/pat/cloneable.hpp>
|
#include <nana/pat/cloneable.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -88,7 +89,6 @@ namespace nana
|
|||||||
struct factory_interface
|
struct factory_interface
|
||||||
: public detail::factory_abstract
|
: public detail::factory_abstract
|
||||||
{
|
{
|
||||||
virtual ~factory_interface(){}
|
|
||||||
virtual ElementInterface* create() const = 0;
|
virtual ElementInterface* create() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -349,4 +349,5 @@ namespace nana
|
|||||||
}//end namespace element
|
}//end namespace element
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif //NANA_GUI_ELEMENT_HPP
|
#endif //NANA_GUI_ELEMENT_HPP
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/**
|
||||||
* Filebox
|
* Filebox
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
@@ -7,7 +7,9 @@
|
|||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/gui/filebox.hpp
|
* @file nana/gui/filebox.hpp
|
||||||
|
* @author Jinhao
|
||||||
|
* @brief a dialog to chose file(s), implemented "native" in windows but using nana for X11
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NANA_GUI_FILEBOX_HPP
|
#ifndef NANA_GUI_FILEBOX_HPP
|
||||||
@@ -37,17 +39,19 @@ namespace nana
|
|||||||
/// Change owner window
|
/// Change owner window
|
||||||
void owner(window);
|
void owner(window);
|
||||||
|
|
||||||
/// specify a title for the dialog
|
/// Set a new title for the dialog
|
||||||
/// @param string a text for title
|
/// @param string a text for title
|
||||||
/// @return old title.
|
/// @return the old title.
|
||||||
::std::string title( ::std::string new_title); ///< . Set a new title for the dialog and \return the old title
|
::std::string title( ::std::string new_title);
|
||||||
|
|
||||||
/** @brief specify a suggestion directory
|
/** @brief Suggest initial path used to locate a directory when the filebox starts.
|
||||||
* @param string a path of initial directory
|
* @param string initial_directory a path of initial directory
|
||||||
* @note the behavior of init_path is different between Win7 and Win2K/XP/Vista, but its behavior under Linux is conformed with Win7.
|
* @note the behavior of init_path is different between Win7 and Win2K/XP/Vista, but its behavior under Linux is conformed with Win7.
|
||||||
*/
|
*/
|
||||||
filebox& init_path(const ::std::string&); ///< Suggested init path used to locate a directory when the filebox starts.
|
filebox& init_path(const ::std::string& initial_directory);
|
||||||
|
|
||||||
filebox& init_file(const ::std::string&); ///< Init file, if it contains a path, the init path is replaced by the path of init file.
|
filebox& init_file(const ::std::string&); ///< Init file, if it contains a path, the init path is replaced by the path of init file.
|
||||||
|
|
||||||
/// \brief Add a filetype filter.
|
/// \brief Add a filetype filter.
|
||||||
/// To specify multiple filter in a single description, use a semicolon to separate the patterns(for example,"*.TXT;*.DOC;*.BAK").
|
/// To specify multiple filter in a single description, use a semicolon to separate the patterns(for example,"*.TXT;*.DOC;*.BAK").
|
||||||
filebox& add_filter(const ::std::string& description, ///< for example. "Text File"
|
filebox& add_filter(const ::std::string& description, ///< for example. "Text File"
|
||||||
@@ -68,8 +72,7 @@ namespace nana
|
|||||||
/// Display the filebox dialog
|
/// Display the filebox dialog
|
||||||
bool show() const;
|
bool show() const;
|
||||||
|
|
||||||
/// Display the filebox dialog
|
/// a function object method alternative to show() to display the filebox dialog,
|
||||||
/// A function object method alternative to show()
|
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
return show();
|
return show();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
//overlap test if overlaped between r1 and r2
|
//overlap test if overlaped between r1 and r2
|
||||||
bool overlap(const rectangle& r1, const rectangle& r2);
|
bool overlapped(const rectangle& r1, const rectangle& r2);
|
||||||
|
|
||||||
// overlap, compute the overlap area between r1 and r2. the r is for root
|
// overlap, compute the overlap area between r1 and r2. the r is for root
|
||||||
bool overlap(const rectangle& r1, const rectangle& r2, rectangle& r);
|
bool overlap(const rectangle& r1, const rectangle& r2, rectangle& r);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_MSGBOX_HPP
|
#ifndef NANA_GUI_MSGBOX_HPP
|
||||||
#define NANA_GUI_MSGBOX_HPP
|
#define NANA_GUI_MSGBOX_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@@ -253,5 +254,6 @@ namespace nana
|
|||||||
::nana::rectangle valid_areas_[4];
|
::nana::rectangle valid_areas_[4];
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Definition of Notifier
|
* Definition of Notifier
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
#define NANA_GUI_NOTIFIER_HPP
|
#define NANA_GUI_NOTIFIER_HPP
|
||||||
#include <nana/gui/basis.hpp>
|
#include <nana/gui/basis.hpp>
|
||||||
#include <nana/gui/detail/general_events.hpp>
|
#include <nana/gui/detail/general_events.hpp>
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -65,4 +66,5 @@ namespace nana
|
|||||||
implement * impl_;
|
implement * impl_;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_PLACE_HPP
|
#ifndef NANA_GUI_PLACE_HPP
|
||||||
#define NANA_GUI_PLACE_HPP
|
#define NANA_GUI_PLACE_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include <nana/gui/basis.hpp>
|
#include <nana/gui/basis.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -99,7 +100,7 @@ namespace nana
|
|||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
/// reference to a field manipulator which refers to a field object created by place
|
/// reference to a field manipulator which refers to a field object created by place
|
||||||
typedef field_interface & field_reference;
|
using field_reference = field_interface &;
|
||||||
|
|
||||||
place();
|
place();
|
||||||
place(window);///< Attaches to a specified widget.
|
place(window);///< Attaches to a specified widget.
|
||||||
@@ -140,10 +141,11 @@ namespace nana
|
|||||||
}
|
}
|
||||||
|
|
||||||
place& dock(const std::string& dockname, std::string factory_name, std::function<std::unique_ptr<widget>(window)> factory);
|
place& dock(const std::string& dockname, std::string factory_name, std::function<std::unique_ptr<widget>(window)> factory);
|
||||||
place& dock_create(const std::string& factory);
|
widget* dock_create(const std::string& factory);
|
||||||
private:
|
private:
|
||||||
implement * impl_;
|
implement * impl_;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif //#ifndef NANA_GUI_PLACE_HPP
|
#endif //#ifndef NANA_GUI_PLACE_HPP
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace nana
|
|||||||
struct widget_traits<widget>
|
struct widget_traits<widget>
|
||||||
{
|
{
|
||||||
using event_type = ::nana::general_events;
|
using event_type = ::nana::general_events;
|
||||||
using scheme_type = ::nana::widget_colors;
|
using scheme_type = ::nana::widget_geometrics;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ namespace API
|
|||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
::nana::widget_colors* make_scheme(::nana::detail::scheme_factory_base&&);
|
::nana::widget_geometrics* make_scheme(::nana::detail::scheme_factory_interface&&);
|
||||||
}
|
}
|
||||||
|
|
||||||
void effects_edge_nimbus(window, effects::edge_nimbus);
|
void effects_edge_nimbus(window, effects::edge_nimbus);
|
||||||
@@ -60,6 +60,8 @@ namespace API
|
|||||||
//@brief: The interfaces defined in namespace dev are used for developing the nana.gui
|
//@brief: The interfaces defined in namespace dev are used for developing the nana.gui
|
||||||
namespace dev
|
namespace dev
|
||||||
{
|
{
|
||||||
|
void affinity_execute(window window_handle, const std::function<void()>&);
|
||||||
|
|
||||||
bool set_events(window, const std::shared_ptr<general_events>&);
|
bool set_events(window, const std::shared_ptr<general_events>&);
|
||||||
|
|
||||||
template<typename Scheme>
|
template<typename Scheme>
|
||||||
@@ -68,8 +70,8 @@ namespace API
|
|||||||
return std::unique_ptr<Scheme>{static_cast<Scheme*>(API::detail::make_scheme(::nana::detail::scheme_factory<Scheme>()))};
|
return std::unique_ptr<Scheme>{static_cast<Scheme*>(API::detail::make_scheme(::nana::detail::scheme_factory<Scheme>()))};
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_scheme(window, widget_colors*);
|
void set_scheme(window, widget_geometrics*);
|
||||||
widget_colors* get_scheme(window);
|
widget_geometrics* get_scheme(window);
|
||||||
|
|
||||||
void attach_drawer(widget&, drawer_trigger&);
|
void attach_drawer(widget&, drawer_trigger&);
|
||||||
::nana::detail::native_string_type window_caption(window) throw();
|
::nana::detail::native_string_type window_caption(window) throw();
|
||||||
@@ -78,8 +80,9 @@ namespace API
|
|||||||
window create_window(window, bool nested, const rectangle&, const appearance&, widget* attached);
|
window create_window(window, bool nested, const rectangle&, const appearance&, widget* attached);
|
||||||
window create_widget(window, const rectangle&, widget* attached);
|
window create_widget(window, const rectangle&, widget* attached);
|
||||||
window create_lite_widget(window, const rectangle&, widget* attached);
|
window create_lite_widget(window, const rectangle&, widget* attached);
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
window create_frame(window, const rectangle&, widget* attached);
|
window create_frame(window, const rectangle&, widget* attached);
|
||||||
|
#endif
|
||||||
paint::graphics* window_graphics(window);
|
paint::graphics* window_graphics(window);
|
||||||
|
|
||||||
void delay_restore(bool);
|
void delay_restore(bool);
|
||||||
@@ -88,10 +91,20 @@ namespace API
|
|||||||
void set_menubar(window wd, bool attach);
|
void set_menubar(window wd, bool attach);
|
||||||
|
|
||||||
void enable_space_click(window, bool enable);
|
void enable_space_click(window, bool enable);
|
||||||
|
|
||||||
|
/// Refreshs a widget surface
|
||||||
|
/*
|
||||||
|
* This function will copy the drawer surface into system window after the event process finished.
|
||||||
|
*/
|
||||||
|
void lazy_refresh();
|
||||||
}//end namespace dev
|
}//end namespace dev
|
||||||
|
|
||||||
|
/// Returns the widget pointer of the specified window.
|
||||||
widget* get_widget(window);
|
/*
|
||||||
|
* @param window_handle A handle to a window owning the widget.
|
||||||
|
* @return A widget pointer.
|
||||||
|
*/
|
||||||
|
widget* get_widget(window window_handle);
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
@@ -143,9 +156,17 @@ namespace API
|
|||||||
};
|
};
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
|
|
||||||
void exit();
|
void exit(); ///< close all windows in current thread
|
||||||
|
void exit_all(); ///< close all windows
|
||||||
|
|
||||||
std::string transform_shortkey_text(std::string text, wchar_t &shortkey, std::string::size_type *skpos);
|
/// @brief Searchs whether the text contains a '&' and removes the character for transforming.
|
||||||
|
/// If the text contains more than one '&' charachers, the others are ignored. e.g
|
||||||
|
/// text = "&&a&bcd&ef", the result should be "&abcdef", shortkey = 'b', and pos = 2.
|
||||||
|
std::string transform_shortkey_text
|
||||||
|
( std::string text, ///< the text is transformed
|
||||||
|
wchar_t &shortkey, ///< the character which indicates a short key.
|
||||||
|
std::string::size_type *skpos ///< retrives the shortkey position if it is not a null_ptr;
|
||||||
|
);
|
||||||
bool register_shortkey(window, unsigned long);
|
bool register_shortkey(window, unsigned long);
|
||||||
void unregister_shortkey(window);
|
void unregister_shortkey(window);
|
||||||
|
|
||||||
@@ -181,9 +202,12 @@ namespace API
|
|||||||
|
|
||||||
void fullscreen(window, bool);
|
void fullscreen(window, bool);
|
||||||
bool enabled_double_click(window, bool);
|
bool enabled_double_click(window, bool);
|
||||||
|
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
bool insert_frame(window frame, native_window_type);
|
bool insert_frame(window frame, native_window_type);
|
||||||
native_window_type frame_container(window frame);
|
native_window_type frame_container(window frame);
|
||||||
native_window_type frame_element(window frame, unsigned index);
|
native_window_type frame_element(window frame, unsigned index);
|
||||||
|
#endif
|
||||||
void close_window(window);
|
void close_window(window);
|
||||||
void show_window(window, bool show); ///< Sets a window visible state.
|
void show_window(window, bool show); ///< Sets a window visible state.
|
||||||
void restore_window(window);
|
void restore_window(window);
|
||||||
@@ -230,7 +254,7 @@ namespace API
|
|||||||
if (nullptr == wdg_colors)
|
if (nullptr == wdg_colors)
|
||||||
throw std::invalid_argument("API::scheme(): bad parameter window handle, no events object or invalid window handle.");
|
throw std::invalid_argument("API::scheme(): bad parameter window handle, no events object or invalid window handle.");
|
||||||
|
|
||||||
if (std::is_same<::nana::widget_colors, scheme_type>::value)
|
if (std::is_same<::nana::widget_geometrics, scheme_type>::value)
|
||||||
return *static_cast<scheme_type*>(wdg_colors);
|
return *static_cast<scheme_type*>(wdg_colors);
|
||||||
|
|
||||||
auto * comp_wdg_colors = dynamic_cast<scheme_type*>(wdg_colors);
|
auto * comp_wdg_colors = dynamic_cast<scheme_type*>(wdg_colors);
|
||||||
@@ -258,20 +282,12 @@ namespace API
|
|||||||
void window_enabled(window, bool);
|
void window_enabled(window, bool);
|
||||||
bool window_enabled(window);
|
bool window_enabled(window);
|
||||||
|
|
||||||
/** @brief A widget drawer draws the widget surface in answering an event.
|
/// Refresh the window and display it immediately calling the refresh function of its drawer_trigger.
|
||||||
*
|
/*
|
||||||
* This function will tell the drawer to copy the graphics into window after event answering.
|
* The drawer::refresh() will be called. If the currently state is lazy_refrsh, the window is delayed to update the graphics until an event is finished.
|
||||||
* Tells Nana.GUI to copy the buffer of event window to screen after the event is processed.
|
* @param window_handle A handle to the window to be refreshed.
|
||||||
* This function only works for a drawer_trigger, when a drawer_trigger receives an event,
|
|
||||||
* after drawing, a drawer_trigger should call lazy_refresh to tell the Nana.GUI to refresh
|
|
||||||
* the window to the screen after the event process finished.
|
|
||||||
*/
|
*/
|
||||||
void lazy_refresh();
|
void refresh_window(window window_handle);
|
||||||
|
|
||||||
/** @brief: calls refresh() of a widget's drawer. if currently state is lazy_refresh, Nana.GUI may paste the drawing on the window after an event processing.
|
|
||||||
* @param window: specify a window to be refreshed.
|
|
||||||
*/
|
|
||||||
void refresh_window(window); ///< Refreshs the window and display it immediately calling the refresh method of its drawer_trigger..
|
|
||||||
void refresh_window_tree(window); ///< Refreshs the specified window and all it<69>s children windows, then display it immediately
|
void refresh_window_tree(window); ///< Refreshs the specified window and all it<69>s children windows, then display it immediately
|
||||||
void update_window(window); ///< Copies the off-screen buffer to the screen for immediate display.
|
void update_window(window); ///< Copies the off-screen buffer to the screen for immediate display.
|
||||||
|
|
||||||
@@ -283,14 +299,36 @@ namespace API
|
|||||||
cursor window_cursor(window);
|
cursor window_cursor(window);
|
||||||
|
|
||||||
void activate_window(window);
|
void activate_window(window);
|
||||||
|
|
||||||
|
/// Determines whether the specified window will get the keyboard focus when its root window gets native system focus.
|
||||||
bool is_focus_ready(window);
|
bool is_focus_ready(window);
|
||||||
|
|
||||||
|
/// Returns the current keyboard focus window.
|
||||||
window focus_window();
|
window focus_window();
|
||||||
|
|
||||||
|
/// Sets the keyboard focus for a specified window.
|
||||||
void focus_window(window);
|
void focus_window(window);
|
||||||
|
|
||||||
|
/// Returns a window which has grabbed the mouse input.
|
||||||
window capture_window();
|
window capture_window();
|
||||||
window capture_window(window, bool); ///< Enables or disables the window to grab the mouse input
|
|
||||||
void capture_ignore_children(bool ignore); ///< Enables or disables the captured window whether redirects the mouse input to its children if the mouse is over its children.
|
/// Enables a window to grab the mouse input.
|
||||||
void modal_window(window); ///< Blocks the routine til the specified window is closed.
|
/**
|
||||||
|
* @param window_handle A handle to a window to grab the mouse input.
|
||||||
|
* @param ignore_children Indicates whether to redirect the mouse input to its children if the mouse pointer is over its children.
|
||||||
|
*/
|
||||||
|
void set_capture(window window_handle, bool ignore_children);
|
||||||
|
|
||||||
|
/// Disable a window to grab the mouse input.
|
||||||
|
/**
|
||||||
|
* @param window handle A handle to a window to release grab of mouse input.
|
||||||
|
*/
|
||||||
|
void release_capture(window window_handle);
|
||||||
|
|
||||||
|
/// 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.
|
||||||
void wait_for(window);
|
void wait_for(window);
|
||||||
|
|
||||||
color fgcolor(window);
|
color fgcolor(window);
|
||||||
@@ -300,20 +338,38 @@ namespace API
|
|||||||
color activated_color(window);
|
color activated_color(window);
|
||||||
color activated_color(window, const color&);
|
color activated_color(window, const color&);
|
||||||
|
|
||||||
void create_caret(window, unsigned width, unsigned height);
|
void create_caret(window, const size&);
|
||||||
void destroy_caret(window);
|
void destroy_caret(window);
|
||||||
void caret_effective_range(window, const rectangle&);
|
|
||||||
void caret_pos(window, const ::nana::point&);
|
|
||||||
nana::point caret_pos(window);
|
|
||||||
nana::size caret_size(window);
|
|
||||||
void caret_size(window, const size&);
|
|
||||||
void caret_visible(window, bool is_show);
|
|
||||||
bool caret_visible(window);
|
|
||||||
|
|
||||||
void tabstop(window); ///< Sets the window that owns the tabstop.
|
/// Opens an existing caret of a window.
|
||||||
/// treu: The focus is not to be changed when Tab key is pressed, and a key_char event with tab will be generated.
|
/**
|
||||||
void eat_tabstop(window, bool);
|
* This function returns an object to operate caret. The object doesn't create or destroy the caret.
|
||||||
window move_tabstop(window, bool next); ///< Sets the focus to the window which tabstop is near to the specified window.
|
* When you are finished with the caret, be sure to reset the pointer.
|
||||||
|
*
|
||||||
|
* @param window_handle A handle to a window whose caret is to be retrieved
|
||||||
|
* @return a pointer to the caret proxy. nullptr if the window doesn't have a caret.
|
||||||
|
*/
|
||||||
|
::std::unique_ptr<caret_interface> open_caret(window window_handle, bool disable_throw = false);
|
||||||
|
|
||||||
|
/// Enables that the user can give input focus to the specified window using TAB key.
|
||||||
|
void tabstop(window);
|
||||||
|
|
||||||
|
/// Enables or disables a window to receive a key_char event for pressing TAB key.
|
||||||
|
/*
|
||||||
|
* @param window_handle A handle to the window to catch TAB key through key_char event.
|
||||||
|
* @param enable Indicates whether to enable or disable catch of TAB key. If this parameter is *true*, the window is
|
||||||
|
* received a key_char when pressing TAB key, and the input focus is not changed. If this parameter is *false*, the
|
||||||
|
* input focus is changed to the next tabstop window.
|
||||||
|
*/
|
||||||
|
void eat_tabstop(window window_handle, bool enable);
|
||||||
|
|
||||||
|
/// Sets the input focus to the window which the tabstop is near to the specified window.
|
||||||
|
/*
|
||||||
|
* @param window_handle A handle to the window.
|
||||||
|
* @param forward Indicates whether forward or backward window to be given the input focus.
|
||||||
|
* @return A handle to the window which to be given the input focus.
|
||||||
|
*/
|
||||||
|
window move_tabstop(window window_handle, bool forward);
|
||||||
|
|
||||||
/// Sets the window active state. If a window active state is false, the window will not obtain the focus when a mouse clicks on it wich will be obteined by take_if_has_active_false.
|
/// Sets the window active state. If a window active state is false, the window will not obtain the focus when a mouse clicks on it wich will be obteined by take_if_has_active_false.
|
||||||
void take_active(window, bool has_active, window take_if_has_active_false);
|
void take_active(window, bool has_active, window take_if_has_active_false);
|
||||||
@@ -343,6 +399,7 @@ namespace API
|
|||||||
|
|
||||||
void at_safe_place(window, std::function<void()>);
|
void at_safe_place(window, std::function<void()>);
|
||||||
}//end namespace API
|
}//end namespace API
|
||||||
|
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#ifndef NANA_GUI_TIMER_HPP
|
#ifndef NANA_GUI_TIMER_HPP
|
||||||
#define NANA_GUI_TIMER_HPP
|
#define NANA_GUI_TIMER_HPP
|
||||||
#include <nana/gui/detail/general_events.hpp>
|
#include <nana/gui/detail/general_events.hpp>
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -58,4 +59,5 @@ namespace nana
|
|||||||
implement * const impl_;
|
implement * const impl_;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#define NANA_GUI_WIDGET_BUTTON_HPP
|
#define NANA_GUI_WIDGET_BUTTON_HPP
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include <nana/gui/element.hpp>
|
#include <nana/gui/element.hpp>
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
|
|
||||||
namespace nana{
|
namespace nana{
|
||||||
namespace drawerbase
|
namespace drawerbase
|
||||||
@@ -105,5 +107,7 @@ namespace nana{
|
|||||||
void _m_caption(native_string_type&&) override;
|
void _m_caption(native_string_type&&) override;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <nana/gui/widgets/widget.hpp>
|
#include <nana/gui/widgets/widget.hpp>
|
||||||
#include <nana/pat/cloneable.hpp>
|
#include <nana/pat/cloneable.hpp>
|
||||||
#include <nana/any.hpp>
|
#include <nana/any.hpp>
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -66,7 +67,7 @@ namespace nana
|
|||||||
|
|
||||||
T null_val;
|
T null_val;
|
||||||
arg_categorize<T> arg(widget_, vp ? *vp : null_val);
|
arg_categorize<T> arg(widget_, vp ? *vp : null_val);
|
||||||
widget_.events().selected.emit(arg);
|
widget_.events().selected.emit(arg, widget_.handle());
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
::nana::categorize<T> & widget_;
|
::nana::categorize<T> & widget_;
|
||||||
@@ -141,7 +142,7 @@ namespace nana
|
|||||||
void mouse_leave(graph_reference, const arg_mouse&) override;
|
void mouse_leave(graph_reference, const arg_mouse&) override;
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<event_agent_interface> event_agent_;
|
std::unique_ptr<event_agent_interface> event_agent_;
|
||||||
scheme * scheme_;
|
scheme * scheme_{nullptr};
|
||||||
};
|
};
|
||||||
}//end namespace categorize
|
}//end namespace categorize
|
||||||
}//end namespace drawerbase
|
}//end namespace drawerbase
|
||||||
@@ -258,5 +259,5 @@ namespace nana
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_WIDGET_CHECKBOX_HPP
|
#ifndef NANA_GUI_WIDGET_CHECKBOX_HPP
|
||||||
#define NANA_GUI_WIDGET_CHECKBOX_HPP
|
#define NANA_GUI_WIDGET_CHECKBOX_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -106,5 +108,6 @@ namespace drawerbase
|
|||||||
std::vector<element_tag> ui_container_;
|
std::vector<element_tag> ui_container_;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_WIDGETS_COMBOX_HPP
|
#ifndef NANA_GUI_WIDGETS_COMBOX_HPP
|
||||||
#define NANA_GUI_WIDGETS_COMBOX_HPP
|
#define NANA_GUI_WIDGETS_COMBOX_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include "float_listbox.hpp"
|
#include "float_listbox.hpp"
|
||||||
#include "skeletons/text_editor_part.hpp"
|
#include "skeletons/text_editor_part.hpp"
|
||||||
@@ -227,4 +228,5 @@ namespace nana
|
|||||||
nana::any * _m_anyobj(std::size_t pos, bool alloc_if_empty) const override;
|
nana::any * _m_anyobj(std::size_t pos, bool alloc_if_empty) const override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A date chooser Implementation
|
* A date chooser Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -12,86 +12,53 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_WIDGETS_DATE_CHOOSER_HPP
|
#ifndef NANA_GUI_WIDGETS_DATE_CHOOSER_HPP
|
||||||
#define NANA_GUI_WIDGETS_DATE_CHOOSER_HPP
|
#define NANA_GUI_WIDGETS_DATE_CHOOSER_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include <nana/datetime.hpp>
|
#include <nana/datetime.hpp>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
class date_chooser;
|
||||||
|
|
||||||
|
struct arg_datechooser
|
||||||
|
: public event_arg
|
||||||
|
{
|
||||||
|
date_chooser * const widget;
|
||||||
|
|
||||||
|
arg_datechooser(date_chooser* wdg)
|
||||||
|
: widget(wdg)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
namespace drawerbase
|
namespace drawerbase
|
||||||
{
|
{
|
||||||
namespace date_chooser
|
namespace date_chooser
|
||||||
{
|
{
|
||||||
|
struct date_chooser_events
|
||||||
|
: public general_events
|
||||||
|
{
|
||||||
|
|
||||||
|
basic_event<arg_datechooser> date_changed;
|
||||||
|
};
|
||||||
|
|
||||||
class trigger : public drawer_trigger
|
class trigger : public drawer_trigger
|
||||||
{
|
{
|
||||||
|
class model;
|
||||||
public:
|
public:
|
||||||
static const int topbar_height = 34;
|
static const int topbar_height = 34;
|
||||||
static const int border_size = 3;
|
static const int border_size = 3;
|
||||||
|
|
||||||
enum class transform_action{none, to_left, to_right, to_enter, to_leave};
|
|
||||||
enum class where{none, left_button, right_button, topbar, textarea};
|
|
||||||
enum class page{date, month};
|
|
||||||
|
|
||||||
struct drawing_basis
|
|
||||||
{
|
|
||||||
nana::point refpos;
|
|
||||||
double line_s;
|
|
||||||
double row_s;
|
|
||||||
};
|
|
||||||
|
|
||||||
trigger();
|
trigger();
|
||||||
bool chose() const;
|
~trigger();
|
||||||
nana::date read() const;
|
model* get_model() const;
|
||||||
void week_name(unsigned index, const std::string&);
|
|
||||||
private:
|
|
||||||
where _m_pos_where(graph_reference, const ::nana::point& pos);
|
|
||||||
void _m_draw_topbar(graph_reference);
|
|
||||||
void _m_make_drawing_basis(drawing_basis&, graph_reference, const nana::point& refpos);
|
|
||||||
void _m_draw_pos(drawing_basis &, graph_reference, int x, int y, const ::std::string&, bool primary, bool sel);
|
|
||||||
void _m_draw_pos(drawing_basis &, graph_reference, int x, int y, int number, bool primary, bool sel);
|
|
||||||
void _m_draw_ex_days(drawing_basis &, graph_reference, int begx, int begy, bool before);
|
|
||||||
void _m_draw_days(const nana::point& refpos, graph_reference);
|
|
||||||
void _m_draw_months(const nana::point& refpos, graph_reference);
|
|
||||||
bool _m_get_trace(point, int & res);
|
|
||||||
void _m_perf_transform(transform_action tfid, graph_reference, graph_reference dirtybuf, graph_reference newbuf, const nana::point& refpos);
|
|
||||||
private:
|
private:
|
||||||
void refresh(graph_reference) override;
|
void refresh(graph_reference) override;
|
||||||
void attached(widget_reference, graph_reference) override;
|
|
||||||
void mouse_move(graph_reference, const arg_mouse&) override;
|
void mouse_move(graph_reference, const arg_mouse&) override;
|
||||||
void mouse_leave(graph_reference, const arg_mouse&) override;
|
void mouse_leave(graph_reference, const arg_mouse&) override;
|
||||||
void mouse_up(graph_reference, const arg_mouse&) override;
|
void mouse_up(graph_reference, const arg_mouse&) override;
|
||||||
|
void key_press(graph_reference, const arg_keyboard&) override;
|
||||||
private:
|
private:
|
||||||
::std::string weekstr_[7];
|
model * model_;
|
||||||
|
|
||||||
widget * widget_;
|
|
||||||
|
|
||||||
bool chose_;
|
|
||||||
page page_;
|
|
||||||
where pos_;
|
|
||||||
nana::point trace_pos_;
|
|
||||||
|
|
||||||
drawing_basis dbasis_;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
int year;
|
|
||||||
int month;
|
|
||||||
int day;
|
|
||||||
}chdate_;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
int year;
|
|
||||||
int month;
|
|
||||||
}chmonth_;
|
|
||||||
|
|
||||||
struct color_tag
|
|
||||||
{
|
|
||||||
::nana::color highlight;
|
|
||||||
::nana::color selected;
|
|
||||||
::nana::color normal;
|
|
||||||
::nana::color bgcolor;
|
|
||||||
}color_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}//end namespace date_chooser
|
}//end namespace date_chooser
|
||||||
@@ -100,19 +67,18 @@ namespace nana
|
|||||||
|
|
||||||
/// \see nana::date
|
/// \see nana::date
|
||||||
class date_chooser
|
class date_chooser
|
||||||
: public widget_object<category::widget_tag, drawerbase::date_chooser::trigger>
|
: public widget_object<category::widget_tag, drawerbase::date_chooser::trigger, drawerbase::date_chooser::date_chooser_events>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
date_chooser();
|
date_chooser();
|
||||||
date_chooser(window, bool visible);
|
date_chooser(window, bool visible);
|
||||||
date_chooser(window, const ::std::string& text, bool visible = true);
|
|
||||||
date_chooser(window, const char* text, bool visible = true);
|
|
||||||
date_chooser(window, const nana::rectangle& r = rectangle(), bool visible = true);
|
date_chooser(window, const nana::rectangle& r = rectangle(), bool visible = true);
|
||||||
|
|
||||||
bool chose() const;
|
bool chose() const;
|
||||||
nana::date read() const;
|
nana::date read() const;
|
||||||
void weekstr(unsigned index, const ::std::string&);///<Set the week strings which will be displayed for day, index is in range of [0, 6]
|
void weekstr(unsigned index, ::std::string);///<Set the week strings which will be displayed for day, index is in range of [0, 6]
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#ifndef NANA_GUI_WIDGETS_DETAIL_TREE_CONT_HPP
|
#ifndef NANA_GUI_WIDGETS_DETAIL_TREE_CONT_HPP
|
||||||
#define NANA_GUI_WIDGETS_DETAIL_TREE_CONT_HPP
|
#define NANA_GUI_WIDGETS_DETAIL_TREE_CONT_HPP
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -515,4 +516,6 @@ namespace detail
|
|||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace widgets
|
}//end namespace widgets
|
||||||
}//end namesace nana
|
}//end namesace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_WIDGETS_FLOAT_LISTBOX_HPP
|
#ifndef NANA_GUI_WIDGETS_FLOAT_LISTBOX_HPP
|
||||||
#define NANA_GUI_WIDGETS_FLOAT_LISTBOX_HPP
|
#define NANA_GUI_WIDGETS_FLOAT_LISTBOX_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -101,5 +102,6 @@ namespace nana
|
|||||||
std::size_t index() const;
|
std::size_t index() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,9 +14,12 @@
|
|||||||
#define NANA_GUI_WIDGET_FORM_HPP
|
#define NANA_GUI_WIDGET_FORM_HPP
|
||||||
|
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
|
#include <nana/gui/place.hpp>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
class place;
|
||||||
|
|
||||||
namespace drawerbase
|
namespace drawerbase
|
||||||
{
|
{
|
||||||
namespace form
|
namespace form
|
||||||
@@ -29,12 +32,29 @@ namespace nana
|
|||||||
private:
|
private:
|
||||||
widget* wd_{nullptr};
|
widget* wd_{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class form_base
|
||||||
|
: public widget_object<category::root_tag, drawerbase::form::trigger, detail::events_root_extension>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
form_base(window owner, bool nested, const rectangle&, const appearance&);
|
||||||
|
|
||||||
|
//place methods
|
||||||
|
|
||||||
|
place & get_place();
|
||||||
|
void div(const char* div_text);
|
||||||
|
place::field_reference operator[](const char* field_name);
|
||||||
|
void collocate() noexcept;
|
||||||
|
private:
|
||||||
|
std::unique_ptr<place> place_;
|
||||||
|
};
|
||||||
}//end namespace form
|
}//end namespace form
|
||||||
}//end namespace drawerbase
|
}//end namespace drawerbase
|
||||||
|
|
||||||
/// \brief Pop-up window. Is different from other window widgets: its default constructor create the window.
|
/// \brief Pop-up window. Is different from other window widgets: its default constructor create the window.
|
||||||
/// \see nana::appearance
|
/// \see nana::appearance
|
||||||
class form: public widget_object<category::root_tag, drawerbase::form::trigger, detail::events_root_extension>
|
class form
|
||||||
|
: public drawerbase::form::form_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using appear = ::nana::appear;
|
using appear = ::nana::appear;
|
||||||
@@ -50,7 +70,8 @@ namespace nana
|
|||||||
void wait_for_this();
|
void wait_for_this();
|
||||||
};
|
};
|
||||||
|
|
||||||
class nested_form : public widget_object<category::root_tag, drawerbase::form::trigger, detail::events_root_extension>
|
class nested_form
|
||||||
|
: public drawerbase::form::form_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using appear = ::nana::appear;
|
using appear = ::nana::appear;
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#define NANA_GUI_WIDGET_FRAME_HPP
|
#define NANA_GUI_WIDGET_FRAME_HPP
|
||||||
|
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
|
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -51,3 +53,4 @@ namespace nana
|
|||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_WIDGET_LABEL_HPP
|
#ifndef NANA_GUI_WIDGET_LABEL_HPP
|
||||||
#define NANA_GUI_WIDGET_LABEL_HPP
|
#define NANA_GUI_WIDGET_LABEL_HPP
|
||||||
#include "widget.hpp"
|
|
||||||
|
|
||||||
|
#include "widget.hpp"
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -80,4 +81,6 @@ namespace nana
|
|||||||
void _m_caption(native_string_type&&) override;
|
void _m_caption(native_string_type&&) override;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,8 @@
|
|||||||
#include <nana/gui/timer.hpp>
|
#include <nana/gui/timer.hpp>
|
||||||
#include <nana/pat/cloneable.hpp>
|
#include <nana/pat/cloneable.hpp>
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
namespace drawerbase
|
namespace drawerbase
|
||||||
@@ -198,4 +200,6 @@ namespace nana
|
|||||||
detail::popuper menu_popuper(menu&, mouse = mouse::right_button);
|
detail::popuper menu_popuper(menu&, mouse = mouse::right_button);
|
||||||
detail::popuper menu_popuper(menu&, window owner, const point&, mouse = mouse::right_button);
|
detail::popuper menu_popuper(menu&, window owner, const point&, mouse = mouse::right_button);
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#define NANA_GUI_WIDGETS_MENUBAR_HPP
|
#define NANA_GUI_WIDGETS_MENUBAR_HPP
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include "menu.hpp"
|
#include "menu.hpp"
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -117,4 +118,6 @@ namespace nana
|
|||||||
::nana::event_handle evt_resized_{nullptr};
|
::nana::event_handle evt_resized_{nullptr};
|
||||||
};//end class menubar
|
};//end class menubar
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef NANA_GUI_WIDGET_PICTURE_HPP
|
#ifndef NANA_GUI_WIDGET_PICTURE_HPP
|
||||||
#define NANA_GUI_WIDGET_PICTURE_HPP
|
#define NANA_GUI_WIDGET_PICTURE_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
@@ -67,4 +69,6 @@ namespace nana
|
|||||||
bool transparent() const;
|
bool transparent() const;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include <nana/gui/timer.hpp>
|
#include <nana/gui/timer.hpp>
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -205,14 +206,14 @@ namespace nana
|
|||||||
void resized(graph_reference graph, const ::nana::arg_resized&) override
|
void resized(graph_reference graph, const ::nana::arg_resized&) override
|
||||||
{
|
{
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph, metrics_.what);
|
||||||
API::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_enter(graph_reference graph, const ::nana::arg_mouse& arg) override
|
void mouse_enter(graph_reference graph, const ::nana::arg_mouse& arg) override
|
||||||
{
|
{
|
||||||
metrics_.what = drawer_.what(graph, arg.pos);
|
metrics_.what = drawer_.what(graph, arg.pos);
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph, metrics_.what);
|
||||||
API::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_move(graph_reference graph, const ::nana::arg_mouse& arg) override
|
void mouse_move(graph_reference graph, const ::nana::arg_mouse& arg) override
|
||||||
@@ -238,7 +239,7 @@ namespace nana
|
|||||||
if (redraw)
|
if (redraw)
|
||||||
{
|
{
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph, metrics_.what);
|
||||||
API::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +263,7 @@ namespace nana
|
|||||||
timer_.start();
|
timer_.start();
|
||||||
break;
|
break;
|
||||||
case buttons::scroll:
|
case buttons::scroll:
|
||||||
API::capture_window(widget_->handle(), true);
|
widget_->set_capture(true);
|
||||||
metrics_.scroll_mouse_offset = (Vertical ? arg.pos.y : arg.pos.x) - metrics_.scroll_pos;
|
metrics_.scroll_mouse_offset = (Vertical ? arg.pos.y : arg.pos.x) - metrics_.scroll_pos;
|
||||||
break;
|
break;
|
||||||
case buttons::forward:
|
case buttons::forward:
|
||||||
@@ -278,7 +279,7 @@ namespace nana
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph, metrics_.what);
|
||||||
API::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,12 +287,12 @@ namespace nana
|
|||||||
{
|
{
|
||||||
timer_.stop();
|
timer_.stop();
|
||||||
|
|
||||||
API::capture_window(widget_->handle(), false);
|
widget_->release_capture();
|
||||||
|
|
||||||
metrics_.pressed = false;
|
metrics_.pressed = false;
|
||||||
metrics_.what = drawer_.what(graph, arg.pos);
|
metrics_.what = drawer_.what(graph, arg.pos);
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph, metrics_.what);
|
||||||
API::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_leave(graph_reference graph, const arg_mouse&) override
|
void mouse_leave(graph_reference graph, const arg_mouse&) override
|
||||||
@@ -300,7 +301,7 @@ namespace nana
|
|||||||
|
|
||||||
metrics_.what = buttons::none;
|
metrics_.what = buttons::none;
|
||||||
drawer_.draw(graph, buttons::none);
|
drawer_.draw(graph, buttons::none);
|
||||||
API::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_wheel(graph_reference graph, const arg_wheel& arg) override
|
void mouse_wheel(graph_reference graph, const arg_wheel& arg) override
|
||||||
@@ -308,13 +309,13 @@ namespace nana
|
|||||||
if (make_step(arg.upwards == false, 3))
|
if (make_step(arg.upwards == false, 3))
|
||||||
{
|
{
|
||||||
drawer_.draw(graph, metrics_.what);
|
drawer_.draw(graph, metrics_.what);
|
||||||
API::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void _m_emit_value_changed()
|
void _m_emit_value_changed()
|
||||||
{
|
{
|
||||||
widget_->events().value_changed.emit({ widget_->handle() });
|
widget_->events().value_changed.emit({ widget_->handle() }, widget_->handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void _m_tick()
|
void _m_tick()
|
||||||
@@ -502,4 +503,5 @@ namespace nana
|
|||||||
}
|
}
|
||||||
};//end class scroll
|
};//end class scroll
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_SKELETONS_TEXT_EDITOR_HPP
|
#ifndef NANA_GUI_SKELETONS_TEXT_EDITOR_HPP
|
||||||
#define NANA_GUI_SKELETONS_TEXT_EDITOR_HPP
|
#define NANA_GUI_SKELETONS_TEXT_EDITOR_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include "textbase.hpp"
|
#include "textbase.hpp"
|
||||||
#include "text_editor_part.hpp"
|
#include "text_editor_part.hpp"
|
||||||
#include <nana/gui/widgets/scroll.hpp>
|
#include <nana/gui/widgets/scroll.hpp>
|
||||||
@@ -40,6 +42,12 @@ namespace nana{ namespace widgets
|
|||||||
using command = EnumCommand;
|
using command = EnumCommand;
|
||||||
using container = std::deque < std::unique_ptr<undoable_command_interface<command>> >;
|
using container = std::deque < std::unique_ptr<undoable_command_interface<command>> >;
|
||||||
|
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
commands_.clear();
|
||||||
|
pos_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void max_steps(std::size_t maxs)
|
void max_steps(std::size_t maxs)
|
||||||
{
|
{
|
||||||
max_steps_ = maxs;
|
max_steps_ = maxs;
|
||||||
@@ -56,7 +64,7 @@ namespace nana{ namespace widgets
|
|||||||
{
|
{
|
||||||
enabled_ = enb;
|
enabled_ = enb;
|
||||||
if (!enb)
|
if (!enb)
|
||||||
commands_.clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool enabled() const
|
bool enabled() const
|
||||||
@@ -130,6 +138,7 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
struct keywords;
|
struct keywords;
|
||||||
class keyword_parser;
|
class keyword_parser;
|
||||||
|
class helper_pencil;
|
||||||
public:
|
public:
|
||||||
using char_type = wchar_t;
|
using char_type = wchar_t;
|
||||||
using size_type = textbase<char_type>::size_type;
|
using size_type = textbase<char_type>::size_type;
|
||||||
@@ -202,7 +211,7 @@ namespace nana{ namespace widgets
|
|||||||
unsigned screen_lines() const;
|
unsigned screen_lines() const;
|
||||||
|
|
||||||
bool getline(std::size_t pos, ::std::wstring&) const;
|
bool getline(std::size_t pos, ::std::wstring&) const;
|
||||||
void text(std::wstring);
|
void text(std::wstring, bool end_caret);
|
||||||
std::wstring text() const;
|
std::wstring text() const;
|
||||||
|
|
||||||
/// Sets caret position through text coordinate.
|
/// Sets caret position through text coordinate.
|
||||||
@@ -218,7 +227,7 @@ namespace nana{ namespace widgets
|
|||||||
void set_end_caret();
|
void set_end_caret();
|
||||||
|
|
||||||
bool hit_text_area(const point&) const;
|
bool hit_text_area(const point&) const;
|
||||||
bool hit_select_area(nana::upoint pos) const;
|
bool hit_select_area(nana::upoint pos, bool ignore_when_select_all) const;
|
||||||
|
|
||||||
bool move_select();
|
bool move_select();
|
||||||
bool mask(wchar_t);
|
bool mask(wchar_t);
|
||||||
@@ -229,6 +238,9 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
/// Returns text position of each line that currently displays on screen
|
/// Returns text position of each line that currently displays on screen
|
||||||
const std::vector<upoint>& text_position() const;
|
const std::vector<upoint>& text_position() const;
|
||||||
|
|
||||||
|
void focus_behavior(text_focus_behavior);
|
||||||
|
void select_behavior(bool move_to_end);
|
||||||
public:
|
public:
|
||||||
void draw_corner();
|
void draw_corner();
|
||||||
void render(bool focused);
|
void render(bool focused);
|
||||||
@@ -249,17 +261,20 @@ namespace nana{ namespace widgets
|
|||||||
const upoint& caret() const;
|
const upoint& caret() const;
|
||||||
point caret_screen_pos() const;
|
point caret_screen_pos() const;
|
||||||
bool scroll(bool upwards, bool vertical);
|
bool scroll(bool upwards, bool vertical);
|
||||||
bool mouse_enter(bool);
|
|
||||||
|
bool focus_changed(const arg_focus&);
|
||||||
|
bool mouse_enter(bool entering);
|
||||||
bool mouse_move(bool left_button, const point& screen_pos);
|
bool mouse_move(bool left_button, const point& screen_pos);
|
||||||
bool mouse_pressed(const arg_mouse& arg);
|
bool mouse_pressed(const arg_mouse& arg);
|
||||||
|
|
||||||
skeletons::textbase<wchar_t>& textbase();
|
skeletons::textbase<wchar_t>& textbase();
|
||||||
const skeletons::textbase<wchar_t>& textbase() const;
|
const skeletons::textbase<wchar_t>& textbase() const;
|
||||||
private:
|
private:
|
||||||
|
void _m_pre_calc_lines(std::size_t line_off, std::size_t lines);
|
||||||
|
|
||||||
bool _m_accepts(char_type) const;
|
bool _m_accepts(char_type) const;
|
||||||
::nana::color _m_bgcolor() const;
|
::nana::color _m_bgcolor() const;
|
||||||
bool _m_scroll_text(bool vertical);
|
bool _m_scroll_text(bool vertical);
|
||||||
void _m_on_scroll(const arg_mouse&);
|
|
||||||
void _m_scrollbar();
|
void _m_scrollbar();
|
||||||
::nana::size _m_text_area() const;
|
::nana::size _m_text_area() const;
|
||||||
void _m_get_scrollbar_size();
|
void _m_get_scrollbar_size();
|
||||||
@@ -267,7 +282,7 @@ namespace nana{ namespace widgets
|
|||||||
::nana::upoint _m_put(::std::wstring);
|
::nana::upoint _m_put(::std::wstring);
|
||||||
::nana::upoint _m_erase_select();
|
::nana::upoint _m_erase_select();
|
||||||
|
|
||||||
bool _m_make_select_string(::std::wstring&) const;
|
::std::wstring _m_make_select_string() const;
|
||||||
static bool _m_resolve_text(const ::std::wstring&, std::vector<std::pair<std::size_t, std::size_t>> & lines);
|
static bool _m_resolve_text(const ::std::wstring&, std::vector<std::pair<std::size_t, std::size_t>> & lines);
|
||||||
|
|
||||||
bool _m_cancel_select(int align);
|
bool _m_cancel_select(int align);
|
||||||
@@ -295,14 +310,16 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
void _m_offset_y(int y);
|
void _m_offset_y(int y);
|
||||||
|
|
||||||
unsigned _m_char_by_pixels(const wchar_t*, std::size_t len, unsigned* pxbuf, int str_px, int pixels, bool is_rtl);
|
unsigned _m_char_by_pixels(const unicode_bidi::entity&, unsigned pos);
|
||||||
unsigned _m_pixels_by_char(const ::std::wstring&, std::size_t pos) const;
|
|
||||||
|
unsigned _m_pixels_by_char(const ::std::wstring&, ::std::size_t pos) const;
|
||||||
void _handle_move_key(const arg_keyboard& arg);
|
void _handle_move_key(const arg_keyboard& arg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<editor_behavior_interface> behavior_;
|
std::unique_ptr<editor_behavior_interface> behavior_;
|
||||||
undoable<command> undo_;
|
undoable<command> undo_;
|
||||||
nana::window window_;
|
nana::window window_;
|
||||||
|
std::unique_ptr<caret_interface> caret_;
|
||||||
graph_reference graph_;
|
graph_reference graph_;
|
||||||
const text_editor_scheme* scheme_;
|
const text_editor_scheme* scheme_;
|
||||||
event_interface * event_handler_{ nullptr };
|
event_interface * event_handler_{ nullptr };
|
||||||
@@ -353,10 +370,12 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
struct selection
|
struct selection
|
||||||
{
|
{
|
||||||
enum mode_selection_t{mode_no_selected, mode_mouse_selected, mode_method_selected};
|
enum class mode{ no_selected, mouse_selected, method_selected, move_selected };
|
||||||
|
|
||||||
mode_selection_t mode_selection;
|
text_focus_behavior behavior;
|
||||||
bool dragged;
|
bool move_to_end;
|
||||||
|
mode mode_selection;
|
||||||
|
bool ignore_press;
|
||||||
nana::upoint a, b;
|
nana::upoint a, b;
|
||||||
}select_;
|
}select_;
|
||||||
|
|
||||||
@@ -372,5 +391,7 @@ namespace nana{ namespace widgets
|
|||||||
}//end namespace widgets
|
}//end namespace widgets
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#ifndef NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP
|
#ifndef NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP
|
||||||
#define NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP
|
#define NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP
|
||||||
|
|
||||||
#include "../../detail/widget_colors.hpp"
|
#include "../../detail/widget_geometrics.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
@@ -11,14 +11,25 @@ namespace nana
|
|||||||
{
|
{
|
||||||
namespace skeletons
|
namespace skeletons
|
||||||
{
|
{
|
||||||
|
enum class text_focus_behavior
|
||||||
|
{
|
||||||
|
none,
|
||||||
|
select,
|
||||||
|
select_if_tabstop,
|
||||||
|
select_if_click,
|
||||||
|
select_if_tabstop_or_click
|
||||||
|
};
|
||||||
|
|
||||||
//forward declaration
|
//forward declaration
|
||||||
class text_editor;
|
class text_editor;
|
||||||
|
|
||||||
struct text_editor_scheme
|
struct text_editor_scheme
|
||||||
: public ::nana::widget_colors
|
: public ::nana::widget_geometrics
|
||||||
{
|
{
|
||||||
color_proxy selection{static_cast<color_rgb>(0x3399FF)};
|
color_proxy selection{static_cast<color_rgb>(0x3399FF)};
|
||||||
color_proxy selection_text{colors::white};
|
color_proxy selection_text{colors::white};
|
||||||
|
|
||||||
|
parameters::mouse_wheel mouse_wheel; ///< The number of lines/characters to scroll when the vertical/horizontal mouse wheel is moved.
|
||||||
};
|
};
|
||||||
|
|
||||||
class text_editor_event_interface
|
class text_editor_event_interface
|
||||||
|
|||||||
@@ -15,13 +15,14 @@
|
|||||||
|
|
||||||
#include <nana/gui/layout_utility.hpp>
|
#include <nana/gui/layout_utility.hpp>
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
namespace nana{ namespace widgets{ namespace skeletons
|
namespace nana{ namespace widgets{ namespace skeletons
|
||||||
{
|
{
|
||||||
//The tokens are defined for representing a text, the tokens are divided
|
//The tokens are defined for representing a text, the tokens are divided
|
||||||
@@ -86,26 +87,12 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
|
|
||||||
std::pair<unsigned, unsigned> binary_number() const
|
std::pair<unsigned, unsigned> binary_number() const
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
return{ std::stoul(binary_.first), std::stoul(binary_.second) };
|
||||||
ss<<static_cast<std::string>(nana::charset(binary_.first))<<' '<<static_cast<std::string>(nana::charset(binary_.second));
|
|
||||||
|
|
||||||
std::pair<unsigned, unsigned> r;
|
|
||||||
ss>>r.first>>r.second;
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int number() const
|
int number() const
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
return std::stoi(idstr_, nullptr, 0);
|
||||||
ss<<static_cast<std::string>(nana::charset(idstr_));
|
|
||||||
|
|
||||||
//It's a hex number.
|
|
||||||
if(idstr_.size() > 2 && idstr_[0] == '0' && (idstr_[1] == 'x' || idstr_[1] == 'X'))
|
|
||||||
ss>>std::hex;
|
|
||||||
|
|
||||||
int n;
|
|
||||||
ss>>n;
|
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
static bool _m_unicode_word_breakable(wchar_t ch)
|
static bool _m_unicode_word_breakable(wchar_t ch)
|
||||||
@@ -192,21 +179,32 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
return token::tag_begin;
|
return token::tag_begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Escape
|
//Escape
|
||||||
if(ch == '\\')
|
if(this->format_enabled_ && (ch == '\\'))
|
||||||
{
|
{
|
||||||
if(iptr_ + 1 < endptr_)
|
if(iptr_ + 1 < endptr_)
|
||||||
{
|
{
|
||||||
ch = *(iptr_ + 1);
|
ch = *(iptr_ + 1);
|
||||||
|
|
||||||
|
if ('<' == ch || '>' == ch) //two characters need to be escaped.
|
||||||
|
{
|
||||||
iptr_ += 2;
|
iptr_ += 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
//ignore escape
|
||||||
|
ch = '\\';
|
||||||
|
iptr_++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
iptr_ = endptr_;
|
iptr_ = endptr_;
|
||||||
return token::eof;
|
return token::eof;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
++iptr_;
|
++iptr_;
|
||||||
|
|
||||||
idstr_.clear();
|
idstr_.clear();
|
||||||
@@ -275,6 +273,8 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
return token::eof;
|
return token::eof;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || '_' == ch)
|
if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || '_' == ch)
|
||||||
{
|
{
|
||||||
--iptr_;
|
--iptr_;
|
||||||
@@ -665,8 +665,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
case token::eof:
|
case token::eof:
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
int * debug = 0; //for debug.
|
throw std::runtime_error("invalid token");
|
||||||
*debug = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -941,4 +940,5 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
}//end namespace skeletons
|
}//end namespace skeletons
|
||||||
}//end namespace widgets
|
}//end namespace widgets
|
||||||
}//end namepsace nana
|
}//end namepsace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif //NANA_GUI_WIDGETS_SKELETONS_TEXT_TOKEN_STREAM
|
#endif //NANA_GUI_WIDGETS_SKELETONS_TEXT_TOKEN_STREAM
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_WIDGET_DETAIL_TEXTBASE_HPP
|
#ifndef NANA_GUI_WIDGET_DETAIL_TEXTBASE_HPP
|
||||||
#define NANA_GUI_WIDGET_DETAIL_TEXTBASE_HPP
|
#define NANA_GUI_WIDGET_DETAIL_TEXTBASE_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include <nana/charset.hpp>
|
#include <nana/charset.hpp>
|
||||||
#include <nana/basic_types.hpp>
|
#include <nana/basic_types.hpp>
|
||||||
@@ -134,7 +135,7 @@ namespace skeletons
|
|||||||
while(ifs.good())
|
while(ifs.good())
|
||||||
{
|
{
|
||||||
std::getline(ifs, str_mbs);
|
std::getline(ifs, str_mbs);
|
||||||
text_cont_.emplace_back(nana::charset(str_mbs));
|
text_cont_.emplace_back(static_cast<string_type&&>(nana::charset{ str_mbs }));
|
||||||
if(text_cont_.back().size() > attr_max_.size)
|
if(text_cont_.back().size() > attr_max_.size)
|
||||||
{
|
{
|
||||||
attr_max_.size = text_cont_.back().size();
|
attr_max_.size = text_cont_.back().size();
|
||||||
@@ -217,7 +218,7 @@ namespace skeletons
|
|||||||
byte_order_translate_4bytes(str);
|
byte_order_translate_4bytes(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
text_cont_.emplace_back(nana::charset(str, encoding));
|
text_cont_.emplace_back(static_cast<string_type&&>(nana::charset{ str, encoding }));
|
||||||
|
|
||||||
attr_max_.size = text_cont_.back().size();
|
attr_max_.size = text_cont_.back().size();
|
||||||
attr_max_.line = 0;
|
attr_max_.line = 0;
|
||||||
@@ -235,7 +236,7 @@ namespace skeletons
|
|||||||
byte_order_translate_4bytes(str);
|
byte_order_translate_4bytes(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
text_cont_.emplace_back(nana::charset(str, encoding));
|
text_cont_.emplace_back(static_cast<string_type&&>(nana::charset{ str, encoding }));
|
||||||
if(text_cont_.back().size() > attr_max_.size)
|
if(text_cont_.back().size() > attr_max_.size)
|
||||||
{
|
{
|
||||||
attr_max_.size = text_cont_.back().size();
|
attr_max_.size = text_cont_.back().size();
|
||||||
@@ -405,7 +406,7 @@ namespace skeletons
|
|||||||
|
|
||||||
void erase_all()
|
void erase_all()
|
||||||
{
|
{
|
||||||
std::deque<string_type>().swap(text_cont_);
|
text_cont_.clear();
|
||||||
attr_max_.reset();
|
attr_max_.reset();
|
||||||
text_cont_.emplace_back(); //text_cont_ must not be empty
|
text_cont_.emplace_back(); //text_cont_ must not be empty
|
||||||
|
|
||||||
@@ -536,4 +537,6 @@ namespace skeletons
|
|||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace widgets
|
}//end namespace widgets
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef NANA_GUI_WIDGETS_SLIDER_HPP
|
#ifndef NANA_GUI_WIDGETS_SLIDER_HPP
|
||||||
#define NANA_GUI_WIDGETS_SLIDER_HPP
|
#define NANA_GUI_WIDGETS_SLIDER_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include <nana/pat/cloneable.hpp>
|
#include <nana/pat/cloneable.hpp>
|
||||||
|
|
||||||
@@ -30,6 +33,23 @@ namespace nana
|
|||||||
{
|
{
|
||||||
namespace slider
|
namespace slider
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct scheme_impl
|
||||||
|
: public widget_geometrics
|
||||||
|
{
|
||||||
|
/// Colors
|
||||||
|
color_proxy color_adorn { static_cast<color_rgb>(0x3da3ce) };
|
||||||
|
color_proxy color_bar { static_cast<color_rgb>(0x878787) };
|
||||||
|
color_proxy color_slider { static_cast<color_rgb>(0x606060) };
|
||||||
|
color_proxy color_slider_highlighted{ static_cast<color_rgb>(0x2d93be) };
|
||||||
|
color_proxy color_vernier { colors::red };
|
||||||
|
color_proxy color_vernier_text { colors::white };
|
||||||
|
|
||||||
|
/// Geometrical parameters
|
||||||
|
unsigned vernier_text_margin{ 8 };
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
struct slider_events
|
struct slider_events
|
||||||
: public general_events
|
: public general_events
|
||||||
{
|
{
|
||||||
@@ -41,65 +61,66 @@ namespace nana
|
|||||||
bilateral, forward, backward
|
bilateral, forward, backward
|
||||||
};
|
};
|
||||||
|
|
||||||
class provider
|
|
||||||
|
class renderer_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~provider() = default;
|
using graph_reference = ::nana::paint::graphics&;
|
||||||
virtual std::string adorn_trace(unsigned vmax, unsigned vadorn) const = 0;
|
using scheme = scheme_impl;
|
||||||
|
|
||||||
|
struct data_bar
|
||||||
|
{
|
||||||
|
bool vert; ///< Indicates whether the slider is vertical.
|
||||||
|
::nana::rectangle area; ///< Position and size of bar.
|
||||||
|
unsigned border_weight; ///< The border weight in pixels.
|
||||||
};
|
};
|
||||||
|
|
||||||
class renderer
|
struct data_slider
|
||||||
{
|
{
|
||||||
public:
|
bool vert; ///< Indicates whether the slider is vertical.
|
||||||
typedef ::nana::paint::graphics & graph_reference;
|
double pos;
|
||||||
|
unsigned border_weight;
|
||||||
struct bar_t
|
unsigned weight;
|
||||||
{
|
|
||||||
bool horizontal;
|
|
||||||
nana::rectangle r; //the rectangle of bar.
|
|
||||||
unsigned border_size; //border_size of bar.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct slider_t
|
struct data_adorn
|
||||||
{
|
{
|
||||||
bool horizontal;
|
bool vert; ///< Indicates whether the slider is vertical.
|
||||||
int pos;
|
::nana::point bound;
|
||||||
unsigned border;
|
|
||||||
unsigned scale;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct adorn_t
|
|
||||||
{
|
|
||||||
bool horizontal;
|
|
||||||
nana::point bound;
|
|
||||||
int fixedpos;
|
int fixedpos;
|
||||||
unsigned block;
|
unsigned block;
|
||||||
unsigned vcur_scale; //pixels of vcur scale.
|
unsigned vcur_scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~renderer() = default;
|
struct data_vernier
|
||||||
|
{
|
||||||
|
bool vert; ///< Indicates whether the slider is vertical.
|
||||||
|
int position;
|
||||||
|
int end_position;
|
||||||
|
unsigned knob_weight;
|
||||||
|
|
||||||
virtual void background(window, graph_reference, bool isglass) = 0;
|
std::string text;
|
||||||
virtual void adorn(window, graph_reference, const adorn_t&) = 0;
|
|
||||||
virtual void adorn_textbox(window, graph_reference, const ::std::string&, const nana::rectangle&) = 0;
|
|
||||||
virtual void bar(window, graph_reference, const bar_t&) = 0;
|
|
||||||
virtual void slider(window, graph_reference, const slider_t&) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class controller;
|
virtual ~renderer_interface() = default;
|
||||||
|
|
||||||
|
virtual void background(window, graph_reference, bool transparent, const scheme&) = 0;
|
||||||
|
virtual void adorn(window, graph_reference, const data_adorn&, const scheme&) = 0;
|
||||||
|
virtual void vernier(window, graph_reference, const data_vernier&, const scheme&) = 0;
|
||||||
|
virtual void bar(window, graph_reference, const data_bar&, const scheme&) = 0;
|
||||||
|
virtual void slider(window, graph_reference, mouse_action, const data_slider&, const scheme&) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class trigger
|
class trigger
|
||||||
: public drawer_trigger
|
: public drawer_trigger
|
||||||
{
|
{
|
||||||
|
class model;
|
||||||
public:
|
public:
|
||||||
typedef controller controller_t;
|
|
||||||
|
|
||||||
trigger();
|
trigger();
|
||||||
~trigger();
|
~trigger();
|
||||||
controller_t* ctrl() const;
|
model* get_model() const;
|
||||||
private:
|
private:
|
||||||
void attached(widget_reference, graph_reference) override;
|
void attached(widget_reference, graph_reference) override;
|
||||||
void detached() override;
|
|
||||||
void refresh(graph_reference) override;
|
void refresh(graph_reference) override;
|
||||||
void mouse_down(graph_reference, const arg_mouse&) override;
|
void mouse_down(graph_reference, const arg_mouse&) override;
|
||||||
void mouse_up(graph_reference, const arg_mouse&) override;
|
void mouse_up(graph_reference, const arg_mouse&) override;
|
||||||
@@ -107,18 +128,19 @@ namespace nana
|
|||||||
void mouse_leave(graph_reference, const arg_mouse&) override;
|
void mouse_leave(graph_reference, const arg_mouse&) override;
|
||||||
void resized(graph_reference, const arg_resized&) override;
|
void resized(graph_reference, const arg_resized&) override;
|
||||||
private:
|
private:
|
||||||
controller_t * impl_;
|
model * model_ptr_;
|
||||||
};
|
};
|
||||||
}//end namespace slider
|
}//end namespace slider
|
||||||
}//end namespace drawerbase
|
}//end namespace drawerbase
|
||||||
/// A slider widget wich the user can drag for tracking
|
|
||||||
|
|
||||||
|
/// A slider widget wich the user can drag for tracking \todo add scheme ?
|
||||||
class slider
|
class slider
|
||||||
: public widget_object<category::widget_tag, drawerbase::slider::trigger, drawerbase::slider::slider_events>
|
: public widget_object<category::widget_tag, drawerbase::slider::trigger, drawerbase::slider::slider_events, drawerbase::slider::scheme_impl>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef drawerbase::slider::renderer renderer; ///< The interface for user-defined renderer.
|
using renderer_interface = drawerbase::slider::renderer_interface; ///< The interface for customized renderer.
|
||||||
typedef drawerbase::slider::provider provider; ///< The interface for user-defined provider.
|
using seekdir = drawerbase::slider::seekdir; ///< Defines the slider seek direction.
|
||||||
typedef drawerbase::slider::seekdir seekdir; ///< Defines the slider seek direction.
|
|
||||||
|
|
||||||
slider();
|
slider();
|
||||||
slider(window, bool visible);
|
slider(window, bool visible);
|
||||||
@@ -127,19 +149,21 @@ namespace nana
|
|||||||
void seek(seekdir); ///< Define the direction that user can seek by using mouse.
|
void seek(seekdir); ///< Define the direction that user can seek by using mouse.
|
||||||
void vertical(bool);
|
void vertical(bool);
|
||||||
bool vertical() const;
|
bool vertical() const;
|
||||||
void vmax(unsigned);
|
void maximum(unsigned);
|
||||||
unsigned vmax() const;
|
unsigned maximum() const;
|
||||||
void value(unsigned);
|
void value(unsigned);
|
||||||
unsigned value() const;
|
unsigned value() const;
|
||||||
unsigned move_step(bool forward); ///< Increase or decrease the value of slider.
|
unsigned move_step(bool forward); ///< Increase or decrease the value of slider.
|
||||||
unsigned adorn() const;
|
unsigned adorn() const;
|
||||||
|
|
||||||
pat::cloneable<renderer>& ext_renderer(); ///< Refers to the current renderer that slider is using.
|
const pat::cloneable<renderer_interface>& renderer(); ///< Refers to the current renderer that slider is using.
|
||||||
void ext_renderer(const pat::cloneable<renderer>&); ///< Set the current renderer.
|
void renderer(const pat::cloneable<renderer_interface>&); ///< Set the current renderer.
|
||||||
void ext_provider(const pat::cloneable<provider>&);
|
|
||||||
|
void vernier(std::function<std::string(unsigned maximum, unsigned cursor_value)> provider);
|
||||||
void transparent(bool);
|
void transparent(bool);
|
||||||
bool transparent() const;
|
bool transparent() const;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_WIDGET_SPINBOX_HPP
|
#ifndef NANA_GUI_WIDGET_SPINBOX_HPP
|
||||||
#define NANA_GUI_WIDGET_SPINBOX_HPP
|
#define NANA_GUI_WIDGET_SPINBOX_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include "skeletons/text_editor_part.hpp"
|
#include "skeletons/text_editor_part.hpp"
|
||||||
|
|
||||||
@@ -68,7 +70,7 @@ namespace nana
|
|||||||
private:
|
private:
|
||||||
implementation * const impl_;
|
implementation * const impl_;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
}//end namespace drawerbase
|
}//end namespace drawerbase
|
||||||
|
|
||||||
/// Spinbox Widget
|
/// Spinbox Widget
|
||||||
@@ -110,5 +112,5 @@ namespace nana
|
|||||||
void _m_caption(native_string_type&&);
|
void _m_caption(native_string_type&&);
|
||||||
}; //end class spinbox
|
}; //end class spinbox
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif //NANA_GUI_WIDGET_SPINBOX_HPP
|
#endif //NANA_GUI_WIDGET_SPINBOX_HPP
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef NANA_GUI_WIDGET_TABBAR_HPP
|
#ifndef NANA_GUI_WIDGET_TABBAR_HPP
|
||||||
#define NANA_GUI_WIDGET_TABBAR_HPP
|
#define NANA_GUI_WIDGET_TABBAR_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include <nana/pat/cloneable.hpp>
|
#include <nana/pat/cloneable.hpp>
|
||||||
#include <nana/any.hpp>
|
#include <nana/any.hpp>
|
||||||
@@ -111,14 +113,14 @@ namespace nana
|
|||||||
if(pos != npos)
|
if(pos != npos)
|
||||||
{
|
{
|
||||||
drawer_trigger_.at_no_bound_check(pos) = T();
|
drawer_trigger_.at_no_bound_check(pos) = T();
|
||||||
tabbar_.events().added.emit(arg_tabbar({ tabbar_, tabbar_[pos] }));
|
tabbar_.events().added.emit(arg_tabbar({ tabbar_, tabbar_[pos] }), tabbar_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void activated(std::size_t pos) override
|
void activated(std::size_t pos) override
|
||||||
{
|
{
|
||||||
if(pos != npos)
|
if(pos != npos)
|
||||||
tabbar_.events().activated.emit(arg_tabbar({ tabbar_, tabbar_[pos]}));
|
tabbar_.events().activated.emit(arg_tabbar({ tabbar_, tabbar_[pos]}), tabbar_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool removed(std::size_t pos, bool & close_attach) override
|
bool removed(std::size_t pos, bool & close_attach) override
|
||||||
@@ -126,7 +128,7 @@ namespace nana
|
|||||||
if (pos != npos)
|
if (pos != npos)
|
||||||
{
|
{
|
||||||
::nana::arg_tabbar_removed<T> arg(tabbar_, tabbar_[pos]);
|
::nana::arg_tabbar_removed<T> arg(tabbar_, tabbar_[pos]);
|
||||||
tabbar_.events().removed.emit(arg);
|
tabbar_.events().removed.emit(arg, tabbar_);
|
||||||
close_attach = arg.close_attach_window;
|
close_attach = arg.close_attach_window;
|
||||||
return arg.remove;
|
return arg.remove;
|
||||||
}
|
}
|
||||||
@@ -410,5 +412,6 @@ namespace nana
|
|||||||
void erase(std::size_t pos, bool close_attached = true);
|
void erase(std::size_t pos, bool close_attached = true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A Textbox Implementation
|
* A Textbox Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -11,6 +11,8 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef NANA_GUI_WIDGET_TEXTBOX_HPP
|
#ifndef NANA_GUI_WIDGET_TEXTBOX_HPP
|
||||||
#define NANA_GUI_WIDGET_TEXTBOX_HPP
|
#define NANA_GUI_WIDGET_TEXTBOX_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include <nana/gui/widgets/widget.hpp>
|
#include <nana/gui/widgets/widget.hpp>
|
||||||
#include "skeletons/textbase_export_interface.hpp"
|
#include "skeletons/textbase_export_interface.hpp"
|
||||||
#include "skeletons/text_editor_part.hpp"
|
#include "skeletons/text_editor_part.hpp"
|
||||||
@@ -98,6 +100,8 @@ namespace nana
|
|||||||
:public widget_object<category::widget_tag, drawerbase::textbox::drawer, drawerbase::textbox::textbox_events, ::nana::widgets::skeletons::text_editor_scheme>
|
:public widget_object<category::widget_tag, drawerbase::textbox::drawer, drawerbase::textbox::textbox_events, ::nana::widgets::skeletons::text_editor_scheme>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using text_focus_behavior = widgets::skeletons::text_focus_behavior;
|
||||||
|
|
||||||
using text_positions = std::vector<upoint>;
|
using text_positions = std::vector<upoint>;
|
||||||
/// The default constructor without creating the widget.
|
/// The default constructor without creating the widget.
|
||||||
textbox();
|
textbox();
|
||||||
@@ -134,8 +138,14 @@ namespace nana
|
|||||||
/// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line.
|
/// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line.
|
||||||
textbox& indention(bool, std::function<std::string()> generator = {});
|
textbox& indention(bool, std::function<std::string()> generator = {});
|
||||||
|
|
||||||
//A workaround for reset, explicit default constructor syntax, because VC2013 incorrectly treats {} as {0}.
|
/// Discards the old text and set a new text. It also clears the filename/edited flags and undo command.
|
||||||
textbox& reset(const std::string& = std::string()); ///< discard the old text and set a new text
|
/// A workaround for reset, explicit default constructor syntax, because VC2013 incorrectly treats {} as {0}.
|
||||||
|
/*
|
||||||
|
* @param text A new text replaces the old text.
|
||||||
|
* @param end_caret Indicates whether to position the caret to the end of text.
|
||||||
|
* @return a reference of *this.
|
||||||
|
*/
|
||||||
|
textbox& reset(const std::string& text = std::string(), bool end_caret = true); ///< discard the old text and set a new text
|
||||||
|
|
||||||
/// The file of last store operation.
|
/// The file of last store operation.
|
||||||
std::string filename() const;
|
std::string filename() const;
|
||||||
@@ -162,15 +172,18 @@ namespace nana
|
|||||||
/// Appends an string. If `at_caret` is `true`, the string is inserted at the position of caret, otherwise, it is appended at end of the textbox.
|
/// Appends an string. If `at_caret` is `true`, the string is inserted at the position of caret, otherwise, it is appended at end of the textbox.
|
||||||
textbox& append(const std::string& text, bool at_caret);
|
textbox& append(const std::string& text, bool at_caret);
|
||||||
|
|
||||||
/// Determine wheter the text is line wrapped.
|
/// Determines whether the text is line wrapped.
|
||||||
bool line_wrapped() const;
|
bool line_wrapped() const;
|
||||||
textbox& line_wrapped(bool);
|
textbox& line_wrapped(bool);
|
||||||
|
|
||||||
/// Determine whether the text is multi-line enabled.
|
/// Determines whether the text is multi-line enabled.
|
||||||
bool multi_lines() const;
|
bool multi_lines() const;
|
||||||
textbox& multi_lines(bool);
|
textbox& multi_lines(bool);
|
||||||
|
|
||||||
|
/// Determines whether the textbox accepts user input
|
||||||
bool editable() const;
|
bool editable() const;
|
||||||
textbox& editable(bool);
|
textbox& editable(bool);
|
||||||
|
|
||||||
void set_accept(std::function<bool(wchar_t)>);
|
void set_accept(std::function<bool(wchar_t)>);
|
||||||
|
|
||||||
textbox& tip_string(::std::string);
|
textbox& tip_string(::std::string);
|
||||||
@@ -207,6 +220,14 @@ namespace nana
|
|||||||
|
|
||||||
/// Returns the height of line in pixels
|
/// Returns the height of line in pixels
|
||||||
unsigned line_pixels() const;
|
unsigned line_pixels() const;
|
||||||
|
|
||||||
|
/// Sets the behavior when textbox gets focus.
|
||||||
|
void focus_behavior(text_focus_behavior);
|
||||||
|
|
||||||
|
/// Sets the caret move behavior when the content of textbox is selected.
|
||||||
|
/// E.g. Whether caret moves to left of selected content or moves to left of last position when left arrow key is pressed.
|
||||||
|
/// @param move_to_end determines whether to move caret to left of selected_content or to left of last position.
|
||||||
|
void select_behavior(bool move_to_end);
|
||||||
protected:
|
protected:
|
||||||
//Overrides widget's virtual functions
|
//Overrides widget's virtual functions
|
||||||
native_string_type _m_caption() const throw() override;
|
native_string_type _m_caption() const throw() override;
|
||||||
@@ -214,4 +235,6 @@ namespace nana
|
|||||||
void _m_typeface(const paint::font&) override;
|
void _m_typeface(const paint::font&) override;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_WIDGET_TOOLBAR_HPP
|
#ifndef NANA_GUI_WIDGET_TOOLBAR_HPP
|
||||||
#define NANA_GUI_WIDGET_TOOLBAR_HPP
|
#define NANA_GUI_WIDGET_TOOLBAR_HPP
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
|
|
||||||
@@ -101,4 +102,6 @@ namespace nana
|
|||||||
bool detached_;
|
bool detached_;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_WIDGETS_TREEBOX_HPP
|
#ifndef NANA_GUI_WIDGETS_TREEBOX_HPP
|
||||||
#define NANA_GUI_WIDGETS_TREEBOX_HPP
|
#define NANA_GUI_WIDGETS_TREEBOX_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include "widget.hpp"
|
#include "widget.hpp"
|
||||||
#include "detail/compset.hpp"
|
#include "detail/compset.hpp"
|
||||||
#include "detail/tree_cont.hpp"
|
#include "detail/tree_cont.hpp"
|
||||||
@@ -70,9 +72,7 @@ namespace nana
|
|||||||
typedef compset_interface::item_attribute_t item_attribute_t;
|
typedef compset_interface::item_attribute_t item_attribute_t;
|
||||||
typedef compset_interface::comp_attribute_t comp_attribute_t;
|
typedef compset_interface::comp_attribute_t comp_attribute_t;
|
||||||
|
|
||||||
virtual ~renderer_interface()
|
virtual ~renderer_interface() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
virtual void set_color(const nana::color& bgcolor, const nana::color& fgcolor) = 0;
|
virtual void set_color(const nana::color& bgcolor, const nana::color& fgcolor) = 0;
|
||||||
|
|
||||||
virtual void bground(graph_reference, const compset_interface *) const = 0;
|
virtual void bground(graph_reference, const compset_interface *) const = 0;
|
||||||
@@ -307,14 +307,14 @@ namespace nana
|
|||||||
{
|
{
|
||||||
_m_value() = t;
|
_m_value() = t;
|
||||||
return *this;
|
return *this;
|
||||||
};
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
item_proxy & value(T&& t)
|
item_proxy & value(T&& t)
|
||||||
{
|
{
|
||||||
_m_value() = std::move(t);
|
_m_value() = std::move(t);
|
||||||
return *this;
|
return *this;
|
||||||
};
|
}
|
||||||
|
|
||||||
// Undocumentated methods for internal use
|
// Undocumentated methods for internal use
|
||||||
trigger::node_type * _m_node() const;
|
trigger::node_type * _m_node() const;
|
||||||
@@ -452,4 +452,6 @@ namespace nana
|
|||||||
item_proxy selected() const; ///< returns the selected node
|
item_proxy selected() const; ///< returns the selected node
|
||||||
};//end class treebox
|
};//end class treebox
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* The fundamental widget class implementation
|
* The fundamental widget class implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -12,11 +12,11 @@
|
|||||||
|
|
||||||
#ifndef NANA_GUI_WIDGET_HPP
|
#ifndef NANA_GUI_WIDGET_HPP
|
||||||
#define NANA_GUI_WIDGET_HPP
|
#define NANA_GUI_WIDGET_HPP
|
||||||
#include "../basis.hpp"
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include "../programming_interface.hpp"
|
#include "../programming_interface.hpp"
|
||||||
#include <nana/internationalization.hpp>
|
#include <nana/internationalization.hpp>
|
||||||
#include <nana/gui/detail/drawer.hpp>
|
#include <nana/gui/detail/drawer.hpp>
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -79,6 +79,15 @@ namespace nana
|
|||||||
nana::size size() const;
|
nana::size size() const;
|
||||||
void size(const nana::size&);
|
void size(const nana::size&);
|
||||||
|
|
||||||
|
/// Enables the widget to grab the mouse input.
|
||||||
|
/*
|
||||||
|
* @param ignore_children Indicates whether to redirect the mouse input to its children if the mouse pointer is over its children.
|
||||||
|
*/
|
||||||
|
void set_capture(bool ignore_children);
|
||||||
|
|
||||||
|
/// Disables the widget to grab the mouse input.
|
||||||
|
void release_capture();
|
||||||
|
|
||||||
point pos() const;
|
point pos() const;
|
||||||
void move(int x, int y);
|
void move(int x, int y);
|
||||||
void move(const point&);
|
void move(const point&);
|
||||||
@@ -132,9 +141,25 @@ namespace nana
|
|||||||
virtual nana::color _m_bgcolor() const;
|
virtual nana::color _m_bgcolor() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
class widget_base
|
||||||
|
: public widget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~widget_base();
|
||||||
|
|
||||||
|
window handle() const override;
|
||||||
|
private:
|
||||||
|
void _m_notify_destroy() override final;
|
||||||
|
protected:
|
||||||
|
window handle_{ nullptr };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Base class of all the classes defined as a widget window. Defaultly a widget_tag
|
/// Base class of all the classes defined as a widget window. Defaultly a widget_tag
|
||||||
template<typename Category, typename DrawerTrigger, typename Events = ::nana::general_events, typename Scheme = ::nana::widget_colors>
|
template<typename Category, typename DrawerTrigger, typename Events = ::nana::general_events, typename Scheme = ::nana::widget_geometrics>
|
||||||
class widget_object: public widget
|
class widget_object: public detail::widget_base
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef DrawerTrigger drawer_trigger_t;
|
typedef DrawerTrigger drawer_trigger_t;
|
||||||
@@ -147,12 +172,6 @@ namespace nana
|
|||||||
scheme_{ API::dev::make_scheme<Scheme>() }
|
scheme_{ API::dev::make_scheme<Scheme>() }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~widget_object()
|
|
||||||
{
|
|
||||||
if(handle_)
|
|
||||||
API::close_window(handle_);
|
|
||||||
}
|
|
||||||
|
|
||||||
event_type& events() const
|
event_type& events() const
|
||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
@@ -179,11 +198,6 @@ namespace nana
|
|||||||
return (this->empty() == false);
|
return (this->empty() == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
window handle() const override
|
|
||||||
{
|
|
||||||
return handle_;
|
|
||||||
}
|
|
||||||
|
|
||||||
widget_object& borderless(bool enable)
|
widget_object& borderless(bool enable)
|
||||||
{
|
{
|
||||||
API::widget_borderless(handle_, enable);
|
API::widget_borderless(handle_, enable);
|
||||||
@@ -214,13 +228,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _m_notify_destroy() override final
|
|
||||||
{
|
|
||||||
handle_ = nullptr;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
window handle_{nullptr};
|
|
||||||
DrawerTrigger trigger_;
|
DrawerTrigger trigger_;
|
||||||
std::shared_ptr<Events> events_;
|
std::shared_ptr<Events> events_;
|
||||||
std::unique_ptr<scheme_type> scheme_;
|
std::unique_ptr<scheme_type> scheme_;
|
||||||
@@ -228,7 +236,7 @@ namespace nana
|
|||||||
|
|
||||||
/// Base class of all the classes defined as a non-graphics-buffer widget window. The second template parameter DrawerTrigger is always ignored.\see nana::panel
|
/// Base class of all the classes defined as a non-graphics-buffer widget window. The second template parameter DrawerTrigger is always ignored.\see nana::panel
|
||||||
template<typename DrawerTrigger, typename Events, typename Scheme>
|
template<typename DrawerTrigger, typename Events, typename Scheme>
|
||||||
class widget_object<category::lite_widget_tag, DrawerTrigger, Events, Scheme>: public widget
|
class widget_object<category::lite_widget_tag, DrawerTrigger, Events, Scheme>: public detail::widget_base
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef DrawerTrigger drawer_trigger_t;
|
typedef DrawerTrigger drawer_trigger_t;
|
||||||
@@ -240,12 +248,6 @@ namespace nana
|
|||||||
: events_{ std::make_shared<Events>() }, scheme_{ API::dev::make_scheme<scheme_type>() }
|
: events_{ std::make_shared<Events>() }, scheme_{ API::dev::make_scheme<scheme_type>() }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~widget_object()
|
|
||||||
{
|
|
||||||
if(handle_)
|
|
||||||
API::close_window(handle_);
|
|
||||||
}
|
|
||||||
|
|
||||||
event_type& events() const
|
event_type& events() const
|
||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
@@ -270,11 +272,6 @@ namespace nana
|
|||||||
return (this->empty() == false);
|
return (this->empty() == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
window handle() const override
|
|
||||||
{
|
|
||||||
return handle_;
|
|
||||||
}
|
|
||||||
|
|
||||||
scheme_type& scheme() const
|
scheme_type& scheme() const
|
||||||
{
|
{
|
||||||
return *scheme_;
|
return *scheme_;
|
||||||
@@ -284,13 +281,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _m_notify_destroy() override final
|
|
||||||
{
|
|
||||||
handle_ = nullptr;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
window handle_{nullptr};
|
|
||||||
std::shared_ptr<Events> events_;
|
std::shared_ptr<Events> events_;
|
||||||
std::unique_ptr<scheme_type> scheme_;
|
std::unique_ptr<scheme_type> scheme_;
|
||||||
};//end class widget_object
|
};//end class widget_object
|
||||||
@@ -298,7 +289,7 @@ namespace nana
|
|||||||
|
|
||||||
/// Base class of all the classes defined as a root window. \see nana::form
|
/// Base class of all the classes defined as a root window. \see nana::form
|
||||||
template<typename DrawerTrigger, typename Events, typename Scheme>
|
template<typename DrawerTrigger, typename Events, typename Scheme>
|
||||||
class widget_object<category::root_tag, DrawerTrigger, Events, Scheme>: public widget
|
class widget_object<category::root_tag, DrawerTrigger, Events, Scheme>: public detail::widget_base
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef DrawerTrigger drawer_trigger_t;
|
typedef DrawerTrigger drawer_trigger_t;
|
||||||
@@ -324,12 +315,6 @@ namespace nana
|
|||||||
_m_bind_and_attach();
|
_m_bind_and_attach();
|
||||||
}
|
}
|
||||||
|
|
||||||
~widget_object()
|
|
||||||
{
|
|
||||||
if(handle_)
|
|
||||||
API::close_window(handle_);
|
|
||||||
}
|
|
||||||
|
|
||||||
event_type& events() const
|
event_type& events() const
|
||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
@@ -340,11 +325,6 @@ namespace nana
|
|||||||
API::activate_window(handle_);
|
API::activate_window(handle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
window handle() const override
|
|
||||||
{
|
|
||||||
return handle_;
|
|
||||||
}
|
|
||||||
|
|
||||||
native_window_type native_handle() const
|
native_window_type native_handle() const
|
||||||
{
|
{
|
||||||
return API::root(handle_);
|
return API::root(handle_);
|
||||||
@@ -435,25 +415,20 @@ namespace nana
|
|||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _m_notify_destroy() override final
|
|
||||||
{
|
|
||||||
handle_ = nullptr;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
window handle_;
|
|
||||||
DrawerTrigger trigger_;
|
DrawerTrigger trigger_;
|
||||||
std::shared_ptr<Events> events_;
|
std::shared_ptr<Events> events_;
|
||||||
std::unique_ptr<scheme_type> scheme_;
|
std::unique_ptr<scheme_type> scheme_;
|
||||||
};//end class widget_object<root_tag>
|
};//end class widget_object<root_tag>
|
||||||
|
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
/// Base class of all the classes defined as a frame window. \see nana::frame
|
/// Base class of all the classes defined as a frame window. \see nana::frame
|
||||||
template<typename Drawer, typename Events, typename Scheme>
|
template<typename Drawer, typename Events, typename Scheme>
|
||||||
class widget_object<category::frame_tag, Drawer, Events, Scheme>: public widget{};
|
class widget_object<category::frame_tag, Drawer, Events, Scheme>: public widget{};
|
||||||
|
|
||||||
/// Especialization. Base class of all the classes defined as a frame window. \see nana::frame
|
/// Especialization. Base class of all the classes defined as a frame window. \see nana::frame
|
||||||
template<typename Events, typename Scheme>
|
template<typename Events, typename Scheme>
|
||||||
class widget_object<category::frame_tag, int, Events, Scheme>: public widget
|
class widget_object<category::frame_tag, int, Events, Scheme>: public detail::widget_base
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef int drawer_trigger_t;
|
typedef int drawer_trigger_t;
|
||||||
@@ -465,12 +440,6 @@ namespace nana
|
|||||||
: events_{ std::make_shared<Events>() }, scheme_{ API::dev::make_scheme<scheme_type>() }
|
: events_{ std::make_shared<Events>() }, scheme_{ API::dev::make_scheme<scheme_type>() }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~widget_object()
|
|
||||||
{
|
|
||||||
if(handle_)
|
|
||||||
API::close_window(handle_);
|
|
||||||
}
|
|
||||||
|
|
||||||
event_type& events() const
|
event_type& events() const
|
||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
@@ -494,11 +463,6 @@ namespace nana
|
|||||||
return (this->empty() == false);
|
return (this->empty() == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
window handle() const override
|
|
||||||
{
|
|
||||||
return handle_;
|
|
||||||
}
|
|
||||||
|
|
||||||
scheme_type& scheme() const
|
scheme_type& scheme() const
|
||||||
{
|
{
|
||||||
return *scheme_;
|
return *scheme_;
|
||||||
@@ -513,15 +477,12 @@ namespace nana
|
|||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _m_notify_destroy() override final
|
|
||||||
{
|
|
||||||
handle_ = nullptr;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
window handle_{nullptr};
|
|
||||||
std::shared_ptr<Events> events_;
|
std::shared_ptr<Events> events_;
|
||||||
std::unique_ptr<scheme_type> scheme_;
|
std::unique_ptr<scheme_type> scheme_;
|
||||||
};//end class widget_object<category::frame_tag>
|
};//end class widget_object<category::frame_tag>
|
||||||
}//end namespace nana
|
#endif
|
||||||
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
/*
|
/**
|
||||||
* Nana GUI Library Definition
|
* Nana GUI Library Definition
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/gui/wvl.hpp
|
* @file nana/gui/wvl.hpp
|
||||||
* @description:
|
* @description
|
||||||
* the header file contains the files required for running of Nana.GUI
|
* the header file contains the files required for running of Nana.GUI
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "msgbox.hpp"
|
#include "msgbox.hpp"
|
||||||
#include "place.hpp"
|
#include "place.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
@@ -58,6 +59,25 @@ namespace nana
|
|||||||
template<typename Form, bool IsVisible = true>
|
template<typename Form, bool IsVisible = true>
|
||||||
using form_loader = detail::form_loader<Form, IsVisible>;
|
using form_loader = detail::form_loader<Form, IsVisible>;
|
||||||
|
|
||||||
void exec();
|
/// @brief Take control of the GUI and optionaly automaticaly tests it.
|
||||||
|
///
|
||||||
|
/// @detail It transfers to nana the program flow control, which begin pumping messages
|
||||||
|
/// from the underlying OS, interpreting and sending it with suitable arguments
|
||||||
|
/// to the nana widgets that registered a response in the corresponding event.
|
||||||
|
/// It also accept arguments to be used in case of automatic GUI testing.
|
||||||
|
/// Other Way the arguments are ignored.
|
||||||
|
void exec(
|
||||||
|
unsigned wait = 1, ///< for the GUI to be constructed, in seconds
|
||||||
|
unsigned wait_end = 1, ///< for the GUI to be destructed, in seconds
|
||||||
|
std::function<void()> = {} ///< emit events to mimics user actions and may asert results
|
||||||
|
);
|
||||||
|
|
||||||
|
/// send a click message to this widget - useffull in GUI testing
|
||||||
|
void click(widget& w);
|
||||||
|
|
||||||
|
/// in seconds
|
||||||
|
void Wait(unsigned wait = 0);
|
||||||
|
|
||||||
|
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,63 +26,63 @@ namespace nana
|
|||||||
}; //end class key_interface
|
}; //end class key_interface
|
||||||
|
|
||||||
//Use less compare for equal compare [call it equal_by_less()?]
|
//Use less compare for equal compare [call it equal_by_less()?]
|
||||||
inline bool pred_equal_by_less(const key_interface * left, const key_interface* right)
|
inline bool pred_equal(const key_interface * left, const key_interface* right)
|
||||||
{
|
{
|
||||||
return (left->compare(right) == false) && (right->compare(left) == false);
|
return (left->same_type(right) && (left->compare(right) == false) && (right->compare(left) == false));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct type_escape
|
struct type_escape
|
||||||
{
|
{
|
||||||
typedef T type;
|
using type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct type_escape<char*>
|
struct type_escape<char*>
|
||||||
{
|
{
|
||||||
typedef std::string type;
|
using type = ::std::string;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct type_escape<const char*>
|
struct type_escape<const char*>
|
||||||
{
|
{
|
||||||
typedef std::string type;
|
using type = ::std::string;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<int Size>
|
template<int Size>
|
||||||
struct type_escape<char[Size]>
|
struct type_escape<char[Size]>
|
||||||
{
|
{
|
||||||
typedef std::string type;
|
using type = ::std::string;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<int Size>
|
template<int Size>
|
||||||
struct type_escape<const char[Size]>
|
struct type_escape<const char[Size]>
|
||||||
{
|
{
|
||||||
typedef std::string type;
|
using type = ::std::string;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct type_escape<wchar_t*>
|
struct type_escape<wchar_t*>
|
||||||
{
|
{
|
||||||
typedef std::wstring type;
|
using type = ::std::wstring;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct type_escape<const wchar_t*>
|
struct type_escape<const wchar_t*>
|
||||||
{
|
{
|
||||||
typedef std::wstring type;
|
using type = ::std::wstring;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<int Size>
|
template<int Size>
|
||||||
struct type_escape<wchar_t[Size]>
|
struct type_escape<wchar_t[Size]>
|
||||||
{
|
{
|
||||||
typedef std::wstring type;
|
using type = ::std::wstring;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<int Size>
|
template<int Size>
|
||||||
struct type_escape<const wchar_t[Size]>
|
struct type_escape<const wchar_t[Size]>
|
||||||
{
|
{
|
||||||
typedef std::wstring type;
|
using type = ::std::wstring;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define NANA_PAINT_DETAIL_IMAGE_IMPL_INTERFACE_HPP
|
#define NANA_PAINT_DETAIL_IMAGE_IMPL_INTERFACE_HPP
|
||||||
|
|
||||||
#include "../image.hpp"
|
#include "../image.hpp"
|
||||||
#include <nana/filesystem/filesystem.hpp>
|
#include <nana/filesystem/filesystem_ext.hpp>
|
||||||
|
|
||||||
namespace nana{ namespace paint{
|
namespace nana{ namespace paint{
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ namespace nana{ namespace paint{
|
|||||||
public:
|
public:
|
||||||
typedef nana::paint::graphics& graph_reference;
|
typedef nana::paint::graphics& graph_reference;
|
||||||
virtual ~image_impl_interface() = 0; //The destructor is defined in ../image.cpp
|
virtual ~image_impl_interface() = 0; //The destructor is defined in ../image.cpp
|
||||||
virtual bool open(const nana::experimental::filesystem::path& file) = 0;
|
virtual bool open(const std::experimental::filesystem::path& file) = 0;
|
||||||
virtual bool open(const void* data, std::size_t bytes) = 0; // reads image from memory
|
virtual bool open(const void* data, std::size_t bytes) = 0; // reads image from memory
|
||||||
virtual bool alpha_channel() const = 0;
|
virtual bool alpha_channel() const = 0;
|
||||||
virtual bool empty() const = 0;
|
virtual bool empty() const = 0;
|
||||||
|
|||||||
@@ -330,19 +330,21 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pixel_argb_t * s_end = s_rgb + rest;
|
const pixel_argb_t * s_end = s_rgb + rest;
|
||||||
|
auto rest_d_rgb = d_rgb;
|
||||||
for(auto i = s_rgb; i != s_end; ++i)
|
for(auto i = s_rgb; i != s_end; ++i)
|
||||||
{
|
{
|
||||||
if(i->element.alpha_channel)
|
if(i->element.alpha_channel)
|
||||||
{
|
{
|
||||||
if(i->element.alpha_channel != 255)
|
if(i->element.alpha_channel != 255)
|
||||||
{
|
{
|
||||||
d_rgb[3].element.red = unsigned(d_rgb[3].element.red * (255 - i->element.alpha_channel) + i->element.red * i->element.alpha_channel) / 255;
|
rest_d_rgb->element.red = unsigned(rest_d_rgb->element.red * (255 - i->element.alpha_channel) + i->element.red * i->element.alpha_channel) / 255;
|
||||||
d_rgb[3].element.green = unsigned(d_rgb[3].element.green * (255 - i->element.alpha_channel) + i->element.green * i->element.alpha_channel) / 255;
|
rest_d_rgb->element.green = unsigned(rest_d_rgb->element.green * (255 - i->element.alpha_channel) + i->element.green * i->element.alpha_channel) / 255;
|
||||||
d_rgb[3].element.blue = unsigned(d_rgb[3].element.blue * (255 - i->element.alpha_channel) + i->element.blue * i->element.alpha_channel) / 255;
|
rest_d_rgb->element.blue = unsigned(rest_d_rgb->element.blue * (255 - i->element.alpha_channel) + i->element.blue * i->element.alpha_channel) / 255;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
d_rgb[3] = *i;
|
*rest_d_rgb = *i;
|
||||||
}
|
}
|
||||||
|
++rest_d_rgb;
|
||||||
}
|
}
|
||||||
d_rgb = pixel_at(d_rgb, d_step_bytes);
|
d_rgb = pixel_at(d_rgb, d_step_bytes);
|
||||||
s_rgb = pixel_at(s_rgb, s_step_bytes);
|
s_rgb = pixel_at(s_rgb, s_step_bytes);
|
||||||
|
|||||||
@@ -13,10 +13,11 @@
|
|||||||
#ifndef NANA_PAINT_GRAPHICS_HPP
|
#ifndef NANA_PAINT_GRAPHICS_HPP
|
||||||
#define NANA_PAINT_GRAPHICS_HPP
|
#define NANA_PAINT_GRAPHICS_HPP
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "../basic_types.hpp"
|
#include "../basic_types.hpp"
|
||||||
#include "../gui/basis.hpp"
|
#include "../gui/basis.hpp"
|
||||||
#include "pixel_buffer.hpp"
|
#include "pixel_buffer.hpp"
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -111,6 +112,7 @@ namespace nana
|
|||||||
void bitblt(const ::nana::rectangle& r_dst, const graphics& src); ///< Transfers the color data corresponding to r_dst from the src graphics to this graphics.
|
void bitblt(const ::nana::rectangle& r_dst, const graphics& src); ///< Transfers the color data corresponding to r_dst from the src graphics to this graphics.
|
||||||
void bitblt(const ::nana::rectangle& r_dst, const graphics& src, const point& p_src);///< Transfers the color data corresponding to r_dst from the src graphics at point p_src to this graphics.
|
void bitblt(const ::nana::rectangle& r_dst, const graphics& src, const point& p_src);///< Transfers the color data corresponding to r_dst from the src graphics at point p_src to this graphics.
|
||||||
|
|
||||||
|
void blend(const ::nana::rectangle& r, const ::nana::color&, double fade_rate);
|
||||||
void blend(const ::nana::rectangle& s_r, graphics& dst, const point& d_pos, double fade_rate) const;///< blends with the dst object.
|
void blend(const ::nana::rectangle& s_r, graphics& dst, const point& d_pos, double fade_rate) const;///< blends with the dst object.
|
||||||
|
|
||||||
void blur(const ::nana::rectangle& r, std::size_t radius); ///< Blur process.
|
void blur(const ::nana::rectangle& r, std::size_t radius); ///< Blur process.
|
||||||
@@ -144,8 +146,6 @@ namespace nana
|
|||||||
unsigned bidi_string(const nana::point&, const wchar_t *, std::size_t len);
|
unsigned bidi_string(const nana::point&, const wchar_t *, std::size_t len);
|
||||||
unsigned bidi_string(const point& pos, const char*, std::size_t len);
|
unsigned bidi_string(const point& pos, const char*, std::size_t len);
|
||||||
|
|
||||||
void blend(const ::nana::rectangle& r, const ::nana::color&, double fade_rate);
|
|
||||||
|
|
||||||
void set_pixel(int x, int y, const ::nana::color&);
|
void set_pixel(int x, int y, const ::nana::color&);
|
||||||
void set_pixel(int x, int y);
|
void set_pixel(int x, int y);
|
||||||
|
|
||||||
@@ -167,6 +167,7 @@ namespace nana
|
|||||||
void rectangle(const ::nana::rectangle&, bool solid);
|
void rectangle(const ::nana::rectangle&, bool solid);
|
||||||
void rectangle(const ::nana::rectangle&, bool solid, const color&);
|
void rectangle(const ::nana::rectangle&, bool solid, const color&);
|
||||||
void frame_rectangle(const ::nana::rectangle&, const color& left, const color& top, const color& right, const color& bottom);
|
void frame_rectangle(const ::nana::rectangle&, const color& left, const color& top, const color& right, const color& bottom);
|
||||||
|
void frame_rectangle(const ::nana::rectangle&, const color&, unsigned gap);
|
||||||
|
|
||||||
void gradual_rectangle(const ::nana::rectangle&, const color& from, const color& to, bool vertical);
|
void gradual_rectangle(const ::nana::rectangle&, const color& from, const color& to, bool vertical);
|
||||||
void round_rectangle(const ::nana::rectangle&, unsigned radius_x, unsigned radius_y, const color&, bool solid, const color& color_if_solid);
|
void round_rectangle(const ::nana::rectangle&, unsigned radius_x, unsigned radius_y, const color&, bool solid, const color& color_if_solid);
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ namespace nana{ namespace paint
|
|||||||
void blend(const nana::rectangle& s_r, drawable_type dw_dst, const nana::point& d_pos, double fade_rate) const;
|
void blend(const nana::rectangle& s_r, drawable_type dw_dst, const nana::point& d_pos, double fade_rate) const;
|
||||||
void blur(const nana::rectangle& r, std::size_t radius);
|
void blur(const nana::rectangle& r, std::size_t radius);
|
||||||
|
|
||||||
|
pixel_buffer rotate(double angle, const color& extend_color);
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<pixel_buffer_storage> storage_;
|
std::shared_ptr<pixel_buffer_storage> storage_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace nana
|
|||||||
class text_renderer
|
class text_renderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef graphics & graph_reference;
|
using graph_reference = graphics &;
|
||||||
|
|
||||||
text_renderer(graph_reference graph, align = align::left);
|
text_renderer(graph_reference graph, align = align::left);
|
||||||
|
|
||||||
@@ -22,6 +22,35 @@ namespace nana
|
|||||||
graph_reference graph_;
|
graph_reference graph_;
|
||||||
align text_align_;
|
align text_align_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Draw aligned string
|
||||||
|
class aligner
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using graph_reference = graphics&;
|
||||||
|
|
||||||
|
/// Constructor
|
||||||
|
/**
|
||||||
|
* @param graph Reference to a graphics object
|
||||||
|
* @param text_align Alignment of text
|
||||||
|
* @param text_align_if_too_long Alignment of text if the pixels of string is larger than text area
|
||||||
|
*/
|
||||||
|
aligner(graph_reference graph, align text_align = align::left);
|
||||||
|
aligner(graph_reference graph, align text_align, align text_align_if_too_long);
|
||||||
|
|
||||||
|
/// Draws a text with specified text alignment.
|
||||||
|
/**
|
||||||
|
* @param text Text to draw
|
||||||
|
* @param pos Postion where the text to draw
|
||||||
|
* @param width The width of text area. If the pixels of text is larger than this parameter, it draws ellipsis
|
||||||
|
*/
|
||||||
|
void draw(const std::string& text, point pos, unsigned width);
|
||||||
|
void draw(const std::wstring& text, point pos, unsigned width);
|
||||||
|
private:
|
||||||
|
graph_reference graph_;
|
||||||
|
align text_align_;
|
||||||
|
align text_align_ex_;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#ifndef NANA_PAT_CLONEABLE_HPP
|
#ifndef NANA_PAT_CLONEABLE_HPP
|
||||||
#define NANA_PAT_CLONEABLE_HPP
|
#define NANA_PAT_CLONEABLE_HPP
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include <nana/c++defines.hpp>
|
#include <nana/c++defines.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@@ -97,9 +98,7 @@ namespace nana{ namespace pat{
|
|||||||
typedef int inner_bool::* operator_bool_t;
|
typedef int inner_bool::* operator_bool_t;
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
struct member_enabled
|
using member_enabled = std::enable_if<(!std::is_base_of<cloneable, typename std::remove_reference<U>::type>::value) && std::is_base_of<base_t, typename std::remove_reference<U>::type>::value, int>;
|
||||||
: public std::enable_if<(!std::is_base_of<cloneable, typename std::remove_reference<U>::type>::value) && std::is_base_of<base_t, typename std::remove_reference<U>::type>::value, int>
|
|
||||||
{};
|
|
||||||
public:
|
public:
|
||||||
cloneable() noexcept = default;
|
cloneable() noexcept = default;
|
||||||
|
|
||||||
@@ -207,5 +206,5 @@ namespace nana{ namespace pat{
|
|||||||
using mutable_cloneable = cloneable<T, true>;
|
using mutable_cloneable = cloneable<T, true>;
|
||||||
}//end namespace pat
|
}//end namespace pat
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
5
include/nana/pop_ignore_diagnostic
Normal file
5
include/nana/pop_ignore_diagnostic
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
#if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 6)
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
4
include/nana/push_ignore_diagnostic
Normal file
4
include/nana/push_ignore_diagnostic
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 6)
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Weffc++"
|
||||||
|
#endif
|
||||||
@@ -8,12 +8,12 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <thread>
|
//#include <thread>
|
||||||
#include <pthread.h>
|
//#include <pthread.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
// http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno.h#L53
|
// http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno.h#L53
|
||||||
#define EPROTO 71 /* Protocol error */
|
//#define EPROTO 71 /* Protocol error */
|
||||||
#include <mingw.thread.h>
|
#include <mingw.thread.h>
|
||||||
#include <mingw.mutex.h>
|
#include <mingw.mutex.h>
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#if defined(STD_THREAD_NOT_SUPPORTED)
|
#if defined(STD_THREAD_NOT_SUPPORTED)
|
||||||
|
|
||||||
#if defined(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
#if defined(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
|
|
||||||
#include <mingw.thread.h>
|
#include <mingw.thread.h>
|
||||||
#else
|
#else
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
@@ -13,5 +14,11 @@ namespace std
|
|||||||
typedef boost::thread thread;
|
typedef boost::thread thread;
|
||||||
}
|
}
|
||||||
#endif // (NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
#endif // (NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#endif // (STD_THREAD_NOT_SUPPORTED)
|
#endif // (STD_THREAD_NOT_SUPPORTED)
|
||||||
|
|
||||||
#endif // NANA_STD_THREAD_HPP
|
#endif // NANA_STD_THREAD_HPP
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace system
|
|||||||
typedef void* module_t;
|
typedef void* module_t;
|
||||||
void* symbols(module_t handle, const char* symbol);
|
void* symbols(module_t handle, const char* symbol);
|
||||||
|
|
||||||
}; //end struct shared_helper
|
} //end namespace shared_helper
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
|
|
||||||
class shared_wrapper
|
class shared_wrapper
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef NANA_UNICODE_BIDI_HPP
|
#ifndef NANA_UNICODE_BIDI_HPP
|
||||||
#define NANA_UNICODE_BIDI_HPP
|
#define NANA_UNICODE_BIDI_HPP
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -60,7 +62,7 @@ namespace nana
|
|||||||
void _m_resolve_weak_types();
|
void _m_resolve_weak_types();
|
||||||
void _m_resolve_neutral_types();
|
void _m_resolve_neutral_types();
|
||||||
void _m_resolve_implicit_levels();
|
void _m_resolve_implicit_levels();
|
||||||
void _m_reordering_resolved_levels(const char_type*, std::vector<entity> & reordered);
|
void _m_reordering_resolved_levels(std::vector<entity> & reordered);
|
||||||
static bidi_category _m_bidi_category(bidi_char);
|
static bidi_category _m_bidi_category(bidi_char);
|
||||||
static bidi_char _m_char_dir(char_type);
|
static bidi_char _m_char_dir(char_type);
|
||||||
private:
|
private:
|
||||||
@@ -71,5 +73,6 @@ namespace nana
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
*
|
*
|
||||||
* @brief show the values of configuration constants during compilation to facilitate build debugging.
|
* @brief show the values of configuration constants during compilation to facilitate build debugging.
|
||||||
*
|
*
|
||||||
* Set VERBOSE_PREPROCESSOR to 1 to show the messages or to 0 for a normal build.
|
* Define VERBOSE_PREPROCESSOR to show the messages or undefine for a normal build.
|
||||||
* Normally set to 0. Set to 1 only in case you want to debug the build system because it is extremely repetitive and slow.
|
* Normally undefined. Define in case you want to debug the build system.
|
||||||
*
|
*
|
||||||
* @authors Ariel Vina-Rodriguez (qPCR4vir)
|
* @authors Ariel Vina-Rodriguez (qPCR4vir)
|
||||||
*
|
*
|
||||||
@@ -25,25 +25,107 @@
|
|||||||
|
|
||||||
#if defined(VERBOSE_PREPROCESSOR)
|
#if defined(VERBOSE_PREPROCESSOR)
|
||||||
|
|
||||||
|
#include <nana/config.hpp>
|
||||||
|
#include <nana/deploy.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define STRING2(x) #x
|
#define STRING2(x) #x
|
||||||
#define STRING(x) STRING2(x)
|
#define STRING(x) STRING2(x)
|
||||||
#pragma message ( "\nVerbose preprocessor =" STRING(VERBOSE_PREPROCESSOR)" , \n STOP_VERBOSE_PREPROCESSOR=" STRING(STOP_VERBOSE_PREPROCESSOR) )
|
#define SHOW_VALUE(x) " " #x " = " STRING2(x)
|
||||||
|
|
||||||
#pragma message ( "\nWindows: \n _WIN32=" STRING(_WIN32) ", \n __WIN32__ =" STRING(__WIN32__) " , \n WIN32=" STRING(WIN32)" , \n NANA_WINDOWS=" STRING(NANA_WINDOWS) )
|
#pragma message ( "\n -----> Verbose preprocessor" )
|
||||||
|
#pragma message ( SHOW_VALUE(VERBOSE_PREPROCESSOR) )
|
||||||
|
#pragma message ( SHOW_VALUE(STOP_VERBOSE_PREPROCESSOR) )
|
||||||
|
|
||||||
#pragma message ( "\nUNICODE: \n NANA_UNICODE=" STRING(NANA_UNICODE) ", \n _UNICODE =" STRING(_UNICODE) " , \n UNICODE=" STRING(UNICODE) )
|
#pragma message ( "\n -----> OS: \n --Windows: " )
|
||||||
|
#pragma message ( SHOW_VALUE(_WIN32) )
|
||||||
|
#pragma message ( SHOW_VALUE(__WIN32__) )
|
||||||
|
#pragma message ( SHOW_VALUE(WIN32) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_WINDOWS) )
|
||||||
|
|
||||||
#pragma message ( "\nMinGW: \n __MINGW32__=" STRING(__MINGW32__) ", \n __MINGW64__=" STRING(__MINGW64__) " , \n MINGW=" STRING(MINGW) )
|
#pragma message ( "\n ---NIX: " )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_LINUX) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_POSIX) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_X11) )
|
||||||
|
#pragma message ( SHOW_VALUE(APPLE) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_IGNORE_CONF) )
|
||||||
|
|
||||||
#pragma message ( "\nGNU: \n __GNUC__=" STRING(__GNUC__) ", \n __GNUC_MINOR__=" STRING(__GNUC_MINOR__) " , \n __GNUC_PATCHLEVEL__=" STRING(__GNUC_PATCHLEVEL__) )
|
|
||||||
|
|
||||||
#pragma message ( "\nSTD: \nSTD_CODECVT_NOT_SUPPORTED=" STRING(STD_CODECVT_NOT_SUPPORTED) " , \nSTD_THREAD_NOT_SUPPORTED=" STRING(STD_THREAD_NOT_SUPPORTED) )
|
#pragma message ( "\n -----> Compilers: \n MinGW: " )
|
||||||
|
#pragma message ( SHOW_VALUE(__MINGW32__) )
|
||||||
|
#pragma message ( SHOW_VALUE(__MINGW64__) )
|
||||||
|
#pragma message ( SHOW_VALUE(MINGW) )
|
||||||
|
|
||||||
#pragma message ( "\nSTD: \nUSE_github_com_meganz_mingw_std_threads=" STRING(USE_github_com_meganz_mingw_std_threads) " , \nSTD_THREAD_NOT_SUPPORTED=" STRING(STD_THREAD_NOT_SUPPORTED) )
|
#pragma message ( "\n ---MSC: " )
|
||||||
|
#pragma message ( SHOW_VALUE(_MSC_VER) )
|
||||||
|
#pragma message ( SHOW_VALUE(_MSC_FULL_VER) )
|
||||||
|
|
||||||
#pragma message ( "\nClang compiler: \n__clang__=" STRING(__clang__) ", \n__GLIBCPP__=" STRING(__GLIBCPP__) " , \n__GLIBCXX__=" STRING(__GLIBCXX__) )
|
#pragma message ( "\n ---GNU: " )
|
||||||
|
#pragma message ( SHOW_VALUE(__GNUC__) )
|
||||||
|
#pragma message ( SHOW_VALUE(__GNUC_MINOR__) )
|
||||||
|
#pragma message ( SHOW_VALUE(__GNUC_PATCHLEVEL__) )
|
||||||
|
|
||||||
#pragma message ( "\nMSC: \n_MSC_VER=" STRING(_MSC_VER) ", \n_MSC_FULL_VER=" STRING(_MSC_FULL_VER ) )
|
#pragma message ( "\n ---Clang compiler: " )
|
||||||
|
#pragma message ( SHOW_VALUE(__clang__) )
|
||||||
|
#pragma message ( SHOW_VALUE(__GLIBCPP__) )
|
||||||
|
#pragma message ( SHOW_VALUE(__GLIBCXX__) )
|
||||||
|
|
||||||
|
#pragma message ( "\n -----> STD: " )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_CODECVT_NOT_SUPPORTED) )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_THREAD_NOT_SUPPORTED) )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED) )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_TO_STRING_NOT_SUPPORTED) )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_TO_WSTRING_NOT_SUPPORTED) )
|
||||||
|
#pragma message ( SHOW_VALUE(USE_github_com_meganz_mingw_std_threads) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_THREAD_NOT_SUPPORTED) )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_put_time_NOT_SUPPORTED) )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_MAKE_UNIQUE_NOT_SUPPORTED) )
|
||||||
|
|
||||||
|
#pragma message ( SHOW_VALUE(STD_FILESYSTEM_NOT_SUPPORTED) )
|
||||||
|
#pragma message ( SHOW_VALUE(BOOST_FILESYSTEM_AVAILABLE) )
|
||||||
|
#pragma message ( SHOW_VALUE(BOOST_FILESYSTEM_FORCE) )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_FILESYSTEM_FORCE) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_FILESYSTEM_FORCE) )
|
||||||
|
#pragma message ( SHOW_VALUE(CXX_NO_INLINE_NAMESPACE) )
|
||||||
|
//#pragma message ( SHOW_VALUE(__has_include) )
|
||||||
|
#pragma message ( SHOW_VALUE(__cpp_lib_experimental_filesystem) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_USING_NANA_FILESYSTEM) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_USING_STD_FILESYSTEM) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_USING_BOOST_FILESYSTEM) )
|
||||||
|
|
||||||
|
#pragma message ( "\n#include <nana/filesystem/filesystem.hpp> " )
|
||||||
|
#include <nana/filesystem/filesystem.hpp>
|
||||||
|
|
||||||
|
#pragma message ( SHOW_VALUE(STD_MAKE_UNIQUE_NOT_SUPPORTED) )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_FILESYSTEM_NOT_SUPPORTED) )
|
||||||
|
#pragma message ( SHOW_VALUE(BOOST_FILESYSTEM_AVAILABLE) )
|
||||||
|
#pragma message ( SHOW_VALUE(BOOST_FILESYSTEM_FORCE) )
|
||||||
|
#pragma message ( SHOW_VALUE(STD_FILESYSTEM_FORCE) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_FILESYSTEM_FORCE) )
|
||||||
|
#pragma message ( SHOW_VALUE(CXX_NO_INLINE_NAMESPACE) )
|
||||||
|
//#pragma message ( SHOW_VALUE(__has_include) )
|
||||||
|
#pragma message ( SHOW_VALUE(__cpp_lib_experimental_filesystem) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_USING_NANA_FILESYSTEM) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_USING_STD_FILESYSTEM) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_USING_BOOST_FILESYSTEM) )
|
||||||
|
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_UNICODE) )
|
||||||
|
#pragma message ( SHOW_VALUE(_UNICODE) )
|
||||||
|
#pragma message ( SHOW_VALUE(UNICODE) )
|
||||||
|
|
||||||
|
#pragma message ( "\n -----> Libraries: " )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_ENABLE_AUDIO) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_ENABLE_PNG) )
|
||||||
|
#pragma message ( SHOW_VALUE(USE_LIBPNG_FROM_OS) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_LIBPNG) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_ENABLE_JPEG) )
|
||||||
|
#pragma message ( SHOW_VALUE(USE_LIBJPEG_FROM_OS) )
|
||||||
|
#pragma message ( SHOW_VALUE(NANA_LIBJPEG) )
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma message ( "\n =" STRING() ", \n =" STRING()" , \n =" STRING() )
|
||||||
|
|
||||||
#if defined(STOP_VERBOSE_PREPROCESSOR)
|
#if defined(STOP_VERBOSE_PREPROCESSOR)
|
||||||
#error ("\nCompilation stopped to avoid annoying messages")
|
#error ("\nCompilation stopped to avoid annoying messages")
|
||||||
@@ -52,5 +134,4 @@
|
|||||||
#endif // VERBOSE_PREPROCESSOR
|
#endif // VERBOSE_PREPROCESSOR
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //NANA_VERBOSE_PREPROCESSOR_H
|
#endif //NANA_VERBOSE_PREPROCESSOR_H
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
#include <nana/audio/player.hpp>
|
#include <nana/audio/player.hpp>
|
||||||
|
|
||||||
|
|
||||||
#ifdef NANA_ENABLE_AUDIO
|
#ifdef NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
#include <nana/audio/detail/audio_stream.hpp>
|
#include <nana/audio/detail/audio_stream.hpp>
|
||||||
|
|||||||
@@ -528,124 +528,25 @@ namespace nana
|
|||||||
return (px_color().value != other.px_color().value);
|
return (px_color().value != other.px_color().value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
color operator+(const color& x, const color& y)
|
||||||
|
{
|
||||||
|
double a = x.a_ + y.a_;
|
||||||
|
auto r = static_cast<unsigned>(x.r_ + y.r_);
|
||||||
|
auto g = static_cast<unsigned>(x.g_ + y.g_);
|
||||||
|
auto b = static_cast<unsigned>(x.b_ + y.b_);
|
||||||
|
|
||||||
|
return color{
|
||||||
|
r > 255 ? 255 : r,
|
||||||
|
g > 255 ? 255 : g,
|
||||||
|
b > 255 ? 255 : b,
|
||||||
|
a > 1.0 ? 1.0 : a };
|
||||||
|
}
|
||||||
//end class color
|
//end class color
|
||||||
//struct point
|
|
||||||
point::point():x(0), y(0){}
|
|
||||||
point::point(int x, int y):x(x), y(y){}
|
|
||||||
point::point(const rectangle& r)
|
|
||||||
: x(r.x), y(r.y)
|
|
||||||
{}
|
|
||||||
|
|
||||||
point& point::operator=(const rectangle& r)
|
|
||||||
{
|
|
||||||
x = r.x;
|
|
||||||
y = r.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool point::operator==(const point& rhs) const
|
|
||||||
{
|
|
||||||
return ((x == rhs.x) && (y == rhs.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool point::operator!=(const point& rhs) const
|
|
||||||
{
|
|
||||||
return ((x != rhs.x) || (y != rhs.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool point::operator<(const point& rhs) const
|
|
||||||
{
|
|
||||||
return ((y < rhs.y) || (y == rhs.y && x < rhs.x));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool point::operator<=(const point& rhs) const
|
|
||||||
{
|
|
||||||
return ((y < rhs.y) || (y == rhs.y && x <= rhs.x));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool point::operator>(const point& rhs) const
|
|
||||||
{
|
|
||||||
return ((y > rhs.y) || (y == rhs.y && x > rhs.x));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool point::operator>=(const point& rhs) const
|
|
||||||
{
|
|
||||||
return ((y > rhs.y) || (y == rhs.y && x >= rhs.x));
|
|
||||||
}
|
|
||||||
|
|
||||||
point point::operator-(const point& rhs) const
|
|
||||||
{
|
|
||||||
return{x - rhs.x, y - rhs.y};
|
|
||||||
}
|
|
||||||
|
|
||||||
point point::operator+(const point& rhs) const
|
|
||||||
{
|
|
||||||
return{ x + rhs.x, y + rhs.y };
|
|
||||||
}
|
|
||||||
|
|
||||||
point& point::operator-=(const point& rhs)
|
|
||||||
{
|
|
||||||
x -= rhs.x;
|
|
||||||
y -= rhs.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
point& point::operator+=(const point& rhs)
|
|
||||||
{
|
|
||||||
x += rhs.x;
|
|
||||||
y += rhs.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
//end struct point
|
|
||||||
|
|
||||||
//struct upoint
|
|
||||||
upoint::upoint():x(0), y(0){}
|
|
||||||
upoint::upoint(unsigned x, unsigned y):x(x), y(y){}
|
|
||||||
|
|
||||||
bool upoint::operator==(const upoint& rhs) const
|
|
||||||
{
|
|
||||||
return ((x == rhs.x) && (y == rhs.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool upoint::operator!=(const upoint& rhs) const
|
|
||||||
{
|
|
||||||
return ((x != rhs.x) || (y != rhs.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool upoint::operator<(const upoint& rhs) const
|
|
||||||
{
|
|
||||||
return ((y < rhs.y) || (y == rhs.y && x < rhs.x));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool upoint::operator<=(const upoint& rhs) const
|
|
||||||
{
|
|
||||||
return ((y < rhs.y) || (y == rhs.y && x <= rhs.x));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool upoint::operator>(const upoint& rhs) const
|
|
||||||
{
|
|
||||||
return ((y > rhs.y) || (y == rhs.y && x > rhs.x));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool upoint::operator>=(const upoint& rhs) const
|
|
||||||
{
|
|
||||||
return ((y > rhs.y) || (y == rhs.y && x >= rhs.x));
|
|
||||||
}
|
|
||||||
//end struct upoint
|
|
||||||
|
|
||||||
//struct size
|
//struct size
|
||||||
size::size():width(0), height(0){}
|
size::size():width(0), height(0){}
|
||||||
size::size(value_type width, value_type height) : width(width), height(height){}
|
size::size(value_type width, value_type height) : width(width), height(height){}
|
||||||
size::size(const rectangle& r)
|
|
||||||
: width(r.width), height(r.height)
|
|
||||||
{}
|
|
||||||
|
|
||||||
size& size::operator=(const rectangle& r)
|
|
||||||
{
|
|
||||||
width = r.width;
|
|
||||||
height = r.height;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool size::empty() const
|
bool size::empty() const
|
||||||
{
|
{
|
||||||
@@ -657,6 +558,12 @@ namespace nana
|
|||||||
return (0 <= pos.x && pos.x < static_cast<int>(width) && 0 <= pos.y && pos.y < static_cast<int>(height));
|
return (0 <= pos.x && pos.x < static_cast<int>(width) && 0 <= pos.y && pos.y < static_cast<int>(height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size& size::shift()
|
||||||
|
{
|
||||||
|
std::swap(width, height);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
bool size::operator==(const size& rhs) const
|
bool size::operator==(const size& rhs) const
|
||||||
{
|
{
|
||||||
return (width == rhs.width) && (height == rhs.height);
|
return (width == rhs.width) && (height == rhs.height);
|
||||||
@@ -700,33 +607,38 @@ namespace nana
|
|||||||
return (width != rhs.width) || (height != rhs.height) || (x != rhs.x) || (y != rhs.y);
|
return (width != rhs.width) || (height != rhs.height) || (x != rhs.x) || (y != rhs.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
rectangle & rectangle::operator=(const point& pos)
|
point rectangle::position() const noexcept
|
||||||
{
|
{
|
||||||
x = pos.x;
|
return{ x, y };
|
||||||
y = pos.y;
|
}
|
||||||
|
|
||||||
|
rectangle& rectangle::position(const point& p) noexcept
|
||||||
|
{
|
||||||
|
x = p.x;
|
||||||
|
y = p.y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
rectangle & rectangle::operator=(const size & sz)
|
size rectangle::dimension() const noexcept
|
||||||
|
{
|
||||||
|
return{width, height};
|
||||||
|
}
|
||||||
|
|
||||||
|
rectangle& rectangle::dimension(const size& sz) noexcept
|
||||||
{
|
{
|
||||||
width = sz.width;
|
width = sz.width;
|
||||||
height = sz.height;
|
height = sz.height;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
rectangle& rectangle::set_pos(const point& pos)
|
/*
|
||||||
{
|
|
||||||
x = pos.x;
|
|
||||||
y = pos.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
rectangle& rectangle::set_size(const size& sz)
|
rectangle& rectangle::set_size(const size& sz)
|
||||||
{
|
{
|
||||||
width = sz.width;
|
width = sz.width;
|
||||||
height = sz.height;
|
height = sz.height;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
rectangle& rectangle::pare_off(int pixels)
|
rectangle& rectangle::pare_off(int pixels)
|
||||||
{
|
{
|
||||||
@@ -763,6 +675,13 @@ namespace nana
|
|||||||
{
|
{
|
||||||
return (0 == width) || (0 == height);
|
return (0 == width) || (0 == height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rectangle& rectangle::shift()
|
||||||
|
{
|
||||||
|
std::swap(x, y);
|
||||||
|
std::swap(width, height);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
//end struct rectangle
|
//end struct rectangle
|
||||||
|
|
||||||
//class rectangle_rotator
|
//class rectangle_rotator
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/**
|
||||||
* A Character Encoding Set Implementation
|
* A Character Encoding Set Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/charset.cpp
|
* @file nana/charset.cpp
|
||||||
* @brief: A conversion between unicode characters and multi bytes characters
|
* @brief A conversion between unicode characters and multi bytes characters
|
||||||
* @contributions:
|
* @contributions
|
||||||
* UTF16 4-byte decoding issue by Renke Yan.
|
* UTF16 4-byte decoding issue by Renke Yan.
|
||||||
* Pr0curo(pr#98)
|
* Pr0curo(pr#98)
|
||||||
*/
|
*/
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
#include <cstring> //Added by Pr0curo(pr#98)
|
#include <cstring> //Added by Pr0curo(pr#98)
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
//GCC 4.7.0 does not implement the <codecvt> and codecvt_utfx classes
|
//GCC 4.7.0 does not implement the <codecvt> and codecvt_utfx classes
|
||||||
#ifndef STD_CODECVT_NOT_SUPPORTED
|
#ifndef STD_CODECVT_NOT_SUPPORTED
|
||||||
@@ -34,6 +35,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
namespace utf
|
namespace utf
|
||||||
{
|
{
|
||||||
|
/// return a pointer to the code unit of the character at pos
|
||||||
const char* char_ptr(const char* text, unsigned pos)
|
const char* char_ptr(const char* text, unsigned pos)
|
||||||
{
|
{
|
||||||
auto ustr = reinterpret_cast<const unsigned char*>(text);
|
auto ustr = reinterpret_cast<const unsigned char*>(text);
|
||||||
@@ -48,10 +50,10 @@ namespace nana
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uch < 0xC0)
|
if (uch < 0xC0) // use police ?
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if ((uch < 0xE0) && (ustr + 1 < end))
|
if ((uch < 0xE0) && (ustr + 1 < end)) //? *(ustr + 1) < 0xE0
|
||||||
ustr += 2;
|
ustr += 2;
|
||||||
else if (uch < 0xF0 && (ustr + 2 <= end))
|
else if (uch < 0xF0 && (ustr + 2 <= end))
|
||||||
ustr += 3;
|
ustr += 3;
|
||||||
@@ -64,6 +66,7 @@ namespace nana
|
|||||||
return reinterpret_cast<const char*>(ustr);
|
return reinterpret_cast<const char*>(ustr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// return a pointer to the code unit of the character at pos - reuse ^ ?
|
||||||
const char* char_ptr(const std::string& text_utf8, unsigned pos)
|
const char* char_ptr(const std::string& text_utf8, unsigned pos)
|
||||||
{
|
{
|
||||||
auto ustr = reinterpret_cast<const unsigned char*>(text_utf8.c_str());
|
auto ustr = reinterpret_cast<const unsigned char*>(text_utf8.c_str());
|
||||||
@@ -94,6 +97,7 @@ namespace nana
|
|||||||
return reinterpret_cast<const char*>(ustr);
|
return reinterpret_cast<const char*>(ustr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// return a code point (max 16 bits?) and the len in code units of the character at pos
|
||||||
wchar_t char_at(const char* text_utf8, unsigned pos, unsigned * len)
|
wchar_t char_at(const char* text_utf8, unsigned pos, unsigned * len)
|
||||||
{
|
{
|
||||||
if (!text_utf8)
|
if (!text_utf8)
|
||||||
@@ -112,10 +116,10 @@ namespace nana
|
|||||||
if (len)
|
if (len)
|
||||||
*len = 1;
|
*len = 1;
|
||||||
|
|
||||||
return *text_utf8;
|
return *text_utf8; // uch ?
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uch < 0xC0)
|
if (uch < 0xC0) // use police or ??
|
||||||
{
|
{
|
||||||
if (len)
|
if (len)
|
||||||
*len = 0;
|
*len = 0;
|
||||||
@@ -151,6 +155,7 @@ namespace nana
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// return a code point (max 16 bits?) and the len in code units of the character at pos
|
||||||
wchar_t char_at(const ::std::string& text_utf8, unsigned pos, unsigned * len)
|
wchar_t char_at(const ::std::string& text_utf8, unsigned pos, unsigned * len)
|
||||||
{
|
{
|
||||||
const char* ptr;
|
const char* ptr;
|
||||||
@@ -211,21 +216,22 @@ namespace nana
|
|||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
/// candidate to be more general??
|
||||||
class locale_initializer
|
class locale_initializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void init()
|
static void init()
|
||||||
{
|
{
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
if(false == initialized)
|
if (initialized) return;
|
||||||
{
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
//Only set the C library locale
|
//Only set the C library locale
|
||||||
std::setlocale(LC_CTYPE, "");
|
std::setlocale(LC_CTYPE, "");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// convert wchar C string from ? ANSI code page CP_ACP (windows) or LC_CTYPE c locale (-nix) into utf8 std::string
|
||||||
bool wc2mb(std::string& mbstr, const wchar_t * s)
|
bool wc2mb(std::string& mbstr, const wchar_t * s)
|
||||||
{
|
{
|
||||||
if(nullptr == s || *s == 0)
|
if(nullptr == s || *s == 0)
|
||||||
@@ -259,6 +265,7 @@ namespace nana
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// convert a char C-string from The system default Windows ANSI code page CP_ACP or from LC_CTYPE c locale (-nix) into utf16 std::wstring
|
||||||
bool mb2wc(std::wstring& wcstr, const char* s)
|
bool mb2wc(std::wstring& wcstr, const char* s)
|
||||||
{
|
{
|
||||||
if(nullptr == s || *s == 0)
|
if(nullptr == s || *s == 0)
|
||||||
@@ -291,6 +298,7 @@ namespace nana
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// convert a char C string from The system default Windows ANSI code page CP_ACP or LC_CTYPE c locale (-nix) into utf16 std::string
|
||||||
bool mb2wc(std::string& wcstr, const char* s)
|
bool mb2wc(std::string& wcstr, const char* s)
|
||||||
{
|
{
|
||||||
if(nullptr == s || *s == 0)
|
if(nullptr == s || *s == 0)
|
||||||
@@ -304,6 +312,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
wcstr.resize((chars - 1) * sizeof(wchar_t));
|
wcstr.resize((chars - 1) * sizeof(wchar_t));
|
||||||
::MultiByteToWideChar(CP_ACP, 0, s, -1, reinterpret_cast<wchar_t*>(&wcstr[0]), chars - 1);
|
::MultiByteToWideChar(CP_ACP, 0, s, -1, reinterpret_cast<wchar_t*>(&wcstr[0]), chars - 1);
|
||||||
|
// ^ the trick !
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
locale_initializer::init();
|
locale_initializer::init();
|
||||||
@@ -338,17 +347,98 @@ namespace nana
|
|||||||
virtual std::wstring&& wstr_move() = 0;
|
virtual std::wstring&& wstr_move() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// playing with the idea - we need a mechanisme to set a user selected police - Testing an abtract interphase
|
||||||
|
struct encoding_error_police
|
||||||
|
{
|
||||||
|
virtual unsigned long next_code_point(const unsigned char*& current_code_unit, const unsigned char* end) = 0;
|
||||||
|
virtual ~encoding_error_police() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// the current nana default: it is safe - you may want to keep it ! use the other at your risk: mainly for debugging
|
||||||
|
struct utf8_error_police : public encoding_error_police
|
||||||
|
{
|
||||||
|
unsigned long next_code_point(const unsigned char*& current_code_unit, const unsigned char* end) override
|
||||||
|
{
|
||||||
|
current_code_unit = end;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
struct utf8_error_police_def_char : public encoding_error_police
|
||||||
|
{
|
||||||
|
static unsigned long def_error_mark ;
|
||||||
|
|
||||||
|
unsigned long error_mark{ def_error_mark };
|
||||||
|
utf8_error_police_def_char() = default;
|
||||||
|
utf8_error_police_def_char( unsigned long mark): error_mark{mark}{}
|
||||||
|
unsigned long next_code_point(const unsigned char*& current_code_unit, const unsigned char* end) override
|
||||||
|
{
|
||||||
|
if(current_code_unit < end)
|
||||||
|
++current_code_unit;
|
||||||
|
return error_mark;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned long utf8_error_police_def_char::def_error_mark{ '*' };
|
||||||
|
|
||||||
|
///
|
||||||
|
struct utf8_error_police_throw : public encoding_error_police
|
||||||
|
{
|
||||||
|
unsigned long next_code_point(const unsigned char*& current_code_unit, const unsigned char* end) override
|
||||||
|
{
|
||||||
|
//utf8_Error::use_throw = true;
|
||||||
|
utf8_Error(std::string("The text is not encoded in UTF8: ") +
|
||||||
|
reinterpret_cast<const char*>( current_code_unit) ).emit();;
|
||||||
|
current_code_unit = end;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct utf8_error_police_latin : public encoding_error_police
|
||||||
|
{
|
||||||
|
unsigned long next_code_point(const unsigned char*& current_code_unit, const unsigned char* /*end*/) override
|
||||||
|
{
|
||||||
|
return *(current_code_unit++) ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// buggie?
|
||||||
|
struct utf8_error_police_system : public encoding_error_police
|
||||||
|
{
|
||||||
|
unsigned long next_code_point(const unsigned char*& current_code_unit, const unsigned char* /*end*/) override
|
||||||
|
{
|
||||||
|
std::wstring wc;
|
||||||
|
mb2wc(wc, reinterpret_cast<const char*>(current_code_unit));
|
||||||
|
current_code_unit++;
|
||||||
|
|
||||||
|
return wc[0]; // use utf16char but what endian?
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// auto def_encoding_error_police = std::make_unique<utf8_error_police>(); // the nana default
|
||||||
|
// auto def_encoding_error_police = std::make_unique<utf8_error_police_latin>();
|
||||||
|
// auto def_encoding_error_police = std::make_unique<utf8_error_police_throw>();
|
||||||
|
// auto def_encoding_error_police = std::make_unique<utf8_error_police_def_char>('X');
|
||||||
|
auto def_encoding_error_police = std::make_unique<utf8_error_police_system>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef STD_CODECVT_NOT_SUPPORTED
|
#ifndef STD_CODECVT_NOT_SUPPORTED
|
||||||
class charset_string
|
class charset_string
|
||||||
: public charset_encoding_interface
|
: public charset_encoding_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
charset_string(const std::string& s)
|
charset_string(const std::string& s)
|
||||||
: data_(s), is_unicode_(false)
|
: data_(s)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
charset_string(std::string&& s)
|
charset_string(std::string&& s)
|
||||||
: data_(std::move(s)), is_unicode_(false)
|
: data_(std::move(s))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
charset_string(const std::string& s, unicode encoding)
|
charset_string(const std::string& s, unicode encoding)
|
||||||
@@ -501,9 +591,9 @@ namespace nana
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::string data_;
|
std::string data_;
|
||||||
std::wstring wdata_for_move_;
|
std::wstring wdata_for_move_{};
|
||||||
bool is_unicode_;
|
bool is_unicode_{ false };
|
||||||
unicode utf_x_;
|
unicode utf_x_{ unicode::utf8 };
|
||||||
};
|
};
|
||||||
|
|
||||||
class charset_wstring
|
class charset_wstring
|
||||||
@@ -578,37 +668,42 @@ namespace nana
|
|||||||
std::string data_for_move_;
|
std::string data_for_move_;
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
|
/// return the first code point and move the pointer to next character, springing to the end by errors
|
||||||
unsigned long utf8char(const unsigned char*& p, const unsigned char* end)
|
unsigned long utf8char(const unsigned char*& p, const unsigned char* end)
|
||||||
{
|
{
|
||||||
if(p != end)
|
if(p != end)
|
||||||
{
|
{
|
||||||
if(*p < 0x80)
|
if(*p < 0x80) // ASCII char 0-127 or 0-0x80
|
||||||
{
|
{
|
||||||
return *(p++);
|
return *(p++);
|
||||||
}
|
}
|
||||||
unsigned ch = *p;
|
unsigned ch = *p;
|
||||||
unsigned long code;
|
unsigned long code;
|
||||||
if(ch < 0xC0)
|
if(ch < 0xC0) // error? - move to end. Posible ANSI or ISO code-page
|
||||||
{
|
{
|
||||||
p = end;
|
//return *(p++); // temp: assume equal
|
||||||
return 0;
|
//p = end;
|
||||||
|
//return 0;
|
||||||
|
return def_encoding_error_police->next_code_point(p, end);
|
||||||
}
|
}
|
||||||
else if(ch < 0xE0 && (p + 1 <= end))
|
else if(ch < 0xE0 && (p + 1 <= end)) // two byte chararcter
|
||||||
{
|
{
|
||||||
code = ((ch & 0x1F) << 6) | (p[1] & 0x3F);
|
code = ((ch & 0x1F) << 6) | (p[1] & 0x3F);
|
||||||
p += 2;
|
p += 2;
|
||||||
}
|
}
|
||||||
else if(ch < 0xF0 && (p + 2 <= end))
|
else if(ch < 0xF0 && (p + 2 <= end)) // 3 byte character
|
||||||
{
|
{
|
||||||
code = ((((ch & 0xF) << 6) | (p[1] & 0x3F)) << 6) | (p[2] & 0x3F);
|
code = ((((ch & 0xF) << 6) | (p[1] & 0x3F)) << 6) | (p[2] & 0x3F);
|
||||||
p += 3;
|
p += 3;
|
||||||
}
|
}
|
||||||
else if(ch < 0x1F && (p + 3 <= end))
|
else if(ch < 0x1F && (p + 3 <= end)) // 4 byte character
|
||||||
{
|
{
|
||||||
code = ((((((ch & 0x7) << 6) | (p[1] & 0x3F)) << 6) | (p[2] & 0x3F)) << 6) | (p[3] & 0x3F);
|
code = ((((((ch & 0x7) << 6) | (p[1] & 0x3F)) << 6) | (p[2] & 0x3F)) << 6) | (p[3] & 0x3F);
|
||||||
p += 4;
|
p += 4;
|
||||||
}
|
}
|
||||||
else
|
else // error, go to end
|
||||||
{
|
{
|
||||||
p = end;
|
p = end;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -950,11 +1045,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
charset_string(const std::string& s)
|
charset_string(const std::string& s)
|
||||||
: data_(s), is_unicode_(false)
|
: data_(s)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
charset_string(std::string&& s)
|
charset_string(std::string&& s)
|
||||||
: data_(std::move(s)), is_unicode_(false)
|
: data_(std::move(s))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
charset_string(const std::string& s, unicode encoding)
|
charset_string(const std::string& s, unicode encoding)
|
||||||
@@ -1067,12 +1162,21 @@ namespace nana
|
|||||||
{
|
{
|
||||||
switch(encoding)
|
switch(encoding)
|
||||||
{
|
{
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
case unicode::utf8:
|
||||||
|
return utf16_to_utf8(wcstr);
|
||||||
|
case unicode::utf32:
|
||||||
|
return utf16_to_utf32(wcstr);
|
||||||
|
case unicode::utf16:
|
||||||
|
return wcstr;
|
||||||
|
#else //POSIX
|
||||||
case unicode::utf8:
|
case unicode::utf8:
|
||||||
return utf32_to_utf8(wcstr);
|
return utf32_to_utf8(wcstr);
|
||||||
case unicode::utf16:
|
case unicode::utf16:
|
||||||
return utf32_to_utf16(wcstr);
|
return utf32_to_utf16(wcstr);
|
||||||
case unicode::utf32:
|
case unicode::utf32:
|
||||||
return wcstr;
|
return wcstr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
@@ -1122,9 +1226,9 @@ namespace nana
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::string data_;
|
std::string data_;
|
||||||
std::wstring wdata_for_move_;
|
std::wstring wdata_for_move_{};
|
||||||
bool is_unicode_;
|
bool is_unicode_{ false };
|
||||||
unicode utf_x_;
|
unicode utf_x_{ unicode::utf8 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1195,7 +1299,7 @@ namespace nana
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::wstring data_;
|
std::wstring data_;
|
||||||
std::string data_for_move_;
|
std::string data_for_move_{};
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,22 +17,35 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void localtime(struct tm& tm)
|
std::tm localtime()
|
||||||
{
|
{
|
||||||
#if defined(NANA_WINDOWS) && !defined(NANA_MINGW)
|
#if defined(NANA_WINDOWS) && !defined(NANA_MINGW)
|
||||||
time_t t;
|
time_t t;
|
||||||
::time(&t);
|
::time(&t);
|
||||||
|
std::tm tm;
|
||||||
if(localtime_s(&tm, &t) != 0)
|
if(localtime_s(&tm, &t) != 0)
|
||||||
{
|
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
|
||||||
|
return tm;
|
||||||
#else
|
#else
|
||||||
time_t t = std::time(nullptr);
|
time_t t = std::time(nullptr);
|
||||||
struct tm * tm_addr = std::localtime(&t);
|
struct tm * tm_addr = std::localtime(&t);
|
||||||
assert(tm_addr);
|
assert(tm_addr);
|
||||||
tm = *tm_addr;
|
|
||||||
|
return *tm_addr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::nana::date::value to_dateval(const std::tm& t)
|
||||||
|
{
|
||||||
|
return {static_cast<unsigned>(t.tm_year + 1900), static_cast<unsigned>(t.tm_mon + 1), static_cast<unsigned>(t.tm_mday)};
|
||||||
|
}
|
||||||
|
|
||||||
|
::nana::time::value to_timeval(const std::tm& t)
|
||||||
|
{
|
||||||
|
return {static_cast<unsigned>(t.tm_hour), static_cast<unsigned>(t.tm_min), static_cast<unsigned>(t.tm_sec)};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace anonymous
|
} // namespace anonymous
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
@@ -40,39 +53,29 @@ namespace nana
|
|||||||
//class date
|
//class date
|
||||||
void date::set(const std::tm& t)
|
void date::set(const std::tm& t)
|
||||||
{
|
{
|
||||||
value_.year = t.tm_year + 1900;
|
value_ = to_dateval(t);
|
||||||
value_.month = t.tm_mon + 1;
|
|
||||||
value_.day = t.tm_mday;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
date::date()
|
date::date()
|
||||||
|
: value_(to_dateval(localtime()))
|
||||||
{
|
{
|
||||||
struct tm t;
|
|
||||||
localtime(t);
|
|
||||||
set(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
date::date(const std::tm& t)
|
date::date(const std::tm& t)
|
||||||
|
: value_(to_dateval(t))
|
||||||
{
|
{
|
||||||
set(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
date::date(int year, int month, int day)
|
date::date(int year, int month, int day)
|
||||||
|
: value_({static_cast<unsigned>(year), static_cast<unsigned>(month), static_cast<unsigned>(day)})
|
||||||
{
|
{
|
||||||
if(1601 <= year && year < 30827 && 0 < month && month < 13 && day > 0)
|
if(1601 <= year && year < 30827 && 0 < month && month < 13 && day > 0)
|
||||||
{
|
{
|
||||||
if(day <= static_cast<int>(date::month_days(year, month)))
|
if(day <= static_cast<int>(date::month_days(year, month)))
|
||||||
{
|
|
||||||
value_.year = year;
|
|
||||||
value_.month = month;
|
|
||||||
value_.day = day;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
struct tm t;
|
set(localtime());
|
||||||
localtime(t);
|
|
||||||
set(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
date date::operator - (int off) const
|
date date::operator - (int off) const
|
||||||
@@ -258,39 +261,27 @@ namespace nana
|
|||||||
//class time
|
//class time
|
||||||
void time::set(const std::tm& t)
|
void time::set(const std::tm& t)
|
||||||
{
|
{
|
||||||
value_.hour = t.tm_hour;
|
value_ = to_timeval(t);
|
||||||
value_.minute = t.tm_min;
|
|
||||||
value_.second = t.tm_sec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
time::time()
|
time::time()
|
||||||
|
: value_(to_timeval(localtime()))
|
||||||
{
|
{
|
||||||
struct tm t;
|
|
||||||
localtime(t);
|
|
||||||
set(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
time::time(const std::tm& t)
|
time::time(const std::tm& t)
|
||||||
|
: value_(to_timeval(t))
|
||||||
{
|
{
|
||||||
value_.hour = t.tm_hour;
|
|
||||||
value_.minute = t.tm_min;
|
|
||||||
value_.second = t.tm_sec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
time::time(unsigned hour, unsigned minute, unsigned second)
|
time::time(unsigned hour, unsigned minute, unsigned second)
|
||||||
|
: value_({hour, minute, second})
|
||||||
{
|
{
|
||||||
if(hour < 24 && minute < 60 && second < 62)
|
if(hour < 24 && minute < 60 && second < 62)
|
||||||
{
|
|
||||||
value_.hour = hour;
|
|
||||||
value_.minute = minute;
|
|
||||||
value_.second = second;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
struct tm t;
|
|
||||||
localtime(t);
|
|
||||||
set(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
set(localtime());
|
||||||
|
}
|
||||||
const time::value& time::read() const
|
const time::value& time::read() const
|
||||||
{
|
{
|
||||||
return value_;
|
return value_;
|
||||||
|
|||||||
@@ -436,9 +436,54 @@ namespace std
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//#ifdef STD_put_time_NOT_SUPPORTED
|
||||||
|
#include <ctime>
|
||||||
|
#include <cwchar>
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
//Workaround for no implemenation of std::put_time in gcc < 5.
|
||||||
|
/* std unspecified return type */
|
||||||
|
//template< class CharT, class RTSTR >// let fail for CharT != char / wchar_t
|
||||||
|
//RTSTR put_time(const std::tm* tmb, const CharT* fmt);
|
||||||
|
|
||||||
|
//template< >
|
||||||
|
std::string put_time/*<char, std::string>*/(const std::tm* tmb, const char* fmt)
|
||||||
|
{
|
||||||
|
std::size_t sz = 200;
|
||||||
|
std::string str(sz, '\0');
|
||||||
|
sz = std::strftime(&str[0], str.size() - 1, fmt, tmb);
|
||||||
|
str.resize(sz);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
//Defined in header <ctime>
|
||||||
|
// std::size_t strftime(char* str, std::size_t count, const char* format, const std::tm* time);
|
||||||
|
//template<>
|
||||||
|
//std::wstring put_time<wchar_t, std::wstring>(const std::tm* tmb, const wchar_t* fmt)
|
||||||
|
//{
|
||||||
|
// unsigned sz = 200;
|
||||||
|
// std::wstring str(sz, L'\0');
|
||||||
|
// sz = std::wcsftime(&str[0], str.size() - 1, fmt, tmb);
|
||||||
|
// str.resize(sz);
|
||||||
|
// return str;
|
||||||
|
//}
|
||||||
|
// http://en.cppreference.com/w/cpp/chrono/c/wcsftime
|
||||||
|
// Defined in header <cwchar>
|
||||||
|
// std::size_t wcsftime(wchar_t* str, std::size_t count, const wchar_t* format, const std::tm* time);
|
||||||
|
// Converts the date and time information from a given calendar time time to a null - terminated
|
||||||
|
// wide character string str according to format string format.Up to count bytes are written.
|
||||||
|
// Parameters
|
||||||
|
// str - pointer to the first element of the wchar_t array for output
|
||||||
|
// count - maximum number of wide characters to write
|
||||||
|
// format - pointer to a null - terminated wide character string specifying the format of conversion.
|
||||||
|
|
||||||
|
}
|
||||||
|
//#endif // STD_put_time_NOT_SUPPORTED
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
bool is_utf8(const char* str, unsigned len)
|
bool is_utf8(const char* str, std::size_t len)
|
||||||
{
|
{
|
||||||
auto ustr = reinterpret_cast<const unsigned char*>(str);
|
auto ustr = reinterpret_cast<const unsigned char*>(str);
|
||||||
auto end = ustr + len;
|
auto end = ustr + len;
|
||||||
@@ -455,38 +500,95 @@ namespace nana
|
|||||||
if (uv < 0xC0)
|
if (uv < 0xC0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((uv < 0xE0) && (ustr + 1 < end))
|
if ((uv < 0xE0) && (end - ustr > 1))
|
||||||
ustr += 2;
|
ustr += 2;
|
||||||
else if (uv < 0xF0 && (ustr + 2 <= end))
|
else if ((uv < 0xF0) && (end - ustr > 2))
|
||||||
ustr += 3;
|
ustr += 3;
|
||||||
else if (uv < 0x1F && (ustr + 3 <= end))
|
else if ((uv < 0x1F) && (end - ustr > 3))
|
||||||
ustr += 4;
|
ustr += 4;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//class utf8_Error
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# if (_MSC_VER < 1900)
|
||||||
|
//A workaround for lack support of C++11 inheriting constructors for VC2013
|
||||||
|
utf8_Error::utf8_Error(const std::string& msg)
|
||||||
|
: std::runtime_error(msg)
|
||||||
|
{}
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void utf8_Error::emit()
|
||||||
|
{
|
||||||
|
if (use_throw)
|
||||||
|
throw utf8_Error(*this);
|
||||||
|
std::cerr << what();
|
||||||
|
}
|
||||||
|
|
||||||
|
//bool utf8_Error::use_throw{true};
|
||||||
|
bool utf8_Error::use_throw{ false };
|
||||||
|
//end class utf8_Error
|
||||||
|
|
||||||
void throw_not_utf8(const std::string& text)
|
void throw_not_utf8(const std::string& text)
|
||||||
{
|
{
|
||||||
if (!is_utf8(text.c_str(), text.length()))
|
if (!is_utf8(text.c_str(), text.length()))
|
||||||
throw std::invalid_argument("The text is not encoded in UTF8");
|
return utf8_Error(std::string("\nThe text is not encoded in UTF8: ") + text).emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void throw_not_utf8(const char* text, unsigned len)
|
void throw_not_utf8(const char* text, std::size_t len)
|
||||||
{
|
{
|
||||||
if (!is_utf8(text, len))
|
if (!is_utf8(text, len))
|
||||||
throw std::invalid_argument("The text is not encoded in UTF8");
|
return utf8_Error(std::string("\nThe text is not encoded in UTF8: ") + std::string(text, len) ).emit();
|
||||||
|
|
||||||
|
//throw std::invalid_argument("The text is not encoded in UTF8");
|
||||||
}
|
}
|
||||||
|
|
||||||
void throw_not_utf8(const char* text)
|
void throw_not_utf8(const char* text)
|
||||||
{
|
{
|
||||||
if (!is_utf8(text, std::strlen(text)))
|
if (!is_utf8(text, std::strlen(text)))
|
||||||
throw std::invalid_argument("The text is not encoded in UTF8");
|
return utf8_Error(std::string("\nThe text is not encoded in UTF8: ") + text).emit();
|
||||||
|
|
||||||
|
//throw std::invalid_argument("The text is not encoded in UTF8");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string recode_to_utf8(std::string no_utf8)
|
||||||
|
{
|
||||||
|
return nana::charset(std::move(no_utf8)).to_bytes(nana::unicode::utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// this text needed change, it needed review ??
|
||||||
|
bool review_utf8(const std::string& text)
|
||||||
|
{
|
||||||
|
if (!is_utf8(text.c_str(), text.length()))
|
||||||
|
{
|
||||||
|
utf8_Error(std::string("\nThe const text is not encoded in UTF8: ") + text).emit();
|
||||||
|
return true; /// it needed change, it needed review !!
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// this text needed change, it needed review ??
|
||||||
|
bool review_utf8(std::string& text)
|
||||||
|
{
|
||||||
|
if (!is_utf8(text.c_str(), text.length()))
|
||||||
|
{
|
||||||
|
utf8_Error(std::string("\nThe text is not encoded in UTF8: ") + text).emit();
|
||||||
|
text=recode_to_utf8(text);
|
||||||
|
return true; /// it needed change, it needed review !!
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const std::string& to_utf8(const std::string& str)
|
const std::string& to_utf8(const std::string& str)
|
||||||
{
|
{
|
||||||
return str;
|
return str;
|
||||||
@@ -599,3 +701,6 @@ namespace nana
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(VERBOSE_PREPROCESSOR)
|
||||||
|
# include <nana/verbose_preprocessor.hpp>
|
||||||
|
#endif
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
#include <nana/detail/platform_spec_selector.hpp>
|
#include <nana/detail/platform_spec_selector.hpp>
|
||||||
#if defined(NANA_POSIX) && defined(NANA_X11)
|
#if defined(NANA_POSIX) && defined(NANA_X11)
|
||||||
|
|
||||||
|
#include <nana/push_ignore_diagnostic>
|
||||||
|
|
||||||
#include <X11/Xlocale.h>
|
#include <X11/Xlocale.h>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -432,13 +435,13 @@ namespace detail
|
|||||||
platform_spec::instance().unlock_xlib();
|
platform_spec::instance().unlock_xlib();
|
||||||
}
|
}
|
||||||
|
|
||||||
int X11_error_handler(Display* disp, XErrorEvent* err)
|
int X11_error_handler(Display*, XErrorEvent* err)
|
||||||
{
|
{
|
||||||
platform_spec::instance().error_code = err->error_code;
|
platform_spec::instance().error_code = err->error_code;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int X11_fatal_handler(Display* disp)
|
int X11_fatal_handler(Display*)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1414,4 +1417,6 @@ namespace detail
|
|||||||
}
|
}
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#include <nana/pop_ignore_diagnostic>
|
||||||
#endif //NANA_POSIX && NANA_X11
|
#endif //NANA_POSIX && NANA_X11
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/**
|
||||||
* Platform Specification Implementation
|
* Platform Specification Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
* @file: nana/detail/platform_spec.cpp
|
* @file: nana/detail/platform_spec.cpp
|
||||||
*
|
*
|
||||||
* This file provides basis class and data structrue that required by nana
|
* @brief basis classes and data structures required by nana
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nana/detail/platform_spec_selector.hpp>
|
#include <nana/detail/platform_spec_selector.hpp>
|
||||||
@@ -19,9 +19,172 @@
|
|||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#include <VersionHelpers.h>
|
|
||||||
#endif // _MSVC
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
* *
|
||||||
|
* VersionHelpers.h -- This module defines helper functions to *
|
||||||
|
* promote version check with proper *
|
||||||
|
* comparisons. *
|
||||||
|
* *
|
||||||
|
* Copyright (c) Microsoft Corp. All rights reserved. *
|
||||||
|
* *
|
||||||
|
******************************************************************/
|
||||||
|
|
||||||
|
#include <specstrings.h> // for _In_, etc.
|
||||||
|
|
||||||
|
#if !defined(__midl) && !defined(SORTPP_PASS)
|
||||||
|
|
||||||
|
#if (NTDDI_VERSION >= NTDDI_WINXP)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#define VERSIONHELPERAPI inline bool
|
||||||
|
|
||||||
|
#else // __cplusplus
|
||||||
|
|
||||||
|
#define VERSIONHELPERAPI FORCEINLINE BOOL
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
|
||||||
|
{
|
||||||
|
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0 };
|
||||||
|
DWORDLONG const dwlConditionMask = VerSetConditionMask(
|
||||||
|
VerSetConditionMask(
|
||||||
|
VerSetConditionMask(
|
||||||
|
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
|
||||||
|
VER_MINORVERSION, VER_GREATER_EQUAL),
|
||||||
|
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
||||||
|
|
||||||
|
osvi.dwMajorVersion = wMajorVersion;
|
||||||
|
osvi.dwMinorVersion = wMinorVersion;
|
||||||
|
osvi.wServicePackMajor = wServicePackMajor;
|
||||||
|
|
||||||
|
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindowsXPOrGreater()
|
||||||
|
{
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindowsXPSP1OrGreater()
|
||||||
|
{
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindowsXPSP2OrGreater()
|
||||||
|
{
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindowsXPSP3OrGreater()
|
||||||
|
{
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindowsVistaOrGreater()
|
||||||
|
{
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindowsVistaSP1OrGreater()
|
||||||
|
{
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindowsVistaSP2OrGreater()
|
||||||
|
{
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindows7OrGreater()
|
||||||
|
{
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindows7SP1OrGreater()
|
||||||
|
{
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32_WINNT_WIN8 // (0x0602)
|
||||||
|
#define _WIN32_WINNT_WIN8 (0x0602)
|
||||||
|
#endif // _WIN32_WINNT_WIN8(0x0602)
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindows8OrGreater()
|
||||||
|
{
|
||||||
|
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32_WINNT_WINBLUE // (0x0602)
|
||||||
|
#define _WIN32_WINNT_WINBLUE (0x0602)
|
||||||
|
#endif // _WIN32_WINNT_WINBLUE (0x0602)
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindows8Point1OrGreater()
|
||||||
|
{
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSIONHELPERAPI
|
||||||
|
IsWindowsServer()
|
||||||
|
{
|
||||||
|
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0, 0, VER_NT_WORKSTATION };
|
||||||
|
DWORDLONG const dwlConditionMask = VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL);
|
||||||
|
|
||||||
|
return !VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, dwlConditionMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NTDDI_VERSION
|
||||||
|
|
||||||
|
#endif // defined(__midl)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#if defined(_MSC_VER)
|
||||||
|
////#include <VersionHelpers.h>
|
||||||
|
//bool IsWindowsVistaOrGreater() { return false; }
|
||||||
|
//bool //VERSIONHELPERAPI
|
||||||
|
//IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
|
||||||
|
//{
|
||||||
|
// OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0 };
|
||||||
|
// DWORDLONG const dwlConditionMask = VerSetConditionMask(
|
||||||
|
// VerSetConditionMask(
|
||||||
|
// VerSetConditionMask(
|
||||||
|
// 0, VER_MAJORVERSION, VER_GREATER_EQUAL),
|
||||||
|
// VER_MINORVERSION, VER_GREATER_EQUAL),
|
||||||
|
// VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
||||||
|
//
|
||||||
|
// osvi.dwMajorVersion = wMajorVersion;
|
||||||
|
// osvi.dwMinorVersion = wMinorVersion;
|
||||||
|
// osvi.wServicePackMajor = wServicePackMajor;
|
||||||
|
//
|
||||||
|
// return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//#endif // _MSVC
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Message Dispatcher Implementation
|
* Message Dispatcher Implementation
|
||||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -164,7 +164,7 @@ namespace detail
|
|||||||
private:
|
private:
|
||||||
void _m_msg_driver()
|
void _m_msg_driver()
|
||||||
{
|
{
|
||||||
int fd_X11 = ConnectionNumber(display_);
|
const int fd_X11 = ConnectionNumber(display_);
|
||||||
|
|
||||||
msg_packet_tag msg_pack;
|
msg_packet_tag msg_pack;
|
||||||
XEvent event;
|
XEvent event;
|
||||||
@@ -177,6 +177,18 @@ namespace detail
|
|||||||
if(pending)
|
if(pending)
|
||||||
{
|
{
|
||||||
::XNextEvent(display_, &event);
|
::XNextEvent(display_, &event);
|
||||||
|
|
||||||
|
if(KeyRelease == event.type)
|
||||||
|
{
|
||||||
|
//Check whether the key is pressed, because X will send KeyRelease when pressing and
|
||||||
|
//holding a key if auto repeat is on.
|
||||||
|
char keymap[32];
|
||||||
|
::XQueryKeymap(display_, keymap);
|
||||||
|
|
||||||
|
if(keymap[event.xkey.keycode / 8] & (1 << (event.xkey.keycode % 8)))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(::XFilterEvent(&event, None))
|
if(::XFilterEvent(&event, None))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,11 @@
|
|||||||
* provide some interface for file managment
|
* provide some interface for file managment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nana/filesystem/filesystem.hpp>
|
#include <nana/filesystem/filesystem_ext.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip> //put_time
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
@@ -36,13 +39,134 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace fs = std::experimental::filesystem;
|
||||||
|
|
||||||
namespace nana { namespace experimental {
|
namespace nana
|
||||||
|
{
|
||||||
|
namespace filesystem_ext
|
||||||
|
{
|
||||||
|
|
||||||
|
fs::path path_user()
|
||||||
|
{
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
wchar_t pstr[MAX_PATH];
|
||||||
|
if (SUCCEEDED(SHGetFolderPath(0, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, pstr)))
|
||||||
|
return pstr;
|
||||||
|
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||||
|
const char * pstr = ::getenv("HOME");
|
||||||
|
if (pstr)
|
||||||
|
return pstr;
|
||||||
|
#endif
|
||||||
|
return fs::path();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string pretty_file_size(const fs::path& path)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
auto bytes = fs::file_size(path);
|
||||||
|
const char * ustr[] = { " KB", " MB", " GB", " TB" };
|
||||||
|
std::stringstream ss;
|
||||||
|
if (bytes < 1024)
|
||||||
|
ss << bytes << " Bytes";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double cap = bytes / 1024.0;
|
||||||
|
std::size_t uid = 0;
|
||||||
|
while ((cap >= 1024.0) && (uid < sizeof(ustr) / sizeof(char *)))
|
||||||
|
{
|
||||||
|
cap /= 1024.0;
|
||||||
|
++uid;
|
||||||
|
}
|
||||||
|
ss << cap;
|
||||||
|
auto s = ss.str();
|
||||||
|
auto pos = s.find('.');
|
||||||
|
if (pos != s.npos)
|
||||||
|
{
|
||||||
|
if (pos + 2 < s.size())
|
||||||
|
s.erase(pos + 2);
|
||||||
|
}
|
||||||
|
return s + ustr[uid];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
catch (...) {}
|
||||||
|
return{};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string pretty_file_date(const fs::path& path) // todo: move to .cpp
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
auto ftime = fs::last_write_time(path);
|
||||||
|
|
||||||
|
// crash: VS2015 will not read the time for some files (for example: C:/hiberfil.sys)
|
||||||
|
// and will return file_time_type(-1) without throwing
|
||||||
|
// https://msdn.microsoft.com/en-us/library/dn823784.aspx
|
||||||
|
|
||||||
|
if (ftime == ((fs::file_time_type::min)())) return{};
|
||||||
|
|
||||||
|
//std::time_t cftime = decltype(ftime)::clock::to_time_t(ftime);
|
||||||
|
|
||||||
|
//A workaround for VC2013
|
||||||
|
using time_point = decltype(ftime);
|
||||||
|
|
||||||
|
auto cftime = time_point::clock::to_time_t(ftime);
|
||||||
|
|
||||||
|
std::stringstream tm;
|
||||||
|
tm << std::put_time(std::localtime(&cftime), "%Y-%m-%d, %H:%M:%S");
|
||||||
|
return tm.str();
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
return{};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool modified_file_time(const fs::path& p, struct tm& t)
|
||||||
|
{
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
WIN32_FILE_ATTRIBUTE_DATA attr;
|
||||||
|
if (::GetFileAttributesEx(p.c_str(), GetFileExInfoStandard, &attr))
|
||||||
|
{
|
||||||
|
FILETIME local_file_time;
|
||||||
|
if (::FileTimeToLocalFileTime(&attr.ftLastWriteTime, &local_file_time))
|
||||||
|
{
|
||||||
|
SYSTEMTIME st;
|
||||||
|
::FileTimeToSystemTime(&local_file_time, &st);
|
||||||
|
t.tm_year = st.wYear - 1900;
|
||||||
|
t.tm_mon = st.wMonth - 1;
|
||||||
|
t.tm_mday = st.wDay;
|
||||||
|
t.tm_wday = st.wDayOfWeek - 1;
|
||||||
|
t.tm_yday = nana::date::day_in_year(st.wYear, st.wMonth, st.wDay);
|
||||||
|
|
||||||
|
t.tm_hour = st.wHour;
|
||||||
|
t.tm_min = st.wMinute;
|
||||||
|
t.tm_sec = st.wSecond;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif defined(NANA_POSIX)
|
||||||
|
struct stat attr;
|
||||||
|
if (0 == ::stat(p.c_str(), &attr))
|
||||||
|
{
|
||||||
|
t = *(::localtime(&attr.st_ctime));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if NANA_USING_NANA_FILESYSTEM
|
||||||
|
|
||||||
|
namespace nana_fs = nana::experimental::filesystem;
|
||||||
|
|
||||||
|
namespace nana { namespace experimental { namespace filesystem
|
||||||
|
{
|
||||||
#ifndef CXX_NO_INLINE_NAMESPACE
|
#ifndef CXX_NO_INLINE_NAMESPACE
|
||||||
inline namespace v1 {
|
inline namespace v1 {
|
||||||
#endif
|
#endif
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
//class filesystem_error
|
//class filesystem_error
|
||||||
filesystem_error::filesystem_error(const std::string& msg, std::error_code err)
|
filesystem_error::filesystem_error(const std::string& msg, std::error_code err)
|
||||||
: std::system_error(err, msg)
|
: std::system_error(err, msg)
|
||||||
@@ -59,12 +183,12 @@ namespace nana { namespace experimental {
|
|||||||
path2_(path2)
|
path2_(path2)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const path& filesystem_error::path1() const
|
const path& filesystem_error::path1() const noexcept
|
||||||
{
|
{
|
||||||
return path1_;
|
return path1_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const path&filesystem_error::path2() const
|
const path& filesystem_error::path2() const noexcept
|
||||||
{
|
{
|
||||||
return path2_;
|
return path2_;
|
||||||
}
|
}
|
||||||
@@ -110,7 +234,8 @@ namespace nana { namespace experimental {
|
|||||||
return pathstr_.compare(p.pathstr_);
|
return pathstr_.compare(p.pathstr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool path::empty() const
|
/// true if the path is empty, false otherwise. ??
|
||||||
|
bool path::empty() const noexcept
|
||||||
{
|
{
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
return (::GetFileAttributes(pathstr_.c_str()) == INVALID_FILE_ATTRIBUTES);
|
return (::GetFileAttributes(pathstr_.c_str()) == INVALID_FILE_ATTRIBUTES);
|
||||||
@@ -122,16 +247,19 @@ namespace nana { namespace experimental {
|
|||||||
|
|
||||||
path path::extension() const
|
path path::extension() const
|
||||||
{
|
{
|
||||||
|
// todo: make more globlal
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
auto pos = pathstr_.find_last_of(L"\\/.");
|
auto SLorP=L"\\/.";
|
||||||
|
auto P=L'.';
|
||||||
#else
|
#else
|
||||||
auto pos = pathstr_.find_last_of("\\/.");
|
auto SLorP="\\/.";
|
||||||
|
auto P='.';
|
||||||
#endif
|
#endif
|
||||||
if ((pos == pathstr_.npos) || (pathstr_[pos] != '.'))
|
auto pos = pathstr_.find_last_of(SLorP);
|
||||||
return path();
|
|
||||||
|
|
||||||
|
if ( ( pos == pathstr_.npos)
|
||||||
if (pos + 1 == pathstr_.size())
|
|| ( pathstr_[pos] != P )
|
||||||
|
|| ( pos + 1 == pathstr_.size() ))
|
||||||
return path();
|
return path();
|
||||||
|
|
||||||
return path(pathstr_.substr(pos));
|
return path(pathstr_.substr(pos));
|
||||||
@@ -139,7 +267,7 @@ namespace nana { namespace experimental {
|
|||||||
|
|
||||||
path path::parent_path() const
|
path path::parent_path() const
|
||||||
{
|
{
|
||||||
return{filesystem::parent_path(pathstr_)};
|
return{nana_fs::parent_path(pathstr_)};
|
||||||
}
|
}
|
||||||
|
|
||||||
file_type path::what() const
|
file_type path::what() const
|
||||||
@@ -338,17 +466,17 @@ namespace nana { namespace experimental {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//class directory_entry
|
//class directory_entry
|
||||||
directory_entry::directory_entry(const filesystem::path& p)
|
directory_entry::directory_entry(const nana_fs::path& p)
|
||||||
:path_{ p }
|
:path_{ p }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//modifiers
|
//modifiers
|
||||||
void directory_entry::assign(const filesystem::path& p)
|
void directory_entry::assign(const nana_fs::path& p)
|
||||||
{
|
{
|
||||||
path_ = p;
|
path_ = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void directory_entry::replace_filename(const filesystem::path& p)
|
void directory_entry::replace_filename(const nana_fs::path& p)
|
||||||
{
|
{
|
||||||
path_ = path_.parent_path() / p;
|
path_ = path_.parent_path() / p;
|
||||||
}
|
}
|
||||||
@@ -356,15 +484,15 @@ namespace nana { namespace experimental {
|
|||||||
//observers
|
//observers
|
||||||
file_status directory_entry::status() const
|
file_status directory_entry::status() const
|
||||||
{
|
{
|
||||||
return filesystem::status(path_);
|
return nana_fs::status(path_);
|
||||||
}
|
}
|
||||||
|
|
||||||
directory_entry::operator const filesystem::path&() const
|
//directory_entry::operator const nana_fs::path&() const
|
||||||
{
|
//{
|
||||||
return path_;
|
// return path_;
|
||||||
}
|
//}
|
||||||
|
|
||||||
const path& directory_entry::path() const
|
const nana_fs::path& directory_entry::path() const
|
||||||
{
|
{
|
||||||
return path_;
|
return path_;
|
||||||
}
|
}
|
||||||
@@ -384,7 +512,7 @@ namespace nana { namespace experimental {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
directory_iterator::directory_iterator()
|
directory_iterator::directory_iterator() noexcept
|
||||||
: end_(true),
|
: end_(true),
|
||||||
handle_(nullptr)
|
handle_(nullptr)
|
||||||
{}
|
{}
|
||||||
@@ -418,10 +546,6 @@ namespace nana { namespace experimental {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// enable directory_iterator range-based for statements
|
|
||||||
directory_iterator directory_iterator::begin() { return *this; }
|
|
||||||
directory_iterator directory_iterator::end() { return{}; }
|
|
||||||
|
|
||||||
void directory_iterator::_m_prepare(const path& file_path)
|
void directory_iterator::_m_prepare(const path& file_path)
|
||||||
{
|
{
|
||||||
path_ = file_path.native();
|
path_ = file_path.native();
|
||||||
@@ -751,40 +875,14 @@ namespace nana { namespace experimental {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool modified_file_time(const path& p, struct tm& t)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
|
||||||
if (::GetFileAttributesEx(p.c_str(), GetFileExInfoStandard, &attr))
|
|
||||||
{
|
|
||||||
FILETIME local_file_time;
|
|
||||||
if (::FileTimeToLocalFileTime(&attr.ftLastWriteTime, &local_file_time))
|
|
||||||
{
|
|
||||||
SYSTEMTIME st;
|
|
||||||
::FileTimeToSystemTime(&local_file_time, &st);
|
|
||||||
t.tm_year = st.wYear - 1900;
|
|
||||||
t.tm_mon = st.wMonth - 1;
|
|
||||||
t.tm_mday = st.wDay;
|
|
||||||
t.tm_wday = st.wDayOfWeek - 1;
|
|
||||||
t.tm_yday = nana::date::day_in_year(st.wYear, st.wMonth, st.wDay);
|
|
||||||
|
|
||||||
t.tm_hour = st.wHour;
|
file_time_type last_write_time(const path& p)
|
||||||
t.tm_min = st.wMinute;
|
|
||||||
t.tm_sec = st.wSecond;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(NANA_POSIX)
|
|
||||||
struct stat attr;
|
|
||||||
if (0 == ::stat(p.c_str(), &attr))
|
|
||||||
{
|
{
|
||||||
t = *(::localtime(&attr.st_ctime));
|
struct tm t;
|
||||||
return true;
|
nana::filesystem_ext::modified_file_time(p, t);
|
||||||
|
std::chrono::system_clock::time_point dateTime =std::chrono::system_clock::from_time_t( mktime(&t) );
|
||||||
|
return dateTime;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool create_directory(const path& p)
|
bool create_directory(const path& p)
|
||||||
{
|
{
|
||||||
@@ -806,6 +904,7 @@ namespace nana { namespace experimental {
|
|||||||
|
|
||||||
bool remove(const path& p, std::error_code & ec)
|
bool remove(const path& p, std::error_code & ec)
|
||||||
{
|
{
|
||||||
|
ec.clear();
|
||||||
auto stat = status(p);
|
auto stat = status(p);
|
||||||
if (stat.type() == file_type::directory)
|
if (stat.type() == file_type::directory)
|
||||||
return detail::rm_dir(p);
|
return detail::rm_dir(p);
|
||||||
@@ -813,20 +912,6 @@ namespace nana { namespace experimental {
|
|||||||
return detail::rm_file(p);
|
return detail::rm_file(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
path path_user()
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
wchar_t pstr[MAX_PATH];
|
|
||||||
if (SUCCEEDED(SHGetFolderPath(0, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, pstr)))
|
|
||||||
return pstr;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
const char * pstr = ::getenv("HOME");
|
|
||||||
if (pstr)
|
|
||||||
return pstr;
|
|
||||||
#endif
|
|
||||||
return path();
|
|
||||||
}
|
|
||||||
|
|
||||||
path current_path()
|
path current_path()
|
||||||
{
|
{
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
@@ -879,3 +964,5 @@ namespace nana { namespace experimental {
|
|||||||
}//end namespace filesystem
|
}//end namespace filesystem
|
||||||
} //end namespace experimental
|
} //end namespace experimental
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
#include <nana/gui/basis.hpp>
|
#include <nana/gui/basis.hpp>
|
||||||
|
|
||||||
namespace nana
|
using namespace nana;
|
||||||
{
|
using namespace nana::parameters;
|
||||||
|
|
||||||
//struct appearance
|
//struct appearance
|
||||||
//@brief: Window appearance structure
|
|
||||||
appearance::appearance()
|
appearance::appearance()
|
||||||
:taskbar(true), floating(false), no_activate(false),
|
:taskbar(true), floating(false), no_activate(false),
|
||||||
minimize(true), maximize(true), sizable(true),
|
minimize(true), maximize(true), sizable(true),
|
||||||
@@ -30,5 +30,22 @@ namespace nana
|
|||||||
decoration(has_decorate)
|
decoration(has_decorate)
|
||||||
{}
|
{}
|
||||||
//end struct appearance
|
//end struct appearance
|
||||||
}//end namespace nana
|
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
# include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mouse_wheel::mouse_wheel()
|
||||||
|
: lines(3), characters(3)
|
||||||
|
{
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
// https://msdn.microsoft.com/en-us/library/ms997498.aspx
|
||||||
|
//#define SPI_SETWHEELSCROLLCHARS 0x006D
|
||||||
|
# ifndef SPI_GETWHEELSCROLLCHARS
|
||||||
|
# define SPI_GETWHEELSCROLLCHARS 0x006C
|
||||||
|
# endif
|
||||||
|
::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines, 0);
|
||||||
|
::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &characters, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,128 +17,55 @@ namespace nana
|
|||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
//class caret_descriptor
|
//class caret
|
||||||
caret_descriptor::caret_descriptor(core_window_t* wd, unsigned width, unsigned height)
|
caret::caret(basic_window* owner, const size& size):
|
||||||
:wd_(wd), size_(width, height), visible_state_(visible_state::invisible), out_of_range_(false)
|
owner_(owner),
|
||||||
|
size_(size)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
caret_descriptor::~caret_descriptor()
|
caret::~caret()
|
||||||
{
|
{
|
||||||
if(wd_) native_interface::caret_destroy(wd_->root);
|
if (owner_)
|
||||||
|
native_interface::caret_destroy(owner_->root);
|
||||||
}
|
}
|
||||||
|
|
||||||
void caret_descriptor::set_active(bool active)
|
void caret::activate(bool activity)
|
||||||
{
|
{
|
||||||
if(wd_)
|
if (owner_)
|
||||||
{
|
{
|
||||||
if(active)
|
if (activity)
|
||||||
{
|
{
|
||||||
native_interface::caret_create(wd_->root, size_);
|
native_interface::caret_create(owner_->root, size_);
|
||||||
|
|
||||||
visible_state_ = visible_state::invisible;
|
visibility_ = visible_state::invisible;
|
||||||
this->position(point_.x, point_.y);
|
this->position(position_);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
native_interface::caret_destroy(wd_->root);
|
native_interface::caret_destroy(owner_->root);
|
||||||
|
|
||||||
wd_->root_widget->other.attribute.root->ime_enabled = active;
|
owner_->root_widget->other.attribute.root->ime_enabled = activity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto caret_descriptor::window() const ->core_window_t*
|
basic_window* caret::owner() const noexcept
|
||||||
{
|
{
|
||||||
return wd_;
|
return owner_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void caret_descriptor::position(int x, int y)
|
void caret::update()
|
||||||
{
|
{
|
||||||
point_.x = x;
|
auto pos = position_;
|
||||||
point_.y = y;
|
auto size = size_;
|
||||||
|
|
||||||
update();
|
auto rect = effect_range_;
|
||||||
}
|
if (0 == effect_range_.width || 0 == effect_range_.height)
|
||||||
|
|
||||||
void caret_descriptor::effective_range(nana::rectangle rect)
|
|
||||||
{
|
|
||||||
//Chech rect
|
|
||||||
if (rect.width && rect.height && rect.right() > 0 && rect.bottom() > 0)
|
|
||||||
{
|
|
||||||
if(rect.x < 0)
|
|
||||||
{
|
|
||||||
rect.width += rect.x;
|
|
||||||
rect.x = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rect.y < 0)
|
|
||||||
{
|
|
||||||
rect.height += rect.y;
|
|
||||||
rect.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(effective_range_ != rect)
|
|
||||||
{
|
|
||||||
effective_range_ = rect;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nana::point caret_descriptor::position() const
|
|
||||||
{
|
|
||||||
return point_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void caret_descriptor::visible(bool is_show)
|
|
||||||
{
|
|
||||||
auto pre_displayed = (visible_state::displayed == visible_state_);
|
|
||||||
|
|
||||||
if (is_show)
|
|
||||||
{
|
|
||||||
visible_state_ = visible_state::visible;
|
|
||||||
if (wd_->displayed() && (! out_of_range_))
|
|
||||||
visible_state_ = visible_state::displayed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
visible_state_ = visible_state::invisible;
|
|
||||||
|
|
||||||
if (pre_displayed != (visible_state::displayed == visible_state_))
|
|
||||||
native_interface::caret_visible(wd_->root, !pre_displayed);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool caret_descriptor::visible() const
|
|
||||||
{
|
|
||||||
return (visible_state::invisible != visible_state_);
|
|
||||||
}
|
|
||||||
|
|
||||||
nana::size caret_descriptor::size() const
|
|
||||||
{
|
|
||||||
return size_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void caret_descriptor::size(const nana::size& s)
|
|
||||||
{
|
|
||||||
size_ = s;
|
|
||||||
update();
|
|
||||||
|
|
||||||
if (visible_state::invisible != visible_state_)
|
|
||||||
visible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void caret_descriptor::update()
|
|
||||||
{
|
|
||||||
nana::point pos = point_;
|
|
||||||
nana::size size = size_;
|
|
||||||
|
|
||||||
nana::rectangle rect = effective_range_;
|
|
||||||
if(0 == effective_range_.width || 0 == effective_range_.height)
|
|
||||||
{
|
{
|
||||||
rect.x = rect.y = 0;
|
rect.x = rect.y = 0;
|
||||||
rect = wd_->dimension;
|
rect.dimension(owner_->dimension);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pos.x += effective_range_.x;
|
pos += effect_range_.position();
|
||||||
pos.y += effective_range_.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pos.x + static_cast<int>(size.width) <= rect.x) || (pos.x >= rect.right()) ||
|
if ((pos.x + static_cast<int>(size.width) <= rect.x) || (pos.x >= rect.right()) ||
|
||||||
@@ -149,7 +76,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
out_of_range_ = true;
|
out_of_range_ = true;
|
||||||
|
|
||||||
if (visible_state::invisible != visible_state_)
|
if (visible_state::invisible != visibility_)
|
||||||
visible(false);
|
visible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,68 +102,158 @@ namespace nana
|
|||||||
|
|
||||||
if (out_of_range_)
|
if (out_of_range_)
|
||||||
{
|
{
|
||||||
if (paint_size_ == size)
|
if (visual_size_ == size)
|
||||||
visible(true);
|
visible(true);
|
||||||
|
|
||||||
out_of_range_ = false;
|
out_of_range_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(paint_size_ != size)
|
if (visual_size_ != size)
|
||||||
{
|
{
|
||||||
bool vs = (visible_state::invisible != visible_state_);
|
bool vs = (visible_state::invisible != visibility_);
|
||||||
native_interface::caret_destroy(wd_->root);
|
native_interface::caret_destroy(owner_->root);
|
||||||
native_interface::caret_create(wd_->root, size);
|
native_interface::caret_create(owner_->root, size);
|
||||||
|
|
||||||
visible_state_ = visible_state::invisible;
|
visibility_ = visible_state::invisible;
|
||||||
if (vs)
|
if (vs)
|
||||||
visible(true);
|
visible(true);
|
||||||
|
|
||||||
|
|
||||||
paint_size_ = size;
|
visual_size_ = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
native_interface::caret_pos(wd_->root, wd_->pos_root + pos);
|
native_interface::caret_pos(owner_->root, owner_->pos_root + pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//end class caret_descriptor
|
|
||||||
|
//Implement caret_interface functions
|
||||||
|
void caret::disable_throw() noexcept
|
||||||
|
{
|
||||||
|
//This function is useless for class caret, see caret_proxy.
|
||||||
|
}
|
||||||
|
|
||||||
|
void caret::effective_range(const rectangle& r)
|
||||||
|
{
|
||||||
|
auto range = r;
|
||||||
|
//Chech rect
|
||||||
|
if (range.width && range.height && range.right() > 0 && range.bottom() > 0)
|
||||||
|
{
|
||||||
|
if (range.x < 0)
|
||||||
|
{
|
||||||
|
range.width += range.x;
|
||||||
|
range.x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (range.y < 0)
|
||||||
|
{
|
||||||
|
range.height += range.y;
|
||||||
|
range.y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (effect_range_ != range)
|
||||||
|
{
|
||||||
|
effect_range_ = range;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void caret::position(const point& pos)
|
||||||
|
{
|
||||||
|
position_ = pos;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
point caret::position() const
|
||||||
|
{
|
||||||
|
return position_;
|
||||||
|
}
|
||||||
|
|
||||||
|
size caret::dimension() const
|
||||||
|
{
|
||||||
|
return size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void caret::dimension(const size& s)
|
||||||
|
{
|
||||||
|
size_ = s;
|
||||||
|
update();
|
||||||
|
|
||||||
|
if (visible_state::invisible != visibility_)
|
||||||
|
visible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void caret::visible(bool visibility)
|
||||||
|
{
|
||||||
|
auto pre_displayed = (visible_state::displayed == visibility_);
|
||||||
|
|
||||||
|
if (visibility)
|
||||||
|
{
|
||||||
|
visibility_ = visible_state::visible;
|
||||||
|
if (owner_->displayed() && (!out_of_range_))
|
||||||
|
visibility_ = visible_state::displayed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
visibility_ = visible_state::invisible;
|
||||||
|
|
||||||
|
if (pre_displayed != (visible_state::displayed == visibility_))
|
||||||
|
native_interface::caret_visible(owner_->root, !pre_displayed);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool caret::visible() const
|
||||||
|
{
|
||||||
|
return (visible_state::invisible != visibility_);
|
||||||
|
}
|
||||||
|
//end class caret
|
||||||
|
|
||||||
//struct basic_window
|
//struct basic_window
|
||||||
//struct basic_window::other_tag
|
//struct basic_window::other_tag
|
||||||
basic_window::other_tag::other_tag(category::flags categ)
|
basic_window::other_tag::other_tag(category::flags categ)
|
||||||
: category(categ), active_window(nullptr), upd_state(update_state::none)
|
: category(categ), active_window(nullptr), upd_state(update_state::none)
|
||||||
{
|
{
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
switch(categ)
|
switch(categ)
|
||||||
{
|
{
|
||||||
case category::root_tag::value:
|
case category::flags::root:
|
||||||
attribute.root = new attr_root_tag;
|
attribute.root = new attr_root_tag;
|
||||||
break;
|
break;
|
||||||
case category::frame_tag::value:
|
case category::flags::frame:
|
||||||
attribute.frame = new attr_frame_tag;
|
attribute.frame = new attr_frame_tag;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
attribute.root = nullptr;
|
attribute.root = nullptr;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (category::flags::root == categ)
|
||||||
|
attribute.root = new attr_root_tag;
|
||||||
|
else
|
||||||
|
attribute.root = nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_window::other_tag::~other_tag()
|
basic_window::other_tag::~other_tag()
|
||||||
{
|
{
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
switch(category)
|
switch(category)
|
||||||
{
|
{
|
||||||
case category::root_tag::value:
|
case category::flags::root:
|
||||||
delete attribute.root;
|
delete attribute.root;
|
||||||
break;
|
break;
|
||||||
case category::frame_tag::value:
|
case category::flags::frame:
|
||||||
delete attribute.frame;
|
delete attribute.frame;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
if (category::flags::root == category)
|
||||||
|
delete attribute.root;
|
||||||
}
|
}
|
||||||
//end struct basic_window::other_tag
|
//end struct basic_window::other_tag
|
||||||
|
|
||||||
//basic_window
|
//basic_window
|
||||||
//@brief: constructor for the root window
|
//@brief: constructor for the root window
|
||||||
basic_window::basic_window(basic_window* owner, std::unique_ptr<widget_notifier_interface>&& wdg_notifier, category::root_tag**)
|
basic_window::basic_window(basic_window* owner, std::unique_ptr<widget_notifier_interface>&& wdg_notifier, category::root_tag**)
|
||||||
: widget_notifier(std::move(wdg_notifier)), other(category::root_tag::value)
|
: widget_notifier(std::move(wdg_notifier)), other(category::flags::root)
|
||||||
{
|
{
|
||||||
drawer.bind(this);
|
drawer.bind(this);
|
||||||
_m_init_pos_and_size(nullptr, rectangle());
|
_m_init_pos_and_size(nullptr, rectangle());
|
||||||
@@ -245,8 +262,8 @@ namespace nana
|
|||||||
|
|
||||||
basic_window::~basic_window()
|
basic_window::~basic_window()
|
||||||
{
|
{
|
||||||
delete together.caret;
|
delete annex.caret_ptr;
|
||||||
together.caret = nullptr;
|
annex.caret_ptr = nullptr;
|
||||||
|
|
||||||
delete effect.bground;
|
delete effect.bground;
|
||||||
effect.bground = nullptr;
|
effect.bground = nullptr;
|
||||||
@@ -256,7 +273,7 @@ namespace nana
|
|||||||
//@brief: bind a native window and baisc_window
|
//@brief: bind a native window and baisc_window
|
||||||
void basic_window::bind_native_window(native_window_type wd, unsigned width, unsigned height, unsigned extra_width, unsigned extra_height, nana::paint::graphics& graphics)
|
void basic_window::bind_native_window(native_window_type wd, unsigned width, unsigned height, unsigned extra_width, unsigned extra_height, nana::paint::graphics& graphics)
|
||||||
{
|
{
|
||||||
if(category::root_tag::value == this->other.category)
|
if(category::flags::root == this->other.category)
|
||||||
{
|
{
|
||||||
this->root = wd;
|
this->root = wd;
|
||||||
dimension.width = width;
|
dimension.width = width;
|
||||||
@@ -268,11 +285,13 @@ namespace nana
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WIDGET_FRAME_DEPRECATED
|
||||||
void basic_window::frame_window(native_window_type wd)
|
void basic_window::frame_window(native_window_type wd)
|
||||||
{
|
{
|
||||||
if(category::frame_tag::value == this->other.category)
|
if(category::flags::frame == this->other.category)
|
||||||
other.attribute.frame->container = wd;
|
other.attribute.frame->container = wd;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool basic_window::is_ancestor_of(const basic_window* wd) const
|
bool basic_window::is_ancestor_of(const basic_window* wd) const
|
||||||
{
|
{
|
||||||
@@ -312,7 +331,7 @@ namespace nana
|
|||||||
|
|
||||||
const basic_window* get_child_caret(const basic_window* wd, bool this_is_a_child)
|
const basic_window* get_child_caret(const basic_window* wd, bool this_is_a_child)
|
||||||
{
|
{
|
||||||
if (this_is_a_child && wd->together.caret)
|
if (this_is_a_child && wd->annex.caret_ptr)
|
||||||
return wd;
|
return wd;
|
||||||
|
|
||||||
for (auto child : wd->children)
|
for (auto child : wd->children)
|
||||||
@@ -346,10 +365,16 @@ namespace nana
|
|||||||
return anc;
|
return anc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void basic_window::set_action(mouse_action act)
|
||||||
|
{
|
||||||
|
flags.action_before = flags.action;
|
||||||
|
flags.action = act;
|
||||||
|
}
|
||||||
|
|
||||||
void basic_window::_m_init_pos_and_size(basic_window* parent, const rectangle& r)
|
void basic_window::_m_init_pos_and_size(basic_window* parent, const rectangle& r)
|
||||||
{
|
{
|
||||||
pos_owner = pos_root = r;
|
pos_owner = pos_root = r.position();
|
||||||
dimension = r;
|
dimension = r.dimension();
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
pos_root += parent->pos_root;
|
pos_root += parent->pos_root;
|
||||||
@@ -357,12 +382,12 @@ namespace nana
|
|||||||
|
|
||||||
void basic_window::_m_initialize(basic_window* agrparent)
|
void basic_window::_m_initialize(basic_window* agrparent)
|
||||||
{
|
{
|
||||||
if(other.category == category::root_tag::value)
|
if(category::flags::root == other.category)
|
||||||
{
|
{
|
||||||
if(agrparent && (nana::system::this_thread_id() != agrparent->thread_id))
|
if(agrparent && (nana::system::this_thread_id() != agrparent->thread_id))
|
||||||
agrparent = nullptr;
|
agrparent = nullptr;
|
||||||
|
|
||||||
while(agrparent && (agrparent->other.category != category::root_tag::value))
|
while(agrparent && (category::flags::root != agrparent->other.category))
|
||||||
agrparent = agrparent->parent;
|
agrparent = agrparent->parent;
|
||||||
|
|
||||||
owner = agrparent;
|
owner = agrparent;
|
||||||
@@ -390,6 +415,8 @@ namespace nana
|
|||||||
flags.fullscreen = false;
|
flags.fullscreen = false;
|
||||||
flags.tab = nana::detail::tab_type::none;
|
flags.tab = nana::detail::tab_type::none;
|
||||||
flags.action = mouse_action::normal;
|
flags.action = mouse_action::normal;
|
||||||
|
flags.action_before = mouse_action::normal;
|
||||||
|
|
||||||
flags.refreshing = false;
|
flags.refreshing = false;
|
||||||
flags.destroying = false;
|
flags.destroying = false;
|
||||||
flags.borderless = false;
|
flags.borderless = false;
|
||||||
@@ -404,8 +431,6 @@ namespace nana
|
|||||||
effect.bground = nullptr;
|
effect.bground = nullptr;
|
||||||
effect.bground_fade_rate = 0;
|
effect.bground_fade_rate = 0;
|
||||||
|
|
||||||
together.caret = nullptr;
|
|
||||||
|
|
||||||
extra_width = extra_height = 0;
|
extra_width = extra_height = 0;
|
||||||
|
|
||||||
//The window must keep its thread_id same as its parent if it is a child.
|
//The window must keep its thread_id same as its parent if it is a child.
|
||||||
@@ -417,15 +442,15 @@ namespace nana
|
|||||||
|
|
||||||
bool basic_window::set_events(const std::shared_ptr<general_events>& p)
|
bool basic_window::set_events(const std::shared_ptr<general_events>& p)
|
||||||
{
|
{
|
||||||
if (together.events_ptr)
|
if (annex.events_ptr)
|
||||||
return false;
|
return false;
|
||||||
together.events_ptr = p;
|
annex.events_ptr = p;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
general_events * basic_window::get_events() const
|
general_events * basic_window::get_events() const
|
||||||
{
|
{
|
||||||
return together.events_ptr.get();
|
return annex.events_ptr.get();
|
||||||
}
|
}
|
||||||
//end struct basic_window
|
//end struct basic_window
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user