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.
21 #include "BaseWindow.h"
22 #include "PicWindow.h"
23 #include "TortoiseIDiff.h"
28 #define SPLITTER_BORDER 2
30 #define WINDOW_MINHEIGHT 200
31 #define WINDOW_MINWIDTH 200
41 * \ingroup TortoiseIDiff
42 * The main window of TortoiseIDiff.
43 * Hosts the two image views, the menu, toolbar, slider, ...
45 class CMainWindow
: public CWindow
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
)));
55 * Registers the window class and creates the window.
57 bool RegisterAndCreateWindow();
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
;
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
;
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
; }
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
95 static BOOL CALLBACK
OpenDlgProc(HWND hwndDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
);
96 static bool AskForFile(HWND owner
, wchar_t* path
);
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;
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
;
120 CPicWindow picWindow1
= nullptr;
121 CPicWindow picWindow2
= nullptr;
122 CPicWindow picWindow3
= nullptr;
123 bool bShowInfo
= false;
124 COLORREF transparentColor
;
130 bool bDragMode
= false;
132 int nSplitterPos
= 100;
133 int nSplitterPos2
= 200;
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
;
150 HWND resolveMsgWnd
= nullptr;
151 WPARAM resolveMsgWParam
= 0;
152 LPARAM resolveMsgLParam
= 0;