fix build
[LibreOffice.git] / include / svx / frmsel.hxx
blob9264a36d8f2a32e1d8dbfe39e12bde1927bd0eb6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_FRMSEL_HXX
21 #define INCLUDED_SVX_FRMSEL_HXX
23 #include <memory>
24 #include <vcl/customweld.hxx>
25 #include <editeng/borderline.hxx>
26 #include <svx/framebordertype.hxx>
27 #include <svx/svxdllapi.h>
28 #include <o3tl/typed_flags_set.hxx>
30 class Color;
32 enum class FrameSelFlags
34 NONE = 0x0000,
35 /** If set, the left frame border is enabled. */
36 Left = 0x0001,
37 /** If set, the right frame border is enabled. */
38 Right = 0x0002,
39 /** If set, the top frame border is enabled. */
40 Top = 0x0004,
41 /** If set, the bottom frame border is enabled. */
42 Bottom = 0x0008,
43 /** If set, the inner horizontal frame border is enabled. */
44 InnerHorizontal = 0x0010,
45 /** If set, the inner vertical frame border is enabled. */
46 InnerVertical = 0x0020,
47 /** If set, the top-left to bottom-right diagonal frame border is enabled. */
48 DiagonalTLBR = 0x0040,
49 /** If set, the bottom-left to top-right diagonal frame border is enabled. */
50 DiagonalBLTR = 0x0080,
52 /** If set, all four outer frame borders are enabled. */
53 Outer = Left | Right | Top | Bottom,
55 /** If set, all frame borders will support the don't care state. */
56 DontCare = 0x0100
58 namespace o3tl
60 template<> struct typed_flags<FrameSelFlags> : is_typed_flags<FrameSelFlags, 0x1ff> {};
63 namespace svx {
65 struct FrameSelectorImpl;
66 namespace a11y { class AccFrameSelectorChild; }
68 /** All possible states of a frame border. */
69 enum class FrameBorderState
71 Show, /// Frame border has a visible style.
72 Hide, /// Frame border is hidden (off).
73 DontCare /// Frame border is in don't care state (if enabled).
77 namespace a11y
79 class AccFrameSelector;
82 class SAL_WARN_UNUSED SVX_DLLPUBLIC FrameSelector final : public weld::CustomWidgetController
84 public:
85 FrameSelector();
86 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
87 virtual ~FrameSelector() override;
89 /** Initializes the control, enables/disables frame borders according to flags. */
90 void Initialize( FrameSelFlags nFlags );
92 // enabled frame borders
94 /** Returns true, if the specified frame border is enabled. */
95 bool IsBorderEnabled( FrameBorderType eBorder ) const;
96 /** Returns the number of enabled frame borders. */
97 sal_Int32 GetEnabledBorderCount() const;
98 /** Returns the border type from the passed index (counts only enabled frame borders). */
99 FrameBorderType GetEnabledBorderType( sal_Int32 nIndex ) const;
101 // frame border state and style
103 /** Returns true, if the control supports the "don't care" frame border state. */
104 bool SupportsDontCareState() const;
106 /** Returns the state (visible/hidden/don't care) of the specified frame border. */
107 FrameBorderState GetFrameBorderState( FrameBorderType eBorder ) const;
108 /** Returns the style of the specified frame border, if it is visible. */
109 const editeng::SvxBorderLine* GetFrameBorderStyle( FrameBorderType eBorder ) const;
111 /** Shows the specified frame border using the passed style, or hides it, if pStyle is 0. */
112 void ShowBorder( FrameBorderType eBorder, const editeng::SvxBorderLine* pStyle );
113 /** Sets the specified frame border to "don't care" state. */
114 void SetBorderDontCare( FrameBorderType eBorder );
116 /** Returns true, if any enabled frame border has a visible style (not "don't care"). */
117 bool IsAnyBorderVisible() const;
118 /** Hides all enabled frame borders. */
119 void HideAllBorders();
121 /** Returns true, if all visible frame borders have equal widths.
122 @descr Ignores hidden and "don't care" frame borders. On success,
123 returns the width in the passed parameter. */
124 bool GetVisibleWidth( tools::Long& rnWidth, SvxBorderLineStyle& rnStyle ) const;
125 /** Returns true, if all visible frame borders have equal color.
126 @descr Ignores hidden and "don't care" frame borders. On success,
127 returns the color in the passed parameter. */
128 bool GetVisibleColor( Color& rColor ) const;
130 // frame border selection
132 /** Returns the current selection handler. */
133 const Link<LinkParamNone*,void>& GetSelectHdl() const;
134 /** Sets the passed handler that is called if the selection of the control changes. */
135 void SetSelectHdl( const Link<LinkParamNone*,void>& rHdl );
137 /** Returns true, if the specified frame border is selected. */
138 bool IsBorderSelected( FrameBorderType eBorder ) const;
139 /** Selects or deselects the specified frame border. */
140 void SelectBorder( FrameBorderType eBorder );
141 /** Returns true, if any of the enabled frame borders is selected. */
142 bool IsAnyBorderSelected() const;
143 /** Selects or deselects all frame borders. */
144 void SelectAllBorders( bool bSelect );
145 /** Deselects all frame borders. */
146 void DeselectAllBorders() { SelectAllBorders( false ); }
148 /** Selects or deselects all visible frame borders (ignores hidden and "don't care" borders). */
149 void SelectAllVisibleBorders();
151 /** Sets the passed line widths to all selected frame borders (in twips). */
152 void SetStyleToSelection( tools::Long nWidth, SvxBorderLineStyle nStyle );
153 /** Sets the passed color to all selected frame borders. */
154 void SetColorToSelection(const Color& rColor, model::ComplexColor const& rComplexColor);
156 SvxBorderLineStyle getCurrentStyleLineStyle() const;
158 // accessibility
160 css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
161 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
162 a11yrelationset get_accessible_relation_set() const { return GetDrawingArea()->get_accessible_relation_set(); }
164 /** Returns the accessibility child object of the specified frame border (if enabled). */
165 rtl::Reference< a11y::AccFrameSelectorChild >
166 GetChildAccessible( FrameBorderType eBorder );
167 /** Returns the accessibility child object with specified index (counts enabled frame borders only). */
168 css::uno::Reference< css::accessibility::XAccessible >
169 GetChildAccessible( sal_Int32 nIndex );
170 /** Returns the accessibility child object at the specified position (relative to control). */
171 css::uno::Reference< css::accessibility::XAccessible >
172 GetChildAccessible( const Point& rPos );
174 /** Returns the bounding rectangle of the specified frame border (if enabled). */
175 tools::Rectangle GetClickBoundRect( FrameBorderType eBorder ) const;
177 private:
178 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
179 virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
180 virtual bool KeyInput( const KeyEvent& rKEvt ) override;
181 virtual void GetFocus() override;
182 virtual void LoseFocus() override;
183 virtual void StyleUpdated() override;
184 virtual void Resize() override;
186 rtl::Reference<a11y::AccFrameSelector> mxAccess; /// Pointer to accessibility object of the control.
187 std::unique_ptr< FrameSelectorImpl > mxImpl;
192 #endif
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */