From dcb472cb062b88102953082f15c626596eebcd63 Mon Sep 17 00:00:00 2001 From: Mexsut Date: Mon, 25 Sep 2017 15:20:38 +0800 Subject: [PATCH] add a native wstring version textbox::append added a textbox::append which accepts texts in std::wstring --- include/nana/gui/widgets/textbox.hpp | 2 +- source/gui/widgets/textbox.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp index d0ac2f67..5f6dbc91 100644 --- a/include/nana/gui/widgets/textbox.hpp +++ b/include/nana/gui/widgets/textbox.hpp @@ -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. 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. bool line_wrapped() const; textbox& line_wrapped(bool); diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index e29b0d88..de6e2dd9 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -435,7 +435,23 @@ namespace drawerbase { } 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. bool textbox::line_wrapped() const {