Merge branch 'develop'
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -38,6 +38,7 @@ lib/
|
|||||||
*.ninja*
|
*.ninja*
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
|
.idea/
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
.idea/
|
.idea/
|
||||||
|
|||||||
51
.travis.yml
Normal file
51
.travis.yml
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
sudo: false
|
||||||
|
language: generic
|
||||||
|
|
||||||
|
cache:
|
||||||
|
apt: true
|
||||||
|
directories:
|
||||||
|
- /tmp/tools
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- env: CXX=g++-5 CC=gcc-5
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- g++-5
|
||||||
|
- libjpeg8-dev
|
||||||
|
- libasound2-dev
|
||||||
|
- alsa-utils
|
||||||
|
- alsa-oss
|
||||||
|
sources: &sources
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-precise
|
||||||
|
- llvm-toolchain-precise-3.7
|
||||||
|
- llvm-toolchain-precise-3.6
|
||||||
|
- env: CXX=g++-4.9 CC=gcc-4.9
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- g++-4.9
|
||||||
|
- libjpeg8-dev
|
||||||
|
- libasound2-dev
|
||||||
|
- alsa-utils
|
||||||
|
- alsa-oss
|
||||||
|
sources: *sources
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- export PATH="$HOME/bin:$PATH"
|
||||||
|
- 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
|
||||||
|
- chmod -R +x /tmp/tools
|
||||||
|
|
||||||
|
install:
|
||||||
|
- /tmp/tools/cmake --prefix="$HOME" --exclude-subdir
|
||||||
|
|
||||||
|
before_script :
|
||||||
|
- mkdir bld
|
||||||
|
- cd bld
|
||||||
|
|
||||||
|
script:
|
||||||
|
- cmake -G"Unix Makefiles" .. -DENABLE_JPEG=ON
|
||||||
|
- make
|
||||||
197
CMakeLists.txt
197
CMakeLists.txt
@@ -1,15 +1,29 @@
|
|||||||
# CMake configuration for Nana
|
# CMake configuration for Nana
|
||||||
# Author: Andrew Kornilov(https://github.com/ierofant)
|
# Author: Andrew Kornilov(https://github.com/ierofant)
|
||||||
# Contributor:
|
# Contributor:
|
||||||
# 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)
|
||||||
|
|
||||||
|
#https://cmake.org/cmake-tutorial/
|
||||||
|
#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
|
||||||
|
# if your changes don't execute
|
||||||
|
option(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF)
|
||||||
|
option(ENABLE_PNG "Enable the use of PNG" OFF)
|
||||||
|
option(LIBPNG_FROM_OS "Use libpng from operating system." ON)
|
||||||
|
option(ENABLE_JPEG "Enable the use of JPEG" OFF)
|
||||||
|
option(LIBJPEG_FROM_OS "Use libjpeg from operating system." ON)
|
||||||
|
option(ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF)
|
||||||
|
option(CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." OFF)
|
||||||
|
option(CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." ON)
|
||||||
|
option(BUILD_NANA_DEMOS "Build all the demos form the nana_demo repository." OFF)
|
||||||
|
|
||||||
# set compile flags
|
# set compile flags
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
|
||||||
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||||
|
|
||||||
|
|
||||||
# move this to the end ??
|
# move this to the end ??
|
||||||
if(BIICODE)
|
if(BIICODE)
|
||||||
# prepare BII_LIB_SRC
|
# prepare BII_LIB_SRC
|
||||||
@@ -18,37 +32,45 @@ if(BIICODE)
|
|||||||
add_biicode_targets()
|
add_biicode_targets()
|
||||||
|
|
||||||
return()
|
return()
|
||||||
endif()
|
endif(BIICODE)
|
||||||
|
|
||||||
project(nana)
|
project(nana)
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
# Compatibility with CMake 3.1
|
||||||
|
if(POLICY CMP0054)
|
||||||
|
# http://www.cmake.org/cmake/help/v3.1/policy/CMP0054.html
|
||||||
|
cmake_policy(SET CMP0054 OLD)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_definitions(-DNANA_IGNORE_CONF)
|
||||||
|
|
||||||
#Global MSVC definitions
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(MSVC)
|
add_definitions(-DWIN32)
|
||||||
|
|
||||||
|
#Global MSVC definitions
|
||||||
|
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)
|
||||||
# ??
|
# ??
|
||||||
if(WIN32_USE_MP)
|
if(WIN32_USE_MP)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||||
endif()
|
endif(WIN32_USE_MP)
|
||||||
|
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
|
if(MINGW)
|
||||||
|
if(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
|
add_definitions(-DNANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
|
endif(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
|
endif(MINGW)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
|
|
||||||
#Unicode
|
|
||||||
option(USE_UNICODE "Use Unicode Character Set")
|
|
||||||
if(USE_UNICODE)
|
|
||||||
add_definitions(-DNANA_UNICODE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
add_definitions(-DAPPLE)
|
add_definitions(-DAPPLE)
|
||||||
include_directories(/opt/X11/include/)
|
include_directories(/opt/X11/include/)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
add_definitions(-Dlinux)
|
add_definitions(-Dlinux)
|
||||||
endif()
|
endif(APPLE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -56,19 +78,10 @@ if(UNIX)
|
|||||||
find_package(Freetype)
|
find_package(Freetype)
|
||||||
if (FREETYPE_FOUND)
|
if (FREETYPE_FOUND)
|
||||||
include_directories( ${FREETYPE_INCLUDE_DIRS})
|
include_directories( ${FREETYPE_INCLUDE_DIRS})
|
||||||
endif()
|
endif(FREETYPE_FOUND)
|
||||||
endif()
|
endif(UNIX)
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
add_definitions(-DWIN32)
|
|
||||||
if(MINGW)
|
|
||||||
add_definitions(-DMINGW)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#Find PNG
|
#Find PNG
|
||||||
option(ENABLE_PNG "Enable the use of PNG")
|
|
||||||
option(LIBPNG_FROM_OS "Use libpng from operating system.")
|
|
||||||
if(ENABLE_PNG)
|
if(ENABLE_PNG)
|
||||||
add_definitions(-DNANA_ENABLE_PNG)
|
add_definitions(-DNANA_ENABLE_PNG)
|
||||||
if(LIBPNG_FROM_OS)
|
if(LIBPNG_FROM_OS)
|
||||||
@@ -76,13 +89,11 @@ if(ENABLE_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()
|
endif(PNG_FOUND)
|
||||||
endif()
|
endif(LIBPNG_FROM_OS)
|
||||||
endif()
|
endif(ENABLE_PNG)
|
||||||
|
|
||||||
#Find JPEG
|
#Find JPEG
|
||||||
option(ENABLE_JPEG "Enable the use of JPEG")
|
|
||||||
option(LIBJPEG_FROM_OS "Use libjpeg from operating system.")
|
|
||||||
if(ENABLE_JPEG)
|
if(ENABLE_JPEG)
|
||||||
add_definitions(-DNANA_ENABLE_JPEG)
|
add_definitions(-DNANA_ENABLE_JPEG)
|
||||||
if(LIBJPEG_FROM_OS)
|
if(LIBJPEG_FROM_OS)
|
||||||
@@ -90,14 +101,30 @@ if(ENABLE_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()
|
endif(JPEG_FOUND)
|
||||||
endif()
|
endif(LIBJPEG_FROM_OS)
|
||||||
endif()
|
endif(ENABLE_JPEG)
|
||||||
|
|
||||||
|
if(ENABLE_AUDIO)
|
||||||
|
add_definitions(-DNANA_ENABLE_AUDIO)
|
||||||
|
if(UNIX)
|
||||||
|
find_package(asound)
|
||||||
|
if (ASOUND_FOUND)
|
||||||
|
include_directories( ${ASOUND_INCLUDE_DIRS})
|
||||||
|
else(ASOUND_FOUND)
|
||||||
|
message(FATAL_ERROR "libasound is not found")
|
||||||
|
endif(ASOUND_FOUND)
|
||||||
|
endif(UNIX)
|
||||||
|
endif(ENABLE_AUDIO)
|
||||||
|
|
||||||
|
#Unicode
|
||||||
|
if(CMAKE_VERBOSE_PREPROCESSOR)
|
||||||
|
add_definitions(-DVERBOSE_PREPROCESSOR)
|
||||||
|
endif(CMAKE_VERBOSE_PREPROCESSOR)
|
||||||
|
|
||||||
|
|
||||||
|
set(NANA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source)
|
||||||
set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source)
|
set(NANA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
set(NANA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
|
|
||||||
|
|
||||||
include_directories(${NANA_INCLUDE_DIR})
|
include_directories(${NANA_INCLUDE_DIR})
|
||||||
aux_source_directory(${NANA_SOURCE_DIR} NANA_SOURCE)
|
aux_source_directory(${NANA_SOURCE_DIR} NANA_SOURCE)
|
||||||
@@ -116,13 +143,15 @@ 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}/system NANA_SYSTEM_SOURCE)
|
||||||
aux_source_directory(${NANA_SOURCE_DIR}/threads NANA_THREADS_SOURCE)
|
aux_source_directory(${NANA_SOURCE_DIR}/threads NANA_THREADS_SOURCE)
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
if(NOT APPLE)
|
||||||
add_library(${PROJECT_NAME} ${NANA_SOURCE}
|
add_library(${PROJECT_NAME} ${NANA_SOURCE}
|
||||||
${NANA_DETAIL_SOURCE}
|
${NANA_DETAIL_SOURCE}
|
||||||
${NANA_FILESYSTEM_SOURCE}
|
${NANA_FILESYSTEM_SOURCE}
|
||||||
#if(NOT APPLE)
|
|
||||||
${NANA_AUDIO_SOURCE}
|
${NANA_AUDIO_SOURCE}
|
||||||
${NANA_AUDIO_DETAIL_SOURCE}
|
${NANA_AUDIO_DETAIL_SOURCE}
|
||||||
#endif
|
|
||||||
${NANA_GUI_SOURCE}
|
${NANA_GUI_SOURCE}
|
||||||
${NANA_GUI_DETAIL_SOURCE}
|
${NANA_GUI_DETAIL_SOURCE}
|
||||||
${NANA_GUI_WIDGETS_SOURCE}
|
${NANA_GUI_WIDGETS_SOURCE}
|
||||||
@@ -131,18 +160,98 @@ add_library(${PROJECT_NAME} ${NANA_SOURCE}
|
|||||||
${NANA_PAINT_DETAIL_SOURCE}
|
${NANA_PAINT_DETAIL_SOURCE}
|
||||||
${NANA_SYSTEM_SOURCE}
|
${NANA_SYSTEM_SOURCE}
|
||||||
${NANA_THREADS_SOURCE})
|
${NANA_THREADS_SOURCE})
|
||||||
|
endif (NOT APPLE)
|
||||||
|
|
||||||
#if(APPLE)
|
|
||||||
target_link_libraries(${PROJECT_NAME} -L/opt/X11/lib/ -lX11 -lXft -lpng -liconv)
|
if(APPLE)
|
||||||
#endif()
|
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} -L/opt/X11/lib/ -lX11 -lXft -lpng -liconv)
|
||||||
|
|
||||||
|
endif(APPLE)
|
||||||
|
|
||||||
install(TARGETS ${PROJECT_NAME}
|
install(TARGETS ${PROJECT_NAME}
|
||||||
ARCHIVE DESTINATION lib
|
ARCHIVE DESTINATION lib
|
||||||
LIBRARY DESTINATION lib)
|
LIBRARY DESTINATION lib)
|
||||||
|
# ??
|
||||||
install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include)
|
install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include)
|
||||||
|
|
||||||
set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 )
|
set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 )
|
||||||
|
|
||||||
add_executable(nana_test test.cpp)
|
if (BUILD_NANA_DEMOS)
|
||||||
set_property( TARGET nana_test PROPERTY CXX_STANDARD 14 )
|
set (CMAKE_INSTALL_PREFIX ${DEMO_BIN})
|
||||||
target_link_libraries(nana_test ${PROJECT_NAME})
|
set(DEMO_BIN ${NANA_SOURCE_DIR}../nana-demo/bin)
|
||||||
|
set(CMAKE_INSTALL_PREFIX )
|
||||||
|
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})
|
||||||
|
|
||||||
|
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})
|
||||||
|
|
||||||
|
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})
|
||||||
|
|
||||||
|
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})
|
||||||
|
|
||||||
|
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(audio_player ../nana-demo/Examples/audio_player.cpp)
|
||||||
|
set_property( TARGET audio_player PROPERTY CXX_STANDARD 14 )
|
||||||
|
target_link_libraries(audio_player ${PROJECT_NAME})
|
||||||
|
|
||||||
|
|
||||||
|
#add_executable(nana_test test.cpp)
|
||||||
|
#set_property( TARGET nana_test PROPERTY CXX_STANDARD 14 )
|
||||||
|
#target_link_libraries(nana_test ${PROJECT_NAME})
|
||||||
|
|
||||||
|
#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})
|
||||||
|
#endforeach( demofile ${DEMO_SOURCES} )
|
||||||
|
endif(BUILD_NANA_DEMOS)
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
# Nana C++ Library
|
# Nana C++ Library [](https://www.biicode.com/qiangwu/nana) [](https://travis-ci.org/cnjinhao/nana) [](LICENSE_1_0.txt)
|
||||||
[](https://www.biicode.com/qiangwu/nana)
|
|
||||||
|
|
||||||
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 contains the entire source of library, you can browse the source code and submit your pull request for contributing.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Nana is licensed under the [Boost Software License].
|
Nana is licensed under the [Boost Software License](http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
[Boost Software License]: http://www.boost.org/LICENSE_1_0.txt
|
|
||||||
|
|
||||||
## Members
|
## Members
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,7 @@
|
|||||||
<Unit filename="../../source/deploy.cpp" />
|
<Unit filename="../../source/deploy.cpp" />
|
||||||
<Unit filename="../../source/detail/platform_spec_posix.cpp" />
|
<Unit filename="../../source/detail/platform_spec_posix.cpp" />
|
||||||
<Unit filename="../../source/detail/platform_spec_windows.cpp" />
|
<Unit filename="../../source/detail/platform_spec_windows.cpp" />
|
||||||
<Unit filename="../../source/filesystem/file_iterator.cpp" />
|
<Unit filename="../../source/filesystem/filesystem.cpp" />
|
||||||
<Unit filename="../../source/filesystem/fs_utility.cpp" />
|
|
||||||
<Unit filename="../../source/gui/animation.cpp" />
|
<Unit filename="../../source/gui/animation.cpp" />
|
||||||
<Unit filename="../../source/gui/basis.cpp" />
|
<Unit filename="../../source/gui/basis.cpp" />
|
||||||
<Unit filename="../../source/gui/detail/basic_window.cpp" />
|
<Unit filename="../../source/gui/detail/basic_window.cpp" />
|
||||||
@@ -119,7 +118,6 @@
|
|||||||
<Unit filename="../../source/system/shared_wrapper.cpp" />
|
<Unit filename="../../source/system/shared_wrapper.cpp" />
|
||||||
<Unit filename="../../source/system/timepiece.cpp" />
|
<Unit filename="../../source/system/timepiece.cpp" />
|
||||||
<Unit filename="../../source/threads/pool.cpp" />
|
<Unit filename="../../source/threads/pool.cpp" />
|
||||||
<Unit filename="../../source/traits.cpp" />
|
|
||||||
<Unit filename="../../source/unicode_bidi.cpp" />
|
<Unit filename="../../source/unicode_bidi.cpp" />
|
||||||
<Extensions>
|
<Extensions>
|
||||||
<code_completion />
|
<code_completion />
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -189,8 +189,6 @@
|
|||||||
<ClCompile Include="..\..\source\deploy.cpp" />
|
<ClCompile Include="..\..\source\deploy.cpp" />
|
||||||
<ClCompile Include="..\..\source\detail\platform_spec_windows.cpp" />
|
<ClCompile Include="..\..\source\detail\platform_spec_windows.cpp" />
|
||||||
<ClCompile Include="..\..\source\filesystem\filesystem.cpp" />
|
<ClCompile Include="..\..\source\filesystem\filesystem.cpp" />
|
||||||
<ClCompile Include="..\..\source\filesystem\file_iterator.cpp" />
|
|
||||||
<ClCompile Include="..\..\source\filesystem\fs_utility.cpp" />
|
|
||||||
<ClCompile Include="..\..\source\gui\animation.cpp" />
|
<ClCompile Include="..\..\source\gui\animation.cpp" />
|
||||||
<ClCompile Include="..\..\source\gui\basis.cpp" />
|
<ClCompile Include="..\..\source\gui\basis.cpp" />
|
||||||
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp" />
|
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp" />
|
||||||
@@ -256,7 +254,6 @@
|
|||||||
<ClCompile Include="..\..\source\system\shared_wrapper.cpp" />
|
<ClCompile Include="..\..\source\system\shared_wrapper.cpp" />
|
||||||
<ClCompile Include="..\..\source\system\timepiece.cpp" />
|
<ClCompile Include="..\..\source\system\timepiece.cpp" />
|
||||||
<ClCompile Include="..\..\source\threads\pool.cpp" />
|
<ClCompile Include="..\..\source\threads\pool.cpp" />
|
||||||
<ClCompile Include="..\..\source\traits.cpp" />
|
|
||||||
<ClCompile Include="..\..\source\unicode_bidi.cpp" />
|
<ClCompile Include="..\..\source\unicode_bidi.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -276,8 +273,6 @@
|
|||||||
<ClInclude Include="..\..\include\nana\detail\linux_X11\platform_spec.hpp" />
|
<ClInclude Include="..\..\include\nana\detail\linux_X11\platform_spec.hpp" />
|
||||||
<ClInclude Include="..\..\include\nana\detail\win32\platform_spec.hpp" />
|
<ClInclude Include="..\..\include\nana\detail\win32\platform_spec.hpp" />
|
||||||
<ClInclude Include="..\..\include\nana\filesystem\filesystem.hpp" />
|
<ClInclude Include="..\..\include\nana\filesystem\filesystem.hpp" />
|
||||||
<ClInclude Include="..\..\include\nana\filesystem\file_iterator.hpp" />
|
|
||||||
<ClInclude Include="..\..\include\nana\filesystem\fs_utility.hpp" />
|
|
||||||
<ClInclude Include="..\..\include\nana\fwd.hpp" />
|
<ClInclude Include="..\..\include\nana\fwd.hpp" />
|
||||||
<ClInclude Include="..\..\include\nana\gui.hpp" />
|
<ClInclude Include="..\..\include\nana\gui.hpp" />
|
||||||
<ClInclude Include="..\..\include\nana\gui\animation.hpp" />
|
<ClInclude Include="..\..\include\nana\gui\animation.hpp" />
|
||||||
|
|||||||
@@ -111,12 +111,6 @@
|
|||||||
<ClCompile Include="..\..\source\filesystem\filesystem.cpp">
|
<ClCompile Include="..\..\source\filesystem\filesystem.cpp">
|
||||||
<Filter>Source Files\nana\filesystem</Filter>
|
<Filter>Source Files\nana\filesystem</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\source\filesystem\file_iterator.cpp">
|
|
||||||
<Filter>Source Files\nana\filesystem</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\source\filesystem\fs_utility.cpp">
|
|
||||||
<Filter>Source Files\nana\filesystem</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp">
|
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp">
|
||||||
<Filter>Source Files\nana\gui\detail</Filter>
|
<Filter>Source Files\nana\gui\detail</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -291,9 +285,6 @@
|
|||||||
<ClCompile Include="..\..\source\deploy.cpp">
|
<ClCompile Include="..\..\source\deploy.cpp">
|
||||||
<Filter>Source Files\nana</Filter>
|
<Filter>Source Files\nana</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\source\traits.cpp">
|
|
||||||
<Filter>Source Files\nana</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\source\unicode_bidi.cpp">
|
<ClCompile Include="..\..\source\unicode_bidi.cpp">
|
||||||
<Filter>Source Files\nana</Filter>
|
<Filter>Source Files\nana</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -619,12 +610,6 @@
|
|||||||
<ClInclude Include="..\..\include\nana\filesystem\filesystem.hpp">
|
<ClInclude Include="..\..\include\nana\filesystem\filesystem.hpp">
|
||||||
<Filter>Header Files\filesystem</Filter>
|
<Filter>Header Files\filesystem</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\include\nana\filesystem\file_iterator.hpp">
|
|
||||||
<Filter>Header Files\filesystem</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\include\nana\filesystem\fs_utility.hpp">
|
|
||||||
<Filter>Header Files\filesystem</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\include\nana\paint\gadget.hpp">
|
<ClInclude Include="..\..\include\nana\paint\gadget.hpp">
|
||||||
<Filter>Header Files\paint</Filter>
|
<Filter>Header Files\paint</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
@@ -183,8 +183,6 @@
|
|||||||
<ClCompile Include="..\..\source\deploy.cpp" />
|
<ClCompile Include="..\..\source\deploy.cpp" />
|
||||||
<ClCompile Include="..\..\source\detail\platform_spec_windows.cpp" />
|
<ClCompile Include="..\..\source\detail\platform_spec_windows.cpp" />
|
||||||
<ClCompile Include="..\..\source\filesystem\filesystem.cpp" />
|
<ClCompile Include="..\..\source\filesystem\filesystem.cpp" />
|
||||||
<ClCompile Include="..\..\source\filesystem\file_iterator.cpp" />
|
|
||||||
<ClCompile Include="..\..\source\filesystem\fs_utility.cpp" />
|
|
||||||
<ClCompile Include="..\..\source\gui\animation.cpp" />
|
<ClCompile Include="..\..\source\gui\animation.cpp" />
|
||||||
<ClCompile Include="..\..\source\gui\basis.cpp" />
|
<ClCompile Include="..\..\source\gui\basis.cpp" />
|
||||||
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp" />
|
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp" />
|
||||||
@@ -249,7 +247,6 @@
|
|||||||
<ClCompile Include="..\..\source\system\platform.cpp" />
|
<ClCompile Include="..\..\source\system\platform.cpp" />
|
||||||
<ClCompile Include="..\..\source\system\timepiece.cpp" />
|
<ClCompile Include="..\..\source\system\timepiece.cpp" />
|
||||||
<ClCompile Include="..\..\source\threads\pool.cpp" />
|
<ClCompile Include="..\..\source\threads\pool.cpp" />
|
||||||
<ClCompile Include="..\..\source\traits.cpp" />
|
|
||||||
<ClCompile Include="..\..\source\unicode_bidi.cpp" />
|
<ClCompile Include="..\..\source\unicode_bidi.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
@@ -69,9 +69,6 @@
|
|||||||
<ClCompile Include="..\..\source\internationalization.cpp">
|
<ClCompile Include="..\..\source\internationalization.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\source\traits.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\source\unicode_bidi.cpp">
|
<ClCompile Include="..\..\source\unicode_bidi.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -87,15 +84,9 @@
|
|||||||
<ClCompile Include="..\..\source\audio\player.cpp">
|
<ClCompile Include="..\..\source\audio\player.cpp">
|
||||||
<Filter>Source Files\audio</Filter>
|
<Filter>Source Files\audio</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\source\filesystem\file_iterator.cpp">
|
|
||||||
<Filter>Source Files\filesystem</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\source\filesystem\filesystem.cpp">
|
<ClCompile Include="..\..\source\filesystem\filesystem.cpp">
|
||||||
<Filter>Source Files\filesystem</Filter>
|
<Filter>Source Files\filesystem</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\source\filesystem\fs_utility.cpp">
|
|
||||||
<Filter>Source Files\filesystem</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp">
|
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp">
|
||||||
<Filter>Source Files\gui\detail</Filter>
|
<Filter>Source Files\gui\detail</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
@@ -1,145 +1,159 @@
|
|||||||
|
/**
|
||||||
|
* Any
|
||||||
|
* 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/any.hpp
|
||||||
|
*
|
||||||
|
* @brief An implementation of experimental library any of C++ standard(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4480.html#any)
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef NANA_ANY_HPP
|
#ifndef NANA_ANY_HPP
|
||||||
#define NANA_ANY_HPP
|
#define NANA_ANY_HPP
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <utility> //C++11 for std::move
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "c++defines.hpp"
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class bad_any_cast
|
||||||
|
: public std::bad_cast
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
class any
|
class any
|
||||||
{
|
{
|
||||||
struct super_type
|
class content_interface
|
||||||
{
|
{
|
||||||
virtual ~super_type();
|
public:
|
||||||
super_type& operator=(const super_type&);
|
virtual ~content_interface() = default;
|
||||||
virtual super_type& assign(const super_type&) = 0;
|
|
||||||
virtual bool same(const super_type&) const = 0;
|
|
||||||
virtual super_type* clone() const = 0;
|
|
||||||
}; //end struct super_type
|
|
||||||
|
|
||||||
template<typename T>
|
virtual const std::type_info& type() const noexcept = 0;
|
||||||
struct object_type
|
virtual content_interface* clone() const = 0;
|
||||||
: public super_type
|
};
|
||||||
|
|
||||||
|
template<typename Value>
|
||||||
|
class holder : public content_interface
|
||||||
{
|
{
|
||||||
object_type(){}
|
holder& operator=(const holder&) = delete;
|
||||||
|
public:
|
||||||
object_type(T const & obj)
|
holder(const Value& other)
|
||||||
: object(obj)
|
: value(other)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
object_type(T && obj)
|
holder(Value&& other)
|
||||||
: object(std::move(obj))
|
: value(static_cast<Value&&>(other))
|
||||||
{}
|
{}
|
||||||
|
public:
|
||||||
object_type(const object_type& rhs)
|
const std::type_info& type() const noexcept override
|
||||||
:object(rhs.object)
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual super_type& assign(const super_type& rhs)
|
|
||||||
{
|
{
|
||||||
if(this != &rhs)
|
return typeid(Value);
|
||||||
{
|
|
||||||
auto other = dynamic_cast<const object_type*>(&rhs);
|
|
||||||
if(other)
|
|
||||||
object = other->object;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool same(const super_type& rhs) const
|
content_interface* clone() const override
|
||||||
{
|
{
|
||||||
return (dynamic_cast<const object_type*>(&rhs) != nullptr);
|
return new holder(value);
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
virtual super_type* clone() const
|
Value value; //representation accessable for friend of any
|
||||||
{
|
};
|
||||||
return new object_type(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
T object;
|
|
||||||
}; //end struct object_type
|
|
||||||
public:
|
public:
|
||||||
template<typename T>
|
//constructors and destructor
|
||||||
any(const T & obj)
|
any() noexcept;
|
||||||
: super_(new object_type<typename std::remove_reference<T>::type>(obj))
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<typename T>
|
any(const any& other);
|
||||||
any(T && obj)
|
any(any&& other) noexcept;
|
||||||
: super_(new object_type<typename std::remove_reference<T>::type>(std::move(obj)))
|
|
||||||
{}
|
template<typename Value>
|
||||||
|
any(Value && value,
|
||||||
|
typename std::enable_if<!std::is_same<any&, Value>::value>::type * = nullptr,
|
||||||
|
typename std::enable_if<!std::is_const<Value>::value>::type* = nullptr)
|
||||||
|
: content_(new holder<typename std::decay<Value>::type>(static_cast<Value&&>(value)))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
any();
|
|
||||||
any(const any&);
|
|
||||||
any(any&&);
|
|
||||||
~any();
|
~any();
|
||||||
|
|
||||||
bool same(const any &) const;
|
//assignments
|
||||||
any& operator=(const any&);
|
any& operator=(const any& other);
|
||||||
any& operator=(any&&);
|
any& operator=(any&& other) noexcept;
|
||||||
|
|
||||||
template<typename T>
|
template<class Value>
|
||||||
any& operator=(T const &rhs)
|
any& operator=(Value&& other)
|
||||||
{
|
{
|
||||||
T * obj = get<T>();
|
any(other).swap(*this);
|
||||||
if(nullptr == obj)
|
|
||||||
{
|
|
||||||
delete super_;
|
|
||||||
super_ = new object_type<T>(rhs);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*obj = rhs;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
//modifiers
|
||||||
any & operator=(T && rhs)
|
void clear() noexcept;
|
||||||
{
|
void swap(any& other) noexcept;
|
||||||
typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type type;
|
|
||||||
type* obj = get<type>();
|
|
||||||
if(nullptr == obj)
|
|
||||||
{
|
|
||||||
delete super_;
|
|
||||||
super_ = new object_type<type>(std::move(rhs));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*obj = std::move(rhs);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
//observers
|
||||||
T * get() const
|
bool empty() const noexcept;
|
||||||
{
|
const std::type_info& type() const noexcept;
|
||||||
if(super_)
|
|
||||||
{
|
|
||||||
typedef typename std::remove_const<T>::type type;
|
|
||||||
object_type<type>* obj = dynamic_cast<object_type<type>*>(super_);
|
|
||||||
if(obj) return &(obj->object);
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
operator T&() const
|
|
||||||
{
|
|
||||||
typedef typename std::remove_const<T>::type type;
|
|
||||||
type *obj = get<type>();
|
|
||||||
|
|
||||||
if(nullptr == obj)
|
|
||||||
throw std::bad_cast();
|
|
||||||
|
|
||||||
return *obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
operator T*() const
|
|
||||||
{
|
|
||||||
typedef typename std::remove_const<T>::type type;
|
|
||||||
return get<type>();
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
super_type * super_;
|
template<typename Value>
|
||||||
|
friend Value* any_cast(any*) noexcept;
|
||||||
|
private:
|
||||||
|
content_interface * content_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Non-member functions
|
||||||
|
inline void swap(any& x, any& y) noexcept
|
||||||
|
{
|
||||||
|
x.swap(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Value>
|
||||||
|
Value any_cast(const any& operand)
|
||||||
|
{
|
||||||
|
using value_type = typename std::remove_reference<Value>::type;
|
||||||
|
return any_cast<const value_type&>(const_cast<any&>(operand));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Value>
|
||||||
|
Value any_cast(any& operand)
|
||||||
|
{
|
||||||
|
using value_type = typename std::remove_reference<Value>::type;
|
||||||
|
|
||||||
|
auto value_ptr = any_cast<value_type>(&operand);
|
||||||
|
if (!value_ptr)
|
||||||
|
throw bad_any_cast();
|
||||||
|
|
||||||
|
using ref_type = typename std::conditional<std::is_reference<Value>::value, Value, typename std::add_lvalue_reference<Value>::type>::type;
|
||||||
|
return static_cast<ref_type>(*value_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Value>
|
||||||
|
Value any_cast(any && operand)
|
||||||
|
{
|
||||||
|
static_assert(std::is_rvalue_reference<Value&&>::value || std::is_const<typename ::std::remove_reference<Value>::type>::value, "nana::any_cast shall not be used for getting non-const reference to temporary objects");
|
||||||
|
return any_cast<Value>(operand);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Value>
|
||||||
|
const Value* any_cast(const any* operand) noexcept
|
||||||
|
{
|
||||||
|
return any_cast<Value>(const_cast<any*>(operand));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Value>
|
||||||
|
Value* any_cast(any* operand) noexcept
|
||||||
|
{
|
||||||
|
if (!operand)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto holder = dynamic_cast<any::holder<Value>*>(operand->content_);
|
||||||
|
return (holder ? &holder->value : nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
#define NANA_AUDIO_DETAIL_AUDIO_DEVICE_HPP
|
#define NANA_AUDIO_DETAIL_AUDIO_DEVICE_HPP
|
||||||
|
|
||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
|
|
||||||
|
#ifdef NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
#include <nana/audio/detail/buffer_preparation.hpp>
|
#include <nana/audio/detail/buffer_preparation.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
@@ -50,4 +53,5 @@ namespace nana{ namespace audio
|
|||||||
}//end namespace audio
|
}//end namespace audio
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#endif //NANA_ENABLE_AUDIO
|
||||||
#endif
|
#endif
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
#ifndef NANA_AUDIO_DETAIL_AUDIO_STREAM_HPP
|
#ifndef NANA_AUDIO_DETAIL_AUDIO_STREAM_HPP
|
||||||
#define NANA_AUDIO_DETAIL_AUDIO_STREAM_HPP
|
#define NANA_AUDIO_DETAIL_AUDIO_STREAM_HPP
|
||||||
#include <fstream>
|
|
||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
|
|
||||||
|
#ifdef NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
namespace nana{ namespace audio{
|
namespace nana{ namespace audio{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
@@ -59,7 +63,7 @@ namespace nana{ namespace audio{
|
|||||||
unsigned cksize;
|
unsigned cksize;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
bool open(const nana::string& file);
|
bool open(const std::string& file);
|
||||||
void close();
|
void close();
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
const wave_spec::format_chunck & format() const;
|
const wave_spec::format_chunck & format() const;
|
||||||
@@ -78,4 +82,5 @@ namespace nana{ namespace audio{
|
|||||||
}
|
}
|
||||||
}//end namespace audio
|
}//end namespace audio
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#endif //NANA_ENABLE_AUDIO
|
||||||
#endif
|
#endif
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
#ifndef NANA_AUDIO_DETAIL_BUFFER_PREPARATION_HPP
|
#ifndef NANA_AUDIO_DETAIL_BUFFER_PREPARATION_HPP
|
||||||
#define NANA_AUDIO_DETAIL_BUFFER_PREPARATION_HPP
|
#define NANA_AUDIO_DETAIL_BUFFER_PREPARATION_HPP
|
||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
|
|
||||||
|
#ifdef NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
#include <nana/audio/detail/audio_stream.hpp>
|
#include <nana/audio/detail/audio_stream.hpp>
|
||||||
|
|
||||||
#if defined(STD_THREAD_NOT_SUPPORTED)
|
#if defined(STD_THREAD_NOT_SUPPORTED)
|
||||||
@@ -62,4 +65,5 @@ namespace nana{ namespace audio
|
|||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace audio
|
}//end namespace audio
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#endif //NANA_ENABLE_AUDIO
|
||||||
#endif
|
#endif
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
#ifndef NANA_AUDIO_PLAYER_HPP
|
#ifndef NANA_AUDIO_PLAYER_HPP
|
||||||
#define NANA_AUDIO_PLAYER_HPP
|
#define NANA_AUDIO_PLAYER_HPP
|
||||||
#include <nana/traits.hpp>
|
|
||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
|
|
||||||
|
#ifdef NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
|
#include <nana/traits.hpp>
|
||||||
|
|
||||||
namespace nana{ namespace audio
|
namespace nana{ namespace audio
|
||||||
{ /// class player
|
{ /// class player
|
||||||
/// \brief play an audio file in PCM Windows WAV format
|
/// \brief play an audio file in PCM Windows WAV format
|
||||||
@@ -14,10 +18,10 @@ namespace nana{ namespace audio
|
|||||||
struct implementation;
|
struct implementation;
|
||||||
public:
|
public:
|
||||||
player();
|
player();
|
||||||
player(const nana::string& file);
|
player(const std::string& file);
|
||||||
~player();
|
~player();
|
||||||
|
|
||||||
bool open(const nana::string& file);
|
bool open(const std::string& file);
|
||||||
void play();
|
void play();
|
||||||
void close();
|
void close();
|
||||||
private:
|
private:
|
||||||
@@ -25,4 +29,6 @@ namespace nana{ namespace audio
|
|||||||
};
|
};
|
||||||
}//end namespace audio
|
}//end namespace audio
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#endif //NANA_ENABLE_AUDIO
|
||||||
#endif
|
#endif
|
||||||
@@ -67,7 +67,8 @@ namespace nana
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::basic_string<nana::char_t, casei_char_traits<nana::char_t> > cistring;
|
using cistring = std::basic_string<char, casei_char_traits<char>>;
|
||||||
|
using ciwstring = std::basic_string<wchar_t, casei_char_traits<wchar_t>>;
|
||||||
|
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
|
|||||||
171
include/nana/c++defines.hpp
Normal file
171
include/nana/c++defines.hpp
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/**
|
||||||
|
* Predefined Symbols for C++
|
||||||
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
|
* Copyright(C) 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/config.hpp
|
||||||
|
*
|
||||||
|
* @brief Provide switches to adapt to the target OS, use of external libraries or workarounds compiler errors or lack of std C++ support.
|
||||||
|
*
|
||||||
|
* To control target OS/compiler:
|
||||||
|
* - NANA_WINDOWS
|
||||||
|
* - NANA_MINGW
|
||||||
|
* - NANA_POSIX
|
||||||
|
* - NANA_LINUX
|
||||||
|
* - NANA_MACOS
|
||||||
|
* - NANA_X11
|
||||||
|
*
|
||||||
|
* External libraries:
|
||||||
|
* - NANA_LIBPNG, USE_LIBPNG_FROM_OS
|
||||||
|
* - NANA_LIBJPEG, USE_LIBJPEG_FROM_OS
|
||||||
|
*
|
||||||
|
* (see: Feature-testing recommendations for C++
|
||||||
|
* in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0096r0.html
|
||||||
|
* for example: __cpp_lib_experimental_filesystem = 201406 in <experimental/filesystem)
|
||||||
|
*
|
||||||
|
* Workaround to known compiler errors, unnecessary warnings or lack of C++11/14/17 support:
|
||||||
|
* - _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_THREAD_NOT_SUPPORTED (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)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NANA_CXX_DEFINES_INCLUDED
|
||||||
|
#define NANA_CXX_DEFINES_INCLUDED
|
||||||
|
|
||||||
|
//C++ language
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# if (_MSC_VER < 1900)
|
||||||
|
# //Nana defines some macros for lack of support of keywords
|
||||||
|
# define _ALLOW_KEYWORD_MACROS
|
||||||
|
#
|
||||||
|
# define noexcept //no support of noexcept until Visual C++ 2015
|
||||||
|
# define constexpr //no support of constexpr until Visual C++ 2015
|
||||||
|
# endif
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
# if (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
|
||||||
|
# define noexcept //no support of noexcept until GCC 4.6
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Select platform ......
|
||||||
|
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) //Microsoft Windows
|
||||||
|
#define NANA_WINDOWS
|
||||||
|
|
||||||
|
// MINGW ...
|
||||||
|
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(MINGW)
|
||||||
|
#define NANA_MINGW
|
||||||
|
#endif // MINGW
|
||||||
|
|
||||||
|
#elif defined(APPLE) //Mac OS X
|
||||||
|
//Symbols for MACOS
|
||||||
|
|
||||||
|
#define NANA_MACOS
|
||||||
|
#define NANA_X11
|
||||||
|
|
||||||
|
#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) //Linux
|
||||||
|
#define NANA_LINUX
|
||||||
|
#define NANA_X11
|
||||||
|
#else
|
||||||
|
# static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//Define a symbol for POSIX operating system.
|
||||||
|
#if defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||||
|
#define NANA_POSIX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Select compiler ...
|
||||||
|
#if defined(_MSC_VER) //Microsoft Visual C++
|
||||||
|
#define _SCL_SECURE_NO_WARNNGS
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#pragma warning(disable : 4996)
|
||||||
|
|
||||||
|
#if (_MSC_VER == 1900)
|
||||||
|
// google: break any code that tries to use codecvt<char16_t> or codecvt<char32_t>.
|
||||||
|
// google: It appears the C++ libs haven't been compiled with native char16_t/char32_t support.
|
||||||
|
// google: Those definitions are for codecvt<wchar_t>::id, codecvt<unsigned short>::id and codecvt<char>::id respectively.
|
||||||
|
// However, the codecvt<char16_t>::id and codecvt<char32_t>::id definitions aren't there, and indeed, if you look at locale0.cpp in the CRT source code you'll see they're not defined at all.
|
||||||
|
// google: That's a known issue, tracked by an active bug (DevDiv#1060849). We were able to update the STL's headers in response to char16_t/char32_t, but we still need to update the separately compiled sources.
|
||||||
|
#define STD_CODECVT_NOT_SUPPORTED
|
||||||
|
#endif // _MSC_VER == 1900
|
||||||
|
|
||||||
|
#elif defined(__clang__) //Clang
|
||||||
|
|
||||||
|
#include <iosfwd> //Introduces some implement-specific flags of ISO C++ Library
|
||||||
|
#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
|
||||||
|
//<codecvt> is a known issue on libstdc++, it works on libc++
|
||||||
|
#define STD_CODECVT_NOT_SUPPORTED
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef STD_MAKE_UNIQUE_NOT_SUPPORTED
|
||||||
|
#define STD_MAKE_UNIQUE_NOT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(__GNUC__) //GCC
|
||||||
|
|
||||||
|
#include <iosfwd> //Introduces some implement-specific flags of ISO C++ Library
|
||||||
|
#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
|
||||||
|
//<codecvt> is a known issue on libstdc++, it works on libc++
|
||||||
|
#define STD_CODECVT_NOT_SUPPORTED
|
||||||
|
|
||||||
|
//It's a known issue of libstdc++ on MinGW
|
||||||
|
//introduce to_string/to_wstring workarounds for disabled capacity of stdlib
|
||||||
|
#ifdef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
|
||||||
|
#if (__GNUC__ < 5)
|
||||||
|
# define STD_TO_STRING_NOT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define STD_TO_WSTRING_NOT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (__GNUC__ == 4)
|
||||||
|
#if ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 1))
|
||||||
|
#define STD_THREAD_NOT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (__GNUC_MINOR__ < 9)
|
||||||
|
#define STD_MAKE_UNIQUE_NOT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(NANA_MINGW)
|
||||||
|
//It's a knonwn issue under MinGW
|
||||||
|
#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (__GNUC_MINOR__ < 8)
|
||||||
|
//introduce to_string/to_wstring workaround for lack of stdlib definitions
|
||||||
|
#ifndef STD_TO_STRING_NOT_SUPPORTED
|
||||||
|
# define STD_TO_STRING_NOT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STD_TO_WSTRING_NOT_SUPPORTED
|
||||||
|
# define STD_TO_WSTRING_NOT_SUPPORTED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
#ifndef _UNICODE
|
||||||
|
#define _UNICODE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UNICODE
|
||||||
|
#define UNICODE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // NANA_CXX_DEFINES_INCLUDED
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* The charset Implementation
|
* The charset 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
|
||||||
@@ -18,6 +18,24 @@
|
|||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
namespace utf
|
||||||
|
{
|
||||||
|
/// Attempt to get a pointer to a character of UTF-8 string by a specifed character index.
|
||||||
|
/// @param text_utf8 A string encoded as UTF-8.
|
||||||
|
/// @param pos The unicode character index.
|
||||||
|
/// @returns A pointer to the unicode character. It returns a null if pos is out of range.
|
||||||
|
const char* char_ptr(const char* text_utf8, unsigned pos);
|
||||||
|
const char* char_ptr(const ::std::string& text_utf8, unsigned pos);
|
||||||
|
|
||||||
|
/// Get the unicode character by a specified character index.
|
||||||
|
/// @param text_utf8 A string encoded as UTF-8.
|
||||||
|
/// @param pos The unicode character index.
|
||||||
|
/// @param len A unsigned pointer to receive the number of bytes it takes in UTF-8 encoded. If len is a nullptr, it is ignored.
|
||||||
|
/// @returns A unicode character. '\0' if pos is out of range.
|
||||||
|
wchar_t char_at(const char* text_utf8, unsigned pos, unsigned * len);
|
||||||
|
wchar_t char_at(const ::std::string& text_utf8, unsigned pos, unsigned * len);
|
||||||
|
}
|
||||||
|
|
||||||
enum class unicode
|
enum class unicode
|
||||||
{
|
{
|
||||||
utf8, utf16, utf32
|
utf8, utf16, utf32
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* A Concepts Definition of Nana C++ Library
|
* A Concepts Definition of Nana C++ Library
|
||||||
* 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
|
||||||
@@ -22,7 +22,7 @@ namespace nana
|
|||||||
class any_objective
|
class any_objective
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~any_objective(){}
|
virtual ~any_objective() = default;
|
||||||
|
|
||||||
template<typename Target>
|
template<typename Target>
|
||||||
void anyobj(const Target& t)
|
void anyobj(const Target& t)
|
||||||
@@ -37,7 +37,7 @@ namespace nana
|
|||||||
void anyobj(Target&& t)
|
void anyobj(Target&& t)
|
||||||
{
|
{
|
||||||
nana::any * p = _m_anyobj(true);
|
nana::any * p = _m_anyobj(true);
|
||||||
if(nullptr == 0)
|
if(nullptr == p)
|
||||||
throw std::runtime_error("Nana.any_objective: Object does not exist");
|
throw std::runtime_error("Nana.any_objective: Object does not exist");
|
||||||
|
|
||||||
*p = std::move(t);
|
*p = std::move(t);
|
||||||
@@ -46,8 +46,7 @@ namespace nana
|
|||||||
template<typename Target>
|
template<typename Target>
|
||||||
Target * anyobj() const ///< Retrieves the attached object. Returns a nullptr if empty or if the type not match.
|
Target * anyobj() const ///< Retrieves the attached object. Returns a nullptr if empty or if the type not match.
|
||||||
{
|
{
|
||||||
nana::any * p = _m_anyobj(false);
|
return any_cast<Target>(_m_anyobj(false));
|
||||||
return (p ? p->get<Target>() : nullptr);
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
virtual nana::any* _m_anyobj(bool allocate_if_empty) const = 0;
|
virtual nana::any* _m_anyobj(bool allocate_if_empty) const = 0;
|
||||||
@@ -60,7 +59,7 @@ namespace nana
|
|||||||
public:
|
public:
|
||||||
typedef IndexType anyobj_index_t; ///< The type of index. It is available if Dimension is greater than 0.
|
typedef IndexType anyobj_index_t; ///< The type of index. It is available if Dimension is greater than 0.
|
||||||
|
|
||||||
virtual ~any_objective(){}
|
virtual ~any_objective() = default;
|
||||||
|
|
||||||
template<typename Target>
|
template<typename Target>
|
||||||
void anyobj(anyobj_index_t i, const Target& t)
|
void anyobj(anyobj_index_t i, const Target& t)
|
||||||
@@ -83,8 +82,7 @@ namespace nana
|
|||||||
template<typename Target>
|
template<typename Target>
|
||||||
Target * anyobj(anyobj_index_t i) const ///< Retrieves the attached object. Returns a nullptr if empty or if the type not match.
|
Target * anyobj(anyobj_index_t i) const ///< Retrieves the attached object. Returns a nullptr if empty or if the type not match.
|
||||||
{
|
{
|
||||||
nana::any * p = _m_anyobj(i, false);
|
return any_cast<Target>(_m_anyobj(i, false));
|
||||||
return (p ? p->get<Target>() : nullptr);
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
virtual nana::any* _m_anyobj(anyobj_index_t i, bool allocate_if_empty) const = 0;
|
virtual nana::any* _m_anyobj(anyobj_index_t i, bool allocate_if_empty) const = 0;
|
||||||
@@ -121,8 +119,7 @@ namespace nana
|
|||||||
template<typename Target>
|
template<typename Target>
|
||||||
Target * anyobj(anyobj_index_t i0, anyobj_index_t i1) const ///< Retrieves the attached object. Returns a nullptr if empty or if the type not match.
|
Target * anyobj(anyobj_index_t i0, anyobj_index_t i1) const ///< Retrieves the attached object. Returns a nullptr if empty or if the type not match.
|
||||||
{
|
{
|
||||||
nana::any * p = _m_anyobj(i0, i1, false);
|
return any_cast<Target>(_m_anyobj(i0, i1, false));
|
||||||
return (p ? p->get<Target>() : nullptr);
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
virtual nana::any* _m_anyobj(anyobj_index_t i0, anyobj_index_t i1, bool allocate_if_empty) const = 0;
|
virtual nana::any* _m_anyobj(anyobj_index_t i0, anyobj_index_t i1, bool allocate_if_empty) const = 0;
|
||||||
|
|||||||
@@ -1,115 +1,48 @@
|
|||||||
/**
|
/**
|
||||||
* Nana Configuration
|
* Nana Configuration
|
||||||
* 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/config.hpp
|
* @file nana/config.hpp
|
||||||
|
*
|
||||||
|
* @brief Provide switches to enable 3rd-party libraries for a certain feature.
|
||||||
|
*
|
||||||
|
* External libraries:
|
||||||
|
* - NANA_LIBPNG, USE_LIBPNG_FROM_OS
|
||||||
|
* - NANA_LIBJPEG, USE_LIBJPEG_FROM_OS
|
||||||
|
*
|
||||||
|
* messages:
|
||||||
|
* - VERBOSE_PREPROCESSOR, STOP_VERBOSE_PREPROCESSOR
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NANA_CONFIG_HPP
|
#ifndef NANA_CONFIG_HPP
|
||||||
#define NANA_CONFIG_HPP
|
#define NANA_CONFIG_HPP
|
||||||
|
|
||||||
// Select platform ......
|
#include "c++defines.hpp"
|
||||||
|
|
||||||
// Windows:
|
|
||||||
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
|
||||||
|
|
||||||
#define NANA_WINDOWS
|
|
||||||
|
|
||||||
// MINGW ...
|
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(MINGW)
|
|
||||||
#define NANA_MINGW
|
|
||||||
#endif // MINGW
|
|
||||||
|
|
||||||
// end Windows
|
|
||||||
|
|
||||||
|
|
||||||
// MacOS: who define APPLE ??
|
|
||||||
//#define APPLE
|
|
||||||
#elif defined(APPLE)
|
|
||||||
#define NANA_MACOS
|
|
||||||
#define NANA_X11
|
|
||||||
// how to add this: include_directories(/opt/X11/include/)
|
|
||||||
// end MacOS
|
|
||||||
|
|
||||||
// Linux: (not sure about __GNU__ ??)
|
|
||||||
#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC)
|
|
||||||
#define NANA_LINUX
|
|
||||||
#define NANA_X11
|
|
||||||
// end Linux
|
|
||||||
#else
|
|
||||||
# static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
|
|
||||||
#endif // Select platform
|
|
||||||
|
|
||||||
#if defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
#define NANA_POSIX
|
|
||||||
#undef NANA_WINDOWS
|
|
||||||
#endif
|
|
||||||
// End Select platform ......
|
|
||||||
|
|
||||||
// compilers ...
|
|
||||||
|
|
||||||
// MSVC++ versions
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#define _SCL_SECURE_NO_WARNNGS
|
|
||||||
#define _CRT_SECURE_NO_DEPRECATE
|
|
||||||
#pragma warning(disable : 4996)
|
|
||||||
|
|
||||||
#if (_MSC_VER == 1900)
|
|
||||||
// google: break any code that tries to use codecvt<char16_t> or codecvt<char32_t>.
|
|
||||||
// google: It appears the C++ libs haven't been compiled with native char16_t/char32_t support.
|
|
||||||
// google: Those definitions are for codecvt<wchar_t>::id, codecvt<unsigned short>::id and codecvt<char>::id respectively.
|
|
||||||
// However, the codecvt<char16_t>::id and codecvt<char32_t>::id definitions aren't there, and indeed, if you look at locale0.cpp in the CRT source code you'll see they're not defined at all.
|
|
||||||
// google: That's a known issue, tracked by an active bug (DevDiv#1060849). We were able to update the STL's headers in response to char16_t/char32_t, but we still need to update the separately compiled sources.
|
|
||||||
#define STD_CODECVT_NOT_SUPPORTED
|
|
||||||
#endif // _MSC_VER == 1900
|
|
||||||
#endif // _MSVC
|
|
||||||
|
|
||||||
#if defined(__clang__)
|
|
||||||
#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
|
|
||||||
//<codecvt> is a known issue on libstdc++, it works on libc++
|
|
||||||
#define STD_CODECVT_NOT_SUPPORTED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(__GNUC__) //GCC
|
|
||||||
#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
|
|
||||||
//<codecvt> is a known issue on libstdc++, it works on libc++
|
|
||||||
#define STD_CODECVT_NOT_SUPPORTED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (__GNUC__ == 4)
|
|
||||||
#if ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 1))
|
|
||||||
#define STD_THREAD_NOT_SUPPORTED
|
|
||||||
|
|
||||||
//boost.thread is preferred
|
|
||||||
//but if USE_github_com_meganz_mingw_std_threads is enabled,
|
|
||||||
//boost.thread will be replaced with meganz's mingw-std-threads.
|
|
||||||
// https://github.com/meganz/mingw-std-threads
|
|
||||||
//#define USE_github_com_meganz_mingw_std_threads
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(NANA_MINGW)
|
|
||||||
//It's a known issue under MinGW
|
|
||||||
#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ((__GNUC_MINOR__ < 8) || defined(NANA_MINGW))
|
|
||||||
#define STD_TO_STRING_NOT_SUPPORTED
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// End compilers ...
|
|
||||||
|
|
||||||
|
//The basic configurations are ignored when NANA_IGNORE_CONF is defined.
|
||||||
|
//The NANA_IGNORE_CONF may be specified by CMake generated makefile.
|
||||||
|
#ifndef NANA_IGNORE_CONF
|
||||||
|
|
||||||
// Here defines some flags that tell Nana what features will be supported.
|
// Here defines some flags that tell Nana what features will be supported.
|
||||||
|
|
||||||
|
|
||||||
|
//Support of std::thread
|
||||||
|
//Boost.Thread is preferred.
|
||||||
|
//NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ is only available on MinGW when STD_THREAD_NOT_SUPPORTED is defined.
|
||||||
|
//if NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ is enabled, Boost.Thread will be replaced with meganz's mingw-std-threads.
|
||||||
|
//https://github.com/meganz/mingw-std-threads
|
||||||
|
//#define NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ
|
||||||
|
|
||||||
|
///////////////////
|
||||||
|
//Support of PCM playback
|
||||||
|
//
|
||||||
|
//#define NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
//Support for PNG
|
//Support for PNG
|
||||||
// Define the NANA_ENABLE_PNG to enable the support of PNG.
|
// Define the NANA_ENABLE_PNG to enable the support of PNG.
|
||||||
@@ -134,22 +67,13 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(VERBOSE_PREPROCESSOR)
|
||||||
|
//#define VERBOSE_PREPROCESSOR
|
||||||
// always define NANA_UNICODE ?? it will be deprecated ?.
|
|
||||||
#ifndef NANA_UNICODE
|
|
||||||
#define NANA_UNICODE
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(NANA_UNICODE) && defined(NANA_WINDOWS)
|
#if !defined(STOP_VERBOSE_PREPROCESSOR)
|
||||||
#ifndef _UNICODE
|
#define STOP_VERBOSE_PREPROCESSOR
|
||||||
#define _UNICODE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef UNICODE
|
|
||||||
#define UNICODE
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // NANA_IGNORE_CONFIG
|
||||||
#endif //NANA_CONFIG_HPP
|
#endif // NANA_CONFIG_HPP
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* The Deploy Implementation
|
* The Deploy 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
|
||||||
@@ -15,11 +15,13 @@
|
|||||||
#ifndef NANA_DEPLOY_HPP
|
#ifndef NANA_DEPLOY_HPP
|
||||||
#define NANA_DEPLOY_HPP
|
#define NANA_DEPLOY_HPP
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
#include <nana/config.hpp>
|
#include <nana/config.hpp>
|
||||||
#include <nana/charset.hpp>
|
#if defined(VERBOSE_PREPROCESSOR)
|
||||||
|
#include <nana/verbose_preprocessor.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <nana/charset.hpp>
|
||||||
|
|
||||||
//Implement workarounds for GCC/MinGW which version is below 4.8.2
|
//Implement workarounds for GCC/MinGW which version is below 4.8.2
|
||||||
#if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED)
|
#if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED)
|
||||||
@@ -72,7 +74,12 @@ namespace std
|
|||||||
std::string to_string(long long);
|
std::string to_string(long long);
|
||||||
std::string to_string(unsigned long long);
|
std::string to_string(unsigned long long);
|
||||||
std::string to_string(float);
|
std::string to_string(float);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STD_TO_WSTRING_NOT_SUPPORTED
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
std::wstring to_wstring(long double);
|
std::wstring to_wstring(long double);
|
||||||
std::wstring to_wstring(double);
|
std::wstring to_wstring(double);
|
||||||
std::wstring to_wstring(unsigned);
|
std::wstring to_wstring(unsigned);
|
||||||
@@ -85,56 +92,58 @@ namespace std
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef NANA_UNICODE
|
|
||||||
namespace nana
|
|
||||||
{
|
|
||||||
typedef char char_t;
|
|
||||||
typedef std::string string; ///< An alias of std::wstring or std::string, depending on the macro NANA_UNICODE
|
|
||||||
}
|
|
||||||
#define STR(string) string
|
|
||||||
#else
|
|
||||||
namespace nana
|
|
||||||
{
|
|
||||||
typedef wchar_t char_t;
|
|
||||||
typedef std::wstring string; ///< An alias of std::wstring or std::string, depending on the macro NANA_UNICODE
|
|
||||||
}
|
|
||||||
#define STR(string) L##string
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
std::size_t strlen(const char_t* str);
|
/// Checks whether a specified text is utf8 encoding
|
||||||
char_t* strcpy(char_t* dest, const char_t* source);
|
bool is_utf8(const char* str, unsigned len);
|
||||||
#ifdef _MSC_VER
|
void throw_not_utf8(const std::string& text);
|
||||||
template <size_t N>
|
void throw_not_utf8(const char*, unsigned len);
|
||||||
inline char* strcpy(char (&dest)[N], const char* source)
|
void throw_not_utf8(const char*);
|
||||||
{
|
|
||||||
::strncpy_s(dest, source, _TRUNCATE);
|
const std::string& to_utf8(const std::string&);
|
||||||
return dest;
|
std::string to_utf8(const std::wstring&);
|
||||||
}
|
|
||||||
template <size_t N>
|
std::wstring to_wstring(const std::string& utf8_str);
|
||||||
inline wchar_t* strcpy(wchar_t (&dest)[N], const wchar_t* source)
|
const std::wstring& to_wstring(const std::wstring& wstr);
|
||||||
{
|
std::wstring&& to_wstring(std::wstring&& wstr);
|
||||||
::wcsncpy_s(dest, source, _TRUNCATE);
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
#endif // #ifdef _MSC_VER
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
#define NANA_SHARED_EXPORT extern "C" _declspec(dllexport)
|
std::string to_osmbstr(const std::string& text_utf8);
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
#else
|
||||||
#define NANA_SHARED_EXPORT extern "C"
|
std::string to_osmbstr(std::string text_utf8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
using native_string_type = std::wstring;
|
||||||
|
#else //POSIX
|
||||||
|
using native_string_type = std::string;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
const detail::native_string_type to_nstring(const std::string&);
|
||||||
|
const detail::native_string_type& to_nstring(const std::wstring&);
|
||||||
|
detail::native_string_type to_nstring(std::string&&);
|
||||||
|
detail::native_string_type&& to_nstring(std::wstring&&);
|
||||||
|
#else //POSIX
|
||||||
|
const detail::native_string_type& to_nstring(const std::string&);
|
||||||
|
const detail::native_string_type to_nstring(const std::wstring&);
|
||||||
|
detail::native_string_type&& to_nstring(std::string&&);
|
||||||
|
detail::native_string_type to_nstring(std::wstring&&);
|
||||||
|
#endif
|
||||||
|
detail::native_string_type to_nstring(int);
|
||||||
|
detail::native_string_type to_nstring(double);
|
||||||
|
detail::native_string_type to_nstring(std::size_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
bool is_incomplete(const nana::string& str, unsigned pos);
|
|
||||||
|
|
||||||
inline unsigned make_rgb(unsigned char red, unsigned char green, unsigned char blue)
|
inline unsigned make_rgb(unsigned char red, unsigned char green, unsigned char blue)
|
||||||
{
|
{
|
||||||
|
|
||||||
return ((unsigned(red) << 16)|((unsigned(green)<<8))|blue);
|
return ((unsigned(red) << 16)|((unsigned(green)<<8))|blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,4 +151,44 @@ namespace nana
|
|||||||
#define NANA_RGB(a) (((DWORD)(a) & 0xFF)<<16) | ((DWORD)(a) & 0xFF00) | (((DWORD)(a) & 0xFF0000) >> 16 )
|
#define NANA_RGB(a) (((DWORD)(a) & 0xFF)<<16) | ((DWORD)(a) & 0xFF00) | (((DWORD)(a) & 0xFF0000) >> 16 )
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef STD_MAKE_UNIQUE_NOT_SUPPORTED
|
||||||
|
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3656.htm
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <memory>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
template<class T> struct _Unique_if {
|
||||||
|
typedef unique_ptr<T> _Single_object;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T> struct _Unique_if<T[]> {
|
||||||
|
typedef unique_ptr<T[]> _Unknown_bound;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, size_t N> struct _Unique_if<T[N]> {
|
||||||
|
typedef void _Known_bound;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T, class... Args>
|
||||||
|
typename _Unique_if<T>::_Single_object
|
||||||
|
make_unique(Args&&... args) {
|
||||||
|
return unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename _Unique_if<T>::_Unknown_bound
|
||||||
|
make_unique(size_t n) {
|
||||||
|
typedef typename remove_extent<T>::type U;
|
||||||
|
return unique_ptr<T>(new U[n]());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, class... Args>
|
||||||
|
typename _Unique_if<T>::_Known_bound
|
||||||
|
make_unique(Args&&...) = delete;
|
||||||
|
}
|
||||||
|
#endif //STD_make_unique_NOT_SUPPORTED
|
||||||
|
|
||||||
#endif //NANA_MACROS_HPP
|
#endif //NANA_MACROS_HPP
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace detail
|
|||||||
Window window;
|
Window window;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
std::vector<nana::string> * files;
|
std::vector<std::string> * files;
|
||||||
}mouse_drop;
|
}mouse_drop;
|
||||||
}u;
|
}u;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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-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
|
||||||
@@ -34,7 +34,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "msg_packet.hpp"
|
#include "msg_packet.hpp"
|
||||||
#if defined(NANA_UNICODE)
|
|
||||||
|
#define NANA_USE_XFT
|
||||||
|
#if defined(NANA_USE_XFT)
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@@ -45,7 +47,7 @@ namespace nana
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class msg_dispatcher;
|
class msg_dispatcher;
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_USE_XFT)
|
||||||
class conf
|
class conf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -70,13 +72,13 @@ namespace detail
|
|||||||
|
|
||||||
struct font_tag
|
struct font_tag
|
||||||
{
|
{
|
||||||
nana::string name;
|
std::string name;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
unsigned weight;
|
unsigned weight;
|
||||||
bool italic;
|
bool italic;
|
||||||
bool underline;
|
bool underline;
|
||||||
bool strikeout;
|
bool strikeout;
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_USE_XFT)
|
||||||
XftFont * handle;
|
XftFont * handle;
|
||||||
#else
|
#else
|
||||||
XFontSet handle;
|
XFontSet handle;
|
||||||
@@ -99,10 +101,10 @@ namespace detail
|
|||||||
unsigned tab_pixels;
|
unsigned tab_pixels;
|
||||||
unsigned whitespace_pixels;
|
unsigned whitespace_pixels;
|
||||||
}string;
|
}string;
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_USE_XFT)
|
||||||
XftDraw * xftdraw{nullptr};
|
XftDraw * xftdraw{nullptr};
|
||||||
XftColor xft_fgcolor;
|
XftColor xft_fgcolor;
|
||||||
const std::string charset(const nana::string& str, const std::string& strcode);
|
const std::string charset(const std::wstring& str, const std::string& strcode);
|
||||||
#endif
|
#endif
|
||||||
drawable_impl_type();
|
drawable_impl_type();
|
||||||
~drawable_impl_type();
|
~drawable_impl_type();
|
||||||
@@ -120,7 +122,7 @@ namespace detail
|
|||||||
unsigned color_{ 0xFFFFFFFF };
|
unsigned color_{ 0xFFFFFFFF };
|
||||||
unsigned text_color_{ 0xFFFFFFFF };
|
unsigned text_color_{ 0xFFFFFFFF };
|
||||||
|
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_USE_XFT)
|
||||||
struct conv_tag
|
struct conv_tag
|
||||||
{
|
{
|
||||||
iconv_t handle;
|
iconv_t handle;
|
||||||
@@ -203,7 +205,7 @@ namespace detail
|
|||||||
void default_native_font(const font_ptr_t&);
|
void default_native_font(const font_ptr_t&);
|
||||||
unsigned font_size_to_height(unsigned) const;
|
unsigned font_size_to_height(unsigned) const;
|
||||||
unsigned font_height_to_size(unsigned) const;
|
unsigned font_height_to_size(unsigned) const;
|
||||||
font_ptr_t make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strick_out);
|
font_ptr_t make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strick_out);
|
||||||
|
|
||||||
Display* open_display();
|
Display* open_display();
|
||||||
void close_display();
|
void close_display();
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace detail
|
|||||||
|
|
||||||
struct font_tag
|
struct font_tag
|
||||||
{
|
{
|
||||||
nana::string name;
|
native_string_type name;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
unsigned weight;
|
unsigned weight;
|
||||||
bool italic;
|
bool italic;
|
||||||
@@ -186,7 +186,7 @@ namespace detail
|
|||||||
void default_native_font(const font_ptr_t&);
|
void default_native_font(const font_ptr_t&);
|
||||||
unsigned font_size_to_height(unsigned) const;
|
unsigned font_size_to_height(unsigned) const;
|
||||||
unsigned font_height_to_size(unsigned) const;
|
unsigned font_height_to_size(unsigned) const;
|
||||||
font_ptr_t make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
|
font_ptr_t make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
|
||||||
|
|
||||||
static platform_spec& instance();
|
static platform_spec& instance();
|
||||||
|
|
||||||
|
|||||||
@@ -1,255 +0,0 @@
|
|||||||
/*
|
|
||||||
* A File Iterator Implementation
|
|
||||||
* Copyright(C) 2003 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: stdex/filesystem/file_iterator.hpp
|
|
||||||
* @description:
|
|
||||||
* file_iterator is a toolkit for applying each file and directory in a
|
|
||||||
* specified path.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NANA_FILESYSTEM_FILE_ITERATOR_HPP
|
|
||||||
#define NANA_FILESYSTEM_FILE_ITERATOR_HPP
|
|
||||||
#include <iterator>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <nana/deploy.hpp>
|
|
||||||
|
|
||||||
#ifdef NANA_WINDOWS
|
|
||||||
#include <windows.h>
|
|
||||||
typedef HANDLE find_handle_t;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
typedef DIR* find_handle_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace nana
|
|
||||||
{
|
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
struct fileinfo
|
|
||||||
{
|
|
||||||
fileinfo();
|
|
||||||
#ifdef NANA_WINDOWS
|
|
||||||
fileinfo(const WIN32_FIND_DATA& wfd);
|
|
||||||
#elif defined(NANA_POSIX)
|
|
||||||
fileinfo(const nana::string& filename, const struct stat &);
|
|
||||||
#endif
|
|
||||||
nana::string name;
|
|
||||||
|
|
||||||
unsigned long size;
|
|
||||||
bool directory;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename FileInfo>
|
|
||||||
class basic_file_iterator
|
|
||||||
:public std::iterator<std::input_iterator_tag, FileInfo>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef FileInfo value_type;
|
|
||||||
|
|
||||||
basic_file_iterator():end_(true), handle_(nullptr){}
|
|
||||||
|
|
||||||
basic_file_iterator(const nana::string& file_path)
|
|
||||||
:end_(false), handle_(nullptr)
|
|
||||||
{
|
|
||||||
_m_prepare(file_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
const value_type&
|
|
||||||
operator*() const { return value_; }
|
|
||||||
|
|
||||||
const value_type*
|
|
||||||
operator->() const { return &(operator*()); }
|
|
||||||
|
|
||||||
basic_file_iterator& operator++()
|
|
||||||
{ _m_read(); return *this; }
|
|
||||||
|
|
||||||
basic_file_iterator operator++(int)
|
|
||||||
{
|
|
||||||
basic_file_iterator tmp = *this;
|
|
||||||
_m_read();
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool equal(const basic_file_iterator& x) const
|
|
||||||
{
|
|
||||||
if(end_ && (end_ == x.end_)) return true;
|
|
||||||
return (value_.name == x.value_.name);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
template<typename Char>
|
|
||||||
static bool _m_ignore(const Char * p)
|
|
||||||
{
|
|
||||||
while(*p == '.')
|
|
||||||
++p;
|
|
||||||
return (*p == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _m_prepare(const nana::string& file_path)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
path_ = file_path;
|
|
||||||
auto pat = file_path;
|
|
||||||
DWORD attr = ::GetFileAttributes(pat.data());
|
|
||||||
if((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY))
|
|
||||||
pat += STR("\\*");
|
|
||||||
|
|
||||||
::HANDLE handle = ::FindFirstFile(pat.data(), &wfd_);
|
|
||||||
|
|
||||||
if(handle == INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
end_ = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(_m_ignore(wfd_.cFileName))
|
|
||||||
{
|
|
||||||
if(::FindNextFile(handle, &wfd_) == 0)
|
|
||||||
{
|
|
||||||
end_ = true;
|
|
||||||
::FindClose(handle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
value_ = value_type(wfd_);
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
path_ = nana::charset(file_path);
|
|
||||||
if(path_.size() && (path_[path_.size() - 1] != '/'))
|
|
||||||
path_ += '/';
|
|
||||||
find_handle_t handle = opendir(path_.c_str());
|
|
||||||
end_ = true;
|
|
||||||
if(handle)
|
|
||||||
{
|
|
||||||
struct dirent * dnt = readdir(handle);
|
|
||||||
if(dnt)
|
|
||||||
{
|
|
||||||
while(_m_ignore(dnt->d_name))
|
|
||||||
{
|
|
||||||
dnt = readdir(handle);
|
|
||||||
if(dnt == 0)
|
|
||||||
{
|
|
||||||
closedir(handle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct stat fst;
|
|
||||||
if(stat((path_ + dnt->d_name).c_str(), &fst) == 0)
|
|
||||||
{
|
|
||||||
value_ = value_type(nana::charset(dnt->d_name), fst);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
value_.name = nana::charset(dnt->d_name);
|
|
||||||
value_.size = 0;
|
|
||||||
value_.directory = false;
|
|
||||||
}
|
|
||||||
end_ = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if(false == end_)
|
|
||||||
{
|
|
||||||
find_ptr_ = std::shared_ptr<find_handle_t>(new find_handle_t(handle), inner_handle_deleter());
|
|
||||||
handle_ = handle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _m_read()
|
|
||||||
{
|
|
||||||
if(handle_)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
if(::FindNextFile(handle_, &wfd_) != 0)
|
|
||||||
{
|
|
||||||
while(_m_ignore(wfd_.cFileName))
|
|
||||||
{
|
|
||||||
if(::FindNextFile(handle_, &wfd_) == 0)
|
|
||||||
{
|
|
||||||
end_ = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
value_ = value_type(wfd_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
end_ = true;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
struct dirent * dnt = readdir(handle_);
|
|
||||||
if(dnt)
|
|
||||||
{
|
|
||||||
while(_m_ignore(dnt->d_name))
|
|
||||||
{
|
|
||||||
dnt = readdir(handle_);
|
|
||||||
if(dnt == 0)
|
|
||||||
{
|
|
||||||
end_ = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
struct stat fst;
|
|
||||||
if(stat((path_ + "/" + dnt->d_name).c_str(), &fst) == 0)
|
|
||||||
value_ = value_type(nana::charset(dnt->d_name), fst);
|
|
||||||
else
|
|
||||||
value_.name = nana::charset(dnt->d_name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
end_ = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
struct inner_handle_deleter
|
|
||||||
{
|
|
||||||
void operator()(find_handle_t * handle)
|
|
||||||
{
|
|
||||||
if(handle && *handle)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
::FindClose(*handle);
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
::closedir(*handle);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
delete handle;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
bool end_;
|
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
WIN32_FIND_DATA wfd_;
|
|
||||||
nana::string path_;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
std::string path_;
|
|
||||||
#endif
|
|
||||||
std::shared_ptr<find_handle_t> find_ptr_;
|
|
||||||
|
|
||||||
find_handle_t handle_;
|
|
||||||
value_type value_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Value_Type>
|
|
||||||
inline bool operator==(const basic_file_iterator<Value_Type> & x, const basic_file_iterator<Value_Type> & y)
|
|
||||||
{
|
|
||||||
return x.equal(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Value_Type>
|
|
||||||
inline bool operator!=(const basic_file_iterator<Value_Type> & x, const basic_file_iterator<Value_Type> & y)
|
|
||||||
{
|
|
||||||
return !x.equal(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef basic_file_iterator<fileinfo> file_iterator;
|
|
||||||
}//end namespace filesystem
|
|
||||||
}//end namespace nana
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,16 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* 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-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/filesystem/filesystem.hpp
|
* @file: nana/filesystem/filesystem.hpp
|
||||||
* @description:
|
|
||||||
* file_iterator is a toolkit for applying each file and directory in a
|
|
||||||
* specified path.
|
|
||||||
* Modiffied by Ariel Vina-Rodriguez:
|
* Modiffied by Ariel Vina-Rodriguez:
|
||||||
* Now mimic std::experimental::filesystem::v1 (boost v3)
|
* Now 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 will be compiler by VC2013
|
||||||
@@ -32,99 +29,74 @@
|
|||||||
|
|
||||||
#ifndef NANA_FILESYSTEM_HPP
|
#ifndef NANA_FILESYSTEM_HPP
|
||||||
#define NANA_FILESYSTEM_HPP
|
#define NANA_FILESYSTEM_HPP
|
||||||
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
|
|
||||||
#ifdef NANA_WINDOWS
|
|
||||||
#include <windows.h>
|
|
||||||
typedef HANDLE find_handle_t;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
typedef DIR* find_handle_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// namespace std { namespace experimental { namespace filesystem { inline namespace v1 {
|
// namespace std { namespace experimental { namespace filesystem { inline namespace v1 {
|
||||||
|
|
||||||
namespace nana { namespace experimental
|
namespace nana { namespace experimental
|
||||||
{
|
{
|
||||||
namespace filesystem
|
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
|
||||||
not_found = -1, ///< Pseudo-type: file was not found. Is not considered an error
|
not_found = -1, ///< Pseudo-type: file was not found. Is not considered an error
|
||||||
regular = 1,
|
regular = 1,
|
||||||
directory = 2 ,
|
directory = 2 ,
|
||||||
symlink =3, ///< Symbolic link file
|
symlink =3, ///< Symbolic link file
|
||||||
block =4, ///< Block special file
|
block =4, ///< Block special file
|
||||||
character= 5 , ///< Character special file
|
character= 5 , ///< Character special file
|
||||||
fifo = 6 , ///< FIFO or pipe file
|
fifo = 6 , ///< FIFO or pipe file
|
||||||
socket =7,
|
socket =7,
|
||||||
unknown= 8 ///< The file does exist, but is of an operating system dependent type not covered by any of the other
|
unknown= 8 ///< The file does exist, but is of an operating system dependent type not covered by any of the other
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class perms
|
enum class perms
|
||||||
{
|
{
|
||||||
none =0, ///< There are no permissions set for the file.
|
none = 0, ///< There are no permissions set for the file.
|
||||||
unknown = 0xFFFF ///< not known, such as when a file_status object is created without specifying the permissions
|
all = 0x1FF, ///< owner_all | group_all | others_all
|
||||||
};
|
mask = 0xFFF, ///< all | set_uid | set_gid | sticky_bit.
|
||||||
|
unknown = 0xFFFF ///< not known, such as when a file_status object is created without specifying the permissions
|
||||||
|
};
|
||||||
//enum class copy_options;
|
//enum class copy_options;
|
||||||
//enum class directory_options;
|
//enum class directory_options;
|
||||||
|
|
||||||
// class filesystem_error;
|
|
||||||
enum class error { none = 0 }; // deprecate ??
|
|
||||||
|
|
||||||
struct attribute // deprecate ??
|
|
||||||
{
|
|
||||||
uintmax_t size {};
|
|
||||||
bool directory{};
|
|
||||||
tm modified {};
|
|
||||||
|
|
||||||
attribute() {} ;
|
|
||||||
attribute( uintmax_t size, bool is_directory) :size{size}, directory{is_directory} {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct space_info
|
struct space_info
|
||||||
{
|
{
|
||||||
uintmax_t capacity;
|
uintmax_t capacity;
|
||||||
uintmax_t free;
|
uintmax_t free;
|
||||||
uintmax_t available;
|
uintmax_t available;
|
||||||
};
|
};
|
||||||
using file_time_type = std::chrono::time_point< std::chrono::system_clock>;// trivial-clock> ;
|
|
||||||
|
|
||||||
class file_status
|
using file_time_type = std::chrono::time_point<std::chrono::system_clock>;// trivial-clock> ;
|
||||||
{
|
|
||||||
file_type m_ft = file_type::none;
|
|
||||||
perms m_prms = perms::unknown;
|
|
||||||
|
|
||||||
public:
|
class file_status
|
||||||
explicit file_status(file_type ft = file_type::none, perms prms = perms::unknown)
|
{
|
||||||
:m_ft{ft}, m_prms{prms}
|
file_type m_ft = file_type::none;
|
||||||
{}
|
perms m_prms = perms::unknown;
|
||||||
|
|
||||||
file_status(const file_status& fs) : m_ft{fs.m_ft}, m_prms{fs.m_prms}{} // = default;
|
public:
|
||||||
file_status(file_status&& fs) : m_ft{fs.m_ft}, m_prms{fs.m_prms}{} // = default;
|
explicit file_status(file_type ft = file_type::none, perms prms = perms::unknown);
|
||||||
|
|
||||||
~file_status(){};
|
// observers
|
||||||
file_status& operator=(const file_status&) = default;
|
file_type type() const;
|
||||||
file_status& operator=(file_status&&fs) // = default;
|
perms permissions() const;
|
||||||
{
|
|
||||||
m_ft=fs.m_ft; m_prms = fs.m_prms;
|
// modifiers
|
||||||
return *this;
|
void type(file_type ft);
|
||||||
}
|
void permissions(perms prms);
|
||||||
// observers
|
private:
|
||||||
file_type type() const { return m_ft;}
|
file_type value_;
|
||||||
perms permissions() const { return m_prms;}
|
perms perms_;
|
||||||
// modifiers
|
};
|
||||||
void type (file_type ft) { m_ft=ft ;}
|
|
||||||
void permissions(perms prms) { m_prms = prms; }
|
|
||||||
};
|
|
||||||
|
|
||||||
/// concerned only with lexical and syntactic aspects and does not necessarily exist in
|
/// concerned only with lexical and syntactic aspects and does not necessarily exist in
|
||||||
/// external storage, and the pathname is not necessarily valid for the current operating system
|
/// external storage, and the pathname is not necessarily valid for the current operating system
|
||||||
@@ -136,55 +108,118 @@ namespace filesystem
|
|||||||
class path
|
class path
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
path();
|
#if defined(NANA_WINDOWS)
|
||||||
path(const nana::string&);
|
using value_type = wchar_t;
|
||||||
|
const static value_type preferred_separator = '\\';
|
||||||
|
#else
|
||||||
|
using value_type = char;
|
||||||
|
const static value_type preferred_separator = '/';
|
||||||
|
#endif
|
||||||
|
using string_type = std::basic_string<value_type>;
|
||||||
|
|
||||||
|
path() = default;
|
||||||
|
|
||||||
|
template<typename Source>
|
||||||
|
path(const Source& source)
|
||||||
|
{
|
||||||
|
_m_assign(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int compare(const path& other) const;
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
path root() const;
|
path extension() const;
|
||||||
|
|
||||||
|
path parent_path() const;
|
||||||
file_type what() const;
|
file_type what() const;
|
||||||
|
|
||||||
nana::string filename() const;
|
//decomposition
|
||||||
#if defined(NANA_WINDOWS)
|
path filename() const;
|
||||||
public:
|
|
||||||
nana::string to_string() const { return text_; }
|
//modifiers
|
||||||
operator nana::string() const { return text_; }
|
path& remove_filename();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const value_type*c_str() const;
|
||||||
|
const string_type& native() const;
|
||||||
|
operator string_type() const;
|
||||||
|
|
||||||
|
std::string string() const;
|
||||||
|
std::wstring wstring() const;
|
||||||
|
std::string u8string() const;
|
||||||
|
|
||||||
|
//appends
|
||||||
|
path& operator/=(const path& other);
|
||||||
|
|
||||||
|
template<typename Source>
|
||||||
|
path& operator/=(const Source& source)
|
||||||
|
{
|
||||||
|
path other(source);
|
||||||
|
return this->operator/=(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Source>
|
||||||
|
path& append(const Source& source)
|
||||||
|
{
|
||||||
|
path other(source);
|
||||||
|
return this->operator/=(other);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
nana::string text_;
|
void _m_assign(const std::string& source_utf8);
|
||||||
#else
|
void _m_assign(const std::wstring& source);
|
||||||
public:
|
|
||||||
std::string to_string() const { return text_; }
|
|
||||||
operator std::string() const { return text_; }
|
|
||||||
private:
|
private:
|
||||||
std::string text_;
|
string_type pathstr_;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct directory_entry
|
bool operator==(const path& lhs, const path& rhs);
|
||||||
|
bool operator!=(const path& lhs, const path& rhs);
|
||||||
|
bool operator<(const path& lhs, const path& rhs);
|
||||||
|
bool operator>(const path& lhs, const path& rhs);
|
||||||
|
path operator/(const path& lhs, const path& rhs);
|
||||||
|
|
||||||
|
|
||||||
|
class filesystem_error
|
||||||
|
: public std::system_error
|
||||||
{
|
{
|
||||||
using path_type = filesystem::path;
|
public:
|
||||||
path_type m_path;
|
explicit filesystem_error(const std::string& msg, std::error_code);
|
||||||
|
|
||||||
attribute attr{};
|
filesystem_error(const std::string& msg, const path& path1, std::error_code err);
|
||||||
//file_status m_status;
|
filesystem_error(const std::string& msg, const path& path1, const path& path2, std::error_code err);
|
||||||
|
|
||||||
directory_entry(){}
|
const path& path1() const; //noexcept
|
||||||
directory_entry(const path_type& p, bool is_directory, uintmax_t size)
|
const path& path2() const; //noexcept
|
||||||
:m_path{p}, attr{size, is_directory}
|
private:
|
||||||
{}
|
path path1_;
|
||||||
|
path path2_;
|
||||||
|
};
|
||||||
|
|
||||||
void assign (const path_type& p){ m_path=p;}
|
|
||||||
void replace_filename(const path_type& p){ m_path=p;}
|
|
||||||
|
|
||||||
//file_status status() const;
|
class directory_entry
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
directory_entry() = default;
|
||||||
|
explicit directory_entry(const path&);
|
||||||
|
|
||||||
operator const path_type&() const {return m_path;};
|
//modifiers
|
||||||
const path_type& path() const {return m_path;}
|
void assign(const path&);
|
||||||
|
void replace_filename(const path&);
|
||||||
|
|
||||||
|
//observers
|
||||||
|
file_status status() const;
|
||||||
|
operator const filesystem::path&() const;
|
||||||
|
const filesystem::path& path() const;
|
||||||
|
private:
|
||||||
|
filesystem::path path_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// an iterator for a sequence of directory_entry elements representing the files in a directory, not an recursive_directory_iterator
|
/// an iterator for a sequence of directory_entry elements representing the files in a directory, not an recursive_directory_iterator
|
||||||
//template<typename FileInfo>
|
//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*;
|
||||||
public:
|
public:
|
||||||
using value_type = directory_entry ;
|
using value_type = directory_entry ;
|
||||||
typedef ptrdiff_t difference_type;
|
typedef ptrdiff_t difference_type;
|
||||||
@@ -192,37 +227,20 @@ namespace filesystem
|
|||||||
typedef const directory_entry& reference;
|
typedef const directory_entry& reference;
|
||||||
typedef std::input_iterator_tag iterator_category;
|
typedef std::input_iterator_tag iterator_category;
|
||||||
|
|
||||||
directory_iterator():end_(true), handle_(nullptr){}
|
directory_iterator();
|
||||||
|
directory_iterator(const path& file_path);
|
||||||
|
|
||||||
directory_iterator(const nana::string& file_path) { _m_prepare(file_path); }
|
const value_type& operator*() const;
|
||||||
directory_iterator(const path& file_path) { _m_prepare(file_path.filename()); }
|
const value_type* operator->() const;
|
||||||
|
|
||||||
const value_type&
|
directory_iterator& operator++();
|
||||||
operator*() const { return value_; }
|
directory_iterator operator++(int);
|
||||||
|
|
||||||
const value_type*
|
|
||||||
operator->() const { return &(operator*()); }
|
|
||||||
|
|
||||||
directory_iterator& operator++()
|
|
||||||
{ _m_read(); return *this; }
|
|
||||||
|
|
||||||
directory_iterator operator++(int)
|
|
||||||
{
|
|
||||||
directory_iterator tmp = *this;
|
|
||||||
_m_read();
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool equal(const directory_iterator& x) const
|
|
||||||
{
|
|
||||||
if(end_ && (end_ == x.end_)) return true;
|
|
||||||
return (value_.path().filename() == x.value_.path().filename());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bool equal(const directory_iterator& x) const;
|
||||||
|
|
||||||
// enable directory_iterator range-based for statements
|
// enable directory_iterator range-based for statements
|
||||||
directory_iterator begin( ) { return *this; }
|
directory_iterator begin();
|
||||||
directory_iterator end( ) { return {}; }
|
directory_iterator end();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename Char>
|
template<typename Char>
|
||||||
@@ -233,152 +251,14 @@ namespace filesystem
|
|||||||
return (*p == 0);
|
return (*p == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _m_prepare(const nana::string& file_path)
|
void _m_prepare(const path& file_path);
|
||||||
{
|
void _m_read();
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
path_ = file_path;
|
|
||||||
auto pat = file_path;
|
|
||||||
DWORD attr = ::GetFileAttributes(pat.data());
|
|
||||||
if((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY))
|
|
||||||
pat += STR("\\*");
|
|
||||||
|
|
||||||
::HANDLE handle = ::FindFirstFile(pat.data(), &wfd_);
|
|
||||||
|
|
||||||
if(handle == INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
end_ = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(_m_ignore(wfd_.cFileName))
|
|
||||||
{
|
|
||||||
if(::FindNextFile(handle, &wfd_) == 0)
|
|
||||||
{
|
|
||||||
end_ = true;
|
|
||||||
::FindClose(handle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
value_ = value_type(path(wfd_.cFileName),
|
|
||||||
(FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY,
|
|
||||||
wfd_.nFileSizeLow);
|
|
||||||
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
path_ = nana::charset(file_path);
|
|
||||||
if(path_.size() && (path_[path_.size() - 1] != '/'))
|
|
||||||
path_ += '/';
|
|
||||||
find_handle_t handle = opendir(path_.c_str());
|
|
||||||
end_ = true;
|
|
||||||
if(handle)
|
|
||||||
{
|
|
||||||
struct dirent * dnt = readdir(handle);
|
|
||||||
if(dnt)
|
|
||||||
{
|
|
||||||
while(_m_ignore(dnt->d_name))
|
|
||||||
{
|
|
||||||
dnt = readdir(handle);
|
|
||||||
if(dnt == 0)
|
|
||||||
{
|
|
||||||
closedir(handle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct stat fst;
|
|
||||||
bool is_directory = false;
|
|
||||||
unsigned size = 0;
|
|
||||||
if(stat((path_ + dnt->d_name).c_str(), &fst) == 0)
|
|
||||||
{
|
|
||||||
is_directory = (0 != S_ISDIR(fst.st_mode));
|
|
||||||
size = fst.st_size;
|
|
||||||
}
|
|
||||||
value_ = value_type(static_cast<nana::string>(nana::charset(dnt->d_name)), is_directory, size);
|
|
||||||
end_ = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if(false == end_)
|
|
||||||
{
|
|
||||||
find_ptr_ = std::shared_ptr<find_handle_t>(new find_handle_t(handle), inner_handle_deleter());
|
|
||||||
handle_ = handle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _m_read()
|
|
||||||
{
|
|
||||||
if(handle_)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
if(::FindNextFile(handle_, &wfd_) != 0)
|
|
||||||
{
|
|
||||||
while(_m_ignore(wfd_.cFileName))
|
|
||||||
{
|
|
||||||
if(::FindNextFile(handle_, &wfd_) == 0)
|
|
||||||
{
|
|
||||||
end_ = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
value_ = value_type(path(wfd_.cFileName),
|
|
||||||
(FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY,
|
|
||||||
wfd_.nFileSizeLow);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
end_ = true;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
struct dirent * dnt = readdir(handle_);
|
|
||||||
if(dnt)
|
|
||||||
{
|
|
||||||
while(_m_ignore(dnt->d_name))
|
|
||||||
{
|
|
||||||
dnt = readdir(handle_);
|
|
||||||
if(dnt == 0)
|
|
||||||
{
|
|
||||||
end_ = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nana::string d_name = nana::charset(dnt->d_name);
|
|
||||||
struct stat fst;
|
|
||||||
if(stat((path_ + "/" + dnt->d_name).c_str(), &fst) == 0)
|
|
||||||
value_ = value_type(std::move(d_name), (0 != S_ISDIR(fst.st_mode)), fst.st_size);
|
|
||||||
else
|
|
||||||
value_.m_path = path(std::move(d_name));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
end_ = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
struct inner_handle_deleter
|
|
||||||
{
|
|
||||||
void operator()(find_handle_t * handle)
|
|
||||||
{
|
|
||||||
if(handle && *handle)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
::FindClose(*handle);
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
::closedir(*handle);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
delete handle;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private:
|
private:
|
||||||
bool end_{false};
|
bool end_{false};
|
||||||
|
path::string_type path_;
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
std::shared_ptr<find_handle> find_ptr_;
|
||||||
WIN32_FIND_DATA wfd_;
|
find_handle handle_{nullptr};
|
||||||
nana::string path_;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
std::string path_;
|
|
||||||
#endif
|
|
||||||
std::shared_ptr<find_handle_t> find_ptr_;
|
|
||||||
find_handle_t handle_{nullptr};
|
|
||||||
value_type value_;
|
value_type value_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -401,68 +281,89 @@ namespace filesystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// file_status status(const path& p);
|
file_status status(const path& p);
|
||||||
bool file_attrib(const nana::string& file, attribute&);
|
file_status status(const path& p, std::error_code&);
|
||||||
|
|
||||||
|
std::uintmax_t file_size(const path& p);
|
||||||
|
//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) { return s.type() == file_type::directory ;}
|
||||||
inline bool is_directory(const path& p) { return directory_iterator(p)->attr.directory; }//works??
|
bool is_directory(const path& p);
|
||||||
inline bool is_directory(const directory_entry& d) { return d.attr.directory; }
|
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;
|
//bool is_regular_file(file_status s) noexcept;
|
||||||
|
|
||||||
inline bool is_empty(const path& p)
|
inline bool is_empty(const path& p)
|
||||||
{
|
{
|
||||||
directory_iterator d(p) ;
|
auto fs = status(p);
|
||||||
return d->attr.directory ? d == directory_iterator()
|
|
||||||
: d->attr.size == 0;
|
if (is_directory(fs))
|
||||||
|
return (directory_iterator() == directory_iterator(p));
|
||||||
|
|
||||||
|
return (file_size(p) == 0);
|
||||||
}
|
}
|
||||||
//bool is_empty(const path& p, error_code& ec) noexcept;
|
//bool is_empty(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
uintmax_t file_size(const nana::string& file); // deprecate?
|
|
||||||
inline uintmax_t file_size(const path& p){return file_size(p.filename());}
|
bool create_directories(const path& p);
|
||||||
//uintmax_t file_size(const path& p, error_code& ec) noexcept;
|
//bool create_directories(const path& p, error_code& ec) noexcept;
|
||||||
//long long filesize(const nana::string& file);
|
bool create_directory(const path& p);
|
||||||
|
//bool create_directory(const path& p, error_code& ec) noexcept;
|
||||||
|
bool create_directory(const path& p, const path& attributes);
|
||||||
|
//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();
|
||||||
|
|
||||||
|
path current_path();
|
||||||
|
//path current_path(error_code& ec);
|
||||||
|
void current_path(const path& p);
|
||||||
|
//void current_path(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
|
|
||||||
bool create_directories(const path& p);
|
bool remove(const path& p);
|
||||||
//bool create_directories(const path& p, error_code& ec) noexcept;
|
bool remove(const path& p, std::error_code& ec); // noexcept;
|
||||||
bool create_directory(const path& p);
|
|
||||||
//bool create_directory(const path& p, error_code& ec) noexcept;
|
|
||||||
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 nana::string& dir, bool & if_exist);
|
|
||||||
inline bool create_directory(const path& p, bool & if_exist)
|
|
||||||
{
|
|
||||||
return create_directory(p.filename(), if_exist);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
//uintmax_t remove_all(const path& p);
|
||||||
|
//uintmax_t remove_all(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
bool modified_file_time(const nana::string& file, struct tm&);
|
template<typename CharType>
|
||||||
|
std::basic_string<CharType> parent_path(const std::basic_string<CharType>& path)
|
||||||
|
{
|
||||||
|
auto index = path.size();
|
||||||
|
|
||||||
|
if (index)
|
||||||
|
{
|
||||||
|
auto str = path.c_str();
|
||||||
|
|
||||||
nana::string path_user();
|
for (--index; index > 0; --index)
|
||||||
|
{
|
||||||
|
auto c = str[index];
|
||||||
|
if (c != '\\' && c != '/')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (--index; index > 0; --index)
|
||||||
|
{
|
||||||
|
auto c = str[index];
|
||||||
|
if (c == '\\' || c == '/')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
path current_path();
|
return index ? path.substr(0, index + 1) : std::basic_string<CharType>();
|
||||||
//path current_path(error_code& ec);
|
}
|
||||||
void current_path(const path& p);
|
|
||||||
//void current_path(const path& p, error_code& ec) noexcept;
|
|
||||||
//nana::string path_current();
|
|
||||||
|
|
||||||
|
|
||||||
//bool remove(const path& p);
|
|
||||||
//bool remove(const path& p, error_code& ec) noexcept;
|
|
||||||
bool rmfile(const nana::char_t* file);
|
|
||||||
|
|
||||||
//uintmax_t remove_all(const path& p);
|
|
||||||
//uintmax_t remove_all(const path& p, error_code& ec) noexcept;
|
|
||||||
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty);
|
|
||||||
nana::string root(const nana::string& path);
|
|
||||||
|
|
||||||
|
|
||||||
}//end namespace filesystem
|
}//end namespace filesystem
|
||||||
} //end namespace experimental
|
} //end namespace experimental
|
||||||
|
|
||||||
|
namespace filesystem = experimental::filesystem;
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
|
|
||||||
#ifndef NANA_FILESYSTEM_FS_UTILITY_HPP
|
|
||||||
#define NANA_FILESYSTEM_FS_UTILITY_HPP
|
|
||||||
|
|
||||||
#include <nana/deploy.hpp>
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
namespace nana
|
|
||||||
{
|
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
struct error
|
|
||||||
{
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
none = 0
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct attribute
|
|
||||||
{
|
|
||||||
long long bytes;
|
|
||||||
bool is_directory;
|
|
||||||
tm modified;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool file_attrib(const nana::string& file, attribute&);
|
|
||||||
long long filesize(const nana::string& file);
|
|
||||||
|
|
||||||
bool mkdir(const nana::string& dir, bool & if_exist);
|
|
||||||
bool modified_file_time(const nana::string& file, struct tm&);
|
|
||||||
|
|
||||||
nana::string path_user();
|
|
||||||
nana::string path_current();
|
|
||||||
|
|
||||||
bool rmfile(const nana::char_t* file);
|
|
||||||
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty);
|
|
||||||
nana::string root(const nana::string& path);
|
|
||||||
|
|
||||||
class path
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct type
|
|
||||||
{ enum{not_exist, file, directory};
|
|
||||||
};
|
|
||||||
|
|
||||||
path();
|
|
||||||
path(const nana::string&);
|
|
||||||
|
|
||||||
bool empty() const;
|
|
||||||
path root() const;
|
|
||||||
int what() const;
|
|
||||||
|
|
||||||
nana::string name() const;
|
|
||||||
private:
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
nana::string text_;
|
|
||||||
#else
|
|
||||||
std::string text_;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
}//end namespace filesystem
|
|
||||||
}//end namespace nana
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Forward Declarations
|
* Forward Declarations
|
||||||
* 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-2015 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
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* 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-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
|
||||||
@@ -145,7 +145,7 @@ namespace detail
|
|||||||
basic_window *parent;
|
basic_window *parent;
|
||||||
basic_window *owner;
|
basic_window *owner;
|
||||||
|
|
||||||
::nana::string 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
|
||||||
@@ -167,7 +167,8 @@ namespace detail
|
|||||||
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
|
||||||
unsigned Reserved :19;
|
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 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;
|
||||||
}flags;
|
}flags;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Definition of General Events
|
* Definition of General Events
|
||||||
* 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
|
||||||
@@ -111,7 +111,7 @@ namespace nana
|
|||||||
evt_->deleted_flags_ = false;
|
evt_->deleted_flags_ = false;
|
||||||
for (auto i = evt_->dockers_->begin(); i != evt_->dockers_->end();)
|
for (auto i = evt_->dockers_->begin(); i != evt_->dockers_->end();)
|
||||||
{
|
{
|
||||||
if (i->get()->flag_deleted)
|
if (static_cast<docker*>(i->get())->flag_deleted)
|
||||||
i = evt_->dockers_->erase(i);
|
i = evt_->dockers_->erase(i);
|
||||||
else
|
else
|
||||||
++i;
|
++i;
|
||||||
@@ -128,11 +128,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
if (nullptr == dockers_)
|
if (nullptr == dockers_)
|
||||||
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
|
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<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
||||||
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
|
auto evt = reinterpret_cast<event_handle>(dck.get());
|
||||||
dockers_->emplace(dockers_->begin(), std::move(dck));
|
dockers_->emplace(dockers_->begin(), std::move(dck));
|
||||||
detail::events_operation_register(evt);
|
detail::events_operation_register(evt);
|
||||||
return evt;
|
return evt;
|
||||||
@@ -151,11 +151,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
if (nullptr == dockers_)
|
if (nullptr == dockers_)
|
||||||
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
|
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<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
||||||
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
|
auto evt = reinterpret_cast<event_handle>(dck.get());
|
||||||
dockers_->emplace_back(std::move(dck));
|
dockers_->emplace_back(std::move(dck));
|
||||||
detail::events_operation_register(evt);
|
detail::events_operation_register(evt);
|
||||||
return evt;
|
return evt;
|
||||||
@@ -174,11 +174,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
if (nullptr == dockers_)
|
if (nullptr == dockers_)
|
||||||
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
|
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<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), true));
|
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>(static_cast<detail::docker_interface*>(dck.get()));
|
auto evt = reinterpret_cast<event_handle>(dck.get());
|
||||||
if (in_front)
|
if (in_front)
|
||||||
dockers_->emplace(dockers_->begin(), std::move(dck));
|
dockers_->emplace(dockers_->begin(), std::move(dck));
|
||||||
else
|
else
|
||||||
@@ -208,7 +208,7 @@ namespace nana
|
|||||||
//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)
|
for (std::size_t pos = 0; pos < dockers_len; ++pos)
|
||||||
{
|
{
|
||||||
auto docker_ptr = dockers[pos].get();
|
auto docker_ptr = static_cast<docker*>(dockers[pos].get());
|
||||||
if (docker_ptr->flag_deleted)
|
if (docker_ptr->flag_deleted)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
for (++pos; pos < dockers_len; ++pos)
|
for (++pos; pos < dockers_len; ++pos)
|
||||||
{
|
{
|
||||||
auto docker_ptr = dockers[pos].get();
|
auto docker_ptr = static_cast<docker*>(dockers[pos].get());
|
||||||
if (!docker_ptr->unignorable || docker_ptr->flag_deleted)
|
if (!docker_ptr->unignorable || docker_ptr->flag_deleted)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ namespace nana
|
|||||||
//Checks whether this event is working now.
|
//Checks whether this event is working now.
|
||||||
if (emitting_count_ > 1)
|
if (emitting_count_ > 1)
|
||||||
{
|
{
|
||||||
i->get()->flag_deleted = true;
|
static_cast<docker*>(i->get())->flag_deleted = true;
|
||||||
deleted_flags_ = true;
|
deleted_flags_ = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -416,7 +416,7 @@ namespace nana
|
|||||||
private:
|
private:
|
||||||
unsigned emitting_count_{ 0 };
|
unsigned emitting_count_{ 0 };
|
||||||
bool deleted_flags_{ false };
|
bool deleted_flags_{ false };
|
||||||
std::unique_ptr<std::vector<std::unique_ptr<docker>>> dockers_;
|
std::unique_ptr<std::vector<std::unique_ptr<detail::docker_interface>>> dockers_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct arg_mouse
|
struct arg_mouse
|
||||||
@@ -460,7 +460,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
::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
|
||||||
std::vector<nana::string> files; ///< external filenames
|
std::vector<std::string> files; ///< external filenames
|
||||||
};
|
};
|
||||||
|
|
||||||
struct arg_expose : public event_arg
|
struct arg_expose : public event_arg
|
||||||
@@ -480,7 +480,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 nana::char_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 not used
|
||||||
bool ctrl; ///< keyboard Ctrl is pressed?
|
bool ctrl; ///< keyboard Ctrl is pressed?
|
||||||
bool shift; ///< keyboard Shift is pressed
|
bool shift; ///< keyboard Shift is pressed
|
||||||
@@ -528,7 +528,7 @@ namespace nana
|
|||||||
/// provides some fundamental events that every widget owns.
|
/// provides some fundamental events that every widget owns.
|
||||||
struct general_events
|
struct general_events
|
||||||
{
|
{
|
||||||
virtual ~general_events(){}
|
virtual ~general_events() = default;
|
||||||
basic_event<arg_mouse> mouse_enter; ///< the cursor enters the window
|
basic_event<arg_mouse> mouse_enter; ///< the cursor enters the window
|
||||||
basic_event<arg_mouse> mouse_move; ///< the cursor moves on the window
|
basic_event<arg_mouse> mouse_move; ///< the cursor moves on the window
|
||||||
basic_event<arg_mouse> mouse_leave; ///< the cursor leaves the window
|
basic_event<arg_mouse> mouse_leave; ///< the cursor leaves the window
|
||||||
|
|||||||
@@ -119,8 +119,9 @@ namespace nana{
|
|||||||
|
|
||||||
struct condition_tag
|
struct condition_tag
|
||||||
{
|
{
|
||||||
core_window_t* pressed{nullptr}; //The handle to a window which is being pressed
|
core_window_t* pressed{nullptr}; //The handle to a window which has been pressed by pressing left button of mouse.
|
||||||
core_window_t* hovered{nullptr}; //the latest window that mouse moved
|
core_window_t* pressed_by_space{ nullptr }; //The handle to a window which has been pressed by pressing spacebar.
|
||||||
|
core_window_t* hovered{nullptr}; //the latest window that mouse moved
|
||||||
}condition;
|
}condition;
|
||||||
|
|
||||||
root_misc(core_window_t * wd, unsigned width, unsigned height)
|
root_misc(core_window_t * wd, unsigned width, unsigned height)
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ namespace detail
|
|||||||
unsigned extra_height; //extra border size, it is useful in Windows, ignore in X11 always 0
|
unsigned extra_height; //extra border size, it is useful in Windows, ignore in X11 always 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using native_string_type = ::nana::detail::native_string_type;
|
||||||
|
|
||||||
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&);
|
||||||
@@ -65,15 +67,17 @@ namespace detail
|
|||||||
|
|
||||||
static void window_size(native_window_type, const size&);
|
static void window_size(native_window_type, const size&);
|
||||||
static void get_window_rect(native_window_type, rectangle&);
|
static void get_window_rect(native_window_type, rectangle&);
|
||||||
static void window_caption(native_window_type, const nana::string&);
|
static void window_caption(native_window_type, const native_string_type&);
|
||||||
static nana::string window_caption(native_window_type);
|
static native_string_type window_caption(native_window_type);
|
||||||
static void capture_window(native_window_type, bool);
|
static void capture_window(native_window_type, bool);
|
||||||
static nana::point cursor_position();
|
static nana::point cursor_position();
|
||||||
static native_window_type get_owner_window(native_window_type);
|
static native_window_type get_owner_window(native_window_type);
|
||||||
|
static native_window_type parent_window(native_window_type);
|
||||||
|
static native_window_type parent_window(native_window_type child, native_window_type new_parent, bool returns_previous);
|
||||||
//For Caret
|
//For Caret
|
||||||
static void caret_create(native_window_type, const ::nana::size&);
|
static void caret_create(native_window_type, const ::nana::size&);
|
||||||
static void caret_destroy(native_window_type);
|
static void caret_destroy(native_window_type);
|
||||||
static void caret_pos(native_window_type, const ::nana::point&);
|
static void caret_pos(native_window_type, const ::nana::point&);
|
||||||
static void caret_visible(native_window_type, bool);
|
static void caret_visible(native_window_type, bool);
|
||||||
|
|
||||||
static void set_focus(native_window_type);
|
static void set_focus(native_window_type);
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ namespace nana
|
|||||||
|
|
||||||
virtual widget* widget_ptr() const = 0;
|
virtual widget* widget_ptr() const = 0;
|
||||||
virtual void destroy() = 0;
|
virtual void destroy() = 0;
|
||||||
virtual std::wstring caption() = 0;
|
virtual ::nana::detail::native_string_type caption() = 0;
|
||||||
virtual void caption(std::wstring) = 0;
|
virtual void caption(::nana::detail::native_string_type) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* A Dragger Implementation
|
||||||
|
* 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/gui/dragger.hpp
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef NANA_GUI_DRAGGER_HPP
|
#ifndef NANA_GUI_DRAGGER_HPP
|
||||||
#define NANA_GUI_DRAGGER_HPP
|
#define NANA_GUI_DRAGGER_HPP
|
||||||
#include "programming_interface.hpp"
|
#include "basis.hpp"
|
||||||
|
#include "../basic_types.hpp"
|
||||||
|
#include "../traits.hpp"
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -18,6 +32,10 @@ namespace nana
|
|||||||
public:
|
public:
|
||||||
dragger();
|
dragger();
|
||||||
~dragger();
|
~dragger();
|
||||||
|
|
||||||
|
dragger(dragger&&);
|
||||||
|
dragger& operator=(dragger&&);
|
||||||
|
|
||||||
void target(window);
|
void target(window);
|
||||||
void target(window, const rectangle& restrict_area, nana::arrange);
|
void target(window, const rectangle& restrict_area, nana::arrange);
|
||||||
void remove_target(window);
|
void remove_target(window);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Filebox
|
* Filebox
|
||||||
* 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,7 +25,7 @@ namespace nana
|
|||||||
filebox(filebox&&) = delete;
|
filebox(filebox&&) = delete;
|
||||||
filebox& operator=(filebox&&) = delete;
|
filebox& operator=(filebox&&) = delete;
|
||||||
public:
|
public:
|
||||||
using filters = std::vector<std::pair<nana::string, nana::string>>;
|
using filters = std::vector<std::pair< ::std::string, ::std::string>>;
|
||||||
|
|
||||||
filebox(bool is_open_mode);
|
filebox(bool is_open_mode);
|
||||||
filebox(window owner, bool is_open_mode);
|
filebox(window owner, bool is_open_mode);
|
||||||
@@ -37,21 +37,21 @@ namespace nana
|
|||||||
/// Change owner window
|
/// Change owner window
|
||||||
void owner(window);
|
void owner(window);
|
||||||
|
|
||||||
/** @brief specify a title for the dialog
|
/// specify a title for the dialog
|
||||||
* @param string a text for title
|
/// @param string a text for title
|
||||||
*/
|
/// @return old title.
|
||||||
nana::string title( nana::string new_title); ///< . Set a new title for the dialog and \return the old title
|
::std::string title( ::std::string new_title); ///< . Set a new title for the dialog and \return the old title
|
||||||
|
|
||||||
/** @brief specify a suggestion directory
|
/** @brief specify a suggestion directory
|
||||||
* @param string a path of initial directory
|
* @param string 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 nana::string&); ///< Suggested init path used to locate a directory when the filebox starts.
|
filebox& init_path(const ::std::string&); ///< Suggested init path used to locate a directory when the filebox starts.
|
||||||
filebox& init_file(const nana::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 nana::string& description, ///< for example. "Text File"
|
filebox& add_filter(const ::std::string& description, ///< for example. "Text File"
|
||||||
const nana::string& filetype ///< filter pattern(for example, "*.TXT")
|
const ::std::string& filetype ///< filter pattern(for example, "*.TXT")
|
||||||
);
|
);
|
||||||
|
|
||||||
filebox& add_filter(const filters &ftres)
|
filebox& add_filter(const filters &ftres)
|
||||||
@@ -62,16 +62,14 @@ namespace nana
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
nana::string path() const;
|
::std::string path() const;
|
||||||
nana::string file() const;
|
::std::string file() const;
|
||||||
|
|
||||||
/** @brief Display the filebox dialog
|
/// Display the filebox dialog
|
||||||
*/
|
|
||||||
bool show() const;
|
bool show() const;
|
||||||
|
|
||||||
/** @brief Display the filebox dialog
|
/// Display the filebox dialog
|
||||||
* @note A function object method alternative to show()
|
/// A function object method alternative to show()
|
||||||
*/
|
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
return show();
|
return show();
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ namespace nana
|
|||||||
msgbox& operator=(const msgbox&);
|
msgbox& operator=(const msgbox&);
|
||||||
|
|
||||||
/// Construct that creates a message box with a specified title and default button.
|
/// Construct that creates a message box with a specified title and default button.
|
||||||
msgbox(const nana::string&);
|
msgbox(const ::std::string&);
|
||||||
|
|
||||||
/// Construct that creates a message box with an owner windoow, a specified title and buttons.
|
/// Construct that creates a message box with an owner windoow, a specified title and buttons.
|
||||||
msgbox(window, const nana::string&, button_t = ok);
|
msgbox(window, const ::std::string&, button_t = ok);
|
||||||
|
|
||||||
/// Sets an icon for informing user.
|
/// Sets an icon for informing user.
|
||||||
msgbox& icon(icon_t);
|
msgbox& icon(icon_t);
|
||||||
@@ -55,10 +55,10 @@ namespace nana
|
|||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
/// Writes a string to the buffer.
|
/// Writes a string to the buffer.
|
||||||
msgbox & operator<<(const nana::string&);
|
msgbox & operator<<(const std::wstring&);
|
||||||
|
|
||||||
/// Writes a string to the buffer.
|
/// Writes a string to the buffer.
|
||||||
msgbox & operator<<(const nana::char_t*);
|
msgbox & operator<<(const wchar_t*);
|
||||||
|
|
||||||
/// Writes a string to the buffer.
|
/// Writes a string to the buffer.
|
||||||
msgbox & operator<<(const nana::charset&);
|
msgbox & operator<<(const nana::charset&);
|
||||||
@@ -86,7 +86,7 @@ namespace nana
|
|||||||
private:
|
private:
|
||||||
std::stringstream sstream_;
|
std::stringstream sstream_;
|
||||||
window wd_;
|
window wd_;
|
||||||
nana::string title_;
|
std::string title_;
|
||||||
button_t button_;
|
button_t button_;
|
||||||
icon_t icon_;
|
icon_t icon_;
|
||||||
};
|
};
|
||||||
@@ -97,7 +97,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
virtual ~abstract_content() = default;
|
virtual ~abstract_content() = default;
|
||||||
|
|
||||||
virtual const ::nana::string& label() const = 0;
|
virtual const ::std::string& label() const = 0;
|
||||||
virtual window create(window, unsigned label_px) = 0;
|
virtual window create(window, unsigned label_px) = 0;
|
||||||
virtual unsigned fixed_pixels() const;
|
virtual unsigned fixed_pixels() const;
|
||||||
};
|
};
|
||||||
@@ -107,13 +107,13 @@ namespace nana
|
|||||||
{
|
{
|
||||||
struct implement;
|
struct implement;
|
||||||
public:
|
public:
|
||||||
integer(::nana::string label, int init_value, int begin, int last, int step);
|
integer(::std::string label, int init_value, int begin, int last, int step);
|
||||||
~integer();
|
~integer();
|
||||||
|
|
||||||
int value() const;
|
int value() const;
|
||||||
private:
|
private:
|
||||||
//Implementation of abstract_content
|
//Implementation of abstract_content
|
||||||
const ::nana::string& label() const override;
|
const ::std::string& label() const override;
|
||||||
window create(window, unsigned label_px) override;
|
window create(window, unsigned label_px) override;
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<implement> impl_;
|
std::unique_ptr<implement> impl_;
|
||||||
@@ -124,13 +124,13 @@ namespace nana
|
|||||||
{
|
{
|
||||||
struct implement;
|
struct implement;
|
||||||
public:
|
public:
|
||||||
real(::nana::string label, double init_value, double begin, double last, double step);
|
real(::std::string label, double init_value, double begin, double last, double step);
|
||||||
~real();
|
~real();
|
||||||
|
|
||||||
double value() const;
|
double value() const;
|
||||||
private:
|
private:
|
||||||
//Implementation of abstract_content
|
//Implementation of abstract_content
|
||||||
const ::nana::string& label() const override;
|
const ::std::string& label() const override;
|
||||||
window create(window, unsigned label_px) override;
|
window create(window, unsigned label_px) override;
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<implement> impl_;
|
std::unique_ptr<implement> impl_;
|
||||||
@@ -144,8 +144,8 @@ namespace nana
|
|||||||
text(const text&) = delete;
|
text(const text&) = delete;
|
||||||
text& operator=(const text&) = delete;
|
text& operator=(const text&) = delete;
|
||||||
public:
|
public:
|
||||||
text(::nana::string label, ::nana::string init_text = ::nana::string());
|
text(::std::string label, ::std::string init_text = ::std::string());
|
||||||
text(::nana::string label, std::vector<::nana::string>);
|
text(::std::string label, std::vector<::std::string>);
|
||||||
|
|
||||||
~text();
|
~text();
|
||||||
|
|
||||||
@@ -154,10 +154,10 @@ namespace nana
|
|||||||
|
|
||||||
void mask_character(wchar_t ch);
|
void mask_character(wchar_t ch);
|
||||||
|
|
||||||
::nana::string value() const;
|
::std::string value() const;
|
||||||
private:
|
private:
|
||||||
//Implementation of abstract_content
|
//Implementation of abstract_content
|
||||||
const ::nana::string& label() const override;
|
const ::std::string& label() const override;
|
||||||
window create(window, unsigned label_px) override;
|
window create(window, unsigned label_px) override;
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<implement> impl_;
|
std::unique_ptr<implement> impl_;
|
||||||
@@ -168,17 +168,17 @@ namespace nana
|
|||||||
{
|
{
|
||||||
struct implement;
|
struct implement;
|
||||||
public:
|
public:
|
||||||
date(::nana::string label);
|
date(::std::string label);
|
||||||
|
|
||||||
~date();
|
~date();
|
||||||
|
|
||||||
::nana::string value() const;
|
::std::string value() const;
|
||||||
int year() const;
|
int year() const;
|
||||||
int month() const; //[1, 12]
|
int month() const; //[1, 12]
|
||||||
int day() const; //[1, 31]
|
int day() const; //[1, 31]
|
||||||
private:
|
private:
|
||||||
//Implementation of abstract_content
|
//Implementation of abstract_content
|
||||||
const ::nana::string& label() const override;
|
const ::std::string& label() const override;
|
||||||
window create(window, unsigned label_px) override;
|
window create(window, unsigned label_px) override;
|
||||||
unsigned fixed_pixels() const override;
|
unsigned fixed_pixels() const override;
|
||||||
private:
|
private:
|
||||||
@@ -190,19 +190,19 @@ namespace nana
|
|||||||
{
|
{
|
||||||
struct implement;
|
struct implement;
|
||||||
public:
|
public:
|
||||||
path(::nana::string label, const ::nana::filebox&);
|
path(::std::string label, const ::nana::filebox&);
|
||||||
~path();
|
~path();
|
||||||
|
|
||||||
::nana::string value() const;
|
::std::string value() const;
|
||||||
private:
|
private:
|
||||||
//Implementation of abstract_content
|
//Implementation of abstract_content
|
||||||
const ::nana::string& label() const override;
|
const ::std::string& label() const override;
|
||||||
window create(window, unsigned label_px) override;
|
window create(window, unsigned label_px) override;
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<implement> impl_;
|
std::unique_ptr<implement> impl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
inputbox(window, ::nana::string description, ::nana::string title = ::nana::string());
|
inputbox(window, ::std::string description, ::std::string title = ::std::string());
|
||||||
|
|
||||||
void image(::nana::paint::image, bool is_left, const rectangle& valid_area = {});
|
void image(::nana::paint::image, bool is_left, const rectangle& valid_area = {});
|
||||||
void image_v(::nana::paint::image, bool is_top, const rectangle& valid_area = {});
|
void image_v(::nana::paint::image, bool is_top, const rectangle& valid_area = {});
|
||||||
@@ -246,8 +246,8 @@ namespace nana
|
|||||||
bool _m_open(std::vector<abstract_content*>&, bool modal);
|
bool _m_open(std::vector<abstract_content*>&, bool modal);
|
||||||
private:
|
private:
|
||||||
window owner_;
|
window owner_;
|
||||||
::nana::string description_;
|
::std::string description_;
|
||||||
::nana::string title_;
|
::std::string title_;
|
||||||
std::function<bool(window)> verifier_;
|
std::function<bool(window)> verifier_;
|
||||||
::nana::paint::image images_[4];
|
::nana::paint::image images_[4];
|
||||||
::nana::rectangle valid_areas_[4];
|
::nana::rectangle valid_areas_[4];
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ namespace nana
|
|||||||
notifier(window);
|
notifier(window);
|
||||||
~notifier();
|
~notifier();
|
||||||
void close();
|
void close();
|
||||||
void text(const nana::string&);
|
void text(const ::std::string&);
|
||||||
void icon(const nana::string& icon_file);
|
void icon(const ::std::string& icon_file);
|
||||||
void insert_icon(const nana::string& icon_file);
|
void insert_icon(const ::std::string& icon_file);
|
||||||
void period(unsigned millisecond);
|
void period(unsigned millisecond);
|
||||||
detail::notifier_events& events();
|
detail::notifier_events& events();
|
||||||
window handle() const;
|
window handle() const;
|
||||||
|
|||||||
@@ -42,13 +42,17 @@ namespace nana
|
|||||||
: init_(std::move(initializer))
|
: init_(std::move(initializer))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
agent(const nana::char_t* text)
|
agent(const char* text)
|
||||||
: text_(text)
|
: text_(text)
|
||||||
{}
|
{
|
||||||
|
throw_not_utf8(text);
|
||||||
|
}
|
||||||
|
|
||||||
agent(nana::string text, std::function<void(Widget&)> initializer = {})
|
agent(std::string text, std::function<void(Widget&)> initializer = {})
|
||||||
: text_(std::move(text)), init_(std::move(initializer))
|
: text_(std::move(text)), init_(std::move(initializer))
|
||||||
{}
|
{
|
||||||
|
throw_not_utf8(text_);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<nana::widget> create(nana::window handle) const override
|
std::unique_ptr<nana::widget> create(nana::window handle) const override
|
||||||
@@ -60,7 +64,7 @@ namespace nana
|
|||||||
return std::move(ptr);
|
return std::move(ptr);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
nana::string text_;
|
std::string text_;
|
||||||
std::function<void(Widget&)> init_;
|
std::function<void(Widget&)> init_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -79,8 +83,8 @@ namespace nana
|
|||||||
public:
|
public:
|
||||||
field_interface() = default;
|
field_interface() = default;
|
||||||
virtual ~field_interface() = default;
|
virtual ~field_interface() = default;
|
||||||
virtual field_interface& operator<<(const nana::char_t* label) = 0;
|
virtual field_interface& operator<<(const char* label) = 0;
|
||||||
virtual field_interface& operator<<(nana::string label) = 0;
|
virtual field_interface& operator<<(std::string label) = 0;
|
||||||
virtual field_interface& operator<<(window) = 0;
|
virtual field_interface& operator<<(window) = 0;
|
||||||
virtual field_interface& fasten(window) = 0;
|
virtual field_interface& fasten(window) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Nana GUI Programming Interface Implementation
|
* Nana GUI Programming Interface 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
|
||||||
@@ -72,8 +72,8 @@ namespace API
|
|||||||
widget_colors* get_scheme(window);
|
widget_colors* get_scheme(window);
|
||||||
|
|
||||||
void attach_drawer(widget&, drawer_trigger&);
|
void attach_drawer(widget&, drawer_trigger&);
|
||||||
nana::string window_caption(window) throw();
|
::nana::detail::native_string_type window_caption(window) throw();
|
||||||
void window_caption(window, nana::string);
|
void window_caption(window, ::nana::detail::native_string_type);
|
||||||
|
|
||||||
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);
|
||||||
@@ -83,6 +83,11 @@ namespace API
|
|||||||
paint::graphics* window_graphics(window);
|
paint::graphics* window_graphics(window);
|
||||||
|
|
||||||
void delay_restore(bool);
|
void delay_restore(bool);
|
||||||
|
|
||||||
|
void register_menu_window(window, bool has_keyboard);
|
||||||
|
void set_menubar(window wd, bool attach);
|
||||||
|
|
||||||
|
void enable_space_click(window, bool enable);
|
||||||
}//end namespace dev
|
}//end namespace dev
|
||||||
|
|
||||||
|
|
||||||
@@ -140,7 +145,7 @@ namespace API
|
|||||||
|
|
||||||
void exit();
|
void exit();
|
||||||
|
|
||||||
nana::string transform_shortkey_text(nana::string text, nana::string::value_type &shortkey, nana::string::size_type *skpos);
|
std::string transform_shortkey_text(std::string text, wchar_t &shortkey, std::string::size_type *skpos);
|
||||||
bool register_shortkey(window, unsigned long);
|
bool register_shortkey(window, unsigned long);
|
||||||
void unregister_shortkey(window);
|
void unregister_shortkey(window);
|
||||||
|
|
||||||
@@ -271,8 +276,8 @@ namespace API
|
|||||||
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.
|
||||||
|
|
||||||
void window_caption(window, const std::string& title_utf8);
|
void window_caption(window, const std::string& title_utf8);
|
||||||
void window_caption(window, const nana::string& title);
|
void window_caption(window, const std::wstring& title);
|
||||||
nana::string window_caption(window);
|
::std::string window_caption(window);
|
||||||
|
|
||||||
void window_cursor(window, cursor);
|
void window_cursor(window, cursor);
|
||||||
cursor window_cursor(window);
|
cursor window_cursor(window);
|
||||||
@@ -310,9 +315,6 @@ namespace API
|
|||||||
void eat_tabstop(window, bool);
|
void eat_tabstop(window, bool);
|
||||||
window move_tabstop(window, bool next); ///< Sets the focus to the window which tabstop is near to the specified window.
|
window move_tabstop(window, bool next); ///< Sets the focus to the window which tabstop is near to the specified window.
|
||||||
|
|
||||||
bool glass_window(window); /// \deprecated
|
|
||||||
bool glass_window(window, bool); /// \deprecated
|
|
||||||
|
|
||||||
/// 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);
|
||||||
|
|
||||||
@@ -328,10 +330,6 @@ namespace API
|
|||||||
|
|
||||||
window find_window(const nana::point& mspos);
|
window find_window(const nana::point& mspos);
|
||||||
|
|
||||||
void register_menu_window(window, bool has_keyboard);
|
|
||||||
bool attach_menubar(window menubar);
|
|
||||||
void detach_menubar(window menubar);
|
|
||||||
|
|
||||||
bool is_window_zoomed(window, bool ask_for_max); ///<Tests a window whether it is maximized or minimized.
|
bool is_window_zoomed(window, bool ask_for_max); ///<Tests a window whether it is maximized or minimized.
|
||||||
|
|
||||||
void widget_borderless(window, bool); ///<Enables or disables a borderless widget.
|
void widget_borderless(window, bool); ///<Enables or disables a borderless widget.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* A Tooltip Implementation
|
* A Tooltip 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
|
||||||
@@ -24,7 +24,7 @@ namespace nana
|
|||||||
|
|
||||||
virtual bool tooltip_empty() const = 0;
|
virtual bool tooltip_empty() const = 0;
|
||||||
virtual nana::size tooltip_size() const = 0;
|
virtual nana::size tooltip_size() const = 0;
|
||||||
virtual void tooltip_text(const nana::string&) = 0;
|
virtual void tooltip_text(const ::std::string&) = 0;
|
||||||
virtual void tooltip_move(const nana::point& screen_pos, bool ignore_pos) = 0;
|
virtual void tooltip_move(const nana::point& screen_pos, bool ignore_pos) = 0;
|
||||||
virtual void duration(std::size_t) = 0;
|
virtual void duration(std::size_t) = 0;
|
||||||
};
|
};
|
||||||
@@ -63,11 +63,11 @@ namespace nana
|
|||||||
}
|
}
|
||||||
|
|
||||||
tooltip(){}
|
tooltip(){}
|
||||||
tooltip(window w, const nana::string &tip){set(w,tip);}
|
tooltip(window w, const ::std::string &tip){set(w,tip);}
|
||||||
|
|
||||||
|
|
||||||
static void set(window, const nana::string&);
|
static void set(window, const ::std::string&);
|
||||||
static void show(window, point pos, const nana::string&, std::size_t duration);
|
static void show(window, point pos, const ::std::string&, std::size_t duration);
|
||||||
static void close();
|
static void close();
|
||||||
private:
|
private:
|
||||||
static void _m_hold_factory(factory_interface*);
|
static void _m_hold_factory(factory_interface*);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A Button Implementation
|
* A Button 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
|
||||||
@@ -43,9 +43,7 @@ namespace nana{
|
|||||||
void mouse_leave(graph_reference, const arg_mouse&) override;
|
void mouse_leave(graph_reference, const arg_mouse&) 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;
|
||||||
void key_char(graph_reference, const arg_keyboard&) override;
|
|
||||||
void key_press(graph_reference, const arg_keyboard&) override;
|
void key_press(graph_reference, const arg_keyboard&) override;
|
||||||
void key_release(graph_reference, const arg_keyboard&) override;
|
|
||||||
void focus(graph_reference, const arg_focus&) override;
|
void focus(graph_reference, const arg_focus&) override;
|
||||||
private:
|
private:
|
||||||
void _m_draw_title(graph_reference, bool enabled);
|
void _m_draw_title(graph_reference, bool enabled);
|
||||||
@@ -83,8 +81,8 @@ namespace nana{
|
|||||||
public:
|
public:
|
||||||
button();
|
button();
|
||||||
button(window, bool visible);
|
button(window, bool visible);
|
||||||
button(window, const nana::string& caption, bool visible = true);
|
button(window, const ::std::string& caption, bool visible = true);
|
||||||
button(window, const nana::char_t* caption, bool visible = true);
|
button(window, const char* caption, bool visible = true);
|
||||||
button(window, const nana::rectangle& = rectangle(), bool visible = true);
|
button(window, const nana::rectangle& = rectangle(), bool visible = true);
|
||||||
|
|
||||||
button& icon(const nana::paint::image&);
|
button& icon(const nana::paint::image&);
|
||||||
@@ -104,7 +102,7 @@ namespace nana{
|
|||||||
private:
|
private:
|
||||||
//Overrides widget virtual functions
|
//Overrides widget virtual functions
|
||||||
void _m_complete_creation() override;
|
void _m_complete_creation() override;
|
||||||
void _m_caption(nana::string&&) override;
|
void _m_caption(native_string_type&&) override;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A Categorize Implementation
|
* A Categorize 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
|
||||||
@@ -62,7 +62,7 @@ namespace nana
|
|||||||
|
|
||||||
void selected(::nana::any & var)
|
void selected(::nana::any & var)
|
||||||
{
|
{
|
||||||
auto vp = var.get<T>();
|
auto vp = any_cast<T>(&var);
|
||||||
|
|
||||||
T null_val;
|
T null_val;
|
||||||
arg_categorize<T> arg(widget_, vp ? *vp : null_val);
|
arg_categorize<T> arg(widget_, vp ? *vp : null_val);
|
||||||
@@ -94,7 +94,7 @@ namespace nana
|
|||||||
virtual ~renderer() = 0;
|
virtual ~renderer() = 0;
|
||||||
virtual void background(graph_reference, window wd, const nana::rectangle&, const ui_element&) = 0;
|
virtual void background(graph_reference, window wd, const nana::rectangle&, const ui_element&) = 0;
|
||||||
virtual void root_arrow(graph_reference, const nana::rectangle&, mouse_action) = 0;
|
virtual void root_arrow(graph_reference, const nana::rectangle&, mouse_action) = 0;
|
||||||
virtual void item(graph_reference, const nana::rectangle&, std::size_t index, const nana::string& name, unsigned textheight, bool has_child, mouse_action) = 0;
|
virtual void item(graph_reference, const nana::rectangle&, std::size_t index, const ::std::string& name, unsigned textheight, bool has_child, mouse_action) = 0;
|
||||||
virtual void border(graph_reference) = 0;
|
virtual void border(graph_reference) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -108,18 +108,18 @@ namespace nana
|
|||||||
trigger();
|
trigger();
|
||||||
~trigger();
|
~trigger();
|
||||||
|
|
||||||
void insert(const nana::string&, nana::any);
|
void insert(const ::std::string&, nana::any);
|
||||||
bool childset(const nana::string&, nana::any);
|
bool childset(const ::std::string&, nana::any);
|
||||||
bool childset_erase(const nana::string&);
|
bool childset_erase(const ::std::string&);
|
||||||
bool clear();
|
bool clear();
|
||||||
|
|
||||||
//splitstr
|
//splitstr
|
||||||
//@brief: Sets the splitstr. If the parameter will be ingored if it is an empty string.
|
//@brief: Sets the splitstr. If the parameter will be ingored if it is an empty string.
|
||||||
void splitstr(const nana::string&);
|
void splitstr(const ::std::string&);
|
||||||
const nana::string& splitstr() const;
|
const ::std::string& splitstr() const;
|
||||||
|
|
||||||
void path(const nana::string&);
|
void path(const ::std::string&);
|
||||||
nana::string path() const;
|
::std::string path() const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void create_event_agent(::nana::categorize<T>& wdg)
|
void create_event_agent(::nana::categorize<T>& wdg)
|
||||||
@@ -155,8 +155,9 @@ namespace nana
|
|||||||
: public widget_object<category::widget_tag, drawerbase::categorize::trigger, drawerbase::categorize::categorize_events<T>>
|
: public widget_object<category::widget_tag, drawerbase::categorize::trigger, drawerbase::categorize::categorize_events<T>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef T value_type; ///< The type of objects stored
|
using native_string_type = widget::native_string_type;
|
||||||
typedef drawerbase::categorize::renderer renderer; ///< The interface for user-defined renderer.
|
using value_type = T; ///< The type of objects stored
|
||||||
|
using renderer = drawerbase::categorize::renderer; ///< The interface for user-defined renderer.
|
||||||
|
|
||||||
categorize()
|
categorize()
|
||||||
{
|
{
|
||||||
@@ -174,13 +175,25 @@ namespace nana
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
categorize(window wd, const nana::string& text, bool visible = true)
|
categorize(window wd, const std::string& text_utf8, bool visible = true)
|
||||||
|
: categorize(wd, ::nana::rectangle(), visible)
|
||||||
|
{
|
||||||
|
this->caption(text_utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
categorize(window wd, const char* text_utf8, bool visible = true)
|
||||||
|
: categorize(wd, ::nana::rectangle(), visible)
|
||||||
|
{
|
||||||
|
this->caption(text_utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
categorize(window wd, const std::wstring& text, bool visible = true)
|
||||||
: categorize(wd, ::nana::rectangle(), visible)
|
: categorize(wd, ::nana::rectangle(), visible)
|
||||||
{
|
{
|
||||||
this->caption(text);
|
this->caption(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
categorize(window wd, const nana::char_t* text, bool visible = true)
|
categorize(window wd, const wchar_t* text, bool visible = true)
|
||||||
: categorize(wd, ::nana::rectangle(), visible)
|
: categorize(wd, ::nana::rectangle(), visible)
|
||||||
{
|
{
|
||||||
this->caption(text);
|
this->caption(text);
|
||||||
@@ -189,7 +202,7 @@ namespace nana
|
|||||||
/// Insert a new category with a specified name and the object of value type.
|
/// Insert a new category with a specified name and the object of value type.
|
||||||
/// The new category would be inserted as a child in current category,
|
/// The new category would be inserted as a child in current category,
|
||||||
/// and after inserting, the new category is replaced of the current category as a new current one.
|
/// and after inserting, the new category is replaced of the current category as a new current one.
|
||||||
categorize& insert(const nana::string& name, const value_type& value)
|
categorize& insert(const std::string& name, const value_type& value)
|
||||||
{
|
{
|
||||||
this->get_drawer_trigger().insert(name, value);
|
this->get_drawer_trigger().insert(name, value);
|
||||||
API::update_window(*this);
|
API::update_window(*this);
|
||||||
@@ -197,15 +210,16 @@ namespace nana
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts a child category into current category.
|
/// Inserts a child category into current category.
|
||||||
categorize& childset(const nana::string& name, const value_type& value)
|
categorize& childset(const std::string& name, const value_type& value)
|
||||||
{
|
{
|
||||||
|
throw_not_utf8(name);
|
||||||
if(this->get_drawer_trigger().childset(name, value))
|
if(this->get_drawer_trigger().childset(name, value))
|
||||||
API::update_window(*this);
|
API::update_window(*this);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Erases a child category with a specified name from current category.
|
/// Erases a child category with a specified name from current category.
|
||||||
categorize& childset_erase(const nana::string& name)
|
categorize& childset_erase(const std::string& name)
|
||||||
{
|
{
|
||||||
if(this->get_drawer_trigger().childset_erase(name))
|
if(this->get_drawer_trigger().childset_erase(name))
|
||||||
API::update_window(*this);
|
API::update_window(*this);
|
||||||
@@ -219,13 +233,13 @@ namespace nana
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the splitter string
|
/// Sets the splitter string
|
||||||
categorize& splitstr(const nana::string& sstr)
|
categorize& splitstr(const std::string& sstr)
|
||||||
{
|
{
|
||||||
this->get_drawer_trigger().splitstr(sstr);
|
this->get_drawer_trigger().splitstr(sstr);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
nana::string splitstr() const
|
std::string splitstr() const
|
||||||
{
|
{
|
||||||
return this->get_drawer_trigger().splitstr();
|
return this->get_drawer_trigger().splitstr();
|
||||||
}
|
}
|
||||||
@@ -237,10 +251,10 @@ namespace nana
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
//Overrides widget's virtual functions
|
//Overrides widget's virtual functions
|
||||||
void _m_caption(nana::string&& str) override
|
void _m_caption(native_string_type&& str) override
|
||||||
{
|
{
|
||||||
this->get_drawer_trigger().path(str);
|
this->get_drawer_trigger().path(to_utf8(str));
|
||||||
API::dev::window_caption(*this, this->get_drawer_trigger().path());
|
API::dev::window_caption(*this, to_nstring(this->get_drawer_trigger().path()) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A CheckBox Implementation
|
* A CheckBox 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
|
||||||
@@ -17,10 +17,30 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace nana {
|
namespace nana {
|
||||||
|
|
||||||
|
//forward-declaration
|
||||||
|
class checkbox;
|
||||||
|
|
||||||
|
struct arg_checkbox
|
||||||
|
: public event_arg
|
||||||
|
{
|
||||||
|
checkbox * const widget;
|
||||||
|
|
||||||
|
arg_checkbox(checkbox* wdg)
|
||||||
|
: widget(wdg)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
namespace drawerbase
|
namespace drawerbase
|
||||||
{
|
{
|
||||||
namespace checkbox
|
namespace checkbox
|
||||||
{
|
{
|
||||||
|
struct events_type
|
||||||
|
: public general_events
|
||||||
|
{
|
||||||
|
basic_event<arg_checkbox> checked;
|
||||||
|
};
|
||||||
|
|
||||||
class drawer
|
class drawer
|
||||||
: public drawer_trigger
|
: public drawer_trigger
|
||||||
{
|
{
|
||||||
@@ -36,14 +56,8 @@ namespace drawerbase
|
|||||||
void mouse_up(graph_reference, const arg_mouse&) override;
|
void mouse_up(graph_reference, const arg_mouse&) override;
|
||||||
public:
|
public:
|
||||||
implement * impl() const;
|
implement * impl() const;
|
||||||
private:
|
|
||||||
void _m_draw_background(graph_reference);
|
|
||||||
void _m_draw_checkbox(graph_reference, unsigned first_line_height);
|
|
||||||
void _m_draw_title(graph_reference);
|
|
||||||
private:
|
private:
|
||||||
static const int interval = 4;
|
static const int interval = 4;
|
||||||
widget* widget_;
|
|
||||||
std::unique_ptr<implement> imptr_;
|
|
||||||
implement * impl_;
|
implement * impl_;
|
||||||
};
|
};
|
||||||
}//end namespace checkbox
|
}//end namespace checkbox
|
||||||
@@ -51,13 +65,13 @@ namespace drawerbase
|
|||||||
|
|
||||||
|
|
||||||
class checkbox
|
class checkbox
|
||||||
: public widget_object<category::widget_tag, drawerbase::checkbox::drawer>
|
: public widget_object<category::widget_tag, drawerbase::checkbox::drawer, drawerbase::checkbox::events_type>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
checkbox();
|
checkbox();
|
||||||
checkbox(window, bool visible);
|
checkbox(window, bool visible);
|
||||||
checkbox(window, const nana::string& text, bool visible = true);
|
checkbox(window, const std::string& text, bool visible = true);
|
||||||
checkbox(window, const nana::char_t* text, bool visible = true);
|
checkbox(window, const char* text, bool visible = true);
|
||||||
checkbox(window, const rectangle& = rectangle(), bool visible = true);
|
checkbox(window, const rectangle& = rectangle(), bool visible = true);
|
||||||
|
|
||||||
void element_set(const char* name);
|
void element_set(const char* name);
|
||||||
@@ -81,6 +95,7 @@ namespace drawerbase
|
|||||||
checkbox * uiobj;
|
checkbox * uiobj;
|
||||||
event_handle eh_checked;
|
event_handle eh_checked;
|
||||||
event_handle eh_destroy;
|
event_handle eh_destroy;
|
||||||
|
event_handle eh_keyboard;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
~radio_group();
|
~radio_group();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A Combox Implementation
|
* A Combox 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
|
||||||
@@ -75,8 +75,8 @@ namespace nana
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
item_proxy(drawer_impl*, std::size_t pos);
|
item_proxy(drawer_impl*, std::size_t pos);
|
||||||
item_proxy& text(const nana::string&);
|
item_proxy& text(const ::std::string&);
|
||||||
nana::string text() const;
|
::std::string text() const;
|
||||||
item_proxy& select();
|
item_proxy& select();
|
||||||
bool selected() const;
|
bool selected() const;
|
||||||
item_proxy& icon(const nana::paint::image&);
|
item_proxy& icon(const nana::paint::image&);
|
||||||
@@ -85,8 +85,7 @@ namespace nana
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
T * value_ptr() const
|
T * value_ptr() const
|
||||||
{
|
{
|
||||||
auto p = _m_anyobj(false);
|
return any_cast<T>(_m_anyobj(false));
|
||||||
return (p ? p->get<T>() : nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -96,7 +95,7 @@ namespace nana
|
|||||||
if (nullptr == pany)
|
if (nullptr == pany)
|
||||||
throw std::runtime_error("combox::item_proxy.value<T>() is empty");
|
throw std::runtime_error("combox::item_proxy.value<T>() is empty");
|
||||||
|
|
||||||
T * p = pany->get<T>();
|
T * p = any_cast<T>(pany);
|
||||||
if (nullptr == p)
|
if (nullptr == p)
|
||||||
throw std::runtime_error("combox::item_proxy.value<T>() invalid type of value");
|
throw std::runtime_error("combox::item_proxy.value<T>() invalid type of value");
|
||||||
return *p;
|
return *p;
|
||||||
@@ -112,14 +111,13 @@ namespace nana
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
item_proxy& value(T&& t)
|
item_proxy& value(T&& t)
|
||||||
{
|
{
|
||||||
*_m_anyobj(true) = std::move(t);
|
*_m_anyobj(true) = ::std::move(t);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
/// Behavior of Iterator's value_type
|
/// Behavior of Iterator's value_type
|
||||||
bool operator==(const nana::string&) const;
|
bool operator==(const ::std::string&) const;
|
||||||
bool operator==(const char*) const;
|
bool operator==(const char*) const;
|
||||||
bool operator==(const wchar_t*) const;
|
|
||||||
|
|
||||||
/// Behavior of Iterator
|
/// Behavior of Iterator
|
||||||
item_proxy & operator=(const item_proxy&);
|
item_proxy & operator=(const item_proxy&);
|
||||||
@@ -166,19 +164,19 @@ namespace nana
|
|||||||
|
|
||||||
combox();
|
combox();
|
||||||
combox(window, bool visible);
|
combox(window, bool visible);
|
||||||
combox(window, nana::string, bool visible = true);
|
combox(window, ::std::string, bool visible = true);
|
||||||
combox(window, const nana::char_t*, bool visible = true);
|
combox(window, const char*, bool visible = true);
|
||||||
combox(window, const rectangle& r = rectangle(), bool visible = true);
|
combox(window, const rectangle& r = rectangle(), bool visible = true);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void editable(bool);
|
void editable(bool);
|
||||||
bool editable() const;
|
bool editable() const;
|
||||||
void set_accept(std::function<bool(nana::char_t)>);
|
void set_accept(std::function<bool(wchar_t)>);
|
||||||
combox& push_back(nana::string);
|
combox& push_back(std::string);
|
||||||
std::size_t the_number_of_options() const;
|
std::size_t the_number_of_options() const;
|
||||||
std::size_t option() const; ///< Index of the last selected, from drop-down list, item.
|
std::size_t option() const; ///< Index of the last selected, from drop-down list, item.
|
||||||
void option(std::size_t); ///< Select the text specified by index
|
void option(std::size_t); ///< Select the text specified by index
|
||||||
nana::string text(std::size_t) const;
|
::std::string text(std::size_t) const;
|
||||||
void erase(std::size_t pos);
|
void erase(std::size_t pos);
|
||||||
|
|
||||||
template<typename Key>
|
template<typename Key>
|
||||||
@@ -224,8 +222,8 @@ namespace nana
|
|||||||
const drawerbase::combox::drawer_impl& _m_impl() const;
|
const drawerbase::combox::drawer_impl& _m_impl() const;
|
||||||
private:
|
private:
|
||||||
//Overrides widget's virtual functions
|
//Overrides widget's virtual functions
|
||||||
nana::string _m_caption() const throw() override;
|
native_string_type _m_caption() const throw() override;
|
||||||
void _m_caption(nana::string&&) override;
|
void _m_caption(native_string_type&&) override;
|
||||||
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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ namespace nana
|
|||||||
trigger();
|
trigger();
|
||||||
bool chose() const;
|
bool chose() const;
|
||||||
nana::date read() const;
|
nana::date read() const;
|
||||||
void week_name(unsigned index, const nana::string&);
|
void week_name(unsigned index, const std::string&);
|
||||||
private:
|
private:
|
||||||
where _m_pos_where(graph_reference, const ::nana::point& pos);
|
where _m_pos_where(graph_reference, const ::nana::point& pos);
|
||||||
void _m_draw_topbar(graph_reference);
|
void _m_draw_topbar(graph_reference);
|
||||||
void _m_make_drawing_basis(drawing_basis&, graph_reference, const nana::point& refpos);
|
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 nana::string&, bool primary, bool sel);
|
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_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_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_days(const nana::point& refpos, graph_reference);
|
||||||
@@ -61,7 +61,7 @@ namespace nana
|
|||||||
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;
|
||||||
private:
|
private:
|
||||||
nana::string weekstr_[7];
|
::std::string weekstr_[7];
|
||||||
|
|
||||||
widget * widget_;
|
widget * widget_;
|
||||||
|
|
||||||
@@ -105,13 +105,13 @@ namespace nana
|
|||||||
public:
|
public:
|
||||||
date_chooser();
|
date_chooser();
|
||||||
date_chooser(window, bool visible);
|
date_chooser(window, bool visible);
|
||||||
date_chooser(window, const nana::string& text, bool visible = true);
|
date_chooser(window, const ::std::string& text, bool visible = true);
|
||||||
date_chooser(window, const nana::char_t* 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 nana::string&);///<Set the week strings which will be displayed for day, index is in range of [0, 6]
|
void weekstr(unsigned index, const ::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
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* A Tree Container class implementation
|
* A Tree Container class 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
|
||||||
@@ -22,7 +22,7 @@ namespace detail
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
struct tree_node
|
struct tree_node
|
||||||
{
|
{
|
||||||
typedef std::pair<nana::string, T> value_type;
|
typedef std::pair<std::string, T> value_type;
|
||||||
|
|
||||||
value_type value;
|
value_type value;
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ namespace detail
|
|||||||
return (verify(node) && (node->owner != &root_) ? node->owner : nullptr);
|
return (verify(node) && (node->owner != &root_) ? node->owner : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
node_type * node(node_type* node, const nana::string& key)
|
node_type * node(node_type* node, const std::string& key)
|
||||||
{
|
{
|
||||||
if(node)
|
if(node)
|
||||||
{
|
{
|
||||||
@@ -121,7 +121,7 @@ namespace detail
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
node_type* insert(node_type* node, const nana::string& key, const element_type& elem)
|
node_type* insert(node_type* node, const std::string& key, const element_type& elem)
|
||||||
{
|
{
|
||||||
if(nullptr == node)
|
if(nullptr == node)
|
||||||
return insert(key, elem);
|
return insert(key, elem);
|
||||||
@@ -159,7 +159,7 @@ namespace detail
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
node_type* insert(const nana::string& key, const element_type& elem)
|
node_type* insert(const std::string& key, const element_type& elem)
|
||||||
{
|
{
|
||||||
auto node = _m_locate<true>(key);
|
auto node = _m_locate<true>(key);
|
||||||
if(node)
|
if(node)
|
||||||
@@ -173,12 +173,12 @@ namespace detail
|
|||||||
delete node;
|
delete node;
|
||||||
}
|
}
|
||||||
|
|
||||||
node_type* find(const nana::string& path) const
|
node_type* find(const std::string& path) const
|
||||||
{
|
{
|
||||||
return _m_locate(path);
|
return _m_locate(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
node_type* ref(const nana::string& path)
|
node_type* ref(const std::string& path)
|
||||||
{
|
{
|
||||||
return _m_locate<true>(path);
|
return _m_locate<true>(path);
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename PredAllowChild>
|
template<typename PredAllowChild>
|
||||||
unsigned child_size_if(const nana::string& key, PredAllowChild pac) const
|
unsigned child_size_if(const ::std::string& key, PredAllowChild pac) const
|
||||||
{
|
{
|
||||||
auto node = _m_locate(key);
|
auto node = _m_locate(key);
|
||||||
return (node ? child_size_if<PredAllowChild>(*node, pac) : 0);
|
return (node ? child_size_if<PredAllowChild>(*node, pac) : 0);
|
||||||
@@ -392,7 +392,7 @@ namespace detail
|
|||||||
:node(&(self.root_))
|
:node(&(self.root_))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool operator()(const nana::string& key_node)
|
bool operator()(const ::std::string& key_node)
|
||||||
{
|
{
|
||||||
node_type *child = node->child;
|
node_type *child = node->child;
|
||||||
node_type *tail = nullptr;
|
node_type *tail = nullptr;
|
||||||
@@ -428,7 +428,7 @@ namespace detail
|
|||||||
:node(&self.root_)
|
:node(&self.root_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool operator()(const nana::string& key_node)
|
bool operator()(const ::std::string& key_node)
|
||||||
{
|
{
|
||||||
return ((node = _m_find(node->child, key_node)) != nullptr);
|
return ((node = _m_find(node->child, key_node)) != nullptr);
|
||||||
}
|
}
|
||||||
@@ -436,7 +436,7 @@ namespace detail
|
|||||||
node_type *node;
|
node_type *node;
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
static node_type* _m_find(node_type* node, const nana::string& key_node)
|
static node_type* _m_find(node_type* node, const ::std::string& key_node)
|
||||||
{
|
{
|
||||||
while(node)
|
while(node)
|
||||||
{
|
{
|
||||||
@@ -449,14 +449,14 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Function>
|
template<typename Function>
|
||||||
void _m_for_each(const nana::string& key, Function function) const
|
void _m_for_each(const ::std::string& key, Function function) const
|
||||||
{
|
{
|
||||||
if(key.size())
|
if(key.size())
|
||||||
{
|
{
|
||||||
nana::string::size_type beg = 0;
|
::std::string::size_type beg = 0;
|
||||||
auto end = key.find_first_of(STR("\\/"));
|
auto end = key.find_first_of("\\/");
|
||||||
|
|
||||||
while(end != nana::string::npos)
|
while(end != ::std::string::npos)
|
||||||
{
|
{
|
||||||
if(beg != end)
|
if(beg != end)
|
||||||
{
|
{
|
||||||
@@ -464,11 +464,11 @@ namespace detail
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto next = key.find_first_not_of(STR("\\/"), end);
|
auto next = key.find_first_not_of("\\/", end);
|
||||||
if(next != nana::string::npos)
|
if(next != ::std::string::npos)
|
||||||
{
|
{
|
||||||
beg = next;
|
beg = next;
|
||||||
end = key.find_first_of(STR("\\/"), beg);
|
end = key.find_first_of("\\/", beg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
@@ -479,7 +479,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<bool CreateIfNotExists>
|
template<bool CreateIfNotExists>
|
||||||
node_type* _m_locate(const nana::string& key)
|
node_type* _m_locate(const ::std::string& key)
|
||||||
{
|
{
|
||||||
if(key.size())
|
if(key.size())
|
||||||
{
|
{
|
||||||
@@ -499,7 +499,7 @@ namespace detail
|
|||||||
return &root_;
|
return &root_;
|
||||||
}
|
}
|
||||||
|
|
||||||
node_type* _m_locate(const nana::string& key) const
|
node_type* _m_locate(const std::string& key) const
|
||||||
{
|
{
|
||||||
if(key.size())
|
if(key.size())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace nana
|
|||||||
virtual ~item_interface(){}
|
virtual ~item_interface(){}
|
||||||
|
|
||||||
virtual const nana::paint::image & image() const = 0;
|
virtual const nana::paint::image & image() const = 0;
|
||||||
virtual const nana::char_t* text() const = 0;
|
virtual const char* text() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
//struct module_def
|
//struct module_def
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace nana{
|
|||||||
/// The construction that creates the widget and set the titel or caption
|
/// The construction that creates the widget and set the titel or caption
|
||||||
|
|
||||||
group(window parent, ///< a handle to the parent
|
group(window parent, ///< a handle to the parent
|
||||||
::nana::string titel, ///< caption of the group
|
::std::string titel, ///< caption of the group
|
||||||
bool formatted = false, ///< Enable/disable the formatted text for the title
|
bool formatted = false, ///< Enable/disable the formatted text for the title
|
||||||
unsigned gap = 2, ///< betwen the content and the external limit
|
unsigned gap = 2, ///< betwen the content and the external limit
|
||||||
const rectangle& r = {} ,
|
const rectangle& r = {} ,
|
||||||
@@ -49,7 +49,7 @@ namespace nana{
|
|||||||
~group();
|
~group();
|
||||||
|
|
||||||
/// Adds an option for user selection
|
/// Adds an option for user selection
|
||||||
group& add_option(::nana::string);
|
group& add_option(::std::string);
|
||||||
|
|
||||||
/// Enables/disables the radio mode which is single selection
|
/// Enables/disables the radio mode which is single selection
|
||||||
group& radio_mode(bool);
|
group& radio_mode(bool);
|
||||||
@@ -77,8 +77,8 @@ namespace nana{
|
|||||||
void _m_add_child(const char* field, widget*);
|
void _m_add_child(const char* field, widget*);
|
||||||
void _m_init();
|
void _m_init();
|
||||||
void _m_complete_creation() override;
|
void _m_complete_creation() override;
|
||||||
::nana::string _m_caption() const throw() override;
|
native_string_type _m_caption() const throw() override;
|
||||||
void _m_caption(::nana::string&&) override;
|
void _m_caption(native_string_type&&) override;
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<implement> impl_;
|
std::unique_ptr<implement> impl_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,26 +57,27 @@ namespace nana
|
|||||||
typedef drawerbase::label::command command;
|
typedef drawerbase::label::command command;
|
||||||
label();
|
label();
|
||||||
label(window, bool visible);
|
label(window, bool visible);
|
||||||
label(window, const nana::string& text, bool visible = true);
|
label(window, const std::string& text, bool visible = true);
|
||||||
label(window parent, const nana::char_t* text, bool visible = true) :label(parent, nana::string(text),visible) {};
|
label(window parent, const char* text, bool visible = true) :label(parent, std::string(text),visible) {};
|
||||||
label(window, const rectangle& = {}, bool visible = true);
|
label(window, const rectangle& = {}, bool visible = true);
|
||||||
label& transparent(bool); ///< Switchs the label widget to the transparent background mode.
|
label& transparent(bool); ///< Switchs the label widget to the transparent background mode.
|
||||||
bool transparent() const throw();
|
bool transparent() const throw();
|
||||||
label& format(bool); ///< Switches the format mode of the widget.
|
label& format(bool); ///< Switches the format mode of the widget.
|
||||||
label& add_format_listener(std::function<void(command, const nana::string&)>);
|
label& add_format_listener(std::function<void(command, const std::string&)>);
|
||||||
|
|
||||||
label& click_for(window associated_window) throw(); // as same as the "for" attribute of a label
|
/// as same as the HTML "for" attribute of a label
|
||||||
|
label& click_for(window associated_window) throw();
|
||||||
|
|
||||||
/// Returns the size of the text. If *allowed_width_in_pixel* is not zero, returns a
|
/// Returns the size of the text. If *allowed_width_in_pixel* is not zero, returns a
|
||||||
/// "corrected" size that changes lines to fit the text into the specified width
|
/// "corrected" size that changes lines to fit the text into the specified width
|
||||||
nana::size measure(unsigned allowed_width_in_pixel) const;
|
nana::size measure(unsigned allowed_width_in_pixel) const;
|
||||||
|
|
||||||
static ::nana::size measure(::nana::paint::graphics&, const ::nana::string&, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align);
|
static ::nana::size measure(::nana::paint::graphics&, const ::std::string&, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align);
|
||||||
|
|
||||||
label& text_align(align horizontal_align, align_v vertical_align= align_v::top);
|
label& text_align(align horizontal_align, align_v vertical_align= align_v::top);
|
||||||
private:
|
private:
|
||||||
//Overrides widget's virtual function
|
//Overrides widget's virtual function
|
||||||
void _m_caption(nana::string&&) override;
|
void _m_caption(native_string_type&&) override;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* A List Box Implementation
|
* A List Box 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/widgets/listbox.hpp
|
* @file: nana/gui/widgets/listbox.hpp
|
||||||
* @contributors: Ariel Vina-Rodriguez
|
* @contributors:
|
||||||
*
|
* Hiroshi Seki
|
||||||
|
* Ariel Vina-Rodriguez
|
||||||
|
* leobackes
|
||||||
|
* Benjamin Navarro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NANA_GUI_WIDGETS_LISTBOX_HPP
|
#ifndef NANA_GUI_WIDGETS_LISTBOX_HPP
|
||||||
@@ -31,6 +34,7 @@ namespace nana
|
|||||||
namespace listbox
|
namespace listbox
|
||||||
{
|
{
|
||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
|
using native_string_type = ::nana::detail::native_string_type;
|
||||||
|
|
||||||
/// usefull for both absolute and display (sorted) positions
|
/// usefull for both absolute and display (sorted) positions
|
||||||
struct index_pair
|
struct index_pair
|
||||||
@@ -81,7 +85,7 @@ namespace nana
|
|||||||
|
|
||||||
using selection = std::vector<index_pair>;
|
using selection = std::vector<index_pair>;
|
||||||
|
|
||||||
using inline_notifier_interface = detail::inline_widget_notifier_interface<index_pair, std::wstring>;
|
using inline_notifier_interface = detail::inline_widget_notifier_interface<index_pair, std::string>;
|
||||||
|
|
||||||
struct cell
|
struct cell
|
||||||
{
|
{
|
||||||
@@ -94,17 +98,17 @@ namespace nana
|
|||||||
format(const ::nana::color& bgcolor, const ::nana::color& fgcolor);
|
format(const ::nana::color& bgcolor, const ::nana::color& fgcolor);
|
||||||
};
|
};
|
||||||
|
|
||||||
using format_ptr = std::unique_ptr < format > ;
|
using format_ptr = ::std::unique_ptr<format>;
|
||||||
|
|
||||||
::nana::string text;
|
::std::string text;
|
||||||
format_ptr custom_format;
|
format_ptr custom_format;
|
||||||
|
|
||||||
cell() = default;
|
cell() = default;
|
||||||
cell(const cell&);
|
cell(const cell&);
|
||||||
cell(cell&&);
|
cell(cell&&);
|
||||||
cell(nana::string);
|
cell(::std::string);
|
||||||
cell(nana::string, const format&);
|
cell(::std::string, const format&);
|
||||||
cell(nana::string, const ::nana::color& bgcolor, const ::nana::color& fgcolor);
|
cell(::std::string, const ::nana::color& bgcolor, const ::nana::color& fgcolor);
|
||||||
|
|
||||||
cell& operator=(const cell&);
|
cell& operator=(const cell&);
|
||||||
cell& operator=(cell&&);
|
cell& operator=(cell&&);
|
||||||
@@ -126,9 +130,9 @@ namespace nana
|
|||||||
oresolver& operator<<(double);
|
oresolver& operator<<(double);
|
||||||
oresolver& operator<<(long double);
|
oresolver& operator<<(long double);
|
||||||
|
|
||||||
oresolver& operator<<(const char*);
|
oresolver& operator<<(const char* text_utf8);
|
||||||
oresolver& operator<<(const wchar_t*);
|
oresolver& operator<<(const wchar_t*);
|
||||||
oresolver& operator<<(const std::string&);
|
oresolver& operator<<(const std::string& text_utf8);
|
||||||
oresolver& operator<<(const std::wstring&);
|
oresolver& operator<<(const std::wstring&);
|
||||||
oresolver& operator<<(std::wstring&&);
|
oresolver& operator<<(std::wstring&&);
|
||||||
oresolver& operator<<(cell);
|
oresolver& operator<<(cell);
|
||||||
@@ -157,7 +161,7 @@ namespace nana
|
|||||||
iresolver& operator>>(double&);
|
iresolver& operator>>(double&);
|
||||||
iresolver& operator>>(long double&);
|
iresolver& operator>>(long double&);
|
||||||
|
|
||||||
iresolver& operator>>(std::string&);
|
iresolver& operator>>(std::string& text_utf8);
|
||||||
iresolver& operator>>(std::wstring&);
|
iresolver& operator>>(std::wstring&);
|
||||||
iresolver& operator>>(cell&);
|
iresolver& operator>>(cell&);
|
||||||
iresolver& operator>>(std::nullptr_t);
|
iresolver& operator>>(std::nullptr_t);
|
||||||
@@ -241,8 +245,9 @@ namespace nana
|
|||||||
size_type columns() const;
|
size_type columns() const;
|
||||||
|
|
||||||
item_proxy& text(size_type col, cell);
|
item_proxy& text(size_type col, cell);
|
||||||
item_proxy& text(size_type col, nana::string);
|
item_proxy& text(size_type col, std::string);
|
||||||
nana::string text(size_type col) const;
|
item_proxy& text(size_type col, std::wstring);
|
||||||
|
std::string text(size_type col) const;
|
||||||
|
|
||||||
void icon(const nana::paint::image&);
|
void icon(const nana::paint::image&);
|
||||||
|
|
||||||
@@ -257,7 +262,7 @@ namespace nana
|
|||||||
for (auto pos = 0u; pos < cols; ++pos)
|
for (auto pos = 0u; pos < cols; ++pos)
|
||||||
{
|
{
|
||||||
auto & el = cells[pos];
|
auto & el = cells[pos];
|
||||||
if (el.text.size() == 1 && el.text[0] == nana::char_t(0))
|
if (el.text.size() == 1 && el.text[0] == '\0')
|
||||||
continue;
|
continue;
|
||||||
text(pos, std::move(el));
|
text(pos, std::move(el));
|
||||||
}
|
}
|
||||||
@@ -275,8 +280,7 @@ namespace nana
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
T* value_ptr() const
|
T* value_ptr() const
|
||||||
{
|
{
|
||||||
auto * pany = _m_value();
|
return any_cast<T>(_m_value());
|
||||||
return (pany ? pany->get<T>() : nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -286,7 +290,7 @@ namespace nana
|
|||||||
if(nullptr == pany)
|
if(nullptr == pany)
|
||||||
throw std::runtime_error("listbox::item_proxy.value<T>() is empty");
|
throw std::runtime_error("listbox::item_proxy.value<T>() is empty");
|
||||||
|
|
||||||
T * p = pany->get<T>();
|
T * p = any_cast<T>(_m_value());
|
||||||
if(nullptr == p)
|
if(nullptr == p)
|
||||||
throw std::runtime_error("listbox::item_proxy.value<T>() invalid type of value");
|
throw std::runtime_error("listbox::item_proxy.value<T>() invalid type of value");
|
||||||
return *p;
|
return *p;
|
||||||
@@ -300,9 +304,10 @@ namespace nana
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Behavior of Iterator's value_type
|
/// Behavior of Iterator's value_type
|
||||||
bool operator==(const nana::string& s) const;
|
|
||||||
bool operator==(const char * s) const;
|
bool operator==(const char * s) const;
|
||||||
bool operator==(const wchar_t * s) const;
|
bool operator==(const wchar_t * s) const;
|
||||||
|
bool operator==(const ::std::string& s) const;
|
||||||
|
bool operator==(const ::std::wstring& s) const;
|
||||||
|
|
||||||
/// Behavior of Iterator
|
/// Behavior of Iterator
|
||||||
item_proxy & operator=(const item_proxy&);
|
item_proxy & operator=(const item_proxy&);
|
||||||
@@ -375,18 +380,20 @@ namespace nana
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Appends one item at the end of this category with the specifies text in the column fields
|
/// Appends one item at the end of this category with the specifies text in the column fields
|
||||||
void append(std::initializer_list<nana::string>);
|
void append(std::initializer_list<std::string> texts_utf8);
|
||||||
|
void append(std::initializer_list<std::wstring> texts);
|
||||||
|
|
||||||
size_type columns() const;
|
size_type columns() const;
|
||||||
|
|
||||||
cat_proxy& text(nana::string);
|
cat_proxy& text(std::string);
|
||||||
nana::string text() const;
|
cat_proxy& text(std::wstring);
|
||||||
|
std::string text() const;
|
||||||
|
|
||||||
cat_proxy & select(bool);
|
cat_proxy & select(bool);
|
||||||
bool selected() const;
|
bool selected() const;
|
||||||
|
|
||||||
/// Behavior of a container
|
/// Behavior of a container
|
||||||
void push_back(nana::string);
|
void push_back(std::string text_utf8);
|
||||||
|
|
||||||
item_proxy begin() const;
|
item_proxy begin() const;
|
||||||
item_proxy end() const;
|
item_proxy end() const;
|
||||||
@@ -449,8 +456,8 @@ namespace nana
|
|||||||
|
|
||||||
struct export_options
|
struct export_options
|
||||||
{
|
{
|
||||||
nana::string sep = nana::string {STR("\t" )},
|
std::string sep = ::std::string {"\t"},
|
||||||
endl= nana::string {STR("\n")};
|
endl= ::std::string {"\n"};
|
||||||
bool only_selected_items{true},
|
bool only_selected_items{true},
|
||||||
only_checked_items {false},
|
only_checked_items {false},
|
||||||
only_visible_columns{true};
|
only_visible_columns{true};
|
||||||
@@ -461,13 +468,30 @@ namespace nana
|
|||||||
}
|
}
|
||||||
}//end namespace drawerbase
|
}//end namespace drawerbase
|
||||||
|
|
||||||
struct arg_listbox
|
struct arg_listbox
|
||||||
|
: public event_arg
|
||||||
|
{
|
||||||
|
mutable drawerbase::listbox::item_proxy item;
|
||||||
|
bool selected;
|
||||||
|
|
||||||
|
arg_listbox(const drawerbase::listbox::item_proxy&, bool selected) noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// The event argument type for listbox's category_dbl_click
|
||||||
|
struct arg_category
|
||||||
: public event_arg
|
: public event_arg
|
||||||
{
|
{
|
||||||
mutable drawerbase::listbox::item_proxy item;
|
drawerbase::listbox::cat_proxy category;
|
||||||
bool selected;
|
|
||||||
|
|
||||||
arg_listbox(const drawerbase::listbox::item_proxy&, bool selected);
|
/// Block expension/shrink of category
|
||||||
|
void block_category_change() const noexcept;
|
||||||
|
|
||||||
|
/// Determines whether expension/shrink of category is blocked
|
||||||
|
bool category_change_blocked() const noexcept;
|
||||||
|
|
||||||
|
arg_category(const drawerbase::listbox::cat_proxy&) noexcept;
|
||||||
|
private:
|
||||||
|
mutable bool block_change_;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace drawerbase
|
namespace drawerbase
|
||||||
@@ -479,6 +503,9 @@ namespace nana
|
|||||||
{
|
{
|
||||||
basic_event<arg_listbox> checked;
|
basic_event<arg_listbox> checked;
|
||||||
basic_event<arg_listbox> selected;
|
basic_event<arg_listbox> selected;
|
||||||
|
|
||||||
|
/// An event occurs when a listbox category is double clicking.
|
||||||
|
basic_event<arg_category> category_dbl_click;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scheme
|
struct scheme
|
||||||
@@ -510,16 +537,16 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
|||||||
and
|
and
|
||||||
antisymmetry(comp(a, b) != comp(b, a) returns true)
|
antisymmetry(comp(a, b) != comp(b, a) returns true)
|
||||||
A simple example.
|
A simple example.
|
||||||
bool sort_compare( const nana::string& s1, nana::any*,
|
bool sort_compare( const std::string& s1, nana::any*,
|
||||||
const nana::string& s2, nana::any*, bool reverse)
|
const std::string& s2, nana::any*, bool reverse)
|
||||||
{
|
{
|
||||||
return (reverse ? s1 > s2 : s1 < s2);
|
return (reverse ? s1 > s2 : s1 < s2);
|
||||||
}
|
}
|
||||||
listbox.set_sort_compare(0, sort_compare);
|
listbox.set_sort_compare(0, sort_compare);
|
||||||
The listbox supports attaching a customer's object for each item, therefore the items can be
|
The listbox supports attaching a customer's object for each item, therefore the items can be
|
||||||
sorted by comparing these customer's object.
|
sorted by comparing these customer's object.
|
||||||
bool sort_compare( const nana::string&, nana::any* o1,
|
bool sort_compare( const std::string&, nana::any* o1,
|
||||||
const nana::string&, nana::any* o2, bool reverse)
|
const std::string&, nana::any* o2, bool reverse)
|
||||||
{
|
{
|
||||||
if(o1 && o2) //some items may not attach a customer object.
|
if(o1 && o2) //some items may not attach a customer object.
|
||||||
{
|
{
|
||||||
@@ -565,15 +592,20 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
|||||||
void scroll(bool to_bottom, const index_pair& pos);
|
void scroll(bool to_bottom, const index_pair& pos);
|
||||||
|
|
||||||
/// Appends a new column with a header text and the specified width at the end, and return it position
|
/// Appends a new column with a header text and the specified width at the end, and return it position
|
||||||
size_type append_header(nana::string header_text, unsigned width = 120);
|
size_type append_header(std::string text_utf8, unsigned width = 120);
|
||||||
|
size_type append_header(std::wstring text, unsigned width = 120);
|
||||||
listbox& header_width(size_type position, unsigned pixels);
|
listbox& header_width(size_type position, unsigned pixels);
|
||||||
unsigned header_width(size_type position) const;
|
unsigned header_width(size_type position) const;
|
||||||
unsigned auto_width(size_type position, unsigned max=3000);
|
unsigned auto_width(size_type position, unsigned max=3000);
|
||||||
|
|
||||||
|
|
||||||
cat_proxy append(nana::string); ///< Appends a new category at the end
|
cat_proxy append(std::string); ///< Appends a new category to the end
|
||||||
void append(std::initializer_list<nana::string>); ///< Appends categories at the end
|
cat_proxy append(std::wstring); ///< Appends a new category to the end
|
||||||
cat_proxy insert(cat_proxy, nana::string);
|
void append(std::initializer_list<std::string>); ///< Appends categories to the end
|
||||||
|
void append(std::initializer_list<std::wstring>); ///< Appends categories to the end
|
||||||
|
|
||||||
|
cat_proxy insert(cat_proxy, ::std::string);
|
||||||
|
cat_proxy insert(cat_proxy, ::std::wstring);
|
||||||
cat_proxy at(size_type pos) const;
|
cat_proxy at(size_type pos) const;
|
||||||
|
|
||||||
/// add categories in order when use a key?
|
/// add categories in order when use a key?
|
||||||
@@ -604,9 +636,18 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
|||||||
return cat_proxy(&_m_ess(), _m_at_key(p));
|
return cat_proxy(&_m_ess(), _m_at_key(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns an item by the specified absolute position
|
||||||
item_proxy at(const index_pair &abs_pos) const;
|
item_proxy at(const index_pair &abs_pos) const;
|
||||||
|
|
||||||
void insert(const index_pair&, nana::string); ///<Insert a new item with a text in the first column.
|
/// Returns an index of item which contains the specified point.
|
||||||
|
index_pair at(const point & pos) const;
|
||||||
|
|
||||||
|
/// Returns the column which contains the specified point.
|
||||||
|
columns_indexs column_from_pos(const point & pos);
|
||||||
|
|
||||||
|
|
||||||
|
void insert(const index_pair&, ::std::string); ///<Insert a new item with a text in the first column.
|
||||||
|
void insert(const index_pair&, ::std::wstring); ///<Insert a new item with a text in the first column.
|
||||||
|
|
||||||
void checkable(bool);
|
void checkable(bool);
|
||||||
selection checked() const; ///<Returns the items which are checked.
|
selection checked() const; ///<Returns the items which are checked.
|
||||||
@@ -637,8 +678,8 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
|||||||
void sortable(bool enable);
|
void sortable(bool enable);
|
||||||
|
|
||||||
///Sets a strict weak ordering comparer for a column
|
///Sets a strict weak ordering comparer for a column
|
||||||
void set_sort_compare(size_type col, std::function<bool(const nana::string&, nana::any*,
|
void set_sort_compare(size_type col, std::function<bool(const std::string&, nana::any*,
|
||||||
const nana::string&, nana::any*, bool reverse)> strick_ordering);
|
const std::string&, nana::any*, bool reverse)> strick_ordering);
|
||||||
|
|
||||||
/// sort() and ivalidate any existing reference from display position to absolute item, that is: after sort() display offset point to different items
|
/// sort() and ivalidate any existing reference from display position to absolute item, that is: after sort() display offset point to different items
|
||||||
void sort_col(size_type col, bool reverse = false);
|
void sort_col(size_type col, bool reverse = false);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace nana
|
|||||||
{
|
{
|
||||||
struct menu_type; //declaration
|
struct menu_type; //declaration
|
||||||
|
|
||||||
|
using native_string_type = ::nana::detail::native_string_type;
|
||||||
|
|
||||||
enum class checks
|
enum class checks
|
||||||
{
|
{
|
||||||
none,
|
none,
|
||||||
@@ -56,7 +58,7 @@ namespace nana
|
|||||||
|
|
||||||
//Default constructor initializes the item as a splitter
|
//Default constructor initializes the item as a splitter
|
||||||
menu_item_type();
|
menu_item_type();
|
||||||
menu_item_type(nana::string, const event_fn_t&);
|
menu_item_type(std::string, const event_fn_t&);
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@@ -66,11 +68,11 @@ namespace nana
|
|||||||
}flags;
|
}flags;
|
||||||
|
|
||||||
menu_type *sub_menu{nullptr};
|
menu_type *sub_menu{nullptr};
|
||||||
nana::string text;
|
std::string text;
|
||||||
event_fn_t functor;
|
event_fn_t functor;
|
||||||
checks style{checks::none};
|
checks style{checks::none};
|
||||||
paint::image image;
|
paint::image image;
|
||||||
mutable nana::char_t hotkey{0};
|
mutable wchar_t hotkey{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct menu_type
|
struct menu_type
|
||||||
@@ -89,7 +91,7 @@ namespace nana
|
|||||||
class renderer_interface
|
class renderer_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef nana::paint::graphics & graph_reference;
|
using graph_reference = nana::paint::graphics &;
|
||||||
|
|
||||||
enum class state
|
enum class state
|
||||||
{
|
{
|
||||||
@@ -109,7 +111,7 @@ namespace nana
|
|||||||
virtual void background(graph_reference, window) = 0;
|
virtual void background(graph_reference, window) = 0;
|
||||||
virtual void item(graph_reference, const nana::rectangle&, const attr&) = 0;
|
virtual void item(graph_reference, const nana::rectangle&, const attr&) = 0;
|
||||||
virtual void item_image(graph_reference, const nana::point&, unsigned image_px, const paint::image&) = 0;
|
virtual void item_image(graph_reference, const nana::point&, unsigned image_px, const paint::image&) = 0;
|
||||||
virtual void item_text(graph_reference, const nana::point&, const nana::string&, unsigned text_pixels, const attr&) = 0;
|
virtual void item_text(graph_reference, const nana::point&, const std::string&, unsigned text_pixels, const attr&) = 0;
|
||||||
virtual void sub_arrow(graph_reference, const nana::point&, unsigned item_pixels, const attr&) = 0;
|
virtual void sub_arrow(graph_reference, const nana::point&, unsigned item_pixels, const attr&) = 0;
|
||||||
};
|
};
|
||||||
}//end namespace menu
|
}//end namespace menu
|
||||||
@@ -134,7 +136,7 @@ namespace nana
|
|||||||
~menu();
|
~menu();
|
||||||
|
|
||||||
/// Appends an item to the menu.
|
/// Appends an item to the menu.
|
||||||
item_proxy append(const nana::string& text, const event_fn_t& callback= event_fn_t());
|
item_proxy append(const std::string& text, const event_fn_t& callback= event_fn_t());
|
||||||
void append_splitter();
|
void append_splitter();
|
||||||
void clear(); ///< Erases all of the items.
|
void clear(); ///< Erases all of the items.
|
||||||
/// Closes the menu. It does not destroy the menu; just close the window for the menu.
|
/// Closes the menu. It does not destroy the menu; just close the window for the menu.
|
||||||
@@ -158,7 +160,7 @@ namespace nana
|
|||||||
bool goto_submen();///< Popup the submenu of the current item if it has a sub menu. Returns true if succeeds.
|
bool goto_submen();///< Popup the submenu of the current item if it has a sub menu. Returns true if succeeds.
|
||||||
bool exit_submenu(); ///< Closes the current window of the sub menu.
|
bool exit_submenu(); ///< Closes the current window of the sub menu.
|
||||||
std::size_t size() const; ///< Return the number of items.
|
std::size_t size() const; ///< Return the number of items.
|
||||||
int send_shortkey(nana::char_t key);
|
int send_shortkey(wchar_t key);
|
||||||
void pick();
|
void pick();
|
||||||
|
|
||||||
menu& max_pixels(unsigned); ///< Sets the max width in pixels of the item.
|
menu& max_pixels(unsigned); ///< Sets the max width in pixels of the item.
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace nana
|
|||||||
{
|
{
|
||||||
namespace menubar
|
namespace menubar
|
||||||
{
|
{
|
||||||
|
using native_string_type = ::nana::detail::native_string_type;
|
||||||
|
|
||||||
class item_renderer
|
class item_renderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -33,7 +35,7 @@ namespace nana
|
|||||||
|
|
||||||
item_renderer(window, graph_reference);
|
item_renderer(window, graph_reference);
|
||||||
virtual void background(const point&, const ::nana::size&, state);
|
virtual void background(const point&, const ::nana::size&, state);
|
||||||
virtual void caption(const point&, const ::nana::string&);
|
virtual void caption(const point&, const native_string_type&);
|
||||||
private:
|
private:
|
||||||
window handle_;
|
window handle_;
|
||||||
graph_reference graph_;
|
graph_reference graph_;
|
||||||
@@ -46,7 +48,7 @@ namespace nana
|
|||||||
public:
|
public:
|
||||||
trigger();
|
trigger();
|
||||||
~trigger();
|
~trigger();
|
||||||
nana::menu* push_back(const nana::string&);
|
nana::menu* push_back(const std::string&);
|
||||||
nana::menu* at(size_t) const;
|
nana::menu* at(size_t) const;
|
||||||
std::size_t size() const;
|
std::size_t size() const;
|
||||||
private:
|
private:
|
||||||
@@ -108,7 +110,7 @@ namespace nana
|
|||||||
menubar(window); ///< Create a menubar at the top of the specified window.
|
menubar(window); ///< Create a menubar at the top of the specified window.
|
||||||
~menubar();
|
~menubar();
|
||||||
void create(window); ///< Create a menubar at the top of the specified window.
|
void create(window); ///< Create a menubar at the top of the specified window.
|
||||||
menu& push_back(const nana::string&); ///< Appends a new (empty) menu.
|
menu& push_back(const std::string&); ///< Appends a new (empty) menu.
|
||||||
menu& at(size_t index) const; ///< Gets the menu specified by index.
|
menu& at(size_t index) const; ///< Gets the menu specified by index.
|
||||||
std::size_t length() const; ///< Number of menus.
|
std::size_t length() const; ///< Number of menus.
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
graph_ = &graph;
|
graph_ = &graph;
|
||||||
widget_ = static_cast< ::nana::scroll<Vertical>*>(&widget);
|
widget_ = static_cast< ::nana::scroll<Vertical>*>(&widget);
|
||||||
widget.caption(STR("Nana Scroll"));
|
widget.caption("nana scroll");
|
||||||
|
|
||||||
timer_.stop();
|
timer_.stop();
|
||||||
timer_.elapse(std::bind(&trigger::_m_tick, this));
|
timer_.elapse(std::bind(&trigger::_m_tick, this));
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* A text editor implementation
|
* A text editor 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
|
||||||
@@ -131,7 +131,7 @@ namespace nana{ namespace widgets
|
|||||||
struct keywords;
|
struct keywords;
|
||||||
class keyword_parser;
|
class keyword_parser;
|
||||||
public:
|
public:
|
||||||
using char_type = ::nana::char_t;
|
using char_type = wchar_t;
|
||||||
using size_type = textbase<char_type>::size_type;
|
using size_type = textbase<char_type>::size_type;
|
||||||
using string_type = textbase<char_type>::string_type;
|
using string_type = textbase<char_type>::string_type;
|
||||||
|
|
||||||
@@ -152,10 +152,10 @@ namespace nana{ namespace widgets
|
|||||||
text_editor(window, graph_reference, const text_editor_scheme*);
|
text_editor(window, graph_reference, const text_editor_scheme*);
|
||||||
~text_editor();
|
~text_editor();
|
||||||
|
|
||||||
void set_highlight(const std::string& name, const ::nana::color&, const ::nana::color&);
|
void set_highlight(const ::std::string& name, const ::nana::color&, const ::nana::color&);
|
||||||
void erase_highlight(const std::string& name);
|
void erase_highlight(const ::std::string& name);
|
||||||
void set_keyword(const ::nana::string& kw, const std::string& name, bool case_sensitive, bool whole_word_matched);
|
void set_keyword(const ::std::wstring& kw, const std::string& name, bool case_sensitive, bool whole_word_matched);
|
||||||
void erase_keyword(const ::nana::string& kw);
|
void erase_keyword(const ::std::wstring& kw);
|
||||||
|
|
||||||
void set_accept(std::function<bool(char_type)>);
|
void set_accept(std::function<bool(char_type)>);
|
||||||
void set_accept(accepts);
|
void set_accept(accepts);
|
||||||
@@ -164,7 +164,7 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
void typeface_changed();
|
void typeface_changed();
|
||||||
|
|
||||||
void indent(bool, std::function<nana::string()> generator);
|
void indent(bool, std::function<std::string()> generator);
|
||||||
void set_event(event_interface*);
|
void set_event(event_interface*);
|
||||||
|
|
||||||
/// Determine whether the text_editor is line wrapped.
|
/// Determine whether the text_editor is line wrapped.
|
||||||
@@ -174,7 +174,7 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
void border_renderer(std::function<void(graph_reference, const ::nana::color& bgcolor)>);
|
void border_renderer(std::function<void(graph_reference, const ::nana::color& bgcolor)>);
|
||||||
|
|
||||||
bool load(const nana::char_t*);
|
bool load(const char*);
|
||||||
|
|
||||||
/// Sets the text area.
|
/// Sets the text area.
|
||||||
/// @return true if the area is changed with the new value.
|
/// @return true if the area is changed with the new value.
|
||||||
@@ -183,7 +183,7 @@ namespace nana{ namespace widgets
|
|||||||
/// Returns the text area
|
/// Returns the text area
|
||||||
rectangle text_area(bool including_scroll) const;
|
rectangle text_area(bool including_scroll) const;
|
||||||
|
|
||||||
bool tip_string(nana::string&&);
|
bool tip_string(::std::string&&);
|
||||||
|
|
||||||
const attributes & attr() const;
|
const attributes & attr() const;
|
||||||
bool multi_lines(bool);
|
bool multi_lines(bool);
|
||||||
@@ -201,9 +201,9 @@ namespace nana{ namespace widgets
|
|||||||
unsigned line_height() const;
|
unsigned line_height() const;
|
||||||
unsigned screen_lines() const;
|
unsigned screen_lines() const;
|
||||||
|
|
||||||
bool getline(std::size_t pos, nana::string&) const;
|
bool getline(std::size_t pos, ::std::wstring&) const;
|
||||||
void text(nana::string);
|
void text(std::wstring);
|
||||||
nana::string text() const;
|
std::wstring text() const;
|
||||||
|
|
||||||
/// Sets caret position through text coordinate.
|
/// Sets caret position through text coordinate.
|
||||||
void move_caret(const upoint&);
|
void move_caret(const upoint&);
|
||||||
@@ -221,7 +221,7 @@ namespace nana{ namespace widgets
|
|||||||
bool hit_select_area(nana::upoint pos) const;
|
bool hit_select_area(nana::upoint pos) const;
|
||||||
|
|
||||||
bool move_select();
|
bool move_select();
|
||||||
bool mask(char_t);
|
bool mask(wchar_t);
|
||||||
|
|
||||||
/// Returns width of text area excluding the vscroll size.
|
/// Returns width of text area excluding the vscroll size.
|
||||||
unsigned width_pixels() const;
|
unsigned width_pixels() const;
|
||||||
@@ -233,8 +233,8 @@ namespace nana{ namespace widgets
|
|||||||
void draw_corner();
|
void draw_corner();
|
||||||
void render(bool focused);
|
void render(bool focused);
|
||||||
public:
|
public:
|
||||||
void put(nana::string);
|
void put(std::wstring);
|
||||||
void put(nana::char_t);
|
void put(wchar_t);
|
||||||
void copy() const;
|
void copy() const;
|
||||||
void cut();
|
void cut();
|
||||||
void paste();
|
void paste();
|
||||||
@@ -253,8 +253,8 @@ namespace nana{ namespace widgets
|
|||||||
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<nana::char_t>& textbase();
|
skeletons::textbase<wchar_t>& textbase();
|
||||||
const skeletons::textbase<nana::char_t>& textbase() const;
|
const skeletons::textbase<wchar_t>& textbase() const;
|
||||||
private:
|
private:
|
||||||
bool _m_accepts(char_type) const;
|
bool _m_accepts(char_type) const;
|
||||||
::nana::color _m_bgcolor() const;
|
::nana::color _m_bgcolor() const;
|
||||||
@@ -264,11 +264,11 @@ namespace nana{ namespace widgets
|
|||||||
::nana::size _m_text_area() const;
|
::nana::size _m_text_area() const;
|
||||||
void _m_get_scrollbar_size();
|
void _m_get_scrollbar_size();
|
||||||
void _m_reset();
|
void _m_reset();
|
||||||
::nana::upoint _m_put(nana::string);
|
::nana::upoint _m_put(::std::wstring);
|
||||||
::nana::upoint _m_erase_select();
|
::nana::upoint _m_erase_select();
|
||||||
|
|
||||||
bool _m_make_select_string(nana::string&) const;
|
bool _m_make_select_string(::std::wstring&) const;
|
||||||
static bool _m_resolve_text(const nana::string&, 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);
|
||||||
unsigned _m_tabs_pixels(size_type tabs) const;
|
unsigned _m_tabs_pixels(size_type tabs) const;
|
||||||
@@ -283,10 +283,10 @@ namespace nana{ namespace widgets
|
|||||||
/// Returns the right/bottom point of text area.
|
/// Returns the right/bottom point of text area.
|
||||||
int _m_end_pos(bool right) const;
|
int _m_end_pos(bool right) const;
|
||||||
|
|
||||||
void _m_draw_parse_string(const keyword_parser&, bool rtl, ::nana::point pos, const ::nana::color& fgcolor, const ::nana::char_t*, std::size_t len) const;
|
void _m_draw_parse_string(const keyword_parser&, bool rtl, ::nana::point pos, const ::nana::color& fgcolor, const wchar_t*, std::size_t len) const;
|
||||||
//_m_draw_string
|
//_m_draw_string
|
||||||
//@brief: Draw a line of string
|
//@brief: Draw a line of string
|
||||||
void _m_draw_string(int top, const ::nana::color&, const nana::upoint& str_pos, const nana::string&, bool if_mask) const;
|
void _m_draw_string(int top, const ::nana::color&, const nana::upoint& str_pos, const ::std::wstring&, bool if_mask) const;
|
||||||
//_m_update_caret_line
|
//_m_update_caret_line
|
||||||
//@brief: redraw whole line specified by caret pos.
|
//@brief: redraw whole line specified by caret pos.
|
||||||
//@return: true if caret overs the border
|
//@return: true if caret overs the border
|
||||||
@@ -295,8 +295,8 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
void _m_offset_y(int y);
|
void _m_offset_y(int y);
|
||||||
|
|
||||||
unsigned _m_char_by_pixels(const nana::char_t*, std::size_t len, unsigned* pxbuf, int str_px, int pixels, bool is_rtl);
|
unsigned _m_char_by_pixels(const wchar_t*, std::size_t len, unsigned* pxbuf, int str_px, int pixels, bool is_rtl);
|
||||||
unsigned _m_pixels_by_char(const nana::string&, 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:
|
||||||
@@ -308,8 +308,8 @@ namespace nana{ namespace widgets
|
|||||||
event_interface * event_handler_{ nullptr };
|
event_interface * event_handler_{ nullptr };
|
||||||
std::unique_ptr<keywords> keywords_;
|
std::unique_ptr<keywords> keywords_;
|
||||||
|
|
||||||
skeletons::textbase<nana::char_t> textbase_;
|
skeletons::textbase<wchar_t> textbase_;
|
||||||
nana::char_t mask_char_{0};
|
wchar_t mask_char_{0};
|
||||||
|
|
||||||
mutable ext_renderer_tag ext_renderer_;
|
mutable ext_renderer_tag ext_renderer_;
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ namespace nana{ namespace widgets
|
|||||||
struct indent_rep
|
struct indent_rep
|
||||||
{
|
{
|
||||||
bool enabled{ false };
|
bool enabled{ false };
|
||||||
std::function<nana::string()> generator;
|
std::function<std::string()> generator;
|
||||||
}indent_;
|
}indent_;
|
||||||
|
|
||||||
struct attributes
|
struct attributes
|
||||||
@@ -326,7 +326,7 @@ namespace nana{ namespace widgets
|
|||||||
accepts acceptive{ accepts::no_restrict };
|
accepts acceptive{ accepts::no_restrict };
|
||||||
std::function<bool(char_type)> pred_acceptive;
|
std::function<bool(char_type)> pred_acceptive;
|
||||||
|
|
||||||
nana::string tip_string;
|
::std::string tip_string;
|
||||||
|
|
||||||
bool line_wrapped{false};
|
bool line_wrapped{false};
|
||||||
bool multi_lines{true};
|
bool multi_lines{true};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Text Token Stream
|
* Text Token Stream
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* 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
|
||||||
@@ -42,7 +42,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
class tokenizer
|
class tokenizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
tokenizer(const nana::string& s, bool format_enabled)
|
tokenizer(const std::wstring& s, bool format_enabled)
|
||||||
: iptr_(s.data()),
|
: iptr_(s.data()),
|
||||||
endptr_(s.data() + s.size()),
|
endptr_(s.data() + s.size()),
|
||||||
format_enabled_(format_enabled)
|
format_enabled_(format_enabled)
|
||||||
@@ -74,12 +74,12 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
return _m_token();
|
return _m_token();
|
||||||
}
|
}
|
||||||
|
|
||||||
const nana::string& idstr() const
|
const ::std::wstring& idstr() const
|
||||||
{
|
{
|
||||||
return idstr_;
|
return idstr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::pair<nana::string, nana::string>& binary() const
|
const std::pair<std::wstring, std::wstring>& binary() const
|
||||||
{
|
{
|
||||||
return binary_;
|
return binary_;
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
static bool _m_unicode_word_breakable(nana::char_t ch)
|
static bool _m_unicode_word_breakable(wchar_t ch)
|
||||||
{
|
{
|
||||||
return ((0x4E00 <= ch) && (ch <= 0x9FFF));
|
return ((0x4E00 <= ch) && (ch <= 0x9FFF));
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
//Read the data token
|
//Read the data token
|
||||||
token _m_token()
|
token _m_token()
|
||||||
{
|
{
|
||||||
nana::char_t ch = *iptr_;
|
wchar_t ch = *iptr_;
|
||||||
|
|
||||||
if(ch > 0xFF)
|
if(ch > 0xFF)
|
||||||
{
|
{
|
||||||
@@ -150,7 +150,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
|
|
||||||
if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))
|
if(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))
|
||||||
{
|
{
|
||||||
const nana::char_t * idstr = iptr_;
|
auto idstr = iptr_;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ch = *(++iptr_);
|
ch = *(++iptr_);
|
||||||
@@ -172,7 +172,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
{
|
{
|
||||||
//pos keeps the current position, and it used for restring
|
//pos keeps the current position, and it used for restring
|
||||||
//iptr_ when the search is failed.
|
//iptr_ when the search is failed.
|
||||||
const nana::char_t * pos = ++iptr_;
|
auto pos = ++iptr_;
|
||||||
_m_eat_whitespace();
|
_m_eat_whitespace();
|
||||||
if(*iptr_ == '/')
|
if(*iptr_ == '/')
|
||||||
{
|
{
|
||||||
@@ -219,7 +219,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
{
|
{
|
||||||
_m_eat_whitespace();
|
_m_eat_whitespace();
|
||||||
|
|
||||||
nana::char_t ch = *iptr_++;
|
auto ch = *iptr_++;
|
||||||
|
|
||||||
switch(ch)
|
switch(ch)
|
||||||
{
|
{
|
||||||
@@ -232,7 +232,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
case '"':
|
case '"':
|
||||||
//Here is a string and all the meta characters will be ignored except "
|
//Here is a string and all the meta characters will be ignored except "
|
||||||
{
|
{
|
||||||
const nana::char_t * str = iptr_;
|
auto str = iptr_;
|
||||||
|
|
||||||
while((iptr_ != endptr_) && (*iptr_ != '"'))
|
while((iptr_ != endptr_) && (*iptr_ != '"'))
|
||||||
++iptr_;
|
++iptr_;
|
||||||
@@ -244,7 +244,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
_m_eat_whitespace();
|
_m_eat_whitespace();
|
||||||
if((iptr_ < endptr_) && _m_is_idstr_element(*iptr_))
|
if((iptr_ < endptr_) && _m_is_idstr_element(*iptr_))
|
||||||
{
|
{
|
||||||
const nana::char_t * pbegin = iptr_;
|
auto pbegin = iptr_;
|
||||||
while((iptr_ < endptr_) && _m_is_idstr_element(*iptr_))
|
while((iptr_ < endptr_) && _m_is_idstr_element(*iptr_))
|
||||||
++iptr_;
|
++iptr_;
|
||||||
|
|
||||||
@@ -281,45 +281,45 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
//Here is a identifier
|
//Here is a identifier
|
||||||
_m_read_idstr();
|
_m_read_idstr();
|
||||||
|
|
||||||
if(STR("font") == idstr_)
|
if(L"font" == idstr_)
|
||||||
return token::font;
|
return token::font;
|
||||||
else if(STR("bold") == idstr_)
|
else if(L"bold" == idstr_)
|
||||||
return token::bold;
|
return token::bold;
|
||||||
else if(STR("size") == idstr_)
|
else if(L"size" == idstr_)
|
||||||
return token::size;
|
return token::size;
|
||||||
else if(STR("baseline") == idstr_)
|
else if(L"baseline" == idstr_)
|
||||||
return token::baseline;
|
return token::baseline;
|
||||||
else if(STR("top") == idstr_)
|
else if(L"top" == idstr_)
|
||||||
return token::top;
|
return token::top;
|
||||||
else if(STR("center") == idstr_)
|
else if(L"center" == idstr_)
|
||||||
return token::center;
|
return token::center;
|
||||||
else if(STR("bottom") == idstr_)
|
else if(L"bottom" == idstr_)
|
||||||
return token::bottom;
|
return token::bottom;
|
||||||
else if(STR("color") == idstr_)
|
else if(L"color" == idstr_)
|
||||||
return token::color;
|
return token::color;
|
||||||
else if(STR("image") == idstr_)
|
else if(L"image" == idstr_)
|
||||||
return token::image;
|
return token::image;
|
||||||
else if(STR("true") == idstr_)
|
else if(L"true" == idstr_)
|
||||||
return token::_true;
|
return token::_true;
|
||||||
else if(STR("url") == idstr_)
|
else if(L"url" == idstr_)
|
||||||
return token::url;
|
return token::url;
|
||||||
else if(STR("target") == idstr_)
|
else if(L"target" == idstr_)
|
||||||
return token::target;
|
return token::target;
|
||||||
else if(STR("false") == idstr_)
|
else if(L"false" == idstr_)
|
||||||
return token::_false;
|
return token::_false;
|
||||||
else if(STR("red") == idstr_)
|
else if(L"red" == idstr_)
|
||||||
return token::red;
|
return token::red;
|
||||||
else if(STR("green") == idstr_)
|
else if(L"green" == idstr_)
|
||||||
return token::green;
|
return token::green;
|
||||||
else if(STR("blue") == idstr_)
|
else if(L"blue" == idstr_)
|
||||||
return token::blue;
|
return token::blue;
|
||||||
else if(STR("white") == idstr_)
|
else if(L"white" == idstr_)
|
||||||
return token::white;
|
return token::white;
|
||||||
else if(STR("black") == idstr_)
|
else if(L"black" == idstr_)
|
||||||
return token::black;
|
return token::black;
|
||||||
else if(STR("min_limited") == idstr_)
|
else if(L"min_limited" == idstr_)
|
||||||
return token::min_limited;
|
return token::min_limited;
|
||||||
else if(STR("max_limited") == idstr_)
|
else if(L"max_limited" == idstr_)
|
||||||
return token::max_limited;
|
return token::max_limited;
|
||||||
|
|
||||||
return token::string;
|
return token::string;
|
||||||
@@ -335,7 +335,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
return token::eof;
|
return token::eof;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _m_is_idstr_element(nana::char_t ch)
|
static bool _m_is_idstr_element(wchar_t ch)
|
||||||
{
|
{
|
||||||
return (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || ('_' == ch) || ('0' <= ch && ch <= '9'));
|
return (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || ('_' == ch) || ('0' <= ch && ch <= '9'));
|
||||||
}
|
}
|
||||||
@@ -343,9 +343,9 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
//Read the identifier.
|
//Read the identifier.
|
||||||
void _m_read_idstr()
|
void _m_read_idstr()
|
||||||
{
|
{
|
||||||
const nana::char_t * idstr = iptr_;
|
auto idstr = iptr_;
|
||||||
|
|
||||||
nana::char_t ch;
|
wchar_t ch;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ch = *(++iptr_);
|
ch = *(++iptr_);
|
||||||
@@ -360,7 +360,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
{
|
{
|
||||||
idstr_.clear();
|
idstr_.clear();
|
||||||
|
|
||||||
nana::char_t ch = *iptr_;
|
wchar_t ch = *iptr_;
|
||||||
|
|
||||||
idstr_ += ch;
|
idstr_ += ch;
|
||||||
|
|
||||||
@@ -412,13 +412,13 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
const ::nana::char_t * iptr_;
|
const wchar_t * iptr_;
|
||||||
const ::nana::char_t * endptr_;
|
const wchar_t * endptr_;
|
||||||
const bool format_enabled_;
|
const bool format_enabled_;
|
||||||
bool format_state_{false};
|
bool format_state_{false};
|
||||||
|
|
||||||
::nana::string idstr_;
|
std::wstring idstr_;
|
||||||
std::pair<nana::string, nana::string> binary_;
|
std::pair<std::wstring, std::wstring> binary_;
|
||||||
token revert_token_{token::eof};
|
token revert_token_{token::eof};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -434,7 +434,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
::nana::string font;
|
::std::string font;
|
||||||
std::size_t font_size;
|
std::size_t font_size;
|
||||||
bool bold;
|
bool bold;
|
||||||
bool bold_empty; //bold should be ignored if bold_empty is true
|
bool bold_empty; //bold should be ignored if bold_empty is true
|
||||||
@@ -442,8 +442,8 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
::nana::color bgcolor; //If the color is not specified, it will be ignored, and the system will search for its parent.
|
::nana::color bgcolor; //If the color is not specified, it will be ignored, and the system will search for its parent.
|
||||||
::nana::color fgcolor; //ditto
|
::nana::color fgcolor; //ditto
|
||||||
|
|
||||||
::nana::string target;
|
::std::wstring target;
|
||||||
::nana::string url;
|
::std::wstring url;
|
||||||
|
|
||||||
fblock * parent;
|
fblock * parent;
|
||||||
};
|
};
|
||||||
@@ -458,7 +458,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
|
|
||||||
virtual bool is_text() const = 0;
|
virtual bool is_text() const = 0;
|
||||||
virtual bool is_whitespace() const = 0;
|
virtual bool is_whitespace() const = 0;
|
||||||
virtual const nana::string& text() const = 0;
|
virtual const std::wstring& text() const = 0;
|
||||||
virtual void measure(graph_reference) = 0;
|
virtual void measure(graph_reference) = 0;
|
||||||
virtual void nontext_render(graph_reference, int x, int y) = 0;
|
virtual void nontext_render(graph_reference, int x, int y) = 0;
|
||||||
virtual const nana::size & size() const = 0;
|
virtual const nana::size & size() const = 0;
|
||||||
@@ -470,7 +470,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
: public data
|
: public data
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
data_text(const nana::string& s)
|
data_text(const std::wstring& s)
|
||||||
: str_(s)
|
: str_(s)
|
||||||
{}
|
{}
|
||||||
private:
|
private:
|
||||||
@@ -484,7 +484,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const nana::string& text() const override
|
virtual const std::wstring& text() const override
|
||||||
{
|
{
|
||||||
return str_;
|
return str_;
|
||||||
}
|
}
|
||||||
@@ -513,7 +513,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
return ascent_;
|
return ascent_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
nana::string str_;
|
std::wstring str_;
|
||||||
nana::size size_;
|
nana::size size_;
|
||||||
std::size_t ascent_;
|
std::size_t ascent_;
|
||||||
};
|
};
|
||||||
@@ -522,7 +522,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
: public data
|
: public data
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
data_image(const nana::string& imgpath, const nana::size & sz, std::size_t limited)
|
data_image(const std::wstring& imgpath, const nana::size & sz, std::size_t limited)
|
||||||
: image_(imgpath)//, limited_(limited)
|
: image_(imgpath)//, limited_(limited)
|
||||||
{
|
{
|
||||||
size_ = image_.size();
|
size_ = image_.size();
|
||||||
@@ -562,7 +562,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const nana::string& text() const override
|
virtual const std::wstring& text() const override
|
||||||
{
|
{
|
||||||
return str_;
|
return str_;
|
||||||
}
|
}
|
||||||
@@ -589,7 +589,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
return size_.height;
|
return size_.height;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
nana::string str_;
|
std::wstring str_;
|
||||||
nana::paint::image image_;
|
nana::paint::image image_;
|
||||||
nana::size size_;
|
nana::size size_;
|
||||||
};
|
};
|
||||||
@@ -626,7 +626,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
fblocks_.clear();
|
fblocks_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse(const nana::string& s, bool format_enabled)
|
void parse(const std::wstring& s, bool format_enabled)
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
|
|
||||||
@@ -706,7 +706,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
if(token::string != tknizer.read())
|
if(token::string != tknizer.read())
|
||||||
throw std::runtime_error("");
|
throw std::runtime_error("");
|
||||||
|
|
||||||
fp->font = tknizer.idstr();
|
fp->font = to_utf8(tknizer.idstr());
|
||||||
break;
|
break;
|
||||||
case token::size:
|
case token::size:
|
||||||
if(token::equal != tknizer.read())
|
if(token::equal != tknizer.read())
|
||||||
@@ -893,7 +893,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
return fbp;
|
return fbp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _m_data_factory(token tk, const nana::string& idstr, fblock* fp, std::deque<value>& line)
|
void _m_data_factory(token tk, const std::wstring& idstr, fblock* fp, std::deque<value>& line)
|
||||||
{
|
{
|
||||||
value v;
|
value v;
|
||||||
v.fblock_ptr = fp;
|
v.fblock_ptr = fp;
|
||||||
@@ -926,7 +926,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
|||||||
|
|
||||||
struct attr_image_tag
|
struct attr_image_tag
|
||||||
{
|
{
|
||||||
nana::string path;
|
std::wstring path;
|
||||||
nana::size size;
|
nana::size size;
|
||||||
std::size_t limited;
|
std::size_t limited;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* A textbase class implementation
|
* A textbase 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
|
||||||
@@ -57,13 +57,12 @@ namespace skeletons
|
|||||||
((text_cont_.size() == 1) && (text_cont_[0].empty())));
|
((text_cont_.size() == 1) && (text_cont_[0].empty())));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool load(const nana::char_t* fs)
|
bool load(const char* file_utf8)
|
||||||
{
|
{
|
||||||
if (nullptr == fs)
|
if (!file_utf8)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string fs_mbs = nana::charset(fs);
|
std::ifstream ifs(to_osmbstr(file_utf8));
|
||||||
std::ifstream ifs(fs_mbs.data());
|
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -81,7 +80,7 @@ namespace skeletons
|
|||||||
if(0xBB == ch && 0xBF == ifs.get())
|
if(0xBB == ch && 0xBF == ifs.get())
|
||||||
{
|
{
|
||||||
ifs.close();
|
ifs.close();
|
||||||
return load(fs, nana::unicode::utf8);
|
return load(file_utf8, nana::unicode::utf8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(0xFF == ch)
|
else if(0xFF == ch)
|
||||||
@@ -94,11 +93,11 @@ namespace skeletons
|
|||||||
if(ifs.get() == 0 && ifs.get() == 0)
|
if(ifs.get() == 0 && ifs.get() == 0)
|
||||||
{
|
{
|
||||||
ifs.close();
|
ifs.close();
|
||||||
return load(fs, nana::unicode::utf32);
|
return load(file_utf8, nana::unicode::utf32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifs.close();
|
ifs.close();
|
||||||
return load(fs, nana::unicode::utf16);
|
return load(file_utf8, nana::unicode::utf16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(0xFE == ch)
|
else if(0xFE == ch)
|
||||||
@@ -107,7 +106,7 @@ namespace skeletons
|
|||||||
{
|
{
|
||||||
//UTF16(big-endian)
|
//UTF16(big-endian)
|
||||||
ifs.close();
|
ifs.close();
|
||||||
return load(fs, nana::unicode::utf16);
|
return load(file_utf8, nana::unicode::utf16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(0 == ch)
|
else if(0 == ch)
|
||||||
@@ -119,7 +118,7 @@ namespace skeletons
|
|||||||
{
|
{
|
||||||
//UTF32(big_endian)
|
//UTF32(big_endian)
|
||||||
ifs.close();
|
ifs.close();
|
||||||
return load(fs, nana::unicode::utf32);
|
return load(file_utf8, nana::unicode::utf32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +142,7 @@ namespace skeletons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_m_saved(fs);
|
_m_saved(file_utf8);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,13 +174,12 @@ namespace skeletons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool load(const nana::char_t * fs, nana::unicode encoding)
|
bool load(const char* file_utf8, nana::unicode encoding)
|
||||||
{
|
{
|
||||||
if (nullptr == fs)
|
if (!file_utf8)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string fs_mbs = nana::charset(fs);
|
std::ifstream ifs(to_osmbstr(file_utf8));
|
||||||
std::ifstream ifs(fs_mbs.data());
|
|
||||||
|
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
return false;
|
return false;
|
||||||
@@ -245,14 +243,13 @@ namespace skeletons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_m_saved(fs);
|
_m_saved(file_utf8);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void store(nana::string fs, bool is_unicode, ::nana::unicode encoding) const
|
void store(std::string fs, bool is_unicode, ::nana::unicode encoding) const
|
||||||
{
|
{
|
||||||
std::string fs_mbs = nana::charset(fs);
|
std::ofstream ofs(to_osmbstr(fs), std::ios::binary);
|
||||||
std::ofstream ofs(fs_mbs.data(), std::ios::binary);
|
|
||||||
if(ofs && text_cont_.size())
|
if(ofs && text_cont_.size())
|
||||||
{
|
{
|
||||||
std::string last_mbs;
|
std::string last_mbs;
|
||||||
@@ -410,7 +407,9 @@ namespace skeletons
|
|||||||
{
|
{
|
||||||
std::deque<string_type>().swap(text_cont_);
|
std::deque<string_type>().swap(text_cont_);
|
||||||
attr_max_.reset();
|
attr_max_.reset();
|
||||||
_m_saved(nana::string());
|
text_cont_.emplace_back(); //text_cont_ must not be empty
|
||||||
|
|
||||||
|
_m_saved(std::string());
|
||||||
}
|
}
|
||||||
|
|
||||||
void merge(size_type pos)
|
void merge(size_type pos)
|
||||||
@@ -427,7 +426,7 @@ namespace skeletons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const nana::string& filename() const
|
const std::string& filename() const
|
||||||
{
|
{
|
||||||
return filename_;
|
return filename_;
|
||||||
}
|
}
|
||||||
@@ -489,7 +488,7 @@ namespace skeletons
|
|||||||
evt_agent_->first_change();
|
evt_agent_->first_change();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _m_saved(nana::string && filename) const
|
void _m_saved(std::string && filename) const
|
||||||
{
|
{
|
||||||
if(filename_ != filename)
|
if(filename_ != filename)
|
||||||
{
|
{
|
||||||
@@ -518,7 +517,7 @@ namespace skeletons
|
|||||||
textbase_event_agent_interface* evt_agent_{ nullptr };
|
textbase_event_agent_interface* evt_agent_{ nullptr };
|
||||||
|
|
||||||
mutable bool changed_{ false };
|
mutable bool changed_{ false };
|
||||||
mutable nana::string filename_; //A string for the saved filename.
|
mutable std::string filename_; //A string for the saved filename.
|
||||||
const string_type nullstr_;
|
const string_type nullstr_;
|
||||||
|
|
||||||
struct attr_max
|
struct attr_max
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~provider() = default;
|
virtual ~provider() = default;
|
||||||
virtual nana::string adorn_trace(unsigned vmax, unsigned vadorn) const = 0;
|
virtual std::string adorn_trace(unsigned vmax, unsigned vadorn) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class renderer
|
class renderer
|
||||||
@@ -81,7 +81,7 @@ namespace nana
|
|||||||
|
|
||||||
virtual void background(window, graph_reference, bool isglass) = 0;
|
virtual void background(window, graph_reference, bool isglass) = 0;
|
||||||
virtual void adorn(window, graph_reference, const adorn_t&) = 0;
|
virtual void adorn(window, graph_reference, const adorn_t&) = 0;
|
||||||
virtual void adorn_textbox(window, graph_reference, const nana::string&, const nana::rectangle&) = 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 bar(window, graph_reference, const bar_t&) = 0;
|
||||||
virtual void slider(window, graph_reference, const slider_t&) = 0;
|
virtual void slider(window, graph_reference, const slider_t&) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -97,17 +97,17 @@ namespace nana
|
|||||||
void range(std::initializer_list<std::wstring> values);
|
void range(std::initializer_list<std::wstring> values);
|
||||||
|
|
||||||
/// Gets the spined value
|
/// Gets the spined value
|
||||||
::nana::string value() const;
|
::std::string value() const;
|
||||||
void value(const ::nana::string&);
|
void value(const ::std::string&);
|
||||||
int to_int() const;
|
int to_int() const;
|
||||||
double to_double() const;
|
double to_double() const;
|
||||||
|
|
||||||
/// Sets the modifiers
|
/// Sets the modifiers
|
||||||
void modifier(std::wstring prefix, std::wstring suffix);
|
void modifier(std::string prefix_utf8, std::string suffix_utf8);
|
||||||
void modifier(const std::string & prefix_utf8, const std::string& suffix_utf8);
|
void modifier(const std::wstring & prefix, const std::wstring& suffix);
|
||||||
private:
|
private:
|
||||||
::nana::string _m_caption() const throw();
|
native_string_type _m_caption() const throw();
|
||||||
void _m_caption(::nana::string&&);
|
void _m_caption(native_string_type&&);
|
||||||
}; //end class spinbox
|
}; //end class spinbox
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A Tabbar implementation
|
* A Tabbar 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
|
||||||
@@ -144,12 +144,14 @@ namespace nana
|
|||||||
: public drawer_trigger
|
: public drawer_trigger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using native_string_type = ::nana::detail::native_string_type;
|
||||||
|
|
||||||
enum class kits
|
enum class kits
|
||||||
{
|
{
|
||||||
add,
|
add, ///< The type identifies the add button of the tabbar's toolbox.
|
||||||
scroll,
|
scroll, ///< The type identifies the scroll button of the tabbar's toolbox
|
||||||
list,
|
list, ///< The type identifies the list button of the tabbar's toolbox
|
||||||
close
|
close ///< The type identifies the close button of the tabbar's toolbox
|
||||||
};
|
};
|
||||||
|
|
||||||
trigger();
|
trigger();
|
||||||
@@ -161,15 +163,15 @@ namespace nana
|
|||||||
const pat::cloneable<item_renderer> & ext_renderer() const;
|
const pat::cloneable<item_renderer> & ext_renderer() const;
|
||||||
void ext_renderer(const pat::cloneable<item_renderer>&);
|
void ext_renderer(const pat::cloneable<item_renderer>&);
|
||||||
void set_event_agent(event_agent_interface*);
|
void set_event_agent(event_agent_interface*);
|
||||||
void insert(std::size_t, nana::string&&, nana::any&&);
|
void insert(std::size_t, native_string_type&&, nana::any&&);
|
||||||
std::size_t length() const;
|
std::size_t length() const;
|
||||||
bool close_fly(bool);
|
bool close_fly(bool);
|
||||||
void attach(std::size_t, window);
|
void attach(std::size_t, window);
|
||||||
void erase(std::size_t);
|
void erase(std::size_t);
|
||||||
void tab_color(std::size_t, bool is_bgcolor, const ::nana::color&);
|
void tab_color(std::size_t, bool is_bgcolor, const ::nana::color&);
|
||||||
void tab_image(size_t, const nana::paint::image&);
|
void tab_image(size_t, const nana::paint::image&);
|
||||||
void text(std::size_t, const nana::string&);
|
void text(std::size_t, const native_string_type&);
|
||||||
nana::string text(std::size_t) const;
|
native_string_type text(std::size_t) const;
|
||||||
bool toolbox(kits, bool);
|
bool toolbox(kits, bool);
|
||||||
private:
|
private:
|
||||||
void attached(widget_reference, graph_reference) override;
|
void attached(widget_reference, graph_reference) override;
|
||||||
@@ -191,30 +193,9 @@ namespace nana
|
|||||||
{
|
{
|
||||||
typedef drawerbase::tabbar::trigger drawer_trigger_t;
|
typedef drawerbase::tabbar::trigger drawer_trigger_t;
|
||||||
public:
|
public:
|
||||||
typedef Type value_type; ///< The type of element data which is stored in the tabbar.
|
using value_type = Type; ///< The type of element data which is stored in the tabbar.
|
||||||
typedef drawerbase::tabbar::item_renderer item_renderer; ///< A user-defined item renderer should be derived from this interface.
|
using item_renderer = drawerbase::tabbar::item_renderer; ///< A user-defined item renderer should be derived from this interface.
|
||||||
|
using kits = drawer_trigger_t::kits;
|
||||||
//These member types is deprecated, they will be removed in Nana 1.3
|
|
||||||
struct button_add{}; ///< The type identifies the add button of the tabbar's toolbox.
|
|
||||||
struct button_scroll{}; ///< The type identifies the scroll button of the tabbar's toolbox.
|
|
||||||
struct button_list{}; ///< The type identifies the list button of the tabbar's toolbox.
|
|
||||||
struct button_close{}; ///< The type identifies the close button of the tabbar's toolbox.
|
|
||||||
|
|
||||||
//This template class is deprecated, it will be removed in 1.3
|
|
||||||
/// A template class identifies the buttons of the tabbar's toolbox. Refer to notes for more details.
|
|
||||||
template<typename ButtonAdd = nana::null_type, typename ButtonScroll = nana::null_type, typename ButtonList = nana::null_type, typename ButtonClose = nana::null_type>
|
|
||||||
struct button_container
|
|
||||||
{
|
|
||||||
typedef meta::fixed_type_set<ButtonAdd, ButtonScroll, ButtonList, ButtonClose> type_set;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class kits
|
|
||||||
{
|
|
||||||
add, ///< The type identifies the add button of the tabbar's toolbox.
|
|
||||||
scroll, ///< The type identifies the scroll button of the tabbar's toolbox
|
|
||||||
list, ///< The type identifies the list button of the tabbar's toolbox
|
|
||||||
close ///< The type identifies the close button of the tabbar's toolbox
|
|
||||||
};
|
|
||||||
|
|
||||||
tabbar()
|
tabbar()
|
||||||
{
|
{
|
||||||
@@ -241,7 +222,7 @@ namespace nana
|
|||||||
|
|
||||||
value_type & operator[](std::size_t pos) const
|
value_type & operator[](std::size_t pos) const
|
||||||
{
|
{
|
||||||
return static_cast<value_type&>(this->get_drawer_trigger().at_no_bound_check(pos));
|
return any_cast<value_type&>(this->get_drawer_trigger().at_no_bound_check(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void activated(std::size_t pos) /// Activates a tab specified by pos.
|
void activated(std::size_t pos) /// Activates a tab specified by pos.
|
||||||
@@ -298,15 +279,19 @@ namespace nana
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_back(nana::string text) /// Append a new item.
|
void push_back(std::string text) /// Append a new item.
|
||||||
{
|
{
|
||||||
this->get_drawer_trigger().insert(::nana::npos, std::move(text), value_type());
|
this->get_drawer_trigger().insert(::nana::npos, to_nstring(std::move(text)), value_type());
|
||||||
API::update_window(*this);
|
API::update_window(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(std::size_t pos, std::string text, value_type value = {})
|
void insert(std::size_t pos, std::string text, value_type value = {})
|
||||||
{
|
{
|
||||||
return this->insert(pos, static_cast<std::wstring>(nana::charset(text, nana::unicode::utf8)), std::move(value));
|
if (pos > length())
|
||||||
|
throw std::out_of_range("tabbar::insert invalid position");
|
||||||
|
|
||||||
|
this->get_drawer_trigger().insert(pos, to_nstring(text), std::move(value));
|
||||||
|
API::update_window(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(std::size_t pos, std::wstring text, value_type value = {})
|
void insert(std::size_t pos, std::wstring text, value_type value = {})
|
||||||
@@ -314,16 +299,10 @@ namespace nana
|
|||||||
if (pos > length())
|
if (pos > length())
|
||||||
throw std::out_of_range("tabbar::insert invalid position");
|
throw std::out_of_range("tabbar::insert invalid position");
|
||||||
|
|
||||||
this->get_drawer_trigger().insert(pos, std::move(text), std::move(value));
|
this->get_drawer_trigger().insert(pos, to_nstring(text), std::move(value));
|
||||||
API::update_window(*this);
|
API::update_window(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//deprecated from 1.2.1, removed from 1.3
|
|
||||||
void relate(std::size_t pos, window wd) /// Binds a window to an item specified by pos, if the item is selected, shows the window, otherwise, hides it.
|
|
||||||
{
|
|
||||||
this->get_drawer_trigger().attach(pos, wd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void attach(std::size_t pos, window attach_wd)
|
void attach(std::size_t pos, window attach_wd)
|
||||||
{
|
{
|
||||||
if (attach_wd && API::empty_window(attach_wd))
|
if (attach_wd && API::empty_window(attach_wd))
|
||||||
@@ -351,46 +330,22 @@ namespace nana
|
|||||||
{
|
{
|
||||||
this->get_drawer_trigger().tab_image(pos, img);
|
this->get_drawer_trigger().tab_image(pos, img);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets buttons of the tabbar's toolbox, refer to notes for more details.
|
/// Sets buttons of the tabbar's toolbox, refer to notes for more details.
|
||||||
template<typename Add, typename Scroll, typename List, typename Close>
|
|
||||||
void toolbox(const button_container<Add, Scroll, List, Close>&, bool enable)
|
|
||||||
{
|
|
||||||
typedef typename button_container<Add, Scroll, List, Close>::type_set type_set;
|
|
||||||
auto & tg = this->get_drawer_trigger();
|
|
||||||
bool redraw = false;
|
|
||||||
|
|
||||||
using inner_kits = drawerbase::tabbar::trigger::kits;
|
|
||||||
|
|
||||||
if(type_set::template count<button_add>::value)
|
|
||||||
redraw |= tg.toolbox(inner_kits::add, enable);
|
|
||||||
|
|
||||||
if(type_set::template count<button_scroll>::value)
|
|
||||||
redraw |= tg.toolbox(inner_kits::scroll, enable);
|
|
||||||
|
|
||||||
if(type_set::template count<button_list>::value)
|
|
||||||
redraw |= tg.toolbox(inner_kits::add, enable);
|
|
||||||
|
|
||||||
if(type_set::template count<button_close>::value)
|
|
||||||
redraw |= tg.toolbox(inner_kits::close, enable);
|
|
||||||
|
|
||||||
if(redraw)
|
|
||||||
API::refresh_window(this->handle());
|
|
||||||
}
|
|
||||||
|
|
||||||
void toolbox(kits kit, bool enable)
|
void toolbox(kits kit, bool enable)
|
||||||
{
|
{
|
||||||
if (this->get_drawer_trigger().toolbox(kit, enable))
|
if (this->get_drawer_trigger().toolbox(kit, enable))
|
||||||
API::refresh_window(this->handle());
|
API::refresh_window(this->handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
void text(std::size_t pos, const nana::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.
|
void text(std::size_t pos, const std::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object.
|
||||||
{
|
{
|
||||||
this->get_drawer_trigger().text(pos, str);
|
this->get_drawer_trigger().text(pos, to_nstring(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
nana::string text(std::size_t pos) const /// Returns a title of a specified item, If pos is invalid, the method trhows a std::out_of_range object.
|
std::string text(std::size_t pos) const /// Returns a title of a specified item, If pos is invalid, the method trhows a std::out_of_range object.
|
||||||
{
|
{
|
||||||
return this->get_drawer_trigger().text(pos);
|
return to_utf8(this->get_drawer_trigger().text(pos));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<drawerbase::tabbar::event_agent<value_type, drawerbase::tabbar::trigger> > evt_agent_;
|
std::unique_ptr<drawerbase::tabbar::event_agent<value_type, drawerbase::tabbar::trigger> > evt_agent_;
|
||||||
|
|||||||
@@ -111,13 +111,13 @@ namespace nana
|
|||||||
/// @param window A handle to the parent window of the widget being created.
|
/// @param window A handle to the parent window of the widget being created.
|
||||||
/// @param text the text that will be displayed.
|
/// @param text the text that will be displayed.
|
||||||
/// @param visible specifying the visible after creating.
|
/// @param visible specifying the visible after creating.
|
||||||
textbox(window, const nana::string& text, bool visible = true);
|
textbox(window, const std::string& text, bool visible = true);
|
||||||
|
|
||||||
/// \brief The construct that creates a widget with a specified text.
|
/// \brief The construct that creates a widget with a specified text.
|
||||||
/// @param window A handle to the parent window of the widget being created.
|
/// @param window A handle to the parent window of the widget being created.
|
||||||
/// @param text the text that will be displayed.
|
/// @param text the text that will be displayed.
|
||||||
/// @param visible specifying the visible after creating.
|
/// @param visible specifying the visible after creating.
|
||||||
textbox(window, const nana::char_t* text, bool visible = true);
|
textbox(window, const char* text, bool visible = true);
|
||||||
|
|
||||||
/// \brief The construct that creates a widget.
|
/// \brief The construct that creates a widget.
|
||||||
/// @param window A handle to the parent window of the widget being created.
|
/// @param window A handle to the parent window of the widget being created.
|
||||||
@@ -126,19 +126,19 @@ namespace nana
|
|||||||
textbox(window, const rectangle& = rectangle(), bool visible = true);
|
textbox(window, const rectangle& = rectangle(), bool visible = true);
|
||||||
|
|
||||||
/// \brief Loads a text file. When attempt to load a unicode encoded text file, be sure the file have a BOM header.
|
/// \brief Loads a text file. When attempt to load a unicode encoded text file, be sure the file have a BOM header.
|
||||||
void load(nana::string file);
|
void load(std::string file);
|
||||||
void store(nana::string file);
|
void store(std::string file);
|
||||||
void store(nana::string file, nana::unicode encoding);
|
void store(std::string file, nana::unicode encoding);
|
||||||
|
|
||||||
/// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter.
|
/// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter.
|
||||||
/// @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<nana::string()> generator = {});
|
textbox& indention(bool, std::function<std::string()> generator = {});
|
||||||
|
|
||||||
//A workaround for reset, explicit default constructor syntax, because VC2013 incorrectly treats {} as {0}.
|
//A workaround for reset, explicit default constructor syntax, because VC2013 incorrectly treats {} as {0}.
|
||||||
textbox& reset(nana::string = nana::string()); ///< discard the old text and set a new text
|
textbox& reset(const std::string& = std::string()); ///< discard the old text and set a new text
|
||||||
|
|
||||||
/// The file of last store operation.
|
/// The file of last store operation.
|
||||||
nana::string filename() const;
|
std::string filename() const;
|
||||||
|
|
||||||
/// Determine whether the text was edited.
|
/// Determine whether the text was edited.
|
||||||
bool edited() const;
|
bool edited() const;
|
||||||
@@ -150,7 +150,7 @@ namespace nana
|
|||||||
bool saved() const;
|
bool saved() const;
|
||||||
|
|
||||||
/// Read the text from a specified line. It returns true for success.
|
/// Read the text from a specified line. It returns true for success.
|
||||||
bool getline(std::size_t pos, nana::string&) const;
|
bool getline(std::size_t pos, std::string&) const;
|
||||||
|
|
||||||
/// Gets the caret position
|
/// Gets the caret position
|
||||||
/// Returns true if the caret is in the area of display, false otherwise.
|
/// Returns true if the caret is in the area of display, false otherwise.
|
||||||
@@ -160,7 +160,7 @@ namespace nana
|
|||||||
textbox& caret_pos(const upoint&);
|
textbox& caret_pos(const upoint&);
|
||||||
|
|
||||||
/// 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 nana::string& text, bool at_caret);
|
textbox& append(const std::string& text, bool at_caret);
|
||||||
|
|
||||||
/// Determine wheter the text is line wrapped.
|
/// Determine wheter the text is line wrapped.
|
||||||
bool line_wrapped() const;
|
bool line_wrapped() const;
|
||||||
@@ -171,12 +171,12 @@ namespace nana
|
|||||||
textbox& multi_lines(bool);
|
textbox& multi_lines(bool);
|
||||||
bool editable() const;
|
bool editable() const;
|
||||||
textbox& editable(bool);
|
textbox& editable(bool);
|
||||||
void set_accept(std::function<bool(nana::char_t)>);
|
void set_accept(std::function<bool(wchar_t)>);
|
||||||
|
|
||||||
textbox& tip_string(nana::string);
|
textbox& tip_string(::std::string);
|
||||||
|
|
||||||
/// Set a mask character. Text is displayed as mask character if a mask character is set. This is used for hiding some special text, such as password.
|
/// Set a mask character. Text is displayed as mask character if a mask character is set. This is used for hiding some special text, such as password.
|
||||||
textbox& mask(nana::char_t);
|
textbox& mask(wchar_t);
|
||||||
|
|
||||||
/// Returns true if some text is selected.
|
/// Returns true if some text is selected.
|
||||||
bool selected() const;
|
bool selected() const;
|
||||||
@@ -195,10 +195,9 @@ namespace nana
|
|||||||
|
|
||||||
void set_highlight(const std::string& name, const ::nana::color& fgcolor, const ::nana::color& bgcolor);
|
void set_highlight(const std::string& name, const ::nana::color& fgcolor, const ::nana::color& bgcolor);
|
||||||
void erase_highlight(const std::string& name);
|
void erase_highlight(const std::string& name);
|
||||||
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<nana::string> kw_list);
|
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<std::wstring> kw_list);
|
||||||
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<std::string> kw_list_utf8);
|
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<std::string> kw_list_utf8);
|
||||||
void erase_keyword(const nana::string& kw);
|
void erase_keyword(const std::string& kw);
|
||||||
|
|
||||||
|
|
||||||
/// Returns the text position of each line that currently displays on screen.
|
/// Returns the text position of each line that currently displays on screen.
|
||||||
text_positions text_position() const;
|
text_positions text_position() const;
|
||||||
@@ -210,8 +209,8 @@ namespace nana
|
|||||||
unsigned line_pixels() const;
|
unsigned line_pixels() const;
|
||||||
protected:
|
protected:
|
||||||
//Overrides widget's virtual functions
|
//Overrides widget's virtual functions
|
||||||
::nana::string _m_caption() const throw() override;
|
native_string_type _m_caption() const throw() override;
|
||||||
void _m_caption(::nana::string&&) override;
|
void _m_caption(native_string_type&&) override;
|
||||||
void _m_typeface(const paint::font&) override;
|
void _m_typeface(const paint::font&) override;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A Toolbar Implementation
|
* A Toolbar 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
|
||||||
@@ -83,15 +83,22 @@ namespace nana
|
|||||||
using size_type = std::size_t; ///< A type to count the number of elements.
|
using size_type = std::size_t; ///< A type to count the number of elements.
|
||||||
|
|
||||||
toolbar() = default;
|
toolbar() = default;
|
||||||
toolbar(window, bool visible);
|
toolbar(window, bool visible, bool detached=false);
|
||||||
toolbar(window, const rectangle& = rectangle(), bool visible = true);
|
toolbar(window, const rectangle& = rectangle(), bool visible = true, bool detached = false);
|
||||||
|
|
||||||
void separate(); ///< Adds a separator.
|
void separate(); ///< Adds a separator.
|
||||||
void append(const nana::string& text, const nana::paint::image& img); ///< Adds a control button.
|
void append(const ::std::string& text, const nana::paint::image& img); ///< Adds a control button.
|
||||||
void append(const nana::string& text); ///< Adds a control button.
|
void append(const ::std::string& text); ///< Adds a control button.
|
||||||
bool enable(size_type index) const;
|
bool enable(size_type index) const;
|
||||||
void enable(size_type index, bool enable_state);
|
void enable(size_type index, bool enable_state);
|
||||||
void scale(unsigned s); ///< Sets the scale of control button.
|
void scale(unsigned s); ///< Sets the scale of control button.
|
||||||
|
|
||||||
|
void go_right();
|
||||||
|
|
||||||
|
bool detached() { return detached_; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool detached_;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A Tree Box Implementation
|
* A Tree Box 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
|
||||||
@@ -55,7 +55,7 @@ namespace nana
|
|||||||
nana::paint::image icon_normal;
|
nana::paint::image icon_normal;
|
||||||
nana::paint::image icon_hover;
|
nana::paint::image icon_hover;
|
||||||
nana::paint::image icon_expanded;
|
nana::paint::image icon_expanded;
|
||||||
nana::string text;
|
::std::string text;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef widgets::detail::compset<component, node_attribute> compset_interface;
|
typedef widgets::detail::compset<component, node_attribute> compset_interface;
|
||||||
@@ -98,14 +98,14 @@ namespace nana
|
|||||||
struct treebox_node_type
|
struct treebox_node_type
|
||||||
{
|
{
|
||||||
treebox_node_type();
|
treebox_node_type();
|
||||||
treebox_node_type(nana::string);
|
treebox_node_type(std::string);
|
||||||
treebox_node_type& operator=(const treebox_node_type&);
|
treebox_node_type& operator=(const treebox_node_type&);
|
||||||
|
|
||||||
nana::string text;
|
::std::string text;
|
||||||
nana::any value;
|
nana::any value;
|
||||||
bool expanded;
|
bool expanded;
|
||||||
checkstate checked;
|
checkstate checked;
|
||||||
nana::string img_idstr;
|
::std::string img_idstr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pseudo_node_type{};
|
struct pseudo_node_type{};
|
||||||
@@ -133,8 +133,8 @@ namespace nana
|
|||||||
const ::nana::pat::cloneable<compset_placer_interface>& placer() const;
|
const ::nana::pat::cloneable<compset_placer_interface>& placer() const;
|
||||||
|
|
||||||
nana::any & value(node_type*) const;
|
nana::any & value(node_type*) const;
|
||||||
node_type* insert(node_type*, const nana::string& key, nana::string&&);
|
node_type* insert(node_type*, const std::string& key, std::string&&);
|
||||||
node_type* insert(const nana::string& path, nana::string&&);
|
node_type* insert(const std::string& path, std::string&&);
|
||||||
|
|
||||||
bool verify(const void*) const;
|
bool verify(const void*) const;
|
||||||
bool verify_kinship(node_type* parent, node_type* child) const;
|
bool verify_kinship(node_type* parent, node_type* child) const;
|
||||||
@@ -143,16 +143,15 @@ namespace nana
|
|||||||
node_type * selected() const;
|
node_type * selected() const;
|
||||||
void selected(node_type*);
|
void selected(node_type*);
|
||||||
void set_expand(node_type*, bool);
|
void set_expand(node_type*, bool);
|
||||||
void set_expand(const nana::string& path, bool);
|
void set_expand(const ::std::string& path, bool);
|
||||||
|
|
||||||
//void image(const nana::string& id, const node_image_tag&);
|
node_image_tag& icon(const ::std::string&) const;
|
||||||
node_image_tag& icon(const nana::string&) const;
|
void icon_erase(const ::std::string&);
|
||||||
void icon_erase(const nana::string&);
|
void node_icon(node_type*, const ::std::string& id);
|
||||||
void node_icon(node_type*, const nana::string& id);
|
|
||||||
|
|
||||||
unsigned node_width(const node_type*) const;
|
unsigned node_width(const node_type*) const;
|
||||||
|
|
||||||
bool rename(node_type*, const nana::char_t* key, const nana::char_t* name);
|
bool rename(node_type*, const char* key, const char* name);
|
||||||
private:
|
private:
|
||||||
//Overrides drawer_trigger methods
|
//Overrides drawer_trigger methods
|
||||||
void attached(widget_reference, graph_reference) override;
|
void attached(widget_reference, graph_reference) override;
|
||||||
@@ -182,11 +181,11 @@ namespace nana
|
|||||||
item_proxy(trigger*, trigger::node_type*);
|
item_proxy(trigger*, trigger::node_type*);
|
||||||
|
|
||||||
/// Append a child.
|
/// Append a child.
|
||||||
item_proxy append(const nana::string& key, nana::string name);
|
item_proxy append(const ::std::string& key, ::std::string name);
|
||||||
|
|
||||||
/// Append a child with a specified value (user object.).
|
/// Append a child with a specified value (user object.).
|
||||||
template<typename T>
|
template<typename T>
|
||||||
item_proxy append(const nana::string& key, nana::string name, const T&t)
|
item_proxy append(const ::std::string& key, ::std::string name, const T&t)
|
||||||
{
|
{
|
||||||
item_proxy ip = append(key, std::move(name));
|
item_proxy ip = append(key, std::move(name));
|
||||||
if(false == ip.empty())
|
if(false == ip.empty())
|
||||||
@@ -220,22 +219,22 @@ namespace nana
|
|||||||
item_proxy& select(bool);
|
item_proxy& select(bool);
|
||||||
|
|
||||||
/// Return the icon.
|
/// Return the icon.
|
||||||
const nana::string& icon() const;
|
const ::std::string& icon() const;
|
||||||
|
|
||||||
/// Set the icon, and returns itself..
|
/// Set the icon, and returns itself..
|
||||||
item_proxy& icon(const nana::string& id);
|
item_proxy& icon(const ::std::string& id);
|
||||||
|
|
||||||
/// Return the text.
|
/// Return the text.
|
||||||
const nana::string& text() const;
|
const ::std::string& text() const;
|
||||||
|
|
||||||
/// Set a new key, and returns itself..
|
|
||||||
item_proxy& key(const nana::string& s);
|
|
||||||
|
|
||||||
/// Return the key.
|
|
||||||
const nana::string& key() const;
|
|
||||||
|
|
||||||
/// Set the text, and returns itself.
|
/// Set the text, and returns itself.
|
||||||
item_proxy& text(const nana::string&);
|
item_proxy& text(const ::std::string&);
|
||||||
|
|
||||||
|
/// Set a new key, and returns itself..
|
||||||
|
item_proxy& key(const ::std::string& s);
|
||||||
|
|
||||||
|
/// Return the key.
|
||||||
|
const ::std::string& key() const;
|
||||||
|
|
||||||
std::size_t size() const; ///< Returns the number of child nodes.
|
std::size_t size() const; ///< Returns the number of child nodes.
|
||||||
|
|
||||||
@@ -257,7 +256,7 @@ namespace nana
|
|||||||
/// Makes an action for each sub item recursively, returns the item that stops the action where action returns false.
|
/// Makes an action for each sub item recursively, returns the item that stops the action where action returns false.
|
||||||
item_proxy visit_recursively(std::function<bool(item_proxy)> action);
|
item_proxy visit_recursively(std::function<bool(item_proxy)> action);
|
||||||
|
|
||||||
bool operator==(const nana::string& s) const; ///< Compare the text of node with s.
|
bool operator==(const ::std::string& s) const; ///< Compare the text of node with s.
|
||||||
bool operator==(const char* s ) const; ///< Compare the text of node with s.
|
bool operator==(const char* s ) const; ///< Compare the text of node with s.
|
||||||
bool operator==(const wchar_t* s ) const; ///< Compare the text of node with s.
|
bool operator==(const wchar_t* s ) const; ///< Compare the text of node with s.
|
||||||
|
|
||||||
@@ -289,15 +288,15 @@ namespace nana
|
|||||||
bool operator!=(const item_proxy&) const;
|
bool operator!=(const item_proxy&) const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T * value_ptr() const
|
const T * value_ptr() const
|
||||||
{
|
{
|
||||||
return _m_value().get<T>();
|
return any_cast<T>(&_m_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T& value() const
|
const T& value() const
|
||||||
{
|
{
|
||||||
T* p = _m_value().get<T>();
|
auto p = any_cast<T>(&_m_value());
|
||||||
if(nullptr == p)
|
if(nullptr == p)
|
||||||
throw std::runtime_error("treebox::value<T>() Invalid type of value.");
|
throw std::runtime_error("treebox::value<T>() Invalid type of value.");
|
||||||
return *p;
|
return *p;
|
||||||
@@ -428,28 +427,28 @@ namespace nana
|
|||||||
/// These states are 'normal', 'hovered' and 'expanded'.
|
/// These states are 'normal', 'hovered' and 'expanded'.
|
||||||
/// If 'hovered' or 'expanded' are not set, it uses 'normal' state image for these 2 states.
|
/// If 'hovered' or 'expanded' are not set, it uses 'normal' state image for these 2 states.
|
||||||
/// See also in [documentation](http://nanapro.org/en-us/help/widgets/treebox.htm)
|
/// See also in [documentation](http://nanapro.org/en-us/help/widgets/treebox.htm)
|
||||||
node_image_type& icon(const nana::string& id ///< the name of an icon scheme. If the name is not existing, it creates a new scheme for the name.
|
node_image_type& icon(const ::std::string& id ///< the name of an icon scheme. If the name is not existing, it creates a new scheme for the name.
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void icon_erase(const nana::string& id);
|
void icon_erase(const ::std::string& id);
|
||||||
|
|
||||||
item_proxy find(const nana::string& keypath); ///< Find an item though a specified keypath.
|
item_proxy find(const ::std::string& keypath); ///< Find an item though a specified keypath.
|
||||||
|
|
||||||
/// Inserts a new node to treebox, but if the keypath exists returns the existing node.
|
/// Inserts a new node to treebox, but if the keypath exists returns the existing node.
|
||||||
item_proxy insert(const nana::string& path_key, ///< specifies the node hierarchy
|
item_proxy insert(const ::std::string& path_key, ///< specifies the node hierarchy
|
||||||
nana::string title ///< used for displaying
|
::std::string title ///< used for displaying
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Inserts a new node to treebox, but if the keypath exists returns the existing node.
|
/// Inserts a new node to treebox, but if the keypath exists returns the existing node.
|
||||||
item_proxy insert( item_proxy pos, ///< the parent item node
|
item_proxy insert( item_proxy pos, ///< the parent item node
|
||||||
const nana::string& key, ///< specifies the new node
|
const ::std::string& key, ///< specifies the new node
|
||||||
nana::string title ///< title used for displaying in the new node.
|
::std::string title ///< title used for displaying in the new node.
|
||||||
);
|
);
|
||||||
item_proxy erase(item_proxy i); ///< Removes the node at pos and return the Item proxy following the removed node
|
item_proxy erase(item_proxy i); ///< Removes the node at pos and return the Item proxy following the removed node
|
||||||
|
|
||||||
void erase(const nana::string& keypath); ///< Removes the node by the key path.
|
void erase(const ::std::string& keypath); ///< Removes the node by the key path.
|
||||||
|
|
||||||
nana::string make_key_path(item_proxy i, const nana::string& splitter) const;///<returns the key path
|
::std::string make_key_path(item_proxy i, const ::std::string& splitter) const;///<returns the key path
|
||||||
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
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ namespace nana
|
|||||||
class inner_widget_notifier;
|
class inner_widget_notifier;
|
||||||
typedef void(*dummy_bool_type)(widget* (*)(const widget&));
|
typedef void(*dummy_bool_type)(widget* (*)(const widget&));
|
||||||
public:
|
public:
|
||||||
|
using native_string_type = detail::native_string_type;
|
||||||
|
|
||||||
virtual ~widget() = default;
|
virtual ~widget() = default;
|
||||||
virtual window handle() const = 0; ///< Returns the handle of window, returns 0 if window is not created.
|
virtual window handle() const = 0; ///< Returns the handle of window, returns 0 if window is not created.
|
||||||
bool empty() const; ///< Determines whether the manipulator is handling a window.
|
bool empty() const; ///< Determines whether the manipulator is handling a window.
|
||||||
@@ -41,9 +43,12 @@ namespace nana
|
|||||||
|
|
||||||
window parent() const;
|
window parent() const;
|
||||||
|
|
||||||
nana::string caption() const throw();
|
::std::string caption() const throw();
|
||||||
void caption(std::string utf8);
|
::std::wstring caption_wstring() const throw();
|
||||||
void caption(std::wstring);
|
native_string_type caption_native() const throw();
|
||||||
|
|
||||||
|
widget& caption(std::string utf8);
|
||||||
|
widget& caption(std::wstring);
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
void i18n(std::string msgid, Args&&... args)
|
void i18n(std::string msgid, Args&&... args)
|
||||||
@@ -88,10 +93,10 @@ namespace nana
|
|||||||
|
|
||||||
void umake_event(event_handle eh) const; ///< Deletes an event callback by a handle.
|
void umake_event(event_handle eh) const; ///< Deletes an event callback by a handle.
|
||||||
|
|
||||||
widget& register_shortkey(char_t); ///< Registers a shortkey. To remove a registered key, pass 0.
|
widget& register_shortkey(wchar_t); ///< Registers a shortkey. To remove a registered key, pass 0.
|
||||||
|
|
||||||
widget& take_active(bool activated, window take_if_not_activated);
|
widget& take_active(bool activated, window take_if_not_activated);
|
||||||
widget& tooltip(const nana::string&);
|
widget& tooltip(const ::std::string&);
|
||||||
|
|
||||||
operator dummy_bool_type() const;
|
operator dummy_bool_type() const;
|
||||||
operator window() const;
|
operator window() const;
|
||||||
@@ -105,8 +110,8 @@ namespace nana
|
|||||||
virtual void _m_complete_creation();
|
virtual void _m_complete_creation();
|
||||||
|
|
||||||
virtual general_events& _m_get_general_events() const = 0;
|
virtual general_events& _m_get_general_events() const = 0;
|
||||||
virtual nana::string _m_caption() const throw();
|
virtual native_string_type _m_caption() const throw();
|
||||||
virtual void _m_caption(nana::string&&);
|
virtual void _m_caption(native_string_type&&);
|
||||||
virtual nana::cursor _m_cursor() const;
|
virtual nana::cursor _m_cursor() const;
|
||||||
virtual void _m_cursor(nana::cursor);
|
virtual void _m_cursor(nana::cursor);
|
||||||
virtual void _m_close();
|
virtual void _m_close();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* An Implementation of i18n
|
* An Implementation of i18n
|
||||||
* 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
|
||||||
@@ -28,34 +28,34 @@ namespace nana
|
|||||||
void load_utf8(const std::string& file);
|
void load_utf8(const std::string& file);
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
nana::string get(std::string msgid_utf8, Args&&... args) const
|
::std::string get(std::string msgid_utf8, Args&&... args) const
|
||||||
{
|
{
|
||||||
std::vector<nana::string> arg_strs;
|
std::vector<std::string> arg_strs;
|
||||||
_m_fetch_args(arg_strs, std::forward<Args>(args)...);
|
_m_fetch_args(arg_strs, std::forward<Args>(args)...);
|
||||||
|
|
||||||
nana::string msgstr;
|
::std::string msgstr;
|
||||||
if (_m_get(msgid_utf8, msgstr))
|
if (_m_get(msgid_utf8, msgstr))
|
||||||
_m_replace_args(msgstr, &arg_strs);
|
_m_replace_args(msgstr, &arg_strs);
|
||||||
return msgstr;
|
return msgstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nana::string get(std::string msgid_utf8) const;
|
::std::string get(std::string msgid_utf8) const;
|
||||||
void set(std::string msgid_utf8, nana::string msgstr);
|
void set(std::string msgid_utf8, ::std::string msgstr);
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
nana::string operator()(std::string msgid_utf8, Args&&... args) const
|
::std::string operator()(std::string msgid_utf8, Args&&... args) const
|
||||||
{
|
{
|
||||||
return get(msgid_utf8, std::forward<Args>(args)...);
|
return get(msgid_utf8, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
bool _m_get(std::string& msgid, nana::string& msgstr) const;
|
bool _m_get(std::string& msgid, ::std::string& msgstr) const;
|
||||||
void _m_replace_args(nana::string& str, std::vector<nana::string> * arg_strs) const;
|
void _m_replace_args(::std::string& str, std::vector<::std::string> * arg_strs) const;
|
||||||
|
|
||||||
void _m_fetch_args(std::vector<nana::string>&) const //Termination of _m_fetch_args
|
void _m_fetch_args(std::vector<std::string>&) const //Termination of _m_fetch_args
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename Arg>
|
template<typename Arg>
|
||||||
void _m_fetch_args(std::vector<nana::string>& v, Arg&& arg) const
|
void _m_fetch_args(std::vector<std::string>& v, Arg&& arg) const
|
||||||
{
|
{
|
||||||
std::wstringstream ss;
|
std::wstringstream ss;
|
||||||
ss << arg;
|
ss << arg;
|
||||||
@@ -63,52 +63,39 @@ namespace nana
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
void _m_fetch_args(std::vector<nana::string>& v, const char* arg, Args&&... args) const
|
void _m_fetch_args(std::vector<std::string>& v, const char* arg, Args&&... args) const
|
||||||
{
|
{
|
||||||
std::wstringstream ss;
|
v.emplace_back(arg);
|
||||||
ss << nana::string(nana::charset(arg));
|
|
||||||
v.emplace_back(ss.str());
|
|
||||||
|
|
||||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
void _m_fetch_args(std::vector<nana::string>& v, const std::string& arg, Args&&... args) const
|
void _m_fetch_args(std::vector<std::string>& v, const std::string& arg, Args&&... args) const
|
||||||
{
|
{
|
||||||
std::wstringstream ss;
|
v.emplace_back(arg);
|
||||||
ss << nana::string(nana::charset(arg));
|
|
||||||
v.emplace_back(ss.str());
|
|
||||||
|
|
||||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
void _m_fetch_args(std::vector<nana::string>& v, std::string& arg, Args&&... args) const
|
void _m_fetch_args(std::vector<std::string>& v, std::string& arg, Args&&... args) const
|
||||||
{
|
{
|
||||||
std::wstringstream ss;
|
v.emplace_back(arg);
|
||||||
ss << nana::string(nana::charset(arg));
|
|
||||||
v.emplace_back(ss.str());
|
|
||||||
|
|
||||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
void _m_fetch_args(std::vector<nana::string>& v, std::string&& arg, Args&&... args) const
|
void _m_fetch_args(std::vector<std::string>& v, std::string&& arg, Args&&... args) const
|
||||||
{
|
{
|
||||||
std::wstringstream ss;
|
v.emplace_back(std::move(arg));
|
||||||
ss << nana::string(nana::charset(arg));
|
|
||||||
v.emplace_back(ss.str());
|
|
||||||
|
|
||||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Arg, typename ...Args>
|
template<typename Arg, typename ...Args>
|
||||||
void _m_fetch_args(std::vector<nana::string>& v, Arg&& arg, Args&&... args) const
|
void _m_fetch_args(std::vector<std::string>& v, Arg&& arg, Args&&... args) const
|
||||||
{
|
{
|
||||||
std::wstringstream ss;
|
std::stringstream ss;
|
||||||
ss << arg;
|
ss << arg;
|
||||||
v.emplace_back(ss.str());
|
v.emplace_back(ss.str());
|
||||||
|
|
||||||
_m_fetch_args(v, std::forward<Args>(args)...);
|
_m_fetch_args(v, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
};//end class internationalization
|
};//end class internationalization
|
||||||
@@ -119,7 +106,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~eval_arg() = default;
|
virtual ~eval_arg() = default;
|
||||||
virtual nana::string eval() const = 0;
|
virtual std::string eval() const = 0;
|
||||||
virtual std::unique_ptr<eval_arg> clone() const = 0;
|
virtual std::unique_ptr<eval_arg> clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -134,9 +121,9 @@ namespace nana
|
|||||||
: fn_(fn)
|
: fn_(fn)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
nana::string eval() const override
|
std::string eval() const override
|
||||||
{
|
{
|
||||||
std::wstringstream ss;
|
std::stringstream ss;
|
||||||
ss << fn_();
|
ss << fn_();
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
@@ -166,7 +153,7 @@ namespace nana
|
|||||||
i18n_eval& operator=(const i18n_eval&);
|
i18n_eval& operator=(const i18n_eval&);
|
||||||
i18n_eval& operator=(i18n_eval&& rhs);
|
i18n_eval& operator=(i18n_eval&& rhs);
|
||||||
|
|
||||||
nana::string operator()() const;
|
std::string operator()() const;
|
||||||
private:
|
private:
|
||||||
void _m_fetch_args(){} //Termination of _m_fetch_args
|
void _m_fetch_args(){} //Termination of _m_fetch_args
|
||||||
|
|
||||||
@@ -180,7 +167,7 @@ namespace nana
|
|||||||
template<typename Arg>
|
template<typename Arg>
|
||||||
void _m_add_args(Arg&& arg)
|
void _m_add_args(Arg&& arg)
|
||||||
{
|
{
|
||||||
std::wstringstream ss;
|
std::stringstream ss;
|
||||||
ss << arg;
|
ss << arg;
|
||||||
_m_add_args(ss.str());
|
_m_add_args(ss.str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +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>
|
||||||
|
|
||||||
namespace nana{ namespace paint{
|
namespace nana{ namespace paint{
|
||||||
|
|
||||||
@@ -15,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::char_t* filename) = 0;
|
virtual bool open(const nana::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;
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ namespace detail
|
|||||||
|
|
||||||
void blend(drawable_type dw, const nana::rectangle& r, pixel_color_t, double fade_rate);
|
void blend(drawable_type dw, const nana::rectangle& r, pixel_color_t, double fade_rate);
|
||||||
|
|
||||||
nana::size raw_text_extent_size(drawable_type, const nana::char_t*, std::size_t len);
|
nana::size raw_text_extent_size(drawable_type, const wchar_t*, std::size_t len);
|
||||||
nana::size text_extent_size(drawable_type, const nana::char_t*, std::size_t len);
|
nana::size text_extent_size(drawable_type, const wchar_t*, std::size_t len);
|
||||||
void draw_string(drawable_type, const nana::point&, const nana::char_t *, std::size_t len);
|
void draw_string(drawable_type, const nana::point&, const wchar_t *, std::size_t len);
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace paint
|
}//end namespace paint
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ namespace nana
|
|||||||
font();
|
font();
|
||||||
font(drawable_type);
|
font(drawable_type);
|
||||||
font(const font&);
|
font(const font&);
|
||||||
font(const char_t* name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
|
font(const ::std::string& name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
|
||||||
~font();
|
~font();
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
void make(const char_t* name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
|
void make(const ::std::string& name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false);
|
||||||
void make_raw(const char_t*, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
|
void make_raw(const ::std::string& name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out);
|
||||||
|
|
||||||
void set_default() const;
|
void set_default() const;
|
||||||
::nana::string name() const;
|
::std::string name() const;
|
||||||
unsigned size() const;
|
unsigned size() const;
|
||||||
bool bold() const;
|
bool bold() const;
|
||||||
unsigned height() const;
|
unsigned height() const;
|
||||||
@@ -89,13 +89,15 @@ namespace nana
|
|||||||
void resize(const ::nana::size&);
|
void resize(const ::nana::size&);
|
||||||
void typeface(const font&); ///< Selects a specified font type into the graphics object.
|
void typeface(const font&); ///< Selects a specified font type into the graphics object.
|
||||||
font typeface() const;
|
font typeface() const;
|
||||||
::nana::size text_extent_size(const char_t*) const; ///< Computes the width and height of the specified string of text.
|
::nana::size text_extent_size(const ::std::string&) const;
|
||||||
::nana::size text_extent_size(const string&) const; ///< Computes the width and height of the specified string of text.
|
::nana::size text_extent_size(const char*, std::size_t len) const;
|
||||||
::nana::size text_extent_size(const char_t*, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
|
::nana::size text_extent_size(const wchar_t*) const; ///< Computes the width and height of the specified string of text.
|
||||||
::nana::size text_extent_size(const string&, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
|
::nana::size text_extent_size(const ::std::wstring&) const; ///< Computes the width and height of the specified string of text.
|
||||||
::nana::size glyph_extent_size(const char_t*, std::size_t length, std::size_t begin, std::size_t end) const;
|
::nana::size text_extent_size(const wchar_t*, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
|
||||||
::nana::size glyph_extent_size(const string&, std::size_t length, std::size_t begin, std::size_t end) const;
|
::nana::size text_extent_size(const ::std::wstring&, std::size_t length) const; ///< Computes the width and height of the specified string of text with the specified length.
|
||||||
bool glyph_pixels(const char_t *, std::size_t length, unsigned* pxbuf) const;
|
::nana::size glyph_extent_size(const wchar_t*, std::size_t length, std::size_t begin, std::size_t end) const;
|
||||||
|
::nana::size glyph_extent_size(const ::std::wstring&, std::size_t length, std::size_t begin, std::size_t end) const;
|
||||||
|
bool glyph_pixels(const wchar_t *, std::size_t length, unsigned* pxbuf) const;
|
||||||
::nana::size bidi_extent_size(const std::wstring&) const;
|
::nana::size bidi_extent_size(const std::wstring&) const;
|
||||||
::nana::size bidi_extent_size(const std::string&) const;
|
::nana::size bidi_extent_size(const std::string&) const;
|
||||||
|
|
||||||
@@ -136,13 +138,10 @@ namespace nana
|
|||||||
/// @param file_utf8 A UTF-8 string to a filename
|
/// @param file_utf8 A UTF-8 string to a filename
|
||||||
void save_as_file(const char* file_utf8) const throw();
|
void save_as_file(const char* file_utf8) const throw();
|
||||||
|
|
||||||
void set_color(const ::nana::color&); //deprecated, graphics::palette() instead
|
|
||||||
void set_text_color(const ::nana::color&); //deprecated, graphics::palette() instead
|
|
||||||
|
|
||||||
::nana::color palette(bool for_text) const;
|
::nana::color palette(bool for_text) const;
|
||||||
graphics& palette(bool for_text, const ::nana::color&);
|
graphics& palette(bool for_text, const ::nana::color&);
|
||||||
|
|
||||||
unsigned bidi_string(const nana::point&, const char_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 blend(const ::nana::rectangle& r, const ::nana::color&, double fade_rate);
|
||||||
@@ -150,10 +149,13 @@ namespace nana
|
|||||||
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);
|
||||||
|
|
||||||
void string(point, const char_t*, std::size_t len);
|
void string(const point&, const std::string& text_utf8);
|
||||||
void string(const point&, const char_t*);
|
void string(const point&, const std::string& text_utf8, const color&);
|
||||||
void string(const point&, const ::nana::string&);
|
|
||||||
void string(const point&, const ::nana::string&, const color&);
|
void string(point, const wchar_t*, std::size_t len);
|
||||||
|
void string(const point&, const wchar_t*);
|
||||||
|
void string(const point&, const ::std::wstring&);
|
||||||
|
void string(const point&, const ::std::wstring&, const color&);
|
||||||
|
|
||||||
void line(const point&, const point&);
|
void line(const point&, const point&);
|
||||||
void line(const point&, const point&, const color&);
|
void line(const point&, const point&, const color&);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Paint Image Implementation
|
* Paint Image 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
|
||||||
@@ -28,24 +28,26 @@ namespace paint
|
|||||||
public:
|
public:
|
||||||
class image_impl_interface;
|
class image_impl_interface;
|
||||||
|
|
||||||
image();
|
image() noexcept;
|
||||||
image(const image&);
|
image(const image&);
|
||||||
image(image&&);
|
image(image&&);
|
||||||
image(const nana::char_t* file);
|
explicit image(const ::std::string& file);
|
||||||
image(const nana::string& filename);
|
explicit image(const ::std::wstring& file);
|
||||||
|
|
||||||
~image();
|
~image();
|
||||||
image& operator=(const image& rhs);
|
image& operator=(const image& rhs);
|
||||||
image& operator=(image&&);
|
image& operator=(image&&);
|
||||||
bool open(const nana::string& filename);
|
bool open(const ::std::string& file);
|
||||||
|
bool open(const ::std::wstring& file);
|
||||||
|
|
||||||
/// Opens an icon from a specified buffer
|
/// Opens an icon from a specified buffer
|
||||||
bool open_icon(const void* data, std::size_t bytes);
|
bool open(const void* data, std::size_t bytes);
|
||||||
bool empty() const;
|
bool empty() const noexcept;
|
||||||
operator unspecified_bool_t() const;
|
operator unspecified_bool_t() const;
|
||||||
void close();
|
void close() noexcept;
|
||||||
|
|
||||||
bool alpha() const;
|
bool alpha() const noexcept;
|
||||||
nana::size size() const;
|
nana::size size() const noexcept;
|
||||||
void paste(graphics& dst, const point& p_dst) const;
|
void paste(graphics& dst, const point& p_dst) const;
|
||||||
void paste(const nana::rectangle& r_src, graphics& dst, const point& p_dst) const;///< Paste the area of picture specified by r_src into the destination graphics specified by dst at position p_dst.
|
void paste(const nana::rectangle& r_src, graphics& dst, const point& p_dst) const;///< Paste the area of picture specified by r_src into the destination graphics specified by dst at position p_dst.
|
||||||
void stretch(const nana::rectangle& r_src, graphics& dst, const nana::rectangle& r_dst) const;///<Paste the picture into the dst, stretching or compressing the picture to fit the given area.
|
void stretch(const nana::rectangle& r_src, graphics& dst, const nana::rectangle& r_dst) const;///<Paste the picture into the dst, stretching or compressing the picture to fit the given area.
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ namespace nana
|
|||||||
|
|
||||||
text_renderer(graph_reference graph, align = align::left);
|
text_renderer(graph_reference graph, align = align::left);
|
||||||
|
|
||||||
nana::size extent_size(int x, int y, const nana::char_t*, std::size_t len, unsigned restricted_pixels) const;
|
nana::size extent_size(int x, int y, const wchar_t*, std::size_t len, unsigned restricted_pixels) const;
|
||||||
|
|
||||||
void render(const point&, const char_t*, std::size_t len);
|
void render(const point&, const wchar_t*, std::size_t len);
|
||||||
void render(const point&, const char_t*, std::size_t len, unsigned restricted_pixels, bool omitted);
|
void render(const point&, const wchar_t*, std::size_t len, unsigned restricted_pixels, bool omitted);
|
||||||
void render(const point&, const char_t*, std::size_t len, unsigned restricted_pixels);
|
void render(const point&, const wchar_t*, std::size_t len, unsigned restricted_pixels);
|
||||||
private:
|
private:
|
||||||
graph_reference graph_;
|
graph_reference graph_;
|
||||||
align text_align_;
|
align text_align_;
|
||||||
|
|||||||
@@ -13,10 +13,12 @@
|
|||||||
#ifndef NANA_PAT_CLONEABLE_HPP
|
#ifndef NANA_PAT_CLONEABLE_HPP
|
||||||
#define NANA_PAT_CLONEABLE_HPP
|
#define NANA_PAT_CLONEABLE_HPP
|
||||||
|
|
||||||
|
#include <nana/c++defines.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
namespace nana{ namespace pat{
|
namespace nana{ namespace pat{
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
@@ -99,9 +101,9 @@ namespace nana{ namespace pat{
|
|||||||
: 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 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() = default;
|
cloneable() noexcept = default;
|
||||||
|
|
||||||
cloneable(std::nullptr_t){}
|
cloneable(std::nullptr_t) noexcept{}
|
||||||
|
|
||||||
template<typename T, typename member_enabled<T>::type* = nullptr>
|
template<typename T, typename member_enabled<T>::type* = nullptr>
|
||||||
cloneable(T&& t)
|
cloneable(T&& t)
|
||||||
@@ -166,22 +168,22 @@ namespace nana{ namespace pat{
|
|||||||
return *fast_ptr_;
|
return *fast_ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_base_ref operator*() const
|
const_base_ref operator*() const noexcept
|
||||||
{
|
{
|
||||||
return *fast_ptr_;
|
return *fast_ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_t * operator->()
|
base_t * operator->() noexcept
|
||||||
{
|
{
|
||||||
return fast_ptr_;
|
return fast_ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_base_ptr operator->() const
|
const_base_ptr operator->() const noexcept
|
||||||
{
|
{
|
||||||
return fast_ptr_;
|
return fast_ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_t * get() const
|
base_t * get() const noexcept
|
||||||
{
|
{
|
||||||
return fast_ptr_;
|
return fast_ptr_;
|
||||||
}
|
}
|
||||||
@@ -192,7 +194,7 @@ namespace nana{ namespace pat{
|
|||||||
cwrapper_.reset();
|
cwrapper_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
operator operator_bool_t() const volatile
|
operator operator_bool_t() const volatile noexcept
|
||||||
{
|
{
|
||||||
return (fast_ptr_ ? &inner_bool::true_stand : nullptr);
|
return (fast_ptr_ ? &inner_bool::true_stand : nullptr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <nana/config.hpp>
|
#include <nana/config.hpp>
|
||||||
|
|
||||||
#if defined(STD_THREAD_NOT_SUPPORTED)
|
#if defined(STD_THREAD_NOT_SUPPORTED)
|
||||||
#if defined(USE_github_com_meganz_mingw_std_threads)
|
#if defined(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
#include <mingw.condition_variable.h>
|
#include <mingw.condition_variable.h>
|
||||||
#else
|
#else
|
||||||
#include <boost/thread/condition_variable.hpp>
|
#include <boost/thread/condition_variable.hpp>
|
||||||
@@ -11,6 +11,6 @@ namespace std
|
|||||||
{
|
{
|
||||||
typedef boost::condition_variable condition_variable;
|
typedef boost::condition_variable condition_variable;
|
||||||
}
|
}
|
||||||
#endif // (USE_github_com_meganz_mingw_std_threads)
|
#endif // (NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
#endif // (STD_THREAD_NOT_SUPPORTED)
|
#endif // (STD_THREAD_NOT_SUPPORTED)
|
||||||
#endif // NANA_STD_CONDITION_VARIABLE_HPP
|
#endif // NANA_STD_CONDITION_VARIABLE_HPP
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#if defined(STD_THREAD_NOT_SUPPORTED)
|
#if defined(STD_THREAD_NOT_SUPPORTED)
|
||||||
|
|
||||||
#if defined(USE_github_com_meganz_mingw_std_threads)
|
#if defined(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
@@ -32,6 +32,6 @@ namespace std
|
|||||||
typedef boost::mutex mutex;
|
typedef boost::mutex mutex;
|
||||||
typedef boost::recursive_mutex recursive_mutex;
|
typedef boost::recursive_mutex recursive_mutex;
|
||||||
}
|
}
|
||||||
#endif // (USE_github_com_meganz_mingw_std_threads)
|
#endif // (NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
#endif // (STD_THREAD_NOT_SUPPORTED)
|
#endif // (STD_THREAD_NOT_SUPPORTED)
|
||||||
#endif // NANA_STD_MUTEX_HPP
|
#endif // NANA_STD_MUTEX_HPP
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#if defined(STD_THREAD_NOT_SUPPORTED)
|
#if defined(STD_THREAD_NOT_SUPPORTED)
|
||||||
|
|
||||||
#if defined(USE_github_com_meganz_mingw_std_threads)
|
#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>
|
||||||
@@ -12,6 +12,6 @@ namespace std
|
|||||||
{
|
{
|
||||||
typedef boost::thread thread;
|
typedef boost::thread thread;
|
||||||
}
|
}
|
||||||
#endif // (USE_github_com_meganz_mingw_std_threads)
|
#endif // (NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
#endif // (STD_THREAD_NOT_SUPPORTED)
|
#endif // (STD_THREAD_NOT_SUPPORTED)
|
||||||
#endif // NANA_STD_THREAD_HPP
|
#endif // NANA_STD_THREAD_HPP
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Data Exchanger Implementation
|
* Data Exchanger Implementation
|
||||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2015 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
|
||||||
@@ -21,22 +21,26 @@ namespace paint{
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace system{
|
namespace system{
|
||||||
/// a data exchange mechanism through Windows Clipboard, X11 Selection.
|
|
||||||
|
/// a data exchange mechanism through Windows Clipboard, X11 Selection.
|
||||||
class dataexch
|
class dataexch
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct format
|
enum class format
|
||||||
{
|
{
|
||||||
enum{ text, unicode, pixmap, end};
|
text, pixmap
|
||||||
};
|
};
|
||||||
|
|
||||||
void set(const nana::char_t* text);
|
void set(const std::string & text_utf8);
|
||||||
void set(const nana::string& text);
|
void set(const std::wstring& text);
|
||||||
|
|
||||||
bool set(const nana::paint::graphics& g);
|
bool set(const nana::paint::graphics& g);
|
||||||
void get(nana::string& str);
|
|
||||||
|
void get(std::string& text_utf8);
|
||||||
|
void get(std::wstring& text);
|
||||||
private:
|
private:
|
||||||
bool _m_set(unsigned type, const void* buf, std::size_t size);
|
bool _m_set(format, const void* buf, std::size_t size);
|
||||||
void* _m_get(unsigned type, size_t& size);
|
void* _m_get(format, size_t& size);
|
||||||
};
|
};
|
||||||
|
|
||||||
}//end namespace system
|
}//end namespace system
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace system
|
|||||||
bool get_async_mouse_state(int button);
|
bool get_async_mouse_state(int button);
|
||||||
|
|
||||||
//open an url through a default browser
|
//open an url through a default browser
|
||||||
void open_url(const nana::string& url);
|
void open_url(const std::string& url);
|
||||||
|
|
||||||
}//end namespace system
|
}//end namespace system
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Operation System Shared Linkage Library Wrapper Implementation
|
* Operation System Shared Linkage Library Wrapper Implementation
|
||||||
* Copyright(C) 2003 Jinhao
|
* Copyright(C) 2003-2016 Jinhao
|
||||||
*
|
*
|
||||||
* 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,7 +13,7 @@
|
|||||||
#define NANA_SYSTEM_SHARED_WRAPPER_HPP
|
#define NANA_SYSTEM_SHARED_WRAPPER_HPP
|
||||||
|
|
||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
#include <nana/traits.hpp>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +69,8 @@ namespace system
|
|||||||
{
|
{
|
||||||
typedef typename function_ptr<Function>::type fptr_type;
|
typedef typename function_ptr<Function>::type fptr_type;
|
||||||
|
|
||||||
if(nana::traits::is_function_pointer<fptr_type>::value == false)
|
//if(nana::traits::is_function_pointer<fptr_type>::value == false)
|
||||||
|
if (::std::is_function<typename std::remove_pointer<fptr_type>::type>::value == false)
|
||||||
throw std::invalid_argument("shared_wrapper::symbols, template<_Function> is not a function type or a function pointer type");
|
throw std::invalid_argument("shared_wrapper::symbols, template<_Function> is not a function type or a function pointer type");
|
||||||
|
|
||||||
if(symbol == 0)
|
if(symbol == 0)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* A Thread Pool Implementation
|
* A Thread Pool 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
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Traits Implementation
|
* Traits Implementation
|
||||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* @file: nana/traits.hpp
|
* @file: nana/traits.hpp
|
||||||
*/
|
*/
|
||||||
@@ -13,502 +13,24 @@ namespace nana
|
|||||||
{
|
{
|
||||||
class null_type{};
|
class null_type{};
|
||||||
|
|
||||||
//The class noncopyable and nonmovable will be deprecated while the compiler
|
/// Prevent a class to be copyable
|
||||||
//supports the deleted functions
|
class noncopyable
|
||||||
struct noncopyable
|
|
||||||
{
|
{
|
||||||
noncopyable(const noncopyable&) = delete;
|
noncopyable(const noncopyable&) = delete;
|
||||||
noncopyable& operator=(const noncopyable&) = delete;
|
noncopyable& operator=(const noncopyable&) = delete;
|
||||||
noncopyable();
|
protected:
|
||||||
|
noncopyable() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nonmovable
|
/// Prevent a class to be movable
|
||||||
|
class nonmovable
|
||||||
{
|
{
|
||||||
nonmovable(nonmovable&&) = delete;
|
nonmovable(nonmovable&&) = delete;
|
||||||
nonmovable& operator=(nonmovable&&) = delete;
|
nonmovable& operator=(nonmovable&&) = delete;
|
||||||
nonmovable();
|
protected:
|
||||||
|
nonmovable() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace traits
|
|
||||||
{
|
|
||||||
//traits types for const-volatile specifier
|
|
||||||
|
|
||||||
struct no_specifier{};
|
|
||||||
struct const_specifier{};
|
|
||||||
struct volatile_specifier{};
|
|
||||||
struct const_volatile_specifier{};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct cv_specifier
|
|
||||||
{
|
|
||||||
typedef no_specifier value_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct cv_specifier<const T>
|
|
||||||
{
|
|
||||||
typedef const_specifier value_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct cv_specifier<volatile T>
|
|
||||||
{
|
|
||||||
typedef volatile_specifier value_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct cv_specifier<const volatile T>
|
|
||||||
{
|
|
||||||
typedef const_volatile_specifier value_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct is_function_pointer
|
|
||||||
: public std::integral_constant<bool, std::is_pointer<T>::value && std::is_function<typename std::remove_pointer<T>::type>::value>
|
|
||||||
{};
|
|
||||||
|
|
||||||
//The traits of pointer to member function
|
|
||||||
template<typename MF>
|
|
||||||
struct mfptr_traits
|
|
||||||
{
|
|
||||||
typedef void function();
|
|
||||||
typedef void return_type;
|
|
||||||
typedef void concept_type;
|
|
||||||
enum{parameter = 0};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept>
|
|
||||||
struct mfptr_traits<R(Concept::*)()>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef return_type function();
|
|
||||||
enum{parameter = 0};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept>
|
|
||||||
struct mfptr_traits<R(Concept::*)() const>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef return_type function();
|
|
||||||
enum{parameter = 0};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept>
|
|
||||||
struct mfptr_traits<R(Concept::*)() volatile>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef return_type function();
|
|
||||||
enum{parameter = 0};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept>
|
|
||||||
struct mfptr_traits<R(Concept::*)() const volatile>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef return_type function();
|
|
||||||
enum{parameter = 0};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P)>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P param0_type;
|
|
||||||
typedef return_type function(param0_type);
|
|
||||||
enum{parameter = 1};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P) const>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P param0_type;
|
|
||||||
typedef return_type function(param0_type);
|
|
||||||
enum{parameter = 1};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P) const volatile>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P param0_type;
|
|
||||||
typedef return_type function(param0_type);
|
|
||||||
enum{parameter = 1};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1)>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef return_type function(param0_type, param1_type);
|
|
||||||
enum{parameter = 2};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1) const>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef return_type function(param0_type, param1_type);
|
|
||||||
enum{parameter = 2};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1) const volatile>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef return_type function(param0_type, param1_type);
|
|
||||||
enum{parameter = 2};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2)>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type);
|
|
||||||
enum{parameter =3};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2) const>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type);
|
|
||||||
enum{parameter =3};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2) volatile>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type);
|
|
||||||
enum{parameter =3};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2) const volatile>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type);
|
|
||||||
enum{parameter =3};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3)>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef P3 param3_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type);
|
|
||||||
enum{parameter = 4};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3) const>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef P3 param3_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type);
|
|
||||||
enum{parameter = 4};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3) volatile>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef P3 param3_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type);
|
|
||||||
enum{parameter = 4};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3) const volatile>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef P3 param3_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type);
|
|
||||||
enum{parameter = 4};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3, typename P4>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3, P4)>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef P3 param3_type;
|
|
||||||
typedef P4 param4_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
|
|
||||||
enum{parameter = 5};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3, typename P4>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3, P4) const>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef P3 param3_type;
|
|
||||||
typedef P4 param4_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
|
|
||||||
enum{parameter = 5};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3, typename P4>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3, P4) volatile>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef P3 param3_type;
|
|
||||||
typedef P4 param4_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
|
|
||||||
enum{parameter = 5};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept, typename P0, typename P1, typename P2, typename P3, typename P4>
|
|
||||||
struct mfptr_traits<R(Concept::*)(P0, P1, P2, P3, P4) const volatile>
|
|
||||||
{
|
|
||||||
typedef Concept concept_type;
|
|
||||||
typedef R return_type;
|
|
||||||
typedef P0 param0_type;
|
|
||||||
typedef P1 param1_type;
|
|
||||||
typedef P2 param2_type;
|
|
||||||
typedef P3 param3_type;
|
|
||||||
typedef P4 param4_type;
|
|
||||||
typedef return_type function(param0_type, param1_type, param2_type, param3_type, param4_type);
|
|
||||||
enum{parameter = 5};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename Function, typename Concept, typename CVSpecifier>
|
|
||||||
struct make_mf
|
|
||||||
{
|
|
||||||
typedef int type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept>
|
|
||||||
struct make_mf<R(), Concept, no_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)();
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept>
|
|
||||||
struct make_mf<R(), Concept, const_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept>
|
|
||||||
struct make_mf<R(), Concept, volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)() volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename Concept>
|
|
||||||
struct make_mf<R(), Concept, const_volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)() const volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename Concept>
|
|
||||||
struct make_mf<R(P0), Concept, no_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename Concept>
|
|
||||||
struct make_mf<R(P0), Concept, const_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename Concept>
|
|
||||||
struct make_mf<R(P0), Concept, volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0) volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename Concept>
|
|
||||||
struct make_mf<R(P0), Concept, const_volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0) const volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1), Concept, no_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1), Concept, const_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1), Concept, volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1) volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1), Concept, const_volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1) const volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2), Concept, no_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2), Concept, const_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2), Concept, volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2) volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2), Concept, const_volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2) const volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3), Concept, no_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3), Concept, const_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3), Concept, volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3) volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3), Concept, const_volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3) const volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3, P4), Concept, no_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3, P4), Concept, const_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3, P4), Concept, volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4) volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3, P4), Concept, const_volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4) const volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3, P4, P5), Concept, no_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4, P5);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3, P4, P5), Concept, const_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4, P5) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3, P4, P5), Concept, volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4, P5) volatile;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename R, typename P0, typename P1, typename P2, typename P3, typename P4, typename P5, typename Concept>
|
|
||||||
struct make_mf<R(P0, P1, P2, P3, P4, P5), Concept, const_volatile_specifier>
|
|
||||||
{
|
|
||||||
typedef R(Concept::*type)(P0, P1, P2, P3, P4, P5) const volatile;
|
|
||||||
};
|
|
||||||
}//end namespace traits
|
|
||||||
|
|
||||||
namespace meta
|
namespace meta
|
||||||
{
|
{
|
||||||
template< typename Param0 = null_type, typename Param1 = null_type,
|
template< typename Param0 = null_type, typename Param1 = null_type,
|
||||||
|
|||||||
56
include/nana/verbose_preprocessor.hpp
Normal file
56
include/nana/verbose_preprocessor.hpp
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* Nana Verbose preprocessor
|
||||||
|
* 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/verbose_preprocessor.hpp
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
* Normally set to 0. Set to 1 only in case you want to debug the build system because it is extremely repetitive and slow.
|
||||||
|
*
|
||||||
|
* @authors Ariel Vina-Rodriguez (qPCR4vir)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// Created by ariel.rodriguez on 08.12.2015.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef NANA_VERBOSE_PREPROCESSOR_H
|
||||||
|
#define NANA_VERBOSE_PREPROCESSOR_H
|
||||||
|
|
||||||
|
#if defined(VERBOSE_PREPROCESSOR)
|
||||||
|
|
||||||
|
#define STRING2(x) #x
|
||||||
|
#define STRING(x) STRING2(x)
|
||||||
|
#pragma message ( "\nVerbose preprocessor =" STRING(VERBOSE_PREPROCESSOR)" , \n STOP_VERBOSE_PREPROCESSOR=" STRING(STOP_VERBOSE_PREPROCESSOR) )
|
||||||
|
|
||||||
|
#pragma message ( "\nWindows: \n _WIN32=" STRING(_WIN32) ", \n __WIN32__ =" STRING(__WIN32__) " , \n WIN32=" STRING(WIN32)" , \n NANA_WINDOWS=" STRING(NANA_WINDOWS) )
|
||||||
|
|
||||||
|
#pragma message ( "\nUNICODE: \n NANA_UNICODE=" STRING(NANA_UNICODE) ", \n _UNICODE =" STRING(_UNICODE) " , \n UNICODE=" STRING(UNICODE) )
|
||||||
|
|
||||||
|
#pragma message ( "\nMinGW: \n __MINGW32__=" STRING(__MINGW32__) ", \n __MINGW64__=" STRING(__MINGW64__) " , \n MINGW=" STRING(MINGW) )
|
||||||
|
|
||||||
|
#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 ( "\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 ( "\nClang compiler: \n__clang__=" STRING(__clang__) ", \n__GLIBCPP__=" STRING(__GLIBCPP__) " , \n__GLIBCXX__=" STRING(__GLIBCXX__) )
|
||||||
|
|
||||||
|
#pragma message ( "\nMSC: \n_MSC_VER=" STRING(_MSC_VER) ", \n_MSC_FULL_VER=" STRING(_MSC_FULL_VER ) )
|
||||||
|
|
||||||
|
#if defined(STOP_VERBOSE_PREPROCESSOR)
|
||||||
|
#error ("\nCompilation stopped to avoid annoying messages")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // VERBOSE_PREPROCESSOR
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //NANA_VERBOSE_PREPROCESSOR_H
|
||||||
119
source/any.cpp
119
source/any.cpp
@@ -1,70 +1,87 @@
|
|||||||
#include <nana/any.hpp>
|
/**
|
||||||
|
* Any
|
||||||
|
* 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/any.cpp
|
||||||
|
*
|
||||||
|
* @brief An implementation of experimental library any of C++ standard(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4480.html#any)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <nana/any.hpp>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
//constructors and destructor
|
||||||
|
any::any() noexcept
|
||||||
|
: content_(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//class any
|
any::any(const any& other)
|
||||||
//struct super_type
|
: content_(other.content_ ? other.content_->clone() : nullptr)
|
||||||
any::super_type::~super_type(){}
|
{}
|
||||||
|
|
||||||
any::super_type& any::super_type::operator=(const super_type &rhs)
|
any::any(any && other) noexcept
|
||||||
{
|
: content_(other.content_)
|
||||||
return assign(rhs);
|
{
|
||||||
}
|
other.content_ = nullptr;
|
||||||
//end struct super_type
|
}
|
||||||
|
|
||||||
any::any()
|
any::~any()
|
||||||
:super_(nullptr)
|
{
|
||||||
{}
|
delete content_;
|
||||||
|
}
|
||||||
|
|
||||||
any::any(const any& rhs)
|
//assignments
|
||||||
:super_(rhs.super_ ? rhs.super_->clone() : nullptr)
|
any& any::operator=(const any& other)
|
||||||
{}
|
{
|
||||||
|
if (this != &other)
|
||||||
|
any(other).swap(*this);
|
||||||
|
|
||||||
any::any(any&& r)
|
return *this;
|
||||||
:super_(r.super_)
|
}
|
||||||
|
|
||||||
|
any& any::operator=(any&& other) noexcept
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
{
|
{
|
||||||
r.super_ = nullptr;
|
other.swap(*this);
|
||||||
|
other.clear();
|
||||||
}
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
any::~any()
|
//modifiers
|
||||||
|
void any::clear() noexcept
|
||||||
|
{
|
||||||
|
if (content_)
|
||||||
{
|
{
|
||||||
delete super_;
|
auto cnt = content_;
|
||||||
|
content_ = nullptr;
|
||||||
|
delete cnt;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
any& any::operator=(const any& rhs)
|
void any::swap(any& other) noexcept
|
||||||
{
|
{
|
||||||
if(this != &rhs)
|
std::swap(content_, other.content_);
|
||||||
{
|
}
|
||||||
delete super_;
|
|
||||||
super_ = (rhs.super_ ? rhs.super_->clone() : nullptr);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
any& any::operator=(any&& r)
|
//observers
|
||||||
{
|
bool any::empty() const noexcept
|
||||||
if(this != &r)
|
{
|
||||||
{
|
return (nullptr == content_);
|
||||||
delete super_;
|
}
|
||||||
super_ = r.super_;
|
|
||||||
r.super_ = nullptr;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool any::same(const any &rhs) const
|
const std::type_info& any::type() const noexcept
|
||||||
{
|
{
|
||||||
if(this != &rhs)
|
return (content_ ? content_->type() : typeid(void));
|
||||||
{
|
}
|
||||||
if(super_ && rhs.super_)
|
|
||||||
return super_->same(*rhs.super_);
|
|
||||||
else if(super_ || rhs.super_)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//end class any
|
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
#include <nana/audio/detail/audio_device.hpp>
|
#include <nana/audio/detail/audio_device.hpp>
|
||||||
|
|
||||||
|
#ifdef NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
#include <nana/system/platform.hpp>
|
#include <nana/system/platform.hpp>
|
||||||
|
|
||||||
#if defined(NANA_LINUX)
|
#if defined(NANA_LINUX)
|
||||||
@@ -235,3 +239,5 @@ namespace nana{namespace audio
|
|||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace audio
|
}//end namespace audio
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#endif //NANA_ENABLE_AUDIO
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
#include <nana/audio/detail/audio_stream.hpp>
|
#include <nana/audio/detail/audio_stream.hpp>
|
||||||
|
#ifdef NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
#include <nana/charset.hpp>
|
#include <nana/charset.hpp>
|
||||||
|
|
||||||
namespace nana{ namespace audio
|
namespace nana{ namespace audio
|
||||||
@@ -6,9 +8,9 @@ namespace nana{ namespace audio
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
//class audio_stream
|
//class audio_stream
|
||||||
bool audio_stream::open(const nana::string& file)
|
bool audio_stream::open(const std::string& file)
|
||||||
{
|
{
|
||||||
fs_.open(static_cast<std::string>(charset(file)), std::ios::binary);
|
fs_.open(to_osmbstr(file), std::ios::binary);
|
||||||
if(fs_)
|
if(fs_)
|
||||||
{
|
{
|
||||||
wave_spec::master_riff_chunk riff;
|
wave_spec::master_riff_chunk riff;
|
||||||
@@ -92,3 +94,4 @@ namespace nana{ namespace audio
|
|||||||
|
|
||||||
}//end namespace audio
|
}//end namespace audio
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
#endif //NANA_ENABLE_AUDIO
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
#include <nana/audio/detail/buffer_preparation.hpp>
|
#include <nana/audio/detail/buffer_preparation.hpp>
|
||||||
|
|
||||||
|
#ifdef NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace nana{ namespace audio
|
namespace nana{ namespace audio
|
||||||
@@ -159,3 +162,5 @@ namespace nana{ namespace audio
|
|||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
}//end namespace audio
|
}//end namespace audio
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#endif //NANA_ENABLE_AUDIO
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
#include <nana/audio/player.hpp>
|
#include <nana/audio/player.hpp>
|
||||||
|
|
||||||
|
#ifdef NANA_ENABLE_AUDIO
|
||||||
|
|
||||||
#include <nana/audio/detail/audio_stream.hpp>
|
#include <nana/audio/detail/audio_stream.hpp>
|
||||||
#include <nana/audio/detail/audio_device.hpp>
|
#include <nana/audio/detail/audio_device.hpp>
|
||||||
#include <nana/audio/detail/buffer_preparation.hpp>
|
#include <nana/audio/detail/buffer_preparation.hpp>
|
||||||
@@ -17,7 +20,7 @@ namespace nana{ namespace audio
|
|||||||
: impl_(new implementation)
|
: impl_(new implementation)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
player::player(const nana::string& file)
|
player::player(const std::string& file)
|
||||||
: impl_(new implementation)
|
: impl_(new implementation)
|
||||||
{
|
{
|
||||||
open(file);
|
open(file);
|
||||||
@@ -28,7 +31,7 @@ namespace nana{ namespace audio
|
|||||||
delete impl_;
|
delete impl_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool player::open(const nana::string& file)
|
bool player::open(const std::string& file)
|
||||||
{
|
{
|
||||||
if(impl_->stream.open(file))
|
if(impl_->stream.open(file))
|
||||||
{
|
{
|
||||||
@@ -63,3 +66,5 @@ namespace nana{ namespace audio
|
|||||||
}
|
}
|
||||||
}//end namespace audio
|
}//end namespace audio
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
#endif //NANA_ENABLE_AUDIO
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* 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-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
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
* @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)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nana/charset.hpp>
|
#include <nana/charset.hpp>
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
#include <cstring> //Added by Pr0curo(pr#98)
|
||||||
|
|
||||||
//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
|
||||||
@@ -30,6 +32,183 @@
|
|||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
namespace utf
|
||||||
|
{
|
||||||
|
const char* char_ptr(const char* text, unsigned pos)
|
||||||
|
{
|
||||||
|
auto ustr = reinterpret_cast<const unsigned char*>(text);
|
||||||
|
auto const end = ustr + std::strlen(text);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i != pos; ++i)
|
||||||
|
{
|
||||||
|
const auto uch = *ustr;
|
||||||
|
if (uch < 0x80)
|
||||||
|
{
|
||||||
|
++ustr;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uch < 0xC0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if ((uch < 0xE0) && (ustr + 1 < end))
|
||||||
|
ustr += 2;
|
||||||
|
else if (uch < 0xF0 && (ustr + 2 <= end))
|
||||||
|
ustr += 3;
|
||||||
|
else if (uch < 0x1F && (ustr + 3 <= end))
|
||||||
|
ustr += 4;
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return reinterpret_cast<const char*>(ustr);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* char_ptr(const std::string& text_utf8, unsigned pos)
|
||||||
|
{
|
||||||
|
auto ustr = reinterpret_cast<const unsigned char*>(text_utf8.c_str());
|
||||||
|
auto const end = ustr + text_utf8.size();
|
||||||
|
|
||||||
|
for (unsigned i = 0; i != pos; ++i)
|
||||||
|
{
|
||||||
|
const auto uch = *ustr;
|
||||||
|
if (uch < 0x80)
|
||||||
|
{
|
||||||
|
++ustr;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uch < 0xC0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if ((uch < 0xE0) && (ustr + 1 < end))
|
||||||
|
ustr += 2;
|
||||||
|
else if (uch < 0xF0 && (ustr + 2 <= end))
|
||||||
|
ustr += 3;
|
||||||
|
else if (uch < 0x1F && (ustr + 3 <= end))
|
||||||
|
ustr += 4;
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return reinterpret_cast<const char*>(ustr);
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t char_at(const char* text_utf8, unsigned pos, unsigned * len)
|
||||||
|
{
|
||||||
|
if (!text_utf8)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (pos)
|
||||||
|
{
|
||||||
|
text_utf8 = char_ptr(text_utf8, pos);
|
||||||
|
if (!text_utf8)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wchar_t uch = *reinterpret_cast<const unsigned char*>(text_utf8);
|
||||||
|
if (uch < 0x80)
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 1;
|
||||||
|
|
||||||
|
return *text_utf8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uch < 0xC0)
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto end = text_utf8 + std::strlen(text_utf8);
|
||||||
|
|
||||||
|
if (uch < 0xE0 && (text_utf8 + 1 <= end))
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 2;
|
||||||
|
return (wchar_t(uch & 0x1F) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[1] & 0x3F);
|
||||||
|
}
|
||||||
|
else if (uch < 0xF0 && (text_utf8 + 2 <= end))
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 3;
|
||||||
|
|
||||||
|
return ((((uch & 0xF) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[1] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[2] & 0x3F);
|
||||||
|
}
|
||||||
|
else if (uch < 0x1F && (text_utf8 + 3 <= end))
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 4;
|
||||||
|
return ((((((uch & 0x7) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[1] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[2] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(text_utf8)[3] & 0x3F);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len)
|
||||||
|
*len = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t char_at(const ::std::string& text_utf8, unsigned pos, unsigned * len)
|
||||||
|
{
|
||||||
|
const char* ptr;
|
||||||
|
if (pos)
|
||||||
|
{
|
||||||
|
ptr = char_ptr(text_utf8, pos);
|
||||||
|
if (!ptr)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ptr = text_utf8.c_str();
|
||||||
|
|
||||||
|
const wchar_t uch = *reinterpret_cast<const unsigned char*>(ptr);
|
||||||
|
if (uch < 0x80)
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 1;
|
||||||
|
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uch < 0xC0)
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto end = text_utf8.c_str() + text_utf8.size();
|
||||||
|
|
||||||
|
if (uch < 0xE0 && (ptr + 1 <= end))
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 2;
|
||||||
|
return (wchar_t(uch & 0x1F) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[1] & 0x3F);
|
||||||
|
}
|
||||||
|
else if (uch < 0xF0 && (ptr + 2 <= end))
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 3;
|
||||||
|
|
||||||
|
return ((((uch & 0xF) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[1] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[2] & 0x3F);
|
||||||
|
}
|
||||||
|
else if (uch < 0x1F && (ptr + 3 <= end))
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 4;
|
||||||
|
return ((((((uch & 0x7) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[1] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[2] & 0x3F)) << 6) | (reinterpret_cast<const unsigned char*>(ptr)[3] & 0x3F);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len)
|
||||||
|
*len = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class locale_initializer
|
class locale_initializer
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include <nana/deploy.hpp>
|
#include <nana/deploy.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cstring> //std::strlen
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
@@ -298,6 +299,7 @@ namespace std
|
|||||||
#endif //STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED
|
#endif //STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED
|
||||||
|
|
||||||
#ifdef STD_TO_STRING_NOT_SUPPORTED
|
#ifdef STD_TO_STRING_NOT_SUPPORTED
|
||||||
|
#include <sstream>
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
std::string to_string(double v)
|
std::string to_string(double v)
|
||||||
@@ -362,7 +364,13 @@ namespace std
|
|||||||
ss << v;
|
ss << v;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif // STD_TO_STRING_NOT_SUPPORTED
|
||||||
|
|
||||||
|
#ifdef STD_TO_WSTRING_NOT_SUPPORTED
|
||||||
|
#include <sstream>
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
std::wstring to_wstring(double v)
|
std::wstring to_wstring(double v)
|
||||||
{
|
{
|
||||||
std::wstringstream ss;
|
std::wstringstream ss;
|
||||||
@@ -430,46 +438,164 @@ namespace std
|
|||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
std::size_t strlen(const char_t* str)
|
bool is_utf8(const char* str, unsigned len)
|
||||||
{
|
{
|
||||||
#if defined(NANA_UNICODE)
|
auto ustr = reinterpret_cast<const unsigned char*>(str);
|
||||||
return ::wcslen(str);
|
auto end = ustr + len;
|
||||||
#else
|
|
||||||
return ::strlen(str);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
char_t* strcpy(char_t* dest, const char_t* source)
|
while (ustr < end)
|
||||||
{
|
|
||||||
#if defined(NANA_UNICODE)
|
|
||||||
return ::wcscpy(dest, source);
|
|
||||||
#else
|
|
||||||
return ::strcpy(dest, source);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace nana
|
|
||||||
{
|
|
||||||
bool is_incomplete(const nana::string& str, unsigned pos)
|
|
||||||
{
|
|
||||||
#ifndef NANA_UNICODE
|
|
||||||
if(pos > str.size())
|
|
||||||
pos = static_cast<unsigned>(str.size());
|
|
||||||
const nana::char_t * pstr = str.c_str();
|
|
||||||
if(pstr[pos] < 0)
|
|
||||||
{
|
{
|
||||||
bool incomp = false;
|
const auto uv = *ustr;
|
||||||
for(unsigned i = 0; i < pos; ++i)
|
if (uv < 0x80)
|
||||||
{
|
{
|
||||||
if(pstr[i] < 0)
|
++ustr;
|
||||||
incomp = !incomp;
|
continue;
|
||||||
else
|
|
||||||
incomp = false;
|
|
||||||
}
|
}
|
||||||
return incomp;
|
|
||||||
|
if (uv < 0xC0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ((uv < 0xE0) && (ustr + 1 < end))
|
||||||
|
ustr += 2;
|
||||||
|
else if (uv < 0xF0 && (ustr + 2 <= end))
|
||||||
|
ustr += 3;
|
||||||
|
else if (uv < 0x1F && (ustr + 3 <= end))
|
||||||
|
ustr += 4;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void throw_not_utf8(const std::string& text)
|
||||||
|
{
|
||||||
|
if (!is_utf8(text.c_str(), text.length()))
|
||||||
|
throw std::invalid_argument("The text is not encoded in UTF8");
|
||||||
|
}
|
||||||
|
|
||||||
|
void throw_not_utf8(const char* text, unsigned len)
|
||||||
|
{
|
||||||
|
if (!is_utf8(text, len))
|
||||||
|
throw std::invalid_argument("The text is not encoded in UTF8");
|
||||||
|
}
|
||||||
|
|
||||||
|
void throw_not_utf8(const char* text)
|
||||||
|
{
|
||||||
|
if (!is_utf8(text, std::strlen(text)))
|
||||||
|
throw std::invalid_argument("The text is not encoded in UTF8");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& to_utf8(const std::string& str)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string to_utf8(const std::wstring& text)
|
||||||
|
{
|
||||||
|
return ::nana::charset(text).to_bytes(::nana::unicode::utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring to_wstring(const std::string& utf8_str)
|
||||||
|
{
|
||||||
|
return ::nana::charset(utf8_str, ::nana::unicode::utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::wstring& to_wstring(const std::wstring& wstr)
|
||||||
|
{
|
||||||
|
return wstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring&& to_wstring(std::wstring&& wstr)
|
||||||
|
{
|
||||||
|
return static_cast<std::wstring&&>(wstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
std::string to_osmbstr(const std::string& text_utf8)
|
||||||
|
{
|
||||||
|
return ::nana::charset(text_utf8, ::nana::unicode::utf8);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
std::string to_osmbstr(std::string text_utf8)
|
||||||
|
{
|
||||||
|
return text_utf8;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
const detail::native_string_type to_nstring(const std::string& text)
|
||||||
|
{
|
||||||
|
return ::nana::charset(text, ::nana::unicode::utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
const detail::native_string_type& to_nstring(const std::wstring& text)
|
||||||
|
{
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::native_string_type to_nstring(std::string&& text)
|
||||||
|
{
|
||||||
|
return ::nana::charset(text, ::nana::unicode::utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::native_string_type&& to_nstring(std::wstring&& text)
|
||||||
|
{
|
||||||
|
return std::move(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::native_string_type to_nstring(int n)
|
||||||
|
{
|
||||||
|
return std::to_wstring(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::native_string_type to_nstring(double d)
|
||||||
|
{
|
||||||
|
return std::to_wstring(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::native_string_type to_nstring(std::size_t d)
|
||||||
|
{
|
||||||
|
return std::to_wstring(d);
|
||||||
|
}
|
||||||
|
#else //POSIX
|
||||||
|
const detail::native_string_type& to_nstring(const std::string& text)
|
||||||
|
{
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
const detail::native_string_type to_nstring(const std::wstring& text)
|
||||||
|
{
|
||||||
|
return ::nana::charset(text).to_bytes(::nana::unicode::utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::native_string_type&& to_nstring(std::string&& text)
|
||||||
|
{
|
||||||
|
return std::move(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::native_string_type to_nstring(std::wstring&& text)
|
||||||
|
{
|
||||||
|
return ::nana::charset(text).to_bytes(::nana::unicode::utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::native_string_type to_nstring(int n)
|
||||||
|
{
|
||||||
|
return std::to_string(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::native_string_type to_nstring(double d)
|
||||||
|
{
|
||||||
|
return std::to_string(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::native_string_type to_nstring(std::size_t d)
|
||||||
|
{
|
||||||
|
return std::to_string(d);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 Nana Software License, Version 1.0.
|
* Distributed under the Nana 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,7 +36,7 @@ namespace nana
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
typedef native_window_type native_window_type;
|
typedef native_window_type native_window_type;
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_USE_XFT)
|
||||||
//class conf
|
//class conf
|
||||||
conf::conf(const char * file)
|
conf::conf(const char * file)
|
||||||
{
|
{
|
||||||
@@ -290,7 +290,7 @@ namespace detail
|
|||||||
string.tab_length = 4;
|
string.tab_length = 4;
|
||||||
string.tab_pixels = 0;
|
string.tab_pixels = 0;
|
||||||
string.whitespace_pixels = 0;
|
string.whitespace_pixels = 0;
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_USE_XFT)
|
||||||
conv_.handle = ::iconv_open("UTF-8", "UTF-32");
|
conv_.handle = ::iconv_open("UTF-8", "UTF-32");
|
||||||
conv_.code = "UTF-32";
|
conv_.code = "UTF-32";
|
||||||
#endif
|
#endif
|
||||||
@@ -298,7 +298,7 @@ namespace detail
|
|||||||
|
|
||||||
drawable_impl_type::~drawable_impl_type()
|
drawable_impl_type::~drawable_impl_type()
|
||||||
{
|
{
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_USE_XFT)
|
||||||
::iconv_close(conv_.handle);
|
::iconv_close(conv_.handle);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -366,7 +366,7 @@ namespace detail
|
|||||||
::XSetForeground(spec.open_display(), context, col);
|
::XSetForeground(spec.open_display(), context, col);
|
||||||
::XSetBackground(spec.open_display(), context, col);
|
::XSetBackground(spec.open_display(), context, col);
|
||||||
|
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_USE_XFT)
|
||||||
xft_fgcolor.color.red = ((0xFF0000 & col) >> 16) * 0x101;
|
xft_fgcolor.color.red = ((0xFF0000 & col) >> 16) * 0x101;
|
||||||
xft_fgcolor.color.green = ((0xFF00 & col) >> 8) * 0x101;
|
xft_fgcolor.color.green = ((0xFF00 & col) >> 8) * 0x101;
|
||||||
xft_fgcolor.color.blue = (0xFF & col) * 0x101;
|
xft_fgcolor.color.blue = (0xFF & col) * 0x101;
|
||||||
@@ -395,7 +395,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
::XSetForeground(spec.open_display(), context, rgb);
|
::XSetForeground(spec.open_display(), context, rgb);
|
||||||
::XSetBackground(spec.open_display(), context, rgb);
|
::XSetBackground(spec.open_display(), context, rgb);
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_USE_XFT)
|
||||||
xft_fgcolor.color.red = ((0xFF0000 & rgb) >> 16) * 0x101;
|
xft_fgcolor.color.red = ((0xFF0000 & rgb) >> 16) * 0x101;
|
||||||
xft_fgcolor.color.green = ((0xFF00 & rgb) >> 8) * 0x101;
|
xft_fgcolor.color.green = ((0xFF00 & rgb) >> 8) * 0x101;
|
||||||
xft_fgcolor.color.blue = (0xFF & rgb) * 0x101;
|
xft_fgcolor.color.blue = (0xFF & rgb) * 0x101;
|
||||||
@@ -412,7 +412,7 @@ namespace detail
|
|||||||
if(fp && fp->handle)
|
if(fp && fp->handle)
|
||||||
{
|
{
|
||||||
platform_scope_guard psg;
|
platform_scope_guard psg;
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_USE_XFT)
|
||||||
::XftFontClose(nana::detail::platform_spec::instance().open_display(), fp->handle);
|
::XftFontClose(nana::detail::platform_spec::instance().open_display(), fp->handle);
|
||||||
#else
|
#else
|
||||||
::XFreeFontSet(nana::detail::platform_spec::instance().open_display(), fp->handle);
|
::XFreeFontSet(nana::detail::platform_spec::instance().open_display(), fp->handle);
|
||||||
@@ -515,7 +515,7 @@ namespace detail
|
|||||||
atombase_.xdnd_finished = ::XInternAtom(display_, "XdndFinished", False);
|
atombase_.xdnd_finished = ::XInternAtom(display_, "XdndFinished", False);
|
||||||
|
|
||||||
//Create default font object.
|
//Create default font object.
|
||||||
def_font_ptr_ = make_native_font(0, font_size_to_height(10), 400, false, false, false);
|
def_font_ptr_ = make_native_font(nullptr, font_size_to_height(10), 400, false, false, false);
|
||||||
msg_dispatcher_ = new msg_dispatcher(display_);
|
msg_dispatcher_ = new msg_dispatcher(display_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -550,17 +550,16 @@ namespace detail
|
|||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_spec::font_ptr_t platform_spec::make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
platform_spec::font_ptr_t platform_spec::make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||||
{
|
{
|
||||||
font_ptr_t ref;
|
font_ptr_t ref;
|
||||||
#if defined(NANA_UNICODE)
|
#if 1 //Xft
|
||||||
if(0 == name || *name == 0)
|
if(0 == name || *name == 0)
|
||||||
name = STR("*");
|
name = "*";
|
||||||
|
|
||||||
std::string nmstr = nana::charset(name);
|
|
||||||
XftFont* handle = 0;
|
XftFont* handle = 0;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<nmstr<<"-"<<(height ? height : 10);
|
ss<<name<<"-"<<(height ? height : 10);
|
||||||
XftPattern * pat = ::XftNameParse(ss.str().c_str());
|
XftPattern * pat = ::XftNameParse(ss.str().c_str());
|
||||||
XftResult res;
|
XftResult res;
|
||||||
XftPattern * match_pat = ::XftFontMatch(display_, ::XDefaultScreen(display_), pat, &res);
|
XftPattern * match_pat = ::XftFontMatch(display_, ::XDefaultScreen(display_), pat, &res);
|
||||||
@@ -1216,7 +1215,7 @@ namespace detail
|
|||||||
0, AnyPropertyType, &type, &format, &len,
|
0, AnyPropertyType, &type, &format, &len,
|
||||||
&dummy_bytes_left, &data))
|
&dummy_bytes_left, &data))
|
||||||
{
|
{
|
||||||
std::vector<nana::string> * files = new std::vector<nana::string>;
|
auto files = new std::vector<std::string>;
|
||||||
std::stringstream ss(reinterpret_cast<char*>(data));
|
std::stringstream ss(reinterpret_cast<char*>(data));
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
@@ -1235,7 +1234,7 @@ namespace detail
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
files->push_back(nana::charset(file));
|
files->push_back(file);
|
||||||
}
|
}
|
||||||
if(files->size())
|
if(files->size())
|
||||||
{
|
{
|
||||||
@@ -1244,6 +1243,8 @@ namespace detail
|
|||||||
msg.u.mouse_drop.y = self.xdnd_.pos.y;
|
msg.u.mouse_drop.y = self.xdnd_.pos.y;
|
||||||
msg.u.mouse_drop.files = files;
|
msg.u.mouse_drop.files = files;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
delete files;
|
||||||
|
|
||||||
accepted = true;
|
accepted = true;
|
||||||
::XFree(data);
|
::XFree(data);
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ namespace detail
|
|||||||
|
|
||||||
//class platform_spec
|
//class platform_spec
|
||||||
platform_spec::co_initializer::co_initializer()
|
platform_spec::co_initializer::co_initializer()
|
||||||
: ole32_(::LoadLibrary(STR("OLE32.DLL")))
|
: ole32_(::LoadLibrary(L"OLE32.DLL"))
|
||||||
{
|
{
|
||||||
if(ole32_)
|
if(ole32_)
|
||||||
{
|
{
|
||||||
@@ -207,7 +207,7 @@ namespace detail
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof metrics, &metrics, 0);
|
::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof metrics, &metrics, 0);
|
||||||
def_font_ptr_ = make_native_font(metrics.lfMessageFont.lfFaceName, font_size_to_height(9), 400, false, false, false);
|
def_font_ptr_ = make_native_font(to_utf8(metrics.lfMessageFont.lfFaceName).c_str(), font_size_to_height(9), 400, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const platform_spec::font_ptr_t& platform_spec::default_native_font() const
|
const platform_spec::font_ptr_t& platform_spec::default_native_font() const
|
||||||
@@ -238,12 +238,15 @@ namespace detail
|
|||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_spec::font_ptr_t platform_spec::make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
platform_spec::font_ptr_t platform_spec::make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||||
{
|
{
|
||||||
::LOGFONT logfont;
|
::LOGFONT logfont;
|
||||||
memset(&logfont, 0, sizeof logfont);
|
memset(&logfont, 0, sizeof logfont);
|
||||||
|
|
||||||
strcpy(logfont.lfFaceName, (name && *name ? name : def_font_ptr_->name.c_str()));
|
if (name && *name)
|
||||||
|
std::wcscpy(logfont.lfFaceName, to_wstring(name).c_str());
|
||||||
|
else
|
||||||
|
std::wcscpy(logfont.lfFaceName, def_font_ptr_->name.c_str());
|
||||||
|
|
||||||
logfont.lfCharSet = DEFAULT_CHARSET;
|
logfont.lfCharSet = DEFAULT_CHARSET;
|
||||||
HDC hdc = ::GetDC(0);
|
HDC hdc = ::GetDC(0);
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* A File Iterator Implementation
|
|
||||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)(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/file_iterator.cpp
|
|
||||||
* @description:
|
|
||||||
* file_iterator is a toolkit for applying each file and directory in a
|
|
||||||
* specified path.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <nana/filesystem/file_iterator.hpp>
|
|
||||||
|
|
||||||
namespace nana
|
|
||||||
{
|
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
//struct fileinfo
|
|
||||||
fileinfo::fileinfo()
|
|
||||||
:size(0), directory(false)
|
|
||||||
{}
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
fileinfo::fileinfo(const WIN32_FIND_DATA& wfd)
|
|
||||||
: name(wfd.cFileName), size(wfd.nFileSizeLow),
|
|
||||||
directory((FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
fileinfo::fileinfo(const nana::string& name, const struct stat& fst)
|
|
||||||
:name(name), size(fst.st_size), directory(0 != S_ISDIR(fst.st_mode))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//end struct fileinfo
|
|
||||||
|
|
||||||
}//end namespace filesystem
|
|
||||||
}//end namespace nana
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,453 +0,0 @@
|
|||||||
/*
|
|
||||||
* A FileSystem Utility Implementation
|
|
||||||
* Copyright(C) 2003-2013 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/fs_utility.cpp
|
|
||||||
* @description:
|
|
||||||
* provide some interface for file managment
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <nana/filesystem/fs_utility.hpp>
|
|
||||||
#include <nana/filesystem/file_iterator.hpp>
|
|
||||||
#include <vector>
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#if defined(NANA_MINGW)
|
|
||||||
#ifndef _WIN32_IE
|
|
||||||
#define _WIN32_IE 0x0500
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <shlobj.h>
|
|
||||||
#include <nana/datetime.hpp>
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
#include <nana/charset.hpp>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstring>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace nana
|
|
||||||
{
|
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
//Because of No wide character version of POSIX
|
|
||||||
#if defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
typedef std::string string_t;
|
|
||||||
const char* splstr = "/\\";
|
|
||||||
#else
|
|
||||||
typedef nana::string string_t;
|
|
||||||
const nana::char_t* splstr = STR("/\\");
|
|
||||||
#endif
|
|
||||||
//class path
|
|
||||||
path::path(){}
|
|
||||||
|
|
||||||
path::path(const nana::string& text)
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
:text_(text)
|
|
||||||
{
|
|
||||||
#else
|
|
||||||
:text_(nana::charset(text))
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
auto pos = text_.find_last_of(splstr);
|
|
||||||
for(; (pos != string_t::npos) && (pos + 1 == text_.size()); pos = text_.find_last_of(splstr))
|
|
||||||
text_.erase(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool path::empty() const
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
return (::GetFileAttributes(text_.c_str()) == INVALID_FILE_ATTRIBUTES);
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
struct stat sta;
|
|
||||||
return (::stat(text_.c_str(), &sta) == -1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
path path::root() const
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
return path(filesystem::root(text_));
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
return path(filesystem::root(nana::charset(text_)));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int path::what() const
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
unsigned long attr = ::GetFileAttributes(text_.c_str());
|
|
||||||
if(INVALID_FILE_ATTRIBUTES == attr)
|
|
||||||
return type::not_exist;
|
|
||||||
|
|
||||||
if(FILE_ATTRIBUTE_DIRECTORY & attr)
|
|
||||||
return type::directory;
|
|
||||||
|
|
||||||
return type::file;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
struct stat sta;
|
|
||||||
if(-1 == ::stat(text_.c_str(), &sta))
|
|
||||||
return type::not_exist;
|
|
||||||
|
|
||||||
if((S_IFDIR & sta.st_mode) == S_IFDIR)
|
|
||||||
return type::directory;
|
|
||||||
|
|
||||||
if((S_IFREG & sta.st_mode) == S_IFREG)
|
|
||||||
return type::file;
|
|
||||||
|
|
||||||
return type::not_exist;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
nana::string path::name() const
|
|
||||||
{
|
|
||||||
string_t::size_type pos = text_.find_last_of(splstr);
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
return text_.substr(pos + 1);
|
|
||||||
#else
|
|
||||||
return nana::charset(text_.substr(pos + 1));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
//end class path
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
//rm_dir_recursive
|
|
||||||
//@brief: remove a directory, if it is not empty, recursively remove it's subfiles and sub directories
|
|
||||||
bool rm_dir_recursive(nana::string&& dir)
|
|
||||||
{
|
|
||||||
std::vector<file_iterator::value_type> files;
|
|
||||||
nana::string path = dir;
|
|
||||||
path += '\\';
|
|
||||||
|
|
||||||
std::copy(file_iterator(dir), file_iterator(), std::back_inserter(files));
|
|
||||||
|
|
||||||
for(auto & f : files)
|
|
||||||
{
|
|
||||||
if(f.directory)
|
|
||||||
rm_dir_recursive(path + f.name);
|
|
||||||
else
|
|
||||||
rmfile((path + f.name).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
return rmdir(dir.c_str(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mkdir_helper(const nana::string& dir, bool & if_exist)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
if(::CreateDirectory(dir.c_str(), 0))
|
|
||||||
{
|
|
||||||
if_exist = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if_exist = (::GetLastError() == ERROR_ALREADY_EXISTS);
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
if(0 == ::mkdir(static_cast<std::string>(nana::charset(dir)).c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
|
|
||||||
{
|
|
||||||
if_exist = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if_exist = (errno == EEXIST);
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
void filetime_to_c_tm(FILETIME& ft, struct tm& t)
|
|
||||||
{
|
|
||||||
FILETIME local_file_time;
|
|
||||||
if(::FileTimeToLocalFileTime(&ft, &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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}//end namespace detail
|
|
||||||
|
|
||||||
bool file_attrib(const nana::string& file, attribute& attr)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
|
||||||
if(::GetFileAttributesEx(file.c_str(), GetFileExInfoStandard, &fad))
|
|
||||||
{
|
|
||||||
LARGE_INTEGER li;
|
|
||||||
li.u.LowPart = fad.nFileSizeLow;
|
|
||||||
li.u.HighPart = fad.nFileSizeHigh;
|
|
||||||
attr.bytes = li.QuadPart;
|
|
||||||
attr.is_directory = (0 != (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
|
|
||||||
detail::filetime_to_c_tm(fad.ftLastWriteTime, attr.modified);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
struct stat fst;
|
|
||||||
if(0 == ::stat(static_cast<std::string>(nana::charset(file)).c_str(), &fst))
|
|
||||||
{
|
|
||||||
attr.bytes = fst.st_size;
|
|
||||||
attr.is_directory = (0 != (040000 & fst.st_mode));
|
|
||||||
attr.modified = *(::localtime(&fst.st_ctime));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
long long filesize(const nana::string& file)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
//Some compilation environment may fail to link to GetFileSizeEx
|
|
||||||
typedef BOOL (__stdcall *GetFileSizeEx_fptr_t)(HANDLE, PLARGE_INTEGER);
|
|
||||||
GetFileSizeEx_fptr_t get_file_size_ex = reinterpret_cast<GetFileSizeEx_fptr_t>(::GetProcAddress(::GetModuleHandleA("Kernel32.DLL"), "GetFileSizeEx"));
|
|
||||||
if(get_file_size_ex)
|
|
||||||
{
|
|
||||||
HANDLE handle = ::CreateFile(file.c_str(), GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
|
||||||
if(INVALID_HANDLE_VALUE != handle)
|
|
||||||
{
|
|
||||||
LARGE_INTEGER li;
|
|
||||||
if(!get_file_size_ex(handle, &li))
|
|
||||||
li.QuadPart = 0;
|
|
||||||
|
|
||||||
::CloseHandle(handle);
|
|
||||||
return li.QuadPart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
#elif defined(NANA_LINUX)
|
|
||||||
FILE * stream = ::fopen(static_cast<std::string>(nana::charset(file)).c_str(), "rb");
|
|
||||||
long long size = 0;
|
|
||||||
if(stream)
|
|
||||||
{
|
|
||||||
fseeko64(stream, 0, SEEK_END);
|
|
||||||
size = ftello64(stream);
|
|
||||||
fclose(stream);
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
#elif defined(NANA_MACOS)
|
|
||||||
FILE * stream = ::fopen(static_cast<std::string>(nana::charset(file)).c_str(), "rb");
|
|
||||||
long long size = 0;
|
|
||||||
if (stream)
|
|
||||||
{
|
|
||||||
fseeko(stream, 0, SEEK_END);
|
|
||||||
size = ftello(stream);
|
|
||||||
fclose(stream);
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool modified_file_time(const nana::string& file, struct tm& t)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
|
||||||
if(::GetFileAttributesEx(file.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_LINUX) || defined(NANA_MACOS)
|
|
||||||
struct stat attr;
|
|
||||||
if(0 == ::stat(static_cast<std::string>(nana::charset(file)).c_str(), &attr))
|
|
||||||
{
|
|
||||||
t = *(::localtime(&attr.st_ctime));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mkdir(const nana::string& path, bool & if_exist)
|
|
||||||
{
|
|
||||||
if_exist = false;
|
|
||||||
if(path.size() == 0) return false;
|
|
||||||
|
|
||||||
nana::string root;
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
if(path.size() > 3 && path[1] == STR(':'))
|
|
||||||
root = path.substr(0, 3);
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
if(path[0] == STR('/'))
|
|
||||||
root = '/';
|
|
||||||
#endif
|
|
||||||
bool mkstat = false;
|
|
||||||
std::size_t beg = root.size();
|
|
||||||
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
beg = path.find_first_not_of(STR("/\\"), beg);
|
|
||||||
if(beg == path.npos)
|
|
||||||
break;
|
|
||||||
|
|
||||||
std::size_t pos = path.find_first_of(STR("/\\"), beg + 1);
|
|
||||||
if(pos != path.npos)
|
|
||||||
{
|
|
||||||
root += path.substr(beg, pos - beg);
|
|
||||||
|
|
||||||
mkstat = detail::mkdir_helper(root, if_exist);
|
|
||||||
if(mkstat == false && if_exist == false)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
root += STR('\\');
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
root += STR('/');
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(beg + 1 < path.size())
|
|
||||||
{
|
|
||||||
root += path.substr(beg);
|
|
||||||
mkstat = detail::mkdir_helper(root, if_exist);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
beg = pos + 1;
|
|
||||||
}
|
|
||||||
return mkstat;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rmfile(const nana::char_t* file)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
bool ret = false;
|
|
||||||
if(file)
|
|
||||||
{
|
|
||||||
ret = (::DeleteFile(file) == TRUE);
|
|
||||||
if(!ret)
|
|
||||||
ret = (ERROR_FILE_NOT_FOUND == ::GetLastError());
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
if(std::remove(static_cast<std::string>(nana::charset(file)).c_str()))
|
|
||||||
return (errno == ENOENT);
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rmdir(const nana::char_t* dir, bool fails_if_not_empty)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
if(dir)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
ret = (::RemoveDirectory(dir) == TRUE);
|
|
||||||
if(!fails_if_not_empty && (::GetLastError() == ERROR_DIR_NOT_EMPTY))
|
|
||||||
ret = detail::rm_dir_recursive(dir);
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
std::string mbstr = nana::charset(dir);
|
|
||||||
if(::rmdir(mbstr.c_str()))
|
|
||||||
{
|
|
||||||
if(!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
|
|
||||||
ret = detail::rm_dir_recursive(dir);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ret = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
nana::string root(const nana::string& path)
|
|
||||||
{
|
|
||||||
std::size_t index = path.size();
|
|
||||||
|
|
||||||
if(index)
|
|
||||||
{
|
|
||||||
const nana::char_t * str = path.c_str();
|
|
||||||
|
|
||||||
for(--index; index > 0; --index)
|
|
||||||
{
|
|
||||||
nana::char_t c = str[index];
|
|
||||||
if(c != '\\' && c != '/')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(--index; index > 0; --index)
|
|
||||||
{
|
|
||||||
nana::char_t c = str[index];
|
|
||||||
if(c == '\\' || c == '/')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return index?path.substr(0, index + 1):nana::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
nana::string path_user()
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
nana::char_t path[MAX_PATH];
|
|
||||||
if(SUCCEEDED(SHGetFolderPath(0, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, path)))
|
|
||||||
return path;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
const char * s = ::getenv("HOME");
|
|
||||||
if(s)
|
|
||||||
return nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8);
|
|
||||||
#endif
|
|
||||||
return nana::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
nana::string path_current()
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
nana::char_t buf[MAX_PATH];
|
|
||||||
DWORD len = ::GetCurrentDirectory(MAX_PATH, buf);
|
|
||||||
if(len)
|
|
||||||
{
|
|
||||||
if(len > MAX_PATH)
|
|
||||||
{
|
|
||||||
nana::char_t * p = new nana::char_t[len + 1];
|
|
||||||
::GetCurrentDirectory(len + 1, p);
|
|
||||||
nana::string s = p;
|
|
||||||
delete [] p;
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
const char * s = ::getenv("PWD");
|
|
||||||
if(s)
|
|
||||||
return nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8);
|
|
||||||
#endif
|
|
||||||
return nana::string();
|
|
||||||
}
|
|
||||||
}//end namespace filesystem
|
|
||||||
}//end namespace nana
|
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
#if defined(STD_THREAD_NOT_SUPPORTED)
|
#if defined(STD_THREAD_NOT_SUPPORTED)
|
||||||
#include <nana/std_thread.hpp>
|
#include <nana/std_thread.hpp>
|
||||||
@@ -350,7 +351,7 @@ namespace nana
|
|||||||
struct animation::impl
|
struct animation::impl
|
||||||
{
|
{
|
||||||
bool looped{false};
|
bool looped{false};
|
||||||
volatile bool paused{true};
|
std::atomic<bool> paused{true};
|
||||||
std::size_t fps;
|
std::size_t fps;
|
||||||
|
|
||||||
std::list<frameset> framesets;
|
std::list<frameset> framesets;
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* A Basic Window Widget Definition
|
||||||
|
* 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/gui/detail/basic_window.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
#include <nana/gui/detail/basic_window.hpp>
|
#include <nana/gui/detail/basic_window.hpp>
|
||||||
#include <nana/gui/detail/native_window_interface.hpp>
|
#include <nana/gui/detail/native_window_interface.hpp>
|
||||||
|
|
||||||
@@ -384,6 +396,7 @@ namespace nana
|
|||||||
flags.make_bground_declared = false;
|
flags.make_bground_declared = false;
|
||||||
flags.ignore_menubar_focus = false;
|
flags.ignore_menubar_focus = false;
|
||||||
flags.ignore_mouse_focus = false;
|
flags.ignore_mouse_focus = false;
|
||||||
|
flags.space_click_enabled = false;
|
||||||
|
|
||||||
visible = false;
|
visible = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
||||||
@@ -233,7 +233,7 @@ namespace detail
|
|||||||
{
|
{
|
||||||
if(wd)
|
if(wd)
|
||||||
{
|
{
|
||||||
internal_scope_guard isg;
|
internal_scope_guard lock;
|
||||||
if(wd_manager().available(wd))
|
if(wd_manager().available(wd))
|
||||||
return wd->other.category;
|
return wd->other.category;
|
||||||
}
|
}
|
||||||
@@ -656,12 +656,17 @@ namespace detail
|
|||||||
|
|
||||||
auto pre_event_window = context.event_window;
|
auto pre_event_window = context.event_window;
|
||||||
auto pressed_wd = root_runtime->condition.pressed;
|
auto pressed_wd = root_runtime->condition.pressed;
|
||||||
|
auto pressed_wd_space = root_runtime->condition.pressed_by_space;
|
||||||
auto hovered_wd = root_runtime->condition.hovered;
|
auto hovered_wd = root_runtime->condition.hovered;
|
||||||
|
|
||||||
const int message = xevent.type;
|
const int message = xevent.type;
|
||||||
switch(xevent.type)
|
switch(xevent.type)
|
||||||
{
|
{
|
||||||
case EnterNotify:
|
case EnterNotify:
|
||||||
|
//Ignore mouse events when a window has been pressed by pressing spacebar.
|
||||||
|
if(pressed_wd_space)
|
||||||
|
break;
|
||||||
|
|
||||||
msgwnd = brock.wd_manager().find_window(native_window, xevent.xcrossing.x, xevent.xcrossing.y);
|
msgwnd = brock.wd_manager().find_window(native_window, xevent.xcrossing.x, xevent.xcrossing.y);
|
||||||
if(msgwnd)
|
if(msgwnd)
|
||||||
{
|
{
|
||||||
@@ -733,6 +738,10 @@ namespace detail
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
|
//Ignore mouse events when a window has been pressed by pressing spacebar
|
||||||
|
if(pressed_wd_space)
|
||||||
|
break;
|
||||||
|
|
||||||
if(xevent.xbutton.button == Button4 || xevent.xbutton.button == Button5)
|
if(xevent.xbutton.button == Button4 || xevent.xbutton.button == Button5)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -788,6 +797,10 @@ namespace detail
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
|
//Ignore mouse events when a window has been pressed by pressing spacebar
|
||||||
|
if(pressed_wd_space)
|
||||||
|
break;
|
||||||
|
|
||||||
if(xevent.xbutton.button == Button4 || xevent.xbutton.button == Button5)
|
if(xevent.xbutton.button == Button4 || xevent.xbutton.button == Button5)
|
||||||
{
|
{
|
||||||
//The hovered window receives the message, unlike in Windows, no redirection is required.
|
//The hovered window receives the message, unlike in Windows, no redirection is required.
|
||||||
@@ -898,6 +911,10 @@ namespace detail
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//Ignore mouse events when a window has been pressed by pressing spacebar
|
||||||
|
if(pressed_wd_space)
|
||||||
|
break;
|
||||||
|
|
||||||
msgwnd = brock.wd_manager().find_window(native_window, xevent.xmotion.x, xevent.xmotion.y);
|
msgwnd = brock.wd_manager().find_window(native_window, xevent.xmotion.x, xevent.xmotion.y);
|
||||||
if (brock.wd_manager().available(hovered_wd) && (msgwnd != hovered_wd))
|
if (brock.wd_manager().available(hovered_wd) && (msgwnd != hovered_wd))
|
||||||
{
|
{
|
||||||
@@ -993,7 +1010,7 @@ namespace detail
|
|||||||
if(input_context)
|
if(input_context)
|
||||||
{
|
{
|
||||||
nana::detail::platform_scope_guard psg;
|
nana::detail::platform_scope_guard psg;
|
||||||
#if defined(NANA_UNICODE)
|
#if 1 //Utf8
|
||||||
len = ::Xutf8LookupString(input_context, &xevent.xkey, keybuf, 32, &keysym, &status);
|
len = ::Xutf8LookupString(input_context, &xevent.xkey, keybuf, 32, &keysym, &status);
|
||||||
if(status == XBufferOverflow)
|
if(status == XBufferOverflow)
|
||||||
{
|
{
|
||||||
@@ -1017,7 +1034,8 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
keybuf[len] = 0;
|
keybuf[len] = 0;
|
||||||
::nana::char_t os_code = 0;
|
wchar_t os_code = 0;
|
||||||
|
auto & wd_manager = brock.wd_manager();
|
||||||
switch(status)
|
switch(status)
|
||||||
{
|
{
|
||||||
case XLookupKeySym:
|
case XLookupKeySym:
|
||||||
@@ -1027,11 +1045,37 @@ namespace detail
|
|||||||
{
|
{
|
||||||
arg_keyboard argkey;
|
arg_keyboard argkey;
|
||||||
brock.get_key_state(argkey);
|
brock.get_key_state(argkey);
|
||||||
auto tstop_wd = brock.wd_manager().tabstop(msgwnd, !argkey.shift);
|
auto tstop_wd = wd_manager.tabstop(msgwnd, !argkey.shift);
|
||||||
if (tstop_wd)
|
if (tstop_wd)
|
||||||
{
|
{
|
||||||
brock.wd_manager().set_focus(tstop_wd, false);
|
wd_manager.set_focus(tstop_wd, false);
|
||||||
brock.wd_manager().do_lazy_refresh(tstop_wd, true);
|
wd_manager.do_lazy_refresh(msgwnd, false);
|
||||||
|
wd_manager.do_lazy_refresh(tstop_wd, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((keyboard::space == os_code) && msgwnd->flags.space_click_enabled)
|
||||||
|
{
|
||||||
|
//Clicked by spacebar
|
||||||
|
if((nullptr == pressed_wd) && (nullptr == pressed_wd_space))
|
||||||
|
{
|
||||||
|
arg_mouse arg;
|
||||||
|
arg.alt = false;
|
||||||
|
arg.button = ::nana::mouse::left_button;
|
||||||
|
arg.ctrl = false;
|
||||||
|
arg.evt_code = event_code::mouse_down;
|
||||||
|
arg.left_button = true;
|
||||||
|
arg.mid_button = false;
|
||||||
|
arg.pos.x = 0;
|
||||||
|
arg.pos.y = 0;
|
||||||
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
|
|
||||||
|
msgwnd->flags.action = mouse_action::pressed;
|
||||||
|
|
||||||
|
pressed_wd_space = msgwnd;
|
||||||
|
auto retain = msgwnd->together.events_ptr;
|
||||||
|
|
||||||
|
emit_drawer(&drawer::mouse_down, msgwnd, arg, &context);
|
||||||
|
wd_manager.do_lazy_refresh(msgwnd, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(keyboard::alt == os_code)
|
else if(keyboard::alt == os_code)
|
||||||
@@ -1074,28 +1118,26 @@ namespace detail
|
|||||||
|
|
||||||
if(brock.wd_manager().available(msgwnd) && (msgwnd->root_widget->other.attribute.root->menubar == msgwnd))
|
if(brock.wd_manager().available(msgwnd) && (msgwnd->root_widget->other.attribute.root->menubar == msgwnd))
|
||||||
{
|
{
|
||||||
int cmd = (menu_wd && (keyboard::escape == static_cast<nana::char_t>(arg.key)) ? 1 : 0 );
|
int cmd = (menu_wd && (keyboard::escape == static_cast<wchar_t>(arg.key)) ? 1 : 0 );
|
||||||
brock.delay_restore(cmd);
|
brock.delay_restore(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(XLookupKeySym == status)
|
if(XLookupKeySym == status)
|
||||||
{
|
{
|
||||||
brock.wd_manager().do_lazy_refresh(msgwnd, false);
|
wd_manager.do_lazy_refresh(msgwnd, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XLookupChars:
|
case XLookupChars:
|
||||||
if (msgwnd->flags.enabled)
|
if (msgwnd->flags.enabled)
|
||||||
{
|
{
|
||||||
const ::nana::char_t* charbuf;
|
const wchar_t* charbuf;
|
||||||
#if defined(NANA_UNICODE)
|
|
||||||
nana::detail::charset_conv charset("UTF-32", "UTF-8");
|
nana::detail::charset_conv charset("UTF-32", "UTF-8");
|
||||||
const std::string& str = charset.charset(std::string(keybuf, keybuf + len));
|
const std::string& str = charset.charset(std::string(keybuf, keybuf + len));
|
||||||
charbuf = reinterpret_cast<const nana::char_t*>(str.c_str()) + 1;
|
charbuf = reinterpret_cast<const wchar_t*>(str.c_str()) + 1;
|
||||||
len = str.size() / sizeof(wchar_t) - 1;
|
len = str.size() / sizeof(wchar_t) - 1;
|
||||||
#else
|
|
||||||
charbuf = keybuf;
|
|
||||||
#endif
|
|
||||||
for(int i = 0; i < len; ++i)
|
for(int i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
arg_keyboard arg;
|
arg_keyboard arg;
|
||||||
@@ -1111,7 +1153,7 @@ namespace detail
|
|||||||
arg.ctrl = arg.shift = false;
|
arg.ctrl = arg.shift = false;
|
||||||
arg.evt_code = event_code::shortkey;
|
arg.evt_code = event_code::shortkey;
|
||||||
brock.set_keyboard_shortkey(true);
|
brock.set_keyboard_shortkey(true);
|
||||||
auto shr_wd = brock.wd_manager().find_shortkey(native_window, arg.key);
|
auto shr_wd = wd_manager.find_shortkey(native_window, arg.key);
|
||||||
if(shr_wd)
|
if(shr_wd)
|
||||||
{
|
{
|
||||||
arg.window_handle = reinterpret_cast<window>(shr_wd);
|
arg.window_handle = reinterpret_cast<window>(shr_wd);
|
||||||
@@ -1123,7 +1165,7 @@ namespace detail
|
|||||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
brock.get_key_state(arg);
|
brock.get_key_state(arg);
|
||||||
msgwnd->together.events_ptr->key_char.emit(arg);
|
msgwnd->together.events_ptr->key_char.emit(arg);
|
||||||
if(arg.ignore == false && brock.wd_manager().available(msgwnd))
|
if(arg.ignore == false && wd_manager.available(msgwnd))
|
||||||
brock.emit_drawer(event_code::key_char, msgwnd, arg, &context);
|
brock.emit_drawer(event_code::key_char, msgwnd, arg, &context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1133,7 +1175,7 @@ namespace detail
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
brock.wd_manager().do_lazy_refresh(msgwnd, false);
|
wd_manager.do_lazy_refresh(msgwnd, false);
|
||||||
if(keybuf != fixbuf)
|
if(keybuf != fixbuf)
|
||||||
delete [] keybuf;
|
delete [] keybuf;
|
||||||
}
|
}
|
||||||
@@ -1151,13 +1193,43 @@ namespace detail
|
|||||||
msgwnd = brock.focus();
|
msgwnd = brock.focus();
|
||||||
if(msgwnd)
|
if(msgwnd)
|
||||||
{
|
{
|
||||||
arg_keyboard arg;
|
if(msgwnd == pressed_wd_space)
|
||||||
arg.evt_code = event_code::key_release;
|
{
|
||||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
msgwnd->flags.action = mouse_action::normal;
|
||||||
arg.ignore = false;
|
|
||||||
arg.key = os_code;
|
arg_click click_arg;
|
||||||
brock.get_key_state(arg);
|
click_arg.mouse_args = nullptr;
|
||||||
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
|
|
||||||
|
auto retain = msgwnd->together.events_ptr;
|
||||||
|
if (brock.emit(event_code::click, msgwnd, click_arg, true, &context))
|
||||||
|
{
|
||||||
|
arg_mouse arg;
|
||||||
|
arg.alt = false;
|
||||||
|
arg.button = ::nana::mouse::left_button;
|
||||||
|
arg.ctrl = false;
|
||||||
|
arg.evt_code = event_code::mouse_up;
|
||||||
|
arg.left_button = true;
|
||||||
|
arg.mid_button = false;
|
||||||
|
arg.pos.x = 0;
|
||||||
|
arg.pos.y = 0;
|
||||||
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
|
|
||||||
|
emit_drawer(&drawer::mouse_up, msgwnd, arg, &context);
|
||||||
|
brock.wd_manager().do_lazy_refresh(msgwnd, false);
|
||||||
|
}
|
||||||
|
pressed_wd_space = nullptr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
arg_keyboard arg;
|
||||||
|
arg.evt_code = event_code::key_release;
|
||||||
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
|
arg.ignore = false;
|
||||||
|
arg.key = os_code;
|
||||||
|
brock.get_key_state(arg);
|
||||||
|
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(os_code < keyboard::os_arrow_left || keyboard::os_arrow_down < os_code)
|
if(os_code < keyboard::os_arrow_left || keyboard::os_arrow_down < os_code)
|
||||||
@@ -1218,6 +1290,7 @@ namespace detail
|
|||||||
context.event_window = pre_event_window;
|
context.event_window = pre_event_window;
|
||||||
root_runtime->condition.pressed = pressed_wd;
|
root_runtime->condition.pressed = pressed_wd;
|
||||||
root_runtime->condition.hovered = hovered_wd;
|
root_runtime->condition.hovered = hovered_wd;
|
||||||
|
root_runtime->condition.pressed_by_space = pressed_wd_space;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
||||||
@@ -141,7 +141,7 @@ namespace detail
|
|||||||
|
|
||||||
struct platform_detail_tag
|
struct platform_detail_tag
|
||||||
{
|
{
|
||||||
nana::char_t keychar;
|
wchar_t keychar;
|
||||||
}platform;
|
}platform;
|
||||||
|
|
||||||
struct cursor_tag
|
struct cursor_tag
|
||||||
@@ -215,7 +215,7 @@ namespace detail
|
|||||||
|
|
||||||
WNDCLASSEX wincl;
|
WNDCLASSEX wincl;
|
||||||
wincl.hInstance = ::GetModuleHandle(0);
|
wincl.hInstance = ::GetModuleHandle(0);
|
||||||
wincl.lpszClassName = STR("NanaWindowInternal");
|
wincl.lpszClassName = L"NanaWindowInternal";
|
||||||
wincl.lpfnWndProc = &Bedrock_WIN32_WindowProc;
|
wincl.lpfnWndProc = &Bedrock_WIN32_WindowProc;
|
||||||
wincl.style = CS_DBLCLKS | CS_OWNDC;
|
wincl.style = CS_DBLCLKS | CS_OWNDC;
|
||||||
wincl.cbSize = sizeof(wincl);
|
wincl.cbSize = sizeof(wincl);
|
||||||
@@ -441,9 +441,9 @@ namespace detail
|
|||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch(std::exception& e)
|
||||||
{
|
{
|
||||||
(msgbox(modal_window, STR("An uncaptured std::exception during message pumping: ")).icon(msgbox::icon_information)
|
(msgbox(modal_window, "An uncaptured std::exception during message pumping: ").icon(msgbox::icon_information)
|
||||||
<<STR("\n in form: ") << API::window_caption(modal_window)
|
<<"\n in form: "<< API::window_caption(modal_window)
|
||||||
<<STR("\n exception : ") << e.what()
|
<<"\n exception : "<< e.what()
|
||||||
).show();
|
).show();
|
||||||
|
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
@@ -459,8 +459,8 @@ namespace detail
|
|||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
(msgbox(modal_window, STR("An exception during message pumping!")).icon(msgbox::icon_information)
|
(msgbox(modal_window, "An exception during message pumping!").icon(msgbox::icon_information)
|
||||||
<< STR("An uncaptured non-std exception during message pumping!")
|
<<"An uncaptured non-std exception during message pumping!"
|
||||||
).show();
|
).show();
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
_m_except_handler();
|
_m_except_handler();
|
||||||
@@ -795,6 +795,7 @@ namespace detail
|
|||||||
auto& context = *brock.get_thread_context();
|
auto& context = *brock.get_thread_context();
|
||||||
|
|
||||||
auto pressed_wd = root_runtime->condition.pressed;
|
auto pressed_wd = root_runtime->condition.pressed;
|
||||||
|
auto pressed_wd_space = root_runtime->condition.pressed_by_space;
|
||||||
auto hovered_wd = root_runtime->condition.hovered;
|
auto hovered_wd = root_runtime->condition.hovered;
|
||||||
|
|
||||||
parameter_decoder pmdec;
|
parameter_decoder pmdec;
|
||||||
@@ -913,6 +914,10 @@ namespace detail
|
|||||||
def_window_proc = true;
|
def_window_proc = true;
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
|
case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
|
||||||
|
//Ignore mouse events when a window has been pressed by pressing spacebar
|
||||||
|
if (pressed_wd_space)
|
||||||
|
break;
|
||||||
|
|
||||||
pressed_wd = nullptr;
|
pressed_wd = nullptr;
|
||||||
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
|
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
|
||||||
if(msgwnd && msgwnd->flags.enabled)
|
if(msgwnd && msgwnd->flags.enabled)
|
||||||
@@ -938,8 +943,13 @@ namespace detail
|
|||||||
def_window_proc = true;
|
def_window_proc = true;
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN:
|
case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN:
|
||||||
|
//Ignore mouse events when a window has been pressed by pressing spacebar
|
||||||
|
if (pressed_wd_space)
|
||||||
|
break;
|
||||||
|
|
||||||
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
|
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
|
||||||
if(nullptr == msgwnd) break;
|
if ((nullptr == msgwnd) || (pressed_wd && (msgwnd != pressed_wd)))
|
||||||
|
break;
|
||||||
|
|
||||||
//if event on the menubar, just remove the menu if it is not associating with the menubar
|
//if event on the menubar, just remove the menu if it is not associating with the menubar
|
||||||
if ((msgwnd == msgwnd->root_widget->other.attribute.root->menubar) && brock.get_menu(msgwnd->root, true))
|
if ((msgwnd == msgwnd->root_widget->other.attribute.root->menubar) && brock.get_menu(msgwnd->root, true))
|
||||||
@@ -994,7 +1004,11 @@ namespace detail
|
|||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
|
//Ignore mouse events when a window has been pressed by pressing spacebar
|
||||||
|
if (pressed_wd_space)
|
||||||
|
break;
|
||||||
|
|
||||||
|
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
|
||||||
if(nullptr == msgwnd)
|
if(nullptr == msgwnd)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1015,7 +1029,7 @@ namespace detail
|
|||||||
if (msgwnd->dimension.is_hit(arg.pos))
|
if (msgwnd->dimension.is_hit(arg.pos))
|
||||||
{
|
{
|
||||||
msgwnd->flags.action = mouse_action::over;
|
msgwnd->flags.action = mouse_action::over;
|
||||||
if (::nana::mouse::left_button == arg.button)
|
if ((::nana::mouse::left_button == arg.button) && (pressed_wd == msgwnd))
|
||||||
{
|
{
|
||||||
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
|
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
emit_drawer(&drawer::click, msgwnd, click_arg, &context);
|
emit_drawer(&drawer::click, msgwnd, click_arg, &context);
|
||||||
@@ -1045,6 +1059,10 @@ namespace detail
|
|||||||
pressed_wd = nullptr;
|
pressed_wd = nullptr;
|
||||||
break;
|
break;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
|
//Ignore mouse events when a window has been pressed by pressing spacebar
|
||||||
|
if (pressed_wd_space)
|
||||||
|
break;
|
||||||
|
|
||||||
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
|
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
|
||||||
if (brock.wd_manager().available(hovered_wd) && (msgwnd != hovered_wd))
|
if (brock.wd_manager().available(hovered_wd) && (msgwnd != hovered_wd))
|
||||||
{
|
{
|
||||||
@@ -1176,7 +1194,7 @@ namespace detail
|
|||||||
{
|
{
|
||||||
arg_dropfiles dropfiles;
|
arg_dropfiles dropfiles;
|
||||||
|
|
||||||
std::unique_ptr<nana::char_t[]> varbuf;
|
std::unique_ptr<wchar_t[]> varbuf;
|
||||||
std::size_t bufsize = 0;
|
std::size_t bufsize = 0;
|
||||||
|
|
||||||
unsigned size = ::DragQueryFile(drop, 0xFFFFFFFF, 0, 0);
|
unsigned size = ::DragQueryFile(drop, 0xFFFFFFFF, 0, 0);
|
||||||
@@ -1185,12 +1203,13 @@ namespace detail
|
|||||||
unsigned reqlen = ::DragQueryFile(drop, i, 0, 0) + 1;
|
unsigned reqlen = ::DragQueryFile(drop, i, 0, 0) + 1;
|
||||||
if(bufsize < reqlen)
|
if(bufsize < reqlen)
|
||||||
{
|
{
|
||||||
varbuf.reset(new nana::char_t[reqlen]);
|
varbuf.reset(new wchar_t[reqlen]);
|
||||||
bufsize = reqlen;
|
bufsize = reqlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
::DragQueryFile(drop, i, varbuf.get(), reqlen);
|
::DragQueryFile(drop, i, varbuf.get(), reqlen);
|
||||||
dropfiles.files.emplace_back(varbuf.get());
|
|
||||||
|
dropfiles.files.emplace_back(to_utf8(varbuf.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
while(msgwnd && (msgwnd->flags.dropable == false))
|
while(msgwnd && (msgwnd->flags.dropable == false))
|
||||||
@@ -1344,7 +1363,7 @@ namespace detail
|
|||||||
arg.evt_code = event_code::key_press;
|
arg.evt_code = event_code::key_press;
|
||||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
arg.ignore = false;
|
arg.ignore = false;
|
||||||
arg.key = static_cast<nana::char_t>(wParam);
|
arg.key = static_cast<wchar_t>(wParam);
|
||||||
brock.get_key_state(arg);
|
brock.get_key_state(arg);
|
||||||
brock.emit(event_code::key_press, msgwnd, arg, true, &context);
|
brock.emit(event_code::key_press, msgwnd, arg, true, &context);
|
||||||
|
|
||||||
@@ -1372,7 +1391,7 @@ namespace detail
|
|||||||
arg.evt_code = event_code::key_release;
|
arg.evt_code = event_code::key_release;
|
||||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
arg.ignore = false;
|
arg.ignore = false;
|
||||||
arg.key = static_cast<nana::char_t>(wParam);
|
arg.key = static_cast<wchar_t>(wParam);
|
||||||
brock.get_key_state(arg);
|
brock.get_key_state(arg);
|
||||||
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
||||||
|
|
||||||
@@ -1396,16 +1415,42 @@ namespace detail
|
|||||||
|
|
||||||
if(msgwnd)
|
if(msgwnd)
|
||||||
{
|
{
|
||||||
if((wParam == 9) && (!msgwnd->visible || (false == (msgwnd->flags.tab & tab_type::eating)))) //Tab
|
auto & wd_manager = brock.wd_manager();
|
||||||
|
if((VK_TAB == wParam) && (!msgwnd->visible || (false == (msgwnd->flags.tab & tab_type::eating)))) //Tab
|
||||||
{
|
{
|
||||||
bool is_forward = (::GetKeyState(VK_SHIFT) >= 0);
|
bool is_forward = (::GetKeyState(VK_SHIFT) >= 0);
|
||||||
|
|
||||||
auto tstop_wd = brock.wd_manager().tabstop(msgwnd, is_forward);
|
auto tstop_wd = wd_manager.tabstop(msgwnd, is_forward);
|
||||||
if (tstop_wd)
|
if (tstop_wd)
|
||||||
{
|
{
|
||||||
brock.wd_manager().set_focus(tstop_wd, false);
|
wd_manager.set_focus(tstop_wd, false);
|
||||||
brock.wd_manager().do_lazy_refresh(msgwnd, false);
|
wd_manager.do_lazy_refresh(msgwnd, false);
|
||||||
brock.wd_manager().do_lazy_refresh(tstop_wd, true);
|
wd_manager.do_lazy_refresh(tstop_wd, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((VK_SPACE == wParam) && msgwnd->flags.space_click_enabled)
|
||||||
|
{
|
||||||
|
//Clicked by spacebar
|
||||||
|
if (nullptr == pressed_wd && nullptr == pressed_wd_space)
|
||||||
|
{
|
||||||
|
arg_mouse arg;
|
||||||
|
arg.alt = false;
|
||||||
|
arg.button = ::nana::mouse::left_button;
|
||||||
|
arg.ctrl = false;
|
||||||
|
arg.evt_code = event_code::mouse_down;
|
||||||
|
arg.left_button = true;
|
||||||
|
arg.mid_button = false;
|
||||||
|
arg.pos.x = 0;
|
||||||
|
arg.pos.y = 0;
|
||||||
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
|
|
||||||
|
msgwnd->flags.action = mouse_action::pressed;
|
||||||
|
|
||||||
|
pressed_wd_space = msgwnd;
|
||||||
|
auto retain = msgwnd->together.events_ptr;
|
||||||
|
|
||||||
|
emit_drawer(&drawer::mouse_down, msgwnd, arg, &context);
|
||||||
|
wd_manager.do_lazy_refresh(msgwnd, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1414,7 +1459,7 @@ namespace detail
|
|||||||
arg.evt_code = event_code::key_press;
|
arg.evt_code = event_code::key_press;
|
||||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
arg.ignore = false;
|
arg.ignore = false;
|
||||||
arg.key = static_cast<nana::char_t>(wParam);
|
arg.key = static_cast<wchar_t>(wParam);
|
||||||
brock.get_key_state(arg);
|
brock.get_key_state(arg);
|
||||||
brock.emit(event_code::key_press, msgwnd, arg, true, &context);
|
brock.emit(event_code::key_press, msgwnd, arg, true, &context);
|
||||||
|
|
||||||
@@ -1425,7 +1470,7 @@ namespace detail
|
|||||||
//If no menu popuped by the menubar, it should enable delay restore to
|
//If no menu popuped by the menubar, it should enable delay restore to
|
||||||
//restore the focus for taken window.
|
//restore the focus for taken window.
|
||||||
|
|
||||||
int cmd = (menu_wd && (keyboard::escape == static_cast<nana::char_t>(wParam)) ? 1 : 0);
|
int cmd = (menu_wd && (keyboard::escape == static_cast<wchar_t>(wParam)) ? 1 : 0);
|
||||||
brock.delay_restore(cmd);
|
brock.delay_restore(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1442,7 +1487,7 @@ namespace detail
|
|||||||
arg_keyboard arg;
|
arg_keyboard arg;
|
||||||
arg.evt_code = event_code::key_char;
|
arg.evt_code = event_code::key_char;
|
||||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
arg.key = static_cast<nana::char_t>(wParam);
|
arg.key = static_cast<wchar_t>(wParam);
|
||||||
brock.get_key_state(arg);
|
brock.get_key_state(arg);
|
||||||
arg.ignore = false;
|
arg.ignore = false;
|
||||||
|
|
||||||
@@ -1455,18 +1500,48 @@ namespace detail
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
if(wParam != 18) //MUST NOT BE AN ALT
|
if(wParam != VK_MENU) //MUST NOT BE AN ALT
|
||||||
{
|
{
|
||||||
msgwnd = brock.focus();
|
msgwnd = brock.focus();
|
||||||
if(msgwnd)
|
if(msgwnd)
|
||||||
{
|
{
|
||||||
arg_keyboard arg;
|
if (msgwnd == pressed_wd_space)
|
||||||
arg.evt_code = event_code::key_release;
|
{
|
||||||
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
msgwnd->flags.action = mouse_action::normal;
|
||||||
arg.key = static_cast<nana::char_t>(wParam);
|
|
||||||
brock.get_key_state(arg);
|
arg_click click_arg;
|
||||||
arg.ignore = false;
|
click_arg.mouse_args = nullptr;
|
||||||
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
|
|
||||||
|
auto retain = msgwnd->together.events_ptr;
|
||||||
|
if (brock.emit(event_code::click, msgwnd, click_arg, true, &context))
|
||||||
|
{
|
||||||
|
arg_mouse arg;
|
||||||
|
arg.alt = false;
|
||||||
|
arg.button = ::nana::mouse::left_button;
|
||||||
|
arg.ctrl = false;
|
||||||
|
arg.evt_code = event_code::mouse_up;
|
||||||
|
arg.left_button = true;
|
||||||
|
arg.mid_button = false;
|
||||||
|
arg.pos.x = 0;
|
||||||
|
arg.pos.y = 0;
|
||||||
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
|
|
||||||
|
emit_drawer(&drawer::mouse_up, msgwnd, arg, &context);
|
||||||
|
brock.wd_manager().do_lazy_refresh(msgwnd, false);
|
||||||
|
}
|
||||||
|
pressed_wd_space = nullptr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
arg_keyboard arg;
|
||||||
|
arg.evt_code = event_code::key_release;
|
||||||
|
arg.window_handle = reinterpret_cast<window>(msgwnd);
|
||||||
|
arg.key = static_cast<wchar_t>(wParam);
|
||||||
|
brock.get_key_state(arg);
|
||||||
|
arg.ignore = false;
|
||||||
|
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1520,6 +1595,7 @@ namespace detail
|
|||||||
{
|
{
|
||||||
root_runtime->condition.pressed = pressed_wd;
|
root_runtime->condition.pressed = pressed_wd;
|
||||||
root_runtime->condition.hovered = hovered_wd;
|
root_runtime->condition.hovered = hovered_wd;
|
||||||
|
root_runtime->condition.pressed_by_space = pressed_wd_space;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!def_window_proc)
|
if (!def_window_proc)
|
||||||
@@ -1728,9 +1804,9 @@ namespace detail
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nana::char_t* translate(cursor id)
|
const wchar_t* translate(cursor id)
|
||||||
{
|
{
|
||||||
const nana::char_t* name = IDC_ARROW;
|
const wchar_t* name = IDC_ARROW;
|
||||||
|
|
||||||
switch(id)
|
switch(id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ namespace nana{
|
|||||||
if(owner && (nested == false))
|
if(owner && (nested == false))
|
||||||
::ClientToScreen(reinterpret_cast<HWND>(owner), &pt);
|
::ClientToScreen(reinterpret_cast<HWND>(owner), &pt);
|
||||||
|
|
||||||
HWND native_wd = ::CreateWindowEx(style_ex, STR("NanaWindowInternal"), STR("Nana Window"),
|
HWND native_wd = ::CreateWindowEx(style_ex, L"NanaWindowInternal", L"Nana Window",
|
||||||
style,
|
style,
|
||||||
pt.x, pt.y, 100, 100,
|
pt.x, pt.y, 100, 100,
|
||||||
reinterpret_cast<HWND>(owner), 0, ::GetModuleHandle(0), 0);
|
reinterpret_cast<HWND>(owner), 0, ::GetModuleHandle(0), 0);
|
||||||
@@ -281,7 +281,8 @@ namespace nana{
|
|||||||
attr_mask, &win_attr);
|
attr_mask, &win_attr);
|
||||||
if(handle)
|
if(handle)
|
||||||
{
|
{
|
||||||
if(owner)
|
//make owner if it is a popup window
|
||||||
|
if((!nested) && owner)
|
||||||
restrict::spec.make_owner(owner, reinterpret_cast<native_window_type>(handle));
|
restrict::spec.make_owner(owner, reinterpret_cast<native_window_type>(handle));
|
||||||
|
|
||||||
XTextProperty name;
|
XTextProperty name;
|
||||||
@@ -377,8 +378,8 @@ namespace nana{
|
|||||||
if(nullptr == parent) return nullptr;
|
if(nullptr == parent) return nullptr;
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
HWND handle = ::CreateWindowEx(WS_EX_CONTROLPARENT, // Extended possibilites for variation
|
HWND handle = ::CreateWindowEx(WS_EX_CONTROLPARENT, // Extended possibilites for variation
|
||||||
STR("NanaWindowInternal"),
|
L"NanaWindowInternal",
|
||||||
STR("Nana Child Window"), // Title Text
|
L"Nana Child Window", // Title Text
|
||||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS,
|
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS,
|
||||||
r.x, r.y, r.width, r.height,
|
r.x, r.y, r.width, r.height,
|
||||||
reinterpret_cast<HWND>(parent), // The window is a child-window to desktop
|
reinterpret_cast<HWND>(parent), // The window is a child-window to desktop
|
||||||
@@ -417,8 +418,6 @@ namespace nana{
|
|||||||
|
|
||||||
if(handle)
|
if(handle)
|
||||||
{
|
{
|
||||||
restrict::spec.make_owner(parent, reinterpret_cast<native_window_type>(handle));
|
|
||||||
|
|
||||||
XTextProperty name;
|
XTextProperty name;
|
||||||
char text[] = "Nana Child Window";
|
char text[] = "Nana Child Window";
|
||||||
char * str = text;
|
char * str = text;
|
||||||
@@ -786,21 +785,30 @@ namespace nana{
|
|||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
::RECT r;
|
::RECT r;
|
||||||
::GetWindowRect(reinterpret_cast<HWND>(wd), & r);
|
::GetWindowRect(reinterpret_cast<HWND>(wd), & r);
|
||||||
HWND owner = ::GetWindow(reinterpret_cast<HWND>(wd), GW_OWNER);
|
HWND coord_wd = ::GetWindow(reinterpret_cast<HWND>(wd), GW_OWNER);
|
||||||
if(owner)
|
|
||||||
|
if (!coord_wd)
|
||||||
|
coord_wd = ::GetParent(reinterpret_cast<HWND>(wd));
|
||||||
|
|
||||||
|
if (coord_wd)
|
||||||
{
|
{
|
||||||
::POINT pos = {r.left, r.top};
|
::POINT pos = {r.left, r.top};
|
||||||
::ScreenToClient(owner, &pos);
|
::ScreenToClient(coord_wd, &pos);
|
||||||
return nana::point(pos.x, pos.y);
|
return nana::point(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
return nana::point(r.left, r.top);
|
return nana::point(r.left, r.top);
|
||||||
#elif defined(NANA_X11)
|
#elif defined(NANA_X11)
|
||||||
int x, y;
|
int x, y;
|
||||||
nana::detail::platform_scope_guard psg;
|
nana::detail::platform_scope_guard psg;
|
||||||
Window root = reinterpret_cast<Window>(restrict::spec.get_owner(wd));
|
Window coord_wd = reinterpret_cast<Window>(restrict::spec.get_owner(wd));
|
||||||
if(root == 0) root = restrict::spec.root_window();
|
if(!coord_wd)
|
||||||
|
{
|
||||||
|
coord_wd = reinterpret_cast<Window>(parent_window(wd));
|
||||||
|
if(!coord_wd)
|
||||||
|
coord_wd = restrict::spec.root_window();
|
||||||
|
}
|
||||||
Window child;
|
Window child;
|
||||||
if(True == ::XTranslateCoordinates(restrict::spec.open_display(), reinterpret_cast<Window>(wd), root, 0, 0, &x, &y, &child))
|
if(True == ::XTranslateCoordinates(restrict::spec.open_display(), reinterpret_cast<Window>(wd), coord_wd, 0, 0, &x, &y, &child))
|
||||||
return nana::point(x, y);
|
return nana::point(x, y);
|
||||||
return nana::point(0, 0);
|
return nana::point(0, 0);
|
||||||
#endif
|
#endif
|
||||||
@@ -1076,48 +1084,37 @@ namespace nana{
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void native_interface::window_caption(native_window_type wd, const nana::string& title)
|
void native_interface::window_caption(native_window_type wd, const native_string_type& title)
|
||||||
{
|
{
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
if(::GetCurrentThreadId() != ::GetWindowThreadProcessId(reinterpret_cast<HWND>(wd), 0))
|
if(::GetCurrentThreadId() != ::GetWindowThreadProcessId(reinterpret_cast<HWND>(wd), 0))
|
||||||
{
|
{
|
||||||
wchar_t * wstr;
|
wchar_t * wstr = new wchar_t[title.length() + 1];
|
||||||
#if defined(NANA_UNICODE)
|
std::wcscpy(wstr, title.c_str());
|
||||||
wstr = new wchar_t[title.length() + 1];
|
|
||||||
wcscpy(wstr, title.c_str());
|
|
||||||
#else
|
|
||||||
std::wstring str = nana::charset(title);
|
|
||||||
wstr = new wchar_t[str.length() + 1];
|
|
||||||
wcscpy(wstr, str.c_str());
|
|
||||||
#endif
|
|
||||||
::PostMessage(reinterpret_cast<HWND>(wd), nana::detail::messages::remote_thread_set_window_text, reinterpret_cast<WPARAM>(wstr), 0);
|
::PostMessage(reinterpret_cast<HWND>(wd), nana::detail::messages::remote_thread_set_window_text, reinterpret_cast<WPARAM>(wstr), 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
::SetWindowText(reinterpret_cast<HWND>(wd), title.c_str());
|
::SetWindowText(reinterpret_cast<HWND>(wd), title.c_str());
|
||||||
#elif defined(NANA_X11)
|
#elif defined(NANA_X11)
|
||||||
::XTextProperty name;
|
::XTextProperty name;
|
||||||
#if defined(NANA_UNICODE)
|
char * text = const_cast<char*>(title.c_str());
|
||||||
std::string mbstr = nana::charset(title);
|
|
||||||
char* text = const_cast<char*>(mbstr.c_str());
|
|
||||||
#else
|
|
||||||
char* text = const_cast<char*>(title.c_str());
|
|
||||||
#endif
|
|
||||||
nana::detail::platform_scope_guard psg;
|
nana::detail::platform_scope_guard psg;
|
||||||
::XStringListToTextProperty(&text, 1, &name);
|
::XStringListToTextProperty(&text, 1, &name);
|
||||||
::XSetWMName(restrict::spec.open_display(), reinterpret_cast<Window>(wd), &name);
|
::XSetWMName(restrict::spec.open_display(), reinterpret_cast<Window>(wd), &name);
|
||||||
::XChangeProperty(restrict::spec.open_display(), reinterpret_cast<Window>(wd),
|
::XChangeProperty(restrict::spec.open_display(), reinterpret_cast<Window>(wd),
|
||||||
restrict::spec.atombase().net_wm_name, restrict::spec.atombase().utf8_string, 8,
|
restrict::spec.atombase().net_wm_name, restrict::spec.atombase().utf8_string, 8,
|
||||||
PropModeReplace, reinterpret_cast<unsigned char*>(text), mbstr.size());
|
PropModeReplace, reinterpret_cast<unsigned char*>(text), title.size());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nana::string native_interface::window_caption(native_window_type wd)
|
auto native_interface::window_caption(native_window_type wd) -> native_string_type
|
||||||
{
|
{
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
int length = ::GetWindowTextLength(reinterpret_cast<HWND>(wd));
|
int length = ::GetWindowTextLength(reinterpret_cast<HWND>(wd));
|
||||||
if(length > 0)
|
if(length > 0)
|
||||||
{
|
{
|
||||||
nana::string str;
|
native_string_type str;
|
||||||
//One for NULL terminator which GetWindowText will write.
|
//One for NULL terminator which GetWindowText will write.
|
||||||
str.resize(length+1);
|
str.resize(length+1);
|
||||||
|
|
||||||
@@ -1128,7 +1125,6 @@ namespace nana{
|
|||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
return nana::string();
|
|
||||||
#elif defined(NANA_X11)
|
#elif defined(NANA_X11)
|
||||||
nana::detail::platform_scope_guard psg;
|
nana::detail::platform_scope_guard psg;
|
||||||
::XTextProperty txtpro;
|
::XTextProperty txtpro;
|
||||||
@@ -1140,14 +1136,14 @@ namespace nana{
|
|||||||
{
|
{
|
||||||
if(size > 1)
|
if(size > 1)
|
||||||
{
|
{
|
||||||
nana::string str = nana::charset(*strlist);
|
std::string text = *strlist;
|
||||||
::XFreeStringList(strlist);
|
::XFreeStringList(strlist);
|
||||||
return str;
|
return text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nana::string();
|
|
||||||
#endif
|
#endif
|
||||||
|
return native_string_type();
|
||||||
}
|
}
|
||||||
|
|
||||||
void native_interface::capture_window(native_window_type wd, bool cap)
|
void native_interface::capture_window(native_window_type wd, bool cap)
|
||||||
@@ -1202,6 +1198,54 @@ namespace nana{
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
native_window_type native_interface::parent_window(native_window_type wd)
|
||||||
|
{
|
||||||
|
#ifdef NANA_WINDOWS
|
||||||
|
return reinterpret_cast<native_window_type>(::GetParent(reinterpret_cast<HWND>(wd)));
|
||||||
|
#elif defined(NANA_X11)
|
||||||
|
Window root;
|
||||||
|
Window parent;
|
||||||
|
Window * children;
|
||||||
|
unsigned size;
|
||||||
|
|
||||||
|
platform_scope_guard lock;
|
||||||
|
|
||||||
|
if(0 != ::XQueryTree(restrict::spec.open_display(), reinterpret_cast<Window>(wd),
|
||||||
|
&root, &parent, &children, &size))
|
||||||
|
{
|
||||||
|
::XFree(children);
|
||||||
|
return reinterpret_cast<native_window_type>(parent);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
native_window_type native_interface::parent_window(native_window_type child, native_window_type new_parent, bool returns_previous)
|
||||||
|
{
|
||||||
|
#ifdef NANA_WINDOWS
|
||||||
|
auto prev = ::SetParent(reinterpret_cast<HWND>(child), reinterpret_cast<HWND>(new_parent));
|
||||||
|
|
||||||
|
if (prev)
|
||||||
|
::PostMessage(prev, /*WM_CHANGEUISTATE*/0x0127, /*UIS_INITIALIZE*/ 3, 0);
|
||||||
|
|
||||||
|
::SetWindowPos(reinterpret_cast<HWND>(child), NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||||
|
|
||||||
|
return reinterpret_cast<native_window_type>(returns_previous ? prev : nullptr);
|
||||||
|
#elif defined(NANA_X11)
|
||||||
|
native_window_type prev = nullptr;
|
||||||
|
|
||||||
|
platform_scope_guard lock;
|
||||||
|
|
||||||
|
if(returns_previous)
|
||||||
|
prev = parent_window(child);
|
||||||
|
|
||||||
|
::XReparentWindow(restrict::spec.open_display(),
|
||||||
|
reinterpret_cast<Window>(child), reinterpret_cast<Window>(new_parent),
|
||||||
|
0, 0);
|
||||||
|
return prev;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void native_interface::caret_create(native_window_type wd, const ::nana::size& caret_sz)
|
void native_interface::caret_create(native_window_type wd, const ::nana::size& caret_sz)
|
||||||
{
|
{
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ namespace nana
|
|||||||
for (++i; i < end; ++i)
|
for (++i; i < end; ++i)
|
||||||
{
|
{
|
||||||
core_window_t* cover = *i;
|
core_window_t* cover = *i;
|
||||||
if (cover->visible && (nullptr == cover->effect.bground))
|
if ((category::flags::root != cover->other.category) && cover->visible && (nullptr == cover->effect.bground))
|
||||||
{
|
{
|
||||||
if (overlap(vis_rect, rectangle{ cover->pos_root, cover->dimension }, block.r))
|
if (overlap(vis_rect, rectangle{ cover->pos_root, cover->dimension }, block.r))
|
||||||
{
|
{
|
||||||
@@ -271,9 +271,15 @@ namespace nana
|
|||||||
for (auto child : wd->children)
|
for (auto child : wd->children)
|
||||||
{
|
{
|
||||||
//it will not past children if no drawer and visible is false.
|
//it will not past children if no drawer and visible is false.
|
||||||
if ((false == child->visible) || ((child->other.category != category::lite_widget_tag::value) && child->drawer.graphics.empty()))
|
if ((false == child->visible) || ((category::flags::lite_widget != child->other.category) && child->drawer.graphics.empty()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (category::flags::root == child->other.category)
|
||||||
|
{
|
||||||
|
paint(child, is_child_refreshed, is_child_refreshed);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (nullptr == child->effect.bground)
|
if (nullptr == child->effect.bground)
|
||||||
{
|
{
|
||||||
if (overlap(nana::rectangle{ child->pos_root, child->dimension }, parent_rect, rect))
|
if (overlap(nana::rectangle{ child->pos_root, child->dimension }, parent_rect, rect))
|
||||||
|
|||||||
@@ -291,6 +291,14 @@ namespace detail
|
|||||||
if (result.native_handle)
|
if (result.native_handle)
|
||||||
{
|
{
|
||||||
core_window_t* wd = new core_window_t(owner, widget_notifier_interface::get_notifier(wdg), (category::root_tag**)nullptr);
|
core_window_t* wd = new core_window_t(owner, widget_notifier_interface::get_notifier(wdg), (category::root_tag**)nullptr);
|
||||||
|
if (nested)
|
||||||
|
{
|
||||||
|
wd->owner = nullptr;
|
||||||
|
wd->parent = owner;
|
||||||
|
wd->index = static_cast<unsigned>(owner->children.size());
|
||||||
|
owner->children.push_back(wd);
|
||||||
|
}
|
||||||
|
|
||||||
wd->flags.take_active = !app.no_activate;
|
wd->flags.take_active = !app.no_activate;
|
||||||
wd->title = native_interface::window_caption(result.native_handle);
|
wd->title = native_interface::window_caption(result.native_handle);
|
||||||
|
|
||||||
@@ -542,10 +550,10 @@ namespace detail
|
|||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
if (impl_->wd_register.available(wd))
|
if (impl_->wd_register.available(wd))
|
||||||
{
|
{
|
||||||
if(wd->other.category != category::root_tag::value)
|
if (category::flags::root != wd->other.category)
|
||||||
{
|
{
|
||||||
//Move child widgets
|
//Move child widgets
|
||||||
if(x != wd->pos_owner.x || y != wd->pos_owner.y)
|
if (x != wd->pos_owner.x || y != wd->pos_owner.y)
|
||||||
{
|
{
|
||||||
point delta{ x - wd->pos_owner.x, y - wd->pos_owner.y };
|
point delta{ x - wd->pos_owner.x, y - wd->pos_owner.y };
|
||||||
|
|
||||||
@@ -562,8 +570,20 @@ namespace detail
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(false == passive)
|
else if (!passive)
|
||||||
|
{
|
||||||
|
//Check if this root is a nested
|
||||||
|
if (wd->parent && (category::flags::root != wd->parent->other.category))
|
||||||
|
{
|
||||||
|
//The parent of the window is not a root, the position should
|
||||||
|
//be transformed to a position based on its parent.
|
||||||
|
|
||||||
|
x += wd->parent->pos_root.x;
|
||||||
|
y += wd->parent->pos_root.y;
|
||||||
|
}
|
||||||
|
|
||||||
native_interface::move_window(wd->root, x, y);
|
native_interface::move_window(wd->root, x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -602,22 +622,36 @@ namespace detail
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
::nana::rectangle root_r = r;
|
||||||
|
//Move event should not get called here,
|
||||||
|
//because the window is a root, the event will get called by system event handler.
|
||||||
|
|
||||||
|
//Check if this root is a nested
|
||||||
|
if (wd->parent && (category::flags::root != wd->parent->other.category))
|
||||||
|
{
|
||||||
|
//The parent of the window is not a root, the position should
|
||||||
|
//be transformed to a position based on its parent.
|
||||||
|
|
||||||
|
root_r.x += wd->parent->pos_root.x;
|
||||||
|
root_r.y += wd->parent->pos_root.y;
|
||||||
|
}
|
||||||
|
|
||||||
if(size_changed)
|
if(size_changed)
|
||||||
{
|
{
|
||||||
wd->dimension.width = r.width;
|
wd->dimension.width = root_r.width;
|
||||||
wd->dimension.height = r.height;
|
wd->dimension.height = root_r.height;
|
||||||
wd->drawer.graphics.make(wd->dimension);
|
wd->drawer.graphics.make(wd->dimension);
|
||||||
wd->root_graph->make(wd->dimension);
|
wd->root_graph->make(wd->dimension);
|
||||||
native_interface::move_window(wd->root, r);
|
native_interface::move_window(wd->root, root_r);
|
||||||
|
|
||||||
arg_resized arg;
|
arg_resized arg;
|
||||||
arg.window_handle = reinterpret_cast<window>(wd);
|
arg.window_handle = reinterpret_cast<window>(wd);
|
||||||
arg.width = r.width;
|
arg.width = root_r.width;
|
||||||
arg.height = r.height;
|
arg.height = root_r.height;
|
||||||
brock.emit(event_code::resized, wd, arg, true, brock.get_thread_context());
|
brock.emit(event_code::resized, wd, arg, true, brock.get_thread_context());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
native_interface::move_window(wd->root, r.x, r.y);
|
native_interface::move_window(wd->root, root_r.x, root_r.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (moved || size_changed);
|
return (moved || size_changed);
|
||||||
@@ -919,34 +953,37 @@ namespace detail
|
|||||||
arg.receiver = wd->root;
|
arg.receiver = wd->root;
|
||||||
brock.emit(event_code::focus, prev_focus, arg, true, brock.get_thread_context());
|
brock.emit(event_code::focus, prev_focus, arg, true, brock.get_thread_context());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check the prev_focus again, because it may be closed in focus event
|
||||||
|
if (!impl_->wd_register.available(prev_focus))
|
||||||
|
prev_focus = nullptr;
|
||||||
}
|
}
|
||||||
else if(wd->root == native_interface::get_focus_window())
|
else if(wd->root == native_interface::get_focus_window())
|
||||||
wd = nullptr; //no new focus_window
|
return prev_focus; //no new focus_window
|
||||||
|
|
||||||
if(wd)
|
|
||||||
{
|
|
||||||
if(wd->together.caret)
|
|
||||||
wd->together.caret->set_active(true);
|
|
||||||
|
|
||||||
arg.window_handle = reinterpret_cast<window>(wd);
|
if(wd->together.caret)
|
||||||
arg.getting = true;
|
wd->together.caret->set_active(true);
|
||||||
arg.receiver = wd->root;
|
|
||||||
brock.emit(event_code::focus, wd, arg, true, brock.get_thread_context());
|
|
||||||
|
|
||||||
if (!root_has_been_focused)
|
arg.window_handle = reinterpret_cast<window>(wd);
|
||||||
native_interface::set_focus(root_wd->root);
|
arg.getting = true;
|
||||||
|
arg.receiver = wd->root;
|
||||||
|
brock.emit(event_code::focus, wd, arg, true, brock.get_thread_context());
|
||||||
|
|
||||||
//A fix by Katsuhisa Yuasa
|
if (!root_has_been_focused)
|
||||||
//The menubar token window will be redirected to the prev focus window when the new
|
native_interface::set_focus(root_wd->root);
|
||||||
//focus window is a menubar.
|
|
||||||
//The focus window will be restore to the prev focus which losts the focus becuase of
|
//A fix by Katsuhisa Yuasa
|
||||||
//memberbar.
|
//The menubar token window will be redirected to the prev focus window when the new
|
||||||
if (wd == wd->root_widget->other.attribute.root->menubar)
|
//focus window is a menubar.
|
||||||
wd = prev_focus;
|
//The focus window will be restore to the prev focus which losts the focus becuase of
|
||||||
|
//memberbar.
|
||||||
|
if (prev_focus && (wd == wd->root_widget->other.attribute.root->menubar))
|
||||||
|
wd = prev_focus;
|
||||||
|
|
||||||
|
if (wd != wd->root_widget->other.attribute.root->menubar)
|
||||||
|
brock.set_menubar_taken(wd);
|
||||||
|
|
||||||
if (wd != wd->root_widget->other.attribute.root->menubar)
|
|
||||||
brock.set_menubar_taken(wd);
|
|
||||||
}
|
|
||||||
return prev_focus;
|
return prev_focus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1301,7 +1338,9 @@ namespace detail
|
|||||||
void window_manager::_m_disengage(core_window_t* wd, core_window_t* for_new)
|
void window_manager::_m_disengage(core_window_t* wd, core_window_t* for_new)
|
||||||
{
|
{
|
||||||
auto * const wdpa = wd->parent;
|
auto * const wdpa = wd->parent;
|
||||||
bool established = (for_new && wdpa != for_new);
|
|
||||||
|
|
||||||
|
bool established = (for_new && (wdpa != for_new));
|
||||||
decltype(for_new->root_widget->other.attribute.root) pa_root_attr = nullptr;
|
decltype(for_new->root_widget->other.attribute.root) pa_root_attr = nullptr;
|
||||||
|
|
||||||
if (established)
|
if (established)
|
||||||
@@ -1443,14 +1482,26 @@ namespace detail
|
|||||||
std::function<void(core_window_t*, const nana::point&)> set_pos_root;
|
std::function<void(core_window_t*, const nana::point&)> set_pos_root;
|
||||||
set_pos_root = [&set_pos_root](core_window_t* wd, const nana::point& delta_pos)
|
set_pos_root = [&set_pos_root](core_window_t* wd, const nana::point& delta_pos)
|
||||||
{
|
{
|
||||||
wd->pos_root -= delta_pos;
|
|
||||||
for (auto child : wd->children)
|
for (auto child : wd->children)
|
||||||
{
|
{
|
||||||
child->root = wd->root;
|
if (category::flags::root == child->other.category)
|
||||||
child->root_graph = wd->root_graph;
|
{
|
||||||
child->root_widget = wd->root_widget;
|
auto pos = native_interface::window_position(child->root);
|
||||||
set_pos_root(child, delta_pos);
|
native_interface::parent_window(child->root, wd->root, false);
|
||||||
|
|
||||||
|
pos -= delta_pos;
|
||||||
|
native_interface::move_window(child->root, pos.x, pos.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
child->root = wd->root;
|
||||||
|
child->root_graph = wd->root_graph;
|
||||||
|
child->root_widget = wd->root_widget;
|
||||||
|
set_pos_root(child, delta_pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wd->pos_root -= delta_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
set_pos_root(wd, delta_pos);
|
set_pos_root(wd, delta_pos);
|
||||||
@@ -1481,8 +1532,30 @@ namespace detail
|
|||||||
brock.emit(event_code::destroy, wd, arg, true, brock.get_thread_context());
|
brock.emit(event_code::destroy, wd, arg, true, brock.get_thread_context());
|
||||||
|
|
||||||
//Delete the children widgets.
|
//Delete the children widgets.
|
||||||
for (auto i = wd->children.rbegin(), end = wd->children.rend(); i != end; ++i)
|
for (auto i = wd->children.rbegin(), end = wd->children.rend(); i != end;)
|
||||||
_m_destroy(*i);
|
{
|
||||||
|
auto child = *i;
|
||||||
|
|
||||||
|
if (category::flags::root == child->other.category)
|
||||||
|
{
|
||||||
|
//closing a child root window erases itself from wd->children,
|
||||||
|
//to make sure the iterator is valid, it must be reloaded.
|
||||||
|
|
||||||
|
auto offset = std::distance(wd->children.rbegin(), i);
|
||||||
|
|
||||||
|
//!!!
|
||||||
|
//a potential issue is that if the calling thread is not same with child's thread,
|
||||||
|
//the child root window may not be erased from wd->children now.
|
||||||
|
native_interface::close_window(child->root);
|
||||||
|
|
||||||
|
i = wd->children.rbegin();
|
||||||
|
std::advance(i, offset);
|
||||||
|
end = wd->children.rend();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_m_destroy(child);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
wd->children.clear();
|
wd->children.clear();
|
||||||
|
|
||||||
|
|
||||||
@@ -1508,7 +1581,7 @@ namespace detail
|
|||||||
|
|
||||||
void window_manager::_m_move_core(core_window_t* wd, const point& delta)
|
void window_manager::_m_move_core(core_window_t* wd, const point& delta)
|
||||||
{
|
{
|
||||||
if(wd->other.category != category::root_tag::value) //A root widget always starts at (0, 0) and its childs are not to be changed
|
if(category::flags::root != wd->other.category) //A root widget always starts at (0, 0) and its childs are not to be changed
|
||||||
{
|
{
|
||||||
wd->pos_root += delta;
|
wd->pos_root += delta;
|
||||||
if (category::flags::frame != wd->other.category)
|
if (category::flags::frame != wd->other.category)
|
||||||
@@ -1525,6 +1598,11 @@ namespace detail
|
|||||||
for (auto child : wd->children)
|
for (auto child : wd->children)
|
||||||
_m_move_core(child, delta);
|
_m_move_core(child, delta);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto pos = native_interface::window_position(wd->root) + delta;
|
||||||
|
native_interface::move_window(wd->root, pos.x, pos.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//_m_find
|
//_m_find
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* A Dragger Implementation
|
||||||
|
* 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/gui/dragger.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
#include <nana/gui/dragger.hpp>
|
#include <nana/gui/dragger.hpp>
|
||||||
|
#include <nana/gui/programming_interface.hpp>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@@ -180,6 +192,23 @@ namespace nana
|
|||||||
delete impl_;
|
delete impl_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dragger::dragger(dragger&& other)
|
||||||
|
: impl_(other.impl_)
|
||||||
|
{
|
||||||
|
other.impl_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
dragger& dragger::operator=(dragger&& other)
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
delete impl_;
|
||||||
|
impl_ = other.impl_;
|
||||||
|
other.impl_ = nullptr;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
void dragger::target(window wd)
|
void dragger::target(window wd)
|
||||||
{
|
{
|
||||||
impl_->drag_target(wd, rectangle(), nana::arrange::horizontal_vertical);
|
impl_->drag_target(wd, rectangle(), nana::arrange::horizontal_vertical);
|
||||||
|
|||||||
@@ -173,11 +173,8 @@ namespace nana
|
|||||||
const int x = r.x + 1;
|
const int x = r.x + 1;
|
||||||
const int y = r.y + 1;
|
const int y = r.y + 1;
|
||||||
|
|
||||||
graph.set_color(bld_bgcolor);
|
graph.rectangle(rectangle{ x + 1, y + 1, 11, 11 }, true, bld_bgcolor);
|
||||||
graph.rectangle(rectangle{ x + 1, y + 1, 11, 11 }, true);
|
graph.rectangle(rectangle{ x, y, 13, 13 }, false, bld_fgcolor);
|
||||||
|
|
||||||
graph.set_color(bld_fgcolor);
|
|
||||||
graph.rectangle(rectangle{ x, y, 13, 13 }, false);
|
|
||||||
|
|
||||||
switch(crook_data.check_state)
|
switch(crook_data.check_state)
|
||||||
{
|
{
|
||||||
@@ -252,11 +249,11 @@ namespace nana
|
|||||||
int x = r.x + (static_cast<int>(r.width) - 16) / 2;
|
int x = r.x + (static_cast<int>(r.width) - 16) / 2;
|
||||||
int y = r.y + (static_cast<int>(r.height) - 16) / 2;
|
int y = r.y + (static_cast<int>(r.height) - 16) / 2;
|
||||||
|
|
||||||
graph.set_color(fgcolor);
|
graph.palette(false, fgcolor);
|
||||||
graph.line(point{ x + 3, y + 7 }, point{ x + 6, y + 10 });
|
graph.line(point{ x + 3, y + 7 }, point{ x + 6, y + 10 });
|
||||||
graph.line(point{ x + 7, y + 9 }, point{ x + 12, y + 4 });
|
graph.line(point{ x + 7, y + 9 }, point{ x + 12, y + 4 });
|
||||||
|
|
||||||
graph.set_color(fgcolor.blend(colors::white, 0.5));
|
graph.palette(false, fgcolor.blend(colors::white, 0.5));
|
||||||
graph.line(point{ x + 3, y + 8 }, point{ x + 6, y + 11 });
|
graph.line(point{ x + 3, y + 8 }, point{ x + 6, y + 11 });
|
||||||
graph.line(point{ x + 7, y + 10 }, point{ x + 12, y + 5 });
|
graph.line(point{ x + 7, y + 10 }, point{ x + 12, y + 5 });
|
||||||
graph.line(point{ x + 4, y + 7 }, point{ x + 6, y + 9 });
|
graph.line(point{ x + 4, y + 7 }, point{ x + 6, y + 9 });
|
||||||
@@ -515,16 +512,16 @@ namespace nana
|
|||||||
::nana::point left_mid{ r.x + 1, r.y + 1 + static_cast<int>(part_px) }, right_mid{ right_top.x, left_mid.y };
|
::nana::point left_mid{ r.x + 1, r.y + 1 + static_cast<int>(part_px) }, right_mid{ right_top.x, left_mid.y };
|
||||||
::nana::point left_bottom{ r.x + 1, r.bottom() - 2 }, right_bottom{ r.right() - 2, r.bottom() - 2 };
|
::nana::point left_bottom{ r.x + 1, r.bottom() - 2 }, right_bottom{ r.right() - 2, r.bottom() - 2 };
|
||||||
|
|
||||||
graph.set_color(bgcolor.blend(colors::white, 0.9));
|
graph.palette(false, bgcolor.blend(colors::white, 0.9));
|
||||||
graph.line(left_top, left_mid);
|
graph.line(left_top, left_mid);
|
||||||
graph.line(right_top, right_mid);
|
graph.line(right_top, right_mid);
|
||||||
|
|
||||||
graph.set_color(bgcolor.blend(colors::white, 0.5));
|
graph.palette(false, bgcolor.blend(colors::white, 0.5));
|
||||||
graph.line(left_top, right_top);
|
graph.line(left_top, right_top);
|
||||||
|
|
||||||
left_mid.y++;
|
left_mid.y++;
|
||||||
right_mid.y++;
|
right_mid.y++;
|
||||||
graph.set_color(bgcolor.blend(colors::black, 0.8));
|
graph.palette(false, bgcolor.blend(colors::black, 0.8));
|
||||||
graph.line(left_mid, left_bottom);
|
graph.line(left_mid, left_bottom);
|
||||||
graph.line(right_mid, right_bottom);
|
graph.line(right_mid, right_bottom);
|
||||||
|
|
||||||
@@ -557,7 +554,7 @@ namespace nana
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
graph.set_color(clr);
|
graph.palette(false, clr);
|
||||||
|
|
||||||
const int x = r.x + 4;
|
const int x = r.x + 4;
|
||||||
const int y = r.y + 4;
|
const int y = r.y + 4;
|
||||||
@@ -959,13 +956,13 @@ namespace nana
|
|||||||
ps[11].x = r.x + gap;
|
ps[11].x = r.x + gap;
|
||||||
ps[11].y = r.y + gap;
|
ps[11].y = r.y + gap;
|
||||||
|
|
||||||
graph.set_color(fgcolor.blend(colors::black, true));
|
graph.palette(false, fgcolor.blend(colors::black, true));
|
||||||
|
|
||||||
for (int i = 0; i < 11; ++i)
|
for (int i = 0; i < 11; ++i)
|
||||||
graph.line(ps[i], ps[i + 1]);
|
graph.line(ps[i], ps[i + 1]);
|
||||||
graph.line(ps[11], ps[0]);
|
graph.line(ps[11], ps[0]);
|
||||||
|
|
||||||
graph.set_color(fgcolor);
|
graph.palette(false, fgcolor);
|
||||||
|
|
||||||
unsigned thk_minus_2 = thickness_ - 2;
|
unsigned thk_minus_2 = thickness_ - 2;
|
||||||
graph.rectangle(rectangle{ ps[10].x + 1, ps[10].y + 1, (gap << 1) + thk_minus_2, thk_minus_2 }, true);
|
graph.rectangle(rectangle{ ps[10].x + 1, ps[10].y + 1, (gap << 1) + thk_minus_2, thk_minus_2 }, true);
|
||||||
@@ -1010,7 +1007,7 @@ namespace nana
|
|||||||
//Implement element_interface
|
//Implement element_interface
|
||||||
bool facade<element::arrow>::draw(graph_reference graph, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state estate)
|
bool facade<element::arrow>::draw(graph_reference graph, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state estate)
|
||||||
{
|
{
|
||||||
graph.set_color(fgcolor);
|
graph.palette(false, fgcolor);
|
||||||
return (*cite_)->draw(graph, bgcolor, fgcolor, r, estate, dir_);
|
return (*cite_)->draw(graph, bgcolor, fgcolor, r, estate, dir_);
|
||||||
}
|
}
|
||||||
//end class facade<element::arrow>
|
//end class facade<element::arrow>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user