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_listbox.h" | 7 #include "xfa/fwl/core/ifwl_listbox.h" |
8 | 8 |
9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fde/tto/fde_textout.h" | 10 #include "xfa/fde/tto/fde_textout.h" |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 SetFocusItem(pItem); | 1082 SetFocusItem(pItem); |
1083 ScrollToVisible(pItem); | 1083 ScrollToVisible(pItem); |
1084 | 1084 |
1085 CFX_RectF rtInvalidate; | 1085 CFX_RectF rtInvalidate; |
1086 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, | 1086 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, |
1087 m_pProperties->m_rtWidget.height); | 1087 m_pProperties->m_rtWidget.height); |
1088 Repaint(&rtInvalidate); | 1088 Repaint(&rtInvalidate); |
1089 } | 1089 } |
1090 | 1090 |
1091 bool IFWL_ListBox::OnScroll(IFWL_ScrollBar* pScrollBar, | 1091 bool IFWL_ListBox::OnScroll(IFWL_ScrollBar* pScrollBar, |
1092 uint32_t dwCode, | 1092 FWL_SCBCODE dwCode, |
1093 FX_FLOAT fPos) { | 1093 FX_FLOAT fPos) { |
1094 CFX_SizeF fs; | 1094 CFX_SizeF fs; |
1095 pScrollBar->GetRange(&fs.x, &fs.y); | 1095 pScrollBar->GetRange(&fs.x, &fs.y); |
1096 FX_FLOAT iCurPos = pScrollBar->GetPos(); | 1096 FX_FLOAT iCurPos = pScrollBar->GetPos(); |
1097 FX_FLOAT fStep = pScrollBar->GetStepSize(); | 1097 FX_FLOAT fStep = pScrollBar->GetStepSize(); |
1098 switch (dwCode) { | 1098 switch (dwCode) { |
1099 case FWL_SCBCODE_Min: { | 1099 case FWL_SCBCODE::Min: { |
1100 fPos = fs.x; | 1100 fPos = fs.x; |
1101 break; | 1101 break; |
1102 } | 1102 } |
1103 case FWL_SCBCODE_Max: { | 1103 case FWL_SCBCODE::Max: { |
1104 fPos = fs.y; | 1104 fPos = fs.y; |
1105 break; | 1105 break; |
1106 } | 1106 } |
1107 case FWL_SCBCODE_StepBackward: { | 1107 case FWL_SCBCODE::StepBackward: { |
1108 fPos -= fStep; | 1108 fPos -= fStep; |
1109 if (fPos < fs.x + fStep / 2) | 1109 if (fPos < fs.x + fStep / 2) |
1110 fPos = fs.x; | 1110 fPos = fs.x; |
1111 break; | 1111 break; |
1112 } | 1112 } |
1113 case FWL_SCBCODE_StepForward: { | 1113 case FWL_SCBCODE::StepForward: { |
1114 fPos += fStep; | 1114 fPos += fStep; |
1115 if (fPos > fs.y - fStep / 2) | 1115 if (fPos > fs.y - fStep / 2) |
1116 fPos = fs.y; | 1116 fPos = fs.y; |
1117 break; | 1117 break; |
1118 } | 1118 } |
1119 case FWL_SCBCODE_PageBackward: { | 1119 case FWL_SCBCODE::PageBackward: { |
1120 fPos -= pScrollBar->GetPageSize(); | 1120 fPos -= pScrollBar->GetPageSize(); |
1121 if (fPos < fs.x) | 1121 if (fPos < fs.x) |
1122 fPos = fs.x; | 1122 fPos = fs.x; |
1123 break; | 1123 break; |
1124 } | 1124 } |
1125 case FWL_SCBCODE_PageForward: { | 1125 case FWL_SCBCODE::PageForward: { |
1126 fPos += pScrollBar->GetPageSize(); | 1126 fPos += pScrollBar->GetPageSize(); |
1127 if (fPos > fs.y) | 1127 if (fPos > fs.y) |
1128 fPos = fs.y; | 1128 fPos = fs.y; |
1129 break; | 1129 break; |
1130 } | 1130 } |
1131 case FWL_SCBCODE_Pos: | 1131 case FWL_SCBCODE::Pos: |
1132 case FWL_SCBCODE_TrackPos: | 1132 case FWL_SCBCODE::TrackPos: |
| 1133 case FWL_SCBCODE::None: |
1133 break; | 1134 break; |
1134 case FWL_SCBCODE_EndScroll: | 1135 case FWL_SCBCODE::EndScroll: |
1135 return false; | 1136 return false; |
1136 } | 1137 } |
1137 if (iCurPos != fPos) { | 1138 if (iCurPos != fPos) { |
1138 pScrollBar->SetPos(fPos); | 1139 pScrollBar->SetPos(fPos); |
1139 pScrollBar->SetTrackPos(fPos); | 1140 pScrollBar->SetTrackPos(fPos); |
1140 Repaint(&m_rtClient); | 1141 Repaint(&m_rtClient); |
1141 } | 1142 } |
1142 return true; | 1143 return true; |
1143 } | 1144 } |
1144 | 1145 |
1145 void IFWL_ListBox::DispatchSelChangedEv() { | 1146 void IFWL_ListBox::DispatchSelChangedEv() { |
1146 CFWL_EvtLtbSelChanged ev; | 1147 CFWL_EvtLtbSelChanged ev; |
1147 ev.m_pSrcTarget = this; | 1148 ev.m_pSrcTarget = this; |
1148 DispatchEvent(&ev); | 1149 DispatchEvent(&ev); |
1149 } | 1150 } |
OLD | NEW |