LCOV - code coverage report
Current view: top level - svx/inc/svx - frmsel.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1 0.0 %
Date: 2012-08-25 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef SVX_FRMSEL_HXX
      30                 :            : #define SVX_FRMSEL_HXX
      31                 :            : 
      32                 :            : #include <memory>
      33                 :            : #include <tools/color.hxx>
      34                 :            : #include <vcl/ctrl.hxx>
      35                 :            : #include <vcl/bitmap.hxx>
      36                 :            : #include <editeng/borderline.hxx>
      37                 :            : #include <svx/framebordertype.hxx>
      38                 :            : #include "svx/svxdllapi.h"
      39                 :            : 
      40                 :            : namespace editeng {
      41                 :            :     class SvxBorderLine;
      42                 :            : }
      43                 :            : 
      44                 :            : namespace svx {
      45                 :            : 
      46                 :            : struct FrameSelectorImpl;
      47                 :            : 
      48                 :            : // ============================================================================
      49                 :            : 
      50                 :            : typedef int FrameSelFlags;
      51                 :            : 
      52                 :            : const FrameSelFlags FRAMESEL_NONE       = 0x0000;
      53                 :            : /** If set, the left frame border is enabled. */
      54                 :            : const FrameSelFlags FRAMESEL_LEFT       = 0x0001;
      55                 :            : /** If set, the right frame border is enabled. */
      56                 :            : const FrameSelFlags FRAMESEL_RIGHT      = 0x0002;
      57                 :            : /** If set, the top frame border is enabled. */
      58                 :            : const FrameSelFlags FRAMESEL_TOP        = 0x0004;
      59                 :            : /** If set, the bottom frame border is enabled. */
      60                 :            : const FrameSelFlags FRAMESEL_BOTTOM     = 0x0008;
      61                 :            : /** If set, the inner horizontal frame border is enabled. */
      62                 :            : const FrameSelFlags FRAMESEL_INNER_HOR  = 0x0010;
      63                 :            : /** If set, the inner vertical frame border is enabled. */
      64                 :            : const FrameSelFlags FRAMESEL_INNER_VER  = 0x0020;
      65                 :            : /** If set, the top-left to bottom-right diagonal frame border is enabled. */
      66                 :            : const FrameSelFlags FRAMESEL_DIAG_TLBR  = 0x0040;
      67                 :            : /** If set, the bottom-left to top-right diagonal frame border is enabled. */
      68                 :            : const FrameSelFlags FRAMESEL_DIAG_BLTR  = 0x0080;
      69                 :            : 
      70                 :            : /** If set, all four outer frame borders are enabled. */
      71                 :            : const FrameSelFlags FRAMESEL_OUTER      = FRAMESEL_LEFT|FRAMESEL_RIGHT|FRAMESEL_TOP|FRAMESEL_BOTTOM;
      72                 :            : /** If set, both inner frame borders are enabled. */
      73                 :            : const FrameSelFlags FRAMESEL_INNER      = FRAMESEL_INNER_HOR|FRAMESEL_INNER_VER;
      74                 :            : /** If set, both diagonal frame borders are enabled. */
      75                 :            : const FrameSelFlags FRAMESEL_DIAGONAL   = FRAMESEL_DIAG_TLBR|FRAMESEL_DIAG_BLTR;
      76                 :            : 
      77                 :            : /** If set, all frame borders will support the don't care state. */
      78                 :            : const FrameSelFlags FRAMESEL_DONTCARE   = 0x0100;
      79                 :            : 
      80                 :            : // ----------------------------------------------------------------------------
      81                 :            : 
      82                 :            : /** All possible states of a frame border. */
      83                 :            : enum FrameBorderState
      84                 :            : {
      85                 :            :     FRAMESTATE_SHOW,        /// Frame border has a visible style.
      86                 :            :     FRAMESTATE_HIDE,        /// Frame border is hidden (off).
      87                 :            :     FRAMESTATE_DONTCARE     /// Frame border is in don't care state (if enabled).
      88                 :            : };
      89                 :            : 
      90                 :            : // ============================================================================
      91                 :            : 
      92                 :            : class SVX_DLLPUBLIC FrameSelector : public Control
      93                 :            : {
      94                 :            : public:
      95                 :            :     explicit            FrameSelector( Window* pParent, const ResId& rResId );
      96                 :            :     virtual             ~FrameSelector();
      97                 :            : 
      98                 :            :     /** Initializes the control, enables/disables frame borders according to flags. */
      99                 :            :     void                Initialize( FrameSelFlags nFlags );
     100                 :            : 
     101                 :            :     // enabled frame borders --------------------------------------------------
     102                 :            : 
     103                 :            :     /** Returns true, if the specified frame border is enabled. */
     104                 :            :     bool                IsBorderEnabled( FrameBorderType eBorder ) const;
     105                 :            :     /** Returns the number of enabled frame borders. */
     106                 :            :     sal_Int32           GetEnabledBorderCount() const;
     107                 :            :     /** Returns the border type from the passed index (counts only enabled frame borders). */
     108                 :            :     FrameBorderType     GetEnabledBorderType( sal_Int32 nIndex ) const;
     109                 :            :     /** Returns the index of a frame border (counts only enabled borders) from passed type. */
     110                 :            :     sal_Int32           GetEnabledBorderIndex( FrameBorderType eBorder ) const;
     111                 :            : 
     112                 :            :     // frame border state and style -------------------------------------------
     113                 :            : 
     114                 :            :     /** Returns true, if the control supports the "don't care" frame border state. */
     115                 :            :     bool                SupportsDontCareState() const;
     116                 :            : 
     117                 :            :     /** Returns the state (visible/hidden/don't care) of the specified frame border. */
     118                 :            :     FrameBorderState    GetFrameBorderState( FrameBorderType eBorder ) const;
     119                 :            :     /** Returns the style of the specified frame border, if it is visible. */
     120                 :            :     const editeng::SvxBorderLine* GetFrameBorderStyle( FrameBorderType eBorder ) const;
     121                 :            : 
     122                 :            :     /** Shows the specified frame border using the passed style, or hides it, if pStyle is 0. */
     123                 :            :     void                ShowBorder( FrameBorderType eBorder, const editeng::SvxBorderLine* pStyle );
     124                 :            :     /** Sets the specified frame border to "don't care" state. */
     125                 :            :     void                SetBorderDontCare( FrameBorderType eBorder );
     126                 :            : 
     127                 :            :     /** Returns true, if any enabled frame border has a visible style (not "don't care"). */
     128                 :            :     bool                IsAnyBorderVisible() const;
     129                 :            :     /** Hides all enabled frame borders. */
     130                 :            :     void                HideAllBorders();
     131                 :            : 
     132                 :            :     /** Returns true, if all visible frame borders have equal widths.
     133                 :            :         @descr  Ignores hidden and "don't care" frame borders. On success,
     134                 :            :         returns the width in the passed parameter. */
     135                 :            :     bool                GetVisibleWidth( long& rnWidth, editeng::SvxBorderStyle& rnStyle ) const;
     136                 :            :     /** Returns true, if all visible frame borders have equal color.
     137                 :            :         @descr  Ignores hidden and "don't care" frame borders. On success,
     138                 :            :         returns the color in the passed parameter. */
     139                 :            :     bool                GetVisibleColor( Color& rColor ) const;
     140                 :            : 
     141                 :            :     // frame border selection -------------------------------------------------
     142                 :            : 
     143                 :            :     /** Returns the current selection handler. */
     144                 :            :     const Link&         GetSelectHdl() const;
     145                 :            :     /** Sets the passed handler that is called if the selection of the control changes. */
     146                 :            :     void                SetSelectHdl( const Link& rHdl );
     147                 :            : 
     148                 :            :     /** Returns true, if the specified frame border is selected. */
     149                 :            :     bool                IsBorderSelected( FrameBorderType eBorder ) const;
     150                 :            :     /** Selects or deselects the specified frame border. */
     151                 :            :     void                SelectBorder( FrameBorderType eBorder, bool bSelect = true );
     152                 :            :     /** Deselects the specified frame border. */
     153                 :            :     inline void         DeselectBorder( FrameBorderType eBorder ) { SelectBorder( eBorder, false ); }
     154                 :            : 
     155                 :            :     /** Returns true, if any of the enabled frame borders is selected. */
     156                 :            :     bool                IsAnyBorderSelected() const;
     157                 :            :     /** Selects or deselects all frame borders. */
     158                 :            :     void                SelectAllBorders( bool bSelect = true );
     159                 :            :     /** Deselects all frame borders. */
     160                 :          0 :     inline void         DeselectAllBorders() { SelectAllBorders( false ); }
     161                 :            : 
     162                 :            :     /** Selects or deselects all visible frame borders (ignores hidden and "don't care" borders). */
     163                 :            :     void                SelectAllVisibleBorders( bool bSelect = true );
     164                 :            : 
     165                 :            :     /** Sets the passed line widths to all selected frame borders (in twips). */
     166                 :            :     void                SetStyleToSelection( long nWidth, editeng::SvxBorderStyle nStyle );
     167                 :            :     /** Sets the passed color to all selected frame borders. */
     168                 :            :     void                SetColorToSelection( const Color& rColor );
     169                 :            : 
     170                 :            :     // accessibility ----------------------------------------------------------
     171                 :            : 
     172                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     173                 :            :                         CreateAccessible();
     174                 :            : 
     175                 :            :     /** Returns the accessibility child object of the specified frame border (if enabled). */
     176                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     177                 :            :                         GetChildAccessible( FrameBorderType eBorder );
     178                 :            :     /** Returns the accessibility child object with specified index (counts enabled frame borders only). */
     179                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     180                 :            :                         GetChildAccessible( sal_Int32 nIndex );
     181                 :            :     /** Returns the accessibility child object at the specified position (relative to control). */
     182                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     183                 :            :                         GetChildAccessible( const Point& rPos );
     184                 :            : 
     185                 :            :     /** Returns true, if the passed point is inside the click area of any enabled frame border. */
     186                 :            :     bool                ContainsClickPoint( const Point& rPos ) const;
     187                 :            :     /** Returns the bounding rectangle of the specified frame border (if enabled). */
     188                 :            :     Rectangle           GetClickBoundRect( FrameBorderType eBorder ) const;
     189                 :            : 
     190                 :            :     // ------------------------------------------------------------------------
     191                 :            : protected:
     192                 :            :     virtual void        Paint( const Rectangle& rRect );
     193                 :            :     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
     194                 :            :     virtual void        KeyInput( const KeyEvent& rKEvt );
     195                 :            :     virtual void        GetFocus();
     196                 :            :     virtual void        LoseFocus();
     197                 :            :     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
     198                 :            : 
     199                 :            : private:
     200                 :            :     std::auto_ptr< FrameSelectorImpl > mxImpl;
     201                 :            : };
     202                 :            : 
     203                 :            : // ============================================================================
     204                 :            : 
     205                 :            : } // namespace svx
     206                 :            : 
     207                 :            : #endif
     208                 :            : 
     209                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10