LibreOffice Module svx (master)  1
frmselimpl.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_FRMSELIMPL_HXX
21 #define INCLUDED_SVX_SOURCE_INC_FRMSELIMPL_HXX
22 
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>
29 
30 namespace svx {
31 
32 namespace a11y {
33  class AccFrameSelector;
34  class AccFrameSelectorChild;
35 }
36 
38 {
39 public:
41  static double GetDefaultPatternScale() { return 0.05; }
42 
44  {
45  return meType;
46  }
47 
48  bool IsEnabled() const
49  {
50  return mbEnabled;
51  }
52  void Enable(FrameSelFlags nFlags);
53 
55  {
56  return meState;
57  }
58  void SetState(FrameBorderState eState);
59 
60  bool IsSelected() const { return mbSelected; }
61  void Select( bool bSelect ) { mbSelected = bSelect; }
62 
63  const editeng::SvxBorderLine& GetCoreStyle() const { return maCoreStyle; }
64  void SetCoreStyle( const editeng::SvxBorderLine* pStyle );
65 
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; }
69 
71  void AddFocusPolygon( const tools::Polygon& rFocus );
72  void MergeFocusToPolyPolygon( tools::PolyPolygon& rPPoly ) const;
73 
75  void AddClickRect( const tools::Rectangle& rRect );
76  bool ContainsClickPoint( const Point& rPos ) const;
78 
80  FrameBorderType eTop, FrameBorderType eBottom);
81  FrameBorderType GetKeyboardNeighbor( sal_uInt16 nKeyCode ) const;
82 
83 private:
94  bool mbEnabled : 1;
95  bool mbSelected : 1;
96 };
97 
98 
99 typedef std::vector< FrameBorder* > FrameBorderPtrVec;
100 
102 {
105  std::vector<Image> maArrows;
111 
122 
124  FrameBorderPtrVec maAllBorders;
125  FrameBorderPtrVec maEnabBorders;
127 
128  long mnCtrlSize;
129  long mnArrowSize;
130  long mnLine1;
131  long mnLine2;
132  long mnLine3;
133  long mnFocusOffs;
134 
135  bool mbHor;
136  bool mbVer;
137  bool mbTLBR;
138  bool mbBLTR;
141  bool mbHCMode;
142 
143  std::vector<rtl::Reference<a11y::AccFrameSelectorChild>>
145  explicit FrameSelectorImpl( FrameSelector& rFrameSel );
147 
148  // initialization
150  void Initialize( FrameSelFlags nFlags );
151 
153  void InitColors();
155  void InitArrowImageList();
157  void InitGlobalGeometry();
159  void InitBorderGeometry();
161  void InitVirtualDevice();
163  void sizeChanged();
164 
165  // frame border access
167  const FrameBorder& GetBorder( FrameBorderType eBorder ) const;
170 
171  // drawing
173  void DrawBackground();
174 
176  void DrawArrows( const FrameBorder& rBorder );
177 
179  Color GetDrawLineColor( const Color& rColor ) const;
181  void DrawAllFrameBorders();
182 
184  void DrawVirtualDevice();
186  void CopyVirDevToControl(vcl::RenderContext& rRenderContext);
187 
189  void DrawAllTrackingRects(vcl::RenderContext& rRenderContext);
190 
192  Point GetDevPosFromMousePos( const Point& rMousePos ) const;
193 
196  void DoInvalidate( bool bFullRepaint );
197 
198  // frame border state and style
200  void SetBorderState( FrameBorder& rBorder, FrameBorderState eState );
202  void SetBorderCoreStyle( FrameBorder& rBorder, const editeng::SvxBorderLine* pStyle );
203 
205  void ToggleBorderState( FrameBorder& rBorder );
206 
207  // frame border selection
209  void SelectBorder( FrameBorder& rBorder, bool bSelect );
211  void SilentGrabFocus();
212 
214  bool SelectedBordersEqual() const;
215 };
216 
217 
220 {
221  bool operator()( const FrameBorder* ) const { return true; }
222 };
223 
226 {
227  bool operator()( const FrameBorder* pBorder ) const { return pBorder->GetState() == FrameBorderState::Show; }
228 };
229 
232 {
233  bool operator()( const FrameBorder* pBorder ) const { return pBorder->IsSelected(); }
234 };
235 
237 template< typename Cont, typename Iter, typename Pred >
239 {
240 public:
241  typedef Cont container_type;
242  typedef Iter iterator_type;
243  typedef typename Cont::value_type value_type;
245 
246  explicit FrameBorderIterBase( container_type& rCont );
247  bool Is() const { return maIt != maEnd; }
248  this_type& operator++();
249  value_type operator*() const { return *maIt; }
250 
251 private:
252  iterator_type maIt;
253  iterator_type maEnd;
254  Pred maPred;
255 };
256 
260 
264 
268 
272 
276 
280 
281 }
282 
283 #endif
284 
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void MergeFocusToPolyPolygon(tools::PolyPolygon &rPPoly) const
Definition: frmsel.cxx:165
static double GetDefaultPatternScale()
Definition: frmselimpl.hxx:41
Cont::value_type value_type
Definition: frmselimpl.hxx:243
FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderSelected_Pred > SelFrameBorderIter
Iterator for mutable svx::FrameBorder containers, iterates over selected borders. ...
Definition: frmselimpl.hxx:279
FrameBorderPtrVec maAllBorders
Flags for enabled frame borders.
Definition: frmselimpl.hxx:124
bool mbAutoSelect
Used for repainting (false = only copy virtual device).
Definition: frmselimpl.hxx:140
void ClearFocusArea()
Definition: frmselimpl.hxx:70
std::vector< FrameBorder * > FrameBorderPtrVec
Definition: frmselimpl.hxx:99
bool operator()(const FrameBorder *pBorder) const
Definition: frmselimpl.hxx:233
const frame::Style & GetUIStyle() const
Definition: frmselimpl.hxx:68
bool IsSelected() const
Definition: frmselimpl.hxx:60
FrameBorderPtrVec maEnabBorders
Pointers to all frame borders.
Definition: frmselimpl.hxx:125
void InitGlobalGeometry()
Initializes global coordinates.
Definition: frmsel.cxx:348
Color maHCLineCol
Selection marker color.
Definition: frmselimpl.hxx:109
void DrawBackground()
Draws the background of the entire control (the gray areas between borders).
Definition: frmsel.cxx:536
Color maBackCol
Arrows in current system colors.
Definition: frmselimpl.hxx:106
void SetBorderCoreStyle(FrameBorder &rBorder, const editeng::SvxBorderLine *pStyle)
Sets the core style of the specified frame border, or hides the frame border, if pStyle is 0...
Definition: frmsel.cxx:763
Predicate for frame border iterators to use only selected borders in a container. ...
Definition: frmselimpl.hxx:231
Dummy predicate for frame border iterators to use all borders in a container.
Definition: frmselimpl.hxx:219
ScopedVclPtr< VirtualDevice > mpVirDev
The control itself.
Definition: frmselimpl.hxx:104
void InitBorderGeometry()
Initializes coordinates of all frame borders.
Definition: frmsel.cxx:372
editeng::SvxBorderLine maCurrStyle
All data of bottom-left to top-right frame border.
Definition: frmselimpl.hxx:120
void Initialize(FrameSelFlags nFlags)
Initializes the control, enables/disables frame borders according to flags.
Definition: frmsel.cxx:273
this_type & operator++()
Definition: frmsel.cxx:1266
const editeng::SvxBorderLine & GetCoreStyle() const
Definition: frmselimpl.hxx:63
Color maMarkCol
Selection arrow color.
Definition: frmselimpl.hxx:108
FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderDummy_Pred > FrameBorderCIter
Iterator for constant svx::FrameBorder containers, iterates over all borders.
Definition: frmselimpl.hxx:259
FrameBorderType meKeyLeft
Internal style to draw lines.
Definition: frmselimpl.hxx:88
bool mbFullRepaint
true = Bottom-left to top-right frame border enabled.
Definition: frmselimpl.hxx:139
long mnLine1
Size of an arrow image.
Definition: frmselimpl.hxx:130
void CopyVirDevToControl(vcl::RenderContext &rRenderContext)
Copies contents of the virtual device to the control.
Definition: frmsel.cxx:704
bool mbEnabled
Mouse click areas.
Definition: frmselimpl.hxx:94
FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderVisible_Pred > VisFrameBorderIter
Iterator for mutable svx::FrameBorder containers, iterates over visible borders.
Definition: frmselimpl.hxx:271
long mnLine3
Middle of inner frame borders.
Definition: frmselimpl.hxx:132
Point maVirDevPos
High contrast line color.
Definition: frmselimpl.hxx:110
void sizeChanged()
call this to recalculate based on parent size
Definition: frmsel.cxx:511
long mnFocusOffs
Middle of right/bottom frame borders.
Definition: frmselimpl.hxx:133
value_type operator*() const
Definition: frmselimpl.hxx:249
void SetKeyboardNeighbors(FrameBorderType eLeft, FrameBorderType eRight, FrameBorderType eTop, FrameBorderType eBottom)
Definition: frmsel.cxx:185
FrameBorderIterBase< Cont, Iter, Pred > this_type
Definition: frmselimpl.hxx:244
FrameBorderState meState
Frame border type (position in control).
Definition: frmselimpl.hxx:85
FrameBorderType meKeyBottom
Upper neighbor for keyboard control.
Definition: frmselimpl.hxx:91
void ToggleBorderState(FrameBorder &rBorder)
Changes the state of a frame border after a control event (mouse/keyboard).
Definition: frmsel.cxx:770
bool mbBLTR
true = Top-left to bottom-right frame border enabled.
Definition: frmselimpl.hxx:138
void SetUIColorPrim(const Color &rColor)
Definition: frmselimpl.hxx:66
FrameBorderState
All possible states of a frame border.
Definition: frmsel.hxx:69
const FrameBorderType meType
Definition: frmselimpl.hxx:84
tools::Rectangle GetClickBoundRect() const
Definition: frmsel.cxx:180
frame::Style maUIStyle
Core style from application.
Definition: frmselimpl.hxx:87
void SetCoreStyle(const editeng::SvxBorderLine *pStyle)
Definition: frmsel.cxx:129
void DrawAllFrameBorders()
Draws all frame borders.
Definition: frmsel.cxx:623
FrameBorderState GetState() const
Definition: frmselimpl.hxx:54
const FrameBorder & GetBorder(FrameBorderType eBorder) const
Returns the object representing the specified frame border.
Definition: frmsel.cxx:521
void Enable(FrameSelFlags nFlags)
Definition: frmsel.cxx:122
Predicate for frame border iterators to use only visible borders in a container.
Definition: frmselimpl.hxx:225
FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderDummy_Pred > FrameBorderIter
Iterator for mutable svx::FrameBorder containers, iterates over all borders.
Definition: frmselimpl.hxx:263
FrameBorder maTLBR
All data of inner vertical frame border.
Definition: frmselimpl.hxx:118
Color GetDrawLineColor(const Color &rColor) const
Returns the color that has to be used to draw a frame border.
Definition: frmsel.cxx:615
FrameBorder maBLTR
All data of top-left to bottom-right frame border.
Definition: frmselimpl.hxx:119
void InitColors()
Fills all color members from current style settings.
Definition: frmsel.cxx:292
void ClearClickArea()
Definition: frmselimpl.hxx:74
void AddClickRect(const tools::Rectangle &rRect)
Definition: frmsel.cxx:170
bool operator()(const FrameBorder *pBorder) const
Definition: frmselimpl.hxx:227
void InitArrowImageList()
Creates the image list with selection arrows regarding current style settings.
Definition: frmsel.cxx:322
void AddFocusPolygon(const tools::Polygon &rFocus)
Definition: frmsel.cxx:160
tools::PolyPolygon maFocusArea
Lower neighbor for keyboard control.
Definition: frmselimpl.hxx:92
Template class for all types of frame border iterators.
Definition: frmselimpl.hxx:238
std::vector< rtl::Reference< a11y::AccFrameSelectorChild > > maChildVec
true = High contrast mode.
Definition: frmselimpl.hxx:144
editeng::SvxBorderLine maCoreStyle
Frame border state (on/off/don't care).
Definition: frmselimpl.hxx:86
tools::PolyPolygon maClickArea
Focus drawing areas.
Definition: frmselimpl.hxx:93
FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderVisible_Pred > VisFrameBorderCIter
Iterator for constant svx::FrameBorder containers, iterates over visible borders. ...
Definition: frmselimpl.hxx:267
void SetColorSecn(const Color &rColor)
Definition: framelink.cxx:216
std::vector< Image > maArrows
For all buffered drawing operations.
Definition: frmselimpl.hxx:105
Link< LinkParamNone *, void > maSelectHdl
Pointers to enables frame borders.
Definition: frmselimpl.hxx:126
FrameBorderType
Enumerates all borders a frame selection control can contain.
FrameBorderType GetType() const
Definition: frmselimpl.hxx:43
bool ContainsClickPoint(const Point &rPos) const
Definition: frmsel.cxx:175
bool IsEnabled() const
Definition: frmselimpl.hxx:48
bool mbTLBR
true = Inner vertical frame border enabled.
Definition: frmselimpl.hxx:137
bool mbSelected
true = Border enabled in control.
Definition: frmselimpl.hxx:95
DocumentType const eType
FrameBorderType meKeyRight
Left neighbor for keyboard control.
Definition: frmselimpl.hxx:89
void SilentGrabFocus()
Grabs focus without auto-selection of a frame border, if no border selected.
Definition: frmsel.cxx:797
void DoInvalidate(bool bFullRepaint)
Invalidates the control.
Definition: frmsel.cxx:735
bool operator()(const FrameBorder *) const
Definition: frmselimpl.hxx:221
FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderSelected_Pred > SelFrameBorderCIter
Iterator for constant svx::FrameBorder containers, iterates over selected borders.
Definition: frmselimpl.hxx:275
FrameSelFlags
Definition: frmsel.hxx:32
FrameBorderType GetKeyboardNeighbor(sal_uInt16 nKeyCode) const
Definition: frmsel.cxx:194
void DrawVirtualDevice()
Draws all contents of the control.
Definition: frmsel.cxx:695
FrameSelectorImpl(FrameSelector &rFrameSel)
Pointers to accessibility objects for frame borders.
Definition: frmsel.cxx:208
frame::Array maArray
Current style and color for new borders.
Definition: frmselimpl.hxx:121
FrameSelector & mrFrameSel
Definition: frmselimpl.hxx:103
long mnCtrlSize
Selection handler.
Definition: frmselimpl.hxx:128
void Select(bool bSelect)
Definition: frmselimpl.hxx:61
bool SelectedBordersEqual() const
Returns true, if all selected frame borders are equal (or if nothing is selected).
Definition: frmsel.cxx:805
void SelectBorder(FrameBorder &rBorder, bool bSelect)
Selects a frame border and schedules redraw.
Definition: frmsel.cxx:789
FrameBorderIterBase(container_type &rCont)
Definition: frmsel.cxx:1258
FrameBorder maRight
All data of left frame border.
Definition: frmselimpl.hxx:113
void SetState(FrameBorderState eState)
Definition: frmsel.cxx:141
FrameBorder maVer
All data of inner horizontal frame border.
Definition: frmselimpl.hxx:117
bool mbVer
true = Inner horizontal frame border enabled.
Definition: frmselimpl.hxx:136
FrameBorderType meKeyTop
Right neighbor for keyboard control.
Definition: frmselimpl.hxx:90
void DrawArrows(const FrameBorder &rBorder)
Draws selection arrows for the specified frame border.
Definition: frmsel.cxx:559
Contains the widths of primary and secondary line of a frame style.
Definition: framelink.hxx:101
void InitVirtualDevice()
Draws the entire control into the internal virtual device.
Definition: frmsel.cxx:502
Point GetDevPosFromMousePos(const Point &rMousePos) const
Converts a mouse position to the virtual device position.
Definition: frmsel.cxx:730
long mnArrowSize
Size of the control (always square).
Definition: frmselimpl.hxx:129
void SetBorderState(FrameBorder &rBorder, FrameBorderState eState)
Sets the state of the specified frame border.
Definition: frmsel.cxx:742
void SetColorPrim(const Color &rColor)
Sets a new color, does not modify other settings.
Definition: framelink.cxx:201
FrameSelFlags mnFlags
Frame link array to draw an array of frame borders.
Definition: frmselimpl.hxx:123
FrameBorder maTop
All data of right frame border.
Definition: frmselimpl.hxx:114
Stores frame styles of an array of cells, supports merged ranges.
bool mbHor
Offset from frame border middle to draw focus.
Definition: frmselimpl.hxx:135
Color maArrowCol
Background color.
Definition: frmselimpl.hxx:107
void DrawAllTrackingRects(vcl::RenderContext &rRenderContext)
Draws tracking rectangles for all selected frame borders.
Definition: frmsel.cxx:711
FrameBorder & GetBorderAccess(FrameBorderType eBorder)
Returns the object representing the specified frame border (write access).
Definition: frmsel.cxx:530
bool mbHCMode
true = Auto select a frame border, if focus reaches control.
Definition: frmselimpl.hxx:141
void SetUIColorSecn(const Color &rColor)
Definition: frmselimpl.hxx:67
FrameBorder maHor
All data of bottom frame border.
Definition: frmselimpl.hxx:116
FrameBorder maLeft
Position of virtual device in the control.
Definition: frmselimpl.hxx:112
FrameBorder(FrameBorderType eType)
Definition: frmsel.cxx:110
FrameBorder maBottom
All data of top frame border.
Definition: frmselimpl.hxx:115
long mnLine2
Middle of left/top frame borders.
Definition: frmselimpl.hxx:131