Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: xfa/fwl/core/cfwl_listbox.h

Issue 2524173002: Merge IFWL and CFWL classes. (Closed)
Patch Set: make chrome build happy Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_CFWL_LISTBOX_H_ 7 #ifndef XFA_FWL_CORE_CFWL_LISTBOX_H_
8 #define XFA_FWL_CORE_CFWL_LISTBOX_H_ 8 #define XFA_FWL_CORE_CFWL_LISTBOX_H_
9 9
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 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"
13 #include "xfa/fwl/core/cfwl_listitem.h" 16 #include "xfa/fwl/core/cfwl_listitem.h"
14 #include "xfa/fwl/core/cfwl_widget.h" 17 #include "xfa/fwl/core/cfwl_widget.h"
15 #include "xfa/fwl/core/fwl_error.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;
16 40
17 class CFWL_ListBox : public CFWL_Widget { 41 class CFWL_ListBox : public CFWL_Widget {
18 public: 42 public:
19 explicit CFWL_ListBox(const CFWL_App* pApp); 43 explicit CFWL_ListBox(const CFWL_App* pApp,
44 std::unique_ptr<CFWL_WidgetProperties> properties,
45 CFWL_Widget* pOuter);
20 ~CFWL_ListBox() override; 46 ~CFWL_ListBox() override;
21 47
22 void Initialize(); 48 // CFWL_Widget
49 FWL_Type GetClassID() const override;
50 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override;
51 void Update() override;
52 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
53 void DrawWidget(CFX_Graphics* pGraphics,
54 const CFX_Matrix* pMatrix = nullptr) override;
55 void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
56 void OnProcessMessage(CFWL_Message* pMessage) override;
57 void OnProcessEvent(CFWL_Event* pEvent) override;
58 void OnDrawWidget(CFX_Graphics* pGraphics,
59 const CFX_Matrix* pMatrix) override;
23 60
24 CFWL_ListItem* GetItem(const IFWL_Widget* pWidget, int32_t nIndex) const; 61 int32_t CountItems(const CFWL_Widget* pWidget) const;
25 void GetItemText(IFWL_Widget* pWidget, 62 CFWL_ListItem* GetItem(const CFWL_Widget* pWidget, int32_t nIndex) const;
63 int32_t GetItemIndex(CFWL_Widget* pWidget, CFWL_ListItem* pItem);
64 uint32_t GetItemStyles(CFWL_Widget* pWidget, CFWL_ListItem* pItem);
65 uint32_t GetItemStates(CFWL_ListItem* pItem);
66 void GetItemText(CFWL_Widget* pWidget,
26 CFWL_ListItem* pItem, 67 CFWL_ListItem* pItem,
27 CFX_WideString& wsText); 68 CFX_WideString& wsText);
28 69 void GetItemRect(CFWL_Widget* pWidget,
70 CFWL_ListItem* pItem,
71 CFX_RectF& rtItem);
72 void* GetItemData(CFWL_Widget* pWidget, CFWL_ListItem* pItem);
73 void SetItemStyles(CFWL_Widget* pWidget,
74 CFWL_ListItem* pItem,
75 uint32_t dwStyle);
76 void SetItemRect(CFWL_Widget* pWidget,
77 CFWL_ListItem* pItem,
78 const CFX_RectF& rtItem);
79 CFX_DIBitmap* GetItemIcon(CFWL_Widget* pWidget, CFWL_ListItem* pItem);
80 void GetItemCheckRect(CFWL_Widget* pWidget,
81 CFWL_ListItem* pItem,
82 CFX_RectF& rtCheck);
83 void SetItemCheckRect(CFWL_Widget* pWidget,
84 CFWL_ListItem* pItem,
85 const CFX_RectF& rtCheck);
86 uint32_t GetItemCheckState(CFWL_Widget* pWidget, CFWL_ListItem* pItem);
87 void SetItemCheckState(CFWL_Widget* pWidget,
88 CFWL_ListItem* pItem,
89 uint32_t dwCheckState);
29 CFWL_ListItem* AddString(const CFX_WideStringC& wsAdd, bool bSelect = false); 90 CFWL_ListItem* AddString(const CFX_WideStringC& wsAdd, bool bSelect = false);
91 bool RemoveAt(int32_t iIndex);
30 bool DeleteString(CFWL_ListItem* pItem); 92 bool DeleteString(CFWL_ListItem* pItem);
31 void DeleteAll(); 93 void DeleteAll();
94
32 int32_t CountSelItems(); 95 int32_t CountSelItems();
33 void SetSelItem(CFWL_ListItem* pItem, bool bSelect = true);
34 CFWL_ListItem* GetSelItem(int32_t nIndexSel); 96 CFWL_ListItem* GetSelItem(int32_t nIndexSel);
35 int32_t GetSelIndex(int32_t nIndex); 97 int32_t GetSelIndex(int32_t nIndex);
98 void SetSelItem(CFWL_ListItem* hItem, bool bSelect = true);
99 void GetDataProviderItemText(CFWL_ListItem* hItem, CFX_WideString& wsText);
36 100
37 uint32_t GetItemStates(CFWL_ListItem* pItem); 101 FX_FLOAT GetItemHeight() const { return m_fItemHeight; }
102 FX_FLOAT CalcItemHeight();
103
104 protected:
105 CFWL_ListItem* GetListItem(CFWL_ListItem* hItem, uint32_t dwKeyCode);
106 void SetSelection(CFWL_ListItem* hStart, CFWL_ListItem* hEnd, bool bSelected);
107 CFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
108 bool ScrollToVisible(CFWL_ListItem* hItem);
109 void InitScrollBar(bool bVert = true);
110 bool IsShowScrollBar(bool bVert);
111 CFWL_ScrollBar* GetVertScrollBar() const { return m_pVertScrollBar.get(); }
112 const CFX_RectF& GetRTClient() const { return m_rtClient; }
113
114 private:
115 void SetSelectionDirect(CFWL_ListItem* hItem, bool bSelect);
116 bool IsItemSelected(CFWL_ListItem* hItem);
117 void ClearSelection();
118 void SelectAll();
119 CFWL_ListItem* GetFocusedItem();
120 void SetFocusItem(CFWL_ListItem* hItem);
121 bool GetItemCheckRectInternal(CFWL_ListItem* hItem, CFX_RectF& rtCheck);
122 bool SetItemChecked(CFWL_ListItem* hItem, bool bChecked);
123 bool GetItemChecked(CFWL_ListItem* hItem);
124 void DrawBkground(CFX_Graphics* pGraphics,
125 IFWL_ThemeProvider* pTheme,
126 const CFX_Matrix* pMatrix = nullptr);
127 void DrawItems(CFX_Graphics* pGraphics,
128 IFWL_ThemeProvider* pTheme,
129 const CFX_Matrix* pMatrix = nullptr);
130 void DrawItem(CFX_Graphics* pGraphics,
131 IFWL_ThemeProvider* pTheme,
132 CFWL_ListItem* hItem,
133 int32_t Index,
134 const CFX_RectF& rtItem,
135 const CFX_Matrix* pMatrix = nullptr);
136 void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme);
137 CFX_SizeF CalcSize(bool bAutoSize = false);
138 void GetItemSize(CFX_SizeF& size,
139 CFWL_ListItem* hItem,
140 FX_FLOAT fWidth,
141 FX_FLOAT fHeight,
142 bool bAutoSize = false);
143 FX_FLOAT GetMaxTextWidth();
144 FX_FLOAT GetScrollWidth();
145
146 void OnFocusChanged(CFWL_Message* pMsg, bool bSet = true);
147 void OnLButtonDown(CFWL_MsgMouse* pMsg);
148 void OnLButtonUp(CFWL_MsgMouse* pMsg);
149 void OnMouseWheel(CFWL_MsgMouseWheel* pMsg);
150 void OnKeyDown(CFWL_MsgKey* pMsg);
151 void OnVK(CFWL_ListItem* hItem, bool bShift, bool bCtrl);
152 bool OnScroll(CFWL_ScrollBar* pScrollBar, FWL_SCBCODE dwCode, 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;
38 }; 167 };
39 168
40 #endif // XFA_FWL_CORE_CFWL_LISTBOX_H_ 169 #endif // XFA_FWL_CORE_CFWL_LISTBOX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698