Use angle brackets for system headers
[TortoiseGit.git] / src / TortoiseIDiff / MainWindow.h
bloba0c9678f3e561f485118ae54374093c882e713c0
1 // TortoiseIDiff - an image diff viewer in TortoiseSVN
3 // Copyright (C) 2006-2007,2009, 2011-2012 - 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 <CommCtrl.h>
23 #include "TortoiseIDiff.h"
25 #define SPLITTER_BORDER 2
27 #define WINDOW_MINHEIGHT 200
28 #define WINDOW_MINWIDTH 200
30 /**
31 * \ingroup TortoiseIDiff
32 * The main window of TortoiseIDiff.
33 * Hosts the two image views, the menu, toolbar, slider, ...
35 class CMainWindow : public CWindow
37 public:
38 CMainWindow(HINSTANCE hInst, const WNDCLASSEX* wcx = NULL) : CWindow(hInst, wcx)
39 , picWindow1(hInst)
40 , picWindow2(hInst)
41 , oldx(-4)
42 , oldy(-4)
43 , bMoved(false)
44 , bDragMode(false)
45 , nSplitterPos(100)
46 , bOverlap(false)
47 , bShowInfo(false)
48 , bVertical(false)
49 , bLinkedPositions(true)
50 , bFitSizes(false)
51 , transparentColor(::GetSysColor(COLOR_WINDOW))
52 , m_BlendType(CPicWindow::BLEND_ALPHA)
53 , hwndTB(0)
55 SetWindowTitle((LPCTSTR)ResString(hResource, IDS_APP_TITLE));
58 /**
59 * Registers the window class and creates the window.
61 bool RegisterAndCreateWindow();
63 /**
64 * Sets the image path and title for the left image view.
66 void SetLeft(tstring leftpath, tstring lefttitle) {leftpicpath=leftpath; leftpictitle=lefttitle;}
67 /**
68 * Sets the image path and the title for the right image view.
70 void SetRight(tstring rightpath, tstring righttitle) {rightpicpath=rightpath; rightpictitle=righttitle;}
72 protected:
73 /// the message handler for this window
74 LRESULT CALLBACK WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
75 /// Handles all the WM_COMMAND window messages (e.g. menu commands)
76 LRESULT DoCommand(int id);
78 /// Positions the child windows. Call this after the window sizes/positions have changed.
79 void PositionChildren(RECT * clientrect = NULL);
80 /// Shows the "Open images" dialog where the user can select the images to diff
81 bool OpenDialog();
82 static BOOL CALLBACK OpenDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
83 static bool AskForFile(HWND owner, TCHAR * path);
85 // splitter methods
86 void DrawXorBar(HDC hdc, int x1, int y1, int width, int height);
87 LRESULT Splitter_OnLButtonDown(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
88 LRESULT Splitter_OnLButtonUp(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
89 LRESULT Splitter_OnMouseMove(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
90 void Splitter_CaptureChanged();
92 // toolbar
93 bool CreateToolbar();
94 HWND hwndTB;
95 HIMAGELIST hToolbarImgList;
97 // command line params
98 static tstring leftpicpath;
99 static tstring leftpictitle;
101 static tstring rightpicpath;
102 static tstring rightpictitle;
104 // image data
105 CPicWindow picWindow1;
106 CPicWindow picWindow2;
107 bool bShowInfo;
108 COLORREF transparentColor;
110 // splitter data
111 int oldx;
112 int oldy;
113 bool bMoved;
114 bool bDragMode;
115 int nSplitterPos;
117 // one/two pane view
118 bool bOverlap;
119 bool bVertical;
120 bool bLinkedPositions;
121 bool bFitSizes;
122 CPicWindow::BlendType m_BlendType;