summaryrefslogtreecommitdiff
path: root/vcl/inc/vcl/ilstbox.hxx
blob: 81dd32ef27050f0ccde8b508fece05a81b108baa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: ilstbox.hxx,v $
 * $Revision: 1.4 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _SV_ILSTBOX_HXX
#define _SV_ILSTBOX_HXX

#include <vcl/sv.h>
#include <vcl/image.hxx>
#include <vcl/ctrl.hxx>
#include <vcl/button.hxx>
#include <vcl/floatwin.hxx>
#include <vcl/lstbox.h>
#include <vcl/timer.hxx>


class ScrollBar;
class ScrollBarBox;

// -----------------
// - ListBox-Types -
// -----------------

#define HORZ_SCROLL         4
#define IMG_TXT_DISTANCE    6

enum LB_EVENT_TYPE
{
    LET_MBDOWN,
    LET_TRACKING,
    LET_TRACKING_END,
    LET_KEYMOVE,
    LET_KEYSPACE
};

// -----------------
// - ImplEntryType -
// -----------------

struct ImplEntryType
{
    XubString   maStr;
    Image       maImage;
    void*       mpUserData;
    BOOL        mbIsSelected;
    long        mnFlags;
    long        mnHeight;

                ImplEntryType( const XubString& rStr, const Image& rImage ) :
                    maStr( rStr ),
                    maImage( rImage ),
                    mnFlags( 0 ),
                    mnHeight( 0 )
                {
                    mbIsSelected = FALSE;
                    mpUserData = NULL;
                }

                ImplEntryType( const XubString& rStr ) :
                    maStr( rStr ),
                    mnFlags( 0 ),
                    mnHeight( 0 )
                {
                    mbIsSelected = FALSE;
                    mpUserData = NULL;
                }

                ImplEntryType( const Image& rImage ) :
                    maImage( rImage ),
                    mnFlags( 0 ),
                    mnHeight( 0 )
                {
                    mbIsSelected = FALSE;
                    mpUserData = NULL;
                }
};

// -----------------
// - ImplEntryList -
// -----------------

class ImplEntryList : private List
{
private:
    Window*         mpWindow;   // For getting the current locale when matching strings
    USHORT          mnLastSelected;
    USHORT          mnSelectionAnchor;
    USHORT          mnImages;

    USHORT          mnMRUCount;
    USHORT          mnMaxMRUCount;

    Link            maSelectionChangedHdl;
    BOOL            mbCallSelectionChangedHdl;

    ImplEntryType*  GetEntry( USHORT nPos ) const { return (ImplEntryType*)List::GetObject( nPos ); }

public:
                    ImplEntryList( Window* pWindow );
                    ~ImplEntryList();

    USHORT                  InsertEntry( USHORT nPos, ImplEntryType* pNewEntry, BOOL bSort );
    void                    RemoveEntry( USHORT nPos );
    const ImplEntryType*    GetEntryPtr( USHORT nPos ) const { return (const ImplEntryType*) GetObject( nPos ); }
    ImplEntryType*          GetMutableEntryPtr( USHORT nPos ) const { return (ImplEntryType*) GetObject( nPos ); }
    void                    Clear();

    USHORT          FindMatchingEntry( const XubString& rStr, USHORT nStart = 0, BOOL bForward = TRUE, BOOL bLazy = TRUE ) const;
    USHORT          FindEntry( const XubString& rStr, BOOL bSearchMRUArea = FALSE ) const;
    USHORT          FindEntry( const void* pData ) const;

    // helper: add up heights up to index nEndIndex.
    // GetAddedHeight( 0 ) returns 0
    // GetAddedHeight( LISTBOX_ENTRY_NOTFOUND ) returns 0
    // GetAddedHeight( i, k ) with k > i is equivalent -GetAddedHeight( k, i )
    long            GetAddedHeight( USHORT nEndIndex, USHORT nBeginIndex = 0, long nBeginHeight = 0 ) const;
    long            GetEntryHeight( USHORT nPos ) const;

