Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1019)

Side by Side Diff: xfa/fwl/basewidget/fwl_listboximp.cpp

Issue 1952693003: Convert FWL_ERR into an enum class. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/basewidget/fwl_listboximp.h ('k') | xfa/fwl/basewidget/fwl_monthcalendarimp.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 } 927 }
945 CFWL_WidgetImpProperties prop; 928 CFWL_WidgetImpProperties prop;
946 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; 929 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
947 prop.m_dwStates = FWL_WGTSTATE_Invisible; 930 prop.m_dwStates = FWL_WGTSTATE_Invisible;
948 prop.m_pParent = m_pInterface; 931 prop.m_pParent = m_pInterface;
949 prop.m_pThemeProvider = m_pScrollBarTP; 932 prop.m_pThemeProvider = m_pScrollBarTP;
950 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); 933 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface);
951 pScrollBar->Initialize(); 934 pScrollBar->Initialize();
952 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); 935 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
953 } 936 }
954 void CFWL_ListBoxImp::SortItem() {} 937
955 FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) { 938 FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) {
956 IFWL_ScrollBar* pScrollbar = 939 IFWL_ScrollBar* pScrollbar =
957 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); 940 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
958 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { 941 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) {
959 return FALSE; 942 return FALSE;
960 } 943 }
961 return !(m_pProperties->m_dwStyleExes & 944 return !(m_pProperties->m_dwStyleExes &
962 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || 945 FWL_STYLEEXT_LTB_ShowScrollBarFocus) ||
963 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); 946 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
964 } 947 }
965 void CFWL_ListBoxImp::ProcessSelChanged() { 948 void CFWL_ListBoxImp::ProcessSelChanged() {
966 CFWL_EvtLtbSelChanged selEvent; 949 CFWL_EvtLtbSelChanged selEvent;
967 selEvent.m_pSrcTarget = m_pInterface; 950 selEvent.m_pSrcTarget = m_pInterface;
968 CFX_Int32Array arrSels; 951 CFX_Int32Array arrSels;
969 int32_t iCount = CountSelItems(); 952 int32_t iCount = CountSelItems();
970 for (int32_t i = 0; i < iCount; i++) { 953 for (int32_t i = 0; i < iCount; i++) {
971 FWL_HLISTITEM item = GetSelItem(i); 954 FWL_HLISTITEM item = GetSelItem(i);
972 if (item == NULL) { 955 if (item == NULL) {
973 continue; 956 continue;
974 } 957 }
975 selEvent.iarraySels.Add(i); 958 selEvent.iarraySels.Add(i);
976 } 959 }
977 DispatchEvent(&selEvent); 960 DispatchEvent(&selEvent);
978 } 961 }
979 962
980 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) 963 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner)
981 : m_pOwner(pOwner) {} 964 : m_pOwner(pOwner) {}
982 965
983 int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { 966 void CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
984 if (!pMessage) 967 if (!pMessage)
985 return 0; 968 return;
986 if (!m_pOwner->IsEnabled()) 969 if (!m_pOwner->IsEnabled())
987 return 1; 970 return;
988 971
989 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 972 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
990 int32_t iRet = 1;
991 switch (dwMsgCode) { 973 switch (dwMsgCode) {
992 case CFWL_MessageType::SetFocus: { 974 case CFWL_MessageType::SetFocus: {
993 OnFocusChanged(pMessage, TRUE); 975 OnFocusChanged(pMessage, TRUE);
994 break; 976 break;
995 } 977 }
996 case CFWL_MessageType::KillFocus: { 978 case CFWL_MessageType::KillFocus: {
997 OnFocusChanged(pMessage, FALSE); 979 OnFocusChanged(pMessage, FALSE);
998 break; 980 break;
999 } 981 }
1000 case CFWL_MessageType::Mouse: { 982 case CFWL_MessageType::Mouse: {
(...skipping 16 matching lines...) Expand all
1017 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); 999 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage));
1018 break; 1000 break;
1019 } 1001 }
1020 case CFWL_MessageType::Key: { 1002 case CFWL_MessageType::Key: {
1021 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); 1003 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage);
1022 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) 1004 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown)
1023 OnKeyDown(pMsg); 1005 OnKeyDown(pMsg);
1024 break; 1006 break;
1025 } 1007 }
1026 default: { 1008 default: {
1027 iRet = 0;
1028 break; 1009 break;
1029 } 1010 }
1030 } 1011 }
1031 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); 1012 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
1032 return iRet;
1033 } 1013 }
1034 1014
1035 FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { 1015 void CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
1036 if (!pEvent) 1016 if (!pEvent)
1037 return FWL_ERR_Indefinite; 1017 return;
1038 if (pEvent->GetClassID() != CFWL_EventType::Scroll) 1018 if (pEvent->GetClassID() != CFWL_EventType::Scroll)
1039 return FWL_ERR_Succeeded; 1019 return;
1040 1020
1041 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; 1021 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget;
1042 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && 1022 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() &&
1043 m_pOwner->m_pVertScrollBar) || 1023 m_pOwner->m_pVertScrollBar) ||
1044 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && 1024 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() &&
1045 m_pOwner->m_pHorzScrollBar)) { 1025 m_pOwner->m_pHorzScrollBar)) {
1046 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); 1026 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent);
1047 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), 1027 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget),
1048 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); 1028 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos);
1049 } 1029 }
1050 return FWL_ERR_Succeeded;
1051 } 1030 }
1052 1031
1053 FWL_ERR CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, 1032 void CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
1054 const CFX_Matrix* pMatrix) { 1033 const CFX_Matrix* pMatrix) {
1055 return m_pOwner->DrawWidget(pGraphics, pMatrix); 1034 m_pOwner->DrawWidget(pGraphics, pMatrix);
1056 } 1035 }
1036
1057 void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { 1037 void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
1058 if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { 1038 if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) {
1059 if (m_pOwner->m_pVertScrollBar) { 1039 if (m_pOwner->m_pVertScrollBar) {
1060 m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); 1040 m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
1061 } 1041 }
1062 if (m_pOwner->m_pHorzScrollBar) { 1042 if (m_pOwner->m_pHorzScrollBar) {
1063 m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); 1043 m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
1064 } 1044 }
1065 } 1045 }
1066 if (bSet) { 1046 if (bSet) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 pScrollBar->SetTrackPos(fPos); 1220 pScrollBar->SetTrackPos(fPos);
1241 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1221 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1242 } 1222 }
1243 return TRUE; 1223 return TRUE;
1244 } 1224 }
1245 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { 1225 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() {
1246 CFWL_EvtLtbSelChanged ev; 1226 CFWL_EvtLtbSelChanged ev;
1247 ev.m_pSrcTarget = m_pOwner->m_pInterface; 1227 ev.m_pSrcTarget = m_pOwner->m_pInterface;
1248 m_pOwner->DispatchEvent(&ev); 1228 m_pOwner->DispatchEvent(&ev);
1249 } 1229 }
OLDNEW
« no previous file with comments | « xfa/fwl/basewidget/fwl_listboximp.h ('k') | xfa/fwl/basewidget/fwl_monthcalendarimp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698