xref: /reactos/base/applications/mspaint/main.h (revision 14d3b53c)
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 main window
5  * COPYRIGHT:  Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
6  *             Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7  */
8 
9 #pragma once
10 
11 class CMainWindow : public CWindowImpl<CMainWindow>
12 {
13 public:
14     DECLARE_WND_CLASS_EX(L"MSPaintApp", CS_DBLCLKS, COLOR_BTNFACE)
15 
16     BEGIN_MSG_MAP(CMainWindow)
17         MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles)
18         MESSAGE_HANDLER(WM_CREATE, OnCreate)
19         MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
20         MESSAGE_HANDLER(WM_CLOSE, OnClose)
21         MESSAGE_HANDLER(WM_INITMENUPOPUP, OnInitMenuPopup)
22         MESSAGE_HANDLER(WM_SIZE, OnSize)
23         MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo)
24         MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
25         MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnSysColorChange)
26         MESSAGE_HANDLER(WM_COMMAND, OnCommand)
27         MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
28     END_MSG_MAP()
29 
30     CMainWindow() : m_hMenu(NULL) { }
31 
32     HWND DoCreate();
33     BOOL GetOpenFileName(IN OUT LPWSTR pszFile, INT cchMaxFile);
34     BOOL GetSaveFileName(IN OUT LPWSTR pszFile, INT cchMaxFile);
35     BOOL ChooseColor(IN OUT COLORREF *prgbColor);
36     VOID TrackPopupMenu(POINT ptScreen, INT iSubMenu);
37     BOOL CanUndo() const;
38     BOOL CanRedo() const;
39     BOOL CanPaste() const;
40 
41 private:
42     HMENU m_hMenu;
43 
44     LRESULT OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
45     LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
46     LRESULT OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
47     LRESULT OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
48     LRESULT OnInitMenuPopup(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
49     LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
50     LRESULT OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
51     LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
52     LRESULT OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
53     LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
54     LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
55 
56     void alignChildrenToMainWindow();
57     void saveImage(BOOL overwrite);
58     void InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window);
59     BOOL ConfirmSave();
60     void ProcessFileMenu(HMENU hPopupMenu);
61 };
62