{
m_bActivated = FALSE;
m_nLastSplitPos = 0;
+ m_pMergeDoc = 0;
}
CChildFrame::~CChildFrame()
pLeft->SetStatusInterface(&m_leftStatus);
pRight->SetStatusInterface(&m_rightStatus);
// tell merge doc about these views
- CMergeDoc * pDoc = dynamic_cast<CMergeDoc *>(pContext->m_pCurrentDoc);
- pDoc->SetMergeViews(pLeft, pRight);
+ m_pMergeDoc = dynamic_cast<CMergeDoc *>(pContext->m_pCurrentDoc);
+ m_pMergeDoc->SetMergeViews(pLeft, pRight);
pLeft->m_nThisPane = 0;
pRight->m_nThisPane = 1;
CMergeDiffDetailView * pLeftDetail = (CMergeDiffDetailView *)m_wndDetailSplitter.GetPane(0,0);
CMergeDiffDetailView * pRightDetail = (CMergeDiffDetailView *)m_wndDetailSplitter.GetPane(1,0);
// tell merge doc about these views
- pDoc->SetMergeDetailViews(pLeftDetail, pRightDetail);
+ m_pMergeDoc->SetMergeDetailViews(pLeftDetail, pRightDetail);
pLeftDetail->m_nThisPane = 0;
pRightDetail->m_nThisPane = 1;
#include "DiffViewBar.h"
#include "LocationBar.h"
+class CMergeDoc;
+
/**
* @brief Frame class for file compare, handles panes, statusbar etc.
*/
DECLARE_DYNCREATE(CChildFrame)
public:
CChildFrame();
+
+// Operations
+public:
+ void UpdateResources();
+ void CloseNow();
IHeaderBar * GetHeaderInterface();
void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; };
+ CMergeDoc * GetMergeDoc() { return m_pMergeDoc; }
// Attributes
protected:
MergeStatus m_leftStatus;
MergeStatus m_rightStatus;
-// Operations
-public:
- void UpdateResources();
-private:
- BOOL EnsureValidDockState(CDockState& state);
-public:
// Overrides
// ClassWizard generated virtual function overrides
//}}AFX_VIRTUAL
// Implementation
-public:
+private:
+ BOOL EnsureValidDockState(CDockState& state);
void UpdateDiffDockbarHeight(int DiffPanelHeight);
void SavePosition();
virtual ~CChildFrame();
- void CloseNow();
// Generated message map functions
-protected:
+private:
int m_nLastSplitPos;
void UpdateHeaderSizes();
BOOL m_bActivated;
+ CMergeDoc * m_pMergeDoc;
+
//{{AFX_MSG(CChildFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnClose();
UpdatePrediffersMenu();
}
+/** @brief Return active merge edit view, if can figure it out/is available */
+CMergeEditView * CMainFrame::GetActiveMergeEditView()
+{
+ // NB: GetActiveDocument does not return the Merge Doc
+ // even when the merge edit view is in front
+ // NB: CChildFrame::GetActiveView returns NULL when location view active
+ // So we have this rather complicated logic to try to get a merge edit view
+ // We look at the front child window, which should be a frame
+ // and we can get a MergeEditView from it, if it is a CChildFrame
+ // (DirViews use a different frame type)
+ CChildFrame * pFrame = dynamic_cast<CChildFrame *>(GetActiveFrame());
+ if (!pFrame) return 0;
+ // Try to get the active MergeEditView (ie, left or right)
+ if (pFrame->GetActiveView() && pFrame->GetActiveView()->IsKindOf(RUNTIME_CLASS(CMergeEditView)))
+ {
+ return dynamic_cast<CMergeEditView *>(pFrame->GetActiveView());
+ }
+ return pFrame->GetMergeDoc()->GetActiveMergeView();
+}
+
void CMainFrame::UpdatePrediffersMenu()
{
CMenu* menu = GetMenu();
HMENU prediffersSubmenu = GetPrediffersSubmenu(hMainMenu);
if (prediffersSubmenu != NULL)
{
- CMergeEditView * pEditView = dynamic_cast<CMergeEditView*> (GetActiveFrame()->GetActiveView());
+ CMergeEditView * pEditView = GetActiveMergeEditView();
if (pEditView)
pEditView->createPrediffersSubmenu(prediffersSubmenu);
else
* @brief Determines currently active view.
* @return one of MERGEVIEW_INDEX_TYPE values or -1 in error.
*/
-int CMergeDoc::GetActiveMergeView()
-{
- CCrystalTextView* curView = dynamic_cast<CCrystalTextView*> (GetParentFrame()->GetActiveView());
- if (curView == m_pView[0])
+int CMergeDoc::GetActiveMergeViewIndexType() const
+{
+ CMergeDoc * pThis = const_cast<CMergeDoc *>(this);
+ // Get active view pointer
+ CView * pActiveView = pThis->GetParentFrame()->GetActiveView();
+ // Cast it to common base of all our views
+ CCrystalTextView* curView = dynamic_cast<CCrystalTextView*> (pActiveView);
+ // Now test it against all our views to see which it is
+ if (curView == GetLeftView())
return MERGEVIEW_LEFT;
- else if (curView == m_pView[1])
+ else if (curView == GetRightView())
return MERGEVIEW_RIGHT;
- else if (curView == m_pDetailView[0])
+ else if (curView == GetLeftDetailView())
return MERGEVIEW_LEFT_DETAIL;
- else if (curView == m_pDetailView[1])
+ else if (curView == GetRightDetailView())
return MERGEVIEW_RIGHT_DETAIL;
_RPTF0(_CRT_ERROR, "Invalid view pointer!");
return -1;
}
+/**
+ * @brief Return active merge edit view (or left one if neither active)
+ */
+CMergeEditView * CMergeDoc::GetActiveMergeView()
+{
+ CView * pActiveView = GetParentFrame()->GetActiveView();
+ CMergeEditView * pMergeEditView = dynamic_cast<CMergeEditView *>(pActiveView);
+ if (!pMergeEditView)
+ pMergeEditView = GetLeftView(); // default to left view (in case some location or detail view active)
+ return pMergeEditView;
+}
+
void CMergeDoc::SetUnpacker(PackingInfo * infoNewHandler)
{
if (infoNewHandler)
{
// Find out diff under cursor
CPoint ptCursor;
- int nActiveView = GetActiveMergeView();
- if (nActiveView == MERGEVIEW_LEFT || nActiveView == MERGEVIEW_RIGHT)
- ptCursor = m_pView[nActiveView]->GetCursorPos();
- else if (nActiveView == MERGEVIEW_LEFT_DETAIL ||
- nActiveView == MERGEVIEW_RIGHT_DETAIL)
+ int nActiveViewIndexType = GetActiveMergeViewIndexType();
+ if (nActiveViewIndexType == MERGEVIEW_LEFT || nActiveViewIndexType == MERGEVIEW_RIGHT)
+ ptCursor = m_pView[nActiveViewIndexType]->GetCursorPos();
+ else if (nActiveViewIndexType == MERGEVIEW_LEFT_DETAIL ||
+ nActiveViewIndexType == MERGEVIEW_RIGHT_DETAIL)
{
- ptCursor = m_pView[nActiveView - MERGEVIEW_LEFT_DETAIL]->GetCursorPos();
+ ptCursor = m_pView[nActiveViewIndexType - MERGEVIEW_LEFT_DETAIL]->GetCursorPos();
}
nDiff = m_diffList.LineToDiff(ptCursor.y);
}
WaitStatusCursor waitstatus(LoadResString(IDS_STATUS_RESCANNING));
- int nActiveView = GetActiveMergeView();
+ int nActiveViewIndexType = GetActiveMergeViewIndexType();
// store cursors and hide caret
m_pView[0]->PushCursors();
m_pView[1]->PushCursors();
m_pDetailView[0]->PushCursors();
m_pDetailView[1]->PushCursors();
- if (nActiveView == MERGEVIEW_LEFT || nActiveView == MERGEVIEW_RIGHT)
- m_pView[nActiveView]->HideCursor();
+ if (nActiveViewIndexType == MERGEVIEW_LEFT || nActiveViewIndexType == MERGEVIEW_RIGHT)
+ m_pView[nActiveViewIndexType]->HideCursor();
BOOL bBinary = FALSE;
BOOL bIdentical = FALSE;
m_pView[1]->PopCursors();
m_pDetailView[0]->PopCursors();
m_pDetailView[1]->PopCursors();
- if (nActiveView == MERGEVIEW_LEFT || nActiveView == MERGEVIEW_RIGHT)
- m_pView[nActiveView]->ShowCursor();
+ if (nActiveViewIndexType == MERGEVIEW_LEFT || nActiveViewIndexType == MERGEVIEW_RIGHT)
+ m_pView[nActiveViewIndexType]->ShowCursor();
// because of ghostlines, m_nTopLine may differ just after Rescan
// scroll both views to the same top line
CMergeEditView * fixedView = m_pView[0];
- if (nActiveView == MERGEVIEW_LEFT || nActiveView == MERGEVIEW_RIGHT)
+ if (nActiveViewIndexType == MERGEVIEW_LEFT || nActiveViewIndexType == MERGEVIEW_RIGHT)
// only one view needs to scroll so do not scroll the active view
- fixedView = m_pView[nActiveView];
+ fixedView = m_pView[nActiveViewIndexType];
fixedView->UpdateSiblingScrollPos(FALSE);
// make sure we see the cursor from the curent view
- if (nActiveView == MERGEVIEW_LEFT || nActiveView == MERGEVIEW_RIGHT)
- m_pView[nActiveView]->EnsureVisible(m_pView[nActiveView]->GetCursorPos());
+ if (nActiveViewIndexType == MERGEVIEW_LEFT || nActiveViewIndexType == MERGEVIEW_RIGHT)
+ m_pView[nActiveViewIndexType]->EnsureVisible(m_pView[nActiveViewIndexType]->GetCursorPos());
// scroll both diff views to the same top line
CMergeDiffDetailView * fixedDetailView = m_pDetailView[0];
- if (nActiveView == MERGEVIEW_LEFT_DETAIL || nActiveView == MERGEVIEW_RIGHT_DETAIL)
+ if (nActiveViewIndexType == MERGEVIEW_LEFT_DETAIL || nActiveViewIndexType == MERGEVIEW_RIGHT_DETAIL)
// only one view needs to scroll so do not scroll the active view
- fixedDetailView = m_pDetailView[nActiveView - MERGEVIEW_LEFT_DETAIL];
+ fixedDetailView = m_pDetailView[nActiveViewIndexType - MERGEVIEW_LEFT_DETAIL];
fixedDetailView->UpdateSiblingScrollPos(FALSE);
// Refresh display