Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / vcl / inc / ilstbox.hxx
blob9f928c9b7937b079c973d133c33d2a2cab017fdf
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 <vcl/image.hxx>
25 #include <vcl/ctrl.hxx>
26 #include <vcl/button.hxx>
27 #include <vcl/floatwin.hxx>
28 #include <vcl/lstbox.h>
29 #include <vcl/timer.hxx>
31 #include "vcl/quickselectionengine.hxx"
33 class ScrollBar;
34 class ScrollBarBox;
36 #define HORZ_SCROLL 4
37 #define IMG_TXT_DISTANCE 6
39 enum LB_EVENT_TYPE
41 LET_MBDOWN,
42 LET_TRACKING,
43 LET_TRACKING_END,
44 LET_KEYMOVE,
45 LET_KEYSPACE
48 struct ImplEntryType
50 OUString maStr;
51 Image maImage;
52 void* mpUserData;
53 bool mbIsSelected;
54 long mnFlags;
55 long mnHeight;
57 ImplEntryType( const OUString& rStr, const Image& rImage ) :
58 maStr( rStr ),
59 maImage( rImage ),
60 mnFlags( 0 ),
61 mnHeight( 0 )
63 mbIsSelected = false;
64 mpUserData = NULL;
67 ImplEntryType( const OUString& rStr ) :
68 maStr( rStr ),
69 mnFlags( 0 ),
70 mnHeight( 0 )
72 mbIsSelected = false;
73 mpUserData = NULL;
76 ImplEntryType( const Image& rImage ) :
77 maImage( rImage ),
78 mnFlags( 0 ),
79 mnHeight( 0 )
81 mbIsSelected = false;
82 mpUserData = NULL;
86 class ImplEntryList
88 private:
89 Window* mpWindow; ///< For getting the current locale when matching strings
90 sal_Int32 mnLastSelected;
91 sal_Int32 mnSelectionAnchor;
92 sal_Int32 mnImages;
94 sal_Int32 mnMRUCount;
95 sal_Int32 mnMaxMRUCount;
97 Link maSelectionChangedHdl;
98 bool mbCallSelectionChangedHdl;
99 boost::ptr_vector<ImplEntryType> maEntries;
101 ImplEntryType* GetEntry( sal_Int32 nPos ) const
103 if (nPos < 0 || static_cast<size_t>(nPos) >= maEntries.size())
104 return NULL;
105 return const_cast<ImplEntryType*>(&maEntries[nPos]);
108 public:
109 ImplEntryList( Window* pWindow );
110 ~ImplEntryList();
112 sal_Int32 InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry, bool bSort );
113 void RemoveEntry( sal_Int32 nPos );
114 const ImplEntryType* GetEntryPtr( sal_Int32 nPos ) const { return (const ImplEntryType*) GetEntry( nPos ); }
115 ImplEntryType* GetMutableEntryPtr( sal_Int32 nPos ) const { return GetEntry( nPos ); }
116 void Clear();
118 sal_Int32 FindMatchingEntry( const OUString& rStr, sal_Int32 nStart = 0, bool bForward = true, bool bLazy = true ) const;
119 sal_Int32 FindEntry( const OUString& rStr, bool bSearchMRUArea = false ) const;
120 sal_Int32 FindEntry( const void* pData ) const;
122 /// helper: add up heights up to index nEndIndex.
123 /// GetAddedHeight( 0 ) @return 0
124 /// GetAddedHeight( LISTBOX_ENTRY_NOTFOUND ) @return 0
125 /// GetAddedHeight( i, k ) with k > i is equivalent -GetAddedHeight( k, i )
126 long GetAddedHeight( sal_Int32 nEndIndex, sal_Int32 nBeginIndex = 0, long nBeginHeight = 0 ) const;
127 long GetEntryHeight( sal_Int32 nPos ) const;
129 sal_Int32 GetEntryCount() const { return (sal_Int32 )maEntries.size(); }
130 bool HasImages() const { return mnImages ? true : false; }
132 OUString GetEntryText( sal_Int32 nPos ) const;
134 bool HasEntryImage( sal_Int32 nPos ) const;
135 Image GetEntryImage( sal_Int32 nPos ) const;
137 void SetEntryData( sal_Int32 nPos, void* pNewData );
138 void* GetEntryData( sal_Int32 nPos ) const;
140 void SetEntryFlags( sal_Int32 nPos, long nFlags );
141 long GetEntryFlags( sal_Int32 nPos ) const;
143 void SelectEntry( sal_Int32 nPos, bool bSelect );
145 sal_Int32 GetSelectEntryCount() const;
146 OUString GetSelectEntry( sal_Int32 nIndex ) const;
147 sal_Int32 GetSelectEntryPos( 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& 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 LISTBOX_ENTRY_FLAG_DISABLE_SELECTION 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 );
177 class ImplListBoxWindow : public Control, public ::vcl::ISearchableStringList
179 private:
180 ImplEntryList* mpEntryList; ///< EntryList
181 Rectangle maFocusRect;
183 Size maUserItemSize;
185 long mnMaxTxtHeight; ///< Maximum height of a text item
186 long mnMaxTxtWidth; ///< Maximum width of a text item
187 ///< Entry without Image
188 long mnMaxImgTxtWidth;///< Maximum width of a text item
189 ///< Entry AND Image
190 long mnMaxImgWidth; ///< Maximum width of an image item
191 long mnMaxImgHeight; ///< Maximum height of an image item
192 long mnMaxWidth; ///< Maximum width of an entry
193 long mnMaxHeight; ///< Maximum height of an entry
195 sal_Int32 mnCurrentPos; ///< Position (Focus)
196 sal_Int32 mnTrackingSaveSelection; ///< Selection before Tracking();
198 sal_Int32 mnSeparatorPos; ///< Separator
200 sal_Int32 mnUserDrawEntry;
202 sal_Int32 mnTop; ///< output from line on
203 long mnLeft; ///< output from column on
204 long mnBorder; ///< distance border - text
205 long mnTextHeight; ///< text height
206 ProminentEntry meProminentType; ///< where is the "prominent" entry
208 sal_uInt16 mnSelectModifier; ///< Modifiers
210 /// bitfield
211 bool mbHasFocusRect : 1;
212 bool mbSort : 1; ///< ListBox sorted
213 bool mbTrack : 1; ///< Tracking
214 bool mbMulti : 1; ///< MultiListBox
215 bool mbStackMode : 1; ///< StackSelection
216 bool mbSimpleMode : 1; ///< SimpleMode for MultiListBox
217 bool mbImgsDiffSz : 1; ///< Images have different sizes
218 bool mbTravelSelect : 1; ///< TravelSelect
219 bool mbTrackingSelect : 1; ///< Selected at a MouseMove
220 bool mbSelectionChanged : 1; ///< Do not call Select() too often ...
221 bool mbMouseMoveSelect : 1; ///< Select at MouseMove
222 bool mbGrabFocus : 1; ///< Grab focus at MBDown
223 bool mbUserDrawEnabled : 1; ///< UserDraw possible
224 bool mbInUserDraw : 1; ///< In UserDraw
225 bool mbReadOnly : 1; ///< ReadOnly
226 bool mbMirroring : 1; ///< pb: #106948# explicit mirroring for calc
227 bool mbRight : 1; ///< right align Text output
228 bool mbCenter : 1; ///< center Text output
229 bool mbEdgeBlending : 1;
231 Link maScrollHdl;
232 Link maSelectHdl;
233 Link maCancelHdl;
234 Link maDoubleClickHdl;
235 Link maUserDrawHdl;
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( 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( sal_Int32 nPos, bool bErase = false, bool bLayout = false );
254 void ImplDoPaint( 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( Window* pParent, WinBits nWinStyle );
269 virtual ~ImplListBoxWindow();
271 ImplEntryList* GetEntryList() const { return mpEntryList; }
273 sal_Int32 InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry );
274 void RemoveEntry( sal_Int32 nPos );
275 void Clear();
276 void ResetCurrentPos() { mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; }
277 sal_Int32 GetCurrentPos() const { return mnCurrentPos; }
278 sal_uInt16 GetDisplayLineCount() const;
279 void SetEntryFlags( sal_Int32 nPos, long nFlags );
281 void DrawEntry( sal_Int32 nPos, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false, bool bLayout = false );
283 void SelectEntry( sal_Int32 nPos, bool bSelect );
284 void DeselectAll();
285 sal_Int32 GetEntryPosForPoint( const Point& rPoint ) const;
286 sal_Int32 GetLastVisibleEntry() const;
288 bool ProcessKeyInput( const KeyEvent& rKEvt );
290 void SetTopEntry( sal_Int32 nTop );
291 sal_Int32 GetTopEntry() const { return mnTop; }
292 /** ShowProminentEntry will set the entry correspoding to nEntryPos
293 either at top or in the middle depending on the chosen style*/
294 void ShowProminentEntry( sal_Int32 nEntryPos );
295 void SetProminentEntryType( ProminentEntry eType ) { meProminentType = eType; }
296 ProminentEntry GetProminentEntryType() const { return meProminentType; }
297 using Window::IsVisible;
298 bool IsVisible( sal_Int32 nEntry ) const;
300 long GetLeftIndent() const { return mnLeft; }
301 void SetLeftIndent( long n );
302 void ScrollHorz( long nDiff );
304 void AllowGrabFocus( bool b ) { mbGrabFocus = b; }
305 bool IsGrabFocusAllowed() const { return mbGrabFocus; }
307 void SetSeparatorPos( sal_Int32 n ) { mnSeparatorPos = n; }
308 sal_Int32 GetSeparatorPos() const { return mnSeparatorPos; }
310 void SetTravelSelect( bool bTravelSelect ) { mbTravelSelect = bTravelSelect; }
311 bool IsTravelSelect() const { return mbTravelSelect; }
312 bool IsTrackingSelect() const { return mbTrackingSelect; }
314 void SetUserItemSize( const Size& rSz );
315 const Size& GetUserItemSize() const { return maUserItemSize; }
317 void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
318 bool IsUserDrawEnabled() const { return mbUserDrawEnabled; }
320 void EnableMultiSelection( bool bMulti, bool bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; }
321 bool IsMultiSelectionEnabled() const { return mbMulti; }
323 void SetMultiSelectionSimpleMode( bool bSimple ) { mbSimpleMode = bSimple; }
324 bool IsMultiSelectionSimpleMode() const { return mbSimpleMode; }
326 void EnableMouseMoveSelect( bool bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; }
327 bool IsMouseMoveSelectEnabled() const { return mbMouseMoveSelect; }
328 bool IsMouseMoveSelect() const { return mbMouseMoveSelect||mbStackMode; }
330 Size CalcSize(sal_Int32 nMaxLines) const;
331 Rectangle GetBoundingRectangle( sal_Int32 nItem ) const;
333 long GetEntryHeight() const { return mnMaxHeight; }
334 long GetMaxEntryWidth() const { return mnMaxWidth; }
336 void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; }
337 const Link& GetScrollHdl() const { return maScrollHdl; }
338 void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
339 const Link& GetSelectHdl() const { return maSelectHdl; }
340 void SetCancelHdl( const Link& rLink ) { maCancelHdl = rLink; }
341 const Link& GetCancelHdl() const { return maCancelHdl; }
342 void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
343 const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
344 void SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; }
345 const Link& GetUserDrawHdl() const { return maUserDrawHdl; }
346 void SetMRUChangedHdl( const Link& rLink ) { maMRUChangedHdl = rLink; }
347 const Link& GetMRUChangedHdl() const { return maMRUChangedHdl; }
348 void SetFocusHdl( const Link& rLink ) { maFocusHdl = rLink ; }
349 const Link& GetFocusHdl() const { return maFocusHdl; }
351 void SetListItemSelectHdl( const Link& rLink ) { maListItemSelectHdl = rLink ; }
352 const Link& GetListItemSelectHdl() const { return maListItemSelectHdl; }
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 using Control::ImplInitSettings;
362 void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
363 sal_uInt16 ImplGetTextStyle() const;
365 /// pb: #106948# explicit mirroring for calc
366 inline void EnableMirroring() { mbMirroring = true; }
367 inline bool IsMirroring() const { return mbMirroring; }
369 bool GetEdgeBlending() const { return mbEdgeBlending; }
370 void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
371 void EnableQuickSelection( const bool& b );
373 protected:
374 // ISearchableStringList
375 virtual ::vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const SAL_OVERRIDE;
376 virtual ::vcl::StringEntryIdentifier NextEntry( ::vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const SAL_OVERRIDE;
377 virtual void SelectEntry( ::vcl::StringEntryIdentifier _entry ) SAL_OVERRIDE;
380 class ImplListBox : public Control
382 private:
383 ImplListBoxWindow maLBWindow;
384 ScrollBar* mpHScrollBar;
385 ScrollBar* mpVScrollBar;
386 ScrollBarBox* mpScrollBarBox;
388 /// bitfield
389 bool mbVScroll : 1; // VScroll an oder aus
390 bool mbHScroll : 1; // HScroll an oder aus
391 bool mbAutoHScroll : 1; // AutoHScroll an oder aus
392 bool mbEdgeBlending : 1;
394 Link maScrollHdl; // because it is needed by ImplListBoxWindow itself
395 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer;
397 protected:
398 virtual void GetFocus() SAL_OVERRIDE;
399 virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
400 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
402 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
404 void ImplResizeControls();
405 void ImplCheckScrollBars();
406 void ImplInitScrollBars();
408 DECL_LINK( ScrollBarHdl, ScrollBar* );
409 DECL_LINK( LBWindowScrolled, void* );
410 DECL_LINK( MRUChanged, void* );
412 public:
413 ImplListBox( Window* pParent, WinBits nWinStyle );
414 virtual ~ImplListBox();
416 const ImplEntryList* GetEntryList() const { return maLBWindow.GetEntryList(); }
417 ImplListBoxWindow* GetMainWindow() { return &maLBWindow; }
419 virtual void Resize() SAL_OVERRIDE;
420 virtual const Wallpaper& GetDisplayBackground() const SAL_OVERRIDE;
421 virtual Window* GetPreferredKeyInputWindow() SAL_OVERRIDE;
423 sal_Int32 InsertEntry( sal_Int32 nPos, const OUString& rStr );
424 sal_Int32 InsertEntry( sal_Int32 nPos, const OUString& rStr, const Image& rImage );
425 void RemoveEntry( sal_Int32 nPos );
426 void SetEntryData( sal_Int32 nPos, void* pNewData ) { maLBWindow.GetEntryList()->SetEntryData( nPos, pNewData ); }
427 void Clear();
429 void SetEntryFlags( sal_Int32 nPos, long nFlags );
431 void SelectEntry( sal_Int32 nPos, bool bSelect );
432 void SetNoSelection();
433 void ResetCurrentPos() { maLBWindow.ResetCurrentPos(); }
434 sal_Int32 GetCurrentPos() const { return maLBWindow.GetCurrentPos(); }
436 bool ProcessKeyInput( const KeyEvent& rKEvt ) { return maLBWindow.ProcessKeyInput( rKEvt ); }
437 bool HandleWheelAsCursorTravel( const CommandEvent& rCEvt );
439 void SetSeparatorPos( sal_Int32 n ) { maLBWindow.SetSeparatorPos( n ); }
440 sal_Int32 GetSeparatorPos() const { return maLBWindow.GetSeparatorPos(); }
442 void SetTopEntry( sal_Int32 nTop ) { maLBWindow.SetTopEntry( nTop ); }
443 sal_Int32 GetTopEntry() const { return maLBWindow.GetTopEntry(); }
444 void ShowProminentEntry( sal_Int32 nPos ) { maLBWindow.ShowProminentEntry( nPos ); }
445 using Window::IsVisible;
446 bool IsVisible( sal_Int32 nEntry ) const { return maLBWindow.IsVisible( nEntry ); }
448 void SetProminentEntryType( ProminentEntry eType ) { maLBWindow.SetProminentEntryType( eType ); }
449 ProminentEntry GetProminentEntryType() const { return maLBWindow.GetProminentEntryType(); }
451 long GetLeftIndent() const { return maLBWindow.GetLeftIndent(); }
452 void SetLeftIndent( sal_uInt16 n ) { maLBWindow.SetLeftIndent( n ); }
453 void ScrollHorz( short nDiff ) { maLBWindow.ScrollHorz( nDiff ); }
455 void SetTravelSelect( bool bTravelSelect ) { maLBWindow.SetTravelSelect( bTravelSelect ); }
456 bool IsTravelSelect() const { return maLBWindow.IsTravelSelect(); }
457 bool IsTrackingSelect() const { return maLBWindow.IsTrackingSelect(); }
459 void EnableMultiSelection( bool bMulti, bool bStackMode ) { maLBWindow.EnableMultiSelection( bMulti, bStackMode ); }
460 bool IsMultiSelectionEnabled() const { return maLBWindow.IsMultiSelectionEnabled(); }
462 void SetMultiSelectionSimpleMode( bool bSimple ) { maLBWindow.SetMultiSelectionSimpleMode( bSimple ); }
463 bool IsMultiSelectionSimpleMode() const { return maLBWindow.IsMultiSelectionSimpleMode(); }
465 void SetReadOnly( bool b ) { maLBWindow.SetReadOnly( b ); }
466 bool IsReadOnly() const { return maLBWindow.IsReadOnly(); }
468 Size CalcSize( sal_Int32 nMaxLines ) const { return maLBWindow.CalcSize( nMaxLines ); }
469 long GetEntryHeight() const { return maLBWindow.GetEntryHeight(); }
470 long GetMaxEntryWidth() const { return maLBWindow.GetMaxEntryWidth(); }
472 void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; }
473 const Link& GetScrollHdl() const { return maScrollHdl; }
474 void SetSelectHdl( const Link& rLink ) { maLBWindow.SetSelectHdl( rLink ); }
475 const Link& GetSelectHdl() const { return maLBWindow.GetSelectHdl(); }
476 void SetCancelHdl( const Link& rLink ) { maLBWindow.SetCancelHdl( rLink ); }
477 const Link& GetCancelHdl() const { return maLBWindow.GetCancelHdl(); }
478 void SetDoubleClickHdl( const Link& rLink ) { maLBWindow.SetDoubleClickHdl( rLink ); }
479 const Link& GetDoubleClickHdl() const { return maLBWindow.GetDoubleClickHdl(); }
480 void SetUserDrawHdl( const Link& rLink ) { maLBWindow.SetUserDrawHdl( rLink ); }
481 const Link& GetUserDrawHdl() const { return maLBWindow.GetUserDrawHdl(); }
483 void SetFocusHdl( const Link& rLink ) { maLBWindow.SetFocusHdl( rLink ); }
484 const Link& GetFocusHdl() const { return maLBWindow.GetFocusHdl(); }
485 void SetListItemSelectHdl( const Link& rLink ) { maLBWindow.SetListItemSelectHdl( rLink ); }
486 const Link& GetListItemSelectHdl() const { return maLBWindow.GetListItemSelectHdl(); }
487 void SetSelectionChangedHdl( const Link& rLnk ) { maLBWindow.GetEntryList()->SetSelectionChangedHdl( rLnk ); }
488 void SetCallSelectionChangedHdl( bool bCall ) { maLBWindow.GetEntryList()->SetCallSelectionChangedHdl( bCall ); }
489 bool IsSelectionChanged() const { return maLBWindow.IsSelectionChanged(); }
490 sal_uInt16 GetSelectModifier() const { return maLBWindow.GetSelectModifier(); }
492 void SetMRUEntries( const OUString& rEntries, sal_Unicode cSep );
493 OUString GetMRUEntries( sal_Unicode cSep ) const;
494 void SetMaxMRUCount( sal_Int32 n ) { maLBWindow.GetEntryList()->SetMaxMRUCount( n ); }
495 sal_Int32 GetMaxMRUCount() const { return maLBWindow.GetEntryList()->GetMaxMRUCount(); }
496 sal_uInt16 GetDisplayLineCount() const
497 { return maLBWindow.GetDisplayLineCount(); }
499 bool GetEdgeBlending() const { return mbEdgeBlending; }
500 void SetEdgeBlending(bool bNew);
502 /// pb: #106948# explicit mirroring for calc
503 inline void EnableMirroring() { maLBWindow.EnableMirroring(); }
504 inline void SetDropTraget(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_xDNDListenerContainer){ mxDNDListenerContainer= i_xDNDListenerContainer; }
507 class ImplListBoxFloatingWindow : public FloatingWindow
509 private:
510 ImplListBox* mpImplLB;
511 Size maPrefSz;
512 sal_uInt16 mnDDLineCount;
513 sal_Int32 mnPopupModeStartSaveSelection;
514 bool mbAutoWidth;
516 protected:
517 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
519 public:
520 ImplListBoxFloatingWindow( Window* pParent );
522 void SetImplListBox( ImplListBox* pLB ) { mpImplLB = pLB; }
524 void SetPrefSize( const Size& rSz ) { maPrefSz = rSz; }
525 const Size& GetPrefSize() const { return maPrefSz; }
527 void SetAutoWidth( bool b ) { mbAutoWidth = b; }
528 bool IsAutoWidth() const { return mbAutoWidth; }
530 Size CalcFloatSize();
531 void StartFloat( bool bStartTracking );
533 virtual void setPosSizePixel( long nX, long nY,
534 long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ) SAL_OVERRIDE;
535 void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) SAL_OVERRIDE
536 { FloatingWindow::SetPosSizePixel( rNewPos, rNewSize ); }
538 void SetDropDownLineCount( sal_uInt16 n ) { mnDDLineCount = n; }
539 sal_uInt16 GetDropDownLineCount() const { return mnDDLineCount; }
541 sal_Int32 GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection; }
543 virtual void Resize() SAL_OVERRIDE;
546 class ImplWin : public Control
548 private:
550 sal_Int32 mnItemPos; ///< because of UserDraw I have to know which item I draw
551 OUString maString;
552 Image maImage;
554 Rectangle maFocusRect;
555 Size maUserItemSize;
557 Link maMBDownHdl;
558 Link maUserDrawHdl;
560 /// bitfield
561 bool mbUserDrawEnabled : 1;
562 bool mbInUserDraw : 1;
563 bool mbEdgeBlending : 1;
565 void ImplDraw( bool bLayout = false );
566 protected:
567 virtual void FillLayoutData() const SAL_OVERRIDE;
568 public:
570 ImplWin( Window* pParent, WinBits nWinStyle = 0 );
571 virtual ~ImplWin() {};
573 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
574 virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
575 virtual void Resize() SAL_OVERRIDE;
576 virtual void GetFocus() SAL_OVERRIDE;
577 virtual void LoseFocus() SAL_OVERRIDE;
578 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
580 sal_Int32 GetItemPos() const { return mnItemPos; }
581 void SetItemPos( sal_Int32 n ) { mnItemPos = n; }
583 const OUString& GetString() const { return maString; }
584 void SetString( const OUString& rStr ) { maString = rStr; }
586 const Image& GetImage() const { return maImage; }
587 void SetImage( const Image& rImg ) { maImage = rImg; }
589 virtual void MBDown();
590 void SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; }
591 const Link& GetMBDownHdl() const { return maMBDownHdl; }
593 void SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; }
594 const Link& GetUserDrawHdl() const { return maUserDrawHdl; }
596 void SetUserItemSize( const Size& rSz ) { maUserItemSize = rSz; }
597 const Size& GetUserItemSize() const { return maUserItemSize; }
599 void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
600 bool IsUserDrawEnabled() const { return mbUserDrawEnabled; }
602 void DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false, bool bLayout = false );
604 bool GetEdgeBlending() const { return mbEdgeBlending; }
605 void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
608 class ImplBtn : public PushButton
610 private:
611 bool mbDown;
613 Link maMBDownHdl;
615 public:
616 ImplBtn( Window* pParent, WinBits nWinStyle = 0 );
617 virtual ~ImplBtn() {};
619 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
621 virtual void MBDown();
622 void SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; }
623 const Link& GetMBDownHdl() const { return maMBDownHdl; }
626 void ImplInitFieldSettings( Window* pWin, bool bFont, bool bForeground, bool bBackground );
627 void ImplInitDropDownButton( PushButton* pButton );
629 #endif // INCLUDED_VCL_INC_ILSTBOX_HXX
631 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */