mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-03 10:51:05 +02:00
cc_frm_scrollbar: add getScrollBarData() function ...
to calculate total pages and current page for CComponentsScrollBar
Origin commit data
------------------
Commit: adb71c756c
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-06-14 (Wed, 14 Jun 2017)
Origin message was:
------------------
- cc_frm_scrollbar: add getScrollBarData() function ...
to calculate total pages and current page for CComponentsScrollBar
This commit is contained in:
@@ -220,6 +220,16 @@ void CComponentsScrollBar::initSegments()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getScrollBarData(int *total_pages, int *current_page, int total_items, int items_per_page, int selected_item)
|
||||||
|
{
|
||||||
|
// avoid divison by zero and fix wrong values
|
||||||
|
total_items = std::max(total_items, 1);
|
||||||
|
items_per_page = std::max(items_per_page, 1);
|
||||||
|
selected_item = std::max(selected_item, 0);
|
||||||
|
|
||||||
|
*total_pages = ((total_items - 1) / items_per_page) + 1;
|
||||||
|
*current_page = selected_item / items_per_page;
|
||||||
|
}
|
||||||
|
|
||||||
void paintScrollBar( const int &x_pos,
|
void paintScrollBar( const int &x_pos,
|
||||||
const int &y_pos,
|
const int &y_pos,
|
||||||
|
@@ -145,6 +145,8 @@ class CComponentsScrollBar : public CComponentsFrmChain
|
|||||||
void disableVisualize(){enableVisualize(false);}
|
void disableVisualize(){enableVisualize(false);}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void getScrollBarData(int *total_pages, int *current_page, int total_items, int items_per_page, int selected_item);
|
||||||
|
|
||||||
/**Small and easy to apply scrollbar paint methode without expilcit object declaration
|
/**Small and easy to apply scrollbar paint methode without expilcit object declaration
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user