    USHORT          GetEntryCount() const { return (USHORT)List::Count(); }
    BOOL            HasImages() const { return mnImages ? TRUE : FALSE; }

    XubString       GetEntryText( USHORT nPos ) const;

    BOOL            HasEntryImage( USHORT nPos ) const;
    Image           GetEntryImage( USHORT nPos ) const;

    void            SetEntryData( USHORT nPos, void* pNewData );
    void*           GetEntryData( USHORT nPos ) const;

    void            SetEntryFlags( USHORT nPos, long nFlags );
    long            GetEntryFlags( USHORT nPos ) const;

    void            SelectEntry( USHORT nPos, BOOL bSelect );

    USHORT          GetSelectEntryCount() const;
    XubString       GetSelectEntry( USHORT nIndex ) const;
    USHORT          GetSelectEntryPos( USHORT nIndex ) const;
    BOOL            IsEntrySelected( const XubString& rStr ) const;
    BOOL            IsEntryPosSelected( USHORT nIndex ) const;

    void            SetLastSelected( USHORT nPos )  { mnLastSelected = nPos; }
    USHORT          GetLastSelected() const { return mnLastSelected; }

    void            SetSelectionAnchor( USHORT nPos )   { mnSelectionAnchor = nPos; }
    USHORT          GetSelectionAnchor() const { return mnSelectionAnchor; }


    void            SetSelectionChangedHdl( const Link& rLnk )  { maSelectionChangedHdl = rLnk; }
    void            SetCallSelectionChangedHdl( BOOL bCall )    { mbCallSelectionChangedHdl = bCall; }

    void            SetMRUCount( USHORT n ) { mnMRUCount = n; }
    USHORT          GetMRUCount() const     { return mnMRUCount; }

    void            SetMaxMRUCount( USHORT n )  { mnMaxMRUCount = n; }
    USHORT          GetMaxMRUCount() const      { return mnMaxMRUCount; }

    /** An Entry is selectable if its mnFlags does not have the
        LISTBOX_ENTRY_FLAG_DISABLE_SELECTION flag set. */
    bool            IsEntrySelectable( USHORT nPos ) const;

    /** returns the first entry found from the given position nPos that is selectable
        or LISTBOX_ENTRY_NOTFOUND if non is found. If the entry at nPos is not selectable,
        it returns the first selectable entry after nPos if bForward is true and the
        first selectable entry after nPos is bForward is false.
        */
    USHORT          FindFirstSelectable( USHORT nPos, bool bForward = true );
};

// ---------------------
// - ImplListBoxWindow -
// ---------------------

class ImplListBoxWindow : public Control
{
private:
    ImplEntryList*  mpEntryList;     // EntryListe
    Rectangle       maFocusRect;
    String          maSearchStr;
    Timer           maSearchTimeout;

    Size            maUserItemSize;

    long            mnMaxTxtHeight;  // Maximale Hoehe eines Text-Items
    long            mnMaxTxtWidth;   // Maximale Breite eines Text-Items
                                     // Entry ohne Image
    long            mnMaxImgTxtWidth;// Maximale Breite eines Text-Items
                                     // Entry UND Image
    long            mnMaxImgWidth;   // Maximale Breite eines Image-Items
    long            mnMaxImgHeight;  // Maximale Hoehe eines Image-Items
    long            mnMaxWidth;      // Maximale Breite eines Eintrags
    long            mnMaxHeight;     // Maximale Hoehe eines Eintrags

    USHORT          mnCurrentPos;    // Position (Focus)
    USHORT          mnTrackingSaveSelection; // Selektion vor Tracking();

    USHORT          mnSeparatorPos; // Separator

    USHORT          mnUserDrawEntry;

    USHORT          mnTop;           // Ausgabe ab Zeile
    long            mnLeft;          // Ausgabe ab Spalte
    long            mnBorder;        // Abstand Rahmen - Text
    long            mnTextHeight;    // Texthoehe

