Public Member Functions | Private Member Functions | Private Attributes

# LinkGraphLegendWindow Struct Reference

Menu window to select cargoes and companies to show in a link graph overlay. More...

`#include <linkgraph_gui.h>`

Inheritance diagram for LinkGraphLegendWindow:

## Public Member Functions
| LinkGraphLegendWindow (WindowDesc *desc, int window_number)
void | SetOverlay (LinkGraphOverlay *overlay)
| Set the overlay belonging to this menu and import its company/cargo settings.
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 | 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 | OnInvalidateData (int data=0, bool gui_scope=true)
| Invalidate the data of this window if the cargoes or companies have changed.
## Private Member Functions
void | UpdateOverlayCompanies ()
| Update the overlay with the new company selection.
void | UpdateOverlayCargoes ()
| Update the overlay with the new cargo selection.
## Private Attributes
LinkGraphOverlay * | overlay

## Detailed Description

Menu window to select cargoes and companies to show in a link graph overlay.

Definition at line 98 of file linkgraph_gui.h.

## Member Function Documentation

void LinkGraphLegendWindow::DrawWidget | ( | const Rect & | r,
|  | int | widget |
| ) |  |  | const`[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 473 of file linkgraph_gui.cpp.

References CargoSpec::abbrev, LinkGraph::cargo, DrawCompanyIcon(), DrawString(), FONT_HEIGHT_SMALL, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::Get(), GetSpriteSize(), GfxFillRect(), IsInsideMM(), Window::IsWidgetDisabled(), LinkGraphOverlay::LINK_COLOURS, and SA_HOR_CENTER.

void LinkGraphLegendWindow::OnClick | ( | Point | pt,
|  | int | widget,
|  | int | click_count |
| ) |  |  | `[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 529 of file linkgraph_gui.cpp.

References IsInsideMM(), Window::IsWidgetDisabled(), Window::SetDirty(), Window::SetWidgetLoweredState(), Window::ToggleWidgetLoweredState(), UpdateOverlayCargoes(), and UpdateOverlayCompanies().

void LinkGraphLegendWindow::OnInvalidateData | ( | int | data = `0`,
|  | bool | gui_scope = `true` |
| ) |  |  | `[virtual]`

Invalidate the data of this window if the cargoes or companies have changed.

Parameters:

  | data | ignored
  | gui_scope | ignored

Reimplemented from Window.

Definition at line 564 of file linkgraph_gui.cpp.

References COMPANY_FIRST, CargoSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), and Window::SetWidgetDisabledState().

void LinkGraphLegendWindow::SetOverlay | ( | LinkGraphOverlay * | overlay | ) |

Set the overlay belonging to this menu and import its company/cargo settings.

overlay New overlay for this menu.

Definition at line 428 of file linkgraph_gui.cpp.

References LinkGraphOverlay::GetCargoMask(), LinkGraphOverlay::GetCompanyMask(), HasBit(), Window::IsWidgetDisabled(), and Window::SetWidgetLoweredState().

void LinkGraphLegendWindow::UpdateWidgetSize | ( | int | widget,
|  | Dimension * | size,
|  | const Dimension & | padding,
|  | Dimension * | fill,
|  | Dimension * | resize |
| ) |  |  | `[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 444 of file linkgraph_gui.cpp.

References CargoSpec::abbrev, LinkGraph::cargo, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::Get(), GetStringBoundingBox(), IsInsideMM(), CargoSpec::IsValid(), maxdim(), WD_FRAMERECT_LEFT, and WD_FRAMERECT_TOP.

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

- src/linkgraph/linkgraph_gui.h
- src/linkgraph/linkgraph_gui.cpp