Codechange: [Win32] simplify when/where GdiFlush() is called
[openttd-github.git] / src / screenshot_gui.cpp
blobc0e65f13d0bb3a260d6885a9bc15230563998a46
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file screenshot_gui.cpp GUI functions related to screenshots. */
10 #include "stdafx.h"
11 #include "window_func.h"
12 #include "window_gui.h"
13 #include "screenshot.h"
14 #include "widgets/screenshot_widget.h"
15 #include "table/strings.h"
17 struct ScreenshotWindow : Window {
18 ScreenshotWindow(WindowDesc *desc) : Window(desc)
20 this->CreateNestedTree();
21 this->FinishInitNested();
24 void OnPaint() override
26 this->DrawWidgets();
29 void OnClick(Point pt, int widget, int click_count) override
31 if (widget < 0) return;
32 ScreenshotType st;
33 switch (widget) {
34 default:
35 case WID_SC_TAKE: st = SC_VIEWPORT; break;
36 case WID_SC_TAKE_ZOOMIN: st = SC_ZOOMEDIN; break;
37 case WID_SC_TAKE_DEFAULTZOOM: st = SC_DEFAULTZOOM; break;
38 case WID_SC_TAKE_WORLD: st = SC_WORLD; break;
39 case WID_SC_TAKE_HEIGHTMAP: st = SC_HEIGHTMAP; break;
40 case WID_SC_TAKE_MINIMAP: st = SC_MINIMAP; break;
42 MakeScreenshotWithConfirm(st);
46 static const NWidgetPart _nested_screenshot[] = {
47 NWidget(NWID_HORIZONTAL),
48 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
49 NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_SCREENSHOT_CAPTION, 0),
50 NWidget(WWT_SHADEBOX, COLOUR_GREY),
51 NWidget(WWT_STICKYBOX, COLOUR_GREY),
52 EndContainer(),
53 NWidget(NWID_VERTICAL, NC_EQUALSIZE),
54 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
55 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_ZOOMIN), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_ZOOMIN_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
56 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_DEFAULTZOOM), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_DEFAULTZOOM_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
57 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_WORLD), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_WORLD_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
58 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_HEIGHTMAP), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_HEIGHTMAP_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
59 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_MINIMAP), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_MINIMAP_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
60 EndContainer(),
63 static WindowDesc _screenshot_window_desc(
64 WDP_AUTO, "take_a_screenshot", 200, 100,
65 WC_SCREENSHOT, WC_NONE,
67 _nested_screenshot, lengthof(_nested_screenshot)
70 void ShowScreenshotWindow()
72 DeleteWindowById(WC_SCREENSHOT, 0);
73 new ScreenshotWindow(&_screenshot_window_desc);