Merge branch 'hotfix-1.5.3' into develop
This commit is contained in:
commit
0e9b4f2755
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Window Layout Implementation
|
||||
* 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
|
||||
@ -72,9 +72,17 @@ namespace detail
|
||||
static void make_bground(core_window_t* const);
|
||||
private:
|
||||
|
||||
//_m_paste_children
|
||||
//@brief:paste children window to the root graphics directly. just paste the visual rectangle
|
||||
static void _m_paste_children(core_window_t*, bool have_refreshed, bool request_refresh_children, const nana::rectangle& parent_rect, nana::paint::graphics& graph, const nana::point& graph_rpos);
|
||||
/// _m_paste_children
|
||||
/**
|
||||
* Pastes children window to the root graphics directly. just paste the visual rectangle
|
||||
* @param window A handle to the window whose child windows will be pasted to the graph.
|
||||
* @param has_refreshed Indicates whethere the window has been refreshed.
|
||||
* @param request_refresh_children A flag indicates whether to refresh its child windows.
|
||||
* @param parent_rect The child windows which are overlapped with the rectangle will be pasted
|
||||
* @param graph A graphics object to which the child windows are pasted.
|
||||
* @param graph_rpos The reference point to the graph.
|
||||
*/
|
||||
static void _m_paste_children(core_window_t* window, bool has_refreshed, bool request_refresh_children, const nana::rectangle& parent_rect, nana::paint::graphics& graph, const nana::point& graph_rpos);
|
||||
|
||||
static void _m_paint_glass_window(core_window_t*, bool is_redraw, bool is_child_refreshed, bool called_by_notify, bool notify_other);
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Message Box Class
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 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
|
||||
|
||||
@ -149,12 +149,13 @@ namespace nana{ namespace widgets
|
||||
void text(std::wstring, bool end_caret);
|
||||
std::wstring text() const;
|
||||
|
||||
/// Sets caret position through text coordinate.
|
||||
/// Moves the caret at specified position
|
||||
/**
|
||||
* @param pos the text position
|
||||
* @param reset indicates whether to reset the text position by the pos. If this parameter is true, the text position is set by pos. If the parameter is false, it only moves the UI caret to the specified position.
|
||||
* @param stay_in_view Indicates whether to adjust the view to make the caret in view. This parameter is ignored if the caret is already in view.
|
||||
* @return true indicates a refresh is required.
|
||||
*/
|
||||
bool move_caret(const upoint& pos, bool reset = false);
|
||||
bool move_caret(upoint pos, bool stay_in_view = false);
|
||||
void move_caret_end(bool update);
|
||||
void reset_caret_pixels() const;
|
||||
void reset_caret(bool stay_in_view = false);
|
||||
@ -211,6 +212,7 @@ namespace nana{ namespace widgets
|
||||
bool mouse_enter(bool entering);
|
||||
bool mouse_move(bool left_button, const point& screen_pos);
|
||||
void mouse_pressed(const arg_mouse& arg);
|
||||
bool select_word(const arg_mouse& arg);
|
||||
|
||||
skeletons::textbase<char_type>& textbase();
|
||||
const skeletons::textbase<char_type>& textbase() const;
|
||||
|
||||
@ -80,6 +80,7 @@ namespace nana
|
||||
void mouse_up(graph_reference, const arg_mouse&) override;
|
||||
void mouse_enter(graph_reference, const arg_mouse&) override;
|
||||
void mouse_leave(graph_reference, const arg_mouse&) override;
|
||||
void dbl_click(graph_reference, const arg_mouse&) override;
|
||||
void key_press(graph_reference, const arg_keyboard&)override;
|
||||
void key_char(graph_reference, const arg_keyboard&) override;
|
||||
void mouse_wheel(graph_reference, const arg_wheel&) override;
|
||||
@ -174,6 +175,9 @@ namespace nana
|
||||
/// Returns true if the caret is in the area of display, false otherwise.
|
||||
bool caret_pos(point& pos, bool text_coordinate) const;
|
||||
|
||||
/// Gets the caret position, in text coordinate
|
||||
upoint caret_pos() const;
|
||||
|
||||
/// Sets the caret position with a text position
|
||||
textbox& caret_pos(const upoint&);
|
||||
|
||||
|
||||
@ -140,6 +140,7 @@ namespace nana
|
||||
private:
|
||||
//Overrides drawer_trigger methods
|
||||
void attached(widget_reference, graph_reference) override;
|
||||
void detached() override;
|
||||
void refresh(graph_reference) override;
|
||||
void dbl_click(graph_reference, const arg_mouse&) override;
|
||||
void mouse_down(graph_reference, const arg_mouse&) override;
|
||||
|
||||
@ -91,7 +91,11 @@ namespace nana
|
||||
const void* pixmap() const;
|
||||
const void* context() const;
|
||||
|
||||
void make(const ::nana::size&); ///< Creates a bitmap resource that size is width by height in pixel
|
||||
/// Creates a graphics/drawable resource
|
||||
/**
|
||||
* @param sz The dimension of the graphics to be requested. If sz is empty, it performs as release().
|
||||
*/
|
||||
void make(const ::nana::size& sz);
|
||||
void resize(const ::nana::size&);
|
||||
void typeface(const font&); ///< Selects a specified font type into the graphics object.
|
||||
font typeface() const;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Window Layout 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
|
||||
@ -266,8 +266,6 @@ namespace nana
|
||||
wd->effect.bground->take_effect(reinterpret_cast<window>(wd), glass_buffer);
|
||||
}
|
||||
|
||||
//_m_paste_children
|
||||
//@brief:paste children window to the root graphics directly. just paste the visual rectangle
|
||||
void window_layout::_m_paste_children(core_window_t* wd, bool have_refreshed, bool req_refresh_children, const nana::rectangle& parent_rect, nana::paint::graphics& graph, const nana::point& graph_rpos)
|
||||
{
|
||||
nana::rectangle rect;
|
||||
@ -287,12 +285,10 @@ namespace nana
|
||||
{
|
||||
if (overlap(nana::rectangle{ child->pos_root, child->dimension }, parent_rect, rect))
|
||||
{
|
||||
bool have_child_refreshed = false;
|
||||
if (category::flags::lite_widget != child->other.category)
|
||||
{
|
||||
if (req_refresh_children && (false == child->flags.refreshing))
|
||||
{
|
||||
have_child_refreshed = true;
|
||||
child->flags.refreshing = true;
|
||||
child->drawer.refresh();
|
||||
child->flags.refreshing = false;
|
||||
@ -301,7 +297,9 @@ namespace nana
|
||||
graph.bitblt(nana::rectangle(rect.x - graph_rpos.x, rect.y - graph_rpos.y, rect.width, rect.height),
|
||||
child->drawer.graphics, nana::point(rect.x - child->pos_root.x, rect.y - child->pos_root.y));
|
||||
}
|
||||
_m_paste_children(child, req_refresh_children, have_child_refreshed, rect, graph, graph_rpos);
|
||||
//req_refresh_children determines whether the child has been refreshed, and also determines whether
|
||||
//the children of child to be refreshed.
|
||||
_m_paste_children(child, req_refresh_children, req_refresh_children, rect, graph, graph_rpos);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Message Box Class
|
||||
* 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
|
||||
@ -18,7 +18,6 @@
|
||||
#include <nana/gui/widgets/textbox.hpp>
|
||||
#include <nana/gui/widgets/panel.hpp>
|
||||
#include <nana/gui/widgets/picture.hpp>
|
||||
#include <nana/gui/place.hpp>
|
||||
#include <nana/datetime.hpp>
|
||||
#include <nana/internationalization.hpp>
|
||||
#include <nana/gui/filebox.hpp>
|
||||
@ -511,7 +510,6 @@ namespace nana
|
||||
|
||||
unsigned height = 20 + desc_extent.height + 10 + 38;
|
||||
|
||||
place_.bind(*this);
|
||||
std::stringstream ss_content;
|
||||
ss_content << "<margin=10 vert <desc weight=" << desc_extent.height << "><vert margin=[10]";
|
||||
|
||||
@ -598,9 +596,10 @@ namespace nana
|
||||
std::stringstream ss;
|
||||
ss << "vert<img_top weight="<<img_sz[0].height<<"><<img_left weight="<<img_sz[2].width<<">"<<ss_content.str()<<"<img_right weight="<<img_sz[3].width<<">><img_bottom weight="<<img_sz[1].height<<">";
|
||||
|
||||
place_.div(ss.str().data());
|
||||
place_["desc"] << desc_;
|
||||
place_["buttons"] << btn_ok_ << btn_cancel_;
|
||||
auto& place = this->get_place();
|
||||
place.div(ss.str().c_str());
|
||||
place["desc"] << desc_;
|
||||
place["buttons"] << btn_ok_ << btn_cancel_;
|
||||
|
||||
const char * img_fields[4] = {"img_top", "img_bottom", "img_left", "img_right"};
|
||||
|
||||
@ -611,11 +610,10 @@ namespace nana
|
||||
images_[i].create(*this, true);
|
||||
images_[i].load(imgs[i], valid_areas[i]);
|
||||
images_[i].stretchable(0, 0, 0, 0);
|
||||
place_[img_fields[i]] << images_[i];
|
||||
place_.field_display(img_fields[i], true);
|
||||
place[img_fields[i]] << images_[i];
|
||||
}
|
||||
else
|
||||
place_.field_display(img_fields[i], false);
|
||||
|
||||
place.field_display(img_fields[i], imgs[i]);
|
||||
}
|
||||
|
||||
move(API::make_center(this->owner(), desc_extent.width, height));
|
||||
@ -626,14 +624,14 @@ namespace nana
|
||||
{
|
||||
verifier_ = std::move(verifier);
|
||||
|
||||
std::size_t index = 0;
|
||||
unsigned index = 0;
|
||||
for (auto wd : inputs)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "input_" << index++;
|
||||
place_[ss.str().data()] << wd;
|
||||
this->operator[](ss.str().data()) << wd;
|
||||
}
|
||||
place_.collocate();
|
||||
this->collocate();
|
||||
show();
|
||||
}
|
||||
|
||||
@ -646,7 +644,6 @@ namespace nana
|
||||
::nana::button btn_ok_;
|
||||
::nana::button btn_cancel_;
|
||||
bool valid_input_{ false };
|
||||
::nana::place place_;
|
||||
std::function<bool(window)> verifier_;
|
||||
::nana::picture images_[4];
|
||||
};
|
||||
|
||||
@ -557,7 +557,10 @@ namespace nana
|
||||
}value_;
|
||||
};//end class number_t
|
||||
|
||||
|
||||
/// Margin attribute
|
||||
/**
|
||||
* Definition at https://github.com/cnjinhao/nana/wiki/Div-Text#margin
|
||||
*/
|
||||
class margin
|
||||
{
|
||||
public:
|
||||
@ -598,7 +601,7 @@ namespace nana
|
||||
{
|
||||
case 0: break;
|
||||
case 1: //top
|
||||
il = ir = it = ib = 0;
|
||||
it = 0;
|
||||
break;
|
||||
case 2://top,bottom and left,right
|
||||
it = ib = 0;
|
||||
@ -624,7 +627,7 @@ namespace nana
|
||||
case 3: //left
|
||||
pos = il; break;
|
||||
default:
|
||||
return number_t{};
|
||||
return {};
|
||||
}
|
||||
|
||||
return (-1 == pos ? number_t{} : margins_[pos]);
|
||||
@ -652,7 +655,7 @@ namespace nana
|
||||
{
|
||||
case 0: break;
|
||||
case 1: //top
|
||||
il = ir = it = ib = 0;
|
||||
it = 0;
|
||||
break;
|
||||
case 2://top,bottom and left,right
|
||||
it = ib = 0;
|
||||
|
||||
@ -1434,7 +1434,8 @@ namespace nana
|
||||
|
||||
bool expand(size_type cat, bool exp) noexcept
|
||||
{
|
||||
if(good(cat) && cat)
|
||||
//It is allowed to expand the 1st category.
|
||||
if(good(cat) && (cat || exp))
|
||||
{
|
||||
auto & expanded = get(cat)->expand;
|
||||
if(expanded != exp)
|
||||
@ -2848,8 +2849,37 @@ namespace nana
|
||||
this->expand(pos.cat, true);
|
||||
ess_->calc_content_size();
|
||||
}
|
||||
else if (!ess_->auto_draw)
|
||||
{
|
||||
//force a update of content size and scrollbar status when auto_draw is false to make
|
||||
//sure that the scroll function works fine.
|
||||
ess_->calc_content_size();
|
||||
}
|
||||
|
||||
ess_->content_view->turn_page(to_bottom, false);
|
||||
auto origin = ess_->content_view->origin();
|
||||
origin.y = 0;
|
||||
|
||||
auto off = this->distance(this->first(), pos) * ess_->item_height();
|
||||
|
||||
auto screen_px = ess_->content_view->view_area().height;
|
||||
|
||||
if (to_bottom)
|
||||
{
|
||||
off += ess_->item_height();
|
||||
if (off >= screen_px)
|
||||
origin.y = static_cast<int>(off - screen_px);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto last_off = this->distance(this->first(), this->last()) * ess_->item_height();
|
||||
if (last_off - off >= screen_px)
|
||||
origin.y = static_cast<int>(off);
|
||||
else if (last_off >= screen_px)
|
||||
origin.y = static_cast<int>(last_off - screen_px);
|
||||
}
|
||||
|
||||
if(ess_->content_view->move_origin(origin - ess_->content_view->origin()))
|
||||
ess_->content_view->sync(false);
|
||||
}
|
||||
|
||||
void es_lister::erase(const index_pair& pos)
|
||||
@ -4488,8 +4518,10 @@ namespace nana
|
||||
|
||||
//pos_ never represents a category if this item_proxy is available.
|
||||
auto & m = cat_->items.at(pos_.item); // a ref to the real item
|
||||
|
||||
//ignore if no change
|
||||
if(m.flags.selected == s)
|
||||
return *this; // ignore if no change
|
||||
return *this;
|
||||
|
||||
m.flags.selected = s; // actually change selection
|
||||
|
||||
@ -4503,14 +4535,8 @@ namespace nana
|
||||
else if (ess_->lister.latest_selected_abs == pos_)
|
||||
ess_->lister.latest_selected_abs.set_both(npos);
|
||||
|
||||
if (scroll_view)
|
||||
{
|
||||
if (ess_->lister.get(pos_.cat)->expand)
|
||||
ess_->lister.get(pos_.cat)->expand = false;
|
||||
|
||||
if (!this->displayed())
|
||||
ess_->lister.scroll(pos_, !(ess_->first_display() > this->to_display()));
|
||||
}
|
||||
if (scroll_view && (!this->displayed()))
|
||||
ess_->lister.scroll(pos_, !(ess_->first_display() > this->to_display()));
|
||||
|
||||
ess_->update();
|
||||
return *this;
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/widgets/skeletons/text_editor.cpp
|
||||
* @contributors: Ariel Vina-Rodriguez
|
||||
* @contributors: Ariel Vina-Rodriguez, Oleg Smolsky
|
||||
*/
|
||||
#include <nana/gui/widgets/skeletons/text_editor.hpp>
|
||||
#include <nana/gui/widgets/skeletons/textbase_export_interface.hpp>
|
||||
@ -234,7 +234,7 @@ namespace nana{ namespace widgets
|
||||
}
|
||||
}
|
||||
|
||||
editor_.move_caret(editor_.points_.caret);
|
||||
editor_.reset_caret();
|
||||
}
|
||||
};
|
||||
|
||||
@ -302,7 +302,7 @@ namespace nana{ namespace widgets
|
||||
editor_.select_.b = sel_b_;
|
||||
}
|
||||
}
|
||||
editor_.move_caret(editor_.points_.caret);
|
||||
editor_.reset_caret();
|
||||
}
|
||||
private:
|
||||
std::wstring text_;
|
||||
@ -440,7 +440,7 @@ namespace nana{ namespace widgets
|
||||
break;
|
||||
}
|
||||
|
||||
return *colored_areas_.emplace(i,
|
||||
return *colored_areas_.emplace(i,
|
||||
std::make_shared<colored_area_type>(colored_area_type{line_pos, 1, color{}, color{}})
|
||||
);
|
||||
}
|
||||
@ -1129,7 +1129,7 @@ namespace nana{ namespace widgets
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
colored_area_access_interface& text_editor::colored_area()
|
||||
{
|
||||
return impl_->colored_area;
|
||||
@ -1273,7 +1273,7 @@ namespace nana{ namespace widgets
|
||||
if (impl_->cview->content_size().empty() || this->attributes_.line_wrapped)
|
||||
_m_reset_content_size(true);
|
||||
|
||||
move_caret(points_.caret);
|
||||
reset_caret();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1564,7 +1564,6 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
//no move occurs
|
||||
select(false);
|
||||
|
||||
move_caret(_m_coordinate_to_caret(arg.pos));
|
||||
}
|
||||
|
||||
@ -1580,6 +1579,45 @@ namespace nana{ namespace widgets
|
||||
}
|
||||
}
|
||||
|
||||
//Added Windows-style mouse double-click to the textbox(https://github.com/cnjinhao/nana/pull/229)
|
||||
//Oleg Smolsky
|
||||
bool text_editor::select_word(const arg_mouse& arg)
|
||||
{
|
||||
if(!attributes_.enable_caret)
|
||||
return false;
|
||||
|
||||
auto is_whitespace = [](wchar_t c) {
|
||||
switch (c) {
|
||||
case L' ':
|
||||
case L'\t':
|
||||
case L'\n':
|
||||
case L'\r':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Set caret pos by screen point and get the caret pos.
|
||||
mouse_caret(arg.pos, true);
|
||||
|
||||
// Set the initial selection: it is an empty range.
|
||||
select_.a = select_.b = points_.caret;
|
||||
const auto& line = impl_->textbase.getline(select_.b.y);
|
||||
|
||||
// Expand the selection forward to the word's end.
|
||||
while (select_.b.x < line.size() && !is_whitespace(line[select_.b.x]))
|
||||
++select_.b.x;
|
||||
|
||||
// Expand the selection backward to the word's start.
|
||||
while (select_.a.x > 0 && !is_whitespace(line[select_.a.x - 1]))
|
||||
--select_.a.x;
|
||||
|
||||
select_.mode_selection = selection::mode::method_selected;
|
||||
impl_->try_refresh = sync_graph::refresh;
|
||||
return true;
|
||||
}
|
||||
|
||||
textbase<text_editor::char_type> & text_editor::textbase()
|
||||
{
|
||||
return impl_->textbase;
|
||||
@ -1638,6 +1676,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
//_m_put calcs the lines
|
||||
_m_reset_content_size(false);
|
||||
impl_->cview->sync(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1660,10 +1699,29 @@ namespace nana{ namespace widgets
|
||||
return str;
|
||||
}
|
||||
|
||||
bool text_editor::move_caret(const upoint& crtpos, bool reset_caret)
|
||||
{
|
||||
bool text_editor::move_caret(upoint crtpos, bool stay_in_view)
|
||||
{
|
||||
const unsigned line_pixels = line_height();
|
||||
|
||||
if (crtpos != points_.caret)
|
||||
{
|
||||
//Check and make the crtpos available
|
||||
if (crtpos.y < impl_->textbase.lines())
|
||||
{
|
||||
crtpos.x = (std::min)(static_cast<decltype(crtpos.x)>(impl_->textbase.getline(crtpos.y).size()), crtpos.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
crtpos.y = impl_->textbase.lines();
|
||||
if (crtpos.y > 0)
|
||||
--crtpos.y;
|
||||
|
||||
crtpos.x = impl_->textbase.getline(crtpos.y).size();
|
||||
}
|
||||
|
||||
points_.caret = crtpos;
|
||||
}
|
||||
|
||||
//The coordinate of caret
|
||||
auto coord = _m_caret_to_coordinate(crtpos);
|
||||
|
||||
@ -1694,9 +1752,11 @@ namespace nana{ namespace widgets
|
||||
caret->position(coord);
|
||||
|
||||
//Adjust the caret into screen when the caret position is modified by this function
|
||||
if (reset_caret && (!hit_text_area(coord)))
|
||||
if (stay_in_view && (!hit_text_area(coord)))
|
||||
{
|
||||
this->_m_adjust_view();
|
||||
if (_m_adjust_view())
|
||||
impl_->cview->sync(false);
|
||||
|
||||
impl_->try_refresh = sync_graph::refresh;
|
||||
caret->visible(true);
|
||||
return true;
|
||||
@ -1711,7 +1771,7 @@ namespace nana{ namespace widgets
|
||||
points_.caret.x = static_cast<unsigned>(impl_->textbase.getline(points_.caret.y).size());
|
||||
|
||||
if (update)
|
||||
this->move_caret(points_.caret, false);
|
||||
this->reset_caret();
|
||||
}
|
||||
|
||||
void text_editor::reset_caret_pixels() const
|
||||
@ -1766,7 +1826,7 @@ namespace nana{ namespace widgets
|
||||
impl_->try_refresh = sync_graph::refresh;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
select_.mode_selection = selection::mode::no_selected;
|
||||
if (_m_cancel_select(0))
|
||||
{
|
||||
@ -1914,10 +1974,10 @@ namespace nana{ namespace widgets
|
||||
if ((false == textbase().empty()) || has_focus)
|
||||
{
|
||||
auto text_pos = _m_render_text(fgcolor);
|
||||
|
||||
|
||||
if (text_pos.empty())
|
||||
text_pos.emplace_back(upoint{});
|
||||
|
||||
|
||||
if (text_pos != impl_->text_position)
|
||||
{
|
||||
impl_->text_position.swap(text_pos);
|
||||
@ -1959,7 +2019,8 @@ namespace nana{ namespace widgets
|
||||
|
||||
if(graph_)
|
||||
{
|
||||
this->_m_adjust_view();
|
||||
if(this->_m_adjust_view())
|
||||
impl_->cview->sync(false);
|
||||
|
||||
reset_caret();
|
||||
impl_->try_refresh = sync_graph::refresh;
|
||||
@ -2276,7 +2337,7 @@ namespace nana{ namespace widgets
|
||||
//The number of charecters in the line of caret
|
||||
auto const text_length = textbase().getline(points_.caret.y).size();
|
||||
|
||||
|
||||
|
||||
switch (key) {
|
||||
case keyboard::os_arrow_left:
|
||||
if (select_.move_to_end && (select_.a != select_.b) && (!arg.shift))
|
||||
@ -2424,7 +2485,7 @@ namespace nana{ namespace widgets
|
||||
if (stay_in_view && this->_m_adjust_view())
|
||||
impl_->try_refresh = sync_graph::refresh;
|
||||
|
||||
move_caret(points_.caret);
|
||||
reset_caret();
|
||||
return points_.caret;
|
||||
}
|
||||
|
||||
@ -2460,7 +2521,7 @@ namespace nana{ namespace widgets
|
||||
lines = impl_->capacities.behavior->take_lines(row.first);
|
||||
else
|
||||
top += static_cast<int>(height * row.second);
|
||||
|
||||
|
||||
const rectangle area_r = { text_area_.area.x, top, width_pixels(), static_cast<unsigned>(height * lines) };
|
||||
|
||||
if (API::is_transparent_background(this->window_))
|
||||
@ -2757,7 +2818,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
const unsigned pixels = line_height();
|
||||
const rectangle update_area = { text_area_.area.x, top, width_pixels(), static_cast<unsigned>(pixels * secondary_count_before) };
|
||||
|
||||
|
||||
if (!API::dev::copy_transparent_background(window_, update_area, graph_, update_area.position()))
|
||||
{
|
||||
_m_draw_colored_area(graph_, { pos, 0 }, true);
|
||||
@ -3047,7 +3108,7 @@ namespace nana{ namespace widgets
|
||||
this->points_.caret = (1 == align ? a : b);
|
||||
this->_m_adjust_view();
|
||||
}
|
||||
|
||||
|
||||
select_.a = select_.b = points_.caret;
|
||||
reset_caret();
|
||||
return true;
|
||||
@ -3195,7 +3256,7 @@ namespace nana{ namespace widgets
|
||||
auto px = static_cast<int>(line_height());
|
||||
return (px ? (impl_->cview->origin().y / px) : px);
|
||||
}
|
||||
|
||||
|
||||
int text_editor::_m_text_x(const text_section& sct) const
|
||||
{
|
||||
auto const behavior = impl_->capacities.behavior;
|
||||
@ -3289,17 +3350,23 @@ namespace nana{ namespace widgets
|
||||
line_px_( editor.line_height() )
|
||||
{}
|
||||
|
||||
color selection_text_color(bool has_focused) const
|
||||
{
|
||||
return (has_focused ? editor_.scheme_->selection_text : editor_.scheme_->foreground).get_color();
|
||||
}
|
||||
|
||||
void write_selection(const point& text_pos, unsigned text_px, const wchar_t* text, std::size_t len, bool has_focused)
|
||||
{
|
||||
graph_.palette(true, editor_.scheme_->selection_text.get_color());
|
||||
graph_.rectangle(::nana::rectangle{ text_pos, { text_px, line_px_ } }, true,
|
||||
graph_.palette(true, selection_text_color(has_focused));
|
||||
|
||||
graph_.rectangle(::nana::rectangle{ text_pos, { text_px, line_px_ } }, true,
|
||||
has_focused ? editor_.scheme_->selection.get_color() : editor_.scheme_->selection_unfocused.get_color());
|
||||
graph_.string(text_pos, text, len);
|
||||
}
|
||||
|
||||
void rtl_string(point strpos, const wchar_t* str, std::size_t len, std::size_t str_px, unsigned glyph_front, unsigned glyph_selected, bool has_focused)
|
||||
{
|
||||
editor_._m_draw_parse_string(parser_, true, strpos, editor_.scheme_->selection_text.get_color(), str, len);
|
||||
editor_._m_draw_parse_string(parser_, true, strpos, selection_text_color(has_focused), str, len);
|
||||
|
||||
//Draw selected part
|
||||
paint::graphics graph({ glyph_selected, line_px_ });
|
||||
@ -3308,7 +3375,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
int sel_xpos = static_cast<int>(str_px - (glyph_front + glyph_selected));
|
||||
|
||||
graph.palette(true, editor_.scheme_->selection_text.get_color());
|
||||
graph.palette(true, selection_text_color(has_focused));
|
||||
graph.string({ -sel_xpos, 0 }, str, len);
|
||||
graph_.bitblt(nana::rectangle(strpos.x + sel_xpos, strpos.y, glyph_selected, line_px_), graph);
|
||||
};
|
||||
@ -3345,7 +3412,7 @@ namespace nana{ namespace widgets
|
||||
const auto line_h_pixels = line_height();
|
||||
|
||||
helper_pencil pencil(graph_, *this, parser);
|
||||
|
||||
|
||||
graph_.palette(true, clr);
|
||||
graph_.palette(false, scheme_->selection.get_color());
|
||||
|
||||
@ -3396,9 +3463,11 @@ namespace nana{ namespace widgets
|
||||
//A text editor feature, it draws an extra block at end of line if the end of line is in range of selection.
|
||||
bool extra_space = false;
|
||||
|
||||
//Create a flag for indicating whether the whole line is selected
|
||||
const bool text_selected = (sbegin == text_ptr && send == text_ptr+ text_len);
|
||||
|
||||
//The text is not selected or the whole line text is selected
|
||||
if (!focused || (!sbegin || !send) || text_selected || !attributes_.enable_caret)
|
||||
if ((!sbegin || !send) || text_selected)
|
||||
{
|
||||
for (auto & ent : reordered)
|
||||
{
|
||||
@ -3567,7 +3636,7 @@ namespace nana{ namespace widgets
|
||||
return 0;
|
||||
|
||||
auto const reordered = unicode_reorder(lnstr.c_str(), lnstr.size());
|
||||
|
||||
|
||||
auto target = lnstr.c_str() + pos;
|
||||
|
||||
unsigned text_w = 0;
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/widgets/textbox.hpp
|
||||
* @contributors: Oleg Smolsky
|
||||
*/
|
||||
|
||||
#include <nana/gui/widgets/textbox.hpp>
|
||||
@ -143,6 +144,14 @@ namespace drawerbase {
|
||||
API::dev::lazy_refresh();
|
||||
}
|
||||
|
||||
//Added Windows-style mouse double-click to the textbox(https://github.com/cnjinhao/nana/pull/229)
|
||||
//Oleg Smolsky
|
||||
void drawer::dbl_click(graph_reference, const arg_mouse& arg)
|
||||
{
|
||||
if(editor_->select_word(arg))
|
||||
API::dev::lazy_refresh();
|
||||
}
|
||||
|
||||
void drawer::key_press(graph_reference, const arg_keyboard& arg)
|
||||
{
|
||||
editor_->respond_key(arg);
|
||||
@ -381,6 +390,16 @@ namespace drawerbase {
|
||||
return editor->hit_text_area(scr_pos);
|
||||
}
|
||||
|
||||
upoint textbox::caret_pos() const
|
||||
{
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
internal_scope_guard lock;
|
||||
if (editor)
|
||||
return editor->caret();
|
||||
|
||||
return{};
|
||||
}
|
||||
|
||||
textbox& textbox::caret_pos(const upoint& pos)
|
||||
{
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
|
||||
@ -1781,6 +1781,11 @@ namespace nana
|
||||
widget.caption("nana treebox");
|
||||
}
|
||||
|
||||
void trigger::detached()
|
||||
{
|
||||
impl_->data.graph = nullptr;
|
||||
}
|
||||
|
||||
void trigger::refresh(graph_reference)
|
||||
{
|
||||
//Don't reset the scroll and update the window
|
||||
|
||||
@ -291,6 +291,12 @@ namespace paint
|
||||
{
|
||||
if(impl_->handle == nullptr || impl_->size != sz)
|
||||
{
|
||||
if (sz.empty())
|
||||
{
|
||||
release();
|
||||
return;
|
||||
}
|
||||
|
||||
//The object will be delete while dwptr_ is performing a release.
|
||||
drawable_type dw = new nana::detail::drawable_impl_type;
|
||||
//Reuse the old font
|
||||
@ -342,7 +348,7 @@ namespace paint
|
||||
Display* disp = spec.open_display();
|
||||
int screen = DefaultScreen(disp);
|
||||
Window root = ::XRootWindow(disp, screen);
|
||||
dw->pixmap = ::XCreatePixmap(disp, root, (sz.width ? sz.width : 1), (sz.height ? sz.height : 1), DefaultDepth(disp, screen));
|
||||
dw->pixmap = ::XCreatePixmap(disp, root, sz.width, sz.height, DefaultDepth(disp, screen));
|
||||
dw->context = ::XCreateGC(disp, dw->pixmap, 0, 0);
|
||||
#if defined(NANA_USE_XFT)
|
||||
dw->xftdraw = ::XftDrawCreate(disp, dw->pixmap, spec.screen_visual(), spec.colormap());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user