    USHORT          mnSelectModifier;   // Modifiers

    BOOL            mbHasFocusRect:         1,
                    mbSort:                 1,  // ListBox sortiert
                    mbTrack:                1,  // Tracking
                    mbMulti:                1,  // MultiListBox
                    mbStackMode:            1,  // StackSelection
                    mbSimpleMode:           1,  // SimpleMode fuer MultiListBox
                    mbImgsDiffSz:           1,  // Images haben verschiedene Groessen
                    mbTravelSelect:         1,  // TravelSelect
                    mbTrackingSelect:       1,  // Selektiert bei MouseMove
                    mbSelectionChanged:     1,  // Select() nicht zu oft rufen...
                    mbMouseMoveSelect:      1,  // Selektieren bei MouseMove
                    mbGrabFocus:            1,  // Focus bei MBDown grabben
                    mbUserDrawEnabled:      1,  // UserDraw possible
                    mbInUserDraw:           1,  // In UserDraw
                    mbReadOnly:             1,  // ReadOnly
                    mbMirroring:            1,  // pb: #106948# explicit mirroring for calc
                    mbRight:                1,  // right align Text output
                    mbCenter:               1;  // center Text output

    Link            maScrollHdl;
    Link            maSelectHdl;
    Link            maCancelHdl;
    Link            maDoubleClickHdl;
    Link            maUserDrawHdl;
    Link            maMRUChangedHdl;

protected:
    DECL_LINK(      SearchStringTimeout, Timer* );

    virtual void    KeyInput( const KeyEvent& rKEvt );
    virtual void    MouseButtonDown( const MouseEvent& rMEvt );
    virtual void    MouseMove( const MouseEvent& rMEvt );
    virtual void    Tracking( const TrackingEvent& rTEvt );
    virtual void    Paint( const Rectangle& rRect );
    virtual void    Resize();
    virtual void    GetFocus();
    virtual void    LoseFocus();

    BOOL            SelectEntries( USHORT nSelect, LB_EVENT_TYPE eLET, BOOL bShift = FALSE, BOOL bCtrl = FALSE );
    void            ImplPaint( USHORT nPos, BOOL bErase = FALSE, bool bLayout = false );
    void            ImplDoPaint( const Rectangle& rRect, bool bLayout = false );
    void            ImplCalcMetrics();
    void            ImplUpdateEntryMetrics( ImplEntryType& rEntry );
    void            ImplCallSelect();

    void            ImplShowFocusRect();
    void            ImplHideFocusRect();


    virtual void    StateChanged( StateChangedType nType );
    virtual void    DataChanged( const DataChangedEvent& rDCEvt );

public:
    virtual void  FillLayoutData() const;

                    ImplListBoxWindow( Window* pParent, WinBits nWinStyle );
                    ~ImplListBoxWindow();

    ImplEntryList*  GetEntryList() const { return mpEntryList; }

    USHORT          InsertEntry( USHORT nPos, ImplEntryType* pNewEntry );
    void            RemoveEntry( USHORT nPos );
    void            Clear();
    void            ResetCurrentPos()               { mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; }
    USHORT          GetCurrentPos() const           { return mnCurrentPos; }
    USHORT          GetDisplayLineCount() const;
    void            SetEntryFlags( USHORT nPos, long nFlags );

    void            DrawEntry( USHORT nPos, BOOL bDrawImage, BOOL bDrawText, BOOL bDrawTextAtImagePos = FALSE, bool bLayout = false );

    void            SelectEntry( USHORT nPos, BOOL bSelect );
    void            DeselectAll();
    USHORT          GetEntryPosForPoint( const Point& rPoint ) const;
    USHORT          GetLastVisibleEntry() const;

    BOOL            ProcessKeyInput( const KeyEvent& rKEvt );

