Merge remote-tracking branch 'cnjinhao/develop' into develop
This commit is contained in:
commit
d889db7c1e
@ -5,6 +5,7 @@
|
|||||||
# Robert Hauck - Enable support for PNG/Freetype
|
# Robert Hauck - Enable support for PNG/Freetype
|
||||||
# Qiangqiang Wu - Add biicode support
|
# Qiangqiang Wu - Add biicode support
|
||||||
# Ariel Vina-Rodriguez (qPCR4vir)
|
# Ariel Vina-Rodriguez (qPCR4vir)
|
||||||
|
# Frostbane - Add option for compiling a shared library
|
||||||
#
|
#
|
||||||
# Nana uses some build systems: MS-VS solution, MAKE, bakefile, codeblock, etc. manually optimized.
|
# Nana uses some build systems: MS-VS solution, MAKE, bakefile, codeblock, etc. manually optimized.
|
||||||
# In the future CMake could be the prefered, and maybe will be used to generate the others and the central nana repo
|
# In the future CMake could be the prefered, and maybe will be used to generate the others and the central nana repo
|
||||||
@ -30,6 +31,7 @@ option(NANA_CMAKE_LIBPNG_FROM_OS "Use libpng from operating system." ON)
|
|||||||
option(NANA_CMAKE_ENABLE_JPEG "Enable the use of JPEG" OFF)
|
option(NANA_CMAKE_ENABLE_JPEG "Enable the use of JPEG" OFF)
|
||||||
option(NANA_CMAKE_LIBJPEG_FROM_OS "Use libjpeg from operating system." ON)
|
option(NANA_CMAKE_LIBJPEG_FROM_OS "Use libjpeg from operating system." ON)
|
||||||
option(NANA_CMAKE_ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF)
|
option(NANA_CMAKE_ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF)
|
||||||
|
option(NANA_CMAKE_SHARED_LIB "Compile nana as a shared library." OFF)
|
||||||
option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." ON)
|
option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." ON)
|
||||||
option(NANA_CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." OFF)
|
option(NANA_CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." OFF)
|
||||||
option(NANA_CMAKE_AUTOMATIC_GUI_TESTING "Activate automatic GUI testing?" OFF)
|
option(NANA_CMAKE_AUTOMATIC_GUI_TESTING "Activate automatic GUI testing?" OFF)
|
||||||
@ -96,8 +98,24 @@ if(WIN32)
|
|||||||
add_definitions(-DNANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
add_definitions(-DNANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
endif(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
endif(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
endif(MINGW)
|
endif(MINGW)
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
set (DLLTOOL OFF)
|
||||||
|
else ()
|
||||||
|
# mingw: If dlltool is found the def and lib file will be created
|
||||||
|
message (STATUS "Detecting dlltool")
|
||||||
|
find_program (DLLTOOL dlltool)
|
||||||
|
if (DLLTOOL)
|
||||||
|
message (STATUS "Found dlltool: ${DLLTOOL}")
|
||||||
|
else ()
|
||||||
|
message (WARNING "dlltool not found. Skipping import library generation.")
|
||||||
|
endif (DLLTOOL)
|
||||||
|
endif (MSVC)
|
||||||
|
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
add_definitions(-DAPPLE)
|
add_definitions(-DAPPLE)
|
||||||
include_directories(/opt/X11/include/)
|
include_directories(/opt/X11/include/)
|
||||||
@ -140,14 +158,21 @@ endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|||||||
|
|
||||||
# enable static linkage # GNU || CLang not MinGW
|
# enable static linkage # GNU || CLang not MinGW
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW
|
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW
|
||||||
# set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -pthread")
|
|
||||||
list(APPEND NANA_LINKS -static-libgcc -static-libstdc++ -pthread)
|
if(NANA_CMAKE_SHARED_LIB)
|
||||||
|
list(APPEND NANA_LINKS -lgcc -lstdc++ -pthread)
|
||||||
|
else()
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -pthread")
|
||||||
# message("Setting NANA_LINKS to -static-libgcc -static-libstdc++ -pthread or ${NANA_LINKS}")
|
# message("Setting NANA_LINKS to -static-libgcc -static-libstdc++ -pthread or ${NANA_LINKS}")
|
||||||
|
endif(NANA_CMAKE_SHARED_LIB)
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
|
||||||
# IS_GNUCXX < 5.3
|
# IS_GNUCXX < 5.3
|
||||||
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
|
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
|
||||||
|
|
||||||
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++fs") # IS_GNUCXX 5.3 or more
|
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++fs") # IS_GNUCXX 5.3 or more
|
||||||
list(APPEND NANA_LINKS -lstdc++fs)
|
list(APPEND NANA_LINKS -lstdc++fs)
|
||||||
|
|
||||||
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
|
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
|
||||||
|
|
||||||
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW
|
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW
|
||||||
@ -163,14 +188,16 @@ endif ()
|
|||||||
|
|
||||||
# Find PNG
|
# Find PNG
|
||||||
if(NANA_CMAKE_ENABLE_PNG)
|
if(NANA_CMAKE_ENABLE_PNG)
|
||||||
add_definitions(-DNANA_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})
|
include_directories( ${PNG_INCLUDE_DIRS})
|
||||||
list(APPEND NANA_LINKS ${PNG_LIBRARIES})
|
list(APPEND NANA_LINKS ${PNG_LIBRARIES})
|
||||||
add_definitions(-DUSE_LIBPNG_FROM_OS)
|
add_definitions("-DNANA_ENABLE_PNG"
|
||||||
|
"-DUSE_LIBPNG_FROM_OS")
|
||||||
endif(PNG_FOUND)
|
endif(PNG_FOUND)
|
||||||
|
else()
|
||||||
|
add_definitions(-DNANA_ENABLE_PNG)
|
||||||
endif(NANA_CMAKE_LIBPNG_FROM_OS)
|
endif(NANA_CMAKE_LIBPNG_FROM_OS)
|
||||||
endif(NANA_CMAKE_ENABLE_PNG)
|
endif(NANA_CMAKE_ENABLE_PNG)
|
||||||
|
|
||||||
@ -182,8 +209,11 @@ if(NANA_CMAKE_ENABLE_JPEG)
|
|||||||
if (JPEG_FOUND)
|
if (JPEG_FOUND)
|
||||||
include_directories( ${JPEG_INCLUDE_DIR})
|
include_directories( ${JPEG_INCLUDE_DIR})
|
||||||
list(APPEND NANA_LINKS ${JPEG_LIBRARY})
|
list(APPEND NANA_LINKS ${JPEG_LIBRARY})
|
||||||
add_definitions(-DUSE_LIBJPEG_FROM_OS)
|
add_definitions("-DNANA_ENABLE_JPEG"
|
||||||
|
"-DUSE_LIBJPEG_FROM_OS")
|
||||||
endif(JPEG_FOUND)
|
endif(JPEG_FOUND)
|
||||||
|
else()
|
||||||
|
add_definitions(-DNANA_ENABLE_JPEG)
|
||||||
endif(NANA_CMAKE_LIBJPEG_FROM_OS)
|
endif(NANA_CMAKE_LIBJPEG_FROM_OS)
|
||||||
endif(NANA_CMAKE_ENABLE_JPEG)
|
endif(NANA_CMAKE_ENABLE_JPEG)
|
||||||
|
|
||||||
@ -266,7 +296,16 @@ foreach(subdir ${NANA_SOURCE_SUBDIRS})
|
|||||||
# message("Subir: ${subdir}") # message("Files: ${sources}")
|
# message("Subir: ${subdir}") # message("Files: ${sources}")
|
||||||
endforeach(subdir ${NANA_SOURCE_SUBDIRS})
|
endforeach(subdir ${NANA_SOURCE_SUBDIRS})
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} ${sources} )
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||||
|
add_definitions(-fmax-errors=3)
|
||||||
|
endif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||||
|
|
||||||
|
if(NANA_CMAKE_SHARED_LIB)
|
||||||
|
add_library(${PROJECT_NAME} SHARED ${sources} )
|
||||||
|
else()
|
||||||
|
add_library(${PROJECT_NAME} STATIC ${sources} )
|
||||||
|
endif(NANA_CMAKE_SHARED_LIB)
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ${NANA_INCLUDE_DIR})
|
target_include_directories(${PROJECT_NAME} PUBLIC ${NANA_INCLUDE_DIR})
|
||||||
target_link_libraries(${PROJECT_NAME} ${NANA_LINKS})
|
target_link_libraries(${PROJECT_NAME} ${NANA_LINKS})
|
||||||
|
|
||||||
@ -276,7 +315,38 @@ target_link_libraries(${PROJECT_NAME} ${NANA_LINKS})
|
|||||||
# Installing: the static "nana lib" will be in DESTDIR/CMAKE_INSTALL_PREFIX/lib/
|
# Installing: the static "nana lib" will be in DESTDIR/CMAKE_INSTALL_PREFIX/lib/
|
||||||
# and the includes files "include/nana/" in DESTDIR/CMAKE_INSTALL_PREFIX/include/nana/
|
# and the includes files "include/nana/" in DESTDIR/CMAKE_INSTALL_PREFIX/include/nana/
|
||||||
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib
|
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib
|
||||||
LIBRARY DESTINATION lib)
|
LIBRARY DESTINATION lib
|
||||||
|
RUNTIME DESTINATION bin)
|
||||||
|
|
||||||
|
set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 )
|
||||||
|
|
||||||
|
if (NANA_CMAKE_SHARED_LIB)
|
||||||
|
if (WIN32)
|
||||||
|
set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||||
|
|
||||||
|
if (DLLTOOL)
|
||||||
|
#message(STATUS "CMAKE_CURRENT_BINARY_DIR = ${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
|
||||||
|
#generate the lib and def files needed by msvc
|
||||||
|
set_target_properties (${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}"
|
||||||
|
ARCHIVE_OUTPUT_NAME "${PROJECT_NAME}"
|
||||||
|
LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--output-def=${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.def")
|
||||||
|
|
||||||
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
COMMAND echo " Generating import library"
|
||||||
|
COMMAND "${DLLTOOL}" --dllname "lib${PROJECT_NAME}.dll"
|
||||||
|
--input-def "lib${PROJECT_NAME}.def"
|
||||||
|
--output-lib "lib${PROJECT_NAME}.lib")
|
||||||
|
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.def"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.lib" DESTINATION lib)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
endif (WIN32)
|
||||||
|
endif (NANA_CMAKE_SHARED_LIB)
|
||||||
|
|
||||||
|
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")
|
||||||
# Install the include directories too.
|
# Install the include directories too.
|
||||||
if(NANA_CMAKE_INSTALL_INCLUDES)
|
if(NANA_CMAKE_INSTALL_INCLUDES)
|
||||||
@ -284,21 +354,22 @@ if(NANA_CMAKE_INSTALL_INCLUDES)
|
|||||||
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")
|
||||||
endif(NANA_CMAKE_INSTALL_INCLUDES)
|
endif(NANA_CMAKE_INSTALL_INCLUDES)
|
||||||
|
|
||||||
set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 )
|
|
||||||
|
|
||||||
# Just for information:
|
# Just for information:
|
||||||
|
message ("")
|
||||||
message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID})
|
message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID})
|
||||||
message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG})
|
message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG})
|
||||||
message ( "CMAKE_COMPILER_IS_GNUCXX= " ${CMAKE_COMPILER_IS_GNUCXX})
|
message ( "CMAKE_COMPILER_IS_GNUCXX = " ${CMAKE_COMPILER_IS_GNUCXX})
|
||||||
message ( "CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS})
|
message ( "CMAKE_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 ( "NANA_LINKS = " ${NANA_LINKS})
|
message ( "NANA_LINKS = " ${NANA_LINKS})
|
||||||
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})
|
||||||
message ( "CMAKE_CURRENT_SOURCE_DIR= " ${CMAKE_CURRENT_SOURCE_DIR})
|
message ( "CMAKE_CURRENT_SOURCE_DIR = " ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
message ( "NANA_CMAKE_ENABLE_AUDIO = " ${NANA_CMAKE_ENABLE_AUDIO})
|
message ( "NANA_CMAKE_ENABLE_AUDIO = " ${NANA_CMAKE_ENABLE_AUDIO})
|
||||||
|
message ( "NANA_CMAKE_SHARED_LIB = " ${NANA_CMAKE_SHARED_LIB})
|
||||||
message ( "NANA_CMAKE_FIND_BOOST_FILESYSTEM = " ${NANA_CMAKE_FIND_BOOST_FILESYSTEM})
|
message ( "NANA_CMAKE_FIND_BOOST_FILESYSTEM = " ${NANA_CMAKE_FIND_BOOST_FILESYSTEM})
|
||||||
message ( "NANA_CMAKE_BOOST_FILESYSTEM_FORCE = " ${NANA_CMAKE_BOOST_FILESYSTEM_FORCE})
|
message ( "NANA_CMAKE_BOOST_FILESYSTEM_FORCE = " ${NANA_CMAKE_BOOST_FILESYSTEM_FORCE})
|
||||||
message ( "NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT = " ${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT})
|
message ( "NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT = " ${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT})
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
<Unit filename="../../source/datetime.cpp" />
|
<Unit filename="../../source/datetime.cpp" />
|
||||||
<Unit filename="../../source/deploy.cpp" />
|
<Unit filename="../../source/deploy.cpp" />
|
||||||
<Unit filename="../../source/detail/platform_abstraction.cpp" />
|
<Unit filename="../../source/detail/platform_abstraction.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/filesystem.cpp" />
|
<Unit filename="../../source/filesystem/filesystem.cpp" />
|
||||||
<Unit filename="../../source/gui/animation.cpp" />
|
<Unit filename="../../source/gui/animation.cpp" />
|
||||||
|
@ -91,6 +91,8 @@ namespace nana
|
|||||||
substitute = 0x1A, //Ctrl+Z
|
substitute = 0x1A, //Ctrl+Z
|
||||||
escape = 0x1B,
|
escape = 0x1B,
|
||||||
space = 0x20, //Space
|
space = 0x20, //Space
|
||||||
|
del = 0x7F, //Delete
|
||||||
|
os_del = del, //Deprecated
|
||||||
|
|
||||||
//The following names are intuitive name of ASCII control codes
|
//The following names are intuitive name of ASCII control codes
|
||||||
select_all = start_of_headline,
|
select_all = start_of_headline,
|
||||||
@ -106,8 +108,8 @@ namespace nana
|
|||||||
os_ctrl = 0x11,
|
os_ctrl = 0x11,
|
||||||
os_pageup = 0x21, os_pagedown,
|
os_pageup = 0x21, os_pagedown,
|
||||||
os_arrow_left = 0x25, os_arrow_up, os_arrow_right, os_arrow_down,
|
os_arrow_left = 0x25, os_arrow_up, os_arrow_right, os_arrow_down,
|
||||||
os_insert = 0x2D, os_del ,
|
os_insert = 0x2D,
|
||||||
os_end = 0x23 , os_home //Pos 1
|
os_end = 0x23, os_home //Pos 1
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ namespace nana
|
|||||||
|
|
||||||
void focus(graph_reference, const arg_focus&) override;
|
void focus(graph_reference, const arg_focus&) override;
|
||||||
void mouse_wheel(graph_reference, const arg_wheel&) override;
|
void mouse_wheel(graph_reference, const arg_wheel&) override;
|
||||||
|
void dbl_click(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_move(graph_reference, const arg_mouse&) override;
|
void mouse_move(graph_reference, const arg_mouse&) override;
|
||||||
void mouse_up(graph_reference, const arg_mouse& arg) override;
|
void mouse_up(graph_reference, const arg_mouse& arg) override;
|
||||||
|
@ -185,7 +185,7 @@ namespace nana
|
|||||||
|
|
||||||
/// Appends an string. If `at_caret` is `true`, the string is inserted at the position of caret, otherwise, it is appended at end of the textbox.
|
/// Appends an string. If `at_caret` is `true`, the string is inserted at the position of caret, otherwise, it is appended at end of the textbox.
|
||||||
textbox& append(const std::string& text, bool at_caret);
|
textbox& append(const std::string& text, bool at_caret);
|
||||||
|
textbox& append(const std::wstring& text, bool at_caret);
|
||||||
/// Determines whether the text is line wrapped.
|
/// Determines whether the text is line wrapped.
|
||||||
bool line_wrapped() const;
|
bool line_wrapped() const;
|
||||||
textbox& line_wrapped(bool);
|
textbox& line_wrapped(bool);
|
||||||
|
@ -14,8 +14,12 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
// http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno.h#L53
|
// http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno.h#L53
|
||||||
//#define EPROTO 71 /* Protocol error */
|
//#define EPROTO 71 /* Protocol error */
|
||||||
|
#ifdef _GLIBCXX_HAS_GTHREADS
|
||||||
|
# include <thread>
|
||||||
|
#else
|
||||||
#include <mingw.thread.h>
|
#include <mingw.thread.h>
|
||||||
#include <mingw.mutex.h>
|
#include <mingw.mutex.h>
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/thread/recursive_mutex.hpp>
|
#include <boost/thread/recursive_mutex.hpp>
|
||||||
|
@ -6,7 +6,11 @@
|
|||||||
|
|
||||||
#if defined(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
#if defined(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||||
|
|
||||||
#include <mingw.thread.h>
|
#ifdef _GLIBCXX_HAS_GTHREADS
|
||||||
|
# include <thread>
|
||||||
|
#else
|
||||||
|
# include <mingw.thread.h>
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
namespace std
|
namespace std
|
||||||
|
@ -78,7 +78,7 @@ namespace nana{ namespace audio
|
|||||||
void buffer_preparation::revert(meta * m)
|
void buffer_preparation::revert(meta * m)
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(token_prepared_)> lock(token_prepared_);
|
std::lock_guard<decltype(token_prepared_)> lock(token_prepared_);
|
||||||
bool if_signal = prepared_.empty();
|
auto const if_signal = prepared_.empty();
|
||||||
prepared_.emplace_back(m);
|
prepared_.emplace_back(m);
|
||||||
if(if_signal)
|
if(if_signal)
|
||||||
cond_prepared_.notify_one();
|
cond_prepared_.notify_one();
|
||||||
|
@ -438,8 +438,8 @@ namespace detail
|
|||||||
keysym = keyboard::os_arrow_left + (keysym - XK_Left); break;
|
keysym = keyboard::os_arrow_left + (keysym - XK_Left); break;
|
||||||
case XK_Insert:
|
case XK_Insert:
|
||||||
keysym = keyboard::os_insert; break;
|
keysym = keyboard::os_insert; break;
|
||||||
case XK_Delete:
|
case XK_Delete: case XK_KP_Delete:
|
||||||
keysym = keyboard::os_del; break;
|
keysym = keyboard::del; break;
|
||||||
case XK_Shift_L: case XK_Shift_R: //shift
|
case XK_Shift_L: case XK_Shift_R: //shift
|
||||||
keysym = keyboard::os_shift; break;
|
keysym = keyboard::os_shift; break;
|
||||||
case XK_Control_L: case XK_Control_R: //ctrl
|
case XK_Control_L: case XK_Control_R: //ctrl
|
||||||
|
@ -775,6 +775,19 @@ namespace detail
|
|||||||
if (thrd) thrd->event_window = prev_event_wd;
|
if (thrd) thrd->event_window = prev_event_wd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Translate OS Virtual-Key into ASCII code
|
||||||
|
wchar_t translate_virtual_key(WPARAM vkey)
|
||||||
|
{
|
||||||
|
switch (vkey)
|
||||||
|
{
|
||||||
|
case VK_DELETE:
|
||||||
|
return 127;
|
||||||
|
case VK_DECIMAL:
|
||||||
|
return 46;
|
||||||
|
}
|
||||||
|
return static_cast<wchar_t>(vkey);
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK Bedrock_WIN32_WindowProc(HWND root_window, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK Bedrock_WIN32_WindowProc(HWND root_window, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
LRESULT window_proc_value = 0;
|
LRESULT window_proc_value = 0;
|
||||||
@ -1436,7 +1449,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<wchar_t>(wParam);
|
arg.key = translate_virtual_key(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);
|
||||||
|
|
||||||
@ -1522,7 +1535,7 @@ namespace detail
|
|||||||
arg_keyboard arg;
|
arg_keyboard arg;
|
||||||
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.key = static_cast<wchar_t>(wParam);
|
arg.key = translate_virtual_key(wParam);
|
||||||
brock.get_key_state(arg);
|
brock.get_key_state(arg);
|
||||||
arg.ignore = false;
|
arg.ignore = false;
|
||||||
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
brock.emit(event_code::key_release, msgwnd, arg, true, &context);
|
||||||
|
@ -149,23 +149,24 @@ namespace nana
|
|||||||
// reads the overlaps that are overlapped a rectangular block
|
// reads the overlaps that are overlapped a rectangular block
|
||||||
bool window_layout::read_overlaps(core_window_t* wd, const nana::rectangle& vis_rect, std::vector<wd_rectangle>& blocks)
|
bool window_layout::read_overlaps(core_window_t* wd, const nana::rectangle& vis_rect, std::vector<wd_rectangle>& blocks)
|
||||||
{
|
{
|
||||||
|
auto const is_wd_root = (category::flags::root == wd->other.category);
|
||||||
wd_rectangle block;
|
wd_rectangle block;
|
||||||
while (wd->parent)
|
while (wd->parent)
|
||||||
{
|
{
|
||||||
auto & siblings = wd->parent->children;
|
auto i = std::find(wd->parent->children.cbegin(), wd->parent->children.cend(), wd);
|
||||||
//It should be checked that whether the window is still a chlid of its parent.
|
if (i != wd->parent->children.cend())
|
||||||
if (siblings.size())
|
|
||||||
{
|
{
|
||||||
auto i = &(siblings[0]);
|
for (++i; i != wd->parent->children.cend(); ++i)
|
||||||
auto *end = i + siblings.size();
|
|
||||||
i = std::find(i, end, wd);
|
|
||||||
if (i != end)
|
|
||||||
{
|
|
||||||
//find the widget that next to wd.
|
|
||||||
for (++i; i < end; ++i)
|
|
||||||
{
|
{
|
||||||
core_window_t* cover = *i;
|
core_window_t* cover = *i;
|
||||||
if ((category::flags::root != cover->other.category) && cover->visible && (nullptr == cover->effect.bground))
|
|
||||||
|
if (!cover->visible)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (is_wd_root ?
|
||||||
|
(category::flags::root == cover->other.category)
|
||||||
|
:
|
||||||
|
((category::flags::root != cover->other.category) && (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))
|
||||||
{
|
{
|
||||||
@ -175,7 +176,7 @@ namespace nana
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
wd = wd->parent;
|
wd = wd->parent;
|
||||||
}
|
}
|
||||||
return (!blocks.empty());
|
return (!blocks.empty());
|
||||||
|
@ -435,20 +435,20 @@ namespace nana
|
|||||||
nodes_.filesystem = tree_.insert("FS.ROOT", "Filesystem");
|
nodes_.filesystem = tree_.insert("FS.ROOT", "Filesystem");
|
||||||
nodes_.filesystem.value(kind::filesystem);
|
nodes_.filesystem.value(kind::filesystem);
|
||||||
|
|
||||||
std::vector<std::string> paths;
|
std::vector<std::pair<std::string, treebox::item_proxy>> paths;
|
||||||
paths.emplace_back(fs_ext::path_user().native());
|
paths.emplace_back(fs_ext::path_user().native(), nodes_.home);
|
||||||
paths.emplace_back("/");
|
paths.emplace_back("/", nodes_.filesystem);
|
||||||
|
|
||||||
fs::directory_iterator end;
|
fs::directory_iterator end;
|
||||||
for (auto & p : paths)
|
for (auto & p : paths)
|
||||||
{
|
{
|
||||||
for (fs::directory_iterator i(p); i != end; ++i)
|
for (fs::directory_iterator i{p.first}; i != end; ++i)
|
||||||
{
|
{
|
||||||
auto name = i->path().filename().native();
|
auto name = i->path().filename().native();
|
||||||
if (!is_directory(i->status()) || (name.size() && name[0] == '.'))
|
if (!is_directory(i->status()) || (name.size() && name[0] == '.'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
item_proxy node = tree_.insert(nodes_.filesystem, name, name);
|
item_proxy node = tree_.insert(p.second, name, name);
|
||||||
if (false == node.empty())
|
if (false == node.empty())
|
||||||
{
|
{
|
||||||
node.value(kind::filesystem);
|
node.value(kind::filesystem);
|
||||||
@ -569,29 +569,64 @@ namespace nana
|
|||||||
if(cat_path.size() && cat_path[cat_path.size() - 1] != '/')
|
if(cat_path.size() && cat_path[cat_path.size() - 1] != '/')
|
||||||
cat_path += '/';
|
cat_path += '/';
|
||||||
|
|
||||||
|
|
||||||
auto beg = head.size();
|
auto beg = head.size();
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
auto pos = path.find('/', beg);
|
auto pos = path.find('/', beg);
|
||||||
auto folder = path.substr(beg, pos != path.npos ? pos - beg: path.npos);
|
auto folder = path.substr(beg, pos != path.npos ? pos - beg: path.npos);
|
||||||
if(folder.size() == 0) break;
|
|
||||||
|
if(folder.empty())
|
||||||
|
break;
|
||||||
|
|
||||||
(cat_path += folder) += '/';
|
(cat_path += folder) += '/';
|
||||||
(head += folder) += '/';
|
(head += folder) += '/';
|
||||||
path_.caption(cat_path);
|
path_.caption(cat_path);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
for(fs::directory_iterator i(head); i != end; ++i)
|
for(fs::directory_iterator i(head); i != end; ++i)
|
||||||
{
|
{
|
||||||
if (is_directory(*i))
|
if (is_directory(*i))
|
||||||
path_.childset(i->path().filename().native(), 0);
|
path_.childset(i->path().filename().native(), 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(fs::filesystem_error&)
|
||||||
|
{
|
||||||
|
//The directory iterator may throw filesystem_error when
|
||||||
|
//the user doesn't have permission to access the directory.
|
||||||
|
|
||||||
|
//It just loads the sub-directories
|
||||||
|
//to the category path.
|
||||||
|
}
|
||||||
|
|
||||||
if(pos == path.npos)
|
if(pos == path.npos)
|
||||||
break;
|
break;
|
||||||
beg = pos + 1;
|
beg = pos + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
_m_load_path(path);
|
_m_load_path(path);
|
||||||
_m_list_fs();
|
_m_list_fs();
|
||||||
}
|
}
|
||||||
|
catch(fs::filesystem_error&)
|
||||||
|
{
|
||||||
|
file_container_.clear();
|
||||||
|
|
||||||
|
drawing dw{ls_file_};
|
||||||
|
dw.clear();
|
||||||
|
dw.draw([](paint::graphics& graph){
|
||||||
|
std::string text = "Permission denied to access the directory";
|
||||||
|
auto txt_sz = graph.text_extent_size(text);
|
||||||
|
auto sz = graph.size();
|
||||||
|
|
||||||
|
graph.string({static_cast<int>(sz.width - txt_sz.width) / 2, static_cast<int>(sz.height - txt_sz.height) / 2}, text, colors::dark_gray);
|
||||||
|
});
|
||||||
|
|
||||||
|
ls_file_.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool _m_filter_allowed(const std::string& name, bool is_dir, const std::string& filter, const std::vector<std::string>* extension) const
|
bool _m_filter_allowed(const std::string& name, bool is_dir, const std::string& filter, const std::vector<std::string>* extension) const
|
||||||
{
|
{
|
||||||
@ -611,6 +646,8 @@ namespace nana
|
|||||||
|
|
||||||
void _m_list_fs()
|
void _m_list_fs()
|
||||||
{
|
{
|
||||||
|
drawing{ls_file_}.clear();
|
||||||
|
|
||||||
auto filter = filter_.caption();
|
auto filter = filter_.caption();
|
||||||
ls_file_.auto_draw(false);
|
ls_file_.auto_draw(false);
|
||||||
|
|
||||||
@ -828,17 +865,31 @@ namespace nana
|
|||||||
|
|
||||||
auto child = node.append(name, name, kind::filesystem);
|
auto child = node.append(name, name, kind::filesystem);
|
||||||
if(!child.empty())
|
if(!child.empty())
|
||||||
|
{
|
||||||
|
//The try-catch can be eleminated by using
|
||||||
|
//directory_iterator( const std::filesystem::path& p, std::error_code& ec ) noexcept;
|
||||||
|
//in C++17
|
||||||
|
try
|
||||||
{
|
{
|
||||||
for(fs::directory_iterator u(i->path()); u != end; ++u)
|
for(fs::directory_iterator u(i->path()); u != end; ++u)
|
||||||
{
|
{
|
||||||
auto uname = i->path().filename().native();
|
auto uname = u->path().filename().native();
|
||||||
if ((!is_directory(*i)) || (uname.size() && uname[0] == '.'))
|
if ((!is_directory(*u)) || (uname.size() && uname[0] == '.'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
child.append(uname, uname, kind::filesystem);
|
child.append(uname, uname, kind::filesystem);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(fs::filesystem_error&)
|
||||||
|
{
|
||||||
|
//The directory iterator may throw filesystem_error when
|
||||||
|
//the user doesn't have permission to access the directory.
|
||||||
|
|
||||||
|
//Catch the error without any process, because the loop is just
|
||||||
|
//to peak whether the directory(i->path) has a sub-directory.
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ namespace nana
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::size_t find(unsigned long shortkey) const
|
std::size_t find(wchar_t shortkey) const
|
||||||
{
|
{
|
||||||
if (shortkey)
|
if (shortkey)
|
||||||
{
|
{
|
||||||
@ -262,7 +262,7 @@ namespace nana
|
|||||||
return *ess_;
|
return *ess_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void trigger::attached(widget_reference widget, graph_reference graph)
|
void trigger::attached(widget_reference widget, graph_reference)
|
||||||
{
|
{
|
||||||
ess_->widget_ptr = &widget;
|
ess_->widget_ptr = &widget;
|
||||||
}
|
}
|
||||||
@ -403,8 +403,15 @@ namespace nana
|
|||||||
ess_->state.nullify_mouse = true;
|
ess_->state.nullify_mouse = true;
|
||||||
|
|
||||||
auto & menu_ptr = ess_->state.menu;
|
auto & menu_ptr = ess_->state.menu;
|
||||||
|
|
||||||
|
//menu_wd will be assigned with the handle of a menu window,
|
||||||
|
//It is used for checking whether the menu is closed. A menu handler
|
||||||
|
//may close the form, checking with the data member of this trigger
|
||||||
|
//is invalid, because the form is closed, the object of menubar may not exist.
|
||||||
|
window menu_wd = nullptr;
|
||||||
if(ess_->state.menu)
|
if(ess_->state.menu)
|
||||||
{
|
{
|
||||||
|
menu_wd = menu_ptr->handle();
|
||||||
switch(arg.key)
|
switch(arg.key)
|
||||||
{
|
{
|
||||||
case keyboard::os_arrow_down:
|
case keyboard::os_arrow_down:
|
||||||
@ -466,8 +473,11 @@ namespace nana
|
|||||||
case keyboard::os_arrow_up:
|
case keyboard::os_arrow_up:
|
||||||
case keyboard::os_arrow_down:
|
case keyboard::os_arrow_down:
|
||||||
case keyboard::enter:
|
case keyboard::enter:
|
||||||
if(ess_->open_menu(true))
|
if (ess_->open_menu(true))
|
||||||
|
{
|
||||||
|
menu_wd = menu_ptr->handle();
|
||||||
menu_ptr->goto_next(true);
|
menu_ptr->goto_next(true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case keyboard::escape:
|
case keyboard::escape:
|
||||||
if(essence::behavior::focus == ess_->state.behave)
|
if(essence::behavior::focus == ess_->state.behave)
|
||||||
@ -481,16 +491,22 @@ namespace nana
|
|||||||
if(index != npos)
|
if(index != npos)
|
||||||
{
|
{
|
||||||
ess_->state.active = index;
|
ess_->state.active = index;
|
||||||
if(ess_->open_menu(true))
|
if (ess_->open_menu(true))
|
||||||
|
{
|
||||||
|
menu_wd = menu_ptr->handle();
|
||||||
menu_ptr->goto_next(true);
|
menu_ptr->goto_next(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (API::is_window(menu_wd))
|
||||||
|
{
|
||||||
refresh(graph);
|
refresh(graph);
|
||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void trigger::key_release(graph_reference graph, const arg_keyboard& arg)
|
void trigger::key_release(graph_reference graph, const arg_keyboard& arg)
|
||||||
{
|
{
|
||||||
|
@ -136,10 +136,8 @@ namespace nana
|
|||||||
{
|
{
|
||||||
const unsigned border_px = substance::border_px;
|
const unsigned border_px = substance::border_px;
|
||||||
|
|
||||||
unsigned width = graph.width() - border_px * 2;
|
|
||||||
unsigned height = graph.height() - border_px * 2;
|
|
||||||
|
|
||||||
rectangle rt_val{ graph.size() };
|
rectangle rt_val{ graph.size() };
|
||||||
|
auto const width = rt_val.width - border_px * 2;
|
||||||
|
|
||||||
rt_val.pare_off(static_cast<int>(border_px));
|
rt_val.pare_off(static_cast<int>(border_px));
|
||||||
|
|
||||||
|
@ -556,6 +556,7 @@ namespace nana{ namespace widgets
|
|||||||
virtual void merge_lines(std::size_t first, std::size_t second) = 0;
|
virtual void merge_lines(std::size_t first, std::size_t second) = 0;
|
||||||
//Calculates how many lines the specified line of text takes with a specified pixels of width.
|
//Calculates how many lines the specified line of text takes with a specified pixels of width.
|
||||||
virtual void add_lines(std::size_t pos, std::size_t lines) = 0;
|
virtual void add_lines(std::size_t pos, std::size_t lines) = 0;
|
||||||
|
virtual void prepare() = 0;
|
||||||
virtual void pre_calc_line(std::size_t line, unsigned pixels) = 0;
|
virtual void pre_calc_line(std::size_t line, unsigned pixels) = 0;
|
||||||
virtual void pre_calc_lines(unsigned pixels) = 0;
|
virtual void pre_calc_lines(unsigned pixels) = 0;
|
||||||
virtual std::size_t take_lines() const = 0;
|
virtual std::size_t take_lines() const = 0;
|
||||||
@ -668,6 +669,12 @@ namespace nana{ namespace widgets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void prepare() override
|
||||||
|
{
|
||||||
|
auto const line_count = editor_.textbase().lines();
|
||||||
|
this->sections_.resize(line_count);
|
||||||
|
}
|
||||||
|
|
||||||
void pre_calc_line(std::size_t pos, unsigned) override
|
void pre_calc_line(std::size_t pos, unsigned) override
|
||||||
{
|
{
|
||||||
auto const & text = editor_.textbase().getline(pos);
|
auto const & text = editor_.textbase().getline(pos);
|
||||||
@ -781,6 +788,12 @@ namespace nana{ namespace widgets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void prepare() override
|
||||||
|
{
|
||||||
|
auto const lines = editor_.textbase().lines();
|
||||||
|
linemtr_.resize(lines);
|
||||||
|
}
|
||||||
|
|
||||||
void pre_calc_line(std::size_t line, unsigned pixels) override
|
void pre_calc_line(std::size_t line, unsigned pixels) override
|
||||||
{
|
{
|
||||||
const string_type& lnstr = editor_.textbase().getline(line);
|
const string_type& lnstr = editor_.textbase().getline(line);
|
||||||
@ -1220,7 +1233,7 @@ namespace nana{ namespace widgets
|
|||||||
case keyboard::os_pagedown:
|
case keyboard::os_pagedown:
|
||||||
_m_handle_move_key(arg);
|
_m_handle_move_key(arg);
|
||||||
break;
|
break;
|
||||||
case keyboard::os_del:
|
case keyboard::del:
|
||||||
// send delete to set_accept function
|
// send delete to set_accept function
|
||||||
if (this->attr().editable && (!impl_->capacities.pred_acceptive || impl_->capacities.pred_acceptive(key)))
|
if (this->attr().editable && (!impl_->capacities.pred_acceptive || impl_->capacities.pred_acceptive(key)))
|
||||||
del();
|
del();
|
||||||
@ -1234,7 +1247,7 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
void text_editor::typeface_changed()
|
void text_editor::typeface_changed()
|
||||||
{
|
{
|
||||||
impl_->capacities.behavior->pre_calc_lines(width_pixels());
|
_m_reset_content_size(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void text_editor::indent(bool enb, std::function<std::string()> generator)
|
void text_editor::indent(bool enb, std::function<std::string()> generator)
|
||||||
@ -1676,7 +1689,7 @@ namespace nana{ namespace widgets
|
|||||||
impl_->try_refresh = sync_graph::refresh;
|
impl_->try_refresh = sync_graph::refresh;
|
||||||
|
|
||||||
//_m_put calcs the lines
|
//_m_put calcs the lines
|
||||||
_m_reset_content_size(false);
|
_m_reset_content_size(true);
|
||||||
impl_->cview->sync(false);
|
impl_->cview->sync(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2886,10 +2899,14 @@ namespace nana{ namespace widgets
|
|||||||
auto text_lines = textbase().lines();
|
auto text_lines = textbase().lines();
|
||||||
if (text_lines <= max_lines)
|
if (text_lines <= max_lines)
|
||||||
{
|
{
|
||||||
|
impl_->capacities.behavior->prepare();
|
||||||
|
|
||||||
|
auto const width_px = _m_width_px(true);
|
||||||
|
|
||||||
std::size_t lines = 0;
|
std::size_t lines = 0;
|
||||||
for (std::size_t i = 0; i < text_lines; ++i)
|
for (std::size_t i = 0; i < text_lines; ++i)
|
||||||
{
|
{
|
||||||
impl_->capacities.behavior->pre_calc_line(i, csize.width);
|
impl_->capacities.behavior->pre_calc_line(i, width_px);
|
||||||
lines += impl_->capacities.behavior->take_lines(i);
|
lines += impl_->capacities.behavior->take_lines(i);
|
||||||
|
|
||||||
if (lines > max_lines)
|
if (lines > max_lines)
|
||||||
|
@ -561,6 +561,12 @@ namespace nana
|
|||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawer::dbl_click(graph_reference, const arg_mouse& arg)
|
||||||
|
{
|
||||||
|
if (impl_->mouse_button(arg, true))
|
||||||
|
API::dev::lazy_refresh();
|
||||||
|
}
|
||||||
|
|
||||||
void drawer::mouse_down(graph_reference, const arg_mouse& arg)
|
void drawer::mouse_down(graph_reference, const arg_mouse& arg)
|
||||||
{
|
{
|
||||||
if (impl_->mouse_button(arg, true))
|
if (impl_->mouse_button(arg, true))
|
||||||
@ -599,8 +605,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
impl_->editor()->respond_char(arg);
|
impl_->editor()->respond_char(arg);
|
||||||
if (impl_->editor()->try_refresh())
|
if (impl_->editor()->try_refresh())
|
||||||
|
{
|
||||||
|
impl_->draw_spins();
|
||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void drawer::resized(graph_reference, const arg_resized&)
|
void drawer::resized(graph_reference, const arg_resized&)
|
||||||
{
|
{
|
||||||
|
@ -435,7 +435,23 @@ namespace drawerbase {
|
|||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
//a native wstring version textbox::append
|
||||||
|
textbox& textbox::append(const std::wstring& text, bool at_caret)
|
||||||
|
{
|
||||||
|
internal_scope_guard lock;
|
||||||
|
auto editor = get_drawer_trigger().editor();
|
||||||
|
if(editor)
|
||||||
|
{
|
||||||
|
if(at_caret == false)
|
||||||
|
editor->move_caret_end(false);
|
||||||
|
|
||||||
|
editor->put(text);
|
||||||
|
|
||||||
|
editor->try_refresh();
|
||||||
|
API::update_window(this->handle());
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
/// Determine wheter the text is auto-line changed.
|
/// Determine wheter the text is auto-line changed.
|
||||||
bool textbox::line_wrapped() const
|
bool textbox::line_wrapped() const
|
||||||
{
|
{
|
||||||
|
@ -1825,7 +1825,6 @@ namespace nana
|
|||||||
item_locator nl(impl_, xpos, arg.pos.x, arg.pos.y);
|
item_locator nl(impl_, xpos, arg.pos.x, arg.pos.y);
|
||||||
impl_->attr.tree_cont.for_each<item_locator&>(shape.first, nl);
|
impl_->attr.tree_cont.for_each<item_locator&>(shape.first, nl);
|
||||||
|
|
||||||
bool has_redraw = false;
|
|
||||||
|
|
||||||
auto & node_state = impl_->node_state;
|
auto & node_state = impl_->node_state;
|
||||||
node_state.pressed_node = nl.node();
|
node_state.pressed_node = nl.node();
|
||||||
@ -1834,22 +1833,18 @@ namespace nana
|
|||||||
{
|
{
|
||||||
if(impl_->set_expanded(node_state.pressed_node, !node_state.pressed_node->value.second.expanded))
|
if(impl_->set_expanded(node_state.pressed_node, !node_state.pressed_node->value.second.expanded))
|
||||||
impl_->make_adjust(node_state.pressed_node, 0);
|
impl_->make_adjust(node_state.pressed_node, 0);
|
||||||
|
|
||||||
has_redraw = true; //btw, don't select the node
|
|
||||||
}
|
}
|
||||||
|
else if (node_state.selected != node_state.pressed_node)
|
||||||
if ((!has_redraw) && (node_state.selected != node_state.pressed_node))
|
|
||||||
{
|
{
|
||||||
impl_->set_selected(node_state.pressed_node);
|
impl_->set_selected(node_state.pressed_node);
|
||||||
has_redraw = true;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
if(has_redraw)
|
|
||||||
{
|
|
||||||
impl_->draw(true);
|
impl_->draw(true);
|
||||||
API::dev::lazy_refresh();
|
API::dev::lazy_refresh();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void trigger::mouse_up(graph_reference, const arg_mouse& arg)
|
void trigger::mouse_up(graph_reference, const arg_mouse& arg)
|
||||||
{
|
{
|
||||||
|
@ -240,12 +240,16 @@ namespace paint
|
|||||||
graphics::graphics(graphics&& other)
|
graphics::graphics(graphics&& other)
|
||||||
: impl_(std::move(other.impl_))
|
: impl_(std::move(other.impl_))
|
||||||
{
|
{
|
||||||
|
other.impl_.reset(new implementation);
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics& graphics::operator=(graphics&& other)
|
graphics& graphics::operator=(graphics&& other)
|
||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
|
{
|
||||||
impl_ = std::move(other.impl_);
|
impl_ = std::move(other.impl_);
|
||||||
|
other.impl_.reset(new implementation);
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user