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

Side by Side Diff: fpdfsdk/pdfwindow/PWL_ListBox.cpp

Issue 2162873003: Remove m_pList conditionals from CPWL_ListBox (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@bug_628995
Patch Set: Created 4 years, 5 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 | « fpdfsdk/pdfwindow/PWL_ComboBox.cpp ('k') | no next file » | 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 "fpdfsdk/pdfwindow/PWL_ListBox.h" 7 #include "fpdfsdk/pdfwindow/PWL_ListBox.h"
8 8
9 #include "fpdfsdk/fxedit/include/fxet_edit.h" 9 #include "fpdfsdk/fxedit/include/fxet_edit.h"
10 #include "fpdfsdk/fxedit/include/fxet_list.h" 10 #include "fpdfsdk/fxedit/include/fxet_list.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 m_pFillerNotify(nullptr) {} 73 m_pFillerNotify(nullptr) {}
74 74
75 CPWL_ListBox::~CPWL_ListBox() { 75 CPWL_ListBox::~CPWL_ListBox() {
76 } 76 }
77 77
78 CFX_ByteString CPWL_ListBox::GetClassName() const { 78 CFX_ByteString CPWL_ListBox::GetClassName() const {
79 return "CPWL_ListBox"; 79 return "CPWL_ListBox";
80 } 80 }
81 81
82 void CPWL_ListBox::OnCreated() { 82 void CPWL_ListBox::OnCreated() {
83 if (m_pList) { 83 m_pList->SetFontMap(GetFontMap());
84 m_pList->SetFontMap(GetFontMap()); 84 m_pListNotify.reset(new CPWL_List_Notify(this));
85 m_pListNotify.reset(new CPWL_List_Notify(this)); 85 m_pList->SetNotify(m_pListNotify.get());
86 m_pList->SetNotify(m_pListNotify.get());
87 86
88 SetHoverSel(HasFlag(PLBS_HOVERSEL)); 87 SetHoverSel(HasFlag(PLBS_HOVERSEL));
89 m_pList->SetMultipleSel(HasFlag(PLBS_MULTIPLESEL)); 88 m_pList->SetMultipleSel(HasFlag(PLBS_MULTIPLESEL));
90 m_pList->SetFontSize(GetCreationParam().fFontSize); 89 m_pList->SetFontSize(GetCreationParam().fFontSize);
91 90
92 m_bHoverSel = HasFlag(PLBS_HOVERSEL); 91 m_bHoverSel = HasFlag(PLBS_HOVERSEL);
93 }
94 } 92 }
95 93
96 void CPWL_ListBox::OnDestroy() { 94 void CPWL_ListBox::OnDestroy() {
97 // Make sure the notifier is removed from the list as we are about to 95 // Make sure the notifier is removed from the list as we are about to
98 // destroy the notifier and don't want to leave a dangling pointer. 96 // destroy the notifier and don't want to leave a dangling pointer.
99 if (m_pList) 97 m_pList->SetNotify(nullptr);
100 m_pList->SetNotify(nullptr);
101 m_pListNotify.reset(); 98 m_pListNotify.reset();
102 } 99 }
103 100
104 void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { 101 void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
105 CPWL_Wnd::GetThisAppearanceStream(sAppStream); 102 CPWL_Wnd::GetThisAppearanceStream(sAppStream);
106 103
107 CFX_ByteTextBuf sListItems; 104 CFX_ByteTextBuf sListItems;
108 105
109 if (m_pList) { 106 CFX_FloatRect rcPlate = m_pList->GetPlateRect();
110 CFX_FloatRect rcPlate = m_pList->GetPlateRect(); 107 for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) {
111 for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) { 108 CFX_FloatRect rcItem = m_pList->GetItemRect(i);
112 CFX_FloatRect rcItem = m_pList->GetItemRect(i);
113 109
114 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) 110 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom)
115 continue; 111 continue;
116 112
117 CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); 113 CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f);
118 if (m_pList->IsItemSelected(i)) { 114 if (m_pList->IsItemSelected(i)) {
119 sListItems << CPWL_Utils::GetRectFillAppStream(rcItem, 115 sListItems << CPWL_Utils::GetRectFillAppStream(rcItem,
120 PWL_DEFAULT_SELBACKCOLOR) 116 PWL_DEFAULT_SELBACKCOLOR)
121 .AsStringC(); 117 .AsStringC();
122 CFX_ByteString sItem = 118 CFX_ByteString sItem =
123 CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset); 119 CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset);
124 if (sItem.GetLength() > 0) { 120 if (sItem.GetLength() > 0) {
125 sListItems << "BT\n" 121 sListItems << "BT\n"
126 << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELTEXTCOLOR) 122 << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELTEXTCOLOR)
127 .AsStringC() 123 .AsStringC()
128 << sItem.AsStringC() << "ET\n"; 124 << sItem.AsStringC() << "ET\n";
129 } 125 }
130 } else { 126 } else {
131 CFX_ByteString sItem = 127 CFX_ByteString sItem =
132 CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset); 128 CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset);
133 if (sItem.GetLength() > 0) { 129 if (sItem.GetLength() > 0) {
134 sListItems << "BT\n" 130 sListItems << "BT\n"
135 << CPWL_Utils::GetColorAppStream(GetTextColor()) 131 << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC()
136 .AsStringC() 132 << sItem.AsStringC() << "ET\n";
137 << sItem.AsStringC() << "ET\n";
138 }
139 } 133 }
140 } 134 }
141 } 135 }
142 136
143 if (sListItems.GetLength() > 0) { 137 if (sListItems.GetLength() > 0) {
144 CFX_ByteTextBuf sClip; 138 CFX_ByteTextBuf sClip;
145 CFX_FloatRect rcClient = GetClientRect(); 139 CFX_FloatRect rcClient = GetClientRect();
146 140
147 sClip << "q\n"; 141 sClip << "q\n";
148 sClip << rcClient.left << " " << rcClient.bottom << " " 142 sClip << rcClient.left << " " << rcClient.bottom << " "
149 << rcClient.right - rcClient.left << " " 143 << rcClient.right - rcClient.left << " "
150 << rcClient.top - rcClient.bottom << " re W n\n"; 144 << rcClient.top - rcClient.bottom << " re W n\n";
151 145
152 sClip << sListItems << "Q\n"; 146 sClip << sListItems << "Q\n";
153 147
154 sAppStream << "/Tx BMC\n" << sClip << "EMC\n"; 148 sAppStream << "/Tx BMC\n" << sClip << "EMC\n";
155 } 149 }
156 } 150 }
157 151
158 void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice, 152 void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
159 CFX_Matrix* pUser2Device) { 153 CFX_Matrix* pUser2Device) {
160 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); 154 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
161 155
162 if (m_pList) { 156 CFX_FloatRect rcPlate = m_pList->GetPlateRect();
163 CFX_FloatRect rcPlate = m_pList->GetPlateRect(); 157 CFX_FloatRect rcList = GetListRect();
164 CFX_FloatRect rcList = GetListRect(); 158 CFX_FloatRect rcClient = GetClientRect();
165 CFX_FloatRect rcClient = GetClientRect();
166 159
167 for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) { 160 for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) {
168 CFX_FloatRect rcItem = m_pList->GetItemRect(i); 161 CFX_FloatRect rcItem = m_pList->GetItemRect(i);
169 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) 162 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom)
170 continue; 163 continue;
171 164
172 CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); 165 CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f);
173 if (CFX_Edit* pEdit = m_pList->GetItemEdit(i)) { 166 if (CFX_Edit* pEdit = m_pList->GetItemEdit(i)) {
174 CFX_FloatRect rcContent = pEdit->GetContentRect(); 167 CFX_FloatRect rcContent = pEdit->GetContentRect();
175 if (rcContent.Width() > rcClient.Width()) 168 if (rcContent.Width() > rcClient.Width())
176 rcItem.Intersect(rcList); 169 rcItem.Intersect(rcList);
177 else 170 else
178 rcItem.Intersect(rcClient); 171 rcItem.Intersect(rcClient);
179 } 172 }
180 173
181 if (m_pList->IsItemSelected(i)) { 174 if (m_pList->IsItemSelected(i)) {
182 CFX_SystemHandler* pSysHandler = GetSystemHandler(); 175 CFX_SystemHandler* pSysHandler = GetSystemHandler();
183 if (pSysHandler && pSysHandler->IsSelectionImplemented()) { 176 if (pSysHandler && pSysHandler->IsSelectionImplemented()) {
184 CFX_Edit::DrawEdit(
185 pDevice, pUser2Device, m_pList->GetItemEdit(i),
186 CPWL_Utils::PWLColorToFXColor(GetTextColor()),
187 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()), rcList,
188 ptOffset, nullptr, pSysHandler, m_pFormFiller);
189 pSysHandler->OutputSelectedRect(m_pFormFiller, rcItem);
190 } else {
191 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem,
192 ArgbEncode(255, 0, 51, 113));
193 CFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
194 ArgbEncode(255, 255, 255, 255), 0, rcList,
195 ptOffset, nullptr, pSysHandler, m_pFormFiller);
196 }
197 } else {
198 CFX_SystemHandler* pSysHandler = GetSystemHandler();
199 CFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i), 177 CFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
200 CPWL_Utils::PWLColorToFXColor(GetTextColor()), 178 CPWL_Utils::PWLColorToFXColor(GetTextColor()),
201 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()), 179 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()),
202 rcList, ptOffset, nullptr, pSysHandler, nullptr); 180 rcList, ptOffset, nullptr, pSysHandler,
181 m_pFormFiller);
182 pSysHandler->OutputSelectedRect(m_pFormFiller, rcItem);
183 } else {
184 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem,
185 ArgbEncode(255, 0, 51, 113));
186 CFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
187 ArgbEncode(255, 255, 255, 255), 0, rcList, ptOffset,
188 nullptr, pSysHandler, m_pFormFiller);
203 } 189 }
190 } else {
191 CFX_SystemHandler* pSysHandler = GetSystemHandler();
192 CFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
193 CPWL_Utils::PWLColorToFXColor(GetTextColor()),
194 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()),
195 rcList, ptOffset, nullptr, pSysHandler, nullptr);
204 } 196 }
205 } 197 }
206 } 198 }
207 199
208 FX_BOOL CPWL_ListBox::OnKeyDown(uint16_t nChar, uint32_t nFlag) { 200 FX_BOOL CPWL_ListBox::OnKeyDown(uint16_t nChar, uint32_t nFlag) {
209 CPWL_Wnd::OnKeyDown(nChar, nFlag); 201 CPWL_Wnd::OnKeyDown(nChar, nFlag);
210 202
211 if (!m_pList)
212 return FALSE;
213
214 switch (nChar) { 203 switch (nChar) {
215 default: 204 default:
216 return FALSE; 205 return FALSE;
217 case FWL_VKEY_Up: 206 case FWL_VKEY_Up:
218 case FWL_VKEY_Down: 207 case FWL_VKEY_Down:
219 case FWL_VKEY_Home: 208 case FWL_VKEY_Home:
220 case FWL_VKEY_Left: 209 case FWL_VKEY_Left:
221 case FWL_VKEY_End: 210 case FWL_VKEY_End:
222 case FWL_VKEY_Right: 211 case FWL_VKEY_Right:
223 break; 212 break;
(...skipping 24 matching lines...) Expand all
248 237
249 FX_BOOL bExit = FALSE; 238 FX_BOOL bExit = FALSE;
250 OnNotifySelChanged(TRUE, bExit, nFlag); 239 OnNotifySelChanged(TRUE, bExit, nFlag);
251 240
252 return TRUE; 241 return TRUE;
253 } 242 }
254 243
255 FX_BOOL CPWL_ListBox::OnChar(uint16_t nChar, uint32_t nFlag) { 244 FX_BOOL CPWL_ListBox::OnChar(uint16_t nChar, uint32_t nFlag) {
256 CPWL_Wnd::OnChar(nChar, nFlag); 245 CPWL_Wnd::OnChar(nChar, nFlag);
257 246
258 if (!m_pList)
259 return FALSE;
260
261 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag))) 247 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)))
262 return FALSE; 248 return FALSE;
263 249
264 FX_BOOL bExit = FALSE; 250 FX_BOOL bExit = FALSE;
265 OnNotifySelChanged(TRUE, bExit, nFlag); 251 OnNotifySelChanged(TRUE, bExit, nFlag);
266 252
267 return TRUE; 253 return TRUE;
268 } 254 }
269 255
270 FX_BOOL CPWL_ListBox::OnLButtonDown(const CFX_FloatPoint& point, 256 FX_BOOL CPWL_ListBox::OnLButtonDown(const CFX_FloatPoint& point,
271 uint32_t nFlag) { 257 uint32_t nFlag) {
272 CPWL_Wnd::OnLButtonDown(point, nFlag); 258 CPWL_Wnd::OnLButtonDown(point, nFlag);
273 259
274 if (ClientHitTest(point)) { 260 if (ClientHitTest(point)) {
275 m_bMouseDown = TRUE; 261 m_bMouseDown = TRUE;
276 SetFocus(); 262 SetFocus();
277 SetCapture(); 263 SetCapture();
278 264
279 if (m_pList) 265 m_pList->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
280 m_pList->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
281 } 266 }
282 267
283 return TRUE; 268 return TRUE;
284 } 269 }
285 270
286 FX_BOOL CPWL_ListBox::OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) { 271 FX_BOOL CPWL_ListBox::OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) {
287 CPWL_Wnd::OnLButtonUp(point, nFlag); 272 CPWL_Wnd::OnLButtonUp(point, nFlag);
288 273
289 if (m_bMouseDown) { 274 if (m_bMouseDown) {
290 ReleaseCapture(); 275 ReleaseCapture();
291 m_bMouseDown = FALSE; 276 m_bMouseDown = FALSE;
292 } 277 }
293 278
294 FX_BOOL bExit = FALSE; 279 FX_BOOL bExit = FALSE;
295 OnNotifySelChanged(FALSE, bExit, nFlag); 280 OnNotifySelChanged(FALSE, bExit, nFlag);
296 281
297 return TRUE; 282 return TRUE;
298 } 283 }
299 284
300 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) { 285 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) {
301 m_bHoverSel = bHoverSel; 286 m_bHoverSel = bHoverSel;
302 } 287 }
303 288
304 FX_BOOL CPWL_ListBox::OnMouseMove(const CFX_FloatPoint& point, uint32_t nFlag) { 289 FX_BOOL CPWL_ListBox::OnMouseMove(const CFX_FloatPoint& point, uint32_t nFlag) {
305 CPWL_Wnd::OnMouseMove(point, nFlag); 290 CPWL_Wnd::OnMouseMove(point, nFlag);
306 291
307 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) { 292 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point))
308 if (m_pList) 293 m_pList->Select(m_pList->GetItemIndex(point));
309 m_pList->Select(m_pList->GetItemIndex(point)); 294 if (m_bMouseDown)
310 } 295 m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
311
312 if (m_bMouseDown) {
313 if (m_pList)
314 m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
315 }
316 296
317 return TRUE; 297 return TRUE;
318 } 298 }
319 299
320 void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd, 300 void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd,
321 uint32_t msg, 301 uint32_t msg,
322 intptr_t wParam, 302 intptr_t wParam,
323 intptr_t lParam) { 303 intptr_t lParam) {
324 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); 304 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
325 305
(...skipping 15 matching lines...) Expand all
341 if (CPWL_Wnd* pChild = GetVScrollBar()) { 321 if (CPWL_Wnd* pChild = GetVScrollBar()) {
342 pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); 322 pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
343 } 323 }
344 break; 324 break;
345 } 325 }
346 break; 326 break;
347 case PNM_SCROLLWINDOW: 327 case PNM_SCROLLWINDOW:
348 fPos = *(FX_FLOAT*)lParam; 328 fPos = *(FX_FLOAT*)lParam;
349 switch (wParam) { 329 switch (wParam) {
350 case SBT_VSCROLL: 330 case SBT_VSCROLL:
351 if (m_pList) 331 m_pList->SetScrollPos(CFX_FloatPoint(0, fPos));
352 m_pList->SetScrollPos(CFX_FloatPoint(0, fPos));
353 break; 332 break;
354 } 333 }
355 break; 334 break;
356 } 335 }
357 } 336 }
358 337
359 void CPWL_ListBox::KillFocus() { 338 void CPWL_ListBox::KillFocus() {
360 CPWL_Wnd::KillFocus(); 339 CPWL_Wnd::KillFocus();
361 } 340 }
362 341
363 void CPWL_ListBox::RePosChildWnd() { 342 void CPWL_ListBox::RePosChildWnd() {
364 CPWL_Wnd::RePosChildWnd(); 343 CPWL_Wnd::RePosChildWnd();
365 344
366 if (m_pList) 345 m_pList->SetPlateRect(GetListRect());
367 m_pList->SetPlateRect(GetListRect());
368 } 346 }
369 347
370 void CPWL_ListBox::OnNotifySelChanged(FX_BOOL bKeyDown, 348 void CPWL_ListBox::OnNotifySelChanged(FX_BOOL bKeyDown,
371 FX_BOOL& bExit, 349 FX_BOOL& bExit,
372 uint32_t nFlag) { 350 uint32_t nFlag) {
373 if (!m_pFillerNotify) 351 if (!m_pFillerNotify)
374 return; 352 return;
375 353
376 FX_BOOL bRC = TRUE; 354 FX_BOOL bRC = TRUE;
377 CFX_WideString swChange = GetText(); 355 CFX_WideString swChange = GetText();
378 CFX_WideString strChangeEx; 356 CFX_WideString strChangeEx;
379 int nSelStart = 0; 357 int nSelStart = 0;
380 int nSelEnd = swChange.GetLength(); 358 int nSelEnd = swChange.GetLength();
381 m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, strChangeEx, 359 m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, strChangeEx,
382 nSelStart, nSelEnd, bKeyDown, bRC, bExit, 360 nSelStart, nSelEnd, bKeyDown, bRC, bExit,
383 nFlag); 361 nFlag);
384 } 362 }
385 363
386 CFX_FloatRect CPWL_ListBox::GetFocusRect() const { 364 CFX_FloatRect CPWL_ListBox::GetFocusRect() const {
387 if (m_pList && m_pList->IsMultipleSel()) { 365 if (m_pList->IsMultipleSel()) {
388 CFX_FloatRect rcCaret = m_pList->GetItemRect(m_pList->GetCaret()); 366 CFX_FloatRect rcCaret = m_pList->GetItemRect(m_pList->GetCaret());
389 rcCaret.Intersect(GetClientRect()); 367 rcCaret.Intersect(GetClientRect());
390 return rcCaret; 368 return rcCaret;
391 } 369 }
392 370
393 return CPWL_Wnd::GetFocusRect(); 371 return CPWL_Wnd::GetFocusRect();
394 } 372 }
395 373
396 void CPWL_ListBox::AddString(const FX_WCHAR* str) { 374 void CPWL_ListBox::AddString(const FX_WCHAR* str) {
397 if (m_pList) { 375 m_pList->AddString(str);
398 m_pList->AddString(str);
399 }
400 } 376 }
401 377
402 CFX_WideString CPWL_ListBox::GetText() const { 378 CFX_WideString CPWL_ListBox::GetText() const {
403 if (m_pList) 379 return m_pList->GetText();
404 return m_pList->GetText();
405
406 return L"";
407 } 380 }
408 381
409 void CPWL_ListBox::SetFontSize(FX_FLOAT fFontSize) { 382 void CPWL_ListBox::SetFontSize(FX_FLOAT fFontSize) {
410 if (m_pList) 383 m_pList->SetFontSize(fFontSize);
411 m_pList->SetFontSize(fFontSize);
412 } 384 }
413 385
414 FX_FLOAT CPWL_ListBox::GetFontSize() const { 386 FX_FLOAT CPWL_ListBox::GetFontSize() const {
415 if (m_pList) 387 return m_pList->GetFontSize();
416 return m_pList->GetFontSize();
417 return 0.0f;
418 } 388 }
419 389
420 void CPWL_ListBox::Select(int32_t nItemIndex) { 390 void CPWL_ListBox::Select(int32_t nItemIndex) {
421 if (m_pList) 391 m_pList->Select(nItemIndex);
422 m_pList->Select(nItemIndex);
423 } 392 }
424 393
425 void CPWL_ListBox::SetCaret(int32_t nItemIndex) { 394 void CPWL_ListBox::SetCaret(int32_t nItemIndex) {
426 if (m_pList) 395 m_pList->SetCaret(nItemIndex);
427 m_pList->SetCaret(nItemIndex);
428 } 396 }
429 397
430 void CPWL_ListBox::SetTopVisibleIndex(int32_t nItemIndex) { 398 void CPWL_ListBox::SetTopVisibleIndex(int32_t nItemIndex) {
431 if (m_pList) 399 m_pList->SetTopItem(nItemIndex);
432 m_pList->SetTopItem(nItemIndex);
433 } 400 }
434 401
435 void CPWL_ListBox::ScrollToListItem(int32_t nItemIndex) { 402 void CPWL_ListBox::ScrollToListItem(int32_t nItemIndex) {
436 if (m_pList) 403 m_pList->ScrollToListItem(nItemIndex);
437 m_pList->ScrollToListItem(nItemIndex);
438 } 404 }
439 405
440 void CPWL_ListBox::ResetContent() { 406 void CPWL_ListBox::ResetContent() {
441 if (m_pList) 407 m_pList->Empty();
442 m_pList->Empty();
443 } 408 }
444 409
445 void CPWL_ListBox::Reset() { 410 void CPWL_ListBox::Reset() {
446 if (m_pList) 411 m_pList->Cancel();
447 m_pList->Cancel();
448 } 412 }
449 413
450 FX_BOOL CPWL_ListBox::IsMultipleSel() const { 414 FX_BOOL CPWL_ListBox::IsMultipleSel() const {
451 if (m_pList) 415 return m_pList->IsMultipleSel();
452 return m_pList->IsMultipleSel();
453
454 return FALSE;
455 } 416 }
456 417
457 int32_t CPWL_ListBox::GetCaretIndex() const { 418 int32_t CPWL_ListBox::GetCaretIndex() const {
458 if (m_pList) 419 return m_pList->GetCaret();
459 return m_pList->GetCaret();
460
461 return -1;
462 } 420 }
463 421
464 int32_t CPWL_ListBox::GetCurSel() const { 422 int32_t CPWL_ListBox::GetCurSel() const {
465 if (m_pList) 423 return m_pList->GetSelect();
466 return m_pList->GetSelect();
467
468 return -1;
469 } 424 }
470 425
471 FX_BOOL CPWL_ListBox::IsItemSelected(int32_t nItemIndex) const { 426 FX_BOOL CPWL_ListBox::IsItemSelected(int32_t nItemIndex) const {
472 if (m_pList) 427 return m_pList->IsItemSelected(nItemIndex);
473 return m_pList->IsItemSelected(nItemIndex);
474
475 return FALSE;
476 } 428 }
477 429
478 int32_t CPWL_ListBox::GetTopVisibleIndex() const { 430 int32_t CPWL_ListBox::GetTopVisibleIndex() const {
479 if (m_pList) { 431 m_pList->ScrollToListItem(m_pList->GetFirstSelected());
480 m_pList->ScrollToListItem(m_pList->GetFirstSelected()); 432 return m_pList->GetTopItem();
481 return m_pList->GetTopItem();
482 }
483
484 return -1;
485 } 433 }
486 434
487 int32_t CPWL_ListBox::GetCount() const { 435 int32_t CPWL_ListBox::GetCount() const {
488 if (m_pList) 436 return m_pList->GetCount();
489 return m_pList->GetCount();
490
491 return 0;
492 } 437 }
493 438
494 int32_t CPWL_ListBox::FindNext(int32_t nIndex, FX_WCHAR nChar) const { 439 int32_t CPWL_ListBox::FindNext(int32_t nIndex, FX_WCHAR nChar) const {
495 if (m_pList) 440 return m_pList->FindNext(nIndex, nChar);
496 return m_pList->FindNext(nIndex, nChar);
497
498 return nIndex;
499 } 441 }
500 442
501 CFX_FloatRect CPWL_ListBox::GetContentRect() const { 443 CFX_FloatRect CPWL_ListBox::GetContentRect() const {
502 if (m_pList) 444 return m_pList->GetContentRect();
503 return m_pList->GetContentRect();
504
505 return CFX_FloatRect();
506 } 445 }
507 446
508 FX_FLOAT CPWL_ListBox::GetFirstHeight() const { 447 FX_FLOAT CPWL_ListBox::GetFirstHeight() const {
509 if (m_pList) 448 return m_pList->GetFirstHeight();
510 return m_pList->GetFirstHeight();
511
512 return 0.0f;
513 } 449 }
514 450
515 CFX_FloatRect CPWL_ListBox::GetListRect() const { 451 CFX_FloatRect CPWL_ListBox::GetListRect() const {
516 return CPWL_Utils::DeflateRect( 452 return CPWL_Utils::DeflateRect(
517 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); 453 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
518 } 454 }
519 455
520 FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta, 456 FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta,
521 const CFX_FloatPoint& point, 457 const CFX_FloatPoint& point,
522 uint32_t nFlag) { 458 uint32_t nFlag) {
523 if (!m_pList) 459 if (zDelta < 0)
524 return FALSE;
525
526 if (zDelta < 0) {
527 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); 460 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
528 } else { 461 else
529 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); 462 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
530 }
531 463
532 FX_BOOL bExit = FALSE; 464 FX_BOOL bExit = FALSE;
533 OnNotifySelChanged(FALSE, bExit, nFlag); 465 OnNotifySelChanged(FALSE, bExit, nFlag);
534 return TRUE; 466 return TRUE;
535 } 467 }
OLDNEW
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_ComboBox.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698