    void            SetTopEntry( USHORT nTop );
    USHORT          GetTopEntry() const             { return mnTop; }
    using Window::IsVisible;
    BOOL            IsVisible( USHORT nEntry ) const;

    long            GetLeftIndent() const           { return mnLeft; }
    void            SetLeftIndent( long n );
    void            ScrollHorz( long nDiff );

    void            AllowGrabFocus( BOOL b )        { mbGrabFocus = b; }
    BOOL            IsGrabFocusAllowed() const      { return mbGrabFocus; }

    void            SetSeparatorPos( USHORT n )     { mnSeparatorPos = n; }
    USHORT          GetSeparatorPos() const         { return mnSeparatorPos; }

    void            SetTravelSelect( BOOL bTravelSelect ) { mbTravelSelect = bTravelSelect; }
    BOOL            IsTravelSelect() const          { return mbTravelSelect; }
    BOOL            IsTrackingSelect() const            { return mbTrackingSelect; }

    void            SetUserItemSize( const Size& rSz );
    const Size&     GetUserItemSize() const             { return maUserItemSize; }

    void            EnableUserDraw( BOOL bUserDraw ) { mbUserDrawEnabled = bUserDraw; }
    BOOL            IsUserDrawEnabled() const   { return mbUserDrawEnabled; }

    void            EnableMultiSelection( BOOL bMulti, BOOL bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; }
    BOOL            IsMultiSelectionEnabled() const     { return mbMulti; }

    void            SetMultiSelectionSimpleMode( BOOL bSimple ) { mbSimpleMode = bSimple; }
    BOOL            IsMultiSelectionSimpleMode() const          { return mbSimpleMode; }

    void            EnableMouseMoveSelect( BOOL bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; }
    BOOL            IsMouseMoveSelectEnabled() const    { return mbMouseMoveSelect; }
    BOOL            IsMouseMoveSelect() const   { return mbMouseMoveSelect||mbStackMode; }

    Size            CalcSize( USHORT nMaxLines ) const;
    Rectangle       GetBoundingRectangle( USHORT nItem ) const;

    long            GetEntryHeight() const              { return mnMaxHeight; }
    long            GetMaxEntryWidth() const            { return mnMaxWidth; }

    void            SetScrollHdl( const Link& rLink )   { maScrollHdl = rLink; }
    const Link&     GetScrollHdl() const                { return maScrollHdl; }
    void            SetSelectHdl( const Link& rLink )   { maSelectHdl = rLink; }
    const Link&     GetSelectHdl() const                { return maSelectHdl; }
    void            SetCancelHdl( const Link& rLink )   { maCancelHdl = rLink; }
    const Link&     GetCancelHdl() const                { return maCancelHdl; }
    void            SetDoubleClickHdl( const Link& rLink )  { maDoubleClickHdl = rLink; }
    const Link&     GetDoubleClickHdl() const               { return maDoubleClickHdl; }
    void            SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; }
    const Link&     GetUserDrawHdl() const              { return maUserDrawHdl; }
    void            SetMRUChangedHdl( const Link& rLink )   { maMRUChangedHdl = rLink; }
    const Link&     GetMRUChangedHdl() const                { return maMRUChangedHdl; }

    BOOL            IsSelectionChanged() const { return mbSelectionChanged; }
    USHORT          GetSelectModifier() const { return mnSelectModifier; }

    void            EnableSort( BOOL b ) { mbSort = b; }

    void            SetReadOnly( BOOL bReadOnly )   { mbReadOnly = bReadOnly; }
    BOOL            IsReadOnly() const              { return mbReadOnly; }

    using Control::ImplInitSettings;
    void            ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
    USHORT          ImplGetTextStyle() const;

    // pb: #106948# explicit mirroring for calc
    inline void     EnableMirroring()       { mbMirroring = TRUE; }
    inline BOOL     IsMirroring() const { return mbMirroring; }
};

// ---------------
// - ImplListBox -
// ---------------

class ImplListBox : public Control
{
private:
    ImplListBoxWindow   maLBWindow;
    ScrollBar*          mpHScrollBar;
    ScrollBar*          mpVScrollBar;
    ScrollBarBox*       mpScrollBarBox;
    BOOL                mbVScroll       : 1,    // VScroll an oder aus
                        mbHScroll       : 1,    // HScroll an oder aus
                        mbAutoHScroll   : 1;    // AutoHScroll an oder aus
    Link                maScrollHdl;    // Weil der vom ImplListBoxWindow selbst benoetigt wird.

protected:
    virtual void        GetFocus();
    virtual void        StateChanged( StateChangedType nType );
    virtual void        DataChanged( const DataChangedEvent& rDCEvt );

    long                Notify( NotifyEvent& rNEvt );

    void                ImplResizeControls();
    void                ImplCheckScrollBars();
    void                ImplInitScrollBars();

    DECL_LINK(          ScrollBarHdl, ScrollBar* );
    DECL_LINK(          LBWindowScrolled, void* );
    DECL_LINK(          MRUChanged, void* );

public:
                    ImplListBox( Window* pParent, WinBits nWinStyle );
                    ~ImplListBox();

    const ImplEntryList*    GetEntryList() const            { return maLBWindow.GetEntryList(); }
    ImplListBoxWindow*      GetMainWindow()                 { return &maLBWindow; }

    virtual void    Resize();
    virtual const Wallpaper& GetDisplayBackground() const;
    virtual Window*     GetPreferredKeyInputWindow();

    USHORT          InsertEntry( USHORT nPos, const XubString& rStr );
    USHORT          InsertEntry( USHORT nPos, const Image& rImage );
    USHORT          InsertEntry( USHORT nPos, const XubString& rStr, const Image& rImage );
    void            RemoveEntry( USHORT nPos );
    void            SetEntryData( USHORT nPos, void* pNewData ) { maLBWindow.GetEntryList()->SetEntryData( nPos, pNewData ); }
    void            Clear();

    void            SetEntryFlags( USHORT nPos, long nFlags );
    long            GetEntryFlags( USHORT nPos ) const;

    void            SelectEntry( USHORT nPos, BOOL bSelect );
    void            SetNoSelection();
    void            ResetCurrentPos()               { maLBWindow.ResetCurrentPos(); }
    USHORT          GetCurrentPos() const           { return maLBWindow.GetCurrentPos(); }

    BOOL            ProcessKeyInput( const KeyEvent& rKEvt )    { return maLBWindow.ProcessKeyInput( rKEvt ); }
    BOOL            HandleWheelAsCursorTravel( const CommandEvent& rCEvt );

    void            SetSeparatorPos( USHORT n )     { maLBWindow.SetSeparatorPos( n ); }
    USHORT          GetSeparatorPos() const         { return maLBWindow.GetSeparatorPos(); }

    void            SetTopEntry( USHORT nTop )      { maLBWindow.SetTopEntry( nTop ); }
    USHORT          GetTopEntry() const             { return maLBWindow.GetTopEntry(); }
    using Window::IsVisible;
    BOOL            IsVisible( USHORT nEntry ) const { return maLBWindow.IsVisible( nEntry ); }

    long            GetLeftIndent() const           { return maLBWindow.GetLeftIndent(); }
    void            SetLeftIndent( USHORT n )       { maLBWindow.SetLeftIndent( n ); }
    void            ScrollHorz( short nDiff )       { maLBWindow.ScrollHorz( nDiff ); }

    void            SetTravelSelect( BOOL bTravelSelect ) { maLBWindow.SetTravelSelect( bTravelSelect ); }
    BOOL            IsTravelSelect() const          { return maLBWindow.IsTravelSelect(); }
    BOOL            IsTrackingSelect() const            { return maLBWindow.IsTrackingSelect(); }

