# BuildIndustryWindow Class Reference

Build (fund or prospect) a new industry,. More...

Inheritance diagram for BuildIndustryWindow:

## Public Member Functions
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 | 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 | OnPaint ()
| The window must be repainted.
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 | OnResize ()
| Called after the window got resized.
virtual void | OnPlaceObject (Point pt, TileIndex tile)
| The user clicked some place on the map when a tile highlight mode has been set.
virtual void | OnTick ()
| Called once per (game) tick.
virtual void | OnTimeout ()
| Called when this window's timeout has been reached.
virtual void | OnPlaceObjectAbort ()
| The user cancelled a tile highlight mode that has been set.
virtual void | OnInvalidateData (int data=0)
| Some data on this window has become invalid.
## Private Member Functions
void | SetupArrays ()
## Private Attributes
int | selected_index
| index of the element in the matrix
IndustryType | selected_type
| industry corresponding to the above index
uint16 | callback_timer
| timer counter for callback eventual verification
bool | timer_enabled
| timer can be used
uint16 | count
| How many industries are loaded.
IndustryType | index [NUM_INDUSTRYTYPES+1]
| Type of industry, in the order it was loaded.
bool | enabled [NUM_INDUSTRYTYPES+1]
| availability state, coming from CBID_INDUSTRY_AVAILABLE (if ever)
## Static Private Attributes
static const int | MATRIX_TEXT_OFFSET = 17
| The offset for the text in the matrix.

## Detailed Description

Build (fund or prospect) a new industry,.

Definition at line 135 of file industry_gui.cpp.

## Member Function Documentation

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

References IndustrySpec::accepts_cargo, count, CST_FUND, CT_INVALID, FONT_HEIGHT_NORMAL, CargoSpec::Get(), GetAllCargoSuffixes(), GetIndustrySpec(), GetStringBoundingBox(), Window::height, Dimension::height, index, INVALID_INDUSTRYTYPE, lengthof, MATRIX_TEXT_OFFSET, maxdim(), CargoSpec::name, IndustrySpec::produced_cargo, SetDParam(), SetDParamStr(), WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WD_MATRIX_BOTTOM, WD_MATRIX_TOP, and Dimension::width.

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

References _settings_game, GameSettings::construction, GetIndustrySpec(), index, IndustrySpec::IsRawIndustry(), ConstructionSettings::raw_industry_construction, selected_index, and SetDParam().

virtual void BuildIndustryWindow::DrawWidget | ( | const Rect & | r,
|  | int | widget |
| ) |  |  | const`[inline, virtual]`

Draw the contents of a nested widget.

Parameters:

  | r | Rectangle occupied by the widget.
  | widget | Number of the widget to draw.

Note:
  This method may not change any state, it may only use drawing functions.

Reimplemented from Window.

Definition at line 298 of file industry_gui.cpp.

References IndustrySpec::accepts_cargo, Rect::bottom, CALLBACK_FAILED, IndustrySpec::callback_mask, CBID_INDUSTRY_FUND_MORE_TEXT, CBM_IND_FUND_MORE_TEXT, count, CST_FUND, CT_INVALID, DrawString(), DrawStringMultiLine(), FONT_HEIGHT_NORMAL, CargoSpec::Get(), GetAllCargoSuffixes(), Scrollbar::GetCapacity(), IndustrySpec::GetConstructionCost(), GetGRFStringID(), GetIndustrySpec(), Scrollbar::GetPosition(), GfxFillRect(), IndustrySpec::grf_prop, GRFFileProps::grffile, GRFFile::grfid, HasBit(), index, INVALID_INDUSTRYTYPE, INVALID_TILE, Window::left, Rect::left, lengthof, IndustrySpec::map_colour, MATRIX_TEXT_OFFSET, CargoSpec::name, IndustrySpec::name, IndustrySpec::produced_cargo, Window::resize, Rect::right, selected_index, selected_type, SetDParam(), SetDParamStr(), ResizeInfo::step_height, Rect::top, Window::vscroll, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WD_MATRIX_LEFT, WD_MATRIX_RIGHT, and WD_MATRIX_TOP.

virtual void BuildIndustryWindow::OnPaint | ( |  | ) | `[inline, virtual]`

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 389 of file industry_gui.cpp.

References Window::DrawWidgets().

virtual void BuildIndustryWindow::OnClick | ( | Point | pt,
|  | int | widget,
|  | int | click_count |
| ) |  |  | `[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.
  | click_count | Number of fast consecutive clicks at same position

Reimplemented from Window.

Definition at line 394 of file industry_gui.cpp.

References _settings_game, CMD_BUILD_INDUSTRY, CMD_MSG, GameSettings::construction, count, DoCommandP(), enabled, GenerateIndustries(), GetIndustrySpec(), Scrollbar::GetPosition(), Window::HandleButtonClick(), HandlePlacePushButton(), HT_RECT, index, INVALID_INDUSTRYTYPE, IndustrySpec::IsRawIndustry(), Window::RaiseButtons(), ConstructionSettings::raw_industry_construction, Window::resize, selected_index, selected_type, Window::SetDirty(), Window::SetWidgetDisabledState(), ShowErrorMessage(), ResizeInfo::step_height, Window::vscroll, and Point::y.

virtual void BuildIndustryWindow::OnResize | ( |  | ) | `[inline, virtual]`

Called after the window got resized.

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

Reimplemented from Window.

Definition at line 442 of file industry_gui.cpp.

References Scrollbar::GetCapacity(), MAT_COL_START, MAT_ROW_START, Scrollbar::SetCapacityFromWidget(), and Window::vscroll.

virtual void BuildIndustryWindow::OnPlaceObject | ( | Point | pt,
|  | TileIndex | tile |
| ) |  |  | `[inline, virtual]`

The user clicked some place on the map when a tile highlight mode has been set.

Parameters:

  | pt | the exact point on the map that has been clicked.
  | tile | the tile on the map that has been clicked.

Reimplemented from Window.

Definition at line 449 of file industry_gui.cpp.

References _settings_client, CMD_BUILD_INDUSTRY, CMD_MSG, DoCommandP(), GetIndustrySpec(), ClientSettings::gui, IndustrySpec::name, IndustrySpec::num_table, OWNER_NONE, GUISettings::persistent_buildingtools, selected_type, SetDParam(), ShowErrorMessage(), Point::x, and Point::y.

virtual void BuildIndustryWindow::OnInvalidateData | ( | int | data = `0` | ) | `[inline, virtual]`

Some data on this window has become invalid.

Parameters:

  | data | information about the changed data.

Reimplemented from Window.

Definition at line 517 of file industry_gui.cpp.

References _settings_game, GameSettings::difficulty, enabled, GetIndustrySpec(), INVALID_INDUSTRYTYPE, DifficultySettings::number_industries, selected_index, selected_type, and Window::SetWidgetDisabledState().

## Field Documentation

const int BuildIndustryWindow::MATRIX_TEXT_OFFSET = 17`[static, private]`

The offset for the text in the matrix.

Definition at line 145 of file industry_gui.cpp.

Referenced by DrawWidget(), and UpdateWidgetSize().

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

- src/industry_gui.cpp