# 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 | OnDoubleClick (Point pt, int widget)
| A double click with the left mouse button has been made on the window.
virtual void | OnClick (Point pt, int widget)
| A click with the left mouse button has been made on the window.
void | HandleClick (Point pt, int widget, bool double_click)
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 73 of file town_gui.cpp.

## Member Function Documentation

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

References FOR_EACH_SET_BIT.

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 107 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.

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

References _dynlang, NWidgetBase::current_x, NWidgetBase::current_y, DrawSprite(), DrawString(), FONT_HEIGHT_NORMAL, HasBit(), 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::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 180 of file town_gui.cpp.

References SetDParam().

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.

Reimplemented from Window.

Definition at line 185 of file town_gui.cpp.

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

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

References _town_action_costs, FONT_HEIGHT_NORMAL, GetStringBoundingBox(), GetStringMultiLineBoundingBox(), Dimension::height, 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, Window::width, and Dimension::width.

virtual void TownAuthorityWindow::OnDoubleClick | ( | Point | pt,
|  | int | widget |
| ) |  |  | `[inline, virtual]`

A double 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 255 of file town_gui.cpp.

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

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

- src/town_gui.cpp