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####
25 //===========================================================================
26 //#####DESCRIPTIONBEGIN####
33 // Description: Implementation of a CSplitterWndEx override for control/cell view split
40 //####DESCRIPTIONEND####
42 //===========================================================================
44 #include "ThinSplitter.h"
45 #include "ControlView.h"
46 //#include "CellView.h"
48 BEGIN_MESSAGE_MAP(CThinSplitter, CSplitterWndEx)
49 //{{AFX_MSG_MAP(CThinSplitter)
56 //IMPLEMENT_DYNCREATE(CThinSplitter, CSplitterWndEx)
58 CThinSplitter::CThinSplitter():
62 m_GrayPen.CreatePen(PS_SOLID,1,RGB(192,192,192));
65 CThinSplitter::~CThinSplitter()
69 void CThinSplitter::OnDrawSplitter( CDC* pDC, ESplitType nType, const CRect& rect )
74 //TRACE("paint bar pDC=%08x\n",pDC);
77 CPen *pOldPen=pDC->SelectObject(&m_GrayPen);
78 //static CPen redpen(PS_SOLID,1,RGB(255,0,0));
79 //pDC->FillSolidRect(rect,RGB(192,192,192));
80 //CPen *pOldPen=pDC->SelectObject(&redpen);
82 pDC->MoveTo(cx,rect.top+m_cyBorder);
83 pDC->LineTo(cx,rect.bottom-m_cyBorder);
84 pDC->MoveTo(cx+1,rect.top+m_cyBorder);
85 pDC->LineTo(cx+1,rect.bottom-m_cyBorder);
86 pDC->SelectObject(pOldPen);
95 GetClientRect(rcClient);
96 CSplitterWndEx::OnDrawSplitter( pDC,splitBorder,rcClient);
103 CSplitterWndEx::OnDrawSplitter( pDC, nType,rect );
106 void CThinSplitter::DeleteColumn(int colDelete)
108 // Do nothing - we don't allow deletion of columns
109 UNUSED_ALWAYS(colDelete);
112 int CThinSplitter::HitTest(CPoint pt) const
118 int rc=CSplitterWndEx::HitTest(pt);
120 // Be more lenient about finding the splitter bar
123 rect.left = m_pColInfo[0].nCurSize-3;
124 rect.right = m_pColInfo[0].nCurSize + m_cxSplitterGap + 3;
125 if (rect.PtInRect(pt))
133 void CThinSplitter::OnSize( UINT nType, int cx, int cy )
135 //if(m_nCols>1 && m_pColInfo){
136 // SetColumnInfo(0,int(m_fColumnRatio * cx + 0.5),0);
138 CSplitterWndEx::OnSize( nType, cx, cy );
141 // Two reasons for this: 1-the annoying debug warning the MFC version emits and
142 // 2- an apparent bug whereby the scrollbar gets frozen.
143 void CThinSplitter::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
145 for (int col = 0; col < m_nCols; col++)
147 GetPane(0, col)->SendMessage(WM_VSCROLL,
148 MAKELONG(nSBCode, nPos), (LPARAM)pScrollBar->m_hWnd);
152 BOOL CThinSplitter::SplitColumn(int cxBefore){
154 GetClientRect(rcClient);
155 m_pColInfo[0].nCurSize=m_pColInfo[0].nIdealSize;
156 //m_pDynamicViewClass = RUNTIME_CLASS(CCellView);
157 int rc=CSplitterWndEx::SplitColumn(cxBefore);
158 double d0=double(m_pColInfo[0].nCurSize);
159 double d1=double(m_pColInfo[1].nCurSize);
160 m_fColumnRatio=d0/(d0+d1);
164 // We do this because the CSplitterWndEx implementation assumes both children are derived
165 // from CScrollView - so here we just let the children handle the message themselves.
166 BOOL CThinSplitter::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
169 UNUSED_ALWAYS(nFlags);
170 UNUSED_ALWAYS(zDelta);
174 void CThinSplitter::RecalcLayout()
176 CSplitterWndEx::RecalcLayout();
177 if (m_nCols==2 && m_pColInfo[0].nCurSize && m_pColInfo[1].nCurSize){
180 m_fColumnRatio=double(m_pColInfo[0].nCurSize)/double(rect.Width());
184 BOOL CThinSplitter::CreateStatic( CWnd* pParentWnd, int nRows, int nCols, DWORD dwStyle, UINT nID)
186 bool rc=CSplitterWndEx::CreateStatic(pParentWnd, nRows, nCols, dwStyle, nID);