New border element

This commit is contained in:
cnjinhao
2015-01-14 04:30:35 +08:00
parent 7496fea110
commit bb49ba651c
6 changed files with 122 additions and 48 deletions

View File

@@ -87,9 +87,6 @@ namespace nana
auto scheme = dynamic_cast< ::nana::widgets::skeletons::text_editor_scheme*>(API::dev::get_scheme(wd));
editor_ = new widgets::skeletons::text_editor(widget_->handle(), graph, scheme);
editor_->border_renderer([this](graph_reference graph, const ::nana::color& bgcolor){
draw_border(graph, bgcolor);
});
editor_->multi_lines(false);
editable(false);
graph_ = &graph;
@@ -286,13 +283,6 @@ namespace nana
_m_draw_image();
}
void draw_border(graph_reference graph, const ::nana::color& bgcolor)
{
graph.rectangle(false, (state_.focused ? ::nana::color(0x05, 0x95, 0xE2) : ::nana::color(0x99, 0x9A, 0x9E)));
nana::rectangle r(graph.size());
graph.rectangle(r.pare_off(1), false, bgcolor);
}
std::size_t the_number_of_options() const
{
return items_.size();

View File

@@ -12,6 +12,7 @@
*/
#include <nana/gui/widgets/skeletons/text_editor.hpp>
#include <nana/gui/widgets/skeletons/textbase_export_interface.hpp>
#include <nana/gui/element.hpp>
#include <nana/system/dataexch.hpp>
#include <nana/unicode_bidi.hpp>
#include <numeric>
@@ -1294,6 +1295,15 @@ namespace nana{ namespace widgets
API::create_caret(wd, 1, line_height());
API::bgcolor(wd, colors::white);
API::fgcolor(wd, colors::black);
text_area_.border_renderer = [this](graph_reference graph, const ::nana::color& bgcolor)
{
if (!API::widget_borderless(this->window_))
{
::nana::facade<element::border> facade;
facade.draw(graph, bgcolor, API::fgcolor(this->window_), API::window_size(this->window_), API::element_state(this->window_));
}
};
}
text_editor::~text_editor()
@@ -1591,6 +1601,7 @@ namespace nana{ namespace widgets
else
select_.mode_selection = selection::mode_no_selected;
}
text_area_.border_renderer(graph_, _m_bgcolor());
return true;
}
@@ -1848,6 +1859,9 @@ namespace nana{ namespace widgets
if (!API::window_enabled(window_))
fgcolor.blend(bgcolor, 0.5);
if (API::widget_borderless(window_))
graph_.rectangle(false, bgcolor);
//Draw background
if(attributes_.enable_background)
graph_.rectangle(text_area_.area, true, bgcolor);
@@ -1864,6 +1878,7 @@ namespace nana{ namespace widgets
_m_draw_tip_string();
draw_scroll_rectangle();
text_area_.border_renderer(graph_, bgcolor);
}
//public:

View File

@@ -61,9 +61,6 @@ namespace nana{ namespace drawerbase {
editor_ = new text_editor(wd, graph, dynamic_cast<::nana::widgets::skeletons::text_editor_scheme*>(scheme));
editor_->textbase().set_event_agent(evt_agent_.get());
editor_->border_renderer([this](graph_reference graph, const ::nana::color& clr){
this->_m_draw_border(graph, clr);
});
_m_text_area(graph.width(), graph.height());
@@ -178,16 +175,6 @@ namespace nana{ namespace drawerbase {
editor_->text_area(r);
}
}
void drawer::_m_draw_border(graph_reference graph, const ::nana::color& bgcolor)
{
if (!API::widget_borderless(widget_->handle()))
{
nana::rectangle r(graph.size());
graph.rectangle(r, false, (status_.has_focus ? ::nana::color(0x05, 0x95, 0xE2) : ::nana::color(0x99, 0x9A, 0x9E)));
graph.rectangle(r.pare_off(1), false, bgcolor);
}
}
//end class drawer
}//end namespace textbox
}//end namespace drawerbase