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 {
775 {
776 // Transparent background
779 }
780 else
781 {
784 }
787 }
788 }
789 else if ( nType == StateChangedType::Style )
790 {
793 bool bSimpleMode = ( GetStyle() & WB_SIMPLEMODE ) != 0;
795 }
797 {
798 if( mpBtn )
799 {
802 }
804 if( mpImplWin )
806 Resize();
807 }
808
810}
811
813{
814 bool bDone = false;
815 if ( mpImplLB )
816 {
817 if( ( rNEvt.GetType() == NotifyEventType::KEYINPUT ) && ( rNEvt.GetWindow() == mpImplWin ) )
818 {
819 KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
820 switch( aKeyEvt.GetKeyCode().GetCode() )
821 {
822 case KEY_DOWN:
823 {
825 aKeyEvt.GetKeyCode().IsMod2() )
826 {
828 mpBtn->SetPressed( true );
829 mpFloatWin->StartFloat( false );
831 bDone = true;
832 }
833 else
834 {
835 bDone = mpImplLB->ProcessKeyInput( aKeyEvt );
836 }
837 }
838 break;
839 case KEY_UP:
840 {
842 aKeyEvt.GetKeyCode().IsMod2() )
843 {
845 bDone = true;
846 }
847 else
848 {
849 bDone = mpImplLB->ProcessKeyInput( aKeyEvt );
850 }
851 }
852 break;
853 case KEY_RETURN:
854 {
855 if( IsInDropDown() )
856 {
857 mpImplLB->ProcessKeyInput( aKeyEvt );
858 bDone = true;
859 }
860 }
861 break;
862
863 default:
864 {
865 bDone = mpImplLB->ProcessKeyInput( aKeyEvt );
866 }
867 }
868 }
869 else if ( rNEvt.GetType() == NotifyEventType::LOSEFOCUS )
870 {
871 if ( IsInDropDown() && !HasChildPathFocus( true ) )
873 }
874 else if ( (rNEvt.GetType() == NotifyEventType::COMMAND) &&
876 (rNEvt.GetWindow() == mpImplWin) )
877 {
878 MouseWheelBehaviour nWheelBehavior( GetSettings().GetMouseSettings().GetWheelBehavior() );
879 if ( ( nWheelBehavior == MouseWheelBehaviour::ALWAYS )
880 || ( ( nWheelBehavior == MouseWheelBehaviour::FocusOnly )
882 )
883 )
884 {
885 bDone = mpImplLB->HandleWheelAsCursorTravel(*rNEvt.GetCommandEvent(), *this);
886 }
887 else
888 {
889 bDone = false; // Don't consume this event, let the default handling take it (i.e. scroll the context)
890 }
891 }
892 }
893
894 return bDone || Control::PreNotify( rNEvt );
895}
896
898{
900}
901
903{
905}
906
908{
909 if (!mpImplLB)
910 return;
911 mpImplLB->Clear();
912 if( IsDropDownBox() )
913 {
915 mpImplWin->SetString( OUString() );
916 Image aImage;
917 mpImplWin->SetImage( aImage );
919 }
920 CallEventListeners( VclEventId::ListboxItemRemoved, reinterpret_cast<void*>(-1) );
921}
922
924{
926 if( IsDropDownBox() )
927 {
929 mpImplWin->SetString( OUString() );
930 Image aImage;
931 mpImplWin->SetImage( aImage );
933 }
934}
935
936sal_Int32 ListBox::InsertEntry( const OUString& rStr, sal_Int32 nPos )
937{
938 sal_Int32 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList().GetMRUCount(), rStr );
939 nRealPos = sal::static_int_cast<sal_Int32>(nRealPos - mpImplLB->GetEntryList().GetMRUCount());
940 CallEventListeners( VclEventId::ListboxItemAdded, reinterpret_cast<void*>(nRealPos) );
941 return nRealPos;
942}
943
944sal_Int32 ListBox::InsertEntry( const OUString& rStr, const Image& rImage, sal_Int32 nPos )
945{
946 sal_Int32 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList().GetMRUCount(), rStr, rImage );
947 nRealPos = sal::static_int_cast<sal_Int32>(nRealPos - mpImplLB->GetEntryList().GetMRUCount());
948 CallEventListeners( VclEventId::ListboxItemAdded, reinterpret_cast<void*>(nRealPos) );
949 return nRealPos;
950}
951
952void ListBox::RemoveEntry( sal_Int32 nPos )
953{
955 CallEventListeners( VclEventId::ListboxItemRemoved, reinterpret_cast<void*>(nPos) );
956}
957
958Image ListBox::GetEntryImage( sal_Int32 nPos ) const
959{
962 return Image();
963}
964
965sal_Int32 ListBox::GetEntryPos( std::u16string_view rStr ) const
966{
967 if (!mpImplLB)
969 sal_Int32 nPos = mpImplLB->GetEntryList().FindEntry( rStr );
972 return nPos;
973}
974
975OUString ListBox::GetEntry( sal_Int32 nPos ) const
976{
977 if (!mpImplLB)
978 return OUString();
980}
981
982sal_Int32 ListBox::GetEntryCount() const
983{
984 if (!mpImplLB)
985 return 0;
987}
988
989OUString ListBox::GetSelectedEntry(sal_Int32 nIndex) const
990{
992}
993
995{
996 if (!mpImplLB)
997 return 0;
999}
1000
1001sal_Int32 ListBox::GetSelectedEntryPos( sal_Int32 nIndex ) const
1002{
1003 if (!mpImplLB)
1005
1008 {
1009 if ( nPos < mpImplLB->GetEntryList().GetMRUCount() )
1012 }
1013 return nPos;
1014}
1015
1016bool ListBox::IsEntryPosSelected( sal_Int32 nPos ) const
1017{
1019}
1020
1021void ListBox::SelectEntry( std::u16string_view rStr, bool bSelect )
1022{
1023 SelectEntryPos( GetEntryPos( rStr ), bSelect );
1024}
1025
1026void ListBox::SelectEntryPos( sal_Int32 nPos, bool bSelect )
1027{
1028 if (!mpImplLB)
1029 return;
1030
1031 if ( 0 <= nPos && nPos < mpImplLB->GetEntryList().GetEntryCount() )
1032 {
1033 sal_Int32 nCurrentPos = mpImplLB->GetCurrentPos();
1035 //Only when bSelect == true, send both Selection & Focus events
1036 if (nCurrentPos != nPos && bSelect)
1037 {
1038 CallEventListeners( VclEventId::ListboxSelect, reinterpret_cast<void*>(nPos));
1039 if (HasFocus())
1040 CallEventListeners( VclEventId::ListboxFocus, reinterpret_cast<void*>(nPos));
1041 }
1042 }
1043}
1044
1045void ListBox::SelectEntriesPos( const std::vector<sal_Int32>& rPositions, bool bSelect )
1046{
1047 if (!mpImplLB)
1048 return;
1049
1050 bool bCallListeners = false;
1051
1052 const sal_Int32 nCurrentPos = mpImplLB->GetCurrentPos();
1053 const auto nEntryCount = mpImplLB->GetEntryList().GetEntryCount();
1054 const auto nMRUCount = mpImplLB->GetEntryList().GetMRUCount();
1055
1056 for (auto nPos : rPositions)
1057 {
1058 if (0 <= nPos && nPos < nEntryCount)
1059 {
1060 mpImplLB->SelectEntry(nPos + nMRUCount, bSelect);
1061 if (nCurrentPos != nPos && bSelect)
1062 bCallListeners = true;
1063 }
1064 }
1065
1066 //Only when bSelect == true, send both Selection & Focus events
1067 if (bCallListeners)
1068 {
1070 if (HasFocus())
1072 }
1073}
1074
1075void ListBox::SetEntryData( sal_Int32 nPos, void* pNewData )
1076{
1078}
1079
1080void* ListBox::GetEntryData( sal_Int32 nPos ) const
1081{
1083}
1084
1085void ListBox::SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags )
1086{
1088}
1089
1090void ListBox::SetTopEntry( sal_Int32 nPos )
1091{
1093}
1094
1095sal_Int32 ListBox::GetTopEntry() const
1096{
1098 if ( nPos < mpImplLB->GetEntryList().GetMRUCount() )
1099 nPos = 0;
1100 return nPos;
1101}
1102
1104{
1105 return mpImplLB->IsTravelSelect();
1106}
1107
1109{
1110 // when the dropdown is dismissed, first mbInPopupMode is set to false, and on the next event iteration then
1111 // mbPopupMode is set to false
1113}
1114
1116{
1118 tools::Rectangle aOffset = mpImplLB->GetMainWindow()->GetWindowExtentsRelative( static_cast<vcl::Window*>(const_cast<ListBox *>(this)) );
1119 aRect.Move( aOffset.Left(), aOffset.Top() );
1120 return aRect;
1121}
1122
1124{
1125 mpImplLB->EnableMultiSelection( bMulti );
1126
1127 // WB_SIMPLEMODE:
1128 // The MultiListBox behaves just like a normal ListBox
1129 // MultiSelection is possible via corresponding additional keys
1130 bool bSimpleMode = ( GetStyle() & WB_SIMPLEMODE ) != 0;
1131 mpImplLB->SetMultiSelectionSimpleMode( bSimpleMode );
1132
1133 // In a MultiSelection, we can't see us travelling without focus
1134 if ( mpFloatWin )
1136}
1137
1139{
1141}
1142
1144{
1145 AllSettings aSettings(GetSettings());
1146 StyleSettings aStyle(aSettings.GetStyleSettings());
1147 aStyle.SetHighlightColor(rColor);
1148 aSettings.SetStyleSettings(aStyle);
1149 SetSettings(aSettings);
1150
1151 mpImplLB->SetHighlightColor(rColor);
1152}
1153
1155{
1156 AllSettings aSettings(GetSettings());
1157 StyleSettings aStyle(aSettings.GetStyleSettings());
1158 aStyle.SetHighlightTextColor(rColor);
1159 aSettings.SetStyleSettings(aStyle);
1160 SetSettings(aSettings);
1161
1163}
1164
1166{
1167 Size aSz;
1168
1169 if (!mpImplLB)
1170 return aSz;
1171
1172 aSz = CalcSubEditSize();
1173
1174 bool bAddScrollWidth = false;
1175
1176 if (IsDropDownBox())
1177 {
1178 aSz.AdjustHeight(4 ); // add a space between entry and border
1179 aSz.AdjustWidth(4 ); // add a little breathing space
1180 bAddScrollWidth = true;
1181 }
1182 else
1183 bAddScrollWidth = (GetStyle() & WB_VSCROLL) == WB_VSCROLL;
1184
1185 if (bAddScrollWidth)
1186 {
1187 // Try native borders; scrollbar size may not be a good indicator
1188 // See how large the edit area inside is to estimate what is needed for the dropdown
1189 ImplControlValue aControlValue;
1190 tools::Rectangle aContent, aBound;
1191 Size aTestSize( 100, 20 );
1192 tools::Rectangle aArea( Point(), aTestSize );
1194 aControlValue, aBound, aContent) )
1195 {
1196 // use the themes drop down size
1197 aSz.AdjustWidth(aTestSize.Width() - aContent.GetWidth() );
1198 }
1199 else
1200 aSz.AdjustWidth(GetSettings().GetStyleSettings().GetScrollBarSize() );
1201 }
1202
1203 aSz = CalcWindowSize( aSz );
1204
1205 if (IsDropDownBox()) // Check minimum height of dropdown box
1206 {
1207 ImplControlValue aControlValue;
1208 tools::Rectangle aRect( Point( 0, 0 ), aSz );
1209 tools::Rectangle aContent, aBound;
1211 aControlValue, aBound, aContent) )
1212 {
1213 if( aBound.GetHeight() > aSz.Height() )
1214 aSz.setHeight( aBound.GetHeight() );
1215 }
1216 }
1217
1218 return aSz;
1219}
1220
1222{
1223 Size aSz;
1224
1225 if (!mpImplLB)
1226 return aSz;
1227
1228 if ( !IsDropDownBox() )
1230 else
1231 {
1233 // Size to maximum entry width
1235
1236 if (m_nMaxWidthChars != -1)
1237 {
1239 aSz.setWidth( std::min(aSz.Width(), nMaxWidth) );
1240 }
1241
1242 // Do not create ultrathin ListBoxes, it doesn't look good
1243 if( aSz.Width() < GetSettings().GetStyleSettings().GetScrollBarSize() )
1244 aSz.setWidth( GetSettings().GetStyleSettings().GetScrollBarSize() );
1245 }
1246
1247 return aSz;
1248}
1249
1251{
1252 return CalcMinimumSize();
1253}
1254
1255Size ListBox::CalcAdjustedSize( const Size& rPrefSize ) const
1256{
1257 Size aSz = rPrefSize;
1258 sal_Int32 nLeft, nTop, nRight, nBottom;
1259 static_cast<vcl::Window*>(const_cast<ListBox *>(this))->GetBorder( nLeft, nTop, nRight, nBottom );
1260 aSz.AdjustHeight( -(nTop+nBottom) );
1261 if ( !IsDropDownBox() )
1262 {
1263 tools::Long nEntryHeight = CalcBlockSize( 1, 1 ).Height();
1264 tools::Long nLines = aSz.Height() / nEntryHeight;
1265 if ( nLines < 1 )
1266 nLines = 1;
1267 aSz.setHeight( nLines * nEntryHeight );
1268 }
1269 else
1270 {
1271 aSz.setHeight( mnDDHeight );
1272 }
1273 aSz.AdjustHeight(nTop+nBottom );
1274
1275 aSz = CalcWindowSize( aSz );
1276 return aSz;
1277}
1278
1279Size ListBox::CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const
1280{
1281 // ScrollBars are shown if needed
1282 Size aMinSz = CalcMinimumSize();
1283 // aMinSz = ImplCalcOutSz( aMinSz );
1284
1285 Size aSz;
1286
1287 // Height
1288 if ( nLines )
1289 {
1290 if ( !IsDropDownBox() )
1291 aSz.setHeight( mpImplLB->CalcSize( nLines ).Height() );
1292 else
1293 aSz.setHeight( mnDDHeight );
1294 }
1295 else
1296 aSz.setHeight( aMinSz.Height() );
1297
1298 // Width
1299 if ( nColumns )
1300 aSz.setWidth( nColumns * GetTextWidth( OUString('X') ) );
1301 else
1302 aSz.setWidth( aMinSz.Width() );
1303
1304 if ( IsDropDownBox() )
1305 aSz.AdjustWidth(GetSettings().GetStyleSettings().GetScrollBarSize() );
1306
1307 if ( !IsDropDownBox() )
1308 {
1309 if ( aSz.Width() < aMinSz.Width() )
1310 aSz.AdjustHeight(GetSettings().GetStyleSettings().GetScrollBarSize() );
1311 if ( aSz.Height() < aMinSz.Height() )
1312 aSz.AdjustWidth(GetSettings().GetStyleSettings().GetScrollBarSize() );
1313 }
1314
1315 aSz = CalcWindowSize( aSz );
1316 return aSz;
1317}
1318
1319void ListBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const
1320{
1321 float nCharWidth = approximate_char_width();
1322 if ( !IsDropDownBox() )
1323 {
1325 rnCols = static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth);
1326 rnLines = static_cast<sal_uInt16>(aOutSz.Height()/mpImplLB->GetEntryHeightWithMargin());
1327 }
1328 else
1329 {
1330 Size aOutSz = mpImplWin->GetOutputSizePixel();
1331 rnCols = static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth);
1332 rnLines = 1;
1333 }
1334}
1335
1336void ListBox::SetReadOnly( bool bReadOnly )
1337{
1338 if ( mpImplLB->IsReadOnly() != bReadOnly )
1339 {
1342 }
1343}
1344
1346{
1347 return mpImplLB->IsReadOnly();
1348}
1349
1350void ListBox::SetSeparatorPos( sal_Int32 n )
1351{
1353}
1354
1356{
1357 return mpImplLB->GetSeparatorPos();
1358}
1359
1360void ListBox::AddSeparator( sal_Int32 n )
1361{
1363}
1364
1366{
1367 return mpImplLB->GetDisplayLineCount();
1368}
1369
1371{
1373}
1374
1376{
1377 // !!! Recursion does not occur because the ImplListBox is initialized by default
1378 // to a non-transparent color in Window::ImplInitData
1380}
1381
1382void ListBox::setMaxWidthChars(sal_Int32 nWidth)
1383{
1384 if (nWidth != m_nMaxWidthChars)
1385 {
1386 m_nMaxWidthChars = nWidth;
1387 queue_resize();
1388 }
1389}
1390
1391bool ListBox::set_property(const OString &rKey, const OUString &rValue)
1392{
1393 if (rKey == "active")
1394 SelectEntryPos(rValue.toInt32());
1395 else if (rKey == "max-width-chars")
1396 setMaxWidthChars(rValue.toInt32());
1397 else if (rKey == "can-focus")
1398 {
1399 // as far as I can see in Gtk, setting a ComboBox as can.focus means
1400 // the focus gets stuck in it, so try here to behave like gtk does
1401 // with the settings that work, i.e. can.focus of false doesn't
1402 // set the hard WB_NOTABSTOP
1403 WinBits nBits = GetStyle();
1404 nBits &= ~(WB_TABSTOP|WB_NOTABSTOP);
1405 if (toBool(rValue))
1406 nBits |= WB_TABSTOP;
1407 SetStyle(nBits);
1408 }
1409 else
1410 return Control::set_property(rKey, rValue);
1411 return true;
1412}
1413
1415{
1417}
1418
1420{
1421 Control::DumpAsPropertyTree(rJsonWriter);
1422
1423 {
1424 auto entriesNode = rJsonWriter.startArray("entries");
1425 for (int i = 0; i < GetEntryCount(); ++i)
1426 {
1427 rJsonWriter.putSimpleValue(GetEntry(i));
1428 }
1429 }
1430
1431 rJsonWriter.put("selectedCount", GetSelectedEntryCount());
1432
1433 {
1434 auto entriesNode = rJsonWriter.startArray("selectedEntries");
1435 for (int i = 0; i < GetSelectedEntryCount(); ++i)
1436 {
1437 rJsonWriter.putSimpleValue(OUString::number(GetSelectedEntryPos(i)));
1438 }
1439 }
1440}
1441
1442MultiListBox::MultiListBox( vcl::Window* pParent, WinBits nStyle ) :
1444{
1445 ImplInit( pParent, nStyle );
1446 EnableMultiSelection( true );
1447}
1448
1449/* 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:91
const StyleSettings & GetStyleSettings() const
void SetStyleSettings(const StyleSettings &rSet)
CommandEventId GetCommand() const
Definition: ctrl.hxx:82
std::optional< vcl::ControlLayoutData > mxLayoutData
Definition: ctrl.hxx:84
tools::Long GetIndexForPoint(const Point &rPoint) const
Definition: ctrl.cxx:135
tools::Long ToRelativeLineIndex(tools::Long nIndex) const
ToRelativeLineIndex changes a layout data index to a count relative to its line.
Definition: ctrl.cxx:212
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
Definition: ctrl.cxx:302
void SetLayoutDataParent(const Control *pParent) const
Definition: ctrl.cxx:321
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:257
virtual void Resize() override
Definition: ctrl.cxx:75
virtual void EnableRTL(bool bEnable=true) override
Definition: ctrl.cxx:66
bool HasLayoutData() const
determines whether we currently have layout data
Definition: ctrl.cxx:91
void AppendLayoutData(const Control &rSubControl) const
Definition: ctrl.cxx:270
SAL_DLLPRIVATE void ImplDrawFrame(OutputDevice *pDev, tools::Rectangle &rRect)
draws a frame around the give rectangle, onto the given device
Definition: ctrl.cxx:332
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: ctrl.cxx:294
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: ctrl.cxx:59
DataChangedEventType GetType() const
Definition: event.hxx:362
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
Definition: floatwin.cxx:949
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:594
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:569
sal_Int32 GetItemPos() const
Definition: listbox.hxx:564
void SetString(const OUString &rStr)
Definition: listbox.hxx:567
void SetEdgeBlending(bool bNew)
Definition: listbox.hxx:576
void SetMBDownHdl(const Link< void *, void > &rLink)
Definition: listbox.hxx:571
void SetItemPos(sal_Int32 n)
Definition: listbox.hxx:565
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:1123
Size CalcSubEditSize() const
Definition: listbox.cxx:1221
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: listbox.cxx:468
void SetNoSelection()
Definition: listbox.cxx:923
sal_Int32 GetEntryPos(std::u16string_view rStr) const
Definition: listbox.cxx:965
void SetHighlightTextColor(const Color &rColor)
Definition: listbox.cxx:1154
Size CalcAdjustedSize(const Size &rPrefSize) const
Definition: listbox.cxx:1255
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:1138
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:1115
void Select()
Definition: listbox.cxx:897
sal_uInt16 mnLineCount
Definition: lstbox.hxx:92
sal_Int32 GetTopEntry() const
Definition: listbox.cxx:1095
void SetSeparatorPos(sal_Int32 n)
Removes existing separators, and sets the position of the one and only separator.
Definition: listbox.cxx:1350
sal_uInt16 GetDisplayLineCount() const
Definition: listbox.cxx:1365
bool IsEntryPosSelected(sal_Int32 nPos) const
Definition: listbox.cxx:1016
sal_Int32 GetSelectedEntryCount() const
Definition: listbox.cxx:994
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:1345
VclPtr< ImplListBox > mpImplLB
Definition: lstbox.hxx:85
bool IsInDropDown() const
Definition: listbox.cxx:1108
sal_Int32 GetEntryCount() const
Definition: listbox.cxx:982
bool IsDropDownBox() const
Definition: lstbox.hxx:114
virtual void LoseFocus() override
Definition: listbox.cxx:452
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: listbox.cxx:158
void GetMaxVisColumnsAndLines(sal_uInt16 &rnCols, sal_uInt16 &rnLines) const
Definition: listbox.cxx:1319
void SelectEntryPos(sal_Int32 nPos, bool bSelect=true)
Definition: listbox.cxx:1026
Link< ListBox &, void > maSelectHdl
Definition: lstbox.hxx:91
Size CalcBlockSize(sal_uInt16 nColumns, sal_uInt16 nLines) const
Definition: listbox.cxx:1279
VclPtr< ImplListBoxFloatingWindow > mpFloatWin
Definition: lstbox.hxx:86
virtual FactoryFunction GetUITestFactory() const override
Definition: listbox.cxx:1414
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:1001
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:1085
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: listbox.cxx:1391
VclPtr< ImplBtn > mpBtn
Definition: lstbox.hxx:88
virtual const Wallpaper & GetDisplayBackground() const override
Definition: listbox.cxx:1375
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:1419
void SetReadOnly(bool bReadOnly=true)
Definition: listbox.cxx:1336
sal_uInt16 GetDropDownLineCount() const
Definition: listbox.cxx:530
void setMaxWidthChars(sal_Int32 nWidth)
Definition: listbox.cxx:1382
tools::Long GetIndexForPoint(const Point &rPoint, sal_Int32 &rPos) const
Definition: listbox.cxx:649
OUString GetEntry(sal_Int32 nPos) const
Definition: listbox.cxx:975
void RemoveEntry(sal_Int32 nPos)
Definition: listbox.cxx:952
VclPtr< ImplWin > mpImplWin
Definition: lstbox.hxx:87
void SetHighlightColor(const Color &rColor)
Definition: listbox.cxx:1143
void Clear()
Definition: listbox.cxx:907
void AdaptDropDownLineCountToMaximum()
Definition: listbox.cxx:520
void AddSeparator(sal_Int32 n)
Adds a new separator at the given position n.
Definition: listbox.cxx:1360
Image GetEntryImage(sal_Int32 nPos) const
Definition: listbox.cxx:958
Size CalcMinimumSize() const
Definition: listbox.cxx:1165
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:1250
bool IsAutoSizeEnabled() const
Definition: lstbox.hxx:150
bool IsTravelSelect() const
Definition: listbox.cxx:1103
void DoubleClick()
Definition: listbox.cxx:902
SAL_DLLPRIVATE void ImplInitListBoxData()
Definition: listbox.cxx:67
void SetEntryData(sal_Int32 nPos, void *pNewData)
Definition: listbox.cxx:1075
void SelectEntriesPos(const std::vector< sal_Int32 > &rPositions, bool bSelect=true)
Definition: listbox.cxx:1045
void * GetEntryData(sal_Int32 nPos) const
Definition: listbox.cxx:1080
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:1355
void SelectEntry(std::u16string_view rStr, bool bSelect=true)
Definition: listbox.cxx:1021
void SetTopEntry(sal_Int32 nPos)
Definition: listbox.cxx:1090
virtual void FillLayoutData() const override
Definition: listbox.cxx:627
OUString GetSelectedEntry(sal_Int32 nSelIndex=0) const
Definition: listbox.cxx:989
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: listbox.cxx:78
tools::Rectangle GetDropDownPosSizePixel() const
Definition: listbox.cxx:1370
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: listbox.cxx:812
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=LISTBOX_APPEND)
Definition: listbox.cxx:936
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:171
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:610
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:892
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)
void SetPressed(bool bPressed)
Definition: button.cxx:1664
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(const char *pPropName, const OUString &rPropValue)
ScopedJsonWriterArray startArray(const char *)
void putSimpleValue(const OUString &rPropValue)
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:2869
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2810
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:1966
void SetFont(const vcl::Font &rNewFont)
Definition: window3.cxx:59
void SetUpdateMode(bool bUpdate)
Definition: window.cxx:2974
bool IsNativeWidgetEnabled() const
Definition: window.cxx:3711
bool IsReallyVisible() const
Definition: window2.cxx:1138
virtual void GetFocus()
Definition: window.cxx:1845
void SetControlForeground()
Definition: window2.cxx:481
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3011
Point LogicToPixel(const Point &rLogicPt) const
Definition: window3.cxx:131
void SetControlFont()
Definition: window2.cxx:433
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1293
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: window.cxx:2428
tools::Long CalcZoom(tools::Long n) const
Definition: window2.cxx:421
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1035
void HideFocus()
Definition: window2.cxx:95
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1358
const Color & GetControlForeground() const
Definition: window2.cxx:1103
void GrabFocus()
Definition: window.cxx:2983
void SetControlBackground()
Definition: window2.cxx:521
bool IsUpdateMode() const
Definition: window2.cxx:1204
bool HasFocus() const
Definition: window.cxx:2988
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:577
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:2437
WinBits GetStyle() const
Definition: window2.cxx:984
const Fraction & GetZoom() const
Definition: window2.cxx:1241
const AllSettings & GetSettings() const
Definition: window3.cxx:129
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2191
Size CalcWindowSize(const Size &rOutSz) const
Definition: window2.cxx:561
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:462
::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:2670
const vcl::Font & GetFont() const
Definition: window3.cxx:58
SAL_DLLPRIVATE float approximate_char_width() const
Definition: window3.cxx:61
tools::Rectangle GetWindowExtentsRelative(const vcl::Window *pRelativeWindow) const
Definition: window.cxx:2917
void RequestDoubleBuffering(bool bRequest)
Enable/disable double-buffering of the frame window and all its children.
Definition: window.cxx:3866
void SetSettings(const AllSettings &rSettings)
Definition: window3.cxx:208
void SetZoom(const Fraction &rZoom)
Definition: window2.cxx:394
tools::Long GetDrawPixel(::OutputDevice const *pDev, tools::Long nPixels) const
Definition: window2.cxx:587
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:3365
bool IsRTLEnabled() const
Definition: window3.cxx:127
Point PixelToLogic(const Point &rDevicePt) const
Definition: window3.cxx:161
virtual Size GetSizePixel() const
Definition: window.cxx:2406
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool IsControlBackground() const
Definition: window2.cxx:1118
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1483
virtual void LoseFocus()
Definition: window.cxx:1859
const Color & GetControlBackground() const
Definition: window2.cxx:1113
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1288
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
Definition: window.cxx:2859
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
Definition: mouse.cxx:675
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2816
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
Definition: window2.cxx:1299
bool IsEnabled() const
Definition: window2.cxx:1153
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:942
void SetCompoundControl(bool bCompound)
Definition: window2.cxx:978
void SetTextColor(const Color &rColor)
Definition: window3.cxx:108
void SetBackground()
Definition: window3.cxx:100
SAL_DLLPRIVATE void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3899
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:76
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