1 // TortoiseMerge - a Diff/Patch program
\r
3 // Copyright (C) 2006-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "TortoiseMerge.h"
\r
21 #include "MainFrm.h"
\r
22 #include "LocatorBar.h"
\r
23 #include "LeftView.h"
\r
24 #include "RightView.h"
\r
25 #include "BottomView.h"
\r
27 IMPLEMENT_DYNAMIC(CLineDiffBar, CPaneDialog)
\r
28 CLineDiffBar::CLineDiffBar() : CPaneDialog()
\r
31 m_pCacheBitmap = NULL;
\r
34 m_bExclusiveRow = TRUE;
\r
37 CLineDiffBar::~CLineDiffBar()
\r
41 m_pCacheBitmap->DeleteObject();
\r
42 delete m_pCacheBitmap;
\r
43 m_pCacheBitmap = NULL;
\r
47 BEGIN_MESSAGE_MAP(CLineDiffBar, CPaneDialog)
\r
53 void CLineDiffBar::DocumentUpdated()
\r
55 //resize according to the font size
\r
56 if ((m_pMainFrm)&&(m_pMainFrm->m_pwndLeftView))
\r
58 m_nLineHeight = m_pMainFrm->m_pwndLeftView->GetLineHeight();
\r
61 GetWindowRect(rect);
\r
62 CSize size = rect.Size();
\r
63 size.cy = 2 * m_nLineHeight;
\r
65 SetWindowPos(NULL, 0, 0, size.cx, 2*m_nLineHeight, SWP_NOMOVE);
\r
68 m_pMainFrm->RecalcLayout();
\r
71 void CLineDiffBar::ShowLines(int nLineIndex)
\r
73 m_nLineIndex = nLineIndex;
\r
77 void CLineDiffBar::OnPaint()
\r
79 CPaintDC dc(this); // device context for painting
\r
81 GetClientRect(rect);
\r
82 int height = rect.Height();
\r
83 int width = rect.Width();
\r
86 VERIFY(cacheDC.CreateCompatibleDC(&dc));
\r
87 cacheDC.FillSolidRect(&rect, ::GetSysColor(COLOR_WINDOW));
\r
88 if (m_pCacheBitmap == NULL)
\r
90 m_pCacheBitmap = new CBitmap;
\r
91 VERIFY(m_pCacheBitmap->CreateCompatibleBitmap(&dc, width, height));
\r
93 CBitmap *pOldBitmap = cacheDC.SelectObject(m_pCacheBitmap);
\r
95 CRect upperrect = CRect(rect.left, rect.top, rect.right, rect.bottom/2);
\r
96 CRect lowerrect = CRect(rect.left, rect.bottom/2, rect.right, rect.bottom);
\r
98 if ((m_pMainFrm)&&(m_pMainFrm->m_pwndLeftView)&&(m_pMainFrm->m_pwndRightView))
\r
100 if ((m_pMainFrm->m_pwndLeftView->IsWindowVisible())&&(m_pMainFrm->m_pwndRightView->IsWindowVisible()))
\r
102 BOOL bViewWhiteSpace = m_pMainFrm->m_pwndLeftView->m_bViewWhitespace;
\r
103 BOOL bInlineDiffs = m_pMainFrm->m_pwndLeftView->m_bShowInlineDiff;
\r
105 m_pMainFrm->m_pwndLeftView->m_bViewWhitespace = TRUE;
\r
106 m_pMainFrm->m_pwndLeftView->m_bShowInlineDiff = TRUE;
\r
107 m_pMainFrm->m_pwndLeftView->m_bShowSelection = false;
\r
108 m_pMainFrm->m_pwndRightView->m_bViewWhitespace = TRUE;
\r
109 m_pMainFrm->m_pwndRightView->m_bShowInlineDiff = TRUE;
\r
110 m_pMainFrm->m_pwndRightView->m_bShowSelection = false;
\r
112 // Use left and right view to display lines next to each other
\r
113 m_pMainFrm->m_pwndLeftView->DrawSingleLine(&cacheDC, &upperrect, m_nLineIndex);
\r
114 m_pMainFrm->m_pwndRightView->DrawSingleLine(&cacheDC, &lowerrect, m_nLineIndex);
\r
116 m_pMainFrm->m_pwndLeftView->m_bViewWhitespace = bViewWhiteSpace;
\r
117 m_pMainFrm->m_pwndLeftView->m_bShowInlineDiff = bInlineDiffs;
\r
118 m_pMainFrm->m_pwndLeftView->m_bShowSelection = true;
\r
119 m_pMainFrm->m_pwndRightView->m_bViewWhitespace = bViewWhiteSpace;
\r
120 m_pMainFrm->m_pwndRightView->m_bShowInlineDiff = bInlineDiffs;
\r
121 m_pMainFrm->m_pwndRightView->m_bShowSelection = true;
\r
125 VERIFY(dc.BitBlt(rect.left, rect.top, width, height, &cacheDC, 0, 0, SRCCOPY));
\r
127 cacheDC.SelectObject(pOldBitmap);
\r
128 cacheDC.DeleteDC();
\r
131 void CLineDiffBar::OnSize(UINT nType, int cx, int cy)
\r
133 CPaneDialog::OnSize(nType, cx, cy);
\r
135 if (m_pCacheBitmap != NULL)
\r
137 m_pCacheBitmap->DeleteObject();
\r
138 delete m_pCacheBitmap;
\r
139 m_pCacheBitmap = NULL;
\r
141 SetWindowPos(NULL, 0, 0, cx, 2*m_nLineHeight, SWP_NOMOVE);
\r
145 BOOL CLineDiffBar::OnEraseBkgnd(CDC* /*pDC*/)
\r