diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 44321f4c..4262604f 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -54,10 +54,10 @@ namespace nana /// Automatically adjusted width /** - * @param minimize The minimized width of column, in pixel - * @param maximize The maximized width of column, in pixel + * @param minimum The minimal width of column, in pixel + * @param maximum The maximal width of column, in pixel */ - virtual void width(unsigned minimize, unsigned maximize) = 0; + virtual void width(unsigned minimum, unsigned maximum) = 0; /// Sets alignment of column text /** @@ -67,9 +67,10 @@ namespace nana /// Adjusts the width to fit the content /** - * The priority of max: maximize, ranged width, scheme's max_fit_content. + * The priority of max: maximum, ranged width, scheme's max_fit_content. + * @param maximum Sets the width of column to the maximum if the width of content is larger than maximum */ - virtual void fit_content(unsigned maximize = 0) noexcept = 0; + virtual void fit_content(unsigned maximum = 0) noexcept = 0; /// Determines the visibility state of the column /** @@ -533,26 +534,20 @@ namespace nana : public event_arg { mutable drawerbase::listbox::item_proxy item; - bool selected; - - arg_listbox(const drawerbase::listbox::item_proxy&, bool selected) noexcept; + + arg_listbox(const drawerbase::listbox::item_proxy&) noexcept; }; - /// The event argument type for listbox's category_dbl_click + /// The event parameter type for listbox's category_dbl_click struct arg_listbox_category : public event_arg { drawerbase::listbox::cat_proxy category; - /// Block expension/shrink of category - void block_category_change() const noexcept; - - /// Determines whether expension/shrink of category is blocked - bool category_change_blocked() const noexcept; + /// A flag that indicates whether or not to block expension/shrink of category when it is double clicking. + mutable bool block_operation{ false }; arg_listbox_category(const drawerbase::listbox::cat_proxy&) noexcept; - private: - mutable bool block_change_; }; namespace drawerbase diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 0ff7b0d6..3656d6ff 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -544,14 +544,14 @@ namespace nana _m_refresh(); } - void width(unsigned minimize, unsigned maximize) + void width(unsigned minimum, unsigned maximum) { - //maximize must be larger than minimize, but minimize == maximize is allowed - if ((minimize >= maximize) && (minimize != 0)) - throw std::invalid_argument("listbox.column.width() minimize must be less than maximize"); + //maximum must be larger than minimum, but maximum == 0 is allowed if minimum is 0 + if ((minimum >= maximum) && (minimum != 0)) + throw std::invalid_argument("listbox.column.width() minimum must be less than maximum"); - range_width_px.first = minimize; - range_width_px.second = maximize; + range_width_px.first = minimum; + range_width_px.second = maximum; } void text_align(::nana::align align) noexcept override @@ -1344,7 +1344,7 @@ namespace nana { m.flags.checked = ck; - arg_listbox arg{ item_proxy{ess_, pos}, ck}; + arg_listbox arg{ item_proxy{ess_, pos}}; wd_ptr()->events().checked.emit(arg, wd_ptr()->handle()); } ++pos.item; @@ -1398,7 +1398,7 @@ namespace nana changed = true; m.flags.selected = sel; - arg_listbox arg{ item_proxy(ess_, i), sel }; + arg_listbox arg{ item_proxy(ess_, i) }; wd_ptr()->events().selected.emit(arg, wd_ptr()->handle()); if (m.flags.selected) @@ -1490,7 +1490,7 @@ namespace nana auto do_cancel = [this, for_selection](category_t::container::value_type& m, std::size_t cat_pos, std::size_t item_pos) { - arg_listbox arg{ item_proxy(ess_, index_pair(cat_pos, item_pos)), false }; + arg_listbox arg{ item_proxy(ess_, index_pair(cat_pos, item_pos)) }; if (for_selection) { m.flags.selected = false; @@ -1573,7 +1573,7 @@ namespace nana auto cancel = [this, for_selection](category_t::container::value_type& m, std::size_t cat_pos, std::size_t item_pos) { - arg_listbox arg{ item_proxy(ess_, index_pair(cat_pos, item_pos)), false }; + arg_listbox arg{ item_proxy(ess_, index_pair(cat_pos, item_pos)) }; if (for_selection) { m.flags.selected = false; @@ -1678,7 +1678,7 @@ namespace nana { m.flags.checked = ck; - arg_listbox arg{ item_proxy(ess_, index_pair(cat, index)), ck}; + arg_listbox arg{ item_proxy(ess_, index_pair(cat, index)) }; wd_ptr()->events().checked.emit(arg, widget_->handle()); changed = true; @@ -3749,7 +3749,7 @@ namespace nana { item_ptr->flags.selected = sel; - arg_listbox arg{ item_proxy{ essence_, abs_item_pos }, sel }; + arg_listbox arg{ item_proxy{ essence_, abs_item_pos } }; lister.wd_ptr()->events().selected.emit(arg, lister.wd_ptr()->handle()); if (item_ptr->flags.selected) @@ -3771,7 +3771,7 @@ namespace nana item_ptr->flags.checked = ! item_ptr->flags.checked; index_pair abs_pos{ item_pos.cat, lister.absolute(item_pos) }; - arg_listbox arg{ item_proxy{ essence_, abs_pos }, item_ptr->flags.checked }; + arg_listbox arg{ item_proxy{ essence_, abs_pos } }; lister.wd_ptr()->events().checked.emit(arg, lister.wd_ptr()->handle()); if (item_ptr->flags.checked) @@ -4043,7 +4043,7 @@ namespace nana if(m.flags.checked != ck) { m.flags.checked = ck; - arg_listbox arg{*this, ck}; + arg_listbox arg{*this}; ess_->lister.wd_ptr()->events().checked.emit(arg, ess_->lister.wd_ptr()->handle()); ess_->update(); } @@ -4063,7 +4063,7 @@ namespace nana if(m.flags.selected == s) return *this; // ignore if no change m.flags.selected = s; // actually change selection - arg_listbox arg{*this, s}; + arg_listbox arg{*this}; ess_->lister.wd_ptr()->events().selected.emit(arg, ess_->lister.wd_ptr()->handle()); if (m.flags.selected) @@ -4594,8 +4594,8 @@ namespace nana } }//end namespace drawerbase - arg_listbox::arg_listbox(const drawerbase::listbox::item_proxy& m, bool selected) noexcept - : item(m), selected(selected) + arg_listbox::arg_listbox(const drawerbase::listbox::item_proxy& m) noexcept + : item(m) { } @@ -4603,20 +4603,10 @@ namespace nana //Implementation of arg_listbox_category //Contributed by leobackes(pr#97) arg_listbox_category::arg_listbox_category(const nana::drawerbase::listbox::cat_proxy& cat) noexcept - : category(cat), block_change_(false) + : category(cat) { } - void arg_listbox_category::block_category_change() const noexcept - { - block_change_ = true; - } - - bool arg_listbox_category::category_change_blocked() const noexcept - { - return block_change_; - } - //class listbox