Fixed c&p error: Usage of wrong path
[TortoiseGit.git] / src / TortoiseIDiff / MainWindow.h
blobe86ed99cea39af11217ebbc2abc3b5ac58a0f994
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.
19 #pragma once
20 #include "BaseWindow.h"
21 #include "PicWindow.h"
22 #include "TortoiseIDiff.h"
24 #include <map>
25 #include <CommCtrl.h>
27 #define SPLITTER_BORDER 2
29 #define WINDOW_MINHEIGHT 200
30 #define WINDOW_MINWIDTH 200
32 enum FileType
34 FileTypeMine = 1,
35 FileTypeTheirs = 2,
36 FileTypeBase = 3,
39 /**
40 * \ingroup TortoiseIDiff
41 * The main window of TortoiseIDiff.
42 * Hosts the two image views, the menu, toolbar, slider, ...
44 class CMainWindow : public CWindow
46 public:
47 CMainWindow(HINSTANCE hInst, const WNDCLASSEX* wcx = NULL) : CWindow(hInst, wcx)
48 , picWindow1(hInst)
49 , picWindow2(hInst)
50 , picWindow3(hInst)
51 , oldx(-4)
52 , oldy(-4)
53 , bMoved(false)
54 , bDragMode(false)
55 , bDrag2(false)
56 , nSplitterPos(100)
57 , nSplitterPos2(200)
58 , bOverlap(false)
59 , bShowInfo(false)
60 , bVertical(false)
61 , bLinkedPositions(true)
62 , bFitWidths(false)
63 , bFitHeights(false)
64 , transparentColor(::GetSysColor(COLOR_WINDOW))
65 , m_BlendType(CPicWindow::BLEND_ALPHA)
66 , hwndTB(0)
67 , hToolbarImgList(NULL)
68 , bSelectionMode(false)
70 SetWindowTitle((LPCTSTR)ResString(hResource, IDS_APP_TITLE));
73 /**
74 * Registers the window class and creates the window.
76 bool RegisterAndCreateWindow();
78 /**
79 * Sets the image path and title for the left image view.
81 void SetLeft(tstring leftpath, tstring lefttitle) {leftpicpath=leftpath; leftpictitle=lefttitle;}
82 /**
83 * Sets the image path and the title for the right image view.
85 void SetRight(tstring rightpath, tstring righttitle) {rightpicpath=rightpath; rightpictitle=righttitle;}
87 /**
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; }
96 protected:
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
105 bool OpenDialog();
106 static BOOL CALLBACK OpenDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
107 static bool AskForFile(HWND owner, TCHAR * path);
109 // splitter methods
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();
116 // toolbar
117 bool CreateToolbar();
118 HWND hwndTB;
119 HIMAGELIST hToolbarImgList;
121 // command line params
122 static tstring leftpicpath;
123 static tstring leftpictitle;
125 static tstring rightpicpath;
126 static tstring rightpictitle;
128 // image data
129 CPicWindow picWindow1;
130 CPicWindow picWindow2;
131 CPicWindow picWindow3;
132 bool bShowInfo;
133 COLORREF transparentColor;
135 // splitter data
136 int oldx;
137 int oldy;
138 bool bMoved;
139 bool bDragMode;
140 bool bDrag2;
141 int nSplitterPos;
142 int nSplitterPos2;
144 // one/two pane view
145 bool bSelectionMode;
146 bool bOverlap;
147 bool bVertical;
148 bool bLinkedPositions;
149 bool bFitWidths;
150 bool bFitHeights;
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;