1
// TortoiseIDiff - an image diff viewer in TortoiseSVN
3 // Copyright (C) 2015-2016 - 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 , picWindow1(hInstance
)
50 , picWindow2(hInstance
)
51 , picWindow3(hInstance
)
62 , bLinkedPositions(true)
65 , transparentColor(::GetSysColor(COLOR_WINDOW
))
66 , m_BlendType(CPicWindow::BLEND_ALPHA
)
68 , hToolbarImgList(nullptr)
69 , bSelectionMode(false)
70 , m_themeCallbackId(0)
71 , resolveMsgWnd(nullptr)
75 SetWindowTitle(static_cast<LPCWSTR
>(ResString(hResource
, IDS_APP_TITLE
)));
79 * Registers the window class and creates the window.
81 bool RegisterAndCreateWindow();
84 * Sets the image path and title for the left image view.
86 void SetLeft(const std::wstring
& leftpath
, const std::wstring
& lefttitle
)
88 leftpicpath
= leftpath
;
89 leftpictitle
= lefttitle
;
92 * Sets the image path and the title for the right image view.
94 void SetRight(const std::wstring
& rightpath
, const std::wstring
& righttitle
)
96 rightpicpath
= rightpath
;
97 rightpictitle
= righttitle
;
101 * Sets the image path and title for selection mode. In selection mode, the images
102 * are shown side-by-side for the user to chose one of them. The chosen image is
103 * saved at the path for \b FileTypeResult (if that path has been set) and the
104 * process return value is the chosen FileType.
106 void SetSelectionImage(FileType ft
, const std::wstring
& path
, const std::wstring
& title
);
107 void SetSelectionResult(const std::wstring
& path
) { selectionResult
= path
; }
110 /// the message handler for this window
111 LRESULT CALLBACK
WinMsgHandler(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
) override
;
112 /// Handles all the WM_COMMAND window messages (e.g. menu commands)
113 LRESULT
DoCommand(int id
, LPARAM lParam
);
115 /// Positions the child windows. Call this after the window sizes/positions have changed.
116 void PositionChildren(RECT
* clientrect
= nullptr);
117 /// Shows the "Open images" dialog where the user can select the images to diff
119 static BOOL CALLBACK
OpenDlgProc(HWND hwndDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
);
120 static bool AskForFile(HWND owner
, wchar_t* path
);
123 void DrawXorBar(HDC hdc
, int x1
, int y1
, int width
, int height
);
124 LRESULT
Splitter_OnLButtonDown(HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
125 LRESULT
Splitter_OnLButtonUp(HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
126 LRESULT
Splitter_OnMouseMove(HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
127 void Splitter_CaptureChanged();
129 void SetTheme(bool bDark
);
130 int m_themeCallbackId
;
132 bool CreateToolbar();
134 HIMAGELIST hToolbarImgList
;
136 // command line params
137 static std::wstring leftpicpath
;
138 static std::wstring leftpictitle
;
140 static std::wstring rightpicpath
;
141 static std::wstring rightpictitle
;
144 CPicWindow picWindow1
;
145 CPicWindow picWindow2
;
146 CPicWindow picWindow3
;
148 COLORREF transparentColor
;
163 bool bLinkedPositions
;
166 CPicWindow::BlendType m_BlendType
;
168 // selection mode data
169 std::map
<FileType
, std::wstring
> selectionPaths
;
170 std::map
<FileType
, std::wstring
> selectionTitles
;
171 std::wstring selectionResult
;
175 WPARAM resolveMsgWParam
;
176 LPARAM resolveMsgLParam
;