diff --git a/include/nana/gui/widgets/button.hpp b/include/nana/gui/widgets/button.hpp index 9be71fd6..5dc4b9b4 100644 --- a/include/nana/gui/widgets/button.hpp +++ b/include/nana/gui/widgets/button.hpp @@ -1,13 +1,15 @@ /** * A Button Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * @file: nana/gui/widgets/button.hpp + * @contributor + * besh81(pr#361) */ #ifndef NANA_GUI_WIDGET_BUTTON_HPP @@ -90,7 +92,12 @@ namespace nana{ button(window, const char* caption, bool visible = true); button(window, const nana::rectangle& = rectangle(), bool visible = true); - button& icon(const nana::paint::image&); + /// Shows an icon in front of caption + /** + * @param image Icon to be shown. If image is empty, the current icon is erased from the button. + * @return the reference of *this. + */ + button& icon(const nana::paint::image& image); button& enable_pushed(bool); bool pushed() const; button& pushed(bool); diff --git a/source/gui/widgets/button.cpp b/source/gui/widgets/button.cpp index eae1923e..96ff7c25 100644 --- a/source/gui/widgets/button.cpp +++ b/source/gui/widgets/button.cpp @@ -381,11 +381,8 @@ namespace nana{ namespace drawerbase { if(img.empty()) { - if(attr_.icon) - { - delete attr_.icon; - attr_.icon = 0; - } + delete attr_.icon; + attr_.icon = nullptr; return; }