    void            EnableMultiSelection( BOOL bMulti, BOOL bStackMode ) { maLBWindow.EnableMultiSelection( bMulti, bStackMode ); }
    BOOL            IsMultiSelectionEnabled() const     { return maLBWindow.IsMultiSelectionEnabled(); }

    void            SetMultiSelectionSimpleMode( BOOL bSimple ) { maLBWindow.SetMultiSelectionSimpleMode( bSimple ); }
    BOOL            IsMultiSelectionSimpleMode() const  { return maLBWindow.IsMultiSelectionSimpleMode(); }

    void            SetReadOnly( BOOL b )           { maLBWindow.SetReadOnly( b ); }
    BOOL            IsReadOnly() const              { return maLBWindow.IsReadOnly(); }


    Size            CalcSize( USHORT nMaxLines ) const              { return maLBWindow.CalcSize( nMaxLines ); }
    long            GetEntryHeight() const          { return maLBWindow.GetEntryHeight(); }
    long            GetMaxEntryWidth() const        { return maLBWindow.GetMaxEntryWidth(); }

    void            SetScrollHdl( const Link& rLink )   { maScrollHdl = rLink; }
    const Link&     GetScrollHdl() const                { return maScrollHdl; }
    void            SetSelectHdl( const Link& rLink )   { maLBWindow.SetSelectHdl( rLink ); }
    const Link&     GetSelectHdl() const                { return maLBWindow.GetSelectHdl(); }
    void            SetCancelHdl( const Link& rLink )   { maLBWindow.SetCancelHdl( rLink ); }
    const Link&     GetCancelHdl() const                { return maLBWindow.GetCancelHdl(); }
    void            SetDoubleClickHdl( const Link& rLink )  { maLBWindow.SetDoubleClickHdl( rLink ); }
    const Link&     GetDoubleClickHdl() const               { return maLBWindow.GetDoubleClickHdl(); }
    void            SetUserDrawHdl( const Link& rLink ) { maLBWindow.SetUserDrawHdl( rLink ); }
    const Link&     GetUserDrawHdl() const              { return maLBWindow.GetUserDrawHdl(); }

    void            SetSelectionChangedHdl( const Link& rLnk )  { maLBWindow.GetEntryList()->SetSelectionChangedHdl( rLnk ); }
    void            SetCallSelectionChangedHdl( BOOL bCall )    { maLBWindow.GetEntryList()->SetCallSelectionChangedHdl( bCall ); }
    BOOL            IsSelectionChanged() const                  { return maLBWindow.IsSelectionChanged(); }
    USHORT          GetSelectModifier() const                   { return maLBWindow.GetSelectModifier(); }

    void            SetMRUEntries( const XubString& rEntries, xub_Unicode cSep );
    XubString       GetMRUEntries( xub_Unicode cSep ) const;
    void            SetMaxMRUCount( USHORT n )                  { maLBWindow.GetEntryList()->SetMaxMRUCount( n ); }
    USHORT          GetMaxMRUCount() const                      { return maLBWindow.GetEntryList()->GetMaxMRUCount(); }
    USHORT          GetDisplayLineCount() const
    { return maLBWindow.GetDisplayLineCount(); }

    // pb: #106948# explicit mirroring for calc
    inline void     EnableMirroring()   { maLBWindow.EnableMirroring(); }
};

// -----------------------------
// - ImplListBoxFloatingWindow -
// -----------------------------

class ImplListBoxFloatingWindow : public FloatingWindow
{
private:
    ImplListBox*    mpImplLB;
    Size            maPrefSz;
    USHORT          mnDDLineCount;
    USHORT          mnPopupModeStartSaveSelection;
    BOOL            mbAutoWidth;

protected:
    long            PreNotify( NotifyEvent& rNEvt );

public:
                    ImplListBoxFloatingWindow( Window* pParent );

    void            SetImplListBox( ImplListBox* pLB )  { mpImplLB = pLB; }

    void            SetPrefSize( const Size& rSz )      { maPrefSz = rSz; }
    const Size&     GetPrefSize() const                 { return maPrefSz; }

