The list of industries. More...
Public Member Functions | |
IndustryDirectoryWindow (WindowDesc *desc, WindowNumber number) | |
virtual void | SetStringParameters (int widget) const |
Initialize string parameters for a widget. | |
virtual void | DrawWidget (const Rect &r, int widget) const |
Draw the contents of a nested widget. | |
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 | 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 | OnResize () |
Called after the window got resized. | |
virtual void | OnPaint () |
The window must be repainted. | |
virtual void | OnHundredthTick () |
Called once every 100 (game) ticks. | |
virtual void | OnInvalidateData (int data=0, bool gui_scope=true) |
Some data on this window has become invalid. | |
Protected Member Functions | |
void | BuildSortIndustriesList () |
(Re)Build industries list | |
StringID | GetIndustryString (const Industry *i) const |
Get the StringID to draw and set the appropriate DParams. | |
Static Protected Member Functions | |
static int | GetCargoTransportedPercentsIfValid (const Industry *i, uint id) |
Returns percents of cargo transported if industry produces this cargo, else -1. | |
static int | GetCargoTransportedSortValue (const Industry *i) |
Returns value representing industry's transported cargo percentage for industry sorting. | |
static int CDECL | IndustryNameSorter (const Industry *const *a, const Industry *const *b) |
Sort industries by name. | |
static int CDECL | IndustryTypeSorter (const Industry *const *a, const Industry *const *b) |
Sort industries by type and name. | |
static int CDECL | IndustryProductionSorter (const Industry *const *a, const Industry *const *b) |
Sort industries by production and name. | |
static int CDECL | IndustryTransportedCargoSorter (const Industry *const *a, const Industry *const *b) |
Sort industries by transported cargo and name. | |
Protected Attributes | |
GUIIndustryList | industries |
Scrollbar * | vscroll |
Static Protected Attributes | |
static Listing | last_sorting = {false, 0} |
static const Industry * | last_industry = NULL |
static const StringID | sorter_names [] |
static GUIIndustryList::SortFunction *const | sorter_funcs [] |
The list of industries.
Definition at line 1065 of file industry_gui.cpp.
virtual void IndustryDirectoryWindow::DrawWidget | ( | const Rect & | r, | |
int | widget | |||
) | const [inline, virtual] |
Draw the contents of a nested widget.
r | Rectangle occupied by the widget. | |
widget | Number of the widget to draw. |
Reimplemented from Window.
Definition at line 1242 of file industry_gui.cpp.
References Window::DrawSortButtonState(), DrawString(), Scrollbar::GetCapacity(), Scrollbar::GetPosition(), GUIList< T, F >::IsDescSortOrder(), SmallVector< T, S >::Length(), Window::resize, SBS_DOWN, ResizeInfo::step_height, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WID_ID_DROPDOWN_ORDER, and WID_ID_INDUSTRY_LIST.
static int IndustryDirectoryWindow::GetCargoTransportedPercentsIfValid | ( | const Industry * | i, | |
uint | id | |||
) | [inline, static, protected] |
Returns percents of cargo transported if industry produces this cargo, else -1.
i | industry to check | |
id | cargo slot |
Definition at line 1106 of file industry_gui.cpp.
References CT_INVALID, Industry::last_month_pct_transported, lengthof, Industry::produced_cargo, and ToPercent8().
Referenced by GetCargoTransportedSortValue().
static int IndustryDirectoryWindow::GetCargoTransportedSortValue | ( | const Industry * | i | ) | [inline, static, protected] |
Returns value representing industry's transported cargo percentage for industry sorting.
i | industry to check |
Definition at line 1121 of file industry_gui.cpp.
References GetCargoTransportedPercentsIfValid(), and Swap().
Referenced by IndustryTransportedCargoSorter().
StringID IndustryDirectoryWindow::GetIndustryString | ( | const Industry * | i | ) | const [inline, protected] |
Get the StringID to draw and set the appropriate DParams.
i | the industry to get the StringID of. |
Definition at line 1185 of file industry_gui.cpp.
References CST_DIR, CT_INVALID, GetAllCargoSuffixes(), GetIndustrySpec(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Industry::last_month_pct_transported, Industry::last_month_production, lengthof, Industry::produced_cargo, SetDParam(), SetDParamStr(), ToPercent8(), and Industry::type.
Referenced by UpdateWidgetSize().
virtual void IndustryDirectoryWindow::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 1305 of file industry_gui.cpp.
References _ctrl_pressed, Scrollbar::GetScrolledRowFromWidget(), SmallVector< T, S >::Length(), ScrollMainWindowToTile(), Window::SetDirty(), ShowDropDownMenu(), ShowExtraViewPortWindow(), GUIList< T, F >::SortType(), GUIList< T, F >::ToggleSortOrder(), WD_FRAMERECT_TOP, WID_ID_DROPDOWN_CRITERIA, WID_ID_DROPDOWN_ORDER, and WID_ID_INDUSTRY_LIST.
virtual void IndustryDirectoryWindow::OnDropdownSelect | ( | int | widget, | |
int | index | |||
) | [inline, virtual] |
A dropdown option associated to this window has been selected.
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 1331 of file industry_gui.cpp.
References BuildSortIndustriesList(), GUIList< T, F >::SetSortType(), and GUIList< T, F >::SortType().
virtual void IndustryDirectoryWindow::OnInvalidateData | ( | int | data = 0 , |
|
bool | gui_scope = true | |||
) | [inline, virtual] |
Some data on this window has become invalid.
data | Information about the changed 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 1361 of file industry_gui.cpp.
References GUIList< T, F >::ForceRebuild(), and GUIList< T, F >::ForceResort().
virtual void IndustryDirectoryWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 1344 of file industry_gui.cpp.
References BuildSortIndustriesList(), Window::DrawWidgets(), and GUIList< T, F >::NeedRebuild().
virtual void IndustryDirectoryWindow::OnResize | ( | ) | [inline, virtual] |
Called after the window got resized.
For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.
Reimplemented from Window.
Definition at line 1339 of file industry_gui.cpp.
References Scrollbar::SetCapacityFromWidget(), and WID_ID_INDUSTRY_LIST.
virtual void IndustryDirectoryWindow::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 1237 of file industry_gui.cpp.
References SetDParam(), GUIList< T, F >::SortType(), and WID_ID_DROPDOWN_CRITERIA.
virtual void IndustryDirectoryWindow::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 1267 of file industry_gui.cpp.
References GetIndustryString(), GetStringBoundingBox(), INVALID_STRING_ID, SmallVector< T, S >::Length(), maxdim(), WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_SORTBUTTON_ARROW_WIDTH, WID_ID_DROPDOWN_CRITERIA, WID_ID_DROPDOWN_ORDER, and WID_ID_INDUSTRY_LIST.
GUIIndustryList::SortFunction *const IndustryDirectoryWindow::sorter_funcs [static, protected] |
{ &IndustryNameSorter, &IndustryTypeSorter, &IndustryProductionSorter, &IndustryTransportedCargoSorter }
Definition at line 1073 of file industry_gui.cpp.
const StringID IndustryDirectoryWindow::sorter_names [static, protected] |
{ STR_SORT_BY_NAME, STR_SORT_BY_TYPE, STR_SORT_BY_PRODUCTION, STR_SORT_BY_TRANSPORTED, INVALID_STRING_ID }
Definition at line 1072 of file industry_gui.cpp.