Revision: 7278
http://winmerge.svn.sourceforge.net/winmerge/?rev=7278&view=rev
Author: jtuc
Date: 2010-09-24 06:25:00 +0000 (Fri, 24 Sep 2010)
Log Message:
-----------
Merge HexMerge* changes from trunk. This does not reenable the feature though, as decision whether to do so is up to Kimmo.
Modified Paths:
--------------
branches/R2_14/Src/HexMergeDoc.cpp
branches/R2_14/Src/HexMergeDoc.h
branches/R2_14/Src/HexMergeFrm.cpp
branches/R2_14/Src/HexMergeFrm.h
branches/R2_14/Src/HexMergeView.cpp
branches/R2_14/Src/HexMergeView.h
Added Paths:
-----------
branches/R2_14/Src/heksedit.h
Modified: branches/R2_14/Src/HexMergeDoc.cpp
===================================================================
--- branches/R2_14/Src/HexMergeDoc.cpp 2010-09-22 19:08:08 UTC (rev 7277)
+++ branches/R2_14/Src/HexMergeDoc.cpp 2010-09-24 06:25:00 UTC (rev 7278)
@@ -146,6 +146,8 @@
{
m_pView[MERGE_VIEW_LEFT] = NULL;
m_pView[MERGE_VIEW_RIGHT] = NULL;
+ m_nBufferType[0] = BUFFER_NORMAL;
+ m_nBufferType[1] = BUFFER_NORMAL;
}
/**
@@ -412,30 +414,48 @@
}
/**
+* @brief Load one file
+*/
+HRESULT CHexMergeDoc::LoadOneFile(int index, LPCTSTR filename, BOOL readOnly)
+{
+ if (Try(m_pView[index]->LoadFile(filename), MB_ICONSTOP) != 0)
+ return E_FAIL;
+ m_pView[index]->SetReadOnly(readOnly);
+ m_filePaths.SetPath(index, filename);
+ ASSERT(m_nBufferType[index] == BUFFER_NORMAL); // should have been initialized to BUFFER_NORMAL in constructor
+ String strDesc = GetMainFrame()->m_strDescriptions[index];
+ if (!strDesc.empty())
+ {
+ m_strDesc[index] = strDesc;
+ m_nBufferType[index] = BUFFER_NORMAL_NAMED;
+ }
+ UpdateHeaderPath(index);
+ m_pView[index]->ResizeWindow();
+ return S_OK;
+}
+
+/**
* @brief Load files and initialize frame's compare result icon
*/
HRESULT CHexMergeDoc::OpenDocs(LPCTSTR pathLeft, LPCTSTR pathRight, BOOL bROLeft, BOOL bRORight)
{
- if (Try(m_pView[MERGE_VIEW_LEFT]->LoadFile(pathLeft), MB_ICONSTOP) == 0)
+ CHexMergeFrame *pf = GetParentFrame();
+ ASSERT(pf);
+ HRESULT hr;
+ if (SUCCEEDED(hr = LoadOneFile(MERGE_VIEW_LEFT, pathLeft, bROLeft)) &&
+ SUCCEEDED(hr = LoadOneFile(MERGE_VIEW_RIGHT, pathRight, bRORight)))
{
- m_pView[MERGE_VIEW_LEFT]->SetReadOnly(bROLeft);
- m_filePaths.SetLeft(pathLeft);
- m_strDesc[MERGE_VIEW_LEFT] = pathLeft;
- UpdateHeaderPath(MERGE_VIEW_LEFT);
+ UpdateDiffItem(0);
+ pf->Invalidate();
+ if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
+ m_pView[MERGE_VIEW_LEFT]->SendMessage(WM_COMMAND, ID_FIRSTDIFF);
}
- if (Try(m_pView[MERGE_VIEW_RIGHT]->LoadFile(pathRight), MB_ICONSTOP) == 0)
+ else
{
- m_pView[MERGE_VIEW_RIGHT]->SetReadOnly(bRORight);
- m_filePaths.SetRight(pathRight);
- m_strDesc[MERGE_VIEW_RIGHT] = pathRight;
- UpdateHeaderPath(MERGE_VIEW_RIGHT);
+ // Use verify macro to trap possible error in debug.
+ VERIFY(pf->DestroyWindow());
}
- m_pView[MERGE_VIEW_LEFT]->ResizeWindow();
- m_pView[MERGE_VIEW_RIGHT]->ResizeWindow();
- UpdateDiffItem(0);
- if (GetOptionsMgr()->GetBool(OPT_SCROLL_TO_FIRST))
- m_pView[MERGE_VIEW_LEFT]->SendMessage(WM_COMMAND, ID_FIRSTDIFF);
- return S_OK;
+ return hr;
}
/**
Modified: branches/R2_14/Src/HexMergeDoc.h
===================================================================
--- branches/R2_14/Src/HexMergeDoc.h 2010-09-22 19:08:08 UTC (rev 7277)
+++ branches/R2_14/Src/HexMergeDoc.h 2010-09-24 06:25:00 UTC (rev 7278)
@@ -25,7 +25,6 @@
// RCS ID line follows -- this is updated by CVS
// $Id$
-#include "TempFile.h"
#include "PathContext.h"
#include "DiffFileInfo.h"
@@ -72,14 +71,14 @@
CHexMergeFrame * GetParentFrame();
void UpdateHeaderPath(int pane);
HRESULT OpenDocs(LPCTSTR pathLeft, LPCTSTR pathRight, BOOL bROLeft, BOOL bRORight);
-protected:
+private:
static void CopySel(CHexMergeView *pViewSrc, CHexMergeView *pViewDst);
static void CopyAll(CHexMergeView *pViewSrc, CHexMergeView *pViewDst);
+ HRESULT LoadOneFile(int index, LPCTSTR filename, BOOL readOnly);
// Implementation data
protected:
CHexMergeView * m_pView[MERGE_VIEW_COUNT]; /**< Pointer to left/right view */
CDirDoc * m_pDirDoc;
- TempFile m_tempFiles[2]; /**< Temp files for compared files */
String m_strDesc[2]; /**< Left/right side description text */
BUFFERTYPE m_nBufferType[2];
Modified: branches/R2_14/Src/HexMergeFrm.cpp
===================================================================
--- branches/R2_14/Src/HexMergeFrm.cpp 2010-09-22 19:08:08 UTC (rev 7277)
+++ branches/R2_14/Src/HexMergeFrm.cpp 2010-09-24 06:25:00 UTC (rev 7278)
@@ -41,11 +41,6 @@
static char THIS_FILE[] = __FILE__;
#endif
-/**
- * @brief RO status panel width
- */
-static UINT RO_PANEL_WIDTH = 40;
-
/////////////////////////////////////////////////////////////////////////////
// CHexMergeFrame
@@ -78,19 +73,6 @@
PANE_RIGHT_EOL,
};
-/**
- * @brief Bottom statusbar panels and indicators
- */
-static UINT indicatorsBottom[] =
-{
- ID_SEPARATOR,
- ID_SEPARATOR,
- ID_SEPARATOR,
- ID_SEPARATOR,
- ID_SEPARATOR,
- ID_SEPARATOR,
-};
-
/////////////////////////////////////////////////////////////////////////////
// CHexMergeFrame construction/destruction
@@ -98,7 +80,6 @@
: m_hIdentical(NULL)
, m_hDifferent(NULL)
{
- m_bActivated = FALSE;
m_nLastSplitPos = 0;
m_pMergeDoc = 0;
}
@@ -145,13 +126,15 @@
/**
* @brief Create a status bar to be associated with a heksedit control
*/
-void CHexMergeFrame::CreateHexWndStatusBar(CStatusBar &wndStatusBar)
+void CHexMergeFrame::CreateHexWndStatusBar(CStatusBar &wndStatusBar, CWnd *pwndPane)
{
- wndStatusBar.Create(this, WS_CHILD|WS_VISIBLE);
+ wndStatusBar.Create(pwndPane, WS_CHILD|WS_VISIBLE);
wndStatusBar.SetIndicators(0, 3);
wndStatusBar.SetPaneInfo(0, 0, SBPS_STRETCH, 0);
- wndStatusBar.SetPaneInfo(1, 0, 0, 72);
- wndStatusBar.SetPaneInfo(2, 0, 0, 72);
+ wndStatusBar.SetPaneInfo(1, 0, 0, 80);
+ wndStatusBar.SetPaneInfo(2, 0, 0, 80);
+ wndStatusBar.SetParent(this);
+ wndStatusBar.SetWindowPos(&wndBottom, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
/**
@@ -194,35 +177,31 @@
m_wndFilePathBar.SetActive(0, FALSE);
m_wndFilePathBar.SetActive(1, FALSE);
+ CHexMergeView *pLeft = static_cast<CHexMergeView *>(m_wndSplitter.GetPane(0, 0));
+ CHexMergeView *pRight = static_cast<CHexMergeView *>(m_wndSplitter.GetPane(0, 1));
+
m_wndLeftStatusBar.m_cxRightBorder = 4;
- ModifyStyle(WS_THICKFRAME, 0); // Prevent SBARS_SIZEGRIP
- CreateHexWndStatusBar(m_wndLeftStatusBar);
- ModifyStyle(0, WS_THICKFRAME);
- CreateHexWndStatusBar(m_wndRightStatusBar);
+ CreateHexWndStatusBar(m_wndLeftStatusBar, pLeft);
+ pRight->ModifyStyle(0, WS_THICKFRAME); // Create an SBARS_SIZEGRIP
+ CreateHexWndStatusBar(m_wndRightStatusBar, pRight);
+ pRight->ModifyStyle(WS_THICKFRAME, 0);
CSize size = m_wndLeftStatusBar.CalcFixedLayout(TRUE, TRUE);
m_rectBorder.bottom = size.cy;
- m_hIdentical = AfxGetApp()->LoadIcon(IDI_EQUALFILE);
- m_hDifferent = AfxGetApp()->LoadIcon(IDI_NOTEQUALFILE);
+ m_hIdentical = AfxGetApp()->LoadIcon(IDI_EQUALBINARY);
+ m_hDifferent = AfxGetApp()->LoadIcon(IDI_BINARYDIFF);
- // stash left & right pointers into the mergedoc
- CHexMergeView *pLeft = static_cast<CHexMergeView *>(m_wndSplitter.GetPane(0,0));
- CHexMergeView *pRight = static_cast<CHexMergeView *>(m_wndSplitter.GetPane(0,1));
+ // get the IHexEditorWindow interfaces
+ IHexEditorWindow *pifLeft = pLeft->GetInterface();
+ IHexEditorWindow *pifRight = pRight->GetInterface();
- IHexEditorWindow *pifLeft = reinterpret_cast<IHexEditorWindow *>(
- ::GetWindowLongPtr(pLeft->m_hWnd, GWLP_USERDATA));
- IHexEditorWindow *pifRight = reinterpret_cast<IHexEditorWindow *>(
- ::GetWindowLongPtr(pRight->m_hWnd, GWLP_USERDATA));
+ // tell the heksedit controls about each other
+ pifLeft->set_sibling(pifRight);
+ pifRight->set_sibling(pifLeft);
- if (pifLeft && pifRight)
- {
- pifLeft->set_sibling(pifRight);
- pifRight->set_sibling(pifLeft);
- pifLeft->set_status_bar(m_wndLeftStatusBar.m_hWnd);
- pifRight->set_status_bar(m_wndRightStatusBar.m_hWnd);
- Customize(pifLeft);
- Customize(pifRight);
- }
+ // adjust a few settings and colors
+ Customize(pifLeft);
+ Customize(pifRight);
// tell merge doc about these views
m_pMergeDoc = dynamic_cast<CHexMergeDoc *>(pContext->m_pCurrentDoc);
@@ -250,6 +229,15 @@
}
}
+void CHexMergeFrame::ActivateFrame(int nCmdShow)
+{
+ if (!GetMDIFrame()->MDIGetActive() && theApp.GetProfileInt(_T("Settings"), _T("ActiveFrameMax"), FALSE))
+ {
+ nCmdShow = SW_SHOWMAXIMIZED;
+ }
+ CMDIChildWnd::ActivateFrame(nCmdShow);
+}
+
/**
* @brief Save the window's position, free related resources, and destroy the window
*/
Modified: branches/R2_14/Src/HexMergeFrm.h
===================================================================
--- branches/R2_14/Src/HexMergeFrm.h 2010-09-22 19:08:08 UTC (rev 7277)
+++ branches/R2_14/Src/HexMergeFrm.h 2010-09-24 06:25:00 UTC (rev 7278)
@@ -28,8 +28,10 @@
#include "SplitterWndEx.h"
#include "EditorFilepathBar.h"
-#include "../externals/heksedit/heksedit.h"
+#define HEKSEDIT_INTERFACE_VERSION 1
+#include "heksedit.h"
+
class CHexMergeDoc;
/**
@@ -67,6 +69,7 @@
//{{AFX_VIRTUAL(CHexMergeFrame)
public:
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
+ virtual void ActivateFrame(int nCmdShow = -1);
virtual BOOL DestroyWindow();
protected:
//}}AFX_VIRTUAL
@@ -75,12 +78,11 @@
private:
void SavePosition();
virtual ~CHexMergeFrame();
- void CreateHexWndStatusBar(CStatusBar &);
+ void CreateHexWndStatusBar(CStatusBar &, CWnd *);
// Generated message map functions
private:
int m_nLastSplitPos;
void UpdateHeaderSizes();
- BOOL m_bActivated;
CHexMergeDoc * m_pMergeDoc;
HICON m_hIdentical;
HICON m_hDifferent;
Modified: branches/R2_14/Src/HexMergeView.cpp
===================================================================
--- branches/R2_14/Src/HexMergeView.cpp 2010-09-22 19:08:08 UTC (rev 7277)
+++ branches/R2_14/Src/HexMergeView.cpp 2010-09-24 06:25:00 UTC (rev 7278)
@@ -34,7 +34,6 @@
#include "HexMergeView.h"
#include "OptionsDef.h"
#include "Environment.h"
-#include "../externals/heksedit/version.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -122,14 +121,14 @@
*/
BOOL CHexMergeView::PreCreateWindow(CREATESTRUCT& cs)
{
- static const TCHAR pe[] = PE_HEKSEDIT;
- static const TCHAR wc[] = WC_HEKSEDIT;
- if ((cs.hInstance = ::GetModuleHandle(pe)) == 0 &&
- (cs.hInstance = ::LoadLibrary(pe)) == 0)
+ static void *pv = NULL;
+ if (pv == NULL)
{
- return FALSE;
+ static const CLSID clsid = { 0xBCA3CA6B, 0xCC6B, 0x4F79,
+ { 0xA2, 0xC2, 0xDD, 0xBE, 0x86, 0x4B, 0x1C, 0x90 } };
+ CoGetClassObject(clsid, CLSCTX_INPROC_SERVER, NULL, IID_IUnknown, &pv);
}
- cs.lpszClass = wc;
+ cs.lpszClass = _T("heksedit");
cs.style |= WS_HSCROLL | WS_VSCROLL;
return TRUE;
}
@@ -142,7 +141,7 @@
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_pif = reinterpret_cast<IHexEditorWindow *>(::GetWindowLongPtr(m_hWnd, GWLP_USERDATA));
- if (m_pif == 0)
+ if (m_pif == 0 || m_pif->get_interface_version() < HEKSEDIT_INTERFACE_VERSION)
return -1;
return 0;
}
@@ -276,7 +275,7 @@
if (hr != S_OK)
GetBuffer(0);
}
- else
+ else if (length != 0)
{
hr = E_OUTOFMEMORY;
}
@@ -336,7 +335,7 @@
if (hr != S_OK)
{
LogErrorString(Fmt(_T("DeleteFile(%s) failed: %s"),
- sIntermediateFilename.c_str(), GetSysError(hr)));
+ sIntermediateFilename.c_str(), GetSysError(hr).c_str()));
}
return S_OK;
}
Modified: branches/R2_14/Src/HexMergeView.h
===================================================================
--- branches/R2_14/Src/HexMergeView.h 2010-09-22 19:08:08 UTC (rev 7277)
+++ branches/R2_14/Src/HexMergeView.h 2010-09-24 06:25:00 UTC (rev 7278)
@@ -47,6 +47,7 @@
public:
HRESULT LoadFile(LPCTSTR);
HRESULT SaveFile(LPCTSTR);
+ IHexEditorWindow *GetInterface() const { return m_pif; }
IHexEditorWindow::Status *GetStatus();
BYTE *GetBuffer(int);
int GetLength();
Added: branches/R2_14/Src/heksedit.h
===================================================================
--- branches/R2_14/Src/heksedit.h (rev 0)
+++ branches/R2_14/Src/heksedit.h 2010-09-24 06:25:00 UTC (rev 7278)
@@ -0,0 +1,115 @@
+/////////////////////////////////////////////////////////////////////////////
+// License (GPLv2+):
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+/////////////////////////////////////////////////////////////////////////////
+/**
+ * @file heksedit.h
+ *
+ * @brief Interface definition for the hekseditor window.
+ *
+ */
+// ID line follows -- this is updated by SVN
+// $Id: heksedit.h 492 2009-04-11 15:17:02Z jtuc $
+
+#ifndef _HEKSEDIT_H_
+#define _HEKSEDIT_H_
+
+#ifndef HEKSEDIT_INTERFACE_VERSION
+#define HEKSEDIT_INTERFACE_VERSION 1
+#endif
+
+/**
+ * @brief Interface for the Hexeditor window.
+ * @note This file is published to hosting applications. Do not add global declarations.
+ */
+class IHexEditorWindow
+{
+public:
+ /**
+ * @brief Byte endians.
+ */
+ enum BYTE_ENDIAN
+ {
+ ENDIAN_LITTLE, /**< Little endian used e.g. in Intel processors. */
+ ENDIAN_BIG /**< Big endian used e.g. in Motorola processors. */
+ };
+
+ struct Colors
+ {
+ COLORREF iTextColorValue, iBkColorValue, iSepColorValue;
+ COLORREF iSelBkColorValue, iSelTextColorValue;
+ COLORREF iBmkColor;
+ COLORREF iDiffBkColorValue, iDiffTextColorValue, iSelDiffBkColorValue, iSelDiffTextColorValue;
+ };
+
+ struct Settings
+ {
+ int iBytesPerLine;
+ int iAutomaticBPL;
+ BYTE_ENDIAN iBinaryMode;
+ int bReadOnly;
+ int bSaveIni;
+ int iFontSize;
+ int iCharacterSet;
+ int iMinOffsetLen;
+ int iMaxOffsetLen;
+ int bAutoOffsetLen;
+ int bCenterCaret;
+ int iFontZoom;
+ };
+
+ struct Status
+ {
+ int iFileChanged;
+ int iEnteringMode;
+ int iCurByte;
+ int iCurNibble;
+ int iVscrollMax;
+ int iVscrollPos;
+ int iHscrollMax;
+ int iHscrollPos;
+ int bSelected;
+ int iStartOfSelection;
+ int iEndOfSelection;
+ };
+
+ virtual unsigned STDMETHODCALLTYPE get_interface_version() = 0;
+ virtual unsigned char *STDMETHODCALLTYPE get_buffer(int) = 0;
+ virtual int STDMETHODCALLTYPE get_length() = 0;
+ virtual void STDMETHODCALLTYPE set_sibling(IHexEditorWindow *) = 0;
+ virtual Colors *STDMETHODCALLTYPE get_colors() = 0;
+ virtual Settings *STDMETHODCALLTYPE get_settings() = 0;
+ virtual Status *STDMETHODCALLTYPE get_status() = 0;
+ virtual void STDMETHODCALLTYPE resize_window() = 0;
+ virtual void STDMETHODCALLTYPE repaint(int from, int to) = 0;
+ virtual void STDMETHODCALLTYPE adjust_hscrollbar() = 0;
+ virtual void STDMETHODCALLTYPE adjust_vscrollbar() = 0;
+ virtual int STDMETHODCALLTYPE translate_accelerator(MSG *) = 0;
+ virtual void STDMETHODCALLTYPE CMD_find() = 0;
+ virtual void STDMETHODCALLTYPE CMD_findprev() = 0;
+ virtual void STDMETHODCALLTYPE CMD_findnext() = 0;
+ virtual void STDMETHODCALLTYPE CMD_replace() = 0;
+ virtual void STDMETHODCALLTYPE CMD_edit_cut() = 0;
+ virtual void STDMETHODCALLTYPE CMD_edit_copy() = 0;
+ virtual void STDMETHODCALLTYPE CMD_edit_paste() = 0;
+ virtual void STDMETHODCALLTYPE CMD_edit_clear() = 0;
+ virtual BOOL STDMETHODCALLTYPE select_next_diff(BOOL bFromStart) = 0;
+ virtual BOOL STDMETHODCALLTYPE select_prev_diff(BOOL bFromEnd) = 0;
+ virtual BOOL STDMETHODCALLTYPE load_lang(LANGID langid, LPCWSTR langdir = NULL) = 0;
+ virtual void STDMETHODCALLTYPE CMD_zoom(int) = 0;
+ virtual void STDMETHODCALLTYPE CMD_select_all() = 0;
+};
+
+#endif // _HEKSEDIT_H_
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|