LibreOffice Module svx (master)  1
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
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 .
18  */
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;
35 }
38 {
39 public:
41  static double GetDefaultPatternScale() { return 0.05; }
44  {
45  return meType;
46  }
48  bool IsEnabled() const
49  {
50  return mbEnabled;
51  }
52  void Enable(FrameSelFlags nFlags);
55  {
56  return meState;
57  }
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; }
71  void AddFocusPolygon( const tools::Polygon& rFocus );
72  void MergeFocusToPolyPolygon( tools::PolyPolygon& rPPoly ) const;
75  void AddClickRect( const tools::Rectangle& rRect );
76  bool ContainsClickPoint( const Point& rPos ) const;
80  FrameBorderType eTop, FrameBorderType eBottom);
81  FrameBorderType GetKeyboardNeighbor( sal_uInt16 nKeyCode ) const;
83 private:
94  bool mbEnabled : 1;
95  bool mbSelected : 1;
96 };
99 typedef std::vector< FrameBorder* > FrameBorderPtrVec;
102 {
105  std::vector<Image> maArrows;
124  FrameBorderPtrVec maAllBorders;
125  FrameBorderPtrVec maEnabBorders;
135  bool mbHor;
136  bool mbVer;
137  bool mbTLBR;
138  bool mbBLTR;
141  bool mbHCMode;
143  std::vector<rtl::Reference<a11y::AccFrameSelectorChild>>
145  explicit FrameSelectorImpl( FrameSelector& rFrameSel );
148  // initialization
150  void Initialize( FrameSelFlags nFlags );
153  void InitColors();
155  void InitArrowImageList();
157  void InitGlobalGeometry();
159  void InitBorderGeometry();
161  void InitVirtualDevice();
163  void sizeChanged();
165  // frame border access
167  const FrameBorder& GetBorder( FrameBorderType eBorder ) const;
171  // drawing
173  void DrawBackground();
176  void DrawArrows( const FrameBorder& rBorder );
179  Color GetDrawLineColor( const Color& rColor ) const;
181  void DrawAllFrameBorders();
184  void DrawVirtualDevice();
186  void CopyVirDevToControl(vcl::RenderContext& rRenderContext);
189  void DrawAllTrackingRects(vcl::RenderContext& rRenderContext);
192  Point GetDevPosFromMousePos( const Point& rMousePos ) const;
196  void DoInvalidate( bool bFullRepaint );
198  // frame border state and style
200  void SetBorderState( FrameBorder& rBorder, FrameBorderState eState );
202  void SetBorderCoreStyle( FrameBorder& rBorder, const editeng::SvxBorderLine* pStyle );
205  void ToggleBorderState( FrameBorder& rBorder );
207  // frame border selection
209  void SelectBorder( FrameBorder& rBorder, bool bSelect );
211  void SilentGrabFocus();
214  bool SelectedBordersEqual() const;
215 };
220 {
221  bool operator()( const FrameBorder* ) const { return true; }
222 };
226 {
227  bool operator()( const FrameBorder* pBorder ) const { return pBorder->GetState() == FrameBorderState::Show; }
228 };
232 {
233  bool operator()( const FrameBorder* pBorder ) const { return pBorder->IsSelected(); }
234 };
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;
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;
255 };
281 }
283 #endif
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void MergeFocusToPolyPolygon(tools::PolyPolygon &rPPoly) const
Definition: frmsel.cxx:171
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:355
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:543
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:770
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:379
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:279
this_type & operator++()
Definition: frmsel.cxx:1278
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 Long
void CopyVirDevToControl(vcl::RenderContext &rRenderContext)
Copies contents of the virtual device to the control.
Definition: frmsel.cxx:711
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
Point maVirDevPos
High contrast line color.
Definition: frmselimpl.hxx:110
void sizeChanged()
call this to recalculate based on parent size
Definition: frmsel.cxx:518
value_type operator*() const
Definition: frmselimpl.hxx:249
void SetKeyboardNeighbors(FrameBorderType eLeft, FrameBorderType eRight, FrameBorderType eTop, FrameBorderType eBottom)
Definition: frmsel.cxx:191
FrameBorderIterBase< Cont, Iter, Pred > this_type
Definition: frmselimpl.hxx:244
tools::Long mnArrowSize
Size of the control (always square).
Definition: frmselimpl.hxx:129
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:777
bool mbBLTR
true = Top-left to bottom-right frame border enabled.
Definition: frmselimpl.hxx:138
tools::Long mnLine3
Middle of inner frame borders.
Definition: frmselimpl.hxx:132
void SetUIColorPrim(const Color &rColor)
Definition: frmselimpl.hxx:66
All possible states of a frame border.
Definition: frmsel.hxx:69
const FrameBorderType meType
Definition: frmselimpl.hxx:84
tools::Long mnLine1
Size of an arrow image.
Definition: frmselimpl.hxx:130
tools::Rectangle GetClickBoundRect() const
Definition: frmsel.cxx:186
frame::Style maUIStyle
Core style from application.
Definition: frmselimpl.hxx:87
void SetCoreStyle(const editeng::SvxBorderLine *pStyle)
Definition: frmsel.cxx:135
tools::Long mnLine2
Middle of left/top frame borders.
Definition: frmselimpl.hxx:131
void DrawAllFrameBorders()
Draws all frame borders.
Definition: frmsel.cxx:630
FrameBorderState GetState() const
Definition: frmselimpl.hxx:54
const FrameBorder & GetBorder(FrameBorderType eBorder) const
Returns the object representing the specified frame border.
Definition: frmsel.cxx:528
void Enable(FrameSelFlags nFlags)
Definition: frmsel.cxx:128
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:622
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:298
void ClearClickArea()
Definition: frmselimpl.hxx:74
void AddClickRect(const tools::Rectangle &rRect)
Definition: frmsel.cxx:176
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:329
void AddFocusPolygon(const tools::Polygon &rFocus)
Definition: frmsel.cxx:166
DocumentType eType
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.hxx:156
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
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:181
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
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:804
void DoInvalidate(bool bFullRepaint)
Invalidates the control.
Definition: frmsel.cxx:742
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
Definition: frmsel.hxx:32
FrameBorderType GetKeyboardNeighbor(sal_uInt16 nKeyCode) const
Definition: frmsel.cxx:200
void DrawVirtualDevice()
Draws all contents of the control.
Definition: frmsel.cxx:702
FrameSelectorImpl(FrameSelector &rFrameSel)
Pointers to accessibility objects for frame borders.
Definition: frmsel.cxx:214
frame::Array maArray
Current style and color for new borders.
Definition: frmselimpl.hxx:121
tools::Long mnCtrlSize
Selection handler.
Definition: frmselimpl.hxx:128
FrameSelector & mrFrameSel
Definition: frmselimpl.hxx:103
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:812
void SelectBorder(FrameBorder &rBorder, bool bSelect)
Selects a frame border and schedules redraw.
Definition: frmsel.cxx:796
FrameBorderIterBase(container_type &rCont)
Definition: frmsel.cxx:1270
FrameBorder maRight
All data of left frame border.
Definition: frmselimpl.hxx:113
void SetState(FrameBorderState eState)
Definition: frmsel.cxx:147
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:566
Contains the widths of primary and secondary line of a frame style.
Definition: framelink.hxx:100
void InitVirtualDevice()
Draws the entire control into the internal virtual device.
Definition: frmsel.cxx:509
tools::Long mnFocusOffs
Middle of right/bottom frame borders.
Definition: frmselimpl.hxx:133
Point GetDevPosFromMousePos(const Point &rMousePos) const
Converts a mouse position to the virtual device position.
Definition: frmsel.cxx:737
void SetBorderState(FrameBorder &rBorder, FrameBorderState eState)
Sets the state of the specified frame border.
Definition: frmsel.cxx:749
void SetColorPrim(const Color &rColor)
Sets a new color, does not modify other settings.
Definition: framelink.hxx:155
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:718
FrameBorder & GetBorderAccess(FrameBorderType eBorder)
Returns the object representing the specified frame border (write access).
Definition: frmsel.cxx:537
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:116
FrameBorder maBottom
All data of top frame border.
Definition: frmselimpl.hxx:115