# IndustryDirectoryWindow Class Reference

The list of industries. More...

Inheritance diagram for IndustryDirectoryWindow:

## Public Member Functions
| IndustryDirectoryWindow (const WindowDesc *desc, WindowNumber number)
virtual void | OnPaint ()
| This window is currently being repainted.
virtual void | OnClick (Point pt, int widget)
| 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 (Point new_size, Point delta)
| Called when the window got resized.
virtual void | OnInvalidateData (int data)
| Some data on this window has become invalid.
## Protected Member Functions
void | BuildIndustriesList ()
| (Re)Build industries list
void | SortIndustriesList ()
| Sort the industries list.
## 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
## 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 []

## Detailed Description

The list of industries.

Definition at line 723 of file industry_gui.cpp.

## Member Function Documentation

static int IndustryDirectoryWindow::GetCargoTransportedPercentsIfValid | ( | const Industry * | i,
|  | uint | id |
| ) |  |  | `[inline, static, protected]`

Returns percents of cargo transported if industry produces this cargo, else -1.

Parameters:

  | i | industry to check
  | id | cargo slot

Returns:
  percents of cargo transported, or -1 if industry doesn't use this cargo slot

Definition at line 760 of file industry_gui.cpp.

References Industry::last_month_pct_transported, lengthof, and Industry::produced_cargo.

Referenced by GetCargoTransportedSortValue().

static int IndustryDirectoryWindow::GetCargoTransportedSortValue | ( | const Industry * | i | ) | `[inline, static, protected]`

Returns value representing industry's transported cargo percentage for industry sorting.

Parameters:

  | i | industry to check

Returns:
  value used for sorting

Definition at line 775 of file industry_gui.cpp.

References GetCargoTransportedPercentsIfValid(), and Swap().

Referenced by IndustryTransportedCargoSorter().

virtual void IndustryDirectoryWindow::OnClick | ( | Point | pt,
|  | int | widget |
| ) |  |  | `[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.

Reimplemented from Window.

Definition at line 912 of file industry_gui.cpp.

References _ctrl_pressed, Scrollbar::cap, IsInsideMM(), Scrollbar::pos, Window::SetDirty(), Window::vscroll, and Point::y.

virtual void IndustryDirectoryWindow::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 941 of file industry_gui.cpp.

References Window::SetDirty().

virtual void IndustryDirectoryWindow::OnResize | ( | Point | new_size,
|  | Point | delta |
| ) |  |  | `[inline, virtual]`

Called when the window got resized.

Parameters:

  | new_size | the new size of the window.
  | delta | the amount of which the window size changed.

Reimplemented from Window.

Definition at line 950 of file industry_gui.cpp.

References Scrollbar::cap, Window::vscroll, and Point::y.

virtual void IndustryDirectoryWindow::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 955 of file industry_gui.cpp.

References Window::InvalidateWidget().

## Field Documentation

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

Initial value:

     {
      STR_SORT_BY_DROPDOWN_NAME,
      STR_SORT_BY_TYPE,
      STR_SORT_BY_PRODUCTION,
      STR_SORT_BY_TRANSPORTED,
      INVALID_STRING_ID
    }

Definition at line 730 of file industry_gui.cpp.

GUIIndustryList::SortFunction *const IndustryDirectoryWindow::sorter_funcs`[static, protected]`

Initial value:

     {
      &IndustryNameSorter,
      &IndustryTypeSorter,
      &IndustryProductionSorter,
      &IndustryTransportedCargoSorter
    }

Definition at line 731 of file industry_gui.cpp.

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

- src/industry_gui.cpp