LibreOffice Module vcl (master)  1
combobox.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 <vcl/toolkit/combobox.hxx>
21 
22 #include <set>
23 
24 #include <comphelper/string.hxx>
25 #include <vcl/toolkit/lstbox.hxx>
26 #include <vcl/commandevent.hxx>
27 #include <vcl/event.hxx>
28 #include <vcl/settings.hxx>
29 #include <vcl/uitest/uiobject.hxx>
30 #include <sal/log.hxx>
31 
32 #include <listbox.hxx>
33 #include <controldata.hxx>
34 #include <comphelper/lok.hxx>
35 
36 namespace {
37 
38 struct ComboBoxBounds
39 {
40  Point aSubEditPos;
41  Size aSubEditSize;
42 
43  Point aButtonPos;
44  Size aButtonSize;
45 };
46 
47 }
48 
50 {
56  sal_uInt16 m_nDDHeight;
58  bool m_isDDAutoSize : 1;
61  bool m_isMatchCase : 1;
62  sal_Int32 m_nMaxWidthChars;
63  sal_Int32 m_nWidthInChars;
65 
66  explicit Impl(ComboBox & rThis)
67  : m_rThis(rThis)
68  , m_nDDHeight(0)
69  , m_cMultiSep(0)
70  , m_isDDAutoSize(false)
71  , m_isSyntheticModify(false)
72  , m_isKeyBoardModify(false)
73  , m_isMatchCase(false)
74  , m_nMaxWidthChars(0)
75  , m_nWidthInChars(-1)
76  {
77  }
78 
79  void ImplInitComboBoxData();
82  const Size &rOutSize, const Size &rBorderOutSize) const;
83 
84  DECL_LINK( ImplSelectHdl, LinkParamNone*, void );
85  DECL_LINK( ImplCancelHdl, LinkParamNone*, void );
86  DECL_LINK( ImplDoubleClickHdl, ImplListBoxWindow*, void );
87  DECL_LINK( ImplClickBtnHdl, void*, void );
88  DECL_LINK( ImplPopupModeEndHdl, FloatingWindow*, void );
89  DECL_LINK( ImplSelectionChangedHdl, sal_Int32, void );
90  DECL_LINK( ImplAutocompleteHdl, Edit&, void );
91  DECL_LINK( ImplListItemSelectHdl , LinkParamNone*, void );
92 };
93 
94 
95 static void lcl_GetSelectedEntries( ::std::set< sal_Int32 >& rSelectedPos, const OUString& rText, sal_Unicode cTokenSep, const ImplEntryList* pEntryList )
96 {
97  if (rText.isEmpty())
98  return;
99 
100  sal_Int32 nIdx{0};
101  do {
102  const sal_Int32 nPos = pEntryList->FindEntry(comphelper::string::strip(rText.getToken(0, cTokenSep, nIdx), ' '));
103  if ( nPos != LISTBOX_ENTRY_NOTFOUND )
104  rSelectedPos.insert( nPos );
105  } while (nIdx>=0);
106 }
107 
108 ComboBox::ComboBox(vcl::Window *const pParent, WinBits const nStyle)
109  : Edit( WindowType::COMBOBOX )
110  , m_pImpl(new Impl(*this))
111 {
112  m_pImpl->ImplInitComboBoxData();
113  ImplInit( pParent, nStyle );
114  SetWidthInChars(-1);
115 }
116 
118 {
119  disposeOnce();
120 }
121 
123 {
124  m_pImpl->m_pSubEdit.disposeAndClear();
125 
126  VclPtr< ImplListBox > pImplLB = m_pImpl->m_pImplLB;
127  m_pImpl->m_pImplLB.clear();
128  pImplLB.disposeAndClear();
129 
130  m_pImpl->m_pFloatWin.disposeAndClear();
131  m_pImpl->m_pBtn.disposeAndClear();
132  Edit::dispose();
133 }
134 
136 {
138  m_pBtn = nullptr;
139  m_pImplLB = nullptr;
140  m_pFloatWin = nullptr;
141 
142  m_nDDHeight = 0;
143  m_isDDAutoSize = true;
144  m_isSyntheticModify = false;
145  m_isKeyBoardModify = false;
146  m_isMatchCase = false;
147  m_cMultiSep = ';';
148  m_nMaxWidthChars = -1;
149  m_nWidthInChars = -1;
150 }
151 
153 {
154  sal_Int32 nLeft, nTop, nRight, nBottom;
155  GetBorder( nLeft, nTop, nRight, nBottom );
156  m_pImpl->m_nDDHeight = static_cast<sal_uInt16>(m_pImpl->m_pSubEdit->GetTextHeight() + nTop + nBottom + 4);
157  if ( !IsDropDownBox() )
158  m_pImpl->m_nDDHeight += 4;
159 
160  tools::Rectangle aCtrlRegion( Point( 0, 0 ), Size( 10, 10 ) );
161  tools::Rectangle aBoundRegion, aContentRegion;
162  ImplControlValue aControlValue;
165  aCtrlRegion,
167  aControlValue,
168  aBoundRegion, aContentRegion ) )
169  {
170  const long nNCHeight = aBoundRegion.GetHeight();
171  if (m_pImpl->m_nDDHeight < nNCHeight)
172  m_pImpl->m_nDDHeight = sal::static_int_cast<sal_uInt16>(nNCHeight);
173  }
174 }
175 
176 void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
177 {
178  bool bNoBorder = ( nStyle & WB_NOBORDER ) != 0;
179  if ( !(nStyle & WB_DROPDOWN) )
180  {
181  nStyle &= ~WB_BORDER;
182  nStyle |= WB_NOBORDER;
183  }
184  else
185  {
186  if ( !bNoBorder )
187  nStyle |= WB_BORDER;
188  }
189 
190  Edit::ImplInit( pParent, nStyle );
191  SetBackground();
192 
193  // DropDown ?
194  WinBits nEditStyle = nStyle & ( WB_LEFT | WB_RIGHT | WB_CENTER );
195  WinBits nListStyle = nStyle;
196  if( nStyle & WB_DROPDOWN )
197  {
198  m_pImpl->m_pFloatWin = VclPtr<ImplListBoxFloatingWindow>::Create( this );
200  m_pImpl->m_pFloatWin->RequestDoubleBuffering(true);
201  m_pImpl->m_pFloatWin->SetAutoWidth( true );
202  m_pImpl->m_pFloatWin->SetPopupModeEndHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplPopupModeEndHdl) );
203 
205  ImplInitDropDownButton( m_pImpl->m_pBtn );
206  m_pImpl->m_pBtn->SetMBDownHdl( LINK( m_pImpl.get(), ComboBox::Impl, ImplClickBtnHdl ) );
207  m_pImpl->m_pBtn->Show();
208 
209  nEditStyle |= WB_NOBORDER;
210  nListStyle &= ~WB_BORDER;
211  nListStyle |= WB_NOBORDER;
212  }
213  else
214  {
215  if ( !bNoBorder )
216  {
217  nEditStyle |= WB_BORDER;
218  nListStyle &= ~WB_NOBORDER;
219  nListStyle |= WB_BORDER;
220  }
221  }
222 
223  m_pImpl->m_pSubEdit.set( VclPtr<Edit>::Create( this, nEditStyle ) );
224  m_pImpl->m_pSubEdit->EnableRTL( false );
225  SetSubEdit( m_pImpl->m_pSubEdit );
226  m_pImpl->m_pSubEdit->SetPosPixel( Point() );
227  EnableAutocomplete( true );
228  m_pImpl->m_pSubEdit->Show();
229 
230  vcl::Window* pLBParent = this;
231  if (m_pImpl->m_pFloatWin)
232  pLBParent = m_pImpl->m_pFloatWin;
233  m_pImpl->m_pImplLB = VclPtr<ImplListBox>::Create( pLBParent, nListStyle|WB_SIMPLEMODE|WB_AUTOHSCROLL );
234  m_pImpl->m_pImplLB->SetPosPixel( Point() );
235  m_pImpl->m_pImplLB->SetSelectHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplSelectHdl) );
236  m_pImpl->m_pImplLB->SetCancelHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplCancelHdl) );
237  m_pImpl->m_pImplLB->SetDoubleClickHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplDoubleClickHdl) );
238  m_pImpl->m_pImplLB->SetSelectionChangedHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplSelectionChangedHdl) );
239  m_pImpl->m_pImplLB->SetListItemSelectHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplListItemSelectHdl) );
240  m_pImpl->m_pImplLB->Show();
241 
242  if (m_pImpl->m_pFloatWin)
243  m_pImpl->m_pFloatWin->SetImplListBox( m_pImpl->m_pImplLB );
244  else
245  m_pImpl->m_pImplLB->GetMainWindow()->AllowGrabFocus( true );
246 
248 
249  SetCompoundControl( true );
250 }
251 
253 {
254  if ( !(nStyle & WB_NOTABSTOP) )
255  nStyle |= WB_TABSTOP;
256  if ( !(nStyle & WB_NOGROUP) )
257  nStyle |= WB_GROUP;
258  return nStyle;
259 }
260 
261 void ComboBox::EnableAutocomplete( bool bEnable, bool bMatchCase )
262 {
263  m_pImpl->m_isMatchCase = bMatchCase;
264 
265  if ( bEnable )
266  m_pImpl->m_pSubEdit->SetAutocompleteHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplAutocompleteHdl) );
267  else
268  m_pImpl->m_pSubEdit->SetAutocompleteHdl( Link<Edit&,void>() );
269 }
270 
272 {
273  return m_pImpl->m_pSubEdit->GetAutocompleteHdl().IsSet();
274 }
275 
276 IMPL_LINK_NOARG(ComboBox::Impl, ImplClickBtnHdl, void*, void)
277 {
278  m_rThis.CallEventListeners( VclEventId::DropdownPreOpen );
279  m_pSubEdit->GrabFocus();
280  if (!m_pImplLB->GetEntryList()->GetMRUCount())
281  ImplUpdateFloatSelection();
282  else
283  m_pImplLB->SelectEntry( 0 , true );
284  m_pBtn->SetPressed( true );
285  m_rThis.SetSelection( Selection( 0, SELECTION_MAX ) );
286  m_pFloatWin->StartFloat( true );
287  m_rThis.CallEventListeners( VclEventId::DropdownOpen );
288 
289  m_rThis.ImplClearLayoutData();
290  if (m_pImplLB)
291  m_pImplLB->GetMainWindow()->ImplClearLayoutData();
292 }
293 
294 IMPL_LINK_NOARG(ComboBox::Impl, ImplPopupModeEndHdl, FloatingWindow*, void)
295 {
296  if (m_pFloatWin->IsPopupModeCanceled())
297  {
298  if (!m_pImplLB->GetEntryList()->IsEntryPosSelected(
299  m_pFloatWin->GetPopupModeStartSaveSelection()))
300  {
301  m_pImplLB->SelectEntry(m_pFloatWin->GetPopupModeStartSaveSelection(), true);
302  bool bTravelSelect = m_pImplLB->IsTravelSelect();
303  m_pImplLB->SetTravelSelect( true );
304  m_rThis.Select();
305  m_pImplLB->SetTravelSelect( bTravelSelect );
306  }
307  }
308 
309  m_rThis.ImplClearLayoutData();
310  if (m_pImplLB)
311  m_pImplLB->GetMainWindow()->ImplClearLayoutData();
312 
313  m_pBtn->SetPressed( false );
314  m_rThis.CallEventListeners( VclEventId::DropdownClose );
315 }
316 
317 IMPL_LINK(ComboBox::Impl, ImplAutocompleteHdl, Edit&, rEdit, void)
318 {
319  Selection aSel = rEdit.GetSelection();
320 
321  {
322  OUString aFullText = rEdit.GetText();
323  OUString aStartText = aFullText.copy( 0, static_cast<sal_Int32>(aSel.Max()) );
324  sal_Int32 nStart = m_pImplLB->GetCurrentPos();
325 
326  if ( nStart == LISTBOX_ENTRY_NOTFOUND )
327  nStart = 0;
328 
329  sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND;
330  if (!m_isMatchCase)
331  {
332  // Try match case insensitive from current position
333  nPos = m_pImplLB->GetEntryList()->FindMatchingEntry(aStartText, nStart, true);
334  if ( nPos == LISTBOX_ENTRY_NOTFOUND )
335  // Try match case insensitive, but from start
336  nPos = m_pImplLB->GetEntryList()->FindMatchingEntry(aStartText, 0, true);
337  }
338 
339  if ( nPos == LISTBOX_ENTRY_NOTFOUND )
340  // Try match full from current position
341  nPos = m_pImplLB->GetEntryList()->FindMatchingEntry(aStartText, nStart, false);
342  if ( nPos == LISTBOX_ENTRY_NOTFOUND )
343  // Match full, but from start
344  nPos = m_pImplLB->GetEntryList()->FindMatchingEntry(aStartText, 0, false);
345 
346  if ( nPos != LISTBOX_ENTRY_NOTFOUND )
347  {
348  OUString aText = m_pImplLB->GetEntryList()->GetEntryText( nPos );
349  Selection aSelection( aText.getLength(), aStartText.getLength() );
350  rEdit.SetText( aText, aSelection );
351  }
352  }
353 }
354 
356 {
357  bool bPopup = m_rThis.IsInDropDown();
358  bool bCallSelect = false;
359  if (m_pImplLB->IsSelectionChanged() || bPopup)
360  {
361  OUString aText;
362  if (m_rThis.IsMultiSelectionEnabled())
363  {
364  aText = m_pSubEdit->GetText();
365 
366  // remove all entries to which there is an entry, but which is not selected
367  sal_Int32 nIndex = 0;
368  while ( nIndex >= 0 )
369  {
370  sal_Int32 nPrevIndex = nIndex;
371  OUString aToken = aText.getToken( 0, m_cMultiSep, nIndex );
372  sal_Int32 nTokenLen = aToken.getLength();
373  aToken = comphelper::string::strip(aToken, ' ');
374  sal_Int32 nP = m_pImplLB->GetEntryList()->FindEntry( aToken );
375  if ((nP != LISTBOX_ENTRY_NOTFOUND) && (!m_pImplLB->GetEntryList()->IsEntryPosSelected(nP)))
376  {
377  aText = aText.replaceAt( nPrevIndex, nTokenLen, "" );
378  nIndex = nIndex - nTokenLen;
379  sal_Int32 nSepCount=0;
380  if ((nPrevIndex+nSepCount < aText.getLength()) && (aText[nPrevIndex+nSepCount] == m_cMultiSep))
381  {
382  nIndex--;
383  ++nSepCount;
384  }
385  aText = aText.replaceAt( nPrevIndex, nSepCount, "" );
386  }
387  aText = comphelper::string::strip(aText, ' ');
388  }
389 
390  // attach missing entries
391  ::std::set< sal_Int32 > aSelInText;
392  lcl_GetSelectedEntries( aSelInText, aText, m_cMultiSep, m_pImplLB->GetEntryList() );
393  sal_Int32 nSelectedEntries = m_pImplLB->GetEntryList()->GetSelectedEntryCount();
394  for ( sal_Int32 n = 0; n < nSelectedEntries; n++ )
395  {
396  sal_Int32 nP = m_pImplLB->GetEntryList()->GetSelectedEntryPos( n );
397  if ( !aSelInText.count( nP ) )
398  {
399  if (!aText.isEmpty() && (aText[aText.getLength()-1] != m_cMultiSep))
400  aText += OUStringChar(m_cMultiSep);
401  if ( !aText.isEmpty() )
402  aText += " "; // slightly loosen
403  aText += m_pImplLB->GetEntryList()->GetEntryText( nP ) +
404  OUStringChar(m_cMultiSep);
405  }
406  }
407  aText = comphelper::string::stripEnd( aText, m_cMultiSep );
408  }
409  else
410  {
411  aText = m_pImplLB->GetEntryList()->GetSelectedEntry( 0 );
412  }
413 
414  m_pSubEdit->SetText( aText );
415 
416  Selection aNewSelection( 0, aText.getLength() );
417  if (m_rThis.IsMultiSelectionEnabled())
418  aNewSelection.Min() = aText.getLength();
419  m_pSubEdit->SetSelection( aNewSelection );
420 
421  bCallSelect = true;
422  }
423 
424  // #84652# Call GrabFocus and EndPopupMode before calling Select/Modify, but after changing the text
425  bool bMenuSelect = bPopup && !m_pImplLB->IsTravelSelect() && (!m_rThis.IsMultiSelectionEnabled() || !m_pImplLB->GetSelectModifier());
426  if (bMenuSelect)
427  {
428  m_pFloatWin->EndPopupMode();
429  m_rThis.GrabFocus();
430  }
431 
432  if ( bCallSelect )
433  {
434  m_isKeyBoardModify = !bMenuSelect;
435  m_pSubEdit->SetModifyFlag();
436  m_isSyntheticModify = true;
437  m_rThis.Modify();
438  m_isSyntheticModify = false;
439  m_rThis.Select();
440  m_isKeyBoardModify = false;
441  }
442 }
443 
445 {
446  return m_pImpl->m_isSyntheticModify;
447 }
448 
450 {
451  return m_pImpl->m_isKeyBoardModify;
452 }
453 
454 IMPL_LINK_NOARG( ComboBox::Impl, ImplListItemSelectHdl, LinkParamNone*, void )
455 {
456  m_rThis.CallEventListeners( VclEventId::DropdownSelect );
457 }
458 
460 {
461  if (m_rThis.IsInDropDown())
462  m_pFloatWin->EndPopupMode();
463 }
464 
465 IMPL_LINK( ComboBox::Impl, ImplSelectionChangedHdl, sal_Int32, nChanged, void )
466 {
467  if (!m_pImplLB->IsTrackingSelect())
468  {
469  if (!m_pSubEdit->IsReadOnly() && m_pImplLB->GetEntryList()->IsEntryPosSelected(nChanged))
470  m_pSubEdit->SetText(m_pImplLB->GetEntryList()->GetEntryText(nChanged));
471  }
472 }
473 
475 {
476  m_rThis.DoubleClick();
477 }
478 
480 {
481  if( IsDropDownBox() )
482  {
483  if (m_pImpl->m_pFloatWin->IsInPopupMode())
484  m_pImpl->m_pFloatWin->EndPopupMode();
485  else
486  {
487  m_pImpl->m_pSubEdit->GrabFocus();
488  if (!m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount())
489  m_pImpl->ImplUpdateFloatSelection();
490  else
491  m_pImpl->m_pImplLB->SelectEntry( 0 , true );
493  m_pImpl->m_pBtn->SetPressed( true );
495  m_pImpl->m_pFloatWin->StartFloat( true );
497  }
498  }
499 }
500 
502 {
503  ImplCallEventListenersAndHandler( VclEventId::ComboboxSelect, [this] () { m_pImpl->m_SelectHdl.Call(*this); } );
504 }
505 
507 {
509 }
510 
511 bool ComboBox::IsAutoSizeEnabled() const { return m_pImpl->m_isDDAutoSize; }
512 
513 void ComboBox::EnableAutoSize( bool bAuto )
514 {
515  m_pImpl->m_isDDAutoSize = bAuto;
516  if (m_pImpl->m_pFloatWin)
517  {
518  if (bAuto && !m_pImpl->m_pFloatWin->GetDropDownLineCount())
519  {
520  // Adapt to GetListBoxMaximumLineCount here; was on fixed number of five before
522  }
523  else if ( !bAuto )
524  {
525  m_pImpl->m_pFloatWin->SetDropDownLineCount( 0 );
526  }
527  }
528 }
529 
530 void ComboBox::SetDropDownLineCount( sal_uInt16 nLines )
531 {
532  if (m_pImpl->m_pFloatWin)
533  m_pImpl->m_pFloatWin->SetDropDownLineCount( nLines );
534 }
535 
537 {
538  // Adapt to maximum allowed number.
539  // Limit for LOK as we can't render outside of the dialog canvas.
542  else
543  SetDropDownLineCount(GetSettings().GetStyleSettings().GetListBoxMaximumLineCount());
544 }
545 
547 {
548  sal_uInt16 nLines = 0;
549  if (m_pImpl->m_pFloatWin)
550  nLines = m_pImpl->m_pFloatWin->GetDropDownLineCount();
551  return nLines;
552 }
553 
554 void ComboBox::setPosSizePixel( long nX, long nY, long nWidth, long nHeight,
555  PosSizeFlags nFlags )
556 {
557  if( IsDropDownBox() && ( nFlags & PosSizeFlags::Size ) )
558  {
559  Size aPrefSz = m_pImpl->m_pFloatWin->GetPrefSize();
560  if ((nFlags & PosSizeFlags::Height) && (nHeight >= 2*m_pImpl->m_nDDHeight))
561  aPrefSz.setHeight( nHeight-m_pImpl->m_nDDHeight );
562  if ( nFlags & PosSizeFlags::Width )
563  aPrefSz.setWidth( nWidth );
564  m_pImpl->m_pFloatWin->SetPrefSize( aPrefSz );
565 
566  if (IsAutoSizeEnabled())
567  nHeight = m_pImpl->m_nDDHeight;
568  }
569 
570  Edit::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
571 }
572 
574 {
575  Control::Resize();
576 
577  if (m_pImpl->m_pSubEdit)
578  {
579  Size aOutSz = GetOutputSizePixel();
580  if( IsDropDownBox() )
581  {
582  ComboBoxBounds aBounds(m_pImpl->calcComboBoxDropDownComponentBounds(aOutSz,
584  m_pImpl->m_pSubEdit->SetPosSizePixel(aBounds.aSubEditPos, aBounds.aSubEditSize);
585  m_pImpl->m_pBtn->SetPosSizePixel(aBounds.aButtonPos, aBounds.aButtonSize);
586  }
587  else
588  {
589  m_pImpl->m_pSubEdit->SetSizePixel(Size(aOutSz.Width(), m_pImpl->m_nDDHeight));
590  m_pImpl->m_pImplLB->setPosSizePixel(0, m_pImpl->m_nDDHeight,
591  aOutSz.Width(), aOutSz.Height() - m_pImpl->m_nDDHeight);
592  if ( !GetText().isEmpty() )
593  m_pImpl->ImplUpdateFloatSelection();
594  }
595  }
596 
597  // adjust the size of the FloatingWindow even when invisible
598  // as KEY_PGUP/DOWN is being processed...
599  if (m_pImpl->m_pFloatWin)
600  m_pImpl->m_pFloatWin->SetSizePixel(m_pImpl->m_pFloatWin->CalcFloatSize());
601 }
602 
603 bool ComboBox::IsDropDownBox() const { return m_pImpl->m_pFloatWin != nullptr; }
604 
606 {
607  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
608  AppendLayoutData( *m_pImpl->m_pSubEdit );
609  m_pImpl->m_pSubEdit->SetLayoutDataParent( this );
610  ImplListBoxWindow* rMainWindow = m_pImpl->m_pImplLB->GetMainWindow();
611  if (m_pImpl->m_pFloatWin)
612  {
613  // dropdown mode
614  if (m_pImpl->m_pFloatWin->IsReallyVisible())
615  {
616  AppendLayoutData( *rMainWindow );
617  rMainWindow->SetLayoutDataParent( this );
618  }
619  }
620  else
621  {
622  AppendLayoutData( *rMainWindow );
623  rMainWindow->SetLayoutDataParent( this );
624  }
625 }
626 
628 {
629  Edit::StateChanged( nType );
630 
631  if ( nType == StateChangedType::ReadOnly )
632  {
633  m_pImpl->m_pImplLB->SetReadOnly( IsReadOnly() );
634  if (m_pImpl->m_pBtn)
635  m_pImpl->m_pBtn->Enable( IsEnabled() && !IsReadOnly() );
636  }
637  else if ( nType == StateChangedType::Enable )
638  {
639  m_pImpl->m_pSubEdit->Enable( IsEnabled() );
640  m_pImpl->m_pImplLB->Enable( IsEnabled() && !IsReadOnly() );
641  if (m_pImpl->m_pBtn)
642  m_pImpl->m_pBtn->Enable( IsEnabled() && !IsReadOnly() );
643  Invalidate();
644  }
645  else if( nType == StateChangedType::UpdateMode )
646  {
647  m_pImpl->m_pImplLB->SetUpdateMode( IsUpdateMode() );
648  }
649  else if ( nType == StateChangedType::Zoom )
650  {
651  m_pImpl->m_pImplLB->SetZoom( GetZoom() );
652  m_pImpl->m_pSubEdit->SetZoom( GetZoom() );
654  Resize();
655  }
656  else if ( nType == StateChangedType::ControlFont )
657  {
658  m_pImpl->m_pImplLB->SetControlFont( GetControlFont() );
659  m_pImpl->m_pSubEdit->SetControlFont( GetControlFont() );
661  Resize();
662  }
663  else if ( nType == StateChangedType::ControlForeground )
664  {
665  m_pImpl->m_pImplLB->SetControlForeground( GetControlForeground() );
666  m_pImpl->m_pSubEdit->SetControlForeground( GetControlForeground() );
667  }
668  else if ( nType == StateChangedType::ControlBackground )
669  {
670  m_pImpl->m_pImplLB->SetControlBackground( GetControlBackground() );
671  m_pImpl->m_pSubEdit->SetControlBackground( GetControlBackground() );
672  }
673  else if ( nType == StateChangedType::Style )
674  {
676  m_pImpl->m_pImplLB->GetMainWindow()->EnableSort( ( GetStyle() & WB_SORT ) != 0 );
677  }
678  else if( nType == StateChangedType::Mirroring )
679  {
680  if (m_pImpl->m_pBtn)
681  {
682  m_pImpl->m_pBtn->EnableRTL( IsRTLEnabled() );
683  ImplInitDropDownButton( m_pImpl->m_pBtn );
684  }
685  m_pImpl->m_pSubEdit->CompatStateChanged( StateChangedType::Mirroring );
686  m_pImpl->m_pImplLB->EnableRTL( IsRTLEnabled() );
687  Resize();
688  }
689 }
690 
692 {
693  Control::DataChanged( rDCEvt );
694 
695  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
697  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
698  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
699  {
700  if (m_pImpl->m_pBtn)
701  {
702  m_pImpl->m_pBtn->SetSettings( GetSettings() );
703  ImplInitDropDownButton( m_pImpl->m_pBtn );
704  }
705  Resize();
706  m_pImpl->m_pImplLB->Resize(); // not called by ComboBox::Resize() if ImplLB is unchanged
707 
708  SetBackground(); // due to a hack in Window::UpdateSettings the background must be reset
709  // otherwise it will overpaint NWF drawn comboboxes
710  }
711 }
712 
714 {
715  bool bDone = false;
716  if ((rNEvt.GetType() == MouseNotifyEvent::KEYINPUT)
717  && (rNEvt.GetWindow() == m_pImpl->m_pSubEdit)
718  && !IsReadOnly())
719  {
720  KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
721  sal_uInt16 nKeyCode = aKeyEvt.GetKeyCode().GetCode();
722  switch( nKeyCode )
723  {
724  case KEY_UP:
725  case KEY_DOWN:
726  case KEY_PAGEUP:
727  case KEY_PAGEDOWN:
728  {
729  m_pImpl->ImplUpdateFloatSelection();
730  if ((nKeyCode == KEY_DOWN) && m_pImpl->m_pFloatWin
731  && !m_pImpl->m_pFloatWin->IsInPopupMode()
732  && aKeyEvt.GetKeyCode().IsMod2())
733  {
735  m_pImpl->m_pBtn->SetPressed( true );
736  if (m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount())
737  m_pImpl->m_pImplLB->SelectEntry( 0 , true );
739  m_pImpl->m_pFloatWin->StartFloat( false );
741  bDone = true;
742  }
743  else if ((nKeyCode == KEY_UP) && m_pImpl->m_pFloatWin
744  && m_pImpl->m_pFloatWin->IsInPopupMode()
745  && aKeyEvt.GetKeyCode().IsMod2())
746  {
747  m_pImpl->m_pFloatWin->EndPopupMode();
748  bDone = true;
749  }
750  else
751  {
752  bDone = m_pImpl->m_pImplLB->ProcessKeyInput( aKeyEvt );
753  }
754  }
755  break;
756 
757  case KEY_RETURN:
758  {
759  if ((rNEvt.GetWindow() == m_pImpl->m_pSubEdit) && IsInDropDown())
760  {
761  m_pImpl->m_pImplLB->ProcessKeyInput( aKeyEvt );
762  bDone = true;
763  }
764  }
765  break;
766  }
767  }
768  else if ((rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS) && m_pImpl->m_pFloatWin)
769  {
770  if (m_pImpl->m_pFloatWin->HasChildPathFocus())
771  m_pImpl->m_pSubEdit->GrabFocus();
772  else if (m_pImpl->m_pFloatWin->IsInPopupMode() && !HasChildPathFocus(true))
773  m_pImpl->m_pFloatWin->EndPopupMode();
774  }
775  else if( (rNEvt.GetType() == MouseNotifyEvent::COMMAND) &&
777  (rNEvt.GetWindow() == m_pImpl->m_pSubEdit) )
778  {
779  MouseWheelBehaviour nWheelBehavior( GetSettings().GetMouseSettings().GetWheelBehavior() );
780  if ( ( nWheelBehavior == MouseWheelBehaviour::ALWAYS )
781  || ( ( nWheelBehavior == MouseWheelBehaviour::FocusOnly )
782  && HasChildPathFocus()
783  )
784  )
785  {
786  bDone = m_pImpl->m_pImplLB->HandleWheelAsCursorTravel( *rNEvt.GetCommandEvent() );
787  }
788  else
789  {
790  bDone = false; // don't eat this event, let the default handling happen (i.e. scroll the context)
791  }
792  }
793  else if ((rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN)
794  && (rNEvt.GetWindow() == m_pImpl->m_pImplLB->GetMainWindow()))
795  {
796  m_pImpl->m_pSubEdit->GrabFocus();
797  }
798 
799  return bDone || Edit::EventNotify( rNEvt );
800 }
801 
802 void ComboBox::SetText( const OUString& rStr )
803 {
805 
806  Edit::SetText( rStr );
807  m_pImpl->ImplUpdateFloatSelection();
808 }
809 
810 void ComboBox::SetText( const OUString& rStr, const Selection& rNewSelection )
811 {
813 
814  Edit::SetText( rStr, rNewSelection );
815  m_pImpl->ImplUpdateFloatSelection();
816 }
817 
819 {
820  if (!m_pImpl->m_isSyntheticModify)
821  m_pImpl->ImplUpdateFloatSelection();
822 
823  Edit::Modify();
824 }
825 
827 {
828  if (!m_pImplLB || !m_pSubEdit)
829  return;
830 
831  // move text in the ListBox into the visible region
832  m_pImplLB->SetCallSelectionChangedHdl( false );
833  if (!m_rThis.IsMultiSelectionEnabled())
834  {
835  OUString aSearchStr( m_pSubEdit->GetText() );
836  sal_Int32 nSelect = LISTBOX_ENTRY_NOTFOUND;
837  bool bSelect = true;
838 
839  if (m_pImplLB->GetCurrentPos() != LISTBOX_ENTRY_NOTFOUND)
840  {
841  OUString aCurrent = m_pImplLB->GetEntryList()->GetEntryText(
842  m_pImplLB->GetCurrentPos());
843  if ( aCurrent == aSearchStr )
844  nSelect = m_pImplLB->GetCurrentPos();
845  }
846 
847  if ( nSelect == LISTBOX_ENTRY_NOTFOUND )
848  nSelect = m_pImplLB->GetEntryList()->FindEntry( aSearchStr );
849  if ( nSelect == LISTBOX_ENTRY_NOTFOUND )
850  {
851  nSelect = m_pImplLB->GetEntryList()->FindMatchingEntry( aSearchStr, 0, true );
852  bSelect = false;
853  }
854 
855  if( nSelect != LISTBOX_ENTRY_NOTFOUND )
856  {
857  if (!m_pImplLB->IsVisible(nSelect))
858  m_pImplLB->ShowProminentEntry( nSelect );
859  m_pImplLB->SelectEntry( nSelect, bSelect );
860  }
861  else
862  {
863  nSelect = m_pImplLB->GetEntryList()->GetSelectedEntryPos( 0 );
864  if( nSelect != LISTBOX_ENTRY_NOTFOUND )
865  m_pImplLB->SelectEntry( nSelect, false );
866  m_pImplLB->ResetCurrentPos();
867  }
868  }
869  else
870  {
871  ::std::set< sal_Int32 > aSelInText;
872  lcl_GetSelectedEntries(aSelInText, m_pSubEdit->GetText(), m_cMultiSep, m_pImplLB->GetEntryList());
873  for (sal_Int32 n = 0; n < m_pImplLB->GetEntryList()->GetEntryCount(); n++)
874  m_pImplLB->SelectEntry( n, aSelInText.count( n ) != 0 );
875  }
876  m_pImplLB->SetCallSelectionChangedHdl( true );
877 }
878 
879 sal_Int32 ComboBox::InsertEntry(const OUString& rStr, sal_Int32 const nPos)
880 {
881  assert(nPos >= 0 && COMBOBOX_MAX_ENTRIES > m_pImpl->m_pImplLB->GetEntryList()->GetEntryCount());
882 
883  sal_Int32 nRealPos;
884  if (nPos == COMBOBOX_APPEND)
885  nRealPos = nPos;
886  else
887  {
888  const sal_Int32 nMRUCount = m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount();
889  assert(nPos <= COMBOBOX_MAX_ENTRIES - nMRUCount);
890  nRealPos = nPos + nMRUCount;
891  }
892 
893  nRealPos = m_pImpl->m_pImplLB->InsertEntry( nRealPos, rStr );
894  nRealPos -= m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount();
895  CallEventListeners( VclEventId::ComboboxItemAdded, reinterpret_cast<void*>(nRealPos) );
896  return nRealPos;
897 }
898 
900  const OUString& rStr, const Image& rImage, sal_Int32 const nPos)
901 {
902  assert(nPos >= 0 && COMBOBOX_MAX_ENTRIES > m_pImpl->m_pImplLB->GetEntryList()->GetEntryCount());
903 
904  sal_Int32 nRealPos;
905  if (nPos == COMBOBOX_APPEND)
906  nRealPos = nPos;
907  else
908  {
909  const sal_Int32 nMRUCount = m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount();
910  assert(nPos <= COMBOBOX_MAX_ENTRIES - nMRUCount);
911  nRealPos = nPos + nMRUCount;
912  }
913 
914  nRealPos = m_pImpl->m_pImplLB->InsertEntry( nRealPos, rStr, rImage );
915  nRealPos -= m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount();
916  CallEventListeners( VclEventId::ComboboxItemAdded, reinterpret_cast<void*>(nRealPos) );
917  return nRealPos;
918 }
919 
920 void ComboBox::RemoveEntryAt(sal_Int32 const nPos)
921 {
922  const sal_Int32 nMRUCount = m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount();
923  assert(nPos >= 0 && nPos <= COMBOBOX_MAX_ENTRIES - nMRUCount);
924  m_pImpl->m_pImplLB->RemoveEntry( nPos + nMRUCount );
925  CallEventListeners( VclEventId::ComboboxItemRemoved, reinterpret_cast<void*>(nPos) );
926 }
927 
929 {
930  if (!m_pImpl->m_pImplLB)
931  return;
932  m_pImpl->m_pImplLB->Clear();
933  CallEventListeners( VclEventId::ComboboxItemRemoved, reinterpret_cast<void*>(-1) );
934 }
935 
936 Image ComboBox::GetEntryImage( sal_Int32 nPos ) const
937 {
938  if (m_pImpl->m_pImplLB->GetEntryList()->HasEntryImage(nPos))
939  return m_pImpl->m_pImplLB->GetEntryList()->GetEntryImage( nPos );
940  return Image();
941 }
942 
943 sal_Int32 ComboBox::GetEntryPos( const OUString& rStr ) const
944 {
945  sal_Int32 nPos = m_pImpl->m_pImplLB->GetEntryList()->FindEntry( rStr );
946  if ( nPos != LISTBOX_ENTRY_NOTFOUND )
947  nPos -= m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount();
948  return nPos;
949 }
950 
951 OUString ComboBox::GetEntry( sal_Int32 nPos ) const
952 {
953  const sal_Int32 nMRUCount = m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount();
954  if (nPos < 0 || nPos > COMBOBOX_MAX_ENTRIES - nMRUCount)
955  return OUString();
956 
957  return m_pImpl->m_pImplLB->GetEntryList()->GetEntryText( nPos + nMRUCount );
958 }
959 
960 sal_Int32 ComboBox::GetEntryCount() const
961 {
962  if (!m_pImpl->m_pImplLB)
963  return 0;
964  return m_pImpl->m_pImplLB->GetEntryList()->GetEntryCount() - m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount();
965 }
966 
968 {
969  return m_pImpl->m_pImplLB->IsTravelSelect();
970 }
971 
973 {
974  // when the dropdown is dismissed, first mbInPopupMode is set to false, and on the next event iteration then
975  // mbPopupMode is set to false
976  return m_pImpl->m_pFloatWin && m_pImpl->m_pFloatWin->IsInPopupMode() && m_pImpl->m_pFloatWin->ImplIsInPrivatePopupMode();
977 }
978 
980 {
981  return m_pImpl->m_pImplLB->IsMultiSelectionEnabled();
982 }
983 
984 void ComboBox::SetSelectHdl(const Link<ComboBox&,void>& rLink) { m_pImpl->m_SelectHdl = rLink; }
985 
987 {
988  if (!m_pImpl->m_pSubEdit)
989  return;
990  m_pImpl->m_pSubEdit->SetActivateHdl(rLink);
991 }
992 
994 {
995  return CalcMinimumSize();
996 }
997 
999 {
1000  long nButtonDownWidth = 0;
1001 
1003  ImplControlValue aControlValue;
1004  tools::Rectangle aContent, aBound;
1005 
1006  // use the full extent of the control
1007  tools::Rectangle aArea( Point(), pBorder->GetOutputSizePixel() );
1008 
1010  aArea, ControlState::NONE, aControlValue, aBound, aContent) )
1011  {
1012  nButtonDownWidth = aContent.getWidth();
1013  }
1014 
1015  long nScrollBarWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
1016 
1017  return std::max(nScrollBarWidth, nButtonDownWidth);
1018 }
1019 
1021 {
1022  Size aSz;
1023 
1024  if (!m_pImpl->m_pImplLB)
1025  return aSz;
1026 
1027  if (!IsDropDownBox())
1028  {
1029  aSz = m_pImpl->m_pImplLB->CalcSize( m_pImpl->m_pImplLB->GetEntryList()->GetEntryCount() );
1030  aSz.AdjustHeight(m_pImpl->m_nDDHeight );
1031  }
1032  else
1033  {
1035 
1036  if (m_pImpl->m_nWidthInChars!= -1)
1037  aSz.setWidth(m_pImpl->m_nWidthInChars * approximate_digit_width());
1038  else
1039  aSz.setWidth(m_pImpl->m_pImplLB->GetMaxEntryWidth());
1040  }
1041 
1042  if (m_pImpl->m_nMaxWidthChars != -1)
1043  {
1044  long nMaxWidth = m_pImpl->m_nMaxWidthChars * approximate_char_width();
1045  aSz.setWidth( std::min(aSz.Width(), nMaxWidth) );
1046  }
1047 
1048  if (IsDropDownBox())
1050 
1051  ComboBoxBounds aBounds(m_pImpl->calcComboBoxDropDownComponentBounds(
1052  Size(0xFFFF, 0xFFFF), Size(0xFFFF, 0xFFFF)));
1053  aSz.AdjustWidth(aBounds.aSubEditPos.X()*2 );
1054 
1055  aSz.AdjustWidth(ImplGetExtraXOffset() * 2 );
1056 
1057  aSz = CalcWindowSize( aSz );
1058  return aSz;
1059 }
1060 
1061 Size ComboBox::CalcAdjustedSize( const Size& rPrefSize ) const
1062 {
1063  Size aSz = rPrefSize;
1064  sal_Int32 nLeft, nTop, nRight, nBottom;
1065  static_cast<vcl::Window*>(const_cast<ComboBox *>(this))->GetBorder( nLeft, nTop, nRight, nBottom );
1066  aSz.AdjustHeight( -(nTop+nBottom) );
1067  if ( !IsDropDownBox() )
1068  {
1069  long nEntryHeight = CalcBlockSize( 1, 1 ).Height();
1070  long nLines = aSz.Height() / nEntryHeight;
1071  if ( nLines < 1 )
1072  nLines = 1;
1073  aSz.setHeight( nLines * nEntryHeight );
1074  aSz.AdjustHeight(m_pImpl->m_nDDHeight );
1075  }
1076  else
1077  {
1078  aSz.setHeight( m_pImpl->m_nDDHeight );
1079  }
1080  aSz.AdjustHeight(nTop+nBottom );
1081 
1082  aSz = CalcWindowSize( aSz );
1083  return aSz;
1084 }
1085 
1086 Size ComboBox::CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const
1087 {
1088  // show ScrollBars where appropriate
1089  Size aMinSz = CalcMinimumSize();
1090  Size aSz;
1091 
1092  // height
1093  if ( nLines )
1094  {
1095  if ( !IsDropDownBox() )
1096  aSz.setHeight( m_pImpl->m_pImplLB->CalcSize( nLines ).Height() + m_pImpl->m_nDDHeight );
1097  else
1098  aSz.setHeight( m_pImpl->m_nDDHeight );
1099  }
1100  else
1101  aSz.setHeight( aMinSz.Height() );
1102 
1103  // width
1104  if ( nColumns )
1105  aSz.setWidth( nColumns * approximate_char_width() );
1106  else
1107  aSz.setWidth( aMinSz.Width() );
1108 
1109  if ( IsDropDownBox() )
1111 
1112  if ( !IsDropDownBox() )
1113  {
1114  if ( aSz.Width() < aMinSz.Width() )
1115  aSz.AdjustHeight(GetSettings().GetStyleSettings().GetScrollBarSize() );
1116  if ( aSz.Height() < aMinSz.Height() )
1117  aSz.AdjustWidth(GetSettings().GetStyleSettings().GetScrollBarSize() );
1118  }
1119 
1120  aSz.AdjustWidth(ImplGetExtraXOffset() * 2 );
1121 
1122  aSz = CalcWindowSize( aSz );
1123  return aSz;
1124 }
1125 
1127 {
1128  return m_pImpl->m_pImplLB->GetEntryHeight();
1129 }
1130 
1131 void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const
1132 {
1133  long nCharWidth = GetTextWidth(OUString(u'x'));
1134  if ( !IsDropDownBox() )
1135  {
1136  Size aOutSz = m_pImpl->m_pImplLB->GetMainWindow()->GetOutputSizePixel();
1137  rnCols = (nCharWidth > 0) ? static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth) : 1;
1138  rnLines = static_cast<sal_uInt16>(aOutSz.Height()/GetDropDownEntryHeight());
1139  }
1140  else
1141  {
1142  Size aOutSz = m_pImpl->m_pSubEdit->GetOutputSizePixel();
1143  rnCols = (nCharWidth > 0) ? static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth) : 1;
1144  rnLines = 1;
1145  }
1146 }
1147 
1148 void ComboBox::Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags )
1149 {
1150  m_pImpl->m_pImplLB->GetMainWindow()->ApplySettings(*pDev);
1151 
1152  Point aPos = pDev->LogicToPixel( rPos );
1153  Size aSize = GetSizePixel();
1154  vcl::Font aFont = m_pImpl->m_pImplLB->GetMainWindow()->GetDrawPixelFont( pDev );
1155 
1156  pDev->Push();
1157  pDev->SetMapMode();
1158  pDev->SetFont( aFont );
1159  pDev->SetTextFillColor();
1160 
1161  // Border/Background
1162  pDev->SetLineColor();
1163  pDev->SetFillColor();
1164  bool bBorder = (GetStyle() & WB_BORDER);
1165  bool bBackground = IsControlBackground();
1166  if ( bBorder || bBackground )
1167  {
1168  tools::Rectangle aRect( aPos, aSize );
1169  // aRect.Top() += nEditHeight;
1170  if ( bBorder )
1171  {
1172  ImplDrawFrame( pDev, aRect );
1173  }
1174  if ( bBackground )
1175  {
1177  pDev->DrawRect( aRect );
1178  }
1179  }
1180 
1181  // contents
1182  if ( !IsDropDownBox() )
1183  {
1184  long nOnePixel = GetDrawPixel( pDev, 1 );
1185  long nTextHeight = pDev->GetTextHeight();
1186  long nEditHeight = nTextHeight + 6*nOnePixel;
1188 
1189  // First, draw the edit part
1190  Size aOrigSize(m_pImpl->m_pSubEdit->GetSizePixel());
1191  m_pImpl->m_pSubEdit->SetSizePixel(Size(aSize.Width(), nEditHeight));
1192  m_pImpl->m_pSubEdit->Draw( pDev, aPos, nFlags );
1193  m_pImpl->m_pSubEdit->SetSizePixel(aOrigSize);
1194 
1195  // Second, draw the listbox
1196  if ( GetStyle() & WB_CENTER )
1197  nTextStyle |= DrawTextFlags::Center;
1198  else if ( GetStyle() & WB_RIGHT )
1199  nTextStyle |= DrawTextFlags::Right;
1200  else
1201  nTextStyle |= DrawTextFlags::Left;
1202 
1203  if ( nFlags & DrawFlags::Mono )
1204  {
1205  pDev->SetTextColor( COL_BLACK );
1206  }
1207  else
1208  {
1209  if ( !IsEnabled() )
1210  {
1211  const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1212  pDev->SetTextColor( rStyleSettings.GetDisableColor() );
1213  }
1214  else
1215  {
1216  pDev->SetTextColor( GetTextColor() );
1217  }
1218  }
1219 
1220  tools::Rectangle aClip( aPos, aSize );
1221  pDev->IntersectClipRegion( aClip );
1222  sal_Int32 nLines = static_cast<sal_Int32>( nTextHeight > 0 ? (aSize.Height()-nEditHeight)/nTextHeight : 1 );
1223  if ( !nLines )
1224  nLines = 1;
1225  const sal_Int32 nTEntry = IsReallyVisible() ? m_pImpl->m_pImplLB->GetTopEntry() : 0;
1226 
1227  tools::Rectangle aTextRect( aPos, aSize );
1228 
1229  aTextRect.AdjustLeft(3*nOnePixel );
1230  aTextRect.AdjustRight( -(3*nOnePixel) );
1231  aTextRect.AdjustTop(nEditHeight + nOnePixel );
1232  aTextRect.SetBottom( aTextRect.Top() + nTextHeight );
1233 
1234  // the drawing starts here
1235  for ( sal_Int32 n = 0; n < nLines; ++n )
1236  {
1237  pDev->DrawText( aTextRect, m_pImpl->m_pImplLB->GetEntryList()->GetEntryText( n+nTEntry ), nTextStyle );
1238  aTextRect.AdjustTop(nTextHeight );
1239  aTextRect.AdjustBottom(nTextHeight );
1240  }
1241  }
1242 
1243  pDev->Pop();
1244 
1245  // Call Edit::Draw after restoring the MapMode...
1246  if ( IsDropDownBox() )
1247  {
1248  Size aOrigSize(m_pImpl->m_pSubEdit->GetSizePixel());
1249  m_pImpl->m_pSubEdit->SetSizePixel(GetSizePixel());
1250  m_pImpl->m_pSubEdit->Draw( pDev, rPos, nFlags );
1251  m_pImpl->m_pSubEdit->SetSizePixel(aOrigSize);
1252  // DD-Button ?
1253  }
1254 }
1255 
1257 {
1258  m_pImpl->m_pImplLB->SetUserDrawHdl(rLink);
1259 }
1260 
1262 {
1263  m_pImpl->m_pImplLB->GetMainWindow()->SetUserItemSize( rSz );
1264 }
1265 
1266 void ComboBox::EnableUserDraw( bool bUserDraw )
1267 {
1268  m_pImpl->m_pImplLB->GetMainWindow()->EnableUserDraw( bUserDraw );
1269 }
1270 
1272 {
1273  SAL_WARN_IF(rEvt.GetWindow() != m_pImpl->m_pImplLB->GetMainWindow(), "vcl", "DrawEntry?!");
1274  m_pImpl->m_pImplLB->GetMainWindow()->DrawEntry(*rEvt.GetRenderContext(), rEvt.GetItemId(), /*bDrawImage*/false, /*bDrawText*/false);
1275 }
1276 
1277 void ComboBox::AddSeparator( sal_Int32 n )
1278 {
1279  m_pImpl->m_pImplLB->AddSeparator( n );
1280 }
1281 
1282 void ComboBox::SetMRUEntries( const OUString& rEntries )
1283 {
1284  m_pImpl->m_pImplLB->SetMRUEntries( rEntries, ';' );
1285 }
1286 
1287 OUString ComboBox::GetMRUEntries() const
1288 {
1289  return m_pImpl->m_pImplLB ? m_pImpl->m_pImplLB->GetMRUEntries( ';' ) : OUString();
1290 }
1291 
1292 void ComboBox::SetMaxMRUCount( sal_Int32 n )
1293 {
1294  m_pImpl->m_pImplLB->SetMaxMRUCount( n );
1295 }
1296 
1297 sal_Int32 ComboBox::GetMaxMRUCount() const
1298 {
1299  return m_pImpl->m_pImplLB ? m_pImpl->m_pImplLB->GetMaxMRUCount() : 0;
1300 }
1301 
1303 {
1304  return m_pImpl->m_pImplLB ? m_pImpl->m_pImplLB->GetDisplayLineCount() : 0;
1305 }
1306 
1307 void ComboBox::SetEntryData( sal_Int32 nPos, void* pNewData )
1308 {
1309  m_pImpl->m_pImplLB->SetEntryData( nPos + m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(), pNewData );
1310 }
1311 
1312 void* ComboBox::GetEntryData( sal_Int32 nPos ) const
1313 {
1314  return m_pImpl->m_pImplLB->GetEntryList()->GetEntryData(
1315  nPos + m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount() );
1316 }
1317 
1318 sal_Int32 ComboBox::GetTopEntry() const
1319 {
1320  sal_Int32 nPos = GetEntryCount() ? m_pImpl->m_pImplLB->GetTopEntry() : LISTBOX_ENTRY_NOTFOUND;
1321  if (nPos < m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount())
1322  nPos = 0;
1323  return nPos;
1324 }
1325 
1327 {
1328  return m_pImpl->m_pFloatWin
1329  ? m_pImpl->m_pFloatWin->GetWindowExtentsRelative(const_cast<ComboBox*>(this))
1330  : tools::Rectangle();
1331 }
1332 
1334 {
1335  if (!m_pImpl->m_pSubEdit->IsBackground())
1337 
1338  const Wallpaper& rBack = m_pImpl->m_pSubEdit->GetBackground();
1339  if( ! rBack.IsBitmap() &&
1340  ! rBack.IsGradient() &&
1341  rBack == COL_TRANSPARENT
1342  )
1344  return rBack;
1345 }
1346 
1348 {
1349  return m_pImpl->m_pImplLB->GetEntryList()->GetSelectedEntryCount();
1350 }
1351 
1352 sal_Int32 ComboBox::GetSelectedEntryPos( sal_Int32 nIndex ) const
1353 {
1354  sal_Int32 nPos = m_pImpl->m_pImplLB->GetEntryList()->GetSelectedEntryPos( nIndex );
1355  if ( nPos != LISTBOX_ENTRY_NOTFOUND )
1356  {
1357  if (nPos < m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount())
1358  nPos = m_pImpl->m_pImplLB->GetEntryList()->FindEntry(m_pImpl->m_pImplLB->GetEntryList()->GetEntryText(nPos));
1359  nPos = sal::static_int_cast<sal_Int32>(nPos - m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount());
1360  }
1361  return nPos;
1362 }
1363 
1364 bool ComboBox::IsEntryPosSelected( sal_Int32 nPos ) const
1365 {
1366  return m_pImpl->m_pImplLB->GetEntryList()->IsEntryPosSelected(
1367  nPos + m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount() );
1368 }
1369 
1370 void ComboBox::SelectEntryPos( sal_Int32 nPos, bool bSelect)
1371 {
1372  if (nPos < m_pImpl->m_pImplLB->GetEntryList()->GetEntryCount())
1373  m_pImpl->m_pImplLB->SelectEntry(
1374  nPos + m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount(), bSelect);
1375 }
1376 
1378 {
1379  m_pImpl->m_pImplLB->SetNoSelection();
1380  m_pImpl->m_pSubEdit->SetText( OUString() );
1381 }
1382 
1384 {
1385  tools::Rectangle aRect = m_pImpl->m_pImplLB->GetMainWindow()->GetBoundingRectangle( nItem );
1386  tools::Rectangle aOffset = m_pImpl->m_pImplLB->GetMainWindow()->GetWindowExtentsRelative( static_cast<vcl::Window*>(const_cast<ComboBox *>(this)) );
1387  aRect.Move( aOffset.TopLeft().X(), aOffset.TopLeft().Y() );
1388  return aRect;
1389 }
1390 
1392 {
1393  Window::SetBorderStyle( nBorderStyle );
1394  if ( !IsDropDownBox() )
1395  {
1396  m_pImpl->m_pSubEdit->SetBorderStyle( nBorderStyle );
1397  m_pImpl->m_pImplLB->SetBorderStyle( nBorderStyle );
1398  }
1399 }
1400 
1401 long ComboBox::GetIndexForPoint( const Point& rPoint, sal_Int32& rPos ) const
1402 {
1403  if( !HasLayoutData() )
1404  FillLayoutData();
1405 
1406  // check whether rPoint fits at all
1407  long nIndex = Control::GetIndexForPoint( rPoint );
1408  if( nIndex != -1 )
1409  {
1410  // point must be either in main list window
1411  // or in impl window (dropdown case)
1412  ImplListBoxWindow* rMain = m_pImpl->m_pImplLB->GetMainWindow();
1413 
1414  // convert coordinates to ImplListBoxWindow pixel coordinate space
1415  Point aConvPoint = LogicToPixel( rPoint );
1416  aConvPoint = OutputToAbsoluteScreenPixel( aConvPoint );
1417  aConvPoint = rMain->AbsoluteScreenToOutputPixel( aConvPoint );
1418  aConvPoint = rMain->PixelToLogic( aConvPoint );
1419 
1420  // try to find entry
1421  sal_Int32 nEntry = rMain->GetEntryPosForPoint( aConvPoint );
1422  if( nEntry == LISTBOX_ENTRY_NOTFOUND )
1423  nIndex = -1;
1424  else
1425  rPos = nEntry;
1426  }
1427 
1428  // get line relative index
1429  if( nIndex != -1 )
1430  nIndex = ToRelativeLineIndex( nIndex );
1431 
1432  return nIndex;
1433 }
1434 
1436  const Size &rOutSz, const Size &rBorderOutSz) const
1437 {
1438  ComboBoxBounds aBounds;
1439 
1440  long nTop = 0;
1441  long nBottom = rOutSz.Height();
1442 
1443  vcl::Window *pBorder = m_rThis.GetWindow( GetWindowType::Border );
1444  ImplControlValue aControlValue;
1445  Point aPoint;
1446  tools::Rectangle aContent, aBound;
1447 
1448  // use the full extent of the control
1449  tools::Rectangle aArea( aPoint, rBorderOutSz );
1450 
1451  if (m_rThis.GetNativeControlRegion(ControlType::Combobox, ControlPart::ButtonDown,
1452  aArea, ControlState::NONE, aControlValue, aBound, aContent) )
1453  {
1454  // convert back from border space to local coordinates
1455  aPoint = pBorder->ScreenToOutputPixel(m_rThis.OutputToScreenPixel(aPoint));
1456  aContent.Move(-aPoint.X(), -aPoint.Y());
1457 
1458  aBounds.aButtonPos = Point(aContent.Left(), nTop);
1459  aBounds.aButtonSize = Size(aContent.getWidth(), (nBottom-nTop));
1460 
1461  // adjust the size of the edit field
1462  if (m_rThis.GetNativeControlRegion(ControlType::Combobox, ControlPart::SubEdit,
1463  aArea, ControlState::NONE, aControlValue, aBound, aContent) )
1464  {
1465  // convert back from border space to local coordinates
1466  aContent.Move(-aPoint.X(), -aPoint.Y());
1467 
1468  // use the themes drop down size
1469  aBounds.aSubEditPos = aContent.TopLeft();
1470  aBounds.aSubEditSize = aContent.GetSize();
1471  }
1472  else
1473  {
1474  // use the themes drop down size for the button
1475  aBounds.aSubEditSize = Size(rOutSz.Width() - aContent.getWidth(), rOutSz.Height());
1476  }
1477  }
1478  else
1479  {
1480  long nSBWidth = m_rThis.GetSettings().GetStyleSettings().GetScrollBarSize();
1481  nSBWidth = m_rThis.CalcZoom( nSBWidth );
1482  aBounds.aSubEditSize = Size(rOutSz.Width() - nSBWidth, rOutSz.Height());
1483  aBounds.aButtonPos = Point(rOutSz.Width() - nSBWidth, nTop);
1484  aBounds.aButtonSize = Size(nSBWidth, (nBottom-nTop));
1485  }
1486  return aBounds;
1487 }
1488 
1489 void ComboBox::SetWidthInChars(sal_Int32 nWidthInChars)
1490 {
1491  if (nWidthInChars != m_pImpl->m_nWidthInChars)
1492  {
1493  m_pImpl->m_nWidthInChars = nWidthInChars;
1494  queue_resize();
1495  }
1496 }
1497 
1498 void ComboBox::setMaxWidthChars(sal_Int32 nWidth)
1499 {
1500  if (nWidth != m_pImpl->m_nMaxWidthChars)
1501  {
1502  m_pImpl->m_nMaxWidthChars = nWidth;
1503  queue_resize();
1504  }
1505 }
1506 
1507 bool ComboBox::set_property(const OString &rKey, const OUString &rValue)
1508 {
1509  if (rKey == "width-chars")
1510  SetWidthInChars(rValue.toInt32());
1511  else if (rKey == "max-width-chars")
1512  setMaxWidthChars(rValue.toInt32());
1513  else if (rKey == "can-focus")
1514  {
1515  // as far as I can see in Gtk, setting a ComboBox as can.focus means
1516  // the focus gets stuck in it, so try here to behave like gtk does
1517  // with the settings that work, i.e. can.focus of false doesn't
1518  // set the hard WB_NOTABSTOP
1519  WinBits nBits = GetStyle();
1520  nBits &= ~(WB_TABSTOP|WB_NOTABSTOP);
1521  if (toBool(rValue))
1522  nBits |= WB_TABSTOP;
1523  SetStyle(nBits);
1524  }
1525  else if (rKey == "placeholder-text")
1526  SetPlaceholderText(rValue);
1527  else
1528  return Control::set_property(rKey, rValue);
1529  return true;
1530 }
1531 
1533 {
1534  return ComboBoxUIObject::create;
1535 }
1536 
1537 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 GetEntryPos(const OUString &rStr) const
Definition: combobox.cxx:943
OString stripEnd(const OString &rIn, char c)
Point TopLeft() const
long Width() const
const Color & GetTextColor() const
Definition: outdev.hxx:1127
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:787
virtual FactoryFunction GetUITestFactory() const override
Definition: combobox.cxx:1532
bool IsControlBackground() const
Definition: window2.cxx:1087
virtual const Wallpaper & GetDisplayBackground() const
Definition: window.cxx:3097
SAL_DLLPRIVATE float approximate_char_width() const
Definition: text.cxx:908
void SetUserDrawHdl(const Link< UserDrawEvent *, void > &rLink)
Definition: combobox.cxx:1256
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
Definition: ctrl.cxx:305
Size CalcBlockSize(sal_uInt16 nColumns, sal_uInt16 nLines) const
Definition: combobox.cxx:1086
sal_Int32 nIndex
bool IsSyntheticModify() const
Definition: combobox.cxx:444
long GetHeight() const
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
SAL_DLLPRIVATE void ImplCalcEditHeight()
Definition: combobox.cxx:152
long ToRelativeLineIndex(long nIndex) const
ToRelativeLineIndex changes a layout data index to a count relative to its line.
Definition: ctrl.cxx:211
static void lcl_GetSelectedEntries(::std::set< sal_Int32 > &rSelectedPos, const OUString &rText, sal_Unicode cTokenSep, const ImplEntryList *pEntryList)
Definition: combobox.cxx:95
Link< ComboBox &, void > m_SelectHdl
Definition: combobox.cxx:64
tools::Rectangle GetBoundingRectangle(sal_Int32 nItem) const
Definition: combobox.cxx:1383
long AdjustWidth(long n)
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
bool IsAutoSizeEnabled() const
Definition: combobox.cxx:511
const CommandEvent * GetCommandEvent() const
Definition: event.hxx:327
virtual void StateChanged(StateChangedType nType) override
Definition: combobox.cxx:627
bool m_isSyntheticModify
Definition: combobox.cxx:59
sal_uInt16 m_nDDHeight
Definition: combobox.cxx:56
long Height() const
SAL_DLLPRIVATE void ImplDrawFrame(OutputDevice *pDev, tools::Rectangle &rRect)
draws a frame around the give rectangle, onto the given device
Definition: ctrl.cxx:336
void ImplUpdateFloatSelection()
Definition: combobox.cxx:826
WinBits const WB_NOGROUP
long getWidth() const
virtual Size CalcMinimumSizeForText(const OUString &rString) const
Definition: edit.cxx:2617
long AdjustLeft(long nHorzMoveDelta)
Point AbsoluteScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2909
sal_Int32 m_nWidthInChars
Definition: combobox.cxx:63
OUString GetMRUEntries() const
Definition: combobox.cxx:1287
void disposeAndClear()
Definition: vclptr.hxx:200
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: combobox.cxx:176
const StyleSettings & GetStyleSettings() const
sal_Int64 n
void ToggleDropDown()
Definition: combobox.cxx:479
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual Size GetSizePixel() const
Definition: window.cxx:2396
WinBits const WB_RIGHT
sal_Int32 GetEntryPosForPoint(const Point &rPoint) const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: edit.cxx:216
void SetMaxMRUCount(sal_Int32 n)
Definition: combobox.cxx:1292
void SetTextFillColor()
Definition: text.cxx:700
sal_uInt16 GetCode() const
Definition: keycod.hxx:53
PosSizeFlags
Definition: window.hxx:140
DataChangedEventType GetType() const
Definition: event.hxx:357
const KeyEvent * GetKeyEvent() const
Definition: event.hxx:311
void IntersectClipRegion(const tools::Rectangle &rRect)
struct SAL_DLLPRIVATE Impl
Definition: combobox.hxx:41
void SetPlaceholderText(const OUString &rStr)
Definition: edit.cxx:2574
void AppendLayoutData(const Control &rSubControl) const
Definition: ctrl.cxx:273
bool IsTravelSelect() const
Definition: combobox.cxx:967
const Color & GetControlBackground() const
Definition: window2.cxx:1082
void Select()
Definition: combobox.cxx:501
Impl(ComboBox &rThis)
Definition: combobox.cxx:66
SAL_DLLPRIVATE long getMaxWidthScrollBarAndDownButton() const
Definition: combobox.cxx:998
long AdjustHeight(long n)
sal_Int32 FindEntry(const OUString &rStr, bool bSearchMRUArea=false) const
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3034
VclPtr< ImplListBoxFloatingWindow > m_pFloatWin
Definition: combobox.cxx:55
sal_Int32 GetMaxMRUCount() const
Definition: combobox.cxx:1297
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
void SetMapMode()
Definition: map.cxx:655
void SetBorderStyle(WindowBorderStyle nBorderStyle)
Definition: combobox.cxx:1391
constexpr sal_uInt16 KEY_UP
Definition: keycodes.hxx:111
#define LISTBOX_ENTRY_NOTFOUND
Definition: lstbox.hxx:38
long AdjustBottom(long nVertMoveDelta)
VclPtr< ImplListBox > m_pImplLB
Definition: combobox.cxx:53
void Move(long nHorzMoveDelta, long nVertMoveDelta)
DECL_LINK(ImplSelectHdl, LinkParamNone *, void)
void SetEntryData(sal_Int32 nPos, void *pNewData)
Definition: combobox.cxx:1307
VclPtr< ImplBtn > m_pBtn
Definition: combobox.cxx:54
const Fraction & GetZoom() const
Definition: window2.cxx:1210
StateChangedType
Definition: window.hxx:310
OUString GetEntry(sal_Int32 nPos) const
Definition: combobox.cxx:951
virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2713
sal_uInt16 GetDisplayLineCount() const
Definition: combobox.cxx:1302
sal_Int64 WinBits
sal_uInt16 sal_Unicode
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
vcl::Window * GetWindow() const
Definition: event.hxx:304
void SetBackground()
bool IsEntryPosSelected(sal_Int32 nPos) const
Definition: combobox.cxx:1364
ESelection aNewSelection(GetSelection())
bool IsMultiSelectionEnabled() const
Definition: combobox.cxx:979
void EnableUserDraw(bool bUserDraw)
Definition: combobox.cxx:1266
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: combobox.cxx:122
Image GetEntryImage(sal_Int32 nPos) const
Definition: combobox.cxx:936
void Clear()
Definition: combobox.cxx:928
void SetSelectHdl(const Link< ComboBox &, void > &rLink)
Definition: combobox.cxx:984
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_Unicode m_cMultiSep
Definition: combobox.cxx:57
sal_uInt16 GetDropDownLineCount() const
Definition: combobox.cxx:546
std::unique_ptr< Impl > m_pImpl
Definition: combobox.hxx:42
AllSettingsFlags GetFlags() const
Definition: event.hxx:358
constexpr sal_uInt16 KEY_PAGEUP
Definition: keycodes.hxx:116
bool IsInDropDown() const
Definition: combobox.cxx:972
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1314
void SetCompoundControl(bool bCompound)
Definition: window2.cxx:947
long Top() const
Definition: edit.hxx:56
ComboBox(vcl::Window *pParent, WinBits nStyle=0)
Definition: combobox.cxx:108
void AdaptDropDownLineCountToMaximum()
Definition: combobox.cxx:536
virtual void SetSelection(const Selection &rSelection)
Definition: edit.cxx:2392
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
Definition: combobox.cxx:1148
void SetWidthInChars(sal_Int32 nWidthInChars)
Definition: combobox.cxx:1489
const Color & GetControlForeground() const
Definition: window2.cxx:1072
long GetDrawPixel(::OutputDevice const *pDev, long nPixels) const
Definition: window2.cxx:563
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: combobox.cxx:252
long GetIndexForPoint(const Point &rPoint, sal_Int32 &rPos) const
Definition: combobox.cxx:1401
void SetUserItemSize(const Size &rSz)
Definition: combobox.cxx:1261
constexpr sal_uInt16 KEY_DOWN
Definition: keycodes.hxx:110
virtual Size GetOptimalSize() const override
Definition: combobox.cxx:993
WinBits const WB_NOLIGHTBORDER
Size CalcWindowSize(const Size &rOutSz) const
Definition: window2.cxx:537
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: combobox.cxx:691
void SetLineColor()
virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags=PosSizeFlags::All) override
Definition: combobox.cxx:554
bool IsDropDownBox() const
Definition: combobox.cxx:603
const Color & GetDisableColor() const
bool IsRTLEnabled() const
Definition: outdev.hxx:1358
vcl::RenderContext * GetRenderContext() const
Definition: event.hxx:243
void SetEntryActivateHdl(const Link< Edit &, bool > &rLink)
Definition: combobox.cxx:986
DrawFlags
Definition: window.hxx:353
void setMaxWidthChars(sal_Int32 nWidth)
Definition: combobox.cxx:1498
The edit field part of a control, e.g.
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: combobox.cxx:713
virtual void StateChanged(StateChangedType nType) override
Definition: edit.cxx:2152
float approximate_digit_width() const
Definition: text.cxx:916
WinBits const WB_SIMPLEMODE
SAL_DLLPRIVATE long ImplGetExtraXOffset() const
Definition: edit.cxx:396
void SetNoSelection()
Definition: combobox.cxx:1377
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1162
virtual OUString GetText() const override
Definition: edit.cxx:2562
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: ctrl.cxx:297
bool IsUpdateMode() const
Definition: window2.cxx:1173
void SetFillColor()
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
CommandEventId GetCommand() const
virtual void Modify()
Definition: edit.cxx:2312
sal_Int32 GetSelectedEntryPos(sal_Int32 nSelIndex=0) const
Definition: combobox.cxx:1352
float u
void SetTextColor(const Color &rColor)
Definition: text.cxx:665
constexpr sal_uInt16 KEY_PAGEDOWN
Definition: keycodes.hxx:117
WinBits const WB_RECTSTYLE
void RemoveEntryAt(sal_Int32 nPos)
Definition: combobox.cxx:920
bool bPopup
MouseNotifyEvent GetType() const
Definition: event.hxx:303
IMPL_LINK_NOARG(ComboBox::Impl, ImplClickBtnHdl, void *, void)
Definition: combobox.cxx:276
void SetSubEdit(Edit *pEdit)
Definition: edit.cxx:2602
WinBits const WB_DROPDOWN
virtual ~ComboBox() override
Definition: combobox.cxx:117
static bool toBool(const OString &rValue)
Definition: builder.cxx:77
const AllSettings & GetSettings() const
Definition: outdev.hxx:418
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
DrawTextFlags
Definition: outdev.hxx:142
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1431
WinBits const WB_SORT
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2856
long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:895
WinBits const WB_LEFT
IMPL_LINK(ComboBox::Impl, ImplAutocompleteHdl, Edit &, rEdit, void)
Definition: combobox.cxx:317
void SetStyle(WinBits nStyle)
Definition: window.cxx:1957
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
Definition: window.cxx:2899
Size GetSize() const
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
WinBits const WB_NOBORDER
sal_uInt16 GetItemId() const
Definition: event.hxx:245
ComboBox & m_rThis
Definition: combobox.cxx:51
void EnableAutocomplete(bool bEnable, bool bMatchCase=false)
Definition: combobox.cxx:261
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1046
void GetMaxVisColumnsAndLines(sal_uInt16 &rnCols, sal_uInt16 &rnLines) const
Definition: combobox.cxx:1131
Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1187
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:942
void ImplInitComboBoxData()
Definition: combobox.cxx:135
tools::Rectangle GetDropDownPosSizePixel() const
Definition: combobox.cxx:1326
long GetDropDownEntryHeight() const
Definition: combobox.cxx:1126
long GetIndexForPoint(const Point &rPoint) const
Definition: ctrl.cxx:134
virtual const Wallpaper & GetDisplayBackground() const override
Definition: combobox.cxx:1333
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: window.cxx:2418
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:54
bool IsGradient() const
Definition: wall.cxx:283
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: combobox.cxx:1507
virtual void Resize() override
Definition: ctrl.cxx:74
weld::Entry & rEdit
long AdjustRight(long nHorzMoveDelta)
VclPtr< Edit > m_pSubEdit
Definition: combobox.cxx:52
WindowType
sal_Int32 GetEntryCount() const
Definition: combobox.cxx:960
#define SAL_WARN_IF(condition, area, stream)
WinBits const WB_BORDER
bool m_isKeyBoardModify
Definition: combobox.cxx:60
void SetFont(const vcl::Font &rNewFont)
bool m_isMatchCase
Definition: combobox.cxx:61
std::unique_ptr< vcl::ImplControlData > mpControlData
Definition: ctrl.hxx:36
bool IsAutocompleteEnabled() const
Definition: combobox.cxx:271
#define COMBOBOX_MAX_ENTRIES
Definition: combobox.hxx:33
sal_Int32 GetTopEntry() const
Definition: combobox.cxx:1318
OString strip(const OString &rIn, char c)
bool m_isDDAutoSize
Definition: combobox.cxx:58
Definition: image.hxx:40
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
void SetBottom(long v)
Size CalcAdjustedSize(const Size &rPrefSize) const
Definition: combobox.cxx:1061
long AdjustTop(long nVertMoveDelta)
bool IsModifyByKeyboard() const
Definition: combobox.cxx:449
WinBits const WB_AUTOHSCROLL
long Left() const
sal_Int32 GetSelectedEntryCount() const
Definition: combobox.cxx:1347
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:884
WinBits const WB_TABSTOP
void * GetEntryData(sal_Int32 nPos) const
Definition: combobox.cxx:1312
virtual void FillLayoutData() const override
Definition: combobox.cxx:605
void DoubleClick()
Definition: combobox.cxx:506
bool IsBitmap() const
Definition: wall.cxx:255
void DrawEntry(const UserDrawEvent &rEvt)
Definition: combobox.cxx:1271
A widget used to choose from a list of items and which has an entry.
Definition: combobox.hxx:38
sal_Int32 m_nMaxWidthChars
Definition: combobox.cxx:62
Event to pass information for UserDraw() handling eg. in comboboxes.
Definition: event.hxx:218
WinBits const WB_CENTER
#define SELECTION_MAX
bool IsEnabled() const
Definition: window2.cxx:1122
void SetDropDownLineCount(sal_uInt16 nLines)
Definition: combobox.cxx:530
sal_Int32 InsertEntryWithImage(const OUString &rStr, const Image &rImage, sal_Int32 nPos=COMBOBOX_APPEND)
Definition: combobox.cxx:899
MouseWheelBehaviour
Definition: settings.hxx:80
WinBits GetStyle() const
Definition: window2.cxx:953
long Max() const
WindowBorderStyle
Definition: vclenum.hxx:108
WinBits const WB_GROUP
void SelectEntryPos(sal_Int32 nPos, bool bSelect=true)
Definition: combobox.cxx:1370
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=COMBOBOX_APPEND)
Definition: combobox.cxx:879
virtual bool IsReadOnly() const
Definition: edit.hxx:180
void ImplInitDropDownButton(PushButton *pButton)
Definition: imp_listbox.cxx:52
virtual void SetText(const OUString &rStr) override
Definition: edit.cxx:2543
void SetMRUEntries(const OUString &rEntries)
Definition: combobox.cxx:1282
long GetScrollBarSize() const
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
bool IsReallyVisible() const
Definition: window2.cxx:1107
vcl::Font GetControlFont() const
Definition: window2.cxx:438
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:60
virtual void SetText(const OUString &rStr) override
Definition: combobox.cxx:802
void setWidth(long nWidth)
void AddSeparator(sal_Int32 n)
Adds a new separator at the given position n.
Definition: combobox.cxx:1277
vcl::Window * GetWindow() const
Definition: event.hxx:242
WinBits const WB_NOTABSTOP
Size CalcMinimumSize() const override
Definition: combobox.cxx:1020
void EnableAutoSize(bool bAuto)
Definition: combobox.cxx:513
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: edit.cxx:299
bool HasLayoutData() const
determines whether we currently have layout data
Definition: ctrl.cxx:90
virtual void Resize() override
Definition: combobox.cxx:573
sal_uInt16 nPos
ComboBoxBounds calcComboBoxDropDownComponentBounds(const Size &rOutSize, const Size &rBorderOutSize) const
Definition: combobox.cxx:1435
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35
#define COMBOBOX_APPEND
Definition: combobox.hxx:31
virtual void Modify() override
Definition: combobox.cxx:818
void SetLayoutDataParent(const Control *pParent) const
Definition: ctrl.cxx:324
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: ctrl.cxx:225
bool IsMod2() const
Definition: keycod.hxx:62
void setHeight(long nHeight)