Public Member Functions | Static Private Member Functions | Private Attributes

# 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.
Scrollbar * | vscroll
uint | displayed_actions_on_previous_painting
| Actions that were available on the previous call to OnPaint().

## Detailed Description

Town authority window.

Definition at line 62 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 119 of file town_gui.cpp.

References _current_text_dir, NWidgetBase::current_x, NWidgetBase::current_y, DrawCompanyIcon(), DrawSprite(), DrawString(), Town::exclusivity, FONT_HEIGHT_NORMAL, GetSpriteSize(), HasBit(), Town::have_ratings, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Window::left, NWidgetBase::pos_x, NWidgetBase::pos_y, Town::ratings, ResizeWindow(), SetDParam(), town, and WD_FRAMERECT_BOTTOM.

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

References _local_company, _town_action_costs, DrawString(), DrawStringMultiLine(), GetMaskOfTownActions(), Scrollbar::GetPosition(), sel_index, SetDParam(), town, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WID_TA_ACTION_INFO, and WID_TA_COMMAND_LIST.

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

References _local_company, CMD_DO_TOWN_ACTION, CMD_MSG, DoCommandP(), FONT_HEIGHT_NORMAL, GetMaskOfTownActions(), GetNthSetBit(), Scrollbar::GetPosition(), Window::GetRowFromWidget(), IsInsideMM(), sel_index, Window::SetDirty(), town, WID_TA_COMMAND_LIST, WID_TA_EXECUTE, and Town::xy.

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

References _local_company, displayed_actions_on_previous_painting, DrawRatings(), Window::DrawWidgets(), GetMaskOfTownActions(), HasBit(), Window::IsShaded(), sel_index, Scrollbar::SetCount(), Window::SetDirty(), Window::SetWidgetDisabledState(), town, and WID_TA_EXECUTE.

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

References SetDParam(), and WID_TA_CAPTION.

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

References _town_action_costs, FONT_HEIGHT_NORMAL, GetStringBoundingBox(), GetStringMultiLineBoundingBox(), max(), maxdim(), SetDParam(), WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WID_TA_ACTION_INFO, WID_TA_COMMAND_LIST, WID_TA_RATING_INFO, and Window::width.

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

- src/town_gui.cpp