1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
26 //===========================================================================
27 //#####DESCRIPTIONBEGIN####
34 // Description: This is the implementation of the extended splitter window class.
41 //####DESCRIPTIONEND####
43 //===========================================================================
45 #include "SplitterWndEx.h"
50 static char THIS_FILE[] = __FILE__;
53 ////////////////////////////////////////////////////////////////////////////
57 CSplitterWndEx::CSplitterWndEx():
58 m_fRowColumnRatio(0.0)
64 BEGIN_MESSAGE_MAP(CSplitterWndEx, CSplitterWnd)
65 //{{AFX_MSG_MAP(CSplitterWndEx)
71 void CSplitterWndEx::ShowPane(CWnd * pWnd,BOOL bShow)
75 m_pwnd2=GetPane(!IsHorizontal(),IsHorizontal());
78 ASSERT(pWnd==m_pwnd1 || pWnd==m_pwnd2);
80 int &nRowCols=IsHorizontal()?m_nCols:m_nRows;
83 if(!pWnd->IsWindowVisible()){
85 ((CSplitterWndEx *)GetParent())->ShowPane(this,TRUE);
86 // Ensure the correct pane reappears
87 if(GetPane(0,0)!=pWnd){
88 // Need to swap the entries
92 } else { // maybe nothing to do
95 // Need to swap the entries
100 pWnd->ShowWindow(SW_SHOW);
103 m_pwnd1->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
104 m_pwnd2->SetDlgCtrlID(AFX_IDW_PANE_FIRST+(IsHorizontal()?1:16));
107 if(pWnd->IsWindowVisible()){
109 pWnd->ShowWindow(SW_HIDE);
112 ((CSplitterWndEx *)GetParent())->ShowPane(this,FALSE);
114 // Both panes currently active
115 int rowActive, colActive;
116 if (GetActivePane(&rowActive, &colActive) != NULL && pWnd==GetPane(rowActive, colActive)){
117 int bHorz=IsHorizontal();
118 SetActivePane((!bHorz)&(rowActive^1), (bHorz)&(colActive^1));
122 m_pwnd2->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
123 m_pwnd1->SetDlgCtrlID(AFX_IDW_PANE_FIRST+1);
132 void CSplitterWndEx::SwapRowColInfo()
134 CRowColInfo*& pRowColInfo=IsHorizontal()?m_pColInfo:m_pRowInfo;
136 // Need to swap the entries
138 memcpy(&save,&pRowColInfo[0],sizeof CRowColInfo);
139 memcpy(&pRowColInfo[0],&pRowColInfo[1],sizeof CRowColInfo);
140 memcpy(&pRowColInfo[1],&save,sizeof CRowColInfo);
144 // We do this because the CSplitterWnd implementation assumes both children are derived
145 // from CScrollView - so here we just let the children handle the message themselves.
146 BOOL CSplitterWndEx::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
149 UNUSED_ALWAYS(nFlags);
150 UNUSED_ALWAYS(zDelta);
154 void CSplitterWndEx::OnSize(UINT nType, int cx, int cy)
156 int &nRowCols=IsHorizontal()?m_nCols:m_nRows;
157 CRowColInfo *&RowColInfo=IsHorizontal()?m_pColInfo:m_pRowInfo;
158 if(nRowCols>1 && (cx|cy) && m_fRowColumnRatio!=0.0){
159 RowColInfo[0].nIdealSize=int(0.5 + m_fRowColumnRatio * double(IsHorizontal()?cx:cy));
161 CSplitterWnd::OnSize( nType, cx, cy );
164 void CSplitterWndEx::RecalcLayout()
166 CSplitterWnd::RecalcLayout();
167 CRowColInfo *&RowColInfo=IsHorizontal()?m_pColInfo:m_pRowInfo;
168 int &nRowCols=IsHorizontal()?m_nCols:m_nRows;
169 if (nRowCols==2 && RowColInfo[0].nCurSize && RowColInfo[1].nCurSize){
172 m_fRowColumnRatio=double(RowColInfo[0].nCurSize)/double(IsHorizontal()?rect.Width():rect.Height());
176 double CSplitterWndEx::GetSplitPoint()
178 return m_fRowColumnRatio;
181 void CSplitterWndEx::SetSplitPoint(double fSplit)
183 m_fRowColumnRatio=fSplit;
186 OnSize(SIZE_RESTORED,rc.Width(),rc.Height());