Add text_changed event for combox, spinbox and textbox

This commit is contained in:
cnjinhao
2015-01-31 04:17:34 +08:00
parent 7c93980530
commit 50f4bd79ce
9 changed files with 156 additions and 15 deletions

View File

@@ -29,7 +29,7 @@ namespace nana
combox & widget;
arg_combox(combox& wdg)
: widget(wdg)
: widget{ wdg }
{}
};
@@ -40,7 +40,8 @@ namespace nana
struct combox_events
: public general_events
{
basic_event<arg_combox> selected;
basic_event<arg_combox> selected;
basic_event<arg_combox> text_changed;
};
class drawer_impl;

View File

@@ -1,7 +1,7 @@
/*
* A textbase class implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -511,6 +511,9 @@ namespace skeletons
_m_first_change();
changed_ = true;
}
if (evt_agent_)
evt_agent_->text_changed();
}
private:
std::deque<string_type> text_cont_;

View File

@@ -1,7 +1,7 @@
/*
* Definitions of textbase export interfaces
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -25,6 +25,7 @@ namespace nana{ namespace widgets
virtual ~textbase_event_agent_interface() = default;
virtual void first_change() = 0; ///< An event for the text first change after text has been opened or stored.
virtual void text_changed() = 0; ///< An event for the change of text.
};
}//end namespace skeletons
}//end namespace widgets

View File

@@ -17,10 +17,27 @@
namespace nana
{
class spinbox;
struct arg_spinbox
{
spinbox & widget;
arg_spinbox(spinbox& wdg)
: widget{ wdg }
{}
};
namespace drawerbase
{
namespace spinbox
{
struct spinbox_events
: public general_events
{
basic_event<arg_spinbox> text_changed;
};
/// Declaration of internal spinbox implementation
class implementation;
@@ -58,7 +75,7 @@ namespace nana
/// Spinbox Widget
class spinbox
: public widget_object <category::widget_tag, drawerbase::spinbox::drawer, ::nana::general_events, ::nana::widgets::skeletons::text_editor_scheme>
: public widget_object <category::widget_tag, drawerbase::spinbox::drawer, drawerbase::spinbox::spinbox_events, ::nana::widgets::skeletons::text_editor_scheme>
{
public:
/// Constructs a spinbox.
@@ -83,6 +100,7 @@ namespace nana
/// Gets the spined value
::nana::string value() const;
void value(const ::nana::string&);
int to_int() const;
double to_double() const;

View File

@@ -40,14 +40,16 @@ namespace nana
: public general_events
{
basic_event<arg_textbox> first_change;
basic_event<arg_textbox> text_changed;
};
class event_agent
: public widgets::skeletons::textbase_event_agent_interface
{
public:
event_agent(::nana::textbox& wdg);
event_agent(::nana::textbox&);
void first_change() override;
void text_changed() override;
private:
::nana::textbox & widget_;
};
@@ -57,7 +59,7 @@ namespace nana
: public drawer_trigger
{
public:
typedef widgets::skeletons::text_editor text_editor;
using text_editor = widgets::skeletons::text_editor;
drawer();
text_editor * editor();