Fix typos
[TortoiseGit.git] / src / TortoiseIDiff / MainWindow.h
blob68173a8a82bf12d77f961e23817ca7b0bc9292f0
1 // TortoiseIDiff - an image diff viewer in TortoiseSVN
3 // Copyright (C) 2015-2016, 2023 - TortoiseGit
4 // Copyright (C) 2006-2007, 2009, 2011-2013, 2015-2016, 2020 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
21 #include "BaseWindow.h"
22 #include "PicWindow.h"
23 #include "TortoiseIDiff.h"
25 #include <map>
26 #include <CommCtrl.h>
28 #define SPLITTER_BORDER 2
30 #define WINDOW_MINHEIGHT 200
31 #define WINDOW_MINWIDTH 200
33 enum class FileType
35 Mine = 1,
36 Theirs = 2,
37 Base = 3,
40 /**
41 * \ingroup TortoiseIDiff
42 * The main window of TortoiseIDiff.
43 * Hosts the two image views, the menu, toolbar, slider, ...
45 class CMainWindow : public CWindow
47 public:
48 CMainWindow(HINSTANCE hInstance, const WNDCLASSEX* wcx = nullptr) : CWindow(hInstance, wcx)
49 , transparentColor(::GetSysColor(COLOR_WINDOW))
51 SetWindowTitle(static_cast<LPCWSTR>(ResString(hResource, IDS_APP_TITLE)));
54 /**
55 * Registers the window class and creates the window.
57 bool RegisterAndCreateWindow();
59 /**
60 * Sets the image path and title for the left image view.
62 void SetLeft(const std::wstring& leftpath, const std::wstring& lefttitle)
64 leftpicpath = leftpath;
65 leftpictitle = lefttitle;
67 /**
68 * Sets the image path and the title for the right image view.
70 void SetRight(const std::wstring& rightpath, const std::wstring& righttitle)
72 rightpicpath = rightpath;
73 rightpictitle = righttitle;
76 /**
77 * Sets the image path and title for selection mode. In selection mode, the images
78 * are shown side-by-side for the user to chose one of them. The chosen image is
79 * saved at the path for \b FileTypeResult (if that path has been set) and the
80 * process return value is the chosen FileType.
82 void SetSelectionImage(FileType ft, const std::wstring& path, const std::wstring& title);
83 void SetSelectionResult(const std::wstring& path) { selectionResult = path; }
85 protected:
86 /// the message handler for this window
87 LRESULT CALLBACK WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) override;
88 /// Handles all the WM_COMMAND window messages (e.g. menu commands)
89 LRESULT DoCommand(int id, LPARAM lParam);
91 /// Positions the child windows. Call this after the window sizes/positions have changed.
92 void PositionChildren(RECT* clientrect = nullptr);
93 /// Shows the "Open images" dialog where the user can select the images to diff
94 bool OpenDialog();
95 static BOOL CALLBACK OpenDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
96 static bool AskForFile(HWND owner, wchar_t* path);
98 // splitter methods
99 void DrawXorBar(HDC hdc, int x1, int y1, int width, int height);
100 LRESULT Splitter_OnLButtonDown(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
101 LRESULT Splitter_OnLButtonUp(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
102 LRESULT Splitter_OnMouseMove(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
103 void Splitter_CaptureChanged();
105 void SetTheme(bool bDark);
106 int m_themeCallbackId = 0;
107 // toolbar
108 bool CreateToolbar();
109 HWND hwndTB = nullptr;
110 HIMAGELIST hToolbarImgList = nullptr;
112 // command line params
113 static std::wstring leftpicpath;
114 static std::wstring leftpictitle;
116 static std::wstring rightpicpath;
117 static std::wstring rightpictitle;
119 // image data
120 CPicWindow picWindow1 = nullptr;
121 CPicWindow picWindow2 = nullptr;
122 CPicWindow picWindow3 = nullptr;
123 bool bShowInfo = false;
124 COLORREF transparentColor;
126 // splitter data
127 int oldx = -4;
128 int oldy = -4;
129 bool bMoved = false;
130 bool bDragMode = false;
131 bool bDrag2 = false;
132 int nSplitterPos = 100;
133 int nSplitterPos2 = 200;
135 // one/two pane view
136 bool bSelectionMode = false;
137 bool bOverlap = false;
138 bool bVertical = false;
139 bool bLinkedPositions = true;
140 bool bFitWidths = false;
141 bool bFitHeights = false;
142 CPicWindow::BlendType m_BlendType = CPicWindow::BlendType::Alpha;
144 // selection mode data
145 std::map<FileType, std::wstring> selectionPaths;
146 std::map<FileType, std::wstring> selectionTitles;
147 std::wstring selectionResult;
149 public:
150 HWND resolveMsgWnd = nullptr;
151 WPARAM resolveMsgWParam = 0;
152 LPARAM resolveMsgLParam = 0;