#include <window_gui.h>
Public Member Functions | |
Scrollbar (bool is_vertical) | |
FORCEINLINE uint16 | GetCount () const |
Gets the number of elements in the list. | |
FORCEINLINE uint16 | GetCapacity () const |
Gets the number of visible elements of the scrollbar. | |
FORCEINLINE uint16 | GetPosition () const |
Gets the position of the first visible element in the list. | |
FORCEINLINE bool | IsVisible (uint16 item) const |
Checks whether given current item is visible in the list. | |
void | SetCount (int num) |
Sets the number of elements in the list. | |
void | SetCapacity (int capacity) |
Set the capacity of visible elements. | |
void | SetCapacityFromWidget (Window *w, int widget, int padding=0) |
Set capacity of visible elements from the size and resize properties of a widget. | |
void | SetPosition (int position) |
Sets the position of the first visible element. | |
void | UpdatePosition (int difference) |
Updates the position of the first visible element by the given amount. | |
void | ScrollTowards (int position) |
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown either at the bottom or top of the window depending on where in the list it was. | |
Private Attributes | |
const bool | is_vertical |
Scrollbar has vertical orientation. | |
uint16 | count |
Number of elements in the list. | |
uint16 | cap |
Number of visible elements of the scroll bar. | |
uint16 | pos |
Index of first visible item of the list. |
Definition at line 175 of file window_gui.h.
FORCEINLINE uint16 Scrollbar::GetCount | ( | ) | const [inline] |
Gets the number of elements in the list.
Definition at line 191 of file window_gui.h.
References count.
Referenced by DispatchMouseWheelEvent(), HandleScrollbarHittest(), AIDebugWindow::OnPaint(), and VehicleListWindow::SetStringParameters().
FORCEINLINE uint16 Scrollbar::GetCapacity | ( | ) | const [inline] |
Gets the number of visible elements of the scrollbar.
Definition at line 200 of file window_gui.h.
References cap.
Referenced by DispatchMouseWheelEvent(), StationViewWindow::DrawWaitingCargo(), VehicleDetailsWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), SelectStationWindow< T >::DrawWidget(), NewGRFAddWindow::DrawWidget(), IndustryDirectoryWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), OrdersWindow::GetOrderFromPt(), HandleScrollbarHittest(), IsVisible(), VehicleListWindow::OnClick(), TownDirectoryWindow::OnClick(), IndustryDirectoryWindow::OnClick(), NewGRFWindow::OnInvalidateData(), NewGRFAddWindow::OnKeyPress(), AIDebugWindow::OnPaint(), VehicleDetailsWindow::OnResize(), VehicleListWindow::OnResize(), NewGRFWindow::OnResize(), BuildIndustryWindow::OnResize(), AISettingsWindow::OnResize(), AIListWindow::OnResize(), ScrollbarClickPositioning(), and ScrollTowards().
FORCEINLINE uint16 Scrollbar::GetPosition | ( | ) | const [inline] |
Gets the position of the first visible element in the list.
Definition at line 209 of file window_gui.h.
References pos.
Referenced by StationViewWindow::DrawWaitingCargo(), TownDirectoryWindow::DrawWidget(), TownAuthorityWindow::DrawWidget(), SelectStationWindow< T >::DrawWidget(), OrdersWindow::DrawWidget(), NewGRFAddWindow::DrawWidget(), IndustryDirectoryWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), AIDebugWindow::DrawWidget(), AIConfigWindow::DrawWidget(), OrdersWindow::GetOrderFromPt(), HandleScrollbarHittest(), IsVisible(), VehicleListWindow::OnClick(), TownDirectoryWindow::OnClick(), SelectStationWindow< T >::OnClick(), NewGRFWindow::OnClick(), NewGRFAddWindow::OnClick(), IndustryDirectoryWindow::OnClick(), BuildIndustryWindow::OnClick(), AIConfigWindow::OnClick(), AISettingsWindow::OnClick(), AIListWindow::OnClick(), AIListWindow::OnDoubleClick(), AIDebugWindow::OnPaint(), and ScrollTowards().
FORCEINLINE bool Scrollbar::IsVisible | ( | uint16 | item | ) | const [inline] |
Checks whether given current item is visible in the list.
item | to check |
Definition at line 219 of file window_gui.h.
References GetCapacity(), GetPosition(), and IsInsideBS().
Referenced by OrdersWindow::DrawWidget(), NewGRFWindow::DrawWidget(), AIDebugWindow::DrawWidget(), AIConfigWindow::DrawWidget(), AISettingsWindow::DrawWidget(), and AIListWindow::DrawWidget().
void Scrollbar::SetCount | ( | int | num | ) | [inline] |
Sets the number of elements in the list.
num | the number of elements in the list |
Definition at line 229 of file window_gui.h.
References cap, count, MAX_UVALUE, and pos.
Referenced by NewGRFAddWindow::BuildGrfList(), IndustryDirectoryWindow::BuildSortIndustriesList(), CompanyStationsWindow::BuildStationsList(), ReplaceVehicleWindow::GenerateLists(), SelectStationWindow< T >::OnInvalidateData(), OrdersWindow::OnInvalidateData(), NewGRFWindow::OnInvalidateData(), VehicleDetailsWindow::OnPaint(), TownAuthorityWindow::OnPaint(), StationViewWindow::OnPaint(), and AIDebugWindow::OnPaint().
void Scrollbar::SetCapacity | ( | int | capacity | ) | [inline] |
Set the capacity of visible elements.
capacity | the new capacity |
Definition at line 245 of file window_gui.h.
References cap, count, max(), MAX_UVALUE, and pos.
Referenced by AISettingsWindow::OnResize(), AIListWindow::OnResize(), and SetCapacityFromWidget().
void Scrollbar::SetCapacityFromWidget | ( | Window * | w, | |
int | widget, | |||
int | padding = 0 | |||
) |
Set capacity of visible elements from the size and resize properties of a widget.
w | Window. | |
widget | Widget with size and resize properties. | |
padding | Padding to subtract from the size. |
Definition at line 89 of file window.cpp.
References NWidgetBase::current_x, NWidgetBase::current_y, Window::GetWidget(), is_vertical, NWidgetBase::resize_x, NWidgetBase::resize_y, and SetCapacity().
Referenced by NewGRFWindow::OnInvalidateData(), VehicleDetailsWindow::OnResize(), VehicleListWindow::OnResize(), TownDirectoryWindow::OnResize(), SelectStationWindow< T >::OnResize(), StationViewWindow::OnResize(), OrdersWindow::OnResize(), NewGRFWindow::OnResize(), NewGRFAddWindow::OnResize(), IndustryDirectoryWindow::OnResize(), BuildIndustryWindow::OnResize(), and AIDebugWindow::OnResize().
void Scrollbar::SetPosition | ( | int | position | ) | [inline] |
Sets the position of the first visible element.
position | the position of the element |
Definition at line 260 of file window_gui.h.
References cap, count, and pos.
Referenced by AIDebugWindow::OnPaint(), ScrollTowards(), and UpdatePosition().
void Scrollbar::UpdatePosition | ( | int | difference | ) | [inline] |
Updates the position of the first visible element by the given amount.
If the position would be too low or high it will be clamped appropriately
difference | the amount of change requested |
Definition at line 272 of file window_gui.h.
References cap, Clamp(), count, max(), pos, and SetPosition().
Referenced by DispatchMouseWheelEvent(), and ScrollbarClickPositioning().
void Scrollbar::ScrollTowards | ( | int | position | ) | [inline] |
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown either at the bottom or top of the window depending on where in the list it was.
position | the position to scroll towards. |
Definition at line 284 of file window_gui.h.
References GetCapacity(), GetPosition(), and SetPosition().
Referenced by NewGRFAddWindow::ScrollToSelected().