# TownViewWindow Struct Reference

Inheritance diagram for TownViewWindow:

## Public Types
enum | { TVW_HEIGHT_NORMAL = 150 }
## Public Member Functions
| TownViewWindow (const WindowDesc *desc, WindowNumber window_number)
virtual void | OnPaint ()
| The window must be repainted.
virtual void | SetStringParameters (int widget) const
| Initialize string parameters for a widget.
const CargoSpec * | FindFirstCargoWithTownEffect (TownEffect effect) const
| Determines the first cargo with a certain town effect.
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.
bool | CanDeleteTown () const
| Can we delete the town? Or in other words, does anything refer to this town?
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.
uint | GetDesiredInfoHeight () const
| Gets the desired height for the information panel.
void | ResizeWindowAsNeeded ()
virtual void | OnResize ()
| Called after the window got resized.
virtual void | OnInvalidateData (int data=0)
| Some data on this window has become invalid.
virtual void | OnQueryTextFinished (char *str)
| The query window opened from this window has closed.
## Private Attributes
Town * | town
| Town displayed by the window.

## Detailed Description

Definition at line 310 of file town_gui.cpp.

## Member Function Documentation

bool TownViewWindow::CanDeleteTown | ( |  | ) | const`[inline]`

Can we delete the town? Or in other words, does anything refer to this town?

Returns:
  true if it's possible

Definition at line 476 of file town_gui.cpp.

References Station::airport_tile, CMD_LANDSCAPE_CLEAR, DC_NONE, DoCommand(), FACIL_AIRPORT, BaseStation::facilities, CommandCost::Failed(), GetTileType(), GetTownIndex(), HasTownOwnedRoad(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IsTileOwner(), MapSize(), MP_ROAD, MP_TUNNELBRIDGE, OWNER_TOWN, town, and BaseStation::town.

Referenced by OnClick().

virtual void TownViewWindow::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 360 of file town_gui.cpp.

References _dynlang, _settings_game, CT_INVALID, DrawString(), GameSettings::economy, FindFirstCargoWithTownEffect(), FONT_HEIGHT_NORMAL, GameSettings::game_creation, GetSnowLine(), GetTropicZone(), GameCreationSettings::landscape, LowestSnowLine(), Town::MaxTownNoise(), SetDParam(), EconomySettings::station_noise_level, TD_RTL, TE_FOOD, TE_WATER, DynamicLanguages::text_dir, TilePixelHeight(), town, TROPICZONE_DESERT, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and WD_FRAMERECT_TOP.

const CargoSpec* TownViewWindow::FindFirstCargoWithTownEffect | ( | TownEffect | effect | ) | const`[inline]`

Determines the first cargo with a certain town effect.

Parameters:

  | effect | Town effect of interest

Returns:
  first active cargo slot with that effect

Definition at line 351 of file town_gui.cpp.

References CargoSpec::town_effect.

Referenced by DrawWidget().

uint TownViewWindow::GetDesiredInfoHeight | ( |  | ) | const`[inline]`

Gets the desired height for the information panel.

Returns:
  the desired height in pixels.

Definition at line 534 of file town_gui.cpp.

References _settings_game, GameSettings::economy, FONT_HEIGHT_NORMAL, GameSettings::game_creation, GetTropicZone(), GameCreationSettings::landscape, LowestSnowLine(), EconomySettings::station_noise_level, TilePixelHeight(), town, TROPICZONE_DESERT, WD_FRAMERECT_BOTTOM, and WD_FRAMERECT_TOP.

Referenced by UpdateWidgetSize().

virtual void TownViewWindow::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 437 of file town_gui.cpp.

References _ctrl_pressed, CanDeleteTown(), CS_ALPHANUMERAL, ExpandTown(), INVALID_STRING_ID, MAX_LENGTH_TOWN_NAME_BYTES, MAX_LENGTH_TOWN_NAME_PIXELS, QSF_ENABLE_DEFAULT, SetDParam(), ShowErrorMessage(), ShowQueryString(), and town.

virtual void TownViewWindow::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 572 of file town_gui.cpp.

References Window::SetDirty().

virtual void TownViewWindow::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 336 of file town_gui.cpp.

References Window::DrawWidgets().

virtual void TownViewWindow::OnQueryTextFinished | ( | char * | str | ) | `[inline, virtual]`

The query window opened from this window has closed.

Parameters:

  | 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 579 of file town_gui.cpp.

References CMD_MSG, CMD_RENAME_TOWN, and DoCommandP().

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

Called after the window got resized.

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

Reimplemented from Window.

Definition at line 564 of file town_gui.cpp.

References NWidgetViewport::UpdateViewportCoordinates(), and Window::viewport.

virtual void TownViewWindow::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 341 of file town_gui.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, SetDParam(), and town.

virtual void TownViewWindow::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 521 of file town_gui.cpp.

References GetDesiredInfoHeight().

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

- src/town_gui.cpp