LCOV - code coverage report
Current view: top level - svx/source/inc - frmselimpl.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 20 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 27 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/framelinkarray.hxx>
      27             : #include <editeng/borderline.hxx>
      28             : 
      29             : namespace svx {
      30             : 
      31             : namespace a11y {
      32             :     class AccFrameSelector;
      33             : }
      34             : 
      35           0 : class FrameBorder
      36             : {
      37             : public:
      38             :     explicit FrameBorder(FrameBorderType eType);
      39             : 
      40           0 :     inline FrameBorderType GetType() const
      41             :     {
      42           0 :         return meType;
      43             :     }
      44             : 
      45           0 :     inline bool IsEnabled() const
      46             :     {
      47           0 :         return mbEnabled;
      48             :     }
      49             :     void Enable(FrameSelFlags nFlags);
      50             : 
      51           0 :     inline FrameBorderState GetState() const
      52             :     {
      53           0 :         return meState;
      54             :     }
      55             :     void SetState(FrameBorderState eState);
      56             : 
      57           0 :     inline bool IsSelected() const { return mbSelected; }
      58           0 :     inline void Select( bool bSelect ) { mbSelected = bSelect; }
      59             : 
      60           0 :     const editeng::SvxBorderLine& GetCoreStyle() const { return maCoreStyle; }
      61             :     void SetCoreStyle( const editeng::SvxBorderLine* pStyle );
      62             : 
      63           0 :     inline void SetUIColorPrim( const Color& rColor ) {maUIStyle.SetColorPrim( rColor ); }
      64           0 :     inline void SetUIColorSecn( const Color& rColor ) {maUIStyle.SetColorSecn( rColor ); }
      65             :     inline void SetUIColorGap( bool bUseIt, const Color& rColor ) {maUIStyle.SetColorGap(bUseIt, rColor);}
      66           0 :     inline const frame::Style& GetUIStyle() const { return maUIStyle; }
      67             : 
      68           0 :     inline void ClearFocusArea() { maFocusArea.Clear(); }
      69             :     void AddFocusPolygon( const Polygon& rFocus );
      70             :     void MergeFocusToPolyPolygon( tools::PolyPolygon& rPPoly ) const;
      71             : 
      72           0 :     inline void ClearClickArea() { maClickArea.Clear(); }
      73             :     void AddClickRect( const Rectangle& rRect );
      74             :     bool ContainsClickPoint( const Point& rPos ) const;
      75             :     Rectangle GetClickBoundRect() const;
      76             : 
      77             :     void SetKeyboardNeighbors(FrameBorderType eLeft, FrameBorderType eRight,
      78             :                               FrameBorderType eTop, FrameBorderType eBottom);
      79             :     FrameBorderType GetKeyboardNeighbor( sal_uInt16 nKeyCode ) const;
      80             : 
      81             : private:
      82             :     const FrameBorderType meType; /// Frame border type (position in control).
      83             :     FrameBorderState meState; /// Frame border state (on/off/don't care).
      84             :     editeng::SvxBorderLine maCoreStyle; /// Core style from application.
      85             :     frame::Style maUIStyle; /// Internal style to draw lines.
      86             :     FrameBorderType meKeyLeft; /// Left neighbor for keyboard control.
      87             :     FrameBorderType meKeyRight; /// Right neighbor for keyboard control.
      88             :     FrameBorderType meKeyTop; /// Upper neighbor for keyboard control.
      89             :     FrameBorderType meKeyBottom;    /// Lower neighbor for keyboard control.
      90             :     tools::PolyPolygon maFocusArea;    /// Focus drawing areas.
      91             :     tools::PolyPolygon maClickArea;    /// Mouse click areas.
      92             :     bool mbEnabled : 1; /// true = Border enabled in control.
      93             :     bool mbSelected : 1; /// true = Border selected in control.
      94             : };
      95             : 
      96             : 
      97             : 
      98             : typedef std::vector< FrameBorder* > FrameBorderPtrVec;
      99             : 
     100             : struct FrameSelectorImpl : public Resource
     101             : {
     102             :     typedef css::uno::Reference<css::accessibility::XAccessible> XAccessibleRef;
     103             :     typedef std::vector<a11y::AccFrameSelector*> AccessibleImplVec;
     104             :     typedef std::vector<XAccessibleRef> XAccessibleRefVec;
     105             : 
     106             :     FrameSelector&      mrFrameSel;     /// The control itself.
     107             :     ScopedVclPtr<VirtualDevice> mpVirDev; /// For all buffered drawing operations.
     108             :     ImageList           maILArrows;     /// Arrows in current system colors.
     109             :     Color               maBackCol;      /// Background color.
     110             :     Color               maArrowCol;     /// Selection arrow color.
     111             :     Color               maMarkCol;      /// Selection marker color.
     112             :     Color               maHCLineCol;    /// High contrast line color.
     113             :     Point               maVirDevPos;    /// Position of virtual device in the control.
     114             :     Point               maMousePos;     /// Last mouse pointer position.
     115             : 
     116             :     FrameBorder         maLeft;         /// All data of left frame border.
     117             :     FrameBorder         maRight;        /// All data of right frame border.
     118             :     FrameBorder         maTop;          /// All data of top frame border.
     119             :     FrameBorder         maBottom;       /// All data of bottom frame border.
     120             :     FrameBorder         maHor;          /// All data of inner horizontal frame border.
     121             :     FrameBorder         maVer;          /// All data of inner vertical frame border.
     122             :     FrameBorder         maTLBR;         /// All data of top-left to bottom-right frame border.
     123             :     FrameBorder         maBLTR;         /// All data of bottom-left to top-right frame border.
     124             :     editeng::SvxBorderLine maCurrStyle;    /// Current style and color for new borders.
     125             :     frame::Array        maArray;        /// Frame link array to draw an array of frame borders.
     126             : 
     127             :     FrameSelFlags       mnFlags;        /// Flags for enabled frame borders.
     128             :     FrameBorderPtrVec   maAllBorders;   /// Pointers to all frame borders.
     129             :     FrameBorderPtrVec   maEnabBorders;  /// Pointers to enables frame borders.
     130             :     Link<>              maSelectHdl;    /// Selection handler.
     131             : 
     132             :     long                mnCtrlSize;     /// Size of the control (always square).
     133             :     long                mnArrowSize;    /// Size of an arrow image.
     134             :     long                mnLine1;        /// Middle of left/top frame borders.
     135             :     long                mnLine2;        /// Middle of inner frame borders.
     136             :     long                mnLine3;        /// Middle of right/bottom frame borders.
     137             :     long                mnFocusOffs;    /// Offset from frame border middle to draw focus.
     138             : 
     139             :     bool                mbHor;          /// true = Inner horizontal frame border enabled.
     140             :     bool                mbVer;          /// true = Inner vertical frame border enabled.
     141             :     bool                mbTLBR;         /// true = Top-left to bottom-right frame border enabled.
     142             :     bool                mbBLTR;         /// true = Bottom-left to top-right frame border enabled.
     143             :     bool                mbFullRepaint;  /// Used for repainting (false = only copy virtual device).
     144             :     bool                mbAutoSelect;   /// true = Auto select a frame border, if focus reaches control.
     145             :     bool                mbClicked;      /// true = The control has been clicked at least one time.
     146             :     bool                mbHCMode;       /// true = High contrast mode.
     147             : 
     148             :     a11y::AccFrameSelector* mpAccess;   /// Pointer to accessibility object of the control.
     149             :     XAccessibleRef      mxAccess;       /// Reference to accessibility object of the control.
     150             :     AccessibleImplVec   maChildVec;     /// Pointers to accessibility objects for frame borders.
     151             :     XAccessibleRefVec   mxChildVec;     /// References to accessibility objects for frame borders.
     152             : 
     153             :     explicit            FrameSelectorImpl( FrameSelector& rFrameSel );
     154             :                         ~FrameSelectorImpl();
     155             : 
     156             :     // initialization
     157             :     /** Initializes the control, enables/disables frame borders according to flags. */
     158             :     void                Initialize( FrameSelFlags nFlags );
     159             : 
     160             :     /** Fills all color members from current style settings. */
     161             :     void                InitColors();
     162             :     /** Creates the image list with selection arrows regarding current style settings. */
     163             :     void                InitArrowImageList();
     164             :     /** Initializes global coordinates. */
     165             :     void                InitGlobalGeometry();
     166             :     /** Initializes coordinates of all frame borders. */
     167             :     void                InitBorderGeometry();
     168             :     /** Initializes click areas of all enabled frame borders. */
     169             :     void                InitClickAreas();
     170             :     /** Draws the entire control into the internal virtual device. */
     171             :     void                InitVirtualDevice();
     172             :     /** call this to recalculate based on parent size */
     173             :     void                sizeChanged();
     174             : 
     175             :     // frame border access
     176             :     /** Returns the object representing the specified frame border. */
     177             :     const FrameBorder&  GetBorder( FrameBorderType eBorder ) const;
     178             :     /** Returns the object representing the specified frame border (write access). */
     179             :     FrameBorder&        GetBorderAccess( FrameBorderType eBorder );
     180             : 
     181             :     // drawing
     182             :     /** Draws the background of the entire control (the gray areas between borders). */
     183             :     void                DrawBackground();
     184             : 
     185             :     /** Draws selection arrows for the specified frame border. */
     186             :     void                DrawArrows( const FrameBorder& rBorder );
     187             :     /** Draws arrows in current selection state for all enabled frame borders. */
     188             :     void                DrawAllArrows();
     189             : 
     190             :     /** Returns the color that has to be used to draw a frame border. */
     191             :     Color               GetDrawLineColor( const Color& rColor ) const;
     192             :     /** Draws all frame borders. */
     193             :     void                DrawAllFrameBorders();
     194             : 
     195             :     /** Draws all contents of the control. */
     196             :     void                DrawVirtualDevice();
     197             :     /** Copies contents of the virtual device to the control. */
     198             :     void                CopyVirDevToControl(vcl::RenderContext& rRenderContext);
     199             : 
     200             :     /** Draws tracking rectangles for all selected frame borders. */
     201             :     void                DrawAllTrackingRects();
     202             : 
     203             :     /** Converts a mouse position to the virtual device position. */
     204             :     Point               GetDevPosFromMousePos( const Point& rMousePos ) const;
     205             : 
     206             :     /** Invalidates the control.
     207             :         @param bFullRepaint  true = Full repaint; false = update selection only. */
     208             :     void                DoInvalidate( bool bFullRepaint );
     209             : 
     210             :     // frame border state and style
     211             :     /** Sets the state of the specified frame border. */
     212             :     void                SetBorderState( FrameBorder& rBorder, FrameBorderState eState );
     213             :     /** Sets the core style of the specified frame border, or hides the frame border, if pStyle is 0. */
     214             :     void                SetBorderCoreStyle( FrameBorder& rBorder, const editeng::SvxBorderLine* pStyle );
     215             : 
     216             :     /** Changes the state of a frame border after a control event (mouse/keyboard). */
     217             :     void                ToggleBorderState( FrameBorder& rBorder );
     218             : 
     219             :     // frame border selection
     220             :     /** Selects a frame border and schedules redraw. */
     221             :     void                SelectBorder( FrameBorder& rBorder, bool bSelect );
     222             :     /** Grabs focus without auto-selection of a frame border, if no border selected. */
     223             :     void                SilentGrabFocus();
     224             : 
     225             :     /** Returns true, if all selected frame borders are equal (or if nothing is selected). */
     226             :     bool                SelectedBordersEqual() const;
     227             : };
     228             : 
     229             : 
     230             : 
     231             : /** Dummy predicate for frame border iterators to use all borders in a container. */
     232             : struct FrameBorderDummy_Pred
     233             : {
     234           0 :     inline bool operator()( const FrameBorder* ) const { return true; }
     235             : };
     236             : 
     237             : /** Predicate for frame border iterators to use only visible borders in a container. */
     238             : struct FrameBorderVisible_Pred
     239             : {
     240           0 :     inline bool operator()( const FrameBorder* pBorder ) const { return pBorder->GetState() == FRAMESTATE_SHOW; }
     241             : };
     242             : 
     243             : /** Predicate for frame border iterators to use only selected borders in a container. */
     244             : struct FrameBorderSelected_Pred
     245             : {
     246           0 :     inline bool operator()( const FrameBorder* pBorder ) const { return pBorder->IsSelected(); }
     247             : };
     248             : 
     249             : /** Template class for all types of frame border iterators. */
     250             : template< typename Cont, typename Iter, typename Pred >
     251             : class FrameBorderIterBase
     252             : {
     253             : public:
     254             :     typedef Cont container_type;
     255             :     typedef Iter iterator_type;
     256             :     typedef Pred predicate_type;
     257             :     typedef typename Cont::value_type value_type;
     258             :     typedef FrameBorderIterBase<Cont, Iter, Pred> this_type;
     259             : 
     260             :     explicit            FrameBorderIterBase( container_type& rCont );
     261           0 :     inline bool         Is() const { return maIt != maEnd; }
     262             :     this_type&          operator++();
     263           0 :     inline value_type   operator*() const { return *maIt; }
     264             : 
     265             : private:
     266             :     iterator_type       maIt;
     267             :     iterator_type       maEnd;
     268             :     predicate_type      maPred;
     269             : };
     270             : 
     271             : /** Iterator for constant svx::FrameBorder containers, iterates over all borders. */
     272             : typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderDummy_Pred >
     273             :     FrameBorderCIter;
     274             : 
     275             : /** Iterator for mutable svx::FrameBorder containers, iterates over all borders. */
     276             : typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderDummy_Pred >
     277             :     FrameBorderIter;
     278             : 
     279             : /** Iterator for constant svx::FrameBorder containers, iterates over visible borders. */
     280             : typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderVisible_Pred >
     281             :     VisFrameBorderCIter;
     282             : 
     283             : /** Iterator for mutable svx::FrameBorder containers, iterates over visible borders. */
     284             : typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderVisible_Pred >
     285             :     VisFrameBorderIter;
     286             : 
     287             : /** Iterator for constant svx::FrameBorder containers, iterates over selected borders. */
     288             : typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderSelected_Pred >
     289             :     SelFrameBorderCIter;
     290             : 
     291             : /** Iterator for mutable svx::FrameBorder containers, iterates over selected borders. */
     292             : typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderSelected_Pred >
     293             :     SelFrameBorderIter;
     294             : 
     295             : }
     296             : 
     297             : #endif
     298             : 
     299             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11