Merge remote-tracking branch 'origin/CMake' into CMake
This commit is contained in:
		
						commit
						b58f4ddc9f
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -42,6 +42,7 @@ lib/
 | 
				
			|||||||
CMakeCache.txt
 | 
					CMakeCache.txt
 | 
				
			||||||
CMakeFiles/
 | 
					CMakeFiles/
 | 
				
			||||||
cmake-build-debug/
 | 
					cmake-build-debug/
 | 
				
			||||||
 | 
					cmake-build-*/
 | 
				
			||||||
.idea/
 | 
					.idea/
 | 
				
			||||||
cmake_install.cmake
 | 
					cmake_install.cmake
 | 
				
			||||||
*.DS_Store
 | 
					*.DS_Store
 | 
				
			||||||
 | 
				
			|||||||
@ -56,18 +56,11 @@ before_script :
 | 
				
			|||||||
  - sleep 3 # give xvfb some time to start
 | 
					  - sleep 3 # give xvfb some time to start
 | 
				
			||||||
  # we have:  qPCR4vir/nana/../nana-demo and  now we are in: qPCR4vir/nana/  our executable tests will access: ../nana-demo/Examples/*.bmp etc.(need to be in parallel with nana-demo/Examples)
 | 
					  # we have:  qPCR4vir/nana/../nana-demo and  now we are in: qPCR4vir/nana/  our executable tests will access: ../nana-demo/Examples/*.bmp etc.(need to be in parallel with nana-demo/Examples)
 | 
				
			||||||
  #- cd ../nana-demo
 | 
					  #- cd ../nana-demo
 | 
				
			||||||
  - mkdir ../nana_lib
 | 
					 | 
				
			||||||
  - mkdir ../nana_demo_bin
 | 
					 | 
				
			||||||
  - cd ../nana_lib
 | 
					  - cd ../nana_lib
 | 
				
			||||||
  - mkdir  bin
 | 
					  - mkdir  bin
 | 
				
			||||||
  - cd bin
 | 
					  - cd bin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
script:
 | 
					script:
 | 
				
			||||||
  # Installing: the static "nana lib" will be in DESTDIR/CMAKE_INSTALL_PREFIX/lib/
 | 
					 | 
				
			||||||
  # and the includes files "nana" in DESTDIR/CMAKE_INSTALL_PREFIX/include/
 | 
					 | 
				
			||||||
  # we are in "... nana/../nana_lib/bin/" we need "../../nana" to get the CMakeList.txt of nana.
 | 
					 | 
				
			||||||
  # Thus, make install will put the nana.lib in "... nana/../nana_lib/lib/"
 | 
					 | 
				
			||||||
  # and the includes in "... nana/../nana_lib/include/"
 | 
					 | 
				
			||||||
  - cmake -G"Unix Makefiles" ../../nana -DCMAKE_INSTALL_PREFIX=.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_BOOST_FILESYSTEM_FORCE=OFF  -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON
 | 
					  - cmake -G"Unix Makefiles" ../../nana -DCMAKE_INSTALL_PREFIX=.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_BOOST_FILESYSTEM_FORCE=OFF  -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON
 | 
				
			||||||
  - make install
 | 
					  - make install
 | 
				
			||||||
  - ls
 | 
					  - ls
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										206
									
								
								CMakeLists.txt
									
									
									
									
									
								
							
							
						
						
									
										206
									
								
								CMakeLists.txt
									
									
									
									
									
								
							@ -17,30 +17,34 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# https://cliutils.gitlab.io/modern-cmake/
 | 
					# https://cliutils.gitlab.io/modern-cmake/
 | 
				
			||||||
# https://cmake.org/cmake-tutorial/
 | 
					# https://cmake.org/cmake-tutorial/
 | 
				
			||||||
# https://cmake.org/cmake/help/v3.3/module/CMakeDependentOption.html?highlight=cmakedependentoption
 | 
					# https://cmake.org/cmake/help/v3.12/module/CMakeDependentOption.html?highlight=cmakedependentoption
 | 
				
			||||||
# use CACHE FORCE  or set(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ ON) or delete CMakecache.txt or the entirely build dir
 | 
					# use CACHE FORCE  or set(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ ON) or delete CMakecache.txt or the entirely build dir
 | 
				
			||||||
# if your changes don't execute
 | 
					# if your changes don't execute
 | 
				
			||||||
#  It seems that project() defines essential system variables like CMAKE_FIND_LIBRARY_PREFIXES.
 | 
					#  It seems that project() defines essential system variables like CMAKE_FIND_LIBRARY_PREFIXES.
 | 
				
			||||||
#  https://bbs.archlinux.org/viewtopic.php?id=84967
 | 
					#  https://bbs.archlinux.org/viewtopic.php?id=84967
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cmake_minimum_required(VERSION 3.12)
 | 
					cmake_minimum_required(VERSION 3.12)
 | 
				
			||||||
project(nana VERSION      1.6.1
 | 
					project(nana VERSION      1.6.2
 | 
				
			||||||
        DESCRIPTION "C++ GUI library"
 | 
					        DESCRIPTION "C++ GUI library"
 | 
				
			||||||
        HOMEPAGE_URL http://nanapro.org
 | 
					        HOMEPAGE_URL http://nanapro.org
 | 
				
			||||||
        LANGUAGES CXX         )
 | 
					        LANGUAGES CXX         )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# instead of option(NANA_CMAKE_SHARED_LIB "Compile nana as a shared library." OFF)  ??
 | 
					 | 
				
			||||||
option(BUILD_SHARED_LIBS "Compile nana as a shared library." OFF)
 | 
					option(BUILD_SHARED_LIBS "Compile nana as a shared library." OFF)
 | 
				
			||||||
set(NANA_CMAKE_SHARED_LIB ${BUILD_SHARED_LIBS})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#######################     Main setting of Nana targets, sources and installs
 | 
					#######################     Main setting of Nana targets, sources and installs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_library(${PROJECT_NAME}  )
 | 
					add_library(nana)
 | 
				
			||||||
 | 
					target_compile_features(nana PUBLIC cxx_std_14)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
