static char THIS_FILE[] = __FILE__;
#endif
-/**
- * @brief RO status panel width
- */
-static UINT RO_PANEL_WIDTH = 40;
-
/////////////////////////////////////////////////////////////////////////////
// CHexMergeFrame
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
/**
* @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);
}
/**
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_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);
#include "SplitterWndEx.h"
#include "EditorFilepathBar.h"
-#include "../externals/heksedit/heksedit.h"
+
+#define HEKSEDIT_INTERFACE_VERSION 1
+#include "heksedit.h"
class CHexMergeDoc;
private:
void SavePosition();
virtual ~CHexMergeFrame();
- void CreateHexWndStatusBar(CStatusBar &);
+ void CreateHexWndStatusBar(CStatusBar &, CWnd *);
// Generated message map functions
private:
int m_nLastSplitPos;
#include "HexMergeView.h"
#include "OptionsDef.h"
#include "Environment.h"
-#include "../externals/heksedit/version.h"
#ifdef _DEBUG
#define new DEBUG_NEW
*/
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;
}
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;
}
public:
HRESULT LoadFile(LPCTSTR);
HRESULT SaveFile(LPCTSTR);
+ IHexEditorWindow *GetInterface() const { return m_pif; }
IHexEditorWindow::Status *GetStatus();
BYTE *GetBuffer(int);
int GetLength();
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////\r
+// License (GPLv2+):\r
+// This program is free software; you can redistribute it and/or modify\r
+// it under the terms of the GNU General Public License as published by\r
+// the Free Software Foundation; either version 2 of the License, or\r
+// (at your option) any later version.\r
+//\r
+// This program is distributed in the hope that it will be useful, but\r
+// WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software\r
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+/////////////////////////////////////////////////////////////////////////////\r
+/** \r
+ * @file heksedit.h\r
+ *\r
+ * @brief Interface definition for the hekseditor window.\r
+ *\r
+ */\r
+// ID line follows -- this is updated by SVN\r
+// $Id: heksedit.h 492 2009-04-11 15:17:02Z jtuc $\r
+\r
+#ifndef _HEKSEDIT_H_\r
+#define _HEKSEDIT_H_\r
+\r
+#ifndef HEKSEDIT_INTERFACE_VERSION\r
+#define HEKSEDIT_INTERFACE_VERSION 1\r
+#endif\r
+\r
+/**\r
+ * @brief Interface for the Hexeditor window.\r
+ * @note This file is published to hosting applications. Do not add global declarations.\r
+ */\r
+class IHexEditorWindow\r
+{\r
+public:\r
+ /**\r
+ * @brief Byte endians.\r
+ */\r
+ enum BYTE_ENDIAN\r
+ {\r
+ ENDIAN_LITTLE, /**< Little endian used e.g. in Intel processors. */\r
+ ENDIAN_BIG /**< Big endian used e.g. in Motorola processors. */\r
+ };\r
+\r
+ struct Colors\r
+ {\r
+ COLORREF iTextColorValue, iBkColorValue, iSepColorValue;\r
+ COLORREF iSelBkColorValue, iSelTextColorValue;\r
+ COLORREF iBmkColor;\r
+ COLORREF iDiffBkColorValue, iDiffTextColorValue, iSelDiffBkColorValue, iSelDiffTextColorValue;\r
+ };\r
+\r
+ struct Settings\r
+ {\r
+ int iBytesPerLine;\r
+ int iAutomaticBPL;\r
+ BYTE_ENDIAN iBinaryMode;\r
+ int bReadOnly;\r
+ int bSaveIni;\r
+ int iFontSize;\r
+ int iCharacterSet;\r
+ int iMinOffsetLen;\r
+ int iMaxOffsetLen;\r
+ int bAutoOffsetLen;\r
+ int bCenterCaret;\r
+ int iFontZoom;\r
+ };\r
+\r
+ struct Status\r
+ {\r
+ int iFileChanged;\r
+ int iEnteringMode;\r
+ int iCurByte;\r
+ int iCurNibble;\r
+ int iVscrollMax;\r
+ int iVscrollPos;\r
+ int iHscrollMax;\r
+ int iHscrollPos;\r
+ int bSelected;\r
+ int iStartOfSelection;\r
+ int iEndOfSelection;\r
+ };\r
+\r
+ virtual unsigned STDMETHODCALLTYPE get_interface_version() = 0;\r
+ virtual unsigned char *STDMETHODCALLTYPE get_buffer(int) = 0;\r
+ virtual int STDMETHODCALLTYPE get_length() = 0;\r
+ virtual void STDMETHODCALLTYPE set_sibling(IHexEditorWindow *) = 0;\r
+ virtual Colors *STDMETHODCALLTYPE get_colors() = 0;\r
+ virtual Settings *STDMETHODCALLTYPE get_settings() = 0;\r
+ virtual Status *STDMETHODCALLTYPE get_status() = 0;\r
+ virtual void STDMETHODCALLTYPE resize_window() = 0;\r
+ virtual void STDMETHODCALLTYPE repaint(int from, int to) = 0;\r
+ virtual void STDMETHODCALLTYPE adjust_hscrollbar() = 0;\r
+ virtual void STDMETHODCALLTYPE adjust_vscrollbar() = 0;\r
+ virtual int STDMETHODCALLTYPE translate_accelerator(MSG *) = 0;\r
+ virtual void STDMETHODCALLTYPE CMD_find() = 0;\r
+ virtual void STDMETHODCALLTYPE CMD_findprev() = 0;\r
+ virtual void STDMETHODCALLTYPE CMD_findnext() = 0;\r
+ virtual void STDMETHODCALLTYPE CMD_replace() = 0;\r
+ virtual void STDMETHODCALLTYPE CMD_edit_cut() = 0;\r
+ virtual void STDMETHODCALLTYPE CMD_edit_copy() = 0;\r
+ virtual void STDMETHODCALLTYPE CMD_edit_paste() = 0;\r
+ virtual void STDMETHODCALLTYPE CMD_edit_clear() = 0;\r
+ virtual BOOL STDMETHODCALLTYPE select_next_diff(BOOL bFromStart) = 0;\r
+ virtual BOOL STDMETHODCALLTYPE select_prev_diff(BOOL bFromEnd) = 0;\r
+ virtual BOOL STDMETHODCALLTYPE load_lang(LANGID langid, LPCWSTR langdir = NULL) = 0;\r
+ virtual void STDMETHODCALLTYPE CMD_zoom(int) = 0;\r
+ virtual void STDMETHODCALLTYPE CMD_select_all() = 0;\r
+};\r
+\r
+#endif // _HEKSEDIT_H_\r