LibreOffice Module vcl (master)  1
imp_listbox.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <memory>
21 
22 #include <vcl/svapp.hxx>
23 #include <vcl/settings.hxx>
24 #include <vcl/event.hxx>
25 #include <vcl/scrbar.hxx>
26 #include <vcl/toolkit/lstbox.hxx>
27 #include <vcl/i18nhelp.hxx>
28 #include <vcl/naturalsort.hxx>
29 
30 #include <listbox.hxx>
31 #include <controldata.hxx>
32 #include <svdata.hxx>
33 #include <window.h>
34 
35 #include <com/sun/star/accessibility/AccessibleRole.hpp>
36 
37 #include <rtl/instance.hxx>
38 #include <sal/log.hxx>
39 #include <o3tl/safeint.hxx>
40 #include <osl/diagnose.h>
41 #include <comphelper/string.hxx>
43 
44 #include <limits>
45 
46 #define MULTILINE_ENTRY_DRAW_FLAGS ( DrawTextFlags::WordBreak | DrawTextFlags::MultiLine | DrawTextFlags::VCenter )
47 
48 using namespace ::com::sun::star;
49 
50 constexpr tools::Long gnBorder = 1;
51 
53 {
54  pButton->SetSymbol( SymbolType::SPIN_DOWN );
55 
58  pButton->SetBackground();
59 }
60 
62 {
63  mpWindow = pWindow;
66  mnImages = 0;
68 
69  mnMRUCount = 0;
70  mnMaxMRUCount = 0;
71 }
72 
74 {
75  Clear();
76 }
77 
79 {
80  mnImages = 0;
81  maEntries.clear();
82 }
83 
84 void ImplEntryList::SelectEntry( sal_Int32 nPos, bool bSelect )
85 {
86  if (0 <= nPos && o3tl::make_unsigned(nPos) < maEntries.size())
87  {
88  std::vector<std::unique_ptr<ImplEntryType> >::iterator iter = maEntries.begin()+nPos;
89 
90  if ( ( (*iter)->mbIsSelected != bSelect ) &&
92  {
93  (*iter)->mbIsSelected = bSelect;
95  maSelectionChangedHdl.Call( nPos );
96  }
97  }
98 }
99 
100 namespace
101 {
102  struct theSorter
103  : public rtl::StaticWithInit< comphelper::string::NaturalStringSorter, theSorter >
104  {
106  {
109  Application::GetSettings().GetLanguageTag().getLocale());
110  }
111  };
112 }
113 
114 namespace vcl
115 {
116  sal_Int32 NaturalSortCompare(const OUString &rA, const OUString &rB)
117  {
118  const comphelper::string::NaturalStringSorter &rSorter = theSorter::get();
119  return rSorter.compare(rA, rB);
120  }
121 }
122 
123 sal_Int32 ImplEntryList::InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry, bool bSort )
124 {
125  assert(nPos >= 0);
127 
128  if ( !!pNewEntry->maImage )
129  mnImages++;
130 
131  sal_Int32 insPos = 0;
132  const sal_Int32 nEntriesSize = static_cast<sal_Int32>(maEntries.size());
133 
134  if ( !bSort || maEntries.empty())
135  {
136  if (0 <= nPos && nPos < nEntriesSize)
137  {
138  insPos = nPos;
139  maEntries.insert( maEntries.begin() + nPos, std::unique_ptr<ImplEntryType>(pNewEntry) );
140  }
141  else
142  {
143  insPos = nEntriesSize;
144  maEntries.push_back(std::unique_ptr<ImplEntryType>(pNewEntry));
145  }
146  }
147  else
148  {
149  const comphelper::string::NaturalStringSorter &rSorter = theSorter::get();
150 
151  const OUString& rStr = pNewEntry->maStr;
152 
153  ImplEntryType* pTemp = GetEntry( nEntriesSize-1 );
154 
155  try
156  {
157  sal_Int32 nComp = rSorter.compare(rStr, pTemp->maStr);
158 
159  // fast insert for sorted data
160  if ( nComp >= 0 )
161  {
162  insPos = nEntriesSize;
163  maEntries.push_back(std::unique_ptr<ImplEntryType>(pNewEntry));
164  }
165  else
166  {
167  pTemp = GetEntry( mnMRUCount );
168 
169  nComp = rSorter.compare(rStr, pTemp->maStr);
170  if ( nComp <= 0 )
171  {
172  insPos = 0;
173  maEntries.insert(maEntries.begin(), std::unique_ptr<ImplEntryType>(pNewEntry));
174  }
175  else
176  {
177  sal_uLong nLow = mnMRUCount;
178  sal_uLong nHigh = maEntries.size()-1;
179  sal_Int32 nMid;
180 
181  // binary search
182  do
183  {
184  nMid = static_cast<sal_Int32>((nLow + nHigh) / 2);
185  pTemp = GetEntry( nMid );
186 
187  nComp = rSorter.compare(rStr, pTemp->maStr);
188 
189  if ( nComp < 0 )
190  nHigh = nMid-1;
191  else
192  {
193  if ( nComp > 0 )
194  nLow = nMid + 1;
195  else
196  break;
197  }
198  }
199  while ( nLow <= nHigh );
200 
201  if ( nComp >= 0 )
202  nMid++;
203 
204  insPos = nMid;
205  maEntries.insert(maEntries.begin()+nMid, std::unique_ptr<ImplEntryType>(pNewEntry));
206  }
207  }
208  }
209  catch (uno::RuntimeException& )
210  {
211  // XXX this is arguable, if the exception occurred because pNewEntry is
212  // garbage you wouldn't insert it. If the exception occurred because the
213  // Collator implementation is garbage then give the user a chance to see
214  // his stuff
215  insPos = 0;
216  maEntries.insert(maEntries.begin(), std::unique_ptr<ImplEntryType>(pNewEntry));
217  }
218 
219  }
220 
221  return insPos;
222 }
223 
224 void ImplEntryList::RemoveEntry( sal_Int32 nPos )
225 {
226  if (0 <= nPos && o3tl::make_unsigned(nPos) < maEntries.size())
227  {
228  std::vector<std::unique_ptr<ImplEntryType> >::iterator iter = maEntries.begin()+ nPos;
229 
230  if ( !!(*iter)->maImage )
231  mnImages--;
232 
233  maEntries.erase(iter);
234  }
235 }
236 
237 sal_Int32 ImplEntryList::FindEntry( std::u16string_view rString, bool bSearchMRUArea ) const
238 {
239  const sal_Int32 nEntries = static_cast<sal_Int32>(maEntries.size());
240  for ( sal_Int32 n = bSearchMRUArea ? 0 : GetMRUCount(); n < nEntries; n++ )
241  {
242  OUString aComp( vcl::I18nHelper::filterFormattingChars( maEntries[n]->maStr ) );
243  if ( aComp == rString )
244  return n;
245  }
246  return LISTBOX_ENTRY_NOTFOUND;
247 }
248 
249 sal_Int32 ImplEntryList::FindMatchingEntry( const OUString& rStr, sal_Int32 nStart, bool bLazy ) const
250 {
251  sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND;
252  sal_Int32 nEntryCount = GetEntryCount();
253 
254  const vcl::I18nHelper& rI18nHelper = mpWindow->GetSettings().GetLocaleI18nHelper();
255  for ( sal_Int32 n = nStart; n < nEntryCount; )
256  {
257  ImplEntryType* pImplEntry = GetEntry( n );
258  bool bMatch;
259  if ( bLazy )
260  {
261  bMatch = rI18nHelper.MatchString( rStr, pImplEntry->maStr );
262  }
263  else
264  {
265  bMatch = pImplEntry->maStr.startsWith(rStr);
266  }
267  if ( bMatch )
268  {
269  nPos = n;
270  break;
271  }
272 
273  n++;
274  }
275 
276  return nPos;
277 }
278 
279 tools::Long ImplEntryList::GetAddedHeight( sal_Int32 i_nEndIndex, sal_Int32 i_nBeginIndex ) const
280 {
281  tools::Long nHeight = 0;
282  sal_Int32 nStart = std::min(i_nEndIndex, i_nBeginIndex);
283  sal_Int32 nStop = std::max(i_nEndIndex, i_nBeginIndex);
284  sal_Int32 nEntryCount = GetEntryCount();
285  if( 0 <= nStop && nStop != LISTBOX_ENTRY_NOTFOUND && nEntryCount != 0 )
286  {
287  // sanity check
288  if( nStop > nEntryCount-1 )
289  nStop = nEntryCount-1;
290  if (nStart < 0)
291  nStart = 0;
292  else if( nStart > nEntryCount-1 )
293  nStart = nEntryCount-1;
294 
295  sal_Int32 nIndex = nStart;
296  while( nIndex != LISTBOX_ENTRY_NOTFOUND && nIndex < nStop )
297  {
298  tools::Long nPosHeight = GetEntryPtr( nIndex )->getHeightWithMargin();
299  if (nHeight > ::std::numeric_limits<tools::Long>::max() - nPosHeight)
300  {
301  SAL_WARN( "vcl", "ImplEntryList::GetAddedHeight: truncated");
302  break;
303  }
304  nHeight += nPosHeight;
305  nIndex++;
306  }
307  }
308  else
309  nHeight = 0;
310  return i_nEndIndex > i_nBeginIndex ? nHeight : -nHeight;
311 }
312 
314 {
315  ImplEntryType* pImplEntry = GetEntry( nPos );
316  return pImplEntry ? pImplEntry->getHeightWithMargin() : 0;
317 }
318 
319 OUString ImplEntryList::GetEntryText( sal_Int32 nPos ) const
320 {
321  OUString aEntryText;
322  ImplEntryType* pImplEntry = GetEntry( nPos );
323  if ( pImplEntry )
324  aEntryText = pImplEntry->maStr;
325  return aEntryText;
326 }
327 
328 bool ImplEntryList::HasEntryImage( sal_Int32 nPos ) const
329 {
330  bool bImage = false;
331  ImplEntryType* pImplEntry = GetEntry( nPos );
332  if ( pImplEntry )
333  bImage = !!pImplEntry->maImage;
334  return bImage;
335 }
336 
337 Image ImplEntryList::GetEntryImage( sal_Int32 nPos ) const
338 {
339  Image aImage;
340  ImplEntryType* pImplEntry = GetEntry( nPos );
341  if ( pImplEntry )
342  aImage = pImplEntry->maImage;
343  return aImage;
344 }
345 
346 void ImplEntryList::SetEntryData( sal_Int32 nPos, void* pNewData )
347 {
348  ImplEntryType* pImplEntry = GetEntry( nPos );
349  if ( pImplEntry )
350  pImplEntry->mpUserData = pNewData;
351 }
352 
353 void* ImplEntryList::GetEntryData( sal_Int32 nPos ) const
354 {
355  ImplEntryType* pImplEntry = GetEntry( nPos );
356  return pImplEntry ? pImplEntry->mpUserData : nullptr;
357 }
358 
359 void ImplEntryList::SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags )
360 {
361  ImplEntryType* pImplEntry = GetEntry( nPos );
362  if ( pImplEntry )
363  pImplEntry->mnFlags = nFlags;
364 }
365 
367 {
368  sal_Int32 nSelCount = 0;
369  for ( sal_Int32 n = GetEntryCount(); n; )
370  {
371  ImplEntryType* pImplEntry = GetEntry( --n );
372  if ( pImplEntry->mbIsSelected )
373  nSelCount++;
374  }
375  return nSelCount;
376 }
377 
378 OUString ImplEntryList::GetSelectedEntry( sal_Int32 nIndex ) const
379 {
380  return GetEntryText( GetSelectedEntryPos( nIndex ) );
381 }
382 
383 sal_Int32 ImplEntryList::GetSelectedEntryPos( sal_Int32 nIndex ) const
384 {
385  sal_Int32 nSelEntryPos = LISTBOX_ENTRY_NOTFOUND;
386  sal_Int32 nSel = 0;
387  sal_Int32 nEntryCount = GetEntryCount();
388 
389  for ( sal_Int32 n = 0; n < nEntryCount; n++ )
390  {
391  ImplEntryType* pImplEntry = GetEntry( n );
392  if ( pImplEntry->mbIsSelected )
393  {
394  if ( nSel == nIndex )
395  {
396  nSelEntryPos = n;
397  break;
398  }
399  nSel++;
400  }
401  }
402 
403  return nSelEntryPos;
404 }
405 
406 bool ImplEntryList::IsEntryPosSelected( sal_Int32 nIndex ) const
407 {
408  ImplEntryType* pImplEntry = GetEntry( nIndex );
409  return pImplEntry && pImplEntry->mbIsSelected;
410 }
411 
412 bool ImplEntryList::IsEntrySelectable( sal_Int32 nPos ) const
413 {
414  ImplEntryType* pImplEntry = GetEntry( nPos );
415  return pImplEntry == nullptr || ((pImplEntry->mnFlags & ListBoxEntryFlags::DisableSelection) == ListBoxEntryFlags::NONE);
416 }
417 
418 sal_Int32 ImplEntryList::FindFirstSelectable( sal_Int32 nPos, bool bForward /* = true */ )
419 {
420  if( IsEntrySelectable( nPos ) )
421  return nPos;
422 
423  if( bForward )
424  {
425  for( nPos = nPos + 1; nPos < GetEntryCount(); nPos++ )
426  {
427  if( IsEntrySelectable( nPos ) )
428  return nPos;
429  }
430  }
431  else
432  {
433  while( nPos )
434  {
435  nPos--;
436  if( IsEntrySelectable( nPos ) )
437  return nPos;
438  }
439  }
440 
441  return LISTBOX_ENTRY_NOTFOUND;
442 }
443 
445  Control( pParent, 0 ),
446  maQuickSelectionEngine( *this )
447 {
448  mpEntryList.reset(new ImplEntryList( this ));
449 
450  mnTop = 0;
451  mnLeft = 0;
452  mnSelectModifier = 0;
454  mbTrack = false;
455  mbTravelSelect = false;
456  mbTrackingSelect = false;
457  mbSelectionChanged = false;
458  mbMouseMoveSelect = false;
459  mbMulti = false;
460  mbGrabFocus = false;
461  mbUserDrawEnabled = false;
462  mbInUserDraw = false;
463  mbReadOnly = false;
464  mbHasFocusRect = false;
465  mbRight = ( nWinStyle & WB_RIGHT );
466  mbCenter = ( nWinStyle & WB_CENTER );
467  mbSimpleMode = ( nWinStyle & WB_SIMPLEMODE );
468  mbSort = ( nWinStyle & WB_SORT );
469  mbIsDropdown = ( nWinStyle & WB_DROPDOWN );
470  mbEdgeBlending = false;
471 
474 
475  SetLineColor();
477  SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) );
478 
479  ApplySettings(*this);
480  ImplCalcMetrics();
481 }
482 
484 {
485  disposeOnce();
486 }
487 
489 {
490  mpEntryList.reset();
492 }
493 
495 {
496  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
497 
498  ApplyControlFont(rRenderContext, rStyleSettings.GetFieldFont());
499  ApplyControlForeground(rRenderContext, rStyleSettings.GetFieldTextColor());
500 
501  if (IsControlBackground())
502  rRenderContext.SetBackground(GetControlBackground());
503  else
504  rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
505 }
506 
508 {
509  mnMaxWidth = 0;
510  mnMaxTxtWidth = 0;
511  mnMaxImgWidth = 0;
512  mnMaxImgTxtWidth= 0;
513  mnMaxImgHeight = 0;
514 
515  mnTextHeight = static_cast<sal_uInt16>(GetTextHeight());
518 
520  mnMaxHeight = static_cast<sal_uInt16>(maUserItemSize.Height());
521  if ( maUserItemSize.Width() > mnMaxWidth )
522  mnMaxWidth= static_cast<sal_uInt16>(maUserItemSize.Width());
523 
524  for ( sal_Int32 n = mpEntryList->GetEntryCount(); n; )
525  {
526  ImplEntryType* pEntry = mpEntryList->GetMutableEntryPtr( --n );
527  ImplUpdateEntryMetrics( *pEntry );
528  }
529 
531  {
532  Size aSz( GetOutputSizePixel().Width(), mpEntryList->GetEntryPtr( mnCurrentPos )->getHeightWithMargin() );
533  maFocusRect.SetSize( aSz );
534  }
535 }
536 
538 {
539  mpEntryList->Clear();
540 
542  mnMaxWidth = 0;
543  mnMaxTxtWidth = 0;
544  mnMaxImgTxtWidth= 0;
545  mnMaxImgWidth = 0;
546  mnMaxImgHeight = 0;
547  mnTop = 0;
548  mnLeft = 0;
550 
553 
554  Invalidate();
555 }
556 
558 {
560  maUserItemSize = rSz;
561  ImplCalcMetrics();
562 }
563 
564 namespace {
565 
566 struct ImplEntryMetrics
567 {
568  bool bText;
569  bool bImage;
570  tools::Long nEntryWidth;
571  tools::Long nEntryHeight;
572  tools::Long nTextWidth;
573  tools::Long nImgWidth;
574  tools::Long nImgHeight;
575 };
576 
577 }
578 
580 {
582 }
583 
585 {
586  if (maStrGlyphs.IsValid())
587  // Use pre-calculated result.
588  return &maStrGlyphs;
589 
590  std::unique_ptr<SalLayout> pLayout = pOutputDevice->ImplLayout(
591  maStr, 0, maStr.getLength(), Point(0, 0), 0, nullptr, SalLayoutFlags::GlyphItemsOnly);
592  if (!pLayout)
593  return nullptr;
594 
595  const SalLayoutGlyphs* pGlyphs = pLayout->GetGlyphs();
596  if (!pGlyphs)
597  return nullptr;
598 
599  // Remember the calculation result.
600  maStrGlyphs = *pGlyphs;
601 
602  return &maStrGlyphs;
603 }
604 
606 {
607  ImplEntryMetrics aMetrics;
608  aMetrics.bText = !rEntry.maStr.isEmpty();
609  aMetrics.bImage = !!rEntry.maImage;
610  aMetrics.nEntryWidth = 0;
611  aMetrics.nEntryHeight = 0;
612  aMetrics.nTextWidth = 0;
613  aMetrics.nImgWidth = 0;
614  aMetrics.nImgHeight = 0;
615 
616  if ( aMetrics.bText )
617  {
619  {
620  // multiline case
621  Size aCurSize( PixelToLogic( GetSizePixel() ) );
622  // set the current size to a large number
623  // GetTextRect should shrink it to the actual size
624  aCurSize.setHeight( 0x7fffff );
625  tools::Rectangle aTextRect( Point( 0, 0 ), aCurSize );
626  aTextRect = GetTextRect( aTextRect, rEntry.maStr, DrawTextFlags::WordBreak | DrawTextFlags::MultiLine );
627  aMetrics.nTextWidth = aTextRect.GetWidth();
628  if( aMetrics.nTextWidth > mnMaxTxtWidth )
629  mnMaxTxtWidth = aMetrics.nTextWidth;
630  aMetrics.nEntryWidth = mnMaxTxtWidth;
631  aMetrics.nEntryHeight = aTextRect.GetHeight() + gnBorder;
632  }
633  else
634  {
635  // normal single line case
636  const SalLayoutGlyphs* pGlyphs = rEntry.GetTextGlyphs(this);
637  aMetrics.nTextWidth
638  = static_cast<sal_uInt16>(GetTextWidth(rEntry.maStr, 0, -1, nullptr, pGlyphs));
639  if( aMetrics.nTextWidth > mnMaxTxtWidth )
640  mnMaxTxtWidth = aMetrics.nTextWidth;
641  aMetrics.nEntryWidth = mnMaxTxtWidth;
642  aMetrics.nEntryHeight = mnTextHeight + gnBorder;
643  }
644  }
645  if ( aMetrics.bImage )
646  {
647  Size aImgSz = rEntry.maImage.GetSizePixel();
648  aMetrics.nImgWidth = static_cast<sal_uInt16>(CalcZoom( aImgSz.Width() ));
649  aMetrics.nImgHeight = static_cast<sal_uInt16>(CalcZoom( aImgSz.Height() ));
650 
651  if( aMetrics.nImgWidth > mnMaxImgWidth )
652  mnMaxImgWidth = aMetrics.nImgWidth;
653  if( aMetrics.nImgHeight > mnMaxImgHeight )
654  mnMaxImgHeight = aMetrics.nImgHeight;
655 
656  mnMaxImgTxtWidth = std::max( mnMaxImgTxtWidth, aMetrics.nTextWidth );
657  aMetrics.nEntryHeight = std::max( aMetrics.nImgHeight, aMetrics.nEntryHeight );
658 
659  }
660 
661  bool bIsUserDrawEnabled = IsUserDrawEnabled();
662  if (bIsUserDrawEnabled || aMetrics.bImage)
663  {
664  aMetrics.nEntryWidth = std::max( aMetrics.nImgWidth, maUserItemSize.Width() );
665  if (!bIsUserDrawEnabled && aMetrics.bText)
666  aMetrics.nEntryWidth += aMetrics.nTextWidth + IMG_TXT_DISTANCE;
667  aMetrics.nEntryHeight = std::max( std::max( mnMaxImgHeight, maUserItemSize.Height() ) + 2,
668  aMetrics.nEntryHeight );
669  }
670 
671  if (!aMetrics.bText && !aMetrics.bImage && !bIsUserDrawEnabled)
672  {
673  // entries which have no (aka an empty) text, and no image,
674  // and are not user-drawn, should be shown nonetheless
675  aMetrics.nEntryHeight = mnTextHeight + gnBorder;
676  }
677 
678  if ( aMetrics.nEntryWidth > mnMaxWidth )
679  mnMaxWidth = aMetrics.nEntryWidth;
680  if ( aMetrics.nEntryHeight > mnMaxHeight )
681  mnMaxHeight = aMetrics.nEntryHeight;
682 
683  rEntry.mnHeight = aMetrics.nEntryHeight;
684 }
685 
687 {
688  if ( !IsTravelSelect() && GetEntryList()->GetMaxMRUCount() )
689  {
690  // Insert the selected entry as MRU, if not already first MRU
691  sal_Int32 nSelected = GetEntryList()->GetSelectedEntryPos( 0 );
692  sal_Int32 nMRUCount = GetEntryList()->GetMRUCount();
693  OUString aSelected = GetEntryList()->GetEntryText( nSelected );
694  sal_Int32 nFirstMatchingEntryPos = GetEntryList()->FindEntry( aSelected, true );
695  if ( nFirstMatchingEntryPos || !nMRUCount )
696  {
697  bool bSelectNewEntry = false;
698  if ( nFirstMatchingEntryPos < nMRUCount )
699  {
700  RemoveEntry( nFirstMatchingEntryPos );
701  nMRUCount--;
702  if ( nFirstMatchingEntryPos == nSelected )
703  bSelectNewEntry = true;
704  }
705  else if ( nMRUCount == GetEntryList()->GetMaxMRUCount() )
706  {
707  RemoveEntry( nMRUCount - 1 );
708  nMRUCount--;
709  }
710 
712 
713  ImplEntryType* pNewEntry = new ImplEntryType( aSelected );
714  pNewEntry->mbIsSelected = bSelectNewEntry;
715  GetEntryList()->InsertEntry( 0, pNewEntry, false );
716  ImplUpdateEntryMetrics( *pNewEntry );
717  GetEntryList()->SetMRUCount( ++nMRUCount );
718  SetSeparatorPos( nMRUCount ? nMRUCount-1 : 0 );
719  maMRUChangedHdl.Call( nullptr );
720  }
721  }
722 
723  maSelectHdl.Call( nullptr );
724  mbSelectionChanged = false;
725 }
726 
727 sal_Int32 ImplListBoxWindow::InsertEntry(sal_Int32 nPos, ImplEntryType* pNewEntry, bool bSort)
728 {
729  assert(nPos >= 0);
730  assert(mpEntryList->GetEntryCount() < LISTBOX_MAX_ENTRIES);
731 
733  sal_Int32 nNewPos = mpEntryList->InsertEntry( nPos, pNewEntry, bSort );
734 
735  if( GetStyle() & WB_WORDBREAK )
737 
738  ImplUpdateEntryMetrics( *pNewEntry );
739  return nNewPos;
740 }
741 
742 sal_Int32 ImplListBoxWindow::InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry )
743 {
744  return InsertEntry(nPos, pNewEntry, mbSort);
745 }
746 
747 void ImplListBoxWindow::RemoveEntry( sal_Int32 nPos )
748 {
750  mpEntryList->RemoveEntry( nPos );
751  if( mnCurrentPos >= mpEntryList->GetEntryCount() )
753  ImplCalcMetrics();
754 }
755 
757 {
758  mpEntryList->SetEntryFlags( nPos, nFlags );
759  ImplEntryType* pEntry = mpEntryList->GetMutableEntryPtr( nPos );
760  if( pEntry )
761  ImplUpdateEntryMetrics( *pEntry );
762 }
763 
765 {
766  if ( mbHasFocusRect )
767  HideFocus();
769  mbHasFocusRect = true;
770 }
771 
773 {
774  if ( mbHasFocusRect )
775  {
776  HideFocus();
777  mbHasFocusRect = false;
778  }
779 }
780 
781 sal_Int32 ImplListBoxWindow::GetEntryPosForPoint( const Point& rPoint ) const
782 {
783  tools::Long nY = gnBorder;
784 
785  sal_Int32 nSelect = mnTop;
786  const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nSelect );
787  while (pEntry)
788  {
789  tools::Long nEntryHeight = pEntry->getHeightWithMargin();
790  if (rPoint.Y() <= nEntryHeight + nY)
791  break;
792  nY += nEntryHeight;
793  pEntry = mpEntryList->GetEntryPtr( ++nSelect );
794  }
795  if( pEntry == nullptr )
796  nSelect = LISTBOX_ENTRY_NOTFOUND;
797 
798  return nSelect;
799 }
800 
801 bool ImplListBoxWindow::IsVisible( sal_Int32 i_nEntry ) const
802 {
803  bool bRet = false;
804 
805  if( i_nEntry >= mnTop )
806  {
807  if( mpEntryList->GetAddedHeight( i_nEntry, mnTop ) <
808  PixelToLogic( GetSizePixel() ).Height() )
809  {
810  bRet = true;
811  }
812  }
813 
814  return bRet;
815 }
816 
818 {
820  return mnMaxHeight + nMargin;
821 }
822 
824 {
825  sal_Int32 nPos = mnTop;
826  tools::Long nWindowHeight = GetSizePixel().Height();
827  sal_Int32 nCount = mpEntryList->GetEntryCount();
828  tools::Long nDiff;
829  for( nDiff = 0; nDiff < nWindowHeight && nPos < nCount; nDiff = mpEntryList->GetAddedHeight( nPos, mnTop ) )
830  nPos++;
831 
832  if( nDiff > nWindowHeight && nPos > mnTop )
833  nPos--;
834 
835  if( nPos >= nCount )
836  nPos = nCount-1;
837 
838  return nPos;
839 }
840 
842 {
843  mbMouseMoveSelect = false; // only till the first MouseButtonDown
845 
846  if ( !IsReadOnly() )
847  {
848  if( rMEvt.GetClicks() == 1 )
849  {
850  sal_Int32 nSelect = GetEntryPosForPoint( rMEvt.GetPosPixel() );
851  if( nSelect != LISTBOX_ENTRY_NOTFOUND )
852  {
855  else
857 
858  mnCurrentPos = nSelect;
859  mbTrackingSelect = true;
860  bool bCurPosChange = (mnCurrentPos != nSelect);
861  (void)SelectEntries( nSelect, LET_MBDOWN, rMEvt.IsShift(), rMEvt.IsMod1() ,bCurPosChange);
862  mbTrackingSelect = false;
863  if ( mbGrabFocus )
864  GrabFocus();
865 
867  }
868  }
869  if( rMEvt.GetClicks() == 2 )
870  {
871  maDoubleClickHdl.Call( this );
872  }
873  }
874  else // if ( mbGrabFocus )
875  {
876  GrabFocus();
877  }
878 }
879 
881 {
882  if (rMEvt.IsLeaveWindow() || mbMulti || !IsMouseMoveSelect() || !mpEntryList->GetEntryCount())
883  return;
884 
886  if( !aRect.IsInside( rMEvt.GetPosPixel() ) )
887  return;
888 
889  if ( IsMouseMoveSelect() )
890  {
891  sal_Int32 nSelect = GetEntryPosForPoint( rMEvt.GetPosPixel() );
892  if( nSelect == LISTBOX_ENTRY_NOTFOUND )
893  nSelect = mpEntryList->GetEntryCount() - 1;
894  nSelect = std::min( nSelect, GetLastVisibleEntry() );
895  nSelect = std::min( nSelect, static_cast<sal_Int32>( mpEntryList->GetEntryCount() - 1 ) );
896  // Select only visible Entries with MouseMove, otherwise Tracking...
897  if ( IsVisible( nSelect ) &&
898  mpEntryList->IsEntrySelectable( nSelect ) &&
899  ( ( nSelect != mnCurrentPos ) || !GetEntryList()->GetSelectedEntryCount() || ( nSelect != GetEntryList()->GetSelectedEntryPos( 0 ) ) ) )
900  {
901  mbTrackingSelect = true;
902  if ( SelectEntries( nSelect, LET_TRACKING ) )
903  {
904  // When list box selection change by mouse move, notify
905  // VclEventId::ListboxSelect vcl event.
906  maListItemSelectHdl.Call(nullptr);
907  }
908  mbTrackingSelect = false;
909  }
910  }
911 
912  // if the DD button was pressed and someone moved into the ListBox
913  // with the mouse button pressed...
914  if ( rMEvt.IsLeft() && !rMEvt.IsSynthetic() )
915  {
918  else
920 
922  }
923 }
924 
926 {
927  while ( GetEntryList()->GetSelectedEntryCount() )
928  {
929  sal_Int32 nS = GetEntryList()->GetSelectedEntryPos( 0 );
930  SelectEntry( nS, false );
931  }
932 }
933 
934 void ImplListBoxWindow::SelectEntry( sal_Int32 nPos, bool bSelect )
935 {
936  if( (mpEntryList->IsEntryPosSelected( nPos ) == bSelect) || !mpEntryList->IsEntrySelectable( nPos ) )
937  return;
938 
940  if( bSelect )
941  {
942  if( !mbMulti )
943  {
944  // deselect the selected entry
945  sal_Int32 nDeselect = GetEntryList()->GetSelectedEntryPos( 0 );
946  if( nDeselect != LISTBOX_ENTRY_NOTFOUND )
947  {
948  //SelectEntryPos( nDeselect, false );
949  GetEntryList()->SelectEntry( nDeselect, false );
950  if (IsUpdateMode() && IsReallyVisible())
951  Invalidate();
952  }
953  }
954  mpEntryList->SelectEntry( nPos, true );
955  mnCurrentPos = nPos;
956  if ( ( nPos != LISTBOX_ENTRY_NOTFOUND ) && IsUpdateMode() )
957  {
958  Invalidate();
959  if ( !IsVisible( nPos ) )
960  {
962  sal_Int32 nVisibleEntries = GetLastVisibleEntry()-mnTop;
963  if ( !nVisibleEntries || !IsReallyVisible() || ( nPos < GetTopEntry() ) )
964  {
965  Resize();
966  ShowProminentEntry( nPos );
967  }
968  else
969  {
970  ShowProminentEntry( nPos );
971  }
972  }
973  }
974  }
975  else
976  {
977  mpEntryList->SelectEntry( nPos, false );
978  Invalidate();
979  }
980  mbSelectionChanged = true;
981 }
982 
983 bool ImplListBoxWindow::SelectEntries( sal_Int32 nSelect, LB_EVENT_TYPE eLET, bool bShift, bool bCtrl, bool bSelectPosChange /*=FALSE*/ )
984 {
985  bool bSelectionChanged = false;
986 
987  if( IsEnabled() && mpEntryList->IsEntrySelectable( nSelect ) )
988  {
989  bool bFocusChanged = false;
990 
991  // here (Single-ListBox) only one entry can be deselected
992  if( !mbMulti )
993  {
994  sal_Int32 nDeselect = mpEntryList->GetSelectedEntryPos( 0 );
995  if( nSelect != nDeselect )
996  {
997  SelectEntry( nSelect, true );
998  mpEntryList->SetLastSelected( nSelect );
999  bFocusChanged = true;
1000  bSelectionChanged = true;
1001  }
1002  }
1003  // MultiListBox without Modifier
1004  else if( mbSimpleMode && !bCtrl && !bShift )
1005  {
1006  sal_Int32 nEntryCount = mpEntryList->GetEntryCount();
1007  for ( sal_Int32 nPos = 0; nPos < nEntryCount; nPos++ )
1008  {
1009  bool bSelect = nPos == nSelect;
1010  if ( mpEntryList->IsEntryPosSelected( nPos ) != bSelect )
1011  {
1012  SelectEntry( nPos, bSelect );
1013  bFocusChanged = true;
1014  bSelectionChanged = true;
1015  }
1016  }
1017  mpEntryList->SetLastSelected( nSelect );
1018  mpEntryList->SetSelectionAnchor( nSelect );
1019  }
1020  // MultiListBox only with CTRL/SHIFT or not in SimpleMode
1021  else if( ( !mbSimpleMode /* && !bShift */ ) || ( mbSimpleMode && ( bCtrl || bShift ) ) )
1022  {
1023  // Space for selection change
1024  if( !bShift && ( ( eLET == LET_KEYSPACE ) || ( eLET == LET_MBDOWN ) ) )
1025  {
1026  bool bSelect = !mpEntryList->IsEntryPosSelected( nSelect );
1027  SelectEntry( nSelect, bSelect );
1028  mpEntryList->SetLastSelected( nSelect );
1029  mpEntryList->SetSelectionAnchor( nSelect );
1030  if ( !mpEntryList->IsEntryPosSelected( nSelect ) )
1031  mpEntryList->SetSelectionAnchor( LISTBOX_ENTRY_NOTFOUND );
1032  bFocusChanged = true;
1033  bSelectionChanged = true;
1034  }
1035  else if( ( ( eLET == LET_TRACKING ) && ( nSelect != mnCurrentPos ) ) ||
1036  ( bShift && ( ( eLET == LET_KEYMOVE ) || ( eLET == LET_MBDOWN ) ) ) )
1037  {
1038  mnCurrentPos = nSelect;
1039  bFocusChanged = true;
1040 
1041  sal_Int32 nAnchor = mpEntryList->GetSelectionAnchor();
1042  if( ( nAnchor == LISTBOX_ENTRY_NOTFOUND ) && mpEntryList->GetSelectedEntryCount() )
1043  {
1044  nAnchor = mpEntryList->GetSelectedEntryPos( mpEntryList->GetSelectedEntryCount() - 1 );
1045  }
1046  if( nAnchor != LISTBOX_ENTRY_NOTFOUND )
1047  {
1048  // All entries from Anchor to nSelect have to be selected
1049  sal_Int32 nStart = std::min( nSelect, nAnchor );
1050  sal_Int32 nEnd = std::max( nSelect, nAnchor );
1051  for ( sal_Int32 n = nStart; n <= nEnd; n++ )
1052  {
1053  if ( !mpEntryList->IsEntryPosSelected( n ) )
1054  {
1055  SelectEntry( n, true );
1056  bSelectionChanged = true;
1057  }
1058  }
1059 
1060  // if appropriate some more has to be deselected...
1061  sal_Int32 nLast = mpEntryList->GetLastSelected();
1062  if ( nLast != LISTBOX_ENTRY_NOTFOUND )
1063  {
1064  if ( ( nLast > nSelect ) && ( nLast > nAnchor ) )
1065  {
1066  for ( sal_Int32 n = nSelect+1; n <= nLast; n++ )
1067  {
1068  if ( mpEntryList->IsEntryPosSelected( n ) )
1069  {
1070  SelectEntry( n, false );
1071  bSelectionChanged = true;
1072  }
1073  }
1074  }
1075  else if ( ( nLast < nSelect ) && ( nLast < nAnchor ) )
1076  {
1077  for ( sal_Int32 n = nLast; n < nSelect; n++ )
1078  {
1079  if ( mpEntryList->IsEntryPosSelected( n ) )
1080  {
1081  SelectEntry( n, false );
1082  bSelectionChanged = true;
1083  }
1084  }
1085  }
1086  }
1087  mpEntryList->SetLastSelected( nSelect );
1088  }
1089  }
1090  else if( eLET != LET_TRACKING )
1091  {
1093  Invalidate();
1094  bFocusChanged = true;
1095  }
1096  }
1097  else if( bShift )
1098  {
1099  bFocusChanged = true;
1100  }
1101 
1102  if( bSelectionChanged )
1103  mbSelectionChanged = true;
1104 
1105  if( bFocusChanged )
1106  {
1107  tools::Long nHeightDiff = mpEntryList->GetAddedHeight( nSelect, mnTop );
1108  maFocusRect.SetPos( Point( 0, nHeightDiff ) );
1109  Size aSz( maFocusRect.GetWidth(),
1110  mpEntryList->GetEntryHeight( nSelect ) );
1111  maFocusRect.SetSize( aSz );
1112  if( HasFocus() )
1114  if (bSelectPosChange)
1115  {
1116  maFocusHdl.Call(nSelect);
1117  }
1118  }
1120  }
1121  return bSelectionChanged;
1122 }
1123 
1125 {
1127  bool bInside = aRect.IsInside( rTEvt.GetMouseEvent().GetPosPixel() );
1128 
1129  if( rTEvt.IsTrackingCanceled() || rTEvt.IsTrackingEnded() ) // MouseButtonUp
1130  {
1131  if ( bInside && !rTEvt.IsTrackingCanceled() )
1132  {
1134  ImplCallSelect();
1135  }
1136  else
1137  {
1138  maCancelHdl.Call( nullptr );
1139  if ( !mbMulti )
1140  {
1141  mbTrackingSelect = true;
1143  mbTrackingSelect = false;
1145  {
1146  tools::Long nHeightDiff = mpEntryList->GetAddedHeight( mnCurrentPos, mnTop );
1147  maFocusRect.SetPos( Point( 0, nHeightDiff ) );
1148  Size aSz( maFocusRect.GetWidth(),
1149  mpEntryList->GetEntryHeight( mnCurrentPos ) );
1150  maFocusRect.SetSize( aSz );
1152  }
1153  }
1154  }
1155 
1156  mbTrack = false;
1157  }
1158  else
1159  {
1160  bool bTrackOrQuickClick = mbTrack;
1161  if( !mbTrack )
1162  {
1163  if ( bInside )
1164  {
1165  mbTrack = true;
1166  }
1167 
1168  // this case only happens, if the mouse button is pressed very briefly
1169  if( rTEvt.IsTrackingEnded() && mbTrack )
1170  {
1171  bTrackOrQuickClick = true;
1172  mbTrack = false;
1173  }
1174  }
1175 
1176  if( bTrackOrQuickClick )
1177  {
1178  MouseEvent aMEvt = rTEvt.GetMouseEvent();
1179  Point aPt( aMEvt.GetPosPixel() );
1180  bool bShift = aMEvt.IsShift();
1181  bool bCtrl = aMEvt.IsMod1();
1182 
1183  sal_Int32 nSelect = LISTBOX_ENTRY_NOTFOUND;
1184  if( aPt.Y() < 0 )
1185  {
1187  {
1188  nSelect = mnCurrentPos ? ( mnCurrentPos - 1 ) : 0;
1189  if( nSelect < mnTop )
1190  SetTopEntry( mnTop-1 );
1191  }
1192  }
1193  else if( aPt.Y() > GetOutputSizePixel().Height() )
1194  {
1196  {
1197  nSelect = std::min( static_cast<sal_Int32>(mnCurrentPos+1), static_cast<sal_Int32>(mpEntryList->GetEntryCount()-1) );
1198  if( nSelect >= GetLastVisibleEntry() )
1199  SetTopEntry( mnTop+1 );
1200  }
1201  }
1202  else
1203  {
1204  nSelect = static_cast<sal_Int32>( ( aPt.Y() + gnBorder ) / mnMaxHeight ) + mnTop;
1205  nSelect = std::min( nSelect, GetLastVisibleEntry() );
1206  nSelect = std::min( nSelect, static_cast<sal_Int32>( mpEntryList->GetEntryCount() - 1 ) );
1207  }
1208 
1209  if ( bInside )
1210  {
1211  if ( ( nSelect != mnCurrentPos ) || !GetEntryList()->GetSelectedEntryCount() )
1212  {
1213  mbTrackingSelect = true;
1214  SelectEntries(nSelect, LET_TRACKING, bShift, bCtrl);
1215  mbTrackingSelect = false;
1216  }
1217  }
1218  else
1219  {
1220  if ( !mbMulti && GetEntryList()->GetSelectedEntryCount() )
1221  {
1222  mbTrackingSelect = true;
1223  SelectEntry( GetEntryList()->GetSelectedEntryPos( 0 ), false );
1224  mbTrackingSelect = false;
1225  }
1226  }
1227  mnCurrentPos = nSelect;
1229  {
1231  }
1232  else
1233  {
1234  tools::Long nHeightDiff = mpEntryList->GetAddedHeight( mnCurrentPos, mnTop );
1235  maFocusRect.SetPos( Point( 0, nHeightDiff ) );
1236  Size aSz( maFocusRect.GetWidth(), mpEntryList->GetEntryHeight( mnCurrentPos ) );
1237  maFocusRect.SetSize( aSz );
1239  }
1240  }
1241  }
1242 }
1243 
1245 {
1246  if( !ProcessKeyInput( rKEvt ) )
1247  Control::KeyInput( rKEvt );
1248 }
1249 
1251 {
1252  // entry to be selected
1253  sal_Int32 nSelect = LISTBOX_ENTRY_NOTFOUND;
1254  LB_EVENT_TYPE eLET = LET_KEYMOVE;
1255 
1256  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
1257 
1258  bool bShift = aKeyCode.IsShift();
1259  bool bCtrl = aKeyCode.IsMod1() || aKeyCode.IsMod3();
1260  bool bMod2 = aKeyCode.IsMod2();
1261  bool bDone = false;
1262  bool bHandleKey = false;
1263 
1264  switch( aKeyCode.GetCode() )
1265  {
1266  case KEY_UP:
1267  {
1268  if ( IsReadOnly() )
1269  {
1270  if ( GetTopEntry() )
1271  SetTopEntry( GetTopEntry()-1 );
1272  }
1273  else if ( !bMod2 )
1274  {
1276  {
1277  nSelect = mpEntryList->FindFirstSelectable( 0 );
1278  }
1279  else if ( mnCurrentPos )
1280  {
1281  // search first selectable above the current position
1282  nSelect = mpEntryList->FindFirstSelectable( mnCurrentPos - 1, false );
1283  }
1284 
1285  if( ( nSelect != LISTBOX_ENTRY_NOTFOUND ) && ( nSelect < mnTop ) )
1286  SetTopEntry( mnTop-1 );
1287 
1288  bDone = true;
1289  }
1291  }
1292  break;
1293 
1294  case KEY_DOWN:
1295  {
1296  if ( IsReadOnly() )
1297  {
1298  SetTopEntry( GetTopEntry()+1 );
1299  }
1300  else if ( !bMod2 )
1301  {
1303  {
1304  nSelect = mpEntryList->FindFirstSelectable( 0 );
1305  }
1306  else if ( (mnCurrentPos+1) < mpEntryList->GetEntryCount() )
1307  {
1308  // search first selectable below the current position
1309  nSelect = mpEntryList->FindFirstSelectable( mnCurrentPos + 1 );
1310  }
1311 
1312  if( ( nSelect != LISTBOX_ENTRY_NOTFOUND ) && ( nSelect >= GetLastVisibleEntry() ) )
1313  SetTopEntry( mnTop+1 );
1314 
1315  bDone = true;
1316  }
1318  }
1319  break;
1320 
1321  case KEY_PAGEUP:
1322  {
1323  if ( IsReadOnly() )
1324  {
1325  sal_Int32 nCurVis = GetLastVisibleEntry() - mnTop +1;
1326  SetTopEntry( ( mnTop > nCurVis ) ?
1327  (mnTop-nCurVis) : 0 );
1328  }
1329  else if ( !bCtrl && !bMod2 )
1330  {
1332  {
1333  nSelect = mpEntryList->FindFirstSelectable( 0 );
1334  }
1335  else if ( mnCurrentPos )
1336  {
1337  if( mnCurrentPos == mnTop )
1338  {
1339  sal_Int32 nCurVis = GetLastVisibleEntry() - mnTop +1;
1340  SetTopEntry( ( mnTop > nCurVis ) ? ( mnTop-nCurVis+1 ) : 0 );
1341  }
1342 
1343  // find first selectable starting from mnTop looking forward
1344  nSelect = mpEntryList->FindFirstSelectable( mnTop );
1345  }
1346  bDone = true;
1347  }
1349  }
1350  break;
1351 
1352  case KEY_PAGEDOWN:
1353  {
1354  if ( IsReadOnly() )
1355  {
1357  }
1358  else if ( !bCtrl && !bMod2 )
1359  {
1361  {
1362  nSelect = mpEntryList->FindFirstSelectable( 0 );
1363  }
1364  else if ( (mnCurrentPos+1) < mpEntryList->GetEntryCount() )
1365  {
1366  sal_Int32 nCount = mpEntryList->GetEntryCount();
1367  sal_Int32 nCurVis = GetLastVisibleEntry() - mnTop;
1368  sal_Int32 nTmp = std::min( nCurVis, nCount );
1369  nTmp += mnTop - 1;
1370  if( mnCurrentPos == nTmp && mnCurrentPos != nCount - 1 )
1371  {
1372  tools::Long nTmp2 = std::min( static_cast<tools::Long>(nCount-nCurVis), static_cast<tools::Long>(static_cast<tools::Long>(mnTop)+static_cast<tools::Long>(nCurVis)-1) );
1373  nTmp2 = std::max( tools::Long(0) , nTmp2 );
1374  nTmp = static_cast<sal_Int32>(nTmp2+(nCurVis-1) );
1375  SetTopEntry( static_cast<sal_Int32>(nTmp2) );
1376  }
1377  // find first selectable starting from nTmp looking backwards
1378  nSelect = mpEntryList->FindFirstSelectable( nTmp, false );
1379  }
1380  bDone = true;
1381  }
1383  }
1384  break;
1385 
1386  case KEY_HOME:
1387  {
1388  if ( IsReadOnly() )
1389  {
1390  SetTopEntry( 0 );
1391  }
1392  else if ( !bCtrl && !bMod2 && mnCurrentPos )
1393  {
1394  nSelect = mpEntryList->FindFirstSelectable( mpEntryList->GetEntryCount() ? 0 : LISTBOX_ENTRY_NOTFOUND );
1395  if( mnTop != 0 )
1396  SetTopEntry( 0 );
1397 
1398  bDone = true;
1399  }
1401  }
1402  break;
1403 
1404  case KEY_END:
1405  {
1406  if ( IsReadOnly() )
1407  {
1408  SetTopEntry( 0xFFFF );
1409  }
1410  else if ( !bCtrl && !bMod2 )
1411  {
1413  {
1414  nSelect = mpEntryList->FindFirstSelectable( 0 );
1415  }
1416  else if ( (mnCurrentPos+1) < mpEntryList->GetEntryCount() )
1417  {
1418  sal_Int32 nCount = mpEntryList->GetEntryCount();
1419  nSelect = mpEntryList->FindFirstSelectable( nCount - 1, false );
1420  sal_Int32 nCurVis = GetLastVisibleEntry() - mnTop + 1;
1421  if( nCount > nCurVis )
1422  SetTopEntry( nCount - nCurVis );
1423  }
1424  bDone = true;
1425  }
1427  }
1428  break;
1429 
1430  case KEY_LEFT:
1431  {
1432  if ( !bCtrl && !bMod2 )
1433  {
1434  ScrollHorz( -HORZ_SCROLL );
1435  bDone = true;
1436  }
1438  }
1439  break;
1440 
1441  case KEY_RIGHT:
1442  {
1443  if ( !bCtrl && !bMod2 )
1444  {
1446  bDone = true;
1447  }
1449  }
1450  break;
1451 
1452  case KEY_RETURN:
1453  {
1454  if ( !bMod2 && !IsReadOnly() )
1455  {
1457  ImplCallSelect();
1458  bDone = false; // do not catch RETURN
1459  }
1461  }
1462  break;
1463 
1464  case KEY_SPACE:
1465  {
1466  if ( !bMod2 && !IsReadOnly() )
1467  {
1468  if( mbMulti && ( !mbSimpleMode || ( mbSimpleMode && bCtrl && !bShift ) ) )
1469  {
1470  nSelect = mnCurrentPos;
1471  eLET = LET_KEYSPACE;
1472  }
1473  bDone = true;
1474  }
1475  bHandleKey = true;
1476  }
1477  break;
1478 
1479  case KEY_A:
1480  {
1481  if( bCtrl && mbMulti )
1482  {
1483  // paint only once
1484  bool bUpdates = IsUpdateMode();
1485  SetUpdateMode( false );
1486 
1487  sal_Int32 nEntryCount = mpEntryList->GetEntryCount();
1488  for( sal_Int32 i = 0; i < nEntryCount; i++ )
1489  SelectEntry( i, true );
1490 
1491  // restore update mode
1492  SetUpdateMode( bUpdates );
1493  Invalidate();
1494 
1496 
1497  bDone = true;
1498  }
1499  else
1500  {
1501  bHandleKey = true;
1502  }
1503  }
1504  break;
1505 
1506  default:
1507  bHandleKey = true;
1508  break;
1509  }
1510  if (bHandleKey && !IsReadOnly())
1511  {
1512  bDone = maQuickSelectionEngine.HandleKeyEvent( rKEvt );
1513  }
1514 
1515  if ( ( nSelect != LISTBOX_ENTRY_NOTFOUND )
1516  && ( ( !mpEntryList->IsEntryPosSelected( nSelect ) )
1517  || ( eLET == LET_KEYSPACE )
1518  )
1519  )
1520  {
1521  SAL_WARN_IF( mpEntryList->IsEntryPosSelected( nSelect ) && !mbMulti, "vcl", "ImplListBox: Selecting same Entry" );
1522  sal_Int32 nCount = mpEntryList->GetEntryCount();
1523  if (nSelect >= nCount)
1524  nSelect = nCount ? nCount-1 : LISTBOX_ENTRY_NOTFOUND;
1525  bool bCurPosChange = (mnCurrentPos != nSelect);
1526  mnCurrentPos = nSelect;
1527  if(SelectEntries( nSelect, eLET, bShift, bCtrl, bCurPosChange))
1528  {
1529  // tdf#129043 Correctly deliver events when changing values with arrow keys in combobox
1530  if (mbIsDropdown && IsReallyVisible())
1531  mbTravelSelect = true;
1533  ImplCallSelect();
1534  mbTravelSelect = false;
1535  }
1536  }
1537 
1538  return bDone;
1539 }
1540 
1541 namespace
1542 {
1543  vcl::StringEntryIdentifier lcl_getEntry( const ImplEntryList& _rList, sal_Int32 _nPos, OUString& _out_entryText )
1544  {
1545  OSL_PRECOND( ( _nPos != LISTBOX_ENTRY_NOTFOUND ), "lcl_getEntry: invalid position!" );
1546  sal_Int32 nEntryCount( _rList.GetEntryCount() );
1547  if ( _nPos >= nEntryCount )
1548  _nPos = 0;
1549  _out_entryText = _rList.GetEntryText( _nPos );
1550 
1551  // vcl::StringEntryIdentifier does not allow for 0 values, but our position is 0-based
1552  // => normalize
1553  return reinterpret_cast< vcl::StringEntryIdentifier >( _nPos + 1 );
1554  }
1555 
1556  sal_Int32 lcl_getEntryPos( vcl::StringEntryIdentifier _entry )
1557  {
1558  // our pos is 0-based, but StringEntryIdentifier does not allow for a NULL
1559  return static_cast< sal_Int32 >( reinterpret_cast< sal_Int64 >( _entry ) ) - 1;
1560  }
1561 }
1562 
1564 {
1565  return lcl_getEntry( *GetEntryList(), ( mnCurrentPos == LISTBOX_ENTRY_NOTFOUND ) ? 0 : mnCurrentPos, _out_entryText );
1566 }
1567 
1569 {
1570  sal_Int32 nNextPos = lcl_getEntryPos( _currentEntry ) + 1;
1571  return lcl_getEntry( *GetEntryList(), nNextPos, _out_entryText );
1572 }
1573 
1575 {
1576  sal_Int32 nSelect = lcl_getEntryPos( _entry );
1577  if ( mpEntryList->IsEntryPosSelected( nSelect ) )
1578  {
1579  // ignore that. This method is a callback from the QuickSelectionEngine, which means the user attempted
1580  // to select the given entry by typing its starting letters. No need to act.
1581  return;
1582  }
1583 
1584  // normalize
1585  OSL_ENSURE( nSelect < mpEntryList->GetEntryCount(), "ImplListBoxWindow::SelectEntry: how that?" );
1586  sal_Int32 nCount = mpEntryList->GetEntryCount();
1587  if (nSelect >= nCount)
1588  nSelect = nCount ? nCount-1 : LISTBOX_ENTRY_NOTFOUND;
1589 
1590  // make visible
1591  ShowProminentEntry( nSelect );
1592 
1593  // actually select
1594  mnCurrentPos = nSelect;
1595  if ( SelectEntries( nSelect, LET_KEYMOVE ) )
1596  {
1597  mbTravelSelect = true;
1598  mnSelectModifier = 0;
1599  ImplCallSelect();
1600  mbTravelSelect = false;
1601  }
1602 }
1603 
1604 void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32 nPos)
1605 {
1606  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1607 
1608  const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nPos );
1609  if (!pEntry)
1610  return;
1611 
1612  tools::Long nWidth = GetOutputSizePixel().Width();
1613  tools::Long nY = mpEntryList->GetAddedHeight(nPos, mnTop);
1614  tools::Rectangle aRect(Point(0, nY), Size(nWidth, pEntry->getHeightWithMargin()));
1615 
1616  bool bSelected = mpEntryList->IsEntryPosSelected(nPos);
1617  if (bSelected)
1618  {
1619  rRenderContext.SetTextColor(!IsEnabled() ? rStyleSettings.GetDisableColor() : rStyleSettings.GetHighlightTextColor());
1620  rRenderContext.SetFillColor(rStyleSettings.GetHighlightColor());
1621  rRenderContext.SetLineColor();
1622  rRenderContext.DrawRect(aRect);
1623  }
1624  else
1625  {
1626  ApplySettings(rRenderContext);
1627  if (!IsEnabled())
1628  rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
1629  }
1630  rRenderContext.SetTextFillColor();
1631 
1632  if (IsUserDrawEnabled())
1633  {
1634  mbInUserDraw = true;
1635  mnUserDrawEntry = nPos;
1636  aRect.AdjustLeft( -mnLeft );
1637  if (nPos < GetEntryList()->GetMRUCount())
1638  nPos = GetEntryList()->FindEntry(GetEntryList()->GetEntryText(nPos));
1639  nPos = nPos - GetEntryList()->GetMRUCount();
1640 
1641  UserDrawEvent aUDEvt(this, &rRenderContext, aRect, nPos, bSelected);
1642  maUserDrawHdl.Call( &aUDEvt );
1643  mbInUserDraw = false;
1644  }
1645  else
1646  {
1647  DrawEntry(rRenderContext, nPos, true, true);
1648  }
1649 }
1650 
1651 void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32 nPos, bool bDrawImage, bool bDrawText)
1652 {
1653  const ImplEntryType* pEntry = mpEntryList->GetEntryPtr(nPos);
1654  if (!pEntry)
1655  return;
1656 
1657  tools::Long nEntryHeight = pEntry->getHeightWithMargin();
1658 
1659  // when changing this function don't forget to adjust ImplWin::DrawEntry()
1660 
1661  if (mbInUserDraw)
1662  nPos = mnUserDrawEntry; // real entry, not the matching entry from MRU
1663 
1664  tools::Long nY = mpEntryList->GetAddedHeight(nPos, mnTop);
1665 
1666  if (bDrawImage && mpEntryList->HasImages())
1667  {
1668  Image aImage = mpEntryList->GetEntryImage(nPos);
1669  if (!!aImage)
1670  {
1671  Size aImgSz = aImage.GetSizePixel();
1672  Point aPtImg(gnBorder - mnLeft, nY + ((nEntryHeight - aImgSz.Height()) / 2));
1673 
1674  if (!IsZoom())
1675  {
1676  rRenderContext.DrawImage(aPtImg, aImage);
1677  }
1678  else
1679  {
1680  aImgSz.setWidth( CalcZoom(aImgSz.Width()) );
1681  aImgSz.setHeight( CalcZoom(aImgSz.Height()) );
1682  rRenderContext.DrawImage(aPtImg, aImgSz, aImage);
1683  }
1684 
1685  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1686  const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0);
1687 
1688  if (nEdgeBlendingPercent && aImgSz.Width() && aImgSz.Height())
1689  {
1690  const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor());
1691  const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor());
1692  const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100);
1693  const BitmapEx aBlendFrame(createBlendFrame(aImgSz, nAlpha, rTopLeft, rBottomRight));
1694 
1695  if (!aBlendFrame.IsEmpty())
1696  {
1697  rRenderContext.DrawBitmapEx(aPtImg, aBlendFrame);
1698  }
1699  }
1700  }
1701  }
1702 
1703  if (bDrawText)
1704  {
1705  OUString aStr(mpEntryList->GetEntryText(nPos));
1706  if (!aStr.isEmpty())
1707  {
1708  tools::Long nMaxWidth = std::max(mnMaxWidth, GetOutputSizePixel().Width() - 2 * gnBorder);
1709  // a multiline entry should only be as wide as the window
1710  if (pEntry->mnFlags & ListBoxEntryFlags::MultiLine)
1711  nMaxWidth = GetOutputSizePixel().Width() - 2 * gnBorder;
1712 
1713  tools::Rectangle aTextRect(Point(gnBorder - mnLeft, nY),
1714  Size(nMaxWidth, nEntryHeight));
1715 
1716  if (mpEntryList->HasEntryImage(nPos) || IsUserDrawEnabled())
1717  {
1718  tools::Long nImageWidth = std::max(mnMaxImgWidth, maUserItemSize.Width());
1719  aTextRect.AdjustLeft(nImageWidth + IMG_TXT_DISTANCE );
1720  }
1721 
1722  DrawTextFlags nDrawStyle = ImplGetTextStyle();
1723  if (pEntry->mnFlags & ListBoxEntryFlags::MultiLine)
1724  nDrawStyle |= MULTILINE_ENTRY_DRAW_FLAGS;
1726  nDrawStyle |= DrawTextFlags::Disable;
1727 
1728  rRenderContext.DrawText(aTextRect, aStr, nDrawStyle);
1729  }
1730  }
1731 
1732  if ( !maSeparators.empty() && ( isSeparator(nPos) || isSeparator(nPos-1) ) )
1733  {
1734  Color aOldLineColor(rRenderContext.GetLineColor());
1735  rRenderContext.SetLineColor((GetBackground() != COL_LIGHTGRAY) ? COL_LIGHTGRAY : COL_GRAY);
1736  Point aStartPos(0, nY);
1737  if (isSeparator(nPos))
1738  aStartPos.AdjustY(pEntry->getHeightWithMargin() - 1 );
1739  Point aEndPos(aStartPos);
1740  aEndPos.setX( GetOutputSizePixel().Width() );
1741  rRenderContext.DrawLine(aStartPos, aEndPos);
1742  rRenderContext.SetLineColor(aOldLineColor);
1743  }
1744 }
1745 
1747 {
1748  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
1749  const_cast<ImplListBoxWindow*>(this)->Invalidate(tools::Rectangle(Point(0, 0), GetOutputSize()));
1750 }
1751 
1753 {
1754  sal_Int32 nCount = mpEntryList->GetEntryCount();
1755 
1756  bool bShowFocusRect = mbHasFocusRect;
1757  if (mbHasFocusRect)
1759 
1760  tools::Long nY = 0; // + gnBorder;
1761  tools::Long nHeight = GetOutputSizePixel().Height();// - mnMaxHeight + gnBorder;
1762 
1763  for (sal_Int32 i = mnTop; i < nCount && nY < nHeight + mnMaxHeight; i++)
1764  {
1765  const ImplEntryType* pEntry = mpEntryList->GetEntryPtr(i);
1766  tools::Long nEntryHeight = pEntry->getHeightWithMargin();
1767  if (nY + nEntryHeight >= rRect.Top() &&
1768  nY <= rRect.Bottom() + mnMaxHeight)
1769  {
1770  ImplPaint(rRenderContext, i);
1771  }
1772  nY += nEntryHeight;
1773  }
1774 
1775  tools::Long nHeightDiff = mpEntryList->GetAddedHeight(mnCurrentPos, mnTop);
1776  maFocusRect.SetPos(Point(0, nHeightDiff));
1777  Size aSz(maFocusRect.GetWidth(), mpEntryList->GetEntryHeight(mnCurrentPos));
1778  maFocusRect.SetSize(aSz);
1779  if (HasFocus() && bShowFocusRect)
1781 }
1782 
1784 {
1786  {
1787  // This widget is explicitly double-buffered, so avoid partial paints.
1788  tools::Rectangle aRect(Point(0, 0), GetOutputSizePixel());
1789  ImplDoPaint(rRenderContext, aRect);
1790  }
1791  else
1792  ImplDoPaint(rRenderContext, rRect);
1793 }
1794 
1796 {
1797  // FIXME: ListBoxEntryFlags::MultiLine
1798 
1799  const sal_Int32 nCount = mpEntryList->GetEntryCount()-mnTop;
1800  tools::Long nHeight = GetOutputSizePixel().Height();// - mnMaxHeight + gnBorder;
1801  sal_uInt16 nEntries = static_cast< sal_uInt16 >( ( nHeight + mnMaxHeight - 1 ) / mnMaxHeight );
1802  if( nEntries > nCount )
1803  nEntries = static_cast<sal_uInt16>(nCount);
1804 
1805  return nEntries;
1806 }
1807 
1809 {
1810  Control::Resize();
1811 
1812  bool bShowFocusRect = mbHasFocusRect;
1813  if ( bShowFocusRect )
1815 
1817  {
1818  Size aSz( GetOutputSizePixel().Width(), mpEntryList->GetEntryHeight( mnCurrentPos ) );
1819  maFocusRect.SetSize( aSz );
1820  }
1821 
1822  if ( bShowFocusRect )
1824 
1826 }
1827 
1829 {
1830  sal_Int32 nPos = mnCurrentPos;
1831  if ( nPos == LISTBOX_ENTRY_NOTFOUND )
1832  nPos = 0;
1833  tools::Long nHeightDiff = mpEntryList->GetAddedHeight( nPos, mnTop );
1834  maFocusRect.SetPos( Point( 0, nHeightDiff ) );
1835  Size aSz( maFocusRect.GetWidth(), mpEntryList->GetEntryHeight( nPos ) );
1836  maFocusRect.SetSize( aSz );
1839 }
1840 
1842 {
1845 }
1846 
1847 void ImplListBoxWindow::SetTopEntry( sal_Int32 nTop )
1848 {
1849  if( mpEntryList->GetEntryCount() == 0 )
1850  return;
1851 
1852  tools::Long nWHeight = PixelToLogic( GetSizePixel() ).Height();
1853 
1854  sal_Int32 nLastEntry = mpEntryList->GetEntryCount()-1;
1855  if( nTop > nLastEntry )
1856  nTop = nLastEntry;
1857  const ImplEntryType* pLast = mpEntryList->GetEntryPtr( nLastEntry );
1858  while( nTop > 0 && mpEntryList->GetAddedHeight( nLastEntry, nTop-1 ) + pLast->getHeightWithMargin() <= nWHeight )
1859  nTop--;
1860 
1861  if ( nTop == mnTop )
1862  return;
1863 
1865  tools::Long nDiff = mpEntryList->GetAddedHeight( mnTop, nTop );
1866  PaintImmediately();
1868  mnTop = nTop;
1869  Scroll( 0, nDiff );
1870  PaintImmediately();
1871  if( HasFocus() )
1873  maScrollHdl.Call( this );
1874 }
1875 
1876 void ImplListBoxWindow::ShowProminentEntry( sal_Int32 nEntryPos )
1877 {
1878  SetTopEntry( nEntryPos );
1879 }
1880 
1882 {
1883  ScrollHorz( n - mnLeft );
1884 }
1885 
1887 {
1888  tools::Long nDiff = 0;
1889  if ( n > 0 )
1890  {
1891  tools::Long nWidth = GetOutputSizePixel().Width();
1892  if( ( mnMaxWidth - mnLeft + n ) > nWidth )
1893  nDiff = n;
1894  }
1895  else if ( n < 0 )
1896  {
1897  if( mnLeft )
1898  {
1899  tools::Long nAbs = -n;
1900  nDiff = - std::min( mnLeft, nAbs );
1901  }
1902  }
1903 
1904  if ( nDiff )
1905  {
1907  mnLeft = sal::static_int_cast<sal_uInt16>(mnLeft + nDiff);
1908  PaintImmediately();
1910  Scroll( -nDiff, 0 );
1911  PaintImmediately();
1912  if( HasFocus() )
1914  maScrollHdl.Call( this );
1915  }
1916 }
1917 
1919 {
1920  maSeparators.clear();
1921 
1922  if ( n != LISTBOX_ENTRY_NOTFOUND )
1923  {
1924  maSeparators.insert( n );
1925  }
1926 }
1927 
1929 {
1930  if (!maSeparators.empty())
1931  return *(maSeparators.begin());
1932  else
1933  return LISTBOX_ENTRY_NOTFOUND;
1934 }
1935 
1936 bool ImplListBoxWindow::isSeparator( const sal_Int32 &n) const
1937 {
1938  return maSeparators.find(n) != maSeparators.end();
1939 }
1940 
1941 Size ImplListBoxWindow::CalcSize(sal_Int32 nMaxLines) const
1942 {
1943  // FIXME: ListBoxEntryFlags::MultiLine
1944 
1945  Size aSz;
1946  aSz.setHeight(nMaxLines * GetEntryHeightWithMargin());
1947  aSz.setWidth( mnMaxWidth + 2*gnBorder );
1948  return aSz;
1949 }
1950 
1952 {
1953  const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nItem );
1954  Size aSz( GetSizePixel().Width(), pEntry ? pEntry->getHeightWithMargin() : GetEntryHeightWithMargin() );
1955  tools::Long nY = mpEntryList->GetAddedHeight( nItem, GetTopEntry() ) + GetEntryList()->GetMRUCount()*GetEntryHeightWithMargin();
1956  tools::Rectangle aRect( Point( 0, nY ), aSz );
1957  return aRect;
1958 }
1959 
1961 {
1962  Control::StateChanged( nType );
1963 
1964  if ( nType == StateChangedType::Zoom )
1965  {
1966  ApplySettings(*this);
1967  ImplCalcMetrics();
1968  Invalidate();
1969  }
1970  else if ( nType == StateChangedType::UpdateMode )
1971  {
1972  if ( IsUpdateMode() && IsReallyVisible() )
1973  Invalidate();
1974  }
1975  else if ( nType == StateChangedType::ControlFont )
1976  {
1977  ApplySettings(*this);
1978  ImplCalcMetrics();
1979  Invalidate();
1980  }
1981  else if ( nType == StateChangedType::ControlForeground )
1982  {
1983  ApplySettings(*this);
1984  Invalidate();
1985  }
1986  else if ( nType == StateChangedType::ControlBackground )
1987  {
1988  ApplySettings(*this);
1989  Invalidate();
1990  }
1991  else if( nType == StateChangedType::Enable )
1992  {
1993  Invalidate();
1994  }
1995 
1997 }
1998 
2000 {
2001  Control::DataChanged( rDCEvt );
2002 
2003  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
2005  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
2006  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
2007  {
2009  ApplySettings(*this);
2010  ImplCalcMetrics();
2011  Invalidate();
2012  }
2013 }
2014 
2016 {
2018 
2019  if (mpEntryList->HasImages())
2020  nTextStyle |= DrawTextFlags::Left;
2021  else if (mbCenter)
2022  nTextStyle |= DrawTextFlags::Center;
2023  else if (mbRight)
2024  nTextStyle |= DrawTextFlags::Right;
2025  else
2026  nTextStyle |= DrawTextFlags::Left;
2027 
2028  return nTextStyle;
2029 }
2030 
2032  Control( pParent, nWinStyle ),
2033  maLBWindow(VclPtr<ImplListBoxWindow>::Create( this, nWinStyle&(~WB_BORDER) ))
2034 {
2035  // for native widget rendering we must be able to detect this window type
2036  SetType( WindowType::LISTBOXWINDOW );
2037 
2041 
2042  Link<ScrollBar*,void> aLink( LINK( this, ImplListBox, ScrollBarHdl ) );
2043  mpVScrollBar->SetScrollHdl( aLink );
2044  mpHScrollBar->SetScrollHdl( aLink );
2045 
2046  mbVScroll = false;
2047  mbHScroll = false;
2048  mbAutoHScroll = ( nWinStyle & WB_AUTOHSCROLL );
2049  mbEdgeBlending = false;
2050 
2051  maLBWindow->SetScrollHdl( LINK( this, ImplListBox, LBWindowScrolled ) );
2052  maLBWindow->SetMRUChangedHdl( LINK( this, ImplListBox, MRUChanged ) );
2054  maLBWindow->Show();
2055 }
2056 
2058 {
2059  disposeOnce();
2060 }
2061 
2063 {
2068  Control::dispose();
2069 }
2070 
2072 {
2073  maLBWindow->Clear();
2074  if ( GetEntryList()->GetMRUCount() )
2075  {
2078  }
2079  mpVScrollBar->SetThumbPos( 0 );
2080  mpHScrollBar->SetThumbPos( 0 );
2082 }
2083 
2084 sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr )
2085 {
2086  ImplEntryType* pNewEntry = new ImplEntryType( rStr );
2087  sal_Int32 nNewPos = maLBWindow->InsertEntry( nPos, pNewEntry );
2089  return nNewPos;
2090 }
2091 
2092 sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr, const Image& rImage )
2093 {
2094  ImplEntryType* pNewEntry = new ImplEntryType( rStr, rImage );
2095  sal_Int32 nNewPos = maLBWindow->InsertEntry( nPos, pNewEntry );
2097  return nNewPos;
2098 }
2099 
2100 void ImplListBox::RemoveEntry( sal_Int32 nPos )
2101 {
2102  maLBWindow->RemoveEntry( nPos );
2104 }
2105 
2106 void ImplListBox::SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags )
2107 {
2108  maLBWindow->SetEntryFlags( nPos, nFlags );
2109 }
2110 
2111 void ImplListBox::SelectEntry( sal_Int32 nPos, bool bSelect )
2112 {
2113  maLBWindow->SelectEntry( nPos, bSelect );
2114 }
2115 
2117 {
2119 }
2120 
2122 {
2123  if (maLBWindow)
2124  maLBWindow->GrabFocus();
2125  else
2127 }
2128 
2130 {
2131  Control::Resize();
2134 }
2135 
2137 {
2138  CompatStateChanged( StateChangedType::Data );
2139 }
2140 
2142 {
2143  tools::Long nSet = GetTopEntry();
2144  if( nSet > mpVScrollBar->GetRangeMax() )
2145  mpVScrollBar->SetRangeMax( GetEntryList()->GetEntryCount() );
2146  mpVScrollBar->SetThumbPos( GetTopEntry() );
2147 
2148  mpHScrollBar->SetThumbPos( GetLeftIndent() );
2149 
2150  maScrollHdl.Call( this );
2151 }
2152 
2153 IMPL_LINK( ImplListBox, ScrollBarHdl, ScrollBar*, pSB, void )
2154 {
2155  sal_uInt16 nPos = static_cast<sal_uInt16>(pSB->GetThumbPos());
2156  if( pSB == mpVScrollBar )
2157  SetTopEntry( nPos );
2158  else if( pSB == mpHScrollBar )
2159  SetLeftIndent( nPos );
2160  if( GetParent() )
2161  GetParent()->Invalidate( InvalidateFlags::Update );
2162 }
2163 
2165 {
2166  bool bArrange = false;
2167 
2168  Size aOutSz = GetOutputSizePixel();
2169  sal_Int32 nEntries = GetEntryList()->GetEntryCount();
2170  sal_uInt16 nMaxVisEntries = static_cast<sal_uInt16>(aOutSz.Height() / GetEntryHeightWithMargin());
2171 
2172  // vertical ScrollBar
2173  if( nEntries > nMaxVisEntries )
2174  {
2175  if( !mbVScroll )
2176  bArrange = true;
2177  mbVScroll = true;
2178 
2179  // check of the scrolled-out region
2180  if( GetEntryList()->GetSelectedEntryCount() == 1 &&
2183  else
2184  SetTopEntry( GetTopEntry() ); // MaxTop is being checked...
2185  }
2186  else
2187  {
2188  if( mbVScroll )
2189  bArrange = true;
2190  mbVScroll = false;
2191  SetTopEntry( 0 );
2192  }
2193 
2194  // horizontal ScrollBar
2195  if( mbAutoHScroll )
2196  {
2197  tools::Long nWidth = static_cast<sal_uInt16>(aOutSz.Width());
2198  if ( mbVScroll )
2199  nWidth -= mpVScrollBar->GetSizePixel().Width();
2200 
2201  tools::Long nMaxWidth = GetMaxEntryWidth();
2202  if( nWidth < nMaxWidth )
2203  {
2204  if( !mbHScroll )
2205  bArrange = true;
2206  mbHScroll = true;
2207 
2208  if ( !mbVScroll ) // maybe we do need one now
2209  {
2210  nMaxVisEntries = static_cast<sal_uInt16>( ( aOutSz.Height() - mpHScrollBar->GetSizePixel().Height() ) / GetEntryHeightWithMargin() );
2211  if( nEntries > nMaxVisEntries )
2212  {
2213  bArrange = true;
2214  mbVScroll = true;
2215 
2216  // check of the scrolled-out region
2217  if( GetEntryList()->GetSelectedEntryCount() == 1 &&
2220  else
2221  SetTopEntry( GetTopEntry() ); // MaxTop is being checked...
2222  }
2223  }
2224 
2225  // check of the scrolled-out region
2226  sal_uInt16 nMaxLI = static_cast<sal_uInt16>(nMaxWidth - nWidth);
2227  if ( nMaxLI < GetLeftIndent() )
2228  SetLeftIndent( nMaxLI );
2229  }
2230  else
2231  {
2232  if( mbHScroll )
2233  bArrange = true;
2234  mbHScroll = false;
2235  SetLeftIndent( 0 );
2236  }
2237  }
2238 
2239  if( bArrange )
2241 
2243 }
2244 
2246 {
2247  Size aOutSz = maLBWindow->GetOutputSizePixel();
2248 
2249  if ( mbVScroll )
2250  {
2251  sal_Int32 nEntries = GetEntryList()->GetEntryCount();
2252  sal_uInt16 nVisEntries = static_cast<sal_uInt16>(aOutSz.Height() / GetEntryHeightWithMargin());
2253  mpVScrollBar->SetRangeMax( nEntries );
2254  mpVScrollBar->SetVisibleSize( nVisEntries );
2255  mpVScrollBar->SetPageSize( nVisEntries - 1 );
2256  }
2257 
2258  if ( mbHScroll )
2259  {
2261  mpHScrollBar->SetVisibleSize( static_cast<sal_uInt16>(aOutSz.Width()) );
2263  mpHScrollBar->SetPageSize( aOutSz.Width() - HORZ_SCROLL );
2264  }
2265 }
2266 
2268 {
2269  // Here we only position the Controls; if the Scrollbars are to be
2270  // visible is already determined in ImplCheckScrollBars
2271 
2272  Size aOutSz = GetOutputSizePixel();
2274  nSBWidth = CalcZoom( nSBWidth );
2275 
2276  Size aInnerSz( aOutSz );
2277  if ( mbVScroll )
2278  aInnerSz.AdjustWidth( -nSBWidth );
2279  if ( mbHScroll )
2280  aInnerSz.AdjustHeight( -nSBWidth );
2281 
2282  Point aWinPos( 0, 0 );
2283  maLBWindow->SetPosSizePixel( aWinPos, aInnerSz );
2284 
2285  // ScrollBarBox
2286  if( mbVScroll && mbHScroll )
2287  {
2288  Point aBoxPos( aInnerSz.Width(), aInnerSz.Height() );
2289  mpScrollBarBox->SetPosSizePixel( aBoxPos, Size( nSBWidth, nSBWidth ) );
2290  mpScrollBarBox->Show();
2291  }
2292  else
2293  {
2294  mpScrollBarBox->Hide();
2295  }
2296 
2297  // vertical ScrollBar
2298  if( mbVScroll )
2299  {
2300  // Scrollbar on left or right side?
2301  Point aVPos( aOutSz.Width() - nSBWidth, 0 );
2302  mpVScrollBar->SetPosSizePixel( aVPos, Size( nSBWidth, aInnerSz.Height() ) );
2303  mpVScrollBar->Show();
2304  }
2305  else
2306  {
2307  mpVScrollBar->Hide();
2308  // #107254# Don't reset top entry after resize, but check for max top entry
2309  SetTopEntry( GetTopEntry() );
2310  }
2311 
2312  // horizontal ScrollBar
2313  if( mbHScroll )
2314  {
2315  Point aHPos( 0, aOutSz.Height() - nSBWidth );
2316  mpHScrollBar->SetPosSizePixel( aHPos, Size( aInnerSz.Width(), nSBWidth ) );
2317  mpHScrollBar->Show();
2318  }
2319  else
2320  {
2321  mpHScrollBar->Hide();
2322  SetLeftIndent( 0 );
2323  }
2324 }
2325 
2327 {
2328  if ( nType == StateChangedType::InitShow )
2329  {
2331  }
2332  else if ( ( nType == StateChangedType::UpdateMode ) || ( nType == StateChangedType::Data ) )
2333  {
2334  bool bUpdate = IsUpdateMode();
2335  maLBWindow->SetUpdateMode( bUpdate );
2336  if ( bUpdate && IsReallyVisible() )
2338  }
2339  else if( nType == StateChangedType::Enable )
2340  {
2344  maLBWindow->Enable( IsEnabled() );
2345 
2346  Invalidate();
2347  }
2348  else if ( nType == StateChangedType::Zoom )
2349  {
2350  maLBWindow->SetZoom( GetZoom() );
2351  Resize();
2352  }
2353  else if ( nType == StateChangedType::ControlFont )
2354  {
2356  }
2357  else if ( nType == StateChangedType::ControlForeground )
2358  {
2360  }
2361  else if ( nType == StateChangedType::ControlBackground )
2362  {
2364  }
2365  else if( nType == StateChangedType::Mirroring )
2366  {
2371  }
2372 
2373  Control::StateChanged( nType );
2374 }
2375 
2377 {
2378  bool bDone = false;
2379  if ( rNEvt.GetType() == MouseNotifyEvent::COMMAND )
2380  {
2381  const CommandEvent& rCEvt = *rNEvt.GetCommandEvent();
2382  if ( rCEvt.GetCommand() == CommandEventId::Wheel )
2383  {
2384  const CommandWheelData* pData = rCEvt.GetWheelData();
2385  if( !pData->GetModifier() && ( pData->GetMode() == CommandWheelMode::SCROLL ) )
2386  {
2387  bDone = HandleScrollCommand( rCEvt, mpHScrollBar, mpVScrollBar );
2388  }
2389  }
2390  else if (rCEvt.GetCommand() == CommandEventId::Gesture)
2391  {
2393  }
2394  }
2395 
2396  return bDone || Window::EventNotify( rNEvt );
2397 }
2398 
2400 {
2401  return maLBWindow->GetDisplayBackground();
2402 }
2403 
2405 {
2406  bool bDone = false;
2407  if ( rCEvt.GetCommand() == CommandEventId::Wheel )
2408  {
2409  const CommandWheelData* pData = rCEvt.GetWheelData();
2410  if( !pData->GetModifier() && ( pData->GetMode() == CommandWheelMode::SCROLL ) )
2411  {
2412  if (!rControl.HasChildPathFocus())
2413  rControl.GrabFocus();
2414  sal_uInt16 nKey = ( pData->GetDelta() < 0 ) ? KEY_DOWN : KEY_UP;
2415  KeyEvent aKeyEvent( 0, vcl::KeyCode( nKey ) );
2416  bDone = ProcessKeyInput( aKeyEvent );
2417  }
2418  }
2419  return bDone;
2420 }
2421 
2422 void ImplListBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep )
2423 {
2424  bool bChanges = GetEntryList()->GetMRUCount() != 0;
2425 
2426  // Remove old MRU entries
2427  for ( sal_Int32 n = GetEntryList()->GetMRUCount();n; )
2428  maLBWindow->RemoveEntry( --n );
2429 
2430  sal_Int32 nMRUCount = 0;
2431  sal_Int32 nIndex = 0;
2432  do
2433  {
2434  OUString aEntry = rEntries.getToken( 0, cSep, nIndex );
2435  // Accept only existing entries
2436  if ( GetEntryList()->FindEntry( aEntry ) != LISTBOX_ENTRY_NOTFOUND )
2437  {
2438  ImplEntryType* pNewEntry = new ImplEntryType( aEntry );
2439  maLBWindow->InsertEntry(nMRUCount++, pNewEntry, false);
2440  bChanges = true;
2441  }
2442  }
2443  while ( nIndex >= 0 );
2444 
2445  if ( bChanges )
2446  {
2447  maLBWindow->GetEntryList()->SetMRUCount( nMRUCount );
2448  SetSeparatorPos( nMRUCount ? nMRUCount-1 : 0 );
2450  }
2451 }
2452 
2454 {
2455  OUStringBuffer aEntries;
2456  for ( sal_Int32 n = 0; n < GetEntryList()->GetMRUCount(); n++ )
2457  {
2458  aEntries.append(GetEntryList()->GetEntryText( n ));
2459  if( n < ( GetEntryList()->GetMRUCount() - 1 ) )
2460  aEntries.append(cSep);
2461  }
2462  return aEntries.makeStringAndClear();
2463 }
2464 
2466 {
2467  if(mbEdgeBlending != bNew)
2468  {
2469  mbEdgeBlending = bNew;
2471  }
2472 }
2473 
2474 ImplWin::ImplWin( vcl::Window* pParent, WinBits nWinStyle ) :
2475  Control ( pParent, nWinStyle )
2476 {
2479  SetBackground();
2480  else
2481  SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) );
2482 
2484 
2485  mbEdgeBlending = false;
2487 }
2488 
2490 {
2491  if( IsEnabled() )
2492  {
2493  maMBDownHdl.Call(this);
2494  }
2495 }
2496 
2498 {
2499  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
2500  ImplWin* pThis = const_cast<ImplWin*>(this);
2501  pThis->ImplDraw(*pThis, true);
2502 }
2503 
2505 {
2506  if( rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE )
2507  {
2508  const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
2509  if( pMouseEvt && (pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow()) )
2510  {
2511  // trigger redraw as mouse over state has changed
2514  {
2516  }
2517  }
2518  }
2519 
2520  return Control::PreNotify(rNEvt);
2521 }
2522 
2523 void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout)
2524 {
2525  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
2526 
2527  if (!bLayout)
2528  {
2529  bool bNativeOK = false;
2530  bool bHasFocus = HasFocus();
2531  bool bIsEnabled = IsEnabled();
2532 
2536  {
2537  // Repaint the (focused) area similarly to
2538  // ImplSmallBorderWindowView::DrawWindow() in
2539  // vcl/source/window/brdwin.cxx
2540  vcl::Window *pWin = GetParent();
2541 
2542  ImplControlValue aControlValue;
2543  bIsEnabled &= pWin->IsEnabled();
2544  if ( !bIsEnabled )
2545  nState &= ~ControlState::ENABLED;
2546  bHasFocus |= pWin->HasFocus();
2547  if ( bHasFocus )
2548  nState |= ControlState::FOCUSED;
2549 
2550  // The listbox is painted over the entire control including the
2551  // border, but ImplWin does not contain the border => correction
2552  // needed.
2553  sal_Int32 nLeft, nTop, nRight, nBottom;
2554  pWin->GetBorder( nLeft, nTop, nRight, nBottom );
2555  Point aPoint( -nLeft, -nTop );
2556  tools::Rectangle aCtrlRegion( aPoint - GetPosPixel(), pWin->GetSizePixel() );
2557 
2558  bool bMouseOver = false;
2559  vcl::Window *pChild = pWin->GetWindow( GetWindowType::FirstChild );
2560  while( pChild )
2561  {
2562  bMouseOver = pChild->IsMouseOver();
2563  if (bMouseOver)
2564  break;
2565  pChild = pChild->GetWindow( GetWindowType::Next );
2566  }
2567  if( bMouseOver )
2568  nState |= ControlState::ROLLOVER;
2569 
2570  // if parent has no border, then nobody has drawn the background
2571  // since no border window exists. so draw it here.
2572  WinBits nParentStyle = pWin->GetStyle();
2573  if( ! (nParentStyle & WB_BORDER) || (nParentStyle & WB_NOBORDER) )
2574  {
2575  tools::Rectangle aParentRect( Point( 0, 0 ), pWin->GetSizePixel() );
2577  nState, aControlValue, OUString() );
2578  }
2579 
2580  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Listbox, ControlPart::Entire, aCtrlRegion,
2581  nState, aControlValue, OUString());
2582  }
2583 
2584  if (bIsEnabled)
2585  {
2586  if (bHasFocus && !ImplGetSVData()->maNWFData.mbDDListBoxNoTextArea)
2587  {
2588  if ( !ImplGetSVData()->maNWFData.mbNoFocusRects )
2589  {
2590  rRenderContext.SetFillColor( rStyleSettings.GetHighlightColor() );
2591  rRenderContext.SetTextColor( rStyleSettings.GetHighlightTextColor() );
2592  }
2593  else
2594  {
2595  rRenderContext.SetLineColor();
2596  rRenderContext.SetFillColor();
2597  rRenderContext.SetTextColor( rStyleSettings.GetFieldTextColor() );
2598  }
2599  rRenderContext.DrawRect( maFocusRect );
2600  }
2601  else
2602  {
2603  Color aColor;
2604  if (IsControlForeground())
2605  aColor = GetControlForeground();
2606  else if (ImplGetSVData()->maNWFData.mbDDListBoxNoTextArea)
2607  {
2608  if( bNativeOK && (nState & ControlState::ROLLOVER) )
2609  aColor = rStyleSettings.GetButtonRolloverTextColor();
2610  else
2611  aColor = rStyleSettings.GetButtonTextColor();
2612  }
2613  else
2614  {
2615  if( bNativeOK && (nState & ControlState::ROLLOVER) )
2616  aColor = rStyleSettings.GetFieldRolloverTextColor();
2617  else
2618  aColor = rStyleSettings.GetFieldTextColor();
2619  }
2620  rRenderContext.SetTextColor(aColor);
2621  if (!bNativeOK)
2622  rRenderContext.Erase(maFocusRect);
2623  }
2624  }
2625  else // Disabled
2626  {
2627  rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
2628  if (!bNativeOK)
2629  rRenderContext.Erase(maFocusRect);
2630  }
2631  }
2632 
2633  DrawEntry(rRenderContext, bLayout);
2634 }
2635 
2637 {
2638  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
2639 
2640  ApplyControlFont(rRenderContext, rStyleSettings.GetFieldFont());
2641  ApplyControlForeground(rRenderContext, rStyleSettings.GetFieldTextColor());
2642 
2643  if (IsControlBackground())
2644  rRenderContext.SetBackground(GetControlBackground());
2645  else
2646  rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
2647 }
2648 
2649 void ImplWin::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& )
2650 {
2651  ImplDraw(rRenderContext);
2652 }
2653 
2654 void ImplWin::DrawEntry(vcl::RenderContext& rRenderContext, bool bLayout)
2655 {
2656  tools::Long nBorder = 1;
2657  Size aOutSz(GetOutputSizePixel());
2658 
2659  bool bImage = !!maImage;
2660  if (bImage && !bLayout)
2661  {
2663  Size aImgSz = maImage.GetSizePixel();
2664  Point aPtImg( nBorder, ( ( aOutSz.Height() - aImgSz.Height() ) / 2 ) );
2665  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
2666 
2667  // check for HC mode
2668  Image *pImage = &maImage;
2669 
2670  if ( !IsZoom() )
2671  {
2672  rRenderContext.DrawImage( aPtImg, *pImage, nStyle );
2673  }
2674  else
2675  {
2676  aImgSz.setWidth( CalcZoom( aImgSz.Width() ) );
2677  aImgSz.setHeight( CalcZoom( aImgSz.Height() ) );
2678  rRenderContext.DrawImage( aPtImg, aImgSz, *pImage, nStyle );
2679  }
2680 
2681  const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0);
2682 
2683  if(nEdgeBlendingPercent)
2684  {
2685  const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor());
2686  const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor());
2687  const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100);
2688  const BitmapEx aBlendFrame(createBlendFrame(aImgSz, nAlpha, rTopLeft, rBottomRight));
2689 
2690  if(!aBlendFrame.IsEmpty())
2691  {
2692  rRenderContext.DrawBitmapEx(aPtImg, aBlendFrame);
2693  }
2694  }
2695  }
2696 
2697  if( !maString.isEmpty() )
2698  {
2700 
2701  if ( bImage && !bLayout )
2702  nTextStyle |= DrawTextFlags::Left;
2703  else if ( GetStyle() & WB_CENTER )
2704  nTextStyle |= DrawTextFlags::Center;
2705  else if ( GetStyle() & WB_RIGHT )
2706  nTextStyle |= DrawTextFlags::Right;
2707  else
2708  nTextStyle |= DrawTextFlags::Left;
2709 
2710  tools::Rectangle aTextRect( Point( nBorder, 0 ), Size( aOutSz.Width()-2*nBorder, aOutSz.Height() ) );
2711 
2712  if ( bImage )
2713  {
2715  }
2716 
2717  MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : nullptr;
2718  OUString* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : nullptr;
2719  rRenderContext.DrawText( aTextRect, maString, nTextStyle, pVector, pDisplayText );
2720  }
2721 
2722  if( HasFocus() && !bLayout )
2724 }
2725 
2727 {
2728  Control::Resize();
2730  Invalidate();
2731 }
2732 
2734 {
2736  if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
2739  {
2741  if( ! pWin )
2742  pWin = GetParent();
2743  pWin->Invalidate();
2744  }
2745  else
2746  Invalidate();
2748 }
2749 
2751 {
2752  HideFocus();
2753  if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
2756  {
2758  if( ! pWin )
2759  pWin = GetParent();
2760  pWin->Invalidate();
2761  }
2762  else
2763  Invalidate();
2765 }
2766 
2768 {
2770  {
2771  ImplControlValue aControlValue;
2772 
2773  vcl::Window *pWin = GetParent();
2774  tools::Rectangle aParentRect(Point(0, 0), pWin->GetSizePixel());
2776  ControlState::FOCUSED, aControlValue, OUString());
2777  }
2778  Control::ShowFocus(rRect);
2779 }
2780 
2781 ImplBtn::ImplBtn( vcl::Window* pParent, WinBits nWinStyle ) :
2782  PushButton( pParent, nWinStyle )
2783 {
2784 }
2785 
2787 {
2788  if( IsEnabled() )
2789  maMBDownHdl.Call(this);
2790 }
2791 
2793  FloatingWindow( pParent, WB_BORDER | WB_SYSTEMWINDOW | WB_NOSHADOW ) // no drop shadow for list boxes
2794 {
2795  mpImplLB = nullptr;
2796  mnDDLineCount = 0;
2797  mbAutoWidth = false;
2798 
2800 
2801  vcl::Window * pBorderWindow = ImplGetBorderWindow();
2802  if( pBorderWindow )
2803  {
2804  SetAccessibleRole(accessibility::AccessibleRole::PANEL);
2805  pBorderWindow->SetAccessibleRole(accessibility::AccessibleRole::WINDOW);
2806  }
2807  else
2808  {
2809  SetAccessibleRole(accessibility::AccessibleRole::WINDOW);
2810  }
2811 
2812 }
2813 
2815 {
2816  disposeOnce();
2817 }
2818 
2820 {
2821  mpImplLB.clear();
2823 }
2824 
2825 
2827 {
2828  if( rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS )
2829  {
2830  if( !GetParent()->HasChildPathFocus( true ) )
2831  EndPopupMode();
2832  }
2833 
2834  return FloatingWindow::PreNotify( rNEvt );
2835 }
2836 
2838 {
2839  FloatingWindow::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
2840 
2841  // Fix #60890# ( MBA ): to be able to resize the Listbox even in its open state
2842  // after a call to Resize(), we adjust its position if necessary
2843  if ( IsReallyVisible() && ( nFlags & PosSizeFlags::Height ) )
2844  {
2845  Point aPos = GetParent()->GetPosPixel();
2846  aPos = GetParent()->GetParent()->OutputToScreenPixel( aPos );
2847 
2848  if ( nFlags & PosSizeFlags::X )
2849  aPos.setX( nX );
2850 
2851  if ( nFlags & PosSizeFlags::Y )
2852  aPos.setY( nY );
2853 
2854  sal_uInt16 nIndex;
2856  }
2857 
2858 // if( !IsReallyVisible() )
2859  {
2860  // The ImplListBox does not get a Resize() as not visible.
2861  // But the windows must get a Resize(), so that the number of
2862  // visible entries is correct for PgUp/PgDown.
2863  // The number also cannot be calculated by List/Combobox, as for
2864  // this the presence of the vertical Scrollbar has to be known.
2866  static_cast<vcl::Window*>(mpImplLB)->Resize();
2867  static_cast<vcl::Window*>(mpImplLB->GetMainWindow())->Resize();
2868  }
2869 }
2870 
2872 {
2875 }
2876 
2878 {
2879  Size aFloatSz( maPrefSz );
2880 
2881  sal_Int32 nLeft, nTop, nRight, nBottom;
2882  GetBorder( nLeft, nTop, nRight, nBottom );
2883 
2884  sal_Int32 nLines = mpImplLB->GetEntryList()->GetEntryCount();
2885  if ( mnDDLineCount && ( nLines > mnDDLineCount ) )
2886  nLines = mnDDLineCount;
2887 
2888  Size aSz = mpImplLB->CalcSize( nLines );
2889  tools::Long nMaxHeight = aSz.Height() + nTop + nBottom;
2890 
2891  if ( mnDDLineCount )
2892  aFloatSz.setHeight( nMaxHeight );
2893 
2894  if( mbAutoWidth )
2895  {
2896  // AutoSize first only for width...
2897 
2898  aFloatSz.setWidth( aSz.Width() + nLeft + nRight );
2899  aFloatSz.AdjustWidth(nRight ); // adding some space looks better...
2900 
2901  if ( ( aFloatSz.Height() < nMaxHeight ) || ( mnDDLineCount && ( mnDDLineCount < mpImplLB->GetEntryList()->GetEntryCount() ) ) )
2902  {
2903  // then we also need the vertical Scrollbar
2905  aFloatSz.AdjustWidth(nSBWidth );
2906  }
2907 
2908  tools::Long nDesktopWidth = GetDesktopRectPixel().getWidth();
2909  if (aFloatSz.Width() > nDesktopWidth)
2910  // Don't exceed the desktop width.
2911  aFloatSz.setWidth( nDesktopWidth );
2912  }
2913 
2914  if ( aFloatSz.Height() > nMaxHeight )
2915  aFloatSz.setHeight( nMaxHeight );
2916 
2917  // Minimal height, in case height is not set to Float height.
2918  // The parent of FloatWin must be DropDown-Combo/Listbox.
2919  Size aParentSz = GetParent()->GetSizePixel();
2920  if( (!mnDDLineCount || !nLines) && ( aFloatSz.Height() < aParentSz.Height() ) )
2921  aFloatSz.setHeight( aParentSz.Height() );
2922 
2923  // do not get narrower than the parent...
2924  if( aFloatSz.Width() < aParentSz.Width() )
2925  aFloatSz.setWidth( aParentSz.Width() );
2926 
2927  // align height to entries...
2928  tools::Long nInnerHeight = aFloatSz.Height() - nTop - nBottom;
2929  tools::Long nEntryHeight = mpImplLB->GetEntryHeightWithMargin();
2930  if ( nInnerHeight % nEntryHeight )
2931  {
2932  nInnerHeight /= nEntryHeight;
2933  nInnerHeight++;
2934  nInnerHeight *= nEntryHeight;
2935  aFloatSz.setHeight( nInnerHeight + nTop + nBottom );
2936  }
2937 
2938  if (aFloatSz.Width() < aSz.Width())
2939  {
2940  // The max width of list box entries exceeds the window width.
2941  // Account for the scroll bar height.
2943  aFloatSz.AdjustHeight(nSBWidth );
2944  }
2945 
2946  return aFloatSz;
2947 }
2948 
2949 void ImplListBoxFloatingWindow::StartFloat( bool bStartTracking )
2950 {
2951  if( IsInPopupMode() )
2952  return;
2953 
2954  Size aFloatSz = CalcFloatSize();
2955 
2956  SetSizePixel( aFloatSz );
2958 
2959  sal_Int32 nPos = mpImplLB->GetEntryList()->GetSelectedEntryPos( 0 );
2961 
2962  Size aSz = GetParent()->GetSizePixel();
2963  Point aPos = GetParent()->GetPosPixel();
2964  aPos = GetParent()->GetParent()->OutputToScreenPixel( aPos );
2965  // FIXME: this ugly hack is for Mac/Aqua
2966  // should be replaced by a real mechanism to place the float rectangle
2967  if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
2969  {
2970  const sal_Int32 nLeft = 4, nTop = 4, nRight = 4, nBottom = 4;
2971  aPos.AdjustX(nLeft );
2972  aPos.AdjustY(nTop );
2973  aSz.AdjustWidth( -(nLeft + nRight) );
2974  aSz.AdjustHeight( -(nTop + nBottom) );
2975  }
2976  tools::Rectangle aRect( aPos, aSz );
2977 
2978  // check if the control's parent is un-mirrored which is the case for form controls in a mirrored UI
2979  // where the document is unmirrored
2980  // because StartPopupMode() expects a rectangle in mirrored coordinates we have to re-mirror
2981  vcl::Window *pGrandparent = GetParent()->GetParent();
2982  const OutputDevice *pGrandparentOutDev = pGrandparent->GetOutDev();
2983 
2984  if( pGrandparent->ImplIsAntiparallel() )
2985  pGrandparentOutDev->ReMirror( aRect );
2986 
2987  // mouse-button right: close the List-Box-Float-win and don't stop the handling fdo#84795
2989 
2990  if( nPos != LISTBOX_ENTRY_NOTFOUND )
2991  mpImplLB->ShowProminentEntry( nPos );
2992 
2993  if( bStartTracking )
2995 
2998 
3000 
3001 }
3002 
3003 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Point GetPosPixel() const
Definition: window.cxx:2789
tools::Rectangle maFocusRect
Definition: listbox.hxx:542
void SelectEntry(sal_Int32 nPos, bool bSelect)
Size GetSizePixel() const
Definition: Image.cxx:86
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
Definition: text.cxx:791
void SetPos(const Point &rPoint)
bool IsControlBackground() const
Definition: window2.cxx:1087
bool GetEdgeBlending() const
Definition: listbox.hxx:493
virtual void EnableRTL(bool bEnable=true) override
Definition: ctrl.cxx:65
virtual void ShowFocus(const tools::Rectangle &rRect) override
bool IsInPopupMode() const
Definition: floatwin.hxx:149
virtual const Wallpaper & GetDisplayBackground() const
Definition: window.cxx:3069
bool mbAutoHScroll
Definition: listbox.hxx:386
WinBits const WB_NOSHADOW
virtual void LoseFocus() override
Link< sal_Int32, void > maFocusHdl
Definition: listbox.hxx:230
bool mbEdgeBlending
Definition: listbox.hxx:546
void SetMRUEntries(const OUString &rEntries, sal_Unicode cSep)
const Wallpaper & GetBackground() const
Definition: outdev.hxx:643
sal_Int32 NaturalSortCompare(const OUString &rA, const OUString &rB)
void StartPopupMode(const tools::Rectangle &rRect, FloatWinPopupFlags nFlags)
Definition: floatwin.cxx:776
void HideFocus()
Definition: window2.cxx:91
sal_Int32 nIndex
SalLayoutGlyphs maStrGlyphs
Definition: listbox.hxx:53
bool mbTrack
Tracking.
Definition: listbox.hxx:207
virtual void Resize() override
#define HORZ_SCROLL
Definition: listbox.hxx:39
virtual void LoseFocus() override
bool HandleKeyEvent(const KeyEvent &_rKEvt)
WinBits const WB_SYSTEMWINDOW
bool HasEntryImage(sal_Int32 nPos) const
virtual void StateChanged(StateChangedType nType) override
const ImplEntryList * GetEntryList() const
Definition: listbox.hxx:410
void SetNoSelection()
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::vector< tools::Rectangle > MetricVector
Definition: outdev.hxx:138
OUString maString
Definition: listbox.hxx:539
static OUString filterFormattingChars(const OUString &)
Definition: i18nhelp.cxx:93
virtual void FillLayoutData() const override
void setWidth(tools::Long nWidth)
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All) override
sal_Int32 GetSelectedEntryPos(sal_Int32 nIndex) const
void SetUserItemSize(const Size &rSz)
const CommandEvent * GetCommandEvent() const
Definition: event.hxx:326
const Color & GetHighlightTextColor() const
BitmapEx createBlendFrame(const Size &rSize, sal_uInt8 nAlpha, Color aColorTopLeft, Color aColorBottomRight)
Create a blend frame as BitmapEx.
Definition: BitmapEx.cxx:1164
std::unique_ptr< ContentProperties > pData
void SetEntryFlags(sal_Int32 nPos, ListBoxEntryFlags nFlags)
virtual ~ImplListBoxWindow() override
tools::Long getWidth() const
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
Definition: button.hxx:32
void ScrollHorz(tools::Long nDiff)
Image maImage
Definition: listbox.hxx:54
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool mbVScroll
Definition: listbox.hxx:384
ImplEntryList * GetEntryList() const
Definition: listbox.hxx:265
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
SAL_DLLPRIVATE void ImplClearLayoutData() const
Definition: ctrl.cxx:330
tools::Rectangle maFocusRect
Definition: listbox.hxx:178
sal_uIntPtr sal_uLong
long Long
void disposeAndClear()
Definition: vclptr.hxx:200
tools::Long mnHeight
Definition: listbox.hxx:58
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:724
constexpr sal_uInt16 KEY_A
Definition: keycodes.hxx:56
tools::Long mnMaxImgWidth
Maximum width of an image item.
Definition: listbox.hxx:187
bool mbSelectionChanged
Do not call Select() too often ...
Definition: listbox.hxx:212
void ImplResizeControls()
bool mbEdgeBlending
Definition: listbox.hxx:387
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:260
ImplSVNWFData maNWFData
Definition: svdata.hxx:397
sal_Int64 n
SAL_DLLPRIVATE vcl::Window * ImplGetBorderWindow() const
Definition: window2.cxx:875
Link< ImplListBoxWindow *, void > maScrollHdl
Definition: listbox.hxx:224
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
void EnableMouseMoveSelect(bool bMouseMoveSelect)
Definition: listbox.hxx:334
sal_Int32 GetTopEntry() const
Definition: listbox.hxx:449
virtual Size GetSizePixel() const
Definition: window.cxx:2400
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1262
WinBits const WB_RIGHT
constexpr tools::Long gnBorder
Definition: imp_listbox.cxx:50
#define IMG_TXT_DISTANCE
Definition: listbox.hxx:40
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:563
sal_Int32 GetEntryPosForPoint(const Point &rPoint) const
void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3907
bool IsShift() const
Definition: event.hxx:155
bool MatchString(const OUString &rStr1, const OUString &rStr2) const
Definition: i18nhelp.cxx:124
void SetMRUCount(sal_Int32 n)
Definition: listbox.hxx:156
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
void SetTextFillColor()
Definition: text.cxx:697
const Color & GetFieldRolloverTextColor() const
sal_uInt16 GetCode() const
Definition: keycod.hxx:51
void SelectEntry(sal_Int32 nPos, bool bSelect)
Definition: imp_listbox.cxx:84
tools::Long GetWidth() const
sal_Int32 FindEntry(std::u16string_view rStr, bool bSearchMRUArea=false) const
sal_Int32 GetSelectedEntryCount() const
PosSizeFlags
Definition: window.hxx:140
DataChangedEventType GetType() const
Definition: event.hxx:356
The invalidated area is updated immediately.
tools::Rectangle GetDesktopRectPixel() const
Definition: window.cxx:2794
sal_Int32 mnMRUCount
Definition: listbox.hxx:93
bool mbMouseMoveSelect
Select at MouseMove.
Definition: listbox.hxx:213
WinBits const WB_VSCROLL
sal_Int32 mnTop
output from line on
Definition: listbox.hxx:199
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
sal_uInt16 GetDisplayLineCount() const
const Color & GetControlBackground() const
Definition: window2.cxx:1082
const CommandWheelData * GetWheelData() const
constexpr sal_uInt16 KEY_SPACE
Definition: keycodes.hxx:123
void SetRangeMax(tools::Long nNewRange)
Definition: scrbar.cxx:1333
void SetSeparatorPos(sal_Int32 n)
Removes existing separators, and sets the position of the one and only separator. ...
void SetType(WindowType nType)
Definition: window2.cxx:968
bool mbCenter
center Text output
Definition: listbox.hxx:218
void PaintImmediately()
Definition: paint.cxx:1288
bool HandleScrollCommand(const CommandEvent &rCmd, ScrollBar *pHScrl, ScrollBar *pVScrl)
Definition: window2.cxx:609
void SetEntryFlags(sal_Int32 nPos, ListBoxEntryFlags nFlags)
virtual void Tracking(const TrackingEvent &rTEvt) override
static Point ImplCalcPos(vcl::Window *pWindow, const tools::Rectangle &rRect, FloatWinPopupFlags nFlags, sal_uInt16 &rArrangeIndex, Point *pLOKTwipsPos=nullptr)
Definition: floatwin.cxx:236
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:244
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3006
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
const vcl::Font & GetFieldFont() const
tools::Long GetLeftIndent() const
Definition: listbox.hxx:454
const Color & GetFieldTextColor() const
int mnListBoxEntryMargin
Definition: svdata.hxx:340
void ImplUpdateEntryMetrics(ImplEntryType &rEntry)
constexpr sal_uInt16 KEY_UP
Definition: keycodes.hxx:111
#define LISTBOX_ENTRY_NOTFOUND
Definition: lstbox.hxx:38
const Color & GetHighlightColor() const
VclPtr< ImplListBoxWindow > maLBWindow
Definition: listbox.hxx:379
bool mbReadOnly
ReadOnly.
Definition: listbox.hxx:217
ImplEntryList(vcl::Window *pWindow)
Definition: imp_listbox.cxx:61
The invalidated area is painted with the background color/pattern.
void ImplInitScrollBars()
Link< void *, void > maMBDownHdl
Definition: listbox.hxx:586
sal_Int32 GetTopEntry() const
Definition: listbox.hxx:286
constexpr sal_uInt16 KEY_END
Definition: keycodes.hxx:115
void RemoveEntry(sal_Int32 nPos)
const Fraction & GetZoom() const
Definition: window2.cxx:1210
void * GetEntryData(sal_Int32 nPos) const
StateChangedType
Definition: window.hxx:317
tools::Long mnMaxWidth
Maximum width of an entry.
Definition: listbox.hxx:189
tools::Rectangle GetTextRect(const tools::Rectangle &rRect, const OUString &rStr, DrawTextFlags nStyle=DrawTextFlags::WordBreak, TextRectInfo *pInfo=nullptr, const vcl::ITextLayout *_pTextLayout=nullptr) const
Definition: text.cxx:1796
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
tools::Long mnTextHeight
text height
Definition: listbox.hxx:201
tools::Long GetMaxEntryWidth() const
Definition: listbox.hxx:472
sal_uInt16 GetEdgeBlending() const
sal_uInt16 GetClicks() const
Definition: event.hxx:123
VclPtr< vcl::Window > mpWindow
For getting the current locale when matching strings.
Definition: listbox.hxx:88
sal_Int64 WinBits
IMPL_LINK_NOARG(ImplListBox, MRUChanged, LinkParamNone *, void)
sal_uInt16 sal_Unicode
bool IsTravelSelect() const
Definition: listbox.hxx:321
std::set< sal_Int32 > maSeparators
Separator positions.
Definition: listbox.hxx:195
virtual bool PreNotify(NotifyEvent &rNEvt) override
void RemoveEntry(sal_Int32 nPos)
void SetBackground()
void SetControlFont()
Definition: window2.cxx:409
tools::Long mnMaxImgTxtWidth
Maximum width of a text item.
Definition: listbox.hxx:185
void Enable(bool bEnable=true, bool bChild=true)
Definition: window.cxx:2431
void SetPageSize(tools::Long nNewSize)
Definition: scrbar.hxx:125
SAL_DLLPRIVATE void ReMirror(Point &rPoint) const
Definition: outdev.cxx:603
this flags lets the item be drawn disabled (e.g.
VclPtr< ImplListBox > mpImplLB
Definition: listbox.hxx:500
void SetSymbol(SymbolType eSymbol)
Definition: button.cxx:1513
virtual void StateChanged(StateChangedType nType) override
LB_EVENT_TYPE
Definition: listbox.hxx:42
virtual ~ImplListBoxFloatingWindow() override
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
bool IsControlForeground() const
Definition: window2.cxx:1077
bool IsEnterWindow() const
Definition: event.hxx:135
bool mbHScroll
Definition: listbox.hxx:385
WinBits const WB_HSCROLL
int nCount
void SetMRUChangedHdl(const Link< LinkParamNone *, void > &rLink)
Definition: listbox.hxx:349
void Hide()
Definition: window.hxx:948
AllSettingsFlags GetFlags() const
Definition: event.hxx:357
constexpr sal_uInt16 KEY_PAGEUP
Definition: keycodes.hxx:116
tools::Long Bottom() const
virtual const Wallpaper & GetDisplayBackground() const override
bool mbIsDropdown
Listbox is actually a dropdown (either combobox, or popup window treated as dropdown) ...
Definition: listbox.hxx:222
tools::Long mnMaxTxtWidth
Maximum width of a text item.
Definition: listbox.hxx:183
tools::Long getHeightWithMargin() const
virtual void Resize() override
sal_uInt16 GetModifier() const
Definition: keycod.hxx:54
const void * StringEntryIdentifier
Link< LinkParamNone *, void > maListItemSelectHdl
Definition: listbox.hxx:231
bool IsValid() const
ImplWin(vcl::Window *pParent, WinBits nWinStyle)
sal_Int32 mnMaxMRUCount
Definition: listbox.hxx:94
bool mbSimpleMode
SimpleMode for MultiListBox.
Definition: listbox.hxx:209
void DrawLine(const Point &rStartPt, const Point &rEndPt)
Definition: line.cxx:88
void SetThumbPos(tools::Long nThumbPos)
Definition: scrbar.cxx:1362
const Color & GetEdgeBlendingBottomRightColor() const
Image GetEntryImage(sal_Int32 nPos) const
void SetLineSize(tools::Long nNewSize)
Definition: scrbar.hxx:123
ImplListBoxWindow * GetMainWindow()
Definition: listbox.hxx:411
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
sal_Int32 mnTrackingSaveSelection
Selection before Tracking();.
Definition: listbox.hxx:193
void SetEntryFlags(sal_Int32 nPos, ListBoxEntryFlags nFlags)
const Color & GetControlForeground() const
Definition: window2.cxx:1072
this flag disables a selection of an entry completely.
void SetTopEntry(sal_Int32 nTop)
Definition: listbox.hxx:448
constexpr sal_uInt16 KEY_DOWN
Definition: keycodes.hxx:110
void RemoveEntry(sal_Int32 nPos)
void SetScrollHdl(const Link< ImplListBoxWindow *, void > &rLink)
Definition: listbox.hxx:344
Link< void *, void > maMBDownHdl
Definition: listbox.hxx:544
ImplListBoxFloatingWindow(vcl::Window *pParent)
sal_Int32 GetSeparatorPos() const
Gets the position of the separator which was added first.
sal_Int32 GetMRUCount() const
Definition: listbox.hxx:157
bool IsEmpty() const
Definition: BitmapEx.cxx:198
void ShowProminentEntry(sal_Int32 nPos)
Definition: listbox.hxx:450
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:73
bool ProcessKeyInput(const KeyEvent &rKEvt)
this flag can be used to make an entry multiline capable A normal entry is single line and will there...
void SetLineColor()
virtual void KeyInput(const KeyEvent &rKEvt) override
void clear()
Definition: vclptr.hxx:190
const Color & GetDisableColor() const
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: syswin.cxx:202
std::vector< std::unique_ptr< ImplEntryType > > maEntries
Definition: listbox.hxx:98
sal_Int32 FindFirstSelectable(sal_Int32 nPos, bool bForward=true)
bool IsRTLEnabled() const
Definition: outdev.hxx:1360
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:50
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
bool IsLeaveWindow() const
Definition: event.hxx:137
int i
virtual void Resize() override
bool IsEntryPosSelected(sal_Int32 nIndex) const
bool IsNativeWidgetEnabled() const
Definition: window.cxx:3700
ImplBtn(vcl::Window *pParent, WinBits nWinStyle)
virtual void Resize() override
constexpr sal_uInt16 KEY_HOME
Definition: keycodes.hxx:114
virtual ~ImplListBox() override
void SetControlBackground()
Definition: window2.cxx:497
virtual bool PreNotify(NotifyEvent &rNEvt) override
WinBits const WB_SIMPLEMODE
IMPL_LINK(ImplListBox, ScrollBarHdl, ScrollBar *, pSB, void)
bool mbMulti
MultiListBox.
Definition: listbox.hxx:208
void SetVisibleSize(tools::Long nNewSize)
Definition: scrbar.cxx:1376
tools::Long mnLeft
output from column on
Definition: listbox.hxx:200
void ImplCheckScrollBars()
Link< ImplListBoxWindow *, void > maDoubleClickHdl
Definition: listbox.hxx:227
void SetSize(const Size &rSize)
void SetControlForeground()
Definition: window2.cxx:457
CommandWheelMode GetMode() const
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1164
SAL_DLLPRIVATE bool ImplIsAntiparallel() const
Definition: outdev.cxx:587
void SetUpdateMode(bool bUpdate)
Definition: window.cxx:2969
Size GetOutputSize() const
Definition: outdev.hxx:450
sal_Int32 mnSelectionAnchor
Definition: listbox.hxx:90
ImplListBox(vcl::Window *pParent, WinBits nWinStyle)
bool IsUpdateMode() const
Definition: window2.cxx:1173
void SetFillColor()
tools::Long Width() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_GRAY
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:303
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
const Color & GetFieldColor() const
tools::Long GetEntryHeightWithMargin() const
CommandEventId GetCommand() const
const Color & GetLineColor() const
Definition: outdev.hxx:630
VclPtr< ScrollBarBox > mpScrollBarBox
Definition: listbox.hxx:382
void SetZoom(const Fraction &rZoom)
Definition: window2.cxx:365
sal_uInt16 GetModifier() const
Size CalcSize(sal_Int32 nMaxLines) const
void SetTextColor(const Color &rColor)
Definition: text.cxx:662
constexpr sal_uInt16 KEY_PAGEDOWN
Definition: keycodes.hxx:117
DrawTextFlags ImplGetTextStyle() const
bool IsZoom() const
Definition: window2.cxx:1215
void SetEdgeBlending(bool bNew)
Definition: listbox.hxx:364
void ImplDoPaint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
MouseNotifyEvent GetType() const
Definition: event.hxx:302
void SetLeftIndent(tools::Long n)
bool IsInside(const Point &rPOINT) const
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
Request rendering of a particular control and/or part.
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: ctrl.cxx:59
WinBits const WB_DROPDOWN
const AllSettings & GetSettings() const
Definition: outdev.hxx:418
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
vcl::QuickSelectionEngine maQuickSelectionEngine
Definition: listbox.hxx:233
DrawTextFlags
Definition: outdev.hxx:143
bool GetEdgeBlending() const
Definition: listbox.hxx:573
tools::Long GetScrollBarSize() const
VclPtr< ScrollBar > mpHScrollBar
Definition: listbox.hxx:380
bool HandleWheelAsCursorTravel(const CommandEvent &rCEvt, Control &rControl)
void ApplyControlForeground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
Definition: window2.cxx:489
Link< LinkParamNone *, void > maCancelHdl
Definition: listbox.hxx:226
std::unique_ptr< ImplEntryList > mpEntryList
EntryList.
Definition: listbox.hxx:177
WinBits const WB_SORT
sal_uInt16 GetModifier() const
Definition: event.hxx:153
bool mbSort
ListBox sorted.
Definition: listbox.hxx:206
tools::Long Top() const
virtual void LoseFocus()
Definition: window.cxx:1854
bool GetEdgeBlending() const
Definition: listbox.hxx:363
void DrawEntry(vcl::RenderContext &rRenderContext, sal_Int32 nPos, bool bDrawImage, bool bDrawText)
OUString maStr
Definition: listbox.hxx:52
void GrabFocus()
Definition: window.cxx:2978
Link< UserDrawEvent *, void > maUserDrawHdl
Definition: listbox.hxx:228
virtual void ShowFocus(const tools::Rectangle &rRect)
Definition: window2.cxx:49
bool mbTravelSelect
TravelSelect.
Definition: listbox.hxx:210
vcl::Window * GetParent() const
Definition: window2.cxx:1097
ListBoxEntryFlags mnFlags
Definition: listbox.hxx:57
sal_Int32 FindMatchingEntry(const OUString &rStr, sal_Int32 nStart, bool bLazy) const
void SetLeftIndent(sal_uInt16 n)
Definition: listbox.hxx:455
void ImplPaint(vcl::RenderContext &rRenderContext, sal_Int32 nPos)
bool IsTrackingEnded() const
Definition: event.hxx:263
std::unique_ptr< SalLayout > ImplLayout(const OUString &, sal_Int32 nIndex, sal_Int32 nLen, const Point &rLogicPos=Point(0, 0), tools::Long nLogicWidth=0, const tools::Long *pLogicDXArray=nullptr, SalLayoutFlags flags=SalLayoutFlags::NONE, vcl::TextLayoutCache const *=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr) const
Definition: text.cxx:1241
Link< LinkParamNone *, void > maMRUChangedHdl
Definition: listbox.hxx:229
virtual void MouseMove(const MouseEvent &rMEvt) override
void DrawEntry(vcl::RenderContext &rRenderContext, bool bLayout)
Size CalcSize(sal_Int32 nMaxLines) const
Definition: listbox.hxx:469
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
WinBits const WB_NOBORDER
const Color & GetButtonRolloverTextColor() const
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
Definition: window2.cxx:1268
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1039
constexpr sal_uInt16 KEY_RIGHT
Definition: keycodes.hxx:113
#define MULTILINE_ENTRY_DRAW_FLAGS
Definition: imp_listbox.cxx:46
bool mbIsSelected
Definition: listbox.hxx:56
sal_Int32 mnCurrentPos
Position (Focus)
Definition: listbox.hxx:192
bool mbUserDrawEnabled
UserDraw possible.
Definition: listbox.hxx:215
Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1049
VclPtr< ScrollBar > mpVScrollBar
Definition: listbox.hxx:381
tools::Long const nBorder
bool IsMouseMoveSelect() const
Definition: listbox.hxx:335
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2664
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1804
const LanguageTag & getLocale()
const vcl::I18nHelper & GetLocaleI18nHelper() const
bool mbUseNativeFocus
Definition: window.h:317
tools::Long mnMaxTxtHeight
Maximum height of a text item.
Definition: listbox.hxx:182
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: window.cxx:2422
void * mpUserData
Definition: listbox.hxx:55
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:54
void Erase()
Definition: wallpaper.cxx:103
bool IsShift() const
Definition: keycod.hxx:56
tools::Long GetAddedHeight(sal_Int32 nEndIndex, sal_Int32 nBeginIndex) const
helper: add up heights up to index nEndIndex.
bool IsUserDrawEnabled() const
Definition: listbox.hxx:327
bool IsMouseOver() const
Definition: mouse.cxx:606
virtual void Resize() override
Definition: ctrl.cxx:74
ImplEntryType * GetEntry(sal_Int32 nPos) const
Definition: listbox.hxx:100
bool ProcessKeyInput(const KeyEvent &rKEvt)
Definition: listbox.hxx:429
virtual void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
Definition: window.cxx:2942
const ImplEntryType * GetEntryPtr(sal_Int32 nPos) const
Definition: listbox.hxx:113
Definition: ctrl.hxx:33
bool IsEntrySelectable(sal_Int32 nPos) const
An Entry is selectable if its mnFlags does not have the ListBoxEntryFlags::DisableSelection flag set...
#define LISTBOX_MAX_ENTRIES
Definition: lstbox.hxx:39
ListBoxEntryFlags
Definition: lstbox.hxx:48
bool IsSynthetic() const
Definition: event.hxx:139
virtual void GetFocus()
Definition: window.cxx:1840
const Color & GetButtonTextColor() const
bool mbNoFocusRects
Definition: svdata.hxx:321
sal_Int32 mnItemPos
because of UserDraw I have to know which item I draw
Definition: listbox.hxx:538
#define SAL_WARN_IF(condition, area, stream)
WinBits const WB_BORDER
unsigned char sal_uInt8
bool bIsEnabled
const MouseEvent * GetMouseEvent() const
Definition: event.hxx:318
std::unique_ptr< vcl::ImplControlData > mpControlData
Definition: ctrl.hxx:36
virtual void GetFocus() override
sal_Int32 mnLastSelected
Definition: listbox.hxx:89
tools::Long GetEntryHeightWithMargin() const
Definition: listbox.hxx:471
bool IsVisible() const
Definition: window2.cxx:1102
virtual vcl::StringEntryIdentifier CurrentEntry(OUString &_out_entryText) const override
returns the current entry in the list of searchable strings.
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:891
sal_Int32 mnPopupModeStartSaveSelection
Definition: listbox.hxx:503
void SetSeparatorPos(sal_Int32 n)
Removes existing separators, and sets the position of the one and only separator. ...
Definition: listbox.hxx:436
bool SelectEntries(sal_Int32 nSelect, LB_EVENT_TYPE eLET, bool bShift=false, bool bCtrl=false, bool bSelectPosChange=false)
sal_uInt16 mnSelectModifier
Modifiers.
Definition: listbox.hxx:203
::OutputDevice const * GetOutDev() const
Definition: window.cxx:578
bool IsLeft() const
Definition: event.hxx:146
tools::Long AdjustWidth(tools::Long n)
void SetScrollHdl(const Link< ScrollBar *, void > &rLink)
Definition: scrbar.hxx:133
Definition: image.hxx:39
bool IsMod1() const
Definition: keycod.hxx:58
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
tools::Long mnMaxImgHeight
Maximum height of an image item.
Definition: listbox.hxx:188
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: text.cxx:880
tools::Long Height() const
Reference< XComponentContext > getProcessComponentContext()
tools::Long CalcZoom(tools::Long n) const
Definition: window2.cxx:397
ImplListBoxWindow(vcl::Window *pParent, WinBits nWinStyle)
bool IsGrabFocusAllowed() const
Definition: listbox.hxx:298
const Point & GetPosPixel() const
Definition: event.hxx:120
sal_Int32 mnImages
Definition: listbox.hxx:91
WinBits const WB_AUTOHSCROLL
tools::Long AdjustHeight(tools::Long n)
virtual void GetFocus() override
tools::Long GetEntryHeight(sal_Int32 nPos) const
sal_Int32 InsertEntry(sal_Int32 nPos, ImplEntryType *pNewEntry)
void setHeight(tools::Long nHeight)
virtual bool EventNotify(NotifyEvent &rNEvt) override
tools::Long GetHeight() const
Event to pass information for UserDraw() handling eg. in comboboxes.
Definition: event.hxx:218
tools::Long GetDelta() const
WinBits const WB_CENTER
sal_Int32 InsertEntry(sal_Int32 nPos, const OUString &rStr)
bool isSeparator(const sal_Int32 &n) const
Checks if the given number n is an element of the separator positions set.
ScXMLEditAttributeMap::Entry const aEntries[]
bool IsEnabled() const
Definition: window2.cxx:1122
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
#define SAL_WARN(area, stream)
Image maImage
Definition: listbox.hxx:540
OUString GetSelectedEntry(sal_Int32 nIndex) const
void SetTopEntry(sal_Int32 nTop)
bool IsTrackingCanceled() const
Definition: event.hxx:265
OUString GetMRUEntries(sal_Unicode cSep) const
WinBits GetStyle() const
Definition: window2.cxx:953
void SelectEntry(sal_Int32 nPos, bool bSelect)
Link< sal_Int32, void > maSelectionChangedHdl
Definition: listbox.hxx:96
sal_Int32 mnUserDrawEntry
Definition: listbox.hxx:197
virtual void FillLayoutData() const override
bool IsReadOnly() const
Definition: listbox.hxx:359
void ApplyControlFont(vcl::RenderContext &rRenderContext, const vcl::Font &rDefaultFont)
Definition: window2.cxx:449
OUString GetEntryText(sal_Int32 nPos) const
constexpr sal_uInt16 KEY_LEFT
Definition: keycodes.hxx:112
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2801
void StartFloat(bool bStartTracking)
sal_Int32 GetLastVisibleEntry() const
void SetEntryData(sal_Int32 nPos, void *pNewData)
void ImplInitDropDownButton(PushButton *pButton)
Definition: imp_listbox.cxx:52
sal_Int32 compare(const OUString &rLHS, const OUString &rRHS) const
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
void SetAccessibleRole(sal_uInt16 nRole)
bool mbInUserDraw
In UserDraw.
Definition: listbox.hxx:216
const MouseEvent & GetMouseEvent() const
Definition: event.hxx:259
bool IsReallyVisible() const
Definition: window2.cxx:1107
vcl::Font GetControlFont() const
Definition: window2.cxx:438
bool mbGrabFocus
Grab focus at MBDown.
Definition: listbox.hxx:214
virtual vcl::StringEntryIdentifier NextEntry(vcl::StringEntryIdentifier _currentEntry, OUString &_out_entryText) const override
returns the next entry in the list.
SalLayoutGlyphs * GetTextGlyphs(const OutputDevice *pOutputDevice)
Computes maStr's text layout (glyphs), cached in maStrGlyphs.
bool HasFocus() const
Definition: window.cxx:2983
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: floatwin.cxx:204
const Color & GetEdgeBlendingTopLeftColor() const
void SetEdgeBlending(bool bNew)
WinBits const WB_WORDBREAK
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
bool SupportsDoubleBuffering() const
Can the widget derived from this Window do the double-buffering via RenderContext properly...
Definition: window.cxx:3869
tools::Long mnMaxHeight
Maximum height of an entry.
Definition: listbox.hxx:190
void ShowProminentEntry(sal_Int32 nEntryPos)
ShowProminentEntry will set the entry corresponding to nEntryPos either at top or in the middle depen...
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
Definition: floatwin.cxx:950
sal_Int32 InsertEntry(sal_Int32 nPos, ImplEntryType *pNewEntry, bool bSort)
sal_Int32 nState
DrawImageFlags
Definition: outdev.hxx:171
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1257
aStr
virtual void Resize() override
Definition: syswin.cxx:1053
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
virtual void GetFocus() override
bool mbCallSelectionChangedHdl
Definition: listbox.hxx:97
sal_Int32 GetEntryCount() const
Definition: listbox.hxx:127
bool IsMod3() const
Definition: keycod.hxx:62
sal_uInt16 nPos
tools::Rectangle GetBoundingRectangle(sal_Int32 nItem) const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:34
Link< LinkParamNone *, void > maSelectHdl
Definition: listbox.hxx:225
bool IsMod1() const
Definition: event.hxx:157
void ImplDraw(vcl::RenderContext &rRenderContext, bool bLayout=false)
WinBits const WB_DRAG
bool IsMod2() const
Definition: keycod.hxx:60
bool mbTrackingSelect
Selected at a MouseMove.
Definition: listbox.hxx:211
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2186
bool mbRight
right align Text output
Definition: listbox.hxx:219
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo