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

Generated by: LCOV version 1.10