LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/svtools - svlbitm.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 38 36.8 %
Date: 2013-07-09 Functions: 6 17 35.3 %
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 _SVLBOXITM_HXX
      22             : #define _SVLBOXITM_HXX
      23             : 
      24             : #include "svtools/svtdllapi.h"
      25             : 
      26             : #include <tools/link.hxx>
      27             : 
      28             : #include <vcl/image.hxx>
      29             : #include <svtools/treelistbox.hxx>
      30             : 
      31             : class SvTreeListEntry;
      32             : 
      33             : 
      34             : #define SV_BMP_UNCHECKED        0
      35             : #define SV_BMP_CHECKED          1
      36             : #define SV_BMP_TRISTATE         2
      37             : #define SV_BMP_HIUNCHECKED      3
      38             : #define SV_BMP_HICHECKED        4
      39             : #define SV_BMP_HITRISTATE       5
      40             : #define SV_BMP_STATICIMAGE      6
      41             : 
      42             : struct SvLBoxButtonData_Impl;
      43             : 
      44             : class SVT_DLLPUBLIC SvLBoxButtonData
      45             : {
      46             : private:
      47             :     Link                    aLink;
      48             :     long                    nWidth;
      49             :     long                    nHeight;
      50             :     SvLBoxButtonData_Impl*  pImpl;
      51             :     sal_Bool                    bDataOk;
      52             :     SvButtonState           eState;
      53             : 
      54             :     SVT_DLLPRIVATE void                     SetWidthAndHeight();
      55             :     SVT_DLLPRIVATE void                 InitData( sal_Bool bImagesFromDefault,
      56             :                                       bool _bRadioBtn, const Control* pControlForSettings = NULL );
      57             : public:
      58             :                             // include creating default images (CheckBox or RadioButton)
      59             :                             SvLBoxButtonData( const Control* pControlForSettings );
      60             :                             SvLBoxButtonData( const Control* pControlForSettings, bool _bRadioBtn );
      61             : 
      62             :                             ~SvLBoxButtonData();
      63             : 
      64             :     sal_uInt16                  GetIndex( sal_uInt16 nItemState );
      65             :     long                    Width();
      66             :     long                    Height();
      67           0 :     void                    SetLink( const Link& rLink) { aLink=rLink; }
      68             :     const Link&             GetLink() const { return aLink; }
      69             :      sal_Bool                   IsRadio();
      70             :     // weil Buttons nicht von LinkHdl abgeleitet sind
      71             :     void                    CallLink();
      72             : 
      73             :     void                    StoreButtonState( SvTreeListEntry* pEntry, sal_uInt16 nItemFlags );
      74             :     SvButtonState           ConvertToButtonState( sal_uInt16 nItemFlags ) const;
      75             : 
      76             :     SvButtonState GetActButtonState() const
      77             :     {
      78             :         return eState;
      79             :     }
      80             : 
      81             :     SvTreeListEntry*            GetActEntry() const;
      82             : 
      83             :     Image aBmps[24];  // Indizes siehe Konstanten BMP_ ....
      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             :     sal_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;
     102             :     virtual void    InitViewData(SvTreeListBox*, SvTreeListEntry*, SvViewDataItem*);
     103      108905 :     OUString   GetText() const { return maText; }
     104       21682 :     void            SetText( const OUString& rText ) { maText = rText; }
     105             : 
     106             :     virtual void Paint(
     107             :         const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry);
     108             : 
     109             :     virtual SvLBoxItem* Create() const;
     110             :     virtual void    Clone( SvLBoxItem* pSource );
     111             : };
     112             : 
     113             : class SvLBoxBmp : public SvLBoxItem
     114             : {
     115             :     Image aBmp;
     116             : public:
     117             :                     SvLBoxBmp();
     118             :     virtual         ~SvLBoxBmp();
     119             :     virtual sal_uInt16 GetType() const;
     120             :     virtual void    InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* );
     121             :     virtual void Paint(
     122             :         const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry);
     123             :     virtual SvLBoxItem* Create() const;
     124             :     virtual void    Clone( SvLBoxItem* pSource );
     125             : };
     126             : 
     127             : 
     128             : #define SV_ITEMSTATE_UNCHECKED          0x0001
     129             : #define SV_ITEMSTATE_CHECKED            0x0002
     130             : #define SV_ITEMSTATE_TRISTATE           0x0004
     131             : #define SV_ITEMSTATE_HILIGHTED          0x0008
     132             : #define SV_STATE_MASK 0xFFF8  // zum Loeschen von UNCHECKED,CHECKED,TRISTATE
     133             : 
     134             : class SVT_DLLPUBLIC SvLBoxButton : public SvLBoxItem
     135             : {
     136             :     bool    isVis;
     137             :     SvLBoxButtonData*   pData;
     138             :     SvLBoxButtonKind eKind;
     139             :     sal_uInt16 nItemFlags;
     140             :     sal_uInt16 nBaseOffs;
     141             : 
     142             :     void ImplAdjustBoxSize( Size& io_rCtrlSize, ControlType i_eType, 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* );
     155             :     virtual sal_uInt16 GetType() const;
     156             :     virtual sal_Bool    ClickHdl(SvTreeListBox* pView, SvTreeListEntry* );
     157             :     virtual void Paint(
     158             :         const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry);
     159             :     virtual SvLBoxItem* Create() const;
     160             :     virtual void    Clone( SvLBoxItem* pSource );
     161           0 :     sal_uInt16          GetButtonFlags() const { return nItemFlags; }
     162           0 :     sal_Bool            IsStateChecked() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_CHECKED)!=0; }
     163           0 :     sal_Bool            IsStateUnchecked() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_UNCHECKED)!=0; }
     164           0 :     sal_Bool            IsStateTristate() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_TRISTATE)!=0; }
     165           0 :     sal_Bool            IsStateHilighted() const { return (sal_Bool)(nItemFlags & SV_ITEMSTATE_HILIGHTED)!=0; }
     166             :     void            SetStateChecked();
     167             :     void            SetStateUnchecked();
     168             :     void            SetStateTristate();
     169             :     void            SetStateHilighted( sal_Bool bHilight );
     170             :     void            SetStateInvisible();
     171             : 
     172           0 :     SvLBoxButtonKind GetKind() const { return eKind; }
     173             : 
     174             :     void            SetBaseOffs( sal_uInt16 nOffs ) { nBaseOffs = nOffs; }
     175             :     sal_uInt16          GetBaseOffs() const { return nBaseOffs; }
     176             : 
     177             :     // Check whether this button can be modified via UI
     178             :     bool            CheckModification() const;
     179             : };
     180             : 
     181           0 : inline void SvLBoxButton::SetStateChecked()
     182             : {
     183           0 :     nItemFlags &= SV_STATE_MASK;
     184           0 :     nItemFlags |= SV_ITEMSTATE_CHECKED;
     185           0 : }
     186           0 : inline void SvLBoxButton::SetStateUnchecked()
     187             : {
     188           0 :     nItemFlags &= SV_STATE_MASK;
     189           0 :     nItemFlags |= SV_ITEMSTATE_UNCHECKED;
     190           0 : }
     191           0 : inline void SvLBoxButton::SetStateTristate()
     192             : {
     193           0 :     nItemFlags &= SV_STATE_MASK;
     194           0 :     nItemFlags |= SV_ITEMSTATE_TRISTATE;
     195           0 : }
     196           0 : inline void SvLBoxButton::SetStateHilighted( sal_Bool bHilight )
     197             : {
     198           0 :     if ( bHilight )
     199           0 :         nItemFlags |= SV_ITEMSTATE_HILIGHTED;
     200             :     else
     201           0 :         nItemFlags &= ~SV_ITEMSTATE_HILIGHTED;
     202           0 : }
     203             : 
     204             : 
     205             : struct SvLBoxContextBmp_Impl;
     206             : class SVT_DLLPUBLIC SvLBoxContextBmp : public SvLBoxItem
     207             : {
     208             :     SvLBoxContextBmp_Impl*  m_pImpl;
     209             : public:
     210             :     SvLBoxContextBmp(
     211             :         SvTreeListEntry* pEntry, sal_uInt16 nItemFlags, Image aBmp1, Image aBmp2, bool bExpanded);
     212             :     SvLBoxContextBmp();
     213             : 
     214             :     virtual         ~SvLBoxContextBmp();
     215             :     virtual sal_uInt16 GetType() const;
     216             :     virtual void    InitViewData( SvTreeListBox*,SvTreeListEntry*,SvViewDataItem* );
     217             :     virtual void Paint(
     218             :         const Point& rPos, SvTreeListBox& rOutDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry);
     219             :     virtual SvLBoxItem* Create() const;
     220             :     virtual void    Clone( SvLBoxItem* pSource );
     221             : 
     222             : 
     223             :     sal_Bool            SetModeImages( const Image& _rBitmap1, const Image& _rBitmap2 );
     224             :     void            GetModeImages(       Image& _rBitmap1,       Image& _rBitmap2 ) const;
     225             : 
     226             :     inline void         SetBitmap1( const Image& _rImage );
     227             :     inline void         SetBitmap2( const Image& _rImage );
     228             :     inline const Image& GetBitmap1( ) const;
     229             :     inline const Image& GetBitmap2( ) const;
     230             : 
     231             : private:
     232             :     Image& implGetImageStore( sal_Bool _bFirst );
     233             : };
     234             : 
     235           1 : inline void SvLBoxContextBmp::SetBitmap1( const Image& _rImage  )
     236             : {
     237           1 :     implGetImageStore( sal_True ) = _rImage;
     238           1 : }
     239             : 
     240           1 : inline void SvLBoxContextBmp::SetBitmap2( const Image& _rImage )
     241             : {
     242           1 :     implGetImageStore( sal_False ) = _rImage;
     243           1 : }
     244             : 
     245       21682 : inline const Image& SvLBoxContextBmp::GetBitmap1( ) const
     246             : {
     247       21682 :     Image& rImage = const_cast< SvLBoxContextBmp* >( this )->implGetImageStore( sal_True );
     248       21682 :     return rImage;
     249             : }
     250             : 
     251       21682 : inline const Image& SvLBoxContextBmp::GetBitmap2( ) const
     252             : {
     253       21682 :     Image& rImage = const_cast< SvLBoxContextBmp* >( this )->implGetImageStore( sal_False );
     254       21682 :     return rImage;
     255             : }
     256             : 
     257             : #endif
     258             : 
     259             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10