Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / ilstbox.hxx
blob363483e209f7bad2d09d31e98b25a38145e77f4a
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_ILSTBOX_HXX
21 #define INCLUDED_VCL_INC_ILSTBOX_HXX
23 #include <boost/ptr_container/ptr_vector.hpp>
24 #include <boost/signals2/signal.hpp>
25 #include <vcl/image.hxx>
26 #include <vcl/ctrl.hxx>
27 #include <vcl/button.hxx>
28 #include <vcl/floatwin.hxx>
29 #include <vcl/lstbox.h>
30 #include <vcl/timer.hxx>
32 #include "vcl/quickselectionengine.hxx"
34 class ScrollBar;
35 class ScrollBarBox;
37 #define HORZ_SCROLL 4
38 #define IMG_TXT_DISTANCE 6
40 enum LB_EVENT_TYPE
42 LET_MBDOWN,
43 LET_TRACKING,
44 LET_TRACKING_END,
45 LET_KEYMOVE,
46 LET_KEYSPACE
49 struct ImplEntryType
51 OUString maStr;
52 Image maImage;
53 void* mpUserData;
54 bool mbIsSelected;
55 ListBoxEntryFlags mnFlags;
56 long mnHeight;
58 ImplEntryType( const OUString& rStr, const Image& rImage ) :
59 maStr( rStr ),
60 maImage( rImage ),
61 mnFlags( ListBoxEntryFlags::NONE ),
62 mnHeight( 0 )
64 mbIsSelected = false;
65 mpUserData = NULL;
68 ImplEntryType( const OUString& rStr ) :
69 maStr( rStr ),
70 mnFlags( ListBoxEntryFlags::NONE ),
71 mnHeight( 0 )
73 mbIsSelected = false;
74 mpUserData = NULL;
77 ImplEntryType( const Image& rImage ) :
78 maImage( rImage ),
79 mnFlags( ListBoxEntryFlags::NONE ),
80 mnHeight( 0 )
82 mbIsSelected = false;
83 mpUserData = NULL;
87 class ImplEntryList
89 private:
90 VclPtr<vcl::Window> mpWindow; ///< For getting the current locale when matching strings
91 sal_Int32 mnLastSelected;
92 sal_Int32 mnSelectionAnchor;
93 sal_Int32 mnImages;
95 sal_Int32 mnMRUCount;
96 sal_Int32 mnMaxMRUCount;
98 Link<> maSelectionChangedHdl;
99 bool mbCallSelectionChangedHdl;
100 boost::ptr_vector<ImplEntryType> maEntries;
102 ImplEntryType* GetEntry( sal_Int32 nPos ) const
104 if (nPos < 0 || static_cast<size_t>(nPos) >= maEntries.size())
105 return NULL;
106 return const_cast<ImplEntryType*>(&maEntries[nPos]);
109 public:
110 ImplEntryList( vcl::Window* pWindow );
111 ~ImplEntryList();
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 (const ImplEntryType*) GetEntry( nPos ); }
116 ImplEntryType* GetMutableEntryPtr( sal_Int32 nPos ) const { return GetEntry( nPos ); }
117 void Clear();
119 sal_Int32 FindMatchingEntry( const OUString& rStr, sal_Int32 nStart = 0, bool bForward = true, bool bLazy = true ) const;
120 sal_Int32 FindEntry( const OUString& rStr, bool bSearchMRUArea = false ) const;
121 sal_Int32 FindEntry( const void* pData ) 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 long GetAddedHeight( sal_Int32 nEndIndex, sal_Int32 nBeginIndex = 0, long nBeginHeight = 0 ) const;
128 long GetEntryHeight( sal_Int32 nPos ) const;
130 sal_Int32 GetEntryCount() const { return (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 );
142 ListBoxEntryFlags GetEntryFlags( sal_Int32 nPos ) const;
144 void SelectEntry( sal_Int32 nPos, bool bSelect );
146 sal_Int32 GetSelectEntryCount() const;
147 OUString GetSelectEntry( sal_Int32 nIndex ) const;
148 sal_Int32 GetSelectEntryPos( sal_Int32 nIndex ) const;
149 bool IsEntryPosSelected( sal_Int32 nIndex ) const;
151 void SetLastSelected( sal_Int32 nPos ) { mnLastSelected = nPos; }
152 sal_Int32 GetLastSelected() const { return mnLastSelected; }
154 void SetSelectionAnchor( sal_Int32 nPos ) { mnSelectionAnchor = nPos; }
155 sal_Int32 GetSelectionAnchor() const { return mnSelectionAnchor; }
157 void SetSelectionChangedHdl( const Link<>& rLnk ) { maSelectionChangedHdl = rLnk; }
158 void SetCallSelectionChangedHdl( bool bCall ) { mbCallSelectionChangedHdl = bCall; }
160 void SetMRUCount( sal_Int32 n ) { mnMRUCount = n; }
161 sal_Int32 GetMRUCount() const { return mnMRUCount; }
163 void SetMaxMRUCount( sal_Int32 n ) { mnMaxMRUCount = n; }
164 sal_Int32 GetMaxMRUCount() const { return mnMaxMRUCount; }
166 /** An Entry is selectable if its mnFlags does not have the
167 ListBoxEntryFlags::DisableSelection flag set. */
168 bool IsEntrySelectable( sal_Int32 nPos ) const;
170 /** @return the first entry found from the given position nPos that is selectable
171 or LISTBOX_ENTRY_NOTFOUND if non is found. If the entry at nPos is not selectable,
172 it returns the first selectable entry after nPos if bForward is true and the
173 first selectable entry after nPos is bForward is false.
175 sal_Int32 FindFirstSelectable( sal_Int32 nPos, bool bForward = true );
178 class ImplListBoxWindow : public Control, public vcl::ISearchableStringList
180 private:
181 ImplEntryList* mpEntryList; ///< EntryList
182 Rectangle maFocusRect;
184 Size maUserItemSize;
186 long mnMaxTxtHeight; ///< Maximum height of a text item
187 long mnMaxTxtWidth; ///< Maximum width of a text item
188 ///< Entry without Image
189 long mnMaxImgTxtWidth;///< Maximum width of a text item
190 ///< Entry AND Image
191 long mnMaxImgWidth; ///< Maximum width of an image item
192 long mnMaxImgHeight; ///< Maximum height of an image item
193 long mnMaxWidth; ///< Maximum width of an entry
194 long mnMaxHeight; ///< Maximum height of an entry
196 sal_Int32 mnCurrentPos; ///< Position (Focus)
197 sal_Int32 mnTrackingSaveSelection; ///< Selection before Tracking();
199 sal_Int32 mnSeparatorPos; ///< Separator
201 sal_Int32 mnUserDrawEntry;
203 sal_Int32 mnTop; ///< output from line on
204 long mnLeft; ///< output from column on
205 long mnBorder; ///< distance border - text
206 long mnTextHeight; ///< text height
207 ProminentEntry meProminentType; ///< where is the "prominent" entry
209 sal_uInt16 mnSelectModifier; ///< Modifiers
211 /// bitfield
212 bool mbHasFocusRect : 1;
213 bool mbSort : 1; ///< ListBox sorted
214 bool mbTrack : 1; ///< Tracking
215 bool mbMulti : 1; ///< MultiListBox
216 bool mbStackMode : 1; ///< StackSelection
217 bool mbSimpleMode : 1; ///< SimpleMode for MultiListBox
218 bool mbImgsDiffSz : 1; ///< Images have different sizes
219 bool mbTravelSelect : 1; ///< TravelSelect
220 bool mbTrackingSelect : 1; ///< Selected at a MouseMove
221 bool mbSelectionChanged : 1; ///< Do not call Select() too often ...
222 bool mbMouseMoveSelect : 1; ///< Select at MouseMove
223 bool mbGrabFocus : 1; ///< Grab focus at MBDown
224 bool mbUserDrawEnabled : 1; ///< UserDraw possible
225 bool mbInUserDraw : 1; ///< In UserDraw
226 bool mbReadOnly : 1; ///< ReadOnly
227 bool mbMirroring : 1; ///< pb: #106948# explicit mirroring for calc
228 bool mbRight : 1; ///< right align Text output
229 bool mbCenter : 1; ///< center Text output
230 bool mbEdgeBlending : 1;
232 Link<> maScrollHdl;
233 Link<> maSelectHdl;
234 Link<> maCancelHdl;
235 Link<> maDoubleClickHdl;
236 Link<> maMRUChangedHdl;
237 Link<> maFocusHdl;
238 Link<> maListItemSelectHdl;
240 vcl::QuickSelectionEngine maQuickSelectionEngine;
242 protected:
243 virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
244 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
245 virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
246 virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
247 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
248 virtual void Resize() SAL_OVERRIDE;
249 virtual void GetFocus() SAL_OVERRIDE;
250 virtual void LoseFocus() SAL_OVERRIDE;
252 bool SelectEntries( sal_Int32 nSelect, LB_EVENT_TYPE eLET, bool bShift = false, bool bCtrl = false, bool bSelectPosChange = false );
253 void ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32 nPos, bool bErase = false, bool bLayout = false);
254 void ImplDoPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect, bool bLayout = false);
255 void ImplCalcMetrics();
256 void ImplUpdateEntryMetrics( ImplEntryType& rEntry );
257 void ImplCallSelect();
259 void ImplShowFocusRect();
260 void ImplHideFocusRect();
262 virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
263 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
265 public:
266 virtual void FillLayoutData() const SAL_OVERRIDE;
268 ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle );
269 virtual ~ImplListBoxWindow();
270 virtual void dispose() SAL_OVERRIDE;
272 ImplEntryList* GetEntryList() const { return mpEntryList; }
274 sal_Int32 InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry );
275 void RemoveEntry( sal_Int32 nPos );
276 void Clear();
277 void ResetCurrentPos() { mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; }
278 sal_Int32 GetCurrentPos() const { return mnCurrentPos; }
279 sal_uInt16 GetDisplayLineCount() const;
280 void SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags );
282 void DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32 nPos, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false, bool bLayout = false);
284 void SelectEntry( sal_Int32 nPos, bool bSelect );
285 void DeselectAll();
286 sal_Int32 GetEntryPosForPoint( const Point& rPoint ) const;
287 sal_Int32 GetLastVisibleEntry() const;
289 bool ProcessKeyInput( const KeyEvent& rKEvt );
291 void SetTopEntry( sal_Int32 nTop );
292 sal_Int32 GetTopEntry() const { return mnTop; }
293 /** ShowProminentEntry will set the entry correspoding to nEntryPos
294 either at top or in the middle depending on the chosen style*/
295 void ShowProminentEntry( sal_Int32 nEntryPos );
296 void SetProminentEntryType( ProminentEntry eType ) { meProminentType = eType; }
297 ProminentEntry GetProminentEntryType() const { return meProminentType; }
298 using Window::IsVisible;
299 bool IsVisible( sal_Int32 nEntry ) const;
301 long GetLeftIndent() const { return mnLeft; }
302 void SetLeftIndent( long n );
303 void ScrollHorz( long nDiff );
305 void AllowGrabFocus( bool b ) { mbGrabFocus = b; }
306 bool IsGrabFocusAllowed() const { return mbGrabFocus; }
308 void SetSeparatorPos( sal_Int32 n ) { mnSeparatorPos = n; }
309 sal_Int32 GetSeparatorPos() const { return mnSeparatorPos; }
311 void SetTravelSelect( bool bTravelSelect ) { mbTravelSelect = bTravelSelect; }
312 bool IsTravelSelect() const { return mbTravelSelect; }
313 bool IsTrackingSelect() const { return mbTrackingSelect; }
315 void SetUserItemSize( const Size& rSz );
316 const Size& GetUserItemSize() const { return maUserItemSize; }
318 void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
319 bool IsUserDrawEnabled() const { return mbUserDrawEnabled; }
321 void EnableMultiSelection( bool bMulti, bool bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; }
322 bool IsMultiSelectionEnabled() const { return mbMulti; }
324 void SetMultiSelectionSimpleMode( bool bSimple ) { mbSimpleMode = bSimple; }
325 bool IsMultiSelectionSimpleMode() const { return mbSimpleMode; }
327 void EnableMouseMoveSelect( bool bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; }
328 bool IsMouseMoveSelectEnabled() const { return mbMouseMoveSelect; }
329 bool IsMouseMoveSelect() const { return mbMouseMoveSelect||mbStackMode; }
331 Size CalcSize(sal_Int32 nMaxLines) const;
332 Rectangle GetBoundingRectangle( sal_Int32 nItem ) const;
334 long GetEntryHeight() const { return mnMaxHeight; }
335 long GetMaxEntryWidth() const { return mnMaxWidth; }
337 void SetScrollHdl( const Link<>& rLink ) { maScrollHdl = rLink; }
338 const Link<>& GetScrollHdl() const { return maScrollHdl; }
339 void SetSelectHdl( const Link<>& rLink ) { maSelectHdl = rLink; }
340 const Link<>& GetSelectHdl() const { return maSelectHdl; }
341 void SetCancelHdl( const Link<>& rLink ) { maCancelHdl = rLink; }
342 const Link<>& GetCancelHdl() const { return maCancelHdl; }
343 void SetDoubleClickHdl( const Link<>& rLink ) { maDoubleClickHdl = rLink; }
344 const Link<>& GetDoubleClickHdl() const { return maDoubleClickHdl; }
345 void SetMRUChangedHdl( const Link<>& rLink ) { maMRUChangedHdl = rLink; }
346 const Link<>& GetMRUChangedHdl() const { return maMRUChangedHdl; }
347 void SetFocusHdl( const Link<>& rLink ) { maFocusHdl = rLink ; }
348 const Link<>& GetFocusHdl() const { return maFocusHdl; }
350 boost::signals2::signal< void ( UserDrawEvent* ) > userDrawSignal;
352 void SetListItemSelectHdl( const Link<>& rLink ) { maListItemSelectHdl = rLink ; }
353 const Link<>& GetListItemSelectHdl() const { return maListItemSelectHdl; }
354 bool IsSelectionChanged() const { return mbSelectionChanged; }
355 sal_uInt16 GetSelectModifier() const { return mnSelectModifier; }
357 void EnableSort( bool b ) { mbSort = b; }
359 void SetReadOnly( bool bReadOnly ) { mbReadOnly = bReadOnly; }
360 bool IsReadOnly() const { return mbReadOnly; }
362 DrawTextFlags ImplGetTextStyle() const;
364 /// pb: #106948# explicit mirroring for calc
365 inline void EnableMirroring() { mbMirroring = true; }
366 inline bool IsMirroring() const { return mbMirroring; }
368 bool GetEdgeBlending() const { return mbEdgeBlending; }
369 void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
370 void EnableQuickSelection( const bool& b );
372 using Control::ImplInitSettings;
373 void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
374 virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
376 protected:
377 // ISearchableStringList
378 virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const SAL_OVERRIDE;
379 virtual vcl::StringEntryIdentifier NextEntry( vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const SAL_OVERRIDE;
380 virtual void SelectEntry( vcl::StringEntryIdentifier _entry ) SAL_OVERRIDE;
383 class ImplListBox : public Control
385 private:
386 VclPtr<ImplListBoxWindow> maLBWindow;
387 VclPtr<ScrollBar> mpHScrollBar;
388 VclPtr<ScrollBar> mpVScrollBar;
389 VclPtr<ScrollBarBox> mpScrollBarBox;
391 /// bitfield
392 bool mbVScroll : 1; // VScroll an oder aus
393 bool mbHScroll : 1; // HScroll an oder aus
394 bool mbAutoHScroll : 1; // AutoHScroll an oder aus
395 bool mbEdgeBlending : 1;
397 Link<> maScrollHdl; // because it is needed by ImplListBoxWindow itself
398 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer;
400 protected:
401 virtual void GetFocus() SAL_OVERRIDE;
402 virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
403 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
405 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
407 void ImplResizeControls();
408 void ImplCheckScrollBars();
409 void ImplInitScrollBars();
411 DECL_LINK( ScrollBarHdl, ScrollBar* );
412 DECL_LINK( LBWindowScrolled, void* );
413 DECL_LINK( MRUChanged, void* );
415 public:
416 ImplListBox( vcl::Window* pParent, WinBits nWinStyle );
417 virtual ~ImplListBox();
418 virtual void dispose() SAL_OVERRIDE;
420 const ImplEntryList* GetEntryList() const { return maLBWindow->GetEntryList(); }
421 ImplListBoxWindow* GetMainWindow() { return maLBWindow.get(); }
423 virtual void Resize() SAL_OVERRIDE;
424 virtual const Wallpaper& GetDisplayBackground() const SAL_OVERRIDE;
425 virtual vcl::Window* GetPreferredKeyInputWindow() SAL_OVERRIDE;
427 sal_Int32 InsertEntry( sal_Int32 nPos, const OUString& rStr );
428 sal_Int32 InsertEntry( sal_Int32 nPos, const OUString& rStr, const Image& rImage );
429 void RemoveEntry( sal_Int32 nPos );
430 void SetEntryData( sal_Int32 nPos, void* pNewData ) { maLBWindow->GetEntryList()->SetEntryData( nPos, pNewData ); }
431 void Clear();
433 void SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags );
435 void SelectEntry( sal_Int32 nPos, bool bSelect );
436 void SetNoSelection();
437 void ResetCurrentPos() { maLBWindow->ResetCurrentPos(); }
438 sal_Int32 GetCurrentPos() const { return maLBWindow->GetCurrentPos(); }
440 bool ProcessKeyInput( const KeyEvent& rKEvt ) { return maLBWindow->ProcessKeyInput( rKEvt ); }
441 bool HandleWheelAsCursorTravel( const CommandEvent& rCEvt );
443 void SetSeparatorPos( sal_Int32 n ) { maLBWindow->SetSeparatorPos( n ); }
444 sal_Int32 GetSeparatorPos() const { return maLBWindow->GetSeparatorPos(); }
446 void SetTopEntry( sal_Int32 nTop ) { maLBWindow->SetTopEntry( nTop ); }
447 sal_Int32 GetTopEntry() const { return maLBWindow->GetTopEntry(); }
448 void ShowProminentEntry( sal_Int32 nPos ) { maLBWindow->ShowProminentEntry( nPos ); }
449 using Window::IsVisible;
450 bool IsVisible( sal_Int32 nEntry ) const { return maLBWindow->IsVisible( nEntry ); }
452 void SetProminentEntryType( ProminentEntry eType ) { maLBWindow->SetProminentEntryType( eType ); }
453 ProminentEntry GetProminentEntryType() const { return maLBWindow->GetProminentEntryType(); }
455 long GetLeftIndent() const { return maLBWindow->GetLeftIndent(); }
456 void SetLeftIndent( sal_uInt16 n ) { maLBWindow->SetLeftIndent( n ); }
457 void ScrollHorz( short nDiff ) { maLBWindow->ScrollHorz( nDiff ); }
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, bool bStackMode ) { maLBWindow->EnableMultiSelection( bMulti, bStackMode ); }
464 bool IsMultiSelectionEnabled() const { return maLBWindow->IsMultiSelectionEnabled(); }
466 void SetMultiSelectionSimpleMode( bool bSimple ) { maLBWindow->SetMultiSelectionSimpleMode( bSimple ); }
467 bool IsMultiSelectionSimpleMode() const { return maLBWindow->IsMultiSelectionSimpleMode(); }
469 void SetReadOnly( bool b ) { maLBWindow->SetReadOnly( b ); }
470 bool IsReadOnly() const { return maLBWindow->IsReadOnly(); }
472 Size CalcSize( sal_Int32 nMaxLines ) const { return maLBWindow->CalcSize( nMaxLines ); }
473 long GetEntryHeight() const { return maLBWindow->GetEntryHeight(); }
474 long GetMaxEntryWidth() const { return maLBWindow->GetMaxEntryWidth(); }
476 void SetScrollHdl( const Link<>& rLink ) { maScrollHdl = rLink; }
477 const Link<>& GetScrollHdl() const { return maScrollHdl; }
478 void SetSelectHdl( const Link<>& rLink ) { maLBWindow->SetSelectHdl( rLink ); }
479 const Link<>& GetSelectHdl() const { return maLBWindow->GetSelectHdl(); }
480 void SetCancelHdl( const Link<>& rLink ) { maLBWindow->SetCancelHdl( rLink ); }
481 const Link<>& GetCancelHdl() const { return maLBWindow->GetCancelHdl(); }
482 void SetDoubleClickHdl( const Link<>& rLink ) { maLBWindow->SetDoubleClickHdl( rLink ); }
483 const Link<>& GetDoubleClickHdl() const { return maLBWindow->GetDoubleClickHdl(); }
485 boost::signals2::signal< void ( UserDrawEvent* ) > userDrawSignal;
487 void SetFocusHdl( const Link<>& rLink ) { maLBWindow->SetFocusHdl( rLink ); }
488 const Link<>& GetFocusHdl() const { return maLBWindow->GetFocusHdl(); }
489 void SetListItemSelectHdl( const Link<>& rLink ) { maLBWindow->SetListItemSelectHdl( rLink ); }
490 const Link<>& GetListItemSelectHdl() const { return maLBWindow->GetListItemSelectHdl(); }
491 void SetSelectionChangedHdl( const Link<>& rLnk ) { maLBWindow->GetEntryList()->SetSelectionChangedHdl( rLnk ); }
492 void SetCallSelectionChangedHdl( bool bCall ) { maLBWindow->GetEntryList()->SetCallSelectionChangedHdl( bCall ); }
493 bool IsSelectionChanged() const { return maLBWindow->IsSelectionChanged(); }
494 sal_uInt16 GetSelectModifier() const { return maLBWindow->GetSelectModifier(); }
496 void SetMRUEntries( const OUString& rEntries, sal_Unicode cSep );
497 OUString GetMRUEntries( sal_Unicode cSep ) const;
498 void SetMaxMRUCount( sal_Int32 n ) { maLBWindow->GetEntryList()->SetMaxMRUCount( n ); }
499 sal_Int32 GetMaxMRUCount() const { return maLBWindow->GetEntryList()->GetMaxMRUCount(); }
500 sal_uInt16 GetDisplayLineCount() const
501 { return maLBWindow->GetDisplayLineCount(); }
503 bool GetEdgeBlending() const { return mbEdgeBlending; }
504 void SetEdgeBlending(bool bNew);
506 /// pb: #106948# explicit mirroring for calc
507 inline void EnableMirroring() { maLBWindow->EnableMirroring(); }
508 inline void SetDropTraget(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_xDNDListenerContainer){ mxDNDListenerContainer= i_xDNDListenerContainer; }
511 class ImplListBoxFloatingWindow : public FloatingWindow
513 private:
514 VclPtr<ImplListBox> mpImplLB;
515 Size maPrefSz;
516 sal_uInt16 mnDDLineCount;
517 sal_Int32 mnPopupModeStartSaveSelection;
518 bool mbAutoWidth;
520 protected:
521 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
523 public:
524 ImplListBoxFloatingWindow( vcl::Window* pParent );
525 virtual ~ImplListBoxFloatingWindow();
526 virtual void dispose() SAL_OVERRIDE;
527 void SetImplListBox( ImplListBox* pLB ) { mpImplLB = pLB; }
529 void SetPrefSize( const Size& rSz ) { maPrefSz = rSz; }
530 const Size& GetPrefSize() const { return maPrefSz; }
532 void SetAutoWidth( bool b ) { mbAutoWidth = b; }
533 bool IsAutoWidth() const { return mbAutoWidth; }
535 Size CalcFloatSize();
536 void StartFloat( bool bStartTracking );
538 virtual void setPosSizePixel( long nX, long nY,
539 long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All ) SAL_OVERRIDE;
540 void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) SAL_OVERRIDE
541 { FloatingWindow::SetPosSizePixel( rNewPos, rNewSize ); }
543 void SetDropDownLineCount( sal_uInt16 n ) { mnDDLineCount = n; }
544 sal_uInt16 GetDropDownLineCount() const { return mnDDLineCount; }
546 sal_Int32 GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection; }
548 virtual void Resize() SAL_OVERRIDE;
551 class ImplWin : public Control
553 private:
555 sal_Int32 mnItemPos; ///< because of UserDraw I have to know which item I draw
556 OUString maString;
557 Image maImage;
559 Rectangle maFocusRect;
560 Size maUserItemSize;
562 /// bitfield
563 bool mbUserDrawEnabled : 1;
564 bool mbInUserDraw : 1;
565 bool mbEdgeBlending : 1;
567 void ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout = false);
568 protected:
569 virtual void FillLayoutData() const SAL_OVERRIDE;
571 public:
572 ImplWin( vcl::Window* pParent, WinBits nWinStyle = 0 );
574 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
575 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
576 virtual void Resize() SAL_OVERRIDE;
577 virtual void GetFocus() SAL_OVERRIDE;
578 virtual void LoseFocus() SAL_OVERRIDE;
579 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
581 sal_Int32 GetItemPos() const { return mnItemPos; }
582 void SetItemPos( sal_Int32 n ) { mnItemPos = n; }
584 const OUString& GetString() const { return maString; }
585 void SetString( const OUString& rStr ) { maString = rStr; }
587 const Image& GetImage() const { return maImage; }
588 void SetImage( const Image& rImg ) { maImage = rImg; }
590 void MBDown();
592 boost::signals2::signal< void ( ImplWin* ) > buttonDownSignal;
593 boost::signals2::signal< void ( UserDrawEvent* ) > userDrawSignal;
595 void SetUserItemSize( const Size& rSz ) { maUserItemSize = rSz; }
596 const Size& GetUserItemSize() const { return maUserItemSize; }
598 void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
599 bool IsUserDrawEnabled() const { return mbUserDrawEnabled; }
601 void DrawEntry(vcl::RenderContext& rRenderContext, bool bDrawImage, bool bDrawText,
602 bool bDrawTextAtImagePos = false, bool bLayout = false);
604 bool GetEdgeBlending() const { return mbEdgeBlending; }
605 void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
607 virtual void ShowFocus(const Rectangle& rRect) SAL_OVERRIDE;
609 using Control::ImplInitSettings;
610 virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
614 class ImplBtn : public PushButton
616 private:
617 bool mbDown;
619 public:
620 ImplBtn( vcl::Window* pParent, WinBits nWinStyle = 0 );
622 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
623 void MBDown();
625 boost::signals2::signal< void ( ImplBtn* ) > buttonDownSignal;
628 void ImplInitFieldSettings( vcl::Window* pWin, bool bFont, bool bForeground, bool bBackground );
629 void ImplInitDropDownButton( PushButton* pButton );
631 #endif // INCLUDED_VCL_INC_ILSTBOX_HXX
633 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */