Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_INC_ILSTBOX_HXX
21 : #define INCLUDED_VCL_INC_ILSTBOX_HXX
22 :
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>
30 :
31 : #include "vcl/quickselectionengine.hxx"
32 :
33 : class ScrollBar;
34 : class ScrollBarBox;
35 :
36 : #define HORZ_SCROLL 4
37 : #define IMG_TXT_DISTANCE 6
38 :
39 : enum LB_EVENT_TYPE
40 : {
41 : LET_MBDOWN,
42 : LET_TRACKING,
43 : LET_TRACKING_END,
44 : LET_KEYMOVE,
45 : LET_KEYSPACE
46 : };
47 :
48 0 : struct ImplEntryType
49 : {
50 : OUString maStr;
51 : Image maImage;
52 : void* mpUserData;
53 : bool mbIsSelected;
54 : long mnFlags;
55 : long mnHeight;
56 :
57 0 : ImplEntryType( const OUString& rStr, const Image& rImage ) :
58 : maStr( rStr ),
59 : maImage( rImage ),
60 : mnFlags( 0 ),
61 0 : mnHeight( 0 )
62 : {
63 0 : mbIsSelected = false;
64 0 : mpUserData = NULL;
65 0 : }
66 :
67 0 : ImplEntryType( const OUString& rStr ) :
68 : maStr( rStr ),
69 : mnFlags( 0 ),
70 0 : mnHeight( 0 )
71 : {
72 0 : mbIsSelected = false;
73 0 : mpUserData = NULL;
74 0 : }
75 :
76 : ImplEntryType( const Image& rImage ) :
77 : maImage( rImage ),
78 : mnFlags( 0 ),
79 : mnHeight( 0 )
80 : {
81 : mbIsSelected = false;
82 : mpUserData = NULL;
83 : }
84 : };
85 :
86 : class ImplEntryList
87 : {
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;
93 :
94 : sal_Int32 mnMRUCount;
95 : sal_Int32 mnMaxMRUCount;
96 :
97 : Link maSelectionChangedHdl;
98 : bool mbCallSelectionChangedHdl;
99 : boost::ptr_vector<ImplEntryType> maEntries;
100 :
101 0 : ImplEntryType* GetEntry( sal_Int32 nPos ) const
102 : {
103 0 : if (nPos < 0 || static_cast<size_t>(nPos) >= maEntries.size())
104 0 : return NULL;
105 0 : return const_cast<ImplEntryType*>(&maEntries[nPos]);
106 : }
107 :
108 : public:
109 : ImplEntryList( Window* pWindow );
110 : ~ImplEntryList();
111 :
112 : sal_Int32 InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry, bool bSort );
113 : void RemoveEntry( sal_Int32 nPos );
114 0 : const ImplEntryType* GetEntryPtr( sal_Int32 nPos ) const { return (const ImplEntryType*) GetEntry( nPos ); }
115 0 : ImplEntryType* GetMutableEntryPtr( sal_Int32 nPos ) const { return GetEntry( nPos ); }
116 : void Clear();
117 :
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;
121 :
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;
128 :
129 0 : sal_Int32 GetEntryCount() const { return (sal_Int32 )maEntries.size(); }
130 0 : bool HasImages() const { return mnImages ? true : false; }
131 :
132 : OUString GetEntryText( sal_Int32 nPos ) const;
133 :
134 : bool HasEntryImage( sal_Int32 nPos ) const;
135 : Image GetEntryImage( sal_Int32 nPos ) const;
136 :
137 : void SetEntryData( sal_Int32 nPos, void* pNewData );
138 : void* GetEntryData( sal_Int32 nPos ) const;
139 :
140 : void SetEntryFlags( sal_Int32 nPos, long nFlags );
141 : long GetEntryFlags( sal_Int32 nPos ) const;
142 :
143 : void SelectEntry( sal_Int32 nPos, bool bSelect );
144 :
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;
149 :
150 0 : void SetLastSelected( sal_Int32 nPos ) { mnLastSelected = nPos; }
151 0 : sal_Int32 GetLastSelected() const { return mnLastSelected; }
152 :
153 0 : void SetSelectionAnchor( sal_Int32 nPos ) { mnSelectionAnchor = nPos; }
154 0 : sal_Int32 GetSelectionAnchor() const { return mnSelectionAnchor; }
155 :
156 0 : void SetSelectionChangedHdl( const Link& rLnk ) { maSelectionChangedHdl = rLnk; }
157 0 : void SetCallSelectionChangedHdl( bool bCall ) { mbCallSelectionChangedHdl = bCall; }
158 :
159 0 : void SetMRUCount( sal_Int32 n ) { mnMRUCount = n; }
160 0 : sal_Int32 GetMRUCount() const { return mnMRUCount; }
161 :
162 0 : void SetMaxMRUCount( sal_Int32 n ) { mnMaxMRUCount = n; }
163 0 : sal_Int32 GetMaxMRUCount() const { return mnMaxMRUCount; }
164 :
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;
168 :
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.
173 : */
174 : sal_Int32 FindFirstSelectable( sal_Int32 nPos, bool bForward = true );
175 : };
176 :
177 : class ImplListBoxWindow : public Control, public ::vcl::ISearchableStringList
178 : {
179 : private:
180 : ImplEntryList* mpEntryList; ///< EntryList
181 : Rectangle maFocusRect;
182 :
183 : Size maUserItemSize;
184 :
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
194 :
195 : sal_Int32 mnCurrentPos; ///< Position (Focus)
196 : sal_Int32 mnTrackingSaveSelection; ///< Selection before Tracking();
197 :
198 : sal_Int32 mnSeparatorPos; ///< Separator
199 :
200 : sal_Int32 mnUserDrawEntry;
201 :
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
207 :
208 : sal_uInt16 mnSelectModifier; ///< Modifiers
209 :
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;
230 :
231 : Link maScrollHdl;
232 : Link maSelectHdl;
233 : Link maCancelHdl;
234 : Link maDoubleClickHdl;
235 : Link maUserDrawHdl;
236 : Link maMRUChangedHdl;
237 : Link maFocusHdl;
238 : Link maListItemSelectHdl;
239 :
240 : ::vcl::QuickSelectionEngine maQuickSelectionEngine;
241 :
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;
251 :
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();
258 :
259 : void ImplShowFocusRect();
260 : void ImplHideFocusRect();
261 :
262 : virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
263 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
264 :
265 : public:
266 : virtual void FillLayoutData() const SAL_OVERRIDE;
267 :
268 : ImplListBoxWindow( Window* pParent, WinBits nWinStyle );
269 : virtual ~ImplListBoxWindow();
270 :
271 0 : ImplEntryList* GetEntryList() const { return mpEntryList; }
272 :
273 : sal_Int32 InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry );
274 : void RemoveEntry( sal_Int32 nPos );
275 : void Clear();
276 0 : void ResetCurrentPos() { mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; }
277 0 : sal_Int32 GetCurrentPos() const { return mnCurrentPos; }
278 : sal_uInt16 GetDisplayLineCount() const;
279 : void SetEntryFlags( sal_Int32 nPos, long nFlags );
280 :
281 : void DrawEntry( sal_Int32 nPos, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false, bool bLayout = false );
282 :
283 : void SelectEntry( sal_Int32 nPos, bool bSelect );
284 : void DeselectAll();
285 : sal_Int32 GetEntryPosForPoint( const Point& rPoint ) const;
286 : sal_Int32 GetLastVisibleEntry() const;
287 :
288 : bool ProcessKeyInput( const KeyEvent& rKEvt );
289 :
290 : void SetTopEntry( sal_Int32 nTop );
291 0 : 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 0 : void SetProminentEntryType( ProminentEntry eType ) { meProminentType = eType; }
296 : ProminentEntry GetProminentEntryType() const { return meProminentType; }
297 : using Window::IsVisible;
298 : bool IsVisible( sal_Int32 nEntry ) const;
299 :
300 0 : long GetLeftIndent() const { return mnLeft; }
301 : void SetLeftIndent( long n );
302 : void ScrollHorz( long nDiff );
303 :
304 0 : void AllowGrabFocus( bool b ) { mbGrabFocus = b; }
305 0 : bool IsGrabFocusAllowed() const { return mbGrabFocus; }
306 :
307 0 : void SetSeparatorPos( sal_Int32 n ) { mnSeparatorPos = n; }
308 0 : sal_Int32 GetSeparatorPos() const { return mnSeparatorPos; }
309 :
310 0 : void SetTravelSelect( bool bTravelSelect ) { mbTravelSelect = bTravelSelect; }
311 0 : bool IsTravelSelect() const { return mbTravelSelect; }
312 0 : bool IsTrackingSelect() const { return mbTrackingSelect; }
313 :
314 : void SetUserItemSize( const Size& rSz );
315 : const Size& GetUserItemSize() const { return maUserItemSize; }
316 :
317 0 : void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
318 0 : bool IsUserDrawEnabled() const { return mbUserDrawEnabled; }
319 :
320 0 : void EnableMultiSelection( bool bMulti, bool bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; }
321 0 : bool IsMultiSelectionEnabled() const { return mbMulti; }
322 :
323 0 : void SetMultiSelectionSimpleMode( bool bSimple ) { mbSimpleMode = bSimple; }
324 : bool IsMultiSelectionSimpleMode() const { return mbSimpleMode; }
325 :
326 0 : void EnableMouseMoveSelect( bool bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; }
327 : bool IsMouseMoveSelectEnabled() const { return mbMouseMoveSelect; }
328 0 : bool IsMouseMoveSelect() const { return mbMouseMoveSelect||mbStackMode; }
329 :
330 : Size CalcSize(sal_Int32 nMaxLines) const;
331 : Rectangle GetBoundingRectangle( sal_Int32 nItem ) const;
332 :
333 0 : long GetEntryHeight() const { return mnMaxHeight; }
334 0 : long GetMaxEntryWidth() const { return mnMaxWidth; }
335 :
336 0 : void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; }
337 : const Link& GetScrollHdl() const { return maScrollHdl; }
338 0 : void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }
339 : const Link& GetSelectHdl() const { return maSelectHdl; }
340 0 : void SetCancelHdl( const Link& rLink ) { maCancelHdl = rLink; }
341 : const Link& GetCancelHdl() const { return maCancelHdl; }
342 0 : void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; }
343 : const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; }
344 0 : void SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; }
345 : const Link& GetUserDrawHdl() const { return maUserDrawHdl; }
346 0 : void SetMRUChangedHdl( const Link& rLink ) { maMRUChangedHdl = rLink; }
347 : const Link& GetMRUChangedHdl() const { return maMRUChangedHdl; }
348 0 : void SetFocusHdl( const Link& rLink ) { maFocusHdl = rLink ; }
349 : const Link& GetFocusHdl() const { return maFocusHdl; }
350 :
351 0 : void SetListItemSelectHdl( const Link& rLink ) { maListItemSelectHdl = rLink ; }
352 : const Link& GetListItemSelectHdl() const { return maListItemSelectHdl; }
353 0 : bool IsSelectionChanged() const { return mbSelectionChanged; }
354 0 : sal_uInt16 GetSelectModifier() const { return mnSelectModifier; }
355 :
356 0 : void EnableSort( bool b ) { mbSort = b; }
357 :
358 0 : void SetReadOnly( bool bReadOnly ) { mbReadOnly = bReadOnly; }
359 0 : bool IsReadOnly() const { return mbReadOnly; }
360 :
361 : using Control::ImplInitSettings;
362 : void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
363 : sal_uInt16 ImplGetTextStyle() const;
364 :
365 : /// pb: #106948# explicit mirroring for calc
366 0 : inline void EnableMirroring() { mbMirroring = true; }
367 0 : inline bool IsMirroring() const { return mbMirroring; }
368 :
369 0 : bool GetEdgeBlending() const { return mbEdgeBlending; }
370 0 : void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
371 : void EnableQuickSelection( const bool& b );
372 :
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;
378 : };
379 :
380 : class ImplListBox : public Control
381 : {
382 : private:
383 : ImplListBoxWindow maLBWindow;
384 : ScrollBar* mpHScrollBar;
385 : ScrollBar* mpVScrollBar;
386 : ScrollBarBox* mpScrollBarBox;
387 :
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;
393 :
394 : Link maScrollHdl; // because it is needed by ImplListBoxWindow itself
395 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer;
396 :
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;
401 :
402 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
403 :
404 : void ImplResizeControls();
405 : void ImplCheckScrollBars();
406 : void ImplInitScrollBars();
407 :
408 : DECL_LINK( ScrollBarHdl, ScrollBar* );
409 : DECL_LINK( LBWindowScrolled, void* );
410 : DECL_LINK( MRUChanged, void* );
411 :
412 : public:
413 : ImplListBox( Window* pParent, WinBits nWinStyle );
414 : virtual ~ImplListBox();
415 :
416 0 : const ImplEntryList* GetEntryList() const { return maLBWindow.GetEntryList(); }
417 0 : ImplListBoxWindow* GetMainWindow() { return &maLBWindow; }
418 :
419 : virtual void Resize() SAL_OVERRIDE;
420 : virtual const Wallpaper& GetDisplayBackground() const SAL_OVERRIDE;
421 : virtual Window* GetPreferredKeyInputWindow() SAL_OVERRIDE;
422 :
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 0 : void SetEntryData( sal_Int32 nPos, void* pNewData ) { maLBWindow.GetEntryList()->SetEntryData( nPos, pNewData ); }
427 : void Clear();
428 :
429 : void SetEntryFlags( sal_Int32 nPos, long nFlags );
430 :
431 : void SelectEntry( sal_Int32 nPos, bool bSelect );
432 : void SetNoSelection();
433 0 : void ResetCurrentPos() { maLBWindow.ResetCurrentPos(); }
434 0 : sal_Int32 GetCurrentPos() const { return maLBWindow.GetCurrentPos(); }
435 :
436 0 : bool ProcessKeyInput( const KeyEvent& rKEvt ) { return maLBWindow.ProcessKeyInput( rKEvt ); }
437 : bool HandleWheelAsCursorTravel( const CommandEvent& rCEvt );
438 :
439 0 : void SetSeparatorPos( sal_Int32 n ) { maLBWindow.SetSeparatorPos( n ); }
440 0 : sal_Int32 GetSeparatorPos() const { return maLBWindow.GetSeparatorPos(); }
441 :
442 0 : void SetTopEntry( sal_Int32 nTop ) { maLBWindow.SetTopEntry( nTop ); }
443 0 : sal_Int32 GetTopEntry() const { return maLBWindow.GetTopEntry(); }
444 0 : void ShowProminentEntry( sal_Int32 nPos ) { maLBWindow.ShowProminentEntry( nPos ); }
445 : using Window::IsVisible;
446 0 : bool IsVisible( sal_Int32 nEntry ) const { return maLBWindow.IsVisible( nEntry ); }
447 :
448 0 : void SetProminentEntryType( ProminentEntry eType ) { maLBWindow.SetProminentEntryType( eType ); }
449 : ProminentEntry GetProminentEntryType() const { return maLBWindow.GetProminentEntryType(); }
450 :
451 0 : long GetLeftIndent() const { return maLBWindow.GetLeftIndent(); }
452 0 : void SetLeftIndent( sal_uInt16 n ) { maLBWindow.SetLeftIndent( n ); }
453 : void ScrollHorz( short nDiff ) { maLBWindow.ScrollHorz( nDiff ); }
454 :
455 0 : void SetTravelSelect( bool bTravelSelect ) { maLBWindow.SetTravelSelect( bTravelSelect ); }
456 0 : bool IsTravelSelect() const { return maLBWindow.IsTravelSelect(); }
457 0 : bool IsTrackingSelect() const { return maLBWindow.IsTrackingSelect(); }
458 :
459 0 : void EnableMultiSelection( bool bMulti, bool bStackMode ) { maLBWindow.EnableMultiSelection( bMulti, bStackMode ); }
460 0 : bool IsMultiSelectionEnabled() const { return maLBWindow.IsMultiSelectionEnabled(); }
461 :
462 0 : void SetMultiSelectionSimpleMode( bool bSimple ) { maLBWindow.SetMultiSelectionSimpleMode( bSimple ); }
463 : bool IsMultiSelectionSimpleMode() const { return maLBWindow.IsMultiSelectionSimpleMode(); }
464 :
465 0 : void SetReadOnly( bool b ) { maLBWindow.SetReadOnly( b ); }
466 0 : bool IsReadOnly() const { return maLBWindow.IsReadOnly(); }
467 :
468 0 : Size CalcSize( sal_Int32 nMaxLines ) const { return maLBWindow.CalcSize( nMaxLines ); }
469 0 : long GetEntryHeight() const { return maLBWindow.GetEntryHeight(); }
470 0 : long GetMaxEntryWidth() const { return maLBWindow.GetMaxEntryWidth(); }
471 :
472 0 : void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; }
473 : const Link& GetScrollHdl() const { return maScrollHdl; }
474 0 : void SetSelectHdl( const Link& rLink ) { maLBWindow.SetSelectHdl( rLink ); }
475 : const Link& GetSelectHdl() const { return maLBWindow.GetSelectHdl(); }
476 0 : void SetCancelHdl( const Link& rLink ) { maLBWindow.SetCancelHdl( rLink ); }
477 : const Link& GetCancelHdl() const { return maLBWindow.GetCancelHdl(); }
478 0 : void SetDoubleClickHdl( const Link& rLink ) { maLBWindow.SetDoubleClickHdl( rLink ); }
479 : const Link& GetDoubleClickHdl() const { return maLBWindow.GetDoubleClickHdl(); }
480 0 : void SetUserDrawHdl( const Link& rLink ) { maLBWindow.SetUserDrawHdl( rLink ); }
481 : const Link& GetUserDrawHdl() const { return maLBWindow.GetUserDrawHdl(); }
482 :
483 0 : void SetFocusHdl( const Link& rLink ) { maLBWindow.SetFocusHdl( rLink ); }
484 : const Link& GetFocusHdl() const { return maLBWindow.GetFocusHdl(); }
485 0 : void SetListItemSelectHdl( const Link& rLink ) { maLBWindow.SetListItemSelectHdl( rLink ); }
486 : const Link& GetListItemSelectHdl() const { return maLBWindow.GetListItemSelectHdl(); }
487 0 : void SetSelectionChangedHdl( const Link& rLnk ) { maLBWindow.GetEntryList()->SetSelectionChangedHdl( rLnk ); }
488 0 : void SetCallSelectionChangedHdl( bool bCall ) { maLBWindow.GetEntryList()->SetCallSelectionChangedHdl( bCall ); }
489 0 : bool IsSelectionChanged() const { return maLBWindow.IsSelectionChanged(); }
490 0 : sal_uInt16 GetSelectModifier() const { return maLBWindow.GetSelectModifier(); }
491 :
492 : void SetMRUEntries( const OUString& rEntries, sal_Unicode cSep );
493 : OUString GetMRUEntries( sal_Unicode cSep ) const;
494 0 : void SetMaxMRUCount( sal_Int32 n ) { maLBWindow.GetEntryList()->SetMaxMRUCount( n ); }
495 0 : sal_Int32 GetMaxMRUCount() const { return maLBWindow.GetEntryList()->GetMaxMRUCount(); }
496 0 : sal_uInt16 GetDisplayLineCount() const
497 0 : { return maLBWindow.GetDisplayLineCount(); }
498 :
499 0 : bool GetEdgeBlending() const { return mbEdgeBlending; }
500 : void SetEdgeBlending(bool bNew);
501 :
502 : /// pb: #106948# explicit mirroring for calc
503 0 : inline void EnableMirroring() { maLBWindow.EnableMirroring(); }
504 0 : inline void SetDropTraget(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_xDNDListenerContainer){ mxDNDListenerContainer= i_xDNDListenerContainer; }
505 : };
506 :
507 0 : class ImplListBoxFloatingWindow : public FloatingWindow
508 : {
509 : private:
510 : ImplListBox* mpImplLB;
511 : Size maPrefSz;
512 : sal_uInt16 mnDDLineCount;
513 : sal_Int32 mnPopupModeStartSaveSelection;
514 : bool mbAutoWidth;
515 :
516 : protected:
517 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
518 :
519 : public:
520 : ImplListBoxFloatingWindow( Window* pParent );
521 :
522 0 : void SetImplListBox( ImplListBox* pLB ) { mpImplLB = pLB; }
523 :
524 0 : void SetPrefSize( const Size& rSz ) { maPrefSz = rSz; }
525 0 : const Size& GetPrefSize() const { return maPrefSz; }
526 :
527 0 : void SetAutoWidth( bool b ) { mbAutoWidth = b; }
528 : bool IsAutoWidth() const { return mbAutoWidth; }
529 :
530 : Size CalcFloatSize();
531 : void StartFloat( bool bStartTracking );
532 :
533 : virtual void setPosSizePixel( long nX, long nY,
534 : long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ) SAL_OVERRIDE;
535 0 : void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) SAL_OVERRIDE
536 0 : { FloatingWindow::SetPosSizePixel( rNewPos, rNewSize ); }
537 :
538 0 : void SetDropDownLineCount( sal_uInt16 n ) { mnDDLineCount = n; }
539 0 : sal_uInt16 GetDropDownLineCount() const { return mnDDLineCount; }
540 :
541 0 : sal_Int32 GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection; }
542 :
543 : virtual void Resize() SAL_OVERRIDE;
544 : };
545 :
546 : class ImplWin : public Control
547 : {
548 : private:
549 :
550 : sal_Int32 mnItemPos; ///< because of UserDraw I have to know which item I draw
551 : OUString maString;
552 : Image maImage;
553 :
554 : Rectangle maFocusRect;
555 : Size maUserItemSize;
556 :
557 : Link maMBDownHdl;
558 : Link maUserDrawHdl;
559 :
560 : /// bitfield
561 : bool mbUserDrawEnabled : 1;
562 : bool mbInUserDraw : 1;
563 : bool mbEdgeBlending : 1;
564 :
565 : void ImplDraw( bool bLayout = false );
566 : protected:
567 : virtual void FillLayoutData() const SAL_OVERRIDE;
568 : public:
569 :
570 : ImplWin( Window* pParent, WinBits nWinStyle = 0 );
571 0 : virtual ~ImplWin() {};
572 :
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;
579 :
580 0 : sal_Int32 GetItemPos() const { return mnItemPos; }
581 0 : void SetItemPos( sal_Int32 n ) { mnItemPos = n; }
582 :
583 : const OUString& GetString() const { return maString; }
584 0 : void SetString( const OUString& rStr ) { maString = rStr; }
585 :
586 : const Image& GetImage() const { return maImage; }
587 0 : void SetImage( const Image& rImg ) { maImage = rImg; }
588 :
589 : virtual void MBDown();
590 0 : void SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; }
591 : const Link& GetMBDownHdl() const { return maMBDownHdl; }
592 :
593 0 : void SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; }
594 : const Link& GetUserDrawHdl() const { return maUserDrawHdl; }
595 :
596 0 : void SetUserItemSize( const Size& rSz ) { maUserItemSize = rSz; }
597 : const Size& GetUserItemSize() const { return maUserItemSize; }
598 :
599 0 : void EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
600 0 : bool IsUserDrawEnabled() const { return mbUserDrawEnabled; }
601 :
602 : void DrawEntry( bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false, bool bLayout = false );
603 :
604 0 : bool GetEdgeBlending() const { return mbEdgeBlending; }
605 0 : void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
606 : };
607 :
608 : class ImplBtn : public PushButton
609 : {
610 : private:
611 : bool mbDown;
612 :
613 : Link maMBDownHdl;
614 :
615 : public:
616 : ImplBtn( Window* pParent, WinBits nWinStyle = 0 );
617 0 : virtual ~ImplBtn() {};
618 :
619 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
620 :
621 : virtual void MBDown();
622 0 : void SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; }
623 : const Link& GetMBDownHdl() const { return maMBDownHdl; }
624 : };
625 :
626 : void ImplInitFieldSettings( Window* pWin, bool bFont, bool bForeground, bool bBackground );
627 : void ImplInitDropDownButton( PushButton* pButton );
628 :
629 : #endif // INCLUDED_VCL_INC_ILSTBOX_HXX
630 :
631 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|