1 /////////////////////////////////////////////////////////////////////////////
2 // WinMerge: an interactive diff/merge utility
3 // Copyright (C) 1997-2000 Thingamahoochie Software
5 // SPDX-License-Identifier: GPL-2.0-or-later
6 /////////////////////////////////////////////////////////////////////////////
8 * @file MergeEditSplitterView.cpp
10 * @brief Implementation of the CMergeEditSplitterView class
14 #include "MergeEditSplitterView.h"
17 #include "MergeEditview.h"
19 #include "OptionsMgr.h"
20 #include "OptionsDef.h"
26 #define SWAPPARAMS_IF(c, a, b) (c ? a : b), (c ? b : a)
28 /////////////////////////////////////////////////////////////////////////////
29 // CMergeEditSplitterView
31 IMPLEMENT_DYNCREATE(CMergeEditSplitterView, CView)
33 CMergeEditSplitterView::CMergeEditSplitterView(): m_bDetailView(false)
37 CMergeEditSplitterView::~CMergeEditSplitterView()
39 dynamic_cast<CMergeDoc *>(GetDocument())->RemoveMergeViews(this);
43 BEGIN_MESSAGE_MAP(CMergeEditSplitterView, CView)
44 //{{AFX_MSG_MAP(CMergeEditSplitterView)
52 /////////////////////////////////////////////////////////////////////////////
53 // CMergeEditSplitterView diagnostics
55 /////////////////////////////////////////////////////////////////////////////
56 // CMergeEditSplitterView message handlers
58 BOOL CMergeEditSplitterView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
60 CView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
62 bool bSplitVert = !GetOptionsMgr()->GetBool(OPT_SPLIT_HORIZONTALLY);
64 bSplitVert = !bSplitVert;
66 CMergeDoc * pDoc = dynamic_cast<CMergeDoc *>(GetDocument());
70 // create a splitter with 1 row, 2 columns
71 if (!m_wndSplitter.CreateStatic(this, SWAPPARAMS_IF(bSplitVert, 1, pDoc->m_nBuffers),
72 WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL) )
74 TRACE0("Failed to CreateStaticSplitter\n");
78 for (int nBuffer = 0; nBuffer < pDoc->m_nBuffers; nBuffer++)
80 if (!m_wndSplitter.CreateView(SWAPPARAMS_IF(bSplitVert, 0, nBuffer),
81 RUNTIME_CLASS(CMergeEditView), CSize(-1, 200), pContext))
83 TRACE1("Failed to create pane%d\n", nBuffer);
88 m_wndSplitter.ResizablePanes(true);
89 m_wndSplitter.AutoResizePanes(GetOptionsMgr()->GetBool(OPT_RESIZE_PANES));
91 // stash left & right pointers into the mergedoc
92 CMergeEditView * pView[3];
93 for (int nBuffer = 0; nBuffer < pDoc->m_nBuffers; nBuffer++)
95 pView[nBuffer] = static_cast<CMergeEditView *>(m_wndSplitter.GetPane(SWAPPARAMS_IF(bSplitVert, 0, nBuffer)));
96 // connect merge views up to display of status info
97 pView[nBuffer]->m_nThisPane = nBuffer;
98 pView[nBuffer]->m_nThisGroup = pDoc->m_nGroups;
99 pView[nBuffer]->m_bDetailView = m_bDetailView;
101 pDoc->AddMergeViews(this, pView);
102 if (!m_bDetailView && pDoc->m_nGroups > 1)
104 for (int nBuffer = 0; nBuffer < pDoc->m_nBuffers; nBuffer++)
106 CMergeEditView *pView2 = pDoc->GetView(pDoc->m_nGroups - 1, nBuffer);
107 pView2->SendMessage(WM_INITIALUPDATE);
108 pView2->CopyProperties(pDoc->GetView(0, nBuffer));
109 pView2->SetStatusInterface(pDoc->GetView(0, nBuffer)->m_piMergeEditStatus);
111 m_wndSplitter.RecalcLayout();
116 void CMergeEditSplitterView::OnInitialUpdate()
118 CView::OnInitialUpdate();
119 CMergeDoc * pDoc = dynamic_cast<CMergeDoc *>(GetDocument());
123 void CMergeEditSplitterView::OnDraw(CDC* pDC)
127 BOOL CMergeEditSplitterView::OnEraseBkgnd (CDC * pdc)
129 UNREFERENCED_PARAMETER(pdc);
133 void CMergeEditSplitterView::OnSize(UINT nType, int cx, int cy)
135 CView::OnSize(nType, cx, cy);
136 if (m_wndSplitter.m_hWnd)
137 m_wndSplitter.MoveWindow(0, 0, cx, cy);