diff --git a/include/nana/gui/widgets/skeletons/text_editor.hpp b/include/nana/gui/widgets/skeletons/text_editor.hpp index 1efa6638..e1edf261 100644 --- a/include/nana/gui/widgets/skeletons/text_editor.hpp +++ b/include/nana/gui/widgets/skeletons/text_editor.hpp @@ -207,6 +207,7 @@ namespace nana{ namespace widgets /// Returns width of text area excluding the vscroll size. unsigned width_pixels() const; + window window_handle() const; public: void draw_scroll_rectangle(); void render(bool focused); diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp index bf8a972d..16c95aac 100644 --- a/include/nana/gui/widgets/textbox.hpp +++ b/include/nana/gui/widgets/textbox.hpp @@ -82,11 +82,6 @@ namespace nana void _m_text_area(unsigned width, unsigned height); private: widget* widget_; - struct status_type - { - bool has_focus; //Indicates whether it has the keyboard focus - }status_; - std::function pred_acceptive_; widgets::skeletons::text_editor * editor_; std::unique_ptr evt_agent_; diff --git a/include/nana/paint/gadget.hpp b/include/nana/paint/gadget.hpp index 6a900548..8709258b 100644 --- a/include/nana/paint/gadget.hpp +++ b/include/nana/paint/gadget.hpp @@ -21,12 +21,6 @@ namespace paint { namespace gadget { - struct directions - { - enum t{to_east, to_southeast, to_south, to_southwest, to_west, to_northwest, to_north, to_northeast}; - }; - - void arrow_16_pixels(nana::paint::graphics&, int x, int y, const color&, uint32_t style, directions::t direction); void close_16_pixels(nana::paint::graphics&, int x, int y, uint32_t style, const color&); void cross(nana::paint::graphics&, int x, int y, uint32_t size, uint32_t thickness, const nana::color&); diff --git a/source/gui/element.cpp b/source/gui/element.cpp index a44c95af..6535f01d 100644 --- a/source/gui/element.cpp +++ b/source/gui/element.cpp @@ -316,7 +316,7 @@ namespace nana bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, ::nana::direction dir) override { int x = r.x + 3; - int y = r.x + 3; + int y = r.y + 3; switch (dir) { case ::nana::direction::east: diff --git a/source/gui/widgets/categorize.cpp b/source/gui/widgets/categorize.cpp index 1fd6c9a3..d07a356b 100644 --- a/source/gui/widgets/categorize.cpp +++ b/source/gui/widgets/categorize.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -85,23 +86,24 @@ namespace nana virtual void root_arrow(graph_reference graph, const nana::rectangle& r, mouse_action state) { - int x = r.x + (r.width - 16) / 2; - int y = r.y + (r.height - 16) / 2; + ::nana::rectangle arrow_r{r.x + static_cast(r.width - 16) / 2, r.y + static_cast(r.height - 16) / 2, 16, 16}; + if(ui_el_.what == ui_el_.item_root) { _m_item_bground(graph, r.x + 1, r.y, r.width - 2, r.height, (state == mouse_action::pressed ? mouse_action::pressed : mouse_action::over)); graph.rectangle(r, false, color{ 0x3C, 0x7F, 0xB1 }); if(state == mouse_action::pressed) { - ++x; - ++y; + ++arrow_r.x; + ++arrow_r.y; } } else graph.rectangle(r, true, style_.bgcolor); - nana::paint::gadget::arrow_16_pixels(graph, x, y, - style_.fgcolor, 3, nana::paint::gadget::directions::to_west); + facade arrow("double"); + arrow.direction(::nana::direction::west); + arrow.draw(graph, {}, style_.fgcolor, arrow_r, element_state::normal); } void item(graph_reference graph, const nana::rectangle& r, std::size_t index, const nana::string& name, unsigned txtheight, bool has_child, mouse_action state) @@ -144,8 +146,9 @@ namespace nana if(has_child) { - nana::paint::gadget::arrow_16_pixels(graph, r.x + r.width - 16, r.y + (r.height - 16)/2, - style_.fgcolor, 3, nana::paint::gadget::directions::to_east); + facade arrow("double"); + arrow.direction(::nana::direction::east); + arrow.draw(graph, {}, style_.fgcolor, { r.right() - 16, r.y + static_cast(r.height - 16) / 2, 16, 16 }, element_state::normal); } } diff --git a/source/gui/widgets/combox.cpp b/source/gui/widgets/combox.cpp index dcd8aad8..6dbd0101 100644 --- a/source/gui/widgets/combox.cpp +++ b/source/gui/widgets/combox.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -494,7 +495,9 @@ namespace nana graph_->rectangle({ left + 1, top, static_cast(right - left - 2), static_cast(mid - top + 1) }, true, topcol); graph_->rectangle({ left + 1, mid + 1, static_cast(right - left - 2), static_cast(bottom - mid) }, true, botcol); - gadget::arrow_16_pixels(*graph_, left, top + ((bottom - top) / 2) - 7, arrow_color, 1, gadget::directions::to_south); + facade arrow("solid_triangle"); + arrow.direction(::nana::direction::south); + arrow.draw(*graph_, {}, arrow_color, { left, top + (bottom - top) / 2 - 7, 16, 16 }, element_state::normal); } void _m_draw_image() diff --git a/source/gui/widgets/date_chooser.cpp b/source/gui/widgets/date_chooser.cpp index 3aff4923..031ec41b 100644 --- a/source/gui/widgets/date_chooser.cpp +++ b/source/gui/widgets/date_chooser.cpp @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -122,13 +123,16 @@ namespace nana void trigger::_m_draw_topbar(graph_reference graph) { - int ypos = (topbar_height - 16) / 2 + 1; - - const auto color = color_.normal; - - nana::paint::gadget::arrow_16_pixels(graph, border_size, ypos, (pos_ == where::left_button ? color_.highlight : color), 1, nana::paint::gadget::directions::to_west); - nana::paint::gadget::arrow_16_pixels(graph, graph.width() - (border_size + 16 + 1), ypos, (pos_ == where::right_button ? color_.highlight : color), 1, nana::paint::gadget::directions::to_east); + ::nana::color arrow_bgcolor; + ::nana::rectangle arrow_r{ static_cast(border_size), (topbar_height - 16) / 2 + 1, 16, 16 }; + facade arrow("solid_triangle"); + arrow.direction(::nana::direction::west); + arrow.draw(graph, arrow_bgcolor, (pos_ == where::left_button ? color_.highlight : color_.normal), arrow_r, element_state::normal); + arrow_r.x = static_cast(graph.width()) - static_cast(border_size + 17); + arrow.direction(::nana::direction::east); + arrow.draw(graph, arrow_bgcolor, (pos_ == where::right_button ? color_.highlight : color_.normal), arrow_r, element_state::normal); + if(graph.width() > 32 + border_size * 2) { std::stringstream ss; @@ -143,12 +147,12 @@ namespace nana nana::size txt_s = graph.text_extent_size(str); - ypos = (topbar_height - static_cast(txt_s.height)) / 2 + 1; + int top = (topbar_height - static_cast(txt_s.height)) / 2 + 1; int xpos = static_cast(graph.width() - txt_s.width) / 2; if(xpos < border_size + 16) xpos = 16 + border_size + 1; - graph.string({ xpos, ypos }, str, (pos_ == where::topbar ? color_.highlight : color)); + graph.string({ xpos, top }, str, (pos_ == where::topbar ? color_.highlight : color_.normal)); } } diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 828d4be2..853d1f50 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2308,8 +2308,9 @@ namespace nana if(item.index == essence_->lister.sort_index()) { - nana::paint::gadget::directions::t dir = essence_->lister.sort_reverse() ? nana::paint::gadget::directions::to_south : nana::paint::gadget::directions::to_north; - nana::paint::gadget::arrow_16_pixels(graph, x + (item.pixels - 16) / 2, -4, colors::black, 0, dir); + facade arrow("hollow_triangle"); + arrow.direction(essence_->lister.sort_reverse() ? ::nana::direction::south : ::nana::direction::north); + arrow.draw(graph, {}, colors::black, { x + static_cast(item.pixels - 16) / 2, -4, 16, 16 }, element_state::normal); } } @@ -2483,8 +2484,10 @@ namespace nana graph->set_color(bgcolor); graph->rectangle(rectangle{ x, y, width, essence_->item_size }, true); - nana::paint::gadget::arrow_16_pixels(*graph, x + 5, y + (essence_->item_size - 16) / 2, { 0x0, 0x33, 0x99 }, 2, (categ.expand ? nana::paint::gadget::directions::to_north : nana::paint::gadget::directions::to_south)); - nana::size text_s = graph->text_extent_size(categ.text); + facade arrow("double"); + arrow.direction(categ.expand ? ::nana::direction::north : ::nana::direction::south); + ::nana::rectangle arrow_r{ x + 5, y + static_cast(essence_->item_size - 16) / 2, 16, 16 }; + arrow.draw(*graph, {}, static_cast(0x3399), arrow_r, element_state::normal); graph->string({ x + 20, y + txtoff }, categ.text, {0, 0x33, 0x99}); @@ -2494,6 +2497,7 @@ namespace nana unsigned str_w = graph->text_extent_size(str).width; + auto text_s = graph->text_extent_size(categ.text); graph->string({ x + 25 + static_cast(text_s.width), y + txtoff }, str); if (x + 35 + text_s.width + str_w < x + width) diff --git a/source/gui/widgets/menu.cpp b/source/gui/widgets/menu.cpp index 02dfa28a..4279264c 100644 --- a/source/gui/widgets/menu.cpp +++ b/source/gui/widgets/menu.cpp @@ -158,7 +158,9 @@ namespace nana void sub_arrow(graph_reference graph, const nana::point& pos, unsigned pixels, const attr&) { - nana::paint::gadget::arrow_16_pixels(graph, pos.x, pos.y + static_cast(pixels - 16) / 2, colors::black, 0, nana::paint::gadget::directions::to_east); + facade arrow("hollow_triangle"); + arrow.direction(::nana::direction::east); + arrow.draw(graph, {}, colors::black, { pos.x, pos.y + static_cast(pixels - 16) / 2, 16, 16 }, element_state::normal); } private: diff --git a/source/gui/widgets/scroll.cpp b/source/gui/widgets/scroll.cpp index 18808c39..3b1d5acb 100644 --- a/source/gui/widgets/scroll.cpp +++ b/source/gui/widgets/scroll.cpp @@ -11,6 +11,7 @@ */ #include +#include namespace nana { @@ -291,35 +292,40 @@ namespace nana { if(_m_check()) _m_button_frame(graph, r, state); - - using namespace nana::paint::gadget; if(buttons::first == what || buttons::second == what) { - nana::size sz = graph.size(); - directions::t dir; - if(buttons::second == what) + auto sz = graph.size(); + int top = static_cast(sz.height - fixedsize); + int left = static_cast(sz.width - fixedsize); + + direction dir; + if (buttons::second == what) { - if(vertical_) + if (vertical_) { - r.y = static_cast(sz.height - fixedsize); - dir = directions::to_south; + r.y = top; + dir = direction::south; } else { - r.x = static_cast(sz.width - fixedsize); - dir = directions::to_east; + r.x = left; + dir = direction::east; } } else - dir = vertical_ ? directions::to_north : directions::to_west; + dir = vertical_ ? direction::north : direction::west; - if(vertical_) - r.x = (static_cast(sz.width) - 16) / 2; + if (vertical_) + r.x = left / 2; else - r.y = (static_cast(sz.height) - 16) / 2; - - arrow_16_pixels(graph, r.x, r.y, (_m_check() ? color(colors::black) : color(0x80, 0x80, 0x80)), (states::none == state ? 0 : 1), dir); + r.y = top / 2; + + r.width = r.height = 16; + + facade arrow(states::none == state ? "hollow_triangle" : "solid_triangle"); + arrow.direction(dir); + arrow.draw(graph, {}, (_m_check() ? colors::black : colors::gray), r, element_state::normal); } } //end class drawer diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 89f43b9c..fde51b77 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -1842,6 +1842,11 @@ namespace nana{ namespace widgets return (text_area_.area.width > caret_px ? text_area_.area.width - caret_px : 0); } + window text_editor::window_handle() const + { + return window_; + } + void text_editor::draw_scroll_rectangle() { if(text_area_.vscroll && text_area_.hscroll) diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index 52324979..9d69b7b6 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -145,36 +146,39 @@ namespace nana virtual void back(graph_reference graph, const nana::rectangle& r, state_t sta) { using namespace nana::paint::gadget; - _m_draw_arrow(graph, r, sta, directions::to_west); + _m_draw_arrow(graph, r, sta, direction::west); } virtual void next(graph_reference graph, const nana::rectangle& r, state_t sta) { using namespace nana::paint::gadget; - _m_draw_arrow(graph, r, sta, directions::to_east); + _m_draw_arrow(graph, r, sta, direction::east); } virtual void list(graph_reference graph, const nana::rectangle& r, state_t sta) { using namespace nana::paint::gadget; - _m_draw_arrow(graph, r, sta, directions::to_south); + _m_draw_arrow(graph, r, sta, direction::south); } private: - void _m_draw_arrow(graph_reference graph, const nana::rectangle& r, state_t sta, nana::paint::gadget::directions::t dir) + void _m_draw_arrow(graph_reference graph, const nana::rectangle& r, state_t sta, ::nana::direction dir) { - using namespace nana::paint::gadget; - - ::nana::color fgcolor(colors::black); - int style = 1; - if(sta == item_renderer::disable) + facade arrow("solid_triangle"); + arrow.direction(dir); + colors fgcolor = colors::black; + if (item_renderer::disable == sta) { - style = 0; - fgcolor = { 0x80, 0x80, 0x80 }; + arrow.switch_to("hollow_triangle"); + fgcolor = colors::gray; } - arrow_16_pixels(graph, r.x + (r.width - 16) / 2, r.y + (r.height - 16) / 2, fgcolor, style, dir); + auto arrow_r = r; + arrow_r.x += static_cast(arrow_r.width - 16) / 2; + arrow_r.y += static_cast(arrow_r.height - 16) / 2; + arrow_r.width = arrow_r.height = 16; + arrow.draw(graph, bgcolor_, fgcolor, arrow_r, element_state::normal); if(item_renderer::highlight == sta) - graph.rectangle(r, false, { 0xA0, 0xA0, 0xA0 }); + graph.rectangle(r, false, colors::dark_gray); } private: ::nana::color bgcolor_; diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index 5e6b1e5a..ac084912 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -33,7 +33,6 @@ namespace nana{ namespace drawerbase { drawer::drawer() : widget_(nullptr), editor_(nullptr) { - status_.has_focus = false; } drawer::text_editor* drawer::editor() @@ -78,15 +77,14 @@ namespace nana{ namespace drawerbase { void drawer::refresh(graph_reference graph) { - editor_->render(status_.has_focus); + editor_->render(API::is_focus_window(*widget_)); } void drawer::focus(graph_reference graph, const arg_focus& arg) { - status_.has_focus = arg.getting; refresh(graph); - editor_->show_caret(status_.has_focus); + editor_->show_caret(arg.getting); editor_->reset_caret(); API::lazy_refresh(); } diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index cd509316..ace4711a 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -1122,16 +1122,17 @@ namespace nana comp_attribute_t attr; if(compset->comp_attribute(component::expender, attr)) { - using namespace nana::paint; - - uint32_t style = 1; - gadget::directions::t dir = gadget::directions::to_southeast; - if(! compset->item_attribute().expended) + facade arrow("solid_triangle"); + arrow.direction(direction::southeast); + if (!compset->item_attribute().expended) { - style = 0; - dir = gadget::directions::to_east; + arrow.switch_to("hollow_triangle"); + arrow.direction(direction::east); } - gadget::arrow_16_pixels(graph, attr.area.x, attr.area.y + (attr.area.height - 16) / 2, (attr.mouse_pointed ? color(0x1C, 0xC4, 0xF7) : color(colors::black)), style, dir); + auto r = attr.area; + r.y += (attr.area.height - 16) / 2; + r.width = r.height = 16; + arrow.draw(graph, bgcolor_, (attr.mouse_pointed ? colors::deep_sky_blue : colors::black), r, element_state::normal); } } diff --git a/source/paint/gadget.cpp b/source/paint/gadget.cpp index 3810b1e6..75298919 100644 --- a/source/paint/gadget.cpp +++ b/source/paint/gadget.cpp @@ -19,217 +19,6 @@ namespace paint { namespace gadget { - namespace detail - { - typedef nana::paint::graphics& graph_reference; - - void hollow_triangle(graph_reference graph, int x, int y, uint32_t direction) - { - x += 3; - y += 3; - switch (direction) - { - case directions::to_east: - graph.line(point{ x + 3, y + 1 }, point{ x + 3, y + 9 }); - graph.line(point{ x + 4, y + 2 }, point{ x + 7, y + 5 }); - graph.line(point{ x + 6, y + 6 }, point{ x + 4, y + 8 }); - break; - case directions::to_southeast: - graph.line(point{ x + 2, y + 7 }, point{ x + 7, y + 7 }); - graph.line(point{ x + 7, y + 2 }, point{ x + 7, y + 6 }); - graph.line(point{ x + 3, y + 6 }, point{ x + 6, y + 3 }); - break; - case directions::to_south: - y += 3; - graph.line(point{ x, y }, point{ x + 8, y }); - graph.line(point{ x + 1, y + 1 }, point{ x + 4, y + 4 }); - graph.line(point{ x + 7, y + 1 }, point{ x + 5, y + 3 }); - break; - case directions::to_west: - x += 5; - y += 1; - graph.line(point{ x, y }, point{ x, y + 8 }); - graph.line(point{ x - 4, y + 4 }, point{ x - 1, y + 1 }); - graph.line(point{ x - 3, y + 5 }, point{ x - 1, y + 7 }); - break; - case directions::to_north: - y += 7; - graph.line(point{ x, y }, point{x + 8, y}); - graph.line(point{x + 1, y - 1}, point{x + 4, y - 4}); - graph.line(point{x + 5, y - 3}, point{x + 7, y - 1}); - break; - } - } - - void solid_triangle(graph_reference graph, int x, int y, uint32_t dir) - { - x += 3; - y += 3; - switch(dir) - { - case directions::to_east: - for(int i = 0; i < 5; ++i) - graph.line(point{ x + 3 + i, y + 1 + i }, point{ x + 3 + i, y + 9 - i }); - break; - case directions::to_southeast: - for(int i = 0; i < 6; ++i) - graph.line(point{ x + 2 + i, y + 7 - i }, point{ x + 7, y + 7 - i }); - break; - case directions::to_south: - y += 3; - for(int i = 0; i < 5; ++i) - graph.line(point{ x + i, y + i }, point{ x + 8 - i, y + i }); - break; - case directions::to_west: - x += 5; - y += 1; - for(int i = 0; i < 5; ++i) - graph.line(point{ x - i, y + i }, point{ x - i, y + 8 - i }); - break; - case directions::to_north: - y += 7; - for(int i = 0; i < 5; ++i) - graph.line(point{ x + i, y - i }, point{ x + 8 - i, y - i }); - break; - } - } - - void direction_arrow(graph_reference graph, int x, int y, uint32_t dir) - { - graph.set_color({ 0x0, 0x2, 0x62 }); - y += 5; - switch(dir) - { - case directions::to_north: - { - x += 3; - int pixels = 1; - for(int l = 0; l < 4; ++l) - { - for(int i = 0; i < pixels; ++i) - { - if(l ==3 && i == 3) - {} - else - graph.set_pixel(x + i, y); - } - - x--; - y++; - pixels += 2; - } - - graph.set_pixel(x + 1, y); - graph.set_pixel(x + 2, y); - graph.set_pixel(x + 6, y); - graph.set_pixel(x + 7, y); - } - break; - case directions::to_south: - { - - graph.set_pixel(x, y); - graph.set_pixel(x + 1, y); - graph.set_pixel(x + 5, y); - graph.set_pixel(x + 6, y); - - ++y; - int pixels = 7; - for (int l = 0; l < 4; ++l) - { - for (int i = 0; i < pixels; ++i) - { - if (l != 0 || i != 3) - graph.set_pixel(x + i, y); - } - - x++; - y++; - pixels -= 2; - } - } - break; - } - } - - void double_arrow_line(nana::paint::graphics & graph, int x, int y, bool horizontal) - { - graph.set_pixel(x, y); - if(horizontal) - { - graph.set_pixel(x + 1, y); - graph.set_pixel(x + 4, y); - graph.set_pixel(x + 5, y); - } - else - { - graph.set_pixel(x, y + 1); - graph.set_pixel(x, y + 4); - graph.set_pixel(x, y + 5); - } - } - - void double_arrow(nana::paint::graphics& graph, int x, int y, directions::t dir) - { - switch(dir) - { - case directions::to_east: - double_arrow_line(graph, x + 4, y + 6, true); - double_arrow_line(graph, x + 5, y + 7, true); - double_arrow_line(graph, x + 6, y + 8, true); - double_arrow_line(graph, x + 5, y + 9, true); - double_arrow_line(graph, x + 4, y + 10, true); - break; - case directions::to_west: - double_arrow_line(graph, x + 5, y + 6, true); - double_arrow_line(graph, x + 4, y + 7, true); - double_arrow_line(graph, x + 3, y + 8, true); - double_arrow_line(graph, x + 4, y + 9, true); - double_arrow_line(graph, x + 5, y + 10, true); - break; - case directions::to_south: - double_arrow_line(graph, x + 5, y + 4, false); - double_arrow_line(graph, x + 6, y + 5, false); - double_arrow_line(graph, x + 7, y + 6, false); - double_arrow_line(graph, x + 8, y + 5, false); - double_arrow_line(graph, x + 9, y + 4, false); - break; - case directions::to_north: - double_arrow_line(graph, x + 5, y + 6, false); - double_arrow_line(graph, x + 6, y + 5, false); - double_arrow_line(graph, x + 7, y + 4, false); - double_arrow_line(graph, x + 8, y + 5, false); - double_arrow_line(graph, x + 9, y + 6, false); - break; - default: - break; - } - } - }//end namespace detail - - //arrow_16_pixels - //param@style: 0 = hollow, 1 = solid - void arrow_16_pixels(nana::paint::graphics& graph, int x, int y, const nana::color& clr, uint32_t style, directions::t dir) - { - graph.set_color(clr); - switch(style) - { - case 1: - detail::solid_triangle(graph, x, y, dir); - break; - case 2: - detail::direction_arrow(graph, x, y, dir); - break; - case 3: - detail::double_arrow(graph, x, y, dir); - break; - case 0: - default: - detail::hollow_triangle(graph, x, y, dir); - break; - } - } - void close_16_pixels(::nana::paint::graphics& graph, int x, int y, uint32_t style, const ::nana::color& clr) { graph.set_color(clr); diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index da30c08f..4f558723 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -968,13 +968,14 @@ namespace paint void graphics::line(const nana::point& pos1, const nana::point& pos2) { - if ((!handle_) || (pos1 == pos2)) return; + if (!handle_) return; #if defined(NANA_WINDOWS) handle_->update_pen(); - - ::MoveToEx(handle_->context, pos1.x, pos1.y, 0); - ::LineTo(handle_->context, pos2.x, pos2.y); - + if (pos1 != pos2) + { + ::MoveToEx(handle_->context, pos1.x, pos1.y, 0); + ::LineTo(handle_->context, pos2.x, pos2.y); + } ::SetPixel(handle_->context, pos2.x, pos2.y, NANA_RGB(handle_->pen.color)); #elif defined(NANA_X11) Display* disp = nana::detail::platform_spec::instance().open_display();