# main_gui.cpp File Reference

Handling of the main viewport. More...

`#include "stdafx.h"`
`#include "currency.h"`
`#include "spritecache.h"`
`#include "window_gui.h"`
`#include "window_func.h"`
`#include "textbuf_gui.h"`
`#include "viewport_func.h"`
`#include "command_func.h"`
`#include "console_gui.h"`
`#include "genworld.h"`
`#include "transparency_gui.h"`
`#include "functions.h"`
`#include "sound_func.h"`
`#include "transparency.h"`
`#include "strings_func.h"`
`#include "zoom_func.h"`
`#include "company_base.h"`
`#include "company_func.h"`
`#include "toolbar_gui.h"`
`#include "statusbar_gui.h"`
`#include "tilehighlight_func.h"`
`#include "network/network.h"`
`#include "network/network_func.h"`
`#include "network/network_gui.h"`
`#include "network/network_base.h"`
`#include "table/sprites.h"`
`#include "table/strings.h"`

Go to the source code of this file.

## Data Structures
struct | MainWindow
## Enumerations
enum | MainWindowWidgets { MW_VIEWPORT }
| Widgets of the main window. More...
## Functions
void | CcGiveMoney (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
void | HandleOnEditText (const char *str)
bool | HandlePlacePushButton (Window *w, int widget, CursorID cursor, HighLightStyle mode, PlaceProc *placeproc)
| This code is shared for the majority of the pushbuttons.
void | CcPlaySound10 (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
void | ShowNetworkGiveMoneyWindow (CompanyID company)
bool | DoZoomInOutWindow (int how, Window *w)
void | ZoomInOrOutToCursorWindow (bool in, Window *w)
void | ShowSelectGameWindow ()
void | SetupColoursAndInitialWindow ()
void | ShowVitalWindows ()
void | GameSizeChanged ()
| Size of the application screen changed.
## Variables
static int | _rename_id = 1
static int | _rename_what = -1
static struct NWidgetPart | _nested_main_window_widgets []
static const WindowDesc | _main_window_desc (WDP_MANUAL, 0, 0, WC_MAIN_WINDOW, WC_NONE, 0, _nested_main_window_widgets, lengthof(_nested_main_window_widgets))

## Detailed Description

Handling of the main viewport.

Definition in file main_gui.cpp.

## Enumeration Type Documentation

enum MainWindowWidgets

Widgets of the main window.

Enumerator:

  MW_VIEWPORT | Main window viewport.

Definition at line 191 of file main_gui.cpp.

## Function Documentation

void GameSizeChanged | ( |  | ) |

Size of the application screen changed.

Adapt the game screen-size, re-allocate the open windows, and repaint everything

Definition at line 438 of file main_gui.cpp.

References MarkWholeScreenDirty(), and RelocateAllWindows().

bool HandlePlacePushButton | ( | Window * | w,
|  | int | widget,
|  | CursorID | cursor,
|  | HighLightStyle | mode,
|  | PlaceProc * | placeproc |
| ) |  |  |

This code is shared for the majority of the pushbuttons.

Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters

Parameters:

  | w | Window which called the function
  | widget | ID of the widget (=button) that called this function
  | cursor | How should the cursor image change? E.g. cursor with depot image in it
  | mode | Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground
  | placeproc | Procedure which will be called when someone clicks on the map

Returns:
  true if the button is clicked, false if it's unclicked

Definition at line 95 of file main_gui.cpp.

References Window::IsWidgetDisabled(), Window::IsWidgetLowered(), Window::LowerWidget(), Window::SetDirty(), Window::window_class, and Window::window_number.

Referenced by BuildRailClick_AutoRail(), BuildRailClick_AutoSignals(), BuildRailClick_Bridge(), BuildRailClick_Convert(), BuildRailClick_Demolish(), BuildRailClick_Depot(), BuildRailClick_E(), BuildRailClick_N(), BuildRailClick_NE(), BuildRailClick_NW(), BuildRailClick_Station(), BuildRailClick_Tunnel(), BuildRailClick_Waypoint(), BuildRoadClick_AutoRoad(), BuildRoadClick_X_Dir(), BuildRoadClick_Y_Dir(), EditorTerraformClick_Dynamite(), BuildTreesWindow::OnClick(), FoundTownWindow::OnClick(), and BuildIndustryWindow::OnClick().

## Variable Documentation

struct NWidgetPart _nested_main_window_widgets[]`[static]`

Initial value:

     {
      NWidget(NWID_VIEWPORT, INVALID_COLOUR, MW_VIEWPORT), SetResize(1, 1),
    }

Definition at line 195 of file main_gui.cpp.