• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The PDFium Authors
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_list_ctrl.h"
14 #include "fpdfsdk/pwl/cpwl_wnd.h"
15 
16 class IPWL_FillerNotify;
17 
18 class CPWL_ListBox : public CPWL_Wnd, public CPWL_ListCtrl::NotifyIface {
19  public:
20   CPWL_ListBox(const CreateParams& cp,
21                std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData);
22   ~CPWL_ListBox() override;
23 
24   // CPWL_Wnd:
25   void OnCreated() override;
26   void OnDestroy() override;
27   void DrawThisAppearance(CFX_RenderDevice* pDevice,
28                           const CFX_Matrix& mtUser2Device) override;
29   bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlag) override;
30   bool OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) override;
31   bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
32                      const CFX_PointF& point) override;
33   bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
34   bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
35   bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlag,
36                     const CFX_PointF& point,
37                     const CFX_Vector& delta) override;
38   WideString GetText() override;
39   void SetScrollInfo(const PWL_SCROLL_INFO& info) override;
40   void SetScrollPosition(float pos) override;
41   void ScrollWindowVertically(float pos) override;
42   bool RePosChildWnd() override;
43   CFX_FloatRect GetFocusRect() const override;
44   void SetFontSize(float fFontSize) override;
45   float GetFontSize() const override;
46 
47   // CPWL_ListCtrl::NotifyIface:
48   void OnSetScrollInfoY(float fPlateMin,
49                         float fPlateMax,
50                         float fContentMin,
51                         float fContentMax,
52                         float fSmallStep,
53                         float fBigStep) override;
54   void OnSetScrollPosY(float fy) override;
55   void OnInvalidateRect(const CFX_FloatRect& pRect) override;
56 
57   bool OnNotifySelectionChanged(bool bKeyDown, Mask<FWL_EVENTFLAG> nFlag);
58 
59   void AddString(const WideString& str);
60   void SetTopVisibleIndex(int32_t nItemIndex);
61   void ScrollToListItem(int32_t nItemIndex);
62 
63   void Select(int32_t nItemIndex);
64   void Deselect(int32_t nItemIndex);
65   void SetCaret(int32_t nItemIndex);
66   void SetHoverSel(bool bHoverSel);
67 
68   int32_t GetCount() const;
69   bool IsMultipleSel() const;
70   int32_t GetCaretIndex() const;
71   int32_t GetCurSel() const;
72   bool IsItemSelected(int32_t nItemIndex) const;
73   int32_t GetTopVisibleIndex() const;
74   CFX_FloatRect GetContentRect() const;
75   float GetFirstHeight() const;
76   CFX_FloatRect GetListRect() const;
77 
78  protected:
79   bool m_bMouseDown = false;
80   bool m_bHoverSel = false;
81   std::unique_ptr<CPWL_ListCtrl> m_pListCtrl;
82 };
83 
84 #endif  // FPDFSDK_PWL_CPWL_LIST_BOX_H_
85