LCOV - code coverage report
Current view: top level - sc/source/ui/inc - olinewin.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 3 66.7 %
Date: 2012-08-25 Functions: 2 3 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10