Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / inc / listbox.hxx
blobd2a096e4f322fe1bf09050895ae16ae8c622d178
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <vcl/button.hxx>
24 #include <vcl/floatwin.hxx>
25 #include <vcl/quickselectionengine.hxx>
27 #include <vector>
28 #include <memory>
30 class ScrollBar;
31 class ScrollBarBox;
33 #define HORZ_SCROLL 4
34 #define IMG_TXT_DISTANCE 6
36 enum LB_EVENT_TYPE
38 LET_MBDOWN,
39 LET_TRACKING,
40 LET_KEYMOVE,
41 LET_KEYSPACE
44 struct ImplEntryType
46 OUString maStr;
47 Image maImage;
48 void* mpUserData;
49 bool mbIsSelected;
50 ListBoxEntryFlags mnFlags;
51 long mnHeight;
53 ImplEntryType( const OUString& rStr, const Image& rImage ) :
54 maStr( rStr ),
55 maImage( rImage ),
56 mnFlags( ListBoxEntryFlags::NONE ),
57 mnHeight( 0 )
59 mbIsSelected = false;
60 mpUserData = nullptr;
63 ImplEntryType( const OUString& rStr ) :
64 maStr( rStr ),
65 mnFlags( ListBoxEntryFlags::NONE ),
66 mnHeight( 0 )
68 mbIsSelected = false;
69 mpUserData = nullptr;
73 class ImplEntryList
75 private:
76 VclPtr<vcl::Window> mpWindow; ///< For getting the current locale when matching strings
77 sal_Int32 mnLastSelected;
78 sal_Int32 mnSelectionAnchor;
79 sal_Int32 mnImages;
81 sal_Int32 mnMRUCount;
82 sal_Int32 mnMaxMRUCount;
84 Link<sal_Int32,void> maSelectionChangedHdl;
85 bool mbCallSelectionChangedHdl;
86 std::vector<std::unique_ptr<ImplEntryType> > maEntries;
88 ImplEntryType* GetEntry( sal_Int32 nPos ) const
90 if (nPos < 0 || static_cast<size_t>(nPos) >= maEntries.size())
91 return nullptr;
92 return maEntries[nPos].get();
95 public:
96 ImplEntryList( vcl::Window* pWindow );
97 ~ImplEntryList();
99 sal_Int32 InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry, bool bSort );
100 void RemoveEntry( sal_Int32 nPos );
101 const ImplEntryType* GetEntryPtr( sal_Int32 nPos ) const { return GetEntry( nPos ); }
102 ImplEntryType* GetMutableEntryPtr( sal_Int32 nPos ) const { return GetEntry( nPos ); }
103 void Clear();
105 sal_Int32 FindMatchingEntry( const OUString& rStr, sal_Int32 nStart, bool bLazy ) const;
106 sal_Int32 FindEntry( const OUString& rStr, bool bSearchMRUArea = false ) const;
107 sal_Int32 FindEntry( const void* pData ) const;
109 /// helper: add up heights up to index nEndIndex.
110 /// GetAddedHeight( 0 ) @return 0
111 /// GetAddedHeight( LISTBOX_ENTRY_NOTFOUND ) @return 0
112 /// GetAddedHeight( i, k ) with k > i is equivalent -GetAddedHeight( k, i )
113 long GetAddedHeight( sal_Int32 nEndIndex, sal_Int32 nBeginIndex ) const;
114 long GetEntryHeight( sal_Int32 nPos ) const;
116 sal_Int32 GetEntryCount() const { return (sal_Int32 )maEntries.size(); }
117 bool HasImages() const { return mnImages != 0; }
119 OUString GetEntryText( sal_Int32 nPos ) const;
121 bool HasEntryImage( sal_Int32 nPos ) const;
122 Image GetEntryImage( sal_Int32 nPos ) const;
124 void SetEntryData( sal_Int32 nPos, void* pNewData );
125 void* GetEntryData( sal_Int32 nPos ) const;
127 void SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags );
128 ListBoxEntryFlags GetEntryFlags( sal_Int32 nPos ) const;
130 void SelectEntry( sal_Int32 nPos, bool bSelect );
132 sal_Int32 GetSelectEntryCount() const;
133 OUString GetSelectEntry( sal_Int32 nIndex ) const;
134 sal_Int32 GetSelectEntryPos( sal_Int32 nIndex ) const;
135 bool IsEntryPosSelected( sal_Int32 nIndex ) const;
137 void SetLastSelected( sal_Int32 nPos ) { mnLastSelected = nPos; }
138 sal_Int32 GetLastSelected() const { return mnLastSelected; }
140 void SetSelectionAnchor( sal_Int32 nPos ) { mnSelectionAnchor = nPos; }
141 sal_Int32 GetSelectionAnchor() const { return mnSelectionAnchor; }
143 void SetSelectionChangedHdl( const Link<sal_Int32,void>& rLnk ) { maSelectionChangedHdl = rLnk; }
144 void SetCallSelectionChangedHdl( bool bCall ) { mbCallSelectionChangedHdl = bCall; }
146 void SetMRUCount( sal_Int32 n ) { mnMRUCount = n; }
147 sal_Int32 GetMRUCount() const { return mnMRUCount; }
149 void SetMaxMRUCount( sal_Int32 n ) { mnMaxMRUCount = n; }
150 sal_Int32 GetMaxMRUCount() const { return mnMaxMRUCount; }
152 /** An Entry is selectable if its mnFlags does not have the
153 ListBoxEntryFlags::DisableSelection flag set. */
154 bool IsEntrySelectable( sal_Int32 nPos ) const;
156 /** @return the first entry found from the given position nPos that is selectable
157 or LISTBOX_ENTRY_NOTFOUND if non is found. If the entry at nPos is not selectable,
158 it returns the first selectable entry after nPos if bForward is true and the
159 first selectable entry after nPos is bForward is false.
161 sal_Int32 FindFirstSelectable( sal_Int32 nPos, bool bForward = true );
164 class ImplListBoxWindow : public Control, public vcl::ISearchableStringList
166 private:
167 ImplEntryList* mpEntryList; ///< EntryList
168 tools::Rectangle maFocusRect;
170 Size maUserItemSize;
172 long mnMaxTxtHeight; ///< Maximum height of a text item
173 long mnMaxTxtWidth; ///< Maximum width of a text item
174 ///< Entry without Image
175 long mnMaxImgTxtWidth;///< Maximum width of a text item
176 ///< Entry AND Image
177 long mnMaxImgWidth; ///< Maximum width of an image item
178 long mnMaxImgHeight; ///< Maximum height of an image item
179 long mnMaxWidth; ///< Maximum width of an entry
180 long mnMaxHeight; ///< Maximum height of an entry
182 sal_Int32 mnCurrentPos; ///< Position (Focus)
183 sal_Int32 mnTrackingSaveSelection; ///< Selection before Tracking();
185 sal_Int32 mnSeparatorPos; ///< Separator
187 sal_Int32 mnUserDrawEntry;
189 sal_Int32 mnTop; ///< output from line on
190 long mnLeft; ///< output from column on
191 long mnBorder; ///< distance border - text
192 long mnTextHeight; ///< text height
193 ProminentEntry meProminentType; ///< where is the "prominent" entry
195 sal_uInt16 mnSelectModifier; ///< Modifiers
197 bool mbHasFocusRect : 1;
198 bool mbSort : 1; ///< ListBox sorted
199 bool mbTrack : 1; ///< Tracking
200 bool mbMulti : 1; ///< MultiListBox
201 bool mbStackMode : 1; ///< StackSelection
202 bool mbSimpleMode : 1; ///< SimpleMode for MultiListBox
203 bool mbImgsDiffSz : 1; ///< Images have different sizes
204 bool mbTravelSelect : 1; ///< TravelSelect
205 bool mbTrackingSelect : 1; ///< Selected at a MouseMove
206 bool mbSelectionChanged : 1; ///< Do not call Select() too often ...
207 bool mbMouseMoveSelect : 1; ///< Select at MouseMove
208 bool mbGrabFocus : 1; ///< Grab focus at MBDown
209 bool mbUserDrawEnabled : 1; ///< UserDraw possible
210 bool mbInUserDraw : 1; ///< In UserDraw
211 bool mbReadOnly : 1; ///< ReadOnly
212 bool mbMirroring : 1; ///< pb: #106948# explicit mirroring for calc
213 bool mbRight : 1; ///< right align Text output
214 bool mbCenter : 1; ///< center Text output
215 bool mbEdgeBlending : 1;
217 Link<ImplListBoxWindow*,void> maScrollHdl;
218 Link<LinkParamNone*,void> maSelectHdl;
219 Link<LinkParamNone*,void> maCancelHdl;
220 Link<ImplListBoxWindow*,void> maDoubleClickHdl;
221 Link<UserDrawEvent*, void> maUserDrawHdl;
222 Link<LinkParamNone*,void> maMRUChangedHdl;
223 Link<sal_Int32,void> maFocusHdl;
224 Link<LinkParamNone*,void> maListItemSelectHdl;
226 vcl::QuickSelectionEngine maQuickSelectionEngine;
228 protected:
229 virtual void KeyInput( const KeyEvent& rKEvt ) override;
230 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
231 virtual void MouseMove( const MouseEvent& rMEvt ) override;
232 virtual void Tracking( const TrackingEvent& rTEvt ) override;
233 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
234 virtual void Resize() override;
235 virtual void GetFocus() override;
236 virtual void LoseFocus() override;
238 bool SelectEntries( sal_Int32 nSelect, LB_EVENT_TYPE eLET, bool bShift = false, bool bCtrl = false, bool bSelectPosChange = false );
239 void ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32 nPos);
240 void ImplDoPaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
241 void ImplCalcMetrics();
242 void ImplUpdateEntryMetrics( ImplEntryType& rEntry );
243 void ImplCallSelect();
245 void ImplShowFocusRect();
246 void ImplHideFocusRect();
248 virtual void StateChanged( StateChangedType nType ) override;
249 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
251 public:
252 virtual void FillLayoutData() const override;
254 ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle );
255 virtual ~ImplListBoxWindow() override;
256 virtual void dispose() override;
258 ImplEntryList* GetEntryList() const { return mpEntryList; }
260 sal_Int32 InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry );
261 void RemoveEntry( sal_Int32 nPos );
262 void Clear();
263 void ResetCurrentPos() { mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; }
264 sal_Int32 GetCurrentPos() const { return mnCurrentPos; }
265 sal_uInt16 GetDisplayLineCount() const;
266 void SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags );
268 void DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32 nPos, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false);
270 void SelectEntry( sal_Int32 nPos, bool bSelect );
271 void DeselectAll();
272 sal_Int32 GetEntryPosForPoint( const Point& rPoint ) const;
273 sal_Int32 GetLastVisibleEntry() const;
275 bool ProcessKeyInput( const KeyEvent& rKEvt );
277 void SetTopEntry( sal_Int32 nTop );
278 sal_Int32 GetTopEntry() const { return mnTop; }
279 /** ShowProminentEntry will set the entry corresponding to nEntryPos
280 either at top or in the middle depending on the chosen style*/
281 void ShowProminentEntry( sal_Int32 nEntryPos );
282 void SetProminentEntryType( ProminentEntry eType ) { meProminentType = eType; }
283 using Window::IsVisible;
284 bool IsVisible( sal_Int32 nEntry ) const;
286 long GetLeftIndent() const { return mnLeft; }
287 void SetLeftIndent( long n );
288 void ScrollHorz( long nDiff );
290 void AllowGrabFocus( bool b ) { mbGrabFocus = b; }
291 bool IsGrabFocusAllowed() const { return mbGrabFocus; }
293 void SetSeparatorPos( sal_Int32 n ) { mnSeparatorPos = n; }
294 sal_Int32 GetSeparatorPos() const { return mnSeparatorPos; }
296 void SetTravelSelect( bool bTravelSelect ) { mbTravelSelect = bTravelSelect; }
297 bool IsTravelSelect() const { return mbTravelSelect; }
298 bool IsTrackingSelect() const { return mbTrackingSelect; }
300 void SetUserItemSize( const Size& rSz );
302 void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
303 bool IsUserDrawEnabled() const { return mbUserDrawEnabled; }
305 void EnableMultiSelection( bool bMulti, bool bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; }
306 bool IsMultiSelectionEnabled() const { return mbMulti; }
308 void SetMultiSelectionSimpleMode( bool bSimple ) { mbSimpleMode = bSimple; }
310 void EnableMouseMoveSelect( bool bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; }
311 bool IsMouseMoveSelect() const { return mbMouseMoveSelect||mbStackMode; }
313 Size CalcSize(sal_Int32 nMaxLines) const;
314 tools::Rectangle GetBoundingRectangle( sal_Int32 nItem ) const;
316 long GetEntryHeight() const { return mnMaxHeight; }
317 long GetMaxEntryWidth() const { return mnMaxWidth; }
319 void SetScrollHdl( const Link<ImplListBoxWindow*,void>& rLink ) { maScrollHdl = rLink; }
320 void SetSelectHdl( const Link<LinkParamNone*,void>& rLink ) { maSelectHdl = rLink; }
321 void SetCancelHdl( const Link<LinkParamNone*,void>& rLink ) { maCancelHdl = rLink; }
322 void SetDoubleClickHdl( const Link<ImplListBoxWindow*,void>& rLink ) { maDoubleClickHdl = rLink; }
323 void SetUserDrawHdl( const Link<UserDrawEvent*, void>& rLink ) { maUserDrawHdl = rLink; }
324 void SetMRUChangedHdl( const Link<LinkParamNone*,void>& rLink ) { maMRUChangedHdl = rLink; }
325 void SetFocusHdl( const Link<sal_Int32,void>& rLink ) { maFocusHdl = rLink ; }
327 void SetListItemSelectHdl( const Link<LinkParamNone*,void>& rLink ) { maListItemSelectHdl = rLink ; }
328 bool IsSelectionChanged() const { return mbSelectionChanged; }
329 sal_uInt16 GetSelectModifier() const { return mnSelectModifier; }
331 void EnableSort( bool b ) { mbSort = b; }
333 void SetReadOnly( bool bReadOnly ) { mbReadOnly = bReadOnly; }
334 bool IsReadOnly() const { return mbReadOnly; }
336 DrawTextFlags ImplGetTextStyle() const;
338 /// pb: #106948# explicit mirroring for calc
339 void EnableMirroring() { mbMirroring = true; }
340 bool IsMirroring() const { return mbMirroring; }
342 bool GetEdgeBlending() const { return mbEdgeBlending; }
343 void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
344 void EnableQuickSelection( bool b );
346 using Control::ImplInitSettings;
347 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
349 protected:
350 // ISearchableStringList
351 virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const override;
352 virtual vcl::StringEntryIdentifier NextEntry( vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const override;
353 virtual void SelectEntry( vcl::StringEntryIdentifier _entry ) override;
356 class ImplListBox : public Control
358 private:
359 VclPtr<ImplListBoxWindow> maLBWindow;
360 VclPtr<ScrollBar> mpHScrollBar;
361 VclPtr<ScrollBar> mpVScrollBar;
362 VclPtr<ScrollBarBox> mpScrollBarBox;
364 bool mbVScroll : 1; // VScroll on or off
365 bool mbHScroll : 1; // HScroll on or off
366 bool mbAutoHScroll : 1; // AutoHScroll on or off
367 bool mbEdgeBlending : 1;
369 Link<ImplListBox*,void> maScrollHdl; // because it is needed by ImplListBoxWindow itself
370 css::uno::Reference< css::uno::XInterface > mxDNDListenerContainer;
372 protected:
373 virtual void GetFocus() override;
374 virtual void StateChanged( StateChangedType nType ) override;
376 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
378 void ImplResizeControls();
379 void ImplCheckScrollBars();
380 void ImplInitScrollBars();
382 DECL_LINK( ScrollBarHdl, ScrollBar*, void );
383 DECL_LINK( LBWindowScrolled, ImplListBoxWindow*, void );
384 DECL_LINK( MRUChanged, LinkParamNone*, void );
386 public:
387 ImplListBox( vcl::Window* pParent, WinBits nWinStyle );
388 virtual ~ImplListBox() override;
389 virtual void dispose() override;
391 const ImplEntryList* GetEntryList() const { return maLBWindow->GetEntryList(); }
392 ImplListBoxWindow* GetMainWindow() { return maLBWindow.get(); }
394 virtual void Resize() override;
395 virtual const Wallpaper& GetDisplayBackground() const override;
397 sal_Int32 InsertEntry( sal_Int32 nPos, const OUString& rStr );
398 sal_Int32 InsertEntry( sal_Int32 nPos, const OUString& rStr, const Image& rImage );
399 void RemoveEntry( sal_Int32 nPos );
400 void SetEntryData( sal_Int32 nPos, void* pNewData ) { maLBWindow->GetEntryList()->SetEntryData( nPos, pNewData ); }
401 void Clear();
403 void SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags );
405 void SelectEntry( sal_Int32 nPos, bool bSelect );
406 void SetNoSelection();
407 void ResetCurrentPos() { maLBWindow->ResetCurrentPos(); }
408 sal_Int32 GetCurrentPos() const { return maLBWindow->GetCurrentPos(); }
410 bool ProcessKeyInput( const KeyEvent& rKEvt ) { return maLBWindow->ProcessKeyInput( rKEvt ); }
411 bool HandleWheelAsCursorTravel( const CommandEvent& rCEvt );
413 void SetSeparatorPos( sal_Int32 n ) { maLBWindow->SetSeparatorPos( n ); }
414 sal_Int32 GetSeparatorPos() const { return maLBWindow->GetSeparatorPos(); }
416 void SetTopEntry( sal_Int32 nTop ) { maLBWindow->SetTopEntry( nTop ); }
417 sal_Int32 GetTopEntry() const { return maLBWindow->GetTopEntry(); }
418 void ShowProminentEntry( sal_Int32 nPos ) { maLBWindow->ShowProminentEntry( nPos ); }
419 using Window::IsVisible;
420 bool IsVisible( sal_Int32 nEntry ) const { return maLBWindow->IsVisible( nEntry ); }
422 void SetProminentEntryType( ProminentEntry eType ) { maLBWindow->SetProminentEntryType( eType ); }
424 long GetLeftIndent() const { return maLBWindow->GetLeftIndent(); }
425 void SetLeftIndent( sal_uInt16 n ) { maLBWindow->SetLeftIndent( n ); }
427 void SetTravelSelect( bool bTravelSelect ) { maLBWindow->SetTravelSelect( bTravelSelect ); }
428 bool IsTravelSelect() const { return maLBWindow->IsTravelSelect(); }
429 bool IsTrackingSelect() const { return maLBWindow->IsTrackingSelect(); }
431 void EnableMultiSelection( bool bMulti, bool bStackMode ) { maLBWindow->EnableMultiSelection( bMulti, bStackMode ); }
432 bool IsMultiSelectionEnabled() const { return maLBWindow->IsMultiSelectionEnabled(); }
434 void SetMultiSelectionSimpleMode( bool bSimple ) { maLBWindow->SetMultiSelectionSimpleMode( bSimple ); }
436 void SetReadOnly( bool b ) { maLBWindow->SetReadOnly( b ); }
437 bool IsReadOnly() const { return maLBWindow->IsReadOnly(); }
439 Size CalcSize( sal_Int32 nMaxLines ) const { return maLBWindow->CalcSize( nMaxLines ); }
440 long GetEntryHeight() const { return maLBWindow->GetEntryHeight(); }
441 long GetMaxEntryWidth() const { return maLBWindow->GetMaxEntryWidth(); }
443 void SetScrollHdl( const Link<ImplListBox*,void>& rLink ) { maScrollHdl = rLink; }
444 void SetSelectHdl( const Link<LinkParamNone*,void>& rLink ) { maLBWindow->SetSelectHdl( rLink ); }
445 void SetCancelHdl( const Link<LinkParamNone*,void>& rLink ) { maLBWindow->SetCancelHdl( rLink ); }
446 void SetDoubleClickHdl( const Link<ImplListBoxWindow*,void>& rLink ) { maLBWindow->SetDoubleClickHdl( rLink ); }
447 void SetUserDrawHdl( const Link<UserDrawEvent*, void>& rLink ) { maLBWindow->SetUserDrawHdl( rLink ); }
448 void SetFocusHdl( const Link<sal_Int32,void>& rLink ) { maLBWindow->SetFocusHdl( rLink ); }
449 void SetListItemSelectHdl( const Link<LinkParamNone*,void>& rLink ) { maLBWindow->SetListItemSelectHdl( rLink ); }
450 void SetSelectionChangedHdl( const Link<sal_Int32,void>& rLnk ) { maLBWindow->GetEntryList()->SetSelectionChangedHdl( rLnk ); }
451 void SetCallSelectionChangedHdl( bool bCall ) { maLBWindow->GetEntryList()->SetCallSelectionChangedHdl( bCall ); }
452 bool IsSelectionChanged() const { return maLBWindow->IsSelectionChanged(); }
453 sal_uInt16 GetSelectModifier() const { return maLBWindow->GetSelectModifier(); }
455 void SetMRUEntries( const OUString& rEntries, sal_Unicode cSep );
456 OUString GetMRUEntries( sal_Unicode cSep ) const;
457 void SetMaxMRUCount( sal_Int32 n ) { maLBWindow->GetEntryList()->SetMaxMRUCount( n ); }
458 sal_Int32 GetMaxMRUCount() const { return maLBWindow->GetEntryList()->GetMaxMRUCount(); }
459 sal_uInt16 GetDisplayLineCount() const
460 { return maLBWindow->GetDisplayLineCount(); }
462 bool GetEdgeBlending() const { return mbEdgeBlending; }
463 void SetEdgeBlending(bool bNew);
465 /// pb: #106948# explicit mirroring for calc
466 void EnableMirroring() { maLBWindow->EnableMirroring(); }
467 void SetDropTraget(const css::uno::Reference< css::uno::XInterface >& i_xDNDListenerContainer){ mxDNDListenerContainer= i_xDNDListenerContainer; }
470 class ImplListBoxFloatingWindow : public FloatingWindow
472 private:
473 VclPtr<ImplListBox> mpImplLB;
474 Size maPrefSz;
475 sal_uInt16 mnDDLineCount;
476 sal_Int32 mnPopupModeStartSaveSelection;
477 bool mbAutoWidth;
479 protected:
480 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
482 public:
483 ImplListBoxFloatingWindow( vcl::Window* pParent );
484 virtual ~ImplListBoxFloatingWindow() override;
485 virtual void dispose() override;
486 void SetImplListBox( ImplListBox* pLB ) { mpImplLB = pLB; }
488 void SetPrefSize( const Size& rSz ) { maPrefSz = rSz; }
489 const Size& GetPrefSize() const { return maPrefSz; }
491 void SetAutoWidth( bool b ) { mbAutoWidth = b; }
493 Size CalcFloatSize();
494 void StartFloat( bool bStartTracking );
496 virtual void setPosSizePixel( long nX, long nY,
497 long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All ) override;
499 void SetDropDownLineCount( sal_uInt16 n ) { mnDDLineCount = n; }
500 sal_uInt16 GetDropDownLineCount() const { return mnDDLineCount; }
502 sal_Int32 GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection; }
504 virtual void Resize() override;
507 class ImplWin : public Control
509 private:
511 sal_Int32 mnItemPos; ///< because of UserDraw I have to know which item I draw
512 OUString maString;
513 Image maImage;
515 tools::Rectangle maFocusRect;
517 Link<void*,void> maMBDownHdl;
518 Link<UserDrawEvent*, void> maUserDrawHdl;
520 bool mbUserDrawEnabled : 1;
521 bool mbInUserDraw : 1;
522 bool mbEdgeBlending : 1;
524 void ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout = false);
525 protected:
526 virtual void FillLayoutData() const override;
528 public:
529 ImplWin( vcl::Window* pParent, WinBits nWinStyle );
531 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
532 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
533 virtual void Resize() override;
534 virtual void GetFocus() override;
535 virtual void LoseFocus() override;
536 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
538 sal_Int32 GetItemPos() const { return mnItemPos; }
539 void SetItemPos( sal_Int32 n ) { mnItemPos = n; }
541 void SetString( const OUString& rStr ) { maString = rStr; }
543 void SetImage( const Image& rImg ) { maImage = rImg; }
545 void SetMBDownHdl( const Link<void*,void>& rLink ) { maMBDownHdl = rLink; }
546 void SetUserDrawHdl( const Link<UserDrawEvent*, void>& rLink ) { maUserDrawHdl = rLink; }
548 void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
549 bool IsUserDrawEnabled() const { return mbUserDrawEnabled; }
551 void DrawEntry(vcl::RenderContext& rRenderContext, bool bLayout);
553 bool GetEdgeBlending() const { return mbEdgeBlending; }
554 void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
556 virtual void ShowFocus(const tools::Rectangle& rRect) override;
558 using Control::ImplInitSettings;
559 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
563 class ImplBtn : public PushButton
565 private:
566 bool mbDown;
567 Link<void*,void> maMBDownHdl;
569 public:
570 ImplBtn( vcl::Window* pParent, WinBits nWinStyle );
572 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
573 void SetMBDownHdl( const Link<void*,void>& rLink ) { maMBDownHdl = rLink; }
576 void ImplInitDropDownButton( PushButton* pButton );
578 #endif // INCLUDED_VCL_INC_LISTBOX_HXX
580 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */