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

Generated by: LCOV version 1.10