1 // TortoiseIDiff - an image diff viewer in TortoiseSVN
3 // Copyright (C) 2006-2007, 2009, 2011-2013 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "BaseWindow.h"
21 #include "PicWindow.h"
22 #include "TortoiseIDiff.h"
27 #define SPLITTER_BORDER 2
29 #define WINDOW_MINHEIGHT 200
30 #define WINDOW_MINWIDTH 200
40 * \ingroup TortoiseIDiff
41 * The main window of TortoiseIDiff.
42 * Hosts the two image views, the menu, toolbar, slider, ...
44 class CMainWindow
: public CWindow
47 CMainWindow(HINSTANCE hInst
, const WNDCLASSEX
* wcx
= NULL
) : CWindow(hInst
, wcx
)
61 , bLinkedPositions(true)
64 , transparentColor(::GetSysColor(COLOR_WINDOW
))
65 , m_BlendType(CPicWindow::BLEND_ALPHA
)
67 , hToolbarImgList(NULL
)
68 , bSelectionMode(false)
70 SetWindowTitle((LPCTSTR
)ResString(hResource
, IDS_APP_TITLE
));
74 * Registers the window class and creates the window.
76 bool RegisterAndCreateWindow();
79 * Sets the image path and title for the left image view.
81 void SetLeft(tstring leftpath
, tstring lefttitle
) {leftpicpath
=leftpath
; leftpictitle
=lefttitle
;}
83 * Sets the image path and the title for the right image view.
85 void SetRight(tstring rightpath
, tstring righttitle
) {rightpicpath
=rightpath
; rightpictitle
=righttitle
;}
88 * Sets the image path and title for selection mode. In selection mode, the images
89 * are shown side-by-side for the user to chose one of them. The chosen image is
90 * saved at the path for \b FileTypeResult (if that path has been set) and the
91 * process return value is the chosen FileType.
93 void SetSelectionImage(FileType ft
, const std::wstring
& path
, const std::wstring
& title
);
94 void SetSelectionResult(const std::wstring
& path
) { selectionResult
= path
; }
97 /// the message handler for this window
98 LRESULT CALLBACK
WinMsgHandler(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
99 /// Handles all the WM_COMMAND window messages (e.g. menu commands)
100 LRESULT
DoCommand(int id
, LPARAM lParam
);
102 /// Positions the child windows. Call this after the window sizes/positions have changed.
103 void PositionChildren(RECT
* clientrect
= NULL
);
104 /// Shows the "Open images" dialog where the user can select the images to diff
106 static BOOL CALLBACK
OpenDlgProc(HWND hwndDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
);
107 static bool AskForFile(HWND owner
, TCHAR
* path
);
110 void DrawXorBar(HDC hdc
, int x1
, int y1
, int width
, int height
);
111 LRESULT
Splitter_OnLButtonDown(HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
112 LRESULT
Splitter_OnLButtonUp(HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
113 LRESULT
Splitter_OnMouseMove(HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
114 void Splitter_CaptureChanged();
117 bool CreateToolbar();
119 HIMAGELIST hToolbarImgList
;
121 // command line params
122 static tstring leftpicpath
;
123 static tstring leftpictitle
;
125 static tstring rightpicpath
;
126 static tstring rightpictitle
;
129 CPicWindow picWindow1
;
130 CPicWindow picWindow2
;
131 CPicWindow picWindow3
;
133 COLORREF transparentColor
;
148 bool bLinkedPositions
;
151 CPicWindow::BlendType m_BlendType
;
153 // selection mode data
154 std::map
<FileType
, std::wstring
> selectionPaths
;
155 std::map
<FileType
, std::wstring
> selectionTitles
;
156 std::wstring selectionResult
;