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

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

Issue 2510793003: Continue formatting fwl/core (Closed)
Patch Set: Fix flag 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
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/core/ifwl_listbox.h" 7 #include "xfa/fwl/core/ifwl_listbox.h"
8 8
9 #include "third_party/base/ptr_util.h" 9 #include "third_party/base/ptr_util.h"
10 #include "xfa/fde/tto/fde_textout.h" 10 #include "xfa/fde/tto/fde_textout.h"
(...skipping 25 matching lines...) Expand all
36 m_rtStatic.Reset(); 36 m_rtStatic.Reset();
37 } 37 }
38 38
39 IFWL_ListBox::~IFWL_ListBox() {} 39 IFWL_ListBox::~IFWL_ListBox() {}
40 40
41 FWL_Type IFWL_ListBox::GetClassID() const { 41 FWL_Type IFWL_ListBox::GetClassID() const {
42 return FWL_Type::ListBox; 42 return FWL_Type::ListBox;
43 } 43 }
44 44
45 void IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 45 void IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
46 if (bAutoSize) { 46 if (!bAutoSize) {
47 rect.Set(0, 0, 0, 0);
48 if (!m_pProperties->m_pThemeProvider) {
49 m_pProperties->m_pThemeProvider = GetAvailableTheme();
50 }
51 CFX_SizeF fs = CalcSize(true);
52 rect.Set(0, 0, fs.x, fs.y);
53 IFWL_Widget::GetWidgetRect(rect, true);
54 } else {
55 rect = m_pProperties->m_rtWidget; 47 rect = m_pProperties->m_rtWidget;
48 return;
56 } 49 }
50
51 rect.Set(0, 0, 0, 0);
52 if (!m_pProperties->m_pThemeProvider)
53 m_pProperties->m_pThemeProvider = GetAvailableTheme();
54
55 CFX_SizeF fs = CalcSize(true);
56 rect.Set(0, 0, fs.x, fs.y);
57 IFWL_Widget::GetWidgetRect(rect, true);
57 } 58 }
58 59
59 void IFWL_ListBox::Update() { 60 void IFWL_ListBox::Update() {
60 if (IsLocked()) { 61 if (IsLocked())
61 return; 62 return;
62 } 63 if (!m_pProperties->m_pThemeProvider)
63 if (!m_pProperties->m_pThemeProvider) {
64 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 64 m_pProperties->m_pThemeProvider = GetAvailableTheme();
65 } 65
66 m_iTTOAligns = FDE_TTOALIGNMENT_Center;
67 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { 66 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) {
68 case FWL_STYLEEXT_LTB_LeftAlign: { 67 case FWL_STYLEEXT_LTB_LeftAlign: {
69 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; 68 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft;
70 break; 69 break;
71 } 70 }
72 case FWL_STYLEEXT_LTB_RightAlign: { 71 case FWL_STYLEEXT_LTB_RightAlign: {
73 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; 72 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight;
74 break; 73 break;
75 } 74 }
76 case FWL_STYLEEXT_LTB_CenterAlign: 75 case FWL_STYLEEXT_LTB_CenterAlign:
77 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } 76 default: {
77 m_iTTOAligns = FDE_TTOALIGNMENT_Center;
78 break;
79 }
78 } 80 }
79 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { 81 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading)
80 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; 82 m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
81 } 83
82 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; 84 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
83 m_fScorllBarWidth = GetScrollWidth(); 85 m_fScorllBarWidth = GetScrollWidth();
84 CalcSize(); 86 CalcSize();
85 } 87 }
86 88
87 FWL_WidgetHit IFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 89 FWL_WidgetHit IFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
88 if (IsShowScrollBar(false)) { 90 if (IsShowScrollBar(false)) {
89 CFX_RectF rect; 91 CFX_RectF rect;
90 m_pHorzScrollBar->GetWidgetRect(rect); 92 m_pHorzScrollBar->GetWidgetRect(rect);
91 if (rect.Contains(fx, fy)) 93 if (rect.Contains(fx, fy))
92 return FWL_WidgetHit::HScrollBar; 94 return FWL_WidgetHit::HScrollBar;
93 } 95 }
94 if (IsShowScrollBar(true)) { 96 if (IsShowScrollBar(true)) {
95 CFX_RectF rect; 97 CFX_RectF rect;
96 m_pVertScrollBar->GetWidgetRect(rect); 98 m_pVertScrollBar->GetWidgetRect(rect);
97 if (rect.Contains(fx, fy)) 99 if (rect.Contains(fx, fy))
98 return FWL_WidgetHit::VScrollBar; 100 return FWL_WidgetHit::VScrollBar;
99 } 101 }
100 if (m_rtClient.Contains(fx, fy)) 102 if (m_rtClient.Contains(fx, fy))
101 return FWL_WidgetHit::Client; 103 return FWL_WidgetHit::Client;
102 return FWL_WidgetHit::Unknown; 104 return FWL_WidgetHit::Unknown;
103 } 105 }
104 106
105 void IFWL_ListBox::DrawWidget(CFX_Graphics* pGraphics, 107 void IFWL_ListBox::DrawWidget(CFX_Graphics* pGraphics,
106 const CFX_Matrix* pMatrix) { 108 const CFX_Matrix* pMatrix) {
107 if (!pGraphics) 109 if (!pGraphics)
108 return; 110 return;
109 if (!m_pProperties->m_pThemeProvider) 111 if (!m_pProperties->m_pThemeProvider)
110 return; 112 return;
113
111 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 114 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
112 pGraphics->SaveGraphState(); 115 pGraphics->SaveGraphState();
113 if (HasBorder()) { 116 if (HasBorder())
114 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); 117 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
115 } 118 if (HasEdge())
116 if (HasEdge()) {
117 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); 119 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
118 } 120
119 CFX_RectF rtClip(m_rtConent); 121 CFX_RectF rtClip(m_rtConent);
120 if (IsShowScrollBar(false)) { 122 if (IsShowScrollBar(false))
121 rtClip.height -= m_fScorllBarWidth; 123 rtClip.height -= m_fScorllBarWidth;
122 } 124 if (IsShowScrollBar(true))
123 if (IsShowScrollBar(true)) {
124 rtClip.width -= m_fScorllBarWidth; 125 rtClip.width -= m_fScorllBarWidth;
125 } 126 if (pMatrix)
126 if (pMatrix) {
127 pMatrix->TransformRect(rtClip); 127 pMatrix->TransformRect(rtClip);
128 } 128
129 pGraphics->SetClipRect(rtClip); 129 pGraphics->SetClipRect(rtClip);
130 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { 130 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0)
131 DrawBkground(pGraphics, pTheme, pMatrix); 131 DrawBkground(pGraphics, pTheme, pMatrix);
132 } 132
133 DrawItems(pGraphics, pTheme, pMatrix); 133 DrawItems(pGraphics, pTheme, pMatrix);
134 pGraphics->RestoreGraphState(); 134 pGraphics->RestoreGraphState();
135 } 135 }
136 136
137 void IFWL_ListBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { 137 void IFWL_ListBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
138 if (pThemeProvider) 138 if (pThemeProvider)
139 m_pProperties->m_pThemeProvider = pThemeProvider; 139 m_pProperties->m_pThemeProvider = pThemeProvider;
140 } 140 }
141
141 int32_t IFWL_ListBox::CountSelItems() { 142 int32_t IFWL_ListBox::CountSelItems() {
142 if (!m_pProperties->m_pDataProvider) 143 if (!m_pProperties->m_pDataProvider)
143 return 0; 144 return 0;
145
144 int32_t iRet = 0; 146 int32_t iRet = 0;
145 IFWL_ListBoxDP* pData = 147 IFWL_ListBoxDP* pData =
146 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 148 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
147 int32_t iCount = pData->CountItems(this); 149 int32_t iCount = pData->CountItems(this);
148 for (int32_t i = 0; i < iCount; i++) { 150 for (int32_t i = 0; i < iCount; i++) {
149 CFWL_ListItem* pItem = pData->GetItem(this, i); 151 CFWL_ListItem* pItem = pData->GetItem(this, i);
150 if (!pItem) { 152 if (!pItem)
151 continue; 153 continue;
152 } 154
153 uint32_t dwStyle = pData->GetItemStyles(this, pItem); 155 uint32_t dwStyle = pData->GetItemStyles(this, pItem);
154 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { 156 if (dwStyle & FWL_ITEMSTATE_LTB_Selected)
155 iRet++; 157 iRet++;
156 }
157 } 158 }
158 return iRet; 159 return iRet;
159 } 160 }
160 161
161 CFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) { 162 CFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) {
npm 2016/11/16 20:57:54 Can this method just call the other GetSelItem?
dsinclair 2016/11/16 21:31:27 Done. Nice catch.
162 if (!m_pProperties->m_pDataProvider) 163 if (!m_pProperties->m_pDataProvider)
163 return nullptr; 164 return nullptr;
165
164 int32_t index = 0; 166 int32_t index = 0;
165 IFWL_ListBoxDP* pData = 167 IFWL_ListBoxDP* pData =
166 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 168 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
167 int32_t iCount = pData->CountItems(this); 169 int32_t iCount = pData->CountItems(this);
168 for (int32_t i = 0; i < iCount; i++) { 170 for (int32_t i = 0; i < iCount; i++) {
169 CFWL_ListItem* pItem = pData->GetItem(this, i); 171 CFWL_ListItem* pItem = pData->GetItem(this, i);
170 if (!pItem) { 172 if (!pItem)
171 return nullptr; 173 return nullptr;
172 } 174
173 uint32_t dwStyle = pData->GetItemStyles(this, pItem); 175 uint32_t dwStyle = pData->GetItemStyles(this, pItem);
174 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { 176 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
175 if (index == nIndexSel) { 177 if (index == nIndexSel)
176 return pItem; 178 return pItem;
177 } else { 179 index++;
178 index++;
179 }
180 } 180 }
181 } 181 }
182 return nullptr; 182 return nullptr;
183 } 183 }
184 184
185 int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { 185 int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) {
186 if (!m_pProperties->m_pDataProvider) 186 if (!m_pProperties->m_pDataProvider)
187 return -1; 187 return -1;
188
188 int32_t index = 0; 189 int32_t index = 0;
189 IFWL_ListBoxDP* pData = 190 IFWL_ListBoxDP* pData =
190 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 191 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
191 int32_t iCount = pData->CountItems(this); 192 int32_t iCount = pData->CountItems(this);
192 for (int32_t i = 0; i < iCount; i++) { 193 for (int32_t i = 0; i < iCount; i++) {
193 CFWL_ListItem* pItem = pData->GetItem(this, i); 194 CFWL_ListItem* pItem = pData->GetItem(this, i);
194 if (!pItem) { 195 if (!pItem)
195 return -1; 196 return -1;
196 } 197
197 uint32_t dwStyle = pData->GetItemStyles(this, pItem); 198 uint32_t dwStyle = pData->GetItemStyles(this, pItem);
198 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { 199 if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
199 if (index == nIndex) { 200 if (index == nIndex)
200 return i; 201 return i;
201 } else { 202 index++;
202 index++;
203 }
204 } 203 }
205 } 204 }
206 return -1; 205 return -1;
207 } 206 }
208 207
209 void IFWL_ListBox::SetSelItem(CFWL_ListItem* pItem, bool bSelect) { 208 void IFWL_ListBox::SetSelItem(CFWL_ListItem* pItem, bool bSelect) {
210 if (!m_pProperties->m_pDataProvider) 209 if (!m_pProperties->m_pDataProvider)
211 return; 210 return;
212 if (!pItem) { 211 if (!pItem) {
213 if (bSelect) { 212 if (bSelect) {
214 SelectAll(); 213 SelectAll();
215 } else { 214 } else {
216 ClearSelection(); 215 ClearSelection();
217 SetFocusItem(nullptr); 216 SetFocusItem(nullptr);
218 } 217 }
219 return; 218 return;
220 } 219 }
221 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { 220 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection)
222 SetSelectionDirect(pItem, bSelect); 221 SetSelectionDirect(pItem, bSelect);
223 } else { 222 else
224 SetSelection(pItem, pItem, bSelect); 223 SetSelection(pItem, pItem, bSelect);
225 }
226 } 224 }
227 225
228 void IFWL_ListBox::GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText) { 226 void IFWL_ListBox::GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText) {
229 if (!m_pProperties->m_pDataProvider) 227 if (!m_pProperties->m_pDataProvider)
230 return; 228 return;
229
231 IFWL_ListBoxDP* pData = 230 IFWL_ListBoxDP* pData =
232 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 231 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
233 if (!pItem) 232 if (!pItem)
234 return; 233 return;
234
235 pData->GetItemText(this, pItem, wsText); 235 pData->GetItemText(this, pItem, wsText);
236 } 236 }
237 237
238 CFWL_ListItem* IFWL_ListBox::GetItem(CFWL_ListItem* pItem, uint32_t dwKeyCode) { 238 CFWL_ListItem* IFWL_ListBox::GetItem(CFWL_ListItem* pItem, uint32_t dwKeyCode) {
239 CFWL_ListItem* hRet = nullptr; 239 CFWL_ListItem* hRet = nullptr;
240 switch (dwKeyCode) { 240 switch (dwKeyCode) {
241 case FWL_VKEY_Up: 241 case FWL_VKEY_Up:
242 case FWL_VKEY_Down: 242 case FWL_VKEY_Down:
243 case FWL_VKEY_Home: 243 case FWL_VKEY_Home:
244 case FWL_VKEY_End: { 244 case FWL_VKEY_End: {
245 const bool bUp = dwKeyCode == FWL_VKEY_Up; 245 const bool bUp = dwKeyCode == FWL_VKEY_Up;
246 const bool bDown = dwKeyCode == FWL_VKEY_Down; 246 const bool bDown = dwKeyCode == FWL_VKEY_Down;
247 const bool bHome = dwKeyCode == FWL_VKEY_Home; 247 const bool bHome = dwKeyCode == FWL_VKEY_Home;
248 IFWL_ListBoxDP* pData = 248 IFWL_ListBoxDP* pData =
249 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 249 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
250 int32_t iDstItem = -1; 250 int32_t iDstItem = -1;
251 if (bUp || bDown) { 251 if (bUp || bDown) {
252 int32_t index = pData->GetItemIndex(this, pItem); 252 int32_t index = pData->GetItemIndex(this, pItem);
253 iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1; 253 iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1;
254 } else if (bHome) { 254 } else if (bHome) {
255 iDstItem = 0; 255 iDstItem = 0;
256 } else { 256 } else {
257 int32_t iCount = pData->CountItems(this); 257 int32_t iCount = pData->CountItems(this);
258 iDstItem = iCount - 1; 258 iDstItem = iCount - 1;
259 } 259 }
260 hRet = pData->GetItem(this, iDstItem); 260 hRet = pData->GetItem(this, iDstItem);
261 break; 261 break;
262 } 262 }
263 default: {} 263 default:
264 break;
264 } 265 }
265 return hRet; 266 return hRet;
266 } 267 }
267 268
268 void IFWL_ListBox::SetSelection(CFWL_ListItem* hStart, 269 void IFWL_ListBox::SetSelection(CFWL_ListItem* hStart,
269 CFWL_ListItem* hEnd, 270 CFWL_ListItem* hEnd,
270 bool bSelected) { 271 bool bSelected) {
271 IFWL_ListBoxDP* pData = 272 IFWL_ListBoxDP* pData =
272 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 273 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
273 int32_t iStart = pData->GetItemIndex(this, hStart); 274 int32_t iStart = pData->GetItemIndex(this, hStart);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 uint32_t dwState = pData->GetItemStyles(this, pItem); 317 uint32_t dwState = pData->GetItemStyles(this, pItem);
317 if (!(dwState & FWL_ITEMSTATE_LTB_Selected)) 318 if (!(dwState & FWL_ITEMSTATE_LTB_Selected))
318 continue; 319 continue;
319 SetSelectionDirect(pItem, false); 320 SetSelectionDirect(pItem, false);
320 if (!bMulti) 321 if (!bMulti)
321 return; 322 return;
322 } 323 }
323 } 324 }
324 325
325 void IFWL_ListBox::SelectAll() { 326 void IFWL_ListBox::SelectAll() {
326 bool bMulti = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; 327 if (!m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection)
327 if (!bMulti) {
328 return; 328 return;
329 } 329
330 IFWL_ListBoxDP* pData = 330 IFWL_ListBoxDP* pData =
331 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 331 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
332 int32_t iCount = pData->CountItems(this); 332 int32_t iCount = pData->CountItems(this);
333 if (iCount > 0) { 333 if (iCount <= 0)
334 CFWL_ListItem* pItemStart = pData->GetItem(this, 0); 334 return;
335 CFWL_ListItem* pItemEnd = pData->GetItem(this, iCount - 1); 335
336 SetSelection(pItemStart, pItemEnd, false); 336 CFWL_ListItem* pItemStart = pData->GetItem(this, 0);
337 } 337 CFWL_ListItem* pItemEnd = pData->GetItem(this, iCount - 1);
338 SetSelection(pItemStart, pItemEnd, false);
338 } 339 }
339 340
340 CFWL_ListItem* IFWL_ListBox::GetFocusedItem() { 341 CFWL_ListItem* IFWL_ListBox::GetFocusedItem() {
341 IFWL_ListBoxDP* pData = 342 IFWL_ListBoxDP* pData =
342 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 343 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
343 int32_t iCount = pData->CountItems(this); 344 int32_t iCount = pData->CountItems(this);
344 for (int32_t i = 0; i < iCount; i++) { 345 for (int32_t i = 0; i < iCount; i++) {
345 CFWL_ListItem* pItem = pData->GetItem(this, i); 346 CFWL_ListItem* pItem = pData->GetItem(this, i);
346 if (!pItem) 347 if (!pItem)
347 return nullptr; 348 return nullptr;
348 if (pData->GetItemStyles(this, pItem) & FWL_ITEMSTATE_LTB_Focused) { 349 if (pData->GetItemStyles(this, pItem) & FWL_ITEMSTATE_LTB_Focused)
349 return pItem; 350 return pItem;
350 }
351 } 351 }
352 return nullptr; 352 return nullptr;
353 } 353 }
354 354
355 void IFWL_ListBox::SetFocusItem(CFWL_ListItem* pItem) { 355 void IFWL_ListBox::SetFocusItem(CFWL_ListItem* pItem) {
356 IFWL_ListBoxDP* pData = 356 IFWL_ListBoxDP* pData =
357 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 357 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
358 CFWL_ListItem* hFocus = GetFocusedItem(); 358 CFWL_ListItem* hFocus = GetFocusedItem();
359 if (pItem != hFocus) { 359 if (pItem == hFocus)
360 if (hFocus) { 360 return;
361 uint32_t dwStyle = pData->GetItemStyles(this, hFocus); 361
362 dwStyle &= ~FWL_ITEMSTATE_LTB_Focused; 362 if (hFocus) {
363 pData->SetItemStyles(this, hFocus, dwStyle); 363 uint32_t dwStyle = pData->GetItemStyles(this, hFocus);
364 } 364 dwStyle &= ~FWL_ITEMSTATE_LTB_Focused;
365 if (pItem) { 365 pData->SetItemStyles(this, hFocus, dwStyle);
366 uint32_t dwStyle = pData->GetItemStyles(this, pItem); 366 }
367 dwStyle |= FWL_ITEMSTATE_LTB_Focused; 367 if (pItem) {
368 pData->SetItemStyles(this, pItem, dwStyle); 368 uint32_t dwStyle = pData->GetItemStyles(this, pItem);
369 } 369 dwStyle |= FWL_ITEMSTATE_LTB_Focused;
370 pData->SetItemStyles(this, pItem, dwStyle);
370 } 371 }
371 } 372 }
372 373
373 CFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { 374 CFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
374 fx -= m_rtConent.left, fy -= m_rtConent.top; 375 fx -= m_rtConent.left, fy -= m_rtConent.top;
375 FX_FLOAT fPosX = 0.0f; 376 FX_FLOAT fPosX = 0.0f;
376 if (m_pHorzScrollBar) { 377 if (m_pHorzScrollBar)
377 fPosX = m_pHorzScrollBar->GetPos(); 378 fPosX = m_pHorzScrollBar->GetPos();
378 } 379
379 FX_FLOAT fPosY = 0.0; 380 FX_FLOAT fPosY = 0.0;
380 if (m_pVertScrollBar) { 381 if (m_pVertScrollBar)
381 fPosY = m_pVertScrollBar->GetPos(); 382 fPosY = m_pVertScrollBar->GetPos();
382 } 383
383 IFWL_ListBoxDP* pData = 384 IFWL_ListBoxDP* pData =
384 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 385 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
385 int32_t nCount = pData->CountItems(this); 386 int32_t nCount = pData->CountItems(this);
386 for (int32_t i = 0; i < nCount; i++) { 387 for (int32_t i = 0; i < nCount; i++) {
387 CFWL_ListItem* pItem = pData->GetItem(this, i); 388 CFWL_ListItem* pItem = pData->GetItem(this, i);
388 if (!pItem) { 389 if (!pItem)
389 continue; 390 continue;
390 } 391
391 CFX_RectF rtItem; 392 CFX_RectF rtItem;
392 pData->GetItemRect(this, pItem, rtItem); 393 pData->GetItemRect(this, pItem, rtItem);
393 rtItem.Offset(-fPosX, -fPosY); 394 rtItem.Offset(-fPosX, -fPosY);
394 if (rtItem.Contains(fx, fy)) { 395 if (rtItem.Contains(fx, fy))
395 return pItem; 396 return pItem;
396 }
397 } 397 }
398 return nullptr; 398 return nullptr;
399 } 399 }
400 400
401 bool IFWL_ListBox::GetItemCheckRect(CFWL_ListItem* pItem, CFX_RectF& rtCheck) { 401 bool IFWL_ListBox::GetItemCheckRect(CFWL_ListItem* pItem, CFX_RectF& rtCheck) {
402 if (!m_pProperties->m_pDataProvider) 402 if (!m_pProperties->m_pDataProvider)
403 return false; 403 return false;
404 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { 404 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check))
405 return false; 405 return false;
406 } 406
407 IFWL_ListBoxDP* pData = 407 IFWL_ListBoxDP* pData =
408 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 408 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
409 pData->GetItemCheckRect(this, pItem, rtCheck); 409 pData->GetItemCheckRect(this, pItem, rtCheck);
410 return true; 410 return true;
411 } 411 }
412 412
413 bool IFWL_ListBox::GetItemChecked(CFWL_ListItem* pItem) { 413 bool IFWL_ListBox::GetItemChecked(CFWL_ListItem* pItem) {
414 if (!m_pProperties->m_pDataProvider) 414 if (!m_pProperties->m_pDataProvider)
415 return false; 415 return false;
416 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { 416 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check))
417 return false; 417 return false;
418 } 418
419 IFWL_ListBoxDP* pData = 419 IFWL_ListBoxDP* pData =
420 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 420 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
421 return !!(pData->GetItemCheckState(this, pItem) & FWL_ITEMSTATE_LTB_Checked); 421 return !!(pData->GetItemCheckState(this, pItem) & FWL_ITEMSTATE_LTB_Checked);
422 } 422 }
423 423
424 bool IFWL_ListBox::SetItemChecked(CFWL_ListItem* pItem, bool bChecked) { 424 bool IFWL_ListBox::SetItemChecked(CFWL_ListItem* pItem, bool bChecked) {
425 if (!m_pProperties->m_pDataProvider) 425 if (!m_pProperties->m_pDataProvider)
426 return false; 426 return false;
427 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { 427 if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check))
428 return false; 428 return false;
429 } 429
430 IFWL_ListBoxDP* pData = 430 IFWL_ListBoxDP* pData =
431 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 431 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
432 pData->SetItemCheckState(this, pItem, 432 pData->SetItemCheckState(this, pItem,
433 bChecked ? FWL_ITEMSTATE_LTB_Checked : 0); 433 bChecked ? FWL_ITEMSTATE_LTB_Checked : 0);
434 return true; 434 return true;
435 } 435 }
436 436
437 bool IFWL_ListBox::ScrollToVisible(CFWL_ListItem* pItem) { 437 bool IFWL_ListBox::ScrollToVisible(CFWL_ListItem* pItem) {
438 if (!m_pVertScrollBar) 438 if (!m_pVertScrollBar)
439 return false; 439 return false;
440
440 CFX_RectF rtItem; 441 CFX_RectF rtItem;
441 IFWL_ListBoxDP* pData = 442 IFWL_ListBoxDP* pData =
442 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 443 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
443 pData->GetItemRect(this, pItem, rtItem); 444 pData->GetItemRect(this, pItem, rtItem);
445
444 bool bScroll = false; 446 bool bScroll = false;
445 FX_FLOAT fPosY = m_pVertScrollBar->GetPos(); 447 FX_FLOAT fPosY = m_pVertScrollBar->GetPos();
446 rtItem.Offset(0, -fPosY + m_rtConent.top); 448 rtItem.Offset(0, -fPosY + m_rtConent.top);
447 if (rtItem.top < m_rtConent.top) { 449 if (rtItem.top < m_rtConent.top) {
448 fPosY += rtItem.top - m_rtConent.top; 450 fPosY += rtItem.top - m_rtConent.top;
449 bScroll = true; 451 bScroll = true;
450 } else if (rtItem.bottom() > m_rtConent.bottom()) { 452 } else if (rtItem.bottom() > m_rtConent.bottom()) {
451 fPosY += rtItem.bottom() - m_rtConent.bottom(); 453 fPosY += rtItem.bottom() - m_rtConent.bottom();
452 bScroll = true; 454 bScroll = true;
453 } 455 }
454 if (!bScroll) { 456 if (!bScroll)
455 return false; 457 return false;
456 } 458
457 m_pVertScrollBar->SetPos(fPosY); 459 m_pVertScrollBar->SetPos(fPosY);
458 m_pVertScrollBar->SetTrackPos(fPosY); 460 m_pVertScrollBar->SetTrackPos(fPosY);
459 Repaint(&m_rtClient); 461 Repaint(&m_rtClient);
460 return true; 462 return true;
461 } 463 }
462 464
463 void IFWL_ListBox::DrawBkground(CFX_Graphics* pGraphics, 465 void IFWL_ListBox::DrawBkground(CFX_Graphics* pGraphics,
464 IFWL_ThemeProvider* pTheme, 466 IFWL_ThemeProvider* pTheme,
465 const CFX_Matrix* pMatrix) { 467 const CFX_Matrix* pMatrix) {
466 if (!pGraphics) 468 if (!pGraphics)
467 return; 469 return;
468 if (!pTheme) 470 if (!pTheme)
469 return; 471 return;
472
470 CFWL_ThemeBackground param; 473 CFWL_ThemeBackground param;
471 param.m_pWidget = this; 474 param.m_pWidget = this;
472 param.m_iPart = CFWL_Part::Background; 475 param.m_iPart = CFWL_Part::Background;
473 param.m_dwStates = 0; 476 param.m_dwStates = 0;
474 param.m_pGraphics = pGraphics; 477 param.m_pGraphics = pGraphics;
475 param.m_matrix.Concat(*pMatrix); 478 param.m_matrix.Concat(*pMatrix);
476 param.m_rtPart = m_rtClient; 479 param.m_rtPart = m_rtClient;
477 if (IsShowScrollBar(false) && IsShowScrollBar(true)) { 480 if (IsShowScrollBar(false) && IsShowScrollBar(true))
478 param.m_pData = &m_rtStatic; 481 param.m_pData = &m_rtStatic;
479 } 482 if (!IsEnabled())
480 if (!IsEnabled()) {
481 param.m_dwStates = CFWL_PartState_Disabled; 483 param.m_dwStates = CFWL_PartState_Disabled;
482 } 484
483 pTheme->DrawBackground(&param); 485 pTheme->DrawBackground(&param);
484 } 486 }
485 487
486 void IFWL_ListBox::DrawItems(CFX_Graphics* pGraphics, 488 void IFWL_ListBox::DrawItems(CFX_Graphics* pGraphics,
487 IFWL_ThemeProvider* pTheme, 489 IFWL_ThemeProvider* pTheme,
488 const CFX_Matrix* pMatrix) { 490 const CFX_Matrix* pMatrix) {
489 FX_FLOAT fPosX = 0.0f; 491 FX_FLOAT fPosX = 0.0f;
490 if (m_pHorzScrollBar) { 492 if (m_pHorzScrollBar)
491 fPosX = m_pHorzScrollBar->GetPos(); 493 fPosX = m_pHorzScrollBar->GetPos();
492 } 494
493 FX_FLOAT fPosY = 0.0f; 495 FX_FLOAT fPosY = 0.0f;
494 if (m_pVertScrollBar) { 496 if (m_pVertScrollBar)
495 fPosY = m_pVertScrollBar->GetPos(); 497 fPosY = m_pVertScrollBar->GetPos();
496 } 498
497 CFX_RectF rtView(m_rtConent); 499 CFX_RectF rtView(m_rtConent);
498 if (m_pHorzScrollBar) { 500 if (m_pHorzScrollBar)
499 rtView.height -= m_fScorllBarWidth; 501 rtView.height -= m_fScorllBarWidth;
500 } 502 if (m_pVertScrollBar)
501 if (m_pVertScrollBar) {
502 rtView.width -= m_fScorllBarWidth; 503 rtView.width -= m_fScorllBarWidth;
503 } 504
504 bool bMultiCol = 505 bool bMultiCol =
505 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn); 506 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn);
506 IFWL_ListBoxDP* pData = 507 IFWL_ListBoxDP* pData =
507 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 508 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
508 int32_t iCount = pData->CountItems(this); 509 int32_t iCount = pData->CountItems(this);
509 for (int32_t i = 0; i < iCount; i++) { 510 for (int32_t i = 0; i < iCount; i++) {
510 CFWL_ListItem* pItem = pData->GetItem(this, i); 511 CFWL_ListItem* pItem = pData->GetItem(this, i);
511 if (!pItem) { 512 if (!pItem)
512 continue; 513 continue;
513 } 514
514 CFX_RectF rtItem; 515 CFX_RectF rtItem;
515 pData->GetItemRect(this, pItem, rtItem); 516 pData->GetItemRect(this, pItem, rtItem);
516 rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY); 517 rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY);
517 if (rtItem.bottom() < m_rtConent.top) { 518 if (rtItem.bottom() < m_rtConent.top)
518 continue; 519 continue;
519 } 520 if (rtItem.top >= m_rtConent.bottom())
520 if (rtItem.top >= m_rtConent.bottom()) {
521 break; 521 break;
522 } 522 if (bMultiCol && rtItem.left > m_rtConent.right())
523 if (bMultiCol && rtItem.left > m_rtConent.right()) {
524 break; 523 break;
525 } 524
526 if (GetStylesEx() & FWL_STYLEEXT_LTB_OwnerDraw) { 525 if (GetStylesEx() & FWL_STYLEEXT_LTB_OwnerDraw) {
527 CFWL_EvtLtbDrawItem ev; 526 CFWL_EvtLtbDrawItem ev;
528 ev.m_pSrcTarget = this; 527 ev.m_pSrcTarget = this;
529 ev.m_pGraphics = pGraphics; 528 ev.m_pGraphics = pGraphics;
530 ev.m_matrix = *pMatrix; 529 ev.m_matrix = *pMatrix;
531 ev.m_index = i; 530 ev.m_index = i;
532 ev.m_rect = rtItem; 531 ev.m_rect = rtItem;
533 DispatchEvent(&ev); 532 DispatchEvent(&ev);
534 } else { 533 } else {
535 DrawItem(pGraphics, pTheme, pItem, i, rtItem, pMatrix); 534 DrawItem(pGraphics, pTheme, pItem, i, rtItem, pMatrix);
536 } 535 }
537 } 536 }
538 } 537 }
539 538
540 void IFWL_ListBox::DrawItem(CFX_Graphics* pGraphics, 539 void IFWL_ListBox::DrawItem(CFX_Graphics* pGraphics,
541 IFWL_ThemeProvider* pTheme, 540 IFWL_ThemeProvider* pTheme,
542 CFWL_ListItem* pItem, 541 CFWL_ListItem* pItem,
543 int32_t Index, 542 int32_t Index,
544 const CFX_RectF& rtItem, 543 const CFX_RectF& rtItem,
545 const CFX_Matrix* pMatrix) { 544 const CFX_Matrix* pMatrix) {
546 IFWL_ListBoxDP* pData = 545 IFWL_ListBoxDP* pData =
547 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 546 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
548 uint32_t dwItemStyles = pData->GetItemStyles(this, pItem); 547 uint32_t dwItemStyles = pData->GetItemStyles(this, pItem);
549 uint32_t dwPartStates = CFWL_PartState_Normal; 548 uint32_t dwPartStates = CFWL_PartState_Normal;
550 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { 549 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
551 dwPartStates = CFWL_PartState_Disabled; 550 dwPartStates = CFWL_PartState_Disabled;
552 } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) { 551 else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected)
553 dwPartStates = CFWL_PartState_Selected; 552 dwPartStates = CFWL_PartState_Selected;
554 } 553
555 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && 554 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused &&
556 dwItemStyles & FWL_ITEMSTATE_LTB_Focused) { 555 dwItemStyles & FWL_ITEMSTATE_LTB_Focused) {
557 dwPartStates |= CFWL_PartState_Focused; 556 dwPartStates |= CFWL_PartState_Focused;
558 } 557 }
559 { 558
559 CFWL_ThemeBackground bg_param;
560 bg_param.m_pWidget = this;
561 bg_param.m_iPart = CFWL_Part::ListItem;
562 bg_param.m_dwStates = dwPartStates;
563 bg_param.m_pGraphics = pGraphics;
564 bg_param.m_matrix.Concat(*pMatrix);
565 bg_param.m_rtPart = rtItem;
566 bg_param.m_bMaximize = true;
567 CFX_RectF rtFocus(rtItem);
568 bg_param.m_pData = &rtFocus;
569 if (m_pVertScrollBar && !m_pHorzScrollBar &&
570 (dwPartStates & CFWL_PartState_Focused)) {
571 bg_param.m_rtPart.left += 1;
572 bg_param.m_rtPart.width -= (m_fScorllBarWidth + 1);
573 rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1);
574 }
575 pTheme->DrawBackground(&bg_param);
576
577 bool bHasIcon = !!(GetStylesEx() & FWL_STYLEEXT_LTB_Icon);
578 if (bHasIcon) {
579 CFX_RectF rtDIB;
580 CFX_DIBitmap* pDib = pData->GetItemIcon(this, pItem);
581 rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height);
582 if (pDib) {
583 CFWL_ThemeBackground param;
584 param.m_pWidget = this;
585 param.m_iPart = CFWL_Part::Icon;
586 param.m_pGraphics = pGraphics;
587 param.m_matrix.Concat(*pMatrix);
588 param.m_rtPart = rtDIB;
589 param.m_bMaximize = true;
590 param.m_pImage = pDib;
591 pTheme->DrawBackground(&param);
592 }
593 }
594
595 bool bHasCheck = !!(GetStylesEx() & FWL_STYLEEXT_LTB_Check);
596 if (bHasCheck) {
597 CFX_RectF rtCheck;
598 rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height);
599 rtCheck.Deflate(2, 2, 2, 2);
600 pData->SetItemCheckRect(this, pItem, rtCheck);
560 CFWL_ThemeBackground param; 601 CFWL_ThemeBackground param;
561 param.m_pWidget = this; 602 param.m_pWidget = this;
562 param.m_iPart = CFWL_Part::ListItem; 603 param.m_iPart = CFWL_Part::Check;
563 param.m_dwStates = dwPartStates;
564 param.m_pGraphics = pGraphics; 604 param.m_pGraphics = pGraphics;
605 if (GetItemChecked(pItem))
606 param.m_dwStates = CFWL_PartState_Checked;
607 else
608 param.m_dwStates = CFWL_PartState_Normal;
565 param.m_matrix.Concat(*pMatrix); 609 param.m_matrix.Concat(*pMatrix);
566 param.m_rtPart = rtItem; 610 param.m_rtPart = rtCheck;
567 param.m_bMaximize = true; 611 param.m_bMaximize = true;
568 CFX_RectF rtFocus(rtItem);
569 param.m_pData = &rtFocus;
570 if (m_pVertScrollBar && !m_pHorzScrollBar &&
571 (dwPartStates & CFWL_PartState_Focused)) {
572 param.m_rtPart.left += 1;
573 param.m_rtPart.width -= (m_fScorllBarWidth + 1);
574 rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1);
575 }
576 pTheme->DrawBackground(&param); 612 pTheme->DrawBackground(&param);
577 } 613 }
578 { 614
579 bool bHasIcon = !!(GetStylesEx() & FWL_STYLEEXT_LTB_Icon); 615 CFX_WideString wsText;
580 if (bHasIcon) { 616 pData->GetItemText(this, pItem, wsText);
581 CFX_RectF rtDIB; 617 if (wsText.GetLength() <= 0)
582 CFX_DIBitmap* pDib = pData->GetItemIcon(this, pItem); 618 return;
583 rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); 619
584 if (pDib) { 620 CFX_RectF rtText(rtItem);
585 CFWL_ThemeBackground param; 621 rtText.Deflate(kItemTextMargin, kItemTextMargin);
586 param.m_pWidget = this; 622 if (bHasIcon || bHasCheck)
587 param.m_iPart = CFWL_Part::Icon; 623 rtText.Deflate(rtItem.height, 0, 0, 0);
588 param.m_pGraphics = pGraphics; 624
589 param.m_matrix.Concat(*pMatrix); 625 CFWL_ThemeText textParam;
590 param.m_rtPart = rtDIB; 626 textParam.m_pWidget = this;
591 param.m_bMaximize = true; 627 textParam.m_iPart = CFWL_Part::ListItem;
592 param.m_pImage = pDib; 628 textParam.m_dwStates = dwPartStates;
593 pTheme->DrawBackground(&param); 629 textParam.m_pGraphics = pGraphics;
594 } 630 textParam.m_matrix.Concat(*pMatrix);
595 } 631 textParam.m_rtPart = rtText;
596 bool bHasCheck = !!(GetStylesEx() & FWL_STYLEEXT_LTB_Check); 632 textParam.m_wsText = wsText;
597 if (bHasCheck) { 633 textParam.m_dwTTOStyles = m_dwTTOStyles;
598 CFX_RectF rtCheck; 634 textParam.m_iTTOAlign = m_iTTOAligns;
599 rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); 635 textParam.m_bMaximize = true;
600 rtCheck.Deflate(2, 2, 2, 2); 636 pTheme->DrawText(&textParam);
601 pData->SetItemCheckRect(this, pItem, rtCheck);
602 CFWL_ThemeBackground param;
603 param.m_pWidget = this;
604 param.m_iPart = CFWL_Part::Check;
605 param.m_pGraphics = pGraphics;
606 if (GetItemChecked(pItem)) {
607 param.m_dwStates = CFWL_PartState_Checked;
608 } else {
609 param.m_dwStates = CFWL_PartState_Normal;
610 }
611 param.m_matrix.Concat(*pMatrix);
612 param.m_rtPart = rtCheck;
613 param.m_bMaximize = true;
614 pTheme->DrawBackground(&param);
615 }
616 CFX_WideString wsText;
617 pData->GetItemText(this, pItem, wsText);
618 if (wsText.GetLength() <= 0) {
619 return;
620 }
621 CFX_RectF rtText(rtItem);
622 rtText.Deflate(kItemTextMargin, kItemTextMargin);
623 if (bHasIcon || bHasCheck) {
624 rtText.Deflate(rtItem.height, 0, 0, 0);
625 }
626 CFWL_ThemeText textParam;
627 textParam.m_pWidget = this;
628 textParam.m_iPart = CFWL_Part::ListItem;
629 textParam.m_dwStates = dwPartStates;
630 textParam.m_pGraphics = pGraphics;
631 textParam.m_matrix.Concat(*pMatrix);
632 textParam.m_rtPart = rtText;
633 textParam.m_wsText = wsText;
634 textParam.m_dwTTOStyles = m_dwTTOStyles;
635 textParam.m_iTTOAlign = m_iTTOAligns;
636 textParam.m_bMaximize = true;
637 pTheme->DrawText(&textParam);
638 }
639 } 637 }
640 638
641 CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) { 639 CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) {
642 CFX_SizeF fs; 640 CFX_SizeF fs;
643 if (!m_pProperties->m_pThemeProvider) 641 if (!m_pProperties->m_pThemeProvider)
644 return fs; 642 return fs;
645 643
646 GetClientRect(m_rtClient); 644 GetClientRect(m_rtClient);
647 m_rtConent = m_rtClient; 645 m_rtConent = m_rtClient;
648 CFX_RectF rtUIMargin; 646 CFX_RectF rtUIMargin;
649 rtUIMargin.Set(0, 0, 0, 0); 647 rtUIMargin.Set(0, 0, 0, 0);
650 if (!m_pOuter) { 648 if (!m_pOuter) {
651 CFX_RectF* pUIMargin = static_cast<CFX_RectF*>( 649 CFX_RectF* pUIMargin = static_cast<CFX_RectF*>(
652 GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); 650 GetThemeCapacity(CFWL_WidgetCapacity::UIMargin));
653 if (pUIMargin) { 651 if (pUIMargin) {
654 m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, 652 m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
655 pUIMargin->height); 653 pUIMargin->height);
656 } 654 }
657 } 655 }
656
658 FX_FLOAT fWidth = 0; 657 FX_FLOAT fWidth = 0;
659 if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(this)) { 658 if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(this)) {
660 IFWL_ListBoxDP* pData = 659 IFWL_ListBoxDP* pData =
661 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 660 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
662 int32_t iCount = pData->CountItems(this); 661 int32_t iCount = pData->CountItems(this);
663 for (int32_t i = 0; i < iCount; i++) { 662 for (int32_t i = 0; i < iCount; i++) {
664 CFWL_ListItem* pItem = pData->GetItem(this, i); 663 CFWL_ListItem* pItem = pData->GetItem(this, i);
665 if (!bAutoSize) { 664 if (!bAutoSize) {
666 CFX_RectF rtItem; 665 CFX_RectF rtItem;
667 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, 0, 0); 666 rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, 0, 0);
668 IFWL_ListBoxDP* pBox = 667 IFWL_ListBoxDP* pBox =
669 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 668 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
670 pBox->SetItemRect(this, pItem, rtItem); 669 pBox->SetItemRect(this, pItem, rtItem);
671 } 670 }
672 if (fs.x < 0) { 671 if (fs.x < 0) {
673 fs.x = 0; 672 fs.x = 0;
674 fWidth = 0; 673 fWidth = 0;
675 } 674 }
676 } 675 }
677 } else { 676 } else {
678 fWidth = GetMaxTextWidth(); 677 fWidth = GetMaxTextWidth();
679 fWidth += 2 * kItemTextMargin; 678 fWidth += 2 * kItemTextMargin;
680 if (!bAutoSize) { 679 if (!bAutoSize) {
681 FX_FLOAT fActualWidth = 680 FX_FLOAT fActualWidth =
682 m_rtClient.width - rtUIMargin.left - rtUIMargin.width; 681 m_rtClient.width - rtUIMargin.left - rtUIMargin.width;
683 if (fWidth < fActualWidth) { 682 fWidth = std::max(fWidth, fActualWidth);
684 fWidth = fActualWidth;
685 }
686 } 683 }
684
687 IFWL_ListBoxDP* pData = 685 IFWL_ListBoxDP* pData =
688 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 686 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
689 m_fItemHeight = CalcItemHeight(); 687 m_fItemHeight = CalcItemHeight();
690 if ((GetStylesEx() & FWL_STYLEEXT_LTB_Icon)) 688 if ((GetStylesEx() & FWL_STYLEEXT_LTB_Icon))
691 fWidth += m_fItemHeight; 689 fWidth += m_fItemHeight;
692 690
693 int32_t iCount = pData->CountItems(this); 691 int32_t iCount = pData->CountItems(this);
694 for (int32_t i = 0; i < iCount; i++) { 692 for (int32_t i = 0; i < iCount; i++) {
695 CFWL_ListItem* htem = pData->GetItem(this, i); 693 CFWL_ListItem* htem = pData->GetItem(this, i);
696 GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize); 694 GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize);
697 } 695 }
698 } 696 }
699 if (bAutoSize) { 697 if (bAutoSize)
700 return fs; 698 return fs;
701 } 699
702 FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width; 700 FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width;
703 FX_FLOAT iHeight = m_rtClient.height; 701 FX_FLOAT iHeight = m_rtClient.height;
704 bool bShowVertScr = 702 bool bShowVertScr =
705 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) && 703 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) &&
706 (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll); 704 (m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll);
707 bool bShowHorzScr = 705 bool bShowHorzScr =
708 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) && 706 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarAlaways) &&
709 (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll); 707 (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll);
710 if (!bShowVertScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll && 708 if (!bShowVertScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_VScroll &&
711 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) == 0) { 709 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) == 0) {
712 bShowVertScr = (fs.y > iHeight); 710 bShowVertScr = (fs.y > iHeight);
713 } 711 }
714 if (!bShowHorzScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) { 712 if (!bShowHorzScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll)
715 bShowHorzScr = (fs.x > iWidth); 713 bShowHorzScr = (fs.x > iWidth);
716 } 714
717 CFX_SizeF szRange; 715 CFX_SizeF szRange;
718 if (bShowVertScr) { 716 if (bShowVertScr) {
719 if (!m_pVertScrollBar) { 717 if (!m_pVertScrollBar)
720 InitScrollBar(); 718 InitScrollBar();
721 } 719
722 CFX_RectF rtScrollBar; 720 CFX_RectF rtScrollBar;
723 rtScrollBar.Set(m_rtClient.right() - m_fScorllBarWidth, m_rtClient.top, 721 rtScrollBar.Set(m_rtClient.right() - m_fScorllBarWidth, m_rtClient.top,
724 m_fScorllBarWidth, m_rtClient.height - 1); 722 m_fScorllBarWidth, m_rtClient.height - 1);
725 if (bShowHorzScr) { 723 if (bShowHorzScr)
726 rtScrollBar.height -= m_fScorllBarWidth; 724 rtScrollBar.height -= m_fScorllBarWidth;
727 } 725
728 m_pVertScrollBar->SetWidgetRect(rtScrollBar); 726 m_pVertScrollBar->SetWidgetRect(rtScrollBar);
729 szRange.x = 0, szRange.y = fs.y - m_rtConent.height; 727 szRange.x = 0, szRange.y = fs.y - m_rtConent.height;
730 if (szRange.y < m_fItemHeight) { 728 szRange.y = std::max(szRange.y, m_fItemHeight);
731 szRange.y = m_fItemHeight; 729
732 }
733 m_pVertScrollBar->SetRange(szRange.x, szRange.y); 730 m_pVertScrollBar->SetRange(szRange.x, szRange.y);
734 m_pVertScrollBar->SetPageSize(rtScrollBar.height * 9 / 10); 731 m_pVertScrollBar->SetPageSize(rtScrollBar.height * 9 / 10);
735 m_pVertScrollBar->SetStepSize(m_fItemHeight); 732 m_pVertScrollBar->SetStepSize(m_fItemHeight);
736 FX_FLOAT fPos = m_pVertScrollBar->GetPos(); 733
737 if (fPos < 0) { 734 FX_FLOAT fPos =
738 fPos = 0; 735 std::min(std::max(m_pVertScrollBar->GetPos(), 0.f), szRange.y);
739 }
740 if (fPos > szRange.y) {
741 fPos = szRange.y;
742 }
743 m_pVertScrollBar->SetPos(fPos); 736 m_pVertScrollBar->SetPos(fPos);
744 m_pVertScrollBar->SetTrackPos(fPos); 737 m_pVertScrollBar->SetTrackPos(fPos);
745 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == 738 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) ==
746 0 || 739 0 ||
747 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) { 740 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) {
748 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, false); 741 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, false);
749 } 742 }
750 m_pVertScrollBar->Update(); 743 m_pVertScrollBar->Update();
751 } else if (m_pVertScrollBar) { 744 } else if (m_pVertScrollBar) {
752 m_pVertScrollBar->SetPos(0); 745 m_pVertScrollBar->SetPos(0);
753 m_pVertScrollBar->SetTrackPos(0); 746 m_pVertScrollBar->SetTrackPos(0);
754 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, true); 747 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, true);
755 } 748 }
756 if (bShowHorzScr) { 749 if (bShowHorzScr) {
757 if (!m_pHorzScrollBar) { 750 if (!m_pHorzScrollBar)
758 InitScrollBar(false); 751 InitScrollBar(false);
759 } 752
760 CFX_RectF rtScrollBar; 753 CFX_RectF rtScrollBar;
761 rtScrollBar.Set(m_rtClient.left, m_rtClient.bottom() - m_fScorllBarWidth, 754 rtScrollBar.Set(m_rtClient.left, m_rtClient.bottom() - m_fScorllBarWidth,
762 m_rtClient.width, m_fScorllBarWidth); 755 m_rtClient.width, m_fScorllBarWidth);
763 if (bShowVertScr) { 756 if (bShowVertScr)
764 rtScrollBar.width -= m_fScorllBarWidth; 757 rtScrollBar.width -= m_fScorllBarWidth;
765 } 758
766 m_pHorzScrollBar->SetWidgetRect(rtScrollBar); 759 m_pHorzScrollBar->SetWidgetRect(rtScrollBar);
767 szRange.x = 0, szRange.y = fs.x - rtScrollBar.width; 760 szRange.x = 0, szRange.y = fs.x - rtScrollBar.width;
768 m_pHorzScrollBar->SetRange(szRange.x, szRange.y); 761 m_pHorzScrollBar->SetRange(szRange.x, szRange.y);
769 m_pHorzScrollBar->SetPageSize(fWidth * 9 / 10); 762 m_pHorzScrollBar->SetPageSize(fWidth * 9 / 10);
770 m_pHorzScrollBar->SetStepSize(fWidth / 10); 763 m_pHorzScrollBar->SetStepSize(fWidth / 10);
771 FX_FLOAT fPos = m_pHorzScrollBar->GetPos(); 764
772 if (fPos < 0) { 765 FX_FLOAT fPos =
773 fPos = 0; 766 std::min(std::max(m_pHorzScrollBar->GetPos(), 0.f), szRange.y);
774 }
775 if (fPos > szRange.y) {
776 fPos = szRange.y;
777 }
778 m_pHorzScrollBar->SetPos(fPos); 767 m_pHorzScrollBar->SetPos(fPos);
779 m_pHorzScrollBar->SetTrackPos(fPos); 768 m_pHorzScrollBar->SetTrackPos(fPos);
780 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == 769 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) ==
781 0 || 770 0 ||
782 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) { 771 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) {
783 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, false); 772 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, false);
784 } 773 }
785 m_pHorzScrollBar->Update(); 774 m_pHorzScrollBar->Update();
786 } else if (m_pHorzScrollBar) { 775 } else if (m_pHorzScrollBar) {
787 m_pHorzScrollBar->SetPos(0); 776 m_pHorzScrollBar->SetPos(0);
788 m_pHorzScrollBar->SetTrackPos(0); 777 m_pHorzScrollBar->SetTrackPos(0);
789 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, true); 778 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, true);
790 } 779 }
791 if (bShowVertScr && bShowHorzScr) { 780 if (bShowVertScr && bShowHorzScr) {
792 m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth, 781 m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth,
793 m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth, 782 m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth,
794 m_fScorllBarWidth); 783 m_fScorllBarWidth);
795 } 784 }
796 return fs; 785 return fs;
797 } 786 }
798 787
799 void IFWL_ListBox::GetItemSize(CFX_SizeF& size, 788 void IFWL_ListBox::GetItemSize(CFX_SizeF& size,
800 CFWL_ListItem* pItem, 789 CFWL_ListItem* pItem,
801 FX_FLOAT fWidth, 790 FX_FLOAT fWidth,
802 FX_FLOAT fItemHeight, 791 FX_FLOAT fItemHeight,
803 bool bAutoSize) { 792 bool bAutoSize) {
804 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) { 793 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn)
805 } else { 794 return;
806 if (!bAutoSize) { 795
807 CFX_RectF rtItem; 796 if (!bAutoSize) {
808 rtItem.Set(0, size.y, fWidth, fItemHeight); 797 CFX_RectF rtItem;
809 IFWL_ListBoxDP* pData = 798 rtItem.Set(0, size.y, fWidth, fItemHeight);
810 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 799 IFWL_ListBoxDP* pData =
811 pData->SetItemRect(this, pItem, rtItem); 800 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
812 } 801 pData->SetItemRect(this, pItem, rtItem);
813 size.x = fWidth;
814 size.y += fItemHeight;
815 } 802 }
803 size.x = fWidth;
804 size.y += fItemHeight;
816 } 805 }
817 806
818 FX_FLOAT IFWL_ListBox::GetMaxTextWidth() { 807 FX_FLOAT IFWL_ListBox::GetMaxTextWidth() {
819 FX_FLOAT fRet = 0.0f; 808 FX_FLOAT fRet = 0.0f;
820 IFWL_ListBoxDP* pData = 809 IFWL_ListBoxDP* pData =
821 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 810 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
822 int32_t iCount = pData->CountItems(this); 811 int32_t iCount = pData->CountItems(this);
823 for (int32_t i = 0; i < iCount; i++) { 812 for (int32_t i = 0; i < iCount; i++) {
824 CFWL_ListItem* pItem = pData->GetItem(this, i); 813 CFWL_ListItem* pItem = pData->GetItem(this, i);
825 if (!pItem) { 814 if (!pItem)
826 continue; 815 continue;
827 } 816
828 CFX_WideString wsText; 817 CFX_WideString wsText;
829 pData->GetItemText(this, pItem, wsText); 818 pData->GetItemText(this, pItem, wsText);
830 CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider); 819 CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider);
831 if (sz.x > fRet) { 820 fRet = std::max(fRet, sz.x);
832 fRet = sz.x;
833 }
834 } 821 }
835 return fRet; 822 return fRet;
836 } 823 }
837 824
838 FX_FLOAT IFWL_ListBox::GetScrollWidth() { 825 FX_FLOAT IFWL_ListBox::GetScrollWidth() {
839 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( 826 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>(
840 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 827 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
841 if (!pfWidth) 828 if (!pfWidth)
842 return 0; 829 return 0;
843 return *pfWidth; 830 return *pfWidth;
844 } 831 }
845 832
846 FX_FLOAT IFWL_ListBox::CalcItemHeight() { 833 FX_FLOAT IFWL_ListBox::CalcItemHeight() {
847 FX_FLOAT* pfFont = 834 FX_FLOAT* pfFont =
848 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); 835 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize));
849 if (!pfFont) 836 if (!pfFont)
850 return 20; 837 return 20;
851 return *pfFont + 2 * kItemTextMargin; 838 return *pfFont + 2 * kItemTextMargin;
852 } 839 }
853 840
854 void IFWL_ListBox::InitScrollBar(bool bVert) { 841 void IFWL_ListBox::InitScrollBar(bool bVert) {
855 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { 842 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar))
856 return; 843 return;
857 } 844
858 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); 845 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
859 prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; 846 prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
860 prop->m_dwStates = FWL_WGTSTATE_Invisible; 847 prop->m_dwStates = FWL_WGTSTATE_Invisible;
861 prop->m_pParent = this; 848 prop->m_pParent = this;
862 prop->m_pThemeProvider = m_pScrollBarTP; 849 prop->m_pThemeProvider = m_pScrollBarTP;
863 IFWL_ScrollBar* sb = new IFWL_ScrollBar(m_pOwnerApp, std::move(prop), this); 850 IFWL_ScrollBar* sb = new IFWL_ScrollBar(m_pOwnerApp, std::move(prop), this);
864 if (bVert) 851 if (bVert)
865 m_pVertScrollBar.reset(sb); 852 m_pVertScrollBar.reset(sb);
866 else 853 else
867 m_pHorzScrollBar.reset(sb); 854 m_pHorzScrollBar.reset(sb);
868 } 855 }
869 856
870 bool IFWL_ListBox::IsShowScrollBar(bool bVert) { 857 bool IFWL_ListBox::IsShowScrollBar(bool bVert) {
871 IFWL_ScrollBar* pScrollbar = 858 IFWL_ScrollBar* pScrollbar =
872 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); 859 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
873 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { 860 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible))
874 return false; 861 return false;
875 }
876 return !(m_pProperties->m_dwStyleExes & 862 return !(m_pProperties->m_dwStyleExes &
877 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || 863 FWL_STYLEEXT_LTB_ShowScrollBarFocus) ||
878 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); 864 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
879 } 865 }
880 866
881 void IFWL_ListBox::ProcessSelChanged() { 867 void IFWL_ListBox::ProcessSelChanged() {
882 CFWL_EvtLtbSelChanged selEvent; 868 CFWL_EvtLtbSelChanged selEvent;
883 selEvent.m_pSrcTarget = this; 869 selEvent.m_pSrcTarget = this;
884 CFX_Int32Array arrSels; 870 CFX_Int32Array arrSels;
885 int32_t iCount = CountSelItems(); 871 int32_t iCount = CountSelItems();
886 for (int32_t i = 0; i < iCount; i++) { 872 for (int32_t i = 0; i < iCount; i++) {
887 CFWL_ListItem* item = GetSelItem(i); 873 CFWL_ListItem* item = GetSelItem(i);
888 if (!item) { 874 if (!item)
889 continue; 875 continue;
890 }
891 selEvent.iarraySels.Add(i); 876 selEvent.iarraySels.Add(i);
892 } 877 }
893 DispatchEvent(&selEvent); 878 DispatchEvent(&selEvent);
894 } 879 }
895 880
896 void IFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) { 881 void IFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) {
897 if (!pMessage) 882 if (!pMessage)
898 return; 883 return;
899 if (!IsEnabled()) 884 if (!IsEnabled())
900 return; 885 return;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 break; 1034 break;
1050 } 1035 }
1051 } 1036 }
1052 1037
1053 void IFWL_ListBox::OnVK(CFWL_ListItem* pItem, bool bShift, bool bCtrl) { 1038 void IFWL_ListBox::OnVK(CFWL_ListItem* pItem, bool bShift, bool bCtrl) {
1054 if (!pItem) 1039 if (!pItem)
1055 return; 1040 return;
1056 1041
1057 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { 1042 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) {
1058 if (bCtrl) { 1043 if (bCtrl) {
1044 // Do nothing.
1059 } else if (bShift) { 1045 } else if (bShift) {
1060 if (m_hAnchor) 1046 if (m_hAnchor)
1061 SetSelection(m_hAnchor, pItem, true); 1047 SetSelection(m_hAnchor, pItem, true);
1062 else 1048 else
1063 SetSelectionDirect(pItem, true); 1049 SetSelectionDirect(pItem, true);
1064 } else { 1050 } else {
1065 SetSelection(pItem, pItem, true); 1051 SetSelection(pItem, pItem, true);
1066 m_hAnchor = pItem; 1052 m_hAnchor = pItem;
1067 } 1053 }
1068 } else { 1054 } else {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 Repaint(&m_rtClient); 1117 Repaint(&m_rtClient);
1132 } 1118 }
1133 return true; 1119 return true;
1134 } 1120 }
1135 1121
1136 void IFWL_ListBox::DispatchSelChangedEv() { 1122 void IFWL_ListBox::DispatchSelChangedEv() {
1137 CFWL_EvtLtbSelChanged ev; 1123 CFWL_EvtLtbSelChanged ev;
1138 ev.m_pSrcTarget = this; 1124 ev.m_pSrcTarget = this;
1139 DispatchEvent(&ev); 1125 DispatchEvent(&ev);
1140 } 1126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698