# TownAuthorityWindow Struct Reference

Town authority window. More...

Inheritance diagram for TownAuthorityWindow:

## Public Member Functions

| TownAuthorityWindow (const WindowDesc *desc, WindowNumber window_number)
virtual void | OnPaint ()
| The window must be repainted.
void | DrawRatings ()
| Draw the contents of the ratings panel.
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 | OnHundredthTick ()
| Called once every 100 (game) ticks.

## Static Private Member Functions

static int | GetNthSetBit (uint32 bits, int n)
| Get the position of the Nth set bit.

## Private Attributes

Town * | town
| Town being displayed.
int | sel_index
| Currently selected town action, `0` to `TACT_COUNT-1`, `-1` means no action selected.

## Detailed Description

Town authority window.

Definition at line 75 of file town_gui.cpp.

## Member Function Documentation

void TownAuthorityWindow::DrawRatings | ( |  | ) | `[inline]`

Draw the contents of the ratings panel.

May request a resize of the window if the contents does not fit.

Definition at line 127 of file town_gui.cpp.

References _dynlang, NWidgetBase::current_x, NWidgetBase::current_y, DrawSprite(), DrawString(), Town::exclusivity, FONT_HEIGHT_NORMAL, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Window::left, NWidgetBase::pos_x, NWidgetBase::pos_y, ResizeWindow(), SetDParam(), TD_RTL, DynamicLanguages::text_dir, town, TWA_RATING_INFO, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and WD_FRAMERECT_TOP.

Referenced by OnPaint().

virtual void TownAuthorityWindow::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.

< Draw only the 5 fitting lines

Reimplemented from Window.

Definition at line 187 of file town_gui.cpp.

References _town_action_costs, DrawString(), DrawStringMultiLine(), FONT_HEIGHT_NORMAL, GetMaskOfTownActions(), Scrollbar::GetPosition(), sel_index, SetDParam(), town, TWA_ACTION_INFO, TWA_COMMAND_LIST, Window::vscroll, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and WD_FRAMERECT_TOP.

static int TownAuthorityWindow::GetNthSetBit | ( | uint32 | bits,
|  | int | n |
| ) |  |  | `[inline, static, private]`

Get the position of the Nth set bit.

If there is no Nth bit set return -1

Parameters:

  | bits | The value to search in
  | n | The Nth set bit from which we want to know the position

Returns:
  The position of the Nth set bit

Definition at line 89 of file town_gui.cpp.

References FOR_EACH_SET_BIT.

Referenced by OnClick().

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

References CMD_DO_TOWN_ACTION, CMD_MSG, DoCommandP(), FONT_HEIGHT_NORMAL, GetMaskOfTownActions(), GetNthSetBit(), Scrollbar::GetPosition(), IsInsideMM(), sel_index, Window::SetDirty(), town, TWA_COMMAND_LIST, TWA_EXECUTE, and Window::vscroll.

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

References DrawRatings(), Window::DrawWidgets(), GetMaskOfTownActions(), HasBit(), Window::IsShaded(), sel_index, Scrollbar::SetCount(), Window::SetWidgetDisabledState(), town, TWA_EXECUTE, and Window::vscroll.

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

References SetDParam().

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

References _town_action_costs, FONT_HEIGHT_NORMAL, GetStringBoundingBox(), GetStringMultiLineBoundingBox(), max(), maxdim(), SetDParam(), TACT_COUNT, TWA_ACTION_INFO, TWA_COMMAND_LIST, TWA_RATING_INFO, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, and Window::width.

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

- src/town_gui.cpp