1 // TortoiseMerge - a Diff/Patch program
3 // Copyright (C) 2006-2008 - 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 "TortoiseMerge.h"
22 #include "LocatorBar.h"
24 #include "RightView.h"
25 #include "BottomView.h"
27 IMPLEMENT_DYNAMIC(CLineDiffBar
, CPaneDialog
)
28 CLineDiffBar::CLineDiffBar() : CPaneDialog()
31 m_pCacheBitmap
= NULL
;
34 m_bExclusiveRow
= TRUE
;
37 CLineDiffBar::~CLineDiffBar()
41 m_pCacheBitmap
->DeleteObject();
42 delete m_pCacheBitmap
;
43 m_pCacheBitmap
= NULL
;
47 BEGIN_MESSAGE_MAP(CLineDiffBar
, CPaneDialog
)
53 void CLineDiffBar::DocumentUpdated()
55 //resize according to the font size
56 if ((m_pMainFrm
)&&(m_pMainFrm
->m_pwndLeftView
))
58 m_nLineHeight
= m_pMainFrm
->m_pwndLeftView
->GetLineHeight();
62 CSize size
= rect
.Size();
63 size
.cy
= 2 * m_nLineHeight
;
65 SetWindowPos(NULL
, 0, 0, size
.cx
, 2*m_nLineHeight
, SWP_NOMOVE
);
68 m_pMainFrm
->RecalcLayout();
71 void CLineDiffBar::ShowLines(int nLineIndex
)
73 m_nLineIndex
= nLineIndex
;
77 void CLineDiffBar::OnPaint()
79 CPaintDC
dc(this); // device context for painting
82 int height
= rect
.Height();
83 int width
= rect
.Width();
86 VERIFY(cacheDC
.CreateCompatibleDC(&dc
));
87 cacheDC
.FillSolidRect(&rect
, ::GetSysColor(COLOR_WINDOW
));
88 if (m_pCacheBitmap
== NULL
)
90 m_pCacheBitmap
= new CBitmap
;
91 VERIFY(m_pCacheBitmap
->CreateCompatibleBitmap(&dc
, width
, height
));
93 CBitmap
*pOldBitmap
= cacheDC
.SelectObject(m_pCacheBitmap
);
95 CRect upperrect
= CRect(rect
.left
, rect
.top
, rect
.right
, rect
.bottom
/2);
96 CRect lowerrect
= CRect(rect
.left
, rect
.bottom
/2, rect
.right
, rect
.bottom
);
98 if ((m_pMainFrm
)&&(m_pMainFrm
->m_pwndLeftView
)&&(m_pMainFrm
->m_pwndRightView
))
100 if ((m_pMainFrm
->m_pwndLeftView
->IsWindowVisible())&&(m_pMainFrm
->m_pwndRightView
->IsWindowVisible()))
102 BOOL bViewWhiteSpace
= m_pMainFrm
->m_pwndLeftView
->m_bViewWhitespace
;
103 BOOL bInlineDiffs
= m_pMainFrm
->m_pwndLeftView
->m_bShowInlineDiff
;
105 m_pMainFrm
->m_pwndLeftView
->m_bViewWhitespace
= TRUE
;
106 m_pMainFrm
->m_pwndLeftView
->m_bShowInlineDiff
= TRUE
;
107 m_pMainFrm
->m_pwndLeftView
->m_bShowSelection
= false;
108 m_pMainFrm
->m_pwndRightView
->m_bViewWhitespace
= TRUE
;
109 m_pMainFrm
->m_pwndRightView
->m_bShowInlineDiff
= TRUE
;
110 m_pMainFrm
->m_pwndRightView
->m_bShowSelection
= false;
112 // Use left and right view to display lines next to each other
113 m_pMainFrm
->m_pwndLeftView
->DrawSingleLine(&cacheDC
, &upperrect
, m_nLineIndex
);
114 m_pMainFrm
->m_pwndRightView
->DrawSingleLine(&cacheDC
, &lowerrect
, m_nLineIndex
);
116 m_pMainFrm
->m_pwndLeftView
->m_bViewWhitespace
= bViewWhiteSpace
;
117 m_pMainFrm
->m_pwndLeftView
->m_bShowInlineDiff
= bInlineDiffs
;
118 m_pMainFrm
->m_pwndLeftView
->m_bShowSelection
= true;
119 m_pMainFrm
->m_pwndRightView
->m_bViewWhitespace
= bViewWhiteSpace
;
120 m_pMainFrm
->m_pwndRightView
->m_bShowInlineDiff
= bInlineDiffs
;
121 m_pMainFrm
->m_pwndRightView
->m_bShowSelection
= true;
125 VERIFY(dc
.BitBlt(rect
.left
, rect
.top
, width
, height
, &cacheDC
, 0, 0, SRCCOPY
));
127 cacheDC
.SelectObject(pOldBitmap
);
131 void CLineDiffBar::OnSize(UINT nType
, int cx
, int cy
)
133 CPaneDialog::OnSize(nType
, cx
, cy
);
135 if (m_pCacheBitmap
!= NULL
)
137 m_pCacheBitmap
->DeleteObject();
138 delete m_pCacheBitmap
;
139 m_pCacheBitmap
= NULL
;
141 SetWindowPos(NULL
, 0, 0, cx
, 2*m_nLineHeight
, SWP_NOMOVE
);
145 BOOL
CLineDiffBar::OnEraseBkgnd(CDC
* /*pDC*/)