add scheme for checkbox square box
This commit is contained in:
parent
1c5f70124c
commit
6e401fe75e
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Widget Geometrics
|
* Widget Geometrics
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -22,12 +22,17 @@ namespace nana
|
|||||||
public:
|
public:
|
||||||
color_proxy(const color_proxy&);
|
color_proxy(const color_proxy&);
|
||||||
color_proxy(color_rgb);
|
color_proxy(color_rgb);
|
||||||
|
color_proxy(color_argb);
|
||||||
|
color_proxy(color_rgba);
|
||||||
color_proxy(colors);
|
color_proxy(colors);
|
||||||
color_proxy& operator=(const color_proxy&);
|
color_proxy& operator=(const color_proxy&);
|
||||||
color_proxy& operator=(const ::nana::color&);
|
color_proxy& operator=(const ::nana::color&);
|
||||||
color_proxy& operator=(color_rgb);
|
color_proxy& operator=(color_rgb);
|
||||||
|
color_proxy& operator=(color_argb);
|
||||||
|
color_proxy& operator=(color_rgba);
|
||||||
color_proxy& operator=(colors);
|
color_proxy& operator=(colors);
|
||||||
color get_color() const;
|
color get_color() const;
|
||||||
|
color get(const color& default_color) const;
|
||||||
operator color() const;
|
operator color() const;
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<color> color_;
|
std::shared_ptr<color> color_;
|
||||||
|
|||||||
@ -37,6 +37,13 @@ namespace drawerbase
|
|||||||
{
|
{
|
||||||
namespace checkbox
|
namespace checkbox
|
||||||
{
|
{
|
||||||
|
struct scheme
|
||||||
|
: public widget_geometrics
|
||||||
|
{
|
||||||
|
color_proxy square_bgcolor{ static_cast<color_argb>(0x0) };
|
||||||
|
color_proxy square_border_color{ colors::black };
|
||||||
|
};
|
||||||
|
|
||||||
struct events_type
|
struct events_type
|
||||||
: public general_events
|
: public general_events
|
||||||
{
|
{
|
||||||
@ -67,7 +74,7 @@ namespace drawerbase
|
|||||||
|
|
||||||
|
|
||||||
class checkbox
|
class checkbox
|
||||||
: public widget_object<category::widget_tag, drawerbase::checkbox::drawer, drawerbase::checkbox::events_type>
|
: public widget_object<category::widget_tag, drawerbase::checkbox::drawer, drawerbase::checkbox::events_type, drawerbase::checkbox::scheme>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
checkbox();
|
checkbox();
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Color Schemes
|
* Color Schemes
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -24,6 +24,14 @@ namespace nana
|
|||||||
: color_(std::make_shared<color>(clr))
|
: color_(std::make_shared<color>(clr))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
color_proxy::color_proxy(color_argb clr)
|
||||||
|
: color_(std::make_shared<color>(clr))
|
||||||
|
{}
|
||||||
|
|
||||||
|
color_proxy::color_proxy(color_rgba clr)
|
||||||
|
: color_(std::make_shared<color>(clr))
|
||||||
|
{}
|
||||||
|
|
||||||
color_proxy::color_proxy(colors clr)
|
color_proxy::color_proxy(colors clr)
|
||||||
: color_(std::make_shared<color>(clr))
|
: color_(std::make_shared<color>(clr))
|
||||||
{}
|
{}
|
||||||
@ -47,6 +55,18 @@ namespace nana
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
color_proxy& color_proxy::operator = (color_argb clr)
|
||||||
|
{
|
||||||
|
color_ = std::make_shared<::nana::color>(clr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
color_proxy& color_proxy::operator = (color_rgba clr)
|
||||||
|
{
|
||||||
|
color_ = std::make_shared<::nana::color>(clr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
color_proxy& color_proxy::operator = (colors clr)
|
color_proxy& color_proxy::operator = (colors clr)
|
||||||
{
|
{
|
||||||
color_ = std::make_shared<::nana::color>(clr);
|
color_ = std::make_shared<::nana::color>(clr);
|
||||||
@ -58,6 +78,13 @@ namespace nana
|
|||||||
return *color_;
|
return *color_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
color color_proxy::get(const color& default_color) const
|
||||||
|
{
|
||||||
|
if (color_->invisible())
|
||||||
|
return default_color;
|
||||||
|
return *color_;
|
||||||
|
}
|
||||||
|
|
||||||
color_proxy::operator color() const
|
color_proxy::operator color() const
|
||||||
{
|
{
|
||||||
return *color_;
|
return *color_;
|
||||||
|
|||||||
@ -24,6 +24,7 @@ namespace nana{ namespace drawerbase
|
|||||||
struct drawer::implement
|
struct drawer::implement
|
||||||
{
|
{
|
||||||
widget * widget_ptr;
|
widget * widget_ptr;
|
||||||
|
scheme * scheme_ptr;
|
||||||
bool react;
|
bool react;
|
||||||
bool radio;
|
bool radio;
|
||||||
facade<element::crook> crook;
|
facade<element::crook> crook;
|
||||||
@ -47,6 +48,7 @@ namespace nana{ namespace drawerbase
|
|||||||
void drawer::attached(widget_reference widget, graph_reference)
|
void drawer::attached(widget_reference widget, graph_reference)
|
||||||
{
|
{
|
||||||
impl_->widget_ptr = &widget;
|
impl_->widget_ptr = &widget;
|
||||||
|
impl_->scheme_ptr =static_cast<scheme*>(API::dev::get_scheme(widget));
|
||||||
API::dev::enable_space_click(widget, true);
|
API::dev::enable_space_click(widget, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,12 +80,14 @@ namespace nana{ namespace drawerbase
|
|||||||
}
|
}
|
||||||
|
|
||||||
//draw crook
|
//draw crook
|
||||||
#ifdef _nana_std_has_string_view
|
|
||||||
auto txt_px = graph.text_extent_size(std::wstring_view( L"jN", 2 )).height + 2;
|
unsigned txt_px = 0, descent = 0, ileading = 0;
|
||||||
#else
|
graph.text_metrics(txt_px, descent, ileading);
|
||||||
auto txt_px = graph.text_extent_size(L"jN", 2).height + 2;
|
txt_px += (descent + 2);
|
||||||
#endif
|
|
||||||
impl_->crook.draw(graph, wdg->bgcolor(), wdg->fgcolor(), rectangle(0, txt_px > 16 ? (txt_px - 16) / 2 : 0, 16, 16), API::element_state(*wdg));
|
impl_->crook.draw(graph,
|
||||||
|
impl_->scheme_ptr->square_bgcolor.get(wdg->bgcolor()), impl_->scheme_ptr->square_border_color.get(wdg->fgcolor()),
|
||||||
|
rectangle(0, txt_px > 16 ? (txt_px - 16) / 2 : 0, 16, 16), API::element_state(*wdg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawer::mouse_down(graph_reference graph, const arg_mouse&)
|
void drawer::mouse_down(graph_reference graph, const arg_mouse&)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user