Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <tools/debug.hxx>
31 : :
32 : : #include <vcl/svapp.hxx>
33 : : #include <vcl/settings.hxx>
34 : : #include <vcl/event.hxx>
35 : : #include <vcl/scrbar.hxx>
36 : : #include <vcl/help.hxx>
37 : : #include <vcl/lstbox.h>
38 : : #include <vcl/unohelp.hxx>
39 : : #include <vcl/i18nhelp.hxx>
40 : :
41 : : #include <ilstbox.hxx>
42 : : #include <controldata.hxx>
43 : : #include <svdata.hxx>
44 : :
45 : : #include <com/sun/star/i18n/XCollator.hpp>
46 : : #include <com/sun/star/accessibility/XAccessible.hpp>
47 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
48 : :
49 : : #include <rtl/instance.hxx>
50 : : #include <comphelper/string.hxx>
51 : : #include <comphelper/processfactory.hxx>
52 : :
53 : : #define MULTILINE_ENTRY_DRAW_FLAGS ( TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE | TEXT_DRAW_VCENTER )
54 : :
55 : : using namespace ::com::sun::star;
56 : :
57 : : // =======================================================================
58 : :
59 : 5275 : void ImplInitFieldSettings( Window* pWin, sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
60 : : {
61 : 5275 : const StyleSettings& rStyleSettings = pWin->GetSettings().GetStyleSettings();
62 : :
63 [ + + ]: 5275 : if ( bFont )
64 : : {
65 [ + - ]: 4900 : Font aFont = rStyleSettings.GetFieldFont();
66 [ + - ][ + + ]: 4900 : if ( pWin->IsControlFont() )
67 [ + - ][ + - ]: 885 : aFont.Merge( pWin->GetControlFont() );
[ + - ]
68 [ + - ][ + - ]: 4900 : pWin->SetZoomedPointFont( aFont );
69 : : }
70 : :
71 [ + + ][ + - ]: 5275 : if ( bFont || bForeground )
72 : : {
73 : 5275 : Color aTextColor = rStyleSettings.GetFieldTextColor();
74 [ - + ][ + - ]: 5275 : if ( pWin->IsControlForeground() )
75 [ # # ]: 0 : aTextColor = pWin->GetControlForeground();
76 [ + - ]: 5275 : pWin->SetTextColor( aTextColor );
77 : : }
78 : :
79 [ + + ]: 5275 : if ( bBackground )
80 : : {
81 [ - + ]: 4301 : if( pWin->IsControlBackground() )
82 [ # # ][ # # ]: 0 : pWin->SetBackground( pWin->GetControlBackground() );
[ # # ]
83 : : else
84 [ + - ]: 4301 : pWin->SetBackground( rStyleSettings.GetFieldColor() );
85 : : }
86 : 5275 : }
87 : :
88 : : // -----------------------------------------------------------------------
89 : :
90 : 4267 : void ImplInitDropDownButton( PushButton* pButton )
91 : : {
92 [ - + ]: 4267 : if ( pButton->GetSettings().GetStyleSettings().GetOptions() & STYLE_OPTION_SPINUPDOWN )
93 : 0 : pButton->SetSymbol( SYMBOL_SPIN_UPDOWN );
94 : : else
95 : 4267 : pButton->SetSymbol( SYMBOL_SPIN_DOWN );
96 : :
97 [ - + # # ]: 4267 : if ( pButton->IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL)
[ - + ]
98 : 0 : && ! pButton->IsNativeControlSupported(CTRL_LISTBOX, PART_BUTTON_DOWN) )
99 : 0 : pButton->SetBackground();
100 : 4267 : }
101 : :
102 : : // =======================================================================
103 : :
104 : 3860 : ImplEntryList::ImplEntryList( Window* pWindow )
105 : : {
106 : 3860 : mpWindow = pWindow;
107 : 3860 : mnLastSelected = LISTBOX_ENTRY_NOTFOUND;
108 : 3860 : mnSelectionAnchor = LISTBOX_ENTRY_NOTFOUND;
109 : 3860 : mnImages = 0;
110 : 3860 : mbCallSelectionChangedHdl = sal_True;
111 : :
112 : 3860 : mnMRUCount = 0;
113 : 3860 : mnMaxMRUCount = 0;
114 : 3860 : }
115 : :
116 : : // -----------------------------------------------------------------------
117 : :
118 : 3856 : ImplEntryList::~ImplEntryList()
119 : : {
120 [ + - ]: 3856 : Clear();
121 : 3856 : }
122 : :
123 : : // -----------------------------------------------------------------------
124 : :
125 : 19369 : void ImplEntryList::Clear()
126 : : {
127 : 19369 : mnImages = 0;
128 : 19369 : maEntries.clear();
129 : 19369 : }
130 : :
131 : : // -----------------------------------------------------------------------
132 : :
133 : 4704 : void ImplEntryList::SelectEntry( sal_uInt16 nPos, sal_Bool bSelect )
134 : : {
135 [ + - ]: 4704 : if (nPos < maEntries.size())
136 : : {
137 [ + - ][ + - ]: 4704 : boost::ptr_vector<ImplEntryType>::iterator iter = maEntries.begin()+nPos;
138 : :
139 [ + - ][ + - ]: 9408 : if ( ( iter->mbIsSelected != bSelect ) &&
[ + - ][ + - ]
140 [ + - ]: 4704 : ( (iter->mnFlags & LISTBOX_ENTRY_FLAG_DISABLE_SELECTION) == 0 ) )
141 : : {
142 [ + - ]: 4704 : iter->mbIsSelected = bSelect;
143 [ + + ]: 4704 : if ( mbCallSelectionChangedHdl )
144 [ + - ]: 4704 : maSelectionChangedHdl.Call( (void*)sal_IntPtr(nPos) );
145 : : }
146 : : }
147 : 4704 : }
148 : :
149 : : namespace
150 : : {
151 : : struct theSorter
152 : : : public rtl::StaticWithInit< comphelper::string::NaturalStringSorter, theSorter >
153 : : {
154 : 38 : comphelper::string::NaturalStringSorter operator () ()
155 : : {
156 : : return comphelper::string::NaturalStringSorter(
157 : : ::comphelper::getProcessComponentContext(),
158 [ + - ]: 38 : Application::GetSettings().GetLocale());
159 : : }
160 : : };
161 : : }
162 : :
163 : : namespace vcl
164 : : {
165 : : namespace unohelper
166 : : {
167 : 0 : const comphelper::string::NaturalStringSorter& getNaturalStringSorterForAppLocale()
168 : : {
169 : 0 : return theSorter::get();
170 : : }
171 : : }
172 : : }
173 : :
174 : 150807 : sal_uInt16 ImplEntryList::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry, sal_Bool bSort )
175 : : {
176 [ + + ]: 150807 : if ( !!pNewEntry->maImage )
177 : 1512 : mnImages++;
178 : :
179 : 150807 : sal_uInt16 insPos = 0;
180 : :
181 [ + + ][ + + ]: 150807 : if ( !bSort || maEntries.empty())
[ + + ]
182 : : {
183 [ + + ]: 110433 : if (nPos < maEntries.size())
184 : : {
185 : 9911 : insPos = nPos;
186 : 9911 : maEntries.insert( maEntries.begin() + nPos, pNewEntry );
187 : : }
188 : : else
189 : : {
190 : 100522 : insPos = maEntries.size();
191 : 100522 : maEntries.push_back(pNewEntry);
192 : : }
193 : : }
194 : : else
195 : : {
196 : 40374 : const comphelper::string::NaturalStringSorter &rSorter = theSorter::get();
197 : :
198 : 40374 : const XubString& rStr = pNewEntry->maStr;
199 : : sal_uLong nLow, nHigh, nMid;
200 : :
201 : 40374 : nHigh = maEntries.size();
202 : :
203 : 40374 : ImplEntryType* pTemp = GetEntry( (sal_uInt16)(nHigh-1) );
204 : :
205 : : try
206 : : {
207 : : // XXX even though XCollator::compareString returns a sal_Int32 the only
208 : : // defined values are {-1, 0, 1} which is compatible with StringCompare
209 [ + - ][ + - ]: 40374 : StringCompare eComp = (StringCompare)rSorter.compare(rStr, pTemp->maStr);
[ + - ]
210 : :
211 : : // Schnelles Einfuegen bei sortierten Daten
212 [ + + ]: 40374 : if ( eComp != COMPARE_LESS )
213 : : {
214 : 39170 : insPos = maEntries.size();
215 [ + - ]: 39170 : maEntries.push_back(pNewEntry);
216 : : }
217 : : else
218 : : {
219 : 1204 : nLow = mnMRUCount;
220 [ + - ]: 1204 : pTemp = (ImplEntryType*)GetEntry( (sal_uInt16)nLow );
221 : :
222 [ + - ][ + - ]: 1204 : eComp = (StringCompare)rSorter.compare(rStr, pTemp->maStr);
[ + - ]
223 [ + + ]: 1204 : if ( eComp != COMPARE_GREATER )
224 : : {
225 : 438 : insPos = 0;
226 [ + - ][ + - ]: 438 : maEntries.insert(maEntries.begin(),pNewEntry);
227 : : }
228 : : else
229 : : {
230 : : // Binaeres Suchen
231 : 766 : nHigh--;
232 [ + + ]: 1580 : do
233 : : {
234 : 1580 : nMid = (nLow + nHigh) / 2;
235 [ + - ]: 1580 : pTemp = (ImplEntryType*)GetEntry( nMid );
236 : :
237 [ + - ][ + - ]: 1580 : eComp = (StringCompare)rSorter.compare(rStr, pTemp->maStr);
[ + - ]
238 : :
239 [ + + ]: 1580 : if ( eComp == COMPARE_LESS )
240 : 766 : nHigh = nMid-1;
241 : : else
242 : : {
243 [ + - ]: 814 : if ( eComp == COMPARE_GREATER )
244 : 814 : nLow = nMid + 1;
245 : : else
246 : 0 : break;
247 : : }
248 : : }
249 : : while ( nLow <= nHigh );
250 : :
251 [ + + ]: 766 : if ( eComp != COMPARE_LESS )
252 : 196 : nMid++;
253 : :
254 : 766 : insPos = nMid;
255 [ + - ][ + - ]: 766 : maEntries.insert(maEntries.begin()+nMid,pNewEntry);
[ + - ]
256 : : }
257 : : }
258 : : }
259 [ # # ]: 0 : catch (uno::RuntimeException& )
260 : : {
261 : : // XXX this is arguable, if the exception occurred because pNewEntry is
262 : : // garbage you wouldn't insert it. If the exception occurred because the
263 : : // Collator implementation is garbage then give the user a chance to see
264 : : // his stuff
265 : 0 : insPos = 0;
266 [ # # # # ]: 0 : maEntries.insert(maEntries.begin(),pNewEntry);
267 : : }
268 : :
269 : : }
270 : :
271 : 150807 : return insPos;
272 : : }
273 : :
274 : : // -----------------------------------------------------------------------
275 : :
276 : 0 : void ImplEntryList::RemoveEntry( sal_uInt16 nPos )
277 : : {
278 [ # # ]: 0 : if (nPos < maEntries.size())
279 : : {
280 [ # # ][ # # ]: 0 : boost::ptr_vector<ImplEntryType>::iterator iter = maEntries.begin()+ nPos;
281 : :
282 [ # # ][ # # ]: 0 : if ( !!iter->maImage )
283 : 0 : mnImages--;
284 : :
285 [ # # ]: 0 : maEntries.erase(iter);
286 : : }
287 : 0 : }
288 : :
289 : : // -----------------------------------------------------------------------
290 : :
291 : 11774 : sal_uInt16 ImplEntryList::FindEntry( const XubString& rString, sal_Bool bSearchMRUArea ) const
292 : : {
293 : 11774 : sal_uInt16 nEntries = maEntries.size();
294 [ + + ][ + - ]: 41096 : for ( sal_uInt16 n = bSearchMRUArea ? 0 : GetMRUCount(); n < nEntries; n++ )
295 : : {
296 [ + - ][ + - ]: 29322 : String aComp( vcl::I18nHelper::filterFormattingChars( maEntries[n].maStr ) );
297 [ + - ][ + + ]: 29322 : if ( aComp == rString )
298 : 29322 : return n;
299 [ + - ][ + + ]: 29322 : }
300 : 11774 : return LISTBOX_ENTRY_NOTFOUND;
301 : : }
302 : :
303 : : // -----------------------------------------------------------------------
304 : :
305 : 9852 : sal_uInt16 ImplEntryList::FindMatchingEntry( const XubString& rStr, sal_uInt16 nStart, sal_Bool bForward, sal_Bool bLazy ) const
306 : : {
307 : 9852 : sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND;
308 : 9852 : sal_uInt16 nEntryCount = GetEntryCount();
309 [ - + ]: 9852 : if ( !bForward )
310 : 0 : nStart++; // wird sofort dekrementiert
311 : :
312 : 9852 : const vcl::I18nHelper& rI18nHelper = mpWindow->GetSettings().GetLocaleI18nHelper();
313 [ + - ][ + + ]: 10903 : for ( sal_uInt16 n = nStart; bForward ? ( n < nEntryCount ) : n; )
314 : : {
315 [ - + ]: 1100 : if ( !bForward )
316 : 0 : n--;
317 : :
318 : 1100 : ImplEntryType* pImplEntry = GetEntry( n );
319 [ + - ][ + - ]: 1100 : sal_Bool bMatch = bLazy ? rI18nHelper.MatchString( rStr, pImplEntry->maStr ) != 0 : ( rStr.Match( pImplEntry->maStr ) == STRING_MATCH );
[ + - ][ # # ]
[ + - ][ + - ]
[ # # # # ]
[ + - ]
320 [ + + ]: 1100 : if ( bMatch )
321 : : {
322 : 49 : nPos = n;
323 : 49 : break;
324 : : }
325 : :
326 [ + - ]: 1051 : if ( bForward )
327 : 1051 : n++;
328 : : }
329 : :
330 : 9852 : return nPos;
331 : : }
332 : :
333 : : // -----------------------------------------------------------------------
334 : :
335 : 0 : sal_uInt16 ImplEntryList::FindEntry( const void* pData ) const
336 : : {
337 : 0 : sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND;
338 [ # # ]: 0 : for ( sal_uInt16 n = GetEntryCount(); n; )
339 : : {
340 : 0 : ImplEntryType* pImplEntry = GetEntry( --n );
341 [ # # ]: 0 : if ( pImplEntry->mpUserData == pData )
342 : : {
343 : 0 : nPos = n;
344 : 0 : break;
345 : : }
346 : : }
347 : 0 : return nPos;
348 : : }
349 : :
350 : : // -----------------------------------------------------------------------
351 : :
352 : 22185 : long ImplEntryList::GetAddedHeight( sal_uInt16 i_nEndIndex, sal_uInt16 i_nBeginIndex, long i_nBeginHeight ) const
353 : : {
354 : 22185 : long nHeight = i_nBeginHeight;
355 [ + + ]: 22185 : sal_uInt16 nStart = i_nEndIndex > i_nBeginIndex ? i_nBeginIndex : i_nEndIndex;
356 [ + + ]: 22185 : sal_uInt16 nStop = i_nEndIndex > i_nBeginIndex ? i_nEndIndex : i_nBeginIndex;
357 : 22185 : sal_uInt16 nEntryCount = GetEntryCount();
358 [ + - ][ + + ]: 22185 : if( nStop != LISTBOX_ENTRY_NOTFOUND && nEntryCount != 0 )
359 : : {
360 : : // sanity check
361 [ - + ]: 21915 : if( nStop > nEntryCount-1 )
362 : 0 : nStop = nEntryCount-1;
363 [ - + ]: 21915 : if( nStart > nEntryCount-1 )
364 : 0 : nStart = nEntryCount-1;
365 : :
366 : 21915 : sal_uInt16 nIndex = nStart;
367 [ + - ][ + + ]: 103511 : while( nIndex != LISTBOX_ENTRY_NOTFOUND && nIndex < nStop )
[ + + ]
368 : : {
369 : 81596 : nHeight += GetEntryPtr( nIndex )-> mnHeight;
370 : 81596 : nIndex++;
371 : 21915 : }
372 : : }
373 : : else
374 : 270 : nHeight = 0;
375 [ + + ]: 22185 : return i_nEndIndex > i_nBeginIndex ? nHeight : -nHeight;
376 : : }
377 : :
378 : : // -----------------------------------------------------------------------
379 : :
380 : 4160 : long ImplEntryList::GetEntryHeight( sal_uInt16 nPos ) const
381 : : {
382 : 4160 : ImplEntryType* pImplEntry = GetEntry( nPos );
383 [ + + ]: 4160 : return pImplEntry ? pImplEntry->mnHeight : 0;
384 : : }
385 : :
386 : : // -----------------------------------------------------------------------
387 : :
388 : 9613 : XubString ImplEntryList::GetEntryText( sal_uInt16 nPos ) const
389 : : {
390 : 9613 : XubString aEntryText;
391 [ + - ]: 9613 : ImplEntryType* pImplEntry = GetEntry( nPos );
392 [ + + ]: 9613 : if ( pImplEntry )
393 [ + - ]: 9609 : aEntryText = pImplEntry->maStr;
394 : 9613 : return aEntryText;
395 : : }
396 : :
397 : : // -----------------------------------------------------------------------
398 : :
399 : 4833 : sal_Bool ImplEntryList::HasEntryImage( sal_uInt16 nPos ) const
400 : : {
401 : 4833 : sal_Bool bImage = sal_False;
402 : 4833 : ImplEntryType* pImplEntry = GetEntry( nPos );
403 [ + - ]: 4833 : if ( pImplEntry )
404 : 4833 : bImage = !!pImplEntry->maImage;
405 : 4833 : return bImage;
406 : : }
407 : :
408 : : // -----------------------------------------------------------------------
409 : :
410 : 206 : Image ImplEntryList::GetEntryImage( sal_uInt16 nPos ) const
411 : : {
412 : 206 : Image aImage;
413 [ + - ]: 206 : ImplEntryType* pImplEntry = GetEntry( nPos );
414 [ + - ]: 206 : if ( pImplEntry )
415 [ + - ]: 206 : aImage = pImplEntry->maImage;
416 : 206 : return aImage;
417 : : }
418 : :
419 : : // -----------------------------------------------------------------------
420 : :
421 : 31026 : void ImplEntryList::SetEntryData( sal_uInt16 nPos, void* pNewData )
422 : : {
423 : 31026 : ImplEntryType* pImplEntry = GetEntry( nPos );
424 [ + - ]: 31026 : if ( pImplEntry )
425 : 31026 : pImplEntry->mpUserData = pNewData;
426 : 31026 : }
427 : :
428 : : // -----------------------------------------------------------------------
429 : :
430 : 0 : void* ImplEntryList::GetEntryData( sal_uInt16 nPos ) const
431 : : {
432 : 0 : ImplEntryType* pImplEntry = GetEntry( nPos );
433 [ # # ]: 0 : return pImplEntry ? pImplEntry->mpUserData : NULL;
434 : : }
435 : :
436 : : // -----------------------------------------------------------------------
437 : :
438 : 0 : void ImplEntryList::SetEntryFlags( sal_uInt16 nPos, long nFlags )
439 : : {
440 : 0 : ImplEntryType* pImplEntry = GetEntry( nPos );
441 [ # # ]: 0 : if ( pImplEntry )
442 : 0 : pImplEntry->mnFlags = nFlags;
443 : 0 : }
444 : :
445 : : // -----------------------------------------------------------------------
446 : :
447 : 0 : long ImplEntryList::GetEntryFlags( sal_uInt16 nPos ) const
448 : : {
449 : 0 : ImplEntryType* pImplEntry = GetEntry( nPos );
450 [ # # ]: 0 : return pImplEntry ? pImplEntry->mnFlags : 0;
451 : : }
452 : :
453 : : // -----------------------------------------------------------------------
454 : :
455 : 972 : sal_uInt16 ImplEntryList::GetSelectEntryCount() const
456 : : {
457 : 972 : sal_uInt16 nSelCount = 0;
458 [ + + ]: 28457 : for ( sal_uInt16 n = GetEntryCount(); n; )
459 : : {
460 : 27485 : ImplEntryType* pImplEntry = GetEntry( --n );
461 [ + + ]: 27485 : if ( pImplEntry->mbIsSelected )
462 : 380 : nSelCount++;
463 : : }
464 : 972 : return nSelCount;
465 : : }
466 : :
467 : : // -----------------------------------------------------------------------
468 : :
469 : 0 : XubString ImplEntryList::GetSelectEntry( sal_uInt16 nIndex ) const
470 : : {
471 : 0 : return GetEntryText( GetSelectEntryPos( nIndex ) );
472 : : }
473 : :
474 : : // -----------------------------------------------------------------------
475 : :
476 : 18464 : sal_uInt16 ImplEntryList::GetSelectEntryPos( sal_uInt16 nIndex ) const
477 : : {
478 : 18464 : sal_uInt16 nSelEntryPos = LISTBOX_ENTRY_NOTFOUND;
479 : 18464 : sal_uInt16 nSel = 0;
480 : 18464 : sal_uInt16 nEntryCount = GetEntryCount();
481 : :
482 [ + + ]: 138816 : for ( sal_uInt16 n = 0; n < nEntryCount; n++ )
483 : : {
484 : 124221 : ImplEntryType* pImplEntry = GetEntry( n );
485 [ + + ]: 124221 : if ( pImplEntry->mbIsSelected )
486 : : {
487 [ + + ]: 3909 : if ( nSel == nIndex )
488 : : {
489 : 3869 : nSelEntryPos = n;
490 : 3869 : break;
491 : : }
492 : 40 : nSel++;
493 : : }
494 : : }
495 : :
496 : 18464 : return nSelEntryPos;
497 : : }
498 : :
499 : : // -----------------------------------------------------------------------
500 : :
501 : 15361 : sal_Bool ImplEntryList::IsEntryPosSelected( sal_uInt16 nIndex ) const
502 : : {
503 : 15361 : ImplEntryType* pImplEntry = GetEntry( nIndex );
504 [ + + ]: 15361 : return pImplEntry ? pImplEntry->mbIsSelected : sal_False;
505 : : }
506 : :
507 : : // -----------------------------------------------------------------------
508 : :
509 : 4702 : bool ImplEntryList::IsEntrySelectable( sal_uInt16 nPos ) const
510 : : {
511 : 4702 : ImplEntryType* pImplEntry = GetEntry( nPos );
512 [ + - ][ + - ]: 4702 : return pImplEntry ? ((pImplEntry->mnFlags & LISTBOX_ENTRY_FLAG_DISABLE_SELECTION) == 0) : true;
513 : : }
514 : :
515 : : // -----------------------------------------------------------------------
516 : :
517 : 0 : sal_uInt16 ImplEntryList::FindFirstSelectable( sal_uInt16 nPos, bool bForward /* = true */ )
518 : : {
519 [ # # ]: 0 : if( IsEntrySelectable( nPos ) )
520 : 0 : return nPos;
521 : :
522 [ # # ]: 0 : if( bForward )
523 : : {
524 [ # # ]: 0 : for( nPos = nPos + 1; nPos < GetEntryCount(); nPos++ )
525 : : {
526 [ # # ]: 0 : if( IsEntrySelectable( nPos ) )
527 : 0 : return nPos;
528 : : }
529 : : }
530 : : else
531 : : {
532 [ # # ]: 0 : while( nPos )
533 : : {
534 : 0 : nPos--;
535 [ # # ]: 0 : if( IsEntrySelectable( nPos ) )
536 : 0 : return nPos;
537 : : }
538 : : }
539 : :
540 : 0 : return LISTBOX_ENTRY_NOTFOUND;
541 : : }
542 : :
543 : : // =======================================================================
544 : :
545 : 3860 : ImplListBoxWindow::ImplListBoxWindow( Window* pParent, WinBits nWinStyle ) :
546 : : Control( pParent, 0 ),
547 [ + - ][ + - ]: 3860 : maQuickSelectionEngine( *this )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
548 : : {
549 [ + - ][ + - ]: 3860 : mpEntryList = new ImplEntryList( this );
550 : :
551 : 3860 : mnTop = 0;
552 : 3860 : mnLeft = 0;
553 : 3860 : mnBorder = 1;
554 : 3860 : mnSelectModifier = 0;
555 : 3860 : mnUserDrawEntry = LISTBOX_ENTRY_NOTFOUND;
556 : 3860 : mbTrack = sal_False;
557 : 3860 : mbImgsDiffSz = sal_False;
558 : 3860 : mbTravelSelect = sal_False;
559 : 3860 : mbTrackingSelect = sal_False;
560 : 3860 : mbSelectionChanged = sal_False;
561 : 3860 : mbMouseMoveSelect = sal_False;
562 : 3860 : mbMulti = sal_False;
563 : 3860 : mbStackMode = sal_False;
564 : 3860 : mbGrabFocus = sal_False;
565 : 3860 : mbUserDrawEnabled = sal_False;
566 : 3860 : mbInUserDraw = sal_False;
567 : 3860 : mbReadOnly = sal_False;
568 : 3860 : mbHasFocusRect = sal_False;
569 [ - + ]: 3860 : mbRight = ( nWinStyle & WB_RIGHT ) ? sal_True : sal_False;
570 [ + + ]: 3860 : mbCenter = ( nWinStyle & WB_CENTER ) ? sal_True : sal_False;
571 [ + + ]: 3860 : mbSimpleMode = ( nWinStyle & WB_SIMPLEMODE ) ? sal_True : sal_False;
572 [ + + ]: 3860 : mbSort = ( nWinStyle & WB_SORT ) ? sal_True : sal_False;
573 : :
574 : : // pb: #106948# explicit mirroring for calc
575 : 3860 : mbMirroring = sal_False;
576 : :
577 : 3860 : mnCurrentPos = LISTBOX_ENTRY_NOTFOUND;
578 : 3860 : mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND;
579 : 3860 : mnSeparatorPos = LISTBOX_ENTRY_NOTFOUND;
580 : 3860 : meProminentType = PROMINENT_TOP;
581 : :
582 [ + - ]: 3860 : SetLineColor();
583 [ + - ]: 3860 : SetTextFillColor();
584 [ + - ][ + - ]: 3860 : SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) );
[ + - ]
585 : :
586 [ + - ]: 3860 : ImplInitSettings( sal_True, sal_True, sal_True );
587 [ + - ]: 3860 : ImplCalcMetrics();
588 : 3860 : }
589 : :
590 : : // -----------------------------------------------------------------------
591 : :
592 [ + - ]: 3856 : ImplListBoxWindow::~ImplListBoxWindow()
593 : : {
594 [ + - ][ + - ]: 3856 : delete mpEntryList;
595 [ - + ]: 3856 : }
596 : :
597 : : // -----------------------------------------------------------------------
598 : :
599 : 5091 : void ImplListBoxWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
600 : : {
601 : 5091 : ImplInitFieldSettings( this, bFont, bForeground, bBackground );
602 : 5091 : }
603 : :
604 : : // -----------------------------------------------------------------------
605 : :
606 : 6898 : void ImplListBoxWindow::ImplCalcMetrics()
607 : : {
608 : 6898 : mnMaxWidth = 0;
609 : 6898 : mnMaxTxtWidth = 0;
610 : 6898 : mnMaxImgWidth = 0;
611 : 6898 : mnMaxImgTxtWidth= 0;
612 : 6898 : mnMaxImgHeight = 0;
613 : :
614 : 6898 : mnTextHeight = (sal_uInt16)GetTextHeight();
615 : 6898 : mnMaxTxtHeight = mnTextHeight + mnBorder;
616 : 6898 : mnMaxHeight = mnMaxTxtHeight;
617 : :
618 [ + + ]: 6898 : if ( maUserItemSize.Height() > mnMaxHeight )
619 : 2 : mnMaxHeight = (sal_uInt16) maUserItemSize.Height();
620 [ + + ]: 6898 : if ( maUserItemSize.Width() > mnMaxWidth )
621 : 1221 : mnMaxWidth= (sal_uInt16) maUserItemSize.Width();
622 : :
623 [ + + ]: 8633 : for ( sal_uInt16 n = mpEntryList->GetEntryCount(); n; )
624 : : {
625 : 1735 : ImplEntryType* pEntry = mpEntryList->GetMutableEntryPtr( --n );
626 : 1735 : ImplUpdateEntryMetrics( *pEntry );
627 : : }
628 : :
629 [ - + ]: 6898 : if( mnCurrentPos != LISTBOX_ENTRY_NOTFOUND )
630 : : {
631 [ # # ]: 0 : Size aSz( GetOutputSizePixel().Width(), mpEntryList->GetEntryPtr( mnCurrentPos )->mnHeight );
632 [ # # ]: 0 : maFocusRect.SetSize( aSz );
633 : : }
634 : 6898 : }
635 : :
636 : : // -----------------------------------------------------------------------
637 : :
638 : 15513 : void ImplListBoxWindow::Clear()
639 : : {
640 : 15513 : mpEntryList->Clear();
641 : :
642 : 15513 : mnMaxHeight = mnMaxTxtHeight;
643 : 15513 : mnMaxWidth = 0;
644 : 15513 : mnMaxTxtWidth = 0;
645 : 15513 : mnMaxImgTxtWidth= 0;
646 : 15513 : mnMaxImgWidth = 0;
647 : 15513 : mnMaxImgHeight = 0;
648 : 15513 : mnTop = 0;
649 : 15513 : mnLeft = 0;
650 : 15513 : mbImgsDiffSz = sal_False;
651 : 15513 : ImplClearLayoutData();
652 : :
653 : 15513 : mnCurrentPos = LISTBOX_ENTRY_NOTFOUND;
654 : 15513 : maQuickSelectionEngine.Reset();
655 : :
656 : 15513 : Invalidate();
657 : 15513 : }
658 : :
659 : 2182 : void ImplListBoxWindow::SetUserItemSize( const Size& rSz )
660 : : {
661 : 2182 : ImplClearLayoutData();
662 : 2182 : maUserItemSize = rSz;
663 : 2182 : ImplCalcMetrics();
664 : 2182 : }
665 : :
666 : : // -----------------------------------------------------------------------
667 : :
668 : : struct ImplEntryMetrics
669 : : {
670 : : sal_Bool bText;
671 : : sal_Bool bImage;
672 : : long nEntryWidth;
673 : : long nEntryHeight;
674 : : long nTextWidth;
675 : : long nImgWidth;
676 : : long nImgHeight;
677 : : };
678 : :
679 : : // -----------------------------------------------------------------------
680 : :
681 : 152542 : void ImplListBoxWindow::ImplUpdateEntryMetrics( ImplEntryType& rEntry )
682 : : {
683 : : ImplEntryMetrics aMetrics;
684 [ + - ]: 152542 : aMetrics.bText = rEntry.maStr.Len() ? sal_True : sal_False;
685 : 152542 : aMetrics.bImage = !!rEntry.maImage;
686 : 152542 : aMetrics.nEntryWidth = 0;
687 : 152542 : aMetrics.nEntryHeight = 0;
688 : 152542 : aMetrics.nTextWidth = 0;
689 : 152542 : aMetrics.nImgWidth = 0;
690 : 152542 : aMetrics.nImgHeight = 0;
691 : :
692 [ + - ]: 152542 : if ( aMetrics.bText )
693 : : {
694 [ - + ]: 152542 : if( (rEntry.mnFlags & LISTBOX_ENTRY_FLAG_MULTILINE) )
695 : : {
696 : : // multiline case
697 [ # # ][ # # ]: 0 : Size aCurSize( PixelToLogic( GetSizePixel() ) );
698 : : // set the current size to a large number
699 : : // GetTextRect should shrink it to the actual size
700 : 0 : aCurSize.Height() = 0x7fffff;
701 [ # # ]: 0 : Rectangle aTextRect( Point( 0, 0 ), aCurSize );
702 [ # # ]: 0 : aTextRect = GetTextRect( aTextRect, rEntry.maStr, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE );
703 [ # # ]: 0 : aMetrics.nTextWidth = aTextRect.GetWidth();
704 [ # # ]: 0 : if( aMetrics.nTextWidth > mnMaxTxtWidth )
705 : 0 : mnMaxTxtWidth = aMetrics.nTextWidth;
706 : 0 : aMetrics.nEntryWidth = mnMaxTxtWidth;
707 [ # # ]: 0 : aMetrics.nEntryHeight = aTextRect.GetHeight() + mnBorder;
708 : : }
709 : : else
710 : : {
711 : : // normal single line case
712 [ + - ]: 152542 : aMetrics.nTextWidth = (sal_uInt16)GetTextWidth( rEntry.maStr );
713 [ + + ]: 152542 : if( aMetrics.nTextWidth > mnMaxTxtWidth )
714 : 44384 : mnMaxTxtWidth = aMetrics.nTextWidth;
715 : 152542 : aMetrics.nEntryWidth = mnMaxTxtWidth;
716 : 152542 : aMetrics.nEntryHeight = mnTextHeight + mnBorder;
717 : : }
718 : : }
719 [ + + ]: 152542 : if ( aMetrics.bImage )
720 : : {
721 [ + - ]: 1512 : Size aImgSz = rEntry.maImage.GetSizePixel();
722 [ + - ]: 1512 : aMetrics.nImgWidth = (sal_uInt16) CalcZoom( aImgSz.Width() );
723 [ + - ]: 1512 : aMetrics.nImgHeight = (sal_uInt16) CalcZoom( aImgSz.Height() );
724 : :
725 [ + + ][ - + ]: 1512 : if( mnMaxImgWidth && ( aMetrics.nImgWidth != mnMaxImgWidth ) )
726 : 0 : mbImgsDiffSz = sal_True;
727 [ + + ][ - + ]: 1512 : else if ( mnMaxImgHeight && ( aMetrics.nImgHeight != mnMaxImgHeight ) )
728 : 0 : mbImgsDiffSz = sal_True;
729 : :
730 [ + + ]: 1512 : if( aMetrics.nImgWidth > mnMaxImgWidth )
731 : 126 : mnMaxImgWidth = aMetrics.nImgWidth;
732 [ + + ]: 1512 : if( aMetrics.nImgHeight > mnMaxImgHeight )
733 : 126 : mnMaxImgHeight = aMetrics.nImgHeight;
734 : :
735 : 1512 : mnMaxImgTxtWidth = Max( mnMaxImgTxtWidth, aMetrics.nTextWidth );
736 : 1512 : aMetrics.nEntryHeight = Max( aMetrics.nImgHeight, aMetrics.nEntryHeight );
737 : :
738 : : }
739 [ + + ][ + + ]: 152542 : if ( IsUserDrawEnabled() || aMetrics.bImage )
[ + + ]
740 : : {
741 : 26552 : aMetrics.nEntryWidth = Max( aMetrics.nImgWidth, maUserItemSize.Width() );
742 [ + - ]: 26552 : if ( aMetrics.bText )
743 : 26552 : aMetrics.nEntryWidth += aMetrics.nTextWidth + IMG_TXT_DISTANCE;
744 : 26552 : aMetrics.nEntryHeight = Max( Max( mnMaxImgHeight, maUserItemSize.Height() ) + 2,
745 : 26552 : aMetrics.nEntryHeight );
746 : : }
747 : :
748 [ - + ][ # # ]: 152542 : if ( !aMetrics.bText && !aMetrics.bImage && !IsUserDrawEnabled() )
[ # # ][ - + ]
749 : : {
750 : : // entries which have no (aka an empty) text, and no image, and are not user-drawn, should be
751 : : // shown nonetheless
752 : 0 : aMetrics.nEntryHeight = mnTextHeight + mnBorder;
753 : : }
754 : :
755 [ + + ]: 152542 : if ( aMetrics.nEntryWidth > mnMaxWidth )
756 : 44384 : mnMaxWidth = aMetrics.nEntryWidth;
757 [ + + ]: 152542 : if ( aMetrics.nEntryHeight > mnMaxHeight )
758 : 4 : mnMaxHeight = aMetrics.nEntryHeight;
759 : :
760 : 152542 : rEntry.mnHeight = aMetrics.nEntryHeight;
761 : 152542 : }
762 : :
763 : : // -----------------------------------------------------------------------
764 : :
765 : 0 : void ImplListBoxWindow::ImplCallSelect()
766 : : {
767 [ # # ][ # # ]: 0 : if ( !IsTravelSelect() && GetEntryList()->GetMaxMRUCount() )
[ # # ]
768 : : {
769 : : // Insert the selected entry as MRU, if not allready first MRU
770 [ # # ]: 0 : sal_uInt16 nSelected = GetEntryList()->GetSelectEntryPos( 0 );
771 : 0 : sal_uInt16 nMRUCount = GetEntryList()->GetMRUCount();
772 [ # # ]: 0 : String aSelected = GetEntryList()->GetEntryText( nSelected );
773 [ # # ]: 0 : sal_uInt16 nFirstMatchingEntryPos = GetEntryList()->FindEntry( aSelected, sal_True );
774 [ # # ][ # # ]: 0 : if ( nFirstMatchingEntryPos || !nMRUCount )
775 : : {
776 : 0 : sal_Bool bSelectNewEntry = sal_False;
777 [ # # ]: 0 : if ( nFirstMatchingEntryPos < nMRUCount )
778 : : {
779 [ # # ]: 0 : RemoveEntry( nFirstMatchingEntryPos );
780 : 0 : nMRUCount--;
781 [ # # ]: 0 : if ( nFirstMatchingEntryPos == nSelected )
782 : 0 : bSelectNewEntry = sal_True;
783 : : }
784 [ # # ]: 0 : else if ( nMRUCount == GetEntryList()->GetMaxMRUCount() )
785 : : {
786 [ # # ]: 0 : RemoveEntry( nMRUCount - 1 );
787 : 0 : nMRUCount--;
788 : : }
789 : :
790 [ # # ]: 0 : ImplClearLayoutData();
791 : :
792 [ # # ][ # # ]: 0 : ImplEntryType* pNewEntry = new ImplEntryType( aSelected );
793 : 0 : pNewEntry->mbIsSelected = bSelectNewEntry;
794 [ # # ]: 0 : GetEntryList()->InsertEntry( 0, pNewEntry, sal_False );
795 [ # # ]: 0 : ImplUpdateEntryMetrics( *pNewEntry );
796 : 0 : GetEntryList()->SetMRUCount( ++nMRUCount );
797 [ # # ]: 0 : SetSeparatorPos( nMRUCount ? nMRUCount-1 : 0 );
798 [ # # ]: 0 : maMRUChangedHdl.Call( NULL );
799 [ # # ]: 0 : }
800 : : }
801 : :
802 : 0 : maSelectHdl.Call( NULL );
803 : 0 : mbSelectionChanged = sal_False;
804 : 0 : }
805 : :
806 : : // -----------------------------------------------------------------------
807 : :
808 : 150807 : sal_uInt16 ImplListBoxWindow::InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry )
809 : : {
810 : 150807 : ImplClearLayoutData();
811 : 150807 : sal_uInt16 nNewPos = mpEntryList->InsertEntry( nPos, pNewEntry, mbSort );
812 : :
813 [ - + ]: 150807 : if( (GetStyle() & WB_WORDBREAK) )
814 : 0 : pNewEntry->mnFlags |= LISTBOX_ENTRY_FLAG_MULTILINE;
815 : :
816 : 150807 : ImplUpdateEntryMetrics( *pNewEntry );
817 : 150807 : return nNewPos;
818 : : }
819 : :
820 : : // -----------------------------------------------------------------------
821 : :
822 : 0 : void ImplListBoxWindow::RemoveEntry( sal_uInt16 nPos )
823 : : {
824 : 0 : ImplClearLayoutData();
825 : 0 : mpEntryList->RemoveEntry( nPos );
826 [ # # ]: 0 : if( mnCurrentPos >= mpEntryList->GetEntryCount() )
827 : 0 : mnCurrentPos = LISTBOX_ENTRY_NOTFOUND;
828 : 0 : ImplCalcMetrics();
829 : 0 : }
830 : :
831 : : // -----------------------------------------------------------------------
832 : :
833 : 0 : void ImplListBoxWindow::SetEntryFlags( sal_uInt16 nPos, long nFlags )
834 : : {
835 : 0 : mpEntryList->SetEntryFlags( nPos, nFlags );
836 : 0 : ImplEntryType* pEntry = mpEntryList->GetMutableEntryPtr( nPos );
837 [ # # ]: 0 : if( pEntry )
838 : 0 : ImplUpdateEntryMetrics( *pEntry );
839 : 0 : }
840 : :
841 : : // -----------------------------------------------------------------------
842 : :
843 : 0 : void ImplListBoxWindow::ImplShowFocusRect()
844 : : {
845 [ # # ]: 0 : if ( mbHasFocusRect )
846 : 0 : HideFocus();
847 : 0 : ShowFocus( maFocusRect );
848 : 0 : mbHasFocusRect = sal_True;
849 : 0 : }
850 : :
851 : : // -----------------------------------------------------------------------
852 : :
853 : 6123 : void ImplListBoxWindow::ImplHideFocusRect()
854 : : {
855 [ - + ]: 6123 : if ( mbHasFocusRect )
856 : : {
857 : 0 : HideFocus();
858 : 0 : mbHasFocusRect = sal_False;
859 : : }
860 : 6123 : }
861 : :
862 : :
863 : : // -----------------------------------------------------------------------
864 : :
865 : 0 : sal_uInt16 ImplListBoxWindow::GetEntryPosForPoint( const Point& rPoint ) const
866 : : {
867 : 0 : long nY = mnBorder;
868 : :
869 : 0 : sal_uInt16 nSelect = mnTop;
870 : 0 : const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nSelect );
871 [ # # ][ # # ]: 0 : while( pEntry && rPoint.Y() > pEntry->mnHeight + nY )
[ # # ]
872 : : {
873 : 0 : nY += pEntry->mnHeight;
874 : 0 : pEntry = mpEntryList->GetEntryPtr( ++nSelect );
875 : : }
876 [ # # ]: 0 : if( pEntry == NULL )
877 : 0 : nSelect = LISTBOX_ENTRY_NOTFOUND;
878 : :
879 : 0 : return nSelect;
880 : : }
881 : :
882 : : // -----------------------------------------------------------------------
883 : :
884 : 7694 : sal_Bool ImplListBoxWindow::IsVisible( sal_uInt16 i_nEntry ) const
885 : : {
886 : 7694 : sal_Bool bRet = sal_False;
887 : :
888 [ + - ]: 7694 : if( i_nEntry >= mnTop )
889 : : {
890 [ + + ]: 15388 : if( mpEntryList->GetAddedHeight( i_nEntry, mnTop ) <
891 [ + - ]: 7694 : PixelToLogic( GetSizePixel() ).Height() )
892 : : {
893 : 4118 : bRet = sal_True;
894 : : }
895 : : }
896 : :
897 : 7694 : return bRet;
898 : : }
899 : :
900 : : // -----------------------------------------------------------------------
901 : :
902 : 2605 : sal_uInt16 ImplListBoxWindow::GetLastVisibleEntry() const
903 : : {
904 : 2605 : sal_uInt16 nPos = mnTop;
905 : 2605 : long nWindowHeight = GetSizePixel().Height();
906 : 2605 : sal_uInt16 nCount = mpEntryList->GetEntryCount();
907 : : long nDiff;
908 [ + + ][ + - ]: 3075 : for( nDiff = 0; nDiff < nWindowHeight && nPos < nCount; nDiff = mpEntryList->GetAddedHeight( nPos, mnTop ) )
[ + + ]
909 : 470 : nPos++;
910 : :
911 [ - + ][ # # ]: 2605 : if( nDiff > nWindowHeight && nPos > mnTop )
912 : 0 : nPos--;
913 : :
914 [ - + ]: 2605 : if( nPos >= nCount )
915 : 0 : nPos = nCount-1;
916 : :
917 : 2605 : return nPos;
918 : : }
919 : :
920 : : // -----------------------------------------------------------------------
921 : :
922 : 0 : void ImplListBoxWindow::MouseButtonDown( const MouseEvent& rMEvt )
923 : : {
924 : 0 : mbMouseMoveSelect = sal_False; // Nur bis zum ersten MouseButtonDown
925 : 0 : maQuickSelectionEngine.Reset();
926 : :
927 [ # # ]: 0 : if ( !IsReadOnly() )
928 : : {
929 [ # # ]: 0 : if( rMEvt.GetClicks() == 1 )
930 : : {
931 : 0 : sal_uInt16 nSelect = GetEntryPosForPoint( rMEvt.GetPosPixel() );
932 [ # # ]: 0 : if( nSelect != LISTBOX_ENTRY_NOTFOUND )
933 : : {
934 [ # # ][ # # ]: 0 : if ( !mbMulti && GetEntryList()->GetSelectEntryCount() )
[ # # ]
935 : 0 : mnTrackingSaveSelection = GetEntryList()->GetSelectEntryPos( 0 );
936 : : else
937 : 0 : mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND;
938 : :
939 : 0 : mnCurrentPos = nSelect;
940 : 0 : mbTrackingSelect = sal_True;
941 : 0 : SelectEntries( nSelect, LET_MBDOWN, rMEvt.IsShift(), rMEvt.IsMod1() );
942 : 0 : mbTrackingSelect = sal_False;
943 [ # # ]: 0 : if ( mbGrabFocus )
944 : 0 : GrabFocus();
945 : :
946 : 0 : StartTracking( STARTTRACK_SCROLLREPEAT );
947 : : }
948 : : }
949 [ # # ]: 0 : if( rMEvt.GetClicks() == 2 )
950 : : {
951 : 0 : maDoubleClickHdl.Call( this );
952 : : }
953 : : }
954 : : else // if ( mbGrabFocus )
955 : : {
956 : 0 : GrabFocus();
957 : : }
958 : 0 : }
959 : :
960 : : // -----------------------------------------------------------------------
961 : :
962 : 0 : void ImplListBoxWindow::MouseMove( const MouseEvent& rMEvt )
963 : : {
964 [ # # ]: 0 : if ( rMEvt.IsLeaveWindow() )
965 : : {
966 [ # # ][ # # ]: 0 : if ( mbStackMode && IsMouseMoveSelect() && IsReallyVisible() )
[ # # ][ # # ]
967 : : {
968 [ # # ]: 0 : if ( rMEvt.GetPosPixel().Y() < 0 )
969 : : {
970 : 0 : DeselectAll();
971 : 0 : mnCurrentPos = LISTBOX_ENTRY_NOTFOUND;
972 : 0 : SetTopEntry( 0 );
973 [ # # ]: 0 : if ( mbStackMode ) // #87072#, #92323#
974 : : {
975 : 0 : mbTravelSelect = sal_True;
976 : 0 : mnSelectModifier = rMEvt.GetModifier();
977 : 0 : ImplCallSelect();
978 : 0 : mbTravelSelect = sal_False;
979 : : }
980 : :
981 : : }
982 : : }
983 : : }
984 [ # # ][ # # ]: 0 : else if ( ( ( !mbMulti && IsMouseMoveSelect() ) || mbStackMode ) && mpEntryList->GetEntryCount() )
[ # # ][ # # ]
[ # # ]
985 : : {
986 : 0 : Point aPoint;
987 [ # # ]: 0 : Rectangle aRect( aPoint, GetOutputSizePixel() );
988 [ # # ][ # # ]: 0 : if( aRect.IsInside( rMEvt.GetPosPixel() ) )
989 : : {
990 [ # # ]: 0 : if ( IsMouseMoveSelect() )
991 : : {
992 [ # # ]: 0 : sal_uInt16 nSelect = GetEntryPosForPoint( rMEvt.GetPosPixel() );
993 [ # # ]: 0 : if( nSelect == LISTBOX_ENTRY_NOTFOUND )
994 [ # # ]: 0 : nSelect = mpEntryList->GetEntryCount() - 1;
995 [ # # ]: 0 : nSelect = Min( nSelect, GetLastVisibleEntry() );
996 [ # # ]: 0 : nSelect = Min( nSelect, (sal_uInt16) ( mpEntryList->GetEntryCount() - 1 ) );
997 : : // Select only visible Entries with MouseMove, otherwise Tracking...
998 [ # # ][ # # ]: 0 : if ( IsVisible( nSelect ) &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
999 [ # # ]: 0 : mpEntryList->IsEntrySelectable( nSelect ) &&
1000 [ # # ][ # # ]: 0 : ( ( nSelect != mnCurrentPos ) || !GetEntryList()->GetSelectEntryCount() || ( nSelect != GetEntryList()->GetSelectEntryPos( 0 ) ) ) )
1001 : : {
1002 : 0 : mbTrackingSelect = sal_True;
1003 [ # # ][ # # ]: 0 : if ( SelectEntries( nSelect, LET_TRACKING, sal_False, sal_False ) )
1004 : : {
1005 [ # # ]: 0 : if ( mbStackMode ) // #87072#
1006 : : {
1007 : 0 : mbTravelSelect = sal_True;
1008 : 0 : mnSelectModifier = rMEvt.GetModifier();
1009 [ # # ]: 0 : ImplCallSelect();
1010 : 0 : mbTravelSelect = sal_False;
1011 : : }
1012 : : }
1013 : 0 : mbTrackingSelect = sal_False;
1014 : : }
1015 : : }
1016 : :
1017 : : // Falls der DD-Button gedrueckt wurde und jemand mit gedrueckter
1018 : : // Maustaste in die ListBox faehrt...
1019 [ # # ][ # # ]: 0 : if ( rMEvt.IsLeft() && !rMEvt.IsSynthetic() )
[ # # ]
1020 : : {
1021 [ # # ][ # # ]: 0 : if ( !mbMulti && GetEntryList()->GetSelectEntryCount() )
[ # # ][ # # ]
1022 [ # # ]: 0 : mnTrackingSaveSelection = GetEntryList()->GetSelectEntryPos( 0 );
1023 : : else
1024 : 0 : mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND;
1025 : :
1026 [ # # ][ # # ]: 0 : if ( mbStackMode && ( mpEntryList->GetSelectionAnchor() == LISTBOX_ENTRY_NOTFOUND ) )
[ # # ]
1027 : 0 : mpEntryList->SetSelectionAnchor( 0 );
1028 : :
1029 [ # # ]: 0 : StartTracking( STARTTRACK_SCROLLREPEAT );
1030 : : }
1031 : : }
1032 : : }
1033 : 0 : }
1034 : :
1035 : : // -----------------------------------------------------------------------
1036 : :
1037 : 275 : void ImplListBoxWindow::DeselectAll()
1038 : : {
1039 [ - + ]: 275 : while ( GetEntryList()->GetSelectEntryCount() )
1040 : : {
1041 : 0 : sal_uInt16 nS = GetEntryList()->GetSelectEntryPos( 0 );
1042 : 0 : SelectEntry( nS, sal_False );
1043 : : }
1044 : 275 : }
1045 : :
1046 : : // -----------------------------------------------------------------------
1047 : :
1048 : 7058 : void ImplListBoxWindow::SelectEntry( sal_uInt16 nPos, sal_Bool bSelect )
1049 : : {
1050 [ + + ][ + - ]: 7058 : if( (mpEntryList->IsEntryPosSelected( nPos ) != bSelect) && mpEntryList->IsEntrySelectable( nPos ) )
[ + + ]
1051 : : {
1052 : 4702 : ImplHideFocusRect();
1053 [ + + ]: 4702 : if( bSelect )
1054 : : {
1055 [ + + ]: 4689 : if( !mbMulti )
1056 : : {
1057 : : // Selektierten Eintrag deselektieren
1058 : 4675 : sal_uInt16 nDeselect = GetEntryList()->GetSelectEntryPos( 0 );
1059 [ + + ]: 4675 : if( nDeselect != LISTBOX_ENTRY_NOTFOUND )
1060 : : {
1061 : : //SelectEntryPos( nDeselect, sal_False );
1062 : 2 : GetEntryList()->SelectEntry( nDeselect, sal_False );
1063 [ - + ][ - + ]: 2 : if ( IsUpdateMode() && IsReallyVisible() )
[ + - ]
1064 : 0 : ImplPaint( nDeselect, sal_True );
1065 : : }
1066 : : }
1067 : 4689 : mpEntryList->SelectEntry( nPos, sal_True );
1068 : 4689 : mnCurrentPos = nPos;
1069 [ + + ][ + + ]: 4689 : if ( ( nPos != LISTBOX_ENTRY_NOTFOUND ) && IsUpdateMode() )
[ + - ]
1070 : : {
1071 : 4447 : ImplPaint( nPos );
1072 [ + + ]: 4447 : if ( !IsVisible( nPos ) )
1073 : : {
1074 : 2605 : ImplClearLayoutData();
1075 : 2605 : sal_uInt16 nVisibleEntries = GetLastVisibleEntry()-mnTop;
1076 [ - + ][ # # ]: 2605 : if ( !nVisibleEntries || !IsReallyVisible() || ( nPos < GetTopEntry() ) )
[ + - ][ + + ]
1077 : : {
1078 : 2605 : Resize();
1079 : 2605 : ShowProminentEntry( nPos );
1080 : : }
1081 : : else
1082 : : {
1083 : 0 : ShowProminentEntry( nPos );
1084 : : }
1085 : : }
1086 : : }
1087 : : }
1088 : : else
1089 : : {
1090 : 13 : mpEntryList->SelectEntry( nPos, sal_False );
1091 : 13 : ImplPaint( nPos, sal_True );
1092 : : }
1093 : 4702 : mbSelectionChanged = sal_True;
1094 : : }
1095 : 7058 : }
1096 : :
1097 : : // -----------------------------------------------------------------------
1098 : :
1099 : 0 : sal_Bool ImplListBoxWindow::SelectEntries( sal_uInt16 nSelect, LB_EVENT_TYPE eLET, sal_Bool bShift, sal_Bool bCtrl )
1100 : : {
1101 : 0 : sal_Bool bFocusChanged = sal_False;
1102 : 0 : sal_Bool bSelectionChanged = sal_False;
1103 : :
1104 [ # # ][ # # ]: 0 : if( IsEnabled() && mpEntryList->IsEntrySelectable( nSelect ) )
[ # # ]
1105 : : {
1106 : : // Hier (Single-ListBox) kann nur ein Eintrag deselektiert werden
1107 [ # # ]: 0 : if( !mbMulti )
1108 : : {
1109 : 0 : sal_uInt16 nDeselect = mpEntryList->GetSelectEntryPos( 0 );
1110 [ # # ]: 0 : if( nSelect != nDeselect )
1111 : : {
1112 : 0 : SelectEntry( nSelect, sal_True );
1113 : 0 : mpEntryList->SetLastSelected( nSelect );
1114 : 0 : bFocusChanged = sal_True;
1115 : 0 : bSelectionChanged = sal_True;
1116 : : }
1117 : : }
1118 : : // MultiListBox ohne Modifier
1119 [ # # ][ # # ]: 0 : else if( mbSimpleMode && !bCtrl && !bShift )
[ # # ]
1120 : : {
1121 : 0 : sal_uInt16 nEntryCount = mpEntryList->GetEntryCount();
1122 [ # # ]: 0 : for ( sal_uInt16 nPos = 0; nPos < nEntryCount; nPos++ )
1123 : : {
1124 : 0 : sal_Bool bSelect = nPos == nSelect;
1125 [ # # ]: 0 : if ( mpEntryList->IsEntryPosSelected( nPos ) != bSelect )
1126 : : {
1127 : 0 : SelectEntry( nPos, bSelect );
1128 : 0 : bFocusChanged = sal_True;
1129 : 0 : bSelectionChanged = sal_True;
1130 : : }
1131 : : }
1132 : 0 : mpEntryList->SetLastSelected( nSelect );
1133 : 0 : mpEntryList->SetSelectionAnchor( nSelect );
1134 : : }
1135 : : // MultiListBox nur mit CTRL/SHIFT oder nicht im SimpleMode
1136 [ # # ][ # # ]: 0 : else if( ( !mbSimpleMode /* && !bShift */ ) || ( (mbSimpleMode && ( bCtrl || bShift )) || mbStackMode ) )
[ # # ][ # # ]
[ # # ]
1137 : : {
1138 : : // Space fuer Selektionswechsel
1139 [ # # ][ # # ]: 0 : if( !bShift && ( ( eLET == LET_KEYSPACE ) || ( eLET == LET_MBDOWN ) ) )
[ # # ]
1140 : : {
1141 [ # # ][ # # ]: 0 : sal_Bool bSelect = ( mbStackMode && IsMouseMoveSelect() ) ? sal_True : !mpEntryList->IsEntryPosSelected( nSelect );
[ # # ]
1142 [ # # ]: 0 : if ( mbStackMode )
1143 : : {
1144 : : sal_uInt16 n;
1145 [ # # ]: 0 : if ( bSelect )
1146 : : {
1147 : : // All entries before nSelect must be selected...
1148 [ # # ]: 0 : for ( n = 0; n < nSelect; n++ )
1149 : 0 : SelectEntry( n, sal_True );
1150 : : }
1151 [ # # ]: 0 : if ( !bSelect )
1152 : : {
1153 [ # # ]: 0 : for ( n = nSelect+1; n < mpEntryList->GetEntryCount(); n++ )
1154 : 0 : SelectEntry( n, sal_False );
1155 : : }
1156 : : }
1157 : 0 : SelectEntry( nSelect, bSelect );
1158 : 0 : mpEntryList->SetLastSelected( nSelect );
1159 [ # # ]: 0 : mpEntryList->SetSelectionAnchor( mbStackMode ? 0 : nSelect );
1160 [ # # ]: 0 : if ( !mpEntryList->IsEntryPosSelected( nSelect ) )
1161 : 0 : mpEntryList->SetSelectionAnchor( LISTBOX_ENTRY_NOTFOUND );
1162 : 0 : bFocusChanged = sal_True;
1163 : 0 : bSelectionChanged = sal_True;
1164 : : }
1165 [ # # ][ # # ]: 0 : else if( ( ( eLET == LET_TRACKING ) && ( nSelect != mnCurrentPos ) ) ||
[ # # ][ # # ]
[ # # ][ # # ]
1166 : : ( (bShift||mbStackMode) && ( ( eLET == LET_KEYMOVE ) || ( eLET == LET_MBDOWN ) ) ) )
1167 : : {
1168 : 0 : mnCurrentPos = nSelect;
1169 : 0 : bFocusChanged = sal_True;
1170 : :
1171 : 0 : sal_uInt16 nAnchor = mpEntryList->GetSelectionAnchor();
1172 [ # # ][ # # ]: 0 : if( ( nAnchor == LISTBOX_ENTRY_NOTFOUND ) && ( mpEntryList->GetSelectEntryCount() || mbStackMode ) )
[ # # ][ # # ]
1173 : : {
1174 [ # # ]: 0 : nAnchor = mbStackMode ? 0 : mpEntryList->GetSelectEntryPos( mpEntryList->GetSelectEntryCount() - 1 );
1175 : : }
1176 [ # # ]: 0 : if( nAnchor != LISTBOX_ENTRY_NOTFOUND )
1177 : : {
1178 : : // Alle Eintraege vom Anchor bis nSelect muessen selektiert sein
1179 : 0 : sal_uInt16 nStart = Min( nSelect, nAnchor );
1180 : 0 : sal_uInt16 nEnd = Max( nSelect, nAnchor );
1181 [ # # ]: 0 : for ( sal_uInt16 n = nStart; n <= nEnd; n++ )
1182 : : {
1183 [ # # ]: 0 : if ( !mpEntryList->IsEntryPosSelected( n ) )
1184 : : {
1185 : 0 : SelectEntry( n, sal_True );
1186 : 0 : bSelectionChanged = sal_True;
1187 : : }
1188 : : }
1189 : :
1190 : : // Ggf. muss noch was deselektiert werden...
1191 : 0 : sal_uInt16 nLast = mpEntryList->GetLastSelected();
1192 [ # # ]: 0 : if ( nLast != LISTBOX_ENTRY_NOTFOUND )
1193 : : {
1194 [ # # ][ # # ]: 0 : if ( ( nLast > nSelect ) && ( nLast > nAnchor ) )
1195 : : {
1196 [ # # ]: 0 : for ( sal_uInt16 n = nSelect+1; n <= nLast; n++ )
1197 : : {
1198 [ # # ]: 0 : if ( mpEntryList->IsEntryPosSelected( n ) )
1199 : : {
1200 : 0 : SelectEntry( n, sal_False );
1201 : 0 : bSelectionChanged = sal_True;
1202 : : }
1203 : 0 : }
1204 : : }
1205 [ # # ][ # # ]: 0 : else if ( ( nLast < nSelect ) && ( nLast < nAnchor ) )
1206 : : {
1207 [ # # ]: 0 : for ( sal_uInt16 n = nLast; n < nSelect; n++ )
1208 : : {
1209 [ # # ]: 0 : if ( mpEntryList->IsEntryPosSelected( n ) )
1210 : : {
1211 : 0 : SelectEntry( n, sal_False );
1212 : 0 : bSelectionChanged = sal_True;
1213 : : }
1214 : : }
1215 : : }
1216 : : }
1217 : 0 : mpEntryList->SetLastSelected( nSelect );
1218 : 0 : }
1219 : : }
1220 [ # # ]: 0 : else if( eLET != LET_TRACKING )
1221 : : {
1222 : 0 : ImplHideFocusRect();
1223 : 0 : ImplPaint( nSelect, sal_True );
1224 : 0 : bFocusChanged = sal_True;
1225 : 0 : }
1226 : : }
1227 [ # # ]: 0 : else if( bShift )
1228 : : {
1229 : 0 : bFocusChanged = sal_True;
1230 : : }
1231 : :
1232 [ # # ]: 0 : if( bSelectionChanged )
1233 : 0 : mbSelectionChanged = sal_True;
1234 : :
1235 [ # # ]: 0 : if( bFocusChanged )
1236 : : {
1237 [ # # ]: 0 : long nHeightDiff = mpEntryList->GetAddedHeight( nSelect, mnTop, 0 );
1238 : 0 : maFocusRect.SetPos( Point( 0, nHeightDiff ) );
1239 : : Size aSz( maFocusRect.GetWidth(),
1240 [ # # ][ # # ]: 0 : mpEntryList->GetEntryHeight( nSelect ) );
1241 [ # # ]: 0 : maFocusRect.SetSize( aSz );
1242 [ # # ][ # # ]: 0 : if( HasFocus() )
1243 [ # # ]: 0 : ImplShowFocusRect();
1244 : : }
1245 : 0 : ImplClearLayoutData();
1246 : : }
1247 : 0 : return bSelectionChanged;
1248 : : }
1249 : :
1250 : : // -----------------------------------------------------------------------
1251 : :
1252 : 0 : void ImplListBoxWindow::Tracking( const TrackingEvent& rTEvt )
1253 : : {
1254 : 0 : Point aPoint;
1255 [ # # ]: 0 : Rectangle aRect( aPoint, GetOutputSizePixel() );
1256 [ # # ]: 0 : sal_Bool bInside = aRect.IsInside( rTEvt.GetMouseEvent().GetPosPixel() );
1257 : :
1258 [ # # ][ # # ]: 0 : if( rTEvt.IsTrackingCanceled() || rTEvt.IsTrackingEnded() ) // MouseButtonUp
[ # # ]
1259 : : {
1260 [ # # ][ # # ]: 0 : if ( bInside && !rTEvt.IsTrackingCanceled() )
[ # # ]
1261 : : {
1262 : 0 : mnSelectModifier = rTEvt.GetMouseEvent().GetModifier();
1263 [ # # ]: 0 : ImplCallSelect();
1264 : : }
1265 : : else
1266 : : {
1267 [ # # ]: 0 : maCancelHdl.Call( NULL );
1268 [ # # ]: 0 : if ( !mbMulti )
1269 : : {
1270 : 0 : mbTrackingSelect = sal_True;
1271 [ # # ]: 0 : SelectEntry( mnTrackingSaveSelection, sal_True );
1272 : 0 : mbTrackingSelect = sal_False;
1273 [ # # ]: 0 : if ( mnTrackingSaveSelection != LISTBOX_ENTRY_NOTFOUND )
1274 : : {
1275 [ # # ]: 0 : long nHeightDiff = mpEntryList->GetAddedHeight( mnCurrentPos, mnTop, 0 );
1276 : 0 : maFocusRect.SetPos( Point( 0, nHeightDiff ) );
1277 : : Size aSz( maFocusRect.GetWidth(),
1278 [ # # ][ # # ]: 0 : mpEntryList->GetEntryHeight( mnCurrentPos ) );
1279 [ # # ]: 0 : maFocusRect.SetSize( aSz );
1280 [ # # ]: 0 : ImplShowFocusRect();
1281 : : }
1282 : : }
1283 : : }
1284 : :
1285 : 0 : mbTrack = sal_False;
1286 : : }
1287 : : else
1288 : : {
1289 : 0 : sal_Bool bTrackOrQuickClick = mbTrack;
1290 [ # # ]: 0 : if( !mbTrack )
1291 : : {
1292 [ # # ]: 0 : if ( bInside )
1293 : : {
1294 : 0 : mbTrack = sal_True;
1295 : : }
1296 : :
1297 : : // Folgender Fall tritt nur auf, wenn man ganz kurz die Maustaste drueckt
1298 [ # # ][ # # ]: 0 : if( rTEvt.IsTrackingEnded() && mbTrack )
[ # # ]
1299 : : {
1300 : 0 : bTrackOrQuickClick = sal_True;
1301 : 0 : mbTrack = sal_False;
1302 : : }
1303 : : }
1304 : :
1305 [ # # ]: 0 : if( bTrackOrQuickClick )
1306 : : {
1307 : 0 : MouseEvent aMEvt = rTEvt.GetMouseEvent();
1308 : 0 : Point aPt( aMEvt.GetPosPixel() );
1309 : 0 : sal_Bool bShift = aMEvt.IsShift();
1310 : 0 : sal_Bool bCtrl = aMEvt.IsMod1();
1311 : :
1312 : 0 : sal_uInt16 nSelect = LISTBOX_ENTRY_NOTFOUND;
1313 [ # # ]: 0 : if( aPt.Y() < 0 )
1314 : : {
1315 [ # # ]: 0 : if ( mnCurrentPos != LISTBOX_ENTRY_NOTFOUND )
1316 : : {
1317 [ # # ]: 0 : nSelect = mnCurrentPos ? ( mnCurrentPos - 1 ) : 0;
1318 [ # # ]: 0 : if( nSelect < mnTop )
1319 [ # # ]: 0 : SetTopEntry( mnTop-1 );
1320 : : }
1321 : : }
1322 [ # # ]: 0 : else if( aPt.Y() > GetOutputSizePixel().Height() )
1323 : : {
1324 [ # # ]: 0 : if ( mnCurrentPos != LISTBOX_ENTRY_NOTFOUND )
1325 : : {
1326 [ # # ]: 0 : nSelect = Min( (sal_uInt16)(mnCurrentPos+1), (sal_uInt16)(mpEntryList->GetEntryCount()-1) );
1327 [ # # ][ # # ]: 0 : if( nSelect >= GetLastVisibleEntry() )
1328 [ # # ]: 0 : SetTopEntry( mnTop+1 );
1329 : : }
1330 : : }
1331 : : else
1332 : : {
1333 : 0 : nSelect = (sal_uInt16) ( ( aPt.Y() + mnBorder ) / mnMaxHeight ) + (sal_uInt16) mnTop;
1334 [ # # ]: 0 : nSelect = Min( nSelect, GetLastVisibleEntry() );
1335 [ # # ]: 0 : nSelect = Min( nSelect, (sal_uInt16) ( mpEntryList->GetEntryCount() - 1 ) );
1336 : : }
1337 : :
1338 [ # # ]: 0 : if ( bInside )
1339 : : {
1340 [ # # ][ # # ]: 0 : if ( ( nSelect != mnCurrentPos ) || !GetEntryList()->GetSelectEntryCount() )
[ # # ][ # # ]
1341 : : {
1342 : 0 : mbTrackingSelect = sal_True;
1343 [ # # ][ # # ]: 0 : if ( SelectEntries( nSelect, LET_TRACKING, bShift, bCtrl ) )
1344 : : {
1345 [ # # ]: 0 : if ( mbStackMode ) // #87734# (#87072#)
1346 : : {
1347 : 0 : mbTravelSelect = sal_True;
1348 : 0 : mnSelectModifier = rTEvt.GetMouseEvent().GetModifier();
1349 [ # # ]: 0 : ImplCallSelect();
1350 : 0 : mbTravelSelect = sal_False;
1351 : : }
1352 : : }
1353 : 0 : mbTrackingSelect = sal_False;
1354 : : }
1355 : : }
1356 : : else
1357 : : {
1358 [ # # ][ # # ]: 0 : if ( !mbMulti && GetEntryList()->GetSelectEntryCount() )
[ # # ][ # # ]
1359 : : {
1360 : 0 : mbTrackingSelect = sal_True;
1361 [ # # ][ # # ]: 0 : SelectEntry( GetEntryList()->GetSelectEntryPos( 0 ), sal_False );
1362 : 0 : mbTrackingSelect = sal_False;
1363 : : }
1364 [ # # ]: 0 : else if ( mbStackMode )
1365 : : {
1366 [ # # ][ # # ]: 0 : if ( ( rTEvt.GetMouseEvent().GetPosPixel().X() > 0 ) && ( rTEvt.GetMouseEvent().GetPosPixel().X() < aRect.Right() ) )
[ # # ]
1367 : : {
1368 [ # # ][ # # ]: 0 : if ( ( rTEvt.GetMouseEvent().GetPosPixel().Y() < 0 ) || ( rTEvt.GetMouseEvent().GetPosPixel().Y() > GetOutputSizePixel().Height() ) )
[ # # ][ # # ]
1369 : : {
1370 : 0 : sal_Bool bSelectionChanged = sal_False;
1371 [ # # ][ # # ]: 0 : if ( ( rTEvt.GetMouseEvent().GetPosPixel().Y() < 0 )
[ # # ]
1372 : 0 : && !mnCurrentPos )
1373 : : {
1374 [ # # ][ # # ]: 0 : if ( mpEntryList->IsEntryPosSelected( 0 ) )
1375 : : {
1376 [ # # ]: 0 : SelectEntry( 0, sal_False );
1377 : 0 : bSelectionChanged = sal_True;
1378 : 0 : nSelect = LISTBOX_ENTRY_NOTFOUND;
1379 : :
1380 : : }
1381 : : }
1382 : : else
1383 : : {
1384 : 0 : mbTrackingSelect = sal_True;
1385 [ # # ]: 0 : bSelectionChanged = SelectEntries( nSelect, LET_TRACKING, bShift, bCtrl );
1386 : 0 : mbTrackingSelect = sal_False;
1387 : : }
1388 : :
1389 [ # # ]: 0 : if ( bSelectionChanged )
1390 : : {
1391 : 0 : mbSelectionChanged = sal_True;
1392 : 0 : mbTravelSelect = sal_True;
1393 : 0 : mnSelectModifier = rTEvt.GetMouseEvent().GetModifier();
1394 [ # # ]: 0 : ImplCallSelect();
1395 : 0 : mbTravelSelect = sal_False;
1396 : : }
1397 : : }
1398 : : }
1399 : : }
1400 : : }
1401 : 0 : mnCurrentPos = nSelect;
1402 [ # # ]: 0 : if ( mnCurrentPos == LISTBOX_ENTRY_NOTFOUND )
1403 : : {
1404 [ # # ]: 0 : ImplHideFocusRect();
1405 : : }
1406 : : else
1407 : : {
1408 [ # # ]: 0 : long nHeightDiff = mpEntryList->GetAddedHeight( mnCurrentPos, mnTop, 0 );
1409 : 0 : maFocusRect.SetPos( Point( 0, nHeightDiff ) );
1410 [ # # ][ # # ]: 0 : Size aSz( maFocusRect.GetWidth(), mpEntryList->GetEntryHeight( mnCurrentPos ) );
1411 [ # # ]: 0 : maFocusRect.SetSize( aSz );
1412 [ # # ]: 0 : ImplShowFocusRect();
1413 : : }
1414 : : }
1415 : : }
1416 : 0 : }
1417 : :
1418 : :
1419 : : // -----------------------------------------------------------------------
1420 : :
1421 : 0 : void ImplListBoxWindow::KeyInput( const KeyEvent& rKEvt )
1422 : : {
1423 [ # # ]: 0 : if( !ProcessKeyInput( rKEvt ) )
1424 : 0 : Control::KeyInput( rKEvt );
1425 : 0 : }
1426 : :
1427 : : // -----------------------------------------------------------------------
1428 : :
1429 : 0 : sal_Bool ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt )
1430 : : {
1431 : : // zu selektierender Eintrag
1432 : 0 : sal_uInt16 nSelect = LISTBOX_ENTRY_NOTFOUND;
1433 : 0 : LB_EVENT_TYPE eLET = LET_KEYMOVE;
1434 : :
1435 : 0 : KeyCode aKeyCode = rKEvt.GetKeyCode();
1436 : :
1437 : 0 : sal_Bool bShift = aKeyCode.IsShift();
1438 [ # # ][ # # ]: 0 : sal_Bool bCtrl = aKeyCode.IsMod1() || aKeyCode.IsMod3();
1439 : 0 : sal_Bool bMod2 = aKeyCode.IsMod2();
1440 : 0 : sal_Bool bDone = sal_False;
1441 : :
1442 [ # # # # : 0 : switch( aKeyCode.GetCode() )
# # # # #
# # # ]
1443 : : {
1444 : : case KEY_UP:
1445 : : {
1446 [ # # ]: 0 : if ( IsReadOnly() )
1447 : : {
1448 [ # # ]: 0 : if ( GetTopEntry() )
1449 [ # # ]: 0 : SetTopEntry( GetTopEntry()-1 );
1450 : : }
1451 [ # # ]: 0 : else if ( !bMod2 )
1452 : : {
1453 [ # # ]: 0 : if( mnCurrentPos == LISTBOX_ENTRY_NOTFOUND )
1454 : : {
1455 [ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( 0, true );
1456 : : }
1457 [ # # ]: 0 : else if ( mnCurrentPos )
1458 : : {
1459 : : // search first selectable above the current position
1460 [ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( mnCurrentPos - 1, false );
1461 : : }
1462 : :
1463 [ # # ][ # # ]: 0 : if( ( nSelect != LISTBOX_ENTRY_NOTFOUND ) && ( nSelect < mnTop ) )
1464 [ # # ]: 0 : SetTopEntry( mnTop-1 );
1465 : :
1466 : 0 : bDone = sal_True;
1467 : : }
1468 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1469 : : }
1470 : 0 : break;
1471 : :
1472 : : case KEY_DOWN:
1473 : : {
1474 [ # # ]: 0 : if ( IsReadOnly() )
1475 : : {
1476 [ # # ]: 0 : SetTopEntry( GetTopEntry()+1 );
1477 : : }
1478 [ # # ]: 0 : else if ( !bMod2 )
1479 : : {
1480 [ # # ]: 0 : if( mnCurrentPos == LISTBOX_ENTRY_NOTFOUND )
1481 : : {
1482 [ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( 0, true );
1483 : : }
1484 [ # # ][ # # ]: 0 : else if ( (mnCurrentPos+1) < mpEntryList->GetEntryCount() )
1485 : : {
1486 : : // search first selectable below the current position
1487 [ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( mnCurrentPos + 1, true );
1488 : : }
1489 : :
1490 [ # # ][ # # ]: 0 : if( ( nSelect != LISTBOX_ENTRY_NOTFOUND ) && ( nSelect >= GetLastVisibleEntry() ) )
[ # # ][ # # ]
1491 [ # # ]: 0 : SetTopEntry( mnTop+1 );
1492 : :
1493 : 0 : bDone = sal_True;
1494 : : }
1495 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1496 : : }
1497 : 0 : break;
1498 : :
1499 : : case KEY_PAGEUP:
1500 : : {
1501 [ # # ]: 0 : if ( IsReadOnly() )
1502 : : {
1503 [ # # ]: 0 : sal_uInt16 nCurVis = GetLastVisibleEntry() - mnTop +1;
1504 : : SetTopEntry( ( mnTop > nCurVis ) ?
1505 [ # # ][ # # ]: 0 : (mnTop-nCurVis) : 0 );
1506 : : }
1507 [ # # ][ # # ]: 0 : else if ( !bCtrl && !bMod2 )
1508 : : {
1509 [ # # ]: 0 : if( mnCurrentPos == LISTBOX_ENTRY_NOTFOUND )
1510 : : {
1511 [ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( 0, true );
1512 : : }
1513 [ # # ]: 0 : else if ( mnCurrentPos )
1514 : : {
1515 [ # # ]: 0 : if( mnCurrentPos == mnTop )
1516 : : {
1517 [ # # ]: 0 : sal_uInt16 nCurVis = GetLastVisibleEntry() - mnTop +1;
1518 [ # # ][ # # ]: 0 : SetTopEntry( ( mnTop > nCurVis ) ? ( mnTop-nCurVis+1 ) : 0 );
1519 : : }
1520 : :
1521 : : // find first selectable starting from mnTop looking foreward
1522 [ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( mnTop, true );
1523 : : }
1524 : 0 : bDone = sal_True;
1525 : : }
1526 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1527 : : }
1528 : 0 : break;
1529 : :
1530 : : case KEY_PAGEDOWN:
1531 : : {
1532 [ # # ]: 0 : if ( IsReadOnly() )
1533 : : {
1534 [ # # ][ # # ]: 0 : SetTopEntry( GetLastVisibleEntry() );
1535 : : }
1536 [ # # ][ # # ]: 0 : else if ( !bCtrl && !bMod2 )
1537 : : {
1538 [ # # ]: 0 : if( mnCurrentPos == LISTBOX_ENTRY_NOTFOUND )
1539 : : {
1540 [ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( 0, true );
1541 : : }
1542 [ # # ][ # # ]: 0 : else if ( (mnCurrentPos+1) < mpEntryList->GetEntryCount() )
1543 : : {
1544 [ # # ]: 0 : sal_uInt16 nCount = mpEntryList->GetEntryCount();
1545 [ # # ]: 0 : sal_uInt16 nCurVis = GetLastVisibleEntry() - mnTop;
1546 : 0 : sal_uInt16 nTmp = Min( nCurVis, nCount );
1547 : 0 : nTmp += mnTop - 1;
1548 [ # # ][ # # ]: 0 : if( mnCurrentPos == nTmp && mnCurrentPos != nCount - 1 )
1549 : : {
1550 : 0 : long nTmp2 = Min( (long)(nCount-nCurVis), (long)((long)mnTop+(long)nCurVis-1) );
1551 : 0 : nTmp2 = Max( (long)0 , nTmp2 );
1552 : 0 : nTmp = (sal_uInt16)(nTmp2+(nCurVis-1) );
1553 [ # # ]: 0 : SetTopEntry( (sal_uInt16)nTmp2 );
1554 : : }
1555 : : // find first selectable starting from nTmp looking backwards
1556 [ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( nTmp, false );
1557 : : }
1558 : 0 : bDone = sal_True;
1559 : : }
1560 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1561 : : }
1562 : 0 : break;
1563 : :
1564 : : case KEY_HOME:
1565 : : {
1566 [ # # ]: 0 : if ( IsReadOnly() )
1567 : : {
1568 [ # # ]: 0 : SetTopEntry( 0 );
1569 : : }
1570 [ # # ][ # # ]: 0 : else if ( !bCtrl && !bMod2 )
1571 : : {
1572 [ # # ]: 0 : if ( mnCurrentPos )
1573 : : {
1574 [ # # ][ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( mpEntryList->GetEntryCount() ? 0 : LISTBOX_ENTRY_NOTFOUND, true );
[ # # ]
1575 [ # # ]: 0 : if( mnTop != 0 )
1576 [ # # ]: 0 : SetTopEntry( 0 );
1577 : :
1578 : 0 : bDone = sal_True;
1579 : : }
1580 : : }
1581 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1582 : : }
1583 : 0 : break;
1584 : :
1585 : : case KEY_END:
1586 : : {
1587 [ # # ]: 0 : if ( IsReadOnly() )
1588 : : {
1589 [ # # ]: 0 : SetTopEntry( 0xFFFF );
1590 : : }
1591 [ # # ][ # # ]: 0 : else if ( !bCtrl && !bMod2 )
1592 : : {
1593 [ # # ]: 0 : if( mnCurrentPos == LISTBOX_ENTRY_NOTFOUND )
1594 : : {
1595 [ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( 0, true );
1596 : : }
1597 [ # # ][ # # ]: 0 : else if ( (mnCurrentPos+1) < mpEntryList->GetEntryCount() )
1598 : : {
1599 [ # # ]: 0 : sal_uInt16 nCount = mpEntryList->GetEntryCount();
1600 [ # # ]: 0 : nSelect = mpEntryList->FindFirstSelectable( nCount - 1, false );
1601 [ # # ]: 0 : sal_uInt16 nCurVis = GetLastVisibleEntry() - mnTop + 1;
1602 [ # # ]: 0 : if( nCount > nCurVis )
1603 [ # # ]: 0 : SetTopEntry( nCount - nCurVis );
1604 : : }
1605 : 0 : bDone = sal_True;
1606 : : }
1607 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1608 : : }
1609 : 0 : break;
1610 : :
1611 : : case KEY_LEFT:
1612 : : {
1613 [ # # ][ # # ]: 0 : if ( !bCtrl && !bMod2 )
1614 : : {
1615 [ # # ]: 0 : ScrollHorz( -HORZ_SCROLL );
1616 : 0 : bDone = sal_True;
1617 : : }
1618 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1619 : : }
1620 : 0 : break;
1621 : :
1622 : : case KEY_RIGHT:
1623 : : {
1624 [ # # ][ # # ]: 0 : if ( !bCtrl && !bMod2 )
1625 : : {
1626 [ # # ]: 0 : ScrollHorz( HORZ_SCROLL );
1627 : 0 : bDone = sal_True;
1628 : : }
1629 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1630 : : }
1631 : 0 : break;
1632 : :
1633 : : case KEY_RETURN:
1634 : : {
1635 [ # # ][ # # ]: 0 : if ( !bMod2 && !IsReadOnly() )
[ # # ]
1636 : : {
1637 : 0 : mnSelectModifier = rKEvt.GetKeyCode().GetModifier();
1638 [ # # ]: 0 : ImplCallSelect();
1639 : 0 : bDone = sal_False; // RETURN nicht abfangen.
1640 : : }
1641 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1642 : : }
1643 : 0 : break;
1644 : :
1645 : : case KEY_SPACE:
1646 : : {
1647 [ # # ][ # # ]: 0 : if ( !bMod2 && !IsReadOnly() )
[ # # ]
1648 : : {
1649 [ # # ][ # # ]: 0 : if( mbMulti && ( !mbSimpleMode || ( mbSimpleMode && bCtrl && !bShift ) || mbStackMode ) )
[ # # ][ # # ]
[ # # ][ # # ]
1650 : : {
1651 : 0 : nSelect = mnCurrentPos;
1652 : 0 : eLET = LET_KEYSPACE;
1653 : : }
1654 : 0 : bDone = sal_True;
1655 : : }
1656 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1657 : : }
1658 : 0 : break;
1659 : :
1660 : : case KEY_A:
1661 : : {
1662 [ # # ][ # # ]: 0 : if( bCtrl && mbMulti )
1663 : : {
1664 : : // paint only once
1665 [ # # ]: 0 : sal_Bool bUpdates = IsUpdateMode();
1666 [ # # ]: 0 : SetUpdateMode( sal_False );
1667 : :
1668 [ # # ]: 0 : sal_uInt16 nEntryCount = mpEntryList->GetEntryCount();
1669 [ # # ]: 0 : for( sal_uInt16 i = 0; i < nEntryCount; i++ )
1670 [ # # ]: 0 : SelectEntry( i, sal_True );
1671 : :
1672 : : // restore update mode
1673 [ # # ]: 0 : SetUpdateMode( bUpdates );
1674 [ # # ]: 0 : Invalidate();
1675 : :
1676 [ # # ]: 0 : maQuickSelectionEngine.Reset();
1677 : :
1678 : 0 : bDone = sal_True;
1679 : 0 : break;
1680 : : }
1681 : : }
1682 : : // fall through intentional
1683 : : default:
1684 : : {
1685 [ # # ]: 0 : if ( !IsReadOnly() )
1686 : : {
1687 [ # # ]: 0 : bDone = maQuickSelectionEngine.HandleKeyEvent( rKEvt );
1688 : : }
1689 : : }
1690 : 0 : break;
1691 : : }
1692 : :
1693 [ # # ][ # # ]: 0 : if ( ( nSelect != LISTBOX_ENTRY_NOTFOUND )
[ # # ][ # # ]
1694 [ # # ]: 0 : && ( ( !mpEntryList->IsEntryPosSelected( nSelect ) )
1695 : : || ( eLET == LET_KEYSPACE )
1696 : : )
1697 : : )
1698 : : {
1699 : : DBG_ASSERT( !mpEntryList->IsEntryPosSelected( nSelect ) || mbMulti, "ImplListBox: Selecting same Entry" );
1700 [ # # ][ # # ]: 0 : if( nSelect >= mpEntryList->GetEntryCount() )
1701 [ # # ]: 0 : nSelect = mpEntryList->GetEntryCount()-1;
1702 : 0 : mnCurrentPos = nSelect;
1703 [ # # ][ # # ]: 0 : if ( SelectEntries( nSelect, eLET, bShift, bCtrl ) )
1704 : : {
1705 : 0 : mbTravelSelect = sal_True;
1706 : 0 : mnSelectModifier = rKEvt.GetKeyCode().GetModifier();
1707 [ # # ]: 0 : ImplCallSelect();
1708 : 0 : mbTravelSelect = sal_False;
1709 : : }
1710 : : }
1711 : :
1712 : 0 : return bDone;
1713 : : }
1714 : :
1715 : : // -----------------------------------------------------------------------
1716 : : namespace
1717 : : {
1718 : 0 : static ::vcl::StringEntryIdentifier lcl_getEntry( const ImplEntryList& _rList, sal_uInt16 _nPos, String& _out_entryText )
1719 : : {
1720 : : OSL_PRECOND( ( _nPos != LISTBOX_ENTRY_NOTFOUND ), "lcl_getEntry: invalid position!" );
1721 : 0 : sal_uInt16 nEntryCount( _rList.GetEntryCount() );
1722 [ # # ]: 0 : if ( _nPos >= nEntryCount )
1723 : 0 : _nPos = 0;
1724 [ # # ]: 0 : _out_entryText = _rList.GetEntryText( _nPos );
1725 : :
1726 : : // ::vcl::StringEntryIdentifier does not allow for 0 values, but our position is 0-based
1727 : : // => normalize
1728 : 0 : return reinterpret_cast< ::vcl::StringEntryIdentifier >( _nPos + 1 );
1729 : : }
1730 : :
1731 : 0 : static sal_uInt16 lcl_getEntryPos( ::vcl::StringEntryIdentifier _entry )
1732 : : {
1733 : : // our pos is 0-based, but StringEntryIdentifier does not allow for a NULL
1734 : 0 : return static_cast< sal_uInt16 >( reinterpret_cast< sal_Int64 >( _entry ) ) - 1;
1735 : : }
1736 : : }
1737 : :
1738 : : // -----------------------------------------------------------------------
1739 : 0 : ::vcl::StringEntryIdentifier ImplListBoxWindow::CurrentEntry( String& _out_entryText ) const
1740 : : {
1741 [ # # ]: 0 : return lcl_getEntry( *GetEntryList(), ( mnCurrentPos == LISTBOX_ENTRY_NOTFOUND ) ? 0 : mnCurrentPos + 1, _out_entryText );
1742 : : }
1743 : :
1744 : : // -----------------------------------------------------------------------
1745 : 0 : ::vcl::StringEntryIdentifier ImplListBoxWindow::NextEntry( ::vcl::StringEntryIdentifier _currentEntry, String& _out_entryText ) const
1746 : : {
1747 : 0 : sal_uInt16 nNextPos = lcl_getEntryPos( _currentEntry ) + 1;
1748 : 0 : return lcl_getEntry( *GetEntryList(), nNextPos, _out_entryText );
1749 : : }
1750 : :
1751 : : // -----------------------------------------------------------------------
1752 : 0 : void ImplListBoxWindow::SelectEntry( ::vcl::StringEntryIdentifier _entry )
1753 : : {
1754 : 0 : sal_uInt16 nSelect = lcl_getEntryPos( _entry );
1755 [ # # ]: 0 : if ( mpEntryList->IsEntryPosSelected( nSelect ) )
1756 : : {
1757 : : // ignore that. This method is a callback from the QuickSelectionEngine, which means the user attempted
1758 : : // to select the given entry by typing its starting letters. No need to act.
1759 : 0 : return;
1760 : : }
1761 : :
1762 : : // normalize
1763 : : OSL_ENSURE( nSelect < mpEntryList->GetEntryCount(), "ImplListBoxWindow::SelectEntry: how that?" );
1764 [ # # ]: 0 : if( nSelect >= mpEntryList->GetEntryCount() )
1765 : 0 : nSelect = mpEntryList->GetEntryCount()-1;
1766 : :
1767 : : // make visible
1768 : 0 : ShowProminentEntry( nSelect );
1769 : :
1770 : : // actually select
1771 : 0 : mnCurrentPos = nSelect;
1772 [ # # ]: 0 : if ( SelectEntries( nSelect, LET_KEYMOVE, sal_False, sal_False ) )
1773 : : {
1774 : 0 : mbTravelSelect = sal_True;
1775 : 0 : mnSelectModifier = 0;
1776 : 0 : ImplCallSelect();
1777 : 0 : mbTravelSelect = sal_False;
1778 : : }
1779 : : }
1780 : :
1781 : : // -----------------------------------------------------------------------
1782 : :
1783 : 4835 : void ImplListBoxWindow::ImplPaint( sal_uInt16 nPos, sal_Bool bErase, bool bLayout )
1784 : : {
1785 : 4835 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1786 : :
1787 [ + - ]: 4835 : const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nPos );
1788 [ + - ]: 4835 : if( ! pEntry )
1789 : 4835 : return;
1790 : :
1791 : 4835 : long nWidth = GetOutputSizePixel().Width();
1792 [ + - ]: 4835 : long nY = mpEntryList->GetAddedHeight( nPos, mnTop );
1793 [ + - ]: 4835 : Rectangle aRect( Point( 0, nY ), Size( nWidth, pEntry->mnHeight ) );
1794 : :
1795 [ + - ]: 4835 : if( ! bLayout )
1796 : : {
1797 [ + - ][ + + ]: 4835 : if( mpEntryList->IsEntryPosSelected( nPos ) )
1798 : : {
1799 [ + - ][ - + ]: 4460 : SetTextColor( !IsEnabled() ? rStyleSettings.GetDisableColor() : rStyleSettings.GetHighlightTextColor() );
[ + - ]
1800 [ + - ]: 4460 : SetFillColor( rStyleSettings.GetHighlightColor() );
1801 [ + - ]: 4460 : SetTextFillColor( rStyleSettings.GetHighlightColor() );
1802 [ + - ]: 4460 : DrawRect( aRect );
1803 : : }
1804 : : else
1805 : : {
1806 [ + - ]: 375 : ImplInitSettings( sal_False, sal_True, sal_False );
1807 [ + - ][ + + ]: 375 : if( !IsEnabled() )
1808 [ + - ]: 118 : SetTextColor( rStyleSettings.GetDisableColor() );
1809 [ + - ]: 375 : SetTextFillColor();
1810 [ + + ]: 375 : if( bErase )
1811 [ + - ]: 13 : Erase( aRect );
1812 : : }
1813 : : }
1814 : :
1815 [ + + ]: 4835 : if ( IsUserDrawEnabled() )
1816 : : {
1817 : 215 : mbInUserDraw = sal_True;
1818 : 215 : mnUserDrawEntry = nPos;
1819 : 215 : aRect.Left() -= mnLeft;
1820 [ - + ]: 215 : if ( nPos < GetEntryList()->GetMRUCount() )
1821 [ # # ][ # # ]: 0 : nPos = GetEntryList()->FindEntry( GetEntryList()->GetEntryText( nPos ) );
[ # # ]
1822 : 215 : nPos = sal::static_int_cast<sal_uInt16>(nPos - GetEntryList()->GetMRUCount());
1823 [ + - ]: 215 : UserDrawEvent aUDEvt( this, aRect, nPos, 0 );
1824 [ + - ]: 215 : maUserDrawHdl.Call( &aUDEvt );
1825 : 215 : mbInUserDraw = sal_False;
1826 : : }
1827 : : else
1828 : : {
1829 [ + - ]: 4835 : DrawEntry( nPos, sal_True, sal_True, sal_False, bLayout );
1830 : : }
1831 : : }
1832 : :
1833 : : // -----------------------------------------------------------------------
1834 : :
1835 : 4835 : void ImplListBoxWindow::DrawEntry( sal_uInt16 nPos, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos, bool bLayout )
1836 : : {
1837 [ + - ]: 4835 : const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nPos );
1838 [ + - ]: 4835 : if( ! pEntry )
1839 : 4835 : return;
1840 : :
1841 : : // Bei Aenderungen in dieser Methode ggf. auch ImplWin::DrawEntry() anpassen.
1842 : :
1843 [ + + ]: 4835 : if ( mbInUserDraw )
1844 : 215 : nPos = mnUserDrawEntry; // real entry, not the matching entry from MRU
1845 : :
1846 [ + - ]: 4835 : long nY = mpEntryList->GetAddedHeight( nPos, mnTop );
1847 : 4835 : Size aImgSz;
1848 : :
1849 [ + + ][ + - ]: 4835 : if( bDrawImage && mpEntryList->HasImages() && !bLayout )
[ + + ][ + + ]
1850 : : {
1851 [ + - ]: 103 : Image aImage = mpEntryList->GetEntryImage( nPos );
1852 [ + - ]: 103 : if( !!aImage )
1853 : : {
1854 [ + - ]: 103 : aImgSz = aImage.GetSizePixel();
1855 : 103 : Point aPtImg( mnBorder - mnLeft, nY + ( ( pEntry->mnHeight - aImgSz.Height() ) / 2 ) );
1856 : :
1857 : : // pb: #106948# explicit mirroring for calc
1858 [ - + ]: 103 : if ( mbMirroring )
1859 : : // right aligned
1860 : 0 : aPtImg.X() = mnMaxWidth + mnBorder - aImgSz.Width() - mnLeft;
1861 : :
1862 [ + - ][ + - ]: 103 : if ( !IsZoom() )
1863 : : {
1864 [ + - ]: 103 : DrawImage( aPtImg, aImage );
1865 : : }
1866 : : else
1867 : : {
1868 [ # # ]: 0 : aImgSz.Width() = CalcZoom( aImgSz.Width() );
1869 [ # # ]: 0 : aImgSz.Height() = CalcZoom( aImgSz.Height() );
1870 [ # # ]: 103 : DrawImage( aPtImg, aImgSz, aImage );
1871 : : }
1872 [ + - ]: 103 : }
1873 : : }
1874 : :
1875 [ + + ]: 4835 : if( bDrawText )
1876 : : {
1877 [ - + ]: 4833 : MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
1878 [ - + ]: 4833 : String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
1879 [ + - ]: 4833 : XubString aStr( mpEntryList->GetEntryText( nPos ) );
1880 [ + - ]: 4833 : if ( aStr.Len() )
1881 : : {
1882 : : long nMaxWidth = Max( static_cast< long >( mnMaxWidth ),
1883 : 4833 : GetOutputSizePixel().Width() - 2*mnBorder );
1884 : : // a multiline entry should only be as wide a the window
1885 [ - + ]: 4833 : if( (pEntry->mnFlags & LISTBOX_ENTRY_FLAG_MULTILINE) )
1886 : 0 : nMaxWidth = GetOutputSizePixel().Width() - 2*mnBorder;
1887 : :
1888 : : Rectangle aTextRect( Point( mnBorder - mnLeft, nY ),
1889 [ + - ]: 4833 : Size( nMaxWidth, pEntry->mnHeight ) );
1890 : :
1891 [ + - ][ + - ]: 4833 : if( !bDrawTextAtImagePos && ( mpEntryList->HasEntryImage(nPos) || IsUserDrawEnabled() ) )
[ + + ][ + + ]
[ + + ]
1892 : : {
1893 : 316 : long nImageWidth = Max( mnMaxImgWidth, maUserItemSize.Width() );
1894 : 316 : aTextRect.Left() += nImageWidth + IMG_TXT_DISTANCE;
1895 : : }
1896 : :
1897 [ - + ]: 4833 : if( bLayout )
1898 [ # # ]: 0 : mpControlData->mpLayoutData->m_aLineIndices.push_back( mpControlData->mpLayoutData->m_aDisplayText.Len() );
1899 : :
1900 : : // pb: #106948# explicit mirroring for calc
1901 [ - + ]: 4833 : if ( mbMirroring )
1902 : : {
1903 : : // right aligned
1904 [ # # ]: 0 : aTextRect.Left() = nMaxWidth + mnBorder - GetTextWidth( aStr ) - mnLeft;
1905 [ # # ]: 0 : if ( aImgSz.Width() > 0 )
1906 : 0 : aTextRect.Left() -= ( aImgSz.Width() + IMG_TXT_DISTANCE );
1907 : : }
1908 : :
1909 : 4833 : sal_uInt16 nDrawStyle = ImplGetTextStyle();
1910 [ - + ]: 4833 : if( (pEntry->mnFlags & LISTBOX_ENTRY_FLAG_MULTILINE) )
1911 : 0 : nDrawStyle |= MULTILINE_ENTRY_DRAW_FLAGS;
1912 [ - + ]: 4833 : if( (pEntry->mnFlags & LISTBOX_ENTRY_FLAG_DRAW_DISABLED) )
1913 : 0 : nDrawStyle |= TEXT_DRAW_DISABLE;
1914 : :
1915 [ + - ]: 4833 : DrawText( aTextRect, aStr, nDrawStyle, pVector, pDisplayText );
1916 [ + - ]: 4833 : }
1917 : : }
1918 : :
1919 [ + - ]: 4835 : if( !bLayout )
1920 : : {
1921 [ + + ][ + + ]: 4835 : if ( ( mnSeparatorPos != LISTBOX_ENTRY_NOTFOUND ) &&
[ + + ]
1922 : : ( ( nPos == mnSeparatorPos ) || ( nPos == mnSeparatorPos+1 ) ) )
1923 : : {
1924 : 764 : Color aOldLineColor( GetLineColor() );
1925 [ + - ][ + - ]: 764 : SetLineColor( ( GetBackground().GetColor() != COL_LIGHTGRAY ) ? COL_LIGHTGRAY : COL_GRAY );
[ + - ]
1926 : 764 : Point aStartPos( 0, nY );
1927 [ + + ]: 764 : if ( nPos == mnSeparatorPos )
1928 : 2 : aStartPos.Y() += pEntry->mnHeight-1;
1929 : 764 : Point aEndPos( aStartPos );
1930 : 764 : aEndPos.X() = GetOutputSizePixel().Width();
1931 [ + - ]: 764 : DrawLine( aStartPos, aEndPos );
1932 [ + - ]: 4835 : SetLineColor( aOldLineColor );
1933 : : }
1934 : : }
1935 : : }
1936 : :
1937 : : // -----------------------------------------------------------------------
1938 : :
1939 : 0 : void ImplListBoxWindow::FillLayoutData() const
1940 : : {
1941 [ # # ]: 0 : mpControlData->mpLayoutData = new vcl::ControlLayoutData();
1942 : : const_cast<ImplListBoxWindow*>(this)->
1943 [ # # ][ # # ]: 0 : ImplDoPaint( Rectangle( Point( 0, 0 ), GetOutputSize() ), true );
1944 : 0 : }
1945 : :
1946 : : // -----------------------------------------------------------------------
1947 : :
1948 : 283 : void ImplListBoxWindow::ImplDoPaint( const Rectangle& rRect, bool bLayout )
1949 : : {
1950 [ + - ]: 283 : sal_uInt16 nCount = mpEntryList->GetEntryCount();
1951 : :
1952 : 283 : sal_Bool bShowFocusRect = mbHasFocusRect;
1953 [ - + ][ # # ]: 283 : if ( mbHasFocusRect && ! bLayout )
1954 [ # # ]: 0 : ImplHideFocusRect();
1955 : :
1956 : 283 : long nY = 0; // + mnBorder;
1957 : 283 : long nHeight = GetOutputSizePixel().Height();// - mnMaxHeight + mnBorder;
1958 : :
1959 [ + + ][ + + ]: 677 : for( sal_uInt16 i = (sal_uInt16)mnTop; i < nCount && nY < nHeight + mnMaxHeight; i++ )
[ + + ]
1960 : : {
1961 [ + - ]: 394 : const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( i );
1962 [ + - + + ]: 788 : if( nY + pEntry->mnHeight >= rRect.Top() &&
[ + + ]
1963 : 394 : nY <= rRect.Bottom() + mnMaxHeight )
1964 : : {
1965 [ + - ]: 375 : ImplPaint( i, sal_False, bLayout );
1966 : : }
1967 : 394 : nY += pEntry->mnHeight;
1968 : : }
1969 : :
1970 [ + - ]: 283 : long nHeightDiff = mpEntryList->GetAddedHeight( mnCurrentPos, mnTop, 0 );
1971 : 283 : maFocusRect.SetPos( Point( 0, nHeightDiff ) );
1972 [ + - ][ + - ]: 283 : Size aSz( maFocusRect.GetWidth(), mpEntryList->GetEntryHeight( mnCurrentPos ) );
1973 [ + - ]: 283 : maFocusRect.SetSize( aSz );
1974 [ + - ][ - + ]: 283 : if( HasFocus() && bShowFocusRect && !bLayout )
[ # # ][ # # ]
[ - + ]
1975 [ # # ]: 0 : ImplShowFocusRect();
1976 : 283 : }
1977 : :
1978 : : // -----------------------------------------------------------------------
1979 : :
1980 : 283 : void ImplListBoxWindow::Paint( const Rectangle& rRect )
1981 : : {
1982 : 283 : ImplDoPaint( rRect );
1983 : 283 : }
1984 : :
1985 : : // -----------------------------------------------------------------------
1986 : :
1987 : 242 : sal_uInt16 ImplListBoxWindow::GetDisplayLineCount() const
1988 : : {
1989 : : // FIXME: LISTBOX_ENTRY_FLAG_MULTILINE
1990 : :
1991 : 242 : sal_uInt16 nCount = mpEntryList->GetEntryCount();
1992 : 242 : long nHeight = GetOutputSizePixel().Height();// - mnMaxHeight + mnBorder;
1993 : 242 : sal_uInt16 nEntries = static_cast< sal_uInt16 >( ( nHeight + mnMaxHeight - 1 ) / mnMaxHeight );
1994 [ - + ]: 242 : if( nEntries > nCount-mnTop )
1995 : 0 : nEntries = nCount-mnTop;
1996 : :
1997 : 242 : return nEntries;
1998 : : }
1999 : :
2000 : : // -----------------------------------------------------------------------
2001 : :
2002 : 15848 : void ImplListBoxWindow::Resize()
2003 : : {
2004 : 15848 : Control::Resize();
2005 : :
2006 : 15848 : sal_Bool bShowFocusRect = mbHasFocusRect;
2007 [ - + ]: 15848 : if ( bShowFocusRect )
2008 : 0 : ImplHideFocusRect();
2009 : :
2010 [ + + ]: 15848 : if( mnCurrentPos != LISTBOX_ENTRY_NOTFOUND )
2011 : : {
2012 [ + - ]: 3877 : Size aSz( GetOutputSizePixel().Width(), mpEntryList->GetEntryHeight( mnCurrentPos ) );
2013 [ + - ]: 3877 : maFocusRect.SetSize( aSz );
2014 : : }
2015 : :
2016 [ - + ]: 15848 : if ( bShowFocusRect )
2017 : 0 : ImplShowFocusRect();
2018 : :
2019 : 15848 : ImplClearLayoutData();
2020 : 15848 : }
2021 : :
2022 : : // -----------------------------------------------------------------------
2023 : :
2024 : 0 : void ImplListBoxWindow::GetFocus()
2025 : : {
2026 : 0 : sal_uInt16 nPos = mnCurrentPos;
2027 [ # # ]: 0 : if ( nPos == LISTBOX_ENTRY_NOTFOUND )
2028 : 0 : nPos = 0;
2029 [ # # ]: 0 : long nHeightDiff = mpEntryList->GetAddedHeight( nPos, mnTop, 0 );
2030 : 0 : maFocusRect.SetPos( Point( 0, nHeightDiff ) );
2031 [ # # ][ # # ]: 0 : Size aSz( maFocusRect.GetWidth(), mpEntryList->GetEntryHeight( nPos ) );
2032 [ # # ]: 0 : maFocusRect.SetSize( aSz );
2033 [ # # ]: 0 : ImplShowFocusRect();
2034 [ # # ]: 0 : Control::GetFocus();
2035 : 0 : }
2036 : :
2037 : : // -----------------------------------------------------------------------
2038 : :
2039 : 0 : void ImplListBoxWindow::LoseFocus()
2040 : : {
2041 : 0 : ImplHideFocusRect();
2042 : 0 : Control::LoseFocus();
2043 : 0 : }
2044 : :
2045 : : // -----------------------------------------------------------------------
2046 : :
2047 : 30894 : void ImplListBoxWindow::SetTopEntry( sal_uInt16 nTop )
2048 : : {
2049 [ + + ]: 30894 : if( mpEntryList->GetEntryCount() == 0 )
2050 : 30894 : return;
2051 : :
2052 [ + - ]: 8454 : long nWHeight = PixelToLogic( GetSizePixel() ).Height();
2053 : :
2054 : 8454 : sal_uInt16 nLastEntry = mpEntryList->GetEntryCount()-1;
2055 [ - + ]: 8454 : if( nTop > nLastEntry )
2056 : 0 : nTop = nLastEntry;
2057 : 8454 : const ImplEntryType* pLast = mpEntryList->GetEntryPtr( nLastEntry );
2058 [ + + ][ + + ]: 8478 : while( nTop > 0 && mpEntryList->GetAddedHeight( nLastEntry, nTop-1 ) + pLast->mnHeight <= nWHeight )
[ + + ]
2059 : 24 : nTop--;
2060 : :
2061 [ + + ]: 8454 : if ( nTop != mnTop )
2062 : : {
2063 : 1421 : ImplClearLayoutData();
2064 : 1421 : long nDiff = mpEntryList->GetAddedHeight( mnTop, nTop, 0 );
2065 : 1421 : Update();
2066 : 1421 : ImplHideFocusRect();
2067 : 1421 : mnTop = nTop;
2068 : 1421 : Scroll( 0, nDiff );
2069 : 1421 : Update();
2070 [ - + ]: 1421 : if( HasFocus() )
2071 : 0 : ImplShowFocusRect();
2072 : 1421 : maScrollHdl.Call( this );
2073 : : }
2074 : : }
2075 : :
2076 : : // -----------------------------------------------------------------------
2077 : :
2078 : 3842 : void ImplListBoxWindow::ShowProminentEntry( sal_uInt16 nEntryPos )
2079 : : {
2080 [ + + ]: 3842 : if( meProminentType == PROMINENT_MIDDLE )
2081 : : {
2082 : 944 : sal_uInt16 nPos = nEntryPos;
2083 [ + - ]: 944 : long nWHeight = PixelToLogic( GetSizePixel() ).Height();
2084 [ + - ][ - + ]: 944 : while( nEntryPos > 0 && mpEntryList->GetAddedHeight( nPos+1, nEntryPos ) < nWHeight/2 )
[ - + ]
2085 : 0 : nEntryPos--;
2086 : : }
2087 : 3842 : SetTopEntry( nEntryPos );
2088 : 3842 : }
2089 : :
2090 : : // -----------------------------------------------------------------------
2091 : :
2092 : 27064 : void ImplListBoxWindow::SetLeftIndent( long n )
2093 : : {
2094 : 27064 : ScrollHorz( n - mnLeft );
2095 : 27064 : }
2096 : :
2097 : : // -----------------------------------------------------------------------
2098 : :
2099 : 27064 : void ImplListBoxWindow::ScrollHorz( long n )
2100 : : {
2101 : 27064 : long nDiff = 0;
2102 [ - + ]: 27064 : if ( n > 0 )
2103 : : {
2104 : 0 : long nWidth = GetOutputSizePixel().Width();
2105 [ # # ]: 0 : if( ( mnMaxWidth - mnLeft + n ) > nWidth )
2106 : 0 : nDiff = n;
2107 : : }
2108 [ - + ]: 27064 : else if ( n < 0 )
2109 : : {
2110 [ # # ]: 0 : if( mnLeft )
2111 : : {
2112 : 0 : long nAbs = -n;
2113 [ # # ]: 0 : nDiff = - ( ( mnLeft > nAbs ) ? nAbs : mnLeft );
2114 : : }
2115 : : }
2116 : :
2117 [ - + ]: 27064 : if ( nDiff )
2118 : : {
2119 : 0 : ImplClearLayoutData();
2120 : 0 : mnLeft = sal::static_int_cast<sal_uInt16>(mnLeft + nDiff);
2121 : 0 : Update();
2122 : 0 : ImplHideFocusRect();
2123 : 0 : Scroll( -nDiff, 0 );
2124 : 0 : Update();
2125 [ # # ]: 0 : if( HasFocus() )
2126 : 0 : ImplShowFocusRect();
2127 : 0 : maScrollHdl.Call( this );
2128 : : }
2129 : 27064 : }
2130 : :
2131 : : // -----------------------------------------------------------------------
2132 : :
2133 : 4931 : Size ImplListBoxWindow::CalcSize( sal_uInt16 nMaxLines ) const
2134 : : {
2135 : : // FIXME: LISTBOX_ENTRY_FLAG_MULTILINE
2136 : :
2137 : 4931 : Size aSz;
2138 : : // sal_uInt16 nL = Min( nMaxLines, mpEntryList->GetEntryCount() );
2139 : 4931 : aSz.Height() = nMaxLines * mnMaxHeight;
2140 : 4931 : aSz.Width() = mnMaxWidth + 2*mnBorder;
2141 : 4931 : return aSz;
2142 : : }
2143 : :
2144 : : // -----------------------------------------------------------------------
2145 : :
2146 : 0 : Rectangle ImplListBoxWindow::GetBoundingRectangle( sal_uInt16 nItem ) const
2147 : : {
2148 [ # # ]: 0 : const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nItem );
2149 [ # # ][ # # ]: 0 : Size aSz( GetSizePixel().Width(), pEntry ? pEntry->mnHeight : GetEntryHeight() );
2150 [ # # ][ # # ]: 0 : long nY = mpEntryList->GetAddedHeight( nItem, GetTopEntry() ) - mpEntryList->GetAddedHeight( GetTopEntry() );
2151 [ # # ]: 0 : Rectangle aRect( Point( 0, nY ), aSz );
2152 : 0 : return aRect;
2153 : : }
2154 : :
2155 : :
2156 : : // -----------------------------------------------------------------------
2157 : :
2158 : 200286 : void ImplListBoxWindow::StateChanged( StateChangedType nType )
2159 : : {
2160 : 200286 : Control::StateChanged( nType );
2161 : :
2162 [ - + ]: 200286 : if ( nType == STATE_CHANGE_ZOOM )
2163 : : {
2164 : 0 : ImplInitSettings( sal_True, sal_False, sal_False );
2165 : 0 : ImplCalcMetrics();
2166 : 0 : Invalidate();
2167 : : }
2168 [ + + ]: 200286 : else if ( nType == STATE_CHANGE_UPDATEMODE )
2169 : : {
2170 [ + + ][ - + ]: 195420 : if ( IsUpdateMode() && IsReallyVisible() )
[ - + ]
2171 : 0 : Invalidate();
2172 : : }
2173 [ + + ]: 4866 : else if ( nType == STATE_CHANGE_CONTROLFONT )
2174 : : {
2175 : 599 : ImplInitSettings( sal_True, sal_False, sal_False );
2176 : 599 : ImplCalcMetrics();
2177 : 599 : Invalidate();
2178 : : }
2179 [ - + ]: 4267 : else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
2180 : : {
2181 : 0 : ImplInitSettings( sal_False, sal_True, sal_False );
2182 : 0 : Invalidate();
2183 : : }
2184 [ - + ]: 4267 : else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
2185 : : {
2186 : 0 : ImplInitSettings( sal_False, sal_False, sal_True );
2187 : 0 : Invalidate();
2188 : : }
2189 : 200286 : ImplClearLayoutData();
2190 : 200286 : }
2191 : :
2192 : : // -----------------------------------------------------------------------
2193 : :
2194 : 307 : void ImplListBoxWindow::DataChanged( const DataChangedEvent& rDCEvt )
2195 : : {
2196 : 307 : Control::DataChanged( rDCEvt );
2197 : :
2198 [ + + ][ + - : 1228 : if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ - + - +
+ ]
2199 : 307 : (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
2200 : 307 : ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
2201 : 307 : (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
2202 : : {
2203 : 257 : ImplClearLayoutData();
2204 : 257 : ImplInitSettings( sal_True, sal_True, sal_True );
2205 : 257 : ImplCalcMetrics();
2206 : 257 : Invalidate();
2207 : : }
2208 : 307 : }
2209 : :
2210 : : // -----------------------------------------------------------------------
2211 : :
2212 : 4833 : sal_uInt16 ImplListBoxWindow::ImplGetTextStyle() const
2213 : : {
2214 : 4833 : sal_uInt16 nTextStyle = TEXT_DRAW_VCENTER;
2215 : :
2216 [ + + ]: 4833 : if ( mpEntryList->HasImages() )
2217 : 103 : nTextStyle |= TEXT_DRAW_LEFT;
2218 [ + + ]: 4730 : else if ( mbCenter )
2219 : 50 : nTextStyle |= TEXT_DRAW_CENTER;
2220 [ - + ]: 4680 : else if ( mbRight )
2221 : 0 : nTextStyle |= TEXT_DRAW_RIGHT;
2222 : : else
2223 : 4680 : nTextStyle |= TEXT_DRAW_LEFT;
2224 : :
2225 : 4833 : return nTextStyle;
2226 : : }
2227 : :
2228 : : // =======================================================================
2229 : :
2230 : 3860 : ImplListBox::ImplListBox( Window* pParent, WinBits nWinStyle ) :
2231 : : Control( pParent, nWinStyle ),
2232 [ + - ][ + - ]: 3860 : maLBWindow( this, nWinStyle&(~WB_BORDER) )
2233 : : {
2234 : : // for native widget rendering we must be able to detect this window type
2235 [ + - ]: 3860 : SetType( WINDOW_LISTBOXWINDOW );
2236 : :
2237 [ + - ][ + - ]: 3860 : mpVScrollBar = new ScrollBar( this, WB_VSCROLL | WB_DRAG );
2238 [ + - ][ + - ]: 3860 : mpHScrollBar = new ScrollBar( this, WB_HSCROLL | WB_DRAG );
2239 [ + - ][ + - ]: 3860 : mpScrollBarBox = new ScrollBarBox( this );
2240 : :
2241 [ + - ]: 3860 : Link aLink( LINK( this, ImplListBox, ScrollBarHdl ) );
2242 : 3860 : mpVScrollBar->SetScrollHdl( aLink );
2243 : 3860 : mpHScrollBar->SetScrollHdl( aLink );
2244 : :
2245 : 3860 : mbVScroll = sal_False;
2246 : 3860 : mbHScroll = sal_False;
2247 [ + + ]: 3860 : mbAutoHScroll = ( nWinStyle & WB_AUTOHSCROLL ) ? sal_True : sal_False;
2248 : :
2249 [ + - ]: 3860 : maLBWindow.SetScrollHdl( LINK( this, ImplListBox, LBWindowScrolled ) );
2250 [ + - ]: 3860 : maLBWindow.SetMRUChangedHdl( LINK( this, ImplListBox, MRUChanged ) );
2251 [ + - ]: 3860 : maLBWindow.Show();
2252 : 3860 : }
2253 : :
2254 : : // -----------------------------------------------------------------------
2255 : :
2256 [ + - ]: 3856 : ImplListBox::~ImplListBox()
2257 : : {
2258 [ + - ][ + - ]: 3856 : delete mpHScrollBar;
2259 [ + - ][ + - ]: 3856 : delete mpVScrollBar;
2260 [ + - ][ + - ]: 3856 : delete mpScrollBarBox;
2261 [ - + ]: 7712 : }
2262 : :
2263 : : // -----------------------------------------------------------------------
2264 : :
2265 : 15513 : void ImplListBox::Clear()
2266 : : {
2267 : 15513 : maLBWindow.Clear();
2268 [ - + ]: 15513 : if ( GetEntryList()->GetMRUCount() )
2269 : : {
2270 : 0 : maLBWindow.GetEntryList()->SetMRUCount( 0 );
2271 : 0 : maLBWindow.SetSeparatorPos( LISTBOX_ENTRY_NOTFOUND );
2272 : : }
2273 : 15513 : mpVScrollBar->SetThumbPos( 0 );
2274 : 15513 : mpHScrollBar->SetThumbPos( 0 );
2275 : 15513 : StateChanged( STATE_CHANGE_DATA );
2276 : 15513 : }
2277 : :
2278 : : // -----------------------------------------------------------------------
2279 : :
2280 : 149093 : sal_uInt16 ImplListBox::InsertEntry( sal_uInt16 nPos, const XubString& rStr )
2281 : : {
2282 [ + - ]: 149093 : ImplEntryType* pNewEntry = new ImplEntryType( rStr );
2283 : 149093 : sal_uInt16 nNewPos = maLBWindow.InsertEntry( nPos, pNewEntry );
2284 : 149093 : StateChanged( STATE_CHANGE_DATA );
2285 : 149093 : return nNewPos;
2286 : : }
2287 : :
2288 : : // -----------------------------------------------------------------------
2289 : :
2290 : 0 : sal_uInt16 ImplListBox::InsertEntry( sal_uInt16 nPos, const Image& rImage )
2291 : : {
2292 [ # # ]: 0 : ImplEntryType* pNewEntry = new ImplEntryType( rImage );
2293 : 0 : sal_uInt16 nNewPos = maLBWindow.InsertEntry( nPos, pNewEntry );
2294 : 0 : StateChanged( STATE_CHANGE_DATA );
2295 : 0 : return nNewPos;
2296 : : }
2297 : :
2298 : : // -----------------------------------------------------------------------
2299 : :
2300 : 1714 : sal_uInt16 ImplListBox::InsertEntry( sal_uInt16 nPos, const XubString& rStr, const Image& rImage )
2301 : : {
2302 [ + - ]: 1714 : ImplEntryType* pNewEntry = new ImplEntryType( rStr, rImage );
2303 : 1714 : sal_uInt16 nNewPos = maLBWindow.InsertEntry( nPos, pNewEntry );
2304 : 1714 : StateChanged( STATE_CHANGE_DATA );
2305 : 1714 : return nNewPos;
2306 : : }
2307 : :
2308 : : // -----------------------------------------------------------------------
2309 : :
2310 : 0 : void ImplListBox::RemoveEntry( sal_uInt16 nPos )
2311 : : {
2312 : 0 : maLBWindow.RemoveEntry( nPos );
2313 : 0 : StateChanged( STATE_CHANGE_DATA );
2314 : 0 : }
2315 : :
2316 : : // -----------------------------------------------------------------------
2317 : :
2318 : 0 : void ImplListBox::SetEntryFlags( sal_uInt16 nPos, long nFlags )
2319 : : {
2320 : 0 : maLBWindow.SetEntryFlags( nPos, nFlags );
2321 : 0 : }
2322 : :
2323 : : // -----------------------------------------------------------------------
2324 : :
2325 : 7058 : void ImplListBox::SelectEntry( sal_uInt16 nPos, sal_Bool bSelect )
2326 : : {
2327 : 7058 : maLBWindow.SelectEntry( nPos, bSelect );
2328 : 7058 : }
2329 : :
2330 : : // -----------------------------------------------------------------------
2331 : :
2332 : 275 : void ImplListBox::SetNoSelection()
2333 : : {
2334 : 275 : maLBWindow.DeselectAll();
2335 : 275 : }
2336 : :
2337 : : // -----------------------------------------------------------------------
2338 : :
2339 : 0 : void ImplListBox::GetFocus()
2340 : : {
2341 : 0 : maLBWindow.GrabFocus();
2342 : 0 : }
2343 : :
2344 : : // -----------------------------------------------------------------------
2345 : :
2346 : 0 : Window* ImplListBox::GetPreferredKeyInputWindow()
2347 : : {
2348 : 0 : return &maLBWindow;
2349 : : }
2350 : :
2351 : : // -----------------------------------------------------------------------
2352 : :
2353 : 13606 : void ImplListBox::Resize()
2354 : : {
2355 : 13606 : Control::Resize();
2356 : 13606 : ImplResizeControls();
2357 : 13606 : ImplCheckScrollBars();
2358 : 13606 : }
2359 : :
2360 : :
2361 : : // -----------------------------------------------------------------------
2362 : :
2363 : 0 : IMPL_LINK_NOARG(ImplListBox, MRUChanged)
2364 : : {
2365 : 0 : StateChanged( STATE_CHANGE_DATA );
2366 : 0 : return 1;
2367 : : }
2368 : :
2369 : : // -----------------------------------------------------------------------
2370 : :
2371 : 1421 : IMPL_LINK_NOARG(ImplListBox, LBWindowScrolled)
2372 : : {
2373 : 1421 : long nSet = GetTopEntry();
2374 [ - + ]: 1421 : if( nSet > mpVScrollBar->GetRangeMax() )
2375 : 0 : mpVScrollBar->SetRangeMax( GetEntryList()->GetEntryCount() );
2376 : 1421 : mpVScrollBar->SetThumbPos( GetTopEntry() );
2377 : :
2378 : 1421 : mpHScrollBar->SetThumbPos( GetLeftIndent() );
2379 : :
2380 : 1421 : maScrollHdl.Call( this );
2381 : :
2382 : 1421 : return 1;
2383 : : }
2384 : :
2385 : : // -----------------------------------------------------------------------
2386 : :
2387 : 0 : IMPL_LINK( ImplListBox, ScrollBarHdl, ScrollBar*, pSB )
2388 : : {
2389 : 0 : sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos();
2390 [ # # ]: 0 : if( pSB == mpVScrollBar )
2391 : 0 : SetTopEntry( nPos );
2392 [ # # ]: 0 : else if( pSB == mpHScrollBar )
2393 : 0 : SetLeftIndent( nPos );
2394 : :
2395 : 0 : return 1;
2396 : : }
2397 : :
2398 : : // -----------------------------------------------------------------------
2399 : :
2400 : 13620 : void ImplListBox::ImplCheckScrollBars()
2401 : : {
2402 : 13620 : sal_Bool bArrange = sal_False;
2403 : :
2404 : 13620 : Size aOutSz = GetOutputSizePixel();
2405 [ + - ]: 13620 : sal_uInt16 nEntries = GetEntryList()->GetEntryCount();
2406 : 13620 : sal_uInt16 nMaxVisEntries = (sal_uInt16) (aOutSz.Height() / GetEntryHeight());
2407 : :
2408 : : // vert. ScrollBar
2409 [ + + ]: 13620 : if( nEntries > nMaxVisEntries )
2410 : : {
2411 [ + + ]: 417 : if( !mbVScroll )
2412 : 161 : bArrange = sal_True;
2413 : 417 : mbVScroll = sal_True;
2414 : :
2415 : : // Ueberpruefung des rausgescrollten Bereichs
2416 [ + - ][ + + ]: 675 : if( GetEntryList()->GetSelectEntryCount() == 1 &&
[ + - ][ + + ]
2417 [ + - ]: 258 : GetEntryList()->GetSelectEntryPos( 0 ) != LISTBOX_ENTRY_NOTFOUND )
2418 [ + - ][ + - ]: 258 : ShowProminentEntry( GetEntryList()->GetSelectEntryPos( 0 ) );
2419 : : else
2420 [ + - ]: 159 : SetTopEntry( GetTopEntry() ); // MaxTop wird geprueft...
2421 : : }
2422 : : else
2423 : : {
2424 [ + + ]: 13203 : if( mbVScroll )
2425 : 129 : bArrange = sal_True;
2426 : 13203 : mbVScroll = sal_False;
2427 [ + - ]: 13203 : SetTopEntry( 0 );
2428 : : }
2429 : :
2430 : : // horz. ScrollBar
2431 [ + + ]: 13620 : if( mbAutoHScroll )
2432 : : {
2433 : 13008 : long nWidth = (sal_uInt16) aOutSz.Width();
2434 [ + + ]: 13008 : if ( mbVScroll )
2435 [ + - ]: 417 : nWidth -= mpVScrollBar->GetSizePixel().Width();
2436 : :
2437 : 13008 : long nMaxWidth = GetMaxEntryWidth();
2438 [ + + ]: 13008 : if( nWidth < nMaxWidth )
2439 : : {
2440 [ + + ]: 14 : if( !mbHScroll )
2441 : 2 : bArrange = sal_True;
2442 : 14 : mbHScroll = sal_True;
2443 : :
2444 [ - + ]: 14 : if ( !mbVScroll ) // ggf. brauchen wir jetzt doch einen
2445 : : {
2446 [ # # ]: 0 : nMaxVisEntries = (sal_uInt16) ( ( aOutSz.Height() - mpHScrollBar->GetSizePixel().Height() ) / GetEntryHeight() );
2447 [ # # ]: 0 : if( nEntries > nMaxVisEntries )
2448 : : {
2449 : 0 : bArrange = sal_True;
2450 : 0 : mbVScroll = sal_True;
2451 : :
2452 : : // Ueberpruefung des rausgescrollten Bereichs
2453 [ # # ][ # # ]: 0 : if( GetEntryList()->GetSelectEntryCount() == 1 &&
[ # # ][ # # ]
2454 [ # # ]: 0 : GetEntryList()->GetSelectEntryPos( 0 ) != LISTBOX_ENTRY_NOTFOUND )
2455 [ # # ][ # # ]: 0 : ShowProminentEntry( GetEntryList()->GetSelectEntryPos( 0 ) );
2456 : : else
2457 [ # # ]: 0 : SetTopEntry( GetTopEntry() ); // MaxTop wird geprueft...
2458 : : }
2459 : : }
2460 : :
2461 : : // Ueberpruefung des rausgescrollten Bereichs
2462 : 14 : sal_uInt16 nMaxLI = (sal_uInt16) (nMaxWidth - nWidth);
2463 [ - + ]: 14 : if ( nMaxLI < GetLeftIndent() )
2464 [ # # ]: 0 : SetLeftIndent( nMaxLI );
2465 : : }
2466 : : else
2467 : : {
2468 [ - + ]: 12994 : if( mbHScroll )
2469 : 0 : bArrange = sal_True;
2470 : 12994 : mbHScroll = sal_False;
2471 [ + - ]: 12994 : SetLeftIndent( 0 );
2472 : : }
2473 : : }
2474 : :
2475 [ + + ]: 13620 : if( bArrange )
2476 [ + - ]: 292 : ImplResizeControls();
2477 : :
2478 [ + - ]: 13620 : ImplInitScrollBars();
2479 : 13620 : }
2480 : :
2481 : : // -----------------------------------------------------------------------
2482 : :
2483 : 13620 : void ImplListBox::ImplInitScrollBars()
2484 : : {
2485 : 13620 : Size aOutSz = maLBWindow.GetOutputSizePixel();
2486 : :
2487 [ + + ]: 13620 : if ( mbVScroll )
2488 : : {
2489 [ + - ]: 417 : sal_uInt16 nEntries = GetEntryList()->GetEntryCount();
2490 : 417 : sal_uInt16 nVisEntries = (sal_uInt16) (aOutSz.Height() / GetEntryHeight());
2491 [ + - ]: 417 : mpVScrollBar->SetRangeMax( nEntries );
2492 [ + - ]: 417 : mpVScrollBar->SetVisibleSize( nVisEntries );
2493 : 417 : mpVScrollBar->SetPageSize( nVisEntries - 1 );
2494 : : }
2495 : :
2496 [ + + ]: 13620 : if ( mbHScroll )
2497 : : {
2498 [ + - ]: 14 : mpHScrollBar->SetRangeMax( GetMaxEntryWidth() + HORZ_SCROLL );
2499 [ + - ]: 14 : mpHScrollBar->SetVisibleSize( (sal_uInt16)aOutSz.Width() );
2500 : 14 : mpHScrollBar->SetLineSize( HORZ_SCROLL );
2501 : 14 : mpHScrollBar->SetPageSize( aOutSz.Width() - HORZ_SCROLL );
2502 : : }
2503 : 13620 : }
2504 : :
2505 : : // -----------------------------------------------------------------------
2506 : :
2507 : 14086 : void ImplListBox::ImplResizeControls()
2508 : : {
2509 : : // Hier werden die Controls nur angeordnet, ob die Scrollbars
2510 : : // sichtbar sein sollen wird bereits in ImplCheckScrollBars ermittelt.
2511 : :
2512 : 14086 : Size aOutSz = GetOutputSizePixel();
2513 : 14086 : long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
2514 [ + - ]: 14086 : nSBWidth = CalcZoom( nSBWidth );
2515 : :
2516 : 14086 : Size aInnerSz( aOutSz );
2517 [ + + ]: 14086 : if ( mbVScroll )
2518 : 552 : aInnerSz.Width() -= nSBWidth;
2519 [ + + ]: 14086 : if ( mbHScroll )
2520 : 16 : aInnerSz.Height() -= nSBWidth;
2521 : :
2522 : : // pb: #106948# explicit mirroring for calc
2523 : : // Scrollbar on left or right side?
2524 : 14086 : sal_Bool bMirroring = maLBWindow.IsMirroring();
2525 [ # # ][ - + ]: 14086 : Point aWinPos( bMirroring && mbVScroll ? nSBWidth : 0, 0 );
2526 [ + - ]: 14086 : maLBWindow.SetPosSizePixel( aWinPos, aInnerSz );
2527 : :
2528 : : // ScrollBarBox
2529 [ + + ][ + + ]: 14086 : if( mbVScroll && mbHScroll )
2530 : : {
2531 [ + - ]: 16 : Point aBoxPos( bMirroring ? 0 : aInnerSz.Width(), aInnerSz.Height() );
2532 [ + - ]: 16 : mpScrollBarBox->SetPosSizePixel( aBoxPos, Size( nSBWidth, nSBWidth ) );
2533 [ + - ]: 16 : mpScrollBarBox->Show();
2534 : : }
2535 : : else
2536 : : {
2537 [ + - ]: 14070 : mpScrollBarBox->Hide();
2538 : : }
2539 : :
2540 : : // vert. ScrollBar
2541 [ + + ]: 14086 : if( mbVScroll )
2542 : : {
2543 : : // Scrollbar on left or right side?
2544 [ + - ]: 552 : Point aVPos( bMirroring ? 0 : aOutSz.Width() - nSBWidth, 0 );
2545 [ + - ]: 552 : mpVScrollBar->SetPosSizePixel( aVPos, Size( nSBWidth, aInnerSz.Height() ) );
2546 [ + - ]: 552 : mpVScrollBar->Show();
2547 : : }
2548 : : else
2549 : : {
2550 [ + - ]: 13534 : mpVScrollBar->Hide();
2551 : : // #107254# Don't reset top entry after resize, but check for max top entry
2552 [ + - ]: 13534 : SetTopEntry( GetTopEntry() );
2553 : : }
2554 : :
2555 : : // horz. ScrollBar
2556 [ + + ]: 14086 : if( mbHScroll )
2557 : : {
2558 [ - + ][ # # ]: 16 : Point aHPos( ( bMirroring && mbVScroll ) ? nSBWidth : 0, aOutSz.Height() - nSBWidth );
2559 [ + - ]: 16 : mpHScrollBar->SetPosSizePixel( aHPos, Size( aInnerSz.Width(), nSBWidth ) );
2560 [ + - ]: 16 : mpHScrollBar->Show();
2561 : : }
2562 : : else
2563 : : {
2564 [ + - ]: 14070 : mpHScrollBar->Hide();
2565 [ + - ]: 14070 : SetLeftIndent( 0 );
2566 : : }
2567 : 14086 : }
2568 : :
2569 : : // -----------------------------------------------------------------------
2570 : :
2571 : 200286 : void ImplListBox::StateChanged( StateChangedType nType )
2572 : : {
2573 [ + + ]: 200286 : if ( nType == STATE_CHANGE_INITSHOW )
2574 : : {
2575 : 14 : ImplCheckScrollBars();
2576 : : }
2577 [ + + ][ + + ]: 200272 : else if ( ( nType == STATE_CHANGE_UPDATEMODE ) || ( nType == STATE_CHANGE_DATA ) )
2578 : : {
2579 : 195420 : sal_Bool bUpdate = IsUpdateMode();
2580 : 195420 : maLBWindow.SetUpdateMode( bUpdate );
2581 [ - + ][ - + ]: 195420 : if ( bUpdate && IsReallyVisible() )
[ + + ]
2582 : 195420 : ImplCheckScrollBars();
2583 : : }
2584 [ + + ]: 4852 : else if( nType == STATE_CHANGE_ENABLE )
2585 : : {
2586 : 205 : mpHScrollBar->Enable( IsEnabled() );
2587 : 205 : mpVScrollBar->Enable( IsEnabled() );
2588 : 205 : mpScrollBarBox->Enable( IsEnabled() );
2589 : 205 : Invalidate();
2590 : : }
2591 [ - + ]: 4647 : else if ( nType == STATE_CHANGE_ZOOM )
2592 : : {
2593 : 0 : maLBWindow.SetZoom( GetZoom() );
2594 : 0 : Resize();
2595 : : }
2596 [ + + ]: 4647 : else if ( nType == STATE_CHANGE_CONTROLFONT )
2597 : : {
2598 [ + - ]: 599 : maLBWindow.SetControlFont( GetControlFont() );
2599 : : }
2600 [ - + ]: 4048 : else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
2601 : : {
2602 [ # # ]: 0 : maLBWindow.SetControlForeground( GetControlForeground() );
2603 : : }
2604 [ - + ]: 4048 : else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
2605 : : {
2606 [ # # ]: 0 : maLBWindow.SetControlBackground( GetControlBackground() );
2607 : : }
2608 [ + + ]: 4048 : else if( nType == STATE_CHANGE_MIRRORING )
2609 : : {
2610 : 188 : maLBWindow.EnableRTL( IsRTLEnabled() );
2611 : 188 : mpHScrollBar->EnableRTL( IsRTLEnabled() );
2612 : 188 : mpVScrollBar->EnableRTL( IsRTLEnabled() );
2613 : 188 : ImplResizeControls();
2614 : : }
2615 : :
2616 : 200286 : Control::StateChanged( nType );
2617 : 200286 : }
2618 : :
2619 : : // -----------------------------------------------------------------------
2620 : :
2621 : 307 : void ImplListBox::DataChanged( const DataChangedEvent& rDCEvt )
2622 : : {
2623 : 307 : Control::DataChanged( rDCEvt );
2624 : 307 : }
2625 : :
2626 : : // -----------------------------------------------------------------------
2627 : :
2628 : 15634 : long ImplListBox::Notify( NotifyEvent& rNEvt )
2629 : : {
2630 : 15634 : long nDone = 0;
2631 [ - + ]: 15634 : if ( rNEvt.GetType() == EVENT_COMMAND )
2632 : : {
2633 : 0 : const CommandEvent& rCEvt = *rNEvt.GetCommandEvent();
2634 [ # # ]: 0 : if ( rCEvt.GetCommand() == COMMAND_WHEEL )
2635 : : {
2636 : 0 : const CommandWheelData* pData = rCEvt.GetWheelData();
2637 [ # # ][ # # ]: 0 : if( !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) )
[ # # ]
2638 : : {
2639 : 0 : nDone = HandleScrollCommand( rCEvt, mpHScrollBar, mpVScrollBar );
2640 : : }
2641 : : }
2642 : : }
2643 : :
2644 [ + - ]: 15634 : return nDone ? nDone : Window::Notify( rNEvt );
2645 : : }
2646 : :
2647 : : // -----------------------------------------------------------------------
2648 : :
2649 : 0 : const Wallpaper& ImplListBox::GetDisplayBackground() const
2650 : : {
2651 : 0 : return maLBWindow.GetDisplayBackground();
2652 : : }
2653 : :
2654 : : // -----------------------------------------------------------------------
2655 : :
2656 : 0 : sal_Bool ImplListBox::HandleWheelAsCursorTravel( const CommandEvent& rCEvt )
2657 : : {
2658 : 0 : sal_Bool bDone = sal_False;
2659 [ # # ]: 0 : if ( rCEvt.GetCommand() == COMMAND_WHEEL )
2660 : : {
2661 : 0 : const CommandWheelData* pData = rCEvt.GetWheelData();
2662 [ # # ][ # # ]: 0 : if( !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) )
[ # # ]
2663 : : {
2664 [ # # ]: 0 : sal_uInt16 nKey = ( pData->GetDelta() < 0 ) ? KEY_DOWN : KEY_UP;
2665 [ # # ]: 0 : KeyEvent aKeyEvent( 0, KeyCode( nKey ) );
2666 [ # # ]: 0 : bDone = ProcessKeyInput( aKeyEvent );
2667 : : }
2668 : : }
2669 : 0 : return bDone;
2670 : : }
2671 : :
2672 : : // -----------------------------------------------------------------------
2673 : :
2674 : 0 : void ImplListBox::SetMRUEntries( const rtl::OUString& rEntries, xub_Unicode cSep )
2675 : : {
2676 [ # # ]: 0 : sal_Bool bChanges = GetEntryList()->GetMRUCount() ? sal_True : sal_False;
2677 : :
2678 : : // Remove old MRU entries
2679 [ # # ]: 0 : for ( sal_uInt16 n = GetEntryList()->GetMRUCount();n; )
2680 [ # # ]: 0 : maLBWindow.RemoveEntry( --n );
2681 : :
2682 : 0 : sal_uInt16 nMRUCount = 0;
2683 : 0 : sal_Int32 nIndex = 0;
2684 [ # # ]: 0 : do
2685 : : {
2686 [ # # ]: 0 : XubString aEntry = rEntries.getToken( 0, cSep, nIndex );
2687 : : // Accept only existing entries
2688 [ # # ][ # # ]: 0 : if ( GetEntryList()->FindEntry( aEntry ) != LISTBOX_ENTRY_NOTFOUND )
2689 : : {
2690 [ # # ][ # # ]: 0 : ImplEntryType* pNewEntry = new ImplEntryType( aEntry );
2691 [ # # ]: 0 : maLBWindow.GetEntryList()->InsertEntry( nMRUCount++, pNewEntry, sal_False );
2692 : 0 : bChanges = sal_True;
2693 [ # # ]: 0 : }
2694 : : }
2695 : : while ( nIndex >= 0 );
2696 : :
2697 [ # # ]: 0 : if ( bChanges )
2698 : : {
2699 : 0 : maLBWindow.GetEntryList()->SetMRUCount( nMRUCount );
2700 [ # # ]: 0 : SetSeparatorPos( nMRUCount ? nMRUCount-1 : 0 );
2701 [ # # ]: 0 : StateChanged( STATE_CHANGE_DATA );
2702 : : }
2703 : 0 : }
2704 : :
2705 : : // -----------------------------------------------------------------------
2706 : :
2707 : 963 : rtl::OUString ImplListBox::GetMRUEntries( sal_Unicode cSep ) const
2708 : : {
2709 [ + - ]: 963 : String aEntries;
2710 [ - + ]: 963 : for ( sal_uInt16 n = 0; n < GetEntryList()->GetMRUCount(); n++ )
2711 : : {
2712 [ # # ][ # # ]: 0 : aEntries += GetEntryList()->GetEntryText( n );
[ # # ]
2713 [ # # ]: 0 : if( n < ( GetEntryList()->GetMRUCount() - 1 ) )
2714 [ # # ]: 0 : aEntries += cSep;
2715 : : }
2716 [ + - ][ + - ]: 963 : return aEntries;
2717 : : }
2718 : :
2719 : : // =======================================================================
2720 : :
2721 : 682 : ImplWin::ImplWin( Window* pParent, WinBits nWinStyle ) :
2722 [ + - ][ + - ]: 682 : Control ( pParent, nWinStyle )
[ + - ][ + - ]
[ + - ]
2723 : : {
2724 [ + - ][ - + ]: 682 : if ( IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL)
[ # # ][ - + ]
2725 [ # # ]: 0 : && ! IsNativeControlSupported(CTRL_LISTBOX, PART_BUTTON_DOWN) )
2726 [ # # ]: 0 : SetBackground();
2727 : : else
2728 [ + - ][ + - ]: 682 : SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) );
[ + - ]
2729 : :
2730 : 682 : mbInUserDraw = sal_False;
2731 : 682 : mbUserDrawEnabled = sal_False;
2732 : 682 : mnItemPos = LISTBOX_ENTRY_NOTFOUND;
2733 : 682 : }
2734 : :
2735 : : // -----------------------------------------------------------------------
2736 : :
2737 : 0 : void ImplWin::MBDown()
2738 : : {
2739 [ # # ]: 0 : if( IsEnabled() )
2740 : 0 : maMBDownHdl.Call( this );
2741 : 0 : }
2742 : :
2743 : : // -----------------------------------------------------------------------
2744 : :
2745 : 0 : void ImplWin::MouseButtonDown( const MouseEvent& )
2746 : : {
2747 [ # # ]: 0 : if( IsEnabled() )
2748 : : {
2749 : 0 : MBDown();
2750 : : }
2751 : 0 : }
2752 : :
2753 : : // -----------------------------------------------------------------------
2754 : :
2755 : 0 : void ImplWin::FillLayoutData() const
2756 : : {
2757 [ # # ]: 0 : mpControlData->mpLayoutData = new vcl::ControlLayoutData();
2758 : 0 : const_cast<ImplWin*>(this)->ImplDraw( true );
2759 : 0 : }
2760 : :
2761 : : // -----------------------------------------------------------------------
2762 : :
2763 : 2 : long ImplWin::PreNotify( NotifyEvent& rNEvt )
2764 : : {
2765 : 2 : long nDone = 0;
2766 : 2 : const MouseEvent* pMouseEvt = NULL;
2767 : :
2768 [ - + ][ # # ]: 2 : if( (rNEvt.GetType() == EVENT_MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != NULL )
[ - + ]
2769 : : {
2770 [ # # ][ # # ]: 0 : if( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() )
[ # # ]
2771 : : {
2772 : : // trigger redraw as mouse over state has changed
2773 [ # # # # ]: 0 : if ( IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL)
[ # # ]
2774 : 0 : && ! IsNativeControlSupported(CTRL_LISTBOX, PART_BUTTON_DOWN) )
2775 : : {
2776 : 0 : GetParent()->GetWindow( WINDOW_BORDER )->Invalidate( INVALIDATE_NOERASE );
2777 : 0 : GetParent()->GetWindow( WINDOW_BORDER )->Update();
2778 : : }
2779 : : }
2780 : : }
2781 : :
2782 [ + - ]: 2 : return nDone ? nDone : Control::PreNotify(rNEvt);
2783 : : }
2784 : :
2785 : : // -----------------------------------------------------------------------
2786 : :
2787 : 2316 : void ImplWin::ImplDraw( bool bLayout )
2788 : : {
2789 : 2316 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2790 : :
2791 : 2316 : sal_Bool bNativeOK = sal_False;
2792 : :
2793 [ + - ]: 2316 : if( ! bLayout )
2794 : : {
2795 : 2316 : ControlState nState = CTRL_STATE_ENABLED;
2796 [ - + # # ]: 2316 : if ( IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL)
[ - + ]
2797 : 0 : && IsNativeControlSupported(CTRL_LISTBOX, HAS_BACKGROUND_TEXTURE) )
2798 : : {
2799 : : // Repaint the (focused) area similarly to
2800 : : // ImplSmallBorderWindowView::DrawWindow() in
2801 : : // vcl/source/window/brdwin.cxx
2802 [ # # ]: 0 : Window *pWin = GetParent();
2803 : :
2804 : 0 : ImplControlValue aControlValue;
2805 [ # # ][ # # ]: 0 : if ( !pWin->IsEnabled() )
2806 : 0 : nState &= ~CTRL_STATE_ENABLED;
2807 [ # # ][ # # ]: 0 : if ( pWin->HasFocus() )
2808 : 0 : nState |= CTRL_STATE_FOCUSED;
2809 : :
2810 : : // The listbox is painted over the entire control including the
2811 : : // border, but ImplWin does not contain the border => correction
2812 : : // needed.
2813 : : sal_Int32 nLeft, nTop, nRight, nBottom;
2814 [ # # ]: 0 : pWin->GetBorder( nLeft, nTop, nRight, nBottom );
2815 : 0 : Point aPoint( -nLeft, -nTop );
2816 [ # # ][ # # ]: 0 : Rectangle aCtrlRegion( aPoint - GetPosPixel(), pWin->GetSizePixel() );
[ # # ]
2817 : :
2818 : 0 : sal_Bool bMouseOver = sal_False;
2819 [ # # ][ # # ]: 0 : if( GetParent() )
2820 : : {
2821 [ # # ][ # # ]: 0 : Window *pChild = GetParent()->GetWindow( WINDOW_FIRSTCHILD );
2822 [ # # ][ # # ]: 0 : while( pChild && (bMouseOver = pChild->IsMouseOver()) == sal_False )
[ # # ][ # # ]
2823 [ # # ]: 0 : pChild = pChild->GetWindow( WINDOW_NEXT );
2824 : : }
2825 : :
2826 [ # # ]: 0 : if( bMouseOver )
2827 : 0 : nState |= CTRL_STATE_ROLLOVER;
2828 : :
2829 : : // if parent has no border, then nobody has drawn the background
2830 : : // since no border window exists. so draw it here.
2831 [ # # ]: 0 : WinBits nParentStyle = pWin->GetStyle();
2832 [ # # ][ # # ]: 0 : if( ! (nParentStyle & WB_BORDER) || (nParentStyle & WB_NOBORDER) )
2833 : : {
2834 [ # # ][ # # ]: 0 : Rectangle aParentRect( Point( 0, 0 ), pWin->GetSizePixel() );
2835 : : pWin->DrawNativeControl( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aParentRect,
2836 [ # # ]: 0 : nState, aControlValue, rtl::OUString() );
2837 : : }
2838 : :
2839 : : bNativeOK = DrawNativeControl( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
2840 [ # # ][ # # ]: 0 : aControlValue, rtl::OUString() );
2841 : : }
2842 : :
2843 [ + + ]: 2316 : if( IsEnabled() )
2844 : : {
2845 [ + + ]: 2179 : if( HasFocus() )
2846 : : {
2847 : 2 : SetTextColor( rStyleSettings.GetHighlightTextColor() );
2848 : 2 : SetFillColor( rStyleSettings.GetHighlightColor() );
2849 : 2 : DrawRect( maFocusRect );
2850 : : }
2851 : : else
2852 : : {
2853 : 2177 : Color aColor;
2854 [ # # ][ - + ]: 2177 : if( bNativeOK && (nState & CTRL_STATE_ROLLOVER) )
2855 : 0 : aColor = rStyleSettings.GetFieldRolloverTextColor();
2856 : : else
2857 : 2177 : aColor = rStyleSettings.GetFieldTextColor();
2858 [ + - ][ - + ]: 2177 : if( IsControlForeground() )
2859 [ # # ]: 0 : aColor = GetControlForeground();
2860 [ + - ]: 2177 : SetTextColor( aColor );
2861 [ + - ]: 2177 : if ( !bNativeOK )
2862 [ + - ]: 2177 : Erase( maFocusRect );
2863 : : }
2864 : : }
2865 : : else // Disabled
2866 : : {
2867 : 137 : SetTextColor( rStyleSettings.GetDisableColor() );
2868 [ + - ]: 137 : if ( !bNativeOK )
2869 : 137 : Erase( maFocusRect );
2870 : : }
2871 : : }
2872 : :
2873 [ + + ]: 2316 : if ( IsUserDrawEnabled() )
2874 : : {
2875 : 572 : mbInUserDraw = sal_True;
2876 [ + - ]: 572 : UserDrawEvent aUDEvt( this, maFocusRect, mnItemPos, 0 );
2877 [ + - ]: 572 : maUserDrawHdl.Call( &aUDEvt );
2878 : 572 : mbInUserDraw = sal_False;
2879 : : }
2880 : : else
2881 : : {
2882 : 1744 : DrawEntry( sal_True, sal_True, sal_False, bLayout );
2883 : : }
2884 : 2316 : }
2885 : :
2886 : : // -----------------------------------------------------------------------
2887 : :
2888 : 2316 : void ImplWin::Paint( const Rectangle& )
2889 : : {
2890 : 2316 : ImplDraw();
2891 : 2316 : }
2892 : :
2893 : : // -----------------------------------------------------------------------
2894 : :
2895 : 2316 : void ImplWin::DrawEntry( sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos, bool bLayout )
2896 : : {
2897 : 2316 : long nBorder = 1;
2898 : 2316 : Size aOutSz = GetOutputSizePixel();
2899 : :
2900 : 2316 : sal_Bool bImage = !!maImage;
2901 [ + + ][ + - ]: 2316 : if( bDrawImage && bImage && !bLayout )
[ + + ]
2902 : : {
2903 : 173 : sal_uInt16 nStyle = 0;
2904 [ + - ]: 173 : Size aImgSz = maImage.GetSizePixel();
2905 : 173 : Point aPtImg( nBorder, ( ( aOutSz.Height() - aImgSz.Height() ) / 2 ) );
2906 : :
2907 : : // check for HC mode
2908 : 173 : Image *pImage = &maImage;
2909 : :
2910 [ + - ][ + - ]: 173 : if ( !IsZoom() )
2911 : : {
2912 [ + - ]: 173 : DrawImage( aPtImg, *pImage, nStyle );
2913 : : }
2914 : : else
2915 : : {
2916 [ # # ]: 0 : aImgSz.Width() = CalcZoom( aImgSz.Width() );
2917 [ # # ]: 0 : aImgSz.Height() = CalcZoom( aImgSz.Height() );
2918 [ # # ]: 173 : DrawImage( aPtImg, aImgSz, *pImage, nStyle );
2919 : : }
2920 : : }
2921 : :
2922 [ + - ][ + + ]: 2316 : if( bDrawText && maString.Len() )
[ + + ]
2923 : : {
2924 : 1785 : sal_uInt16 nTextStyle = TEXT_DRAW_VCENTER;
2925 : :
2926 [ + + ][ + + ]: 1785 : if ( bDrawImage && bImage && !bLayout )
[ + - ]
2927 : 173 : nTextStyle |= TEXT_DRAW_LEFT;
2928 [ + - ][ - + ]: 1612 : else if ( GetStyle() & WB_CENTER )
2929 : 0 : nTextStyle |= TEXT_DRAW_CENTER;
2930 [ + - ][ - + ]: 1612 : else if ( GetStyle() & WB_RIGHT )
2931 : 0 : nTextStyle |= TEXT_DRAW_RIGHT;
2932 : : else
2933 : 1612 : nTextStyle |= TEXT_DRAW_LEFT;
2934 : :
2935 [ + - ]: 1785 : Rectangle aTextRect( Point( nBorder, 0 ), Size( aOutSz.Width()-2*nBorder, aOutSz.Height() ) );
2936 : :
2937 [ + - ][ + + ]: 1785 : if ( !bDrawTextAtImagePos && ( bImage || IsUserDrawEnabled() ) )
[ + + ][ + + ]
2938 : : {
2939 [ + - ]: 519 : long nMaxWidth = Max( maImage.GetSizePixel().Width(), maUserItemSize.Width() );
2940 : 519 : aTextRect.Left() += nMaxWidth + IMG_TXT_DISTANCE;
2941 : : }
2942 : :
2943 [ - + ]: 1785 : MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
2944 [ - + ]: 1785 : String* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
2945 [ + - ]: 1785 : DrawText( aTextRect, maString, nTextStyle, pVector, pDisplayText );
2946 : : }
2947 : :
2948 [ + - ][ + + ]: 2316 : if( HasFocus() && !bLayout )
[ + - ][ + + ]
2949 [ + - ]: 2 : ShowFocus( maFocusRect );
2950 : 2316 : }
2951 : :
2952 : : // -----------------------------------------------------------------------
2953 : :
2954 : 1746 : void ImplWin::Resize()
2955 : : {
2956 : 1746 : Control::Resize();
2957 [ + - ]: 1746 : maFocusRect.SetSize( GetOutputSizePixel() );
2958 : 1746 : Invalidate();
2959 : 1746 : }
2960 : :
2961 : : // -----------------------------------------------------------------------
2962 : :
2963 : 2 : void ImplWin::GetFocus()
2964 : : {
2965 : 2 : ShowFocus( maFocusRect );
2966 [ - + ][ - + : 2 : if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
# # # # ]
2967 : 0 : IsNativeWidgetEnabled() &&
2968 : 0 : IsNativeControlSupported( CTRL_LISTBOX, PART_ENTIRE_CONTROL ) )
2969 : : {
2970 : 0 : Window* pWin = GetParent()->GetWindow( WINDOW_BORDER );
2971 [ # # ]: 0 : if( ! pWin )
2972 : 0 : pWin = GetParent();
2973 : 0 : pWin->Invalidate();
2974 : : }
2975 : : else
2976 : 2 : Invalidate();
2977 : 2 : Control::GetFocus();
2978 : 2 : }
2979 : :
2980 : : // -----------------------------------------------------------------------
2981 : :
2982 : 0 : void ImplWin::LoseFocus()
2983 : : {
2984 : 0 : HideFocus();
2985 [ # # ][ # # : 0 : if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
# # # # ]
2986 : 0 : IsNativeWidgetEnabled() &&
2987 : 0 : IsNativeControlSupported( CTRL_LISTBOX, PART_ENTIRE_CONTROL ) )
2988 : : {
2989 : 0 : Window* pWin = GetParent()->GetWindow( WINDOW_BORDER );
2990 [ # # ]: 0 : if( ! pWin )
2991 : 0 : pWin = GetParent();
2992 : 0 : pWin->Invalidate();
2993 : : }
2994 : : else
2995 : 0 : Invalidate();
2996 : 0 : Control::LoseFocus();
2997 : 0 : }
2998 : :
2999 : : // =======================================================================
3000 : :
3001 : 3806 : ImplBtn::ImplBtn( Window* pParent, WinBits nWinStyle ) :
3002 : : PushButton( pParent, nWinStyle ),
3003 [ + - ]: 3806 : mbDown ( sal_False )
3004 : : {
3005 : 3806 : }
3006 : :
3007 : : // -----------------------------------------------------------------------
3008 : :
3009 : 0 : void ImplBtn::MBDown()
3010 : : {
3011 [ # # ]: 0 : if( IsEnabled() )
3012 : 0 : maMBDownHdl.Call( this );
3013 : 0 : }
3014 : :
3015 : : // -----------------------------------------------------------------------
3016 : :
3017 : 0 : void ImplBtn::MouseButtonDown( const MouseEvent& )
3018 : : {
3019 : : //PushButton::MouseButtonDown( rMEvt );
3020 [ # # ]: 0 : if( IsEnabled() )
3021 : : {
3022 : 0 : MBDown();
3023 : 0 : mbDown = sal_True;
3024 : : }
3025 : 0 : }
3026 : :
3027 : : // =======================================================================
3028 : :
3029 : 3806 : ImplListBoxFloatingWindow::ImplListBoxFloatingWindow( Window* pParent ) :
3030 : 3806 : FloatingWindow( pParent, WB_BORDER | WB_SYSTEMWINDOW | WB_NOSHADOW ) // no drop shadow for list boxes
3031 : : {
3032 : 3806 : mpImplLB = NULL;
3033 : 3806 : mnDDLineCount = 0;
3034 : 3806 : mbAutoWidth = sal_False;
3035 : :
3036 : 3806 : mnPopupModeStartSaveSelection = LISTBOX_ENTRY_NOTFOUND;
3037 : :
3038 [ + - ]: 3806 : EnableSaveBackground();
3039 : :
3040 [ + - ]: 3806 : Window * pBorderWindow = ImplGetBorderWindow();
3041 [ + - ]: 3806 : if( pBorderWindow )
3042 : : {
3043 [ + - ]: 3806 : SetAccessibleRole(accessibility::AccessibleRole::PANEL);
3044 [ + - ]: 3806 : pBorderWindow->SetAccessibleRole(accessibility::AccessibleRole::WINDOW);
3045 : : }
3046 : : else
3047 : : {
3048 [ # # ]: 0 : SetAccessibleRole(accessibility::AccessibleRole::WINDOW);
3049 : : }
3050 : :
3051 : 3806 : }
3052 : :
3053 : : // -----------------------------------------------------------------------
3054 : :
3055 : 0 : long ImplListBoxFloatingWindow::PreNotify( NotifyEvent& rNEvt )
3056 : : {
3057 [ # # ]: 0 : if( rNEvt.GetType() == EVENT_LOSEFOCUS )
3058 : : {
3059 [ # # ]: 0 : if( !GetParent()->HasChildPathFocus( sal_True ) )
3060 : 0 : EndPopupMode();
3061 : : }
3062 : :
3063 : 0 : return FloatingWindow::PreNotify( rNEvt );
3064 : : }
3065 : :
3066 : : // -----------------------------------------------------------------------
3067 : :
3068 : 4909 : void ImplListBoxFloatingWindow::SetPosSizePixel( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags )
3069 : : {
3070 : 4909 : FloatingWindow::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
3071 : :
3072 : : // Fix #60890# ( MBA ): um auch im aufgeklappten Zustand der Listbox die Gr"o\se einfach zu einen
3073 : : // Aufruf von Resize() "andern zu k"onnen, wird die Position hier ggf. angepa\t
3074 [ # # ][ - + ]: 4909 : if ( IsReallyVisible() && ( nFlags & WINDOW_POSSIZE_HEIGHT ) )
[ - + ]
3075 : : {
3076 [ # # ][ # # ]: 0 : Point aPos = GetParent()->GetPosPixel();
3077 [ # # ][ # # ]: 0 : aPos = GetParent()->GetParent()->OutputToScreenPixel( aPos );
[ # # ]
3078 : :
3079 [ # # ]: 0 : if ( nFlags & WINDOW_POSSIZE_X )
3080 : 0 : aPos.X() = nX;
3081 : :
3082 [ # # ]: 0 : if ( nFlags & WINDOW_POSSIZE_Y )
3083 : 0 : aPos.Y() = nY;
3084 : :
3085 : : sal_uInt16 nIndex;
3086 [ # # ][ # # ]: 0 : SetPosPixel( ImplCalcPos( this, Rectangle( aPos, GetParent()->GetSizePixel() ), FLOATWIN_POPUPMODE_DOWN, nIndex ) );
[ # # ][ # # ]
[ # # ]
3087 : : }
3088 : :
3089 : : // if( !IsReallyVisible() )
3090 : : {
3091 : : // Die ImplListBox erhaelt kein Resize, weil nicht sichtbar.
3092 : : // Die Fenster muessen aber ein Resize() erhalten, damit die
3093 : : // Anzahl der sichtbaren Eintraege fuer PgUp/PgDown stimmt.
3094 : : // Die Anzahl kann auch nicht von List/Combobox berechnet werden,
3095 : : // weil hierfuer auch die ggf. vorhandene vertikale Scrollbar
3096 : : // beruecksichtigt werden muss.
3097 [ + - ]: 4909 : mpImplLB->SetSizePixel( GetOutputSizePixel() );
3098 : 4909 : ((Window*)mpImplLB)->Resize();
3099 : 4909 : ((Window*)mpImplLB->GetMainWindow())->Resize();
3100 : : }
3101 : 4909 : }
3102 : :
3103 : : // -----------------------------------------------------------------------
3104 : :
3105 : 4 : void ImplListBoxFloatingWindow::Resize()
3106 : : {
3107 : 4 : mpImplLB->GetMainWindow()->ImplClearLayoutData();
3108 : 4 : FloatingWindow::Resize();
3109 : 4 : }
3110 : :
3111 : : // -----------------------------------------------------------------------
3112 : :
3113 : 4901 : Size ImplListBoxFloatingWindow::CalcFloatSize()
3114 : : {
3115 : 4901 : Size aFloatSz( maPrefSz );
3116 : :
3117 : : sal_Int32 nLeft, nTop, nRight, nBottom;
3118 [ + - ]: 4901 : GetBorder( nLeft, nTop, nRight, nBottom );
3119 : :
3120 [ + - ]: 4901 : sal_uInt16 nLines = mpImplLB->GetEntryList()->GetEntryCount();
3121 [ + + ][ - + ]: 4901 : if ( mnDDLineCount && ( nLines > mnDDLineCount ) )
3122 : 0 : nLines = mnDDLineCount;
3123 : :
3124 [ + - ]: 4901 : Size aSz = mpImplLB->CalcSize( nLines );
3125 : 4901 : long nMaxHeight = aSz.Height() + nTop + nBottom;
3126 : :
3127 [ + + ]: 4901 : if ( mnDDLineCount )
3128 : 1134 : aFloatSz.Height() = nMaxHeight;
3129 : :
3130 [ + - ]: 4901 : if( mbAutoWidth )
3131 : : {
3132 : : // AutoSize erstmal nur fuer die Breite...
3133 : :
3134 : 4901 : aFloatSz.Width() = aSz.Width() + nLeft + nRight;
3135 : 4901 : aFloatSz.Width() += nRight; // etwas mehr Platz sieht besser aus...
3136 : :
3137 [ + + ][ + - ]: 4901 : if ( ( aFloatSz.Height() < nMaxHeight ) || ( mnDDLineCount && ( mnDDLineCount < mpImplLB->GetEntryList()->GetEntryCount() ) ) )
[ - + ][ + + ]
[ + + ]
3138 : : {
3139 : : // dann wird noch der vertikale Scrollbar benoetigt
3140 : 151 : long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
3141 : 151 : aFloatSz.Width() += nSBWidth;
3142 : : }
3143 : :
3144 [ + - ]: 4901 : long nDesktopWidth = GetDesktopRectPixel().getWidth();
3145 [ - + ]: 4901 : if (aFloatSz.Width() > nDesktopWidth)
3146 : : // Don't exceed the desktop width.
3147 : 0 : aFloatSz.Width() = nDesktopWidth;
3148 : : }
3149 : :
3150 [ + + ]: 4901 : if ( aFloatSz.Height() > nMaxHeight )
3151 : 3616 : aFloatSz.Height() = nMaxHeight;
3152 : :
3153 : : // Minimale Hoehe, falls Hoehe nicht auf Float-Hoehe eingestellt wurde.
3154 : : // Der Parent vom FloatWin muss die DropDown-Combo/Listbox sein.
3155 [ + - ][ + - ]: 4901 : Size aParentSz = GetParent()->GetSizePixel();
3156 [ + + ][ + + ]: 4901 : if( !mnDDLineCount && ( aFloatSz.Height() < aParentSz.Height() ) )
[ + + ]
3157 : 3485 : aFloatSz.Height() = aParentSz.Height();
3158 : :
3159 : : // Nicht schmaler als der Parent werden...
3160 [ + + ]: 4901 : if( aFloatSz.Width() < aParentSz.Width() )
3161 : 4879 : aFloatSz.Width() = aParentSz.Width();
3162 : :
3163 : : // Hoehe auf Entries alignen...
3164 : 4901 : long nInnerHeight = aFloatSz.Height() - nTop - nBottom;
3165 : 4901 : long nEntryHeight = mpImplLB->GetEntryHeight();
3166 [ + + ]: 4901 : if ( nInnerHeight % nEntryHeight )
3167 : : {
3168 : 3636 : nInnerHeight /= nEntryHeight;
3169 : 3636 : nInnerHeight++;
3170 : 3636 : nInnerHeight *= nEntryHeight;
3171 : 3636 : aFloatSz.Height() = nInnerHeight + nTop + nBottom;
3172 : : }
3173 : :
3174 [ - + ]: 4901 : if (aFloatSz.Width() < aSz.Width())
3175 : : {
3176 : : // The max width of list box entries exceeds the window width.
3177 : : // Account for the scroll bar height.
3178 : 0 : long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
3179 : 4901 : aFloatSz.Height() += nSBWidth;
3180 : : }
3181 : 4901 : return aFloatSz;
3182 : : }
3183 : :
3184 : : // -----------------------------------------------------------------------
3185 : :
3186 : 8 : void ImplListBoxFloatingWindow::StartFloat( sal_Bool bStartTracking )
3187 : : {
3188 [ + - ]: 8 : if( !IsInPopupMode() )
3189 : : {
3190 [ + - ]: 8 : Size aFloatSz = CalcFloatSize();
3191 : :
3192 [ + - ]: 8 : SetSizePixel( aFloatSz );
3193 [ + - ]: 8 : mpImplLB->SetSizePixel( GetOutputSizePixel() );
3194 : :
3195 [ + - ]: 8 : sal_uInt16 nPos = mpImplLB->GetEntryList()->GetSelectEntryPos( 0 );
3196 : 8 : mnPopupModeStartSaveSelection = nPos;
3197 : :
3198 [ + - ][ + - ]: 8 : Size aSz = GetParent()->GetSizePixel();
3199 [ + - ][ + - ]: 8 : Point aPos = GetParent()->GetPosPixel();
3200 [ + - ][ + - ]: 8 : aPos = GetParent()->GetParent()->OutputToScreenPixel( aPos );
[ + - ]
3201 : : // FIXME: this ugly hack is for Mac/Aqua
3202 : : // should be replaced by a real mechanism to place the float rectangle
3203 [ + - ][ - + ]: 8 : if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
[ # # ][ - + ]
3204 [ # # ][ # # ]: 0 : GetParent()->IsNativeWidgetEnabled() )
3205 : : {
3206 : 0 : sal_Int32 nLeft = 4, nTop = 4, nRight = 4, nBottom = 4;
3207 : 0 : aPos.X() += nLeft;
3208 : 0 : aPos.Y() += nTop;
3209 : 0 : aSz.Width() -= nLeft + nRight;
3210 : 0 : aSz.Height() -= nTop + nBottom;
3211 : : }
3212 [ + - ]: 8 : Rectangle aRect( aPos, aSz );
3213 : :
3214 : : // check if the control's parent is un-mirrored which is the case for form controls in a mirrored UI
3215 : : // where the document is unmirrored
3216 : : // because StartPopupMode() expects a rectangle in mirrored coordinates we have to re-mirror
3217 [ + - ][ + - ]: 8 : if( GetParent()->GetParent()->ImplIsAntiparallel() )
[ + - ][ - + ]
3218 [ # # ][ # # ]: 0 : GetParent()->GetParent()->ImplReMirror( aRect );
[ # # ]
3219 : :
3220 [ + - ]: 8 : StartPopupMode( aRect, FLOATWIN_POPUPMODE_DOWN );
3221 : :
3222 [ + - ]: 8 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
3223 [ + - ]: 8 : mpImplLB->ShowProminentEntry( nPos );
3224 : :
3225 [ + - ]: 8 : if( bStartTracking )
3226 : 8 : mpImplLB->GetMainWindow()->EnableMouseMoveSelect( sal_True );
3227 : :
3228 [ - + ]: 8 : if ( mpImplLB->GetMainWindow()->IsGrabFocusAllowed() )
3229 [ # # ]: 0 : mpImplLB->GetMainWindow()->GrabFocus();
3230 : :
3231 [ + - ]: 8 : mpImplLB->GetMainWindow()->ImplClearLayoutData();
3232 : : }
3233 : 8 : }
3234 : :
3235 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|