LibreOffice Module vcl (master) 1
listbox.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <vcl/builder.hxx>
21#include <vcl/commandevent.hxx>
22#include <vcl/event.hxx>
24#include <vcl/settings.hxx>
26#include <sal/log.hxx>
27
28#include <svdata.hxx>
29#include <listbox.hxx>
31#include <comphelper/lok.hxx>
32
33#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
34#include <boost/property_tree/ptree.hpp>
35#include <tools/json_writer.hxx>
36
38 : Control(nType)
39 , mpImplLB(nullptr)
40{
42}
43
45{
47 ImplInit( pParent, nStyle );
48}
49
51{
53}
54
56{
58
63
65}
66
68{
69 mpFloatWin = nullptr;
70 mpImplWin = nullptr;
71 mpBtn = nullptr;
72 mnDDHeight = 0;
73 mnLineCount = 0;
75 mbDDAutoSize = true;
76}
77
78void ListBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
79{
80 nStyle = ImplInitStyle( nStyle );
81 if ( !(nStyle & WB_NOBORDER) && ( nStyle & WB_DROPDOWN ) )
82 nStyle |= WB_BORDER;
83
84 Control::ImplInit( pParent, nStyle, nullptr );
85
86 css::uno::Reference< css::datatransfer::dnd::XDropTargetListener> xDrop = new DNDEventDispatcher(this);
87
88 if( nStyle & WB_DROPDOWN )
89 {
90 sal_Int32 nLeft, nTop, nRight, nBottom;
91 GetBorder( nLeft, nTop, nRight, nBottom );
92 mnDDHeight = static_cast<sal_uInt16>(GetTextHeight() + nTop + nBottom + 4);
93
96 {
97 ImplControlValue aControlValue;
98 tools::Rectangle aCtrlRegion( Point( 0, 0 ), Size( 20, mnDDHeight ) );
99 tools::Rectangle aBoundingRgn( aCtrlRegion );
100 tools::Rectangle aContentRgn( aCtrlRegion );
102 ControlState::ENABLED, aControlValue,
103 aBoundingRgn, aContentRgn ) )
104 {
105 sal_Int32 nHeight = aBoundingRgn.GetHeight();
106 if( nHeight > mnDDHeight )
107 mnDDHeight = static_cast<sal_uInt16>(nHeight);
108 }
109 }
110
114 mpFloatWin->SetAutoWidth( true );
115 mpFloatWin->SetPopupModeEndHdl( LINK( this, ListBox, ImplPopupModeEndHdl ) );
116 mpFloatWin->GetDropTarget()->addDropTargetListener(xDrop);
117
119 mpImplWin->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) );
120 mpImplWin->Show();
121 mpImplWin->GetDropTarget()->addDropTargetListener(xDrop);
123
126 mpBtn->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) );
127 mpBtn->Show();
128 mpBtn->GetDropTarget()->addDropTargetListener(xDrop);
129 }
130
131 vcl::Window* pLBParent = this;
132 if ( mpFloatWin )
133 pLBParent = mpFloatWin;
134 mpImplLB = VclPtr<ImplListBox>::Create( pLBParent, nStyle&(~WB_BORDER) );
135 mpImplLB->SetSelectHdl( LINK( this, ListBox, ImplSelectHdl ) );
136 mpImplLB->SetScrollHdl( LINK( this, ListBox, ImplScrollHdl ) );
137 mpImplLB->SetCancelHdl( LINK( this, ListBox, ImplCancelHdl ) );
138 mpImplLB->SetDoubleClickHdl( LINK( this, ListBox, ImplDoubleClickHdl ) );
139 mpImplLB->SetFocusHdl( LINK( this, ListBox, ImplFocusHdl ) );
140 mpImplLB->SetListItemSelectHdl( LINK( this, ListBox, ImplListItemSelectHdl ) );
143 mpImplLB->Show();
144
145 mpImplLB->GetDropTarget()->addDropTargetListener(xDrop);
146
147 if ( mpFloatWin )
148 {
150 mpImplLB->SetSelectionChangedHdl( LINK( this, ListBox, ImplSelectionChangedHdl ) );
151 }
152 else
154
155 SetCompoundControl( true );
156}
157
159{
160 if ( !(nStyle & WB_NOTABSTOP) )
161 nStyle |= WB_TABSTOP;
162 if ( !(nStyle & WB_NOGROUP) )
163 nStyle |= WB_GROUP;
164 return nStyle;
165}
166
167IMPL_LINK_NOARG(ListBox, ImplSelectHdl, LinkParamNone*, void)
168{
169 bool bPopup = IsInDropDown();
170 if( IsDropDownBox() )
171 {
172 if( !mpImplLB->IsTravelSelect() )
173 {
174 mpFloatWin->EndPopupMode();
175 mpImplWin->GrabFocus();
176 }
177
178 mpImplWin->SetItemPos( GetSelectedEntryPos() );
179 mpImplWin->SetString( GetSelectedEntry() );
180 if( mpImplLB->GetEntryList().HasImages() )
181 {
182 Image aImage = mpImplLB->GetEntryList().GetEntryImage( GetSelectedEntryPos() );
183 mpImplWin->SetImage( aImage );
184 }
185 mpImplWin->Invalidate();
186 }
187
188 if ( ( !IsTravelSelect() || mpImplLB->IsSelectionChanged() ) || ( bPopup && !IsMultiSelectionEnabled() ) )
189 Select();
190}
191
192IMPL_LINK( ListBox, ImplFocusHdl, sal_Int32, nPos, void )
193{
194 CallEventListeners( VclEventId::ListboxFocus, reinterpret_cast<void*>(nPos) );
195}
196
197IMPL_LINK_NOARG( ListBox, ImplListItemSelectHdl, LinkParamNone*, void )
198{
199 CallEventListeners( VclEventId::DropdownSelect );
200}
201
202IMPL_LINK_NOARG(ListBox, ImplScrollHdl, ImplListBox*, void)
203{
204 CallEventListeners( VclEventId::ListboxScrolled );
205}
206
207IMPL_LINK_NOARG(ListBox, ImplCancelHdl, LinkParamNone*, void)
208{
209 if( IsInDropDown() )
210 mpFloatWin->EndPopupMode();
211}
212
213IMPL_LINK( ListBox, ImplSelectionChangedHdl, sal_Int32, nChanged, void )
214{
215 if ( mpImplLB->IsTrackingSelect() )
216 return;
217
218 const ImplEntryList& rEntryList = mpImplLB->GetEntryList();
219 if ( rEntryList.IsEntryPosSelected( nChanged ) )
220 {
221 // FIXME? This should've been turned into an ImplPaintEntry some time ago...
222 if ( nChanged < rEntryList.GetMRUCount() )
223 nChanged = rEntryList.FindEntry( rEntryList.GetEntryText( nChanged ) );
224 mpImplWin->SetItemPos( nChanged );
225 mpImplWin->SetString( rEntryList.GetEntryText( nChanged ) );
226 if( rEntryList.HasImages() )
227 {
228 Image aImage = rEntryList.GetEntryImage( nChanged );
229 mpImplWin->SetImage( aImage );
230 }
231 }
232 else
233 {
234 mpImplWin->SetItemPos( LISTBOX_ENTRY_NOTFOUND );
235 mpImplWin->SetString( OUString() );
236 Image aImage;
237 mpImplWin->SetImage( aImage );
238 }
239 mpImplWin->Invalidate();
240}
241
242IMPL_LINK_NOARG(ListBox, ImplDoubleClickHdl, ImplListBoxWindow*, void)
243{
244 DoubleClick();
245}
246
247IMPL_LINK_NOARG(ListBox, ImplClickBtnHdl, void*, void)
248{
249 if( mpFloatWin->IsInPopupMode() )
250 return;
251
252 CallEventListeners( VclEventId::DropdownPreOpen );
253 mpImplWin->GrabFocus();
254 mpBtn->SetPressed( true );
255 mpFloatWin->StartFloat( true );
256 CallEventListeners( VclEventId::DropdownOpen );
257
258 ImplClearLayoutData();
259 if( mpImplLB )
260 mpImplLB->GetMainWindow()->ImplClearLayoutData();
261 if( mpImplWin )
262 mpImplWin->ImplClearLayoutData();
263}
264
265IMPL_LINK_NOARG(ListBox, ImplPopupModeEndHdl, FloatingWindow*, void)
266{
267 if( mpFloatWin->IsPopupModeCanceled() )
268 {
269 if ( ( mpFloatWin->GetPopupModeStartSaveSelection() != LISTBOX_ENTRY_NOTFOUND )
270 && !IsEntryPosSelected( mpFloatWin->GetPopupModeStartSaveSelection() ) )
271 {
272 mpImplLB->SelectEntry( mpFloatWin->GetPopupModeStartSaveSelection(), true );
273 bool bTravelSelect = mpImplLB->IsTravelSelect();
274 mpImplLB->SetTravelSelect( true );
275
276 VclPtr<vcl::Window> xWindow = this;
277 Select();
278 if ( xWindow->isDisposed() )
279 return;
280
281 mpImplLB->SetTravelSelect( bTravelSelect );
282 }
283 }
284
285 ImplClearLayoutData();
286 if( mpImplLB )
287 mpImplLB->GetMainWindow()->ImplClearLayoutData();
288 if( mpImplWin )
289 mpImplWin->ImplClearLayoutData();
290
291 mpBtn->SetPressed( false );
292 CallEventListeners( VclEventId::DropdownClose );
293}
294
296{
297 if( !IsDropDownBox() )
298 return;
299
302 else
303 {
306 mpBtn->SetPressed( true );
307 mpFloatWin->StartFloat( true );
309 }
310}
311
313{
314 rRenderContext.SetBackground();
315}
316
317void ListBox::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags )
318{
320
321 Point aPos = pDev->LogicToPixel( rPos );
322 Size aSize = GetSizePixel();
324
325 pDev->Push();
326 pDev->SetMapMode();
327 pDev->SetFont( aFont );
328 pDev->SetTextFillColor();
329
330 // Border/Background
331 pDev->SetLineColor();
332 pDev->SetFillColor();
333 bool bBorder = (GetStyle() & WB_BORDER);
334 bool bBackground = IsControlBackground();
335 if ( bBorder || bBackground )
336 {
337 tools::Rectangle aRect( aPos, aSize );
338 if ( bBorder )
339 {
340 ImplDrawFrame( pDev, aRect );
341 }
342 if ( bBackground )
343 {
345 pDev->DrawRect( aRect );
346 }
347 }
348
349 // Content
350 if ( nFlags & SystemTextColorFlags::Mono )
351 {
352 pDev->SetTextColor( COL_BLACK );
353 }
354 else
355 {
356 if ( !IsEnabled() )
357 {
358 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
359 pDev->SetTextColor( rStyleSettings.GetDisableColor() );
360 }
361 else
362 {
363 pDev->SetTextColor( GetTextColor() );
364 }
365 }
366
367 const tools::Long nOnePixel = GetDrawPixel( pDev, 1 );
368 const tools::Long nOffX = 3*nOnePixel;
370 tools::Rectangle aTextRect( aPos, aSize );
371
372 if ( GetStyle() & WB_CENTER )
373 nTextStyle |= DrawTextFlags::Center;
374 else if ( GetStyle() & WB_RIGHT )
375 nTextStyle |= DrawTextFlags::Right;
376 else
377 nTextStyle |= DrawTextFlags::Left;
378
379 aTextRect.AdjustLeft(nOffX );
380 aTextRect.AdjustRight( -nOffX );
381
382 if ( IsDropDownBox() )
383 {
384 OUString aText = GetSelectedEntry();
385 tools::Long nTextHeight = pDev->GetTextHeight();
386 tools::Long nTextWidth = pDev->GetTextWidth( aText );
387 tools::Long nOffY = (aSize.Height()-nTextHeight) / 2;
388
389 // Clipping?
390 if ( (nOffY < 0) ||
391 ((nOffY+nTextHeight) > aSize.Height()) ||
392 ((nOffX+nTextWidth) > aSize.Width()) )
393 {
394 tools::Rectangle aClip( aPos, aSize );
395 if ( nTextHeight > aSize.Height() )
396 aClip.AdjustBottom(nTextHeight-aSize.Height()+1 ); // So that HP Printers don't optimize this away
397 pDev->IntersectClipRegion( aClip );
398 }
399
400 pDev->DrawText( aTextRect, aText, nTextStyle );
401 }
402 else
403 {
404 tools::Long nTextHeight = pDev->GetTextHeight();
405 sal_uInt16 nLines = ( nTextHeight > 0 ) ? static_cast<sal_uInt16>(aSize.Height() / nTextHeight) : 1;
406 tools::Rectangle aClip( aPos, aSize );
407
408 pDev->IntersectClipRegion( aClip );
409
410 if ( !nLines )
411 nLines = 1;
412
413 for ( sal_uInt16 n = 0; n < nLines; n++ )
414 {
415 sal_Int32 nEntry = n+mpImplLB->GetTopEntry();
416 bool bSelected = mpImplLB->GetEntryList().IsEntryPosSelected( nEntry );
417 if ( bSelected )
418 {
419 pDev->SetFillColor( COL_BLACK );
420 pDev->DrawRect( tools::Rectangle( Point( aPos.X(), aPos.Y() + n*nTextHeight ),
421 Point( aPos.X() + aSize.Width(), aPos.Y() + (n+1)*nTextHeight + 2*nOnePixel ) ) );
422 pDev->SetFillColor();
423 pDev->SetTextColor( COL_WHITE );
424 }
425
426 aTextRect.SetTop( aPos.Y() + n*nTextHeight );
427 aTextRect.SetBottom( aTextRect.Top() + nTextHeight );
428
429 pDev->DrawText( aTextRect, mpImplLB->GetEntryList().GetEntryText( nEntry ), nTextStyle );
430
431 if ( bSelected )
432 pDev->SetTextColor( COL_BLACK );
433 }
434 }
435
436 pDev->Pop();
437}
438
440{
441 if ( mpImplLB )
442 {
443 if( IsDropDownBox() )
445 else
447 }
448
450}
451
453{
454 if( IsDropDownBox() )
455 {
456 if (mpImplWin)
458 }
459 else
460 {
461 if (mpImplLB)
463 }
464
466}
467
469{
470 Control::DataChanged( rDCEvt );
471
472 if ( !((rDCEvt.GetType() == DataChangedEventType::FONTS) ||
475 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))) )
476 return;
477
478 SetBackground(); // Due to a hack in Window::UpdateSettings the background must be reset
479 // otherwise it will overpaint NWF drawn listboxes
480 Resize();
481 mpImplLB->Resize(); // Is not called by ListBox::Resize() if the ImplLB does not change
482
483 if ( mpImplWin )
484 {
485 mpImplWin->GetOutDev()->SetSettings( GetSettings() ); // If not yet set...
487
490 }
491
492 if ( IsDropDownBox() )
493 Invalidate();
494}
495
496void ListBox::EnableAutoSize( bool bAuto )
497{
498 mbDDAutoSize = bAuto;
499 if ( mpFloatWin )
500 {
501 if ( bAuto && !mpFloatWin->GetDropDownLineCount() )
502 {
503 // use GetListBoxMaximumLineCount here; before, was on fixed number of five
505 }
506 else if ( !bAuto )
507 {
509 }
510 }
511}
512
513void ListBox::SetDropDownLineCount( sal_uInt16 nLines )
514{
515 mnLineCount = nLines;
516 if ( mpFloatWin )
518}
519
521{
522 // Adapt to maximum allowed number.
523 // Limit for LOK as we can't render outside of the dialog canvas.
526 else
527 SetDropDownLineCount(GetSettings().GetStyleSettings().GetListBoxMaximumLineCount());
528}
529
531{
532 if ( mpFloatWin )
534 return mnLineCount;
535}
536
538{
539 if( IsDropDownBox() && ( nFlags & PosSizeFlags::Size ) )
540 {
541 Size aPrefSz = mpFloatWin->GetPrefSize();
542 if ( ( nFlags & PosSizeFlags::Height ) && ( nHeight >= 2*mnDDHeight ) )
543 aPrefSz.setHeight( nHeight-mnDDHeight );
544 if ( nFlags & PosSizeFlags::Width )
545 aPrefSz.setWidth( nWidth );
546 mpFloatWin->SetPrefSize( aPrefSz );
547
548 if (IsAutoSizeEnabled())
549 nHeight = mnDDHeight;
550 }
551
552 Control::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
553}
554
556{
557 Size aOutSz = GetOutputSizePixel();
558 if( IsDropDownBox() )
559 {
560 // Initialize the dropdown button size with the standard scrollbar width
562 tools::Long nBottom = aOutSz.Height();
563
564 // Note: in case of no border, pBorder will actually be this
566 ImplControlValue aControlValue;
567 Point aPoint;
568 tools::Rectangle aContent, aBound;
569
570 // Use the full extent of the control
571 tools::Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() );
572
574 aArea, ControlState::NONE, aControlValue, aBound, aContent) )
575 {
576 // Convert back from border space to local coordinates
577 aPoint = pBorder->ScreenToOutputPixel( OutputToScreenPixel( aPoint ) );
578 aContent.Move( -aPoint.X(), -aPoint.Y() );
579
580 // Use the themes drop down size for the button
581 aOutSz.setWidth( aContent.Left() );
582 mpBtn->setPosSizePixel( aContent.Left(), 0, aContent.GetWidth(), nBottom );
583
584 // Adjust the size of the edit field
586 aArea, ControlState::NONE, aControlValue, aBound, aContent) )
587 {
588 // Convert back from border space to local coordinates
589 aContent.Move( -aPoint.X(), -aPoint.Y() );
590
591 // Use the themes drop down size
592 if( ! (GetStyle() & WB_BORDER) && ImplGetSVData()->maNWFData.mbNoFocusRects )
593 {
594 // No border but focus ring behavior -> we have a problem; the
595 // native rect relies on the border to draw the focus
596 // let's do the best we can and center vertically, so it doesn't look
597 // completely wrong.
598 Size aSz( GetOutputSizePixel() );
599 tools::Long nDiff = aContent.Top() - (aSz.Height() - aContent.GetHeight())/2;
600 aContent.AdjustTop( -nDiff );
601 aContent.AdjustBottom( -nDiff );
602 }
603 mpImplWin->SetPosSizePixel( aContent.TopLeft(), aContent.GetSize() );
604 }
605 else
606 mpImplWin->SetSizePixel( aOutSz );
607 }
608 else
609 {
610 nSBWidth = CalcZoom( nSBWidth );
611 mpImplWin->setPosSizePixel( 0, 0, aOutSz.Width() - nSBWidth, aOutSz.Height() );
612 mpBtn->setPosSizePixel( aOutSz.Width() - nSBWidth, 0, nSBWidth, aOutSz.Height() );
613 }
614 }
615 else
616 {
617 mpImplLB->SetSizePixel( aOutSz );
618 }
619
620 // Retain FloatingWindow size even when it's invisible, as we still process KEY_PGUP/DOWN ...
621 if ( mpFloatWin )
623
625}
626
628{
629 mxLayoutData.emplace();
630 const ImplListBoxWindow* rMainWin = mpImplLB->GetMainWindow();
631 if( mpFloatWin )
632 {
633 // Dropdown mode
637 {
638 AppendLayoutData( *rMainWin );
639 rMainWin->SetLayoutDataParent( this );
640 }
641 }
642 else
643 {
644 AppendLayoutData( *rMainWin );
645 rMainWin->SetLayoutDataParent( this );
646 }
647}
648
649tools::Long ListBox::GetIndexForPoint( const Point& rPoint, sal_Int32& rPos ) const
650{
651 if( !HasLayoutData() )
653
654 // Check whether rPoint fits at all
656 if( nIndex != -1 )
657 {
658 // Point must be either in main list window
659 // or in impl window (dropdown case)
661
662 // Convert coordinates to ImplListBoxWindow pixel coordinate space
663 Point aConvPoint = LogicToPixel( rPoint );
664 aConvPoint = OutputToAbsoluteScreenPixel( aConvPoint );
665 aConvPoint = rMain->AbsoluteScreenToOutputPixel( aConvPoint );
666 aConvPoint = rMain->PixelToLogic( aConvPoint );
667
668 // Try to find entry
669 sal_Int32 nEntry = rMain->GetEntryPosForPoint( aConvPoint );
670 if( nEntry == LISTBOX_ENTRY_NOTFOUND )
671 {
672 // Not found, maybe dropdown case
674 {
675 // Convert to impl window pixel coordinates
676 aConvPoint = LogicToPixel( rPoint );
677 aConvPoint = OutputToAbsoluteScreenPixel( aConvPoint );
678 aConvPoint = mpImplWin->AbsoluteScreenToOutputPixel( aConvPoint );
679
680 // Check whether converted point is inside impl window
681 Size aImplWinSize = mpImplWin->GetOutputSizePixel();
682 if( aConvPoint.X() >= 0 && aConvPoint.Y() >= 0 && aConvPoint.X() < aImplWinSize.Width() && aConvPoint.Y() < aImplWinSize.Height() )
683 {
684 // Inside the impl window, the position is the current item pos
685 rPos = mpImplWin->GetItemPos();
686 }
687 else
688 nIndex = -1;
689 }
690 else
691 nIndex = -1;
692 }
693 else
694 rPos = nEntry;
695
696 SAL_WARN_IF( nIndex == -1, "vcl", "found index for point, but relative index failed" );
697 }
698
699 // Get line relative index
700 if( nIndex != -1 )
702
703 return nIndex;
704}
705
707{
709 {
710 if( mpImplWin )
712 if( mpBtn )
713 mpBtn->Enable( !IsReadOnly() );
714 }
715 else if( nType == StateChangedType::Enable )
716 {
718 if( mpImplWin )
719 {
723 {
725 }
726 else
728 }
729 if( mpBtn )
730 mpBtn->Enable( IsEnabled() );
731 }
733 {
735 }
736 else if ( nType == StateChangedType::Zoom )
737 {
739 if ( mpImplWin )
740 {
744 }
745 Resize();
746 }
748 {
750 if ( mpImplWin )
751 {
755 }
756 Resize();
757 }
759 {
761 if ( mpImplWin )
762 {
767 }
768 }
770 {
772 if ( mpImplWin )
773 {
774
779 }
780 }
781 else if ( nType == StateChangedType::Style )
782 {
785 bool bSimpleMode = ( GetStyle() & WB_SIMPLEMODE ) != 0;
787 }
789 {
790 if( mpBtn )
791 {
794 }
796 if( mpImplWin )
798 Resize();
799 }
800
802}
803
805{
806 bool bDone = false;
807 if ( mpImplLB )
808 {
809 if( ( rNEvt.GetType() == NotifyEventType::KEYINPUT ) && ( rNEvt.GetWindow() == mpImplWin ) )
810 {
811 KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
812 switch( aKeyEvt.GetKeyCode().GetCode() )
813 {
814 case KEY_DOWN:
815 {
817 aKeyEvt.GetKeyCode().IsMod2() )
818 {
820 mpBtn->SetPressed( true );
821 mpFloatWin->StartFloat( false );
823 bDone = true;
824 }
825 else
826 {
827 bDone = mpImplLB->ProcessKeyInput( aKeyEvt );
828 }
829 }
830 break;
831 case KEY_UP:
832 {
834 aKeyEvt.GetKeyCode().IsMod2() )
835 {
837 bDone = true;
838 }
839 else
840 {
841 bDone = mpImplLB->ProcessKeyInput( aKeyEvt );
842 }
843 }
844 break;
845 case KEY_RETURN:
846 {
847 if( IsInDropDown() )
848 {
849 mpImplLB->ProcessKeyInput( aKeyEvt );
850 bDone = true;
851 }
852 }
853 break;
854
855 default:
856 {
857 bDone = mpImplLB->ProcessKeyInput( aKeyEvt );
858 }
859 }
860 }
861 else if ( rNEvt.GetType() == NotifyEventType::LOSEFOCUS )
862 {
863 if ( IsInDropDown() && !HasChildPathFocus( true ) )
865 }
866 else if ( (rNEvt.GetType() == NotifyEventType::COMMAND) &&
868 (rNEvt.GetWindow() == mpImplWin) )
869 {
870 MouseWheelBehaviour nWheelBehavior( GetSettings().GetMouseSettings().GetWheelBehavior() );
871 if ( ( nWheelBehavior == MouseWheelBehaviour::ALWAYS )
872 || ( ( nWheelBehavior == MouseWheelBehaviour::FocusOnly )
874 )
875 )
876 {
877 bDone = mpImplLB->HandleWheelAsCursorTravel(*rNEvt.GetCommandEvent(), *this);
878 }
879 else
880 {
881 bDone = false; // Don't consume this event, let the default handling take it (i.e. scroll the context)
882 }
883 }
884 }
885
886 if (rNEvt.GetType() == NotifyEventType::MOUSEMOVE)
887 {
888 const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
889 if (pMouseEvt && (pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow()))
890 {
891 // trigger redraw as mouse over state has changed
894 {
896 }
897 }
898 }
899
900 return bDone || Control::PreNotify( rNEvt );
901}
902
904{
906}
907
909{
911}
912
914{
915 if (!mpImplLB)
916 return;
917 mpImplLB->Clear();
918 if( IsDropDownBox() )
919 {
921 mpImplWin->SetString( OUString() );
922 Image aImage;
923 mpImplWin->SetImage( aImage );
925 }
926 CallEventListeners( VclEventId::ListboxItemRemoved, reinterpret_cast<void*>(-1) );
927}
928
930{
932 if( IsDropDownBox() )
933 {
935 mpImplWin->SetString( OUString() );
936 Image aImage;
937 mpImplWin->SetImage( aImage );
939 }
940}
941
942sal_Int32 ListBox::InsertEntry( const OUString& rStr, sal_Int32 nPos )
943{
944 sal_Int32 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList().GetMRUCount(), rStr );
945 nRealPos = sal::static_int_cast<sal_Int32>(nRealPos - mpImplLB->GetEntryList().GetMRUCount());
946 CallEventListeners( VclEventId::ListboxItemAdded, reinterpret_cast<void*>(nRealPos) );
947 return nRealPos;
948}
949
950sal_Int32 ListBox::InsertEntry( const OUString& rStr, const Image& rImage, sal_Int32 nPos )
951{
952 sal_Int32 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList().GetMRUCount(), rStr, rImage );
953 nRealPos = sal::static_int_cast<sal_Int32>(nRealPos - mpImplLB->GetEntryList().GetMRUCount());
954 CallEventListeners( VclEventId::ListboxItemAdded, reinterpret_cast<void*>(nRealPos) );
955 return nRealPos;
956}
957
958void ListBox::RemoveEntry( sal_Int32 nPos )
959{
961 CallEventListeners( VclEventId::ListboxItemRemoved, reinterpret_cast<void*>(nPos) );
962}
963
964Image ListBox::GetEntryImage( sal_Int32 nPos ) const
965{
968 return Image();
969}
970
971sal_Int32 ListBox::GetEntryPos( std::u16string_view rStr ) const
972{
973 if (!mpImplLB)
975 sal_Int32 nPos = mpImplLB->GetEntryList().FindEntry( rStr );
978 return nPos;
979}
980
981OUString ListBox::GetEntry( sal_Int32 nPos ) const
982{
983 if (!mpImplLB)
984 return OUString();
986}
987
988sal_Int32 ListBox::GetEntryCount() const
989{
990 if (!mpImplLB)
991 return 0;
993}
994
995OUString ListBox::GetSelectedEntry(sal_Int32 nIndex) const
996{
998}
999
1001{
1002 if (!mpImplLB)
1003 return 0;
1005}
1006
1007sal_Int32 ListBox::GetSelectedEntryPos( sal_Int32 nIndex ) const
1008{
1009 if (!mpImplLB)
1011
1014 {
1015 if ( nPos < mpImplLB->GetEntryList().GetMRUCount() )
1018 }
1019 return nPos;
1020}
1021
1022bool ListBox::IsEntryPosSelected( sal_Int32 nPos ) const
1023{
1025}
1026
1027void ListBox::SelectEntry( std::u16string_view rStr, bool bSelect )
1028{
1029 SelectEntryPos( GetEntryPos( rStr ), bSelect );
1030}
1031
1032void ListBox::SelectEntryPos( sal_Int32 nPos, bool bSelect )
1033{
1034 if (!mpImplLB)
1035 return;
1036
1037 if ( 0 <= nPos && nPos < mpImplLB->GetEntryList().GetEntryCount() )
1038 {
1039 sal_Int32 nCurrentPos = mpImplLB->GetCurrentPos();
1041 //Only when bSelect == true, send both Selection & Focus events
1042 if (nCurrentPos != nPos && bSelect)
1043 {
1044 CallEventListeners( VclEventId::ListboxSelect, reinterpret_cast<void*>(nPos));
1045 if (HasFocus())
1046 CallEventListeners( VclEventId::ListboxFocus, reinterpret_cast<void*>(nPos));
1047 }
1048 }
1049}
1050
1051void ListBox::SelectEntriesPos( const std::vector<sal_Int32>& rPositions, bool bSelect )
1052{
1053 if (!mpImplLB)
1054 return;
1055
1056 bool bCallListeners = false;
1057
1058 const sal_Int32 nCurrentPos = mpImplLB->GetCurrentPos();
1059 const auto nEntryCount = mpImplLB->GetEntryList().GetEntryCount();
1060 const auto nMRUCount = mpImplLB->GetEntryList().GetMRUCount();
1061
1062 for (auto nPos : rPositions)
1063 {
1064 if (0 <= nPos && nPos < nEntryCount)
1065 {
1066 mpImplLB->SelectEntry(nPos + nMRUCount, bSelect);
1067 if (nCurrentPos != nPos && bSelect)
1068 bCallListeners = true;
1069 }
1070 }
1071
1072 //Only when bSelect == true, send both Selection & Focus events
1073 if (bCallListeners)
1074 {
1076 if (HasFocus())
1078 }
1079}
1080
1081void ListBox::SetEntryData( sal_Int32 nPos, void* pNewData )
1082{
1084}
1085
1086void* ListBox::GetEntryData( sal_Int32 nPos ) const
1087{
1089}
1090
1091void ListBox::SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags )
1092{
1094}
1095
1096void ListBox::SetTopEntry( sal_Int32 nPos )
1097{
1099}
1100
1101sal_Int32 ListBox::GetTopEntry() const
1102{
1104 if ( nPos < mpImplLB->GetEntryList().GetMRUCount() )
1105 nPos = 0;
1106 return nPos;
1107}
1108
1110{
1111 return mpImplLB->IsTravelSelect();
1112}
1113
1115{
1116 // when the dropdown is dismissed, first mbInPopupMode is set to false, and on the next event iteration then
1117 // mbPopupMode is set to false
1119}
1120
1122{
1124 tools::Rectangle aOffset = mpImplLB->GetMainWindow()->GetWindowExtentsRelative( *static_cast<vcl::Window*>(const_cast<ListBox *>(this)) );
1125 aRect.Move( aOffset.Left(), aOffset.Top() );
1126 return aRect;
1127}
1128
1130{
1131 mpImplLB->EnableMultiSelection( bMulti );
1132
1133 // WB_SIMPLEMODE:
1134 // The MultiListBox behaves just like a normal ListBox
1135 // MultiSelection is possible via corresponding additional keys
1136 bool bSimpleMode = ( GetStyle() & WB_SIMPLEMODE ) != 0;
1137 mpImplLB->SetMultiSelectionSimpleMode( bSimpleMode );
1138
1139 // In a MultiSelection, we can't see us travelling without focus
1140 if ( mpFloatWin )
1142}
1143
1145{
1147}
1148
1150{
1151 AllSettings aSettings(GetSettings());
1152 StyleSettings aStyle(aSettings.GetStyleSettings());
1153 aStyle.SetHighlightColor(rColor);
1154 aSettings.SetStyleSettings(aStyle);
1155 SetSettings(aSettings);
1156
1157 mpImplLB->SetHighlightColor(rColor);
1158}
1159
1161{
1162 AllSettings aSettings(GetSettings());
1163 StyleSettings aStyle(aSettings.GetStyleSettings());
1164 aStyle.SetHighlightTextColor(rColor);
1165 aSettings.SetStyleSettings(aStyle);
1166 SetSettings(aSettings);
1167
1169}
1170
1172{
1173 Size aSz;
1174
1175 if (!mpImplLB)
1176 return aSz;
1177
1178 aSz = CalcSubEditSize();
1179
1180 bool bAddScrollWidth = false;
1181
1182 if (IsDropDownBox())
1183 {
1184 aSz.AdjustHeight(4 ); // add a space between entry and border
1185 aSz.AdjustWidth(4 ); // add a little breathing space
1186 bAddScrollWidth = true;
1187 }
1188 else
1189 bAddScrollWidth = (GetStyle() & WB_VSCROLL) == WB_VSCROLL;
1190
1191 if (bAddScrollWidth)
1192 {
1193 // Try native borders; scrollbar size may not be a good indicator
1194 // See how large the edit area inside is to estimate what is needed for the dropdown
1195 ImplControlValue aControlValue;
1196 tools::Rectangle aContent, aBound;
1197 Size aTestSize( 100, 20 );
1198 tools::Rectangle aArea( Point(), aTestSize );
1200 aControlValue, aBound, aContent) )
1201 {
1202 // use the themes drop down size
1203 aSz.AdjustWidth(aTestSize.Width() - aContent.GetWidth() );
1204 }
1205 else
1206 aSz.AdjustWidth(GetSettings().GetStyleSettings().GetScrollBarSize() );
1207 }
1208
1209 aSz = CalcWindowSize( aSz );
1210
1211 if (IsDropDownBox()) // Check minimum height of dropdown box
1212 {
1213 ImplControlValue aControlValue;
1214 tools::Rectangle aRect( Point( 0, 0 ), aSz );
1215 tools::Rectangle aContent, aBound;
1217 aControlValue, aBound, aContent) )
1218 {
1219 if( aBound.GetHeight() > aSz.Height() )
1220 aSz.setHeight( aBound.GetHeight() );
1221 }
1222 }
1223
1224 return aSz;
1225}
1226
1228{
1229 Size aSz;
1230
1231 if (!mpImplLB)
1232 return aSz;
1233
1234 if ( !IsDropDownBox() )
1236 else
1237 {
1239 // Size to maximum entry width
1241
1242 if (m_nMaxWidthChars != -1)
1243 {
1245 aSz.setWidth( std::min(aSz.Width(), nMaxWidth) );
1246 }
1247
1248 // Do not create ultrathin ListBoxes, it doesn't look good
1249 if( aSz.Width() < GetSettings().GetStyleSettings().GetScrollBarSize() )
1250 aSz.setWidth( GetSettings().GetStyleSettings().GetScrollBarSize() );
1251 }
1252
1253 return aSz;
1254}
1255
1257{
1258 return CalcMinimumSize();
1259}
1260
1261Size ListBox::CalcAdjustedSize( const Size& rPrefSize ) const
1262{
1263 Size aSz = rPrefSize;
1264 sal_Int32 nLeft, nTop, nRight, nBottom;
1265 static_cast<vcl::Window*>(const_cast<ListBox *>(this))->GetBorder( nLeft, nTop, nRight, nBottom );
1266 aSz.AdjustHeight( -(nTop+nBottom) );
1267 if ( !IsDropDownBox() )
1268 {
1269 tools::Long nEntryHeight = CalcBlockSize( 1, 1 ).Height();
1270 tools::Long nLines = aSz.Height() / nEntryHeight;
1271 if ( nLines < 1 )
1272 nLines = 1;
1273 aSz.setHeight( nLines * nEntryHeight );
1274 }
1275 else
1276 {
1277 aSz.setHeight( mnDDHeight );
1278 }
1279 aSz.AdjustHeight(nTop+nBottom );
1280
1281 aSz = CalcWindowSize( aSz );
1282 return aSz;
1283}
1284
1285Size ListBox::CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const
1286{
1287 // ScrollBars are shown if needed
1288 Size aMinSz = CalcMinimumSize();
1289 // aMinSz = ImplCalcOutSz( aMinSz );
1290
1291 Size aSz;
1292
1293 // Height
1294 if ( nLines )
1295 {
1296 if ( !IsDropDownBox() )
1297 aSz.setHeight( mpImplLB->CalcSize( nLines ).Height() );
1298 else
1299 aSz.setHeight( mnDDHeight );
1300 }
1301 else
1302 aSz.setHeight( aMinSz.Height() );
1303
1304 // Width
1305 if ( nColumns )
1306 aSz.setWidth( nColumns * GetTextWidth( OUString('X') ) );
1307 else
1308 aSz.setWidth( aMinSz.Width() );
1309
1310 if ( IsDropDownBox() )
1311 aSz.AdjustWidth(GetSettings().GetStyleSettings().GetScrollBarSize() );
1312
1313 if ( !IsDropDownBox() )
1314 {
1315 if ( aSz.Width() < aMinSz.Width() )
1316 aSz.AdjustHeight(GetSettings().GetStyleSettings().GetScrollBarSize() );
1317 if ( aSz.Height() < aMinSz.Height() )
1318 aSz.AdjustWidth(GetSettings().GetStyleSettings().GetScrollBarSize() );
1319 }
1320
1321 aSz = CalcWindowSize( aSz );
1322 return aSz;
1323}
1324
1325void ListBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const
1326{
1327 float nCharWidth = approximate_char_width();
1328 if ( !IsDropDownBox() )
1329 {
1331 rnCols = static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth);
1332 rnLines = static_cast<sal_uInt16>(aOutSz.Height()/mpImplLB->GetEntryHeightWithMargin());
1333 }
1334 else
1335 {
1336 Size aOutSz = mpImplWin->GetOutputSizePixel();
1337 rnCols = static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth);
1338 rnLines = 1;
1339 }
1340}
1341
1342void ListBox::SetReadOnly( bool bReadOnly )
1343{
1344 if ( mpImplLB->IsReadOnly() != bReadOnly )
1345 {
1348 }
1349}
1350
1352{
1353 return mpImplLB->IsReadOnly();
1354}
1355
1356void ListBox::SetSeparatorPos( sal_Int32 n )
1357{
1359}
1360
1362{
1363 return mpImplLB->GetSeparatorPos();
1364}
1365
1366void ListBox::AddSeparator( sal_Int32 n )
1367{
1369}
1370
1372{
1373 return mpImplLB->GetDisplayLineCount();
1374}
1375
1377{
1379}
1380
1382{
1383 // !!! Recursion does not occur because the ImplListBox is initialized by default
1384 // to a non-transparent color in Window::ImplInitData
1386}
1387
1388void ListBox::setMaxWidthChars(sal_Int32 nWidth)
1389{
1390 if (nWidth != m_nMaxWidthChars)
1391 {
1392 m_nMaxWidthChars = nWidth;
1393 queue_resize();
1394 }
1395}
1396
1397bool ListBox::set_property(const OUString &rKey, const OUString &rValue)
1398{
1399 if (rKey == "active")
1400 SelectEntryPos(rValue.toInt32());
1401 else if (rKey == "max-width-chars")
1402 setMaxWidthChars(rValue.toInt32());
1403 else if (rKey == "can-focus")
1404 {
1405 // as far as I can see in Gtk, setting a ComboBox as can.focus means
1406 // the focus gets stuck in it, so try here to behave like gtk does
1407 // with the settings that work, i.e. can.focus of false doesn't
1408 // set the hard WB_NOTABSTOP
1409 WinBits nBits = GetStyle();
1410 nBits &= ~(WB_TABSTOP|WB_NOTABSTOP);
1411 if (toBool(rValue))
1412 nBits |= WB_TABSTOP;
1413 SetStyle(nBits);
1414 }
1415 else
1416 return Control::set_property(rKey, rValue);
1417 return true;
1418}
1419
1421{
1423}
1424
1426{
1427 Control::DumpAsPropertyTree(rJsonWriter);
1428
1429 {
1430 auto entriesNode = rJsonWriter.startArray("entries");
1431 for (int i = 0; i < GetEntryCount(); ++i)
1432 {
1433 rJsonWriter.putSimpleValue(GetEntry(i));
1434 }
1435 }
1436
1437 rJsonWriter.put("selectedCount", GetSelectedEntryCount());
1438
1439 {
1440 auto entriesNode = rJsonWriter.startArray("selectedEntries");
1441 for (int i = 0; i < GetSelectedEntryCount(); ++i)
1442 {
1443 rJsonWriter.putSimpleValue(OUString::number(GetSelectedEntryPos(i)));
1444 }
1445 }
1446}
1447
1448MultiListBox::MultiListBox( vcl::Window* pParent, WinBits nStyle ) :
1450{
1451 ImplInit( pParent, nStyle );
1452 EnableMultiSelection( true );
1453}
1454
1455/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawTextFlags
SystemTextColorFlags
@ SubEdit
The edit field part of a control, e.g.
static bool toBool(std::string_view rValue)
Definition: builder.cxx:92
const StyleSettings & GetStyleSettings() const
void SetStyleSettings(const StyleSettings &rSet)
CommandEventId GetCommand() const
Definition: ctrl.hxx:80
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 void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:256
virtual void Resize() override
Definition: ctrl.cxx:77
virtual void EnableRTL(bool bEnable=true) override
Definition: ctrl.cxx:68
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
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: ctrl.cxx:61
DataChangedEventType GetType() const
Definition: event.hxx:362
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
Definition: floatwin.cxx:964
bool IsInPopupMode() const
Definition: floatwin.hxx:130
void SetPopupModeEndHdl(const Link< FloatingWindow *, void > &rLink)
Definition: floatwin.hxx:135
SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const
Definition: floatwin.hxx:104
Definition: image.hxx:40
void SetMBDownHdl(const Link< void *, void > &rLink)
Definition: listbox.hxx:593
bool HasEntryImage(sal_Int32 nPos) const
sal_Int32 GetSelectedEntryPos(sal_Int32 nIndex) const
bool HasImages() const
Definition: listbox.hxx:131
Image GetEntryImage(sal_Int32 nPos) const
sal_Int32 GetSelectedEntryCount() const
sal_Int32 FindEntry(std::u16string_view rStr, bool bSearchMRUArea=false) const
OUString GetEntryText(sal_Int32 nPos) const
void * GetEntryData(sal_Int32 nPos) const
sal_Int32 GetEntryCount() const
Definition: listbox.hxx:130
sal_Int32 GetMRUCount() const
Definition: listbox.hxx:160
bool IsEntryPosSelected(sal_Int32 nIndex) const
sal_uInt16 GetDropDownLineCount() const
Definition: listbox.hxx:530
void SetDropDownLineCount(sal_uInt16 n)
Definition: listbox.hxx:529
void SetAutoWidth(bool b)
Definition: listbox.hxx:521
void SetImplListBox(ImplListBox *pLB)
Definition: listbox.hxx:516
const Size & GetPrefSize() const
Definition: listbox.hxx:519
void SetPrefSize(const Size &rSz)
Definition: listbox.hxx:518
void StartFloat(bool bStartTracking)
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 EnableSort(bool b)
Definition: listbox.hxx:359
sal_uInt16 GetDisplayLineCount() const
Definition: listbox.hxx:494
ImplListBoxWindow * GetMainWindow()
Definition: listbox.hxx:413
bool IsReadOnly() const
Definition: listbox.hxx:469
tools::Long GetMaxEntryWidth() const
Definition: listbox.hxx:474
Size CalcSize(sal_Int32 nMaxLines) const
Definition: listbox.hxx:471
bool IsMultiSelectionEnabled() const
Definition: listbox.hxx:464
void SetSeparatorPos(sal_Int32 n)
Removes existing separators, and sets the position of the one and only separator.
Definition: listbox.hxx:438
void SelectEntry(sal_Int32 nPos, bool bSelect)
void RemoveEntry(sal_Int32 nPos)
void SetDoubleClickHdl(const Link< ImplListBoxWindow *, void > &rLink)
Definition: listbox.hxx:479
void SetSelectHdl(const Link< LinkParamNone *, void > &rLink)
Definition: listbox.hxx:477
void SetHighlightColor(const Color &rColor)
void SetHighlightTextColor(const Color &rColor)
void SetEntryFlags(sal_Int32 nPos, ListBoxEntryFlags nFlags)
virtual const Wallpaper & GetDisplayBackground() const override
bool ProcessKeyInput(const KeyEvent &rKEvt)
Definition: listbox.hxx:431
void SetListItemSelectHdl(const Link< LinkParamNone *, void > &rLink)
Definition: listbox.hxx:482
void SetReadOnly(bool b)
Definition: listbox.hxx:468
virtual void Resize() override
sal_Int32 GetTopEntry() const
Definition: listbox.hxx:451
void SetTopEntry(sal_Int32 nTop)
Definition: listbox.hxx:450
const ImplEntryList & GetEntryList() const
Definition: listbox.hxx:412
bool IsTravelSelect() const
Definition: listbox.hxx:460
bool HandleWheelAsCursorTravel(const CommandEvent &rCEvt, Control &rControl)
void SetNoSelection()
void SetScrollHdl(const Link< ImplListBox *, void > &rLink)
Definition: listbox.hxx:476
void SetCancelHdl(const Link< LinkParamNone *, void > &rLink)
Definition: listbox.hxx:478
void AddSeparator(sal_Int32 n)
Adds a new separator at the given position n.
Definition: listbox.hxx:448
tools::Long GetEntryHeightWithMargin() const
Definition: listbox.hxx:473
void SetFocusHdl(const Link< sal_Int32, void > &rLink)
Definition: listbox.hxx:481
sal_Int32 InsertEntry(sal_Int32 nPos, const OUString &rStr)
void SetMultiSelectionSimpleMode(bool bSimple)
Definition: listbox.hxx:466
void EnableMultiSelection(bool bMulti)
Definition: listbox.hxx:463
void SetEdgeBlending(bool bNew)
sal_Int32 GetSeparatorPos() const
Gets the position of the separator which was added first.
Definition: listbox.hxx:443
void SetSelectionChangedHdl(const Link< sal_Int32, void > &rLnk)
Definition: listbox.hxx:483
void SetEntryData(sal_Int32 nPos, void *pNewData)
Definition: listbox.hxx:421
tools::Long GetEntryHeight() const
Definition: listbox.hxx:472
sal_Int32 GetCurrentPos() const
Definition: listbox.hxx:429
void SetImage(const Image &rImg)
Definition: listbox.hxx:568
sal_Int32 GetItemPos() const
Definition: listbox.hxx:563
void SetString(const OUString &rStr)
Definition: listbox.hxx:566
void SetEdgeBlending(bool bNew)
Definition: listbox.hxx:575
void SetMBDownHdl(const Link< void *, void > &rLink)
Definition: listbox.hxx:570
void SetItemPos(sal_Int32 n)
Definition: listbox.hxx:564
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
A widget used to choose from a list of items and which has no entry.
Definition: lstbox.hxx:83
void EnableMultiSelection(bool bMulti)
Definition: listbox.cxx:1129
Size CalcSubEditSize() const
Definition: listbox.cxx:1227
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: listbox.cxx:468
void SetNoSelection()
Definition: listbox.cxx:929
sal_Int32 GetEntryPos(std::u16string_view rStr) const
Definition: listbox.cxx:971
void SetHighlightTextColor(const Color &rColor)
Definition: listbox.cxx:1160
Size CalcAdjustedSize(const Size &rPrefSize) const
Definition: listbox.cxx:1261
virtual ~ListBox() override
Definition: listbox.cxx:50
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All) override
Definition: listbox.cxx:537
bool IsMultiSelectionEnabled() const
Definition: listbox.cxx:1144
bool mbDDAutoSize
Definition: lstbox.hxx:94
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: listbox.cxx:317
tools::Rectangle GetBoundingRectangle(sal_Int32 nItem) const
Definition: listbox.cxx:1121
void Select()
Definition: listbox.cxx:903
sal_uInt16 mnLineCount
Definition: lstbox.hxx:92
sal_Int32 GetTopEntry() const
Definition: listbox.cxx:1101
void SetSeparatorPos(sal_Int32 n)
Removes existing separators, and sets the position of the one and only separator.
Definition: listbox.cxx:1356
sal_uInt16 GetDisplayLineCount() const
Definition: listbox.cxx:1371
bool IsEntryPosSelected(sal_Int32 nPos) const
Definition: listbox.cxx:1022
sal_Int32 GetSelectedEntryCount() const
Definition: listbox.cxx:1000
ListBox(WindowType nType)
Definition: listbox.cxx:37
void EnableAutoSize(bool bAuto)
Definition: listbox.cxx:496
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: listbox.cxx:312
bool IsReadOnly() const
Definition: listbox.cxx:1351
VclPtr< ImplListBox > mpImplLB
Definition: lstbox.hxx:85
bool IsInDropDown() const
Definition: listbox.cxx:1114
sal_Int32 GetEntryCount() const
Definition: listbox.cxx:988
bool IsDropDownBox() const
Definition: lstbox.hxx:114
virtual void LoseFocus() override
Definition: listbox.cxx:452
virtual bool set_property(const OUString &rKey, const OUString &rValue) override
Definition: listbox.cxx:1397
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: listbox.cxx:158
void GetMaxVisColumnsAndLines(sal_uInt16 &rnCols, sal_uInt16 &rnLines) const
Definition: listbox.cxx:1325
void SelectEntryPos(sal_Int32 nPos, bool bSelect=true)
Definition: listbox.cxx:1032
Link< ListBox &, void > maSelectHdl
Definition: lstbox.hxx:91
Size CalcBlockSize(sal_uInt16 nColumns, sal_uInt16 nLines) const
Definition: listbox.cxx:1285
VclPtr< ImplListBoxFloatingWindow > mpFloatWin
Definition: lstbox.hxx:86
virtual FactoryFunction GetUITestFactory() const override
Definition: listbox.cxx:1420
virtual void GetFocus() override
Definition: listbox.cxx:439
void ToggleDropDown()
Definition: listbox.cxx:295
sal_Int32 GetSelectedEntryPos(sal_Int32 nSelIndex=0) const
Definition: listbox.cxx:1007
sal_Int32 m_nMaxWidthChars
Definition: lstbox.hxx:90
void SetEntryFlags(sal_Int32 nPos, ListBoxEntryFlags nFlags)
this methods stores a combination of flags from the ListBoxEntryFlags::* defines at the given entry.
Definition: listbox.cxx:1091
VclPtr< ImplBtn > mpBtn
Definition: lstbox.hxx:88
virtual const Wallpaper & GetDisplayBackground() const override
Definition: listbox.cxx:1381
virtual void DumpAsPropertyTree(tools::JsonWriter &) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
Definition: listbox.cxx:1425
void SetReadOnly(bool bReadOnly=true)
Definition: listbox.cxx:1342
sal_uInt16 GetDropDownLineCount() const
Definition: listbox.cxx:530
void setMaxWidthChars(sal_Int32 nWidth)
Definition: listbox.cxx:1388
tools::Long GetIndexForPoint(const Point &rPoint, sal_Int32 &rPos) const
Definition: listbox.cxx:649
OUString GetEntry(sal_Int32 nPos) const
Definition: listbox.cxx:981
void RemoveEntry(sal_Int32 nPos)
Definition: listbox.cxx:958
VclPtr< ImplWin > mpImplWin
Definition: lstbox.hxx:87
void SetHighlightColor(const Color &rColor)
Definition: listbox.cxx:1149
void Clear()
Definition: listbox.cxx:913
void AdaptDropDownLineCountToMaximum()
Definition: listbox.cxx:520
void AddSeparator(sal_Int32 n)
Adds a new separator at the given position n.
Definition: listbox.cxx:1366
Image GetEntryImage(sal_Int32 nPos) const
Definition: listbox.cxx:964
Size CalcMinimumSize() const
Definition: listbox.cxx:1171
sal_uInt16 mnDDHeight
Definition: lstbox.hxx:89
virtual void Resize() override
Definition: listbox.cxx:555
void SetDropDownLineCount(sal_uInt16 nLines)
Definition: listbox.cxx:513
virtual Size GetOptimalSize() const override
Definition: listbox.cxx:1256
bool IsAutoSizeEnabled() const
Definition: lstbox.hxx:150
bool IsTravelSelect() const
Definition: listbox.cxx:1109
void DoubleClick()
Definition: listbox.cxx:908
SAL_DLLPRIVATE void ImplInitListBoxData()
Definition: listbox.cxx:67
void SetEntryData(sal_Int32 nPos, void *pNewData)
Definition: listbox.cxx:1081
void SelectEntriesPos(const std::vector< sal_Int32 > &rPositions, bool bSelect=true)
Definition: listbox.cxx:1051
void * GetEntryData(sal_Int32 nPos) const
Definition: listbox.cxx:1086
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: listbox.cxx:55
virtual void StateChanged(StateChangedType nType) override
Definition: listbox.cxx:706
sal_Int32 GetSeparatorPos() const
Gets the position of the separator which was added first.
Definition: listbox.cxx:1361
void SelectEntry(std::u16string_view rStr, bool bSelect=true)
Definition: listbox.cxx:1027
void SetTopEntry(sal_Int32 nPos)
Definition: listbox.cxx:1096
virtual void FillLayoutData() const override
Definition: listbox.cxx:627
OUString GetSelectedEntry(sal_Int32 nSelIndex=0) const
Definition: listbox.cxx:995
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: listbox.cxx:78
tools::Rectangle GetDropDownPosSizePixel() const
Definition: listbox.cxx:1376
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: listbox.cxx:804
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=LISTBOX_APPEND)
Definition: listbox.cxx:942
bool IsEnterWindow() const
Definition: event.hxx:138
bool IsLeaveWindow() const
Definition: event.hxx:140
const KeyEvent * GetKeyEvent() const
Definition: event.hxx:316
vcl::Window * GetWindow() const
Definition: event.hxx:309
const CommandEvent * GetCommandEvent() const
Definition: event.hxx:332
const MouseEvent * GetMouseEvent() const
Definition: event.hxx:324
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
virtual void SetSettings(const AllSettings &rSettings)
Definition: outdev.cxx:215
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
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: text.cxx:886
void SetTextColor(const Color &rColor)
Definition: text.cxx:716
void SetFillColor()
Definition: fill.cxx:29
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:879
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 SetBackground()
Definition: background.cxx:27
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
void SetPressed(bool bPressed)
Definition: button.cxx:1683
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
void disposeAndClear()
Definition: vclptr.hxx:200
static VclPtr< reference_type > Create(Arg &&... arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
bool isDisposed() const
void put(std::u16string_view pPropName, const OUString &rPropValue)
void putSimpleValue(const OUString &rPropValue)
ScopedJsonWriterArray startArray(std::string_view)
constexpr tools::Long GetWidth() const
constexpr void SetTop(tools::Long v)
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)
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
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2806
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
void SetFont(const vcl::Font &rNewFont)
Definition: window3.cxx:59
void SetUpdateMode(bool bUpdate)
Definition: window.cxx:2967
bool IsNativeWidgetEnabled() const
Definition: window.cxx:3710
bool IsReallyVisible() const
Definition: window2.cxx:1133
virtual void GetFocus()
Definition: window.cxx:1841
void SetControlForeground()
Definition: window2.cxx:486
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3004
Point LogicToPixel(const Point &rLogicPt) const
Definition: window3.cxx:131
void SetControlFont()
Definition: window2.cxx:438
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1288
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: window.cxx:2424
tools::Long CalcZoom(tools::Long n) const
Definition: window2.cxx:426
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1036
void HideFocus()
Definition: window2.cxx:95
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1353
const Color & GetControlForeground() const
Definition: window2.cxx:1098
void GrabFocus()
Definition: window.cxx:2976
void SetControlBackground()
Definition: window2.cxx:526
bool IsUpdateMode() const
Definition: window2.cxx:1199
bool HasFocus() const
Definition: window.cxx:2981
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
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: window3.cxx:65
void Enable(bool bEnable=true, bool bChild=true)
Definition: window.cxx:2433
WinBits GetStyle() const
Definition: window2.cxx:979
const Fraction & GetZoom() const
Definition: window2.cxx:1236
const AllSettings & GetSettings() const
Definition: window3.cxx:129
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2187
Size CalcWindowSize(const Size &rOutSz) const
Definition: window2.cxx:566
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:52
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
::OutputDevice const * GetOutDev() const
Definition: window.cxx:567
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2666
const vcl::Font & GetFont() const
Definition: window3.cxx:58
SAL_DLLPRIVATE float approximate_char_width() const
Definition: window3.cxx:61
void RequestDoubleBuffering(bool bRequest)
Enable/disable double-buffering of the frame window and all its children.
Definition: window.cxx:3865
void SetSettings(const AllSettings &rSettings)
Definition: window3.cxx:208
void SetZoom(const Fraction &rZoom)
Definition: window2.cxx:399
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
virtual void LoseFocus()
Definition: window.cxx:1855
const Color & GetControlBackground() const
Definition: window2.cxx:1108
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1283
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
Definition: window.cxx:2855
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
Definition: mouse.cxx:651
virtual bool set_property(const OUString &rKey, const OUString &rValue)
Definition: window2.cxx:1478
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2812
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
Definition: window2.cxx:1294
tools::Rectangle GetWindowExtentsRelative(const vcl::Window &rRelativeWindow) const
Definition: window.cxx:2914
bool IsEnabled() const
Definition: window2.cxx:1148
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:941
void SetCompoundControl(bool bCompound)
Definition: window2.cxx:973
void SetTextColor(const Color &rColor)
Definition: window3.cxx:108
void SetBackground()
Definition: window3.cxx:100
SAL_DLLPRIVATE void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3898
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
bool bReadOnly
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_UP
Definition: keycodes.hxx:111
constexpr sal_uInt16 KEY_DOWN
Definition: keycodes.hxx:110
sal_uInt16 nPos
IMPL_LINK_NOARG(ListBox, ImplSelectHdl, LinkParamNone *, void)
Definition: listbox.cxx:167
IMPL_LINK(ListBox, ImplFocusHdl, sal_Int32, nPos, void)
Definition: listbox.cxx:192
#define SAL_WARN_IF(condition, area, stream)
#define LISTBOX_ENTRY_NOTFOUND
Definition: lstbox.hxx:37
ListBoxEntryFlags
Definition: lstbox.hxx:48
int i
long Long
QPRO_FUNC_TYPE nType
MouseWheelBehaviour
Definition: settings.hxx:78
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:77
bool bPopup
@ ListboxItemRemoved
@ ListboxDoubleClick
PosSizeFlags
Definition: window.hxx:127
StateChangedType
Definition: window.hxx:291
@ NoErase
The invalidated area is painted with the background color/pattern.
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_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_VSCROLL
Definition: wintypes.hxx:178
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