change textbox event text_position_changed in favor of text_exposed

This commit is contained in:
Jinhao
2015-10-23 00:51:58 +08:00
parent fb3b1d51d4
commit 09b314b94c
7 changed files with 47 additions and 94 deletions

View File

@@ -229,8 +229,6 @@ namespace nana{ namespace widgets
/// Returns text position of each line that currently displays on screen
const std::vector<upoint>& text_position() const;
void set_text_position_changed(std::function<void(const std::vector<upoint>&)>);
public:
void draw_corner();
void render(bool focused);
@@ -317,7 +315,6 @@ namespace nana{ namespace widgets
mutable ext_renderer_tag ext_renderer_;
std::vector<upoint> text_position_; //position of text from last rendering.
std::function<void(const std::vector<upoint>&)> text_position_function_;
struct indent_rep
{

View File

@@ -11,6 +11,9 @@ namespace nana
{
namespace skeletons
{
//forward declaration
class text_editor;
struct text_editor_scheme
: public ::nana::widget_colors
{
@@ -23,7 +26,7 @@ namespace nana
public:
virtual ~text_editor_event_interface() = default;
virtual void text_position_changed(const std::vector<upoint>&) = 0;
virtual void text_exposed(const std::vector<upoint>&) = 0;
};
}
}

View File

@@ -23,28 +23,11 @@ namespace nana
: public event_arg
{
textbox& widget;
const std::vector<upoint>* text_position;
const std::vector<upoint>& text_position; ///< position of characters that the first character of line which are displayed
arg_textbox(textbox&);
arg_textbox(textbox&, const std::vector<upoint>&);
};
struct arg_textbox_text_position
: public event_arg
{
textbox& widget;
const std::vector<upoint>& text_position;
arg_textbox_text_position(textbox&, const std::vector<upoint>&);
};
namespace widgets
{
namespace skeletons
{
class text_editor;
}
}
namespace drawerbase
{
namespace textbox
@@ -54,15 +37,7 @@ namespace nana
{
basic_event<arg_textbox> first_change;
basic_event<arg_textbox> text_changed;
basic_event<arg_textbox_text_position> text_position_changed;
};
class event_interface
{
public:
virtual ~event_interface() = default;
virtual void text_position_changed(const std::vector<upoint>&) = 0;
basic_event<arg_textbox> text_exposed;
};
class event_agent
@@ -70,16 +45,17 @@ namespace nana
public widgets::skeletons::text_editor_event_interface
{
public:
event_agent(::nana::textbox&);
event_agent(::nana::textbox&, const std::vector<upoint>&);
private:
//Overrides textbase_event_agent_interface
void first_change() override;
void text_changed() override;
private:
//Overrides text_editor_event_interface
void text_position_changed(const std::vector<upoint>&) override;
void text_exposed(const std::vector<upoint>&) override;
private:
::nana::textbox & widget_;
const std::vector<upoint>& text_position_;
};
//class drawer
@@ -122,6 +98,7 @@ namespace nana
:public widget_object<category::widget_tag, drawerbase::textbox::drawer, drawerbase::textbox::textbox_events, ::nana::widgets::skeletons::text_editor_scheme>
{
public:
using text_positions = std::vector<upoint>;
/// The default constructor without creating the widget.
textbox();
@@ -220,7 +197,7 @@ namespace nana
/// Returns the text position of each line that currently displays on screen.
std::vector<upoint> text_position() const;
text_positions text_position() const;
/// Returns the rectangle of text area
rectangle text_area() const;

View File

@@ -30,7 +30,7 @@ namespace detail
{
///@brief Seek a pixel address by using offset bytes
///@return the specified pixel address
inline pixel_color_t * pixel_at(pixel_color_t * p, std::size_t bytes) //deprecated
inline pixel_color_t * pixel_at(pixel_color_t * p, std::size_t bytes)
{
return reinterpret_cast<pixel_color_t*>(reinterpret_cast<char*>(p) + bytes);
}