diff options
Diffstat (limited to 'fpdfsdk/pdfwindow')
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_ScrollBar.cpp | 20 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_ScrollBar.h | 28 |
2 files changed, 36 insertions, 12 deletions
diff --git a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp index 1789d15764..17f62f58d6 100644 --- a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp +++ b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp @@ -818,15 +818,14 @@ void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd, } break; case PNM_SETSCROLLINFO: { - if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) { - if (FXSYS_memcmp(&m_OriginInfo, pInfo, sizeof(PWL_SCROLL_INFO)) != 0) { - m_OriginInfo = *pInfo; - FX_FLOAT fMax = - pInfo->fContentMax - pInfo->fContentMin - pInfo->fPlateWidth; - fMax = fMax > 0.0f ? fMax : 0.0f; - SetScrollRange(0, fMax, pInfo->fPlateWidth); - SetScrollStep(pInfo->fBigStep, pInfo->fSmallStep); - } + PWL_SCROLL_INFO* pInfo = reinterpret_cast<PWL_SCROLL_INFO*>(lParam); + if (pInfo && *pInfo != m_OriginInfo) { + m_OriginInfo = *pInfo; + FX_FLOAT fMax = + pInfo->fContentMax - pInfo->fContentMin - pInfo->fPlateWidth; + fMax = fMax > 0.0f ? fMax : 0.0f; + SetScrollRange(0, fMax, pInfo->fPlateWidth); + SetScrollStep(pInfo->fBigStep, pInfo->fSmallStep); } } break; case PNM_SETSCROLLPOS: { @@ -1183,13 +1182,12 @@ void CPWL_ScrollBar::CreateChildWnd(const PWL_CREATEPARAM& cp) { void CPWL_ScrollBar::TimerProc() { PWL_SCROLL_PRIVATEDATA sTemp = m_sData; - if (m_bMinOrMax) m_sData.SubSmall(); else m_sData.AddSmall(); - if (FXSYS_memcmp(&m_sData, &sTemp, sizeof(PWL_SCROLL_PRIVATEDATA)) != 0) { + if (sTemp != m_sData) { MovePosButton(TRUE); NotifyScrollWindow(); } diff --git a/fpdfsdk/pdfwindow/PWL_ScrollBar.h b/fpdfsdk/pdfwindow/PWL_ScrollBar.h index c03b20dbbc..ae71472696 100644 --- a/fpdfsdk/pdfwindow/PWL_ScrollBar.h +++ b/fpdfsdk/pdfwindow/PWL_ScrollBar.h @@ -20,6 +20,16 @@ struct PWL_SCROLL_INFO { fPlateWidth(0.0f), fBigStep(0.0f), fSmallStep(0.0f) {} + + bool operator==(const PWL_SCROLL_INFO& that) const { + return fContentMin == that.fContentMin && fContentMax == that.fContentMax && + fPlateWidth == that.fPlateWidth && fBigStep == that.fBigStep && + fSmallStep == that.fSmallStep; + } + bool operator!=(const PWL_SCROLL_INFO& that) const { + return !(*this == that); + } + FX_FLOAT fContentMin; FX_FLOAT fContentMax; FX_FLOAT fPlateWidth; @@ -58,18 +68,34 @@ struct PWL_FLOATRANGE { public: PWL_FLOATRANGE(); PWL_FLOATRANGE(FX_FLOAT min, FX_FLOAT max); + + bool operator==(const PWL_FLOATRANGE& that) const { + return fMin == that.fMin && fMax == that.fMax; + } + bool operator!=(const PWL_FLOATRANGE& that) const { return !(*this == that); } + void Default(); void Set(FX_FLOAT min, FX_FLOAT max); FX_BOOL In(FX_FLOAT x) const; FX_FLOAT GetWidth() const; - FX_FLOAT fMin, fMax; + FX_FLOAT fMin; + FX_FLOAT fMax; }; struct PWL_SCROLL_PRIVATEDATA { public: PWL_SCROLL_PRIVATEDATA(); + bool operator==(const PWL_SCROLL_PRIVATEDATA& that) const { + return ScrollRange == that.ScrollRange && + fClientWidth == that.fClientWidth && fScrollPos == that.fScrollPos && + fBigStep == that.fBigStep && fSmallStep == that.fSmallStep; + } + bool operator!=(const PWL_SCROLL_PRIVATEDATA& that) const { + return !(*this == that); + } + void Default(); void SetScrollRange(FX_FLOAT min, FX_FLOAT max); void SetClientWidth(FX_FLOAT width); |