# NewGRFWindow Struct Reference

Window for showing NewGRF files. More...

Inheritance diagram for NewGRFWindow:

## Public Member Functions
| NewGRFWindow (const WindowDesc *desc, bool editable, bool show_params, bool exec_changes, GRFConfig **config)
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 | OnResize ()
| Called after the window got resized.
virtual void | SetStringParameters (int widget) const
| Initialize string parameters for a widget.
virtual void | OnPaint ()
| The window must be repainted.
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.
virtual void | OnDropdownSelect (int widget, int index)
| A dropdown option associated to this window has been selected.
virtual void | OnQueryTextFinished (char *str)
| The query window opened from this window has closed.
virtual void | OnInvalidateData (int data=0)
| Some data on this window has become invalid.
## Data Fields
GRFConfig ** | orig_list
| grf list the window is shown with
GRFConfig * | list
| temporary grf list to which changes are made
GRFConfig * | sel
| selected grf item
bool | editable
| is the window editable
bool | show_params
| are the grf-parameters shown in the info-panel
bool | execute
| on pressing 'apply changes' are grf changes applied immediately, or only list is updated
int | query_widget
| widget that opened a query
int | preset
| selected preset

## Detailed Description

Window for showing NewGRF files.

Definition at line 552 of file newgrf_gui.cpp.

## Member Function Documentation

virtual void NewGRFWindow::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 652 of file newgrf_gui.cpp.

References _dynlang, DrawSprite(), DrawString(), GRFConfig::error, GRFConfig::filename, GRFConfig::flags, FONT_HEIGHT_NORMAL, GCF_COMPATIBLE, GCF_STATIC, GCS_ACTIVATED, GCS_DISABLED, GCS_NOT_FOUND, HasBit(), Scrollbar::IsVisible(), GRFConfig::name, GRFConfig::next, Window::resize, sel, GRFConfig::status, ResizeInfo::step_height, StrEmpty(), TD_RTL, DynamicLanguages::text_dir, Window::vscroll, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, and WD_MATRIX_TOP.

virtual void NewGRFWindow::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 711 of file newgrf_gui.cpp.

References _network_available, SmallVector< T, S >::Append(), BSWAP32(), CONTENT_TYPE_NEWGRF, CopyGRFConfigList(), CS_ALPHANUMERAL, CS_NUMERAL_SPACE, Window::DeleteChildWindows(), DeleteWindowByClass(), ContentInfo::DOES_NOT_EXIST, execute, GRFConfig::filename, GRFConfig::flags, GamelogGetOriginalGRFMD5Checksum(), GCF_COMPATIBLE, GCS_NOT_FOUND, Scrollbar::GetPosition(), GRFIdentifier::grfid, HasBit(), INVALID_STRING_ID, Window::InvalidateData(), lastof, SmallVector< T, S >::Length(), lengthof, GRFIdentifier::md5sum, ContentInfo::md5sum, GRFConfig::name, ContentInfo::name, NewGRFConfirmationCallback(), GRFConfig::next, orig_list, preset, query_widget, ReloadNewGRFData(), Window::resize, Scrollbar::ScrollTowards(), sel, Window::SetDirty(), SetDParamStr(), ShowDropDownList(), ShowErrorMessage(), ShowNetworkContentListWindow(), ShowQuery(), ShowQueryString(), ContentInfo::state, GRFConfig::status, ResizeInfo::step_height, ttd_strlcpy(), ContentInfo::type, ContentInfo::unique_id, Window::vscroll, and GRFConfig::windows_paletted.

virtual void NewGRFWindow::OnDropdownSelect | ( | int | widget,
|  | int | index |
| ) |  |  | `[inline, virtual]`

A dropdown option associated to this window has been selected.

Parameters:

  | widget | the widget (button) that the dropdown is associated with.
  | index | the element in the dropdown that is selected.

Reimplemented from Window.

Definition at line 885 of file newgrf_gui.cpp.

References Window::InvalidateData(), preset, and sel.

virtual void NewGRFWindow::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 938 of file newgrf_gui.cpp.

References Window::DisableWidget(), editable, GRFConfig::filename, GRFConfig::flags, GCF_COMPATIBLE, GCS_NOT_FOUND, GCS_UNKNOWN, Scrollbar::GetCapacity(), GRFIdentifier::grfid, HasBit(), GRFConfig::info, GRFConfig::IsOpenTTDBaseGRF(), MAT_COL_START, MAT_ROW_START, GRFIdentifier::md5sum, GRFConfig::name, GRFConfig::next, preset, sel, Scrollbar::SetCapacityFromWidget(), Scrollbar::SetCount(), Window::SetWidgetDisabledState(), Window::SetWidgetsDisabledState(), GRFConfig::status, Window::vscroll, and WIDGET_LIST_END.

virtual void NewGRFWindow::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 647 of file newgrf_gui.cpp.

References Window::DrawWidgets().

virtual void NewGRFWindow::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 902 of file newgrf_gui.cpp.

References Window::InvalidateData(), SmallVector< T, S >::Length(), lengthof, GRFConfig::num_params, GRFConfig::param, parse_intlist(), preset, query_widget, and sel.

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

Called after the window got resized.

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

Reimplemented from Window.

Definition at line 627 of file newgrf_gui.cpp.

References Scrollbar::GetCapacity(), MAT_COL_START, MAT_ROW_START, Scrollbar::SetCapacityFromWidget(), and Window::vscroll.

virtual void NewGRFWindow::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 633 of file newgrf_gui.cpp.

References preset, SetDParam(), and SetDParamStr().

virtual void NewGRFWindow::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 592 of file newgrf_gui.cpp.

References FONT_HEIGHT_NORMAL, GetStringBoundingBox(), SmallVector< T, S >::Length(), max(), maxdim(), SetDParamStr(), WD_FRAMERECT_BOTTOM, WD_FRAMERECT_TOP, WD_MATRIX_BOTTOM, and WD_MATRIX_TOP.

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

- src/newgrf_gui.cpp