Merge branch 'develop'

This commit is contained in:
Jinhao 2017-06-22 00:14:49 +08:00
commit 1ed7702790
38 changed files with 929 additions and 976 deletions

View File

@ -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) # ??

View File

@ -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)

View File

@ -23,7 +23,7 @@
<ProjectGuid>{42D0520F-EFA5-4831-84FE-2B9085301C5D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>nana</RootNamespace>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -82,6 +82,18 @@
<IntDir>..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>../bin/</OutDir>
<IntDir>..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName)</TargetName>
<IncludePath>..\..\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>../bin/</OutDir>
<IntDir>..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName)</TargetName>
<IncludePath>..\..\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>

View File

@ -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

View File

@ -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:

View File

@ -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<int>(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<int>(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<int>(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<int>(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<cell>& cells) override
void assign(std::size_t /*pos*/, const std::vector<cell>& /*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<typename T>
T* value_ptr() const
T const * value_ptr() const
{
return any_cast<T>(_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<std::string> categories); ///< Appends categories to the end
void append(std::initializer_list<std::wstring> 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<std::string> categories); ///< Appends categories to the end
void append(std::initializer_list<std::wstring> 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);

View File

@ -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_;
};

View File

@ -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<upoint> _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<std::pair<std::size_t, std::size_t>> & 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

View File

@ -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<string_type&&>(nana::charset{ str_mbs }));
if(text_cont_.back().size() > attr_max_.size)
text_cont_.emplace_back(new string_type(static_cast<string_type&&>(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<string_type&&>(nana::charset{ str, encoding }));
text_cont_.emplace_back(new string_type(static_cast<string_type&&>(nana::charset{ str, encoding })));
attr_max_.size = text_cont_.back().size();
attr_max_.size = text_cont_.back()->size();
attr_max_.line = 0;
}
@ -236,10 +236,10 @@ namespace skeletons
byte_order_translate_4bytes(str);
}
text_cont_.emplace_back(static_cast<string_type&&>(nana::charset{ str, encoding }));
if(text_cont_.back().size() > attr_max_.size)
text_cont_.emplace_back(new string_type(static_cast<string_type&&>(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<int>(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<std::streamsize>(mbs.size()));
}
auto mbs = nana::charset(**(i++)).to_bytes(encoding);
ofs.write(mbs.c_str(), static_cast<std::streamsize>(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<std::streamsize>(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<unsigned>(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<std::unique_ptr<string_type>>::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<string_type> text_cont_;
std::deque<std::unique_ptr<string_type>> text_cont_;
textbase_event_agent_interface* evt_agent_{ nullptr };
mutable bool changed_{ false };

View File

@ -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<value_type&>(this->get_drawer_trigger().at(pos));
return any_cast<value_type&>(this->get_drawer_trigger().at(pos));
}
void close_fly(bool fly) /// Draw or not a close button in each tab.

View File

@ -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;

View File

@ -49,7 +49,7 @@ namespace nana
unsigned level;
};
void linestr(const char_type*, std::size_t len, std::vector<entity> & reordered);
std::vector<entity> 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<entity> & 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<entity> levels_;
};
std::vector<unicode_bidi::entity> unicode_reorder(const wchar_t* text, std::size_t length);
}
#include <nana/pop_ignore_diagnostic>

View File

@ -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()

View File

@ -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<std::codecvt_utf8<char32_t>, char32_t>().from_bytes(data_);
return std::string(reinterpret_cast<const char*>(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<std::codecvt_utf16<char32_t>, char32_t>().from_bytes(data_);
return std::string(reinterpret_cast<const char*>(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<std::codecvt_utf16<char32_t>, char32_t>().to_bytes(
std::u32string(reinterpret_cast<const char32_t*>(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:

View File

@ -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&);

View File

@ -21,7 +21,7 @@
#include <nana/push_ignore_diagnostic>
#include <X11/Xlocale.h>
#include <locale>
#include <clocale>
#include <map>
#include <set>
#include <algorithm>
@ -423,35 +423,6 @@ namespace detail
}
}
void drawable_impl_type::fgcolor(const ::nana::color& clr)
{
auto rgb = clr.px_color().value;
if (rgb != current_color_)
{
auto & spec = nana::detail::platform_spec::instance();
platform_scope_guard psg;
current_color_ = rgb;
switch(spec.screen_depth())
{
case 16:
rgb = ((((rgb >> 16) & 0xFF) * 31 / 255) << 11) |
((((rgb >> 8) & 0xFF) * 63 / 255) << 5) |
(rgb & 0xFF) * 31 / 255;
break;
}
::XSetForeground(spec.open_display(), context, rgb);
::XSetBackground(spec.open_display(), context, rgb);
#if defined(NANA_USE_XFT)
xft_fgcolor.color.red = ((0xFF0000 & rgb) >> 16) * 0x101;
xft_fgcolor.color.green = ((0xFF00 & rgb) >> 8) * 0x101;
xft_fgcolor.color.blue = (0xFF & rgb) * 0x101;
xft_fgcolor.color.alpha = 0xFFFF;
#endif
}
}
platform_scope_guard::platform_scope_guard()
{
platform_spec::instance().lock_xlib();

View File

@ -221,11 +221,6 @@ namespace detail
::DeleteObject(round_region.handle);
}
void drawable_impl_type::fgcolor(const ::nana::color& clr)
{
set_text_color(clr);
}
unsigned drawable_impl_type::get_color() const
{
return color_;

View File

@ -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
@ -101,7 +101,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&);

View File

@ -454,7 +454,7 @@ namespace nana
thr->performance_parameter = 0.0;
thr->fps = p->fps;
thr->interval = 1000.0 / double(p->fps);
thr->thread = std::make_shared<std::thread>([this, thr]()
thr->thread = std::make_shared<std::thread>([thr]()
{
nana::system::timepiece tmpiece;
while (true)

View File

@ -131,7 +131,7 @@ namespace nana
if (((0 == thread_id) || (wd->thread_id == thread_id)) && (wd->root != root))
{
root = wd->root;
if (roots.cend() == std::find(roots.cbegin(), roots.cend(), root))
if (roots.end() == std::find(roots.begin(), roots.end(), root))
roots.emplace_back(root);
}
}

View File

@ -1397,14 +1397,14 @@ namespace detail
{
auto & tabs = wd->root_widget->other.attribute.root->tabstop;
auto end = tabs.cend();
auto end = tabs.end();
if (forward)
{
if (detail::tab_type::none == wd->flags.tab)
return (tabs.front());
else if (detail::tab_type::tabstop & wd->flags.tab)
{
auto i = std::find(tabs.cbegin(), end, wd);
auto i = std::find(tabs.begin(), end, wd);
if (i != end)
{
++i;
@ -1417,9 +1417,9 @@ namespace detail
}
else if (tabs.size() > 1) //at least 2 elments in tabs are required when moving backward.
{
auto i = std::find(tabs.cbegin(), end, wd);
auto i = std::find(tabs.begin(), end, wd);
if (i != end)
return (tabs.cbegin() == i ? tabs.back() : *(i - 1));
return (tabs.begin() == i ? tabs.back() : *(i - 1));
}
return nullptr;
}
@ -1549,7 +1549,7 @@ namespace detail
for (auto child : wd->children)
{
auto child_keys = shortkeys(child, true);
std::copy(child_keys.cbegin(), child_keys.cend(), std::back_inserter(result));
std::copy(child_keys.begin(), child_keys.end(), std::back_inserter(result));
}
}
}
@ -1716,7 +1716,7 @@ namespace detail
if (pa_children.size() > 1)
{
for (auto i = pa_children.cbegin(), end = pa_children.cend(); i != end; ++i)
for (auto i = pa_children.begin(), end = pa_children.end(); i != end; ++i)
{
if (((*i)->index) > (wd->index))
{

View File

@ -270,7 +270,7 @@ namespace nana
return (reverse ? a > b : a < b);
});
ls_file_.set_sort_compare(3, [this](const std::string&, nana::any* anyptr_a, const std::string&, nana::any* anyptr_b, bool reverse) -> bool
ls_file_.set_sort_compare(3, [](const std::string&, nana::any* anyptr_a, const std::string&, nana::any* anyptr_b, bool reverse) -> bool
{
item_fs * fsa = any_cast<item_fs>(anyptr_a);
item_fs * fsb = any_cast<item_fs>(anyptr_b);

View File

@ -265,6 +265,9 @@ namespace nana
auto ico = impl_->icons[impl_->play_index++];
impl_->set_icon(ico);
#else
//eliminates warnings in clang
static_cast<void>(this);
#endif
});

View File

@ -3055,7 +3055,7 @@ namespace nana
void place::bind(window wd)
{
if (impl_->window_handle)
throw std::runtime_error("place.bind: it has already binded to a window.");
throw std::runtime_error("place.bind: it has already bound to a window.");
impl_->window_handle = wd;
impl_->event_size_handle = API::events(wd).resized.connect([this](const arg_resized& arg)

View File

@ -68,13 +68,13 @@ namespace nana
API::dev::lazy_refresh();
}
void mouse_down(graph_reference graph, const arg_mouse&)
void mouse_down(graph_reference graph, const arg_mouse&) override
{
refresh(graph);
API::dev::lazy_refresh();
}
void mouse_up(graph_reference graph, const arg_mouse&)
void mouse_up(graph_reference graph, const arg_mouse&) override
{
refresh(graph);
API::dev::lazy_refresh();

View File

@ -519,9 +519,7 @@ namespace nana
void _m_draw_block(graph_reference graph, const std::wstring& s, dstream::linecontainer::iterator block_start, render_status& rs)
{
nana::unicode_bidi bidi;
std::vector<nana::unicode_bidi::entity> reordered;
bidi.linestr(s.data(), s.length(), reordered);
auto const reordered = unicode_reorder(s.data(), s.length());
pixel_tag px = rs.pixels[rs.index];

File diff suppressed because it is too large Load Diff

View File

@ -85,7 +85,7 @@ namespace nana
//class item_renderer
item_renderer::item_renderer(window wd, graph_reference graph)
:handle_(wd), graph_(graph), scheme_ptr_(static_cast<scheme*>(API::dev::get_scheme(wd)))
:graph_(graph), scheme_ptr_(static_cast<scheme*>(API::dev::get_scheme(wd)))
{}
void item_renderer::background(const nana::point& pos, const nana::size& size, state item_state)

View File

@ -30,7 +30,8 @@ namespace nana {
point skew_vert;
nana::size extra_px;
bool enable_update{ true };
bool passive{ true }; //The passive mode determines whether to update if scrollbar changes. It updates the client window if passive is true.
bool drag_started{ false };
point origin;
@ -171,7 +172,7 @@ namespace nana {
});
}
void size_changed(bool try_update)
void size_changed(bool passive)
{
auto imd_area = view.view_area();
@ -186,11 +187,11 @@ namespace nana {
if (this->events.scrolled)
this->events.scrolled();
if (this->enable_update)
if (this->passive)
API::refresh_window(this->window_handle);
};
this->enable_update = try_update;
this->passive = passive;
if (imd_area.width != disp_area.width)
{
@ -199,7 +200,7 @@ namespace nana {
vert.create(window_handle);
vert.events().value_changed.connect_unignorable(event_fn);
API::take_active(vert, false, window_handle);
this->enable_update = false;
this->passive = false;
}
vert.move({
@ -226,7 +227,7 @@ namespace nana {
horz.create(window_handle);
horz.events().value_changed.connect_unignorable(event_fn);
API::take_active(horz, false, window_handle);
this->enable_update = false;
this->passive = false;
}
horz.move({
@ -246,7 +247,7 @@ namespace nana {
origin.x = 0;
}
this->enable_update = true;
this->passive = true;
}
};
@ -319,31 +320,31 @@ namespace nana {
void content_view::content_size(const size& sz, bool try_update)
{
auto const view_sz = this->view_area(sz);
if (sz.height < impl_->content_size.height)
{
if (impl_->origin.y + impl_->disp_area.height > sz.height)
if (impl_->origin.y + view_sz.height > sz.height)
{
if (impl_->disp_area.height > sz.height)
if (view_sz.height > sz.height)
impl_->origin.y = 0;
else
impl_->origin.y = sz.height - impl_->disp_area.height;
impl_->origin.y = sz.height - view_sz.height;
}
}
if (sz.width < impl_->content_size.width)
{
if (impl_->origin.x + impl_->disp_area.width > sz.width)
if (impl_->origin.x + view_sz.width > sz.width)
{
if (impl_->disp_area.width > sz.width)
if (view_sz.width > sz.width)
impl_->origin.x = 0;
else
impl_->origin.x = sz.width - impl_->disp_area.width;
impl_->origin.x = sz.width - view_sz.width;
}
}
impl_->content_size = sz;
impl_->size_changed(try_update);
}
@ -388,18 +389,23 @@ namespace nana {
rectangle content_view::view_area() const
{
unsigned extra_horz = (impl_->disp_area.width < impl_->content_size.width ? space() : 0);
unsigned extra_vert = (impl_->disp_area.height < impl_->content_size.height + extra_horz ? space() : 0);
return view_area(impl_->content_size);
}
rectangle content_view::view_area(const size& alt_content_size) const
{
unsigned extra_horz = (impl_->disp_area.width < alt_content_size.width ? space() : 0);
unsigned extra_vert = (impl_->disp_area.height < alt_content_size.height + extra_horz ? space() : 0);
if ((0 == extra_horz) && extra_vert)
extra_horz = (impl_->disp_area.width < impl_->content_size.width + extra_vert ? space() : 0);
extra_horz = (impl_->disp_area.width < alt_content_size.width + extra_vert ? space() : 0);
return rectangle{
impl_->disp_area.position(),
size{
impl_->disp_area.width > extra_vert ? impl_->disp_area.width - extra_vert : 0,
impl_->disp_area.height > extra_horz ? impl_->disp_area.height - extra_horz : 0
}
impl_->disp_area.width > extra_vert ? impl_->disp_area.width - extra_vert : 0,
impl_->disp_area.height > extra_horz ? impl_->disp_area.height - extra_horz : 0
}
};
}
@ -457,12 +463,12 @@ namespace nana {
return (pre_origin != impl_->origin);
}
void content_view::sync(bool try_update)
void content_view::sync(bool passive)
{
impl_->enable_update = try_update;
impl_->passive = passive;
impl_->horz.value(impl_->origin.x);
impl_->vert.value(impl_->origin.y);
impl_->enable_update = true;
impl_->passive = true;
}
void content_view::pursue(const point& cursor)

View File

@ -65,6 +65,7 @@ namespace skeletons
void draw_corner(graph_reference);
rectangle view_area() const;
rectangle view_area(const size& alt_content_size) const;
unsigned extra_space(bool horz) const;
@ -73,7 +74,7 @@ namespace skeletons
/// Returns true if the origin is moved
bool move_origin(const point& skew);
void sync(bool try_update);
void sync(bool passive);
void pursue(const point& cursor);

File diff suppressed because it is too large Load Diff

View File

@ -441,7 +441,10 @@ namespace nana
text = to_wstring(modifier_.prefix + range_->value() + modifier_.suffix);
if (editor_->text() != text)
{
editor_->text(text, false);
editor_->try_refresh();
}
_m_draw_spins(spin_stated_);
}
@ -736,7 +739,8 @@ namespace nana
if (editor)
{
editor->text(to_wstring(text), false);
API::refresh_window(*this);
if (editor->try_refresh())
API::update_window(*this);
}
}
}//end namespace nana

View File

@ -720,6 +720,26 @@ namespace drawerbase {
editor->set_undo_queue_length(len);
}
std::size_t textbox::display_line_count() const noexcept
{
internal_scope_guard lock;
auto editor = get_drawer_trigger().editor();
if (editor)
return editor->line_count(false);
return 0;
}
std::size_t textbox::text_line_count() const noexcept
{
internal_scope_guard lock;
auto editor = get_drawer_trigger().editor();
if (editor)
return editor->line_count(true);
return 0;
}
//Override _m_caption for caption()
auto textbox::_m_caption() const throw() -> native_string_type
{
@ -738,7 +758,9 @@ namespace drawerbase {
if (editor)
{
editor->text(to_wstring(str), false);
API::update_window(this->handle());
if (editor->try_refresh())
API::update_window(this->handle());
}
}

View File

@ -2200,7 +2200,7 @@ namespace nana
}
path.insert(0, pnode->value.first);
return std::move(path);
return path;
}
return{};
}

View File

@ -509,9 +509,7 @@ namespace paint
nana::size sz;
if(impl_->handle && impl_->handle->context && str.size())
{
std::vector<unicode_bidi::entity> reordered;
unicode_bidi bidi;
bidi.linestr(str.c_str(), str.size(), reordered);
auto const reordered = unicode_reorder(str.c_str(), str.size());
for(auto & i: reordered)
{
nana::size t = text_extent_size(i.begin, i.end - i.begin);
@ -958,9 +956,8 @@ namespace paint
unsigned graphics::bidi_string(const nana::point& pos, const wchar_t * str, std::size_t len)
{
auto moved_pos = pos;
unicode_bidi bidi;
std::vector<unicode_bidi::entity> reordered;
bidi.linestr(str, len, reordered);
auto const reordered = unicode_reorder(str, len);
for (auto & i : reordered)
{
string(moved_pos, i.begin, i.end - i.begin);
@ -1208,7 +1205,8 @@ namespace paint
unsigned last_color = (int(r) << 16) | (int(g) << 8) | int(b);
Display * disp = nana::detail::platform_spec::instance().open_display();
impl_->handle->fgcolor(static_cast<color_rgb>(last_color));
impl_->handle->set_color(static_cast<color_rgb>(last_color));
impl_->handle->update_color();
const int endpos = deltapx + (vertical ? rct.y : rct.x);
if (endpos > 0)
{
@ -1223,7 +1221,8 @@ namespace paint
if (new_color != last_color)
{
last_color = new_color;
impl_->handle->fgcolor(static_cast<color_rgb>(last_color));
impl_->handle->set_color(static_cast<color_rgb>(last_color));
impl_->handle->update_color();
}
}
}
@ -1238,7 +1237,8 @@ namespace paint
if (new_color != last_color)
{
last_color = new_color;
impl_->handle->fgcolor(static_cast<color_rgb>(last_color));
impl_->handle->set_color(static_cast<color_rgb>(last_color));
impl_->handle->update_color();
}
}
}

View File

@ -13,26 +13,23 @@ namespace nana
template<typename F>
void for_each_line(const wchar_t * str, std::size_t len, int top, F & f)
{
auto head = str;
auto end = str + len;
auto const end = str + len;
for(auto i = str; i != end; ++i)
{
if(*i == '\n')
{
top += static_cast<int>(f(top, head, i - head));
head = i + 1;
top += static_cast<int>(f(top, str, i - str));
str = i + 1;
}
}
if(head != end)
f(top, head, end - head);
if(str != end)
f(top, str, end - str);
}
struct draw_string
{
drawable_type dw;
const int x, endpos;
nana::unicode_bidi bidi;
std::vector<nana::unicode_bidi::entity> reordered;
align text_align;
draw_string(drawable_type dw, int x, int endpos, align ta)
@ -41,9 +38,13 @@ namespace nana
unsigned operator()(const int top, const wchar_t * buf, std::size_t bufsize)
{
auto const reordered = unicode_reorder(buf, bufsize);
if (reordered.empty())
return 0;
nana::point pos{ x, top };
unsigned pixels = 0;
bidi.linestr(buf, bufsize, reordered);
switch(text_align)
{
case align::left:
@ -64,23 +65,28 @@ namespace nana
case align::center:
{
unsigned lenpx = 0;
std::vector<unsigned> widths;
std::unique_ptr<unsigned[]> entity_pxs(new unsigned[reordered.size()]);
auto ent_px = entity_pxs.get();
for(auto & ent : reordered)
{
auto ts = detail::text_extent_size(dw, ent.begin, ent.end - ent.begin);
if(ts.height > pixels) pixels = ts.height;
lenpx += ts.width;
widths.emplace_back(ts.width);
*ent_px++ = ts.width;
}
pos.x += (endpos - pos.x - static_cast<int>(lenpx))/2;
auto ipx = widths.begin();
ent_px = entity_pxs.get();
for(auto & ent : reordered)
{
if(pos.x + static_cast<int>(*ipx) > 0)
if (pos.x + static_cast<int>(*ent_px) > 0)
detail::draw_string(dw, pos, ent.begin, ent.end - ent.begin);
pos.x += static_cast<int>(*ipx);
pos.x += static_cast<int>(*ent_px++);
if(pos.x >= endpos)
break;
}
@ -90,7 +96,7 @@ namespace nana
{
int xend = endpos;
std::swap(pos.x, xend);
for(auto i = reordered.rbegin(), end = reordered.rend(); i != end; ++i)
for(auto i = reordered.crbegin(); i != reordered.crend(); ++i)
{
auto & ent = *i;
std::size_t len = ent.end - ent.begin;
@ -118,13 +124,11 @@ namespace nana
graphics & graph;
int x, endpos;
unsigned omitted_pixels;
nana::unicode_bidi bidi;
std::vector<nana::unicode_bidi::entity> reordered;
draw_string_omitted(graphics& graph, int x, int endpos, bool omitted)
: graph(graph), x(x), endpos(endpos)
{
omitted_pixels = (omitted ? graph.text_extent_size(L"...", 3).width : 0);
omitted_pixels = (omitted ? graph.text_extent_size("...", 3).width : 0);
if (endpos - x > static_cast<int>(omitted_pixels))
this->endpos -= omitted_pixels;
else
@ -136,7 +140,9 @@ namespace nana
drawable_type dw = graph.handle();
::nana::point pos{ x, top };
unsigned pixels = 0;
bidi.linestr(buf, bufsize, reordered);
auto const reordered = unicode_reorder(buf, bufsize);
for(auto & i : reordered)
{
std::size_t len = i.end - i.begin;
@ -178,9 +184,6 @@ namespace nana
{
graphics & graph;
int x, endpos;
nana::unicode_bidi bidi;
std::vector<nana::unicode_bidi::entity> reordered;
std::vector<nana::size> ts_keeper;
align text_align;
draw_string_auto_changing_lines(graphics& graph, int x, int endpos, align ta)
@ -191,10 +194,13 @@ namespace nana
{
unsigned pixels = 0;
drawable_type dw = graph.handle();
auto const dw = graph.handle();
unsigned str_w = 0;
ts_keeper.clear();
bidi.linestr(buf, bufsize, reordered);
std::vector<nana::size> ts_keeper;
auto const reordered = unicode_reorder(buf, bufsize);
for(auto & i : reordered)
{
nana::size ts = detail::text_extent_size(dw, i.begin, i.end - i.begin);
@ -219,22 +225,27 @@ namespace nana
bool beyond_edge = (pos.x + static_cast<int>(i_ts_keeper->width) > endpos);
if(beyond_edge)
{
std::size_t len = i.end - i.begin;
const std::size_t len = i.end - i.begin;
if(len > 1)
{
unsigned * pxbuf = new unsigned[len];
std::unique_ptr<unsigned[]> pixel_buf(new unsigned[len]);
//Find the char that should be splitted
graph.glyph_pixels(i.begin, len, pxbuf);
graph.glyph_pixels(i.begin, len, pixel_buf.get());
std::size_t idx_head = 0, idx_splitted;
do
{
auto pxbuf = pixel_buf.get();
idx_splitted = find_splitted(idx_head, len, pos.x, endpos, pxbuf);
if(idx_splitted == len)
{
detail::draw_string(dw, pos, i.begin + idx_head, idx_splitted - idx_head);
for(std::size_t i = idx_head; i < len; ++i)
pos.x += static_cast<int>(pxbuf[i]);
break;
}
//Check the word whether it is splittable.
@ -243,7 +254,7 @@ namespace nana
detail::draw_string(dw, pos, i.begin + idx_head, idx_splitted - idx_head);
idx_head = idx_splitted;
pos.x = x;
pos.y += line_pixels;
pos.y += static_cast<int>(line_pixels);
line_pixels = i_ts_keeper->height;
}
else
@ -283,18 +294,16 @@ namespace nana
for(std::size_t k = idx_head; k < idx_head + splen; ++k)
pos.x += static_cast<int>(pxbuf[k]);
if (pos.x >= endpos)
{
pos.x = x;
pos.y += static_cast<int>(line_pixels);
line_pixels = i_ts_keeper->height;
}
idx_head += splen;
}
}
}while(idx_head < len);
delete [] pxbuf;
}
else
{
@ -340,7 +349,7 @@ namespace nana
{
point pos{ endpos, top };
auto i_ts_keeper = ts_keeper.crbegin();
for(auto i = reordered.crbegin(), end = reordered.crend(); i != end; ++i)
for(auto i = reordered.crbegin(); i != reordered.crend(); ++i)
{
auto & ent = *i;
std::size_t len = ent.end - ent.begin;
@ -397,9 +406,6 @@ namespace nana
{
graphics & graph;
int x, endpos;
nana::unicode_bidi bidi;
std::vector<nana::unicode_bidi::entity> reordered;
std::vector<nana::size> ts_keeper;
unsigned extents;
extent_auto_changing_lines(graphics& graph, int x, int endpos)
@ -412,8 +418,10 @@ namespace nana
drawable_type dw = graph.handle();
unsigned str_w = 0;
ts_keeper.clear();
bidi.linestr(buf, bufsize, reordered);
std::vector<nana::size> ts_keeper;
auto const reordered = unicode_reorder(buf, bufsize);
for(auto & i : reordered)
{
nana::size ts = detail::text_extent_size(dw, i.begin, i.end - i.begin);
@ -503,7 +511,6 @@ namespace nana
{
xpos = x;
top += line_pixels;
line_pixels = i_ts_keeper->height;
}
idx_head += splen;
}
@ -645,11 +652,9 @@ namespace nana
substr_px += *p;
} while (p != end);
pos.x += static_cast<int>(width - ellipsis - substr_px);
graph_.string(pos, "...");
pos.x += ellipsis;
pos.x += static_cast<int>(width - ellipsis - substr_px) + ellipsis;
graph_.bidi_string(pos, text.c_str() + substr_len, text.size() - substr_len);
pos.x -= ellipsis;
}
else
{
@ -669,8 +674,9 @@ namespace nana
graph_.bidi_string(pos, text.c_str(), substr_len);
pos.x += substr_px;
graph_.string(pos, "...");
}
graph_.string(pos, "...");
}
//end class string

View File

@ -66,7 +66,7 @@ namespace nana
if (ifs.read(reinterpret_cast<char*>(&table_directory), sizeof table_directory).gcount() != sizeof table_directory)
return;
if (reinterpret_cast<const std::uint32_t&>("name") == reinterpret_cast<std::uint32_t&>(table_directory.name))
if (*reinterpret_cast<const std::uint32_t*>("name") == reinterpret_cast<std::uint32_t&>(table_directory.name))
{
//const std::size_t length = _m_swap(table_directory.length);
const std::size_t directory_offset = _m_swap(table_directory.offset);

View File

@ -276,8 +276,7 @@ namespace nana
if(ch <= 0x1CC7) return L; //N = 141
if(0x1CD3 == ch || 0x1CE1 == ch) return L;
if(ch <= 0x1CE8) return NSM; //N = 7
if(0x1CED == ch) return NSM;
if(0x1CF4 == ch) return NSM;
if(0x1CED == ch || 0x1CF4 == ch) return NSM;
if(ch <= 0x1DBF) return L; //N = 203
if(ch <= 0x1DFF) return NSM; //N = 64
if(ch <= 0x1FBC) return L; //N = 445
@ -504,21 +503,21 @@ namespace nana
}
//class unicode_bidi
void unicode_bidi::linestr(const char_type* str, std::size_t len, std::vector<entity> & reordered)
std::vector<unicode_bidi::entity> unicode_bidi::reorder(const char_type* str, std::size_t len)
{
levels_.clear();
const char_type * const end = str + len;
std::vector<remember> stack;
remember cur = {0, directional_override_status::neutral};
remember cur = { 0, directional_override_status::neutral };
cur.level = _m_paragraph_level(str, end);
//First character type
bidi_char begin_char_type = {};
const char_type * begin_character = nullptr;
for(const char_type * c = str; c < end; ++c)
for (const char_type * c = str; c < end; ++c)
{
if (PDF == *c)
{
@ -579,13 +578,17 @@ namespace nana
begin_character = c;
}
}
if(begin_character)
if (begin_character)
_m_push_entity(begin_character, end, cur.level, begin_char_type);
_m_resolve_weak_types();
_m_resolve_neutral_types();
_m_resolve_implicit_levels();
std::vector<unicode_bidi::entity> reordered;
_m_reordering_resolved_levels(reordered);
return reordered;
}
unsigned unicode_bidi::_m_paragraph_level(const char_type * begin, const char_type * end)
@ -938,4 +941,9 @@ namespace nana
return static_cast<bidi_char>(static_cast<int>(type - bidi_charmap::B) + 0x2000);
}
//end class unicode_bidi
std::vector<unicode_bidi::entity> unicode_reorder(const wchar_t* text, std::size_t length)
{
return unicode_bidi{}.reorder(text, length);
}
}//end namespace nana