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::GetCount (  )  const [inline]

Gets the number of elements in the list.

Returns:
the number of elements

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]

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

FORCEINLINE bool Scrollbar::IsVisible ( uint16  item  )  const [inline]

Checks whether given current item is visible in the list.

Parameters:
item to check
Returns:
true iff the item is visible

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]

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 AISettingsWindow::OnResize(), AIListWindow::OnResize(), and SetCapacityFromWidget().

void Scrollbar::SetCapacityFromWidget ( Window w,
int  widget,
int  padding = 0 
)

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 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(), 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.

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(), and NewGRFAddWindow::ScrollToSelected().


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

Generated on Thu Feb 4 17:21:01 2010 for OpenTTD by  doxygen 1.5.6