diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f0dc030..7f89337e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,6 +66,7 @@ endif()
if(WIN32)
add_definitions(-DWIN32)
+ set(CMAKE_DEBUG_POSTFIX "_d")
#Global MSVC definitions. You may prefer the hand-tuned sln and projects from the nana repository.
if(MSVC)
option(MSVC_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON)
@@ -100,7 +101,7 @@ endif(WIN32)
if(APPLE)
add_definitions(-DAPPLE)
include_directories(/opt/X11/include/)
- set(NANA_LINKS "${NANA_LINKS} -L/opt/X11/lib/ -liconv")
+ list(APPEND NANA_LINKS -L/opt/X11/lib/ -liconv)
set(ENABLE_AUDIO OFF)
elseif(UNIX)
add_definitions(-Dlinux)
@@ -108,11 +109,11 @@ elseif(UNIX)
endif(APPLE)
if(UNIX)
- set(NANA_LINKS "${NANA_LINKS} -lX11")
+ list(APPEND NANA_LINKS -lX11)
find_package(Freetype)
if (FREETYPE_FOUND)
include_directories( ${FREETYPE_INCLUDE_DIRS})
- set(NANA_LINKS "${NANA_LINKS} -lXft")
+ list(APPEND NANA_LINKS -lXft)
endif(FREETYPE_FOUND)
endif(UNIX)
@@ -140,13 +141,13 @@ endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# enable static linkage # GNU || CLang not MinGW
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW
# set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -pthread")
- set(NANA_LINKS "${NANA_LINKS} -static-libgcc -static-libstdc++ -pthread")
+ list(APPEND NANA_LINKS -static-libgcc -static-libstdc++ -pthread)
# message("Setting NANA_LINKS to -static-libgcc -static-libstdc++ -pthread or ${NANA_LINKS}")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
# IS_GNUCXX < 5.3
else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++fs") # IS_GNUCXX 5.3 or more
- set(NANA_LINKS "${NANA_LINKS} -lstdc++fs")
+ list(APPEND NANA_LINKS -lstdc++fs)
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW
@@ -154,7 +155,7 @@ endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") #
if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # APPLE Clang
# set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libstdc++")
- set(NANA_LINKS "${NANA_LINKS} -stdlib=libstdc++")
+ list(APPEND NANA_LINKS -stdlib=libstdc++)
endif ()
@@ -163,11 +164,11 @@ endif ()
# Find PNG
if(NANA_CMAKE_ENABLE_PNG)
add_definitions(-DNANA_ENABLE_PNG)
- set(NANA_LINKS "${NANA_LINKS} -lpng")
if(NANA_CMAKE_LIBPNG_FROM_OS)
find_package(PNG)
if (PNG_FOUND)
include_directories( ${PNG_INCLUDE_DIRS})
+ list(APPEND NANA_LINKS ${PNG_LIBRARIES})
add_definitions(-DUSE_LIBPNG_FROM_OS)
endif(PNG_FOUND)
endif(NANA_CMAKE_LIBPNG_FROM_OS)
@@ -176,11 +177,11 @@ endif(NANA_CMAKE_ENABLE_PNG)
# Find JPEG
if(NANA_CMAKE_ENABLE_JPEG)
add_definitions(-DNANA_ENABLE_JPEG)
- set(NANA_LINKS "${NANA_LINKS} -ljpeg")
if(NANA_CMAKE_LIBJPEG_FROM_OS)
find_package(JPEG)
if (JPEG_FOUND)
- include_directories( ${JPEG_INCLUDE_DIRS})
+ include_directories( ${JPEG_INCLUDE_DIR})
+ list(APPEND NANA_LINKS ${JPEG_LIBRARY})
add_definitions(-DUSE_LIBJPEG_FROM_OS)
endif(JPEG_FOUND)
endif(NANA_CMAKE_LIBJPEG_FROM_OS)
@@ -193,7 +194,7 @@ if(NANA_CMAKE_ENABLE_AUDIO)
find_package(ASOUND)
if (ASOUND_FOUND)
include_directories( ${ASOUND_INCLUDE_DIRS})
- set(NANA_LINKS "${NANA_LINKS} -lasound")
+ list(APPEND NANA_LINKS -lasound)
else(ASOUND_FOUND)
message(FATAL_ERROR "libasound is not found")
endif(ASOUND_FOUND)
@@ -217,7 +218,7 @@ elseif (NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
if (Boost_FOUND)
add_definitions(-DNANA_BOOST_FILESYSTEM_AVAILABLE)
include_directories(SYSTEM "${Boost_INCLUDE_DIR}")
- set(NANA_LINKS "${NANA_LINKS} ${Boost_LIBRARIES}") ###### FIRST !!!!!!!!!!!!!!!!! add is not first
+ list(APPEND NANA_LINKS ${Boost_LIBRARIES}) ###### FIRST !!!!!!!!!!!!!!!!! add is not first
endif (Boost_FOUND)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON) # ??
diff --git a/build/makefile/makefile b/build/makefile/makefile
index 9f0fb052..0cdc8d1d 100644
--- a/build/makefile/makefile
+++ b/build/makefile/makefile
@@ -8,7 +8,6 @@ SRCROOT = ../../source
EXTRLIB = ../../extrlib
NANA_INC= $(INCROOT)/nana
OUTROOT = out
-#CXXFLAGS= -g -std=c++11 -Wall
CXXFLAGS= -g -fexceptions -std=c++11 -Wall -Wextra -Wunused-variable -Wfatal-errors
INCS = -I$(INCROOT) -I/usr/include/freetype2 -I$(EXTRLIB)
diff --git a/build/vc2017/nana.vcxproj b/build/vc2017/nana.vcxproj
index 6ee38270..b1e450b8 100644
--- a/build/vc2017/nana.vcxproj
+++ b/build/vc2017/nana.vcxproj
@@ -23,7 +23,7 @@
{42D0520F-EFA5-4831-84FE-2B9085301C5D}
Win32Proj
nana
- 10.0.14393.0
+ 10.0.15063.0
@@ -82,6 +82,18 @@
..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\
$(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName)
+
+ ../bin/
+ ..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\
+ $(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName)
+ ..\..\include;$(IncludePath)
+
+
+ ../bin/
+ ..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\
+ $(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName)
+ ..\..\include;$(IncludePath)
+
diff --git a/include/nana/c++defines.hpp b/include/nana/c++defines.hpp
index 551b45bb..a9381f23 100644
--- a/include/nana/c++defines.hpp
+++ b/include/nana/c++defines.hpp
@@ -62,7 +62,7 @@
# else
# undef STD_FILESYSTEM_NOT_SUPPORTED
# endif
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && not defined(__clang__)
# if (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
# define noexcept //no support of noexcept until GCC 4.6
# endif
diff --git a/include/nana/gui/detail/basic_window.hpp b/include/nana/gui/detail/basic_window.hpp
index 2230a422..c686f889 100644
--- a/include/nana/gui/detail/basic_window.hpp
+++ b/include/nana/gui/detail/basic_window.hpp
@@ -52,7 +52,7 @@ namespace detail
void position(const point& pos) override;
nana::point position() const override;
size dimension() const override;
- void dimension(const size& s);
+ void dimension(const size& s) override;
void visible(bool visibility) override;
bool visible() const override;
private:
diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp
index 410e5118..6215d276 100644
--- a/include/nana/gui/widgets/listbox.hpp
+++ b/include/nana/gui/widgets/listbox.hpp
@@ -186,7 +186,7 @@ namespace nana
public:
virtual ~container_interface() = default;
- virtual void clear() noexcept = 0;
+ virtual void clear() = 0;
virtual void erase(std::size_t pos) = 0;
virtual std::size_t size() const = 0;
@@ -238,7 +238,7 @@ namespace nana
translator_({ vtrans, ctrans })
{}
private:
- void clear() noexcept override
+ void clear() override
{
container_.clear();
}
@@ -246,7 +246,7 @@ namespace nana
void erase(std::size_t pos) override
{
auto i = container_.begin();
- std::advance(i, static_cast(pos));
+ std::advance(i, pos);
container_.erase(i);
}
@@ -263,7 +263,7 @@ namespace nana
void emplace(std::size_t pos) override
{
auto i = container_.begin();
- std::advance(i, static_cast(pos));
+ std::advance(i, pos);
container_.emplace(i);
}
@@ -327,7 +327,7 @@ namespace nana
}
private:
- void clear() noexcept override
+ void clear() override
{
container_.clear();
}
@@ -335,7 +335,7 @@ namespace nana
void erase(std::size_t pos) override
{
auto i = container_.begin();
- std::advance(i, static_cast(pos));
+ std::advance(i, pos);
container_.erase(i);
}
@@ -352,7 +352,7 @@ namespace nana
void emplace(std::size_t pos) override
{
auto i = container_.begin();
- std::advance(i, static_cast(pos));
+ std::advance(i, pos);
container_.emplace(i);
}
@@ -419,7 +419,7 @@ namespace nana
throw std::runtime_error("nana::listbox disallow to remove items because of immutable model");
}
- void erase(std::size_t pos) override
+ void erase(std::size_t /*pos*/) override
{
throw std::runtime_error("nana::listbox disallow to remove items because of immutable model");
}
@@ -434,7 +434,7 @@ namespace nana
return true;
}
- void emplace(std::size_t pos) override
+ void emplace(std::size_t /*pos*/) override
{
throw std::runtime_error("nana::listbox disallow to remove items because of immutable model");
}
@@ -444,7 +444,7 @@ namespace nana
throw std::runtime_error("nana::listbox disallow to remove items because of immutable model");
}
- void assign(std::size_t pos, const std::vector& cells) override
+ void assign(std::size_t /*pos*/, const std::vector| & /*cells*/) override
{
throw std::runtime_error("nana::listbox disallow to remove items because of immutable model");
}
@@ -454,7 +454,7 @@ namespace nana
return ctrans_(container_.at(pos));
}
- bool push_back(const const_virtual_pointer& dptr) override
+ bool push_back(const const_virtual_pointer& /*dptr*/) override
{
throw std::runtime_error("nana::listbox disallow to remove items because of immutable model");
}
@@ -893,7 +893,7 @@ namespace nana
}
template
- T* value_ptr() const
+ T const * value_ptr() const
{
return any_cast(_m_value());
}
@@ -1395,6 +1395,11 @@ the nana::detail::basic_window member pointer scheme
size_type append_header(std::string text_utf8, unsigned width = 120);
size_type append_header(std::wstring text, unsigned width = 120);
+ cat_proxy append(std::string category); ///< Appends a new category to the end
+ cat_proxy append(std::wstring category); ///< Appends a new category to the end
+ void append(std::initializer_list categories); ///< Appends categories to the end
+ void append(std::initializer_list categories); ///< Appends categories to the end
+
/// Access a column at specified position
/**
* @param pos Position of column
@@ -1416,10 +1421,8 @@ the nana::detail::basic_window member pointer scheme
/// Returns the number of columns
size_type column_size() const;
- cat_proxy append(std::string category); ///< Appends a new category to the end
- cat_proxy append(std::wstring category); ///< Appends a new category to the end
- void append(std::initializer_list categories); ///< Appends categories to the end
- void append(std::initializer_list categories); ///< Appends categories to the end
+ /// Returns a rectangle in where the content is drawn.
+ rectangle content_area() const;
cat_proxy insert(cat_proxy, ::std::string);
cat_proxy insert(cat_proxy, ::std::wstring);
diff --git a/include/nana/gui/widgets/menubar.hpp b/include/nana/gui/widgets/menubar.hpp
index b636a125..a76b21bb 100644
--- a/include/nana/gui/widgets/menubar.hpp
+++ b/include/nana/gui/widgets/menubar.hpp
@@ -50,7 +50,6 @@ namespace nana
virtual void caption(const point&, const native_string_type&);
scheme *scheme_ptr() const { return scheme_ptr_; };
private:
- window handle_;
graph_reference graph_;
scheme *scheme_ptr_;
};
diff --git a/include/nana/gui/widgets/skeletons/text_editor.hpp b/include/nana/gui/widgets/skeletons/text_editor.hpp
index 896027c0..cf8ee302 100644
--- a/include/nana/gui/widgets/skeletons/text_editor.hpp
+++ b/include/nana/gui/widgets/skeletons/text_editor.hpp
@@ -85,6 +85,8 @@ namespace nana{ namespace widgets
text_editor(window, graph_reference, const text_editor_scheme*);
~text_editor();
+ size caret_size() const;
+
void set_highlight(const ::std::string& name, const ::nana::color&, const ::nana::color&);
void erase_highlight(const ::std::string& name);
void set_keyword(const ::std::wstring& kw, const std::string& name, bool case_sensitive, bool whole_word_matched);
@@ -181,6 +183,8 @@ namespace nana{ namespace widgets
void focus_behavior(text_focus_behavior);
void select_behavior(bool move_to_end);
+
+ std::size_t line_count(bool text_lines) const;
public:
void draw_corner();
void render(bool focused);
@@ -217,8 +221,10 @@ namespace nana{ namespace widgets
std::vector _m_render_text(const ::nana::color& text_color);
void _m_pre_calc_lines(std::size_t line_off, std::size_t lines);
- ::nana::point _m_caret_to_screen(::nana::upoint pos) const;
- ::nana::upoint _m_screen_to_caret(::nana::point pos) const;
+ //Caret to screen coordinate or context coordiate(in pixels)
+ ::nana::point _m_caret_to_coordinate(::nana::upoint pos, bool to_screen_coordinate = true) const;
+ //Screen coordinate or context coordinate(in pixels) to caret,
+ ::nana::upoint _m_coordinate_to_caret(::nana::point pos, bool from_screen_coordinate = true) const;
bool _m_pos_from_secondary(std::size_t textline, const nana::upoint& secondary, unsigned & pos);
bool _m_pos_secondary(const nana::upoint& charpos, nana::upoint& secondary_pos) const;
@@ -240,11 +246,11 @@ namespace nana{ namespace widgets
static bool _m_resolve_text(const ::std::wstring&, std::vector> & lines);
bool _m_cancel_select(int align);
- unsigned _m_tabs_pixels(size_type tabs) const;
nana::size _m_text_extent_size(const char_type*, size_type n) const;
- /// Moves the view of window.
- bool _m_move_offset_x_while_over_border(int many);
+ /// Adjust position of view to make caret stay in screen
+ bool _m_adjust_view();
+
bool _m_move_select(bool record_undo);
int _m_text_top_base() const;
@@ -316,7 +322,6 @@ namespace nana{ namespace widgets
{
nana::upoint caret; //position of caret by text, it specifies the position of a new character
nana::upoint shift_begin_caret;
- unsigned xpos{0}; //This data is used for move up/down
}points_;
};
}//end namespace skeletons
diff --git a/include/nana/gui/widgets/skeletons/textbase.hpp b/include/nana/gui/widgets/skeletons/textbase.hpp
index 55828351..751d9888 100644
--- a/include/nana/gui/widgets/skeletons/textbase.hpp
+++ b/include/nana/gui/widgets/skeletons/textbase.hpp
@@ -1,7 +1,7 @@
/*
* A textbase class implementation
* Nana C++ Library(http://www.nanapro.org)
- * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
+ * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -44,7 +44,7 @@ namespace skeletons
{
attr_max_.reset();
//Insert an empty string for the first line of empty text.
- text_cont_.emplace_back();
+ text_cont_.emplace_back(new string_type);
}
void set_event_agent(textbase_event_agent_interface * evt)
@@ -55,7 +55,7 @@ namespace skeletons
bool empty() const
{
return (text_cont_.empty() ||
- ((text_cont_.size() == 1) && (text_cont_[0].empty())));
+ ((text_cont_.size() == 1) && (text_cont_.front()->empty())));
}
bool load(const char* file_utf8)
@@ -135,10 +135,10 @@ namespace skeletons
while(ifs.good())
{
std::getline(ifs, str_mbs);
- text_cont_.emplace_back(static_cast(nana::charset{ str_mbs }));
- if(text_cont_.back().size() > attr_max_.size)
+ text_cont_.emplace_back(new string_type(static_cast(nana::charset{ str_mbs })));
+ if(text_cont_.back()->size() > attr_max_.size)
{
- attr_max_.size = text_cont_.back().size();
+ attr_max_.size = text_cont_.back()->size();
attr_max_.line = text_cont_.size() - 1;
}
}
@@ -218,9 +218,9 @@ namespace skeletons
byte_order_translate_4bytes(str);
}
- text_cont_.emplace_back(static_cast(nana::charset{ str, encoding }));
+ text_cont_.emplace_back(new string_type(static_cast(nana::charset{ str, encoding })));
- attr_max_.size = text_cont_.back().size();
+ attr_max_.size = text_cont_.back()->size();
attr_max_.line = 0;
}
@@ -236,10 +236,10 @@ namespace skeletons
byte_order_translate_4bytes(str);
}
- text_cont_.emplace_back(static_cast(nana::charset{ str, encoding }));
- if(text_cont_.back().size() > attr_max_.size)
+ text_cont_.emplace_back(new string_type(static_cast(nana::charset{ str, encoding })));
+ if(text_cont_.back()->size() > attr_max_.size)
{
- attr_max_.size = text_cont_.back().size();
+ attr_max_.size = text_cont_.back()->size();
attr_max_.line = text_cont_.size() - 1;
}
}
@@ -253,6 +253,9 @@ namespace skeletons
std::ofstream ofs(to_osmbstr(fs), std::ios::binary);
if(ofs && text_cont_.size())
{
+ auto i = text_cont_.cbegin();
+ auto const count = text_cont_.size() - 1;
+
std::string last_mbs;
if (is_unicode)
@@ -272,32 +275,27 @@ namespace skeletons
if (bytes)
ofs.write(le_boms[static_cast(encoding)], bytes);
- if (text_cont_.size() > 1)
+ for (std::size_t pos = 0; pos < count; ++pos)
{
- std::string mbs;
- for (auto i = text_cont_.cbegin(), end = text_cont_.cend() - 1; i != end; ++i)
- {
- std::string(nana::charset(*i).to_bytes(encoding)).swap(mbs);
- mbs += "\r\n";
- ofs.write(mbs.c_str(), static_cast(mbs.size()));
- }
+ auto mbs = nana::charset(**(i++)).to_bytes(encoding);
+ ofs.write(mbs.c_str(), static_cast(mbs.size()));
+ ofs.write("\r\n", 2);
}
- last_mbs = nana::charset(text_cont_.back()).to_bytes(encoding);
+ last_mbs = nana::charset(*text_cont_.back()).to_bytes(encoding);
}
else
{
- if (text_cont_.size() > 1)
+ for (std::size_t pos = 0; pos < count; ++pos)
{
- for (auto i = text_cont_.cbegin(), end = text_cont_.cend() - 1; i != end; ++i)
- {
- std::string mbs = nana::charset(*i);
- ofs.write(mbs.c_str(), mbs.size());
- ofs.write("\r\n", 2);
- }
+ std::string mbs = nana::charset(**(i++));
+ ofs.write(mbs.c_str(), mbs.size());
+ ofs.write("\r\n", 2);
}
- last_mbs = nana::charset(text_cont_.back());
+
+ last_mbs = nana::charset(*text_cont_.back());
}
+
ofs.write(last_mbs.c_str(), static_cast(last_mbs.size()));
_m_saved(std::move(fs));
}
@@ -310,8 +308,8 @@ namespace skeletons
const string_type& getline(size_type pos) const
{
- if(pos < text_cont_.size())
- return text_cont_[pos];
+ if (pos < text_cont_.size())
+ return *text_cont_[pos];
return nullstr_;
}
@@ -323,13 +321,13 @@ namespace skeletons
public:
void replace(size_type pos, string_type && text)
{
- if(text_cont_.size() <= pos)
+ if (text_cont_.size() <= pos)
{
- text_cont_.emplace_back(std::move(text));
+ text_cont_.emplace_back(new string_type(std::move(text)));
pos = text_cont_.size() - 1;
}
else
- text_cont_[pos].swap(text);
+ _m_at(pos).swap(text);
_m_make_max(pos);
_m_edited();
@@ -339,7 +337,7 @@ namespace skeletons
{
if(pos.y < text_cont_.size())
{
- string_type& lnstr = text_cont_[pos.y];
+ string_type& lnstr = _m_at(pos.y);
if(pos.x < lnstr.size())
lnstr.insert(pos.x, str);
@@ -348,7 +346,7 @@ namespace skeletons
}
else
{
- text_cont_.emplace_back(std::move(str));
+ text_cont_.emplace_back(new string_type(std::move(str)));
pos.y = static_cast(text_cont_.size() - 1);
}
@@ -358,10 +356,10 @@ namespace skeletons
void insertln(size_type pos, string_type&& str)
{
- if(pos < text_cont_.size())
- text_cont_.emplace(text_cont_.begin() + pos, std::move(str));
+ if (pos < text_cont_.size())
+ text_cont_.emplace(_m_iat(pos), new string_type(std::move(str)));
else
- text_cont_.emplace_back(std::move(str));
+ text_cont_.emplace_back(new string_type(std::move(str)));
_m_make_max(pos);
_m_edited();
@@ -371,7 +369,7 @@ namespace skeletons
{
if (line < text_cont_.size())
{
- string_type& lnstr = text_cont_[line];
+ string_type& lnstr = _m_at(line);
if ((pos == 0) && (count >= lnstr.size()))
lnstr.clear();
else
@@ -393,7 +391,7 @@ namespace skeletons
if (pos + n > text_cont_.size())
n = text_cont_.size() - pos;
- text_cont_.erase(text_cont_.begin() + pos, text_cont_.begin() + (pos + n));
+ text_cont_.erase(_m_iat(pos), _m_iat(pos + n));
if (pos <= attr_max_.line && attr_max_.line < pos + n)
_m_scan_for_max();
@@ -408,7 +406,7 @@ namespace skeletons
{
text_cont_.clear();
attr_max_.reset();
- text_cont_.emplace_back(); //text_cont_ must not be empty
+ text_cont_.emplace_back(new string_type); //text_cont_ must not be empty
_m_saved(std::string());
}
@@ -417,9 +415,14 @@ namespace skeletons
{
if(pos + 1 < text_cont_.size())
{
- text_cont_[pos] += text_cont_[pos + 1];
- text_cont_.erase(text_cont_.begin() + (pos + 1));
+ auto i = _m_iat(pos + 1);
+ _m_at(pos) += **i;
+ text_cont_.erase(i);
_m_make_max(pos);
+
+ //If the maxline is behind the pos line,
+ //decrease the maxline. Because a line between maxline and pos line
+ //has been deleted.
if(pos < attr_max_.line)
--attr_max_.line;
@@ -458,9 +461,19 @@ namespace skeletons
return edited() || filename_.empty();
}
private:
+ string_type& _m_at(size_type pos)
+ {
+ return **_m_iat(pos);
+ }
+
+ typename std::deque>::iterator _m_iat(size_type pos)
+ {
+ return text_cont_.begin() + pos;
+ }
+
void _m_make_max(std::size_t pos)
{
- const string_type& str = text_cont_[pos];
+ const string_type& str = _m_at(pos);
if(str.size() > attr_max_.size)
{
attr_max_.size = str.size();
@@ -472,11 +485,11 @@ namespace skeletons
{
attr_max_.size = 0;
std::size_t n = 0;
- for(auto & s : text_cont_)
+ for(auto & p : text_cont_)
{
- if(s.size() > attr_max_.size)
+ if(p->size() > attr_max_.size)
{
- attr_max_.size = s.size();
+ attr_max_.size = p->size();
attr_max_.line = n;
}
++n;
@@ -514,7 +527,7 @@ namespace skeletons
evt_agent_->text_changed();
}
private:
- std::deque text_cont_;
+ std::deque> text_cont_;
textbase_event_agent_interface* evt_agent_{ nullptr };
mutable bool changed_{ false };
diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp
index f22e6e5c..0e2e2e9c 100644
--- a/include/nana/gui/widgets/tabbar.hpp
+++ b/include/nana/gui/widgets/tabbar.hpp
@@ -237,9 +237,9 @@ namespace nana
return this->get_drawer_trigger().activated();
}
- value_type & at(std::size_t pos) const /// Returns pos'th element
+ value_type const & at(std::size_t pos) const /// Returns pos'th element
{
- return static_cast(this->get_drawer_trigger().at(pos));
+ return any_cast(this->get_drawer_trigger().at(pos));
}
void close_fly(bool fly) /// Draw or not a close button in each tab.
diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp
index e37ed6fc..591b4e7e 100644
--- a/include/nana/gui/widgets/textbox.hpp
+++ b/include/nana/gui/widgets/textbox.hpp
@@ -257,6 +257,17 @@ namespace nana
* @param len The length of the queue. If this parameter is zero, the undo/redo is disabled.
*/
void set_undo_queue_length(std::size_t len);
+
+ /// Returns the number of lines that text are displayed in the screen.
+ /**
+ * The number of display lines may be not equal to the number of text lines when the textbox
+ * is line wrapped mode.
+ * @return the number of lines that text are displayed in the screen.
+ */
+ std::size_t display_line_count() const noexcept;
+
+ /// Returns the number of text lines.
+ std::size_t text_line_count() const noexcept;
protected:
//Overrides widget's virtual functions
native_string_type _m_caption() const throw() override;
diff --git a/include/nana/unicode_bidi.hpp b/include/nana/unicode_bidi.hpp
index 71a5f882..72d65860 100644
--- a/include/nana/unicode_bidi.hpp
+++ b/include/nana/unicode_bidi.hpp
@@ -49,7 +49,7 @@ namespace nana
unsigned level;
};
- void linestr(const char_type*, std::size_t len, std::vector & reordered);
+ std::vector reorder(const char_type*, std::size_t len);
private:
static unsigned _m_paragraph_level(const char_type * begin, const char_type * end);
@@ -65,13 +65,12 @@ namespace nana
void _m_reordering_resolved_levels(std::vector & reordered);
static bidi_category _m_bidi_category(bidi_char);
static bidi_char _m_char_dir(char_type);
- private:
- void _m_output_levels() const;
- void _m_output_bidi_char() const;
private:
std::vector levels_;
};
+ std::vector unicode_reorder(const wchar_t* text, std::size_t length);
+
}
#include
diff --git a/source/audio/detail/buffer_preparation.cpp b/source/audio/detail/buffer_preparation.cpp
index acd0aaa3..82942846 100644
--- a/source/audio/detail/buffer_preparation.cpp
+++ b/source/audio/detail/buffer_preparation.cpp
@@ -33,7 +33,7 @@ namespace nana{ namespace audio
prepared_.emplace_back(m);
}
- thr_ = std::move(std::thread([this](){this->_m_prepare_routine();}));
+ thr_ = std::thread{[this](){this->_m_prepare_routine();}};
}
buffer_preparation::~buffer_preparation()
diff --git a/source/charset.cpp b/source/charset.cpp
index 5c802b15..454b5ea3 100644
--- a/source/charset.cpp
+++ b/source/charset.cpp
@@ -484,7 +484,7 @@ namespace nana
virtual std::string&& str_move()
{
if(is_unicode_)
- data_ = std::move(str());
+ data_ = str();
return std::move(data_);
}
@@ -506,6 +506,8 @@ namespace nana
std::u32string u32str = std::wstring_convert, char32_t>().from_bytes(data_);
return std::string(reinterpret_cast(u32str.c_str()), u32str.size() * sizeof(char32_t));
}
+ default:
+ break; //no conversion
}
break;
case unicode::utf16:
@@ -520,6 +522,8 @@ namespace nana
std::u32string u32str = std::wstring_convert, char32_t>().from_bytes(data_);
return std::string(reinterpret_cast(u32str.c_str()), u32str.size() * sizeof(char32_t));
}
+ default:
+ break; //no conversion
}
break;
case unicode::utf32:
@@ -533,6 +537,8 @@ namespace nana
return std::wstring_convert, char32_t>().to_bytes(
std::u32string(reinterpret_cast(data_.c_str()), data_.size() / sizeof(char32_t))
);
+ default:
+ break; //no conversion
}
break;
}
@@ -588,7 +594,7 @@ namespace nana
virtual std::wstring && wstr_move()
{
- wdata_for_move_ = std::move(wstr());
+ wdata_for_move_ = wstr();
return std::move(wdata_for_move_);
}
private:
diff --git a/source/detail/mswin/platform_spec.hpp b/source/detail/mswin/platform_spec.hpp
index 6de8c4e2..ed4b0d9a 100644
--- a/source/detail/mswin/platform_spec.hpp
+++ b/source/detail/mswin/platform_spec.hpp
@@ -1,7 +1,7 @@
/*
* Platform Specification Implementation
* Nana C++ Library(http://www.nanapro.org)
- * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
+ * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -144,7 +144,6 @@ namespace detail
drawable_impl_type();
~drawable_impl_type();
- void fgcolor(const ::nana::color&); //deprecated
unsigned get_color() const;
unsigned get_text_color() const;
void set_color(const ::nana::color&);
diff --git a/source/detail/platform_spec_posix.cpp b/source/detail/platform_spec_posix.cpp
index 89ea7b8c..e495cf7d 100644
--- a/source/detail/platform_spec_posix.cpp
+++ b/source/detail/platform_spec_posix.cpp
@@ -21,7 +21,7 @@
#include
#include
-#include
+#include
#include | |