OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fwl/core/ifwl_edit.h" | 7 #include "xfa/fwl/core/ifwl_edit.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 } | 1921 } |
1922 iError = m_pEdtEngine->Insert(nCaret, &c, 1); | 1922 iError = m_pEdtEngine->Insert(nCaret, &c, 1); |
1923 break; | 1923 break; |
1924 } | 1924 } |
1925 } | 1925 } |
1926 if (iError < 0) | 1926 if (iError < 0) |
1927 ProcessInsertError(iError); | 1927 ProcessInsertError(iError); |
1928 } | 1928 } |
1929 | 1929 |
1930 bool IFWL_Edit::OnScroll(IFWL_ScrollBar* pScrollBar, | 1930 bool IFWL_Edit::OnScroll(IFWL_ScrollBar* pScrollBar, |
1931 uint32_t dwCode, | 1931 FWL_SCBCODE dwCode, |
1932 FX_FLOAT fPos) { | 1932 FX_FLOAT fPos) { |
1933 CFX_SizeF fs; | 1933 CFX_SizeF fs; |
1934 pScrollBar->GetRange(&fs.x, &fs.y); | 1934 pScrollBar->GetRange(&fs.x, &fs.y); |
1935 FX_FLOAT iCurPos = pScrollBar->GetPos(); | 1935 FX_FLOAT iCurPos = pScrollBar->GetPos(); |
1936 FX_FLOAT fStep = pScrollBar->GetStepSize(); | 1936 FX_FLOAT fStep = pScrollBar->GetStepSize(); |
1937 switch (dwCode) { | 1937 switch (dwCode) { |
1938 case FWL_SCBCODE_Min: { | 1938 case FWL_SCBCODE::Min: { |
1939 fPos = fs.x; | 1939 fPos = fs.x; |
1940 break; | 1940 break; |
1941 } | 1941 } |
1942 case FWL_SCBCODE_Max: { | 1942 case FWL_SCBCODE::Max: { |
1943 fPos = fs.y; | 1943 fPos = fs.y; |
1944 break; | 1944 break; |
1945 } | 1945 } |
1946 case FWL_SCBCODE_StepBackward: { | 1946 case FWL_SCBCODE::StepBackward: { |
1947 fPos -= fStep; | 1947 fPos -= fStep; |
1948 if (fPos < fs.x + fStep / 2) { | 1948 if (fPos < fs.x + fStep / 2) { |
1949 fPos = fs.x; | 1949 fPos = fs.x; |
1950 } | 1950 } |
1951 break; | 1951 break; |
1952 } | 1952 } |
1953 case FWL_SCBCODE_StepForward: { | 1953 case FWL_SCBCODE::StepForward: { |
1954 fPos += fStep; | 1954 fPos += fStep; |
1955 if (fPos > fs.y - fStep / 2) { | 1955 if (fPos > fs.y - fStep / 2) { |
1956 fPos = fs.y; | 1956 fPos = fs.y; |
1957 } | 1957 } |
1958 break; | 1958 break; |
1959 } | 1959 } |
1960 case FWL_SCBCODE_PageBackward: { | 1960 case FWL_SCBCODE::PageBackward: { |
1961 fPos -= pScrollBar->GetPageSize(); | 1961 fPos -= pScrollBar->GetPageSize(); |
1962 if (fPos < fs.x) { | 1962 if (fPos < fs.x) { |
1963 fPos = fs.x; | 1963 fPos = fs.x; |
1964 } | 1964 } |
1965 break; | 1965 break; |
1966 } | 1966 } |
1967 case FWL_SCBCODE_PageForward: { | 1967 case FWL_SCBCODE::PageForward: { |
1968 fPos += pScrollBar->GetPageSize(); | 1968 fPos += pScrollBar->GetPageSize(); |
1969 if (fPos > fs.y) { | 1969 if (fPos > fs.y) { |
1970 fPos = fs.y; | 1970 fPos = fs.y; |
1971 } | 1971 } |
1972 break; | 1972 break; |
1973 } | 1973 } |
1974 case FWL_SCBCODE_Pos: | 1974 case FWL_SCBCODE::Pos: |
1975 case FWL_SCBCODE_TrackPos: | 1975 case FWL_SCBCODE::TrackPos: |
| 1976 case FWL_SCBCODE::None: |
1976 break; | 1977 break; |
1977 case FWL_SCBCODE_EndScroll: | 1978 case FWL_SCBCODE::EndScroll: |
1978 return false; | 1979 return false; |
1979 default: | |
1980 break; | |
1981 } | 1980 } |
1982 if (iCurPos != fPos) { | 1981 if (iCurPos != fPos) { |
1983 pScrollBar->SetPos(fPos); | 1982 pScrollBar->SetPos(fPos); |
1984 pScrollBar->SetTrackPos(fPos); | 1983 pScrollBar->SetTrackPos(fPos); |
1985 UpdateOffset(pScrollBar, fPos - iCurPos); | 1984 UpdateOffset(pScrollBar, fPos - iCurPos); |
1986 if (m_pEdtEngine) { | 1985 if (m_pEdtEngine) { |
1987 UpdateCaret(); | 1986 UpdateCaret(); |
1988 } | 1987 } |
1989 CFX_RectF rect; | 1988 CFX_RectF rect; |
1990 GetWidgetRect(rect); | 1989 GetWidgetRect(rect); |
1991 CFX_RectF rtInvalidate; | 1990 CFX_RectF rtInvalidate; |
1992 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); | 1991 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); |
1993 Repaint(&rtInvalidate); | 1992 Repaint(&rtInvalidate); |
1994 } | 1993 } |
1995 return true; | 1994 return true; |
1996 } | 1995 } |
OLD | NEW |