LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/vcl - lstbox.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 14 50.0 %
Date: 2013-07-09 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 _SV_LSTBOX_HXX
      21             : #define _SV_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_uInt16                  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             : 
      67             : protected:
      68             :     using Window::ImplInit;
      69             :     SAL_DLLPRIVATE void    ImplInit( Window* pParent, WinBits nStyle );
      70             :     SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle );
      71             :     SAL_DLLPRIVATE void    ImplLoadRes( const ResId& rResId );
      72        3428 :     sal_Bool                IsDropDownBox() const { return mpFloatWin ? sal_True : sal_False; }
      73             : 
      74             : protected:
      75             :     explicit            ListBox( WindowType nType );
      76             : 
      77             :     virtual void        FillLayoutData() const;
      78             : 
      79             : public:
      80             :     explicit            ListBox( Window* pParent, WinBits nStyle = WB_BORDER );
      81             :     explicit            ListBox( Window* pParent, const ResId& );
      82             :     virtual             ~ListBox();
      83             : 
      84             :     virtual void        Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
      85             :     virtual void        Resize();
      86             :     virtual long        PreNotify( NotifyEvent& rNEvt );
      87             :     virtual void        StateChanged( StateChangedType nType );
      88             :     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
      89             :     virtual void        UserDraw( const UserDrawEvent& rUDEvt );
      90             : 
      91             :     virtual void        Select();
      92             :     virtual void        DoubleClick();
      93             :     virtual void        GetFocus();
      94             :     virtual void        LoseFocus();
      95             :     virtual Window*     GetPreferredKeyInputWindow();
      96             : 
      97             :     virtual const Wallpaper& GetDisplayBackground() const;
      98             : 
      99             :     virtual void        setPosSizePixel( long nX, long nY,
     100             :                                          long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
     101         119 :     void                SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
     102         119 :                         { Control::SetPosSizePixel( rNewPos, rNewSize ); }
     103           0 :     void                SetDropDownSizePixel( const Size& rNewSize )
     104           0 :     { if( IsDropDownBox() ) setPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(), WINDOW_POSSIZE_SIZE | WINDOW_POSSIZE_DROPDOWN ); }
     105             : 
     106             :     Rectangle           GetDropDownPosSizePixel() const;
     107             : 
     108             :     void AdaptDropDownLineCountToMaximum();
     109             :     void                SetDropDownLineCount( sal_uInt16 nLines );
     110             :     sal_uInt16          GetDropDownLineCount() const;
     111             : 
     112             :     void                EnableAutoSize( bool bAuto );
     113         698 :     bool                IsAutoSizeEnabled() const { return mbDDAutoSize; }
     114             : 
     115             :     void                EnableDDAutoWidth( sal_Bool b );
     116             : 
     117             :     virtual sal_uInt16      InsertEntry( const XubString& rStr, sal_uInt16 nPos = LISTBOX_APPEND );
     118             :     virtual sal_uInt16      InsertEntry( const Image& rImage, sal_uInt16 nPos = LISTBOX_APPEND );
     119             :     virtual sal_uInt16      InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos = LISTBOX_APPEND );
     120             :     virtual void        RemoveEntry( const XubString& rStr );
     121             :     virtual void        RemoveEntry( sal_uInt16 nPos );
     122             : 
     123             :     virtual void        Clear();
     124             : 
     125             :     virtual sal_uInt16      GetEntryPos( const XubString& rStr ) const;
     126             :     virtual sal_uInt16      GetEntryPos( const void* pData ) const;
     127             :             Image       GetEntryImage( sal_uInt16 nPos ) const;
     128             :     virtual XubString   GetEntry( sal_uInt16 nPos ) const;
     129             :     virtual sal_uInt16      GetEntryCount() const;
     130             : 
     131             :     virtual void        SelectEntry( const XubString& rStr, sal_Bool bSelect = sal_True );
     132             :     virtual void        SelectEntryPos( sal_uInt16 nPos, sal_Bool bSelect = sal_True );
     133             : 
     134             :     virtual sal_uInt16      GetSelectEntryCount() const;
     135             :     virtual XubString   GetSelectEntry( sal_uInt16 nSelIndex = 0 ) const;
     136             :     virtual sal_uInt16      GetSelectEntryPos( sal_uInt16 nSelIndex = 0 ) const;
     137             : 
     138             :     virtual sal_Bool        IsEntrySelected( const XubString& rStr ) const;
     139             :     virtual sal_Bool        IsEntryPosSelected( sal_uInt16 nPos ) const;
     140             :     virtual void        SetNoSelection();
     141             : 
     142             :     void                SetEntryData( sal_uInt16 nPos, void* pNewData );
     143             :     void*               GetEntryData( sal_uInt16 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_uInt16 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_uInt16 nPos ) const;
     161             : 
     162             :     void            SetTopEntry( sal_uInt16 nPos );
     163             :     sal_uInt16          GetTopEntry() const;
     164             : 
     165         779 :     void            SaveValue() { mnSaveValue = GetSelectEntryPos(); }
     166           0 :     sal_uInt16          GetSavedValue() const { return mnSaveValue; }
     167             : 
     168             :     void            SetSeparatorPos( sal_uInt16 n = LISTBOX_ENTRY_NOTFOUND );
     169             :     sal_uInt16          GetSeparatorPos() const;
     170             : 
     171             :     sal_Bool            IsTravelSelect() const;
     172             :     sal_Bool            IsInDropDown() const;
     173             :     void            ToggleDropDown();
     174             : 
     175             :     void            EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackSelection );
     176             :     void            EnableMultiSelection( sal_Bool bMulti );
     177             :     sal_Bool            IsMultiSelectionEnabled() const;
     178             : 
     179             :     void            SetReadOnly( sal_Bool bReadOnly = sal_True );
     180             :     sal_Bool            IsReadOnly() const;
     181             : 
     182             :     Rectangle       GetBoundingRectangle( sal_uInt16 nItem ) const;
     183             : 
     184             :     void            SetUserItemSize( const Size& rSz );
     185             : 
     186             :     void            EnableUserDraw( sal_Bool bUserDraw );
     187             : 
     188             :     void            DrawEntry( const UserDrawEvent& rEvt, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False );
     189             : 
     190         205 :     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;
     198             :     Size            CalcAdjustedSize( const Size& rPrefSize ) const;
     199             :     Size            CalcSize( 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        1114 :     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_uInt16& 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);
     234             : };
     235             : 
     236             : // ----------------
     237             : // - MultiListBox -
     238             : // ----------------
     239             : 
     240           0 : class VCL_DLLPUBLIC MultiListBox : public ListBox
     241             : {
     242             : public:
     243             :     using ListBox::SaveValue;
     244             :     using ListBox::GetSavedValue;
     245             : private:
     246             :     // Bei MultiListBox nicht erlaubt...
     247             :     void            SaveValue();
     248             :     sal_uInt16          GetSavedValue();
     249             : 
     250             : public:
     251             :     explicit        MultiListBox( Window* pParent, WinBits nStyle = 0 );
     252             :     explicit        MultiListBox( Window* pParent, const ResId& rResId );
     253             : };
     254             : 
     255             : #endif  // _SV_LSTBOX_HXX
     256             : 
     257             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10