1 //*******************************************************************************
4 // You may use this source code, compile or redistribute it as part of your application
5 // for free. You cannot redistribute it as a part of a software development
6 // library without the agreement of the author. If the sources are
7 // distributed along with the application, you should leave the original
8 // copyright notes in the source code without any changes.
9 // This code can be used WITHOUT ANY WARRANTIES at your own risk.
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
19 #include "UITabSplitterWnd.h"
21 /////////////////////////////////////////////////////////////////////////////
22 // CTabSplitterWnd message handlers
24 LPCTSTR CTabSplitterWnd::szSplitterSection = _T("Splitter");
25 LPCTSTR CTabSplitterWnd::szPaneWidthCurrent = _T("PaneWidthCurrent");
26 LPCTSTR CTabSplitterWnd::szPaneWidthMinimum = _T("PaneWidthMinimum");
27 LPCTSTR CTabSplitterWnd::szPaneHeightCurrent = _T("PaneHeightCurrent");
28 LPCTSTR CTabSplitterWnd::szPaneHeightMinimum = _T("PaneHeightMinimum");
30 IMPLEMENT_DYNAMIC(CTabSplitterWnd, CSplitterWnd)
32 BEGIN_MESSAGE_MAP(CTabSplitterWnd, CSplitterWnd)
33 //{{AFX_MSG_MAP(CTabSplitterWnd)
42 CTabSplitterWnd::CTabSplitterWnd()
43 : m_strSection(szSplitterSection)
45 m_nCurCol = m_nCurRow = 0;
46 m_cxCur = m_cyCur = 0;
47 m_cxMin = m_cyMin = 0;
50 void CTabSplitterWnd::SetSection(LPCTSTR szSection)
52 m_strSection = szSplitterSection;
53 m_strSection += _T("\\");
54 m_strSection += szSection;
57 CWnd *CTabSplitterWnd::GetActiveWnd()
60 return GetActivePane(row,col);
63 void CTabSplitterWnd::ActivateNext(BOOL bPrev)
67 // find the coordinate of the current pane
69 if (GetActivePane(&row, &col) == NULL)
74 ASSERT(row >= 0 && row < m_nRows);
75 ASSERT(col >= 0 && col < m_nCols);
77 // determine next pane
99 // set newly active pane
100 SetActivePane(row, col);
103 void CTabSplitterWnd::SaveSize()
106 if (m_strSection == szSplitterSection)
107 TRACE0("Warning: SetSection has not been called in IMSplitterWnd!\n");
109 GetColumnInfo(0,m_cxCur,m_cxMin);
111 AfxGetApp()->WriteProfileInt(m_strSection,szPaneWidthCurrent,m_cxCur);
113 AfxGetApp()->WriteProfileInt(m_strSection,szPaneWidthMinimum,m_cxMin);
114 GetRowInfo(0,m_cyCur,m_cyMin);
116 AfxGetApp()->WriteProfileInt(m_strSection,szPaneHeightCurrent,m_cyCur);
118 AfxGetApp()->WriteProfileInt(m_strSection,szPaneHeightMinimum,m_cyMin);
121 void CTabSplitterWnd::SetSize(int nCur,int nMin)
135 void CTabSplitterWnd::Apply()
139 SetRowInfo(0,m_cyCur,m_cyMin);
142 else if (m_nCols > 1)
144 SetColumnInfo(0,m_cxCur,m_cxMin);
148 TRACE0("Applying splitter bar before creating it!\n");
151 BOOL CTabSplitterWnd::CreateView(int row,int col,CRuntimeClass* pViewClass,SIZE sizeInit,CCreateContext* pContext)
156 sizeInit.cx = m_cxCur;
157 else if (m_strSection != szSplitterSection)
158 sizeInit.cx = AfxGetApp()->GetProfileInt(m_strSection,szPaneWidthCurrent,sizeInit.cx);
159 m_cxCur = sizeInit.cx;
164 sizeInit.cy = m_cyCur;
165 else if (m_strSection != szSplitterSection)
166 sizeInit.cy = AfxGetApp()->GetProfileInt(m_strSection,szPaneHeightCurrent,sizeInit.cy);
167 m_cyCur = sizeInit.cy;
169 return CSplitterWnd::CreateView(row,col,pViewClass,sizeInit,pContext);
172 void CTabSplitterWnd::StopTracking(BOOL bAccept)
174 // save old active view
175 CWnd* pOldActiveView = GetActivePane();
176 CSplitterWnd::StopTracking(bAccept);
179 if (pOldActiveView == GetActivePane())
181 if (pOldActiveView == NULL)
185 // pOldActiveView->SetFocus(); // make sure focus is restored
194 /////////////////////////////////////////////////////////////////////////////
195 // CTabSplitterWnd message handlers
196 void CTabSplitterWnd::OnDestroy()
198 CSplitterWnd::OnDestroy();
203 void CTabSplitterWnd::OnClose()
205 // TODO: Add your message handler code here and/or call default
207 CSplitterWnd::OnClose();
210 void CTabSplitterWnd::OnSetFocus(CWnd* pOldWnd)
212 CSplitterWnd::OnSetFocus(pOldWnd);
214 // TODO: Add your message handler code here
215 if (m_nCurRow >= 0 && m_nCurCol >= 0)
217 SetActivePane(m_nCurRow,m_nCurCol);
218 CWnd *pWnd = GetPane(m_nCurRow,m_nCurCol);
223 void CTabSplitterWnd::OnKillFocus(CWnd* pNewWnd)
225 CSplitterWnd::OnKillFocus(pNewWnd);
227 // TODO: Add your message handler code here
228 GetActivePane(&m_nCurRow,&m_nCurCol);
231 // This currently only saves the first pane
232 void CTabSplitterWnd::Serialize(CArchive& ar)
250 // mouse wheel handled by the views
251 BOOL CTabSplitterWnd::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
253 // TODO: Add your message handler code here and/or call default
254 TRACE(_T("SplitterWnd mouse wheel message\n"));
255 /* if (m_nCurRow >= 0 && m_nCurCol >= 0)
257 SetActivePane(m_nCurRow,m_nCurCol);
258 CWnd *pWnd = GetPane(m_nCurRow,m_nCurCol);
263 BOOL CTabSplitterWnd::PreCreateWindow(CREATESTRUCT& cs)
265 // TODO: Add your specialized code here and/or call the base class
266 cs.lpszClass = AfxRegisterWndClass(
271 ASSERT(cs.lpszClass);
273 return CSplitterWnd::PreCreateWindow(cs);