| 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_CORE_CFWL_LISTBOX_H_ | |
| 8 #define XFA_FWL_CORE_CFWL_LISTBOX_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "xfa/fwl/core/cfwl_edit.h" | |
| 14 #include "xfa/fwl/core/cfwl_event.h" | |
| 15 #include "xfa/fwl/core/cfwl_listbox.h" | |
| 16 #include "xfa/fwl/core/cfwl_listitem.h" | |
| 17 #include "xfa/fwl/core/cfwl_widget.h" | |
| 18 #include "xfa/fwl/core/cfwl_widgetproperties.h" | |
| 19 | |
| 20 #define FWL_STYLEEXT_LTB_MultiSelection (1L << 0) | |
| 21 #define FWL_STYLEEXT_LTB_ShowScrollBarAlaways (1L << 2) | |
| 22 #define FWL_STYLEEXT_LTB_MultiColumn (1L << 3) | |
| 23 #define FWL_STYLEEXT_LTB_LeftAlign (0L << 4) | |
| 24 #define FWL_STYLEEXT_LTB_CenterAlign (1L << 4) | |
| 25 #define FWL_STYLEEXT_LTB_RightAlign (2L << 4) | |
| 26 #define FWL_STYLEEXT_LTB_MultiLine (1L << 6) | |
| 27 #define FWL_STYLEEXT_LTB_OwnerDraw (1L << 7) | |
| 28 #define FWL_STYLEEXT_LTB_Icon (1L << 8) | |
| 29 #define FWL_STYLEEXT_LTB_Check (1L << 9) | |
| 30 #define FWL_STYLEEXT_LTB_AlignMask (3L << 4) | |
| 31 #define FWL_STYLEEXT_LTB_ShowScrollBarFocus (1L << 10) | |
| 32 #define FWL_ITEMSTATE_LTB_Selected (1L << 0) | |
| 33 #define FWL_ITEMSTATE_LTB_Focused (1L << 1) | |
| 34 #define FWL_ITEMSTATE_LTB_Checked (1L << 2) | |
| 35 | |
| 36 class CFWL_MsgKillFocus; | |
| 37 class CFWL_MsgMouse; | |
| 38 class CFWL_MsgMouseWheel; | |
| 39 class CFX_DIBitmap; | |
| 40 | |
| 41 class CFWL_ListBox : public CFWL_Widget { | |
| 42 public: | |
| 43 explicit CFWL_ListBox(const CFWL_App* pApp, | |
| 44 std::unique_ptr<CFWL_WidgetProperties> properties, | |
| 45 CFWL_Widget* pOuter); | |
| 46 ~CFWL_ListBox() override; | |
| 47 | |
| 48 // CFWL_Widget | |
| 49 FWL_Type GetClassID() const override; | |
| 50 void Update() override; | |
| 51 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | |
| 52 void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; | |
| 53 void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; | |
| 54 void OnProcessMessage(CFWL_Message* pMessage) override; | |
| 55 void OnProcessEvent(CFWL_Event* pEvent) override; | |
| 56 void OnDrawWidget(CFX_Graphics* pGraphics, | |
| 57 const CFX_Matrix* pMatrix) override; | |
| 58 | |
| 59 int32_t CountItems(const CFWL_Widget* pWidget) const; | |
| 60 CFWL_ListItem* GetItem(const CFWL_Widget* pWidget, int32_t nIndex) const; | |
| 61 int32_t GetItemIndex(CFWL_Widget* pWidget, CFWL_ListItem* pItem); | |
| 62 uint32_t GetItemStyles(CFWL_Widget* pWidget, CFWL_ListItem* pItem); | |
| 63 uint32_t GetItemStates(CFWL_ListItem* pItem); | |
| 64 CFX_WideString GetItemText(CFWL_Widget* pWidget, CFWL_ListItem* pItem); | |
| 65 void GetItemRect(CFWL_Widget* pWidget, | |
| 66 CFWL_ListItem* pItem, | |
| 67 CFX_RectF& rtItem); | |
| 68 void* GetItemData(CFWL_Widget* pWidget, CFWL_ListItem* pItem); | |
| 69 void SetItemStyles(CFWL_Widget* pWidget, | |
| 70 CFWL_ListItem* pItem, | |
| 71 uint32_t dwStyle); | |
| 72 void SetItemRect(CFWL_Widget* pWidget, | |
| 73 CFWL_ListItem* pItem, | |
| 74 const CFX_RectF& rtItem); | |
| 75 CFX_DIBitmap* GetItemIcon(CFWL_Widget* pWidget, CFWL_ListItem* pItem); | |
| 76 void GetItemCheckRect(CFWL_Widget* pWidget, | |
| 77 CFWL_ListItem* pItem, | |
| 78 CFX_RectF& rtCheck); | |
| 79 void SetItemCheckRect(CFWL_Widget* pWidget, | |
| 80 CFWL_ListItem* pItem, | |
| 81 const CFX_RectF& rtCheck); | |
| 82 uint32_t GetItemCheckState(CFWL_Widget* pWidget, CFWL_ListItem* pItem); | |
| 83 void SetItemCheckState(CFWL_Widget* pWidget, | |
| 84 CFWL_ListItem* pItem, | |
| 85 uint32_t dwCheckState); | |
| 86 CFWL_ListItem* AddString(const CFX_WideStringC& wsAdd); | |
| 87 bool RemoveAt(int32_t iIndex); | |
| 88 bool DeleteString(CFWL_ListItem* pItem); | |
| 89 void DeleteAll(); | |
| 90 | |
| 91 int32_t CountSelItems(); | |
| 92 CFWL_ListItem* GetSelItem(int32_t nIndexSel); | |
| 93 int32_t GetSelIndex(int32_t nIndex); | |
| 94 void SetSelItem(CFWL_ListItem* hItem, bool bSelect); | |
| 95 CFX_WideString GetDataProviderItemText(CFWL_ListItem* hItem); | |
| 96 | |
| 97 FX_FLOAT GetItemHeight() const { return m_fItemHeight; } | |
| 98 FX_FLOAT CalcItemHeight(); | |
| 99 | |
| 100 protected: | |
| 101 CFWL_ListItem* GetListItem(CFWL_ListItem* hItem, uint32_t dwKeyCode); | |
| 102 void SetSelection(CFWL_ListItem* hStart, CFWL_ListItem* hEnd, bool bSelected); | |
| 103 CFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); | |
| 104 bool ScrollToVisible(CFWL_ListItem* hItem); | |
| 105 void InitVerticalScrollBar(); | |
| 106 void InitHorizontalScrollBar(); | |
| 107 bool IsShowScrollBar(bool bVert); | |
| 108 CFWL_ScrollBar* GetVertScrollBar() const { return m_pVertScrollBar.get(); } | |
| 109 const CFX_RectF& GetRTClient() const { return m_rtClient; } | |
| 110 | |
| 111 private: | |
| 112 void SetSelectionDirect(CFWL_ListItem* hItem, bool bSelect); | |
| 113 bool IsMultiSelection() const; | |
| 114 bool IsItemSelected(CFWL_ListItem* hItem); | |
| 115 void ClearSelection(); | |
| 116 void SelectAll(); | |
| 117 CFWL_ListItem* GetFocusedItem(); | |
| 118 void SetFocusItem(CFWL_ListItem* hItem); | |
| 119 bool GetItemCheckRectInternal(CFWL_ListItem* hItem, CFX_RectF& rtCheck); | |
| 120 bool SetItemChecked(CFWL_ListItem* hItem, bool bChecked); | |
| 121 bool GetItemChecked(CFWL_ListItem* hItem); | |
| 122 void DrawBkground(CFX_Graphics* pGraphics, | |
| 123 IFWL_ThemeProvider* pTheme, | |
| 124 const CFX_Matrix* pMatrix); | |
| 125 void DrawItems(CFX_Graphics* pGraphics, | |
| 126 IFWL_ThemeProvider* pTheme, | |
| 127 const CFX_Matrix* pMatrix); | |
| 128 void DrawItem(CFX_Graphics* pGraphics, | |
| 129 IFWL_ThemeProvider* pTheme, | |
| 130 CFWL_ListItem* hItem, | |
| 131 int32_t Index, | |
| 132 const CFX_RectF& rtItem, | |
| 133 const CFX_Matrix* pMatrix); | |
| 134 void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); | |
| 135 CFX_SizeF CalcSize(bool bAutoSize); | |
| 136 void GetItemSize(CFX_SizeF& size, | |
| 137 CFWL_ListItem* hItem, | |
| 138 FX_FLOAT fWidth, | |
| 139 FX_FLOAT fHeight, | |
| 140 bool bAutoSize); | |
| 141 FX_FLOAT GetMaxTextWidth(); | |
| 142 FX_FLOAT GetScrollWidth(); | |
| 143 | |
| 144 void OnFocusChanged(CFWL_Message* pMsg, bool bSet); | |
| 145 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
| 146 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
| 147 void OnMouseWheel(CFWL_MsgMouseWheel* pMsg); | |
| 148 void OnKeyDown(CFWL_MsgKey* pMsg); | |
| 149 void OnVK(CFWL_ListItem* hItem, bool bShift, bool bCtrl); | |
| 150 bool OnScroll(CFWL_ScrollBar* pScrollBar, | |
| 151 CFWL_EvtScroll::Code dwCode, | |
| 152 FX_FLOAT fPos); | |
| 153 | |
| 154 CFX_RectF m_rtClient; | |
| 155 CFX_RectF m_rtStatic; | |
| 156 CFX_RectF m_rtConent; | |
| 157 std::unique_ptr<CFWL_ScrollBar> m_pHorzScrollBar; | |
| 158 std::unique_ptr<CFWL_ScrollBar> m_pVertScrollBar; | |
| 159 uint32_t m_dwTTOStyles; | |
| 160 int32_t m_iTTOAligns; | |
| 161 CFWL_ListItem* m_hAnchor; | |
| 162 FX_FLOAT m_fItemHeight; | |
| 163 FX_FLOAT m_fScorllBarWidth; | |
| 164 bool m_bLButtonDown; | |
| 165 IFWL_ThemeProvider* m_pScrollBarTP; | |
| 166 std::vector<std::unique_ptr<CFWL_ListItem>> m_ItemArray; | |
| 167 }; | |
| 168 | |
| 169 #endif // XFA_FWL_CORE_CFWL_LISTBOX_H_ | |
| OLD | NEW |