Public Member Functions | Private Attributes

# BuildTreesWindow Class Reference

The build trees window. More...

Inheritance diagram for BuildTreesWindow:

## Public Member Functions
| BuildTreesWindow (const WindowDesc *desc, WindowNumber window_number)
Dimension | GetMaxTreeSpriteSize ()
| Calculate the maximum size of all tree sprites.
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 | 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 | OnPlaceObject (Point pt, TileIndex tile)
| The user clicked some place on the map when a tile highlight mode has been set.
virtual void | OnPlaceDrag (ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
| The user is dragging over the map when the tile highlight mode has been set.
virtual void | OnPlaceMouseUp (ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
| The user has dragged over the map when the tile highlight mode has been set.
virtual void | OnInit ()
| Initialize the window data.
virtual void | OnTimeout ()
| Called when this window's timeout has been reached.
virtual void | OnPlaceObjectAbort ()
| The user cancelled a tile highlight mode that has been set.
## Private Attributes
uint16 | base
| Base tree number used for drawing the window.
uint16 | count
| Number of different trees available.
TreeType | tree_to_plant
| Tree number to plant, `TREE_INVALID` for a random tree.

## Detailed Description

The build trees window.

Definition at line 48 of file tree_gui.cpp.

## Member Function Documentation

virtual void BuildTreesWindow::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 108 of file tree_gui.cpp.

References base, count, DrawSprite(), WD_FRAMERECT_LEFT, WID_BT_TYPE_11, and WID_BT_TYPE_34.

Dimension BuildTreesWindow::GetMaxTreeSpriteSize | ( |  | ) | `[inline]`

Calculate the maximum size of all tree sprites.

Returns:
  Dimension of the largest tree sprite

Definition at line 65 of file tree_gui.cpp.

References base, count, GetSpriteSize(), and lengthof.

Referenced by UpdateWidgetSize().

virtual void BuildTreesWindow::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 117 of file tree_gui.cpp.

References base, count, HandlePlacePushButton(), HT_RECT, Window::LowerWidget(), MarkWholeScreenDirty(), PlaceTreesRandomly(), Window::SetTimeout(), tree_to_plant, WID_BT_MANY_RANDOM, WID_BT_TYPE_11, WID_BT_TYPE_12, WID_BT_TYPE_13, WID_BT_TYPE_14, WID_BT_TYPE_21, WID_BT_TYPE_22, WID_BT_TYPE_23, WID_BT_TYPE_24, WID_BT_TYPE_31, WID_BT_TYPE_32, WID_BT_TYPE_33, WID_BT_TYPE_34, and WID_BT_TYPE_RANDOM.

virtual void BuildTreesWindow::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 103 of file tree_gui.cpp.

References Window::DrawWidgets().

virtual void BuildTreesWindow::OnPlaceDrag | ( | ViewportPlaceMethod | select_method,
|  | ViewportDragDropSelectionProcess | select_proc,
|  | Point | pt |
| ) |  |  | `[inline, virtual]`

The user is dragging over the map when the tile highlight mode has been set.

Parameters:

  | select_method | the method of selection (allowed directions)
  | select_proc | what will be created when the drag is over.
  | pt | the exact point on the map where the mouse is.

Reimplemented from Window.

Definition at line 152 of file tree_gui.cpp.

References VpSelectTilesWithMethod().

virtual void BuildTreesWindow::OnPlaceMouseUp | ( | ViewportPlaceMethod | select_method,
|  | ViewportDragDropSelectionProcess | select_proc,
|  | Point | pt,
|  | TileIndex | start_tile,
|  | TileIndex | end_tile |
| ) |  |  | `[inline, virtual]`

The user has dragged over the map when the tile highlight mode has been set.

Parameters:

  | select_method | the method of selection (allowed directions)
  | select_proc | what should be created.
  | pt | the exact point on the map where the mouse was released.
  | start_tile | the begin tile of the drag.
  | end_tile | the end tile of the drag.

Reimplemented from Window.

Definition at line 157 of file tree_gui.cpp.

References CMD_MSG, CMD_PLANT_TREE, DDSP_PLANT_TREES, DoCommandP(), and tree_to_plant.

virtual void BuildTreesWindow::OnPlaceObject | ( | Point | pt,
|  | TileIndex | tile |
| ) |  |  | `[inline, virtual]`

The user clicked some place on the map when a tile highlight mode has been set.

Parameters:

  | pt | the exact point on the map that has been clicked.
  | tile | the tile on the map that has been clicked.

Reimplemented from Window.

Definition at line 146 of file tree_gui.cpp.

References DDSP_PLANT_TREES, VPM_X_AND_Y_LIMITED, and VpStartPlaceSizing().

virtual void BuildTreesWindow::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 85 of file tree_gui.cpp.

References GetMaxTreeSpriteSize(), WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WID_BT_MANY_RANDOM, WID_BT_TYPE_11, and WID_BT_TYPE_34.

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

- src/tree_gui.cpp