LCOV - code coverage report
Current view: top level - sc/source/ui/inc - olinewin.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 3 66.7 %
Date: 2014-11-03 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             : 
      66             :     /** Sets the size of the header area (width/height dep. on window type). */
      67             :     void                        SetHeaderSize( long nNewSize );
      68             :     /** Returns the width/height the window needs to show all levels. */
      69             :     long                        GetDepthSize() const;
      70             : 
      71             :     /** Scrolls the window content by the specified amount of pixels. */
      72             :     void                        ScrollPixel( long nDiff );
      73             : 
      74             :     using Window::ShowFocus;
      75             : 
      76             : private:
      77             :     /** Initializes color and image settings. */
      78             :     void                        InitSettings();
      79             : 
      80             :     /** Returns the calc document. */
      81         346 :     inline ScDocument&          GetDoc() const { return *mrViewData.GetDocument(); }
      82             :     /** Returns the current sheet index. */
      83         346 :     inline SCTAB                GetTab() const { return mrViewData.GetTabNo(); }
      84             :     /** Returns the outline array of the corresponding document. */
      85             :     const ScOutlineArray*       GetOutlineArray() const;
      86             :     /** Returns the specified outline entry. */
      87             :     const ScOutlineEntry*       GetOutlineEntry( size_t nLevel, size_t nEntry ) const;
      88             : 
      89             :     /** Returns true, if the column/row is hidden. */
      90             :     bool                        IsHidden( SCCOLROW nColRowIndex ) const;
      91             :     /** Returns true, if the column/row is filtered. */
      92             :     bool                        IsFiltered( SCCOLROW nColRowIndex ) const;
      93             :     /** Returns true, if all columns/rows before nColRowIndex are hidden. */
      94             :     bool                        IsFirstVisible( SCCOLROW nColRowIndex ) const;
      95             :     /** Returns the currently visible column/row range. */
      96             :     void                        GetVisibleRange( SCCOLROW& rnColRowStart, SCCOLROW& rnColRowEnd ) const;
      97             : 
      98             :     /** Returns the point in the window of the specified position. */
      99             :     Point                       GetPoint( long nLevelPos, long nEntryPos ) const;
     100             :     /** Returns the rectangle in the window of the specified position. */
     101             :     Rectangle                   GetRectangle(
     102             :                                     long nLevelStart, long nEntryStart,
     103             :                                     long nLevelEnd, long nEntryEnd ) const;
     104             : 
     105             :     /** Returns the window size for the level coordinate. */
     106             :     long                        GetOutputSizeLevel() const;
     107             :     /** Returns the window size for the entry coordinate. */
     108             :     long                        GetOutputSizeEntry() const;
     109             : 
     110             :     /** Returns the count of levels of the outline array. 0 means no outlines. */
     111             :     size_t                      GetLevelCount() const;
     112             :     /** Returns the pixel position of the specified level. */
     113             :     long                        GetLevelPos( size_t nLevel ) const;
     114             :     /** Returns the level of the passed pixel position. */
     115             :     size_t                      GetLevelFromPos( long nLevelPos ) const;
     116             : 
     117             :     /** Returns the start coordinate of the specified column/row in the window. */
     118             :     long                        GetColRowPos( SCCOLROW nColRowIndex ) const;
     119             :     /** Returns the entry position of header images. */
     120             :     long                        GetHeaderEntryPos() const;
     121             :     /** Calculates the coordinates the outline entry takes in the window.
     122             :         @return  false = no part of the group is visible (outside window or collapsed by parent group). */
     123             :     bool                        GetEntryPos(
     124             :                                     size_t nLevel, size_t nEntry,
     125             :                                     long& rnStartPos, long& rnEndPos, long& rnImagePos ) const;
     126             :     /** Calculates the absolute position of the image of the specified outline entry.
     127             :         @param nLevel  The level of the entry.
     128             :         @param nEntry  The entry index or SC_OL_HEADERENTRY for the header image.
     129             :         @return  false = image is not visible. */
     130             :     bool                        GetImagePos( size_t nLevel, size_t nEntry, Point& rPos ) const;
     131             :     /** Returns true, if the button of the specified entry is visible in the window. */
     132             :     bool                        IsButtonVisible( size_t nLevel, size_t nEntry ) const;
     133             : 
     134             :     /** Returns true, if rPos is inside of a button or over the line of an expanded
     135             :         group. The outline entry data is stored in the passed variables. */
     136             :     bool                        ItemHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry, bool& rbButton ) const;
     137             :     /** Returns true, if rPos is inside of a button.
     138             :         The button data is stored in the passed variables. */
     139             :     bool                        ButtonHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const;
     140             :     /** Returns true, if rPos is over the line of an expanded group.
     141             :         The outline entry data is stored in the passed variables. */
     142             :     bool                        LineHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const;
     143             : 
     144             :     /** Performs an action with the specified item.
     145             :         @param nLevel  The level of the entry.
     146             :         @param nEntry  The entry index or SC_OL_HEADERENTRY for the header entry. */
     147             :     void                        DoFunction( size_t nLevel, size_t nEntry ) const;
     148             :     /** Expands the specified entry (does nothing with header entries). */
     149             :     void                        DoExpand( size_t nLevel, size_t nEntry ) const;
     150             :     /** Collapses the specified entry (does nothing with header entries). */
     151             :     void                        DoCollapse( size_t nLevel, size_t nEntry ) const;
     152             : 
     153             :     /** Returns true, if the focused button is visible in the window. */
     154             :     bool                        IsFocusButtonVisible() const;
     155             : 
     156             :     /** Calculates index of next/previous focus button in the current level (no paint).
     157             :         @param bFindVisible  true = repeats until a visible button has been found.
     158             :         @return  true = focus wrapped from end to start or vice versa. */
     159             :     bool                        ImplMoveFocusByEntry( bool bForward, bool bFindVisible );
     160             :     /** Calculates position of focus button in next/previous level (no paint).
     161             :         @return  true = focus wrapped from end to start or vice versa. */
     162             :     bool                        ImplMoveFocusByLevel( bool bForward );
     163             :     /** Calculates position of focus button in tab order.
     164             :         @param bFindVisible  true = repeats until a visible button has been found.
     165             :         @return  true = focus wrapped from end to start or vice versa. */
     166             :     bool                        ImplMoveFocusByTabOrder( bool bForward, bool bFindVisible );
     167             : 
     168             :     /** If the focused entry is invisible, tries to move to visible position. */
     169             :     void                        ImplMoveFocusToVisible( bool bForward );
     170             : 
     171             :     /** Focuses next/previous button in the current level. */
     172             :     void                        MoveFocusByEntry( bool bForward );
     173             :     /** Focuses button in next/previous level. */
     174             :     void                        MoveFocusByLevel( bool bForward );
     175             :     /** Focuses next/previous button in tab order. */
     176             :     void                        MoveFocusByTabOrder( bool bForward );
     177             : 
     178             :     /** Starts mouse tracking after click on a button. */
     179             :     void                        StartMouseTracking( size_t nLevel, size_t nEntry );
     180             :     /** Returns whether mouse tracking mode is active. */
     181           0 :     inline bool                 IsMouseTracking() const { return mbMTActive; }
     182             :     /** Ends mouse tracking. */
     183             :     void                        EndMouseTracking();
     184             : 
     185             :     /** Sets a clip region for the window area without header. */
     186             :     void                        SetEntryAreaClipRegion();
     187             :     /** Converts coordinates to real window points and draws the line. */
     188             :     void                        DrawLineRel(
     189             :                                     long nLevelStart, long nEntryStart,
     190             :                                     long nLevelEnd, long nEntryEnd );
     191             :     /** Converts coordinates to real window points and draws the rectangle. */
     192             :     void                        DrawRectRel(
     193             :                                     long nLevelStart, long nEntryStart,
     194             :                                     long nLevelEnd, long nEntryEnd );
     195             :     /** Draws the specified image unpressed. */
     196             :     void                        DrawImageRel( long nLevelPos, long nEntryPos, sal_uInt16 nId );
     197             :     /** Draws a pressed or unpressed border. */
     198             :     void                        DrawBorderRel( size_t nLevel, size_t nEntry, bool bPressed );
     199             : 
     200             :     /** Draws the focus rectangle into the focused button. */
     201             :     void                        ShowFocus();
     202             :     /** Erases the focus rectangle from the focused button. */
     203             :     void                        HideFocus();
     204             : 
     205             :     /** Scrolls the specified range of the window in entry-relative direction. */
     206             :     void                        ScrollRel( long nEntryDiff, long nEntryStart, long nEntryEnd );
     207             : 
     208             : protected:
     209             :     virtual void                Paint( const Rectangle& rRect ) SAL_OVERRIDE;
     210             : 
     211             :     virtual void                Resize() SAL_OVERRIDE;
     212             :     virtual void                GetFocus() SAL_OVERRIDE;
     213             :     virtual void                LoseFocus() SAL_OVERRIDE;
     214             : 
     215             :     virtual void                MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     216             :     virtual void                MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     217             :     virtual void                MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     218             : 
     219             :     virtual void                KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     220             : 
     221             : public:
     222             :     virtual void                DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     223             : };
     224             : 
     225             : #endif
     226             : 
     227             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10