develop inline widgets for listbox

This commit is contained in:
Jinhao
2015-06-21 04:44:49 +08:00
parent c761aced03
commit 1bb9a09a8a
9 changed files with 121 additions and 43 deletions

View File

@@ -406,10 +406,10 @@ namespace nana
struct rectangle
{
rectangle(); ///< a zero-size rectangle at (0, 0).
rectangle(); ///< a zero-size rectangle at (0, 0).
rectangle(int x, int y, unsigned width, unsigned height);
rectangle(const size &); ///< a rectangle with specified size at coordinate (0, 0).
rectangle(const point&, const size& = size());
explicit rectangle(const size &); ///< a rectangle with specified size at coordinate (0, 0).
explicit rectangle(const point&, const size& = size());
bool operator==(const rectangle& rhs) const;
bool operator!=(const rectangle& rhs) const;

View File

@@ -23,29 +23,56 @@ namespace nana
class inline_widget_indicator
{
public:
/// A type to index a item
using index_type = Index;
/// A type to the value of the item
using value_type = Value;
/// The destructor
virtual ~inline_widget_indicator() = default;
private:
virtual void modify(index_type, const value_type&) const = 0;
/// Modifies the value of a item specified by pos
virtual void modify(index_type pos, const value_type&) const = 0;
/// Sends a signal that a specified item is selected
virtual void selected(index_type) = 0;
/// Sends a signal that a specified item is hovered
virtual void hovered(index_type) = 0;
};
template<typename Index, typename Value>
class inline_widget_interface
class inline_widget_notifier_interface
{
public:
/// A type to index a item
using index_type = Index;
/// A type to the value of the item
using value_type = Value;
/// A typedef name of a inline widget indicator
using inline_indicator = inline_widget_indicator<index_type, value_type>;
using factory_interface = inline_widget_interface;
virtual ~inline_widget_interface() = default;
/// A type to the notifier interface that will be refered by the abstract factory pattern
using factory_interface = inline_widget_notifier_interface;
/// The destructor
virtual ~inline_widget_notifier_interface() = default;
/// A message to create the inline widget
virtual void create(window) = 0;
/// A message to activate the inline widget to attach a specified item
virtual void activate(inline_indicator&, index_type) = 0;
/// A message to resize the inline widget
virtual void resize(const size&) = 0;
/// A message to set the value from a item
virtual void set(const value_type&) = 0;
};
}; //end class inline_widget_notifier_interface
}
}

View File

@@ -81,7 +81,7 @@ namespace nana
using selection = std::vector<index_pair>;
using inline_interface = detail::inline_widget_interface<index_pair, std::wstring>;
using inline_notifier_interface = detail::inline_widget_notifier_interface<index_pair, std::wstring>;
struct cell
{
@@ -347,7 +347,7 @@ namespace nana
: public std::iterator < std::input_iterator_tag, cat_proxy >
{
public:
using inline_interface = drawerbase::listbox::inline_interface;
using inline_notifier_interface = drawerbase::listbox::inline_notifier_interface;
cat_proxy() = default;
cat_proxy(essence_t*, size_type pos);
@@ -429,7 +429,7 @@ namespace nana
/// Behavior of Iterator
bool operator!=(const cat_proxy&) const;
void inline_factory(size_type column, pat::cloneable<pat::abstract_factory<inline_interface>> factory);
void inline_factory(size_type column, pat::cloneable<pat::abstract_factory<inline_notifier_interface>> factory);
private:
void _m_append(std::vector<cell> && cells);
void _m_cat_by_pos();
@@ -506,7 +506,7 @@ By \a clicking on a header the list get \a reordered, first up, and then down al
using cell = drawerbase::listbox::cell;
using export_options= drawerbase::listbox::export_options;
using columns_indexs= drawerbase::listbox::size_type;
using inline_interface = drawerbase::listbox::inline_interface;
using inline_notifier_interface = drawerbase::listbox::inline_notifier_interface;
public:
listbox() = default;
listbox(window, bool visible);

View File

@@ -76,6 +76,7 @@ namespace nana
point pos() const;
void move(int x, int y);
//void move(const point&);
void move(const rectangle&);
void fgcolor(const nana::color&);