• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FPDFSDK_PWL_CPWL_LIST_BOX_H_
8 #define FPDFSDK_PWL_CPWL_LIST_BOX_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/unowned_ptr.h"
13 #include "fpdfsdk/pwl/cpwl_wnd.h"
14 
15 class CPWL_ListCtrl;
16 class CPWL_List_Notify;
17 class CPWL_ListBox;
18 class IPWL_Filler_Notify;
19 struct CPVT_WordPlace;
20 
21 class CPWL_List_Notify {
22  public:
23   explicit CPWL_List_Notify(CPWL_ListBox* pList);
24   ~CPWL_List_Notify();
25 
26   void IOnSetScrollInfoY(float fPlateMin,
27                          float fPlateMax,
28                          float fContentMin,
29                          float fContentMax,
30                          float fSmallStep,
31                          float fBigStep);
32   void IOnSetScrollPosY(float fy);
33   void IOnInvalidateRect(CFX_FloatRect* pRect);
34 
35  private:
36   UnownedPtr<CPWL_ListBox> m_pList;
37 };
38 
39 class CPWL_ListBox : public CPWL_Wnd {
40  public:
41   CPWL_ListBox();
42   ~CPWL_ListBox() override;
43 
44   // CPWL_Wnd
45   ByteString GetClassName() const override;
46   void OnCreated() override;
47   void OnDestroy() override;
48   void DrawThisAppearance(CFX_RenderDevice* pDevice,
49                           const CFX_Matrix& mtUser2Device) override;
50   bool OnKeyDown(uint16_t nChar, uint32_t nFlag) override;
51   bool OnChar(uint16_t nChar, uint32_t nFlag) override;
52   bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override;
53   bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) override;
54   bool OnMouseMove(const CFX_PointF& point, uint32_t nFlag) override;
55   bool OnMouseWheel(short zDelta,
56                     const CFX_PointF& point,
57                     uint32_t nFlag) override;
58   void KillFocus() override;
59   void SetScrollInfo(const PWL_SCROLL_INFO& info) override;
60   void SetScrollPosition(float pos) override;
61   void ScrollWindowVertically(float pos) override;
62   bool RePosChildWnd() override;
63   CFX_FloatRect GetFocusRect() const override;
64   void SetFontSize(float fFontSize) override;
65   float GetFontSize() const override;
66 
67   virtual WideString GetText() const;
68 
69   bool OnNotifySelectionChanged(bool bKeyDown, uint32_t nFlag);
70 
71   void AddString(const WideString& str);
72   void SetTopVisibleIndex(int32_t nItemIndex);
73   void ScrollToListItem(int32_t nItemIndex);
74   void ResetContent();
75   void Reset();
76   void Select(int32_t nItemIndex);
77   void SetCaret(int32_t nItemIndex);
78   void SetHoverSel(bool bHoverSel);
79 
80   int32_t GetCount() const;
81   bool IsMultipleSel() const;
82   int32_t GetCaretIndex() const;
83   int32_t GetCurSel() const;
84   bool IsItemSelected(int32_t nItemIndex) const;
85   int32_t GetTopVisibleIndex() const;
86   int32_t FindNext(int32_t nIndex, wchar_t nChar) const;
87   CFX_FloatRect GetContentRect() const;
88   float GetFirstHeight() const;
89   CFX_FloatRect GetListRect() const;
90 
SetFillerNotify(IPWL_Filler_Notify * pNotify)91   void SetFillerNotify(IPWL_Filler_Notify* pNotify) {
92     m_pFillerNotify = pNotify;
93   }
94 
AttachFFLData(CFFL_FormFiller * pData)95   void AttachFFLData(CFFL_FormFiller* pData) { m_pFormFiller = pData; }
96 
97  protected:
98   std::unique_ptr<CPWL_ListCtrl> m_pList;
99   std::unique_ptr<CPWL_List_Notify> m_pListNotify;
100   bool m_bMouseDown;
101   bool m_bHoverSel;
102   UnownedPtr<IPWL_Filler_Notify> m_pFillerNotify;
103 
104  private:
105   UnownedPtr<CFFL_FormFiller> m_pFormFiller;
106 };
107 
108 #endif  // FPDFSDK_PWL_CPWL_LIST_BOX_H_
109