From a2a7d1fc378d7c3713d46e3c9b7493bab0d2a4ab Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 3 Jan 2016 17:50:10 +0800 Subject: [PATCH] remove deprecated components --- include/nana/gui/programming_interface.hpp | 11 ++-- include/nana/gui/widgets/tabbar.hpp | 67 +++----------------- include/nana/paint/graphics.hpp | 3 - source/gui/element.cpp | 25 ++++---- source/gui/place_parts.hpp | 5 +- source/gui/programming_interface.cpp | 59 +++++++++-------- source/gui/widgets/button.cpp | 15 ++--- source/gui/widgets/categorize.cpp | 4 +- source/gui/widgets/checkbox.cpp | 6 +- source/gui/widgets/date_chooser.cpp | 8 +-- source/gui/widgets/float_listbox.cpp | 8 +-- source/gui/widgets/listbox.cpp | 22 +++---- source/gui/widgets/menu.cpp | 12 ++-- source/gui/widgets/menubar.cpp | 5 +- source/gui/widgets/scroll.cpp | 2 +- source/gui/widgets/skeletons/text_editor.cpp | 37 ++++++----- source/gui/widgets/slider.cpp | 3 +- source/gui/widgets/tabbar.cpp | 12 ++-- source/gui/widgets/toolbar.cpp | 8 +-- source/paint/graphics.cpp | 22 ++----- source/paint/text_renderer.cpp | 2 +- 21 files changed, 127 insertions(+), 209 deletions(-) diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index f1caf871..1faba2a9 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -83,6 +83,9 @@ namespace API paint::graphics* window_graphics(window); void delay_restore(bool); + + void register_menu_window(window, bool has_keyboard); + void set_menubar(window wd, bool attach); }//end namespace dev @@ -310,8 +313,8 @@ namespace API void eat_tabstop(window, bool); window move_tabstop(window, bool next); ///< Sets the focus to the window which tabstop is near to the specified window. - bool glass_window(window); /// \deprecated - bool glass_window(window, bool); /// \deprecated + //bool glass_window(window); //deprecated + //bool glass_window(window, bool); //deprecated /// Sets the window active state. If a window active state is false, the window will not obtain the focus when a mouse clicks on it wich will be obteined by take_if_has_active_false. void take_active(window, bool has_active, window take_if_has_active_false); @@ -328,10 +331,6 @@ namespace API window find_window(const nana::point& mspos); - void register_menu_window(window, bool has_keyboard); - bool attach_menubar(window menubar); - void detach_menubar(window menubar); - bool is_window_zoomed(window, bool ask_for_max); /// - struct button_container - { - typedef meta::fixed_type_set type_set; - }; - - enum class kits - { - add, ///< The type identifies the add button of the tabbar's toolbox. - scroll, ///< The type identifies the scroll button of the tabbar's toolbox - list, ///< The type identifies the list button of the tabbar's toolbox - close ///< The type identifies the close button of the tabbar's toolbox - }; + using value_type = Type; ///< The type of element data which is stored in the tabbar. + using item_renderer = drawerbase::tabbar::item_renderer; ///< A user-defined item renderer should be derived from this interface. + using kits = drawer_trigger_t::kits; tabbar() { @@ -324,12 +303,6 @@ namespace nana API::update_window(*this); } - //deprecated from 1.2.1, removed from 1.3 - void relate(std::size_t pos, window wd) /// Binds a window to an item specified by pos, if the item is selected, shows the window, otherwise, hides it. - { - this->get_drawer_trigger().attach(pos, wd); - } - void attach(std::size_t pos, window attach_wd) { if (attach_wd && API::empty_window(attach_wd)) @@ -357,32 +330,8 @@ namespace nana { this->get_drawer_trigger().tab_image(pos, img); } + /// Sets buttons of the tabbar's toolbox, refer to notes for more details. - template - void toolbox(const button_container&, bool enable) - { - typedef typename button_container::type_set type_set; - auto & tg = this->get_drawer_trigger(); - bool redraw = false; - - using inner_kits = drawerbase::tabbar::trigger::kits; - - if(type_set::template count::value) - redraw |= tg.toolbox(inner_kits::add, enable); - - if(type_set::template count::value) - redraw |= tg.toolbox(inner_kits::scroll, enable); - - if(type_set::template count::value) - redraw |= tg.toolbox(inner_kits::add, enable); - - if(type_set::template count::value) - redraw |= tg.toolbox(inner_kits::close, enable); - - if(redraw) - API::refresh_window(this->handle()); - } - void toolbox(kits kit, bool enable) { if (this->get_drawer_trigger().toolbox(kit, enable)) diff --git a/include/nana/paint/graphics.hpp b/include/nana/paint/graphics.hpp index ef2f37f1..501d30fc 100644 --- a/include/nana/paint/graphics.hpp +++ b/include/nana/paint/graphics.hpp @@ -138,9 +138,6 @@ namespace nana /// @param file_utf8 A UTF-8 string to a filename void save_as_file(const char* file_utf8) const throw(); - void set_color(const ::nana::color&); //deprecated, graphics::palette() instead - void set_text_color(const ::nana::color&); //deprecated, graphics::palette() instead - ::nana::color palette(bool for_text) const; graphics& palette(bool for_text, const ::nana::color&); diff --git a/source/gui/element.cpp b/source/gui/element.cpp index 4271a4d2..b2fdbb7f 100644 --- a/source/gui/element.cpp +++ b/source/gui/element.cpp @@ -173,11 +173,8 @@ namespace nana const int x = r.x + 1; const int y = r.y + 1; - graph.set_color(bld_bgcolor); - graph.rectangle(rectangle{ x + 1, y + 1, 11, 11 }, true); - - graph.set_color(bld_fgcolor); - graph.rectangle(rectangle{ x, y, 13, 13 }, false); + graph.rectangle(rectangle{ x + 1, y + 1, 11, 11 }, true, bld_bgcolor); + graph.rectangle(rectangle{ x, y, 13, 13 }, false, bld_fgcolor); switch(crook_data.check_state) { @@ -252,11 +249,11 @@ namespace nana int x = r.x + (static_cast(r.width) - 16) / 2; int y = r.y + (static_cast(r.height) - 16) / 2; - graph.set_color(fgcolor); + graph.palette(false, fgcolor); graph.line(point{ x + 3, y + 7 }, point{ x + 6, y + 10 }); graph.line(point{ x + 7, y + 9 }, point{ x + 12, y + 4 }); - graph.set_color(fgcolor.blend(colors::white, 0.5)); + graph.palette(false, fgcolor.blend(colors::white, 0.5)); graph.line(point{ x + 3, y + 8 }, point{ x + 6, y + 11 }); graph.line(point{ x + 7, y + 10 }, point{ x + 12, y + 5 }); graph.line(point{ x + 4, y + 7 }, point{ x + 6, y + 9 }); @@ -515,16 +512,16 @@ namespace nana ::nana::point left_mid{ r.x + 1, r.y + 1 + static_cast(part_px) }, right_mid{ right_top.x, left_mid.y }; ::nana::point left_bottom{ r.x + 1, r.bottom() - 2 }, right_bottom{ r.right() - 2, r.bottom() - 2 }; - graph.set_color(bgcolor.blend(colors::white, 0.9)); + graph.palette(false, bgcolor.blend(colors::white, 0.9)); graph.line(left_top, left_mid); graph.line(right_top, right_mid); - graph.set_color(bgcolor.blend(colors::white, 0.5)); + graph.palette(false, bgcolor.blend(colors::white, 0.5)); graph.line(left_top, right_top); left_mid.y++; right_mid.y++; - graph.set_color(bgcolor.blend(colors::black, 0.8)); + graph.palette(false, bgcolor.blend(colors::black, 0.8)); graph.line(left_mid, left_bottom); graph.line(right_mid, right_bottom); @@ -557,7 +554,7 @@ namespace nana break; } - graph.set_color(clr); + graph.palette(false, clr); const int x = r.x + 4; const int y = r.y + 4; @@ -959,13 +956,13 @@ namespace nana ps[11].x = r.x + gap; ps[11].y = r.y + gap; - graph.set_color(fgcolor.blend(colors::black, true)); + graph.palette(false, fgcolor.blend(colors::black, true)); for (int i = 0; i < 11; ++i) graph.line(ps[i], ps[i + 1]); graph.line(ps[11], ps[0]); - graph.set_color(fgcolor); + graph.palette(false, fgcolor); unsigned thk_minus_2 = thickness_ - 2; graph.rectangle(rectangle{ ps[10].x + 1, ps[10].y + 1, (gap << 1) + thk_minus_2, thk_minus_2 }, true); @@ -1010,7 +1007,7 @@ namespace nana //Implement element_interface bool facade::draw(graph_reference graph, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state estate) { - graph.set_color(fgcolor); + graph.palette(false, fgcolor); return (*cite_)->draw(graph, bgcolor, fgcolor, r, estate, dir_); } //end class facade diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index 501dbad9..5daba048 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -79,9 +79,8 @@ namespace nana void refresh(graph_reference& graph) override { - graph.set_color(static_cast(0x83EB)); - graph.set_text_color(colors::white); - graph.rectangle(true); + graph.palette(true, colors::white); + graph.rectangle(true, static_cast(0x83EB)); //draw caption auto text = utf8_cast(API::window_caption(window_handle_)); diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index 02a68fca..2185ebd9 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -280,6 +280,33 @@ namespace API { restrict::bedrock.delay_restore(enable ? 0 : 1); } + + void register_menu_window(window wd, bool has_keyboard) + { + internal_scope_guard lock; + if (restrict::wd_manager().available(reinterpret_cast(wd))) + restrict::bedrock.set_menu(reinterpret_cast(wd)->root, has_keyboard); + } + + void set_menubar(window wd, bool attach) + { + auto iwd = reinterpret_cast(wd); + internal_scope_guard lock; + if (restrict::wd_manager().available(iwd)) + { + auto root_attr = iwd->root_widget->other.attribute.root; + if (attach) + { + if (!root_attr->menubar) + root_attr->menubar = iwd; + } + else + { + if (iwd == root_attr->menubar) + root_attr->menubar = nullptr; + } + } + } }//end namespace dev @@ -1141,6 +1168,7 @@ namespace API return reinterpret_cast(ts_wd); } + /* //glass_window deprecated //@brief: Test a window whether it is a glass attribute. bool glass_window(window wd) @@ -1156,6 +1184,7 @@ namespace API effects_bground_remove(wd); return true; } + */ void take_active(window wd, bool active, window take_if_active_false) { @@ -1247,36 +1276,6 @@ namespace API return nullptr; } - void register_menu_window(window wd, bool has_keyboard) - { - internal_scope_guard lock; - if(restrict::wd_manager().available(reinterpret_cast(wd))) - restrict::bedrock.set_menu(reinterpret_cast(wd)->root, has_keyboard); - } - - bool attach_menubar(window menubar) - { - auto iwd = reinterpret_cast(menubar); - internal_scope_guard lock; - if(restrict::wd_manager().available(iwd) && (nullptr == iwd->root_widget->other.attribute.root->menubar)) - { - iwd->root_widget->other.attribute.root->menubar = iwd; - return true; - } - return false; - } - - void detach_menubar(window menubar) - { - auto iwd = reinterpret_cast(menubar); - internal_scope_guard lock; - if (restrict::wd_manager().available(iwd)) - { - if (iwd->root_widget->other.attribute.root->menubar == iwd) - iwd->root_widget->other.attribute.root->menubar = nullptr; - } - } - bool is_window_zoomed(window wd, bool ask_for_max) { auto const iwd = reinterpret_cast(wd); diff --git a/source/gui/widgets/button.cpp b/source/gui/widgets/button.cpp index 8e3810a0..5e487840 100644 --- a/source/gui/widgets/button.cpp +++ b/source/gui/widgets/button.cpp @@ -248,7 +248,7 @@ namespace nana{ namespace drawerbase ++pos.y; } - graph.set_text_color(attr_.focus_color && attr_.focused ? ::nana::color(colors::blue) : attr_.fgcolor); + graph.palette(true, attr_.focus_color && attr_.focused ? ::nana::color(colors::blue) : attr_.fgcolor); if (attr_.omitted) tr.render(pos, txtptr, txtlen, omitted_pixels, true); @@ -268,23 +268,22 @@ namespace nana{ namespace drawerbase pos.x += off_w; pos.y += static_cast(ascent + 2); - graph.set_color(colors::black); - graph.line(pos, point{ pos.x + static_cast(shortkey_size.width) - 1, pos.y }); + graph.line(pos, point{ pos.x + static_cast(shortkey_size.width) - 1, pos.y }, colors::black); } } else { - graph.set_text_color(::nana::color(colors::white)); + graph.palette(true, ::nana::color(colors::white)); if(attr_.omitted) { tr.render(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen, omitted_pixels, true); - graph.set_text_color(::nana::color(colors::gray)); + graph.palette(true, ::nana::color(colors::gray)); tr.render(pos, txtptr, txtlen, omitted_pixels, true); } else { graph.bidi_string(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen); - graph.set_text_color(::nana::color(colors::gray)); + graph.palette(true, ::nana::color(colors::gray)); graph.bidi_string(pos, txtptr, txtlen); } } @@ -325,10 +324,10 @@ namespace nana{ namespace drawerbase ::nana::color lt(static_cast(0x7f7f7f)), rb(static_cast(0x707070)); graph.frame_rectangle(r, lt, lt, rb, rb); - graph.set_color(colors::button_face); + graph.palette(false, colors::button_face); draw_corner_point(graph, r); - graph.set_color(static_cast(0x919191)); + graph.palette(false, static_cast(0x919191)); draw_corner_point(graph, r.pare_off(1)); if (element_state::pressed == attr_.e_state) diff --git a/source/gui/widgets/categorize.cpp b/source/gui/widgets/categorize.cpp index eb68d29e..5263f7b6 100644 --- a/source/gui/widgets/categorize.cpp +++ b/source/gui/widgets/categorize.cpp @@ -191,12 +191,12 @@ namespace nana int bottom = y + height - 1; int right = x + width - 1; - graph.set_color(static_cast(0x6E8D9F)); + graph.palette(false, static_cast(0x6E8D9F)); graph.line(point{ x, y }, point{right, y}); graph.line(point{ x, y + 1 }, point{ x, bottom }); ++x; ++y; - graph.set_color(color(0xa6, 0xc7, 0xd9)); + graph.palette(false, color(0xa6, 0xc7, 0xd9)); graph.line(point{ x, y }, point{ right, y }); graph.line(point{ x, y + 1 }, point{ x, bottom }); } diff --git a/source/gui/widgets/checkbox.cpp b/source/gui/widgets/checkbox.cpp index 0323a50d..9373e5f7 100644 --- a/source/gui/widgets/checkbox.cpp +++ b/source/gui/widgets/checkbox.cpp @@ -105,12 +105,12 @@ namespace checkbox nana::paint::text_renderer tr(graph); if (API::window_enabled(widget_->handle()) == false) { - graph.set_text_color(colors::white); + graph.palette(true, colors::white); tr.render({ 17 + interval, 2 }, title.c_str(), title.length(), pixels); - graph.set_text_color({ 0x80, 0x80, 0x80 }); + graph.palette(true, { 0x80, 0x80, 0x80 }); } else - graph.set_text_color(widget_->fgcolor()); + graph.palette(true, widget_->fgcolor()); tr.render({ 16 + interval, 1 }, title.c_str(), title.length(), pixels); } diff --git a/source/gui/widgets/date_chooser.cpp b/source/gui/widgets/date_chooser.cpp index c269dddf..97150e06 100644 --- a/source/gui/widgets/date_chooser.cpp +++ b/source/gui/widgets/date_chooser.cpp @@ -111,8 +111,7 @@ namespace nana int xpos = static_cast(graph.width() - txt_s.width) / 2; if(xpos < border_size + 16) xpos = 16 + border_size + 1; - graph.set_text_color(pos_ == where::topbar ? color_.highlight : color_.normal); - graph.string({ xpos, top }, str); + graph.string({ xpos, top }, str, (pos_ == where::topbar ? color_.highlight : color_.normal)); } } @@ -167,9 +166,8 @@ namespace nana if(false == primary) color = { 0xB0, 0xB0, 0xB0 }; - nana::size txt_s = graph.text_extent_size(str_utf8); - graph.set_text_color(color); - graph.string({ r.x + static_cast(r.width - txt_s.width) / 2, r.y + static_cast(r.height - txt_s.height) / 2 }, str_utf8); + auto txt_s = graph.text_extent_size(str_utf8); + graph.string({ r.x + static_cast(r.width - txt_s.width) / 2, r.y + static_cast(r.height - txt_s.height) / 2 }, str_utf8, color); } void trigger::_m_draw_pos(drawing_basis & dbasis, graph_reference graph, int x, int y, int number, bool primary, bool sel) diff --git a/source/gui/widgets/float_listbox.cpp b/source/gui/widgets/float_listbox.cpp index 1fde5065..d2591ac0 100644 --- a/source/gui/widgets/float_listbox.cpp +++ b/source/gui/widgets/float_listbox.cpp @@ -39,7 +39,7 @@ namespace nana auto right = r.right() - 1; auto bottom = r.bottom() - 1; - graph.set_color(colors::white); + graph.palette(false, colors::white); graph.set_pixel(r.x, r.y); graph.set_pixel(right, r.y); graph.set_pixel(r.x, bottom); @@ -47,7 +47,7 @@ namespace nana --right; --bottom; - graph.set_color(clr); + graph.palette(false, clr); graph.set_pixel(r.x + 1, r.y + 1); graph.set_pixel(right, r.y + 1); graph.set_pixel(r.x + 1, bottom); @@ -103,8 +103,8 @@ namespace nana } x += (image_pixels_ + 2); } - graph.set_text_color(colors::black); - graph.string({ x, r.y + 2 }, item->text()); + + graph.string({ x, r.y + 2 }, item->text(), colors::black); } unsigned item_pixels(graph_reference graph) const diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index b9a458e1..db0af9d3 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2855,7 +2855,7 @@ namespace nana auto fgcolor = wdptr->fgcolor(); unsigned header_w = essence_->header.pixels(); - essence_->graph->set_color(bgcolor); + essence_->graph->palette(false, bgcolor); if(header_w - essence_->scroll.offset_x < rect.width) essence_->graph->rectangle(rectangle{ point(rect.x + static_cast(header_w)-essence_->scroll.offset_x, rect.y), size(static_cast(rect.width) + essence_->scroll.offset_x - static_cast(header_w), rect.height) }, @@ -3154,31 +3154,28 @@ namespace nana if (item_state::highlighted == state) it_bgcolor = it_bgcolor.blend(static_cast(0x99defd), 0.8); - graph->set_color(it_bgcolor); - - graph->rectangle(rectangle{ item_xpos, y, header.pixels, essence_->item_size }, true); + graph->rectangle(rectangle{ item_xpos, y, header.pixels, essence_->item_size }, true, it_bgcolor); cell_txtcolor = m_cell.custom_format->fgcolor; } if (draw_column) { - graph->set_text_color(cell_txtcolor); - graph->string(point{ item_xpos + content_pos, y + txtoff }, m_cell.text); // draw full text of the cell index (column) + graph->string(point{ item_xpos + content_pos, y + txtoff }, m_cell.text, cell_txtcolor); // draw full text of the cell index (column) if (static_cast(ts.width) > static_cast(header.pixels) - (content_pos + item_xpos)) // it was an excess { //The text is painted over the next subitem // here beging the ... int xpos = item_xpos + static_cast(header.pixels) - static_cast(essence_->suspension_width); - graph->set_color(it_bgcolor); // litter rect with the item bg end ... - graph->rectangle(rectangle{ xpos, y + 2, essence_->suspension_width, essence_->item_size - 4 }, true); + // litter rect with the item bg end ... + graph->rectangle(rectangle{ xpos, y + 2, essence_->suspension_width, essence_->item_size - 4 }, true, it_bgcolor); graph->string(point{ xpos, y + 2 }, L"..."); //Erase the part that over the next subitem only if the right of column is less than right of listbox if (item_xpos + content_pos < content_r.right() - static_cast(header.pixels)) { - graph->set_color(bgcolor); // we need to erase the excess, because some cell may not draw text over + graph->palette(false, bgcolor); // we need to erase the excess, because some cell may not draw text over graph->rectangle(rectangle{ item_xpos + static_cast(header.pixels), y + 2, ts.width + static_cast(content_pos)-header.pixels, essence_->item_size - 4 }, true); } @@ -3193,10 +3190,9 @@ namespace nana item_xpos += static_cast(header.pixels); if (display_order + 1 >= seqs.size() && static_cast(extreme_text) > item_xpos) - { - graph->set_color(item.bgcolor); - graph->rectangle(rectangle{item_xpos , y + 2, extreme_text - item_xpos, essence_->item_size - 4}, true); - } + { + graph->rectangle(rectangle{item_xpos , y + 2, extreme_text - item_xpos, essence_->item_size - 4}, true, item.bgcolor); + } } //Draw selecting inner rectangle diff --git a/source/gui/widgets/menu.cpp b/source/gui/widgets/menu.cpp index f2a9b61c..09d0171f 100644 --- a/source/gui/widgets/menu.cpp +++ b/source/gui/widgets/menu.cpp @@ -121,7 +121,7 @@ namespace nana nana::point(r.x + r.width - 1, r.y + r.height - 1) }; - graph.set_color(static_cast(0xc0ddfc)); + graph.palette(false, static_cast(0xc0ddfc)); for(int i = 0; i < 4; ++i) graph.set_pixel(points[i].x, points[i].y); @@ -150,7 +150,7 @@ namespace nana void item_text(graph_reference graph, const nana::point& pos, const std::string& text, unsigned text_pixels, const attr& at) { - graph.set_text_color(at.enabled ? colors::black : colors::gray_border); + graph.palette(true, at.enabled ? colors::black : colors::gray_border); nana::paint::text_renderer tr(graph); auto wstr = to_wstring(text); @@ -372,8 +372,7 @@ namespace nana { if (m.flags.splitter) { - graph_->set_color(colors::gray_border); - graph_->line({ item_r.x + 40, item_r.y }, { static_cast(graph.width()) - 1, item_r.y }); + graph_->line({ item_r.x + 40, item_r.y }, { static_cast(graph.width()) - 1, item_r.y }, colors::gray_border); item_r.y += 2; ++pos; continue; @@ -403,8 +402,7 @@ namespace nana int x = item_r.x + 40 + off_w; int y = item_r.y + text_top_off + hotkey_size.height; - graph_->set_color(colors::black); - graph_->line({ x, y }, { x + static_cast(hotkey_size.width) - 1, y }); + graph_->line({ x, y }, { x + static_cast(hotkey_size.width) - 1, y }, colors::black); } } @@ -751,7 +749,7 @@ namespace nana if(submenu_.parent == nullptr) { state_.owner_menubar = owner_menubar; - API::register_menu_window(this->handle(), !owner_menubar); + API::dev::register_menu_window(this->handle(), !owner_menubar); } auto & events = this->events(); diff --git a/source/gui/widgets/menubar.cpp b/source/gui/widgets/menubar.cpp index 831b633b..459b61fb 100644 --- a/source/gui/widgets/menubar.cpp +++ b/source/gui/widgets/menubar.cpp @@ -114,7 +114,7 @@ namespace nana int right = pos.x + static_cast(size.width) - 1; int bottom = pos.y + static_cast(size.height) - 1; - graph_.set_color(corner); + graph_.palette(false, corner); graph_.set_pixel(pos.x, pos.y); graph_.set_pixel(right, pos.y); graph_.set_pixel(pos.x, bottom); @@ -608,7 +608,8 @@ namespace nana { widget_object ::create(wd, rectangle(nana::size(API::window_size(wd).width, 28))); - API::attach_menubar(handle()); + + API::dev::set_menubar(handle(), true); evt_resized_ = API::events(wd).resized([this](const ::nana::arg_resized& arg) { auto sz = this->size(); diff --git a/source/gui/widgets/scroll.cpp b/source/gui/widgets/scroll.cpp index bfac622f..b59e4721 100644 --- a/source/gui/widgets/scroll.cpp +++ b/source/gui/widgets/scroll.cpp @@ -199,7 +199,7 @@ namespace nana graph.rectangle(r, false, clr); clr = clr.blend(colors::white, 0.5); - graph.set_color(clr); + graph.palette(false, clr); r.pare_off(2); if(vertical_) diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index b8ca8286..74ff5c3d 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -2971,7 +2971,7 @@ namespace nana{ namespace widgets void text_editor::_m_draw_parse_string(const keyword_parser& parser, bool rtl, ::nana::point pos, const ::nana::color& fgcolor, const wchar_t* str, std::size_t len) const { - graph_.set_text_color(fgcolor); + graph_.palette(true, fgcolor); graph_.string(pos, str, len); if (parser.entities().empty()) return; @@ -3010,8 +3010,8 @@ namespace nana{ namespace widgets auto ent_end = (ent.end < str_end ? ent.end : str_end); auto ent_pixels = std::accumulate(glyphs + (ent_begin - str), glyphs + (ent_end - str), unsigned{}); - canvas.set_color(ent.scheme->bgcolor.invisible() ? _m_bgcolor() : ent.scheme->bgcolor); - canvas.set_text_color(ent.scheme->fgcolor.invisible() ? fgcolor : ent.scheme->fgcolor); + canvas.palette(false, ent.scheme->bgcolor.invisible() ? _m_bgcolor() : ent.scheme->bgcolor); + canvas.palette(true, ent.scheme->fgcolor.invisible() ? fgcolor : ent.scheme->fgcolor); canvas.rectangle(true); @@ -3058,9 +3058,8 @@ namespace nana{ namespace widgets //The line of text is in the range of selection nana::upoint a, b; - graph_.set_text_color(clr); - - graph_.set_color(scheme_->selection.get_color()); + graph_.palette(true, clr); + graph_.palette(false, scheme_->selection.get_color()); //The text is not selected or the whole line text is selected if (!focused || (!_m_get_sort_select_points(a, b)) || (select_.a.y != str_pos.y && select_.b.y != str_pos.y)) @@ -3075,7 +3074,7 @@ namespace nana{ namespace widgets { if (selected && focused) { - graph_.set_text_color(scheme_->selection_text.get_color()); + graph_.palette(true, scheme_->selection_text.get_color()); graph_.rectangle(::nana::rectangle{ text_pos, { str_w, line_h_pixels } }, true); graph_.string(text_pos, ent.begin, len); } @@ -3099,7 +3098,7 @@ namespace nana{ namespace widgets int sel_xpos = static_cast(str_px - (glyph_front + glyph_selected)); - graph_.set_text_color(scheme_->selection_text.get_color()); + graph.palette(true, scheme_->selection_text.get_color()); graph.string({-sel_xpos, 0}, str, len); graph_.bitblt(nana::rectangle(strpos.x + sel_xpos, strpos.y, glyph_selected, line_h_pixels), graph); }; @@ -3123,7 +3122,7 @@ namespace nana{ namespace widgets if (a.x <= pos && str_end <= b.x) { graph_.rectangle(::nana::rectangle{ text_pos, { str_w, line_h_pixels } }, true); - graph_.set_text_color(scheme_->selection_text.get_color()); + graph_.palette(true, scheme_->selection_text.get_color()); graph_.string(text_pos, ent.begin, len); } else @@ -3139,7 +3138,7 @@ namespace nana{ namespace widgets auto head_w = std::accumulate(pxbuf, pxbuf + (a.x - pos), unsigned()); auto sel_w = std::accumulate(pxbuf + (a.x - pos), pxbuf + (endpos - pos), unsigned()); - graph_.set_text_color(clr); + graph_.palette(true, clr); if (is_right_text(ent)) { //RTL rtl_string(text_pos, ent.begin, len, str_w, head_w, sel_w); @@ -3153,7 +3152,7 @@ namespace nana{ namespace widgets //Draw selected part graph_.rectangle(::nana::rectangle{ part_pos, { sel_w, line_h_pixels } }, true); - graph_.set_text_color(scheme_->selection_text.get_color()); + graph_.palette(true, scheme_->selection_text.get_color()); graph_.string(part_pos, ent.begin + (a.x - pos), endpos - a.x); if (static_cast(endpos) < str_end) @@ -3171,14 +3170,14 @@ namespace nana{ namespace widgets if (is_right_text(ent)) { //RTL - graph_.set_text_color(clr); + graph_.palette(true, clr); rtl_string(text_pos, ent.begin, len, str_w, 0, sel_w); } else { //LTR //Draw selected part graph_.rectangle(::nana::rectangle{ text_pos, { sel_w, line_h_pixels } }, true); - graph_.set_text_color(scheme_->selection_text.get_color()); + graph_.palette(true, scheme_->selection_text.get_color()); graph_.string(text_pos, ent.begin, endpos - pos); _m_draw_parse_string(parser, false, text_pos + ::nana::point(static_cast(sel_w), 0), clr, ent.begin + (endpos - pos), str_end - endpos); @@ -3196,7 +3195,7 @@ namespace nana{ namespace widgets unsigned str_w = graph_.text_extent_size(ent.begin, len).width; if ((text_pos.x + static_cast(str_w) > text_area_.area.x) && (text_pos.x < text_right)) { - graph_.set_text_color(clr); + graph_.palette(true, clr); std::size_t pos = ent.begin - strbeg + str_pos.x; if ((pos + len <= a.x) || (a.x < pos)) //Not selected or selected all { @@ -3204,7 +3203,7 @@ namespace nana{ namespace widgets { //Draw selected all graph_.rectangle(::nana::rectangle{ text_pos, { str_w, line_h_pixels } }, true, static_cast(0x3399FF)); - graph_.set_text_color(scheme_->selection_text.get_color()); + graph_.palette(true, scheme_->selection_text.get_color()); graph_.string(text_pos, ent.begin, len); } else @@ -3225,7 +3224,7 @@ namespace nana{ namespace widgets //Draw selected part graph_.rectangle(::nana::rectangle{ part_pos, {str_w - head_w, line_h_pixels } }, true); - graph_.set_text_color(scheme_->selection_text.get_color()); + graph_.palette(true, scheme_->selection_text.get_color()); graph_.string(part_pos, ent.begin + a.x - pos, len - (a.x - pos)); } } @@ -3249,12 +3248,12 @@ namespace nana{ namespace widgets if ((text_pos.x + static_cast(str_w) > text_area_.area.x) && (text_pos.x < text_right)) { std::size_t pos = ent.begin - strbeg + str_pos.x; - graph_.set_text_color(clr); + graph_.palette(true, clr); if (pos + len <= b.x) { //Draw selected part graph_.rectangle(::nana::rectangle{ text_pos, { str_w, line_h_pixels } }, true); - graph_.set_text_color(scheme_->selection_text.get_color()); + graph_.palette(true, scheme_->selection_text.get_color()); graph_.string(text_pos, ent.begin, len); } else if (pos <= b.x && b.x < pos + len) @@ -3268,7 +3267,7 @@ namespace nana{ namespace widgets { //draw selected part graph_.rectangle(::nana::rectangle{ text_pos, { sel_w, line_h_pixels } }, true); - graph_.set_text_color(scheme_->selection_text.get_color()); + graph_.palette(true, scheme_->selection_text.get_color()); graph_.string(text_pos, ent.begin, b.x - pos); _m_draw_parse_string(parser, false, text_pos + ::nana::point(static_cast(sel_w), 0), clr, ent.begin + b.x - pos, len - (b.x - pos)); diff --git a/source/gui/widgets/slider.cpp b/source/gui/widgets/slider.cpp index 673cf1f3..72fb50ca 100644 --- a/source/gui/widgets/slider.cpp +++ b/source/gui/widgets/slider.cpp @@ -50,8 +50,7 @@ namespace nana virtual void adorn_textbox(window, graph_reference graph, const std::string& str, const nana::rectangle & r) { graph.rectangle(r, false, colors::white); - graph.set_text_color(colors::white); - graph.string({ r.x + 2, r.y + 1 }, str); + graph.string({ r.x + 2, r.y + 1 }, str, colors::white); } virtual void slider(window, graph_reference graph, const slider_t& s) diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index c2f5afe5..8aa7037e 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -1004,7 +1004,7 @@ namespace nana if(item.text.size()) { nana::size ts = basis_.graph->text_extent_size(item.text); - basis_.graph->set_text_color(m.fgcolor.invisible() ? fgcolor : m.fgcolor); + basis_.graph->palette(true, m.fgcolor.invisible() ? fgcolor : m.fgcolor); nana::paint::text_renderer tr(*basis_.graph); std::wstring wtext = to_wstring(item.text); @@ -1030,7 +1030,7 @@ namespace nana } } - basis_.graph->set_color(static_cast(0x808080)); + basis_.graph->palette(false, static_cast(0x808080)); int right = static_cast(basis_.graph->width()); int end = active_m.r.x + static_cast(active_m.r.width); @@ -1453,8 +1453,8 @@ namespace nana rectangle r{ m.pos_ends.first, 0, static_cast(m.pos_ends.second - m.pos_ends.first), graph.height() }; if (indexes.active_pos == pos) { - graph.set_color(colors::white); - graph.set_text_color(colors::black); + graph.palette(false, colors::white); + graph.palette(true, colors::black); } else { @@ -1463,8 +1463,8 @@ namespace nana if (pos == indexes.hovered_pos) bgcolor = bgcolor.blend(colors::white, 0.5); - graph.set_color(bgcolor); - graph.set_text_color(colors::white); + graph.palette(false, bgcolor); + graph.palette(true, colors::white); } graph.rectangle(r, true); diff --git a/source/gui/widgets/toolbar.cpp b/source/gui/widgets/toolbar.cpp index f5d34f6f..c70f34ea 100644 --- a/source/gui/widgets/toolbar.cpp +++ b/source/gui/widgets/toolbar.cpp @@ -138,9 +138,9 @@ namespace nana if (imgsize.width > scale) imgsize.width = scale; if (imgsize.height > scale) imgsize.height = scale; - nana::point pos(x, y); - pos.x += static_cast(scale + extra_size - imgsize.width) / 2; - pos.y += static_cast(height - imgsize.height) / 2; + nana::point pos( + x + static_cast(scale + extra_size - imgsize.width) / 2, + y + static_cast(height - imgsize.height) / 2); item.image.paste(::nana::rectangle{ imgsize }, graph, pos); if(item.enable == false) @@ -213,7 +213,7 @@ namespace nana int x = 2, y = 2; auto bgcolor = API::bgcolor(widget_->handle()); - graph.set_text_color(bgcolor); + graph.palette(true, bgcolor); graph.gradual_rectangle(rectangle{ graph.size() }, bgcolor.blend(colors::white, 0.9), bgcolor.blend(colors::black, 0.95), true); item_renderer ir(graph, impl_->textout, impl_->scale, bgcolor); diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index 11117f30..65d537c7 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -873,18 +873,6 @@ namespace paint } } - void graphics::set_color(const ::nana::color& col) - { - if (handle_) - handle_->set_color(col); - } - - void graphics::set_text_color(const ::nana::color& col) - { - if (handle_) - handle_->set_text_color(col); - } - ::nana::color graphics::palette(bool for_text) const { if (handle_) @@ -967,7 +955,7 @@ namespace paint void graphics::string(const point& pos, const std::string& text_utf8, const color& clr) { - set_text_color(clr); + palette(true, clr); string(pos, text_utf8); } @@ -1025,7 +1013,7 @@ namespace paint void graphics::string(const point& pos, const ::std::wstring& text, const color& clr) { - set_text_color(clr); + palette(true, clr); string(pos, text.data(), text.size()); } @@ -1050,7 +1038,7 @@ namespace paint void graphics::line(const point& pos_a, const point& pos_b, const color& clr) { - set_color(clr); + palette(false, clr); line(pos_a, pos_b); } @@ -1085,7 +1073,7 @@ namespace paint void graphics::rectangle(bool solid, const ::nana::color& clr) { - set_color(clr); + palette(false, clr); rectangle(::nana::rectangle{ size() }, solid); } @@ -1111,7 +1099,7 @@ namespace paint void graphics::rectangle(const ::nana::rectangle& r, bool solid, const color& clr) { - set_color(clr); + palette(false, clr); rectangle(r, solid); } diff --git a/source/paint/text_renderer.cpp b/source/paint/text_renderer.cpp index f9f0c77c..4acd0f36 100644 --- a/source/paint/text_renderer.cpp +++ b/source/paint/text_renderer.cpp @@ -158,7 +158,7 @@ namespace nana dum_graph.bitblt(r, graph, pos); - dum_graph.set_text_color(graph.palette(true)); + dum_graph.palette(true, graph.palette(true)); dum_graph.string({}, i.begin, len); r.x = pos.x;