Update diff del rename ignore document.
[TortoiseGit.git] / src / TortoiseMerge / XSplitter.cpp
blob6b454bde0f2c762eafcf8a0d57122f6ba82f2d24
1 // TortoiseMerge - a Diff/Patch program
3 // Copyright (C) 2006 - Stefan Kueng
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 #include "stdafx.h"
20 #include "XSplitter.h"
22 #ifdef _DEBUG
23 #define new DEBUG_NEW
24 #undef THIS_FILE
25 static char THIS_FILE[] = __FILE__;
26 #endif
28 CXSplitter::CXSplitter()
30 m_bBarLocked=FALSE;
31 m_nHiddenCol = -1;
32 m_nHiddenRow = -1;
35 CXSplitter::~CXSplitter()
40 BEGIN_MESSAGE_MAP(CXSplitter, CSplitterWnd)
41 ON_WM_LBUTTONDOWN()
42 ON_WM_MOUSEMOVE()
43 ON_WM_SETCURSOR()
44 END_MESSAGE_MAP()
46 void CXSplitter::OnLButtonDown(UINT nFlags, CPoint point)
48 if (!m_bBarLocked)
49 CSplitterWnd::OnLButtonDown(nFlags, point);
52 void CXSplitter::OnMouseMove(UINT nFlags, CPoint point)
54 if (!m_bBarLocked)
55 CSplitterWnd::OnMouseMove(nFlags, point);
56 else
57 CWnd::OnMouseMove(nFlags, point);
60 BOOL CXSplitter::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
62 if (!m_bBarLocked)
63 return CWnd::OnSetCursor(pWnd, nHitTest, message);
65 return CSplitterWnd::OnSetCursor(pWnd, nHitTest, message);
68 BOOL CXSplitter::ReplaceView(int row, int col,CRuntimeClass * pViewClass,SIZE size)
70 CCreateContext context;
71 BOOL bSetActive;
73 if ((GetPane(row,col)->IsKindOf(pViewClass))==TRUE)
74 return FALSE;
76 // Get pointer to CDocument object so that it can be used in the creation
77 // process of the new view
78 CDocument * pDoc= ((CView *)GetPane(row,col))->GetDocument();
79 CView * pActiveView=GetParentFrame()->GetActiveView();
80 if (pActiveView==NULL || pActiveView==GetPane(row,col))
81 bSetActive=TRUE;
82 else
83 bSetActive=FALSE;
85 // set flag so that document will not be deleted when view is destroyed
86 pDoc->m_bAutoDelete=FALSE;
87 // Delete existing view
88 ((CView *) GetPane(row,col))->DestroyWindow();
89 // set flag back to default
90 pDoc->m_bAutoDelete=TRUE;
92 // Create new view
93 context.m_pNewViewClass=pViewClass;
94 context.m_pCurrentDoc=pDoc;
95 context.m_pNewDocTemplate=NULL;
96 context.m_pLastView=NULL;
97 context.m_pCurrentFrame=NULL;
99 CreateView(row,col,pViewClass,size, &context);
101 CView * pNewView= (CView *)GetPane(row,col);
103 if (bSetActive==TRUE)
104 GetParentFrame()->SetActiveView(pNewView);
106 RecalcLayout();
107 GetPane(row,col)->SendMessage(WM_PAINT);
109 return TRUE;
112 void CXSplitter::HideRow(int nRowHide)
114 ASSERT_VALID( this );
115 ASSERT( m_nRows > 1 );
116 ASSERT( nRowHide < m_nRows );
117 ASSERT( m_nHiddenRow == -1 );
118 m_nHiddenRow = nRowHide;
120 int nActiveRow, nActiveCol;
122 // if the nRow has an active window -- change it
123 if( GetActivePane( &nActiveRow, &nActiveCol ) != NULL )
125 if( nActiveRow == nRowHide )
127 if( ++nActiveRow >= m_nRows )
128 nActiveRow = 0;
129 SetActivePane( nActiveRow, nActiveCol );
133 // hide all nRow panes.
134 for( int nCol = 0; nCol < m_nCols; ++nCol )
136 CWnd* pPaneHide = GetPane( nRowHide, nCol );
137 ASSERT( pPaneHide != NULL );
139 pPaneHide->ShowWindow( SW_HIDE );
140 pPaneHide->SetDlgCtrlID( AFX_IDW_PANE_FIRST+nCol * 16+m_nRows );
142 for( int nRow = nRowHide+1; nRow < m_nRows; ++nRow )
144 CWnd* pPane = GetPane( nRow, nCol );
145 ASSERT( pPane != NULL );
147 pPane->SetDlgCtrlID( IdFromRowCol( nRow-1, nCol ));
151 m_nRows--;
152 m_pRowInfo[m_nRows].nCurSize = m_pRowInfo[nRowHide].nCurSize;
153 RecalcLayout();
156 void CXSplitter::ShowRow()
158 ASSERT_VALID( this );
159 ASSERT( m_nRows < m_nMaxRows );
160 ASSERT( m_nHiddenRow != -1 );
162 int nShowRow = m_nHiddenRow;
163 m_nHiddenRow = -1;
165 int cyNew = m_pRowInfo[m_nRows].nCurSize;
166 m_nRows++; // add a nRow
168 ASSERT( m_nRows == m_nMaxRows );
170 int nRow;
172 // Show the hidden nRow
173 for( int nCol = 0; nCol < m_nCols; ++nCol )
175 CWnd* pPaneShow = GetDlgItem( AFX_IDW_PANE_FIRST+nCol * 16+m_nRows );
176 ASSERT( pPaneShow != NULL );
177 pPaneShow->ShowWindow( SW_SHOWNA );
179 for( nRow = m_nRows - 2; nRow >= nShowRow; --nRow )
181 CWnd* pPane = GetPane( nRow, nCol );
182 ASSERT( pPane != NULL );
183 pPane->SetDlgCtrlID( IdFromRowCol( nRow + 1, nCol ));
186 pPaneShow->SetDlgCtrlID( IdFromRowCol( nShowRow, nCol ));
189 // new panes have been created -- recalculate layout
190 for( nRow = nShowRow+1; nRow < m_nRows; nRow++ )
191 m_pRowInfo[nRow].nIdealSize = m_pRowInfo[nRow - 1].nCurSize;
193 m_pRowInfo[nShowRow].nIdealSize = cyNew;
194 RecalcLayout();
197 void CXSplitter::HideColumn(int nColHide)
199 ASSERT_VALID( this );
200 ASSERT( m_nCols > 1 );
201 ASSERT( nColHide < m_nCols );
202 ASSERT( m_nHiddenCol == -1 );
203 m_nHiddenCol = nColHide;
205 // if the column has an active window -- change it
206 int nActiveRow, nActiveCol;
207 if( GetActivePane( &nActiveRow, &nActiveCol ) != NULL )
209 if( nActiveCol == nColHide )
211 if( ++nActiveCol >= m_nCols )
212 nActiveCol = 0;
213 SetActivePane( nActiveRow, nActiveCol );
217 // hide all column panes
218 for( int nRow = 0; nRow < m_nRows; nRow++)
220 CWnd* pPaneHide = GetPane(nRow, nColHide);
221 ASSERT( pPaneHide != NULL );
223 pPaneHide->ShowWindow(SW_HIDE);
224 pPaneHide->SetDlgCtrlID( AFX_IDW_PANE_FIRST+nRow * 16+m_nCols );
226 for( int nCol = nColHide + 1; nCol < m_nCols; nCol++ )
228 CWnd* pPane = GetPane( nRow, nCol );
229 ASSERT( pPane != NULL );
231 pPane->SetDlgCtrlID( IdFromRowCol( nRow, nCol - 1 ));
235 m_nCols--;
236 m_pColInfo[m_nCols].nCurSize = m_pColInfo[nColHide].nCurSize;
237 RecalcLayout();
240 void CXSplitter::ShowColumn()
242 ASSERT_VALID( this );
243 ASSERT( m_nCols < m_nMaxCols );
244 ASSERT( m_nHiddenCol != -1 );
246 int nShowCol = m_nHiddenCol;
247 m_nHiddenCol = -1;
249 int cxNew = m_pColInfo[m_nCols].nCurSize;
250 m_nCols++; // add a column
252 ASSERT( m_nCols == m_nMaxCols );
254 int nCol;
256 // Show the hidden column
257 for( int nRow = 0; nRow < m_nRows; ++nRow )
259 CWnd* pPaneShow = GetDlgItem( AFX_IDW_PANE_FIRST+nRow * 16+m_nCols );
260 ASSERT( pPaneShow != NULL );
261 pPaneShow->ShowWindow( SW_SHOWNA );
263 for( nCol = m_nCols - 2; nCol >= nShowCol; --nCol )
265 CWnd* pPane = GetPane( nRow, nCol );
266 ASSERT( pPane != NULL );
267 pPane->SetDlgCtrlID( IdFromRowCol( nRow, nCol + 1 ));
270 pPaneShow->SetDlgCtrlID( IdFromRowCol( nRow, nShowCol ));
273 // new panes have been created -- recalculate layout
274 for( nCol = nShowCol+1; nCol < m_nCols; nCol++ )
275 m_pColInfo[nCol].nIdealSize = m_pColInfo[nCol - 1].nCurSize;
277 m_pColInfo[nShowCol].nIdealSize = cxNew;
278 RecalcLayout();