LCOV - code coverage report
Current view: top level - libreoffice/svx/source/inc - fmcontrolbordermanager.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 16 0.0 %
Date: 2012-12-27 Functions: 0 9 0.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 SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX
      21             : #define SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX
      22             : 
      23             : #include <com/sun/star/awt/VisualEffect.hpp>
      24             : #include <com/sun/star/awt/FontUnderline.hpp>
      25             : #include <com/sun/star/awt/XControl.hpp>
      26             : #include <com/sun/star/awt/XVclWindowPeer.hpp>
      27             : #include <comphelper/stl_types.hxx>
      28             : 
      29             : #include <set>
      30             : 
      31             : namespace com { namespace sun { namespace star { namespace form { namespace validation {
      32             :     class XValidatableFormComponent;
      33             : } } } } }
      34             : 
      35             : //........................................................................
      36             : namespace svxform
      37             : {
      38             : //........................................................................
      39             : 
      40             :     typedef sal_Int16 ControlStatus;
      41             : 
      42             :     #define CONTROL_STATUS_NONE         0x00
      43             :     #define CONTROL_STATUS_FOCUSED      0x01
      44             :     #define CONTROL_STATUS_MOUSE_HOVER  0x02
      45             :     #define CONTROL_STATUS_INVALID      0x04
      46             : 
      47             :     //====================================================================
      48             :     //= BorderDescriptor
      49             :     //====================================================================
      50             :     struct BorderDescriptor
      51             :     {
      52             :         sal_Int16   nBorderType;
      53             :         sal_Int32   nBorderColor;
      54             : 
      55           0 :         BorderDescriptor()
      56             :             :nBorderType( ::com::sun::star::awt::VisualEffect::FLAT )
      57           0 :             ,nBorderColor( 0x00000000 )
      58             :         {
      59           0 :         }
      60             :         inline void clear()
      61             :         {
      62             :             nBorderType = ::com::sun::star::awt::VisualEffect::FLAT;
      63             :             nBorderColor = 0x00000000;
      64             :         }
      65             :     };
      66             : 
      67             :     //====================================================================
      68             :     //= UnderlineDescriptor
      69             :     //====================================================================
      70             :     struct UnderlineDescriptor
      71             :     {
      72             :         sal_Int16 nUnderlineType;
      73             :         sal_Int32 nUnderlineColor;
      74             : 
      75           0 :         UnderlineDescriptor()
      76             :             :nUnderlineType( ::com::sun::star::awt::FontUnderline::NONE )
      77           0 :             ,nUnderlineColor( 0x00000000 )
      78             :         {
      79           0 :         }
      80             : 
      81           0 :         UnderlineDescriptor( sal_Int16 _nUnderlineType, sal_Int32 _nUnderlineColor )
      82             :             :nUnderlineType( _nUnderlineType )
      83           0 :             ,nUnderlineColor( _nUnderlineColor )
      84             :         {
      85           0 :         }
      86             : 
      87             :         inline void clear()
      88             :         {
      89             :             nUnderlineType = ::com::sun::star::awt::FontUnderline::NONE;
      90             :             nUnderlineColor = 0x00000000;
      91             :         }
      92             :     };
      93             : 
      94             :     //====================================================================
      95             :     //= ControlData
      96             :     //====================================================================
      97           0 :     struct ControlData : public BorderDescriptor, UnderlineDescriptor
      98             :     {
      99             :         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > xControl;
     100             :         ::rtl::OUString                                                     sOriginalHelpText;
     101             : 
     102           0 :         ControlData() : BorderDescriptor() { }
     103           0 :         ControlData( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl )
     104           0 :             :xControl( _rxControl )
     105             :         {
     106           0 :         }
     107             :         void clear()
     108             :         {
     109             :             BorderDescriptor::clear();
     110             :             UnderlineDescriptor::clear();
     111             :             xControl.clear();
     112             :             sOriginalHelpText = ::rtl::OUString();
     113             :         }
     114             :     };
     115             : 
     116             :     //====================================================================
     117             :     //= ControlBorderManager
     118             :     //====================================================================
     119             :     /** manages the dynamic border color for form controls
     120             : 
     121             :         Used by the <type>FormController</type>, this class manages the dynamic changes in the
     122             :         border color of form controls. For this a set of events have to be forwarded to the manager
     123             :         instance, which then will switch the border color depending on the mouse and focus status
     124             :         of the controls.
     125             :     */
     126             :     class ControlBorderManager
     127             :     {
     128             :     private:
     129             :         struct ControlDataCompare : public ::std::binary_function< ControlData, ControlData, bool >
     130             :         {
     131           0 :            bool operator()( const ControlData& _rLHS, const ControlData& _rRHS ) const
     132             :            {
     133           0 :                return _rLHS.xControl.get() < _rRHS.xControl.get();
     134             :            }
     135             :         };
     136             : 
     137             :         typedef ::std::set< ControlData, ControlDataCompare > ControlBag;
     138             :         typedef ::com::sun::star::awt::XVclWindowPeer                                       WindowPeer;
     139             :         typedef ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclWindowPeer >   WindowPeerRef;
     140             :         typedef ::std::set< WindowPeerRef, ::comphelper::OInterfaceCompare< WindowPeer > >  PeerBag;
     141             : 
     142             :         PeerBag     m_aColorableControls;
     143             :         PeerBag     m_aNonColorableControls;
     144             : 
     145             :         ControlData m_aFocusControl;
     146             :         ControlData m_aMouseHoverControl;
     147             :         ControlBag  m_aInvalidControls;
     148             : 
     149             :         // ----------------
     150             :         // attributes
     151             :         sal_Int32   m_nFocusColor;
     152             :         sal_Int32   m_nMouseHoveColor;
     153             :         sal_Int32   m_nInvalidColor;
     154             :         bool        m_bDynamicBorderColors;
     155             : 
     156             :     public:
     157             :         ControlBorderManager();
     158             :         ~ControlBorderManager();
     159             : 
     160             :     public:
     161             :         void    focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl ) SAL_THROW(());
     162             :         void    focusLost( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl ) SAL_THROW(());
     163             :         void    mouseEntered( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl ) SAL_THROW(());
     164             :         void    mouseExited( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl ) SAL_THROW(());
     165             : 
     166             :         void    validityChanged(
     167             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl,
     168             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::form::validation::XValidatableFormComponent >& _rxValidatable
     169             :                 ) SAL_THROW(());
     170             : 
     171             :         /// enables dynamic border color for the controls
     172             :         void    enableDynamicBorderColor( );
     173             :         /// disables dynamic border color for the controls
     174             :         void    disableDynamicBorderColor( );
     175             : 
     176             :         /** sets a color to be used for a given status
     177             :             @param _nStatus
     178             :                 the status which the color should be applied for. Must not be CONTROL_STATUS_NONE
     179             :             @param _nColor
     180             :                 the color to apply for the given status
     181             :         */
     182             :         void    setStatusColor( ControlStatus _nStatus, sal_Int32 _nColor );
     183             : 
     184             :         /** restores all colors of all controls where we possibly changed them
     185             :         */
     186             :         void    restoreAll();
     187             : 
     188             :     private:
     189             :         /** called when a control got one of the two possible stati (focused, and hovered with the mouse)
     190             :             @param _rxControl
     191             :                 the control which gained the status
     192             :             @param _rControlData
     193             :                 the control's status data, as a reference to our respective member
     194             :         */
     195             :         void    controlStatusGained(
     196             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl,
     197             :                     ControlData& _rControlData
     198             :                 ) SAL_THROW(());
     199             : 
     200             :         /** called when a control lost one of the two possible stati (focused, and hovered with the mouse)
     201             :             @param _rxControl
     202             :                 the control which lost the status
     203             :             @param _rControlData
     204             :                 the control's status data, as a reference to our respective member
     205             :         */
     206             :         void    controlStatusLost( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl, ControlData& _rControlData ) SAL_THROW(());
     207             : 
     208             :         /** determines whether the border of a given peer can be colored
     209             :             @param _rxPeer
     210             :                 the peer to examine. Must not be <NULL/>
     211             :         */
     212             :         bool    canColorBorder( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclWindowPeer >& _rxPeer );
     213             : 
     214             :         /** determines the status of the given control
     215             :         */
     216             :         ControlStatus   getControlStatus( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ) SAL_THROW(());
     217             : 
     218             :         /** retrieves the color associated with a given ControlStatus
     219             :             @param _eStatus
     220             :                 the status of the control. Must not be <member>ControlStatus::none</member>
     221             :         */
     222             :         sal_Int32       getControlColorByStatus( ControlStatus _eStatus );
     223             : 
     224             :         /** sets the border color for a given control, depending on its status
     225             :             @param _rxControl
     226             :                 the control to set the border color for. Must not be <NULL/>
     227             :             @param _rxPeer
     228             :                 the peer of the control, to be passed herein for optimization the caller usually needs it, anyway).
     229             :                 Must not be <NULL/>
     230             :             @param _rFallback
     231             :                 the color/type to use when the control has the status CONTROL_STATUS_NONE
     232             :         */
     233             :         void            updateBorderStyle(
     234             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl,
     235             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclWindowPeer >& _rxPeer,
     236             :                             const BorderDescriptor& _rFallback
     237             :                         ) SAL_THROW(());
     238             : 
     239             :         /** determines the to-be-remembered original border color and type for a control
     240             : 
     241             :             The method also takes into account that the control may currently have an overwritten
     242             :             border style
     243             : 
     244             :             @param _rxControl
     245             :                 the control to examine. Must not be <NULL/>, and have a non-<NULL/> peer
     246             :         */
     247             :         void determineOriginalBorderStyle(
     248             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl,
     249             :                     BorderDescriptor& _rData
     250             :                 ) const;
     251             :     };
     252             : 
     253             : //........................................................................
     254             : } // namespace svxform
     255             : //........................................................................
     256             : 
     257             : #endif // SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX
     258             : 
     259             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10