1 // TortoiseIDiff - an image diff viewer in TortoiseSVN
3 // Copyright (C) 2015 - TortoiseGit
4 // Copyright (C) 2006-2007, 2009, 2011-2013, 2015 - 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
= NULL
) : 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(NULL
)
69 , bSelectionMode(false)
70 , resolveMsgWnd(nullptr)
71 , resolveMsgLParam(NULL
)
72 , resolveMsgWParam(NULL
)
74 SetWindowTitle((LPCTSTR
)ResString(hResource
, IDS_APP_TITLE
));
78 * Registers the window class and creates the window.
80 bool RegisterAndCreateWindow();
83 * Sets the image path and title for the left image view.
85 void SetLeft(const tstring
& leftpath
, const tstring
& lefttitle
) { leftpicpath
= leftpath
; leftpictitle
= lefttitle
; }
87 * Sets the image path and the title for the right image view.
89 void SetRight(const tstring
& rightpath
, const tstring
& righttitle
) { rightpicpath
= rightpath
; rightpictitle
= righttitle
; }
92 * Sets the image path and title for selection mode. In selection mode, the images
93 * are shown side-by-side for the user to chose one of them. The chosen image is
94 * saved at the path for \b FileTypeResult (if that path has been set) and the
95 * process return value is the chosen FileType.
97 void SetSelectionImage(FileType ft
, const std::wstring
& path
, const std::wstring
& title
);
98 void SetSelectionResult(const std::wstring
& path
) { selectionResult
= path
; }
101 /// the message handler for this window
102 LRESULT CALLBACK
WinMsgHandler(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
103 /// Handles all the WM_COMMAND window messages (e.g. menu commands)
104 LRESULT
DoCommand(int id
, LPARAM lParam
);
106 /// Positions the child windows. Call this after the window sizes/positions have changed.
107 void PositionChildren(RECT
* clientrect
= NULL
);
108 /// Shows the "Open images" dialog where the user can select the images to diff
110 static BOOL CALLBACK
OpenDlgProc(HWND hwndDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
);
111 static bool AskForFile(HWND owner
, TCHAR
* path
);
114 void DrawXorBar(HDC hdc
, int x1
, int y1
, int width
, int height
);
115 LRESULT
Splitter_OnLButtonDown(HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
116 LRESULT
Splitter_OnLButtonUp(HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
117 LRESULT
Splitter_OnMouseMove(HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
118 void Splitter_CaptureChanged();
121 bool CreateToolbar();
123 HIMAGELIST hToolbarImgList
;
125 // command line params
126 static tstring leftpicpath
;
127 static tstring leftpictitle
;
129 static tstring rightpicpath
;
130 static tstring rightpictitle
;
133 CPicWindow picWindow1
;
134 CPicWindow picWindow2
;
135 CPicWindow picWindow3
;
137 COLORREF transparentColor
;
152 bool bLinkedPositions
;
155 CPicWindow::BlendType m_BlendType
;
157 // selection mode data
158 std::map
<FileType
, std::wstring
> selectionPaths
;
159 std::map
<FileType
, std::wstring
> selectionTitles
;
160 std::wstring selectionResult
;
164 WPARAM resolveMsgWParam
;
165 LPARAM resolveMsgLParam
;