###    collect all source sub-directories in a list to avoid duplication here
 | 
					###    collect all source sub-directories in a list to avoid duplication here
 | 
				
			||||||
set(NANA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source)
 | 
					
 | 
				
			||||||
 | 
					# By using CMAKE_CURRENT_LIST_DIR here you can compile and consume nana by just:
 | 
				
			||||||
 | 
					# include(path/to/nana/CMakeLists.txt)
 | 
				
			||||||
 | 
					# in your own CMakeLists.txt, and them :
 | 
				
			||||||
 | 
					# target_link_libraries(yourApp PRIVATE nana )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set(NANA_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/source)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(NANA_SOURCE_SUBDIRS
 | 
					set(NANA_SOURCE_SUBDIRS
 | 
				
			||||||
        /.
 | 
					        /.
 | 
				
			||||||
@ -64,17 +68,16 @@ endif()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# collect all source files in the source-sub-dir
 | 
					# collect all source files in the source-sub-dir
 | 
				
			||||||
foreach(subdir ${NANA_SOURCE_SUBDIRS})
 | 
					foreach(subdir ${NANA_SOURCE_SUBDIRS})
 | 
				
			||||||
    aux_source_directory(${NANA_SOURCE_DIR}${subdir} SOURCES)
 | 
					    aux_source_directory(${NANA_SOURCE_DIR}${subdir} SOURCES) # todo: use GLOB to add headers too ??
 | 
				
			||||||
endforeach()
 | 
					endforeach()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target_sources(${PROJECT_NAME} PRIVATE ${SOURCES})
 | 
					target_sources(nana PRIVATE ${SOURCES})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
###    collect all headers sub-directories in a list to avoid duplication here
 | 
					###    collect all headers sub-directories in a list to avoid duplication here ??
 | 
				
			||||||
# To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library / target_sources
 | 
					# To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library / target_sources
 | 
				
			||||||
# and Use SOURCE_GROUP if all your sources are in the same directory
 | 
					# and Use SOURCE_GROUP if all your sources are in the same directory
 | 
				
			||||||
set(NANA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
 | 
					set(NANA_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include)
 | 
				
			||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${NANA_INCLUDE_DIR})
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(NANA_INCLUDE_SUBDIRS
 | 
					set(NANA_INCLUDE_SUBDIRS
 | 
				
			||||||
        /.
 | 
					        /.
 | 
				
			||||||
@ -97,79 +100,68 @@ if(NANA_CMAKE_ENABLE_AUDIO)
 | 
				
			|||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
foreach(subdir ${NANA_INCLUDE_SUBDIRS})
 | 
					foreach(subdir ${NANA_INCLUDE_SUBDIRS})
 | 
				
			||||||
    aux_source_directory(${NANA_INCLUDE_DIR}/nana${subdir} HEADERS)
 | 
					    aux_source_directory(${NANA_INCLUDE_DIR}/nana${subdir} HEADERS)  # todo: use GLOB to add headers too !!!!!!!
 | 
				
			||||||
endforeach()
 | 
					endforeach()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Install the include directories too.
 | 
					# Install the include directories too.
 | 
				
			||||||
if(NANA_CMAKE_INSTALL_INCLUDES)
 | 
					if(NANA_CMAKE_INSTALL_INCLUDES)
 | 
				
			||||||
    target_sources(${PROJECT_NAME} PRIVATE ${HEADERS})
 | 
					    target_sources(nana PRIVATE ${HEADERS})
 | 
				
			||||||
    install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include)
 | 
					    target_include_directories(nana PRIVATE ${NANA_INCLUDE_DIR})
 | 
				
			||||||
    foreach(subdir ${NANA_INCLUDE_SUBDIRS})
 | 
					    install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include) # in ${CMAKE_INSTALL_PREFIX}/include/nana
 | 
				
			||||||
 | 
					    foreach(subdir ${NANA_INCLUDE_SUBDIRS})                         # this works?
 | 
				
			||||||
        aux_source_directory($<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/nana${subdir}> PUBLIC_HEADERS)
 | 
					        aux_source_directory($<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/nana${subdir}> PUBLIC_HEADERS)
 | 
				
			||||||
    endforeach()
 | 
					    endforeach()                                                    # todo: use GLOB to add headers too !!!!!!!
 | 
				
			||||||
    target_sources(${PROJECT_NAME} INTERFACE ${PUBLIC_HEADERS})
 | 
					    target_sources(nana INTERFACE ${PUBLIC_HEADERS})
 | 
				
			||||||
    message("The Nana include files will be installed in ${CMAKE_INSTALL_PREFIX}/include")
 | 
					    message("The Nana include files will be installed in ${CMAKE_INSTALL_PREFIX}/include")
 | 
				
			||||||
else()
 | 
					else()
 | 
				
			||||||
    target_sources(${PROJECT_NAME} PUBLIC ${HEADERS})
 | 
					    target_sources(nana PUBLIC ${HEADERS})
 | 
				
			||||||
 | 
					    target_include_directories(nana PUBLIC ${NANA_INCLUDE_DIR})
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)     #
 | 
					 | 
				
			||||||
target_link_libraries(${PROJECT_NAME} ${NANA_LINKS})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#  Headers: use INCLUDE_DIRECTORIES
 | 
					 | 
				
			||||||
#  Libraries: use FIND_LIBRARY and link with the result of it (try to avoid LINK_DIRECTORIES)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
message("")
 | 
					message("")
 | 
				
			||||||
message("The compiled Nana library will be installed in ${CMAKE_INSTALL_PREFIX}/lib")
 | 
					message("The compiled Nana library will be installed in ${CMAKE_INSTALL_PREFIX}/lib")
 | 
				
			||||||
# Actually in DESTDIR/CMAKE_INSTALL_PREFIX/lib but in windows there is no DESTDIR/ part.
 | 
					# Actually in DESTDIR/CMAKE_INSTALL_PREFIX/lib but in windows there is no DESTDIR/ part.
 | 
				
			||||||
