Data Structures | Public Types | Public Member Functions | Data Fields | Static Public Attributes

StationViewWindow Struct Reference

The StationView window. More...

Inheritance diagram for StationViewWindow:
Window ZeroedMemoryAllocator

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< RowDisplayCargoDataVector

Public Member Functions

 StationViewWindow (const 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.
virtual void OnInvalidateData (int data=0, bool gui_scope=true)
 Invalidate the cache for the given cargo.
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 ID >
void HandleCargoWaitingClick (CargoDataEntry *filter, ID 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.

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.
Scrollbarvscroll
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).

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.

Detailed Description

The StationView window.

Definition at line 1016 of file station_gui.cpp.


Member Enumeration Documentation

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

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

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

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

References CargoDataEntry::Begin(), cached_destinations, CargoPacket::Count(), DivideApprox(), CargoDataEntry::End(), CargoDataEntry::GetCount(), CargoDataEntry::GetStation(), CargoList< Tinst, Tcont >::Packets(), 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 1402 of file station_gui.cpp.

References BuildCargoList(), BuildFlowList(), cached_destinations, GoodsEntry::cargo, current_mode, GoodsEntry::flows, Station::goods, MODE_WAITING, 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 1347 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 1591 of file station_gui.cpp.

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

Referenced by OnPaint().

int StationViewWindow::DrawCargoRatings ( const Rect r  )  const [inline]
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 1511 of file station_gui.cpp.

References _current_text_dir, CargoDataEntry::Begin(), DrawCargoIcons(), DrawString(), CargoDataEntry::End(), expand_shrink_width, SpecializedStation< Station, false >::Get(), CargoDataEntry::GetCargo(), CargoDataEntry::GetCount(), GetEntryString(), CargoDataEntry::GetNumChildren(), CargoDataEntry::GetStation(), GR_CARGO, GR_DESTINATION, GR_NEXT, GR_SOURCE, groupings, SpecializedStation< Station, false >::IsValidID(), NUM_COLUMNS, scroll_to_row, ScrollMainWindowToTile(), SearchNonStop(), SetDisplayedRow(), SetDParam(), sort_orders, sortings, ST_AS_GROUPING, ST_COUNT, ST_STATION_STRING, 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 1294 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, depending on what station the entry refers to.

Definition at line 1455 of file station_gui.cpp.

References SetDParam().

Referenced by DrawEntries().

template<class ID >
void StationViewWindow::HandleCargoWaitingClick ( CargoDataEntry filter,
ID  next 
) [inline]

Expand or collapse a specific row.

Parameters:
filter Parent of the row.
next ID pointing to the row.

Definition at line 1638 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 1651 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::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 1816 of file station_gui.cpp.

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

virtual void StationViewWindow::OnInvalidateData ( int  data = 0,
bool  gui_scope = true 
) [inline, virtual]

Invalidate the cache for the given cargo.

Parameters:
cargo ID of the cargo.
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 1580 of file station_gui.cpp.

References cached_destinations, and CargoDataEntry::Remove().

virtual void StationViewWindow::OnQueryTextFinished ( char *  str  )  [inline, virtual]

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

References CMD_MSG, CMD_RENAME_STATION, and DoCommandP().

virtual void StationViewWindow::OnResize (  )  [inline, virtual]

Called after the window got resized.

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

Reimplemented from Window.

Definition at line 1832 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 1260 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 1474 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 1776 of file station_gui.cpp.

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

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

References _settings_client, _sort_names, current_mode, ClientSettings::gui, Window::SetDirty(), sortings, and GUISettings::station_gui_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 1733 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 1422 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 [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 1246 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, SetDParam(), and WID_SV_CAPTION.

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

References expanded_rows, GR_CARGO, GR_DESTINATION, GR_NEXT, GR_SOURCE, groupings, CargoDataEntry::InsertOrRetrieve(), NUM_COLUMNS, CargoDataEntry::Retrieve(), and CargoDataEntry::Update().

Referenced by BuildCargoList(), and BuildFlowList().

virtual void StationViewWindow::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 1175 of file station_gui.cpp.

References accepts_lines, expand_shrink_width, FONT_HEIGHT_NORMAL, GetStringBoundingBox(), max(), rating_lines, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WID_SV_ACCEPT_RATING_LIST, WID_SV_WAITING, and Window::width.


Field Documentation

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

Referenced by OnClick(), and SelectGroupBy().

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

Referenced by OnClick(), and SelectSortBy().

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

Definition at line 1094 of file station_gui.cpp.

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

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

Referenced by DrawEntries(), and SelectSortBy().


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