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_INCLUDE_PDFWINDOW_PWL_LISTBOX_H_ 8 #define FPDFSDK_INCLUDE_PDFWINDOW_PWL_LISTBOX_H_ 9 10 #include "PWL_Wnd.h" 11 #include "fpdfsdk/include/fxedit/fx_edit.h" 12 13 class CPDF_ListCtrl; 14 class CPWL_List_Notify; 15 class CPWL_ListBox; 16 class IPWL_Filler_Notify; 17 18 class CPWL_List_Notify : public IFX_List_Notify { 19 public: 20 CPWL_List_Notify(CPWL_ListBox* pList); 21 ~CPWL_List_Notify() override; 22 23 // IFX_List_Notify IOnSetScrollInfoX(FX_FLOAT fPlateMin,FX_FLOAT fPlateMax,FX_FLOAT fContentMin,FX_FLOAT fContentMax,FX_FLOAT fSmallStep,FX_FLOAT fBigStep)24 void IOnSetScrollInfoX(FX_FLOAT fPlateMin, 25 FX_FLOAT fPlateMax, 26 FX_FLOAT fContentMin, 27 FX_FLOAT fContentMax, 28 FX_FLOAT fSmallStep, 29 FX_FLOAT fBigStep) override {} 30 void IOnSetScrollInfoY(FX_FLOAT fPlateMin, 31 FX_FLOAT fPlateMax, 32 FX_FLOAT fContentMin, 33 FX_FLOAT fContentMax, 34 FX_FLOAT fSmallStep, 35 FX_FLOAT fBigStep) override; IOnSetScrollPosX(FX_FLOAT fx)36 void IOnSetScrollPosX(FX_FLOAT fx) override {} 37 void IOnSetScrollPosY(FX_FLOAT fy) override; 38 void IOnInvalidateRect(CPDF_Rect* pRect) override; 39 40 void IOnSetCaret(FX_BOOL bVisible, 41 const CPDF_Point& ptHead, 42 const CPDF_Point& ptFoot, 43 const CPVT_WordPlace& place); 44 void IOnCaretChange(const CPVT_SecProps& secProps, 45 const CPVT_WordProps& wordProps); 46 47 private: 48 CPWL_ListBox* m_pList; 49 }; 50 51 class CPWL_ListBox : public CPWL_Wnd { 52 public: 53 CPWL_ListBox(); 54 ~CPWL_ListBox() override; 55 56 // CPWL_Wnd 57 CFX_ByteString GetClassName() const override; 58 void OnCreated() override; 59 void OnDestroy() override; 60 void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override; 61 void DrawThisAppearance(CFX_RenderDevice* pDevice, 62 CFX_Matrix* pUser2Device) override; 63 FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) override; 64 FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag) override; 65 FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) override; 66 FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) override; 67 FX_BOOL OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag) override; 68 FX_BOOL OnMouseWheel(short zDelta, 69 const CPDF_Point& point, 70 FX_DWORD nFlag) override; 71 void KillFocus() override; 72 void OnNotify(CPWL_Wnd* pWnd, 73 FX_DWORD msg, 74 intptr_t wParam = 0, 75 intptr_t lParam = 0) override; 76 void RePosChildWnd() override; 77 CPDF_Rect GetFocusRect() const override; 78 void SetFontSize(FX_FLOAT fFontSize) override; 79 FX_FLOAT GetFontSize() const override; 80 81 virtual CFX_WideString GetText() const; 82 83 void OnNotifySelChanged(FX_BOOL bKeyDown, FX_BOOL& bExit, FX_DWORD nFlag); 84 85 void AddString(const FX_WCHAR* string); 86 void SetTopVisibleIndex(int32_t nItemIndex); 87 void ScrollToListItem(int32_t nItemIndex); 88 void ResetContent(); 89 void Reset(); 90 void Select(int32_t nItemIndex); 91 void SetCaret(int32_t nItemIndex); 92 void SetHoverSel(FX_BOOL bHoverSel); 93 94 int32_t GetCount() const; 95 FX_BOOL IsMultipleSel() const; 96 int32_t GetCaretIndex() const; 97 int32_t GetCurSel() const; 98 FX_BOOL IsItemSelected(int32_t nItemIndex) const; 99 int32_t GetTopVisibleIndex() const; 100 int32_t FindNext(int32_t nIndex, FX_WCHAR nChar) const; 101 CPDF_Rect GetContentRect() const; 102 FX_FLOAT GetFirstHeight() const; 103 CPDF_Rect GetListRect() const; 104 SetFillerNotify(IPWL_Filler_Notify * pNotify)105 void SetFillerNotify(IPWL_Filler_Notify* pNotify) { 106 m_pFillerNotify = pNotify; 107 } 108 109 protected: 110 IFX_List* m_pList; 111 CPWL_List_Notify* m_pListNotify; 112 FX_BOOL m_bMouseDown; 113 FX_BOOL m_bHoverSel; 114 IPWL_Filler_Notify* m_pFillerNotify; 115 116 public: AttachFFLData(void * pData)117 void AttachFFLData(void* pData) { m_pFormFiller = pData; } 118 119 private: 120 void* m_pFormFiller; 121 }; 122 123 #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_LISTBOX_H_ 124