Limit GUI updates the the main thread
[TortoiseGit.git] / src / TortoiseIDiff / MainWindow.h
blob5281952846571a2ba2091ca1e8551698a249c0f2
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)
54 , hToolbarImgList(NULL)
56 SetWindowTitle((LPCTSTR)ResString(hResource, IDS_APP_TITLE));
59 /**
60 * Registers the window class and creates the window.
62 bool RegisterAndCreateWindow();
64 /**
65 * Sets the image path and title for the left image view.
67 void SetLeft(tstring leftpath, tstring lefttitle) {leftpicpath=leftpath; leftpictitle=lefttitle;}
68 /**
69 * Sets the image path and the title for the right image view.
71 void SetRight(tstring rightpath, tstring righttitle) {rightpicpath=rightpath; rightpictitle=righttitle;}
73 protected:
74 /// the message handler for this window
75 LRESULT CALLBACK WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
76 /// Handles all the WM_COMMAND window messages (e.g. menu commands)
77 LRESULT DoCommand(int id);
79 /// Positions the child windows. Call this after the window sizes/positions have changed.
80 void PositionChildren(RECT * clientrect = NULL);
81 /// Shows the "Open images" dialog where the user can select the images to diff
82 bool OpenDialog();
83 static BOOL CALLBACK OpenDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
84 static bool AskForFile(HWND owner, TCHAR * path);
86 // splitter methods
87 void DrawXorBar(HDC hdc, int x1, int y1, int width, int height);
88 LRESULT Splitter_OnLButtonDown(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
89 LRESULT Splitter_OnLButtonUp(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
90 LRESULT Splitter_OnMouseMove(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
91 void Splitter_CaptureChanged();
93 // toolbar
94 bool CreateToolbar();
95 HWND hwndTB;
96 HIMAGELIST hToolbarImgList;
98 // command line params
99 static tstring leftpicpath;
100 static tstring leftpictitle;
102 static tstring rightpicpath;
103 static tstring rightpictitle;
105 // image data
106 CPicWindow picWindow1;
107 CPicWindow picWindow2;
108 bool bShowInfo;
109 COLORREF transparentColor;
111 // splitter data
112 int oldx;
113 int oldy;
114 bool bMoved;
115 bool bDragMode;
116 int nSplitterPos;
118 // one/two pane view
119 bool bOverlap;
120 bool bVertical;
121 bool bLinkedPositions;
122 bool bFitSizes;
123 CPicWindow::BlendType m_BlendType;