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

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

Issue 2492563002: Continue IFWL cleanup (Closed)
Patch Set: Rebase to master Created 4 years, 1 month 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
« no previous file with comments | « xfa/fwl/core/ifwl_formproxy.h ('k') | xfa/fwl/core/ifwl_listbox.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 public: 53 public:
54 virtual int32_t CountItems(const IFWL_Widget* pWidget) = 0; 54 virtual int32_t CountItems(const IFWL_Widget* pWidget) = 0;
55 virtual CFWL_ListItem* GetItem(const IFWL_Widget* pWidget, 55 virtual CFWL_ListItem* GetItem(const IFWL_Widget* pWidget,
56 int32_t nIndex) = 0; 56 int32_t nIndex) = 0;
57 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, CFWL_ListItem* pItem) = 0; 57 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, CFWL_ListItem* pItem) = 0;
58 virtual bool SetItemIndex(IFWL_Widget* pWidget, 58 virtual bool SetItemIndex(IFWL_Widget* pWidget,
59 CFWL_ListItem* pItem, 59 CFWL_ListItem* pItem,
60 int32_t nIndex) = 0; 60 int32_t nIndex) = 0;
61 virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, 61 virtual uint32_t GetItemStyles(IFWL_Widget* pWidget,
62 CFWL_ListItem* pItem) = 0; 62 CFWL_ListItem* pItem) = 0;
63 virtual FWL_Error GetItemText(IFWL_Widget* pWidget, 63 virtual void GetItemText(IFWL_Widget* pWidget,
64 CFWL_ListItem* pItem, 64 CFWL_ListItem* pItem,
65 CFX_WideString& wsText) = 0; 65 CFX_WideString& wsText) = 0;
66 virtual FWL_Error GetItemRect(IFWL_Widget* pWidget, 66 virtual void GetItemRect(IFWL_Widget* pWidget,
67 CFWL_ListItem* pItem, 67 CFWL_ListItem* pItem,
68 CFX_RectF& rtItem) = 0; 68 CFX_RectF& rtItem) = 0;
69 virtual void* GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem) = 0; 69 virtual void* GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem) = 0;
70 virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget, 70 virtual void SetItemStyles(IFWL_Widget* pWidget,
71 CFWL_ListItem* pItem, 71 CFWL_ListItem* pItem,
72 uint32_t dwStyle) = 0; 72 uint32_t dwStyle) = 0;
73 virtual FWL_Error SetItemText(IFWL_Widget* pWidget, 73 virtual void SetItemText(IFWL_Widget* pWidget,
74 CFWL_ListItem* pItem, 74 CFWL_ListItem* pItem,
75 const FX_WCHAR* pszText) = 0; 75 const FX_WCHAR* pszText) = 0;
76 virtual FWL_Error SetItemRect(IFWL_Widget* pWidget, 76 virtual void SetItemRect(IFWL_Widget* pWidget,
77 CFWL_ListItem* pItem, 77 CFWL_ListItem* pItem,
78 const CFX_RectF& rtItem) = 0; 78 const CFX_RectF& rtItem) = 0;
79 virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) = 0; 79 virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) = 0;
80 virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, 80 virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget,
81 CFWL_ListItem* pItem) = 0; 81 CFWL_ListItem* pItem) = 0;
82 virtual FWL_Error GetItemCheckRect(IFWL_Widget* pWidget, 82 virtual void GetItemCheckRect(IFWL_Widget* pWidget,
83 CFWL_ListItem* pItem, 83 CFWL_ListItem* pItem,
84 CFX_RectF& rtCheck) = 0; 84 CFX_RectF& rtCheck) = 0;
85 virtual FWL_Error SetItemCheckRect(IFWL_Widget* pWidget, 85 virtual void SetItemCheckRect(IFWL_Widget* pWidget,
86 CFWL_ListItem* pItem, 86 CFWL_ListItem* pItem,
87 const CFX_RectF& rtCheck) = 0; 87 const CFX_RectF& rtCheck) = 0;
88 virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget, 88 virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget,
89 CFWL_ListItem* pItem) = 0; 89 CFWL_ListItem* pItem) = 0;
90 virtual FWL_Error SetItemCheckState(IFWL_Widget* pWidget, 90 virtual void SetItemCheckState(IFWL_Widget* pWidget,
91 CFWL_ListItem* pItem, 91 CFWL_ListItem* pItem,
92 uint32_t dwCheckState) = 0; 92 uint32_t dwCheckState) = 0;
93 };
94
95 class IFWL_ListBoxCompare {
96 public:
97 virtual ~IFWL_ListBoxCompare() {}
98 virtual int32_t Compare(CFWL_ListItem* hLeft, CFWL_ListItem* hRight) = 0;
99 }; 93 };
100 94
101 class IFWL_ListBox : public IFWL_Widget { 95 class IFWL_ListBox : public IFWL_Widget {
102 public: 96 public:
103 IFWL_ListBox(const IFWL_App* app, 97 IFWL_ListBox(const IFWL_App* app,
104 std::unique_ptr<CFWL_WidgetProperties> properties, 98 std::unique_ptr<CFWL_WidgetProperties> properties,
105 IFWL_Widget* pOuter); 99 IFWL_Widget* pOuter);
106 ~IFWL_ListBox() override; 100 ~IFWL_ListBox() override;
107 101
108 // IFWL_Widget 102 // IFWL_Widget
109 FWL_Type GetClassID() const override; 103 FWL_Type GetClassID() const override;
110 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; 104 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override;
111 void Update() override; 105 void Update() override;
112 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; 106 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
113 void DrawWidget(CFX_Graphics* pGraphics, 107 void DrawWidget(CFX_Graphics* pGraphics,
114 const CFX_Matrix* pMatrix = nullptr) override; 108 const CFX_Matrix* pMatrix = nullptr) override;
115 void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; 109 void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
116 void OnProcessMessage(CFWL_Message* pMessage) override; 110 void OnProcessMessage(CFWL_Message* pMessage) override;
117 void OnProcessEvent(CFWL_Event* pEvent) override; 111 void OnProcessEvent(CFWL_Event* pEvent) override;
118 void OnDrawWidget(CFX_Graphics* pGraphics, 112 void OnDrawWidget(CFX_Graphics* pGraphics,
119 const CFX_Matrix* pMatrix) override; 113 const CFX_Matrix* pMatrix) override;
120 114
121 int32_t CountSelItems(); 115 int32_t CountSelItems();
122 CFWL_ListItem* GetSelItem(int32_t nIndexSel); 116 CFWL_ListItem* GetSelItem(int32_t nIndexSel);
123 int32_t GetSelIndex(int32_t nIndex); 117 int32_t GetSelIndex(int32_t nIndex);
124 FWL_Error SetSelItem(CFWL_ListItem* hItem, bool bSelect = true); 118 void SetSelItem(CFWL_ListItem* hItem, bool bSelect = true);
125 FWL_Error GetItemText(CFWL_ListItem* hItem, CFX_WideString& wsText); 119 void GetItemText(CFWL_ListItem* hItem, CFX_WideString& wsText);
126 FWL_Error GetScrollPos(FX_FLOAT& fPos, bool bVert = true); 120 void GetScrollPos(FX_FLOAT& fPos, bool bVert = true);
127 FWL_Error* Sort(IFWL_ListBoxCompare* pCom);
128 121
129 protected: 122 protected:
130 friend class CFWL_ListBoxImpDelegate;
131
132 CFWL_ListItem* GetItem(CFWL_ListItem* hItem, uint32_t dwKeyCode); 123 CFWL_ListItem* GetItem(CFWL_ListItem* hItem, uint32_t dwKeyCode);
133 void SetSelection(CFWL_ListItem* hStart, CFWL_ListItem* hEnd, bool bSelected); 124 void SetSelection(CFWL_ListItem* hStart, CFWL_ListItem* hEnd, bool bSelected);
125 CFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
126 bool ScrollToVisible(CFWL_ListItem* hItem);
127 FX_FLOAT CalcItemHeight();
128 void InitScrollBar(bool bVert = true);
129 bool IsShowScrollBar(bool bVert);
130 FX_FLOAT GetItemHeight() const { return m_fItemHeight; }
131 IFWL_ScrollBar* GetVertScrollBar() const { return m_pVertScrollBar.get(); }
132 const CFX_RectF& GetRTClient() const { return m_rtClient; }
133
134 private:
134 void SetSelectionDirect(CFWL_ListItem* hItem, bool bSelect); 135 void SetSelectionDirect(CFWL_ListItem* hItem, bool bSelect);
135 bool IsItemSelected(CFWL_ListItem* hItem); 136 bool IsItemSelected(CFWL_ListItem* hItem);
136 void ClearSelection(); 137 void ClearSelection();
137 void SelectAll(); 138 void SelectAll();
138 CFWL_ListItem* GetFocusedItem(); 139 CFWL_ListItem* GetFocusedItem();
139 void SetFocusItem(CFWL_ListItem* hItem); 140 void SetFocusItem(CFWL_ListItem* hItem);
140 CFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
141 bool GetItemCheckRect(CFWL_ListItem* hItem, CFX_RectF& rtCheck); 141 bool GetItemCheckRect(CFWL_ListItem* hItem, CFX_RectF& rtCheck);
142 bool SetItemChecked(CFWL_ListItem* hItem, bool bChecked); 142 bool SetItemChecked(CFWL_ListItem* hItem, bool bChecked);
143 bool GetItemChecked(CFWL_ListItem* hItem); 143 bool GetItemChecked(CFWL_ListItem* hItem);
144 bool ScrollToVisible(CFWL_ListItem* hItem);
145 void DrawBkground(CFX_Graphics* pGraphics, 144 void DrawBkground(CFX_Graphics* pGraphics,
146 IFWL_ThemeProvider* pTheme, 145 IFWL_ThemeProvider* pTheme,
147 const CFX_Matrix* pMatrix = nullptr); 146 const CFX_Matrix* pMatrix = nullptr);
148 void DrawItems(CFX_Graphics* pGraphics, 147 void DrawItems(CFX_Graphics* pGraphics,
149 IFWL_ThemeProvider* pTheme, 148 IFWL_ThemeProvider* pTheme,
150 const CFX_Matrix* pMatrix = nullptr); 149 const CFX_Matrix* pMatrix = nullptr);
151 void DrawItem(CFX_Graphics* pGraphics, 150 void DrawItem(CFX_Graphics* pGraphics,
152 IFWL_ThemeProvider* pTheme, 151 IFWL_ThemeProvider* pTheme,
153 CFWL_ListItem* hItem, 152 CFWL_ListItem* hItem,
154 int32_t Index, 153 int32_t Index,
155 const CFX_RectF& rtItem, 154 const CFX_RectF& rtItem,
156 const CFX_Matrix* pMatrix = nullptr); 155 const CFX_Matrix* pMatrix = nullptr);
157 void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); 156 void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme);
158 CFX_SizeF CalcSize(bool bAutoSize = false); 157 CFX_SizeF CalcSize(bool bAutoSize = false);
159 void GetItemSize(CFX_SizeF& size, 158 void GetItemSize(CFX_SizeF& size,
160 CFWL_ListItem* hItem, 159 CFWL_ListItem* hItem,
161 FX_FLOAT fWidth, 160 FX_FLOAT fWidth,
162 FX_FLOAT fHeight, 161 FX_FLOAT fHeight,
163 bool bAutoSize = false); 162 bool bAutoSize = false);
164 FX_FLOAT GetMaxTextWidth(); 163 FX_FLOAT GetMaxTextWidth();
165 FX_FLOAT GetScrollWidth(); 164 FX_FLOAT GetScrollWidth();
166 FX_FLOAT GetItemHeigt();
167 void InitScrollBar(bool bVert = true);
168 bool IsShowScrollBar(bool bVert);
169 void ProcessSelChanged(); 165 void ProcessSelChanged();
166 void OnFocusChanged(CFWL_Message* pMsg, bool bSet = true);
167 void OnLButtonDown(CFWL_MsgMouse* pMsg);
168 void OnLButtonUp(CFWL_MsgMouse* pMsg);
169 void OnMouseWheel(CFWL_MsgMouseWheel* pMsg);
170 void OnKeyDown(CFWL_MsgKey* pMsg);
171 void OnVK(CFWL_ListItem* hItem, bool bShift, bool bCtrl);
172 bool OnScroll(IFWL_ScrollBar* pScrollBar, FWL_SCBCODE dwCode, FX_FLOAT fPos);
173 void DispatchSelChangedEv();
170 174
171 CFX_RectF m_rtClient; 175 CFX_RectF m_rtClient;
172 CFX_RectF m_rtStatic; 176 CFX_RectF m_rtStatic;
173 CFX_RectF m_rtConent; 177 CFX_RectF m_rtConent;
174 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; 178 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar;
175 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; 179 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar;
176 uint32_t m_dwTTOStyles; 180 uint32_t m_dwTTOStyles;
177 int32_t m_iTTOAligns; 181 int32_t m_iTTOAligns;
178 CFWL_ListItem* m_hAnchor; 182 CFWL_ListItem* m_hAnchor;
179 FX_FLOAT m_fItemHeight; 183 FX_FLOAT m_fItemHeight;
180 FX_FLOAT m_fScorllBarWidth; 184 FX_FLOAT m_fScorllBarWidth;
181 bool m_bLButtonDown; 185 bool m_bLButtonDown;
182 IFWL_ThemeProvider* m_pScrollBarTP; 186 IFWL_ThemeProvider* m_pScrollBarTP;
183
184 private:
185 void OnFocusChanged(CFWL_Message* pMsg, bool bSet = true);
186 void OnLButtonDown(CFWL_MsgMouse* pMsg);
187 void OnLButtonUp(CFWL_MsgMouse* pMsg);
188 void OnMouseWheel(CFWL_MsgMouseWheel* pMsg);
189 void OnKeyDown(CFWL_MsgKey* pMsg);
190 void OnVK(CFWL_ListItem* hItem, bool bShift, bool bCtrl);
191 bool OnScroll(IFWL_ScrollBar* pScrollBar, FWL_SCBCODE dwCode, FX_FLOAT fPos);
192 void DispatchSelChangedEv();
193 }; 187 };
194 188
195 #endif // XFA_FWL_CORE_IFWL_LISTBOX_H_ 189 #endif // XFA_FWL_CORE_IFWL_LISTBOX_H_
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_formproxy.h ('k') | xfa/fwl/core/ifwl_listbox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698