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/basewidget/fwl_listboximp.h" | 7 #include "xfa/fwl/basewidget/fwl_listboximp.h" |
8 | 8 |
9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
10 #include "xfa/fwl/basewidget/fwl_comboboximp.h" | 10 #include "xfa/fwl/basewidget/fwl_comboboximp.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 IFWL_ListBox::IFWL_ListBox() {} | 45 IFWL_ListBox::IFWL_ListBox() {} |
46 int32_t IFWL_ListBox::CountSelItems() { | 46 int32_t IFWL_ListBox::CountSelItems() { |
47 return static_cast<CFWL_ListBoxImp*>(GetImpl())->CountSelItems(); | 47 return static_cast<CFWL_ListBoxImp*>(GetImpl())->CountSelItems(); |
48 } | 48 } |
49 FWL_HLISTITEM IFWL_ListBox::GetSelItem(int32_t nIndexSel) { | 49 FWL_HLISTITEM IFWL_ListBox::GetSelItem(int32_t nIndexSel) { |
50 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelItem(nIndexSel); | 50 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelItem(nIndexSel); |
51 } | 51 } |
52 int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { | 52 int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { |
53 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelIndex(nIndex); | 53 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelIndex(nIndex); |
54 } | 54 } |
55 FWL_ERR IFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { | 55 FWL_Error IFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { |
56 return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(hItem, bSelect); | 56 return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(hItem, bSelect); |
57 } | 57 } |
58 FWL_ERR IFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText) { | 58 FWL_Error IFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, |
| 59 CFX_WideString& wsText) { |
59 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(hItem, wsText); | 60 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(hItem, wsText); |
60 } | 61 } |
61 FWL_ERR IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { | 62 FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { |
62 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetScrollPos(fPos, bVert); | 63 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetScrollPos(fPos, bVert); |
63 } | 64 } |
64 FWL_ERR* IFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) { | |
65 return static_cast<CFWL_ListBoxImp*>(GetImpl())->Sort(pCom); | |
66 } | |
67 | 65 |
68 CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, | 66 CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, |
69 IFWL_Widget* pOuter) | 67 IFWL_Widget* pOuter) |
70 : CFWL_WidgetImp(properties, pOuter), | 68 : CFWL_WidgetImp(properties, pOuter), |
71 m_dwTTOStyles(0), | 69 m_dwTTOStyles(0), |
72 m_iTTOAligns(0), | 70 m_iTTOAligns(0), |
73 m_hAnchor(NULL), | 71 m_hAnchor(NULL), |
74 m_fScorllBarWidth(0), | 72 m_fScorllBarWidth(0), |
75 m_bLButtonDown(FALSE), | 73 m_bLButtonDown(FALSE), |
76 m_pScrollBarTP(NULL) { | 74 m_pScrollBarTP(NULL) { |
77 m_rtClient.Reset(); | 75 m_rtClient.Reset(); |
78 m_rtConent.Reset(); | 76 m_rtConent.Reset(); |
79 m_rtStatic.Reset(); | 77 m_rtStatic.Reset(); |
80 } | 78 } |
81 CFWL_ListBoxImp::~CFWL_ListBoxImp() {} | 79 CFWL_ListBoxImp::~CFWL_ListBoxImp() {} |
82 FWL_ERR CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const { | 80 FWL_Error CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const { |
83 wsClass = FWL_CLASS_ListBox; | 81 wsClass = FWL_CLASS_ListBox; |
84 return FWL_ERR_Succeeded; | 82 return FWL_Error::Succeeded; |
85 } | 83 } |
86 uint32_t CFWL_ListBoxImp::GetClassID() const { | 84 uint32_t CFWL_ListBoxImp::GetClassID() const { |
87 return FWL_CLASSHASH_ListBox; | 85 return FWL_CLASSHASH_ListBox; |
88 } | 86 } |
89 FWL_ERR CFWL_ListBoxImp::Initialize() { | 87 FWL_Error CFWL_ListBoxImp::Initialize() { |
90 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 88 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) |
91 return FWL_ERR_Indefinite; | 89 return FWL_Error::Indefinite; |
92 m_pDelegate = new CFWL_ListBoxImpDelegate(this); | 90 m_pDelegate = new CFWL_ListBoxImpDelegate(this); |
93 return FWL_ERR_Succeeded; | 91 return FWL_Error::Succeeded; |
94 } | 92 } |
95 FWL_ERR CFWL_ListBoxImp::Finalize() { | 93 FWL_Error CFWL_ListBoxImp::Finalize() { |
96 if (m_pVertScrollBar) { | 94 if (m_pVertScrollBar) { |
97 m_pVertScrollBar->Finalize(); | 95 m_pVertScrollBar->Finalize(); |
98 } | 96 } |
99 if (m_pHorzScrollBar) { | 97 if (m_pHorzScrollBar) { |
100 m_pHorzScrollBar->Finalize(); | 98 m_pHorzScrollBar->Finalize(); |
101 } | 99 } |
102 delete m_pDelegate; | 100 delete m_pDelegate; |
103 m_pDelegate = nullptr; | 101 m_pDelegate = nullptr; |
104 return CFWL_WidgetImp::Finalize(); | 102 return CFWL_WidgetImp::Finalize(); |
105 } | 103 } |
106 FWL_ERR CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 104 FWL_Error CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
107 if (bAutoSize) { | 105 if (bAutoSize) { |
108 rect.Set(0, 0, 0, 0); | 106 rect.Set(0, 0, 0, 0); |
109 if (!m_pProperties->m_pThemeProvider) { | 107 if (!m_pProperties->m_pThemeProvider) { |
110 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 108 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
111 } | 109 } |
112 CFX_SizeF fs = CalcSize(TRUE); | 110 CFX_SizeF fs = CalcSize(TRUE); |
113 rect.Set(0, 0, fs.x, fs.y); | 111 rect.Set(0, 0, fs.x, fs.y); |
114 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); | 112 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); |
115 } else { | 113 } else { |
116 rect = m_pProperties->m_rtWidget; | 114 rect = m_pProperties->m_rtWidget; |
117 } | 115 } |
118 return FWL_ERR_Succeeded; | 116 return FWL_Error::Succeeded; |
119 } | 117 } |
120 FWL_ERR CFWL_ListBoxImp::Update() { | 118 FWL_Error CFWL_ListBoxImp::Update() { |
121 if (IsLocked()) { | 119 if (IsLocked()) { |
122 return FWL_ERR_Indefinite; | 120 return FWL_Error::Indefinite; |
123 } | 121 } |
124 if (!m_pProperties->m_pThemeProvider) { | 122 if (!m_pProperties->m_pThemeProvider) { |
125 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 123 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
126 } | 124 } |
127 m_iTTOAligns = FDE_TTOALIGNMENT_Center; | 125 m_iTTOAligns = FDE_TTOALIGNMENT_Center; |
128 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { | 126 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { |
129 case FWL_STYLEEXT_LTB_LeftAlign: { | 127 case FWL_STYLEEXT_LTB_LeftAlign: { |
130 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; | 128 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; |
131 break; | 129 break; |
132 } | 130 } |
133 case FWL_STYLEEXT_LTB_RightAlign: { | 131 case FWL_STYLEEXT_LTB_RightAlign: { |
134 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; | 132 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; |
135 break; | 133 break; |
136 } | 134 } |
137 case FWL_STYLEEXT_LTB_CenterAlign: | 135 case FWL_STYLEEXT_LTB_CenterAlign: |
138 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } | 136 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } |
139 } | 137 } |
140 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { | 138 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { |
141 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; | 139 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; |
142 } | 140 } |
143 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; | 141 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; |
144 m_fScorllBarWidth = GetScrollWidth(); | 142 m_fScorllBarWidth = GetScrollWidth(); |
145 SortItem(); | |
146 CalcSize(); | 143 CalcSize(); |
147 return FWL_ERR_Succeeded; | 144 return FWL_Error::Succeeded; |
148 } | 145 } |
149 FWL_WidgetHit CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 146 FWL_WidgetHit CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
150 if (IsShowScrollBar(FALSE)) { | 147 if (IsShowScrollBar(FALSE)) { |
151 CFX_RectF rect; | 148 CFX_RectF rect; |
152 m_pHorzScrollBar->GetWidgetRect(rect); | 149 m_pHorzScrollBar->GetWidgetRect(rect); |
153 if (rect.Contains(fx, fy)) | 150 if (rect.Contains(fx, fy)) |
154 return FWL_WidgetHit::HScrollBar; | 151 return FWL_WidgetHit::HScrollBar; |
155 } | 152 } |
156 if (IsShowScrollBar(TRUE)) { | 153 if (IsShowScrollBar(TRUE)) { |
157 CFX_RectF rect; | 154 CFX_RectF rect; |
158 m_pVertScrollBar->GetWidgetRect(rect); | 155 m_pVertScrollBar->GetWidgetRect(rect); |
159 if (rect.Contains(fx, fy)) | 156 if (rect.Contains(fx, fy)) |
160 return FWL_WidgetHit::VScrollBar; | 157 return FWL_WidgetHit::VScrollBar; |
161 } | 158 } |
162 if (m_rtClient.Contains(fx, fy)) | 159 if (m_rtClient.Contains(fx, fy)) |
163 return FWL_WidgetHit::Client; | 160 return FWL_WidgetHit::Client; |
164 return FWL_WidgetHit::Unknown; | 161 return FWL_WidgetHit::Unknown; |
165 } | 162 } |
166 FWL_ERR CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics, | 163 FWL_Error CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics, |
167 const CFX_Matrix* pMatrix) { | 164 const CFX_Matrix* pMatrix) { |
168 if (!pGraphics) | 165 if (!pGraphics) |
169 return FWL_ERR_Indefinite; | 166 return FWL_Error::Indefinite; |
170 if (!m_pProperties->m_pThemeProvider) | 167 if (!m_pProperties->m_pThemeProvider) |
171 return FWL_ERR_Indefinite; | 168 return FWL_Error::Indefinite; |
172 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 169 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
173 pGraphics->SaveGraphState(); | 170 pGraphics->SaveGraphState(); |
174 if (HasBorder()) { | 171 if (HasBorder()) { |
175 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 172 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
176 } | 173 } |
177 if (HasEdge()) { | 174 if (HasEdge()) { |
178 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 175 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
179 } | 176 } |
180 CFX_RectF rtClip(m_rtConent); | 177 CFX_RectF rtClip(m_rtConent); |
181 if (IsShowScrollBar(FALSE)) { | 178 if (IsShowScrollBar(FALSE)) { |
182 rtClip.height -= m_fScorllBarWidth; | 179 rtClip.height -= m_fScorllBarWidth; |
183 } | 180 } |
184 if (IsShowScrollBar(TRUE)) { | 181 if (IsShowScrollBar(TRUE)) { |
185 rtClip.width -= m_fScorllBarWidth; | 182 rtClip.width -= m_fScorllBarWidth; |
186 } | 183 } |
187 if (pMatrix) { | 184 if (pMatrix) { |
188 pMatrix->TransformRect(rtClip); | 185 pMatrix->TransformRect(rtClip); |
189 } | 186 } |
190 pGraphics->SetClipRect(rtClip); | 187 pGraphics->SetClipRect(rtClip); |
191 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { | 188 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { |
192 DrawBkground(pGraphics, pTheme, pMatrix); | 189 DrawBkground(pGraphics, pTheme, pMatrix); |
193 } | 190 } |
194 DrawItems(pGraphics, pTheme, pMatrix); | 191 DrawItems(pGraphics, pTheme, pMatrix); |
195 pGraphics->RestoreGraphState(); | 192 pGraphics->RestoreGraphState(); |
196 return FWL_ERR_Succeeded; | 193 return FWL_Error::Succeeded; |
197 } | 194 } |
198 FWL_ERR CFWL_ListBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | 195 FWL_Error CFWL_ListBoxImp::SetThemeProvider( |
| 196 IFWL_ThemeProvider* pThemeProvider) { |
199 if (!pThemeProvider) | 197 if (!pThemeProvider) |
200 return FWL_ERR_Indefinite; | 198 return FWL_Error::Indefinite; |
201 if (!pThemeProvider->IsValidWidget(m_pInterface)) { | 199 if (!pThemeProvider->IsValidWidget(m_pInterface)) { |
202 m_pScrollBarTP = pThemeProvider; | 200 m_pScrollBarTP = pThemeProvider; |
203 return FWL_ERR_Succeeded; | 201 return FWL_Error::Succeeded; |
204 } | 202 } |
205 m_pProperties->m_pThemeProvider = pThemeProvider; | 203 m_pProperties->m_pThemeProvider = pThemeProvider; |
206 return FWL_ERR_Succeeded; | 204 return FWL_Error::Succeeded; |
207 } | 205 } |
208 int32_t CFWL_ListBoxImp::CountSelItems() { | 206 int32_t CFWL_ListBoxImp::CountSelItems() { |
209 if (!m_pProperties->m_pDataProvider) | 207 if (!m_pProperties->m_pDataProvider) |
210 return 0; | 208 return 0; |
211 int32_t iRet = 0; | 209 int32_t iRet = 0; |
212 IFWL_ListBoxDP* pData = | 210 IFWL_ListBoxDP* pData = |
213 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 211 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
214 int32_t iCount = pData->CountItems(m_pInterface); | 212 int32_t iCount = pData->CountItems(m_pInterface); |
215 for (int32_t i = 0; i < iCount; i++) { | 213 for (int32_t i = 0; i < iCount; i++) { |
216 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); | 214 FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { | 261 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { |
264 if (index == nIndex) { | 262 if (index == nIndex) { |
265 return i; | 263 return i; |
266 } else { | 264 } else { |
267 index++; | 265 index++; |
268 } | 266 } |
269 } | 267 } |
270 } | 268 } |
271 return -1; | 269 return -1; |
272 } | 270 } |
273 FWL_ERR CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { | 271 FWL_Error CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { |
274 if (!m_pProperties->m_pDataProvider) | 272 if (!m_pProperties->m_pDataProvider) |
275 return FWL_ERR_Indefinite; | 273 return FWL_Error::Indefinite; |
276 if (!hItem) { | 274 if (!hItem) { |
277 if (bSelect) { | 275 if (bSelect) { |
278 SelectAll(); | 276 SelectAll(); |
279 } else { | 277 } else { |
280 ClearSelection(); | 278 ClearSelection(); |
281 SetFocusItem(NULL); | 279 SetFocusItem(NULL); |
282 } | 280 } |
283 return FWL_ERR_Indefinite; | 281 return FWL_Error::Indefinite; |
284 } | 282 } |
285 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { | 283 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { |
286 SetSelectionDirect(hItem, bSelect); | 284 SetSelectionDirect(hItem, bSelect); |
287 } else { | 285 } else { |
288 SetSelection(hItem, hItem, bSelect); | 286 SetSelection(hItem, hItem, bSelect); |
289 } | 287 } |
290 return FWL_ERR_Succeeded; | 288 return FWL_Error::Succeeded; |
291 } | 289 } |
292 FWL_ERR CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, | 290 FWL_Error CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, |
293 CFX_WideString& wsText) { | 291 CFX_WideString& wsText) { |
294 if (!m_pProperties->m_pDataProvider) | 292 if (!m_pProperties->m_pDataProvider) |
295 return FWL_ERR_Indefinite; | 293 return FWL_Error::Indefinite; |
296 IFWL_ListBoxDP* pData = | 294 IFWL_ListBoxDP* pData = |
297 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | 295 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); |
298 if (!hItem) | 296 if (!hItem) |
299 return FWL_ERR_Indefinite; | 297 return FWL_Error::Indefinite; |
300 pData->GetItemText(m_pInterface, hItem, wsText); | 298 pData->GetItemText(m_pInterface, hItem, wsText); |
301 return FWL_ERR_Succeeded; | 299 return FWL_Error::Succeeded; |
302 } | 300 } |
303 FWL_ERR CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { | 301 |
| 302 FWL_Error CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { |
304 if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) { | 303 if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) { |
305 IFWL_ScrollBar* pScrollBar = | 304 IFWL_ScrollBar* pScrollBar = |
306 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 305 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
307 fPos = pScrollBar->GetPos(); | 306 fPos = pScrollBar->GetPos(); |
308 return FWL_ERR_Succeeded; | 307 return FWL_Error::Succeeded; |
309 } | 308 } |
310 return FWL_ERR_Indefinite; | 309 return FWL_Error::Indefinite; |
311 } | 310 } |
312 FWL_ERR* CFWL_ListBoxImp::Sort(IFWL_ListBoxCompare* pCom) { | 311 |
313 FWL_HLISTITEM hTemp; | |
314 IFWL_ListBoxDP* pData = | |
315 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); | |
316 int32_t sz = pData->CountItems(m_pInterface); | |
317 for (int32_t i = 0; i < sz - 1; i++) { | |
318 for (int32_t j = i + 1; j < sz; j++) { | |
319 if (pCom->Compare(pData->GetItem(m_pInterface, i), | |
320 pData->GetItem(m_pInterface, j)) > 0) { | |
321 hTemp = pData->GetItem(m_pInterface, i); | |
322 pData->SetItemIndex(m_pInterface, pData->GetItem(m_pInterface, j), i); | |
323 pData->SetItemIndex(m_pInterface, hTemp, j); | |
324 } | |
325 } | |
326 } | |
327 return FWL_ERR_Succeeded; | |
328 } | |
329 FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, | 312 FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, |
330 uint32_t dwKeyCode) { | 313 uint32_t dwKeyCode) { |
331 FWL_HLISTITEM hRet = NULL; | 314 FWL_HLISTITEM hRet = NULL; |
332 switch (dwKeyCode) { | 315 switch (dwKeyCode) { |
333 case FWL_VKEY_Up: | 316 case FWL_VKEY_Up: |
334 case FWL_VKEY_Down: | 317 case FWL_VKEY_Down: |
335 case FWL_VKEY_Home: | 318 case FWL_VKEY_Home: |
336 case FWL_VKEY_End: { | 319 case FWL_VKEY_End: { |
337 const bool bUp = dwKeyCode == FWL_VKEY_Up; | 320 const bool bUp = dwKeyCode == FWL_VKEY_Up; |
338 const bool bDown = dwKeyCode == FWL_VKEY_Down; | 321 const bool bDown = dwKeyCode == FWL_VKEY_Down; |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 } | 930 } |
948 CFWL_WidgetImpProperties prop; | 931 CFWL_WidgetImpProperties prop; |
949 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 932 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
950 prop.m_dwStates = FWL_WGTSTATE_Invisible; | 933 prop.m_dwStates = FWL_WGTSTATE_Invisible; |
951 prop.m_pParent = m_pInterface; | 934 prop.m_pParent = m_pInterface; |
952 prop.m_pThemeProvider = m_pScrollBarTP; | 935 prop.m_pThemeProvider = m_pScrollBarTP; |
953 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); | 936 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); |
954 pScrollBar->Initialize(); | 937 pScrollBar->Initialize(); |
955 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); | 938 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); |
956 } | 939 } |
957 void CFWL_ListBoxImp::SortItem() {} | 940 |
958 FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) { | 941 FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) { |
959 IFWL_ScrollBar* pScrollbar = | 942 IFWL_ScrollBar* pScrollbar = |
960 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 943 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
961 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { | 944 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { |
962 return FALSE; | 945 return FALSE; |
963 } | 946 } |
964 return !(m_pProperties->m_dwStyleExes & | 947 return !(m_pProperties->m_dwStyleExes & |
965 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || | 948 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || |
966 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); | 949 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); |
967 } | 950 } |
968 void CFWL_ListBoxImp::ProcessSelChanged() { | 951 void CFWL_ListBoxImp::ProcessSelChanged() { |
969 CFWL_EvtLtbSelChanged selEvent; | 952 CFWL_EvtLtbSelChanged selEvent; |
970 selEvent.m_pSrcTarget = m_pInterface; | 953 selEvent.m_pSrcTarget = m_pInterface; |
971 CFX_Int32Array arrSels; | 954 CFX_Int32Array arrSels; |
972 int32_t iCount = CountSelItems(); | 955 int32_t iCount = CountSelItems(); |
973 for (int32_t i = 0; i < iCount; i++) { | 956 for (int32_t i = 0; i < iCount; i++) { |
974 FWL_HLISTITEM item = GetSelItem(i); | 957 FWL_HLISTITEM item = GetSelItem(i); |
975 if (item == NULL) { | 958 if (item == NULL) { |
976 continue; | 959 continue; |
977 } | 960 } |
978 selEvent.iarraySels.Add(i); | 961 selEvent.iarraySels.Add(i); |
979 } | 962 } |
980 DispatchEvent(&selEvent); | 963 DispatchEvent(&selEvent); |
981 } | 964 } |
982 | 965 |
983 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) | 966 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) |
984 : m_pOwner(pOwner) {} | 967 : m_pOwner(pOwner) {} |
985 | 968 |
986 int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 969 void CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
987 if (!pMessage) | 970 if (!pMessage) |
988 return 0; | 971 return; |
989 if (!m_pOwner->IsEnabled()) | 972 if (!m_pOwner->IsEnabled()) |
990 return 1; | 973 return; |
991 | 974 |
992 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 975 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
993 int32_t iRet = 1; | |
994 switch (dwMsgCode) { | 976 switch (dwMsgCode) { |
995 case CFWL_MessageType::SetFocus: { | 977 case CFWL_MessageType::SetFocus: { |
996 OnFocusChanged(pMessage, TRUE); | 978 OnFocusChanged(pMessage, TRUE); |
997 break; | 979 break; |
998 } | 980 } |
999 case CFWL_MessageType::KillFocus: { | 981 case CFWL_MessageType::KillFocus: { |
1000 OnFocusChanged(pMessage, FALSE); | 982 OnFocusChanged(pMessage, FALSE); |
1001 break; | 983 break; |
1002 } | 984 } |
1003 case CFWL_MessageType::Mouse: { | 985 case CFWL_MessageType::Mouse: { |
(...skipping 16 matching lines...) Expand all Loading... |
1020 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); | 1002 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); |
1021 break; | 1003 break; |
1022 } | 1004 } |
1023 case CFWL_MessageType::Key: { | 1005 case CFWL_MessageType::Key: { |
1024 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); | 1006 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); |
1025 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) | 1007 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) |
1026 OnKeyDown(pMsg); | 1008 OnKeyDown(pMsg); |
1027 break; | 1009 break; |
1028 } | 1010 } |
1029 default: { | 1011 default: { |
1030 iRet = 0; | |
1031 break; | 1012 break; |
1032 } | 1013 } |
1033 } | 1014 } |
1034 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1015 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
1035 return iRet; | |
1036 } | 1016 } |
1037 | 1017 |
1038 FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1018 void CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
1039 if (!pEvent) | 1019 if (!pEvent) |
1040 return FWL_ERR_Indefinite; | 1020 return; |
1041 if (pEvent->GetClassID() != CFWL_EventType::Scroll) | 1021 if (pEvent->GetClassID() != CFWL_EventType::Scroll) |
1042 return FWL_ERR_Succeeded; | 1022 return; |
1043 | 1023 |
1044 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; | 1024 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; |
1045 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && | 1025 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && |
1046 m_pOwner->m_pVertScrollBar) || | 1026 m_pOwner->m_pVertScrollBar) || |
1047 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && | 1027 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && |
1048 m_pOwner->m_pHorzScrollBar)) { | 1028 m_pOwner->m_pHorzScrollBar)) { |
1049 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); | 1029 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); |
1050 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), | 1030 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), |
1051 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); | 1031 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); |
1052 } | 1032 } |
1053 return FWL_ERR_Succeeded; | |
1054 } | 1033 } |
1055 | 1034 |
1056 FWL_ERR CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1035 void CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
1057 const CFX_Matrix* pMatrix) { | 1036 const CFX_Matrix* pMatrix) { |
1058 return m_pOwner->DrawWidget(pGraphics, pMatrix); | 1037 m_pOwner->DrawWidget(pGraphics, pMatrix); |
1059 } | 1038 } |
| 1039 |
1060 void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { | 1040 void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { |
1061 if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { | 1041 if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { |
1062 if (m_pOwner->m_pVertScrollBar) { | 1042 if (m_pOwner->m_pVertScrollBar) { |
1063 m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); | 1043 m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); |
1064 } | 1044 } |
1065 if (m_pOwner->m_pHorzScrollBar) { | 1045 if (m_pOwner->m_pHorzScrollBar) { |
1066 m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); | 1046 m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); |
1067 } | 1047 } |
1068 } | 1048 } |
1069 if (bSet) { | 1049 if (bSet) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 pScrollBar->SetTrackPos(fPos); | 1223 pScrollBar->SetTrackPos(fPos); |
1244 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1224 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
1245 } | 1225 } |
1246 return TRUE; | 1226 return TRUE; |
1247 } | 1227 } |
1248 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { | 1228 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { |
1249 CFWL_EvtLtbSelChanged ev; | 1229 CFWL_EvtLtbSelChanged ev; |
1250 ev.m_pSrcTarget = m_pOwner->m_pInterface; | 1230 ev.m_pSrcTarget = m_pOwner->m_pInterface; |
1251 m_pOwner->DispatchEvent(&ev); | 1231 m_pOwner->DispatchEvent(&ev); |
1252 } | 1232 } |
OLD | NEW |