From cdba16289742f5aaeecfa91110a18ae5ad67ecf9 Mon Sep 17 00:00:00 2001 From: dankan1890 Date: Sun, 14 Aug 2016 23:48:42 +0200 Subject: [PATCH 1/2] Fixed some 'false' value implicitly cast to the integer type. --- source/gui/widgets/date_chooser.cpp | 2 +- source/paint/graphics.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/gui/widgets/date_chooser.cpp b/source/gui/widgets/date_chooser.cpp index 0085f30b..aa824637 100644 --- a/source/gui/widgets/date_chooser.cpp +++ b/source/gui/widgets/date_chooser.cpp @@ -393,7 +393,7 @@ namespace nana int n = trace_.logic_pos.y * rows + trace_.logic_pos.x + 1; if (page_mode::date == page) { - if (n < 8) return false; //Here is week title bar + if (n < 8) return 0; //Here is week title bar int dw = nana::date::day_of_week(view_month_.year, view_month_.month, 1); n -= (dw ? dw + 7 : 14); } diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index 6cbfe571..aa606f4e 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -140,13 +140,13 @@ namespace paint unsigned font::height() const { - if(empty()) return false; + if(empty()) return 0; return (impl_->font_ptr->height); } unsigned font::weight() const { - if(empty()) return false; + if(empty()) return 0; return (impl_->font_ptr->weight); } From 236ba4356ed8fb3309a76f8670f031e2dcbba966 Mon Sep 17 00:00:00 2001 From: dankan1890 Date: Mon, 15 Aug 2016 00:07:55 +0200 Subject: [PATCH 2/2] Removed some useless static_cast. --- source/gui/widgets/button.cpp | 2 +- source/gui/widgets/float_listbox.cpp | 4 ++-- source/gui/widgets/menubar.cpp | 2 +- source/gui/widgets/tabbar.cpp | 2 +- source/paint/graphics.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/gui/widgets/button.cpp b/source/gui/widgets/button.cpp index f4a1ab3f..3d397ab5 100644 --- a/source/gui/widgets/button.cpp +++ b/source/gui/widgets/button.cpp @@ -235,7 +235,7 @@ namespace nana{ namespace drawerbase if(shortkey) { - unsigned off_w = (shortkey_pos ? graph.text_extent_size(mbstr.c_str(), static_cast(shortkey_pos)).width : 0); + unsigned off_w = (shortkey_pos ? graph.text_extent_size(mbstr.c_str(), shortkey_pos).width : 0); wchar_t keystr[2] = {nana::utf::char_at(mbstr.c_str() + shortkey_pos, 0, 0), 0}; auto shortkey_size = graph.text_extent_size(keystr, 1); diff --git a/source/gui/widgets/float_listbox.cpp b/source/gui/widgets/float_listbox.cpp index d47098cb..0bf42f94 100644 --- a/source/gui/widgets/float_listbox.cpp +++ b/source/gui/widgets/float_listbox.cpp @@ -161,7 +161,7 @@ namespace nana --(state_.index); else if(recycle) { - state_.index = static_cast(module_->items.size() - 1); + state_.index = module_->items.size() - 1; state_.offset_y = last_offset_y; } @@ -179,7 +179,7 @@ namespace nana } if(state_.index >= state_.offset_y + module_->max_items) - state_.offset_y = static_cast(state_.index - module_->max_items + 1); + state_.offset_y = state_.index - module_->max_items + 1; } } else diff --git a/source/gui/widgets/menubar.cpp b/source/gui/widgets/menubar.cpp index 9d40d9ec..7d6d4de1 100644 --- a/source/gui/widgets/menubar.cpp +++ b/source/gui/widgets/menubar.cpp @@ -216,7 +216,7 @@ namespace nana if (hotkey) { - unsigned off_w = (hotkey_pos ? graph.text_extent_size(text.c_str(), static_cast(hotkey_pos)).width : 0); + unsigned off_w = (hotkey_pos ? graph.text_extent_size(text.c_str(), hotkey_pos).width : 0); nana::size hotkey_size = graph.text_extent_size(text.c_str() + hotkey_pos, 1); unsigned ascent, descent, inleading; diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index 61150e9f..b8824f3b 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -751,7 +751,7 @@ namespace nana if((pos == npos) || (pos >= list_.size())) { this->list_.emplace_back(); - pos = static_cast(list_.size() - 1); + pos = list_.size() - 1; } else list_.emplace(iterator_at(pos)); diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index aa606f4e..684a8ca2 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -413,7 +413,7 @@ namespace paint nana::size graphics::text_extent_size(const std::wstring& text) const { - return text_extent_size(text.c_str(), static_cast(text.length())); + return text_extent_size(text.c_str(), text.length()); } nana::size graphics::text_extent_size(const wchar_t* str, std::size_t len) const