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

Side by Side Diff: xfa/fwl/core/ifwl_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
(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_IFWL_LISTBOX_H_
8 #define XFA_FWL_CORE_IFWL_LISTBOX_H_
9
10 #include <memory>
11 #include <vector>
12
13 #include "xfa/fwl/core/cfwl_event.h"
14 #include "xfa/fwl/core/cfwl_listitem.h"
15 #include "xfa/fwl/core/cfwl_widgetproperties.h"
16 #include "xfa/fwl/core/ifwl_edit.h"
17 #include "xfa/fwl/core/ifwl_listbox.h"
18 #include "xfa/fwl/core/ifwl_widget.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 IFWL_ListBox : public IFWL_Widget {
42 public:
43 IFWL_ListBox(const CFWL_App* app,
44 std::unique_ptr<CFWL_WidgetProperties> properties,
45 IFWL_Widget* pOuter);
46 ~IFWL_ListBox() override;
47
48 // IFWL_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;
60
61 int32_t CountItems(const IFWL_Widget* pWidget) const;
62 CFWL_ListItem* GetItem(const IFWL_Widget* pWidget, int32_t nIndex) const;
63 int32_t GetItemIndex(IFWL_Widget* pWidget, CFWL_ListItem* pItem);
64 uint32_t GetItemStyles(IFWL_Widget* pWidget, CFWL_ListItem* pItem);
65 void GetItemText(IFWL_Widget* pWidget,
66 CFWL_ListItem* pItem,
67 CFX_WideString& wsText);
68 void GetItemRect(IFWL_Widget* pWidget,
69 CFWL_ListItem* pItem,
70 CFX_RectF& rtItem);
71 void* GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem);
72 void SetItemStyles(IFWL_Widget* pWidget,
73 CFWL_ListItem* pItem,
74 uint32_t dwStyle);
75 void SetItemRect(IFWL_Widget* pWidget,
76 CFWL_ListItem* pItem,
77 const CFX_RectF& rtItem);
78 CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, CFWL_ListItem* pItem);
79 void GetItemCheckRect(IFWL_Widget* pWidget,
80 CFWL_ListItem* pItem,
81 CFX_RectF& rtCheck);
82 void SetItemCheckRect(IFWL_Widget* pWidget,
83 CFWL_ListItem* pItem,
84 const CFX_RectF& rtCheck);
85 uint32_t GetItemCheckState(IFWL_Widget* pWidget, CFWL_ListItem* pItem);
86 void SetItemCheckState(IFWL_Widget* pWidget,
87 CFWL_ListItem* pItem,
88 uint32_t dwCheckState);
89 CFWL_ListItem* AddString(const CFX_WideStringC& wsAdd, bool bSelect = false);
90 bool RemoveAt(int32_t iIndex);
91 bool DeleteString(CFWL_ListItem* pItem);
92 void DeleteAll();
93
94 int32_t CountSelItems();
95 CFWL_ListItem* GetSelItem(int32_t nIndexSel);
96 int32_t GetSelIndex(int32_t nIndex);
97 void SetSelItem(CFWL_ListItem* hItem, bool bSelect = true);
98 void GetDataProviderItemText(CFWL_ListItem* hItem, CFX_WideString& wsText);
99
100 FX_FLOAT GetItemHeight() const { return m_fItemHeight; }
101 FX_FLOAT CalcItemHeight();
102
103 protected:
104 CFWL_ListItem* GetListItem(CFWL_ListItem* hItem, uint32_t dwKeyCode);
105 void SetSelection(CFWL_ListItem* hStart, CFWL_ListItem* hEnd, bool bSelected);
106 CFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
107 bool ScrollToVisible(CFWL_ListItem* hItem);
108 void InitScrollBar(bool bVert = true);
109 bool IsShowScrollBar(bool bVert);
110 CFWL_ScrollBar* GetVertScrollBar() const { return m_pVertScrollBar.get(); }
111 const CFX_RectF& GetRTClient() const { return m_rtClient; }
112
113 private:
114 void SetSelectionDirect(CFWL_ListItem* hItem, bool bSelect);
115 bool IsItemSelected(CFWL_ListItem* hItem);
116 void ClearSelection();
117 void SelectAll();
118 CFWL_ListItem* GetFocusedItem();
119 void SetFocusItem(CFWL_ListItem* hItem);
120 bool GetItemCheckRectInternal(CFWL_ListItem* hItem, CFX_RectF& rtCheck);
121 bool SetItemChecked(CFWL_ListItem* hItem, bool bChecked);
122 bool GetItemChecked(CFWL_ListItem* hItem);
123 void DrawBkground(CFX_Graphics* pGraphics,
124 IFWL_ThemeProvider* pTheme,
125 const CFX_Matrix* pMatrix = nullptr);
126 void DrawItems(CFX_Graphics* pGraphics,
127 IFWL_ThemeProvider* pTheme,
128 const CFX_Matrix* pMatrix = nullptr);
129 void DrawItem(CFX_Graphics* pGraphics,
130 IFWL_ThemeProvider* pTheme,
131 CFWL_ListItem* hItem,
132 int32_t Index,
133 const CFX_RectF& rtItem,
134 const CFX_Matrix* pMatrix = nullptr);
135 void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme);
136 CFX_SizeF CalcSize(bool bAutoSize = false);
137 void GetItemSize(CFX_SizeF& size,
138 CFWL_ListItem* hItem,
139 FX_FLOAT fWidth,
140 FX_FLOAT fHeight,
141 bool bAutoSize = false);
142 FX_FLOAT GetMaxTextWidth();
143 FX_FLOAT GetScrollWidth();
144
145 void OnFocusChanged(CFWL_Message* pMsg, bool bSet = true);
146 void OnLButtonDown(CFWL_MsgMouse* pMsg);
147 void OnLButtonUp(CFWL_MsgMouse* pMsg);
148 void OnMouseWheel(CFWL_MsgMouseWheel* pMsg);
149 void OnKeyDown(CFWL_MsgKey* pMsg);
150 void OnVK(CFWL_ListItem* hItem, bool bShift, bool bCtrl);
151 bool OnScroll(CFWL_ScrollBar* pScrollBar, FWL_SCBCODE dwCode, FX_FLOAT fPos);
152
153 CFX_RectF m_rtClient;
154 CFX_RectF m_rtStatic;
155 CFX_RectF m_rtConent;
156 std::unique_ptr<CFWL_ScrollBar> m_pHorzScrollBar;
157 std::unique_ptr<CFWL_ScrollBar> m_pVertScrollBar;
158 uint32_t m_dwTTOStyles;
159 int32_t m_iTTOAligns;
160 CFWL_ListItem* m_hAnchor;
161 FX_FLOAT m_fItemHeight;
162 FX_FLOAT m_fScorllBarWidth;
163 bool m_bLButtonDown;
164 IFWL_ThemeProvider* m_pScrollBarTP;
165 std::vector<std::unique_ptr<CFWL_ListItem>> m_ItemArray;
166 };
167
168 #endif // XFA_FWL_CORE_IFWL_LISTBOX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698