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

Generated by: LCOV version 1.10