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

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

Issue 2432423002: Merge the CFWL_*Imp classes into the IFWL_* classes. (Closed)
Patch Set: Review feedback Created 4 years, 2 months 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_listbox.h ('k') | xfa/fwl/core/ifwl_monthcalendar.h » ('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 #include "xfa/fwl/basewidget/fwl_listboximp.h" 7 #include "xfa/fwl/core/ifwl_listbox.h"
8 8
9 #include "xfa/fde/tto/fde_textout.h" 9 #include "xfa/fde/tto/fde_textout.h"
10 #include "xfa/fwl/basewidget/fwl_comboboximp.h"
11 #include "xfa/fwl/basewidget/fwl_scrollbarimp.h"
12 #include "xfa/fwl/core/cfwl_message.h" 10 #include "xfa/fwl/core/cfwl_message.h"
13 #include "xfa/fwl/core/cfwl_themebackground.h" 11 #include "xfa/fwl/core/cfwl_themebackground.h"
14 #include "xfa/fwl/core/cfwl_themepart.h" 12 #include "xfa/fwl/core/cfwl_themepart.h"
15 #include "xfa/fwl/core/cfwl_themetext.h" 13 #include "xfa/fwl/core/cfwl_themetext.h"
16 #include "xfa/fwl/core/fwl_widgetimp.h"
17 #include "xfa/fwl/core/ifwl_app.h" 14 #include "xfa/fwl/core/ifwl_app.h"
18 #include "xfa/fwl/core/ifwl_themeprovider.h" 15 #include "xfa/fwl/core/ifwl_themeprovider.h"
19 16
20 namespace { 17 namespace {
21 18
22 const int kItemTextMargin = 2; 19 const int kItemTextMargin = 2;
23 20
24 } // namespace 21 } // namespace
25 22
26 // static 23 // static
27 IFWL_ListBox* IFWL_ListBox::Create(const CFWL_WidgetImpProperties& properties, 24 IFWL_ListBox* IFWL_ListBox::Create(const CFWL_WidgetImpProperties& properties,
28 IFWL_Widget* pOuter) { 25 IFWL_Widget* pOuter) {
29 IFWL_ListBox* pListBox = new IFWL_ListBox; 26 return new IFWL_ListBox(properties, pOuter);
30 CFWL_ListBoxImp* pListBoxImpl = new CFWL_ListBoxImp(properties, pOuter);
31 pListBox->SetImpl(pListBoxImpl);
32 pListBoxImpl->SetInterface(pListBox);
33 return pListBox;
34 }
35 // static
36 IFWL_ListBox* IFWL_ListBox::CreateComboList(
37 const CFWL_WidgetImpProperties& properties,
38 IFWL_Widget* pOuter) {
39 IFWL_ListBox* pListBox = new IFWL_ListBox;
40 CFWL_ListBoxImp* pComboListImpl = new CFWL_ComboListImp(properties, pOuter);
41 pListBox->SetImpl(pComboListImpl);
42 pComboListImpl->SetInterface(pListBox);
43 return pListBox;
44 }
45 IFWL_ListBox::IFWL_ListBox() {}
46 int32_t IFWL_ListBox::CountSelItems() {
47 return static_cast<CFWL_ListBoxImp*>(GetImpl())->CountSelItems();
48 }
49 IFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) {
50 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelItem(nIndexSel);
51 }
52 int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) {
53 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelIndex(nIndex);
54 }
55 FWL_Error IFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) {
56 return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(pItem, bSelect);
57 }
58 FWL_Error IFWL_ListBox::GetItemText(IFWL_ListItem* pItem,
59 CFX_WideString& wsText) {
60 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(pItem, wsText);
61 }
62 FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
63 return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetScrollPos(fPos, bVert);
64 } 27 }
65 28
66 CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, 29 IFWL_ListBox::IFWL_ListBox(const CFWL_WidgetImpProperties& properties,
67 IFWL_Widget* pOuter) 30 IFWL_Widget* pOuter)
68 : CFWL_WidgetImp(properties, pOuter), 31 : IFWL_Widget(properties, pOuter),
69 m_dwTTOStyles(0), 32 m_dwTTOStyles(0),
70 m_iTTOAligns(0), 33 m_iTTOAligns(0),
71 m_hAnchor(nullptr), 34 m_hAnchor(nullptr),
72 m_fScorllBarWidth(0), 35 m_fScorllBarWidth(0),
73 m_bLButtonDown(FALSE), 36 m_bLButtonDown(FALSE),
74 m_pScrollBarTP(nullptr) { 37 m_pScrollBarTP(nullptr) {
75 m_rtClient.Reset(); 38 m_rtClient.Reset();
76 m_rtConent.Reset(); 39 m_rtConent.Reset();
77 m_rtStatic.Reset(); 40 m_rtStatic.Reset();
78 } 41 }
79 42
80 CFWL_ListBoxImp::~CFWL_ListBoxImp() {} 43 IFWL_ListBox::~IFWL_ListBox() {}
81 44
82 FWL_Error CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const { 45 FWL_Error IFWL_ListBox::GetClassName(CFX_WideString& wsClass) const {
83 wsClass = FWL_CLASS_ListBox; 46 wsClass = FWL_CLASS_ListBox;
84 return FWL_Error::Succeeded; 47 return FWL_Error::Succeeded;
85 } 48 }
86 49
87 FWL_Type CFWL_ListBoxImp::GetClassID() const { 50 FWL_Type IFWL_ListBox::GetClassID() const {
88 return FWL_Type::ListBox; 51 return FWL_Type::ListBox;
89 } 52 }
90 53
91 FWL_Error CFWL_ListBoxImp::Initialize() { 54 FWL_Error IFWL_ListBox::Initialize() {
92 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) 55 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
93 return FWL_Error::Indefinite; 56 return FWL_Error::Indefinite;
94 57
95 m_pDelegate = new CFWL_ListBoxImpDelegate(this); 58 m_pDelegate = new CFWL_ListBoxImpDelegate(this);
96 return FWL_Error::Succeeded; 59 return FWL_Error::Succeeded;
97 } 60 }
98 61
99 FWL_Error CFWL_ListBoxImp::Finalize() { 62 FWL_Error IFWL_ListBox::Finalize() {
100 if (m_pVertScrollBar) { 63 if (m_pVertScrollBar) {
101 m_pVertScrollBar->Finalize(); 64 m_pVertScrollBar->Finalize();
102 } 65 }
103 if (m_pHorzScrollBar) { 66 if (m_pHorzScrollBar) {
104 m_pHorzScrollBar->Finalize(); 67 m_pHorzScrollBar->Finalize();
105 } 68 }
106 delete m_pDelegate; 69 delete m_pDelegate;
107 m_pDelegate = nullptr; 70 m_pDelegate = nullptr;
108 return CFWL_WidgetImp::Finalize(); 71 return IFWL_Widget::Finalize();
109 } 72 }
110 FWL_Error CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 73
74 FWL_Error IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
111 if (bAutoSize) { 75 if (bAutoSize) {
112 rect.Set(0, 0, 0, 0); 76 rect.Set(0, 0, 0, 0);
113 if (!m_pProperties->m_pThemeProvider) { 77 if (!m_pProperties->m_pThemeProvider) {
114 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 78 m_pProperties->m_pThemeProvider = GetAvailableTheme();
115 } 79 }
116 CFX_SizeF fs = CalcSize(TRUE); 80 CFX_SizeF fs = CalcSize(TRUE);
117 rect.Set(0, 0, fs.x, fs.y); 81 rect.Set(0, 0, fs.x, fs.y);
118 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); 82 IFWL_Widget::GetWidgetRect(rect, TRUE);
119 } else { 83 } else {
120 rect = m_pProperties->m_rtWidget; 84 rect = m_pProperties->m_rtWidget;
121 } 85 }
122 return FWL_Error::Succeeded; 86 return FWL_Error::Succeeded;
123 } 87 }
124 FWL_Error CFWL_ListBoxImp::Update() { 88
89 FWL_Error IFWL_ListBox::Update() {
125 if (IsLocked()) { 90 if (IsLocked()) {
126 return FWL_Error::Indefinite; 91 return FWL_Error::Indefinite;
127 } 92 }
128 if (!m_pProperties->m_pThemeProvider) { 93 if (!m_pProperties->m_pThemeProvider) {
129 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 94 m_pProperties->m_pThemeProvider = GetAvailableTheme();
130 } 95 }
131 m_iTTOAligns = FDE_TTOALIGNMENT_Center; 96 m_iTTOAligns = FDE_TTOALIGNMENT_Center;
132 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { 97 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) {
133 case FWL_STYLEEXT_LTB_LeftAlign: { 98 case FWL_STYLEEXT_LTB_LeftAlign: {
134 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; 99 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft;
135 break; 100 break;
136 } 101 }
137 case FWL_STYLEEXT_LTB_RightAlign: { 102 case FWL_STYLEEXT_LTB_RightAlign: {
138 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; 103 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight;
139 break; 104 break;
140 } 105 }
141 case FWL_STYLEEXT_LTB_CenterAlign: 106 case FWL_STYLEEXT_LTB_CenterAlign:
142 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } 107 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; }
143 } 108 }
144 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { 109 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
145 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; 110 m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
146 } 111 }
147 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; 112 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
148 m_fScorllBarWidth = GetScrollWidth(); 113 m_fScorllBarWidth = GetScrollWidth();
149 CalcSize(); 114 CalcSize();
150 return FWL_Error::Succeeded; 115 return FWL_Error::Succeeded;
151 } 116 }
152 FWL_WidgetHit CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 117
118 FWL_WidgetHit IFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
153 if (IsShowScrollBar(FALSE)) { 119 if (IsShowScrollBar(FALSE)) {
154 CFX_RectF rect; 120 CFX_RectF rect;
155 m_pHorzScrollBar->GetWidgetRect(rect); 121 m_pHorzScrollBar->GetWidgetRect(rect);
156 if (rect.Contains(fx, fy)) 122 if (rect.Contains(fx, fy))
157 return FWL_WidgetHit::HScrollBar; 123 return FWL_WidgetHit::HScrollBar;
158 } 124 }
159 if (IsShowScrollBar(TRUE)) { 125 if (IsShowScrollBar(TRUE)) {
160 CFX_RectF rect; 126 CFX_RectF rect;
161 m_pVertScrollBar->GetWidgetRect(rect); 127 m_pVertScrollBar->GetWidgetRect(rect);
162 if (rect.Contains(fx, fy)) 128 if (rect.Contains(fx, fy))
163 return FWL_WidgetHit::VScrollBar; 129 return FWL_WidgetHit::VScrollBar;
164 } 130 }
165 if (m_rtClient.Contains(fx, fy)) 131 if (m_rtClient.Contains(fx, fy))
166 return FWL_WidgetHit::Client; 132 return FWL_WidgetHit::Client;
167 return FWL_WidgetHit::Unknown; 133 return FWL_WidgetHit::Unknown;
168 } 134 }
169 FWL_Error CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics, 135
170 const CFX_Matrix* pMatrix) { 136 FWL_Error IFWL_ListBox::DrawWidget(CFX_Graphics* pGraphics,
137 const CFX_Matrix* pMatrix) {
171 if (!pGraphics) 138 if (!pGraphics)
172 return FWL_Error::Indefinite; 139 return FWL_Error::Indefinite;
173 if (!m_pProperties->m_pThemeProvider) 140 if (!m_pProperties->m_pThemeProvider)
174 return FWL_Error::Indefinite; 141 return FWL_Error::Indefinite;
175 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 142 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
176 pGraphics->SaveGraphState(); 143 pGraphics->SaveGraphState();
177 if (HasBorder()) { 144 if (HasBorder()) {
178 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); 145 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
179 } 146 }
180 if (HasEdge()) { 147 if (HasEdge()) {
(...skipping 10 matching lines...) Expand all
191 pMatrix->TransformRect(rtClip); 158 pMatrix->TransformRect(rtClip);
192 } 159 }
193 pGraphics->SetClipRect(rtClip); 160 pGraphics->SetClipRect(rtClip);
194 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { 161 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) {
195 DrawBkground(pGraphics, pTheme, pMatrix); 162 DrawBkground(pGraphics, pTheme, pMatrix);
196 } 163 }
197 DrawItems(pGraphics, pTheme, pMatrix); 164 DrawItems(pGraphics, pTheme, pMatrix);
198 pGraphics->RestoreGraphState(); 165 pGraphics->RestoreGraphState();
199 return FWL_Error::Succeeded; 166 return FWL_Error::Succeeded;
200 } 167 }
201 FWL_Error CFWL_ListBoxImp::SetThemeProvider( 168
202 IFWL_ThemeProvider* pThemeProvider) { 169 FWL_Error IFWL_ListBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
203 if (!pThemeProvider) 170 if (!pThemeProvider)
204 return FWL_Error::Indefinite; 171 return FWL_Error::Indefinite;
205 m_pProperties->m_pThemeProvider = pThemeProvider; 172 m_pProperties->m_pThemeProvider = pThemeProvider;
206 return FWL_Error::Succeeded; 173 return FWL_Error::Succeeded;
207 } 174 }
208 int32_t CFWL_ListBoxImp::CountSelItems() { 175 int32_t IFWL_ListBox::CountSelItems() {
209 if (!m_pProperties->m_pDataProvider) 176 if (!m_pProperties->m_pDataProvider)
210 return 0; 177 return 0;
211 int32_t iRet = 0; 178 int32_t iRet = 0;
212 IFWL_ListBoxDP* pData = 179 IFWL_ListBoxDP* pData =
213 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 180 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
214 int32_t iCount = pData->CountItems(m_pInterface); 181 int32_t iCount = pData->CountItems(this);
215 for (int32_t i = 0; i < iCount; i++) { 182 for (int32_t i = 0; i < iCount; i++) {
216 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); 183 IFWL_ListItem* pItem = pData->GetItem(this, i);
217 if (!pItem) { 184 if (!pItem) {
218 continue; 185 continue;
219 } 186 }
220 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem); 187 uint32_t dwStyle = pData->GetItemStyles(this, pItem);
221 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { 188 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
222 iRet++; 189 iRet++;
223 } 190 }
224 } 191 }
225 return iRet; 192 return iRet;
226 } 193 }
227 IFWL_ListItem* CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) { 194
195 IFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) {
228 if (!m_pProperties->m_pDataProvider) 196 if (!m_pProperties->m_pDataProvider)
229 return nullptr; 197 return nullptr;
230 int32_t index = 0; 198 int32_t index = 0;
231 IFWL_ListBoxDP* pData = 199 IFWL_ListBoxDP* pData =
232 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 200 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
233 int32_t iCount = pData->CountItems(m_pInterface); 201 int32_t iCount = pData->CountItems(this);
234 for (int32_t i = 0; i < iCount; i++) { 202 for (int32_t i = 0; i < iCount; i++) {
235 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); 203 IFWL_ListItem* pItem = pData->GetItem(this, i);
236 if (!pItem) { 204 if (!pItem) {
237 return nullptr; 205 return nullptr;
238 } 206 }
239 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem); 207 uint32_t dwStyle = pData->GetItemStyles(this, pItem);
240 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { 208 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
241 if (index == nIndexSel) { 209 if (index == nIndexSel) {
242 return pItem; 210 return pItem;
243 } else { 211 } else {
244 index++; 212 index++;
245 } 213 }
246 } 214 }
247 } 215 }
248 return nullptr; 216 return nullptr;
249 } 217 }
250 int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) { 218
219 int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) {
251 if (!m_pProperties->m_pDataProvider) 220 if (!m_pProperties->m_pDataProvider)
252 return -1; 221 return -1;
253 int32_t index = 0; 222 int32_t index = 0;
254 IFWL_ListBoxDP* pData = 223 IFWL_ListBoxDP* pData =
255 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 224 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
256 int32_t iCount = pData->CountItems(m_pInterface); 225 int32_t iCount = pData->CountItems(this);
257 for (int32_t i = 0; i < iCount; i++) { 226 for (int32_t i = 0; i < iCount; i++) {
258 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); 227 IFWL_ListItem* pItem = pData->GetItem(this, i);
259 if (!pItem) { 228 if (!pItem) {
260 return -1; 229 return -1;
261 } 230 }
262 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem); 231 uint32_t dwStyle = pData->GetItemStyles(this, pItem);
263 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { 232 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
264 if (index == nIndex) { 233 if (index == nIndex) {
265 return i; 234 return i;
266 } else { 235 } else {
267 index++; 236 index++;
268 } 237 }
269 } 238 }
270 } 239 }
271 return -1; 240 return -1;
272 } 241 }
273 FWL_Error CFWL_ListBoxImp::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) { 242
243 FWL_Error IFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) {
274 if (!m_pProperties->m_pDataProvider) 244 if (!m_pProperties->m_pDataProvider)
275 return FWL_Error::Indefinite; 245 return FWL_Error::Indefinite;
276 if (!pItem) { 246 if (!pItem) {
277 if (bSelect) { 247 if (bSelect) {
278 SelectAll(); 248 SelectAll();
279 } else { 249 } else {
280 ClearSelection(); 250 ClearSelection();
281 SetFocusItem(nullptr); 251 SetFocusItem(nullptr);
282 } 252 }
283 return FWL_Error::Indefinite; 253 return FWL_Error::Indefinite;
284 } 254 }
285 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { 255 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) {
286 SetSelectionDirect(pItem, bSelect); 256 SetSelectionDirect(pItem, bSelect);
287 } else { 257 } else {
288 SetSelection(pItem, pItem, bSelect); 258 SetSelection(pItem, pItem, bSelect);
289 } 259 }
290 return FWL_Error::Succeeded; 260 return FWL_Error::Succeeded;
291 } 261 }
292 FWL_Error CFWL_ListBoxImp::GetItemText(IFWL_ListItem* pItem, 262
293 CFX_WideString& wsText) { 263 FWL_Error IFWL_ListBox::GetItemText(IFWL_ListItem* pItem,
264 CFX_WideString& wsText) {
294 if (!m_pProperties->m_pDataProvider) 265 if (!m_pProperties->m_pDataProvider)
295 return FWL_Error::Indefinite; 266 return FWL_Error::Indefinite;
296 IFWL_ListBoxDP* pData = 267 IFWL_ListBoxDP* pData =
297 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 268 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
298 if (!pItem) 269 if (!pItem)
299 return FWL_Error::Indefinite; 270 return FWL_Error::Indefinite;
300 pData->GetItemText(m_pInterface, pItem, wsText); 271 pData->GetItemText(this, pItem, wsText);
301 return FWL_Error::Succeeded; 272 return FWL_Error::Succeeded;
302 } 273 }
303 274
304 FWL_Error CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { 275 FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
305 if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) { 276 if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) {
306 IFWL_ScrollBar* pScrollBar = 277 IFWL_ScrollBar* pScrollBar =
307 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); 278 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
308 fPos = pScrollBar->GetPos(); 279 fPos = pScrollBar->GetPos();
309 return FWL_Error::Succeeded; 280 return FWL_Error::Succeeded;
310 } 281 }
311 return FWL_Error::Indefinite; 282 return FWL_Error::Indefinite;
312 } 283 }
313 284
314 IFWL_ListItem* CFWL_ListBoxImp::GetItem(IFWL_ListItem* pItem, 285 IFWL_ListItem* IFWL_ListBox::GetItem(IFWL_ListItem* pItem, uint32_t dwKeyCode) {
315 uint32_t dwKeyCode) {
316 IFWL_ListItem* hRet = nullptr; 286 IFWL_ListItem* hRet = nullptr;
317 switch (dwKeyCode) { 287 switch (dwKeyCode) {
318 case FWL_VKEY_Up: 288 case FWL_VKEY_Up:
319 case FWL_VKEY_Down: 289 case FWL_VKEY_Down:
320 case FWL_VKEY_Home: 290 case FWL_VKEY_Home:
321 case FWL_VKEY_End: { 291 case FWL_VKEY_End: {
322 const bool bUp = dwKeyCode == FWL_VKEY_Up; 292 const bool bUp = dwKeyCode == FWL_VKEY_Up;
323 const bool bDown = dwKeyCode == FWL_VKEY_Down; 293 const bool bDown = dwKeyCode == FWL_VKEY_Down;
324 const bool bHome = dwKeyCode == FWL_VKEY_Home; 294 const bool bHome = dwKeyCode == FWL_VKEY_Home;
325 IFWL_ListBoxDP* pData = 295 IFWL_ListBoxDP* pData =
326 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 296 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
327 int32_t iDstItem = -1; 297 int32_t iDstItem = -1;
328 if (bUp || bDown) { 298 if (bUp || bDown) {
329 int32_t index = pData->GetItemIndex(m_pInterface, pItem); 299 int32_t index = pData->GetItemIndex(this, pItem);
330 iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1; 300 iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1;
331 } else if (bHome) { 301 } else if (bHome) {
332 iDstItem = 0; 302 iDstItem = 0;
333 } else { 303 } else {
334 int32_t iCount = pData->CountItems(m_pInterface); 304 int32_t iCount = pData->CountItems(this);
335 iDstItem = iCount - 1; 305 iDstItem = iCount - 1;
336 } 306 }
337 hRet = pData->GetItem(m_pInterface, iDstItem); 307 hRet = pData->GetItem(this, iDstItem);
338 break; 308 break;
339 } 309 }
340 default: {} 310 default: {}
341 } 311 }
342 return hRet; 312 return hRet;
343 } 313 }
344 void CFWL_ListBoxImp::SetSelection(IFWL_ListItem* hStart, 314
345 IFWL_ListItem* hEnd, 315 void IFWL_ListBox::SetSelection(IFWL_ListItem* hStart,
346 FX_BOOL bSelected) { 316 IFWL_ListItem* hEnd,
317 FX_BOOL bSelected) {
347 IFWL_ListBoxDP* pData = 318 IFWL_ListBoxDP* pData =
348 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 319 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
349 int32_t iStart = pData->GetItemIndex(m_pInterface, hStart); 320 int32_t iStart = pData->GetItemIndex(this, hStart);
350 int32_t iEnd = pData->GetItemIndex(m_pInterface, hEnd); 321 int32_t iEnd = pData->GetItemIndex(this, hEnd);
351 if (iStart > iEnd) { 322 if (iStart > iEnd) {
352 int32_t iTemp = iStart; 323 int32_t iTemp = iStart;
353 iStart = iEnd; 324 iStart = iEnd;
354 iEnd = iTemp; 325 iEnd = iTemp;
355 } 326 }
356 if (bSelected) { 327 if (bSelected) {
357 int32_t iCount = pData->CountItems(m_pInterface); 328 int32_t iCount = pData->CountItems(this);
358 for (int32_t i = 0; i < iCount; i++) { 329 for (int32_t i = 0; i < iCount; i++) {
359 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); 330 IFWL_ListItem* pItem = pData->GetItem(this, i);
360 SetSelectionDirect(pItem, FALSE); 331 SetSelectionDirect(pItem, FALSE);
361 } 332 }
362 } 333 }
363 for (; iStart <= iEnd; iStart++) { 334 for (; iStart <= iEnd; iStart++) {
364 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, iStart); 335 IFWL_ListItem* pItem = pData->GetItem(this, iStart);
365 SetSelectionDirect(pItem, bSelected); 336 SetSelectionDirect(pItem, bSelected);
366 } 337 }
367 } 338 }
368 void CFWL_ListBoxImp::SetSelectionDirect(IFWL_ListItem* pItem, 339
369 FX_BOOL bSelect) { 340 void IFWL_ListBox::SetSelectionDirect(IFWL_ListItem* pItem, FX_BOOL bSelect) {
370 IFWL_ListBoxDP* pData = 341 IFWL_ListBoxDP* pData =
371 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 342 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
372 uint32_t dwOldStyle = pData->GetItemStyles(m_pInterface, pItem); 343 uint32_t dwOldStyle = pData->GetItemStyles(this, pItem);
373 bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected 344 bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected
374 : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected; 345 : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected;
375 pData->SetItemStyles(m_pInterface, pItem, dwOldStyle); 346 pData->SetItemStyles(this, pItem, dwOldStyle);
376 } 347 }
377 FX_BOOL CFWL_ListBoxImp::IsItemSelected(IFWL_ListItem* pItem) { 348
349 FX_BOOL IFWL_ListBox::IsItemSelected(IFWL_ListItem* pItem) {
378 IFWL_ListBoxDP* pData = 350 IFWL_ListBoxDP* pData =
379 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 351 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
380 uint32_t dwState = pData->GetItemStyles(m_pInterface, pItem); 352 uint32_t dwState = pData->GetItemStyles(this, pItem);
381 return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0; 353 return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0;
382 } 354 }
383 void CFWL_ListBoxImp::ClearSelection() { 355
356 void IFWL_ListBox::ClearSelection() {
384 FX_BOOL bMulti = 357 FX_BOOL bMulti =
385 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; 358 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection;
386 IFWL_ListBoxDP* pData = 359 IFWL_ListBoxDP* pData =
387 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 360 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
388 int32_t iCount = pData->CountItems(m_pInterface); 361 int32_t iCount = pData->CountItems(this);
389 for (int32_t i = 0; i < iCount; i++) { 362 for (int32_t i = 0; i < iCount; i++) {
390 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); 363 IFWL_ListItem* pItem = pData->GetItem(this, i);
391 uint32_t dwState = pData->GetItemStyles(m_pInterface, pItem); 364 uint32_t dwState = pData->GetItemStyles(this, pItem);
392 if (!(dwState & FWL_ITEMSTATE_LTB_Selected)) 365 if (!(dwState & FWL_ITEMSTATE_LTB_Selected))
393 continue; 366 continue;
394 SetSelectionDirect(pItem, FALSE); 367 SetSelectionDirect(pItem, FALSE);
395 if (!bMulti) 368 if (!bMulti)
396 return; 369 return;
397 } 370 }
398 } 371 }
399 void CFWL_ListBoxImp::SelectAll() { 372
373 void IFWL_ListBox::SelectAll() {
400 FX_BOOL bMulti = 374 FX_BOOL bMulti =
401 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; 375 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection;
402 if (!bMulti) { 376 if (!bMulti) {
403 return; 377 return;
404 } 378 }
405 IFWL_ListBoxDP* pData = 379 IFWL_ListBoxDP* pData =
406 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 380 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
407 int32_t iCount = pData->CountItems(m_pInterface); 381 int32_t iCount = pData->CountItems(this);
408 if (iCount > 0) { 382 if (iCount > 0) {
409 IFWL_ListItem* pItemStart = pData->GetItem(m_pInterface, 0); 383 IFWL_ListItem* pItemStart = pData->GetItem(this, 0);
410 IFWL_ListItem* pItemEnd = pData->GetItem(m_pInterface, iCount - 1); 384 IFWL_ListItem* pItemEnd = pData->GetItem(this, iCount - 1);
411 SetSelection(pItemStart, pItemEnd, FALSE); 385 SetSelection(pItemStart, pItemEnd, FALSE);
412 } 386 }
413 } 387 }
414 IFWL_ListItem* CFWL_ListBoxImp::GetFocusedItem() { 388
389 IFWL_ListItem* IFWL_ListBox::GetFocusedItem() {
415 IFWL_ListBoxDP* pData = 390 IFWL_ListBoxDP* pData =
416 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 391 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
417 int32_t iCount = pData->CountItems(m_pInterface); 392 int32_t iCount = pData->CountItems(this);
418 for (int32_t i = 0; i < iCount; i++) { 393 for (int32_t i = 0; i < iCount; i++) {
419 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); 394 IFWL_ListItem* pItem = pData->GetItem(this, i);
420 if (!pItem) 395 if (!pItem)
421 return nullptr; 396 return nullptr;
422 if (pData->GetItemStyles(m_pInterface, pItem) & FWL_ITEMSTATE_LTB_Focused) { 397 if (pData->GetItemStyles(this, pItem) & FWL_ITEMSTATE_LTB_Focused) {
423 return pItem; 398 return pItem;
424 } 399 }
425 } 400 }
426 return nullptr; 401 return nullptr;
427 } 402 }
428 void CFWL_ListBoxImp::SetFocusItem(IFWL_ListItem* pItem) { 403
404 void IFWL_ListBox::SetFocusItem(IFWL_ListItem* pItem) {
429 IFWL_ListBoxDP* pData = 405 IFWL_ListBoxDP* pData =
430 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 406 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
431 IFWL_ListItem* hFocus = GetFocusedItem(); 407 IFWL_ListItem* hFocus = GetFocusedItem();
432 if (pItem != hFocus) { 408 if (pItem != hFocus) {
433 if (hFocus) { 409 if (hFocus) {
434 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hFocus); 410 uint32_t dwStyle = pData->GetItemStyles(this, hFocus);
435 dwStyle &= ~FWL_ITEMSTATE_LTB_Focused; 411 dwStyle &= ~FWL_ITEMSTATE_LTB_Focused;
436 pData->SetItemStyles(m_pInterface, hFocus, dwStyle); 412 pData->SetItemStyles(this, hFocus, dwStyle);
437 } 413 }
438 if (pItem) { 414 if (pItem) {
439 uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem); 415 uint32_t dwStyle = pData->GetItemStyles(this, pItem);
440 dwStyle |= FWL_ITEMSTATE_LTB_Focused; 416 dwStyle |= FWL_ITEMSTATE_LTB_Focused;
441 pData->SetItemStyles(m_pInterface, pItem, dwStyle); 417 pData->SetItemStyles(this, pItem, dwStyle);
442 } 418 }
443 } 419 }
444 } 420 }
445 IFWL_ListItem* CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { 421
422 IFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
446 fx -= m_rtConent.left, fy -= m_rtConent.top; 423 fx -= m_rtConent.left, fy -= m_rtConent.top;
447 FX_FLOAT fPosX = 0.0f; 424 FX_FLOAT fPosX = 0.0f;
448 if (m_pHorzScrollBar) { 425 if (m_pHorzScrollBar) {
449 fPosX = m_pHorzScrollBar->GetPos(); 426 fPosX = m_pHorzScrollBar->GetPos();
450 } 427 }
451 FX_FLOAT fPosY = 0.0; 428 FX_FLOAT fPosY = 0.0;
452 if (m_pVertScrollBar) { 429 if (m_pVertScrollBar) {
453 fPosY = m_pVertScrollBar->GetPos(); 430 fPosY = m_pVertScrollBar->GetPos();
454 } 431 }
455 IFWL_ListBoxDP* pData = 432 IFWL_ListBoxDP* pData =
456 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 433 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
457 int32_t nCount = pData->CountItems(m_pInterface); 434 int32_t nCount = pData->CountItems(this);
458 for (int32_t i = 0; i < nCount; i++) { 435 for (int32_t i = 0; i < nCount; i++) {
459 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); 436 IFWL_ListItem* pItem = pData->GetItem(this, i);
460 if (!pItem) { 437 if (!pItem) {
461 continue; 438 continue;
462 } 439 }
463 CFX_RectF rtItem; 440 CFX_RectF rtItem;
464 pData->GetItemRect(m_pInterface, pItem, rtItem); 441 pData->GetItemRect(this, pItem, rtItem);
465 rtItem.Offset(-fPosX, -fPosY); 442 rtItem.Offset(-fPosX, -fPosY);
466 if (rtItem.Contains(fx, fy)) { 443 if (rtItem.Contains(fx, fy)) {
467 return pItem; 444 return pItem;
468 } 445 }
469 } 446 }
470 return nullptr; 447 return nullptr;
471 } 448 }
472 FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(IFWL_ListItem* pItem, 449
473 CFX_RectF& rtCheck) { 450 FX_BOOL IFWL_ListBox::GetItemCheckRect(IFWL_ListItem* pItem,
451 CFX_RectF& rtCheck) {
474 if (!m_pProperties->m_pDataProvider) 452 if (!m_pProperties->m_pDataProvider)
475 return FALSE; 453 return FALSE;
476 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { 454 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
477 return FALSE; 455 return FALSE;
478 } 456 }
479 IFWL_ListBoxDP* pData = 457 IFWL_ListBoxDP* pData =
480 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 458 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
481 pData->GetItemCheckRect(m_pInterface, pItem, rtCheck); 459 pData->GetItemCheckRect(this, pItem, rtCheck);
482 return TRUE; 460 return TRUE;
483 } 461 }
484 FX_BOOL CFWL_ListBoxImp::GetItemChecked(IFWL_ListItem* pItem) { 462
463 FX_BOOL IFWL_ListBox::GetItemChecked(IFWL_ListItem* pItem) {
485 if (!m_pProperties->m_pDataProvider) 464 if (!m_pProperties->m_pDataProvider)
486 return FALSE; 465 return FALSE;
487 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { 466 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
488 return FALSE; 467 return FALSE;
489 } 468 }
490 IFWL_ListBoxDP* pData = 469 IFWL_ListBoxDP* pData =
491 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 470 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
492 return (pData->GetItemCheckState(m_pInterface, pItem) & 471 return (pData->GetItemCheckState(this, pItem) & FWL_ITEMSTATE_LTB_Checked);
493 FWL_ITEMSTATE_LTB_Checked);
494 } 472 }
495 FX_BOOL CFWL_ListBoxImp::SetItemChecked(IFWL_ListItem* pItem, 473
496 FX_BOOL bChecked) { 474 FX_BOOL IFWL_ListBox::SetItemChecked(IFWL_ListItem* pItem, FX_BOOL bChecked) {
497 if (!m_pProperties->m_pDataProvider) 475 if (!m_pProperties->m_pDataProvider)
498 return FALSE; 476 return FALSE;
499 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { 477 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
500 return FALSE; 478 return FALSE;
501 } 479 }
502 IFWL_ListBoxDP* pData = 480 IFWL_ListBoxDP* pData =
503 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 481 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
504 pData->SetItemCheckState(m_pInterface, pItem, 482 pData->SetItemCheckState(this, pItem,
505 bChecked ? FWL_ITEMSTATE_LTB_Checked : 0); 483 bChecked ? FWL_ITEMSTATE_LTB_Checked : 0);
506 return TRUE; 484 return TRUE;
507 } 485 }
508 FX_BOOL CFWL_ListBoxImp::ScrollToVisible(IFWL_ListItem* pItem) { 486
487 FX_BOOL IFWL_ListBox::ScrollToVisible(IFWL_ListItem* pItem) {
509 if (!m_pVertScrollBar) 488 if (!m_pVertScrollBar)
510 return FALSE; 489 return FALSE;
511 CFX_RectF rtItem; 490 CFX_RectF rtItem;
512 IFWL_ListBoxDP* pData = 491 IFWL_ListBoxDP* pData =
513 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 492 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
514 pData->GetItemRect(m_pInterface, pItem, rtItem); 493 pData->GetItemRect(this, pItem, rtItem);
515 FX_BOOL bScroll = FALSE; 494 FX_BOOL bScroll = FALSE;
516 FX_FLOAT fPosY = m_pVertScrollBar->GetPos(); 495 FX_FLOAT fPosY = m_pVertScrollBar->GetPos();
517 rtItem.Offset(0, -fPosY + m_rtConent.top); 496 rtItem.Offset(0, -fPosY + m_rtConent.top);
518 if (rtItem.top < m_rtConent.top) { 497 if (rtItem.top < m_rtConent.top) {
519 fPosY += rtItem.top - m_rtConent.top; 498 fPosY += rtItem.top - m_rtConent.top;
520 bScroll = TRUE; 499 bScroll = TRUE;
521 } else if (rtItem.bottom() > m_rtConent.bottom()) { 500 } else if (rtItem.bottom() > m_rtConent.bottom()) {
522 fPosY += rtItem.bottom() - m_rtConent.bottom(); 501 fPosY += rtItem.bottom() - m_rtConent.bottom();
523 bScroll = TRUE; 502 bScroll = TRUE;
524 } 503 }
525 if (!bScroll) { 504 if (!bScroll) {
526 return FALSE; 505 return FALSE;
527 } 506 }
528 m_pVertScrollBar->SetPos(fPosY); 507 m_pVertScrollBar->SetPos(fPosY);
529 m_pVertScrollBar->SetTrackPos(fPosY); 508 m_pVertScrollBar->SetTrackPos(fPosY);
530 Repaint(&m_rtClient); 509 Repaint(&m_rtClient);
531 return TRUE; 510 return TRUE;
532 } 511 }
533 void CFWL_ListBoxImp::DrawBkground(CFX_Graphics* pGraphics, 512
534 IFWL_ThemeProvider* pTheme, 513 void IFWL_ListBox::DrawBkground(CFX_Graphics* pGraphics,
535 const CFX_Matrix* pMatrix) { 514 IFWL_ThemeProvider* pTheme,
515 const CFX_Matrix* pMatrix) {
536 if (!pGraphics) 516 if (!pGraphics)
537 return; 517 return;
538 if (!pTheme) 518 if (!pTheme)
539 return; 519 return;
540 CFWL_ThemeBackground param; 520 CFWL_ThemeBackground param;
541 param.m_pWidget = m_pInterface; 521 param.m_pWidget = this;
542 param.m_iPart = CFWL_Part::Background; 522 param.m_iPart = CFWL_Part::Background;
543 param.m_dwStates = 0; 523 param.m_dwStates = 0;
544 param.m_pGraphics = pGraphics; 524 param.m_pGraphics = pGraphics;
545 param.m_matrix.Concat(*pMatrix); 525 param.m_matrix.Concat(*pMatrix);
546 param.m_rtPart = m_rtClient; 526 param.m_rtPart = m_rtClient;
547 if (IsShowScrollBar(FALSE) && IsShowScrollBar(TRUE)) { 527 if (IsShowScrollBar(FALSE) && IsShowScrollBar(TRUE)) {
548 param.m_pData = &m_rtStatic; 528 param.m_pData = &m_rtStatic;
549 } 529 }
550 if (!IsEnabled()) { 530 if (!IsEnabled()) {
551 param.m_dwStates = CFWL_PartState_Disabled; 531 param.m_dwStates = CFWL_PartState_Disabled;
552 } 532 }
553 pTheme->DrawBackground(&param); 533 pTheme->DrawBackground(&param);
554 } 534 }
555 void CFWL_ListBoxImp::DrawItems(CFX_Graphics* pGraphics, 535
556 IFWL_ThemeProvider* pTheme, 536 void IFWL_ListBox::DrawItems(CFX_Graphics* pGraphics,
557 const CFX_Matrix* pMatrix) { 537 IFWL_ThemeProvider* pTheme,
538 const CFX_Matrix* pMatrix) {
558 FX_FLOAT fPosX = 0.0f; 539 FX_FLOAT fPosX = 0.0f;
559 if (m_pHorzScrollBar) { 540 if (m_pHorzScrollBar) {
560 fPosX = m_pHorzScrollBar->GetPos(); 541 fPosX = m_pHorzScrollBar->GetPos();
561 } 542 }
562 FX_FLOAT fPosY = 0.0f; 543 FX_FLOAT fPosY = 0.0f;
563 if (m_pVertScrollBar) { 544 if (m_pVertScrollBar) {
564 fPosY = m_pVertScrollBar->GetPos(); 545 fPosY = m_pVertScrollBar->GetPos();
565 } 546 }
566 CFX_RectF rtView(m_rtConent); 547 CFX_RectF rtView(m_rtConent);
567 if (m_pHorzScrollBar) { 548 if (m_pHorzScrollBar) {
568 rtView.height -= m_fScorllBarWidth; 549 rtView.height -= m_fScorllBarWidth;
569 } 550 }
570 if (m_pVertScrollBar) { 551 if (m_pVertScrollBar) {
571 rtView.width -= m_fScorllBarWidth; 552 rtView.width -= m_fScorllBarWidth;
572 } 553 }
573 FX_BOOL bMultiCol = 554 FX_BOOL bMultiCol =
574 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn; 555 m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn;
575 IFWL_ListBoxDP* pData = 556 IFWL_ListBoxDP* pData =
576 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 557 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
577 int32_t iCount = pData->CountItems(m_pInterface); 558 int32_t iCount = pData->CountItems(this);
578 for (int32_t i = 0; i < iCount; i++) { 559 for (int32_t i = 0; i < iCount; i++) {
579 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); 560 IFWL_ListItem* pItem = pData->GetItem(this, i);
580 if (!pItem) { 561 if (!pItem) {
581 continue; 562 continue;
582 } 563 }
583 CFX_RectF rtItem; 564 CFX_RectF rtItem;
584 pData->GetItemRect(m_pInterface, pItem, rtItem); 565 pData->GetItemRect(this, pItem, rtItem);
585 rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY); 566 rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY);
586 if (rtItem.bottom() < m_rtConent.top) { 567 if (rtItem.bottom() < m_rtConent.top) {
587 continue; 568 continue;
588 } 569 }
589 if (rtItem.top >= m_rtConent.bottom()) { 570 if (rtItem.top >= m_rtConent.bottom()) {
590 break; 571 break;
591 } 572 }
592 if (bMultiCol && rtItem.left > m_rtConent.right()) { 573 if (bMultiCol && rtItem.left > m_rtConent.right()) {
593 break; 574 break;
594 } 575 }
595 if (GetStylesEx() & FWL_STYLEEXT_LTB_OwnerDraw) { 576 if (GetStylesEx() & FWL_STYLEEXT_LTB_OwnerDraw) {
596 CFWL_EvtLtbDrawItem ev; 577 CFWL_EvtLtbDrawItem ev;
597 ev.m_pSrcTarget = m_pInterface; 578 ev.m_pSrcTarget = this;
598 ev.m_pGraphics = pGraphics; 579 ev.m_pGraphics = pGraphics;
599 ev.m_matrix = *pMatrix; 580 ev.m_matrix = *pMatrix;
600 ev.m_index = i; 581 ev.m_index = i;
601 ev.m_rect = rtItem; 582 ev.m_rect = rtItem;
602 DispatchEvent(&ev); 583 DispatchEvent(&ev);
603 } else { 584 } else {
604 DrawItem(pGraphics, pTheme, pItem, i, rtItem, pMatrix); 585 DrawItem(pGraphics, pTheme, pItem, i, rtItem, pMatrix);
605 } 586 }
606 } 587 }
607 } 588 }
608 void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics, 589
609 IFWL_ThemeProvider* pTheme, 590 void IFWL_ListBox::DrawItem(CFX_Graphics* pGraphics,
610 IFWL_ListItem* pItem, 591 IFWL_ThemeProvider* pTheme,
611 int32_t Index, 592 IFWL_ListItem* pItem,
612 const CFX_RectF& rtItem, 593 int32_t Index,
613 const CFX_Matrix* pMatrix) { 594 const CFX_RectF& rtItem,
595 const CFX_Matrix* pMatrix) {
614 IFWL_ListBoxDP* pData = 596 IFWL_ListBoxDP* pData =
615 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 597 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
616 uint32_t dwItemStyles = pData->GetItemStyles(m_pInterface, pItem); 598 uint32_t dwItemStyles = pData->GetItemStyles(this, pItem);
617 uint32_t dwPartStates = CFWL_PartState_Normal; 599 uint32_t dwPartStates = CFWL_PartState_Normal;
618 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { 600 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
619 dwPartStates = CFWL_PartState_Disabled; 601 dwPartStates = CFWL_PartState_Disabled;
620 } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) { 602 } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) {
621 dwPartStates = CFWL_PartState_Selected; 603 dwPartStates = CFWL_PartState_Selected;
622 } 604 }
623 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && 605 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused &&
624 dwItemStyles & FWL_ITEMSTATE_LTB_Focused) { 606 dwItemStyles & FWL_ITEMSTATE_LTB_Focused) {
625 dwPartStates |= CFWL_PartState_Focused; 607 dwPartStates |= CFWL_PartState_Focused;
626 } 608 }
627 { 609 {
628 CFWL_ThemeBackground param; 610 CFWL_ThemeBackground param;
629 param.m_pWidget = m_pInterface; 611 param.m_pWidget = this;
630 param.m_iPart = CFWL_Part::ListItem; 612 param.m_iPart = CFWL_Part::ListItem;
631 param.m_dwStates = dwPartStates; 613 param.m_dwStates = dwPartStates;
632 param.m_pGraphics = pGraphics; 614 param.m_pGraphics = pGraphics;
633 param.m_matrix.Concat(*pMatrix); 615 param.m_matrix.Concat(*pMatrix);
634 param.m_rtPart = rtItem; 616 param.m_rtPart = rtItem;
635 param.m_bMaximize = true; 617 param.m_bMaximize = true;
636 CFX_RectF rtFocus(rtItem); 618 CFX_RectF rtFocus(rtItem);
637 param.m_pData = &rtFocus; 619 param.m_pData = &rtFocus;
638 if (m_pVertScrollBar && !m_pHorzScrollBar && 620 if (m_pVertScrollBar && !m_pHorzScrollBar &&
639 (dwPartStates & CFWL_PartState_Focused)) { 621 (dwPartStates & CFWL_PartState_Focused)) {
640 param.m_rtPart.left += 1; 622 param.m_rtPart.left += 1;
641 param.m_rtPart.width -= (m_fScorllBarWidth + 1); 623 param.m_rtPart.width -= (m_fScorllBarWidth + 1);
642 rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1); 624 rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1);
643 } 625 }
644 pTheme->DrawBackground(&param); 626 pTheme->DrawBackground(&param);
645 } 627 }
646 { 628 {
647 FX_BOOL bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon; 629 FX_BOOL bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon;
648 if (bHasIcon) { 630 if (bHasIcon) {
649 CFX_RectF rtDIB; 631 CFX_RectF rtDIB;
650 CFX_DIBitmap* pDib = pData->GetItemIcon(m_pInterface, pItem); 632 CFX_DIBitmap* pDib = pData->GetItemIcon(this, pItem);
651 rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); 633 rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height);
652 if (pDib) { 634 if (pDib) {
653 CFWL_ThemeBackground param; 635 CFWL_ThemeBackground param;
654 param.m_pWidget = m_pInterface; 636 param.m_pWidget = this;
655 param.m_iPart = CFWL_Part::Icon; 637 param.m_iPart = CFWL_Part::Icon;
656 param.m_pGraphics = pGraphics; 638 param.m_pGraphics = pGraphics;
657 param.m_matrix.Concat(*pMatrix); 639 param.m_matrix.Concat(*pMatrix);
658 param.m_rtPart = rtDIB; 640 param.m_rtPart = rtDIB;
659 param.m_bMaximize = true; 641 param.m_bMaximize = true;
660 param.m_pImage = pDib; 642 param.m_pImage = pDib;
661 pTheme->DrawBackground(&param); 643 pTheme->DrawBackground(&param);
662 } 644 }
663 } 645 }
664 FX_BOOL bHasCheck = GetStylesEx() & FWL_STYLEEXT_LTB_Check; 646 FX_BOOL bHasCheck = GetStylesEx() & FWL_STYLEEXT_LTB_Check;
665 if (bHasCheck) { 647 if (bHasCheck) {
666 CFX_RectF rtCheck; 648 CFX_RectF rtCheck;
667 rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); 649 rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height);
668 rtCheck.Deflate(2, 2, 2, 2); 650 rtCheck.Deflate(2, 2, 2, 2);
669 pData->SetItemCheckRect(m_pInterface, pItem, rtCheck); 651 pData->SetItemCheckRect(this, pItem, rtCheck);
670 CFWL_ThemeBackground param; 652 CFWL_ThemeBackground param;
671 param.m_pWidget = m_pInterface; 653 param.m_pWidget = this;
672 param.m_iPart = CFWL_Part::Check; 654 param.m_iPart = CFWL_Part::Check;
673 param.m_pGraphics = pGraphics; 655 param.m_pGraphics = pGraphics;
674 if (GetItemChecked(pItem)) { 656 if (GetItemChecked(pItem)) {
675 param.m_dwStates = CFWL_PartState_Checked; 657 param.m_dwStates = CFWL_PartState_Checked;
676 } else { 658 } else {
677 param.m_dwStates = CFWL_PartState_Normal; 659 param.m_dwStates = CFWL_PartState_Normal;
678 } 660 }
679 param.m_matrix.Concat(*pMatrix); 661 param.m_matrix.Concat(*pMatrix);
680 param.m_rtPart = rtCheck; 662 param.m_rtPart = rtCheck;
681 param.m_bMaximize = true; 663 param.m_bMaximize = true;
682 pTheme->DrawBackground(&param); 664 pTheme->DrawBackground(&param);
683 } 665 }
684 CFX_WideString wsText; 666 CFX_WideString wsText;
685 pData->GetItemText(m_pInterface, pItem, wsText); 667 pData->GetItemText(this, pItem, wsText);
686 if (wsText.GetLength() <= 0) { 668 if (wsText.GetLength() <= 0) {
687 return; 669 return;
688 } 670 }
689 CFX_RectF rtText(rtItem); 671 CFX_RectF rtText(rtItem);
690 rtText.Deflate(kItemTextMargin, kItemTextMargin); 672 rtText.Deflate(kItemTextMargin, kItemTextMargin);
691 if (bHasIcon || bHasCheck) { 673 if (bHasIcon || bHasCheck) {
692 rtText.Deflate(rtItem.height, 0, 0, 0); 674 rtText.Deflate(rtItem.height, 0, 0, 0);
693 } 675 }
694 CFWL_ThemeText textParam; 676 CFWL_ThemeText textParam;
695 textParam.m_pWidget = m_pInterface; 677 textParam.m_pWidget = this;
696 textParam.m_iPart = CFWL_Part::ListItem; 678 textParam.m_iPart = CFWL_Part::ListItem;
697 textParam.m_dwStates = dwPartStates; 679 textParam.m_dwStates = dwPartStates;
698 textParam.m_pGraphics = pGraphics; 680 textParam.m_pGraphics = pGraphics;
699 textParam.m_matrix.Concat(*pMatrix); 681 textParam.m_matrix.Concat(*pMatrix);
700 textParam.m_rtPart = rtText; 682 textParam.m_rtPart = rtText;
701 textParam.m_wsText = wsText; 683 textParam.m_wsText = wsText;
702 textParam.m_dwTTOStyles = m_dwTTOStyles; 684 textParam.m_dwTTOStyles = m_dwTTOStyles;
703 textParam.m_iTTOAlign = m_iTTOAligns; 685 textParam.m_iTTOAlign = m_iTTOAligns;
704 textParam.m_bMaximize = true; 686 textParam.m_bMaximize = true;
705 pTheme->DrawText(&textParam); 687 pTheme->DrawText(&textParam);
706 } 688 }
707 } 689 }
708 CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) { 690
691 CFX_SizeF IFWL_ListBox::CalcSize(FX_BOOL bAutoSize) {
709 CFX_SizeF fs; 692 CFX_SizeF fs;
710 if (!m_pProperties->m_pThemeProvider) 693 if (!m_pProperties->m_pThemeProvider)
711 return fs; 694 return fs;
712 695
713 GetClientRect(m_rtClient); 696 GetClientRect(m_rtClient);
714 m_rtConent = m_rtClient; 697 m_rtConent = m_rtClient;
715 CFX_RectF rtUIMargin; 698 CFX_RectF rtUIMargin;
716 rtUIMargin.Set(0, 0, 0, 0); 699 rtUIMargin.Set(0, 0, 0, 0);
717 if (!m_pOuter) { 700 if (!m_pOuter) {
718 CFX_RectF* pUIMargin = static_cast<CFX_RectF*>( 701 CFX_RectF* pUIMargin = static_cast<CFX_RectF*>(
719 GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); 702 GetThemeCapacity(CFWL_WidgetCapacity::UIMargin));
720 if (pUIMargin) { 703 if (pUIMargin) {
721 m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, 704 m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
722 pUIMargin->height); 705 pUIMargin->height);
723 } 706 }
724 } 707 }
725 FX_FLOAT fWidth = 0; 708 FX_FLOAT fWidth = 0;
726 if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) { 709 if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(this)) {
727 IFWL_ListBoxDP* pData = 710 IFWL_ListBoxDP* pData =
728 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 711 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
729 int32_t iCount = pData->CountItems(m_pInterface); 712 int32_t iCount = pData->CountItems(this);
730 for (int32_t i = 0; i < iCount; i++) { 713 for (int32_t i = 0; i < iCount; i++) {
731 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); 714 IFWL_ListItem* pItem = pData->GetItem(this, i);
732 if (!bAutoSize) { 715 if (!bAutoSize) {
733 CFX_RectF rtItem; 716 CFX_RectF rtItem;
734 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, 0, 0); 717 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, 0, 0);
735 IFWL_ListBoxDP* pBox = 718 IFWL_ListBoxDP* pBox =
736 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 719 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
737 pBox->SetItemRect(m_pInterface, pItem, rtItem); 720 pBox->SetItemRect(this, pItem, rtItem);
738 } 721 }
739 if (fs.x < 0) { 722 if (fs.x < 0) {
740 fs.x = 0; 723 fs.x = 0;
741 fWidth = 0; 724 fWidth = 0;
742 } 725 }
743 } 726 }
744 } else { 727 } else {
745 fWidth = GetMaxTextWidth(); 728 fWidth = GetMaxTextWidth();
746 fWidth += 2 * kItemTextMargin; 729 fWidth += 2 * kItemTextMargin;
747 if (!bAutoSize) { 730 if (!bAutoSize) {
748 FX_FLOAT fActualWidth = 731 FX_FLOAT fActualWidth =
749 m_rtClient.width - rtUIMargin.left - rtUIMargin.width; 732 m_rtClient.width - rtUIMargin.left - rtUIMargin.width;
750 if (fWidth < fActualWidth) { 733 if (fWidth < fActualWidth) {
751 fWidth = fActualWidth; 734 fWidth = fActualWidth;
752 } 735 }
753 } 736 }
754 IFWL_ListBoxDP* pData = 737 IFWL_ListBoxDP* pData =
755 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 738 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
756 m_fItemHeight = GetItemHeigt(); 739 m_fItemHeight = GetItemHeigt();
757 FX_BOOL bHasIcon; 740 FX_BOOL bHasIcon;
758 bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon; 741 bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon;
759 if (bHasIcon) { 742 if (bHasIcon) {
760 fWidth += m_fItemHeight; 743 fWidth += m_fItemHeight;
761 } 744 }
762 int32_t iCount = pData->CountItems(m_pInterface); 745 int32_t iCount = pData->CountItems(this);
763 for (int32_t i = 0; i < iCount; i++) { 746 for (int32_t i = 0; i < iCount; i++) {
764 IFWL_ListItem* htem = pData->GetItem(m_pInterface, i); 747 IFWL_ListItem* htem = pData->GetItem(this, i);
765 GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize); 748 GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize);
766 } 749 }
767 } 750 }
768 if (bAutoSize) { 751 if (bAutoSize) {
769 return fs; 752 return fs;
770 } 753 }
771 FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width; 754 FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width;
772 FX_FLOAT iHeight = m_rtClient.height; 755 FX_FLOAT iHeight = m_rtClient.height;
773 FX_BOOL bShowVertScr = 756 FX_BOOL bShowVertScr =
774 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) && 757 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) &&
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 m_pHorzScrollBar->SetTrackPos(0); 840 m_pHorzScrollBar->SetTrackPos(0);
858 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE); 841 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, TRUE);
859 } 842 }
860 if (bShowVertScr && bShowHorzScr) { 843 if (bShowVertScr && bShowHorzScr) {
861 m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth, 844 m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth,
862 m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth, 845 m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth,
863 m_fScorllBarWidth); 846 m_fScorllBarWidth);
864 } 847 }
865 return fs; 848 return fs;
866 } 849 }
867 void CFWL_ListBoxImp::GetItemSize(CFX_SizeF& size, 850
868 IFWL_ListItem* pItem, 851 void IFWL_ListBox::GetItemSize(CFX_SizeF& size,
869 FX_FLOAT fWidth, 852 IFWL_ListItem* pItem,
870 FX_FLOAT fItemHeight, 853 FX_FLOAT fWidth,
871 FX_BOOL bAutoSize) { 854 FX_FLOAT fItemHeight,
855 FX_BOOL bAutoSize) {
872 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) { 856 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) {
873 } else { 857 } else {
874 if (!bAutoSize) { 858 if (!bAutoSize) {
875 CFX_RectF rtItem; 859 CFX_RectF rtItem;
876 rtItem.Set(0, size.y, fWidth, fItemHeight); 860 rtItem.Set(0, size.y, fWidth, fItemHeight);
877 IFWL_ListBoxDP* pData = 861 IFWL_ListBoxDP* pData =
878 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 862 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
879 pData->SetItemRect(m_pInterface, pItem, rtItem); 863 pData->SetItemRect(this, pItem, rtItem);
880 } 864 }
881 size.x = fWidth; 865 size.x = fWidth;
882 size.y += fItemHeight; 866 size.y += fItemHeight;
883 } 867 }
884 } 868 }
885 FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth() { 869
870 FX_FLOAT IFWL_ListBox::GetMaxTextWidth() {
886 FX_FLOAT fRet = 0.0f; 871 FX_FLOAT fRet = 0.0f;
887 IFWL_ListBoxDP* pData = 872 IFWL_ListBoxDP* pData =
888 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 873 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
889 int32_t iCount = pData->CountItems(m_pInterface); 874 int32_t iCount = pData->CountItems(this);
890 for (int32_t i = 0; i < iCount; i++) { 875 for (int32_t i = 0; i < iCount; i++) {
891 IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); 876 IFWL_ListItem* pItem = pData->GetItem(this, i);
892 if (!pItem) { 877 if (!pItem) {
893 continue; 878 continue;
894 } 879 }
895 CFX_WideString wsText; 880 CFX_WideString wsText;
896 pData->GetItemText(m_pInterface, pItem, wsText); 881 pData->GetItemText(this, pItem, wsText);
897 CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider); 882 CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider);
898 if (sz.x > fRet) { 883 if (sz.x > fRet) {
899 fRet = sz.x; 884 fRet = sz.x;
900 } 885 }
901 } 886 }
902 return fRet; 887 return fRet;
903 } 888 }
904 FX_FLOAT CFWL_ListBoxImp::GetScrollWidth() { 889
890 FX_FLOAT IFWL_ListBox::GetScrollWidth() {
905 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( 891 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>(
906 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 892 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
907 if (!pfWidth) 893 if (!pfWidth)
908 return 0; 894 return 0;
909 return *pfWidth; 895 return *pfWidth;
910 } 896 }
911 FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() { 897
898 FX_FLOAT IFWL_ListBox::GetItemHeigt() {
912 FX_FLOAT* pfFont = 899 FX_FLOAT* pfFont =
913 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); 900 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize));
914 if (!pfFont) 901 if (!pfFont)
915 return 20; 902 return 20;
916 return *pfFont + 2 * kItemTextMargin; 903 return *pfFont + 2 * kItemTextMargin;
917 } 904 }
918 void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) { 905
906 void IFWL_ListBox::InitScrollBar(FX_BOOL bVert) {
919 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { 907 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) {
920 return; 908 return;
921 } 909 }
922 CFWL_WidgetImpProperties prop; 910 CFWL_WidgetImpProperties prop;
923 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; 911 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
924 prop.m_dwStates = FWL_WGTSTATE_Invisible; 912 prop.m_dwStates = FWL_WGTSTATE_Invisible;
925 prop.m_pParent = m_pInterface; 913 prop.m_pParent = this;
926 prop.m_pThemeProvider = m_pScrollBarTP; 914 prop.m_pThemeProvider = m_pScrollBarTP;
927 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface); 915 IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, this);
928 pScrollBar->Initialize(); 916 pScrollBar->Initialize();
929 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); 917 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
930 } 918 }
931 919
932 FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) { 920 FX_BOOL IFWL_ListBox::IsShowScrollBar(FX_BOOL bVert) {
933 IFWL_ScrollBar* pScrollbar = 921 IFWL_ScrollBar* pScrollbar =
934 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); 922 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
935 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { 923 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) {
936 return FALSE; 924 return FALSE;
937 } 925 }
938 return !(m_pProperties->m_dwStyleExes & 926 return !(m_pProperties->m_dwStyleExes &
939 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || 927 FWL_STYLEEXT_LTB_ShowScrollBarFocus) ||
940 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); 928 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
941 } 929 }
942 void CFWL_ListBoxImp::ProcessSelChanged() { 930
931 void IFWL_ListBox::ProcessSelChanged() {
943 CFWL_EvtLtbSelChanged selEvent; 932 CFWL_EvtLtbSelChanged selEvent;
944 selEvent.m_pSrcTarget = m_pInterface; 933 selEvent.m_pSrcTarget = this;
945 CFX_Int32Array arrSels; 934 CFX_Int32Array arrSels;
946 int32_t iCount = CountSelItems(); 935 int32_t iCount = CountSelItems();
947 for (int32_t i = 0; i < iCount; i++) { 936 for (int32_t i = 0; i < iCount; i++) {
948 IFWL_ListItem* item = GetSelItem(i); 937 IFWL_ListItem* item = GetSelItem(i);
949 if (!item) { 938 if (!item) {
950 continue; 939 continue;
951 } 940 }
952 selEvent.iarraySels.Add(i); 941 selEvent.iarraySels.Add(i);
953 } 942 }
954 DispatchEvent(&selEvent); 943 DispatchEvent(&selEvent);
955 } 944 }
956 945
957 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) 946 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(IFWL_ListBox* pOwner)
958 : m_pOwner(pOwner) {} 947 : m_pOwner(pOwner) {}
959 948
960 void CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { 949 void CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
961 if (!pMessage) 950 if (!pMessage)
962 return; 951 return;
963 if (!m_pOwner->IsEnabled()) 952 if (!m_pOwner->IsEnabled())
964 return; 953 return;
965 954
966 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 955 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
967 switch (dwMsgCode) { 956 switch (dwMsgCode) {
(...skipping 24 matching lines...) Expand all
992 case CFWL_MessageType::MouseWheel: { 981 case CFWL_MessageType::MouseWheel: {
993 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); 982 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage));
994 break; 983 break;
995 } 984 }
996 case CFWL_MessageType::Key: { 985 case CFWL_MessageType::Key: {
997 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); 986 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage);
998 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) 987 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown)
999 OnKeyDown(pMsg); 988 OnKeyDown(pMsg);
1000 break; 989 break;
1001 } 990 }
1002 default: { 991 default: { break; }
1003 break;
1004 }
1005 } 992 }
1006 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); 993 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
1007 } 994 }
1008 995
1009 void CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { 996 void CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
1010 if (!pEvent) 997 if (!pEvent)
1011 return; 998 return;
1012 if (pEvent->GetClassID() != CFWL_EventType::Scroll) 999 if (pEvent->GetClassID() != CFWL_EventType::Scroll)
1013 return; 1000 return;
1014 1001
(...skipping 22 matching lines...) Expand all
1037 m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); 1024 m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
1038 } 1025 }
1039 } 1026 }
1040 if (bSet) { 1027 if (bSet) {
1041 m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); 1028 m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
1042 } else { 1029 } else {
1043 m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); 1030 m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
1044 } 1031 }
1045 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1032 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1046 } 1033 }
1034
1047 void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { 1035 void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
1048 m_pOwner->m_bLButtonDown = TRUE; 1036 m_pOwner->m_bLButtonDown = TRUE;
1049 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { 1037 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
1050 m_pOwner->SetFocus(TRUE); 1038 m_pOwner->SetFocus(TRUE);
1051 } 1039 }
1052 IFWL_ListItem* pItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); 1040 IFWL_ListItem* pItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
1053 if (!pItem) { 1041 if (!pItem) {
1054 return; 1042 return;
1055 } 1043 }
1056 if (m_pOwner->m_pProperties->m_dwStyleExes & 1044 if (m_pOwner->m_pProperties->m_dwStyleExes &
(...skipping 29 matching lines...) Expand all
1086 } 1074 }
1087 m_pOwner->Update(); 1075 m_pOwner->Update();
1088 } 1076 }
1089 } 1077 }
1090 m_pOwner->SetFocusItem(pItem); 1078 m_pOwner->SetFocusItem(pItem);
1091 m_pOwner->ScrollToVisible(pItem); 1079 m_pOwner->ScrollToVisible(pItem);
1092 m_pOwner->SetGrab(TRUE); 1080 m_pOwner->SetGrab(TRUE);
1093 m_pOwner->ProcessSelChanged(); 1081 m_pOwner->ProcessSelChanged();
1094 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1082 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1095 } 1083 }
1084
1096 void CFWL_ListBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { 1085 void CFWL_ListBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
1097 if (m_pOwner->m_bLButtonDown) { 1086 if (m_pOwner->m_bLButtonDown) {
1098 m_pOwner->m_bLButtonDown = FALSE; 1087 m_pOwner->m_bLButtonDown = FALSE;
1099 m_pOwner->SetGrab(FALSE); 1088 m_pOwner->SetGrab(FALSE);
1100 DispatchSelChangedEv(); 1089 DispatchSelChangedEv();
1101 } 1090 }
1102 } 1091 }
1092
1103 void CFWL_ListBoxImpDelegate::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) { 1093 void CFWL_ListBoxImpDelegate::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) {
1104 if (!m_pOwner->IsShowScrollBar(TRUE)) { 1094 if (!m_pOwner->IsShowScrollBar(TRUE)) {
1105 return; 1095 return;
1106 } 1096 }
1107 IFWL_WidgetDelegate* pDelegate = 1097 IFWL_WidgetDelegate* pDelegate =
1108 m_pOwner->m_pVertScrollBar->SetDelegate(nullptr); 1098 m_pOwner->m_pVertScrollBar->SetDelegate(nullptr);
1109 pDelegate->OnProcessMessage(pMsg); 1099 pDelegate->OnProcessMessage(pMsg);
1110 } 1100 }
1101
1111 void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { 1102 void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
1112 uint32_t dwKeyCode = pMsg->m_dwKeyCode; 1103 uint32_t dwKeyCode = pMsg->m_dwKeyCode;
1113 switch (dwKeyCode) { 1104 switch (dwKeyCode) {
1114 case FWL_VKEY_Tab: 1105 case FWL_VKEY_Tab:
1115 case FWL_VKEY_Up: 1106 case FWL_VKEY_Up:
1116 case FWL_VKEY_Down: 1107 case FWL_VKEY_Down:
1117 case FWL_VKEY_Home: 1108 case FWL_VKEY_Home:
1118 case FWL_VKEY_End: { 1109 case FWL_VKEY_End: {
1119 IFWL_ListItem* pItem = m_pOwner->GetFocusedItem(); 1110 IFWL_ListItem* pItem = m_pOwner->GetFocusedItem();
1120 pItem = m_pOwner->GetItem(pItem, dwKeyCode); 1111 pItem = m_pOwner->GetItem(pItem, dwKeyCode);
1121 FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; 1112 FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift;
1122 FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl; 1113 FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl;
1123 OnVK(pItem, bShift, bCtrl); 1114 OnVK(pItem, bShift, bCtrl);
1124 DispatchSelChangedEv(); 1115 DispatchSelChangedEv();
1125 m_pOwner->ProcessSelChanged(); 1116 m_pOwner->ProcessSelChanged();
1126 break; 1117 break;
1127 } 1118 }
1128 default: {} 1119 default:
1120 break;
1129 } 1121 }
1130 } 1122 }
1123
1131 void CFWL_ListBoxImpDelegate::OnVK(IFWL_ListItem* pItem, 1124 void CFWL_ListBoxImpDelegate::OnVK(IFWL_ListItem* pItem,
1132 FX_BOOL bShift, 1125 FX_BOOL bShift,
1133 FX_BOOL bCtrl) { 1126 FX_BOOL bCtrl) {
1134 if (!pItem) { 1127 if (!pItem) {
1135 return; 1128 return;
1136 } 1129 }
1137 if (m_pOwner->m_pProperties->m_dwStyleExes & 1130 if (m_pOwner->m_pProperties->m_dwStyleExes &
1138 FWL_STYLEEXT_LTB_MultiSelection) { 1131 FWL_STYLEEXT_LTB_MultiSelection) {
1139 if (bCtrl) { 1132 if (bCtrl) {
1140 } else if (bShift) { 1133 } else if (bShift) {
(...skipping 11 matching lines...) Expand all
1152 } 1145 }
1153 m_pOwner->SetFocusItem(pItem); 1146 m_pOwner->SetFocusItem(pItem);
1154 m_pOwner->ScrollToVisible(pItem); 1147 m_pOwner->ScrollToVisible(pItem);
1155 { 1148 {
1156 CFX_RectF rtInvalidate; 1149 CFX_RectF rtInvalidate;
1157 rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, 1150 rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width,
1158 m_pOwner->m_pProperties->m_rtWidget.height); 1151 m_pOwner->m_pProperties->m_rtWidget.height);
1159 m_pOwner->Repaint(&rtInvalidate); 1152 m_pOwner->Repaint(&rtInvalidate);
1160 } 1153 }
1161 } 1154 }
1155
1162 FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar, 1156 FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar,
1163 uint32_t dwCode, 1157 uint32_t dwCode,
1164 FX_FLOAT fPos) { 1158 FX_FLOAT fPos) {
1165 CFX_SizeF fs; 1159 CFX_SizeF fs;
1166 pScrollBar->GetRange(fs.x, fs.y); 1160 pScrollBar->GetRange(fs.x, fs.y);
1167 FX_FLOAT iCurPos = pScrollBar->GetPos(); 1161 FX_FLOAT iCurPos = pScrollBar->GetPos();
1168 FX_FLOAT fStep = pScrollBar->GetStepSize(); 1162 FX_FLOAT fStep = pScrollBar->GetStepSize();
1169 switch (dwCode) { 1163 switch (dwCode) {
1170 case FWL_SCBCODE_Min: { 1164 case FWL_SCBCODE_Min: {
1171 fPos = fs.x; 1165 fPos = fs.x;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 case FWL_SCBCODE_EndScroll: 1203 case FWL_SCBCODE_EndScroll:
1210 return FALSE; 1204 return FALSE;
1211 } 1205 }
1212 if (iCurPos != fPos) { 1206 if (iCurPos != fPos) {
1213 pScrollBar->SetPos(fPos); 1207 pScrollBar->SetPos(fPos);
1214 pScrollBar->SetTrackPos(fPos); 1208 pScrollBar->SetTrackPos(fPos);
1215 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1209 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1216 } 1210 }
1217 return TRUE; 1211 return TRUE;
1218 } 1212 }
1213
1219 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { 1214 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() {
1220 CFWL_EvtLtbSelChanged ev; 1215 CFWL_EvtLtbSelChanged ev;
1221 ev.m_pSrcTarget = m_pOwner->m_pInterface; 1216 ev.m_pSrcTarget = m_pOwner;
1222 m_pOwner->DispatchEvent(&ev); 1217 m_pOwner->DispatchEvent(&ev);
1223 } 1218 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_listbox.h ('k') | xfa/fwl/core/ifwl_monthcalendar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698