LCOV - code coverage report
Current view: top level - include/vcl - combobox.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 5 11 45.5 %
Date: 2015-06-13 12:38:46 Functions: 4 10 40.0 %
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_COMBOBOX_HXX
      21             : #define INCLUDED_VCL_COMBOBOX_HXX
      22             : 
      23             : #include <boost/signals2/connection.hpp>
      24             : #include <vcl/dllapi.h>
      25             : #include <vcl/ctrl.hxx>
      26             : #include <vcl/combobox.h>
      27             : #include <vcl/edit.hxx>
      28             : 
      29             : class UserDrawEvent;
      30             : 
      31             : class ImplListBoxFloatingWindow;
      32             : class ImplListBox;
      33             : class ImplBtn;
      34             : 
      35             : class VCL_DLLPUBLIC ComboBox : public Edit
      36             : {
      37             : private:
      38             :     VclPtr<Edit>                mpSubEdit;
      39             :     VclPtr<ImplListBox>         mpImplLB;
      40             :     VclPtr<ImplBtn>             mpBtn;
      41             :     VclPtr<ImplListBoxFloatingWindow>  mpFloatWin;
      42             :     sal_uInt16                  mnDDHeight;
      43             :     sal_Unicode                 mcMultiSep;
      44             :     bool                        mbDDAutoSize        : 1;
      45             :     bool                        mbSyntheticModify   : 1;
      46             :     bool                        mbMatchCase         : 1;
      47             :     sal_Int32                   m_nMaxWidthChars;
      48             :     Link<>                      maSelectHdl;
      49             :     Link<>                      maDoubleClickHdl;
      50             :     boost::signals2::scoped_connection mAutocompleteConnection;
      51             : 
      52        6035 :     struct ComboBoxBounds
      53             :     {
      54             :         Point aSubEditPos;
      55             :         Size aSubEditSize;
      56             : 
      57             :         Point aButtonPos;
      58             :         Size aButtonSize;
      59             :     };
      60             : 
      61             : private:
      62             :     SAL_DLLPRIVATE void     ImplInitComboBoxData();
      63             :     SAL_DLLPRIVATE void     ImplUpdateFloatSelection();
      64             :     SAL_DLLPRIVATE ComboBoxBounds calcComboBoxDropDownComponentBounds(
      65             :         const Size &rOutSize, const Size &rBorderOutSize) const;
      66             : 
      67             :     DECL_DLLPRIVATE_LINK(   ImplSelectHdl, void* );
      68             :     DECL_DLLPRIVATE_LINK(   ImplCancelHdl, void* );
      69             :     DECL_DLLPRIVATE_LINK(   ImplDoubleClickHdl, void* );
      70             :     DECL_DLLPRIVATE_LINK(   ImplPopupModeEndHdl, void* );
      71             :     DECL_DLLPRIVATE_LINK(   ImplSelectionChangedHdl, void* );
      72             :     DECL_DLLPRIVATE_LINK(   ImplListItemSelectHdl , void* );
      73             : 
      74             :     SAL_DLLPRIVATE void ImplClickButtonHandler( ImplBtn* );
      75             :     SAL_DLLPRIVATE void ImplUserDrawHandler( UserDrawEvent* );
      76             :     SAL_DLLPRIVATE void ImplAutocompleteHandler( Edit* );
      77             : 
      78             : protected:
      79             :     using Window::ImplInit;
      80             :     SAL_DLLPRIVATE void     ImplInit( vcl::Window* pParent, WinBits nStyle );
      81             :     SAL_DLLPRIVATE WinBits  ImplInitStyle( WinBits nStyle );
      82             :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
      83             :     SAL_DLLPRIVATE void     ImplCalcEditHeight();
      84             :     SAL_DLLPRIVATE long     getMaxWidthScrollBarAndDownButton() const;
      85             : 
      86             : protected:
      87       28309 :     bool            IsDropDownBox() const { return mpFloatWin != nullptr; }
      88             : 
      89             :     virtual void    FillLayoutData() const SAL_OVERRIDE;
      90             : 
      91             : public:
      92             :     explicit        ComboBox( vcl::Window* pParent, WinBits nStyle = 0 );
      93             :     explicit        ComboBox( vcl::Window* pParent, const ResId& );
      94             :     virtual         ~ComboBox();
      95             :     virtual void    dispose() SAL_OVERRIDE;
      96             : 
      97             :     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) SAL_OVERRIDE;
      98             :     virtual void    Resize() SAL_OVERRIDE;
      99             :     virtual bool    PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     100             :     virtual bool    Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     101             :     virtual void    StateChanged( StateChangedType nType ) SAL_OVERRIDE;
     102             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     103             : 
     104             :     virtual void    UserDraw( const UserDrawEvent& rUDEvt );
     105             :     virtual void    Select();
     106             :     virtual void    DoubleClick();
     107             : 
     108             :     virtual void    Modify() SAL_OVERRIDE;
     109             : 
     110             :     virtual const Wallpaper& GetDisplayBackground() const SAL_OVERRIDE;
     111             : 
     112             :     virtual void    setPosSizePixel( long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All ) SAL_OVERRIDE;
     113          28 :     void            SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) SAL_OVERRIDE
     114          28 :                         { Edit::SetPosSizePixel( rNewPos, rNewSize ); }
     115             : 
     116             :     Rectangle       GetDropDownPosSizePixel() const;
     117             : 
     118             :     void            AdaptDropDownLineCountToMaximum();
     119             :     void            SetDropDownLineCount( sal_uInt16 nLines );
     120             :     sal_uInt16      GetDropDownLineCount() const;
     121             : 
     122             :     void            EnableAutoSize( bool bAuto );
     123        9227 :     bool            IsAutoSizeEnabled() const               { return mbDDAutoSize; }
     124             : 
     125             :     void            EnableDDAutoWidth( bool b );
     126             : 
     127             :     virtual void    SetText( const OUString& rStr ) SAL_OVERRIDE;
     128             :     virtual void    SetText( const OUString& rStr, const Selection& rNewSelection ) SAL_OVERRIDE;
     129             : 
     130             :     virtual sal_Int32  InsertEntry(const OUString& rStr, sal_Int32  nPos = COMBOBOX_APPEND);
     131             :     sal_Int32       InsertEntryWithImage( const OUString& rStr, const Image& rImage, sal_Int32  nPos = COMBOBOX_APPEND );
     132             : 
     133             :     void            RemoveEntry( const OUString& rStr );
     134             :     virtual void    RemoveEntryAt(sal_Int32  nPos);
     135             : 
     136             :     void            Clear();
     137             : 
     138             :     sal_Int32       GetEntryPos( const OUString& rStr ) const;
     139             :     sal_Int32       GetEntryPos( const void* pData ) const;
     140             :     Image           GetEntryImage( sal_Int32  nPos ) const;
     141             :     OUString        GetEntry( sal_Int32  nPos ) const;
     142             :     sal_Int32       GetEntryCount() const;
     143             : 
     144             :     bool            IsTravelSelect() const;
     145             :     bool            IsInDropDown() const;
     146             :     void            ToggleDropDown();
     147             : 
     148             :     long            CalcWindowSizePixel( sal_uInt16 nLines ) const;
     149             : 
     150             :     void            SetUserItemSize( const Size& rSz );
     151             :     void            EnableUserDraw( bool bUserDraw );
     152             : 
     153             :     void            DrawEntry( const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false );
     154             :     void            SetBorderStyle( WindowBorderStyle nBorderStyle );
     155             : 
     156             :     void            SetSeparatorPos( sal_Int32  n = COMBOBOX_ENTRY_NOTFOUND );
     157             : 
     158             :     void            EnableAutocomplete( bool bEnable, bool bMatchCase = false );
     159             :     bool            IsAutocompleteEnabled() const;
     160             : 
     161             :     void            EnableMultiSelection( bool bMulti );
     162             :     bool            IsMultiSelectionEnabled() const;
     163             :     void            SetMultiSelectionSeparator( sal_Unicode cSep ) { mcMultiSep = cSep; }
     164           0 :     sal_Unicode     GetMultiSelectionSeparator() const { return mcMultiSep; }
     165             : 
     166           0 :     void            SetSelectHdl( const Link<>& rLink )     { maSelectHdl = rLink; }
     167           0 :     const Link<>&   GetSelectHdl() const                    { return maSelectHdl; }
     168           0 :     void            SetDoubleClickHdl( const Link<>& rLink ) { maDoubleClickHdl = rLink; }
     169           0 :     const Link<>&   GetDoubleClickHdl() const               { return maDoubleClickHdl; }
     170             : 
     171             :     Size            CalcMinimumSize() const SAL_OVERRIDE;
     172             :     virtual Size    GetOptimalSize() const SAL_OVERRIDE;
     173             :     Size            CalcAdjustedSize( const Size& rPrefSize ) const;
     174             :     Size            CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const;
     175             :     void            GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const;
     176             : 
     177             :     void            SetMRUEntries( const OUString& rEntries, sal_Unicode cSep = ';' );
     178             :     OUString        GetMRUEntries( sal_Unicode cSep = ';' ) const;
     179             :     void            SetMaxMRUCount( sal_Int32  n );
     180             :     sal_Int32       GetMaxMRUCount() const;
     181             :     void            SetEntryData( sal_Int32  nPos, void* pNewData );
     182             :     void*           GetEntryData( sal_Int32  nPos ) const;
     183             : 
     184             :     sal_Int32       GetTopEntry() const;
     185             : 
     186             :     void            SetProminentEntryType( ProminentEntry eType );
     187             : 
     188             :     sal_uInt16      GetDisplayLineCount() const;
     189             : 
     190             :     sal_Int32       GetSelectEntryCount() const;
     191             :     sal_Int32       GetSelectEntryPos( sal_Int32  nSelIndex = 0 ) const;
     192           0 :     OUString        GetSelectEntry() const { return GetEntry( GetSelectEntryPos() ); }
     193             :     bool            IsEntryPosSelected( sal_Int32  nPos ) const;
     194             :     void            SelectEntryPos( sal_Int32  nPos, bool bSelect = true );
     195             :     void            SetNoSelection();
     196             :     Rectangle       GetBoundingRectangle( sal_Int32  nItem ) const;
     197             : 
     198             :     /** checks whether a certain point lies within the bounds of
     199             :         a list item and returns the item as well as the character position
     200             :         the point is at.
     201             : 
     202             :         <p>If the point is inside an item the item pos is put into <code>rPos</code> and
     203             :         the item-relative character index is returned. If the point is not inside
     204             :         an item -1 is returned and rPos is unchanged.</p>
     205             : 
     206             :         @param rPoint
     207             :         tells the point for which an item is requested.
     208             : 
     209             :         @param rPos
     210             :         gets the item at the specified point <code>rPoint</code>
     211             : 
     212             :         @returns
     213             :         the item-relative character index at point <code>rPos</code> or -1
     214             :         if no item is at that point.
     215             :      */
     216             :     using Control::GetIndexForPoint;
     217             :     long GetIndexForPoint( const Point& rPoint, sal_Int32 & rPos ) const;
     218             : 
     219             :     sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; }
     220             :     void setMaxWidthChars(sal_Int32 nWidth);
     221             : 
     222             :     virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
     223             : };
     224             : 
     225             : #endif  // _COMBOBOX_HXX
     226             : 
     227             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11