memset(m_data, 0, m_width * m_height * sizeof(T));\r
}\r
\r
- Array2D(const Array2D<T>& other) : m_width(other.m_width), m_height(other.m_height), m_data(new T[other.m_width * other.m_height])\r
+ Array2D(const Array2D& other) : m_width(other.m_width), m_height(other.m_height), m_data(new T[other.m_width * other.m_height])\r
{\r
memcpy(m_data, other.m_data, m_width * m_height * sizeof(T));\r
}\r
\r
Array2D& operator=(const Array2D& other)\r
{\r
- delete m_data;\r
- m_width = other.m_width;\r
- m_height = other.m_height;\r
- m_data = new T[other.m_width * other.m_height];\r
- memcpy(m_data, other.m_data, m_width * m_height * sizeof(T));\r
+ if (this != &other)\r
+ {\r
+ delete[] m_data;\r
+ m_width = other.m_width;\r
+ m_height = other.m_height;\r
+ m_data = new T[other.m_width * other.m_height];\r
+ memcpy(m_data, other.m_data, m_width * m_height * sizeof(T));\r
+ }\r
return *this;\r
}\r
\r
~Array2D()\r
{\r
- delete m_data;\r
+ delete[] m_data;\r
}\r
\r
void resize(size_t width, size_t height)\r
{\r
- delete m_data;\r
+ delete[] m_data;\r
m_data = new T[width * height];\r
m_width = width;\r
m_height = height;\r
\r
void clear()\r
{\r
- delete m_data;\r
+ delete[] m_data;\r
m_data = NULL;\r
m_width = 0;\r
m_height = 0;\r
, m_diffColorAlpha(0.7)\r
, m_diffCount(0)\r
, m_currentDiffIndex(-1)\r
+ , m_oldSplitPosX(-4)\r
+ , m_oldSplitPosY(-4)\r
{\r
memset(m_ChildWndProc, 0, sizeof(m_ChildWndProc));\r
+ memset(m_currentPage, 0, sizeof(m_currentPage));\r
}\r
\r
~CImgMergeWindow()\r
\r
void SetBackColor(RGBQUAD backColor)\r
{\r
- for (int i = 0; i < m_nImages; ++i)\r
+ for (int i = 0; i < 3; ++i)\r
m_imgWindow[i].SetBackColor(backColor);\r
}\r
\r
\r
void SetUseBackColor(bool useBackColor)\r
{\r
- for (int i = 0; i < m_nImages; ++i)\r
+ for (int i = 0; i < 3; ++i)\r
m_imgWindow[i].SetUseBackColor(useBackColor);\r
}\r
\r
\r
void SetZoom(double zoom)\r
{\r
- for (int i = 0; i < m_nImages; ++i)\r
+ for (int i = 0; i < 3; ++i)\r
m_imgWindow[i].SetZoom(zoom);\r
}\r
\r
\r
bool LastConflict()\r
{\r
- for (int i = m_diffInfos.size() - 1; i >= 0; --i)\r
+ for (int i = static_cast<int>(m_diffInfos.size() - 1); i >= 0; --i)\r
{\r
if (m_diffInfos[i].op == DiffInfo::OP_DIFF)\r
{\r
\r
bool NextConflict()\r
{\r
- for (int i = m_currentDiffIndex + 1; i < m_diffInfos.size(); ++i)\r
+ for (size_t i = m_currentDiffIndex + 1; i < m_diffInfos.size(); ++i)\r
{\r
if (m_diffInfos[i].op == DiffInfo::OP_DIFF)\r
{\r
- m_currentDiffIndex = i;\r
+ m_currentDiffIndex = static_cast<int>(i);\r
break;\r
}\r
}\r
\r
int GetNextConflictIndex() const\r
{\r
- for (int i = m_currentDiffIndex + 1; i < m_diffInfos.size(); ++i)\r
+ for (size_t i = m_currentDiffIndex + 1; i < m_diffInfos.size(); ++i)\r
if (m_diffInfos[i].op == DiffInfo::OP_DIFF)\r
- return i;\r
+ return static_cast<int>(i);\r
return -1;\r
}\r
\r
int GetPrevConflictIndex() const\r
{\r
- for (int i = m_currentDiffIndex - 1; i >= 0; --i)\r
+ for (int i = static_cast<int>(m_currentDiffIndex - 1); i >= 0; --i)\r
if (m_diffInfos[i].op == DiffInfo::OP_DIFF)\r
return i;\r
return -1;\r
if (m_nImages <= 1)\r
return;\r
InitializeDiff();\r
- if (m_showDifferences)\r
+ if (m_nImages == 2)\r
{\r
- if (m_nImages == 2)\r
- {\r
- CompareImages2(0, 1, m_diff);\r
- m_diffCount = MarkDiffIndex(m_diff);\r
- }\r
- else if (m_nImages == 3)\r
- {\r
- CompareImages2(0, 1, m_diff01);\r
- CompareImages2(2, 1, m_diff21);\r
- CompareImages2(0, 2, m_diff02);\r
- Make3WayDiff(m_diff01, m_diff21, m_diff);\r
- m_diffCount = MarkDiffIndex3way(m_diff01, m_diff21, m_diff02, m_diff);\r
- }\r
- if (m_currentDiffIndex >= m_diffCount)\r
- m_currentDiffIndex = m_diffCount - 1;\r
+ CompareImages2(0, 1, m_diff);\r
+ m_diffCount = MarkDiffIndex(m_diff);\r
+ }\r
+ else if (m_nImages == 3)\r
+ {\r
+ CompareImages2(0, 1, m_diff01);\r
+ CompareImages2(2, 1, m_diff21);\r
+ CompareImages2(0, 2, m_diff02);\r
+ Make3WayDiff(m_diff01, m_diff21, m_diff);\r
+ m_diffCount = MarkDiffIndex3way(m_diff01, m_diff21, m_diff02, m_diff);\r
}\r
+ if (m_currentDiffIndex >= m_diffCount)\r
+ m_currentDiffIndex = m_diffCount - 1;\r
RefreshImages();\r
}\r
\r
void ScrollToDiff(int diffIndex)\r
{\r
- if (diffIndex >= 0 && diffIndex < m_diffInfos.size())\r
+ if (diffIndex >= 0 && diffIndex < static_cast<int>(m_diffInfos.size()))\r
{\r
for (int i = 0; i < m_nImages; ++i)\r
m_imgWindow[i].ScrollTo(m_diffInfos[diffIndex].pt.x * m_diffBlockSize, m_diffInfos[diffIndex].pt.y * m_diffBlockSize);\r
if (data(x, y) != -1)\r
continue;\r
data(x, y) = val;\r
- if (x + 1 < data.width())\r
+ if (x + 1 < static_cast<int>(data.width()))\r
{\r
stack.push_back(Point<int>(x + 1, y));\r
- if (y + 1 < data.height())\r
+ if (y + 1 < static_cast<int>(data.height()))\r
stack.push_back(Point<int>(x + 1, y + 1));\r
if (y - 1 >= 0)\r
stack.push_back(Point<int>(x + 1, y - 1));\r
if (x - 1 >= 0)\r
{\r
stack.push_back(Point<int>(x - 1, y));\r
- if (y + 1 < data.height())\r
+ if (y + 1 < static_cast<int>(data.height()))\r
stack.push_back(Point<int>(x - 1, y + 1));\r
if (y - 1 >= 0)\r
stack.push_back(Point<int>(x - 1, y - 1));\r
}\r
- if (y + 1 < data.height())\r
+ if (y + 1 < static_cast<int>(data.height()))\r
stack.push_back(Point<int>(x, y + 1));\r
if (y - 1 >= 0)\r
stack.push_back(Point<int>(x, y - 1));\r
}\r
}\r
\r
- for (int i = 0; i < m_diffInfos.size(); ++i)\r
+ for (size_t i = 0; i < m_diffInfos.size(); ++i)\r
{\r
int op;\r
if (counter[i][0] != 0 && counter[i][1] == 0 && counter[i][2] == 0 && counter[i][3] == 0)\r
{\r
if (iMsg == WM_NCCREATE)\r
SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams));\r
- CImgMergeWindow *pImgWnd = (CImgMergeWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA);\r
+ CImgMergeWindow *pImgWnd = reinterpret_cast<CImgMergeWindow *>(GetWindowLongPtr(hwnd, GWLP_USERDATA));\r
LRESULT lResult = pImgWnd->OnWndMsg(hwnd, iMsg, wParam, lParam);\r
return lResult;\r
}\r
{\r
Event evt;\r
int i;\r
- CImgMergeWindow *pImgWnd = (CImgMergeWindow *)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);\r
+ CImgMergeWindow *pImgWnd = reinterpret_cast<CImgMergeWindow *>(GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA));\r
for (i = 0; i < pImgWnd->m_nImages; ++i)\r
if (pImgWnd->m_imgWindow[i].GetHWND() == hwnd)\r
break;\r
{\r
m_backColor = backColor;\r
if (m_fip)\r
+ {\r
m_fip->setModified(true);\r
- InvalidateRect(m_hWnd, NULL, TRUE);\r
+ InvalidateRect(m_hWnd, NULL, TRUE);\r
+ }\r
}\r
\r
bool GetUseBackColor() const\r
{\r
m_useBackColor = useBackColor;\r
if (m_fip)\r
+ {\r
m_fip->setModified(true);\r
- InvalidateRect(m_hWnd, NULL, TRUE);\r
+ InvalidateRect(m_hWnd, NULL, TRUE);\r
+ }\r
}\r
\r
double GetZoom() const\r
\r
void SetZoom(double zoom)\r
{\r
+ double oldZoom = m_zoom;\r
m_zoom = zoom;\r
- m_nVScrollPos = 0;\r
- m_nHScrollPos = 0;\r
- CalcScrollBarRange();\r
- InvalidateRect(m_hWnd, NULL, TRUE);\r
+ if (m_zoom < 0.1)\r
+ m_zoom = 0.1;\r
+ m_nVScrollPos = static_cast<int>(m_nVScrollPos / oldZoom * m_zoom);\r
+ m_nHScrollPos = static_cast<int>(m_nHScrollPos / oldZoom * m_zoom);\r
+ if (m_fip)\r
+ {\r
+ CalcScrollBarRange();\r
+ InvalidateRect(m_hWnd, NULL, TRUE);\r
+ }\r
}\r
\r
void Invalidate()\r
else\r
{\r
if (zDelta > 0)\r
- SetZoom(m_zoom * 1.2);\r
+ SetZoom(m_zoom + 0.1);\r
else\r
- SetZoom(m_zoom * 0.8);\r
+ SetZoom(m_zoom - 0.1);\r
}\r
}\r
\r
{\r
if (iMsg == WM_NCCREATE)\r
SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams));\r
- CImgWindow *pImgWnd = (CImgWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA);\r
+ CImgWindow *pImgWnd = reinterpret_cast<CImgWindow *>(GetWindowLongPtr(hwnd, GWLP_USERDATA));\r
LRESULT lResult = pImgWnd->OnWndMsg(hwnd, iMsg, wParam, lParam);\r
return lResult;\r
}\r
double m_zoom;\r
bool m_useBackColor;\r
RGBQUAD m_backColor;\r
-};
\ No newline at end of file
+};\r