The StationView window. More...
Public Types | |
enum | AcceptListHeight { ALH_RATING = 13, ALH_ACCEPTS = 3 } |
Height of the SVW_ACCEPTLIST widget for different views. More... | |
Public Member Functions | |
StationViewWindow (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 | SetStringParameters (int widget) const |
Initialize string parameters for a widget. | |
void | OrderWaitingCargo (CargoDataList *cargolist, uint32 *transfers) |
Order waiting cargo by type and destination. | |
int | FillCargodestList (CargoDestEntry::Type sort_by, CargoDestEntry::List *list) |
Fill cargo list sorted by type and destination/next hop. | |
void | DrawWaitingCargo (const Rect &r, const CargoDataList &cargolist, uint32 transfers) const |
Draw waiting cargo. | |
int | DrawSingleDestEntry (CargoID cid, int *pos, int maxrows, int left, int right, int shrink_left, int shrink_right, int offs_left, int offs_right, int y, const CargoDestEntry &entry) const |
Draw a dest entry and its children. | |
void | DrawWaitingCargoByDest (const Rect &r, const CargoDestEntry::List *list) const |
Draw waiting cargo ordered by destination/next hop. | |
int | DrawAcceptedCargo (const Rect &r) const |
Draw accepted cargo in the SVW_ACCEPTLIST widget. | |
int | DrawCargoRatings (const Rect &r) const |
Draw cargo ratings in the SVW_ACCEPTLIST widget. | |
bool | HandleCargoDestEntryClick (CargoDestEntry &entry, int row) |
Test and handle a possible mouse click on a dest entry and its children. | |
void | HandleCargoWaitingClick (int row) |
void | ClearCargodestList () |
Clear the 'cargo by destination' list. | |
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 | OnQueryTextFinished (char *str) |
The query window opened from this window has closed. | |
virtual void | OnResize () |
Called after the window got resized. | |
Data Fields | |
uint32 | cargo |
Bitmask of cargo types to expand. | |
uint16 | cargo_rows [NUM_CARGO] |
Header row for each cargo type. | |
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 |
CargoDestEntry::List | cargodest_list [NUM_CARGO] |
List of cargoes sorted by destination. | |
Static Public Attributes | |
static StringID | last_cargo_from_str = STR_STATION_VIEW_WAITING_VIA_BUTTON |
static StringID | last_cargo_from_tooltip = STR_STATION_VIEW_WAITING_VIA_TOOLTIP |
The StationView window.
Definition at line 1015 of file station_gui.cpp.
Height of the SVW_ACCEPTLIST widget for different views.
ALH_RATING |
Height of the cargo ratings view. |
ALH_ACCEPTS |
Height of the accepted cargo view. |
Definition at line 1028 of file station_gui.cpp.
void StationViewWindow::ClearCargodestList | ( | ) | [inline] |
Clear the 'cargo by destination' list.
Definition at line 1563 of file station_gui.cpp.
References cargodest_list.
Referenced by OnClick().
int StationViewWindow::DrawAcceptedCargo | ( | const Rect & | r | ) | const [inline] |
Draw accepted cargo in the SVW_ACCEPTLIST widget.
r | Rectangle of the widget. |
Definition at line 1440 of file station_gui.cpp.
References CeilDiv(), DrawCargoListText(), FONT_HEIGHT_NORMAL, SpecializedStation< Station, false >::Get(), Station::goods, HasBit(), NUM_CARGO, SetBit(), 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 SVW_ACCEPTLIST widget.
r | Rectangle of the widget. |
Definition at line 1458 of file station_gui.cpp.
References CeilDiv(), DrawString(), FONT_HEIGHT_NORMAL, SpecializedStation< Station, false >::Get(), Station::goods, HasBit(), CargoSpec::Index(), CargoSpec::name, SetDParam(), ToPercent8(), WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and WD_FRAMERECT_TOP.
Referenced by OnPaint().
int StationViewWindow::DrawSingleDestEntry | ( | CargoID | cid, | |
int * | pos, | |||
int | maxrows, | |||
int | left, | |||
int | right, | |||
int | shrink_left, | |||
int | shrink_right, | |||
int | offs_left, | |||
int | offs_right, | |||
int | y, | |||
const CargoDestEntry & | entry | |||
) | const [inline] |
Draw a dest entry and its children.
cid | Current cargo type. | |
pos | Scroll position | |
maxrows | Number of visible rows. | |
left | Left string bound. | |
right | Right string bound. | |
shrink_left | Left bound of the expand marker. | |
shrink_right | Right bound of the expand marker. | |
offs_left | Child offset of the left bound. | |
offs_right | Child offset of the right bound. | |
y | Top of the current line. | |
entry | The entry to draw. |
Definition at line 1345 of file station_gui.cpp.
References CargoDestEntry::children, CargoDestEntry::data, DrawString(), CargoDestEntry::expanded, CargoDestEntry::FINAL_DEST, FONT_HEIGHT_NORMAL, CargoDestEntry::NEXT_HOP, SA_RIGHT, SetDParam(), ST_INDUSTRY, ST_TOWN, and CargoDestEntry::type.
Referenced by DrawWaitingCargoByDest().
void StationViewWindow::DrawWaitingCargo | ( | const Rect & | r, | |
const CargoDataList & | cargolist, | |||
uint32 | transfers | |||
) | const [inline] |
Draw waiting cargo.
r | Rectangle of the widget. | |
cargolist | Cargo, ordered by type and destination. | |
transfers | Bitmask for cargoes that are transfered. |
Definition at line 1278 of file station_gui.cpp.
References _current_text_dir, cargo, GoodsEntry::cargo, DrawCargoIcons(), DrawString(), CargoList< Tinst >::Empty(), expand_shrink_width, FONT_HEIGHT_NORMAL, SpecializedStation< Station, false >::Get(), Scrollbar::GetCapacity(), Scrollbar::GetPosition(), Station::goods, HasBit(), NUM_CARGO, SA_RIGHT, SetDParam(), TD_RTL, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and WD_FRAMERECT_TOP.
Referenced by OnPaint().
void StationViewWindow::DrawWaitingCargoByDest | ( | const Rect & | r, | |
const CargoDestEntry::List * | list | |||
) | const [inline] |
Draw waiting cargo ordered by destination/next hop.
r | Rectangle of the widget. | |
list | List to draw. |
Definition at line 1385 of file station_gui.cpp.
References _current_text_dir, cargo, GoodsEntry::cargo, CargoList< Tinst >::Count(), DrawCargoIcons(), DrawSingleDestEntry(), DrawString(), CargoList< Tinst >::Empty(), expand_shrink_width, FONT_HEIGHT_NORMAL, SpecializedStation< Station, false >::Get(), Scrollbar::GetCapacity(), Scrollbar::GetPosition(), Station::goods, HasBit(), NUM_CARGO, SA_RIGHT, SetDParam(), TD_RTL, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, and WD_FRAMETEXT_LEFT.
Referenced by OnPaint().
int StationViewWindow::FillCargodestList | ( | CargoDestEntry::Type | sort_by, | |
CargoDestEntry::List * | list | |||
) | [inline] |
Fill cargo list sorted by type and destination/next hop.
sort_via | Set to true to sort by next hop, false to sort by final destination. | |
list | Cargo list to fill. |
Definition at line 1214 of file station_gui.cpp.
References AddCargoPacketToList(), cargo, GoodsEntry::cargo, cargo_rows, CargoDestEntry::children, CargoList< Tinst >::Empty(), CargoDestEntry::FINAL_DEST, SpecializedStation< Station, false >::Get(), Station::goods, HasBit(), CargoDestEntry::NEXT_HOP, NUM_CARGO, CargoList< Tinst >::Packets(), and CargoDestEntry::TRANSFER_HOP.
Referenced by OnPaint().
bool StationViewWindow::HandleCargoDestEntryClick | ( | CargoDestEntry & | entry, | |
int | row | |||
) | [inline] |
Test and handle a possible mouse click on a dest entry and its children.
entry | The entry to test for a hit. | |
row | The number of the clicked row. |
Definition at line 1486 of file station_gui.cpp.
References _ctrl_pressed, CargoDestEntry::children, CargoDestEntry::data, CargoDestEntry::expanded, CargoDestEntry::FINAL_DEST, SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::Get(), CargoDestEntry::NEXT_HOP, ScrollMainWindowToTile(), Window::SetWidgetDirty(), ST_HEADQUARTERS, ST_INDUSTRY, ST_TOWN, CargoDestEntry::start_row, SVW_SCROLLBAR, SVW_WAITING, CargoDestEntry::TRANSFER_HOP, CargoDestEntry::type, and BaseStation::xy.
virtual void StationViewWindow::OnClick | ( | Point | pt, | |
int | widget, | |||
int | click_count | |||
) | [inline, virtual] |
A click with the left mouse button has been made on the window.
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 1570 of file station_gui.cpp.
References _ctrl_pressed, accepts_lines, ClearCargodestList(), CS_ALPHANUMERAL, FONT_HEIGHT_NORMAL, SpecializedStation< Station, false >::Get(), Scrollbar::GetScrolledRowFromWidget(), MAX_LENGTH_STATION_NAME_CHARS, QSF_ENABLE_DEFAULT, QSF_LEN_IN_CHARS, rating_lines, Window::ReInit(), ScrollMainWindowToTile(), NWidgetCore::SetDataTip(), SetDParam(), Window::SetWidgetDirty(), ShowExtraViewPortWindow(), ShowQueryString(), SVW_CARGO_FROM, SVW_LOCATION, SVW_PLANES, SVW_RATINGS, SVW_RENAME, SVW_ROADVEHS, SVW_SCROLLBAR, SVW_SHIPS, SVW_TRAINS, SVW_WAITING, WD_FRAMERECT_TOP, and NWidgetCore::widget_data.
virtual void StationViewWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 1074 of file station_gui.cpp.
References _local_company, accepts_lines, cargodest_list, NWidgetBase::current_x, NWidgetBase::current_y, DrawAcceptedCargo(), DrawCargoRatings(), DrawWaitingCargo(), DrawWaitingCargoByDest(), Window::DrawWidgets(), FACIL_AIRPORT, FACIL_BUS_STOP, FACIL_DOCK, FACIL_TRAIN, FACIL_TRUCK_STOP, BaseStation::facilities, FillCargodestList(), CargoDestEntry::FINAL_DEST, SpecializedStation< Station, false >::Get(), Window::IsShaded(), CargoDestEntry::NEXT_HOP, OrderWaitingCargo(), BaseStation::owner, NWidgetBase::pos_x, NWidgetBase::pos_y, rating_lines, Window::ReInit(), Scrollbar::SetCount(), Window::SetWidgetDisabledState(), SVW_ACCEPTLIST, SVW_ACCEPTS, SVW_CARGO_FROM, SVW_PLANES, SVW_RENAME, SVW_ROADVEHS, SVW_SHIPS, SVW_TRAINS, SVW_WAITING, CargoDestEntry::TRANSFER_HOP, and NWidgetCore::widget_data.
virtual void StationViewWindow::OnQueryTextFinished | ( | char * | str | ) | [inline, virtual] |
The query window opened from this window has closed.
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 1647 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 1654 of file station_gui.cpp.
References Scrollbar::SetCapacityFromWidget(), SVW_WAITING, WD_FRAMERECT_BOTTOM, and WD_FRAMERECT_TOP.
void StationViewWindow::OrderWaitingCargo | ( | CargoDataList * | cargolist, | |
uint32 * | transfers | |||
) | [inline] |
Order waiting cargo by type and destination.
cargolist | [out] Ordered cargo. | |
transfers | [out] Bitmask for cargoes being transfered. |
*cargolist
must be empty. Definition at line 1159 of file station_gui.cpp.
References cargo, GoodsEntry::cargo, cargo_rows, CargoPacket::Count(), CargoList< Tinst >::Count(), CargoList< Tinst >::Empty(), SpecializedStation< Station, false >::Get(), Station::goods, HasBit(), NUM_CARGO, CargoList< Tinst >::Packets(), SetBit(), and CargoPacket::SourceStation().
Referenced by OnPaint().
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.
widget | Widget number. |
Reimplemented from Window.
Definition at line 1144 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 SVW_CAPTION.
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.
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 1059 of file station_gui.cpp.
References accepts_lines, expand_shrink_width, FONT_HEIGHT_NORMAL, GetStringBoundingBox(), max(), rating_lines, SVW_ACCEPTLIST, SVW_ACCEPTS, SVW_WAITING, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, and Window::width.