add textbox::content_origin
This commit is contained in:
parent
d5c01b3dd1
commit
27e1d7aff5
@ -86,6 +86,7 @@ namespace nana{ namespace widgets
|
||||
~text_editor();
|
||||
|
||||
size caret_size() const;
|
||||
const point& content_origin() const;
|
||||
|
||||
void set_highlight(const ::std::string& name, const ::nana::color&, const ::nana::color&);
|
||||
void erase_highlight(const ::std::string& name);
|
||||
|
||||
@ -140,6 +140,8 @@ namespace nana
|
||||
|
||||
colored_area_access_interface* colored_area_access();
|
||||
|
||||
point content_origin() const;
|
||||
|
||||
/// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter.
|
||||
/// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line.
|
||||
textbox& indention(bool, std::function<std::string()> generator = {});
|
||||
|
||||
@ -497,6 +497,7 @@ namespace nana{ namespace widgets
|
||||
undoable<command> undo; //undo command
|
||||
renderers customized_renderers;
|
||||
std::vector<upoint> text_position; //positions of text since last rendering.
|
||||
int text_position_origin{ -1 }; //origin when last text_exposed
|
||||
|
||||
skeletons::textbase<wchar_t> textbase;
|
||||
|
||||
@ -1083,6 +1084,11 @@ namespace nana{ namespace widgets
|
||||
return { 1, line_height() };
|
||||
}
|
||||
|
||||
const point& text_editor::content_origin() const
|
||||
{
|
||||
return impl_->cview->origin();
|
||||
}
|
||||
|
||||
void text_editor::set_highlight(const std::string& name, const ::nana::color& fgcolor, const ::nana::color& bgcolor)
|
||||
{
|
||||
if (fgcolor.invisible() && bgcolor.invisible())
|
||||
@ -1982,8 +1988,9 @@ namespace nana{ namespace widgets
|
||||
if (text_pos.empty())
|
||||
text_pos.emplace_back(upoint{});
|
||||
|
||||
if (text_pos != impl_->text_position)
|
||||
if ((impl_->text_position_origin != impl_->cview->origin().y) || (text_pos != impl_->text_position))
|
||||
{
|
||||
impl_->text_position_origin = impl_->cview->origin().y;
|
||||
impl_->text_position.swap(text_pos);
|
||||
if (event_handler_)
|
||||
event_handler_->text_exposed(impl_->text_position);
|
||||
|
||||
@ -269,6 +269,15 @@ namespace drawerbase {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
point textbox::content_origin() const
|
||||
{
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
if (editor)
|
||||
return editor->content_origin();
|
||||
|
||||
return{};
|
||||
}
|
||||
|
||||
/// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter.
|
||||
/// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line.
|
||||
textbox& textbox::indention(bool enb, std::function<std::string()> generator)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user