Scrollbar Class Reference

Scrollbar data structure. More...

#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.

Detailed Description

Scrollbar data structure.

Definition at line 175 of file window_gui.h.


Member Function Documentation

FORCEINLINE uint16 Scrollbar::GetCapacity (  )  const [inline]

Gets the number of visible elements of the scrollbar.

Returns:
the number of visible elements

Definition at line 200 of file window_gui.h.

References cap.

Referenced by DispatchMouseWheelEvent(), BaseVehicleListWindow::DrawVehicleListItems(), StationViewWindow::DrawWaitingCargo(), VehicleDetailsWindow::DrawWidget(), RefitWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), SubsidyListWindow::DrawWidget(), SelectStationWindow< T >::DrawWidget(), GameSettingsWindow::DrawWidget(), MessageHistoryWindow::DrawWidget(), NewGRFAddWindow::DrawWidget(), NetworkGameWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), IndustryDirectoryWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), BuildVehicleWindow::DrawWidget(), OrdersWindow::GetOrderFromPt(), HandleScrollbarHittest(), IsVisible(), VehicleListWindow::OnClick(), TownDirectoryWindow::OnClick(), SubsidyListWindow::OnClick(), SignListWindow::OnClick(), BuildRailStationWindow::OnClick(), NetworkLobbyWindow::OnClick(), NetworkGameWindow::OnClick(), NetworkContentListWindow::OnClick(), IndustryDirectoryWindow::OnClick(), VehicleGroupWindow::OnClick(), BuildBridgeWindow::OnClick(), VehicleGroupWindow::OnDragDrop(), NewGRFWindow::OnInvalidateData(), NewGRFAddWindow::OnKeyPress(), NetworkGameWindow::OnKeyPress(), NetworkContentListWindow::OnKeyPress(), BuildRailWaypointWindow::OnPaint(), DepotWindow::OnPaint(), AIDebugWindow::OnPaint(), VehicleDetailsWindow::OnResize(), VehicleListWindow::OnResize(), RefitWindow::OnResize(), NewGRFWindow::OnResize(), NetworkLobbyWindow::OnResize(), NetworkGameWindow::OnResize(), NetworkContentListWindow::OnResize(), BuildIndustryWindow::OnResize(), VehicleGroupWindow::OnResize(), DepotWindow::OnResize(), BuildVehicleWindow::OnResize(), BuildBridgeWindow::OnResize(), AISettingsWindow::OnResize(), AIListWindow::OnResize(), ScrollbarClickPositioning(), and ScrollTowards().

FORCEINLINE uint16 Scrollbar::GetCount (  )  const [inline]
FORCEINLINE uint16 Scrollbar::GetPosition (  )  const [inline]

Gets the position of the first visible element in the list.

Returns:
the position of the element

Definition at line 209 of file window_gui.h.

References pos.

Referenced by DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), StationViewWindow::DrawWaitingCargo(), DropdownWindow::DrawWidget(), RefitWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), TownAuthorityWindow::DrawWidget(), TimetableWindow::DrawWidget(), SubsidyListWindow::DrawWidget(), SelectStationWindow< T >::DrawWidget(), SignListWindow::DrawWidget(), GameSettingsWindow::DrawWidget(), BuildRailStationWindow::DrawWidget(), OrdersWindow::DrawWidget(), MessageHistoryWindow::DrawWidget(), NewGRFAddWindow::DrawWidget(), NetworkGameWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), IndustryDirectoryWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), DepotWindow::DrawWidget(), BuildVehicleWindow::DrawWidget(), BuildBridgeWindow::DrawWidget(), AIDebugWindow::DrawWidget(), AIConfigWindow::DrawWidget(), DropdownWindow::GetDropDownItem(), OrdersWindow::GetOrderFromPt(), HandleScrollbarHittest(), IsVisible(), VehicleListWindow::OnClick(), RefitWindow::OnClick(), TownDirectoryWindow::OnClick(), TownAuthorityWindow::OnClick(), SubsidyListWindow::OnClick(), SelectStationWindow< T >::OnClick(), SignListWindow::OnClick(), GameSettingsWindow::OnClick(), BuildRailWaypointWindow::OnClick(), BuildRailStationWindow::OnClick(), NewGRFWindow::OnClick(), NewGRFAddWindow::OnClick(), NetworkLobbyWindow::OnClick(), NetworkStartServerWindow::OnClick(), NetworkGameWindow::OnClick(), NetworkContentListWindow::OnClick(), SaveLoadWindow::OnClick(), IndustryDirectoryWindow::OnClick(), BuildIndustryWindow::OnClick(), VehicleGroupWindow::OnClick(), BuildVehicleWindow::OnClick(), BuildBridgeWindow::OnClick(), AIConfigWindow::OnClick(), AISettingsWindow::OnClick(), AIListWindow::OnClick(), VehicleGroupWindow::OnDragDrop(), BuildRailWaypointWindow::OnPaint(), AIDebugWindow::OnPaint(), DropdownWindow::OnTick(), and ScrollTowards().

FORCEINLINE bool Scrollbar::IsVisible ( uint16  item  )  const [inline]
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.

Parameters:
position the position to scroll towards.

Definition at line 284 of file window_gui.h.

References GetCapacity(), GetPosition(), and SetPosition().

Referenced by NewGRFWindow::OnClick(), AIConfigWindow::OnClick(), NewGRFAddWindow::ScrollToSelected(), NetworkContentListWindow::ScrollToSelected(), and NetworkGameWindow::ScrollToSelectedServer().

void Scrollbar::SetCapacity ( int  capacity  )  [inline]

Set the capacity of visible elements.

Parameters:
capacity the new capacity
Note:
updates the position if needed

Definition at line 245 of file window_gui.h.

References cap, count, max(), MAX_UVALUE, and pos.

Referenced by DropdownWindow::DropdownWindow(), MessageHistoryWindow::OnResize(), VehicleGroupWindow::OnResize(), DepotWindow::OnResize(), AISettingsWindow::OnResize(), AIListWindow::OnResize(), and SetCapacityFromWidget().

void Scrollbar::SetCapacityFromWidget ( Window w,
int  widget,
int  padding = 0 
)
void Scrollbar::SetCount ( int  num  )  [inline]
void Scrollbar::SetPosition ( int  position  )  [inline]

Sets the position of the first visible element.

Parameters:
position the position of the element

Definition at line 260 of file window_gui.h.

References cap, count, and pos.

Referenced by BuildRailStationWindow::OnDropdownSelect(), 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

Parameters:
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(), DropdownWindow::OnTick(), and ScrollbarClickPositioning().


The documentation for this class was generated from the following files:

Generated on Sat Jun 5 21:52:59 2010 for OpenTTD by  doxygen 1.6.1