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