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>
28#include <tools/color.hxx>
29
30#include <set>
31#include <utility>
32
33namespace com::sun::star::form::validation { class XValidatableFormComponent; }
34
35enum class ControlStatus {
36 NONE = 0x00,
37 Focused = 0x01,
38 MouseHover = 0x02,
39 Invalid = 0x04
40};
41namespace o3tl {
42 template<> struct typed_flags<ControlStatus> : is_typed_flags<ControlStatus, 0x07> {};
43}
44
45
46namespace svxform
47{
48
49
51 {
52 sal_Int16 nBorderType;
54
56 :nBorderType( css::awt::VisualEffect::FLAT )
57 {
58 }
59 };
60
62 {
63 sal_Int16 nUnderlineType;
65
67 :nUnderlineType( css::awt::FontUnderline::NONE )
68 {
69 }
70
71 UnderlineDescriptor( sal_Int16 _nUnderlineType, Color _nUnderlineColor )
72 :nUnderlineType( _nUnderlineType )
73 ,nUnderlineColor( _nUnderlineColor )
74 {
75 }
76 };
77
79 {
80 css::uno::Reference< css::awt::XControl > xControl;
82
84 ControlData( css::uno::Reference< css::awt::XControl > _xControl )
85 :xControl(std::move( _xControl ))
86 {
87 }
88 };
89
90
91 //= ControlBorderManager
92
101 {
102 private:
104 {
105 bool operator()( const ControlData& _rLHS, const ControlData& _rRHS ) const
106 {
107 return _rLHS.xControl.get() < _rRHS.xControl.get();
108 }
109 };
110
111 typedef ::std::set< ControlData, ControlDataCompare > ControlBag;
112 typedef ::std::set< css::uno::Reference< css::awt::XVclWindowPeer > > PeerBag;
113
116
120
121
122 // attributes
127
128 public:
131
132 public:
133 void focusGained( const css::uno::Reference< css::uno::XInterface >& _rxControl );
134 void focusLost( const css::uno::Reference< css::uno::XInterface >& _rxControl );
135 void mouseEntered( const css::uno::Reference< css::uno::XInterface >& _rxControl );
136 void mouseExited( const css::uno::Reference< css::uno::XInterface >& _rxControl );
137
138 void validityChanged(
139 const css::uno::Reference< css::awt::XControl >& _rxControl,
140 const css::uno::Reference< css::form::validation::XValidatableFormComponent >& _rxValidatable
141 );
142
147
154 void setStatusColor( ControlStatus _nStatus, Color _nColor );
155
158 void restoreAll();
159
160 private:
168 const css::uno::Reference< css::uno::XInterface >& _rxControl,
169 ControlData& _rControlData
170 );
171
178 void controlStatusLost( const css::uno::Reference< css::uno::XInterface >& _rxControl, ControlData& _rControlData );
179
184 bool canColorBorder( const css::uno::Reference< css::awt::XVclWindowPeer >& _rxPeer );
185
188 ControlStatus getControlStatus( const css::uno::Reference< css::awt::XControl >& _rxControl );
189
195
206 const css::uno::Reference< css::awt::XControl >& _rxControl,
207 const css::uno::Reference< css::awt::XVclWindowPeer >& _rxPeer,
208 const BorderDescriptor& _rFallback
209 );
210
220 const css::uno::Reference< css::awt::XControl >& _rxControl,
221 BorderDescriptor& _rData
222 ) const;
223 };
224
225
226}
227
228
229#endif // INCLUDED_SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX
230
231/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
manages the dynamic border color for form controls
void enableDynamicBorderColor()
enables dynamic border color for the controls
ControlStatus getControlStatus(const css::uno::Reference< css::awt::XControl > &_rxControl)
determines the status of the given control
void setStatusColor(ControlStatus _nStatus, Color _nColor)
sets a color to be used for a given status
::std::set< ControlData, ControlDataCompare > ControlBag
void focusGained(const css::uno::Reference< css::uno::XInterface > &_rxControl)
void mouseEntered(const css::uno::Reference< css::uno::XInterface > &_rxControl)
Color getControlColorByStatus(ControlStatus _eStatus) const
retrieves the color associated with a given ControlStatus
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)
bool canColorBorder(const css::uno::Reference< css::awt::XVclWindowPeer > &_rxPeer)
determines whether the border of a given peer can be colored
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 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
::std::set< css::uno::Reference< css::awt::XVclWindowPeer > > PeerBag
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 validityChanged(const css::uno::Reference< css::awt::XControl > &_rxControl, const css::uno::Reference< css::form::validation::XValidatableFormComponent > &_rxValidatable)
void restoreAll()
restores all colors of all controls where we possibly changed them
void focusLost(const css::uno::Reference< css::uno::XInterface > &_rxControl)
void disableDynamicBorderColor()
disables dynamic border color for the controls
void mouseExited(const css::uno::Reference< css::uno::XInterface > &_rxControl)
NONE
class FmSearchEngine - Impl class for FmSearchDialog
bool operator()(const ControlData &_rLHS, const ControlData &_rRHS) const
css::uno::Reference< css::awt::XControl > xControl
ControlData(css::uno::Reference< css::awt::XControl > _xControl)
UnderlineDescriptor(sal_Int16 _nUnderlineType, Color _nUnderlineColor)