install(TARGETS ${PROJECT_NAME}
 | 
					install(TARGETS nana
 | 
				
			||||||
        ARCHIVE DESTINATION lib
 | 
					        ARCHIVE DESTINATION lib
 | 
				
			||||||
        LIBRARY DESTINATION lib
 | 
					        LIBRARY DESTINATION lib
 | 
				
			||||||
        RUNTIME DESTINATION bin)
 | 
					        RUNTIME DESTINATION bin)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# test BUILD_SHARED_LIBS directly?
 | 
					if(BUILD_SHARED_LIBS)    # ??
 | 
				
			||||||
if(NANA_CMAKE_SHARED_LIB)
 | 
					 | 
				
			||||||
    if(WIN32)
 | 
					    if(WIN32)
 | 
				
			||||||
        set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
 | 
					        set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
 | 
				
			||||||
        if(DLLTOOL)
 | 
					        if(DLLTOOL)
 | 
				
			||||||
            #generate the lib and def files needed by msvc
 | 
					            #generate the lib and def files needed by msvc
 | 
				
			||||||
            set_target_properties (${PROJECT_NAME}
 | 
					            set_target_properties (nana   PROPERTIES
 | 
				
			||||||
                    PROPERTIES OUTPUT_NAME            "${PROJECT_NAME}"
 | 
					                    OUTPUT_NAME         nana
 | 
				
			||||||
                               ARCHIVE_OUTPUT_NAME    "${PROJECT_NAME}"
 | 
					                    ARCHIVE_OUTPUT_NAME nana
 | 
				
			||||||
                    LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--output-def=${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.def"
 | 
					                    LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--output-def=${CMAKE_CURRENT_BINARY_DIR}/libnana.def"
 | 
				
			||||||
                    )
 | 
					                    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
 | 
					            add_custom_command(TARGET nana POST_BUILD
 | 
				
			||||||
                    WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
 | 
					                    WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
 | 
				
			||||||
                    COMMAND echo "       Generating import library"
 | 
					                    COMMAND echo "       Generating import library"
 | 
				
			||||||
                    COMMAND "${DLLTOOL}" --dllname    "lib${PROJECT_NAME}.dll"
 | 
					                    COMMAND "${DLLTOOL}" --dllname    "libnana.dll"
 | 
				
			||||||
                    --input-def  "lib${PROJECT_NAME}.def"
 | 
					                    --input-def  "libnana.def"
 | 
				
			||||||
                    --output-lib "lib${PROJECT_NAME}.lib")
 | 
					                    --output-lib "libnana.lib")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.def"
 | 
					            install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnana.def"
 | 
				
			||||||
                    "${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.lib" DESTINATION lib)
 | 
					                    "${CMAKE_CURRENT_BINARY_DIR}/libnana.lib" DESTINATION lib)
 | 
				
			||||||
        endif()
 | 
					        endif()
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Install the include directories too.
 | 
					 | 
				
			||||||
if(NANA_CMAKE_INSTALL_INCLUDES)
 | 
					 | 
				
			||||||
    install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include)
 | 
					 | 
				
			||||||
    message("The Nana include files will be installed in ${CMAKE_INSTALL_PREFIX}/include")
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
######## Nana options
 | 
					######## Nana options
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_definitions(-DNANA_IGNORE_CONF)
 | 
					target_compile_definitions(nana PRIVATE NANA_IGNORE_CONF)
 | 
				
			||||||
if(NANA_CMAKE_VERBOSE_PREPROCESSOR)
 | 
					if(NANA_CMAKE_VERBOSE_PREPROCESSOR)
 | 
				
			||||||
    add_definitions(-DVERBOSE_PREPROCESSOR)
 | 
					    target_compile_definitions(nana PRIVATE VERBOSE_PREPROCESSOR)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
