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