diff --git a/include/nana/c++defines.hpp b/include/nana/c++defines.hpp index 8007666b..26ffe63f 100644 --- a/include/nana/c++defines.hpp +++ b/include/nana/c++defines.hpp @@ -86,7 +86,7 @@ #define NANA_LINUX #define NANA_X11 #else -# static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)"); + static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)"); #endif //Define a symbol for POSIX operating system. diff --git a/include/nana/gui/basis.hpp b/include/nana/gui/basis.hpp index a80ff3da..a13b3bac 100644 --- a/include/nana/gui/basis.hpp +++ b/include/nana/gui/basis.hpp @@ -284,6 +284,18 @@ that return a corresponding nana::appearance with predefined values. virtual void visible(bool visibility) = 0; virtual bool visible() const = 0; };//end class caret_interface + + namespace parameters + { + /// The system-wide parameters for mouse wheel + struct mouse_wheel + { + unsigned lines; ///< The number of lines to scroll when the vertical mouse wheel is moved. + unsigned characters; ///< The number of characters to scroll when the horizontal mouse wheel is moved. + + mouse_wheel(); + }; + } }//end namespace nana #include diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 699aec19..a21b13ec 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -575,8 +575,6 @@ namespace nana color_proxy header_floated{ static_cast(0xBABBBC)}; color_proxy item_selected{ static_cast(0xD5EFFC) }; - /// \todo how to implement some geometrical parameters ?? - /// The max column width which is generated by fit_content is allowed. It is ignored when it is 0, or a max value is passed to fit_content. unsigned max_fit_content{ 0 }; @@ -591,8 +589,7 @@ namespace nana unsigned header_splitter_area_before{ 2 }; ///< def=2. But 4 is better... IMO unsigned header_splitter_area_after { 3 }; ///< def=3. But 4 is better... - //void debug_print(const std::string &msg); - + ::nana::parameters::mouse_wheel mouse_wheel{}; ///< The number of lines/characters to scroll when vertical/horizontal mouse wheel is moved. }; } }//end namespace drawerbase diff --git a/include/nana/gui/widgets/skeletons/text_editor_part.hpp b/include/nana/gui/widgets/skeletons/text_editor_part.hpp index 71d8f525..0b5eb266 100644 --- a/include/nana/gui/widgets/skeletons/text_editor_part.hpp +++ b/include/nana/gui/widgets/skeletons/text_editor_part.hpp @@ -28,6 +28,8 @@ namespace nana { color_proxy selection{static_cast(0x3399FF)}; color_proxy selection_text{colors::white}; + + parameters::mouse_wheel mouse_wheel; ///< The number of lines/characters to scroll when the vertical/horizontal mouse wheel is moved. }; class text_editor_event_interface diff --git a/source/gui/basis.cpp b/source/gui/basis.cpp index 28893fb4..3fe44813 100644 --- a/source/gui/basis.cpp +++ b/source/gui/basis.cpp @@ -14,21 +14,33 @@ #include -namespace nana +using namespace nana; +using namespace nana::parameters; + +//struct appearance +appearance::appearance() + :taskbar(true), floating(false), no_activate(false), + minimize(true), maximize(true), sizable(true), + decoration(true) +{} + +appearance::appearance(bool has_decorate, bool taskbar, bool is_float, bool no_activate, bool min, bool max, bool sizable) + : taskbar(taskbar), floating(is_float), no_activate(no_activate), + minimize(min), maximize(max), sizable(sizable), + decoration(has_decorate) +{} +//end struct appearance + +#if defined(NANA_WINDOWS) +# include +#endif + +mouse_wheel::mouse_wheel() + : lines(3), characters(3) { - //struct appearance - //@brief: Window appearance structure - appearance::appearance() - :taskbar(true), floating(false), no_activate(false), - minimize(true), maximize(true), sizable(true), - decoration(true) - {} - - appearance::appearance(bool has_decorate, bool taskbar, bool is_float, bool no_activate, bool min, bool max, bool sizable) - : taskbar(taskbar), floating(is_float), no_activate(no_activate), - minimize(min), maximize(max), sizable(sizable), - decoration(has_decorate) - {} - //end struct appearance -}//end namespace nana +#if defined(NANA_WINDOWS) + ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines, 0); + ::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &characters, 0); +#endif +} diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 8cf10cbc..2c485590 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2147,8 +2147,17 @@ namespace nana } /// directly set a tested relative display pos - void set_scroll_y_dpl(const index_pair& pos_dpl) + void set_scroll_y_dpl(index_pair pos_dpl) { + if (lister.first() != pos_dpl) + { + //check the pos_dpl to make sure the last item is at bottom of listbox + const auto numbers = this->number_of_lister_items(false); + const auto distance = lister.distance(pos_dpl, lister.last()); + if (numbers > 1 && distance < numbers) + lister.backward(lister.last(), numbers - 1, pos_dpl); + } + scroll.offset_y_dpl = pos_dpl; if (pos_dpl.is_category()) scroll.offset_y_abs = pos_dpl; @@ -2161,7 +2170,7 @@ namespace nana //number_of_lister_item - /// @brief Returns the number of items that are contained in pixels + /// @brief Returns the number of items that are contained on screen. /// @param with_rest: Means whether including extra one item that is not completely contained in reset pixels. size_type number_of_lister_items(bool with_rest) const { @@ -2509,11 +2518,11 @@ namespace nana if(scroll.v.empty() || !scroll.v.scrollable(upwards)) return false; - index_pair target; - if(upwards == false) - lister.forward(scroll.offset_y_dpl, 1, target); + index_pair target; //index for display + if (upwards == false) + lister.forward(scroll.offset_y_dpl, this->scheme_ptr->mouse_wheel.lines, target); else - lister.backward(scroll.offset_y_dpl, 1, target); + lister.backward(scroll.offset_y_dpl, this->scheme_ptr->mouse_wheel.lines, target); if (target == scroll.offset_y_dpl) return false; diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 3062b445..a63d832f 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -2584,7 +2584,7 @@ namespace nana{ namespace widgets { if(vert && attributes_.vscroll) { - attributes_.vscroll->make_step(!upwards); + attributes_.vscroll->make_step(!upwards, this->scheme_->mouse_wheel.lines); if(_m_scroll_text(true)) { render(true);