refactor toolbar

This commit is contained in:
Jinhao
2015-05-30 16:55:03 +08:00
parent 11d65763ce
commit ee9d102f8d
2 changed files with 163 additions and 227 deletions

View File

@@ -14,7 +14,6 @@
#define NANA_GUI_WIDGET_TOOLBAR_HPP
#include "widget.hpp"
#include <vector>
namespace nana
{
@@ -39,10 +38,10 @@ namespace nana
basic_event<arg_toolbar> selected; ///< A mouse click on a control button.
basic_event<arg_toolbar> enter; ///< The mouse enters a control button.
basic_event<arg_toolbar> leave; ///< The mouse leaves a control button.
};
struct item_type;
class item_container;
class drawer
: public drawer_trigger
@@ -50,15 +49,12 @@ namespace nana
struct drawer_impl_type;
public:
typedef std::size_t size_type;
using size_type = std::size_t;
drawer();
~drawer();
void append(const nana::string&, const nana::paint::image&);
void append();
bool enable(size_type) const;
bool enable(size_type, bool);
item_container& items() const;
void scale(unsigned);
private:
void refresh(graph_reference) override;
@@ -69,32 +65,28 @@ namespace nana
void mouse_down(graph_reference, const arg_mouse&) override;
void mouse_up(graph_reference, const arg_mouse&) override;
private:
size_type _m_which(int x, int y, bool want_if_disabled) const;
void _m_draw_background(const ::nana::color&);
void _m_draw();
void _m_owner_sized(const arg_resized&);
private:
void _m_fill_pixels(item_type*, bool force);
size_type _m_which(point, bool want_if_disabled) const;
void _m_calc_pixels(item_type*, bool force);
private:
::nana::toolbar* widget_;
::nana::paint::graphics* graph_;
drawer_impl_type* impl_;
};
}//end namespace toolbar
}//end namespace drawerbase
/// Control bar that contains buttons for controlling
class toolbar
: public widget_object<category::widget_tag, drawerbase::toolbar::drawer, drawerbase::toolbar::toolbar_events>
{
public:
typedef std::size_t size_type; ///< A type to count the number of elements.
using size_type = std::size_t; ///< A type to count the number of elements.
toolbar() = default;
toolbar(window, bool visible);
toolbar(window, const rectangle& = rectangle(), bool visible = true);
void append(); ///< Adds a separator.
void separate(); ///< Adds a separator.
void append(const nana::string& text, const nana::paint::image& img); ///< Adds a control button.
void append(const nana::string& text); ///< Adds a control button.
bool enable(size_type index) const;