LCOV - code coverage report
Current view: top level - sc/source/ui/inc - olinewin.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 3 66.7 %
Date: 2015-06-13 12:38:46 Functions: 2 3 66.7 %
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_SC_SOURCE_UI_INC_OLINEWIN_HXX
      21             : #define INCLUDED_SC_SOURCE_UI_INC_OLINEWIN_HXX
      22             : 
      23             : #include "viewdata.hxx"
      24             : 
      25             : class ScOutlineEntry;
      26             : class ScOutlineArray;
      27             : 
      28             : enum ScOutlineMode { SC_OUTLINE_HOR, SC_OUTLINE_VER };
      29             : 
      30             : /** The window left of or above the spreadsheet containing the outline groups
      31             :     and controls to expand/collapse them. */
      32             : class ScOutlineWindow : public vcl::Window
      33             : {
      34             : private:
      35             :     ScViewData&                 mrViewData;         /// View data containing the document.
      36             :     ScSplitPos                  meWhich;            /// Which area in split window.
      37             :     bool                        mbHoriz;            /// true = Horizontal orientation.
      38             :     bool                        mbMirrorEntries;    /// true = mirror the order of entries (including header)
      39             :     bool                        mbMirrorLevels;     /// true = mirror the order of levels, including the border
      40             : 
      41             :     ImageList*                  mpSymbols;          /// Symbols for buttons.
      42             :     Color                       maLineColor;        /// Line color for expanded groups.
      43             :     long                        mnHeaderSize;       /// Size of the header area in entry direction.
      44             :     long                        mnHeaderPos;        /// Position of the header area in entry direction.
      45             :     long                        mnMainFirstPos;     /// First position of main area in entry direction.
      46             :     long                        mnMainLastPos;      /// Last position of main area in entry direction.
      47             : 
      48             :     size_t                      mnMTLevel;          /// Mouse tracking: Level of active button.
      49             :     size_t                      mnMTEntry;          /// Mouse tracking: Entry index of active button.
      50             :     bool                        mbMTActive;         /// Mouse tracking active?
      51             :     bool                        mbMTPressed;        /// Mouse tracking: Button currently drawed pressed?
      52             : 
      53             :     Rectangle                   maFocusRect;        /// Focus rectangle on screen.
      54             :     size_t                      mnFocusLevel;       /// Level of focused button.
      55             :     size_t                      mnFocusEntry;       /// Entry index of focused button.
      56             :     bool                        mbDontDrawFocus;    /// Do not redraw focus in next Paint().
      57             : 
      58             : public:
      59             :                                 ScOutlineWindow(
      60             :                                     vcl::Window* pParent,
      61             :                                     ScOutlineMode eMode,
      62             :                                     ScViewData* pViewData,
      63             :                                     ScSplitPos eWhich );
      64             :     virtual                     ~ScOutlineWindow();
      65             :     virtual void                dispose() SAL_OVERRIDE;
      66             : 
      67             :     /** Sets the size of the header area (width/height dep. on window type). */
      68             :     void                        SetHeaderSize( long nNewSize );
      69             :     /** Returns the width/height the window needs to show all levels. */
      70             :     long                        GetDepthSize() const;
      71             : 
      72             :     /** Scrolls the window content by the specified amount of pixels. */
      73             :     void                        ScrollPixel( long nDiff );
      74             : 
      75             :     using Window::ShowFocus;
      76             : 
      77             : private:
      78             :     /** Initializes color and image settings. */
      79             :     void                        InitSettings();
      80             : 
      81             :     /** Returns the calc document. */
      82         203 :     inline ScDocument&          GetDoc() const { return *mrViewData.GetDocument(); }
      83             :     /** Returns the current sheet index. */
      84         203 :     inline SCTAB                GetTab() const { return mrViewData.GetTabNo(); }
      85             :     /** Returns the outline array of the corresponding document. */
      86             :     const ScOutlineArray*       GetOutlineArray() const;
      87             :     /** Returns the specified outline entry. */
      88             :     const ScOutlineEntry*       GetOutlineEntry( size_t nLevel, size_t nEntry ) const;
      89             : 
      90             :     /** Returns true, if the column/row is hidden. */
      91             :     bool                        IsHidden( SCCOLROW nColRowIndex ) const;
      92             :     /** Returns true, if the column/row is filtered. */
      93             :     bool                        IsFiltered( SCCOLROW nColRowIndex ) const;
      94             :     /** Returns true, if all columns/rows before nColRowIndex are hidden. */
      95             :     bool                        IsFirstVisible( SCCOLROW nColRowIndex ) const;
      96             :     /** Returns the currently visible column/row range. */
      97             :     void                        GetVisibleRange( SCCOLROW& rnColRowStart, SCCOLROW& rnColRowEnd ) const;
      98             : 
      99             :     /** Returns the point in the window of the specified position. */
     100             :     Point                       GetPoint( long nLevelPos, long nEntryPos ) const;
     101             :     /** Returns the rectangle in the window of the specified position. */
     102             :     Rectangle                   GetRectangle(
     103             :                                     long nLevelStart, long nEntryStart,
     104             :                                     long nLevelEnd, long nEntryEnd ) const;
     105             : 
     106             :     /** Returns the window size for the level coordinate. */
     107             :     long                        GetOutputSizeLevel() const;
     108             :     /** Returns the window size for the entry coordinate. */
     109             :     long                        GetOutputSizeEntry() const;
     110             : 
     111             :     /** Returns the count of levels of the outline array. 0 means no outlines. */
     112             :     size_t                      GetLevelCount() const;
     113             :     /** Returns the pixel position of the specified level. */
     114             :     long                        GetLevelPos( size_t nLevel ) const;
     115             :     /** Returns the level of the passed pixel position. */
     116             :     size_t                      GetLevelFromPos( long nLevelPos ) const;
     117             : 
     118             :     /** Returns the start coordinate of the specified column/row in the window. */
     119             :     long                        GetColRowPos( SCCOLROW nColRowIndex ) const;
     120             :     /** Returns the entry position of header images. */
     121             :     long                        GetHeaderEntryPos() const;
     122             :     /** Calculates the coordinates the outline entry takes in the window.
     123             :         @return  false = no part of the group is visible (outside window or collapsed by parent group). */
     124             :     bool                        GetEntryPos(
     125             :                                     size_t nLevel, size_t nEntry,
     126             :                                     long& rnStartPos, long& rnEndPos, long& rnImagePos ) const;
     127             :     /** Calculates the absolute position of the image of the specified outline entry.
     128             :         @param nLevel  The level of the entry.
     129             :         @param nEntry  The entry index or SC_OL_HEADERENTRY for the header image.
     130             :         @return  false = image is not visible. */
     131             :     bool                        GetImagePos( size_t nLevel, size_t nEntry, Point& rPos ) const;
     132             :     /** Returns true, if the button of the specified entry is visible in the window. */
     133             :     bool                        IsButtonVisible( size_t nLevel, size_t nEntry ) const;
     134             : 
     135             :     /** Returns true, if rPos is inside of a button or over the line of an expanded
     136             :         group. The outline entry data is stored in the passed variables. */
     137             :     bool                        ItemHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry, bool& rbButton ) const;
     138             :     /** Returns true, if rPos is inside of a button.
     139             :         The button data is stored in the passed variables. */
     140             :     bool                        ButtonHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const;
     141             :     /** Returns true, if rPos is over the line of an expanded group.
     142             :         The outline entry data is stored in the passed variables. */
     143             :     bool                        LineHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const;
     144             : 
     145             :     /** Performs an action with the specified item.
     146             :         @param nLevel  The level of the entry.
     147             :         @param nEntry  The entry index or SC_OL_HEADERENTRY for the header entry. */
     148             :     void                        DoFunction( size_t nLevel, size_t nEntry ) const;
     149             :     /** Expands the specified entry (does nothing with header entries). */
     150             :     void                        DoExpand( size_t nLevel, size_t nEntry ) const;
     151             :     /** Collapses the specified entry (does nothing with header entries). */
     152             :     void                        DoCollapse( size_t nLevel, size_t nEntry ) const;
     153             : 
     154             :     /** Returns true, if the focused button is visible in the window. */
     155             :     bool                        IsFocusButtonVisible() const;
     156             : 
     157             :     /** Calculates index of next/previous focus button in the current level (no paint).
     158             :         @param bFindVisible  true = repeats until a visible button has been found.
     159             :         @return  true = focus wrapped from end to start or vice versa. */
     160             :     bool                        ImplMoveFocusByEntry( bool bForward, bool bFindVisible );
     161             :     /** Calculates position of focus button in next/previous level (no paint).
     162             :         @return  true = focus wrapped from end to start or vice versa. */
     163             :     bool                        ImplMoveFocusByLevel( bool bForward );
     164             :     /** Calculates position of focus button in tab order.
     165             :         @param bFindVisible  true = repeats until a visible button has been found.
     166             :         @return  true = focus wrapped from end to start or vice versa. */
     167             :     bool                        ImplMoveFocusByTabOrder( bool bForward, bool bFindVisible );
     168             : 
     169             :     /** If the focused entry is invisible, tries to move to visible position. */
     170             :     void                        ImplMoveFocusToVisible( bool bForward );
     171             : 
     172             :     /** Focuses next/previous button in the current level. */
     173             :     void                        MoveFocusByEntry( bool bForward );
     174             :     /** Focuses button in next/previous level. */
     175             :     void                        MoveFocusByLevel( bool bForward );
     176             :     /** Focuses next/previous button in tab order. */
     177             :     void                        MoveFocusByTabOrder( bool bForward );
     178             : 
     179             :     /** Starts mouse tracking after click on a button. */
     180             :     void                        StartMouseTracking( size_t nLevel, size_t nEntry );
     181             :     /** Returns whether mouse tracking mode is active. */
     182           0 :     inline bool                 IsMouseTracking() const { return mbMTActive; }
     183             :     /** Ends mouse tracking. */
     184             :     void                        EndMouseTracking();
     185             : 
     186             :     /** Sets a clip region for the window area without header. */
     187             :     void                        SetEntryAreaClipRegion();
     188             :     /** Converts coordinates to real window points and draws the line. */
     189             :     void                        DrawLineRel(
     190             :                                     long nLevelStart, long nEntryStart,
     191             :                                     long nLevelEnd, long nEntryEnd );
     192             :     /** Converts coordinates to real window points and draws the rectangle. */
     193             :     void                        DrawRectRel(
     194             :                                     long nLevelStart, long nEntryStart,
     195             :                                     long nLevelEnd, long nEntryEnd );
     196             :     /** Draws the specified image unpressed. */
     197             :     void                        DrawImageRel( long nLevelPos, long nEntryPos, sal_uInt16 nId );
     198             :     /** Draws a pressed or unpressed border. */
     199             :     void                        DrawBorderRel( size_t nLevel, size_t nEntry, bool bPressed );
     200             : 
     201             :     /** Draws the focus rectangle into the focused button. */
     202             :     void                        ShowFocus();
     203             :     /** Erases the focus rectangle from the focused button. */
     204             :     void                        HideFocus();
     205             : 
     206             :     /** Scrolls the specified range of the window in entry-relative direction. */
     207             :     void                        ScrollRel( long nEntryDiff, long nEntryStart, long nEntryEnd );
     208             : 
     209             : protected:
     210             :     virtual void                Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
     211             : 
     212             :     virtual void                Resize() SAL_OVERRIDE;
     213             :     virtual void                GetFocus() SAL_OVERRIDE;
     214             :     virtual void                LoseFocus() SAL_OVERRIDE;
     215             : 
     216             :     virtual void                MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     217             :     virtual void                MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     218             :     virtual void                MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     219             : 
     220             :     virtual void                KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     221             : 
     222             : public:
     223             :     virtual void                DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     224             : };
     225             : 
     226             : #endif
     227             : 
     228             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11