OpenTTD: StationViewWindow Struct Reference

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Data Structures | Public Types | Public Member Functions | Data Fields | Static Public Attributes
StationViewWindow Struct Reference

The StationView window. More...

Inheritance diagram for StationViewWindow:

## Data Structures
struct | RowDisplay
| A row being displayed in the cargo view (as opposed to being "hidden" behind a plus sign). More...

## Public Types
enum | Invalidation { INV_FLOWS = 0x100, INV_CARGO = 0x200 }
| Type of data invalidation. More...
enum | Grouping { GR_SOURCE, GR_NEXT, GR_DESTINATION, GR_CARGO }
| Type of grouping used in each of the "columns". More...
enum | Mode { MODE_WAITING, MODE_PLANNED }
| Display mode of the cargo view. More...
enum | AcceptListHeight { ALH_RATING = 13, ALH_ACCEPTS = 3 }
| Height of the WID_SV_ACCEPT_RATING_LIST widget for different views. More...
typedef std::vector< RowDisplay > | CargoDataVector

## Public Member Functions
| StationViewWindow (WindowDesc *desc, WindowNumber window_number)
void | ShowCargo (CargoDataEntry *data, CargoID cargo, StationID source, StationID next, StationID dest, uint count)
| Show a certain cargo entry characterized by source/next/dest station, cargo ID and amount of cargo at the right place in the cargo view.
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 | SetStringParameters (int widget) const
| Initialize string parameters for a widget.
void | RecalcDestinations (CargoID i)
| Rebuild the cache for estimated destinations which is used to quickly show the "destination" entries even if we actually don't know the destination of a certain packet from just looking at it.
void | EstimateDestinations (CargoID cargo, StationID source, StationID next, uint count, CargoDataEntry *dest)
| Estimate the amounts of cargo per final destination for a given cargo, source station and next hop and save the result as children of the given CargoDataEntry.
void | BuildFlowList (CargoID i, const FlowStatMap &flows, CargoDataEntry *cargo)
| Build up the cargo view for PLANNED mode and a specific cargo.
void | BuildCargoList (CargoID i, const StationCargoList &packets, CargoDataEntry *cargo)
| Build up the cargo view for WAITING mode and a specific cargo.
void | BuildCargoList (CargoDataEntry *cargo, const Station *st)
| Build up the cargo view for all cargoes.
void | SetDisplayedRow (const CargoDataEntry *data)
| Mark a specific row, characterized by its CargoDataEntry, as expanded.
StringID | GetEntryString (StationID station, StringID here, StringID other_station, StringID any)
| Select the correct string for an entry referring to the specified station.
StringID | SearchNonStop (CargoDataEntry *cd, StationID station, int column)
| Determine if we need to show the special "non-stop" string.
int | DrawEntries (CargoDataEntry *entry, Rect &r, int pos, int maxrows, int column, CargoID cargo=CT_INVALID)
| Draw the given cargo entries in the station GUI.
int | DrawAcceptedCargo (const Rect &r) const
| Draw accepted cargo in the WID_SV_ACCEPT_RATING_LIST widget.
int | DrawCargoRatings (const Rect &r) const
| Draw cargo ratings in the WID_SV_ACCEPT_RATING_LIST widget.
template<class Tid >
void | HandleCargoWaitingClick (CargoDataEntry *filter, Tid next)
| Expand or collapse a specific row.
void | HandleCargoWaitingClick (int row)
| Handle a click on a specific row in the cargo view.
virtual void | OnClick (Point pt, int widget, int click_count)
| A click with the left mouse button has been made on the window.
void | SelectSortOrder (SortOrder order)
| Select a new sort order for the cargo view.
void | SelectSortBy (int index)
| Select a new sort criterium for the cargo view.
void | SelectGroupBy (int index)
| Select a new grouping mode for the cargo view.
virtual void | OnDropdownSelect (int widget, int index)
| A dropdown option associated to this window has been selected.
virtual void | OnQueryTextFinished (char *str)
| The query window opened from this window has closed.
virtual void | OnResize ()
| Called after the window got resized.
virtual void | OnInvalidateData (int data=0, bool gui_scope=true)
| Some data on this window has become invalid.
Public Member Functions inherited from Window
| Window (WindowDesc *desc)
| Empty constructor, initialization has been moved to InitNested() called from the constructor of the derived class.
virtual | ~Window ()
| Remove window and all its child windows from the window stack.
void * | operator new[] (size_t size)
| Helper allocation function to disallow something.
void | operator delete (void *ptr)
| Helper allocation function to disallow something.
template<class NWID >
const NWID * | GetWidget (uint widnum) const
| Specialized case of Window::GetWidget for the nested widget base class.
template<class NWID >
NWID * | GetWidget (uint widnum)
| Get the nested widget with number widnum from the nested widget tree.
const Scrollbar * | GetScrollbar (uint widnum) const
| Return the Scrollbar to a widget index.
Scrollbar * | GetScrollbar (uint widnum)
| Return the Scrollbar to a widget index.
const QueryString * | GetQueryString (uint widnum) const
| Return the querystring associated to a editbox.
QueryString * | GetQueryString (uint widnum)
| Return the querystring associated to a editbox.
virtual const char * | GetFocusedText () const
| Get the current input text if an edit box has the focus.
virtual const char * | GetCaret () const
| Get the string at the caret if an edit box has the focus.
virtual const char * | GetMarkedText (size_t *length) const
| Get the range of the currently marked input text.
virtual Point | GetCaretPosition () const
| Get the current caret position if an edit box has the focus.
virtual Rect | GetTextBoundingRect (const char *from, const char *to) const
| Get the bounding rectangle for a text range if an edit box has the focus.
virtual const char * | GetTextCharacterAtPosition (const Point &pt) const
| Get the character that is rendered at a position by the focused edit box.
void | InitNested (WindowNumber number=0)
| Perform complete initialization of the Window with nested widgets, to allow use.
void | CreateNestedTree (bool fill_nested=true)
| Perform the first part of the initialization of a nested widget tree.
void | FinishInitNested (WindowNumber window_number=0)
| Perform the second part of the initialization of a nested widget tree.
void | SetTimeout ()
| Set the timeout flag of the window and initiate the timer.
void | SetWhiteBorder ()
| Set the timeout flag of the window and initiate the timer.
void | DisableAllWidgetHighlight ()
| Disable the highlighted status of all widgets.
void | SetWidgetHighlight (byte widget_index, TextColour highlighted_colour)
| Sets the highlighted status of a widget.
bool | IsWidgetHighlighted (byte widget_index) const
| Gets the highlighted status of a widget.
void | SetWidgetDisabledState (byte widget_index, bool disab_stat)
| Sets the enabled/disabled status of a widget.
void | DisableWidget (byte widget_index)
| Sets a widget to disabled.
void | EnableWidget (byte widget_index)
| Sets a widget to Enabled.
bool | IsWidgetDisabled (byte widget_index) const
| Gets the enabled/disabled status of a widget.
bool | IsWidgetFocused (byte widget_index) const
| Check if given widget is focused within this window.
bool | IsWidgetGloballyFocused (byte widget_index) const
| Check if given widget has user input focus.
void | SetWidgetLoweredState (byte widget_index, bool lowered_stat)
| Sets the lowered/raised status of a widget.
void | ToggleWidgetLoweredState (byte widget_index)
| Invert the lowered/raised status of a widget.
void | LowerWidget (byte widget_index)
| Marks a widget as lowered.
void | RaiseWidget (byte widget_index)
| Marks a widget as raised.
bool | IsWidgetLowered (byte widget_index) const
| Gets the lowered state of a widget.
void | UnfocusFocusedWidget ()
| Makes no widget on this window have focus.
bool | SetFocusedWidget (int widget_index)
| Set focus within this window to the given widget.
EventState | HandleEditBoxKey (int wid, WChar key, uint16 keycode)
| Process keypress for editbox widget.
virtual void | InsertTextString (int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end)
| Insert a text string at the cursor position into the edit box widget.
void | HandleButtonClick (byte widget)
| Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
int | GetRowFromWidget (int clickpos, int widget, int padding, int line_height=-1) const
| Compute the row of a widget that a user clicked in.
void | RaiseButtons (bool autoraise=false)
| Raise the buttons of the window.
void CDECL | SetWidgetsDisabledState (bool disab_stat, int widgets,...)
| Sets the enabled/disabled status of a list of widgets.
void CDECL | SetWidgetsLoweredState (bool lowered_stat, int widgets,...)
| Sets the lowered/raised status of a list of widgets.
void | SetWidgetDirty (byte widget_index) const
| Invalidate a widget, i.e.
void | DrawWidgets () const
| Paint all widgets of a window.
void | DrawViewport () const
| Draw the viewport of this window.
void | DrawSortButtonState (int widget, SortButtonState state) const
| Draw a sort button's up or down arrow symbol.
void | DeleteChildWindows (WindowClass wc=WC_INVALID) const
| Delete all children a window might have in a head-recursive manner.
void | SetDirty () const
| Mark entire window as dirty (in need of re-paint)
void | ReInit (int rx=0, int ry=0)
| Re-initialize a window, and optionally change its size.
bool | IsShaded () const
| Is window shaded currently?
void | SetShaded (bool make_shaded)
| Set the shaded state of the window to make_shaded.
void | InvalidateData (int data=0, bool gui_scope=true)
| Mark this window's data as invalid (in need of re-computing)
void | ProcessScheduledInvalidations ()
| Process all scheduled invalidations.
void | ProcessHighlightedInvalidations ()
| Process all invalidation of highlighted widgets.
virtual void | OnInit ()
| Notification that the nested widget tree gets initialized.
virtual void | ApplyDefaults ()
| Read default values from WindowDesc configuration an apply them to the window.
virtual Point | OnInitialPosition (int16 sm_width, int16 sm_height, int window_number)
| Compute the initial position of the window.
virtual void | DrawWidget (const Rect &r, int widget) const
| Draw the contents of a nested widget.
virtual void | OnFocus ()
| Called when window gains focus.
virtual void | OnFocusLost ()
| Called when window looses focus.
virtual EventState | OnKeyPress (WChar key, uint16 keycode)
| A key has been pressed.
virtual EventState | OnHotkey (int hotkey)
| A hotkey has been pressed.
virtual EventState | OnCTRLStateChange ()
| The state of the control key has changed.
virtual bool | OnRightClick (Point pt, int widget)
| A click with the right mouse button has been made on the window.
virtual void | OnHover (Point pt, int widget)
| The mouse is hovering over a widget in the window, perform an action for it, like opening a custom tooltip.
virtual void | OnMouseDrag (Point pt, int widget)
| An 'object' is being dragged at the provided position, highlight the target if possible.
virtual void | OnDragDrop (Point pt, int widget)
| A dragged 'object' has been released.
virtual void | OnScroll (Point delta)
| Handle the request for (viewport) scrolling.
virtual void | OnMouseOver (Point pt, int widget)
| The mouse is currently moving over the window or has just moved outside of the window.
virtual void | OnMouseWheel (int wheel)
| The mouse wheel has been turned.
virtual void | OnMouseLoop ()
| Called for every mouse loop run, which is at least once per (game) tick.
virtual void | OnTick ()
| Called once per (game) tick.
virtual void | OnHundredthTick ()
| Called once every 100 (game) ticks.
virtual void | OnTimeout ()
| Called when this window's timeout has been reached.
virtual void | OnDropdownClose (Point pt, int widget, int index, bool instant_close)
| A dropdown window associated to this window has been closed.
virtual void | OnEditboxChanged (int widget)
| The text in an editbox has been edited.
virtual void | OnPlaceObject (Point pt, TileIndex tile)
| The user clicked some place on the map when a tile highlight mode has been set.
virtual bool | OnVehicleSelect (const struct Vehicle *v)
| The user clicked on a vehicle while HT_VEHICLE has been set.
virtual void | OnPlaceObjectAbort ()
| The user cancelled a tile highlight mode that has been set.
virtual void | OnPlaceDrag (ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
| The user is dragging over the map when the tile highlight mode has been set.
virtual void | OnPlaceMouseUp (ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
| The user has dragged over the map when the tile highlight mode has been set.
virtual void | OnPlacePresize (Point pt, TileIndex tile)
| The user moves over the map when a tile highlight mode has been set when the special mouse mode has been set to 'PRESIZE' mode.
virtual bool | IsNewGRFInspectable () const
| Is the data related to this window NewGRF inspectable?
virtual void | ShowNewGRFInspectWindow () const
| Show the NewGRF inspection window.
Public Member Functions inherited from ZeroedMemoryAllocator
void * | operator new (size_t size)
| Memory allocator for a single class instance.
void | operator delete[] (void *ptr)
| Memory release for an array of class instances.

## Data Fields
uint | expand_shrink_width
| The width allocated to the expand/shrink 'button'.
int | rating_lines
| Number of lines in the cargo ratings view.
int | accepts_lines
| Number of lines in the accepted cargo view.
Scrollbar * | vscroll
CargoSortType | sortings [NUM_COLUMNS]
| Sort types of the different 'columns'.
SortOrder | sort_orders [NUM_COLUMNS]
| Sort order (ascending/descending) for the 'columns'.
int | scroll_to_row
| If set, scroll the main viewport to the station pointed to by this row.
int | grouping_index
| Currently selected entry in the grouping drop down.
Mode | current_mode
| Currently selected display mode of cargo view.
Grouping | groupings [NUM_COLUMNS]
| Grouping modes for the different columns.
CargoDataEntry | expanded_rows
| Parent entry of currently expanded rows.
CargoDataEntry | cached_destinations
| Cache for the flows passing through this station.
CargoDataVector | displayed_rows
| Parent entry of currently displayed rows (including collapsed ones).
Data Fields inherited from Window
WindowDesc * | window_desc
| Window description.
WindowFlags | flags
| Window flags.
WindowClass | window_class
| Window class.
WindowNumber | window_number
| Window number within the window class.
uint8 | timeout_timer
| Timer value of the WF_TIMEOUT for flags.
uint8 | white_border_timer
| Timer value of the WF_WHITE_BORDER for flags.
int | left
| x position of left edge of the window
int | top
| y position of top edge of the window
int | width
| width of the window (number of pixels to the right in x direction)
int | height
| Height of the window (number of pixels down in y direction)
ResizeInfo | resize
| Resize information.
Owner | owner
| The owner of the content shown in this window. Company colour is acquired from this variable.
ViewportData * | viewport
| Pointer to viewport data, if present.
const NWidgetCore * | nested_focus
| Currently focused nested widget, or `NULL` if no nested widget has focus.
SmallMap< int, QueryString * > | querystrings
| QueryString associated to WWT_EDITBOX widgets.
NWidgetBase * | nested_root
| Root of the nested tree.
NWidgetBase ** | nested_array
| Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
uint | nested_array_size
| Size of the nested array.
NWidgetStacked * | shade_select
| Selection widget (NWID_SELECTION) to use for shading the window. If `NULL`, window cannot shade.
Dimension | unshaded_size
| Last known unshaded size (only valid while shaded).
int | scrolling_scrollbar
| Widgetindex of just being dragged scrollbar. -1 if none is active.
Window * | parent
| Parent window.
Window * | z_front
| The window in front of us in z-order.
Window * | z_back
| The window behind us in z-order.

## Static Public Attributes
static const int | NUM_COLUMNS = 4
| Number of "columns" in the cargo view: cargo, from, via, to.
static const StringID | _sort_names []
| Names of the sorting options in the dropdown.
static const StringID | _group_names []
| Names of the grouping options in the dropdown.

## Additional Inherited Members
Static Public Member Functions inherited from Window
static int | SortButtonWidth ()
| Get width of up/down arrow of sort button state.
Protected Member Functions inherited from Window
void | InitializeData (WindowNumber window_number)
| Initializes the data (except the position and initial size) of a new Window.
void | InitializePositionSize (int x, int y, int min_width, int min_height)
| Set the position and smallest size of the window.
void | FindWindowPlacementAndResize (int def_width, int def_height)
| Resize window towards the default size.
Protected Attributes inherited from Window
SmallVector< int, 4 > | scheduled_invalidation_data
| Data of scheduled OnInvalidateData() calls.

## Detailed Description

The StationView window.

Definition at line 1203 of file station_gui.cpp.

## Member Enumeration Documentation

enum StationViewWindow::AcceptListHeight

Height of the WID_SV_ACCEPT_RATING_LIST widget for different views.

Enumerator:

  ALH_RATING | Height of the cargo ratings view.
  ALH_ACCEPTS | Height of the accepted cargo view.

Definition at line 1264 of file station_gui.cpp.

enum StationViewWindow::Grouping

Type of grouping used in each of the "columns".

Enumerator:

  GR_SOURCE | Group by source of cargo ("from").
  GR_NEXT | Group by next station ("via").
  GR_DESTINATION | Group by estimated final destination ("to").
  GR_CARGO | Group by cargo type.

Definition at line 1243 of file station_gui.cpp.

enum StationViewWindow::Invalidation

Type of data invalidation.

Enumerator:

  INV_FLOWS | The planned flows have been recalculated and everything has to be updated.
  INV_CARGO | Some cargo has been added or removed.

Definition at line 1235 of file station_gui.cpp.

enum StationViewWindow::Mode

Display mode of the cargo view.

Enumerator:

  MODE_WAITING | Show cargo waiting at the station.
  MODE_PLANNED | Show cargo planned to pass through the station.

Definition at line 1253 of file station_gui.cpp.

## Member Function Documentation

void StationViewWindow::BuildCargoList | ( | CargoID | i,
|  | const StationCargoList & | packets,
|  | CargoDataEntry * | cargo
| ) |  |
| inline

Build up the cargo view for WAITING mode and a specific cargo.

Parameters

  i | Cargo to show.
  packets | The current station's cargo list for that cargo.
  cargo | The CargoDataEntry to save the result in.

Definition at line 1568 of file station_gui.cpp.

References CargoDataEntry::Begin(), cached_destinations, CargoPacket::Count(), DivideApprox(), CargoDataEntry::End(), CargoDataEntry::GetCount(), CargoDataEntry::GetStation(), CargoList< Tinst, Tcont >::Packets(), StationCargoList::ReservedCount(), CargoDataEntry::Retrieve(), ShowCargo(), and CargoPacket::SourceStation().

Referenced by BuildCargoList(), and OnPaint().

void StationViewWindow::BuildCargoList | ( | CargoDataEntry * | cargo,
|  | const Station * | st
| ) |  |
| inline

Build up the cargo view for all cargoes.

Parameters

  cargo | The root cargo entry to save all results in.
  st | The station to calculate the cargo view from.

Definition at line 1601 of file station_gui.cpp.

References BuildCargoList(), BuildFlowList(), cached_destinations, GoodsEntry::cargo, current_mode, GoodsEntry::flows, Station::goods, MODE_WAITING, NUM_CARGO, RecalcDestinations(), and CargoDataEntry::Retrieve().

void StationViewWindow::BuildFlowList | ( | CargoID | i,
|  | const FlowStatMap & | flows,
|  | CargoDataEntry * | cargo
| ) |  |
| inline

Build up the cargo view for PLANNED mode and a specific cargo.

Parameters

  i | Cargo to show.
  flows | The current station's flows for that cargo.
  cargo | The CargoDataEntry to save the results in.

Definition at line 1545 of file station_gui.cpp.

References CargoDataEntry::Begin(), cached_destinations, CargoDataEntry::End(), CargoDataEntry::GetCount(), CargoDataEntry::GetStation(), CargoDataEntry::Retrieve(), and ShowCargo().

Referenced by BuildCargoList().

int StationViewWindow::DrawAcceptedCargo | ( | const Rect & | r | ) | const
| inline

Draw accepted cargo in the WID_SV_ACCEPT_RATING_LIST widget.

Parameters

  r | Rectangle of the widget.

Returns
  Number of lines needed for drawing the accepted cargo.

Definition at line 1798 of file station_gui.cpp.

References CeilDiv(), DrawStringMultiLine(), FONT_HEIGHT_NORMAL, GoodsEntry::GES_ACCEPTANCE, SpecializedStation< Station, false >::Get(), Station::goods, HasBit(), NUM_CARGO, SetBit(), SetDParam(), GoodsEntry::status, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and WD_FRAMERECT_TOP.

Referenced by OnPaint().

int StationViewWindow::DrawCargoRatings | ( | const Rect & | r | ) | const
| inline

Draw cargo ratings in the WID_SV_ACCEPT_RATING_LIST widget.

Parameters

  r | Rectangle of the widget.

Returns
  Number of lines needed for drawing the cargo ratings.

Definition at line 1816 of file station_gui.cpp.

References CeilDiv(), DrawString(), DrawStringMultiLine(), Town::exclusive_counter, Town::exclusivity, FONT_HEIGHT_NORMAL, FOR_ALL_SORTED_STANDARD_CARGOSPECS, SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::GetIfValid(), Station::goods, GoodsEntry::HasRating(), CargoSpec::Index(), GoodsEntry::link_graph, LinkGraph::Monthly(), CargoSpec::name, GoodsEntry::node, BaseStation::owner, GoodsEntry::rating, SetDParam(), ToPercent8(), BaseStation::town, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, and WD_PAR_VSEP_WIDE.

Referenced by OnPaint().

int StationViewWindow::DrawEntries | ( | CargoDataEntry * | entry,
|  | Rect & | r,
|  | int | pos,
|  | int | maxrows,
|  | int | column,
|  | CargoID | cargo = `CT_INVALID`
| ) |  |
| inline

Draw the given cargo entries in the station GUI.

Parameters

  entry | Root entry for all cargo to be drawn.
  r | Screen rectangle to draw into.
  pos | Current row to be drawn to (counted down from 0 to -maxrows, same as vscroll->GetPosition()).
  maxrows | Maximum row to be drawn.
  column | Current "column" being drawn.
  cargo | Current cargo being drawn (if cargo column has been passed).

Returns
  row (in "pos" counting) after the one we have last drawn to.

Definition at line 1712 of file station_gui.cpp.

References _current_text_dir, _settings_game, CargoDataEntry::Begin(), GoodsEntry::cargo, DrawCargoIcons(), DrawString(), DT_MANUAL, CargoDataEntry::End(), expand_shrink_width, FONT_HEIGHT_NORMAL, SpecializedStation< Station, false >::Get(), CargoDataEntry::GetCargo(), CargoDataEntry::GetCount(), GetEntryString(), CargoDataEntry::GetNumChildren(), CargoDataEntry::GetStation(), Station::goods, GR_CARGO, GR_DESTINATION, GR_NEXT, GR_SOURCE, groupings, CargoDataEntry::HasTransfers(), SpecializedStation< Station, false >::IsValidID(), GameSettings::linkgraph, NUM_COLUMNS, StationCargoList::ReservedCount(), scroll_to_row, ScrollMainWindowToTile(), SearchNonStop(), SetDisplayedRow(), SetDParam(), sort_orders, sortings, ST_AS_GROUPING, ST_COUNT, ST_STATION_STRING, TD_RTL, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and WD_FRAMERECT_TOP.

Referenced by OnPaint().

void StationViewWindow::EstimateDestinations | ( | CargoID | cargo,
|  | StationID | source,
|  | StationID | next,
|  | uint | count,
|  | CargoDataEntry * | dest
| ) |  |
| inline

Estimate the amounts of cargo per final destination for a given cargo, source station and next hop and save the result as children of the given CargoDataEntry.

Parameters

  cargo | ID of the cargo to estimate destinations for.
  source | Source station of the given batch of cargo.
  next | Intermediate hop to start the calculation at ("next hop").
  count | Size of the batch of cargo.
  dest | CargoDataEntry to save the results in.

Definition at line 1492 of file station_gui.cpp.

References CargoDataEntry::Begin(), DivideApprox(), CargoDataEntry::End(), GoodsEntry::flows, SpecializedStation< Station, false >::Get(), CargoDataEntry::GetCount(), CargoDataEntry::GetStation(), Station::goods, CargoDataEntry::InsertOrRetrieve(), SpecializedStation< Station, false >::IsValidID(), and CargoDataEntry::Update().

Referenced by RecalcDestinations().

StringID StationViewWindow::GetEntryString | ( | StationID | station,
|  | StringID | here,
|  | StringID | other_station,
|  | StringID | any
| ) |  |
| inline

Select the correct string for an entry referring to the specified station.

Parameters

  station | Station the entry is showing cargo for.
  here | String to be shown if the entry refers to the same station as this station GUI belongs to.
  other_station | String to be shown if the entry refers to a specific other station.
  any | String to be shown if the entry refers to "any station".

Returns
  One of the three given strings or STR_STATION_VIEW_RESERVED, depending on what station the entry refers to.

Definition at line 1654 of file station_gui.cpp.

References SetDParam().

Referenced by DrawEntries().

template<class Tid >

void StationViewWindow::HandleCargoWaitingClick | ( | CargoDataEntry * | filter,
|  | Tid | next
| ) |  |
| inline

Expand or collapse a specific row.

Parameters

  filter | Parent of the row.
  next | ID pointing to the row.

Definition at line 1852 of file station_gui.cpp.

References CargoDataEntry::InsertOrRetrieve(), CargoDataEntry::Remove(), and CargoDataEntry::Retrieve().

Referenced by OnClick().

void StationViewWindow::HandleCargoWaitingClick | ( | int | row | ) |
| inline

Handle a click on a specific row in the cargo view.

Parameters

  row | Row being clicked.

Definition at line 1865 of file station_gui.cpp.

References _ctrl_pressed, displayed_rows, StationViewWindow::RowDisplay::filter, StationViewWindow::RowDisplay::next_cargo, StationViewWindow::RowDisplay::next_station, scroll_to_row, Window::SetWidgetDirty(), and WID_SV_WAITING.

virtual void StationViewWindow::OnClick | ( | Point | pt,
|  | int | widget,
|  | int | click_count
| ) |  |
| inlinevirtual

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 1881 of file station_gui.cpp.

References _ctrl_pressed, _group_names, _sort_names, accepts_lines, CMD_OPEN_CLOSE_AIRPORT, CS_ALPHANUMERAL, current_mode, DoCommandP(), FONT_HEIGHT_NORMAL, SpecializedStation< Station, false >::Get(), Scrollbar::GetPosition(), Scrollbar::GetScrolledRowFromWidget(), grouping_index, HandleCargoWaitingClick(), Window::LowerWidget(), MAX_LENGTH_STATION_NAME_CHARS, BaseStation::owner, Window::owner, QSF_ENABLE_DEFAULT, QSF_LEN_IN_CHARS, rating_lines, Window::ReInit(), ScrollMainWindowToTile(), SelectSortOrder(), NWidgetCore::SetDataTip(), SetDParam(), Window::SetTimeout(), ShowDropDownMenu(), ShowExtraViewPortWindow(), ShowQueryString(), sort_orders, sortings, ST_COUNT, WD_FRAMERECT_TOP, WID_SV_ACCEPTS_RATINGS, WID_SV_CLOSE_AIRPORT, WID_SV_GROUP_BY, WID_SV_LOCATION, WID_SV_PLANES, WID_SV_RENAME, WID_SV_ROADVEHS, WID_SV_SHIPS, WID_SV_SORT_BY, WID_SV_SORT_ORDER, WID_SV_TRAINS, and WID_SV_WAITING.

virtual void StationViewWindow::OnDropdownSelect | ( | int | widget,
|  | int | index
| ) |  |
| inlinevirtual

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 2042 of file station_gui.cpp.

References SelectGroupBy(), SelectSortBy(), and WID_SV_SORT_BY.

virtual void StationViewWindow::OnInvalidateData | ( | int | data = `0`,
|  | bool | gui_scope = `true`
| ) |  |
| inlinevirtual

Some data on this window has become invalid.

Invalidate the cache for the given cargo if necessary.

Parameters

  data | Information about the changed data. If it's a valid cargo ID, invalidate the cargo data.
  gui_scope | Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See InvalidateWindowData() for details.

Reimplemented from Window.

Definition at line 2068 of file station_gui.cpp.

References cached_destinations, NUM_CARGO, Window::ReInit(), and CargoDataEntry::Remove().

virtual void StationViewWindow::OnPaint | ( |  | ) |
| inlinevirtual

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 1390 of file station_gui.cpp.

References _local_company, accepts_lines, Station::airport, AIRPORT_CLOSED_block, BuildCargoList(), NWidgetBase::current_x, NWidgetBase::current_y, displayed_rows, DrawAcceptedCargo(), DrawCargoRatings(), DrawEntries(), Window::DrawSortButtonState(), Window::DrawWidgets(), FACIL_AIRPORT, FACIL_BUS_STOP, FACIL_DOCK, FACIL_TRAIN, FACIL_TRUCK_STOP, BaseStation::facilities, Airport::flags, SpecializedStation< Station, false >::Get(), Scrollbar::GetCapacity(), CargoDataEntry::GetNumChildren(), Scrollbar::GetPosition(), Window::IsShaded(), BaseStation::owner, OWNER_NONE, NWidgetBase::pos_x, NWidgetBase::pos_y, rating_lines, Window::ReInit(), SBS_DOWN, SBS_UP, scroll_to_row, Scrollbar::SetCount(), Window::SetWidgetDisabledState(), Window::SetWidgetLoweredState(), sort_orders, WID_SV_ACCEPT_RATING_LIST, WID_SV_ACCEPTS_RATINGS, WID_SV_CLOSE_AIRPORT, WID_SV_PLANES, WID_SV_RENAME, WID_SV_ROADVEHS, WID_SV_SHIPS, WID_SV_SORT_ORDER, WID_SV_TRAINS, and WID_SV_WAITING.

virtual void StationViewWindow::OnQueryTextFinished | ( | char * | str | ) |
| inlinevirtual

The query window opened from this window has closed.

Parameters

  str | the new value of the string, NULL if the window was cancelled or an empty string when the default button was pressed, i.e. StrEmpty(str).

Reimplemented from Window.

Definition at line 2051 of file station_gui.cpp.

References CMD_MSG, CMD_RENAME_STATION, and DoCommandP().

virtual void StationViewWindow::OnResize | ( |  | ) |
| inlinevirtual

Called after the window got resized.

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

Reimplemented from Window.

Definition at line 2058 of file station_gui.cpp.

References Scrollbar::SetCapacityFromWidget(), WD_FRAMERECT_BOTTOM, WD_FRAMERECT_TOP, and WID_SV_WAITING.

void StationViewWindow::RecalcDestinations | ( | CargoID | i | ) |
| inline

Rebuild the cache for estimated destinations which is used to quickly show the "destination" entries even if we actually don't know the destination of a certain packet from just looking at it.

Parameters

  i | Cargo to recalculate the cache for.

Definition at line 1458 of file station_gui.cpp.

References cached_destinations, CargoDataEntry::Clear(), EstimateDestinations(), GoodsEntry::flows, SpecializedStation< Station, false >::Get(), Station::goods, CargoDataEntry::InsertOrRetrieve(), and CargoDataEntry::Update().

Referenced by BuildCargoList().

StringID StationViewWindow::SearchNonStop | ( | CargoDataEntry * | cd,
|  | StationID | station,
|  | int | column
| ) |  |
| inline

Determine if we need to show the special "non-stop" string.

Parameters

  cd | Entry we are going to show.
  station | Station the entry refers to.
  column | The "column" the entry will be shown in.

Returns
  either STR_STATION_VIEW_VIA or STR_STATION_VIEW_NONSTOP.

Definition at line 1675 of file station_gui.cpp.

References CargoDataEntry::Begin(), CargoDataEntry::End(), CargoDataEntry::GetParent(), CargoDataEntry::GetStation(), GR_DESTINATION, groupings, and Window::parent.

Referenced by DrawEntries().

void StationViewWindow::SelectGroupBy | ( | int | index | ) |
| inline

Select a new grouping mode for the cargo view.

Parameters

  index | Row being selected in the grouping drop down.

Definition at line 2002 of file station_gui.cpp.

References _group_names, _settings_client, GR_DESTINATION, GR_NEXT, GR_SOURCE, grouping_index, groupings, ClientSettings::gui, Window::SetDirty(), GUISettings::station_gui_group_order, and WID_SV_GROUP_BY.

Referenced by OnDropdownSelect().

void StationViewWindow::SelectSortBy | ( | int | index | ) |
| inline

Select a new sort criterium for the cargo view.

Parameters

  index | Row being selected in the sort criteria drop down.

Definition at line 1970 of file station_gui.cpp.

References _settings_client, _sort_names, current_mode, ClientSettings::gui, MODE_PLANNED, MODE_WAITING, Window::SetDirty(), sortings, ST_AS_GROUPING, ST_COUNT, GUISettings::station_gui_sort_by, and WID_SV_SORT_BY.

Referenced by OnDropdownSelect().

void StationViewWindow::SelectSortOrder | ( | SortOrder | order | ) |
| inline

Select a new sort order for the cargo view.

Parameters

  order | New sort order.

Definition at line 1959 of file station_gui.cpp.

References _settings_client, ClientSettings::gui, Window::SetDirty(), sort_orders, and GUISettings::station_gui_sort_order.

Referenced by OnClick().

void StationViewWindow::SetDisplayedRow | ( | const CargoDataEntry * | data | ) |
| inline

Mark a specific row, characterized by its CargoDataEntry, as expanded.

Parameters

  data | The row to be marked as expanded.

Definition at line 1621 of file station_gui.cpp.

References displayed_rows, expanded_rows, CargoDataEntry::GetCargo(), CargoDataEntry::GetParent(), CargoDataEntry::GetStation(), Window::parent, and CargoDataEntry::Retrieve().

Referenced by DrawEntries().

virtual void StationViewWindow::SetStringParameters | ( | int | widget | ) | const
| inlinevirtual

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 1446 of file station_gui.cpp.

References BaseStation::facilities, SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, and SetDParam().

void StationViewWindow::ShowCargo | ( | CargoDataEntry * | data,
|  | CargoID | cargo,
|  | StationID | source,
|  | StationID | next,
|  | StationID | dest,
|  | uint | count
| ) |  |
| inline

Show a certain cargo entry characterized by source/next/dest station, cargo ID and amount of cargo at the right place in the cargo view.

I.e. update as many rows as are expanded following that characterization.

Parameters

  data | Root entry of the tree.
  cargo | Cargo ID of the entry to be shown.
  source | Source station of the entry to be shown.
  next | Next station the cargo to be shown will visit.
  dest | Final destination of the cargo to be shown.
  count | Amount of cargo to be shown.

Definition at line 1330 of file station_gui.cpp.

References _settings_game, DT_MANUAL, expanded_rows, GR_CARGO, GR_DESTINATION, GR_NEXT, GR_SOURCE, groupings, CargoDataEntry::InsertOrRetrieve(), GameSettings::linkgraph, NUM_COLUMNS, CargoDataEntry::Retrieve(), CargoDataEntry::SetTransfers(), and CargoDataEntry::Update().

Referenced by BuildCargoList(), and BuildFlowList().

virtual void StationViewWindow::UpdateWidgetSize | ( | int | widget,
|  | Dimension * | size,
|  | const Dimension & | padding,
|  | Dimension * | fill,
|  | Dimension * | resize
| ) |  |
| inlinevirtual

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 1366 of file station_gui.cpp.

References accepts_lines, expand_shrink_width, FACIL_AIRPORT, BaseStation::facilities, FONT_HEIGHT_NORMAL, SpecializedStation< Station, false >::Get(), GetStringBoundingBox(), max(), rating_lines, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WID_SV_ACCEPT_RATING_LIST, WID_SV_ACCEPTS_RATINGS, WID_SV_CLOSE_AIRPORT, WID_SV_WAITING, and Window::width.

## Field Documentation

const StringID StationViewWindow::_group_names
| static

Initial value:
{
STR_STATION_VIEW_GROUP_S_V_D,
STR_STATION_VIEW_GROUP_S_D_V,
STR_STATION_VIEW_GROUP_V_S_D,
STR_STATION_VIEW_GROUP_V_D_S,
STR_STATION_VIEW_GROUP_D_S_V,
STR_STATION_VIEW_GROUP_D_V_S,
INVALID_STRING_ID
}

Names of the grouping options in the dropdown.

Definition at line 1270 of file station_gui.cpp.

Referenced by OnClick(), and SelectGroupBy().

const StringID StationViewWindow::_sort_names
| static

Initial value:
{
STR_STATION_VIEW_WAITING_STATION,
STR_STATION_VIEW_WAITING_AMOUNT,
STR_STATION_VIEW_PLANNED_STATION,
STR_STATION_VIEW_PLANNED_AMOUNT,
INVALID_STRING_ID
}

Names of the sorting options in the dropdown.

Definition at line 1269 of file station_gui.cpp.

Referenced by OnClick(), and SelectSortBy().

SortOrder StationViewWindow::sort_orders[NUM_COLUMNS]

Sort order (ascending/descending) for the 'columns'.

Definition at line 1281 of file station_gui.cpp.

Referenced by DrawEntries(), OnClick(), OnPaint(), and SelectSortOrder().

CargoSortType StationViewWindow::sortings[NUM_COLUMNS]

Sort types of the different 'columns'.

In fact only ST_COUNT and ST_AS_GROUPING are active and you can only sort all the columns in the same way. The other options haven't been included in the GUI due to lack of space.

Definition at line 1278 of file station_gui.cpp.

Referenced by DrawEntries(), OnClick(), and SelectSortBy().

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

- src/station_gui.cpp