if(NANA_CMAKE_AUTOMATIC_GUI_TESTING)
 | 
					if(NANA_CMAKE_AUTOMATIC_GUI_TESTING)
 | 
				
			||||||
    add_definitions(-DNANA_AUTOMATIC_GUI_TESTING)
 | 
					    target_compile_definitions(nana PUBLIC NANA_AUTOMATIC_GUI_TESTING)
 | 
				
			||||||
    enable_testing()
 | 
					    enable_testing()       #  ??
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -204,9 +196,11 @@ option(NANA_CMAKE_STD_FILESYSTEM_FORCE "Use of STD filesystem?(a compilation err
 | 
				
			|||||||
option(NANA_CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if available (over STD)?" OFF)
 | 
					option(NANA_CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if available (over STD)?" OFF)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
########### OS
 | 
					########### OS
 | 
				
			||||||
 | 
					# https://blog.kowalczyk.info/article/j/guide-to-predefined-macros-in-c-compilers-gcc-clang-msvc-etc..html
 | 
				
			||||||
 | 
					# http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(WIN32)
 | 
					if(WIN32)
 | 
				
			||||||
    add_definitions(-DWIN32)
 | 
					    target_compile_definitions(nana PUBLIC WIN32)    # todo: why not simple test for _WIN32 in code??
 | 
				
			||||||
    # Global MSVC definitions. You may prefer the hand-tuned sln and projects from the nana repository.
 | 
					    # Global MSVC definitions. You may prefer the hand-tuned sln and projects from the nana repository.
 | 
				
			||||||
    if(MSVC)
 | 
					    if(MSVC)
 | 
				
			||||||
        option(MSVC_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON)
 | 
					        option(MSVC_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON)
 | 
				
			||||||
@ -214,7 +208,7 @@ if(WIN32)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # Change the MSVC Compiler flags
 | 
					        # Change the MSVC Compiler flags
 | 
				
			||||||
        if(MSVC_USE_MP)
 | 
					        if(MSVC_USE_MP)
 | 
				
			||||||
            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
 | 
					            target_compile_options(nana PUBLIC "/MP" )
 | 
				
			||||||
        endif()
 | 
					        endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(MSVC_USE_STATIC_RUNTIME)
 | 
					        if(MSVC_USE_STATIC_RUNTIME)
 | 
				
			||||||
@ -231,9 +225,9 @@ if(WIN32)
 | 
				
			|||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(MINGW)
 | 
					    if(MINGW)
 | 
				
			||||||
        if(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
 | 
					        if(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)      # deprecated ?????
 | 
				
			||||||
            add_definitions(-DSTD_THREAD_NOT_SUPPORTED)
 | 
					            target_compile_definitions(nana PUBLIC STD_THREAD_NOT_SUPPORTED)
 | 
				
			||||||
            add_definitions(-DNANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
 | 
					            target_compile_definitions(nana PUBLIC NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
 | 
				
			||||||
        endif()
 | 
					        endif()
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -249,20 +243,20 @@ if(WIN32)
 | 
				
			|||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(APPLE)
 | 
					if(APPLE)
 | 
				
			||||||
    add_definitions(-DAPPLE)
 | 
					    target_compile_definitions(nana PUBLIC APPLE)      # ??? not added by compilers? use  __APPLE__  ?
 | 
				
			||||||
    include_directories(/opt/X11/include/)
 | 
					    target_include_directories(nana PUBLIC /opt/X11/include/)
 | 
				
			||||||
    list(APPEND NANA_LINKS -L/opt/X11/lib/ -liconv)
 | 
					    target_compile_options(nana PUBLIC  -L/opt/X11/lib/ -liconv)
 | 
				
			||||||
    set(ENABLE_AUDIO OFF)
 | 
					    set(ENABLE_AUDIO OFF)
 | 
				
			||||||
elseif(UNIX)
 | 
					elseif(UNIX)
 | 
				
			||||||
    add_definitions(-Dlinux)
 | 
					    target_compile_definitions(nana PUBLIC linux)      # todo: eliminate. Added by compilers. Also __linux posible
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(UNIX)
 | 
					if(UNIX)
 | 
				
			||||||
    list(APPEND NANA_LINKS -lX11)
 | 
					    target_compile_options(nana PUBLIC  -lX11)
 | 
				
			||||||
    include(FindFreetype)
 | 
					    include(FindFreetype)
 | 
				
			||||||
    if(FREETYPE_FOUND)
 | 
					    if(FREETYPE_FOUND)
 | 
				
			||||||
        include_directories( ${FREETYPE_INCLUDE_DIRS})
 | 
					        target_include_directories(nana PUBLIC  ${FREETYPE_INCLUDE_DIRS})
 | 
				
			||||||
        list(APPEND NANA_LINKS -lXft -lfontconfig)
 | 
					        target_compile_options(nana PUBLIC  -lXft -lfontconfig)
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -280,41 +274,32 @@ endif()
 | 
				
			|||||||
# see at end of:  https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html
 | 
					# see at end of:  https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
 | 
					if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    target_compile_options(nana PRIVATE  -Wall)
 | 
				
			||||||
    if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
 | 
					    if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
 | 
				
			||||||
        if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
 | 
					        if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
 | 
				
			||||||
            set(CMAKE_CXX_FLAGS "-std=gnu++14 -Wall -I/usr/local/include")
 | 
					            target_compile_options(nana PRIVATE -I/usr/local/include)
 | 
				
			||||||
        else()
 | 
					 | 
				
			||||||
            set(CMAKE_CXX_FLAGS "-std=gnu++14 -Wall")
 | 
					 | 
				
			||||||
        endif()
 | 
					 | 
				
			||||||
    else()
 | 
					 | 
				
			||||||
        set(CMAKE_CXX_FLAGS "-std=c++14 -Wall")
 | 
					 | 
				
			||||||
        endif()
 | 
					        endif()
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
 | 
					    if(BUILD_SHARED_LIBS)
 | 
				
			||||||
    if(NANA_CMAKE_SHARED_LIB)
 | 
					        target_compile_options(nana PRIVATE  -lgcc -lstdc++)
 | 
				
			||||||
        list(APPEND NANA_LINKS -lgcc -lstdc++ -pthread)
 | 
					 | 
				
			||||||
    else()
 | 
					    else()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(MINGW)
 | 
					        if(MINGW)
 | 
				
			||||||
            set(CMAKE_EXE_LINKER_FLAGS "-static -pthread")
 | 
					            target_compile_options(nana PRIVATE -static)     #  -static ?? cmake knows BUILD_SHARED_LIBS
 | 
				
			||||||
        else()
 | 
					        else()
 | 
				
			||||||
            set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -pthread")
 | 
					            target_compile_options(nana PRIVATE -static-libgcc -static-libstdc++)
 | 
				
			||||||
        endif()
 | 
					        endif()
 | 
				
			||||||
    endif(NANA_CMAKE_SHARED_LIB)
 | 
					    endif(BUILD_SHARED_LIBS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    target_compile_options(nana PRIVATE -pthread)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
 | 
					 | 
				
			||||||
        # GCC 4.9
 | 
					 | 
				
			||||||
        list(APPEND NANA_LINKS "-lboost_system -lboost_thread")
 | 
					 | 
				
			||||||
    elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
 | 
					 | 
				
			||||||
        # IS_GNUCXX < 5.3
 | 
					 | 
				
			||||||
    else()
 | 
					 | 
				
			||||||
        list(APPEND NANA_LINKS -lstdc++fs)
 | 
					 | 
				
			||||||
    endif()
 | 
					 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")                    # APPLE Clang
 | 
					if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")                    # APPLE Clang
 | 
				
			||||||
    list(APPEND NANA_LINKS -stdlib=libstdc++)
 | 
					    target_compile_options(nana PRIVATE -stdlib=libstdc++)
 | 
				
			||||||
endif ()
 | 
					endif ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -325,38 +310,37 @@ if(NANA_CMAKE_ENABLE_PNG)
 | 
				
			|||||||
    if(NANA_CMAKE_LIBPNG_FROM_OS)
 | 
					    if(NANA_CMAKE_LIBPNG_FROM_OS)
 | 
				
			||||||
        find_package(PNG)
 | 
					        find_package(PNG)
 | 
				
			||||||
        if(PNG_FOUND)
 | 
					        if(PNG_FOUND)
 | 
				
			||||||
            include_directories(${PNG_INCLUDE_DIRS})
 | 
					            target_include_directories(nana PRIVATE ${PNG_INCLUDE_DIRS})
 | 
				
			||||||
            list(APPEND NANA_LINKS ${PNG_LIBRARIES})
 | 
					            target_compile_options    (nana PRIVATE ${PNG_LIBRARIES})
 | 
				
			||||||
            add_definitions(-DNANA_ENABLE_PNG -DUSE_LIBPNG_FROM_OS)
 | 
					            target_compile_definitions(nana PUBLIC NANA_ENABLE_PNG USE_LIBPNG_FROM_OS)
 | 
				
			||||||
        endif()
 | 
					        endif()
 | 
				
			||||||
    else()
 | 
					    else()
 | 
				
			||||||
        add_definitions(-DNANA_ENABLE_PNG)
 | 
					        target_compile_definitions(nana PRIVATE NANA_ENABLE_PNG)
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Find JPEG
 | 
					# Find JPEG
 | 
				
			||||||
if(NANA_CMAKE_ENABLE_JPEG)
 | 
					if(NANA_CMAKE_ENABLE_JPEG)
 | 
				
			||||||
    add_definitions(-DNANA_ENABLE_JPEG)
 | 
					 | 
				
			||||||
    if(NANA_CMAKE_LIBJPEG_FROM_OS)
 | 
					    if(NANA_CMAKE_LIBJPEG_FROM_OS)
 | 
				
			||||||
        find_package(JPEG)
 | 
					        find_package(JPEG)
 | 
				
			||||||
        if(JPEG_FOUND)
 | 
					        if(JPEG_FOUND)
 | 
				
			||||||
            include_directories( ${JPEG_INCLUDE_DIR})
 | 
					            target_include_directories(nana PRIVATE  ${JPEG_INCLUDE_DIR})
 | 
				
			||||||
            list(APPEND NANA_LINKS ${JPEG_LIBRARY})
 | 
					            target_compile_options    (nana PRIVATE  ${JPEG_LIBRARY})
 | 
				
			||||||
            add_definitions(-DNANA_ENABLE_JPEG -DUSE_LIBJPEG_FROM_OS)
 | 
					            target_compile_definitions(nana PUBLIC NANA_ENABLE_JPEG USE_LIBJPEG_FROM_OS)
 | 
				
			||||||
        endif()
 | 
					        endif()
 | 
				
			||||||
    else()
 | 
					    else()
 | 
				
			||||||
        add_definitions(-DNANA_ENABLE_JPEG)
 | 
					        target_compile_definitions(nana PRIVATE NANA_ENABLE_JPEG)
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Find ASOUND
 | 
					# Find ASOUND
 | 
				
			||||||
if(NANA_CMAKE_ENABLE_AUDIO)
 | 
					if(NANA_CMAKE_ENABLE_AUDIO)
 | 
				
			||||||
    add_definitions(-DNANA_ENABLE_AUDIO)
 | 
					    target_compile_definitions(nana PUBLIC NANA_ENABLE_AUDIO)
 | 
				
			||||||
    if(UNIX)
 | 
					    if(UNIX)
 | 
				
			||||||
        find_package(ASOUND)
 | 
					        find_package(ASOUND)
 | 
				
			||||||
        if(ASOUND_FOUND)
 | 
					        if(ASOUND_FOUND)
 | 
				
			||||||
            include_directories(${ASOUND_INCLUDE_DIRS})
 | 
					            target_include_directories(nana PRIVATE ${ASOUND_INCLUDE_DIRS})
 | 
				
			||||||
            list(APPEND NANA_LINKS -lasound)
 | 
					            target_compile_options(nana PRIVATE  -lasound)
 | 
				
			||||||
        else()
 | 
					        else()
 | 
				
			||||||
            message(FATAL_ERROR "libasound is not found")
 | 
					            message(FATAL_ERROR "libasound is not found")
 | 
				
			||||||
        endif()
 | 
					        endif()
 | 
				
			||||||
@ -364,37 +348,46 @@ if(NANA_CMAKE_ENABLE_AUDIO)
 | 
				
			|||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Find/Select filesystem
 | 
					# Find/Select filesystem
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(NANA_CMAKE_NANA_FILESYSTEM_FORCE)
 | 
					if(NANA_CMAKE_NANA_FILESYSTEM_FORCE)
 | 
				
			||||||
    add_definitions(-DNANA_FILESYSTEM_FORCE)
 | 
					    target_compile_definitions(nana PUBLIC NANA_FILESYSTEM_FORCE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
elseif(NANA_CMAKE_STD_FILESYSTEM_FORCE)
 | 
					elseif(NANA_CMAKE_STD_FILESYSTEM_FORCE)
 | 
				
			||||||
    add_definitions(-DSTD_FILESYSTEM_FORCE)
 | 
					    target_compile_definitions(nana PUBLIC STD_FILESYSTEM_FORCE)
 | 
				
			||||||
 | 
					    target_compile_options    (nana PUBLIC -lstdc++fs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
elseif(NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
 | 
					elseif(NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
 | 
				
			||||||
    if(NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
 | 
					    if(NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
 | 
				
			||||||
        add_definitions(-DBOOST_FILESYSTEM_FORCE)
 | 
					        target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_FORCE)
 | 
				
			||||||
 | 
					    else()
 | 
				
			||||||
 | 
					        target_compile_options    (nana PUBLIC -lstdc++fs)
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # https://cmake.org/cmake/help/git-master/module/FindBoost.html
 | 
					    # https://cmake.org/cmake/help/git-master/module/FindBoost.html
 | 
				
			||||||
    # Implicit dependencies such as Boost::filesystem requiring Boost::system will be automatically detected and satisfied,
 | 
					    # Implicit dependencies such as Boost::filesystem requiring Boost::system will be automatically detected and satisfied,
 | 
				
			||||||
    # even if system is not specified when using find_package and if Boost::system is not added to target_link_libraries.
 | 
					    # even if system is not specified when using find_package and if Boost::system is not added to target_link_libraries.
 | 
				
			||||||
    # If using Boost::thread, then Thread::Thread will also be added automatically.
 | 
					    # If using Boost::thread, then Thread::Thread will also be added automatically.
 | 
				
			||||||
    find_package(Boost COMPONENTS filesystem)
 | 
					    find_package(Boost COMPONENTS filesystem)
 | 
				
			||||||
    if(Boost_FOUND)
 | 
					    if(Boost_FOUND)
 | 
				
			||||||
        add_definitions(-DBOOST_FILESYSTEM_AVAILABLE)
 | 
					        target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_AVAILABLE)
 | 
				
			||||||
        include_directories(SYSTEM "${Boost_INCLUDE_DIR}")
 | 
					        target_include_directories(nana PUBLIC "${Boost_INCLUDE_DIR}")    # ?? SYSTEM
 | 
				
			||||||
        list(APPEND NANA_LINKS ${Boost_LIBRARIES})
 | 
					        target_link_libraries     (nana PUBLIC ${Boost_LIBRARIES})
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
    set(Boost_USE_STATIC_LIBS ON)
 | 
					    set(Boost_USE_STATIC_LIBS ON)
 | 
				
			||||||
    set(Boost_USE_STATIC_RUNTIME ON)
 | 
					    set(Boost_USE_STATIC_RUNTIME ON)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
 | 
					if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
 | 
				
			||||||
    add_definitions(-fmax-errors=3)
 | 
					    target_compile_options(nana PRIVATE -fmax-errors=3)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(CMAKE_DEBUG_POSTFIX "_d")
 | 
					set(CMAKE_DEBUG_POSTFIX "_d")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
# Just for information:
 | 
					# Just for information:
 | 
				
			||||||
include(CMakePrintHelpers)
 | 
					include(CMakePrintHelpers)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -410,8 +403,15 @@ message ( "CMAKE_COMPILER_IS_GNUCXX  = "  ${CMAKE_COMPILER_IS_GNUCXX})
 | 
				
			|||||||
message ( "CMAKE_CXX_FLAGS           = "  ${CMAKE_CXX_FLAGS})
 | 
					message ( "CMAKE_CXX_FLAGS           = "  ${CMAKE_CXX_FLAGS})
 | 
				
			||||||
message ( "CMAKE_EXE_LINKER_FLAGS    = "  ${CMAKE_EXE_LINKER_FLAGS})
 | 
					message ( "CMAKE_EXE_LINKER_FLAGS    = "  ${CMAKE_EXE_LINKER_FLAGS})
 | 
				
			||||||
message ( "CMAKE_STATIC_LINKER_FLAGS = "  ${CMAKE_STATIC_LINKER_FLAGS})
 | 
					message ( "CMAKE_STATIC_LINKER_FLAGS = "  ${CMAKE_STATIC_LINKER_FLAGS})
 | 
				
			||||||
#message ("")
 | 
					
 | 
				
			||||||
cmake_print_variables ( NANA_LINKS )
 | 
					
 | 
				
			||||||
 | 
					# see: https://cmake.org/cmake/help/v3.12/manual/cmake-properties.7.html#properties-on-targets
 | 
				
			||||||
 | 
					cmake_print_properties(TARGETS nana  PROPERTIES
 | 
				
			||||||
 | 
					        COMPILE_DEFINITIONS   COMPILE_OPTIONS    COMPILE_FLAGS  LINK_LIBRARIES
 | 
				
			||||||
 | 
					        INCLUDE_DIRECTORIES   INSTALL_NAME_DIR   LINK_FLAGS     VERSION
 | 
				
			||||||
 | 
					                                      )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
message ( "DESTDIR                   = "  ${DESTDIR})
 | 
					message ( "DESTDIR                   = "  ${DESTDIR})
 | 
				
			||||||
message ( "CMAKE_INSTALL_PREFIX      = "  ${CMAKE_INSTALL_PREFIX})
 | 
					message ( "CMAKE_INSTALL_PREFIX      = "  ${CMAKE_INSTALL_PREFIX})
 | 
				
			||||||
message ( "NANA_INCLUDE_DIR          = "  ${NANA_INCLUDE_DIR})
 | 
					message ( "NANA_INCLUDE_DIR          = "  ${NANA_INCLUDE_DIR})
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
/*
 | 
					/**
 | 
				
			||||||
 *	Platform Specification Implementation
 | 
					 *	Platform Specification Implementation
 | 
				
			||||||
 *	Nana C++ Library(http://www.nanapro.org)
 | 
					 *	Nana C++ Library(http://www.nanapro.org)
 | 
				
			||||||
 *	Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
 | 
					 *	Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
 | 
				
			||||||
@ -7,7 +7,7 @@
 | 
				
			|||||||
 *	(See accompanying file LICENSE_1_0.txt or copy at
 | 
					 *	(See accompanying file LICENSE_1_0.txt or copy at
 | 
				
			||||||
 *	http://www.boost.org/LICENSE_1_0.txt)
 | 
					 *	http://www.boost.org/LICENSE_1_0.txt)
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *	@file: nana/detail/platform_spec.hpp
 | 
					 *	@file nana/detail/platform_spec.hpp
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *	This file provides basis class and data structrue that required by nana
 | 
					 *	This file provides basis class and data structrue that required by nana
 | 
				
			||||||
 *	This file should not be included by any header files.
 | 
					 *	This file should not be included by any header files.
 | 
				
			||||||
 | 
				
			|||||||
@ -83,7 +83,7 @@ namespace nana
 | 
				
			|||||||
					dstream_.parse(s, format_enabled_);
 | 
										dstream_.parse(s, format_enabled_);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				bool format(bool fm)
 | 
									bool format(bool fm) noexcept
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if (fm == format_enabled_)
 | 
										if (fm == format_enabled_)
 | 
				
			||||||
						return false;
 | 
											return false;
 | 
				
			||||||
@ -96,46 +96,20 @@ namespace nana
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					traceable_.clear();
 | 
										traceable_.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					auto pre_font = graph.typeface();	//used for restoring the font
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef _nana_std_has_string_view
 | 
					 | 
				
			||||||
					const unsigned def_line_pixels = graph.text_extent_size(std::wstring_view{ L" ", 1 }).height;
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
					const unsigned def_line_pixels = graph.text_extent_size(L" ", 1).height;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					font_ = pre_font;
 | 
					 | 
				
			||||||
					current_fblock_ = nullptr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					_m_set_default(pre_font, fgcolor);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					render_status rs;
 | 
										render_status rs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					rs.allowed_width = graph.size().width;
 | 
										rs.allowed_width = graph.size().width;
 | 
				
			||||||
					rs.text_align = th;
 | 
										rs.text_align = th;
 | 
				
			||||||
					rs.text_align_v = tv;
 | 
										rs.text_align_v = tv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										::nana::size extent_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					//All visual lines data of whole text.
 | 
										//All visual lines data of whole text.
 | 
				
			||||||
					std::deque<std::vector<visual_line>> content_lines;
 | 
										auto content_lines = _m_measure_extent_size(graph, th, tv, true, graph.size().width, extent_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					std::size_t extent_v_pixels = 0;	//the pixels, in height, that text will be painted.
 | 
										if ((tv != align_v::top) && extent_size.height < graph.height())
 | 
				
			||||||
 | 
					 | 
				
			||||||
					for (auto & line : dstream_)
 | 
					 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						_m_prepare_visual_lines(graph, line, def_line_pixels, rs);
 | 
											rs.pos.y = static_cast<int>(graph.height() - extent_size.height);
 | 
				
			||||||
 | 
					 | 
				
			||||||
						for (auto & vsline : rs.vslines)
 | 
					 | 
				
			||||||
							extent_v_pixels += vsline.extent_height_px;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						content_lines.emplace_back(std::move(rs.vslines));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						if(extent_v_pixels >= graph.height())
 | 
					 | 
				
			||||||
							break;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					if((tv != align_v::top) && extent_v_pixels < graph.height())
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						rs.pos.y = static_cast<int>(graph.height() - extent_v_pixels);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
						if (align_v::center == tv)
 | 
											if (align_v::center == tv)
 | 
				
			||||||
							rs.pos.y >>= 1;
 | 
												rs.pos.y >>= 1;
 | 
				
			||||||
@ -143,6 +117,10 @@ namespace nana
 | 
				
			|||||||
					else
 | 
										else
 | 
				
			||||||
						rs.pos.y = 0;
 | 
											rs.pos.y = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										auto pre_font = graph.typeface();	//used for restoring the font
 | 
				
			||||||
 | 
										_m_set_default(pre_font, fgcolor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					for (auto & line : content_lines)
 | 
										for (auto & line : content_lines)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						rs.index = 0;
 | 
											rs.index = 0;
 | 
				
			||||||
@ -155,19 +133,19 @@ namespace nana
 | 
				
			|||||||
						rs.pos.y += static_cast<int>(rs.vslines.back().extent_height_px);
 | 
											rs.pos.y += static_cast<int>(rs.vslines.back().extent_height_px);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					if (font_ != pre_font)
 | 
										if (transient_.current_font != pre_font)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						graph.typeface(pre_font);
 | 
											graph.typeface(pre_font);
 | 
				
			||||||
						font_.release();
 | 
											transient_.current_font.release();
 | 
				
			||||||
						current_fblock_ = nullptr;
 | 
											transient_.current_fblock = nullptr;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				bool find(int x, int y, std::wstring& target, std::wstring& url) const noexcept
 | 
									bool find(const point& mouse_pos, std::wstring& target, std::wstring& url) const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					for (auto & t : traceable_)
 | 
										for (auto & t : traceable_)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						if(t.r.is_hit(x, y))
 | 
											if(t.r.is_hit(mouse_pos))
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							target = t.target;
 | 
												target = t.target;
 | 
				
			||||||
							url = t.url;
 | 
												url = t.url;
 | 
				
			||||||
@ -180,49 +158,10 @@ namespace nana
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				::nana::size measure(graph_reference graph, unsigned limited, align th, align_v tv)
 | 
									::nana::size measure(graph_reference graph, unsigned limited, align th, align_v tv)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					::nana::size retsize;
 | 
										::nana::size extent_size;
 | 
				
			||||||
 | 
										_m_measure_extent_size(graph, th, tv, false, limited, extent_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					auto pre_font = graph.typeface();	//used for restoring the font
 | 
										return extent_size;
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef _nana_std_has_string_view
 | 
					 | 
				
			||||||
					const unsigned def_line_pixels = graph.text_extent_size(std::wstring_view(L" ", 1)).height;
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
					const unsigned def_line_pixels = graph.text_extent_size(L" ", 1).height;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					font_ = pre_font;
 | 
					 | 
				
			||||||
					current_fblock_ = nullptr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					_m_set_default(pre_font, colors::black);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					render_status rs;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					rs.allowed_width = limited;
 | 
					 | 
				
			||||||
					rs.text_align = th;
 | 
					 | 
				
			||||||
					rs.text_align_v = tv;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					for(auto & line: dstream_)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						rs.vslines.clear();
 | 
					 | 
				
			||||||
						auto w = _m_prepare_visual_lines(graph, line, def_line_pixels, rs);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						if(limited && (w > limited))
 | 
					 | 
				
			||||||
							w = limited;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						if(retsize.width < w)
 | 
					 | 
				
			||||||
							retsize.width = w;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						for (auto& vsline : rs.vslines)
 | 
					 | 
				
			||||||
							retsize.height += static_cast<unsigned>(vsline.extent_height_px);
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					if (font_ != pre_font)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						graph.typeface(pre_font);
 | 
					 | 
				
			||||||
						font_.release();
 | 
					 | 
				
			||||||
						current_fblock_ = nullptr;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					return retsize;
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			private:
 | 
								private:
 | 
				
			||||||
				//Manage the fblock for a specified rectangle if it is a traceable fblock.
 | 
									//Manage the fblock for a specified rectangle if it is a traceable fblock.
 | 
				
			||||||
@ -250,6 +189,9 @@ namespace nana
 | 
				
			|||||||
					def_.font_size = ft.size();
 | 
										def_.font_size = ft.size();
 | 
				
			||||||
					def_.font_bold = ft.bold();
 | 
										def_.font_bold = ft.bold();
 | 
				
			||||||
					def_.fgcolor = fgcolor;
 | 
										def_.fgcolor = fgcolor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										transient_.current_font = ft;
 | 
				
			||||||
 | 
										transient_.current_fblock = nullptr;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				const ::nana::color& _m_fgcolor(nana::widgets::skeletons::fblock* fp) noexcept
 | 
									const ::nana::color& _m_fgcolor(nana::widgets::skeletons::fblock* fp) noexcept
 | 
				
			||||||
@ -298,20 +240,20 @@ namespace nana
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				void _m_change_font(graph_reference graph, nana::widgets::skeletons::fblock* fp)
 | 
									void _m_change_font(graph_reference graph, nana::widgets::skeletons::fblock* fp)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if (fp != current_fblock_)
 | 
										if (fp != transient_.current_fblock)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						auto& name = _m_fontname(fp);
 | 
											auto& name = _m_fontname(fp);
 | 
				
			||||||
						auto fontsize = _m_font_size(fp);
 | 
											auto fontsize = _m_font_size(fp);
 | 
				
			||||||
						bool bold = _m_bold(fp);
 | 
											bool bold = _m_bold(fp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						if((fontsize != font_.size()) || bold != font_.bold() || name != font_.name())
 | 
											if((fontsize != transient_.current_font.size()) || bold != transient_.current_font.bold() || name != transient_.current_font.name())
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							paint::font::font_style fs;
 | 
												paint::font::font_style fs;
 | 
				
			||||||
							fs.weight = (bold ? 800 : 400);
 | 
												fs.weight = (bold ? 800 : 400);
 | 
				
			||||||
							font_ = paint::font{ name, fontsize, fs };
 | 
												transient_.current_font = paint::font{ name, fontsize, fs };
 | 
				
			||||||
							graph.typeface(font_);
 | 
												graph.typeface(transient_.current_font);
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						current_fblock_ = fp;
 | 
											transient_.current_fblock = fp;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -331,6 +273,57 @@ namespace nana
 | 
				
			|||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									std::deque<std::vector<visual_line>> _m_measure_extent_size(graph_reference graph, nana::align text_align, nana::align_v text_align_v, bool only_screen, unsigned allowed_width_px, nana::size & extent_size)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										auto pre_font = graph.typeface();	//used for restoring the font
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										unsigned text_ascent, text_descent, text_ileading;
 | 
				
			||||||
 | 
										graph.text_metrics(text_ascent, text_descent, text_ileading);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										auto const def_line_pixels = text_ascent + text_descent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										_m_set_default(pre_font, colors::black);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										render_status rs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										rs.allowed_width = allowed_width_px;
 | 
				
			||||||
 | 
										rs.text_align = text_align;
 | 
				
			||||||
 | 
										rs.text_align_v = text_align_v;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										//All visual lines data of whole text.
 | 
				
			||||||
 | 
										std::deque<std::vector<visual_line>> content_lines;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										extent_size.width = extent_size.height = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										for (auto & line : dstream_)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											auto width_px = _m_prepare_visual_lines(graph, line, def_line_pixels, rs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											if (width_px > extent_size.width)
 | 
				
			||||||
 | 
												extent_size.width = width_px;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											for (auto & vsline : rs.vslines)
 | 
				
			||||||
 | 
												extent_size.height += vsline.extent_height_px;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											content_lines.emplace_back(std::move(rs.vslines));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											if (only_screen && (extent_size.height >= graph.height()))
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if (allowed_width_px < extent_size.width)
 | 
				
			||||||
 | 
											extent_size.width = allowed_width_px;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if (transient_.current_font != pre_font)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											graph.typeface(pre_font);
 | 
				
			||||||
 | 
											transient_.current_font.release();
 | 
				
			||||||
 | 
											transient_.current_fblock = nullptr;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										return content_lines;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				/**
 | 
									/**
 | 
				
			||||||
				 * prepare data for rendering a line of text.
 | 
									 * prepare data for rendering a line of text.
 | 
				
			||||||
				 */
 | 
									 */
 | 
				
			||||||
@ -579,8 +572,7 @@ namespace nana
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
					if (data->is_text())
 | 
										if (data->is_text())
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						auto const text = data->text().c_str() + vsline_elm.range.first;
 | 
											auto const reordered = unicode_reorder(data->text().c_str() + vsline_elm.range.first, vsline_elm.range.second);
 | 
				
			||||||
						auto const reordered = unicode_reorder(text, vsline_elm.range.second);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
						_m_change_font(graph, fblock);
 | 
											_m_change_font(graph, fblock);
 | 
				
			||||||
						for (auto & bidi : reordered)
 | 
											for (auto & bidi : reordered)
 | 
				
			||||||
@ -614,26 +606,18 @@ namespace nana
 | 
				
			|||||||
						rs.pos.x += static_cast<int>(data->size().width);
 | 
											rs.pos.x += static_cast<int>(data->size().width);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					 | 
				
			||||||
				static std::pair<std::size_t, std::size_t> _m_locate(dstream::linecontainer::iterator& i, std::size_t pos)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					std::size_t n = i->data_ptr->text().length();
 | 
					 | 
				
			||||||
					while(pos >= n)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						pos -= n;
 | 
					 | 
				
			||||||
						n = (++i)->data_ptr->text().length();
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					return{ pos, n - pos };
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			private:
 | 
								private:
 | 
				
			||||||
				dstream dstream_;
 | 
									dstream dstream_;
 | 
				
			||||||
				bool format_enabled_ = false;
 | 
									bool format_enabled_ = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				::nana::widgets::skeletons::fblock * current_fblock_{ nullptr };
 | 
					 | 
				
			||||||
				::std::deque<traceable> traceable_;
 | 
									::std::deque<traceable> traceable_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				::nana::paint::font font_;
 | 
									struct transient
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										widgets::skeletons::fblock * current_fblock{ nullptr };
 | 
				
			||||||
 | 
										paint::font current_font;
 | 
				
			||||||
 | 
									}transient_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				struct def_font_tag
 | 
									struct def_font_tag
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					::std::string font_name;
 | 
										::std::string font_name;
 | 
				
			||||||
@ -731,7 +715,7 @@ namespace nana
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					std::wstring target, url;
 | 
										std::wstring target, url;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					if(impl_->renderer.find(arg.pos.x, arg.pos.y, target, url))
 | 
										if(impl_->renderer.find(arg.pos, target, url))
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						int cur_state = 0;
 | 
											int cur_state = 0;
 | 
				
			||||||
						if(target != impl_->target)
 | 
											if(target != impl_->target)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user