modifiable mouse wheel scroll step

This commit is contained in:
Jinhao
2016-06-27 10:36:08 +08:00
parent 3cf10ef940
commit a8219fe760
7 changed files with 60 additions and 28 deletions

View File

@@ -14,21 +14,33 @@
#include <nana/gui/basis.hpp>
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 <windows.h>
#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
}

View File

@@ -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;

View File

@@ -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);