# CompanyStationsWindow Class Reference

The list of stations per company. More...

Inheritance diagram for CompanyStationsWindow:

## Public Member Functions

| CompanyStationsWindow (const WindowDesc *desc, WindowNumber window_number)
virtual void | UpdateWidgetSize (int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
| Update size and resize step of a widget in the window.
virtual void | OnPaint ()
| The window must be repainted.
virtual void | DrawWidget (const Rect &r, int widget) const
| Draw the contents of a nested widget.
virtual void | SetStringParameters (int widget) const
| Initialize string parameters for a widget.
virtual void | OnClick (Point pt, int widget, int click_count)
| A click with the left mouse button has been made on the window.
virtual void | OnDropdownSelect (int widget, int index)
| A dropdown option associated to this window has been selected.
virtual void | OnTick ()
| Called once per (game) tick.
virtual void | OnTimeout ()
| Called when this window's timeout has been reached.
virtual void | OnResize ()
| Called after the window got resized.
virtual void | OnInvalidateData (int data)
| Some data on this window has become invalid.

## Protected Member Functions

void | BuildStationsList (const Owner owner)
| (Re)Build station list
void | SortStationsList ()
| Sort the stations list.

## Static Protected Member Functions

static int CDECL | StationNameSorter (const Station *const *a, const Station *const *b)
| Sort stations by their name.
static int CDECL | StationTypeSorter (const Station *const *a, const Station *const *b)
| Sort stations by their type.
static int CDECL | StationWaitingSorter (const Station *const *a, const Station *const *b)
| Sort stations by their waiting cargo.
static int CDECL | StationRatingMaxSorter (const Station *const *a, const Station *const *b)
| Sort stations by their rating.
static int CDECL | StationRatingMinSorter (const Station *const *a, const Station *const *b)
| Sort stations by their rating.

## Protected Attributes

GUIStationList | stations

## Static Protected Attributes

static Listing | last_sorting = {false, 0}
static byte | facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK
static bool | include_empty = true
static const uint32 | cargo_filter_max = UINT32_MAX
static uint32 | cargo_filter = UINT32_MAX
static const Station * | last_station = NULL
static const StringID | sorter_names []
static GUIStationList::SortFunction *const | sorter_funcs []

## Detailed Description

The list of stations per company.

Definition at line 203 of file station_gui.cpp.

## Member Function Documentation

void CompanyStationsWindow::BuildStationsList | ( | const Owner | owner | ) | `[inline, protected]`

(Re)Build station list

Parameters:

  | owner | company whose stations are to be in list

Definition at line 226 of file station_gui.cpp.

References SmallVector< T, S >::Append(), GoodsEntry::cargo, SmallVector< T, S >::Clear(), SmallVector< T, S >::Compact(), CargoList< Tinst >::Empty(), BaseStation::facilities, Station::goods, HasBit(), HasStationInUse(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, SmallVector< T, S >::Length(), GUIList< T, F >::NeedRebuild(), NUM_CARGO, BaseStation::owner, OWNER_NONE, GUIList< T, F >::RebuildDone(), Scrollbar::SetCount(), and Window::vscroll.

virtual void CompanyStationsWindow::DrawWidget | ( | const Rect & | r,
|  | int | widget |
| ) |  |  | const`[inline, virtual]`

Draw the contents of a nested widget.

Parameters:

  | r | Rectangle occupied by the widget.
  | widget | Number of the widget to draw.

Note:
  This method may not change any state, it may only use drawing functions.

Reimplemented from Window.

Definition at line 443 of file station_gui.cpp.

References _dynlang, CargoSpec::abbrev, GoodsEntry::cargo, CargoList< Tinst >::Count(), DrawString(), CargoList< Tinst >::Empty(), BaseStation::facilities, FONT_HEIGHT_NORMAL, CargoSpec::Get(), GfxFillRect(), Station::goods, HasBit(), CargoSpec::Index(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, CargoSpec::IsValid(), max(), min(), BaseStation::owner, OWNER_NONE, SA_CENTER, SBS_DOWN, SBS_UP, SetDParam(), SLW_CARGOALL, SLW_CARGOSTART, SLW_FACILALL, SLW_LIST, SLW_NOCARGOWAITING, SLW_SORTBY, StationsWndShowStationRating(), TD_RTL, DynamicLanguages::text_dir, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, and BaseStation::xy.

virtual void CompanyStationsWindow::OnClick | ( | Point | pt,
|  | int | widget,
|  | int | click_count |
| ) |  |  | `[inline, virtual]`

A click with the left mouse button has been made on the window.

Parameters:

  | pt | the point inside the window that has been clicked.
  | widget | the clicked widget.
  | click_count | Number of fast consecutive clicks at same position

Reimplemented from Window.

Definition at line 535 of file station_gui.cpp.

References _cargo_mask, _ctrl_pressed, FACIL_AIRPORT, FACIL_BUS_STOP, FACIL_DOCK, FACIL_TRAIN, FACIL_TRUCK_STOP, FONT_HEIGHT_NORMAL, FOR_EACH_SET_BIT, CargoSpec::Get(), CargoSpec::Index(), CargoSpec::IsValid(), BaseStation::owner, OWNER_NONE, SetBit(), ShowDropDownMenu(), SLW_AIRPLANE, SLW_BUS, SLW_CARGOALL, SLW_CARGOSTART, SLW_FACILALL, SLW_LIST, SLW_NOCARGOWAITING, SLW_SHIP, SLW_SORTBY, SLW_SORTDROPBTN, SLW_TRAIN, SLW_TRUCK, ToggleBit(), WD_FRAMERECT_TOP, WF_TIMEOUT_BEGIN, and BaseStation::xy.

virtual void CompanyStationsWindow::OnDropdownSelect | ( | int | widget,
|  | int | index |
| ) |  |  | `[inline, virtual]`

A dropdown option associated to this window has been selected.

Parameters:

  | widget | the widget (button) that the dropdown is associated with.
  | index | the element in the dropdown that is selected.

Reimplemented from Window.

Definition at line 667 of file station_gui.cpp.

References SLW_SORTDROPBTN.

virtual void CompanyStationsWindow::OnInvalidateData | ( | int | data | ) | `[inline, virtual]`

Some data on this window has become invalid.

Parameters:

  | data | information about the changed data.

Reimplemented from Window.

Definition at line 699 of file station_gui.cpp.

virtual void CompanyStationsWindow::OnPaint | ( |  | ) | `[inline, virtual]`

The window must be repainted.

Note:
  This method should not change any state, it should only use drawing functions.

Reimplemented from Window.

Definition at line 435 of file station_gui.cpp.

virtual void CompanyStationsWindow::OnResize | ( |  | ) | `[inline, virtual]`

Called after the window got resized.

For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.

Reimplemented from Window.

Definition at line 694 of file station_gui.cpp.

References SLW_LIST, WD_FRAMERECT_BOTTOM, and WD_FRAMERECT_TOP.

virtual void CompanyStationsWindow::SetStringParameters | ( | int | widget | ) | const`[inline, virtual]`

Initialize string parameters for a widget.

Calls to this function are made during initialization to measure the size (that is as part of InitNested()), during drawing, and while re-initializing the window. Only for widgets that render text initializing is requested.

Parameters:

  | widget | Widget number.

Reimplemented from Window.

Definition at line 527 of file station_gui.cpp.

References SetDParam(), and SLW_CAPTION.

virtual void CompanyStationsWindow::UpdateWidgetSize | ( | int | widget,
|  | Dimension * | size,
|  | const Dimension & | padding,
|  | Dimension * | fill,
|  | Dimension * | resize |
| ) |  |  | `[inline, virtual]`

Update size and resize step of a widget in the window.

After retrieval of the minimal size and the resize-steps of a widget, this function is called to allow further refinement, typically by computing the real maximal size of the content. Afterwards, size is taken to be the minimal size of the widget and resize is taken to contain the resize steps. For the convenience of the callee, padding contains the amount of padding between the content and the edge of the widget. This should be added to the returned size.

Parameters:

  | widget | Widget number.
  | size | Size of the widget.
  | padding | Recommended amount of space between the widget content and the widget edge.
  | fill | Fill step of the widget.
  | resize | Resize step of the widget.

Reimplemented from Window.

Definition at line 376 of file station_gui.cpp.

References CargoSpec::abbrev, FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL, CargoSpec::Get(), GetStringBoundingBox(), INVALID_STRING_ID, CargoSpec::IsValid(), maxdim(), SLW_AIRPLANE, SLW_BUS, SLW_CARGOALL, SLW_CARGOSTART, SLW_FACILALL, SLW_LIST, SLW_NOCARGOWAITING, SLW_SHIP, SLW_SORTBY, SLW_SORTDROPBTN, SLW_TRAIN, SLW_TRUCK, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_TOP, and WD_SORTBUTTON_ARROW_WIDTH.

## Field Documentation

GUIStationList::SortFunction *const CompanyStationsWindow::sorter_funcs`[static, protected]`

Initial value:

     {
      &StationNameSorter,
      &StationTypeSorter,
      &StationWaitingSorter,
      &StationRatingMaxSorter,
      &StationRatingMinSorter
    }

Definition at line 216 of file station_gui.cpp.

const StringID CompanyStationsWindow::sorter_names`[static, protected]`

Initial value:

     {
      STR_SORT_BY_NAME,
      STR_SORT_BY_FACILITY,
      STR_SORT_BY_WAITING,
      STR_SORT_BY_RATING_MAX,
      STR_SORT_BY_RATING_MIN,
      INVALID_STRING_ID
    }

Definition at line 215 of file station_gui.cpp.

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

- src/station_gui.cpp