From d384a6a8e7629bbcdf19049b9b2411ac85ee23db Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 4 Jun 2017 05:47:57 +0800 Subject: [PATCH] fix issue that graphics::gradual_rectangle modifies fgcolor unexpectedly --- source/detail/mswin/platform_spec.hpp | 3 +-- source/detail/platform_spec_posix.cpp | 29 ------------------------- source/detail/platform_spec_windows.cpp | 5 ----- source/detail/posix/platform_spec.hpp | 3 +-- source/gui/widgets/listbox.cpp | 11 ---------- source/paint/graphics.cpp | 9 +++++--- 6 files changed, 8 insertions(+), 52 deletions(-) diff --git a/source/detail/mswin/platform_spec.hpp b/source/detail/mswin/platform_spec.hpp index 6de8c4e2..ed4b0d9a 100644 --- a/source/detail/mswin/platform_spec.hpp +++ b/source/detail/mswin/platform_spec.hpp @@ -1,7 +1,7 @@ /* * Platform Specification Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -144,7 +144,6 @@ namespace detail drawable_impl_type(); ~drawable_impl_type(); - void fgcolor(const ::nana::color&); //deprecated unsigned get_color() const; unsigned get_text_color() const; void set_color(const ::nana::color&); diff --git a/source/detail/platform_spec_posix.cpp b/source/detail/platform_spec_posix.cpp index 89ea7b8c..0b7e9538 100644 --- a/source/detail/platform_spec_posix.cpp +++ b/source/detail/platform_spec_posix.cpp @@ -423,35 +423,6 @@ namespace detail } } - void drawable_impl_type::fgcolor(const ::nana::color& clr) - { - auto rgb = clr.px_color().value; - - if (rgb != current_color_) - { - auto & spec = nana::detail::platform_spec::instance(); - platform_scope_guard psg; - - current_color_ = rgb; - switch(spec.screen_depth()) - { - case 16: - rgb = ((((rgb >> 16) & 0xFF) * 31 / 255) << 11) | - ((((rgb >> 8) & 0xFF) * 63 / 255) << 5) | - (rgb & 0xFF) * 31 / 255; - break; - } - ::XSetForeground(spec.open_display(), context, rgb); - ::XSetBackground(spec.open_display(), context, rgb); -#if defined(NANA_USE_XFT) - xft_fgcolor.color.red = ((0xFF0000 & rgb) >> 16) * 0x101; - xft_fgcolor.color.green = ((0xFF00 & rgb) >> 8) * 0x101; - xft_fgcolor.color.blue = (0xFF & rgb) * 0x101; - xft_fgcolor.color.alpha = 0xFFFF; -#endif - } - } - platform_scope_guard::platform_scope_guard() { platform_spec::instance().lock_xlib(); diff --git a/source/detail/platform_spec_windows.cpp b/source/detail/platform_spec_windows.cpp index 3e4e044b..eb58c603 100644 --- a/source/detail/platform_spec_windows.cpp +++ b/source/detail/platform_spec_windows.cpp @@ -221,11 +221,6 @@ namespace detail ::DeleteObject(round_region.handle); } - void drawable_impl_type::fgcolor(const ::nana::color& clr) - { - set_text_color(clr); - } - unsigned drawable_impl_type::get_color() const { return color_; diff --git a/source/detail/posix/platform_spec.hpp b/source/detail/posix/platform_spec.hpp index f1f32448..2ada1eac 100644 --- a/source/detail/posix/platform_spec.hpp +++ b/source/detail/posix/platform_spec.hpp @@ -1,7 +1,7 @@ /* * Platform Specification Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -101,7 +101,6 @@ namespace detail drawable_impl_type(); ~drawable_impl_type(); - void fgcolor(const ::nana::color&); //deprecated unsigned get_color() const; unsigned get_text_color() const; void set_color(const ::nana::color&); diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 1b33d880..3aa2262f 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2248,7 +2248,6 @@ namespace nana if (seq.empty()) return 0; - //return (header.position(seq[0], nullptr) - this->content_view->origin().x + r.x); //deprecated return header.range(seq.front()).first + r.x - this->content_view->origin().x; } @@ -3226,14 +3225,10 @@ namespace nana auto i = essence_->header.column_from_point(x); if (i == npos) - //i = essence_->header.boundary(essence_->header.position(grab, nullptr) >= x); //deprecated i = essence_->header.boundary(essence_->header.range(grab).first >= x); if(grab != i) { - //unsigned item_pixels = 0; - //auto item_x = essence_->header.position(i, &item_pixels); //deprecated - auto item_rg = essence_->header.range(i); //Get the item pos @@ -3319,7 +3314,6 @@ namespace nana _m_draw_header_item(fl_graph, margin, rectangle{ fl_graph.size()}, colors::white, col, item_state::floated); - //auto xpos = essence_->header.position(col.index, nullptr) + pos.x - grabs_.start_pos; //deprecated auto xpos = essence_->header.range(col.index).first + pos.x - grabs_.start_pos; essence_->graph->blend(rectangle{ point{ xpos - essence_->content_view->origin().x + rect.x, rect.y } , fl_graph.size() }, fl_graph, {}, 0.5); } @@ -3405,7 +3399,6 @@ namespace nana auto & ptr_where = essence_->pointer_where; - //int item_top = rect.y - (origin.y % item_height_px); //deprecated auto first_disp = essence_->first_display(); point item_coord{ @@ -3444,8 +3437,6 @@ namespace nana ind->detach(); } - //const int x = essence_->item_xpos(rect); //deprecated - //Here we draw the root categ (0) or a first item if the first drawing is not a categ.(item!=npos)) if (idx.cat == 0 || !idx.is_category()) { @@ -3579,7 +3570,6 @@ namespace nana //Draw selecting inner rectangle if (item.flags.selected && (categ.expand == false)) - //_m_draw_item_border(r.x, y, (std::min)(r.width, width - essence_->content_view->origin().x)); //deprecated _m_draw_item_border(y); } @@ -3816,7 +3806,6 @@ namespace nana //Draw selecting inner rectangle if (item.flags.selected) - //_m_draw_item_border(content_r.x, coord.y, show_w); //deprecated _m_draw_item_border(coord.y); } diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index b3bedd40..18a9df2a 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -1208,7 +1208,8 @@ namespace paint unsigned last_color = (int(r) << 16) | (int(g) << 8) | int(b); Display * disp = nana::detail::platform_spec::instance().open_display(); - impl_->handle->fgcolor(static_cast(last_color)); + impl_->handle->set_color(static_cast(last_color)); + impl_->handle->update_color(); const int endpos = deltapx + (vertical ? rct.y : rct.x); if (endpos > 0) { @@ -1223,7 +1224,8 @@ namespace paint if (new_color != last_color) { last_color = new_color; - impl_->handle->fgcolor(static_cast(last_color)); + impl_->handle->set_color(static_cast(last_color)); + impl_->handle->update_color(); } } } @@ -1238,7 +1240,8 @@ namespace paint if (new_color != last_color) { last_color = new_color; - impl_->handle->fgcolor(static_cast(last_color)); + impl_->handle->set_color(static_cast(last_color)); + impl_->handle->update_color(); } } }