Town authority window. More...
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 |
Town authority window.
Definition at line 74 of file town_gui.cpp.
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 128 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(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Window::left, NWidgetBase::pos_x, NWidgetBase::pos_y, Town::ratings, ResizeWindow(), SetDParam(), TD_RTL, 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.
r | Rectangle occupied by the widget. | |
widget | Number of the widget to draw. |
< Draw only the 5 fitting lines
Reimplemented from Window.
Definition at line 195 of file town_gui.cpp.
References _local_company, _town_action_costs, DrawString(), DrawStringMultiLine(), FONT_HEIGHT_NORMAL, GetMaskOfTownActions(), Scrollbar::GetPosition(), sel_index, SetDParam(), town, TWA_ACTION_INFO, TWA_COMMAND_LIST, 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
bits | The value to search in | |
n | The Nth set bit from which we want to know the position |
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.
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 264 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, TWA_COMMAND_LIST, and TWA_EXECUTE.
virtual void TownAuthorityWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 110 of file town_gui.cpp.
References _local_company, DrawRatings(), Window::DrawWidgets(), GetMaskOfTownActions(), HasBit(), Window::IsShaded(), sel_index, Scrollbar::SetCount(), Window::SetWidgetDisabledState(), town, and TWA_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.
widget | Widget number. |
Reimplemented from Window.
Definition at line 190 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.
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 230 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.