| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef XFA_FWL_CORE_IFWL_LISTBOX_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_LISTBOX_H_ |
| 8 #define XFA_FWL_CORE_IFWL_LISTBOX_H_ | 8 #define XFA_FWL_CORE_IFWL_LISTBOX_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 CFX_RectF m_rect;) | 49 CFX_RectF m_rect;) |
| 50 | 50 |
| 51 class IFWL_ListItem {}; | 51 class IFWL_ListItem {}; |
| 52 | 52 |
| 53 class IFWL_ListBoxDP : public IFWL_DataProvider { | 53 class IFWL_ListBoxDP : public IFWL_DataProvider { |
| 54 public: | 54 public: |
| 55 virtual int32_t CountItems(const IFWL_Widget* pWidget) = 0; | 55 virtual int32_t CountItems(const IFWL_Widget* pWidget) = 0; |
| 56 virtual IFWL_ListItem* GetItem(const IFWL_Widget* pWidget, | 56 virtual IFWL_ListItem* GetItem(const IFWL_Widget* pWidget, |
| 57 int32_t nIndex) = 0; | 57 int32_t nIndex) = 0; |
| 58 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0; | 58 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0; |
| 59 virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget, | 59 virtual bool SetItemIndex(IFWL_Widget* pWidget, |
| 60 IFWL_ListItem* pItem, | 60 IFWL_ListItem* pItem, |
| 61 int32_t nIndex) = 0; | 61 int32_t nIndex) = 0; |
| 62 virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, | 62 virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, |
| 63 IFWL_ListItem* pItem) = 0; | 63 IFWL_ListItem* pItem) = 0; |
| 64 virtual FWL_Error GetItemText(IFWL_Widget* pWidget, | 64 virtual FWL_Error GetItemText(IFWL_Widget* pWidget, |
| 65 IFWL_ListItem* pItem, | 65 IFWL_ListItem* pItem, |
| 66 CFX_WideString& wsText) = 0; | 66 CFX_WideString& wsText) = 0; |
| 67 virtual FWL_Error GetItemRect(IFWL_Widget* pWidget, | 67 virtual FWL_Error GetItemRect(IFWL_Widget* pWidget, |
| 68 IFWL_ListItem* pItem, | 68 IFWL_ListItem* pItem, |
| 69 CFX_RectF& rtItem) = 0; | 69 CFX_RectF& rtItem) = 0; |
| 70 virtual void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0; | 70 virtual void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0; |
| 71 virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget, | 71 virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 | 101 |
| 102 class IFWL_ListBox : public IFWL_Widget { | 102 class IFWL_ListBox : public IFWL_Widget { |
| 103 public: | 103 public: |
| 104 IFWL_ListBox(const IFWL_App* app, | 104 IFWL_ListBox(const IFWL_App* app, |
| 105 const CFWL_WidgetImpProperties& properties, | 105 const CFWL_WidgetImpProperties& properties, |
| 106 IFWL_Widget* pOuter); | 106 IFWL_Widget* pOuter); |
| 107 ~IFWL_ListBox() override; | 107 ~IFWL_ListBox() override; |
| 108 | 108 |
| 109 // IFWL_Widget | 109 // IFWL_Widget |
| 110 FWL_Type GetClassID() const override; | 110 FWL_Type GetClassID() const override; |
| 111 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | 111 FWL_Error GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; |
| 112 FWL_Error Update() override; | 112 FWL_Error Update() override; |
| 113 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | 113 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; |
| 114 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | 114 FWL_Error DrawWidget(CFX_Graphics* pGraphics, |
| 115 const CFX_Matrix* pMatrix = nullptr) override; | 115 const CFX_Matrix* pMatrix = nullptr) override; |
| 116 FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; | 116 FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; |
| 117 void OnProcessMessage(CFWL_Message* pMessage) override; | 117 void OnProcessMessage(CFWL_Message* pMessage) override; |
| 118 void OnProcessEvent(CFWL_Event* pEvent) override; | 118 void OnProcessEvent(CFWL_Event* pEvent) override; |
| 119 void OnDrawWidget(CFX_Graphics* pGraphics, | 119 void OnDrawWidget(CFX_Graphics* pGraphics, |
| 120 const CFX_Matrix* pMatrix) override; | 120 const CFX_Matrix* pMatrix) override; |
| 121 | 121 |
| 122 int32_t CountSelItems(); | 122 int32_t CountSelItems(); |
| 123 IFWL_ListItem* GetSelItem(int32_t nIndexSel); | 123 IFWL_ListItem* GetSelItem(int32_t nIndexSel); |
| 124 int32_t GetSelIndex(int32_t nIndex); | 124 int32_t GetSelIndex(int32_t nIndex); |
| 125 FWL_Error SetSelItem(IFWL_ListItem* hItem, FX_BOOL bSelect = TRUE); | 125 FWL_Error SetSelItem(IFWL_ListItem* hItem, bool bSelect = true); |
| 126 FWL_Error GetItemText(IFWL_ListItem* hItem, CFX_WideString& wsText); | 126 FWL_Error GetItemText(IFWL_ListItem* hItem, CFX_WideString& wsText); |
| 127 FWL_Error GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE); | 127 FWL_Error GetScrollPos(FX_FLOAT& fPos, bool bVert = true); |
| 128 FWL_Error* Sort(IFWL_ListBoxCompare* pCom); | 128 FWL_Error* Sort(IFWL_ListBoxCompare* pCom); |
| 129 | 129 |
| 130 protected: | 130 protected: |
| 131 friend class CFWL_ListBoxImpDelegate; | 131 friend class CFWL_ListBoxImpDelegate; |
| 132 | 132 |
| 133 IFWL_ListItem* GetItem(IFWL_ListItem* hItem, uint32_t dwKeyCode); | 133 IFWL_ListItem* GetItem(IFWL_ListItem* hItem, uint32_t dwKeyCode); |
| 134 void SetSelection(IFWL_ListItem* hStart, | 134 void SetSelection(IFWL_ListItem* hStart, IFWL_ListItem* hEnd, bool bSelected); |
| 135 IFWL_ListItem* hEnd, | 135 void SetSelectionDirect(IFWL_ListItem* hItem, bool bSelect); |
| 136 FX_BOOL bSelected); | 136 bool IsItemSelected(IFWL_ListItem* hItem); |
| 137 void SetSelectionDirect(IFWL_ListItem* hItem, FX_BOOL bSelect); | |
| 138 FX_BOOL IsItemSelected(IFWL_ListItem* hItem); | |
| 139 void ClearSelection(); | 137 void ClearSelection(); |
| 140 void SelectAll(); | 138 void SelectAll(); |
| 141 IFWL_ListItem* GetFocusedItem(); | 139 IFWL_ListItem* GetFocusedItem(); |
| 142 void SetFocusItem(IFWL_ListItem* hItem); | 140 void SetFocusItem(IFWL_ListItem* hItem); |
| 143 IFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); | 141 IFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); |
| 144 FX_BOOL GetItemCheckRect(IFWL_ListItem* hItem, CFX_RectF& rtCheck); | 142 bool GetItemCheckRect(IFWL_ListItem* hItem, CFX_RectF& rtCheck); |
| 145 FX_BOOL SetItemChecked(IFWL_ListItem* hItem, FX_BOOL bChecked); | 143 bool SetItemChecked(IFWL_ListItem* hItem, bool bChecked); |
| 146 FX_BOOL GetItemChecked(IFWL_ListItem* hItem); | 144 bool GetItemChecked(IFWL_ListItem* hItem); |
| 147 FX_BOOL ScrollToVisible(IFWL_ListItem* hItem); | 145 bool ScrollToVisible(IFWL_ListItem* hItem); |
| 148 void DrawBkground(CFX_Graphics* pGraphics, | 146 void DrawBkground(CFX_Graphics* pGraphics, |
| 149 IFWL_ThemeProvider* pTheme, | 147 IFWL_ThemeProvider* pTheme, |
| 150 const CFX_Matrix* pMatrix = nullptr); | 148 const CFX_Matrix* pMatrix = nullptr); |
| 151 void DrawItems(CFX_Graphics* pGraphics, | 149 void DrawItems(CFX_Graphics* pGraphics, |
| 152 IFWL_ThemeProvider* pTheme, | 150 IFWL_ThemeProvider* pTheme, |
| 153 const CFX_Matrix* pMatrix = nullptr); | 151 const CFX_Matrix* pMatrix = nullptr); |
| 154 void DrawItem(CFX_Graphics* pGraphics, | 152 void DrawItem(CFX_Graphics* pGraphics, |
| 155 IFWL_ThemeProvider* pTheme, | 153 IFWL_ThemeProvider* pTheme, |
| 156 IFWL_ListItem* hItem, | 154 IFWL_ListItem* hItem, |
| 157 int32_t Index, | 155 int32_t Index, |
| 158 const CFX_RectF& rtItem, | 156 const CFX_RectF& rtItem, |
| 159 const CFX_Matrix* pMatrix = nullptr); | 157 const CFX_Matrix* pMatrix = nullptr); |
| 160 void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); | 158 void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); |
| 161 CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE); | 159 CFX_SizeF CalcSize(bool bAutoSize = false); |
| 162 void GetItemSize(CFX_SizeF& size, | 160 void GetItemSize(CFX_SizeF& size, |
| 163 IFWL_ListItem* hItem, | 161 IFWL_ListItem* hItem, |
| 164 FX_FLOAT fWidth, | 162 FX_FLOAT fWidth, |
| 165 FX_FLOAT fHeight, | 163 FX_FLOAT fHeight, |
| 166 FX_BOOL bAutoSize = FALSE); | 164 bool bAutoSize = false); |
| 167 FX_FLOAT GetMaxTextWidth(); | 165 FX_FLOAT GetMaxTextWidth(); |
| 168 FX_FLOAT GetScrollWidth(); | 166 FX_FLOAT GetScrollWidth(); |
| 169 FX_FLOAT GetItemHeigt(); | 167 FX_FLOAT GetItemHeigt(); |
| 170 void InitScrollBar(FX_BOOL bVert = TRUE); | 168 void InitScrollBar(bool bVert = true); |
| 171 FX_BOOL IsShowScrollBar(FX_BOOL bVert); | 169 bool IsShowScrollBar(bool bVert); |
| 172 void ProcessSelChanged(); | 170 void ProcessSelChanged(); |
| 173 | 171 |
| 174 CFX_RectF m_rtClient; | 172 CFX_RectF m_rtClient; |
| 175 CFX_RectF m_rtStatic; | 173 CFX_RectF m_rtStatic; |
| 176 CFX_RectF m_rtConent; | 174 CFX_RectF m_rtConent; |
| 177 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; | 175 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; |
| 178 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; | 176 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; |
| 179 uint32_t m_dwTTOStyles; | 177 uint32_t m_dwTTOStyles; |
| 180 int32_t m_iTTOAligns; | 178 int32_t m_iTTOAligns; |
| 181 IFWL_ListItem* m_hAnchor; | 179 IFWL_ListItem* m_hAnchor; |
| 182 FX_FLOAT m_fItemHeight; | 180 FX_FLOAT m_fItemHeight; |
| 183 FX_FLOAT m_fScorllBarWidth; | 181 FX_FLOAT m_fScorllBarWidth; |
| 184 FX_BOOL m_bLButtonDown; | 182 bool m_bLButtonDown; |
| 185 IFWL_ThemeProvider* m_pScrollBarTP; | 183 IFWL_ThemeProvider* m_pScrollBarTP; |
| 186 | 184 |
| 187 private: | 185 private: |
| 188 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | 186 void OnFocusChanged(CFWL_Message* pMsg, bool bSet = true); |
| 189 void OnLButtonDown(CFWL_MsgMouse* pMsg); | 187 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
| 190 void OnLButtonUp(CFWL_MsgMouse* pMsg); | 188 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
| 191 void OnMouseWheel(CFWL_MsgMouseWheel* pMsg); | 189 void OnMouseWheel(CFWL_MsgMouseWheel* pMsg); |
| 192 void OnKeyDown(CFWL_MsgKey* pMsg); | 190 void OnKeyDown(CFWL_MsgKey* pMsg); |
| 193 void OnVK(IFWL_ListItem* hItem, FX_BOOL bShift, FX_BOOL bCtrl); | 191 void OnVK(IFWL_ListItem* hItem, bool bShift, bool bCtrl); |
| 194 FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); | 192 bool OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); |
| 195 void DispatchSelChangedEv(); | 193 void DispatchSelChangedEv(); |
| 196 }; | 194 }; |
| 197 | 195 |
| 198 #endif // XFA_FWL_CORE_IFWL_LISTBOX_H_ | 196 #endif // XFA_FWL_CORE_IFWL_LISTBOX_H_ |
| OLD | NEW |