    void            SetAutoWidth( BOOL b )              { mbAutoWidth = b; }
    BOOL            IsAutoWidth() const                 { return mbAutoWidth; }

    Size            CalcFloatSize();
    void            StartFloat( BOOL bStartTracking );

    virtual void    SetPosSizePixel( long nX, long nY,
                                     long nWidth, long nHeight, USHORT nFlags = WINDOW_POSSIZE_ALL );
    void            SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
                        { FloatingWindow::SetPosSizePixel( rNewPos, rNewSize ); }

    void            SetDropDownLineCount( USHORT n ) { mnDDLineCount = n; }
    USHORT          GetDropDownLineCount() const { return mnDDLineCount; }

    USHORT          GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection; }

    virtual void    Resize();
};

// -----------
// - ImplWin -
// -----------

class ImplWin : public Control
{
private:

    USHORT          mnItemPos;  // wegen UserDraw muss ich wissen, welches Item ich darstelle.
    XubString       maString;
    Image           maImage;
    Image           maImageHC;

    Rectangle       maFocusRect;
    Size            maUserItemSize;

    Link            maMBDownHdl;
    Link            maUserDrawHdl;

    BOOL            mbUserDrawEnabled   : 1,
                    mbInUserDraw        : 1;


    void ImplDraw( bool bLayout = false );
protected:
    virtual void  FillLayoutData() const;
public:

                    ImplWin( Window* pParent, WinBits nWinStyle = 0 );
                    ~ImplWin() {};

    virtual void    MouseButtonDown( const MouseEvent& rMEvt );
    virtual void    Paint( const Rectangle& rRect );
    virtual void    Resize();
    virtual void    GetFocus();
    virtual void    LoseFocus();
    virtual long    PreNotify( NotifyEvent& rNEvt );

    USHORT          GetItemPos() const { return mnItemPos; }
    void            SetItemPos( USHORT n ) { mnItemPos = n; }

    const XubString& GetString() const { return maString; }
    void            SetString( const XubString& rStr ) { maString = rStr; }

    const Image&    GetImage() const { return maImage; }
    void            SetImage( const Image& rImg ) { maImage = rImg; }

    BOOL            SetModeImage( const Image& rImage, BmpColorMode eMode = BMP_COLOR_NORMAL );
    const Image&    GetModeImage( BmpColorMode eMode = BMP_COLOR_NORMAL ) const;


    virtual void    MBDown();
    void            SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; }
    const Link&     GetMBDownHdl() const { return maMBDownHdl; }

    void            SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; }
    const Link&     GetUserDrawHdl() const              { return maUserDrawHdl; }

    void            SetUserItemSize( const Size& rSz )  { maUserItemSize = rSz; }
    const Size&     GetUserItemSize() const             { return maUserItemSize; }

    void            EnableUserDraw( BOOL bUserDraw )    { mbUserDrawEnabled = bUserDraw; }
    BOOL            IsUserDrawEnabled() const           { return mbUserDrawEnabled; }

    void            DrawEntry( BOOL bDrawImage, BOOL bDrawText, BOOL bDrawTextAtImagePos = FALSE, bool bLayout = false );
};

// -----------
// - ImplBtn -
// -----------

class ImplBtn : public PushButton
{
private:
    BOOL            mbDown;

    Link            maMBDownHdl;

public:
                    ImplBtn( Window* pParent, WinBits nWinStyle = 0 );
                    ~ImplBtn() {};

    virtual void    MouseButtonDown( const MouseEvent& rMEvt );

    virtual void    MBDown();
    void            SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; }
    const Link&     GetMBDownHdl() const { return maMBDownHdl; }
};


void ImplInitFieldSettings( Window* pWin, BOOL bFont, BOOL bForeground, BOOL bBackground );
void ImplInitDropDownButton( PushButton* pButton );

#endif  // _SV_ILSTBOX_HXX