LCOV - code coverage report
Current view: top level - include/vcl - lstbox.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 7 14 50.0 %
Date: 2014-04-11 Functions: 6 13 46.2 %
Legend: Lines: hit not hit

          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_LSTBOX_HXX
      21             : #define INCLUDED_VCL_LSTBOX_HXX
      22             : 
      23             : #include <vcl/dllapi.h>
      24             : #include <vcl/ctrl.hxx>
      25             : #include <vcl/lstbox.h>
      26             : 
      27             : class Image;
      28             : class ImplListBox;
      29             : class ImplListBoxFloatingWindow;
      30             : class ImplBtn;
      31             : class ImplWin;
      32             : 
      33             : 
      34             : //  - ListBox -
      35             : 
      36             : 
      37             : class VCL_DLLPUBLIC ListBox : public Control
      38             : {
      39             : private:
      40             :     ImplListBox*                mpImplLB;
      41             :     ImplListBoxFloatingWindow*  mpFloatWin;
      42             :     ImplWin*                    mpImplWin;
      43             :     ImplBtn*                    mpBtn;
      44             :     sal_uInt16                  mnDDHeight;
      45             :     sal_Int32                   mnSaveValue;
      46             :     sal_Int32                   m_nMaxWidthChars;
      47             :     Link                        maSelectHdl;
      48             :     Link                        maDoubleClickHdl;
      49             :     sal_uInt16                  mnLineCount;
      50             : 
      51             :     /// bitfield
      52             :     bool            mbDDAutoSize : 1;
      53             :     bool            mbEdgeBlending : 1;
      54             : 
      55             : private:
      56             :     SAL_DLLPRIVATE void    ImplInitListBoxData();
      57             : 
      58             :     DECL_DLLPRIVATE_LINK(  ImplSelectHdl, void* );
      59             :     DECL_DLLPRIVATE_LINK(  ImplScrollHdl, void* );
      60             :     DECL_DLLPRIVATE_LINK(  ImplCancelHdl, void* );
      61             :     DECL_DLLPRIVATE_LINK(  ImplDoubleClickHdl, void* );
      62             :     DECL_DLLPRIVATE_LINK(  ImplClickBtnHdl, void* );
      63             :     DECL_DLLPRIVATE_LINK(  ImplPopupModeEndHdl, void* );
      64             :     DECL_DLLPRIVATE_LINK(  ImplSelectionChangedHdl, void* );
      65             :     DECL_DLLPRIVATE_LINK(  ImplUserDrawHdl, UserDrawEvent* );
      66             :     DECL_DLLPRIVATE_LINK(  ImplFocusHdl, void* );
      67             :     DECL_DLLPRIVATE_LINK(  ImplListItemSelectHdl, void* );
      68             : protected:
      69             :     using Window::ImplInit;
      70             :     SAL_DLLPRIVATE void    ImplInit( Window* pParent, WinBits nStyle );
      71             :     SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
      72             :     SAL_DLLPRIVATE void    ImplLoadRes( const ResId& rResId );
      73        3449 :     bool               IsDropDownBox() const { return mpFloatWin ? true : false; }
      74             : 
      75             : protected:
      76             :     explicit            ListBox( WindowType nType );
      77             : 
      78             :     virtual void        FillLayoutData() const SAL_OVERRIDE;
      79             : 
      80             : public:
      81             :     explicit            ListBox( Window* pParent, WinBits nStyle = WB_BORDER );
      82             :     explicit            ListBox( Window* pParent, const ResId& );
      83             :     virtual             ~ListBox();
      84             : 
      85             :     virtual void        Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
      86             :     virtual void        Resize() SAL_OVERRIDE;
      87             :     virtual bool        PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
      88             :     virtual void        StateChanged( StateChangedType nType ) SAL_OVERRIDE;
      89             :     virtual void        DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
      90             :     virtual void        UserDraw( const UserDrawEvent& rUDEvt );
      91             : 
      92             :     virtual void        Select();
      93             :     virtual void        DoubleClick();
      94             :     virtual void        GetFocus() SAL_OVERRIDE;
      95             :     virtual void        LoseFocus() SAL_OVERRIDE;
      96             :     virtual Window*     GetPreferredKeyInputWindow() SAL_OVERRIDE;
      97             : 
      98             :     virtual const Wallpaper& GetDisplayBackground() const SAL_OVERRIDE;
      99             : 
     100             :     virtual void        setPosSizePixel( long nX, long nY,
     101             :                                          long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ) SAL_OVERRIDE;
     102         117 :     void                SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) SAL_OVERRIDE
     103         117 :                         { Control::SetPosSizePixel( rNewPos, rNewSize ); }
     104           0 :     void                SetDropDownSizePixel( const Size& rNewSize )
     105           0 :     { if( IsDropDownBox() ) setPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(), WINDOW_POSSIZE_SIZE | WINDOW_POSSIZE_DROPDOWN ); }
     106             : 
     107             :     Rectangle           GetDropDownPosSizePixel() const;
     108             : 
     109             :     void                AdaptDropDownLineCountToMaximum();
     110             :     void                SetDropDownLineCount( sal_uInt16 nLines );
     111             :     sal_uInt16          GetDropDownLineCount() const;
     112             : 
     113             :     void                EnableAutoSize( bool bAuto );
     114         688 :     bool                IsAutoSizeEnabled() const { return mbDDAutoSize; }
     115             : 
     116             :     void                EnableDDAutoWidth( bool b );
     117             : 
     118             :     sal_Int32           InsertEntry( const OUString& rStr, sal_Int32  nPos = LISTBOX_APPEND );
     119             :     sal_Int32           InsertEntry( const OUString& rStr, const Image& rImage, sal_Int32  nPos = LISTBOX_APPEND );
     120             :     void                RemoveEntry( const OUString& rStr );
     121             :     void                RemoveEntry( sal_Int32  nPos );
     122             : 
     123             :     void                Clear();
     124             : 
     125             :     sal_Int32           GetEntryPos( const OUString& rStr ) const;
     126             :     sal_Int32           GetEntryPos( const void* pData ) const;
     127             :     Image               GetEntryImage( sal_Int32  nPos ) const;
     128             :     OUString            GetEntry( sal_Int32  nPos ) const;
     129             :     sal_Int32           GetEntryCount() const;
     130             : 
     131             :     void                SelectEntry( const OUString& rStr, bool bSelect = true );
     132             :     void                SelectEntryPos( sal_Int32  nPos, bool bSelect = true );
     133             : 
     134             :     sal_Int32           GetSelectEntryCount() const;
     135             :     OUString            GetSelectEntry( sal_Int32  nSelIndex = 0 ) const;
     136             :     sal_Int32           GetSelectEntryPos( sal_Int32  nSelIndex = 0 ) const;
     137             : 
     138             :     bool                IsEntrySelected(const OUString& rStr) const;
     139             :     bool                IsEntryPosSelected( sal_Int32  nPos ) const;
     140             :     void                SetNoSelection();
     141             : 
     142             :     void                SetEntryData( sal_Int32  nPos, void* pNewData );
     143             :     void*               GetEntryData( sal_Int32  nPos ) const;
     144             : 
     145             :     /** this methods stores a combination of flags from the
     146             :         LISTBOX_ENTRY_FLAG_* defines at the given entry.
     147             :         See description of the possible LISTBOX_ENTRY_FLAG_* flags
     148             :         for details.
     149             :         Do not use these flags for user data as they are reserved
     150             :         to change the internal behaviour of the ListBox implementation
     151             :         for specific entries.
     152             :     */
     153             :     void                SetEntryFlags( sal_Int32  nPos, long nFlags );
     154             : 
     155             :     /** this methods gets the current combination of flags from the
     156             :         LISTBOX_ENTRY_FLAG_* defines from the given entry.
     157             :         See description of the possible LISTBOX_ENTRY_FLAG_* flags
     158             :         for details.
     159             :     */
     160             :     long                GetEntryFlags( sal_Int32  nPos ) const;
     161             : 
     162             :     void                SetTopEntry( sal_Int32  nPos );
     163             :     sal_Int32           GetTopEntry() const;
     164             : 
     165         780 :     void                SaveValue() { mnSaveValue = GetSelectEntryPos(); }
     166           0 :     sal_Int32           GetSavedValue() const { return mnSaveValue; }
     167             : 
     168             :     void                SetSeparatorPos( sal_Int32  n = LISTBOX_ENTRY_NOTFOUND );
     169             :     sal_Int32           GetSeparatorPos() const;
     170             : 
     171             :     bool                IsTravelSelect() const;
     172             :     bool                IsInDropDown() const;
     173             :     void                ToggleDropDown();
     174             : 
     175             :     void                EnableMultiSelection( bool bMulti, bool bStackSelection );
     176             :     void                EnableMultiSelection( bool bMulti );
     177             :     bool                IsMultiSelectionEnabled() const;
     178             : 
     179             :     void                SetReadOnly( bool bReadOnly = true );
     180             :     bool                IsReadOnly() const;
     181             : 
     182             :     Rectangle           GetBoundingRectangle( sal_Int32  nItem ) const;
     183             : 
     184             :     void                SetUserItemSize( const Size& rSz );
     185             : 
     186             :     void                EnableUserDraw( bool bUserDraw );
     187             : 
     188             :     void                DrawEntry( const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false );
     189             : 
     190         203 :     void                SetSelectHdl( const Link& rLink )       { maSelectHdl = rLink; }
     191           0 :     const Link&         GetSelectHdl() const                    { return maSelectHdl; }
     192           0 :     void                SetDoubleClickHdl( const Link& rLink )  { maDoubleClickHdl = rLink; }
     193           0 :     const Link&         GetDoubleClickHdl() const               { return maDoubleClickHdl; }
     194             : 
     195             :     Size                CalcSubEditSize() const;    //size of area inside lstbox, i.e. no scrollbar/dropdown
     196             :     Size                CalcMinimumSize() const;    //size of lstbox area, i.e. including scrollbar/dropdown
     197             :     virtual Size        GetOptimalSize() const SAL_OVERRIDE;
     198             :     Size                CalcAdjustedSize( const Size& rPrefSize ) const;
     199             :     Size                CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
     200             :     void                GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
     201             : 
     202             :     sal_uInt16          GetDisplayLineCount() const;
     203             : 
     204             :     void                EnableMirroring();
     205             : 
     206        1171 :     bool                GetEdgeBlending() const { return mbEdgeBlending; }
     207             :     void                SetEdgeBlending(bool bNew);
     208             : 
     209             :     /** checks whether a certain point lies within the bounds of
     210             :         a listbox item and returns the item as well as the character position
     211             :         the point is at.
     212             : 
     213             :         <p>If the point is inside an item the item pos is put into <code>rPos</code> and
     214             :         the item-relative character index is returned. If the point is not inside
     215             :         an item -1 is returned and rPos is unchanged.</p>
     216             : 
     217             :         @param rPoint
     218             :         tells the point for which an item is requested.
     219             : 
     220             :         @param rPos
     221             :         gets the item at the specified point <code>rPoint</code>
     222             : 
     223             :         @returns
     224             :         the item-relative character index at point <code>rPos</code> or -1
     225             :         if no item is at that point.
     226             :      */
     227             :     using Control::GetIndexForPoint;
     228             :     long GetIndexForPoint( const Point& rPoint, sal_Int32 & rPos ) const;
     229             : 
     230             :     sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; }
     231             :     void setMaxWidthChars(sal_Int32 nWidth);
     232             : 
     233             :     virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
     234             : 
     235             :     void EnableQuickSelection( const bool& b );
     236             : };
     237             : 
     238             : 
     239             : // - MultiListBox -
     240             : 
     241             : 
     242           0 : class VCL_DLLPUBLIC MultiListBox : public ListBox
     243             : {
     244             : public:
     245             :     using ListBox::SaveValue;
     246             :     using ListBox::GetSavedValue;
     247             : private:
     248             :     // Bei MultiListBox nicht erlaubt...
     249             :     void            SaveValue();
     250             :     sal_Int32       GetSavedValue();
     251             : 
     252             : public:
     253             :     explicit        MultiListBox( Window* pParent, WinBits nStyle = 0 );
     254             :     explicit        MultiListBox( Window* pParent, const ResId& rResId );
     255             : 
     256             : };
     257             : 
     258             : #endif // INCLUDED_VCL_LSTBOX_HXX
     259             : 
     260             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10