From 3657be8f7d8ebf3d22703b8400ce2326363d80c9 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 1 May 2017 16:57:26 +0800 Subject: [PATCH] refacter tooltip remove compiler warnings remove deprecated code --- include/nana/gui/tooltip.hpp | 2 +- include/nana/paint/graphics.hpp | 9 --------- source/gui/tooltip.cpp | 31 ++++++++----------------------- source/paint/truetype.hpp | 7 +++---- 4 files changed, 12 insertions(+), 37 deletions(-) diff --git a/include/nana/gui/tooltip.hpp b/include/nana/gui/tooltip.hpp index ca1f9d1d..e724d19b 100644 --- a/include/nana/gui/tooltip.hpp +++ b/include/nana/gui/tooltip.hpp @@ -62,7 +62,7 @@ namespace nana _m_hold_factory(new factory); } - tooltip(){} + tooltip() = default; tooltip(window w, const ::std::string &tip){set(w,tip);} diff --git a/include/nana/paint/graphics.hpp b/include/nana/paint/graphics.hpp index c63f08a3..4eafffa2 100644 --- a/include/nana/paint/graphics.hpp +++ b/include/nana/paint/graphics.hpp @@ -43,19 +43,10 @@ namespace nana ~font(); bool empty() const; - /* //deprecated - void make(const ::std::string& name, unsigned size, bool bold = false, bool italic = false, bool underline = false, bool strike_out = false); - void make_raw(const ::std::string& name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out); - - void make(const ::std::string& font_family, unsigned size, const font_style& fs = {}); - void make_from_ttf(const path_type& truetype, unsigned size, const font_style& fs = {}); - */ - void set_default() const; ::std::string name() const; double size() const; bool bold() const; - //unsigned height() const; //deprecated unsigned weight() const; bool italic() const; native_font_type handle() const; diff --git a/source/gui/tooltip.cpp b/source/gui/tooltip.cpp index 847fbab0..862a2720 100644 --- a/source/gui/tooltip.cpp +++ b/source/gui/tooltip.cpp @@ -1,7 +1,7 @@ /* * A Tooltip Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2015 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 @@ -210,24 +210,7 @@ namespace nana _m_get(wd).second = str; } - void show(const std::string& text) - { - if (nullptr == window_ || window_->tooltip_empty()) - { - auto fp = factory(); - - window_ = std::unique_ptr(fp->create(), [fp](tooltip_interface* ti) - { - fp->destroy(ti); - }); - } - - window_->duration(0); - window_->tooltip_text(text); - window_->tooltip_move(API::cursor_position(), true); - } - - void show_duration(window /*wd*/, point pos, const std::string& text, std::size_t duration) + void show(const std::string& text, const point* pos, std::size_t duration) { if (nullptr == window_ || window_->tooltip_empty()) { @@ -242,8 +225,10 @@ namespace nana window_->duration(duration); window_->tooltip_text(text); - pos = pos_by_screen(pos, window_->tooltip_size(), true); - window_->tooltip_move(pos, false); + if (pos) + window_->tooltip_move(pos_by_screen(*pos, window_->tooltip_size(), true), false); + else + window_->tooltip_move(API::cursor_position(), true); } void close() @@ -289,7 +274,7 @@ namespace nana { auto & pr = _m_get(arg.window_handle); if (pr.second.size()) - this->show(pr.second); + this->show(pr.second, nullptr, 0); } else this->close(); @@ -329,7 +314,7 @@ namespace nana { internal_scope_guard lock; API::calc_screen_point(wd, pos); - ctrl::instance()->show_duration(wd, pos, text, duration); + ctrl::instance()->show(text, &pos, duration); } void tooltip::close() diff --git a/source/paint/truetype.hpp b/source/paint/truetype.hpp index 59d12249..2caa3f0e 100644 --- a/source/paint/truetype.hpp +++ b/source/paint/truetype.hpp @@ -105,11 +105,10 @@ namespace nana text.resize(string_length); ifs.read(&text.front(), string_length); - for (auto i = 0; i < string_length; i += 2) - { + for (std::size_t i = 0; i < string_length; i += 2) std::swap(text[i], text[i + 1]); - } - text = nana::charset(text, nana::unicode::utf16).to_bytes(nana::unicode::utf8); + + text = ::nana::charset(text, nana::unicode::utf16).to_bytes(nana::unicode::utf8); } } else