tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / svx / source / inc / frmselimpl.hxx
blob79df99cfb1504e8c6459ae476d69525e2956ba23
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_SOURCE_INC_FRMSELIMPL_HXX
21 #define INCLUDED_SVX_SOURCE_INC_FRMSELIMPL_HXX
23 #include <vcl/virdev.hxx>
24 #include <vcl/image.hxx>
25 #include <svx/frmsel.hxx>
26 #include <svx/framelink.hxx>
27 #include <svx/framelinkarray.hxx>
28 #include <editeng/borderline.hxx>
30 namespace svx {
32 namespace a11y {
33 class AccFrameSelector;
34 class AccFrameSelectorChild;
37 class FrameBorder
39 public:
40 explicit FrameBorder(FrameBorderType eType);
41 static double GetDefaultPatternScale() { return 0.05; }
43 FrameBorderType GetType() const
45 return meType;
48 bool IsEnabled() const
50 return mbEnabled;
52 void Enable(FrameSelFlags nFlags);
54 FrameBorderState GetState() const
56 return meState;
58 void SetState(FrameBorderState eState);
60 bool IsSelected() const { return mbSelected; }
61 void Select( bool bSelect ) { mbSelected = bSelect; }
63 const editeng::SvxBorderLine& GetCoreStyle() const { return maCoreStyle; }
64 void SetCoreStyle( const editeng::SvxBorderLine* pStyle );
66 void SetUIColorPrim( const Color& rColor ) {maUIStyle.SetColorPrim( rColor ); }
67 void SetUIColorSecn( const Color& rColor ) {maUIStyle.SetColorSecn( rColor ); }
68 const frame::Style& GetUIStyle() const { return maUIStyle; }
70 void ClearFocusArea() { maFocusArea.Clear(); }
71 void AddFocusPolygon( const tools::Polygon& rFocus );
72 void MergeFocusToPolyPolygon( tools::PolyPolygon& rPPoly ) const;
74 void ClearClickArea() { maClickArea.Clear(); }
75 void AddClickRect( const tools::Rectangle& rRect );
76 bool ContainsClickPoint( const Point& rPos ) const;
77 tools::Rectangle GetClickBoundRect() const;
79 void SetKeyboardNeighbors(FrameBorderType eLeft, FrameBorderType eRight,
80 FrameBorderType eTop, FrameBorderType eBottom);
81 FrameBorderType GetKeyboardNeighbor( sal_uInt16 nKeyCode ) const;
83 private:
84 const FrameBorderType meType; /// Frame border type (position in control).
85 FrameBorderState meState; /// Frame border state (on/off/don't care).
86 editeng::SvxBorderLine maCoreStyle; /// Core style from application.
87 frame::Style maUIStyle; /// Internal style to draw lines.
88 FrameBorderType meKeyLeft; /// Left neighbor for keyboard control.
89 FrameBorderType meKeyRight; /// Right neighbor for keyboard control.
90 FrameBorderType meKeyTop; /// Upper neighbor for keyboard control.
91 FrameBorderType meKeyBottom; /// Lower neighbor for keyboard control.
92 tools::PolyPolygon maFocusArea; /// Focus drawing areas.
93 tools::PolyPolygon maClickArea; /// Mouse click areas.
94 bool mbEnabled : 1; /// true = Border enabled in control.
95 bool mbSelected : 1; /// true = Border selected in control.
99 typedef std::vector< FrameBorder* > FrameBorderPtrVec;
101 struct FrameSelectorImpl
103 FrameSelector& mrFrameSel; /// The control itself.
104 ScopedVclPtr<VirtualDevice> mpVirDev; /// For all buffered drawing operations.
105 std::vector<Image> maArrows; /// Arrows in current system colors.
106 Color maBackCol; /// Background color.
107 Color maArrowCol; /// Selection arrow color.
108 Color maMarkCol; /// Selection marker color.
109 Color maHCLineCol; /// High contrast line color.
110 Point maVirDevPos; /// Position of virtual device in the control.
112 FrameBorder maLeft; /// All data of left frame border.
113 FrameBorder maRight; /// All data of right frame border.
114 FrameBorder maTop; /// All data of top frame border.
115 FrameBorder maBottom; /// All data of bottom frame border.
116 FrameBorder maHor; /// All data of inner horizontal frame border.
117 FrameBorder maVer; /// All data of inner vertical frame border.
118 FrameBorder maTLBR; /// All data of top-left to bottom-right frame border.
119 FrameBorder maBLTR; /// All data of bottom-left to top-right frame border.
120 editeng::SvxBorderLine maCurrStyle; /// Current style and color for new borders.
121 frame::Array maArray; /// Frame link array to draw an array of frame borders.
123 FrameSelFlags mnFlags; /// Flags for enabled frame borders.
124 FrameBorderPtrVec maAllBorders; /// Pointers to all frame borders.
125 FrameBorderPtrVec maEnabBorders; /// Pointers to enables frame borders.
126 Link<LinkParamNone*,void> maSelectHdl; /// Selection handler.
128 tools::Long mnCtrlSize; /// Size of the control (always square).
129 tools::Long mnArrowSize; /// Size of an arrow image.
130 tools::Long mnLine1; /// Middle of left/top frame borders.
131 tools::Long mnLine2; /// Middle of inner frame borders.
132 tools::Long mnLine3; /// Middle of right/bottom frame borders.
133 tools::Long mnFocusOffs; /// Offset from frame border middle to draw focus.
135 bool mbHor; /// true = Inner horizontal frame border enabled.
136 bool mbVer; /// true = Inner vertical frame border enabled.
137 bool mbTLBR; /// true = Top-left to bottom-right frame border enabled.
138 bool mbBLTR; /// true = Bottom-left to top-right frame border enabled.
139 bool mbFullRepaint; /// Used for repainting (false = only copy virtual device).
140 bool mbAutoSelect; /// true = Auto select a frame border, if focus reaches control.
141 bool mbHCMode; /// true = High contrast mode.
143 std::vector<rtl::Reference<a11y::AccFrameSelectorChild>>
144 maChildVec; /// Pointers to accessibility objects for frame borders.
145 explicit FrameSelectorImpl( FrameSelector& rFrameSel );
146 ~FrameSelectorImpl();
148 // initialization
149 /** Initializes the control, enables/disables frame borders according to flags. */
150 void Initialize( FrameSelFlags nFlags );
152 /** Fills all color members from current style settings. */
153 void InitColors();
154 /** Creates the image list with selection arrows regarding current style settings. */
155 void InitArrowImageList();
156 /** Initializes global coordinates. */
157 void InitGlobalGeometry();
158 /** Initializes coordinates of all frame borders. */
159 void InitBorderGeometry();
160 /** Draws the entire control into the internal virtual device. */
161 void InitVirtualDevice();
162 /** call this to recalculate based on parent size */
163 void sizeChanged();
165 // frame border access
166 /** Returns the object representing the specified frame border. */
167 const FrameBorder& GetBorder( FrameBorderType eBorder ) const;
168 /** Returns the object representing the specified frame border (write access). */
169 FrameBorder& GetBorderAccess( FrameBorderType eBorder );
171 // drawing
172 /** Draws the background of the entire control (the gray areas between borders). */
173 void DrawBackground();
175 /** Draws selection arrows for the specified frame border. */
176 void DrawArrows( const FrameBorder& rBorder );
178 /** Returns the color that has to be used to draw a frame border. */
179 Color GetDrawLineColor( const Color& rColor ) const;
180 /** Draws all frame borders. */
181 void DrawAllFrameBorders();
183 /** Draws all contents of the control. */
184 void DrawVirtualDevice();
185 /** Copies contents of the virtual device to the control. */
186 void CopyVirDevToControl(vcl::RenderContext& rRenderContext);
188 /** Draws tracking rectangles for all selected frame borders. */
189 void DrawAllTrackingRects(vcl::RenderContext& rRenderContext);
191 /** Converts a mouse position to the virtual device position. */
192 Point GetDevPosFromMousePos( const Point& rMousePos ) const;
194 /** Invalidates the control.
195 @param bFullRepaint true = Full repaint; false = update selection only. */
196 void DoInvalidate( bool bFullRepaint );
198 // frame border state and style
199 /** Sets the state of the specified frame border. */
200 void SetBorderState( FrameBorder& rBorder, FrameBorderState eState );
201 /** Sets the core style of the specified frame border, or hides the frame border, if pStyle is 0. */
202 void SetBorderCoreStyle( FrameBorder& rBorder, const editeng::SvxBorderLine* pStyle );
204 /** Changes the state of a frame border after a control event (mouse/keyboard). */
205 void ToggleBorderState( FrameBorder& rBorder );
207 // frame border selection
208 /** Selects a frame border and schedules redraw. */
209 void SelectBorder( FrameBorder& rBorder, bool bSelect );
210 /** Grabs focus without auto-selection of a frame border, if no border selected. */
211 void SilentGrabFocus();
213 /** Returns true, if all selected frame borders are equal (or if nothing is selected). */
214 bool SelectedBordersEqual() const;
218 /** Dummy predicate for frame border iterators to use all borders in a container. */
219 struct FrameBorderDummy_Pred
221 bool operator()( const FrameBorder* ) const { return true; }
224 /** Predicate for frame border iterators to use only visible borders in a container. */
225 struct FrameBorderVisible_Pred
227 bool operator()( const FrameBorder* pBorder ) const { return pBorder->GetState() == FrameBorderState::Show; }
230 /** Predicate for frame border iterators to use only selected borders in a container. */
231 struct FrameBorderSelected_Pred
233 bool operator()( const FrameBorder* pBorder ) const { return pBorder->IsSelected(); }
236 /** Template class for all types of frame border iterators. */
237 template< typename Cont, typename Iter, typename Pred >
238 class FrameBorderIterBase
240 public:
241 typedef Cont container_type;
242 typedef Iter iterator_type;
243 typedef typename Cont::value_type value_type;
244 typedef FrameBorderIterBase<Cont, Iter, Pred> this_type;
246 explicit FrameBorderIterBase( container_type& rCont );
247 bool Is() const { return maIt != maEnd; }
248 this_type& operator++();
249 value_type operator*() const { return *maIt; }
251 private:
252 iterator_type maIt;
253 iterator_type maEnd;
254 Pred maPred;
257 /** Iterator for constant svx::FrameBorder containers, iterates over all borders. */
258 typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderDummy_Pred >
259 FrameBorderCIter;
261 /** Iterator for mutable svx::FrameBorder containers, iterates over all borders. */
262 typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderDummy_Pred >
263 FrameBorderIter;
265 /** Iterator for constant svx::FrameBorder containers, iterates over visible borders. */
266 typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderVisible_Pred >
267 VisFrameBorderCIter;
269 /** Iterator for mutable svx::FrameBorder containers, iterates over visible borders. */
270 typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderVisible_Pred >
271 VisFrameBorderIter;
273 /** Iterator for constant svx::FrameBorder containers, iterates over selected borders. */
274 typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderSelected_Pred >
275 SelFrameBorderCIter;
277 /** Iterator for mutable svx::FrameBorder containers, iterates over selected borders. */
278 typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderSelected_Pred >
279 SelFrameBorderIter;
283 #endif
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */