| OLD | NEW |
| (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 #ifndef XFA_FWL_BASEWIDGET_FWL_LISTBOXIMP_H_ | |
| 8 #define XFA_FWL_BASEWIDGET_FWL_LISTBOXIMP_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "xfa/fwl/basewidget/ifwl_combobox.h" | |
| 13 #include "xfa/fwl/basewidget/ifwl_edit.h" | |
| 14 #include "xfa/fwl/basewidget/ifwl_listbox.h" | |
| 15 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" | |
| 16 #include "xfa/fwl/core/fwl_widgetimp.h" | |
| 17 | |
| 18 class CFWL_ListBoxImpDelegate; | |
| 19 class CFWL_MsgKillFocus; | |
| 20 class CFWL_MsgMouse; | |
| 21 class CFWL_MsgMouseWheel; | |
| 22 | |
| 23 class CFWL_ListBoxImp : public CFWL_WidgetImp { | |
| 24 public: | |
| 25 CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, | |
| 26 IFWL_Widget* pOuter); | |
| 27 ~CFWL_ListBoxImp() override; | |
| 28 | |
| 29 // CFWL_WidgetImp | |
| 30 FWL_Error GetClassName(CFX_WideString& wsClass) const override; | |
| 31 FWL_Type GetClassID() const override; | |
| 32 FWL_Error Initialize() override; | |
| 33 FWL_Error Finalize() override; | |
| 34 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | |
| 35 FWL_Error Update() override; | |
| 36 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | |
| 37 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | |
| 38 const CFX_Matrix* pMatrix = nullptr) override; | |
| 39 FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; | |
| 40 | |
| 41 int32_t CountSelItems(); | |
| 42 IFWL_ListItem* GetSelItem(int32_t nIndexSel); | |
| 43 int32_t GetSelIndex(int32_t nIndex); | |
| 44 FWL_Error SetSelItem(IFWL_ListItem* hItem, FX_BOOL bSelect = TRUE); | |
| 45 FWL_Error GetItemText(IFWL_ListItem* hItem, CFX_WideString& wsText); | |
| 46 FWL_Error GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE); | |
| 47 FWL_Error* Sort(IFWL_ListBoxCompare* pCom); | |
| 48 | |
| 49 protected: | |
| 50 friend class CFWL_ListBoxImpDelegate; | |
| 51 | |
| 52 IFWL_ListItem* GetItem(IFWL_ListItem* hItem, uint32_t dwKeyCode); | |
| 53 void SetSelection(IFWL_ListItem* hStart, | |
| 54 IFWL_ListItem* hEnd, | |
| 55 FX_BOOL bSelected); | |
| 56 void SetSelectionDirect(IFWL_ListItem* hItem, FX_BOOL bSelect); | |
| 57 FX_BOOL IsItemSelected(IFWL_ListItem* hItem); | |
| 58 void ClearSelection(); | |
| 59 void SelectAll(); | |
| 60 IFWL_ListItem* GetFocusedItem(); | |
| 61 void SetFocusItem(IFWL_ListItem* hItem); | |
| 62 IFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); | |
| 63 FX_BOOL GetItemCheckRect(IFWL_ListItem* hItem, CFX_RectF& rtCheck); | |
| 64 FX_BOOL SetItemChecked(IFWL_ListItem* hItem, FX_BOOL bChecked); | |
| 65 FX_BOOL GetItemChecked(IFWL_ListItem* hItem); | |
| 66 FX_BOOL ScrollToVisible(IFWL_ListItem* hItem); | |
| 67 void DrawBkground(CFX_Graphics* pGraphics, | |
| 68 IFWL_ThemeProvider* pTheme, | |
| 69 const CFX_Matrix* pMatrix = nullptr); | |
| 70 void DrawItems(CFX_Graphics* pGraphics, | |
| 71 IFWL_ThemeProvider* pTheme, | |
| 72 const CFX_Matrix* pMatrix = nullptr); | |
| 73 void DrawItem(CFX_Graphics* pGraphics, | |
| 74 IFWL_ThemeProvider* pTheme, | |
| 75 IFWL_ListItem* hItem, | |
| 76 int32_t Index, | |
| 77 const CFX_RectF& rtItem, | |
| 78 const CFX_Matrix* pMatrix = nullptr); | |
| 79 void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); | |
| 80 CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE); | |
| 81 void GetItemSize(CFX_SizeF& size, | |
| 82 IFWL_ListItem* hItem, | |
| 83 FX_FLOAT fWidth, | |
| 84 FX_FLOAT fHeight, | |
| 85 FX_BOOL bAutoSize = FALSE); | |
| 86 FX_FLOAT GetMaxTextWidth(); | |
| 87 FX_FLOAT GetScrollWidth(); | |
| 88 FX_FLOAT GetItemHeigt(); | |
| 89 void InitScrollBar(FX_BOOL bVert = TRUE); | |
| 90 FX_BOOL IsShowScrollBar(FX_BOOL bVert); | |
| 91 void ProcessSelChanged(); | |
| 92 | |
| 93 CFX_RectF m_rtClient; | |
| 94 CFX_RectF m_rtStatic; | |
| 95 CFX_RectF m_rtConent; | |
| 96 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; | |
| 97 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; | |
| 98 uint32_t m_dwTTOStyles; | |
| 99 int32_t m_iTTOAligns; | |
| 100 IFWL_ListItem* m_hAnchor; | |
| 101 FX_FLOAT m_fItemHeight; | |
| 102 FX_FLOAT m_fScorllBarWidth; | |
| 103 FX_BOOL m_bLButtonDown; | |
| 104 IFWL_ThemeProvider* m_pScrollBarTP; | |
| 105 }; | |
| 106 class CFWL_ListBoxImpDelegate : public CFWL_WidgetImpDelegate { | |
| 107 public: | |
| 108 CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner); | |
| 109 void OnProcessMessage(CFWL_Message* pMessage) override; | |
| 110 void OnProcessEvent(CFWL_Event* pEvent) override; | |
| 111 void OnDrawWidget(CFX_Graphics* pGraphics, | |
| 112 const CFX_Matrix* pMatrix = nullptr) override; | |
| 113 | |
| 114 protected: | |
| 115 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | |
| 116 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
| 117 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
| 118 void OnMouseWheel(CFWL_MsgMouseWheel* pMsg); | |
| 119 void OnKeyDown(CFWL_MsgKey* pMsg); | |
| 120 void OnVK(IFWL_ListItem* hItem, FX_BOOL bShift, FX_BOOL bCtrl); | |
| 121 FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); | |
| 122 void DispatchSelChangedEv(); | |
| 123 CFWL_ListBoxImp* m_pOwner; | |
| 124 }; | |
| 125 | |
| 126 #endif // XFA_FWL_BASEWIDGET_FWL_LISTBOXIMP_H_ | |
| OLD | NEW |