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>
26 #include <vcl/toolkit/button.hxx>
27 #include <vcl/toolkit/floatwin.hxx>
28 #include <vcl/quickselectionengine.hxx>
29 #include <vcl/glyphitem.hxx>
30 #include <vcl/vcllayout.hxx>
40 #define IMG_TXT_DISTANCE 6
53 SalLayoutGlyphs maStrGlyphs
;
57 ListBoxEntryFlags mnFlags
;
60 tools::Long
getHeightWithMargin() const;
62 ImplEntryType( const OUString
& rStr
, const Image
& rImage
) :
65 mnFlags( ListBoxEntryFlags::NONE
),
72 ImplEntryType( const OUString
& rStr
) :
74 mnFlags( ListBoxEntryFlags::NONE
),
81 /// Computes maStr's text layout (glyphs), cached in maStrGlyphs.
82 SalLayoutGlyphs
* GetTextGlyphs(const OutputDevice
* pOutputDevice
);
88 VclPtr
<vcl::Window
> mpWindow
; ///< For getting the current locale when matching strings
89 sal_Int32 mnLastSelected
;
90 sal_Int32 mnSelectionAnchor
;
94 sal_Int32 mnMaxMRUCount
;
96 Link
<sal_Int32
,void> maSelectionChangedHdl
;
97 bool mbCallSelectionChangedHdl
;
98 std::vector
<std::unique_ptr
<ImplEntryType
> > maEntries
;
100 ImplEntryType
* GetEntry( sal_Int32 nPos
) const
102 if (nPos
< 0 || o3tl::make_unsigned(nPos
) >= maEntries
.size())
104 return maEntries
[nPos
].get();
108 ImplEntryList( vcl::Window
* pWindow
);
111 sal_Int32
InsertEntry( sal_Int32 nPos
, ImplEntryType
* pNewEntry
, bool bSort
);
112 void RemoveEntry( sal_Int32 nPos
);
113 const ImplEntryType
* GetEntryPtr( sal_Int32 nPos
) const { return GetEntry( nPos
); }
114 ImplEntryType
* GetMutableEntryPtr( sal_Int32 nPos
) const { return GetEntry( nPos
); }
117 sal_Int32
FindMatchingEntry( const OUString
& rStr
, sal_Int32 nStart
, bool bLazy
) const;
118 sal_Int32
FindEntry( std::u16string_view rStr
, bool bSearchMRUArea
= false ) const;
120 /// helper: add up heights up to index nEndIndex.
121 /// GetAddedHeight( 0 ) @return 0
122 /// GetAddedHeight( LISTBOX_ENTRY_NOTFOUND ) @return 0
123 /// GetAddedHeight( i, k ) with k > i is equivalent -GetAddedHeight( k, i )
124 tools::Long
GetAddedHeight( sal_Int32 nEndIndex
, sal_Int32 nBeginIndex
) const;
125 tools::Long
GetEntryHeight( sal_Int32 nPos
) const;
127 sal_Int32
GetEntryCount() const { return static_cast<sal_Int32
>(maEntries
.size()); }
128 bool HasImages() const { return mnImages
!= 0; }
130 OUString
GetEntryText( sal_Int32 nPos
) const;
132 bool HasEntryImage( sal_Int32 nPos
) const;
133 Image
GetEntryImage( sal_Int32 nPos
) const;
135 void SetEntryData( sal_Int32 nPos
, void* pNewData
);
136 void* GetEntryData( sal_Int32 nPos
) const;
138 void SetEntryFlags( sal_Int32 nPos
, ListBoxEntryFlags nFlags
);
140 void SelectEntry( sal_Int32 nPos
, bool bSelect
);
142 sal_Int32
GetSelectedEntryCount() const;
143 OUString
GetSelectedEntry( sal_Int32 nIndex
) const;
144 sal_Int32
GetSelectedEntryPos( sal_Int32 nIndex
) const;
145 bool IsEntryPosSelected( sal_Int32 nIndex
) const;
147 void SetLastSelected( sal_Int32 nPos
) { mnLastSelected
= nPos
; }
148 sal_Int32
GetLastSelected() const { return mnLastSelected
; }
150 void SetSelectionAnchor( sal_Int32 nPos
) { mnSelectionAnchor
= nPos
; }
151 sal_Int32
GetSelectionAnchor() const { return mnSelectionAnchor
; }
153 void SetSelectionChangedHdl( const Link
<sal_Int32
,void>& rLnk
) { maSelectionChangedHdl
= rLnk
; }
154 void SetCallSelectionChangedHdl( bool bCall
) { mbCallSelectionChangedHdl
= bCall
; }
156 void SetMRUCount( sal_Int32 n
) { mnMRUCount
= n
; }
157 sal_Int32
GetMRUCount() const { return mnMRUCount
; }
159 void SetMaxMRUCount( sal_Int32 n
) { mnMaxMRUCount
= n
; }
160 sal_Int32
GetMaxMRUCount() const { return mnMaxMRUCount
; }
162 /** An Entry is selectable if its mnFlags does not have the
163 ListBoxEntryFlags::DisableSelection flag set. */
164 bool IsEntrySelectable( sal_Int32 nPos
) const;
166 /** @return the first entry found from the given position nPos that is selectable
167 or LISTBOX_ENTRY_NOTFOUND if non is found. If the entry at nPos is not selectable,
168 it returns the first selectable entry after nPos if bForward is true and the
169 first selectable entry after nPos is bForward is false.
171 sal_Int32
FindFirstSelectable( sal_Int32 nPos
, bool bForward
= true );
174 class ImplListBoxWindow
: public Control
, public vcl::ISearchableStringList
177 std::unique_ptr
<ImplEntryList
> mpEntryList
; ///< EntryList
178 tools::Rectangle maFocusRect
;
182 tools::Long mnMaxTxtHeight
; ///< Maximum height of a text item
183 tools::Long mnMaxTxtWidth
; ///< Maximum width of a text item
184 ///< Entry without Image
185 tools::Long mnMaxImgTxtWidth
;///< Maximum width of a text item
187 tools::Long mnMaxImgWidth
; ///< Maximum width of an image item
188 tools::Long mnMaxImgHeight
; ///< Maximum height of an image item
189 tools::Long mnMaxWidth
; ///< Maximum width of an entry
190 tools::Long mnMaxHeight
; ///< Maximum height of an entry
192 sal_Int32 mnCurrentPos
; ///< Position (Focus)
193 sal_Int32 mnTrackingSaveSelection
; ///< Selection before Tracking();
195 std::set
< sal_Int32
> maSeparators
; ///< Separator positions
197 sal_Int32 mnUserDrawEntry
;
199 sal_Int32 mnTop
; ///< output from line on
200 tools::Long mnLeft
; ///< output from column on
201 tools::Long mnTextHeight
; ///< text height
203 sal_uInt16 mnSelectModifier
; ///< Modifiers
205 bool mbHasFocusRect
: 1;
206 bool mbSort
: 1; ///< ListBox sorted
207 bool mbTrack
: 1; ///< Tracking
208 bool mbMulti
: 1; ///< MultiListBox
209 bool mbSimpleMode
: 1; ///< SimpleMode for MultiListBox
210 bool mbTravelSelect
: 1; ///< TravelSelect
211 bool mbTrackingSelect
: 1; ///< Selected at a MouseMove
212 bool mbSelectionChanged
: 1; ///< Do not call Select() too often ...
213 bool mbMouseMoveSelect
: 1; ///< Select at MouseMove
214 bool mbGrabFocus
: 1; ///< Grab focus at MBDown
215 bool mbUserDrawEnabled
: 1; ///< UserDraw possible
216 bool mbInUserDraw
: 1; ///< In UserDraw
217 bool mbReadOnly
: 1; ///< ReadOnly
218 bool mbCenter
: 1; ///< center Text output
219 bool mbRight
: 1; ///< right align Text output
220 bool mbEdgeBlending
: 1;
221 /// Listbox is actually a dropdown (either combobox, or popup window treated as dropdown)
222 bool mbIsDropdown
: 1;
224 Link
<ImplListBoxWindow
*,void> maScrollHdl
;
225 Link
<LinkParamNone
*,void> maSelectHdl
;
226 Link
<LinkParamNone
*,void> maCancelHdl
;
227 Link
<ImplListBoxWindow
*,void> maDoubleClickHdl
;
228 Link
<UserDrawEvent
*, void> maUserDrawHdl
;
229 Link
<LinkParamNone
*,void> maMRUChangedHdl
;
230 Link
<sal_Int32
,void> maFocusHdl
;
231 Link
<LinkParamNone
*,void> maListItemSelectHdl
;
233 vcl::QuickSelectionEngine maQuickSelectionEngine
;
236 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
237 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
238 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
239 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
240 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
241 virtual void Resize() override
;
242 virtual void GetFocus() override
;
243 virtual void LoseFocus() override
;
245 bool SelectEntries( sal_Int32 nSelect
, LB_EVENT_TYPE eLET
, bool bShift
= false, bool bCtrl
= false, bool bSelectPosChange
= false );
246 void ImplPaint(vcl::RenderContext
& rRenderContext
, sal_Int32 nPos
);
247 void ImplDoPaint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
);
248 void ImplCalcMetrics();
249 void ImplUpdateEntryMetrics( ImplEntryType
& rEntry
);
250 void ImplCallSelect();
252 void ImplShowFocusRect();
253 void ImplHideFocusRect();
255 virtual void StateChanged( StateChangedType nType
) override
;
256 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
259 virtual void FillLayoutData() const override
;
261 ImplListBoxWindow( vcl::Window
* pParent
, WinBits nWinStyle
);
262 virtual ~ImplListBoxWindow() override
;
263 virtual void dispose() override
;
265 ImplEntryList
* GetEntryList() const { return mpEntryList
.get(); }
267 sal_Int32
InsertEntry( sal_Int32 nPos
, ImplEntryType
* pNewEntry
); // sorts using mbSort
268 sal_Int32
InsertEntry( sal_Int32 nPos
, ImplEntryType
* pNewEntry
, bool bSort
); // to insert ignoring mbSort, e.g. mru
269 void RemoveEntry( sal_Int32 nPos
);
271 void ResetCurrentPos() { mnCurrentPos
= LISTBOX_ENTRY_NOTFOUND
; }
272 sal_Int32
GetCurrentPos() const { return mnCurrentPos
; }
273 sal_uInt16
GetDisplayLineCount() const;
274 void SetEntryFlags( sal_Int32 nPos
, ListBoxEntryFlags nFlags
);
276 void DrawEntry(vcl::RenderContext
& rRenderContext
, sal_Int32 nPos
, bool bDrawImage
, bool bDrawText
);
278 void SelectEntry( sal_Int32 nPos
, bool bSelect
);
280 sal_Int32
GetEntryPosForPoint( const Point
& rPoint
) const;
281 sal_Int32
GetLastVisibleEntry() const;
283 bool ProcessKeyInput( const KeyEvent
& rKEvt
);
285 void SetTopEntry( sal_Int32 nTop
);
286 sal_Int32
GetTopEntry() const { return mnTop
; }
287 /** ShowProminentEntry will set the entry corresponding to nEntryPos
288 either at top or in the middle depending on the chosen style*/
289 void ShowProminentEntry( sal_Int32 nEntryPos
);
290 using Window::IsVisible
;
291 bool IsVisible( sal_Int32 nEntry
) const;
293 tools::Long
GetLeftIndent() const { return mnLeft
; }
294 void SetLeftIndent( tools::Long n
);
295 void ScrollHorz( tools::Long nDiff
);
297 void AllowGrabFocus( bool b
) { mbGrabFocus
= b
; }
298 bool IsGrabFocusAllowed() const { return mbGrabFocus
; }
301 * Removes existing separators, and sets the position of the
302 * one and only separator.
304 void SetSeparatorPos( sal_Int32 n
);
306 * Gets the position of the separator which was added first.
307 * Returns LISTBOX_ENTRY_NOTFOUND if there is no separator.
309 sal_Int32
GetSeparatorPos() const;
312 * Adds a new separator at the given position n.
314 void AddSeparator( sal_Int32 n
) { maSeparators
.insert( n
); }
316 * Checks if the given number n is an element of the separator positions set.
318 bool isSeparator( const sal_Int32
&n
) const;
320 void SetTravelSelect( bool bTravelSelect
) { mbTravelSelect
= bTravelSelect
; }
321 bool IsTravelSelect() const { return mbTravelSelect
; }
322 bool IsTrackingSelect() const { return mbTrackingSelect
; }
324 void SetUserItemSize( const Size
& rSz
);
326 void EnableUserDraw( bool bUserDraw
) { mbUserDrawEnabled
= bUserDraw
; }
327 bool IsUserDrawEnabled() const { return mbUserDrawEnabled
; }
329 void EnableMultiSelection( bool bMulti
) { mbMulti
= bMulti
; }
330 bool IsMultiSelectionEnabled() const { return mbMulti
; }
332 void SetMultiSelectionSimpleMode( bool bSimple
) { mbSimpleMode
= bSimple
; }
334 void EnableMouseMoveSelect( bool bMouseMoveSelect
) { mbMouseMoveSelect
= bMouseMoveSelect
; }
335 bool IsMouseMoveSelect() const { return mbMouseMoveSelect
; }
337 Size
CalcSize(sal_Int32 nMaxLines
) const;
338 tools::Rectangle
GetBoundingRectangle( sal_Int32 nItem
) const;
340 tools::Long
GetEntryHeight() const { return mnMaxHeight
; }
341 tools::Long
GetEntryHeightWithMargin() const;
342 tools::Long
GetMaxEntryWidth() const { return mnMaxWidth
; }
344 void SetScrollHdl( const Link
<ImplListBoxWindow
*,void>& rLink
) { maScrollHdl
= rLink
; }
345 void SetSelectHdl( const Link
<LinkParamNone
*,void>& rLink
) { maSelectHdl
= rLink
; }
346 void SetCancelHdl( const Link
<LinkParamNone
*,void>& rLink
) { maCancelHdl
= rLink
; }
347 void SetDoubleClickHdl( const Link
<ImplListBoxWindow
*,void>& rLink
) { maDoubleClickHdl
= rLink
; }
348 void SetUserDrawHdl( const Link
<UserDrawEvent
*, void>& rLink
) { maUserDrawHdl
= rLink
; }
349 void SetMRUChangedHdl( const Link
<LinkParamNone
*,void>& rLink
) { maMRUChangedHdl
= rLink
; }
350 void SetFocusHdl( const Link
<sal_Int32
,void>& rLink
) { maFocusHdl
= rLink
; }
352 void SetListItemSelectHdl( const Link
<LinkParamNone
*,void>& rLink
) { maListItemSelectHdl
= rLink
; }
353 bool IsSelectionChanged() const { return mbSelectionChanged
; }
354 sal_uInt16
GetSelectModifier() const { return mnSelectModifier
; }
356 void EnableSort( bool b
) { mbSort
= b
; }
358 void SetReadOnly( bool bReadOnly
) { mbReadOnly
= bReadOnly
; }
359 bool IsReadOnly() const { return mbReadOnly
; }
361 DrawTextFlags
ImplGetTextStyle() const;
363 bool GetEdgeBlending() const { return mbEdgeBlending
; }
364 void SetEdgeBlending(bool bNew
) { mbEdgeBlending
= bNew
; }
366 using Control::ImplInitSettings
;
367 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
370 // ISearchableStringList
371 virtual vcl::StringEntryIdentifier
CurrentEntry( OUString
& _out_entryText
) const override
;
372 virtual vcl::StringEntryIdentifier
NextEntry( vcl::StringEntryIdentifier _currentEntry
, OUString
& _out_entryText
) const override
;
373 virtual void SelectEntry( vcl::StringEntryIdentifier _entry
) override
;
376 class ImplListBox
: public Control
379 VclPtr
<ImplListBoxWindow
> maLBWindow
;
380 VclPtr
<ScrollBar
> mpHScrollBar
;
381 VclPtr
<ScrollBar
> mpVScrollBar
;
382 VclPtr
<ScrollBarBox
> mpScrollBarBox
;
384 bool mbVScroll
: 1; // VScroll on or off
385 bool mbHScroll
: 1; // HScroll on or off
386 bool mbAutoHScroll
: 1; // AutoHScroll on or off
387 bool mbEdgeBlending
: 1;
389 Link
<ImplListBox
*,void> maScrollHdl
; // because it is needed by ImplListBoxWindow itself
392 virtual void GetFocus() override
;
393 virtual void StateChanged( StateChangedType nType
) override
;
395 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
397 void ImplResizeControls();
398 void ImplCheckScrollBars();
399 void ImplInitScrollBars();
401 DECL_LINK( ScrollBarHdl
, ScrollBar
*, void );
402 DECL_LINK( LBWindowScrolled
, ImplListBoxWindow
*, void );
403 DECL_LINK( MRUChanged
, LinkParamNone
*, void );
406 ImplListBox( vcl::Window
* pParent
, WinBits nWinStyle
);
407 virtual ~ImplListBox() override
;
408 virtual void dispose() override
;
410 const ImplEntryList
* GetEntryList() const { return maLBWindow
->GetEntryList(); }
411 ImplListBoxWindow
* GetMainWindow() { return maLBWindow
.get(); }
413 virtual void Resize() override
;
414 virtual const Wallpaper
& GetDisplayBackground() const override
;
416 sal_Int32
InsertEntry( sal_Int32 nPos
, const OUString
& rStr
);
417 sal_Int32
InsertEntry( sal_Int32 nPos
, const OUString
& rStr
, const Image
& rImage
);
418 void RemoveEntry( sal_Int32 nPos
);
419 void SetEntryData( sal_Int32 nPos
, void* pNewData
) { maLBWindow
->GetEntryList()->SetEntryData( nPos
, pNewData
); }
422 void SetEntryFlags( sal_Int32 nPos
, ListBoxEntryFlags nFlags
);
424 void SelectEntry( sal_Int32 nPos
, bool bSelect
);
425 void SetNoSelection();
426 void ResetCurrentPos() { maLBWindow
->ResetCurrentPos(); }
427 sal_Int32
GetCurrentPos() const { return maLBWindow
->GetCurrentPos(); }
429 bool ProcessKeyInput( const KeyEvent
& rKEvt
) { return maLBWindow
->ProcessKeyInput( rKEvt
); }
430 bool HandleWheelAsCursorTravel(const CommandEvent
& rCEvt
, Control
& rControl
);
433 * Removes existing separators, and sets the position of the
434 * one and only separator.
436 void SetSeparatorPos( sal_Int32 n
) { maLBWindow
->SetSeparatorPos( n
); }
438 * Gets the position of the separator which was added first.
439 * Returns LISTBOX_ENTRY_NOTFOUND if there is no separator.
441 sal_Int32
GetSeparatorPos() const { return maLBWindow
->GetSeparatorPos(); }
444 * Adds a new separator at the given position n.
446 void AddSeparator( sal_Int32 n
) { maLBWindow
->AddSeparator( n
); }
448 void SetTopEntry( sal_Int32 nTop
) { maLBWindow
->SetTopEntry( nTop
); }
449 sal_Int32
GetTopEntry() const { return maLBWindow
->GetTopEntry(); }
450 void ShowProminentEntry( sal_Int32 nPos
) { maLBWindow
->ShowProminentEntry( nPos
); }
451 using Window::IsVisible
;
452 bool IsVisible( sal_Int32 nEntry
) const { return maLBWindow
->IsVisible( nEntry
); }
454 tools::Long
GetLeftIndent() const { return maLBWindow
->GetLeftIndent(); }
455 void SetLeftIndent( sal_uInt16 n
) { maLBWindow
->SetLeftIndent( n
); }
457 void SetTravelSelect( bool bTravelSelect
) { maLBWindow
->SetTravelSelect( bTravelSelect
); }
458 bool IsTravelSelect() const { return maLBWindow
->IsTravelSelect(); }
459 bool IsTrackingSelect() const { return maLBWindow
->IsTrackingSelect(); }
461 void EnableMultiSelection( bool bMulti
) { maLBWindow
->EnableMultiSelection( bMulti
); }
462 bool IsMultiSelectionEnabled() const { return maLBWindow
->IsMultiSelectionEnabled(); }
464 void SetMultiSelectionSimpleMode( bool bSimple
) { maLBWindow
->SetMultiSelectionSimpleMode( bSimple
); }
466 void SetReadOnly( bool b
) { maLBWindow
->SetReadOnly( b
); }
467 bool IsReadOnly() const { return maLBWindow
->IsReadOnly(); }
469 Size
CalcSize( sal_Int32 nMaxLines
) const { return maLBWindow
->CalcSize( nMaxLines
); }
470 tools::Long
GetEntryHeight() const { return maLBWindow
->GetEntryHeight(); }
471 tools::Long
GetEntryHeightWithMargin() const{ return maLBWindow
->GetEntryHeightWithMargin(); }
472 tools::Long
GetMaxEntryWidth() const { return maLBWindow
->GetMaxEntryWidth(); }
474 void SetScrollHdl( const Link
<ImplListBox
*,void>& rLink
) { maScrollHdl
= rLink
; }
475 void SetSelectHdl( const Link
<LinkParamNone
*,void>& rLink
) { maLBWindow
->SetSelectHdl( rLink
); }
476 void SetCancelHdl( const Link
<LinkParamNone
*,void>& rLink
) { maLBWindow
->SetCancelHdl( rLink
); }
477 void SetDoubleClickHdl( const Link
<ImplListBoxWindow
*,void>& rLink
) { maLBWindow
->SetDoubleClickHdl( rLink
); }
478 void SetUserDrawHdl( const Link
<UserDrawEvent
*, void>& rLink
) { maLBWindow
->SetUserDrawHdl( rLink
); }
479 void SetFocusHdl( const Link
<sal_Int32
,void>& rLink
) { maLBWindow
->SetFocusHdl( rLink
); }
480 void SetListItemSelectHdl( const Link
<LinkParamNone
*,void>& rLink
) { maLBWindow
->SetListItemSelectHdl( rLink
); }
481 void SetSelectionChangedHdl( const Link
<sal_Int32
,void>& rLnk
) { maLBWindow
->GetEntryList()->SetSelectionChangedHdl( rLnk
); }
482 void SetCallSelectionChangedHdl( bool bCall
) { maLBWindow
->GetEntryList()->SetCallSelectionChangedHdl( bCall
); }
483 bool IsSelectionChanged() const { return maLBWindow
->IsSelectionChanged(); }
484 sal_uInt16
GetSelectModifier() const { return maLBWindow
->GetSelectModifier(); }
486 void SetMRUEntries( const OUString
& rEntries
, sal_Unicode cSep
);
487 OUString
GetMRUEntries( sal_Unicode cSep
) const;
488 void SetMaxMRUCount( sal_Int32 n
) { maLBWindow
->GetEntryList()->SetMaxMRUCount( n
); }
489 sal_Int32
GetMaxMRUCount() const { return maLBWindow
->GetEntryList()->GetMaxMRUCount(); }
490 sal_uInt16
GetDisplayLineCount() const
491 { return maLBWindow
->GetDisplayLineCount(); }
493 bool GetEdgeBlending() const { return mbEdgeBlending
; }
494 void SetEdgeBlending(bool bNew
);
497 class ImplListBoxFloatingWindow
: public FloatingWindow
500 VclPtr
<ImplListBox
> mpImplLB
;
502 sal_uInt16 mnDDLineCount
;
503 sal_Int32 mnPopupModeStartSaveSelection
;
507 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
510 ImplListBoxFloatingWindow( vcl::Window
* pParent
);
511 virtual ~ImplListBoxFloatingWindow() override
;
512 virtual void dispose() override
;
513 void SetImplListBox( ImplListBox
* pLB
) { mpImplLB
= pLB
; }
515 void SetPrefSize( const Size
& rSz
) { maPrefSz
= rSz
; }
516 const Size
& GetPrefSize() const { return maPrefSz
; }
518 void SetAutoWidth( bool b
) { mbAutoWidth
= b
; }
520 Size
CalcFloatSize();
521 void StartFloat( bool bStartTracking
);
523 virtual void setPosSizePixel( tools::Long nX
, tools::Long nY
,
524 tools::Long nWidth
, tools::Long nHeight
, PosSizeFlags nFlags
= PosSizeFlags::All
) override
;
526 void SetDropDownLineCount( sal_uInt16 n
) { mnDDLineCount
= n
; }
527 sal_uInt16
GetDropDownLineCount() const { return mnDDLineCount
; }
529 sal_Int32
GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection
; }
531 virtual void Resize() override
;
534 class ImplWin
: public Control
538 sal_Int32 mnItemPos
; ///< because of UserDraw I have to know which item I draw
542 tools::Rectangle maFocusRect
;
544 Link
<void*,void> maMBDownHdl
;
546 bool mbEdgeBlending
: 1;
548 void ImplDraw(vcl::RenderContext
& rRenderContext
, bool bLayout
= false);
550 virtual void FillLayoutData() const override
;
553 ImplWin( vcl::Window
* pParent
, WinBits nWinStyle
);
555 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
556 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
557 virtual void Resize() override
;
558 virtual void GetFocus() override
;
559 virtual void LoseFocus() override
;
560 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
562 sal_Int32
GetItemPos() const { return mnItemPos
; }
563 void SetItemPos( sal_Int32 n
) { mnItemPos
= n
; }
565 void SetString( const OUString
& rStr
) { maString
= rStr
; }
567 void SetImage( const Image
& rImg
) { maImage
= rImg
; }
569 void SetMBDownHdl( const Link
<void*,void>& rLink
) { maMBDownHdl
= rLink
; }
571 void DrawEntry(vcl::RenderContext
& rRenderContext
, bool bLayout
);
573 bool GetEdgeBlending() const { return mbEdgeBlending
; }
574 void SetEdgeBlending(bool bNew
) { mbEdgeBlending
= bNew
; }
576 virtual void ShowFocus(const tools::Rectangle
& rRect
) override
;
578 using Control::ImplInitSettings
;
579 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
583 class ImplBtn
: public PushButton
586 Link
<void*,void> maMBDownHdl
;
589 ImplBtn( vcl::Window
* pParent
, WinBits nWinStyle
);
591 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
592 void SetMBDownHdl( const Link
<void*,void>& rLink
) { maMBDownHdl
= rLink
; }
595 void ImplInitDropDownButton( PushButton
* pButton
);
597 #endif // INCLUDED_VCL_INC_LISTBOX_HXX
599 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */