xref: /trunk/main/vcl/inc/ilstbox.hxx (revision b597708ba18998e5b62934c916addb8de3415a8a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_ILSTBOX_HXX
25 #define _SV_ILSTBOX_HXX
26 
27 #include <vcl/sv.h>
28 #include <vcl/image.hxx>
29 #include <vcl/ctrl.hxx>
30 #include <vcl/button.hxx>
31 #include <vcl/floatwin.hxx>
32 #include <vcl/lstbox.h>
33 #include <vcl/timer.hxx>
34 
35 #include "vcl/quickselectionengine.hxx"
36 
37 class ScrollBar;
38 class ScrollBarBox;
39 
40 // -----------------
41 // - ListBox-Types -
42 // -----------------
43 
44 #define HORZ_SCROLL         4
45 #define IMG_TXT_DISTANCE    6
46 
47 enum LB_EVENT_TYPE
48 {
49     LET_MBDOWN,
50     LET_TRACKING,
51     LET_TRACKING_END,
52     LET_KEYMOVE,
53     LET_KEYSPACE
54 };
55 
56 // -----------------
57 // - ImplEntryType -
58 // -----------------
59 
60 struct ImplEntryType
61 {
62     XubString   maStr;
63     Image       maImage;
64     void*       mpUserData;
65     sal_Bool        mbIsSelected;
66     long        mnFlags;
67     long        mnHeight;
68 
69     ImplEntryType( const XubString& rStr, const Image& rImage ) :
70         maStr( rStr ),
71         maImage( rImage ),
72         mnFlags( 0 ),
73         mnHeight( 0 )
74     {
75         mbIsSelected = sal_False;
76         mpUserData = NULL;
77     }
78 
79     ImplEntryType( const XubString& rStr ) :
80         maStr( rStr ),
81         mnFlags( 0 ),
82         mnHeight( 0 )
83     {
84         mbIsSelected = sal_False;
85         mpUserData = NULL;
86     }
87 
88     ImplEntryType( const Image& rImage ) :
89         maImage( rImage ),
90         mnFlags( 0 ),
91         mnHeight( 0 )
92     {
93         mbIsSelected = sal_False;
94         mpUserData = NULL;
95     }
96 };
97 
98 // -----------------
99 // - ImplEntryList -
100 // -----------------
101 
102 class ImplEntryList : private List
103 {
104 private:
105     Window*         mpWindow;   // For getting the current locale when matching strings
106     sal_uInt16          mnLastSelected;
107     sal_uInt16          mnSelectionAnchor;
108     sal_uInt16          mnImages;
109 
110     sal_uInt16          mnMRUCount;
111     sal_uInt16          mnMaxMRUCount;
112 
113     Link            maSelectionChangedHdl;
114     sal_Bool            mbCallSelectionChangedHdl;
115 
116     ImplEntryType*  GetEntry( sal_uInt16 nPos ) const { return (ImplEntryType*)List::GetObject( nPos ); }
117 
118 public:
119                     ImplEntryList( Window* pWindow );
120                     ~ImplEntryList();
121 
122     sal_uInt16                  InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry, sal_Bool bSort );
123     void                    RemoveEntry( sal_uInt16 nPos );
124     const ImplEntryType*    GetEntryPtr( sal_uInt16 nPos ) const { return (const ImplEntryType*) GetObject( nPos ); }
125     ImplEntryType*          GetMutableEntryPtr( sal_uInt16 nPos ) const { return (ImplEntryType*) GetObject( nPos ); }
126     void                    Clear();
127 
128     sal_uInt16          FindMatchingEntry( const XubString& rStr, sal_uInt16 nStart = 0, sal_Bool bForward = sal_True, sal_Bool bLazy = sal_True ) const;
129     sal_uInt16          FindEntry( const XubString& rStr, sal_Bool bSearchMRUArea = sal_False ) const;
130     sal_uInt16          FindEntry( const void* pData ) const;
131 
132     // helper: add up heights up to index nEndIndex.
133     // GetAddedHeight( 0 ) returns 0
134     // GetAddedHeight( LISTBOX_ENTRY_NOTFOUND ) returns 0
135     // GetAddedHeight( i, k ) with k > i is equivalent -GetAddedHeight( k, i )
136     long            GetAddedHeight( sal_uInt16 nEndIndex, sal_uInt16 nBeginIndex = 0, long nBeginHeight = 0 ) const;
137     long            GetEntryHeight( sal_uInt16 nPos ) const;
138 
139     sal_uInt16          GetEntryCount() const { return (sal_uInt16)List::Count(); }
140     sal_Bool            HasImages() const { return mnImages ? sal_True : sal_False; }
141 
142     XubString       GetEntryText( sal_uInt16 nPos ) const;
143 
144     sal_Bool            HasEntryImage( sal_uInt16 nPos ) const;
145     Image           GetEntryImage( sal_uInt16 nPos ) const;
146 
147     void            SetEntryData( sal_uInt16 nPos, void* pNewData );
148     void*           GetEntryData( sal_uInt16 nPos ) const;
149 
150     void            SetEntryFlags( sal_uInt16 nPos, long nFlags );
151     long            GetEntryFlags( sal_uInt16 nPos ) const;
152 
153     void            SelectEntry( sal_uInt16 nPos, sal_Bool bSelect );
154 
155     sal_uInt16          GetSelectEntryCount() const;
156     XubString       GetSelectEntry( sal_uInt16 nIndex ) const;
157     sal_uInt16          GetSelectEntryPos( sal_uInt16 nIndex ) const;
158     sal_Bool            IsEntrySelected( const XubString& rStr ) const;
159     sal_Bool            IsEntryPosSelected( sal_uInt16 nIndex ) const;
160 
161     void            SetLastSelected( sal_uInt16 nPos )  { mnLastSelected = nPos; }
162     sal_uInt16          GetLastSelected() const { return mnLastSelected; }
163 
164     void            SetSelectionAnchor( sal_uInt16 nPos )   { mnSelectionAnchor = nPos; }
165     sal_uInt16          GetSelectionAnchor() const { return mnSelectionAnchor; }
166 
167 
168     void            SetSelectionChangedHdl( const Link& rLnk )  { maSelectionChangedHdl = rLnk; }
169     void            SetCallSelectionChangedHdl( sal_Bool bCall )    { mbCallSelectionChangedHdl = bCall; }
170 
171     void            SetMRUCount( sal_uInt16 n ) { mnMRUCount = n; }
172     sal_uInt16          GetMRUCount() const     { return mnMRUCount; }
173 
174     void            SetMaxMRUCount( sal_uInt16 n )  { mnMaxMRUCount = n; }
175     sal_uInt16          GetMaxMRUCount() const      { return mnMaxMRUCount; }
176 
177     /** An Entry is selectable if its mnFlags does not have the
178         LISTBOX_ENTRY_FLAG_DISABLE_SELECTION flag set. */
179     bool            IsEntrySelectable( sal_uInt16 nPos ) const;
180 
181     /** returns the first entry found from the given position nPos that is selectable
182         or LISTBOX_ENTRY_NOTFOUND if non is found. If the entry at nPos is not selectable,
183         it returns the first selectable entry after nPos if bForward is true and the
184         first selectable entry after nPos is bForward is false.
185         */
186     sal_uInt16          FindFirstSelectable( sal_uInt16 nPos, bool bForward = true );
187 };
188 
189 // ---------------------
190 // - ImplListBoxWindow -
191 // ---------------------
192 
193 class ImplListBoxWindow : public Control, public ::vcl::ISearchableStringList
194 {
195 private:
196     ImplEntryList*  mpEntryList;     // EntryListe
197     Rectangle       maFocusRect;
198 
199     Size            maUserItemSize;
200 
201     long            mnMaxTxtHeight;  // Maximale Hoehe eines Text-Items
202     long            mnMaxTxtWidth;   // Maximale Breite eines Text-Items
203                                      // Entry ohne Image
204     long            mnMaxImgTxtWidth;// Maximale Breite eines Text-Items
205                                      // Entry UND Image
206     long            mnMaxImgWidth;   // Maximale Breite eines Image-Items
207     long            mnMaxImgHeight;  // Maximale Hoehe eines Image-Items
208     long            mnMaxWidth;      // Maximale Breite eines Eintrags
209     long            mnMaxHeight;     // Maximale Hoehe eines Eintrags
210 
211     sal_uInt16          mnCurrentPos;    // Position (Focus)
212     sal_uInt16          mnTrackingSaveSelection; // Selektion vor Tracking();
213 
214     sal_uInt16          mnSeparatorPos; // Separator
215 
216     sal_uInt16          mnUserDrawEntry;
217 
218     sal_uInt16          mnTop;           // Ausgabe ab Zeile
219     long            mnLeft;          // Ausgabe ab Spalte
220     long            mnBorder;        // Abstand Rahmen - Text
221     long            mnTextHeight;    // Texthoehe
222     ProminentEntry  meProminentType; // where is the "prominent" entry
223 
224     sal_uInt16          mnSelectModifier;   // Modifiers
225 
226     /// bitfield
227     bool mbHasFocusRect : 1;
228     bool mbSort : 1;             // ListBox sortiert
229     bool mbTrack : 1;            // Tracking
230     bool mbMulti : 1;            // MultiListBox
231     bool mbStackMode : 1;        // StackSelection
232     bool mbSimpleMode : 1;       // SimpleMode fuer MultiListBox
233     bool mbImgsDiffSz : 1;       // Images haben verschiedene Groessen
234     bool mbTravelSelect : 1;     // TravelSelect
235     bool mbTrackingSelect : 1;   // Selektiert bei MouseMove
236     bool mbSelectionChanged : 1; // Select() nicht zu oft rufen...
237     bool mbMouseMoveSelect : 1;  // Selektieren bei MouseMove
238     bool mbGrabFocus : 1;        // Focus bei MBDown grabben
239     bool mbUserDrawEnabled : 1;  // UserDraw possible
240     bool mbInUserDraw : 1;       // In UserDraw
241     bool mbReadOnly : 1;         // ReadOnly
242     bool mbMirroring : 1;        // pb: #106948# explicit mirroring for calc
243     bool mbRight : 1;            // right align Text output
244     bool mbCenter : 1;           // center Text output
245     bool mbEdgeBlending : 1;
246 
247     Link            maScrollHdl;
248     Link            maSelectHdl;
249     Link            maCancelHdl;
250     Link            maDoubleClickHdl;
251     Link            maUserDrawHdl;
252     Link            maMRUChangedHdl;
253 //IAccessibility2 Implementation 2009-----
254     Link            maFocusHdl;
255     Link            maListItemSelectHdl;
256 //-----IAccessibility2 Implementation 2009
257 
258     ::vcl::QuickSelectionEngine maQuickSelectionEngine;
259 
260 protected:
261     virtual void    KeyInput( const KeyEvent& rKEvt );
262     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
263     virtual void    MouseMove( const MouseEvent& rMEvt );
264     virtual void    Tracking( const TrackingEvent& rTEvt );
265     virtual void    Paint( const Rectangle& rRect );
266     virtual void    Resize();
267     virtual void    GetFocus();
268     virtual void    LoseFocus();
269 
270     //IAccessibility2 Implementation 2009-----
271     //sal_Bool          SelectEntries( sal_uInt16 nSelect, LB_EVENT_TYPE eLET, sal_Bool bShift = sal_False, sal_Bool bCtrl = sal_False );
272     sal_Bool            SelectEntries( sal_uInt16 nSelect, LB_EVENT_TYPE eLET, sal_Bool bShift = sal_False, sal_Bool bCtrl = sal_False, sal_Bool bSelectPosChange = sal_False );
273     //-----IAccessibility2 Implementation 2009
274     void            ImplPaint( sal_uInt16 nPos, sal_Bool bErase = sal_False, bool bLayout = false );
275     void            ImplDoPaint( const Rectangle& rRect, bool bLayout = false );
276     void            ImplCalcMetrics();
277     void            ImplUpdateEntryMetrics( ImplEntryType& rEntry );
278     void            ImplCallSelect();
279 
280     void            ImplShowFocusRect();
281     void            ImplHideFocusRect();
282 
283 
284     virtual void    StateChanged( StateChangedType nType );
285     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
286 
287 public:
288     virtual void  FillLayoutData() const;
289 
290                     ImplListBoxWindow( Window* pParent, WinBits nWinStyle );
291                     ~ImplListBoxWindow();
292 
293     ImplEntryList*  GetEntryList() const { return mpEntryList; }
294 
295     sal_uInt16          InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry );
296     void            RemoveEntry( sal_uInt16 nPos );
297     void            Clear();
298     void            ResetCurrentPos()               { mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; }
299     sal_uInt16          GetCurrentPos() const           { return mnCurrentPos; }
300     sal_uInt16          GetDisplayLineCount() const;
301     void            SetEntryFlags( sal_uInt16 nPos, long nFlags );
302 
303     void            DrawEntry( sal_uInt16 nPos, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False, bool bLayout = false );
304 
305     void            SelectEntry( sal_uInt16 nPos, sal_Bool bSelect );
306     void            DeselectAll();
307     sal_uInt16          GetEntryPosForPoint( const Point& rPoint ) const;
308     sal_uInt16          GetLastVisibleEntry() const;
309 
310     sal_Bool            ProcessKeyInput( const KeyEvent& rKEvt );
311 
312     void            SetTopEntry( sal_uInt16 nTop );
313     sal_uInt16          GetTopEntry() const             { return mnTop; }
314     // ShowProminentEntry will set the entry correspoding to nEntryPos
315     // either at top or in the middle depending on the chosen style
316     void            ShowProminentEntry( sal_uInt16 nEntryPos );
317     void            SetProminentEntryType( ProminentEntry eType ) { meProminentType = eType; }
318     ProminentEntry  GetProminentEntryType() const { return meProminentType; }
319     using Window::IsVisible;
320     sal_Bool            IsVisible( sal_uInt16 nEntry ) const;
321 
322     long            GetLeftIndent() const           { return mnLeft; }
323     void            SetLeftIndent( long n );
324     void            ScrollHorz( long nDiff );
325 
326     void            AllowGrabFocus( bool b )        { mbGrabFocus = b; }
327     bool            IsGrabFocusAllowed() const      { return mbGrabFocus; }
328 
329     void            SetSeparatorPos( sal_uInt16 n )     { mnSeparatorPos = n; }
330     sal_uInt16          GetSeparatorPos() const         { return mnSeparatorPos; }
331 
332     void            SetTravelSelect( bool bTravelSelect ) { mbTravelSelect = bTravelSelect; }
333     bool            IsTravelSelect() const          { return mbTravelSelect; }
334     bool            IsTrackingSelect() const        { return mbTrackingSelect; }
335 
336     void            SetUserItemSize( const Size& rSz );
337     const Size&     GetUserItemSize() const             { return maUserItemSize; }
338 
339     void            EnableUserDraw( bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
340     bool            IsUserDrawEnabled() const   { return mbUserDrawEnabled; }
341 
342     void            EnableMultiSelection( bool bMulti, bool bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; }
343     bool            IsMultiSelectionEnabled() const     { return mbMulti; }
344 
345     void            SetMultiSelectionSimpleMode( bool bSimple ) { mbSimpleMode = bSimple; }
346     bool            IsMultiSelectionSimpleMode() const          { return mbSimpleMode; }
347 
348     void            EnableMouseMoveSelect( bool bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; }
349     bool            IsMouseMoveSelectEnabled() const    { return mbMouseMoveSelect; }
350     bool            IsMouseMoveSelect() const   { return mbMouseMoveSelect||mbStackMode; }
351 
352     Size            CalcSize( sal_uInt16 nMaxLines ) const;
353     Rectangle       GetBoundingRectangle( sal_uInt16 nItem ) const;
354 
355     long            GetEntryHeight() const              { return mnMaxHeight; }
356     long            GetMaxEntryWidth() const            { return mnMaxWidth; }
357 
358     void            SetScrollHdl( const Link& rLink )   { maScrollHdl = rLink; }
359     const Link&     GetScrollHdl() const                { return maScrollHdl; }
360     void            SetSelectHdl( const Link& rLink )   { maSelectHdl = rLink; }
361     const Link&     GetSelectHdl() const                { return maSelectHdl; }
362     void            SetCancelHdl( const Link& rLink )   { maCancelHdl = rLink; }
363     const Link&     GetCancelHdl() const                { return maCancelHdl; }
364     void            SetDoubleClickHdl( const Link& rLink )  { maDoubleClickHdl = rLink; }
365     const Link&     GetDoubleClickHdl() const               { return maDoubleClickHdl; }
366     void            SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; }
367     const Link&     GetUserDrawHdl() const              { return maUserDrawHdl; }
368     void            SetMRUChangedHdl( const Link& rLink )   { maMRUChangedHdl = rLink; }
369     const Link&     GetMRUChangedHdl() const                { return maMRUChangedHdl; }
370 //IAccessibility2 Implementation 2009-----
371     void            SetFocusHdl( const Link& rLink )    { maFocusHdl = rLink ; }
372     const Link&     GetFocusHdl() const             { return maFocusHdl; }
373 
374     void            SetListItemSelectHdl( const Link& rLink )   { maListItemSelectHdl = rLink ; }
375     const Link&     GetListItemSelectHdl() const                { return maListItemSelectHdl; }
376 //-----IAccessibility2 Implementation 2009
377     bool            IsSelectionChanged() const { return mbSelectionChanged; }
378     sal_uInt16          GetSelectModifier() const { return mnSelectModifier; }
379 
380     void            EnableSort( bool b ) { mbSort = b; }
381 
382     void            SetReadOnly( bool bReadOnly )   { mbReadOnly = bReadOnly; }
383     bool            IsReadOnly() const              { return mbReadOnly; }
384 
385     using Control::ImplInitSettings;
386     void            ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
387     sal_uInt16          ImplGetTextStyle() const;
388 
389     // pb: #106948# explicit mirroring for calc
390     inline void     EnableMirroring()       { mbMirroring = true; }
391     inline bool     IsMirroring() const { return mbMirroring; }
392 
393     bool GetEdgeBlending() const { return mbEdgeBlending; }
394     void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
395 
396 protected:
397     // ISearchableStringList
398     virtual ::vcl::StringEntryIdentifier    CurrentEntry( String& _out_entryText ) const;
399     virtual ::vcl::StringEntryIdentifier    NextEntry( ::vcl::StringEntryIdentifier _currentEntry, String& _out_entryText ) const;
400     virtual void                            SelectEntry( ::vcl::StringEntryIdentifier _entry );
401 };
402 
403 // ---------------
404 // - ImplListBox -
405 // ---------------
406 
407 class ImplListBox : public Control
408 {
409 private:
410     ImplListBoxWindow   maLBWindow;
411     ScrollBar*          mpHScrollBar;
412     ScrollBar*          mpVScrollBar;
413     ScrollBarBox*       mpScrollBarBox;
414 
415     /// bitfield
416     bool mbVScroll : 1;     // VScroll an oder aus
417     bool mbHScroll : 1;     // HScroll an oder aus
418     bool mbAutoHScroll : 1; // AutoHScroll an oder aus
419     bool mbEdgeBlending : 1;
420 
421     Link                maScrollHdl;    // Weil der vom ImplListBoxWindow selbst benoetigt wird.
422     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer;
423 
424 protected:
425     virtual void        GetFocus();
426     virtual void        StateChanged( StateChangedType nType );
427     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
428 
429     long                Notify( NotifyEvent& rNEvt );
430 
431     void                ImplResizeControls();
432     void                ImplCheckScrollBars();
433     void                ImplInitScrollBars();
434 
435     DECL_LINK(          ScrollBarHdl, ScrollBar* );
436     DECL_LINK(          LBWindowScrolled, void* );
437     DECL_LINK(          MRUChanged, void* );
438 
439 public:
440                     ImplListBox( Window* pParent, WinBits nWinStyle );
441                     ~ImplListBox();
442 
443     const ImplEntryList*    GetEntryList() const            { return maLBWindow.GetEntryList(); }
444     ImplListBoxWindow*      GetMainWindow()                 { return &maLBWindow; }
445 
446     virtual void    Resize();
447     virtual const Wallpaper& GetDisplayBackground() const;
448     virtual Window*     GetPreferredKeyInputWindow();
449 
450     sal_uInt16          InsertEntry( sal_uInt16 nPos, const XubString& rStr );
451     sal_uInt16          InsertEntry( sal_uInt16 nPos, const Image& rImage );
452     sal_uInt16          InsertEntry( sal_uInt16 nPos, const XubString& rStr, const Image& rImage );
453     void            RemoveEntry( sal_uInt16 nPos );
454     void            SetEntryData( sal_uInt16 nPos, void* pNewData ) { maLBWindow.GetEntryList()->SetEntryData( nPos, pNewData ); }
455     void            Clear();
456 
457     void            SetEntryFlags( sal_uInt16 nPos, long nFlags );
458     long            GetEntryFlags( sal_uInt16 nPos ) const;
459 
460     void            SelectEntry( sal_uInt16 nPos, sal_Bool bSelect );
461     void            SetNoSelection();
462     void            ResetCurrentPos()               { maLBWindow.ResetCurrentPos(); }
463     sal_uInt16          GetCurrentPos() const           { return maLBWindow.GetCurrentPos(); }
464 
465     sal_Bool            ProcessKeyInput( const KeyEvent& rKEvt )    { return maLBWindow.ProcessKeyInput( rKEvt ); }
466     sal_Bool            HandleWheelAsCursorTravel( const CommandEvent& rCEvt );
467 
468     void            SetSeparatorPos( sal_uInt16 n )     { maLBWindow.SetSeparatorPos( n ); }
469     sal_uInt16          GetSeparatorPos() const         { return maLBWindow.GetSeparatorPos(); }
470 
471     void            SetTopEntry( sal_uInt16 nTop )      { maLBWindow.SetTopEntry( nTop ); }
472     sal_uInt16          GetTopEntry() const             { return maLBWindow.GetTopEntry(); }
473     void            ShowProminentEntry( sal_uInt16 nPos ) { maLBWindow.ShowProminentEntry( nPos ); }
474     using Window::IsVisible;
475     sal_Bool            IsVisible( sal_uInt16 nEntry ) const { return maLBWindow.IsVisible( nEntry ); }
476 
477     void            SetProminentEntryType( ProminentEntry eType ) { maLBWindow.SetProminentEntryType( eType ); }
478     ProminentEntry  GetProminentEntryType() const { return maLBWindow.GetProminentEntryType(); }
479 
480     long            GetLeftIndent() const           { return maLBWindow.GetLeftIndent(); }
481     void            SetLeftIndent( sal_uInt16 n )       { maLBWindow.SetLeftIndent( n ); }
482     void            ScrollHorz( short nDiff )       { maLBWindow.ScrollHorz( nDiff ); }
483 
484     void            SetTravelSelect( sal_Bool bTravelSelect ) { maLBWindow.SetTravelSelect( bTravelSelect ); }
485     sal_Bool            IsTravelSelect() const          { return maLBWindow.IsTravelSelect(); }
486     sal_Bool            IsTrackingSelect() const            { return maLBWindow.IsTrackingSelect(); }
487 
488     void            EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackMode ) { maLBWindow.EnableMultiSelection( bMulti, bStackMode ); }
489     sal_Bool            IsMultiSelectionEnabled() const     { return maLBWindow.IsMultiSelectionEnabled(); }
490 
491     void            SetMultiSelectionSimpleMode( sal_Bool bSimple ) { maLBWindow.SetMultiSelectionSimpleMode( bSimple ); }
492     sal_Bool            IsMultiSelectionSimpleMode() const  { return maLBWindow.IsMultiSelectionSimpleMode(); }
493 
494     void            SetReadOnly( sal_Bool b )           { maLBWindow.SetReadOnly( b ); }
495     sal_Bool            IsReadOnly() const              { return maLBWindow.IsReadOnly(); }
496 
497 
498     Size            CalcSize( sal_uInt16 nMaxLines ) const              { return maLBWindow.CalcSize( nMaxLines ); }
499     long            GetEntryHeight() const          { return maLBWindow.GetEntryHeight(); }
500     long            GetMaxEntryWidth() const        { return maLBWindow.GetMaxEntryWidth(); }
501 
502     void            SetScrollHdl( const Link& rLink )   { maScrollHdl = rLink; }
503     const Link&     GetScrollHdl() const                { return maScrollHdl; }
504     void            SetSelectHdl( const Link& rLink )   { maLBWindow.SetSelectHdl( rLink ); }
505     const Link&     GetSelectHdl() const                { return maLBWindow.GetSelectHdl(); }
506     void            SetCancelHdl( const Link& rLink )   { maLBWindow.SetCancelHdl( rLink ); }
507     const Link&     GetCancelHdl() const                { return maLBWindow.GetCancelHdl(); }
508     void            SetDoubleClickHdl( const Link& rLink )  { maLBWindow.SetDoubleClickHdl( rLink ); }
509     const Link&     GetDoubleClickHdl() const               { return maLBWindow.GetDoubleClickHdl(); }
510     void            SetUserDrawHdl( const Link& rLink ) { maLBWindow.SetUserDrawHdl( rLink ); }
511     const Link&     GetUserDrawHdl() const              { return maLBWindow.GetUserDrawHdl(); }
512 
513 //IAccessibility2 Implementation 2009-----
514     void            SetFocusHdl( const Link& rLink )    { maLBWindow.SetFocusHdl( rLink ); }
515     const Link&     GetFocusHdl() const             { return maLBWindow.GetFocusHdl(); }
516     void            SetListItemSelectHdl( const Link& rLink )   { maLBWindow.SetListItemSelectHdl( rLink ); }
517     const Link&     GetListItemSelectHdl() const    { return maLBWindow.GetListItemSelectHdl(); }
518 //-----IAccessibility2 Implementation 2009
519     void            SetSelectionChangedHdl( const Link& rLnk )  { maLBWindow.GetEntryList()->SetSelectionChangedHdl( rLnk ); }
520     void            SetCallSelectionChangedHdl( sal_Bool bCall )    { maLBWindow.GetEntryList()->SetCallSelectionChangedHdl( bCall ); }
521     sal_Bool            IsSelectionChanged() const                  { return maLBWindow.IsSelectionChanged(); }
522     sal_uInt16          GetSelectModifier() const                   { return maLBWindow.GetSelectModifier(); }
523 
524     void            SetMRUEntries( const XubString& rEntries, xub_Unicode cSep );
525     XubString       GetMRUEntries( xub_Unicode cSep ) const;
526     void            SetMaxMRUCount( sal_uInt16 n )                  { maLBWindow.GetEntryList()->SetMaxMRUCount( n ); }
527     sal_uInt16          GetMaxMRUCount() const                      { return maLBWindow.GetEntryList()->GetMaxMRUCount(); }
528     sal_uInt16          GetDisplayLineCount() const
529     { return maLBWindow.GetDisplayLineCount(); }
530 
531     bool GetEdgeBlending() const { return mbEdgeBlending; }
532     void SetEdgeBlending(bool bNew);
533 
534     // pb: #106948# explicit mirroring for calc
535     inline void     EnableMirroring()   { maLBWindow.EnableMirroring(); }
536     inline void     SetDropTraget(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_xDNDListenerContainer){ mxDNDListenerContainer= i_xDNDListenerContainer; }
537 };
538 
539 // -----------------------------
540 // - ImplListBoxFloatingWindow -
541 // -----------------------------
542 
543 class ImplListBoxFloatingWindow : public FloatingWindow
544 {
545 private:
546     ImplListBox*    mpImplLB;
547     Size            maPrefSz;
548     sal_uInt16          mnDDLineCount;
549     sal_uInt16          mnPopupModeStartSaveSelection;
550     sal_Bool            mbAutoWidth;
551 
552 protected:
553     long            PreNotify( NotifyEvent& rNEvt );
554 
555 public:
556                     ImplListBoxFloatingWindow( Window* pParent );
557 
558     void            SetImplListBox( ImplListBox* pLB )  { mpImplLB = pLB; }
559 
560     void            SetPrefSize( const Size& rSz )      { maPrefSz = rSz; }
561     const Size&     GetPrefSize() const                 { return maPrefSz; }
562 
563     void            SetAutoWidth( sal_Bool b )              { mbAutoWidth = b; }
564     sal_Bool            IsAutoWidth() const                 { return mbAutoWidth; }
565 
566     Size            CalcFloatSize();
567     void            StartFloat( sal_Bool bStartTracking );
568 
569     virtual void    SetPosSizePixel( long nX, long nY,
570                                      long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
571     void            SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
572                         { FloatingWindow::SetPosSizePixel( rNewPos, rNewSize ); }
573 
574     void            SetDropDownLineCount( sal_uInt16 n ) { mnDDLineCount = n; }
575     sal_uInt16          GetDropDownLineCount() const { return mnDDLineCount; }
576 
577     sal_uInt16          GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection; }
578 
579     virtual void    Resize();
580 };
581 
582 // -----------
583 // - ImplWin -
584 // -----------
585 
586 class ImplWin : public Control
587 {
588 private:
589 
590     sal_uInt16          mnItemPos;  // wegen UserDraw muss ich wissen, welches Item ich darstelle.
591     XubString       maString;
592     Image           maImage;
593     Image           maImageHC;
594 
595     Rectangle       maFocusRect;
596     Size            maUserItemSize;
597 
598     Link            maMBDownHdl;
599     Link            maUserDrawHdl;
600 
601     /// bitfield
602     bool            mbUserDrawEnabled : 1;
603     bool            mbInUserDraw : 1;
604     bool            mbEdgeBlending : 1;
605 
606     void ImplDraw( bool bLayout = false );
607 protected:
608     virtual void  FillLayoutData() const;
609 public:
610 
611                     ImplWin( Window* pParent, WinBits nWinStyle = 0 );
612                     ~ImplWin() {};
613 
614     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
615     virtual void    Paint( const Rectangle& rRect );
616     virtual void    Resize();
617     virtual void    GetFocus();
618     virtual void    LoseFocus();
619     virtual long    PreNotify( NotifyEvent& rNEvt );
620 
621     sal_uInt16          GetItemPos() const { return mnItemPos; }
622     void            SetItemPos( sal_uInt16 n ) { mnItemPos = n; }
623 
624     const XubString& GetString() const { return maString; }
625     void            SetString( const XubString& rStr ) { maString = rStr; }
626 
627     const Image&    GetImage() const { return maImage; }
628     void            SetImage( const Image& rImg ) { maImage = rImg; }
629 
630     sal_Bool            SetModeImage( const Image& rImage, BmpColorMode eMode = BMP_COLOR_NORMAL );
631     const Image&    GetModeImage( BmpColorMode eMode = BMP_COLOR_NORMAL ) const;
632 
633 
634     virtual void    MBDown();
635     void            SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; }
636     const Link&     GetMBDownHdl() const { return maMBDownHdl; }
637 
638     void            SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; }
639     const Link&     GetUserDrawHdl() const              { return maUserDrawHdl; }
640 
641     void            SetUserItemSize( const Size& rSz )  { maUserItemSize = rSz; }
642     const Size&     GetUserItemSize() const             { return maUserItemSize; }
643 
644     void            EnableUserDraw( bool bUserDraw )    { mbUserDrawEnabled = bUserDraw; }
645     bool            IsUserDrawEnabled() const           { return mbUserDrawEnabled; }
646 
647     void            DrawEntry( sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False, bool bLayout = false );
648 
649     bool GetEdgeBlending() const { return mbEdgeBlending; }
650     void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
651 };
652 
653 // -----------
654 // - ImplBtn -
655 // -----------
656 
657 class ImplBtn : public PushButton
658 {
659 private:
660     sal_Bool            mbDown;
661 
662     Link            maMBDownHdl;
663 
664 public:
665                     ImplBtn( Window* pParent, WinBits nWinStyle = 0 );
666                     ~ImplBtn() {};
667 
668     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
669 
670     virtual void    MBDown();
671     void            SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; }
672     const Link&     GetMBDownHdl() const { return maMBDownHdl; }
673 };
674 
675 
676 void ImplInitFieldSettings( Window* pWin, sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
677 void ImplInitDropDownButton( PushButton* pButton );
678 
679 #endif  // _SV_ILSTBOX_HXX
680