1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_LISTBOX_HXX
21 #define INCLUDED_VCL_INC_LISTBOX_HXX
23 #include <sal/config.h>
25 #include <o3tl/safeint.hxx>
27 #include <vcl/toolkit/button.hxx>
28 #include <vcl/toolkit/floatwin.hxx>
29 #include <vcl/quickselectionengine.hxx>
30 #include <vcl/vcllayout.hxx>
32 #include "glyphid.hxx"
42 #define IMG_TXT_DISTANCE 6
55 SalLayoutGlyphs maStrGlyphs
;
59 ListBoxEntryFlags mnFlags
;
62 tools::Long
getHeightWithMargin() const;
64 ImplEntryType( OUString aStr
, Image aImage
) :
65 maStr(std::move( aStr
)),
66 maImage(std::move( aImage
)),
67 mnFlags( ListBoxEntryFlags::NONE
),
74 ImplEntryType( OUString aStr
) :
75 maStr(std::move( aStr
)),
76 mnFlags( ListBoxEntryFlags::NONE
),
83 /// Computes maStr's text layout (glyphs), cached in maStrGlyphs.
84 SalLayoutGlyphs
* GetTextGlyphs(const OutputDevice
* pOutputDevice
);
90 VclPtr
<vcl::Window
> mpWindow
; ///< For getting the current locale when matching strings
91 sal_Int32 mnLastSelected
;
92 sal_Int32 mnSelectionAnchor
;
96 sal_Int32 mnMaxMRUCount
;
98 Link
<sal_Int32
,void> maSelectionChangedHdl
;
99 bool mbCallSelectionChangedHdl
;
100 std::vector
<std::unique_ptr
<ImplEntryType
> > maEntries
;
102 ImplEntryType
* GetEntry( sal_Int32 nPos
) const
104 if (nPos
< 0 || o3tl::make_unsigned(nPos
) >= maEntries
.size())
106 return maEntries
[nPos
].get();
110 ImplEntryList( vcl::Window
* pWindow
);
113 sal_Int32
InsertEntry( sal_Int32 nPos
, ImplEntryType
* pNewEntry
, bool bSort
);
114 void RemoveEntry( sal_Int32 nPos
);
115 const ImplEntryType
* GetEntryPtr( sal_Int32 nPos
) const { return GetEntry( nPos
); }
116 ImplEntryType
* GetMutableEntryPtr( sal_Int32 nPos
) const { return GetEntry( nPos
); }
120 sal_Int32
FindMatchingEntry( const OUString
& rStr
, sal_Int32 nStart
, bool bLazy
) const;
121 sal_Int32
FindEntry( std::u16string_view rStr
, bool bSearchMRUArea
= false ) const;
123 /// helper: add up heights up to index nEndIndex.
124 /// GetAddedHeight( 0 ) @return 0
125 /// GetAddedHeight( LISTBOX_ENTRY_NOTFOUND ) @return 0
126 /// GetAddedHeight( i, k ) with k > i is equivalent -GetAddedHeight( k, i )
127 tools::Long
GetAddedHeight( sal_Int32 nEndIndex
, sal_Int32 nBeginIndex
) const;
128 tools::Long
GetEntryHeight( sal_Int32 nPos
) const;
130 sal_Int32
GetEntryCount() const { return static_cast<sal_Int32
>(maEntries
.size()); }
131 bool HasImages() const { return mnImages
!= 0; }
133 OUString
GetEntryText( sal_Int32 nPos
) const;
135 bool HasEntryImage( sal_Int32 nPos
) const;
136 Image
GetEntryImage( sal_Int32 nPos
) const;
138 void SetEntryData( sal_Int32 nPos
, void* pNewData
);
139 void* GetEntryData( sal_Int32 nPos
) const;
141 void SetEntryFlags( sal_Int32 nPos
, ListBoxEntryFlags nFlags
);
143 void SelectEntry( sal_Int32 nPos
, bool bSelect
);
145 sal_Int32
GetSelectedEntryCount() const;
146 OUString
GetSelectedEntry( sal_Int32 nIndex
) const;
147 sal_Int32
GetSelectedEntryPos( sal_Int32 nIndex
) const;
148 bool IsEntryPosSelected( sal_Int32 nIndex
) const;
150 void SetLastSelected( sal_Int32 nPos
) { mnLastSelected
= nPos
; }
151 sal_Int32
GetLastSelected() const { return mnLastSelected
; }
153 void SetSelectionAnchor( sal_Int32 nPos
) { mnSelectionAnchor
= nPos
; }
154 sal_Int32
GetSelectionAnchor() const { return mnSelectionAnchor
; }
156 void SetSelectionChangedHdl( const Link
<sal_Int32
,void>& rLnk
) { maSelectionChangedHdl
= rLnk
; }
157 void SetCallSelectionChangedHdl( bool bCall
) { mbCallSelectionChangedHdl
= bCall
; }
159 void SetMRUCount( sal_Int32 n
) { mnMRUCount
= n
; }
160 sal_Int32
GetMRUCount() const { return mnMRUCount
; }
162 void SetMaxMRUCount( sal_Int32 n
) { mnMaxMRUCount
= n
; }
163 sal_Int32
GetMaxMRUCount() const { return mnMaxMRUCount
; }
165 /** An Entry is selectable if its mnFlags does not have the
166 ListBoxEntryFlags::DisableSelection flag set. */
167 bool IsEntrySelectable( sal_Int32 nPos
) const;
169 /** @return the first entry found from the given position nPos that is selectable
170 or LISTBOX_ENTRY_NOTFOUND if non is found. If the entry at nPos is not selectable,
171 it returns the first selectable entry after nPos if bForward is true and the
172 first selectable entry after nPos is bForward is false.
174 sal_Int32
FindFirstSelectable( sal_Int32 nPos
, bool bForward
= true ) const;
177 class ImplListBoxWindow final
: public Control
, public vcl::ISearchableStringList
180 ImplEntryList maEntryList
; ///< EntryList
181 tools::Rectangle maFocusRect
;
185 tools::Long mnMaxTxtHeight
; ///< Maximum height of a text item
186 tools::Long mnMaxTxtWidth
; ///< Maximum width of a text item
187 ///< Entry without Image
188 tools::Long mnMaxImgTxtWidth
;///< Maximum width of a text item
190 tools::Long mnMaxImgWidth
; ///< Maximum width of an image item
191 tools::Long mnMaxImgHeight
; ///< Maximum height of an image item
192 tools::Long mnMaxWidth
; ///< Maximum width of an entry
193 tools::Long mnMaxHeight
; ///< Maximum height of an entry
195 sal_Int32 mnCurrentPos
; ///< Position (Focus)
196 sal_Int32 mnTrackingSaveSelection
; ///< Selection before Tracking();
198 std::set
< sal_Int32
> maSeparators
; ///< Separator positions
200 sal_Int32 mnUserDrawEntry
;
202 sal_Int32 mnTop
; ///< output from line on
203 tools::Long mnLeft
; ///< output from column on
204 tools::Long mnTextHeight
; ///< text height
206 sal_uInt16 mnSelectModifier
; ///< Modifiers
208 bool mbHasFocusRect
: 1;
209 bool mbSort
: 1; ///< ListBox sorted
210 bool mbTrack
: 1; ///< Tracking
211 bool mbMulti
: 1; ///< MultiListBox
212 bool mbSimpleMode
: 1; ///< SimpleMode for MultiListBox
213 bool mbTravelSelect
: 1; ///< TravelSelect
214 bool mbTrackingSelect
: 1; ///< Selected at a MouseMove
215 bool mbSelectionChanged
: 1; ///< Do not call Select() too often ...
216 bool mbMouseMoveSelect
: 1; ///< Select at MouseMove
217 bool mbGrabFocus
: 1; ///< Grab focus at MBDown
218 bool mbUserDrawEnabled
: 1; ///< UserDraw possible
219 bool mbInUserDraw
: 1; ///< In UserDraw
220 bool mbReadOnly
: 1; ///< ReadOnly
221 bool mbCenter
: 1; ///< center Text output
222 bool mbRight
: 1; ///< right align Text output
223 bool mbEdgeBlending
: 1;
224 /// Listbox is actually a dropdown (either combobox, or popup window treated as dropdown)
225 bool mbIsDropdown
: 1;
227 Link
<ImplListBoxWindow
*,void> maScrollHdl
;
228 Link
<LinkParamNone
*,void> maSelectHdl
;
229 Link
<LinkParamNone
*,void> maCancelHdl
;
230 Link
<ImplListBoxWindow
*,void> maDoubleClickHdl
;
231 Link
<UserDrawEvent
*, void> maUserDrawHdl
;
232 Link
<LinkParamNone
*,void> maMRUChangedHdl
;
233 Link
<sal_Int32
,void> maFocusHdl
;
234 Link
<LinkParamNone
*,void> maListItemSelectHdl
;
236 vcl::QuickSelectionEngine maQuickSelectionEngine
;
238 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
239 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
240 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
241 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
242 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
243 virtual void Resize() override
;
244 virtual void GetFocus() override
;
245 virtual void LoseFocus() override
;
247 bool SelectEntries( sal_Int32 nSelect
, LB_EVENT_TYPE eLET
, bool bShift
= false, bool bCtrl
= false, bool bSelectPosChange
= false );
248 void ImplPaint(vcl::RenderContext
& rRenderContext
, sal_Int32 nPos
);
249 void ImplDoPaint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
);
250 void ImplCalcMetrics();
251 void ImplUpdateEntryMetrics( ImplEntryType
& rEntry
);
252 void ImplCallSelect();
254 void ImplShowFocusRect();
255 void ImplHideFocusRect();
257 virtual void StateChanged( StateChangedType nType
) override
;
258 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
261 virtual void FillLayoutData() const override
;
263 ImplListBoxWindow( vcl::Window
* pParent
, WinBits nWinStyle
);
264 virtual ~ImplListBoxWindow() override
;
265 virtual void dispose() override
;
267 const ImplEntryList
& GetEntryList() const { return maEntryList
; }
268 ImplEntryList
& GetEntryList() { return maEntryList
; }
270 sal_Int32
InsertEntry( sal_Int32 nPos
, ImplEntryType
* pNewEntry
); // sorts using mbSort
271 sal_Int32
InsertEntry( sal_Int32 nPos
, ImplEntryType
* pNewEntry
, bool bSort
); // to insert ignoring mbSort, e.g. mru
272 void RemoveEntry( sal_Int32 nPos
);
274 void ResetCurrentPos() { mnCurrentPos
= LISTBOX_ENTRY_NOTFOUND
; }
275 sal_Int32
GetCurrentPos() const { return mnCurrentPos
; }
276 sal_uInt16
GetDisplayLineCount() const;
277 void SetEntryFlags( sal_Int32 nPos
, ListBoxEntryFlags nFlags
);
279 void DrawEntry(vcl::RenderContext
& rRenderContext
, sal_Int32 nPos
, bool bDrawImage
, bool bDrawText
);
281 void SelectEntry( sal_Int32 nPos
, bool bSelect
);
283 sal_Int32
GetEntryPosForPoint( const Point
& rPoint
) const;
284 sal_Int32
GetLastVisibleEntry() const;
286 bool ProcessKeyInput( const KeyEvent
& rKEvt
);
288 void SetTopEntry( sal_Int32 nTop
);
289 sal_Int32
GetTopEntry() const { return mnTop
; }
290 /** ShowProminentEntry will set the entry corresponding to nEntryPos
291 either at top or in the middle depending on the chosen style*/
292 void ShowProminentEntry( sal_Int32 nEntryPos
);
293 using Window::IsVisible
;
294 bool IsVisible( sal_Int32 nEntry
) const;
296 tools::Long
GetLeftIndent() const { return mnLeft
; }
297 void SetLeftIndent( tools::Long n
);
298 void ScrollHorz( tools::Long nDiff
);
300 void AllowGrabFocus( bool b
) { mbGrabFocus
= b
; }
301 bool IsGrabFocusAllowed() const { return mbGrabFocus
; }
304 * Removes existing separators, and sets the position of the
305 * one and only separator.
307 void SetSeparatorPos( sal_Int32 n
);
309 * Gets the position of the separator which was added first.
310 * Returns LISTBOX_ENTRY_NOTFOUND if there is no separator.
312 sal_Int32
GetSeparatorPos() const;
315 * Adds a new separator at the given position n.
317 void AddSeparator( sal_Int32 n
) { maSeparators
.insert( n
); }
319 * Checks if the given number n is an element of the separator positions set.
321 bool isSeparator( const sal_Int32
&n
) const;
323 void SetTravelSelect( bool bTravelSelect
) { mbTravelSelect
= bTravelSelect
; }
324 bool IsTravelSelect() const { return mbTravelSelect
; }
325 bool IsTrackingSelect() const { return mbTrackingSelect
; }
327 void SetUserItemSize( const Size
& rSz
);
329 void EnableUserDraw( bool bUserDraw
) { mbUserDrawEnabled
= bUserDraw
; }
330 bool IsUserDrawEnabled() const { return mbUserDrawEnabled
; }
332 void EnableMultiSelection( bool bMulti
) { mbMulti
= bMulti
; }
333 bool IsMultiSelectionEnabled() const { return mbMulti
; }
335 void SetMultiSelectionSimpleMode( bool bSimple
) { mbSimpleMode
= bSimple
; }
337 void EnableMouseMoveSelect( bool bMouseMoveSelect
) { mbMouseMoveSelect
= bMouseMoveSelect
; }
338 bool IsMouseMoveSelect() const { return mbMouseMoveSelect
; }
340 Size
CalcSize(sal_Int32 nMaxLines
) const;
341 tools::Rectangle
GetBoundingRectangle( sal_Int32 nItem
) const;
343 tools::Long
GetEntryHeight() const { return mnMaxHeight
; }
344 tools::Long
GetEntryHeightWithMargin() const;
345 tools::Long
GetMaxEntryWidth() const { return mnMaxWidth
; }
347 void SetScrollHdl( const Link
<ImplListBoxWindow
*,void>& rLink
) { maScrollHdl
= rLink
; }
348 void SetSelectHdl( const Link
<LinkParamNone
*,void>& rLink
) { maSelectHdl
= rLink
; }
349 void SetCancelHdl( const Link
<LinkParamNone
*,void>& rLink
) { maCancelHdl
= rLink
; }
350 void SetDoubleClickHdl( const Link
<ImplListBoxWindow
*,void>& rLink
) { maDoubleClickHdl
= rLink
; }
351 void SetUserDrawHdl( const Link
<UserDrawEvent
*, void>& rLink
) { maUserDrawHdl
= rLink
; }
352 void SetMRUChangedHdl( const Link
<LinkParamNone
*,void>& rLink
) { maMRUChangedHdl
= rLink
; }
353 void SetFocusHdl( const Link
<sal_Int32
,void>& rLink
) { maFocusHdl
= rLink
; }
355 void SetListItemSelectHdl( const Link
<LinkParamNone
*,void>& rLink
) { maListItemSelectHdl
= rLink
; }
356 bool IsSelectionChanged() const { return mbSelectionChanged
; }
357 sal_uInt16
GetSelectModifier() const { return mnSelectModifier
; }
359 void EnableSort( bool b
) { mbSort
= b
; }
361 void SetReadOnly( bool bReadOnly
) { mbReadOnly
= bReadOnly
; }
362 bool IsReadOnly() const { return mbReadOnly
; }
364 DrawTextFlags
ImplGetTextStyle() const;
366 bool GetEdgeBlending() const { return mbEdgeBlending
; }
367 void SetEdgeBlending(bool bNew
) { mbEdgeBlending
= bNew
; }
369 using Control::ImplInitSettings
;
370 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
373 // ISearchableStringList
374 virtual vcl::StringEntryIdentifier
CurrentEntry( OUString
& _out_entryText
) const override
;
375 virtual vcl::StringEntryIdentifier
NextEntry( vcl::StringEntryIdentifier _currentEntry
, OUString
& _out_entryText
) const override
;
376 virtual void SelectEntry( vcl::StringEntryIdentifier _entry
) override
;
379 class ImplListBox final
: public Control
382 VclPtr
<ImplListBoxWindow
> maLBWindow
;
383 VclPtr
<ScrollBar
> mpHScrollBar
;
384 VclPtr
<ScrollBar
> mpVScrollBar
;
385 VclPtr
<ScrollBarBox
> mpScrollBarBox
;
387 bool mbVScroll
: 1; // VScroll on or off
388 bool mbHScroll
: 1; // HScroll on or off
389 bool mbAutoHScroll
: 1; // AutoHScroll on or off
390 bool mbEdgeBlending
: 1;
392 Link
<ImplListBox
*,void> maScrollHdl
; // because it is needed by ImplListBoxWindow itself
394 virtual void GetFocus() override
;
395 virtual void StateChanged( StateChangedType nType
) override
;
397 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
399 void ImplResizeControls();
400 void ImplCheckScrollBars();
401 void ImplInitScrollBars();
403 DECL_LINK( ScrollBarHdl
, ScrollBar
*, void );
404 DECL_LINK( LBWindowScrolled
, ImplListBoxWindow
*, void );
405 DECL_LINK( MRUChanged
, LinkParamNone
*, void );
408 ImplListBox( vcl::Window
* pParent
, WinBits nWinStyle
);
409 virtual ~ImplListBox() override
;
410 virtual void dispose() override
;
412 const ImplEntryList
& GetEntryList() const { return maLBWindow
->GetEntryList(); }
413 ImplListBoxWindow
* GetMainWindow() { return maLBWindow
.get(); }
415 virtual void Resize() override
;
416 virtual const Wallpaper
& GetDisplayBackground() const override
;
418 sal_Int32
InsertEntry( sal_Int32 nPos
, const OUString
& rStr
);
419 sal_Int32
InsertEntry( sal_Int32 nPos
, const OUString
& rStr
, const Image
& rImage
);
420 void RemoveEntry( sal_Int32 nPos
);
421 void SetEntryData( sal_Int32 nPos
, void* pNewData
) { maLBWindow
->GetEntryList().SetEntryData( nPos
, pNewData
); }
424 void SetEntryFlags( sal_Int32 nPos
, ListBoxEntryFlags nFlags
);
426 void SelectEntry( sal_Int32 nPos
, bool bSelect
);
427 void SetNoSelection();
428 void ResetCurrentPos() { maLBWindow
->ResetCurrentPos(); }
429 sal_Int32
GetCurrentPos() const { return maLBWindow
->GetCurrentPos(); }
431 bool ProcessKeyInput( const KeyEvent
& rKEvt
) { return maLBWindow
->ProcessKeyInput( rKEvt
); }
432 bool HandleWheelAsCursorTravel(const CommandEvent
& rCEvt
, Control
& rControl
);
435 * Removes existing separators, and sets the position of the
436 * one and only separator.
438 void SetSeparatorPos( sal_Int32 n
) { maLBWindow
->SetSeparatorPos( n
); }
440 * Gets the position of the separator which was added first.
441 * Returns LISTBOX_ENTRY_NOTFOUND if there is no separator.
443 sal_Int32
GetSeparatorPos() const { return maLBWindow
->GetSeparatorPos(); }
446 * Adds a new separator at the given position n.
448 void AddSeparator( sal_Int32 n
) { maLBWindow
->AddSeparator( n
); }
450 void SetTopEntry( sal_Int32 nTop
) { maLBWindow
->SetTopEntry( nTop
); }
451 sal_Int32
GetTopEntry() const { return maLBWindow
->GetTopEntry(); }
452 void ShowProminentEntry( sal_Int32 nPos
) { maLBWindow
->ShowProminentEntry( nPos
); }
453 using Window::IsVisible
;
454 bool IsVisible( sal_Int32 nEntry
) const { return maLBWindow
->IsVisible( nEntry
); }
456 tools::Long
GetLeftIndent() const { return maLBWindow
->GetLeftIndent(); }
457 void SetLeftIndent( sal_uInt16 n
) { maLBWindow
->SetLeftIndent( n
); }
459 void SetTravelSelect( bool bTravelSelect
) { maLBWindow
->SetTravelSelect( bTravelSelect
); }
460 bool IsTravelSelect() const { return maLBWindow
->IsTravelSelect(); }
461 bool IsTrackingSelect() const { return maLBWindow
->IsTrackingSelect(); }
463 void EnableMultiSelection( bool bMulti
) { maLBWindow
->EnableMultiSelection( bMulti
); }
464 bool IsMultiSelectionEnabled() const { return maLBWindow
->IsMultiSelectionEnabled(); }
466 void SetMultiSelectionSimpleMode( bool bSimple
) { maLBWindow
->SetMultiSelectionSimpleMode( bSimple
); }
468 void SetReadOnly( bool b
) { maLBWindow
->SetReadOnly( b
); }
469 bool IsReadOnly() const { return maLBWindow
->IsReadOnly(); }
471 Size
CalcSize( sal_Int32 nMaxLines
) const { return maLBWindow
->CalcSize( nMaxLines
); }
472 tools::Long
GetEntryHeight() const { return maLBWindow
->GetEntryHeight(); }
473 tools::Long
GetEntryHeightWithMargin() const{ return maLBWindow
->GetEntryHeightWithMargin(); }
474 tools::Long
GetMaxEntryWidth() const { return maLBWindow
->GetMaxEntryWidth(); }
476 void SetScrollHdl( const Link
<ImplListBox
*,void>& rLink
) { maScrollHdl
= rLink
; }
477 void SetSelectHdl( const Link
<LinkParamNone
*,void>& rLink
) { maLBWindow
->SetSelectHdl( rLink
); }
478 void SetCancelHdl( const Link
<LinkParamNone
*,void>& rLink
) { maLBWindow
->SetCancelHdl( rLink
); }
479 void SetDoubleClickHdl( const Link
<ImplListBoxWindow
*,void>& rLink
) { maLBWindow
->SetDoubleClickHdl( rLink
); }
480 void SetUserDrawHdl( const Link
<UserDrawEvent
*, void>& rLink
) { maLBWindow
->SetUserDrawHdl( rLink
); }
481 void SetFocusHdl( const Link
<sal_Int32
,void>& rLink
) { maLBWindow
->SetFocusHdl( rLink
); }
482 void SetListItemSelectHdl( const Link
<LinkParamNone
*,void>& rLink
) { maLBWindow
->SetListItemSelectHdl( rLink
); }
483 void SetSelectionChangedHdl( const Link
<sal_Int32
,void>& rLnk
) { maLBWindow
->GetEntryList().SetSelectionChangedHdl( rLnk
); }
484 void SetCallSelectionChangedHdl( bool bCall
) { maLBWindow
->GetEntryList().SetCallSelectionChangedHdl( bCall
); }
485 bool IsSelectionChanged() const { return maLBWindow
->IsSelectionChanged(); }
486 sal_uInt16
GetSelectModifier() const { return maLBWindow
->GetSelectModifier(); }
487 void SetHighlightColor(const Color
& rColor
);
488 void SetHighlightTextColor(const Color
& rColor
);
490 void SetMRUEntries( std::u16string_view rEntries
, sal_Unicode cSep
);
491 OUString
GetMRUEntries( sal_Unicode cSep
) const;
492 void SetMaxMRUCount( sal_Int32 n
) { maLBWindow
->GetEntryList().SetMaxMRUCount( n
); }
493 sal_Int32
GetMaxMRUCount() const { return maLBWindow
->GetEntryList().GetMaxMRUCount(); }
494 sal_uInt16
GetDisplayLineCount() const
495 { return maLBWindow
->GetDisplayLineCount(); }
497 bool GetEdgeBlending() const { return mbEdgeBlending
; }
498 void SetEdgeBlending(bool bNew
);
501 class ImplListBoxFloatingWindow final
: public FloatingWindow
504 VclPtr
<ImplListBox
> mpImplLB
;
506 sal_uInt16 mnDDLineCount
;
507 sal_Int32 mnPopupModeStartSaveSelection
;
510 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
513 ImplListBoxFloatingWindow( vcl::Window
* pParent
);
514 virtual ~ImplListBoxFloatingWindow() override
;
515 virtual void dispose() override
;
516 void SetImplListBox( ImplListBox
* pLB
) { mpImplLB
= pLB
; }
518 void SetPrefSize( const Size
& rSz
) { maPrefSz
= rSz
; }
519 const Size
& GetPrefSize() const { return maPrefSz
; }
521 void SetAutoWidth( bool b
) { mbAutoWidth
= b
; }
523 Size
CalcFloatSize() const;
524 void StartFloat( bool bStartTracking
);
526 virtual void setPosSizePixel( tools::Long nX
, tools::Long nY
,
527 tools::Long nWidth
, tools::Long nHeight
, PosSizeFlags nFlags
= PosSizeFlags::All
) override
;
529 void SetDropDownLineCount( sal_uInt16 n
) { mnDDLineCount
= n
; }
530 sal_uInt16
GetDropDownLineCount() const { return mnDDLineCount
; }
532 sal_Int32
GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection
; }
534 virtual void Resize() override
;
537 class ImplWin final
: public Control
541 sal_Int32 mnItemPos
; ///< because of UserDraw I have to know which item I draw
545 tools::Rectangle maFocusRect
;
547 Link
<void*,void> maMBDownHdl
;
549 bool mbEdgeBlending
: 1;
551 void ImplDraw(vcl::RenderContext
& rRenderContext
, bool bLayout
= false);
552 virtual void FillLayoutData() const override
;
555 ImplWin( vcl::Window
* pParent
, WinBits nWinStyle
);
557 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
558 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
559 virtual void Resize() override
;
560 virtual void GetFocus() override
;
561 virtual void LoseFocus() override
;
563 sal_Int32
GetItemPos() const { return mnItemPos
; }
564 void SetItemPos( sal_Int32 n
) { mnItemPos
= n
; }
566 void SetString( const OUString
& rStr
) { maString
= rStr
; }
568 void SetImage( const Image
& rImg
) { maImage
= rImg
; }
570 void SetMBDownHdl( const Link
<void*,void>& rLink
) { maMBDownHdl
= rLink
; }
572 void DrawEntry(vcl::RenderContext
& rRenderContext
, bool bLayout
);
574 bool GetEdgeBlending() const { return mbEdgeBlending
; }
575 void SetEdgeBlending(bool bNew
) { mbEdgeBlending
= bNew
; }
577 virtual void ShowFocus(const tools::Rectangle
& rRect
) override
;
579 using Control::ImplInitSettings
;
580 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
584 class ImplBtn final
: public PushButton
587 Link
<void*,void> maMBDownHdl
;
590 ImplBtn( vcl::Window
* pParent
, WinBits nWinStyle
);
592 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
593 void SetMBDownHdl( const Link
<void*,void>& rLink
) { maMBDownHdl
= rLink
; }
596 void ImplInitDropDownButton( PushButton
* pButton
);
598 #endif // INCLUDED_VCL_INC_LISTBOX_HXX
600 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */