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

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp

Issue 1799773002: Move fpdfsdk/src up to fpdfsdk/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 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/src/pdfwindow/PWL_Caret.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Edit.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "fpdfsdk/include/pdfwindow/PWL_ComboBox.h"
8
9 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h"
10 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h"
11 #include "fpdfsdk/include/pdfwindow/PWL_ListBox.h"
12 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
13 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
14 #include "public/fpdf_fwlevent.h"
15
16 #define PWLCB_DEFAULTFONTSIZE 12.0f
17
18 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
19 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
20 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
21 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
22
23 FX_BOOL CPWL_CBListBox::OnLButtonUp(const CFX_FloatPoint& point,
24 FX_DWORD nFlag) {
25 CPWL_Wnd::OnLButtonUp(point, nFlag);
26
27 if (m_bMouseDown) {
28 ReleaseCapture();
29 m_bMouseDown = FALSE;
30
31 if (ClientHitTest(point)) {
32 if (CPWL_Wnd* pParent = GetParentWindow()) {
33 pParent->OnNotify(this, PNM_LBUTTONUP, 0,
34 PWL_MAKEDWORD(point.x, point.y));
35 }
36
37 FX_BOOL bExit = FALSE;
38 OnNotifySelChanged(FALSE, bExit, nFlag);
39 if (bExit)
40 return FALSE;
41 }
42 }
43
44 return TRUE;
45 }
46
47 FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(FX_WORD nChar,
48 FX_BOOL& bExit,
49 FX_DWORD nFlag) {
50 if (!m_pList)
51 return FALSE;
52
53 switch (nChar) {
54 default:
55 return FALSE;
56 case FWL_VKEY_Up:
57 case FWL_VKEY_Down:
58 case FWL_VKEY_Home:
59 case FWL_VKEY_Left:
60 case FWL_VKEY_End:
61 case FWL_VKEY_Right:
62 break;
63 }
64
65 switch (nChar) {
66 case FWL_VKEY_Up:
67 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
68 break;
69 case FWL_VKEY_Down:
70 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
71 break;
72 case FWL_VKEY_Home:
73 m_pList->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
74 break;
75 case FWL_VKEY_Left:
76 m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
77 break;
78 case FWL_VKEY_End:
79 m_pList->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
80 break;
81 case FWL_VKEY_Right:
82 m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
83 break;
84 case FWL_VKEY_Delete:
85 break;
86 }
87
88 OnNotifySelChanged(TRUE, bExit, nFlag);
89
90 return TRUE;
91 }
92
93 FX_BOOL CPWL_CBListBox::OnCharWithExit(FX_WORD nChar,
94 FX_BOOL& bExit,
95 FX_DWORD nFlag) {
96 if (!m_pList)
97 return FALSE;
98
99 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)))
100 return FALSE;
101
102 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) {
103 pComboBox->SetSelectText();
104 }
105
106 OnNotifySelChanged(TRUE, bExit, nFlag);
107
108 return TRUE;
109 }
110
111 void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
112 CPWL_Wnd::GetThisAppearanceStream(sAppStream);
113
114 CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();
115
116 if (IsVisible() && !rectWnd.IsEmpty()) {
117 CFX_ByteTextBuf sButton;
118
119 CFX_FloatPoint ptCenter = GetCenterPoint();
120
121 CFX_FloatPoint pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
122 ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
123 CFX_FloatPoint pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
124 ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
125 CFX_FloatPoint pt3(ptCenter.x,
126 ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
127
128 if (IsFloatBigger(rectWnd.right - rectWnd.left,
129 PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
130 IsFloatBigger(rectWnd.top - rectWnd.bottom,
131 PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
132 sButton << "0 g\n";
133 sButton << pt1.x << " " << pt1.y << " m\n";
134 sButton << pt2.x << " " << pt2.y << " l\n";
135 sButton << pt3.x << " " << pt3.y << " l\n";
136 sButton << pt1.x << " " << pt1.y << " l f\n";
137
138 sAppStream << "q\n" << sButton << "Q\n";
139 }
140 }
141 }
142
143 void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
144 CFX_Matrix* pUser2Device) {
145 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
146
147 CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();
148
149 if (IsVisible() && !rectWnd.IsEmpty()) {
150 CFX_FloatPoint ptCenter = GetCenterPoint();
151
152 CFX_FloatPoint pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
153 ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
154 CFX_FloatPoint pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
155 ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
156 CFX_FloatPoint pt3(ptCenter.x,
157 ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
158
159 if (IsFloatBigger(rectWnd.right - rectWnd.left,
160 PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
161 IsFloatBigger(rectWnd.top - rectWnd.bottom,
162 PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
163 CFX_PathData path;
164
165 path.SetPointCount(4);
166 path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO);
167 path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO);
168 path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
169 path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);
170
171 pDevice->DrawPath(&path, pUser2Device, NULL,
172 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR,
173 GetTransparency()),
174 0, FXFILL_ALTERNATE);
175 }
176 }
177 }
178
179 FX_BOOL CPWL_CBButton::OnLButtonDown(const CFX_FloatPoint& point,
180 FX_DWORD nFlag) {
181 CPWL_Wnd::OnLButtonDown(point, nFlag);
182
183 SetCapture();
184
185 if (CPWL_Wnd* pParent = GetParentWindow()) {
186 pParent->OnNotify(this, PNM_LBUTTONDOWN, 0,
187 PWL_MAKEDWORD(point.x, point.y));
188 }
189
190 return TRUE;
191 }
192
193 FX_BOOL CPWL_CBButton::OnLButtonUp(const CFX_FloatPoint& point,
194 FX_DWORD nFlag) {
195 CPWL_Wnd::OnLButtonUp(point, nFlag);
196
197 ReleaseCapture();
198
199 return TRUE;
200 }
201
202 CPWL_ComboBox::CPWL_ComboBox()
203 : m_pEdit(NULL),
204 m_pButton(NULL),
205 m_pList(NULL),
206 m_bPopup(FALSE),
207 m_nPopupWhere(0),
208 m_nSelectItem(-1),
209 m_pFillerNotify(NULL) {}
210
211 CFX_ByteString CPWL_ComboBox::GetClassName() const {
212 return "CPWL_ComboBox";
213 }
214
215 void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM& cp) {
216 cp.dwFlags &= ~PWS_HSCROLL;
217 cp.dwFlags &= ~PWS_VSCROLL;
218 }
219
220 void CPWL_ComboBox::SetFocus() {
221 if (m_pEdit)
222 m_pEdit->SetFocus();
223 }
224
225 void CPWL_ComboBox::KillFocus() {
226 SetPopup(FALSE);
227 CPWL_Wnd::KillFocus();
228 }
229
230 CFX_WideString CPWL_ComboBox::GetText() const {
231 if (m_pEdit) {
232 return m_pEdit->GetText();
233 }
234 return CFX_WideString();
235 }
236
237 void CPWL_ComboBox::SetText(const FX_WCHAR* text) {
238 if (m_pEdit)
239 m_pEdit->SetText(text);
240 }
241
242 void CPWL_ComboBox::AddString(const FX_WCHAR* str) {
243 if (m_pList)
244 m_pList->AddString(str);
245 }
246
247 int32_t CPWL_ComboBox::GetSelect() const {
248 return m_nSelectItem;
249 }
250
251 void CPWL_ComboBox::SetSelect(int32_t nItemIndex) {
252 if (m_pList)
253 m_pList->Select(nItemIndex);
254
255 m_pEdit->SetText(m_pList->GetText().c_str());
256
257 m_nSelectItem = nItemIndex;
258 }
259
260 void CPWL_ComboBox::SetEditSel(int32_t nStartChar, int32_t nEndChar) {
261 if (m_pEdit) {
262 m_pEdit->SetSel(nStartChar, nEndChar);
263 }
264 }
265
266 void CPWL_ComboBox::GetEditSel(int32_t& nStartChar, int32_t& nEndChar) const {
267 nStartChar = -1;
268 nEndChar = -1;
269
270 if (m_pEdit) {
271 m_pEdit->GetSel(nStartChar, nEndChar);
272 }
273 }
274
275 void CPWL_ComboBox::Clear() {
276 if (m_pEdit) {
277 m_pEdit->Clear();
278 }
279 }
280
281 void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM& cp) {
282 CreateEdit(cp);
283 CreateButton(cp);
284 CreateListBox(cp);
285 }
286
287 void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM& cp) {
288 if (!m_pEdit) {
289 m_pEdit = new CPWL_CBEdit;
290 m_pEdit->AttachFFLData(m_pFormFiller);
291
292 PWL_CREATEPARAM ecp = cp;
293 ecp.pParentWnd = this;
294 ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PES_CENTER |
295 PES_AUTOSCROLL | PES_UNDO;
296
297 if (HasFlag(PWS_AUTOFONTSIZE))
298 ecp.dwFlags |= PWS_AUTOFONTSIZE;
299
300 if (!HasFlag(PCBS_ALLOWCUSTOMTEXT))
301 ecp.dwFlags |= PWS_READONLY;
302
303 ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
304 ecp.dwBorderWidth = 0;
305 ecp.nBorderStyle = PBS_SOLID;
306
307 m_pEdit->Create(ecp);
308 }
309 }
310
311 void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM& cp) {
312 if (!m_pButton) {
313 m_pButton = new CPWL_CBButton;
314
315 PWL_CREATEPARAM bcp = cp;
316 bcp.pParentWnd = this;
317 bcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND;
318 bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR;
319 bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
320 bcp.dwBorderWidth = 2;
321 bcp.nBorderStyle = PBS_BEVELED;
322 bcp.eCursorType = FXCT_ARROW;
323
324 m_pButton->Create(bcp);
325 }
326 }
327
328 void CPWL_ComboBox::CreateListBox(const PWL_CREATEPARAM& cp) {
329 if (!m_pList) {
330 m_pList = new CPWL_CBListBox;
331 m_pList->AttachFFLData(m_pFormFiller);
332 PWL_CREATEPARAM lcp = cp;
333 lcp.pParentWnd = this;
334 lcp.dwFlags =
335 PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOVERSEL | PWS_VSCROLL;
336 lcp.nBorderStyle = PBS_SOLID;
337 lcp.dwBorderWidth = 1;
338 lcp.eCursorType = FXCT_ARROW;
339 lcp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
340
341 if (cp.dwFlags & PWS_AUTOFONTSIZE)
342 lcp.fFontSize = PWLCB_DEFAULTFONTSIZE;
343 else
344 lcp.fFontSize = cp.fFontSize;
345
346 if (cp.sBorderColor.nColorType == COLORTYPE_TRANSPARENT)
347 lcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
348
349 if (cp.sBackgroundColor.nColorType == COLORTYPE_TRANSPARENT)
350 lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
351
352 m_pList->Create(lcp);
353 }
354 }
355
356 void CPWL_ComboBox::RePosChildWnd() {
357 CFX_FloatRect rcClient = GetClientRect();
358
359 if (m_bPopup) {
360 CFX_FloatRect rclient = GetClientRect();
361 CFX_FloatRect rcButton = rclient;
362 CFX_FloatRect rcEdit = rcClient;
363 CFX_FloatRect rcList = CPWL_Wnd::GetWindowRect();
364
365 FX_FLOAT fOldWindowHeight = m_rcOldWindow.Height();
366 FX_FLOAT fOldClientHeight = fOldWindowHeight - GetBorderWidth() * 2;
367
368 switch (m_nPopupWhere) {
369 case 0:
370 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
371
372 if (rcButton.left < rclient.left)
373 rcButton.left = rclient.left;
374
375 rcButton.bottom = rcButton.top - fOldClientHeight;
376
377 rcEdit.right = rcButton.left - 1.0f;
378
379 if (rcEdit.left < rclient.left)
380 rcEdit.left = rclient.left;
381
382 if (rcEdit.right < rcEdit.left)
383 rcEdit.right = rcEdit.left;
384
385 rcEdit.bottom = rcEdit.top - fOldClientHeight;
386
387 rcList.top -= fOldWindowHeight;
388
389 break;
390 case 1:
391 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
392
393 if (rcButton.left < rclient.left)
394 rcButton.left = rclient.left;
395
396 rcButton.top = rcButton.bottom + fOldClientHeight;
397
398 rcEdit.right = rcButton.left - 1.0f;
399
400 if (rcEdit.left < rclient.left)
401 rcEdit.left = rclient.left;
402
403 if (rcEdit.right < rcEdit.left)
404 rcEdit.right = rcEdit.left;
405
406 rcEdit.top = rcEdit.bottom + fOldClientHeight;
407
408 rcList.bottom += fOldWindowHeight;
409
410 break;
411 }
412
413 if (m_pButton)
414 m_pButton->Move(rcButton, TRUE, FALSE);
415
416 if (m_pEdit)
417 m_pEdit->Move(rcEdit, TRUE, FALSE);
418
419 if (m_pList) {
420 m_pList->SetVisible(TRUE);
421 m_pList->Move(rcList, TRUE, FALSE);
422 m_pList->ScrollToListItem(m_nSelectItem);
423 }
424 } else {
425 CFX_FloatRect rcButton = rcClient;
426
427 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
428
429 if (rcButton.left < rcClient.left)
430 rcButton.left = rcClient.left;
431
432 if (m_pButton)
433 m_pButton->Move(rcButton, TRUE, FALSE);
434
435 CFX_FloatRect rcEdit = rcClient;
436 rcEdit.right = rcButton.left - 1.0f;
437
438 if (rcEdit.left < rcClient.left)
439 rcEdit.left = rcClient.left;
440
441 if (rcEdit.right < rcEdit.left)
442 rcEdit.right = rcEdit.left;
443
444 if (m_pEdit)
445 m_pEdit->Move(rcEdit, TRUE, FALSE);
446
447 if (m_pList)
448 m_pList->SetVisible(FALSE);
449 }
450 }
451
452 void CPWL_ComboBox::SelectAll() {
453 if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT))
454 m_pEdit->SelectAll();
455 }
456
457 CFX_FloatRect CPWL_ComboBox::GetFocusRect() const {
458 return CFX_FloatRect();
459 }
460
461 void CPWL_ComboBox::SetPopup(FX_BOOL bPopup) {
462 if (!m_pList)
463 return;
464 if (bPopup == m_bPopup)
465 return;
466 FX_FLOAT fListHeight = m_pList->GetContentRect().Height();
467 if (!IsFloatBigger(fListHeight, 0.0f))
468 return;
469
470 if (bPopup) {
471 if (m_pFillerNotify) {
472 #ifdef PDF_ENABLE_XFA
473 FX_BOOL bExit = FALSE;
474 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0);
475 if (bExit)
476 return;
477 #endif // PDF_ENABLE_XFA
478 int32_t nWhere = 0;
479 FX_FLOAT fPopupRet = 0.0f;
480 FX_FLOAT fPopupMin = 0.0f;
481 if (m_pList->GetCount() > 3)
482 fPopupMin =
483 m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2;
484 FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2;
485 m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin, fPopupMax,
486 nWhere, fPopupRet);
487
488 if (IsFloatBigger(fPopupRet, 0.0f)) {
489 m_bPopup = bPopup;
490
491 CFX_FloatRect rcWindow = CPWL_Wnd::GetWindowRect();
492 m_rcOldWindow = rcWindow;
493 switch (nWhere) {
494 default:
495 case 0:
496 rcWindow.bottom -= fPopupRet;
497 break;
498 case 1:
499 rcWindow.top += fPopupRet;
500 break;
501 }
502
503 m_nPopupWhere = nWhere;
504 Move(rcWindow, TRUE, TRUE);
505 #ifdef PDF_ENABLE_XFA
506 bExit = FALSE;
507 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, 0);
508 if (bExit)
509 return;
510 #endif // PDF_ENABLE_XFA
511 }
512 }
513 } else {
514 m_bPopup = bPopup;
515 Move(m_rcOldWindow, TRUE, TRUE);
516 }
517 }
518
519 FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
520 if (!m_pList)
521 return FALSE;
522 if (!m_pEdit)
523 return FALSE;
524
525 m_nSelectItem = -1;
526
527 switch (nChar) {
528 case FWL_VKEY_Up:
529 if (m_pList->GetCurSel() > 0) {
530 FX_BOOL bExit = FALSE;
531 #ifdef PDF_ENABLE_XFA
532 if (m_pFillerNotify) {
533 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
534 if (bExit)
535 return FALSE;
536 bExit = FALSE;
537 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
538 if (bExit)
539 return FALSE;
540 }
541 #endif // PDF_ENABLE_XFA
542 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) {
543 if (bExit)
544 return FALSE;
545 SetSelectText();
546 }
547 }
548 return TRUE;
549 case FWL_VKEY_Down:
550 if (m_pList->GetCurSel() < m_pList->GetCount() - 1) {
551 FX_BOOL bExit = FALSE;
552 #ifdef PDF_ENABLE_XFA
553 if (m_pFillerNotify) {
554 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
555 if (bExit)
556 return FALSE;
557 bExit = FALSE;
558 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
559 if (bExit)
560 return FALSE;
561 }
562 #endif // PDF_ENABLE_XFA
563 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) {
564 if (bExit)
565 return FALSE;
566 SetSelectText();
567 }
568 }
569 return TRUE;
570 }
571
572 if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
573 return m_pEdit->OnKeyDown(nChar, nFlag);
574
575 return FALSE;
576 }
577
578 FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
579 if (!m_pList)
580 return FALSE;
581
582 if (!m_pEdit)
583 return FALSE;
584
585 m_nSelectItem = -1;
586 if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
587 return m_pEdit->OnChar(nChar, nFlag);
588
589 FX_BOOL bExit = FALSE;
590 #ifdef PDF_ENABLE_XFA
591 if (m_pFillerNotify) {
592 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
593 if (bExit)
594 return FALSE;
595
596 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
597 if (bExit)
598 return FALSE;
599 }
600 #endif // PDF_ENABLE_XFA
601 return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : FALSE;
602 }
603
604 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd,
605 FX_DWORD msg,
606 intptr_t wParam,
607 intptr_t lParam) {
608 switch (msg) {
609 case PNM_LBUTTONDOWN:
610 if (pWnd == m_pButton) {
611 SetPopup(!m_bPopup);
612 return;
613 }
614 break;
615 case PNM_LBUTTONUP:
616 if (m_pEdit && m_pList) {
617 if (pWnd == m_pList) {
618 SetSelectText();
619 SelectAll();
620 m_pEdit->SetFocus();
621 SetPopup(FALSE);
622 return;
623 }
624 }
625 }
626
627 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
628 }
629
630 FX_BOOL CPWL_ComboBox::IsPopup() const {
631 return m_bPopup;
632 }
633
634 void CPWL_ComboBox::SetSelectText() {
635 CFX_WideString swText = m_pList->GetText();
636 m_pEdit->SelectAll();
637 m_pEdit->ReplaceSel(m_pList->GetText().c_str());
638 m_pEdit->SelectAll();
639
640 m_nSelectItem = m_pList->GetCurSel();
641 }
642
643 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) {
644 m_pFillerNotify = pNotify;
645
646 if (m_pEdit)
647 m_pEdit->SetFillerNotify(pNotify);
648
649 if (m_pList)
650 m_pList->SetFillerNotify(pNotify);
651 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_Caret.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Edit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698