Defined a new color class

The new color class is temporarily named expr_color for experiment.
This commit is contained in:
cnjinhao
2014-12-14 10:15:19 +08:00
parent d0a317bd45
commit 74c09eb9b3
37 changed files with 1495 additions and 674 deletions

View File

@@ -1078,7 +1078,16 @@ namespace nana
class internal_renderer
: public renderer_interface
{
void bground(graph_reference graph, nana::color_t bgcolor, nana::color_t fgcolor, const compset_interface * compset) const override
nana::expr_color bgcolor_;
nana::expr_color fgcolor_;
void set_color(const nana::expr_color & bgcolor, const nana::expr_color& fgcolor) override
{
bgcolor_ = bgcolor;
fgcolor_ = fgcolor;
}
void bground(graph_reference graph, const compset_interface * compset) const override
{
comp_attribute_t attr;
@@ -1108,7 +1117,7 @@ namespace nana
}
}
void expander(graph_reference graph, nana::color_t bgcolor, nana::color_t fgcolor, const compset_interface * compset) const override
void expander(graph_reference graph, const compset_interface * compset) const override
{
comp_attribute_t attr;
if(compset->comp_attribute(component::expender, attr))
@@ -1126,18 +1135,18 @@ namespace nana
}
}
void crook(graph_reference graph, nana::color_t bgcolor, nana::color_t fgcolor, const compset_interface * compset) const override
void crook(graph_reference graph, const compset_interface * compset) const override
{
comp_attribute_t attr;
if(compset->comp_attribute(component::crook, attr))
{
attr.area.y += (attr.area.height - 16) / 2;
crook_.check(compset->item_attribute().checked);
crook_.draw(graph, bgcolor, fgcolor, attr.area, attr.mouse_pointed ? element_state::hovered : element_state::normal);
crook_.draw(graph, bgcolor_, fgcolor_, attr.area, attr.mouse_pointed ? element_state::hovered : element_state::normal);
}
}
virtual void icon(graph_reference graph, nana::color_t bgcolor, nana::color_t fgcolor, const compset_interface * compset) const override
virtual void icon(graph_reference graph, const compset_interface * compset) const override
{
comp_attribute_t attr;
if(compset->comp_attribute(component::icon, attr))
@@ -1170,11 +1179,14 @@ namespace nana
}
}
virtual void text(graph_reference graph, nana::color_t bgcolor, nana::color_t fgcolor, const compset_interface * compset) const override
virtual void text(graph_reference graph, const compset_interface * compset) const override
{
comp_attribute_t attr;
if(compset->comp_attribute(component::text, attr))
graph.string(attr.area.x, attr.area.y + 3, fgcolor, compset->item_attribute().text);
if (compset->comp_attribute(component::text, attr))
{
graph.set_text_color(fgcolor_);
graph.string(point{ attr.area.x, attr.area.y + 3 }, compset->item_attribute().text);
}
}
private:
@@ -1279,8 +1291,8 @@ namespace nana
item_renderer(implement * impl, const nana::point& pos)
:impl_(impl), pos_(pos)
{
bgcolor_ = impl_->data.widget_ptr->background();
fgcolor_ = impl_->data.widget_ptr->foreground();
bgcolor_ = impl_->data.widget_ptr->bgcolor();
fgcolor_ = impl_->data.widget_ptr->fgcolor();
}
//affect
@@ -1310,11 +1322,12 @@ namespace nana
node_r_.height = comp_placer->item_height(*impl_->data.graph);
auto renderer = draw_impl->data.renderer;
renderer->bground(*draw_impl->data.graph, bgcolor_, fgcolor_, this);
renderer->expander(*draw_impl->data.graph, bgcolor_, fgcolor_, this);
renderer->crook(*draw_impl->data.graph, bgcolor_, fgcolor_, this);
renderer->icon(*draw_impl->data.graph, bgcolor_, fgcolor_, this);
renderer->text(*draw_impl->data.graph, bgcolor_, fgcolor_, this);
renderer->set_color(bgcolor_, fgcolor_);
renderer->bground(*draw_impl->data.graph, this);
renderer->expander(*draw_impl->data.graph, this);
renderer->crook(*draw_impl->data.graph, this);
renderer->icon(*draw_impl->data.graph, this);
renderer->text(*draw_impl->data.graph, this);
pos_.y += node_r_.height;
@@ -1343,8 +1356,10 @@ namespace nana
}
private:
trigger::implement * impl_;
nana::color_t bgcolor_;
nana::color_t fgcolor_;
//nana::color_t bgcolor_; //deprecated
//nana::color_t fgcolor_;
nana::expr_color bgcolor_;
nana::expr_color fgcolor_;
nana::point pos_;
const node_type * iterated_node_;
item_attribute_t node_attr_;
@@ -1386,13 +1401,12 @@ namespace nana
nana::paint::graphics item_graph(item_r_.width, item_r_.height);
item_graph.typeface(graph_->typeface());
auto bgcolor = widget_->background();
auto fgcolor = widget_->foreground();
renderer_->bground(item_graph, bgcolor, fgcolor, this);
renderer_->expander(item_graph, bgcolor, fgcolor, this);
renderer_->crook(item_graph, bgcolor, fgcolor, this);
renderer_->icon(item_graph, bgcolor, fgcolor, this);
renderer_->text(item_graph, bgcolor, fgcolor, this);
renderer_->set_color(widget_->bgcolor(), widget_->fgcolor());
renderer_->bground(item_graph, this);
renderer_->expander(item_graph, this);
renderer_->crook(item_graph, this);
renderer_->icon(item_graph, this);
renderer_->text(item_graph, this);
item_graph.paste(attr.area, *graph_, 1, 1);
graph_->rectangle(0x0, false);