1 /*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4 * PURPOSE: The precompiled header
5 * COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
6 * Copyright 2018 Stanislav Motylkov <x86corez@gmail.com>
7 * Copyright 2021-2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
8 */
9
10 #pragma once
11
12 #ifdef NDEBUG
13 #undef DBG
14 #undef _DEBUG
15 #endif
16
17 #include <windef.h>
18 #include <winbase.h>
19 #include <winuser.h>
20 #include <wingdi.h>
21 #include <tchar.h>
22 #include <atlbase.h>
23 #include <atlcom.h>
24 #include <atlpath.h>
25 #include <atlstr.h>
26 #include <atlwin.h>
27 #include <atltypes.h>
28 #include <windowsx.h>
29 #include <commdlg.h>
30 #include <commctrl.h>
31 #include <stdlib.h>
32 #define _USE_MATH_DEFINES /* for M_PI */
33 #include <math.h>
34 #include <shellapi.h>
35 #include <htmlhelp.h>
36 #include <strsafe.h>
37 #include <ui/CWaitCursor.h>
38
39 #include <debug.h>
40
41 /* CONSTANTS *******************************************************/
42
43 #define GRIP_SIZE 3
44 #define MIN_ZOOM 125
45 #define MAX_ZOOM 8000
46
47 #define MAX_LONG_PATH 512
48
49 #define WM_TOOLSMODELTOOLCHANGED (WM_APP + 0)
50 #define WM_TOOLSMODELSETTINGSCHANGED (WM_APP + 1)
51 #define WM_TOOLSMODELZOOMCHANGED (WM_APP + 2)
52 #define WM_PALETTEMODELCOLORCHANGED (WM_APP + 3)
53
54 enum HITTEST // hit
55 {
56 HIT_NONE = 0, // Nothing hit or outside
57 HIT_UPPER_LEFT,
58 HIT_UPPER_CENTER,
59 HIT_UPPER_RIGHT,
60 HIT_MIDDLE_LEFT,
61 HIT_MIDDLE_RIGHT,
62 HIT_LOWER_LEFT,
63 HIT_LOWER_CENTER,
64 HIT_LOWER_RIGHT,
65 HIT_BORDER,
66 HIT_INNER,
67 };
68
69 /* COMMON FUNCTIONS *************************************************/
70
71 void ShowOutOfMemory(void);
72 BOOL nearlyEqualPoints(INT x0, INT y0, INT x1, INT y1);
73 BOOL OpenMailer(HWND hWnd, LPCWSTR pszPathName);
74 void getBoundaryOfPtStack(RECT& rcBoundary, INT cPoints, const POINT *pPoints);
75
76 #define DEG2RAD(degree) (((degree) * M_PI) / 180)
77 #define RAD2DEG(radian) ((LONG)(((radian) * 180) / M_PI))
78
79 /* This simplifies checking and unchecking menu items */
80 #define CHECKED_IF(bChecked) \
81 ((bChecked) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND))
82
83 /* This simplifies enabling or graying menu items */
84 #define ENABLED_IF(bEnabled) \
85 ((bEnabled) ? (MF_ENABLED | MF_BYCOMMAND) : (MF_GRAYED | MF_BYCOMMAND))
86
87 template <typename T>
Swap(T & a,T & b)88 inline void Swap(T& a, T& b)
89 {
90 T tmp = a;
91 a = b;
92 b = tmp;
93 }
94
95 /* LOCAL INCLUDES ***************************************************/
96
97 #include "resource.h"
98 #include "drawing.h"
99 #include "dib.h"
100 #include "fullscreen.h"
101 #include "history.h"
102 #include "miniature.h"
103 #include "palette.h"
104 #include "palettemodel.h"
105 #include "registry.h"
106 #include "selectionmodel.h"
107 #include "sizebox.h"
108 #include "canvas.h"
109 #include "textedit.h"
110 #include "toolbox.h"
111 #include "toolsettings.h"
112 #include "toolsmodel.h"
113 #include "main.h"
114 #include "dialogs.h"
115 #include "atlimagedx.h"
116
117 /* GLOBAL VARIABLES *************************************************/
118
119 extern HINSTANCE g_hinstExe;
120
121 extern WCHAR g_szFileName[MAX_LONG_PATH];
122 extern BOOL g_isAFile;
123 extern BOOL g_imageSaved;
124 extern BOOL g_showGrid;
125 extern BOOL g_askBeforeEnlarging;
126
127 extern CMainWindow mainWindow;
128
129 extern CMirrorRotateDialog mirrorRotateDialog;
130 extern CAttributesDialog attributesDialog;
131 extern CStretchSkewDialog stretchSkewDialog;
132 extern CFontsDialog fontsDialog;
133
134 extern RegistrySettings registrySettings;
135 extern ImageModel imageModel;
136 extern ToolsModel toolsModel;
137 extern SelectionModel selectionModel;
138 extern PaletteModel paletteModel;
139
140 extern HWND g_hStatusBar;
141 extern float g_xDpi;
142 extern float g_yDpi;
143 extern INT g_fileSize;
144 extern SYSTEMTIME g_fileTime;
145
146 extern CFullscreenWindow fullscreenWindow;
147 extern CMiniatureWindow miniature;
148 extern CToolBox toolBoxContainer;
149 extern CToolSettingsWindow toolSettingsWindow;
150 extern CPaletteWindow paletteWindow;
151 extern CCanvasWindow canvasWindow;
152 extern CTextEditWindow textEditWindow;
153