Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

# BuildIndustryWindow Class Reference

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

Inheritance diagram for BuildIndustryWindow:

## Public Member Functions
virtual void | OnInit ()
| Notification that the nested widget tree gets initialized.
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 | 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, bool gui_scope=true)
| Some data on this window has become invalid.
## Private Member Functions
void | SetupArrays ()
void | SetButtons ()
| Update status of the fund and display-chain widgets.
## 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_PROBABILITY (if ever)
Scrollbar * | vscroll
## 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 198 of file industry_gui.cpp.

## Member Function Documentation

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

References IndustrySpec::accepts_cargo, CALLBACK_FAILED, IndustrySpec::callback_mask, CBID_INDUSTRY_FUND_MORE_TEXT, CBM_IND_FUND_MORE_TEXT, count, CST_FUND, CT_INVALID, DrawString(), DrawStringMultiLine(), ErrorUnknownCallbackResult(), CargoSpec::Get(), GetAllCargoSuffixes(), Scrollbar::GetCapacity(), IndustrySpec::GetConstructionCost(), GetGRFStringID(), GetIndustryCallback(), GetIndustrySpec(), Scrollbar::GetPosition(), GfxFillRect(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), index, INVALID_INDUSTRYTYPE, INVALID_TILE, Window::left, lengthof, IndustrySpec::map_colour, MATRIX_TEXT_OFFSET, CargoSpec::name, IndustrySpec::name, PC_BLACK, PC_WHITE, Window::resize, selected_index, selected_type, SetDParam(), SetDParamStr(), StartTextRefStackUsage(), ResizeInfo::step_height, StopTextRefStackUsage(), WD_MATRIX_RIGHT, WD_MATRIX_TOP, WID_DPI_INFOPANEL, and WID_DPI_MATRIX_WIDGET.

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

References _generating_world, _settings_game, CMD_BUILD_INDUSTRY, CMD_MSG, GameSettings::construction, count, DoCommandP(), enabled, GenerateIndustries(), TileHighlightData::GetCallbackWnd(), GetIndustrySpec(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), Scrollbar::GetScrolledRowFromWidget(), Window::HandleButtonClick(), HandlePlacePushButton(), HT_RECT, index, INVALID_INDUSTRYTYPE, IndustrySpec::IsRawIndustry(), Window::RaiseButtons(), ConstructionSettings::raw_industry_construction, selected_index, selected_type, SetButtons(), Window::SetDirty(), ShowErrorMessage(), ShowIndustryCargoesWindow(), WID_DPI_DISPLAY_WIDGET, WID_DPI_FUND_WIDGET, WID_DPI_MATRIX_WIDGET, and WL_INFO.

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

Notification that the nested widget tree gets initialized.

The event can be used to perform general computations.

Note:
  nested_root and/or nested_array (normally accessed via GetWidget()) may not exist during this call.

Reimplemented from Window.

Definition at line 284 of file industry_gui.cpp.

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

Some data on this window has become invalid.

Parameters:

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

References _settings_game, GameSettings::difficulty, enabled, GetIndustrySpec(), DifficultySettings::industry_density, INVALID_INDUSTRYTYPE, selected_index, selected_type, and SetButtons().

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

References _current_company, _generating_world, _settings_client, CcBuildIndustry(), CMD_BUILD_INDUSTRY, CMD_MSG, DoCommandP(), GetIndustrySpec(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), ClientSettings::gui, IndustrySpec::name, IndustrySpec::num_table, OWNER_NONE, GUISettings::persistent_buildingtools, Backup< T >::Restore(), selected_type, SetDParam(), ShowErrorMessage(), and WL_INFO.

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

References Scrollbar::GetCapacity(), MAT_COL_START, Scrollbar::SetCapacityFromWidget(), and WID_DPI_MATRIX_WIDGET.

void BuildIndustryWindow::SetButtons | ( |  | ) | `[inline, private]`

Update status of the fund and display-chain widgets.

Definition at line 261 of file industry_gui.cpp.

References enabled, INVALID_INDUSTRYTYPE, selected_index, selected_type, Window::SetWidgetDisabledState(), WID_DPI_DISPLAY_WIDGET, and WID_DPI_FUND_WIDGET.

Referenced by OnClick(), OnInvalidateData(), and OnTick().

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

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

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

References _loaded_newgrf_features, IndustrySpec::accepts_cargo, count, CST_FUND, CT_INVALID, FONT_HEIGHT_NORMAL, CargoSpec::Get(), GetAllCargoSuffixes(), GetIndustrySpec(), GetStringBoundingBox(), GRFLoadedFeatures::has_newindustries, Window::height, index, INVALID_INDUSTRYTYPE, lengthof, MATRIX_TEXT_OFFSET, maxdim(), CargoSpec::name, SetDParam(), SetDParamStr(), WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_MATRIX_TOP, WID_DPI_FUND_WIDGET, WID_DPI_INFOPANEL, and WID_DPI_MATRIX_WIDGET.

## Field Documentation

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

The offset for the text in the matrix.

Definition at line 209 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