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