LCOV - code coverage report
Current view: top level - include/svtools - svlbitm.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 14 41 34.1 %
Date: 2014-11-03 Functions: 6 20 30.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             : 
      21             : #ifndef INCLUDED_SVTOOLS_SVLBITM_HXX
      22             : #define INCLUDED_SVTOOLS_SVLBITM_HXX
      23             : 
      24             : #include <svtools/svtdllapi.h>
      25             : #include <tools/link.hxx>
      26             : #include <vcl/image.hxx>
      27             : #include <svtools/treelistbox.hxx>
      28             : 
      29             : class SvTreeListEntry;
      30             : 
      31             : 
      32             : enum class SvBmp
      33             : {
      34             :     UNCHECKED        = 0,
      35             :     CHECKED          = 1,
      36             :     TRISTATE         = 2,
      37             :     HIUNCHECKED      = 3,
      38             :     HICHECKED        = 4,
      39             :     HITRISTATE       = 5,
      40             :     STATICIMAGE      = 6
      41             : };
      42             : 
      43             : struct SvLBoxButtonData_Impl;
      44             : 
      45             : class SVT_DLLPUBLIC SvLBoxButtonData
      46             : {
      47             : private:
      48             :     Link                    aLink;
      49             :     long                    nWidth;
      50             :     long                    nHeight;
      51             :     SvLBoxButtonData_Impl*  pImpl;
      52             :     bool                    bDataOk;
      53             :     SvButtonState           eState;
      54             :     std::vector<Image>      aBmps;  // Indizes siehe Konstanten BMP_ ....
      55             : 
      56             :     SVT_DLLPRIVATE void     SetWidthAndHeight();
      57             :     SVT_DLLPRIVATE void     InitData( bool bImagesFromDefault,
      58             :                                       bool _bRadioBtn, const Control* pControlForSettings = NULL );
      59             : public:
      60             :                             // include creating default images (CheckBox or RadioButton)
      61             :                             SvLBoxButtonData( const Control* pControlForSettings );
      62             :                             SvLBoxButtonData( const Control* pControlForSettings, bool _bRadioBtn );
      63             : 
      64             :                             ~SvLBoxButtonData();
      65             : 
      66             :     SvBmp                   GetIndex( sal_uInt16 nItemState );
      67             :     long                    Width();
      68             :     long                    Height();
      69           0 :     void                    SetLink( const Link& rLink) { aLink=rLink; }
      70             :     const Link&             GetLink() const { return aLink; }
      71             :     bool                    IsRadio();
      72             :     // weil Buttons nicht von LinkHdl abgeleitet sind
      73             :     void                    CallLink();
      74             : 
      75             :     void                    StoreButtonState( SvTreeListEntry* pEntry, sal_uInt16 nItemFlags );
      76             :     SvButtonState           ConvertToButtonState( sal_uInt16 nItemFlags ) const;
      77             : 
      78             :     SvButtonState           GetActButtonState() const { return eState; }
      79             : 
      80             :     SvTreeListEntry*        GetActEntry() const;
      81             : 
      82           0 :     void                    SetImage(SvBmp nIndex, const Image& aImage) { aBmps[(int)nIndex] = aImage; }
      83           0 :     Image&                  GetImage(SvBmp nIndex) { return aBmps[(int)nIndex]; }
      84             : 
      85             :     void                    SetDefaultImages( const Control* pControlForSettings = NULL );
      86             :                                 // set images acording to the color scheeme of the Control
      87             :                                 // pControlForSettings == NULL: settings are taken from Application
      88             :     bool                    HasDefaultImages( void ) const;
      89             : };
      90             : 
      91             : // **********************************************************************
      92             : 
      93             : class SVT_DLLPUBLIC SvLBoxString : public SvLBoxItem
      94             : {
      95             : protected:
      96             :     OUString maText;
      97             : public:
      98             :                     SvLBoxString(SvTreeListEntry*, sal_uInt16 nFlags, const OUString& rStr);
      99             :                     SvLBoxString();
     100             :     virtual         ~SvLBoxString();
     101             :     virtual sal_uInt16 GetType() const SAL_OVERRIDE;
     102             :     virtual void    InitViewData(SvTreeListBox*, SvTreeListEntry*, SvViewDataItem*) SAL_OVERRIDE;
     103        1548 :     OUString   GetText() const { return maText; }
     104           0 :     virtual OUString GetExtendText() const { return OUString(); }
     105        2900 :     void            SetText( const OUString& rText ) { maText = rText; }
     106             : 
     107             :     virtual void Paint(
     108             :         const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) SAL_OVERRIDE;
     109             : 
     110             :     virtual SvLBoxItem* Create() const SAL_OVERRIDE;
     111             :     virtual void    Clone( SvLBoxItem* pSource ) SAL_OVERRIDE;
     112             : };
     113             : 
     114             : class SvLBoxBmp : public SvLBoxItem
     115             : {
     116             :     Image aBmp;
     117             : public:
     118             :                     SvLBoxBmp();
     119             :     virtual         ~SvLBoxBmp();
     120             :     virtual sal_uInt16 GetType() const SAL_OVERRIDE;
     121             :     virtual void    InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* ) SAL_OVERRIDE;
     122             :     virtual void Paint(
     123             :         const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) SAL_OVERRIDE;
     124             :     virtual SvLBoxItem* Create() const SAL_OVERRIDE;
     125             :     virtual void    Clone( SvLBoxItem* pSource ) SAL_OVERRIDE;
     126             : };
     127             : 
     128             : 
     129             : #define SV_ITEMSTATE_UNCHECKED          0x0001
     130             : #define SV_ITEMSTATE_CHECKED            0x0002
     131             : #define SV_ITEMSTATE_TRISTATE           0x0004
     132             : #define SV_ITEMSTATE_HILIGHTED          0x0008
     133             : #define SV_STATE_MASK 0xFFF8  // zum Loeschen von UNCHECKED,CHECKED,TRISTATE
     134             : 
     135             : class SVT_DLLPUBLIC SvLBoxButton : public SvLBoxItem
     136             : {
     137             :     bool    isVis;
     138             :     SvLBoxButtonData*   pData;
     139             :     SvLBoxButtonKind eKind;
     140             :     sal_uInt16 nItemFlags;
     141             : 
     142             :     void ImplAdjustBoxSize( Size& io_rCtrlSize, ControlType i_eType, vcl::Window* pParent );
     143             : public:
     144             :                     // An SvLBoxButton can be of three different kinds: an
     145             :                     // enabled checkbox (the normal kind), a disabled checkbox
     146             :                     // (which cannot be modified via UI), or a static image
     147             :                     // (see SV_BMP_STATICIMAGE; nFlags are effectively ignored
     148             :                     // for that kind).
     149             :                     SvLBoxButton( SvTreeListEntry* pEntry,
     150             :                                   SvLBoxButtonKind eTheKind, sal_uInt16 nFlags,
     151             :                                   SvLBoxButtonData* pBData );
     152             :                     SvLBoxButton();
     153             :     virtual         ~SvLBoxButton();
     154             :     virtual void    InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* ) SAL_OVERRIDE;
     155             :     virtual sal_uInt16 GetType() const SAL_OVERRIDE;
     156             :     virtual bool    ClickHdl(SvTreeListBox* pView, SvTreeListEntry* );
     157             :     virtual void Paint(
     158             :         const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) SAL_OVERRIDE;
     159             :     virtual SvLBoxItem* Create() const SAL_OVERRIDE;
     160             :     virtual void    Clone( SvLBoxItem* pSource ) SAL_OVERRIDE;
     161           0 :     sal_uInt16          GetButtonFlags() const { return nItemFlags; }
     162           0 :     bool            IsStateChecked() const { return (nItemFlags & SV_ITEMSTATE_CHECKED)!=0; }
     163           0 :     bool            IsStateUnchecked() const { return (nItemFlags & SV_ITEMSTATE_UNCHECKED)!=0; }
     164           0 :     bool            IsStateTristate() const { return (nItemFlags & SV_ITEMSTATE_TRISTATE)!=0; }
     165           0 :     bool            IsStateHilighted() const { return (nItemFlags & SV_ITEMSTATE_HILIGHTED)!=0; }
     166             :     void            SetStateChecked();
     167             :     void            SetStateUnchecked();
     168             :     void            SetStateTristate();
     169             :     void            SetStateHilighted( bool bHilight );
     170             :     void            SetStateInvisible();
     171             : 
     172           0 :     SvLBoxButtonKind GetKind() const { return eKind; }
     173             : 
     174             :     // Check whether this button can be modified via UI
     175             :     bool            CheckModification() const;
     176             :     SvLBoxButtonData* GetButtonData() const{ return pData;}
     177             : };
     178             : 
     179           0 : inline void SvLBoxButton::SetStateChecked()
     180             : {
     181           0 :     nItemFlags &= SV_STATE_MASK;
     182           0 :     nItemFlags |= SV_ITEMSTATE_CHECKED;
     183           0 : }
     184           0 : inline void SvLBoxButton::SetStateUnchecked()
     185             : {
     186           0 :     nItemFlags &= SV_STATE_MASK;
     187           0 :     nItemFlags |= SV_ITEMSTATE_UNCHECKED;
     188           0 : }
     189           0 : inline void SvLBoxButton::SetStateTristate()
     190             : {
     191           0 :     nItemFlags &= SV_STATE_MASK;
     192           0 :     nItemFlags |= SV_ITEMSTATE_TRISTATE;
     193           0 : }
     194           0 : inline void SvLBoxButton::SetStateHilighted( bool bHilight )
     195             : {
     196           0 :     if ( bHilight )
     197           0 :         nItemFlags |= SV_ITEMSTATE_HILIGHTED;
     198             :     else
     199           0 :         nItemFlags &= ~SV_ITEMSTATE_HILIGHTED;
     200           0 : }
     201             : 
     202             : 
     203             : struct SvLBoxContextBmp_Impl;
     204             : class SVT_DLLPUBLIC SvLBoxContextBmp : public SvLBoxItem
     205             : {
     206             :     SvLBoxContextBmp_Impl*  m_pImpl;
     207             : public:
     208             :     SvLBoxContextBmp(
     209             :         SvTreeListEntry* pEntry, sal_uInt16 nItemFlags, Image aBmp1, Image aBmp2, bool bExpanded);
     210             :     SvLBoxContextBmp();
     211             : 
     212             :     virtual         ~SvLBoxContextBmp();
     213             :     virtual sal_uInt16 GetType() const SAL_OVERRIDE;
     214             :     virtual void    InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* ) SAL_OVERRIDE;
     215             :     virtual void Paint(
     216             :         const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) SAL_OVERRIDE;
     217             :     virtual SvLBoxItem* Create() const SAL_OVERRIDE;
     218             :     virtual void    Clone( SvLBoxItem* pSource ) SAL_OVERRIDE;
     219             : 
     220             : 
     221             :     bool            SetModeImages( const Image& _rBitmap1, const Image& _rBitmap2 );
     222             :     void            GetModeImages(       Image& _rBitmap1,       Image& _rBitmap2 ) const;
     223             : 
     224             :     inline void         SetBitmap1( const Image& _rImage );
     225             :     inline void         SetBitmap2( const Image& _rImage );
     226             :     inline const Image& GetBitmap1( ) const;
     227             :     inline const Image& GetBitmap2( ) const;
     228             : 
     229             : private:
     230             :     Image& implGetImageStore( bool _bFirst );
     231             : };
     232             : 
     233           2 : inline void SvLBoxContextBmp::SetBitmap1( const Image& _rImage  )
     234             : {
     235           2 :     implGetImageStore( true ) = _rImage;
     236           2 : }
     237             : 
     238           2 : inline void SvLBoxContextBmp::SetBitmap2( const Image& _rImage )
     239             : {
     240           2 :     implGetImageStore( false ) = _rImage;
     241           2 : }
     242             : 
     243        2900 : inline const Image& SvLBoxContextBmp::GetBitmap1( ) const
     244             : {
     245        2900 :     Image& rImage = const_cast< SvLBoxContextBmp* >( this )->implGetImageStore( true );
     246        2900 :     return rImage;
     247             : }
     248             : 
     249        2900 : inline const Image& SvLBoxContextBmp::GetBitmap2( ) const
     250             : {
     251        2900 :     Image& rImage = const_cast< SvLBoxContextBmp* >( this )->implGetImageStore( false );
     252        2900 :     return rImage;
     253             : }
     254             : 
     255             : #endif
     256             : 
     257             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10