LibreOffice Module svx (master)  1
fmcontrolbordermanager.hxx
Go to the documentation of this file.
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 INCLUDED_SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX
21 #define INCLUDED_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 <o3tl/typed_flags_set.hxx>
28 #include <tools/color.hxx>
29 
30 #include <set>
31 
32 namespace com::sun::star::form::validation { class XValidatableFormComponent; }
33 
34 enum class ControlStatus {
35  NONE = 0x00,
36  Focused = 0x01,
37  MouseHover = 0x02,
38  Invalid = 0x04
39 };
40 namespace o3tl {
41  template<> struct typed_flags<ControlStatus> : is_typed_flags<ControlStatus, 0x07> {};
42 }
43 
44 
45 namespace svxform
46 {
47 
48 
50  {
51  sal_Int16 nBorderType;
53 
55  :nBorderType( css::awt::VisualEffect::FLAT )
56  {
57  }
58  };
59 
61  {
62  sal_Int16 nUnderlineType;
64 
66  :nUnderlineType( css::awt::FontUnderline::NONE )
67  {
68  }
69 
70  UnderlineDescriptor( sal_Int16 _nUnderlineType, Color _nUnderlineColor )
71  :nUnderlineType( _nUnderlineType )
72  ,nUnderlineColor( _nUnderlineColor )
73  {
74  }
75  };
76 
78  {
79  css::uno::Reference< css::awt::XControl > xControl;
81 
83  ControlData( const css::uno::Reference< css::awt::XControl >& _rxControl )
84  :xControl( _rxControl )
85  {
86  }
87  };
88 
89 
90  //= ControlBorderManager
91 
100  {
101  private:
103  {
104  bool operator()( const ControlData& _rLHS, const ControlData& _rRHS ) const
105  {
106  return _rLHS.xControl.get() < _rRHS.xControl.get();
107  }
108  };
109 
110  typedef ::std::set< ControlData, ControlDataCompare > ControlBag;
111  typedef ::std::set< css::uno::Reference< css::awt::XVclWindowPeer > > PeerBag;
112 
115 
118  ControlBag m_aInvalidControls;
119 
120 
121  // attributes
126 
127  public:
130 
131  public:
132  void focusGained( const css::uno::Reference< css::uno::XInterface >& _rxControl );
133  void focusLost( const css::uno::Reference< css::uno::XInterface >& _rxControl );
134  void mouseEntered( const css::uno::Reference< css::uno::XInterface >& _rxControl );
135  void mouseExited( const css::uno::Reference< css::uno::XInterface >& _rxControl );
136 
137  void validityChanged(
138  const css::uno::Reference< css::awt::XControl >& _rxControl,
139  const css::uno::Reference< css::form::validation::XValidatableFormComponent >& _rxValidatable
140  );
141 
143  void enableDynamicBorderColor( );
146 
153  void setStatusColor( ControlStatus _nStatus, Color _nColor );
154 
157  void restoreAll();
158 
159  private:
166  void controlStatusGained(
167  const css::uno::Reference< css::uno::XInterface >& _rxControl,
168  ControlData& _rControlData
169  );
170 
177  void controlStatusLost( const css::uno::Reference< css::uno::XInterface >& _rxControl, ControlData& _rControlData );
178 
183  bool canColorBorder( const css::uno::Reference< css::awt::XVclWindowPeer >& _rxPeer );
184 
187  ControlStatus getControlStatus( const css::uno::Reference< css::awt::XControl >& _rxControl );
188 
194 
204  void updateBorderStyle(
205  const css::uno::Reference< css::awt::XControl >& _rxControl,
206  const css::uno::Reference< css::awt::XVclWindowPeer >& _rxPeer,
207  const BorderDescriptor& _rFallback
208  );
209 
219  const css::uno::Reference< css::awt::XControl >& _rxControl,
220  BorderDescriptor& _rData
221  ) const;
222  };
223 
224 
225 }
226 
227 
228 #endif // INCLUDED_SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX
229 
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ControlData(const css::uno::Reference< css::awt::XControl > &_rxControl)
::std::set< css::uno::Reference< css::awt::XVclWindowPeer > > PeerBag
void mouseExited(const css::uno::Reference< css::uno::XInterface > &_rxControl)
exports com.sun.star. awt
void focusGained(const css::uno::Reference< css::uno::XInterface > &_rxControl)
ControlStatus getControlStatus(const css::uno::Reference< css::awt::XControl > &_rxControl)
determines the status of the given control
NONE
bool canColorBorder(const css::uno::Reference< css::awt::XVclWindowPeer > &_rxPeer)
determines whether the border of a given peer can be colored
void updateBorderStyle(const css::uno::Reference< css::awt::XControl > &_rxControl, const css::uno::Reference< css::awt::XVclWindowPeer > &_rxPeer, const BorderDescriptor &_rFallback)
sets the border color for a given control, depending on its status
bool operator()(const ControlData &_rLHS, const ControlData &_rRHS) const
void determineOriginalBorderStyle(const css::uno::Reference< css::awt::XControl > &_rxControl, BorderDescriptor &_rData) const
determines the to-be-remembered original border color and type for a control
void disableDynamicBorderColor()
disables dynamic border color for the controls
void restoreAll()
restores all colors of all controls where we possibly changed them
::std::set< ControlData, ControlDataCompare > ControlBag
void controlStatusGained(const css::uno::Reference< css::uno::XInterface > &_rxControl, ControlData &_rControlData)
called when a control got one of the two possible statuses (focused, and hovered with the mouse) ...
void enableDynamicBorderColor()
enables dynamic border color for the controls
void mouseEntered(const css::uno::Reference< css::uno::XInterface > &_rxControl)
void validityChanged(const css::uno::Reference< css::awt::XControl > &_rxControl, const css::uno::Reference< css::form::validation::XValidatableFormComponent > &_rxValidatable)
manages the dynamic border color for form controls
void controlStatusLost(const css::uno::Reference< css::uno::XInterface > &_rxControl, ControlData &_rControlData)
called when a control lost one of the two possible statuses (focused, and hovered with the mouse) ...
void setStatusColor(ControlStatus _nStatus, Color _nColor)
sets a color to be used for a given status
class FmSearchEngine - Impl class for FmSearchDialog
void focusLost(const css::uno::Reference< css::uno::XInterface > &_rxControl)
UnderlineDescriptor(sal_Int16 _nUnderlineType, Color _nUnderlineColor)
Color getControlColorByStatus(ControlStatus _eStatus)
retrieves the color associated with a given ControlStatus
css::uno::Reference< css::awt::XControl > xControl