LCOV - code coverage report
Current view: top level - include/vcl - lstbox.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 7 14 50.0 %
Date: 2015-06-13 12:38:46 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             :     VclPtr<ImplListBox>                mpImplLB;
      41             :     VclPtr<ImplListBoxFloatingWindow>  mpFloatWin;
      42             :     VclPtr<ImplWin>                    mpImplWin;
      43             :     VclPtr<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        3927 :     bool               IsDropDownBox() const { return mpFloatWin != nullptr; }
      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             :     virtual void        dispose() SAL_OVERRIDE;
      87             : 
      88             :     virtual void        ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
      89             :     virtual void        Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) SAL_OVERRIDE;
      90             :     virtual void        Resize() SAL_OVERRIDE;
      91             :     virtual bool        PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
      92             :     virtual void        StateChanged( StateChangedType nType ) SAL_OVERRIDE;
      93             :     virtual void        DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
      94             :     virtual void        UserDraw( const UserDrawEvent& rUDEvt );
      95             : 
      96             :     virtual void        Select();
      97             :     virtual void        DoubleClick();
      98             :     virtual void        GetFocus() SAL_OVERRIDE;
      99             :     virtual void        LoseFocus() SAL_OVERRIDE;
     100             :     virtual vcl::Window*     GetPreferredKeyInputWindow() SAL_OVERRIDE;
     101             : 
     102             :     virtual const Wallpaper& GetDisplayBackground() const SAL_OVERRIDE;
     103             : 
     104             :     virtual void        setPosSizePixel( long nX, long nY,
     105             :                                          long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All ) SAL_OVERRIDE;
     106         130 :     void                SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) SAL_OVERRIDE
     107         130 :                         { Control::SetPosSizePixel( rNewPos, rNewSize ); }
     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         259 :     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           0 :     void*               GetSelectEntryData() const { return GetEntryData(GetSelectEntryPos()); }
     147             : 
     148             :     /** this methods stores a combination of flags from the
     149             :         ListBoxEntryFlags::* defines at the given entry.
     150             :         See description of the possible ListBoxEntryFlags::* flags
     151             :         for details.
     152             :         Do not use these flags for user data as they are reserved
     153             :         to change the internal behaviour of the ListBox implementation
     154             :         for specific entries.
     155             :     */
     156             :     void                SetEntryFlags( sal_Int32  nPos, ListBoxEntryFlags nFlags );
     157             : 
     158             :     /** this methods gets the current combination of flags from the
     159             :         ListBoxEntryFlags::* defines from the given entry.
     160             :         See description of the possible ListBoxEntryFlags::* flags
     161             :         for details.
     162             :     */
     163             :     ListBoxEntryFlags   GetEntryFlags( sal_Int32  nPos ) const;
     164             : 
     165             :     void                SetTopEntry( sal_Int32  nPos );
     166             :     sal_Int32           GetTopEntry() const;
     167             : 
     168         820 :     void                SaveValue() { mnSaveValue = GetSelectEntryPos(); }
     169           0 :     sal_Int32           GetSavedValue() const { return mnSaveValue; }
     170           0 :     bool                IsValueChangedFromSaved() const { return mnSaveValue != GetSelectEntryPos(); }
     171             : 
     172             :     void                SetSeparatorPos( sal_Int32  n = LISTBOX_ENTRY_NOTFOUND );
     173             :     sal_Int32           GetSeparatorPos() const;
     174             : 
     175             :     bool                IsTravelSelect() const;
     176             :     bool                IsInDropDown() const;
     177             :     void                ToggleDropDown();
     178             : 
     179             :     void                EnableMultiSelection( bool bMulti, bool bStackSelection );
     180             :     void                EnableMultiSelection( bool bMulti );
     181             :     bool                IsMultiSelectionEnabled() const;
     182             : 
     183             :     void                SetReadOnly( bool bReadOnly = true );
     184             :     bool                IsReadOnly() const;
     185             : 
     186             :     Rectangle           GetBoundingRectangle( sal_Int32  nItem ) const;
     187             : 
     188             :     void                SetUserItemSize( const Size& rSz );
     189             : 
     190             :     void                EnableUserDraw( bool bUserDraw );
     191             : 
     192             :     void                DrawEntry( const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false );
     193             : 
     194         285 :     void                SetSelectHdl( const Link<>& rLink )     { maSelectHdl = rLink; }
     195           0 :     const Link<>&       GetSelectHdl() const                    { return maSelectHdl; }
     196           0 :     void                SetDoubleClickHdl( const Link<>& rLink ) { maDoubleClickHdl = rLink; }
     197           0 :     const Link<>&       GetDoubleClickHdl() const               { return maDoubleClickHdl; }
     198             : 
     199             :     Size                CalcSubEditSize() const;    //size of area inside lstbox, i.e. no scrollbar/dropdown
     200             :     Size                CalcMinimumSize() const;    //size of lstbox area, i.e. including scrollbar/dropdown
     201             :     virtual Size        GetOptimalSize() const SAL_OVERRIDE;
     202             :     Size                CalcAdjustedSize( const Size& rPrefSize ) const;
     203             :     Size                CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
     204             :     void                GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
     205             : 
     206             :     sal_uInt16          GetDisplayLineCount() const;
     207             : 
     208             :     void                EnableMirroring();
     209             : 
     210         734 :     bool                GetEdgeBlending() const { return mbEdgeBlending; }
     211             :     void                SetEdgeBlending(bool bNew);
     212             : 
     213             :     /** checks whether a certain point lies within the bounds of
     214             :         a listbox item and returns the item as well as the character position
     215             :         the point is at.
     216             : 
     217             :         <p>If the point is inside an item the item pos is put into <code>rPos</code> and
     218             :         the item-relative character index is returned. If the point is not inside
     219             :         an item -1 is returned and rPos is unchanged.</p>
     220             : 
     221             :         @param rPoint
     222             :         tells the point for which an item is requested.
     223             : 
     224             :         @param rPos
     225             :         gets the item at the specified point <code>rPoint</code>
     226             : 
     227             :         @returns
     228             :         the item-relative character index at point <code>rPos</code> or -1
     229             :         if no item is at that point.
     230             :      */
     231             :     using Control::GetIndexForPoint;
     232             :     long GetIndexForPoint( const Point& rPoint, sal_Int32 & rPos ) const;
     233             : 
     234             :     sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; }
     235             :     void setMaxWidthChars(sal_Int32 nWidth);
     236             : 
     237             :     virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
     238             : 
     239             :     void EnableQuickSelection( const bool& b );
     240             : };
     241             : 
     242             : 
     243             : // - MultiListBox -
     244             : 
     245             : 
     246           0 : class VCL_DLLPUBLIC MultiListBox : public ListBox
     247             : {
     248             : public:
     249             :     using ListBox::SaveValue;
     250             :     using ListBox::GetSavedValue;
     251             :     using ListBox::IsValueChangedFromSaved;
     252             : private:
     253             :     // Bei MultiListBox nicht erlaubt...
     254             :     void            SaveValue();
     255             :     sal_Int32       GetSavedValue();
     256             :     bool            IsValueChangedFromSaved() const;
     257             : 
     258             : public:
     259             :     explicit        MultiListBox( vcl::Window* pParent, WinBits nStyle = 0 );
     260             : 
     261             : };
     262             : 
     263             : #endif // INCLUDED_VCL_LSTBOX_HXX
     264             : 
     265             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11