1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef SC_OLINEWIN_HXX 29*cdf0e10cSrcweir #define SC_OLINEWIN_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "viewdata.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir class ScOutlineEntry; 34*cdf0e10cSrcweir class ScOutlineArray; 35*cdf0e10cSrcweir class ScOutlineTable; 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir // ============================================================================ 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir enum ScOutlineMode { SC_OUTLINE_HOR, SC_OUTLINE_VER }; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir /** The window left of or above the spreadsheet containing the outline groups 46*cdf0e10cSrcweir and controls to expand/collapse them. */ 47*cdf0e10cSrcweir class ScOutlineWindow : public Window 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir private: 50*cdf0e10cSrcweir ScViewData& mrViewData; /// View data containing the document. 51*cdf0e10cSrcweir ScSplitPos meWhich; /// Which area in split window. 52*cdf0e10cSrcweir bool mbHoriz; /// true = Horizontal orientation. 53*cdf0e10cSrcweir bool mbMirrorEntries; /// true = mirror the order of entries (including header) 54*cdf0e10cSrcweir bool mbMirrorLevels; /// true = mirror the order of levels, including the border 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir ImageList* mpSymbols; /// Symbols for buttons. 57*cdf0e10cSrcweir Color maLineColor; /// Line color for expanded groups. 58*cdf0e10cSrcweir long mnHeaderSize; /// Size of the header area in entry direction. 59*cdf0e10cSrcweir long mnHeaderPos; /// Position of the header area in entry direction. 60*cdf0e10cSrcweir long mnMainFirstPos; /// First position of main area in entry direction. 61*cdf0e10cSrcweir long mnMainLastPos; /// Last position of main area in entry direction. 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir size_t mnMTLevel; /// Mouse tracking: Level of active button. 64*cdf0e10cSrcweir size_t mnMTEntry; /// Mouse tracking: Entry index of active button. 65*cdf0e10cSrcweir bool mbMTActive; /// Mouse tracking active? 66*cdf0e10cSrcweir bool mbMTPressed; /// Mouse tracking: Button currently drawed pressed? 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir Rectangle maFocusRect; /// Focus rectangle on screen. 69*cdf0e10cSrcweir size_t mnFocusLevel; /// Level of focused button. 70*cdf0e10cSrcweir size_t mnFocusEntry; /// Entry index of focused button. 71*cdf0e10cSrcweir bool mbDontDrawFocus; /// Do not redraw focus in next Paint(). 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir public: 74*cdf0e10cSrcweir ScOutlineWindow( 75*cdf0e10cSrcweir Window* pParent, 76*cdf0e10cSrcweir ScOutlineMode eMode, 77*cdf0e10cSrcweir ScViewData* pViewData, 78*cdf0e10cSrcweir ScSplitPos eWhich ); 79*cdf0e10cSrcweir virtual ~ScOutlineWindow(); 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir /** Sets the size of the header area (width/height dep. on window type). */ 82*cdf0e10cSrcweir void SetHeaderSize( long nNewSize ); 83*cdf0e10cSrcweir /** Returns the width/height the window needs to show all levels. */ 84*cdf0e10cSrcweir long GetDepthSize() const; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir /** Scrolls the window content by the specified amount of pixels. */ 87*cdf0e10cSrcweir void ScrollPixel( long nDiff ); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir using Window::ShowFocus; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir private: 92*cdf0e10cSrcweir /** Initializes color and image settings. */ 93*cdf0e10cSrcweir void InitSettings(); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir /** Returns the calc document. */ 96*cdf0e10cSrcweir inline ScDocument& GetDoc() const { return *mrViewData.GetDocument(); } 97*cdf0e10cSrcweir /** Returns the current sheet index. */ 98*cdf0e10cSrcweir inline SCTAB GetTab() const { return mrViewData.GetTabNo(); } 99*cdf0e10cSrcweir /** Returns the outline array of the corresponding document. */ 100*cdf0e10cSrcweir const ScOutlineArray* GetOutlineArray() const; 101*cdf0e10cSrcweir /** Returns the specified outline entry. */ 102*cdf0e10cSrcweir const ScOutlineEntry* GetOutlineEntry( size_t nLevel, size_t nEntry ) const; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir /** Returns true, if the column/row is hidden. */ 105*cdf0e10cSrcweir bool IsHidden( SCCOLROW nColRowIndex ) const; 106*cdf0e10cSrcweir /** Returns true, if the column/row is filtered. */ 107*cdf0e10cSrcweir bool IsFiltered( SCCOLROW nColRowIndex ) const; 108*cdf0e10cSrcweir /** Returns true, if all columns/rows before nColRowIndex are hidden. */ 109*cdf0e10cSrcweir bool IsFirstVisible( SCCOLROW nColRowIndex ) const; 110*cdf0e10cSrcweir /** Returns the currently visible column/row range. */ 111*cdf0e10cSrcweir void GetVisibleRange( SCCOLROW& rnColRowStart, SCCOLROW& rnColRowEnd ) const; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir /** Returns the point in the window of the specified position. */ 114*cdf0e10cSrcweir Point GetPoint( long nLevelPos, long nEntryPos ) const; 115*cdf0e10cSrcweir /** Returns the rectangle in the window of the specified position. */ 116*cdf0e10cSrcweir Rectangle GetRectangle( 117*cdf0e10cSrcweir long nLevelStart, long nEntryStart, 118*cdf0e10cSrcweir long nLevelEnd, long nEntryEnd ) const; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir /** Returns the window size for the level coordinate. */ 121*cdf0e10cSrcweir long GetOutputSizeLevel() const; 122*cdf0e10cSrcweir /** Returns the window size for the entry coordinate. */ 123*cdf0e10cSrcweir long GetOutputSizeEntry() const; 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir /** Returns the count of levels of the outline array. 0 means no outlines. */ 126*cdf0e10cSrcweir size_t GetLevelCount() const; 127*cdf0e10cSrcweir /** Returns the pixel position of the specified level. */ 128*cdf0e10cSrcweir long GetLevelPos( size_t nLevel ) const; 129*cdf0e10cSrcweir /** Returns the level of the passed pixel position. */ 130*cdf0e10cSrcweir size_t GetLevelFromPos( long nLevelPos ) const; 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir /** Returns the start coordinate of the specified column/row in the window. */ 133*cdf0e10cSrcweir long GetColRowPos( SCCOLROW nColRowIndex ) const; 134*cdf0e10cSrcweir /** Returns the entry position of header images. */ 135*cdf0e10cSrcweir long GetHeaderEntryPos() const; 136*cdf0e10cSrcweir /** Calculates the coordinates the outline entry takes in the window. 137*cdf0e10cSrcweir @return false = no part of the group is visible (outside window or collapsed by parent group). */ 138*cdf0e10cSrcweir bool GetEntryPos( 139*cdf0e10cSrcweir size_t nLevel, size_t nEntry, 140*cdf0e10cSrcweir long& rnStartPos, long& rnEndPos, long& rnImagePos ) const; 141*cdf0e10cSrcweir /** Calculates the absolute position of the image of the specified outline entry. 142*cdf0e10cSrcweir @param nLevel The level of the entry. 143*cdf0e10cSrcweir @param nEntry The entry index or SC_OL_HEADERENTRY for the header image. 144*cdf0e10cSrcweir @return false = image is not visible. */ 145*cdf0e10cSrcweir bool GetImagePos( size_t nLevel, size_t nEntry, Point& rPos ) const; 146*cdf0e10cSrcweir /** Returns true, if the button of the specified entry is visible in the window. */ 147*cdf0e10cSrcweir bool IsButtonVisible( size_t nLevel, size_t nEntry ) const; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir /** Returns true, if rPos is inside of a button or over the line of an expanded 150*cdf0e10cSrcweir group. The outline entry data is stored in the passed variables. */ 151*cdf0e10cSrcweir bool ItemHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry, bool& rbButton ) const; 152*cdf0e10cSrcweir /** Returns true, if rPos is inside of a button. 153*cdf0e10cSrcweir The button data is stored in the passed variables. */ 154*cdf0e10cSrcweir bool ButtonHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const; 155*cdf0e10cSrcweir /** Returns true, if rPos is over the line of an expanded group. 156*cdf0e10cSrcweir The outline entry data is stored in the passed variables. */ 157*cdf0e10cSrcweir bool LineHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir /** Performs an action with the specified item. 160*cdf0e10cSrcweir @param nLevel The level of the entry. 161*cdf0e10cSrcweir @param nEntry The entry index or SC_OL_HEADERENTRY for the header entry. */ 162*cdf0e10cSrcweir void DoFunction( size_t nLevel, size_t nEntry ) const; 163*cdf0e10cSrcweir /** Expands the specified entry (does nothing with header entries). */ 164*cdf0e10cSrcweir void DoExpand( size_t nLevel, size_t nEntry ) const; 165*cdf0e10cSrcweir /** Collapses the specified entry (does nothing with header entries). */ 166*cdf0e10cSrcweir void DoCollapse( size_t nLevel, size_t nEntry ) const; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir /** Returns true, if the focused button is visible in the window. */ 169*cdf0e10cSrcweir bool IsFocusButtonVisible() const; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir /** Calculates index of next/previous focus button in the current level (no paint). 172*cdf0e10cSrcweir @param bFindVisible true = repeats until a visible button has been found. 173*cdf0e10cSrcweir @return true = focus wrapped from end to start or vice versa. */ 174*cdf0e10cSrcweir bool ImplMoveFocusByEntry( bool bForward, bool bFindVisible ); 175*cdf0e10cSrcweir /** Calculates position of focus button in next/previous level (no paint). 176*cdf0e10cSrcweir @return true = focus wrapped from end to start or vice versa. */ 177*cdf0e10cSrcweir bool ImplMoveFocusByLevel( bool bForward ); 178*cdf0e10cSrcweir /** Calculates position of focus button in tab order. 179*cdf0e10cSrcweir @param bFindVisible true = repeats until a visible button has been found. 180*cdf0e10cSrcweir @return true = focus wrapped from end to start or vice versa. */ 181*cdf0e10cSrcweir bool ImplMoveFocusByTabOrder( bool bForward, bool bFindVisible ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir /** If the focused entry is invisible, tries to move to visible position. */ 184*cdf0e10cSrcweir void ImplMoveFocusToVisible( bool bForward ); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir /** Focuses next/previous button in the current level. */ 187*cdf0e10cSrcweir void MoveFocusByEntry( bool bForward ); 188*cdf0e10cSrcweir /** Focuses button in next/previous level. */ 189*cdf0e10cSrcweir void MoveFocusByLevel( bool bForward ); 190*cdf0e10cSrcweir /** Focuses next/previous button in tab order. */ 191*cdf0e10cSrcweir void MoveFocusByTabOrder( bool bForward ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir /** Starts mouse tracking after click on a button. */ 194*cdf0e10cSrcweir void StartMouseTracking( size_t nLevel, size_t nEntry ); 195*cdf0e10cSrcweir /** Returns whether mouse tracking mode is active. */ 196*cdf0e10cSrcweir inline bool IsMouseTracking() const { return mbMTActive; } 197*cdf0e10cSrcweir /** Ends mouse tracking. */ 198*cdf0e10cSrcweir void EndMouseTracking(); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir /** Sets a clip region for the window area without header. */ 201*cdf0e10cSrcweir void SetEntryAreaClipRegion(); 202*cdf0e10cSrcweir /** Converts coordinates to real window points and draws the line. */ 203*cdf0e10cSrcweir void DrawLineRel( 204*cdf0e10cSrcweir long nLevelStart, long nEntryStart, 205*cdf0e10cSrcweir long nLevelEnd, long nEntryEnd ); 206*cdf0e10cSrcweir /** Converts coordinates to real window points and draws the rectangle. */ 207*cdf0e10cSrcweir void DrawRectRel( 208*cdf0e10cSrcweir long nLevelStart, long nEntryStart, 209*cdf0e10cSrcweir long nLevelEnd, long nEntryEnd ); 210*cdf0e10cSrcweir /** Draws the specified image unpressed. */ 211*cdf0e10cSrcweir void DrawImageRel( long nLevelPos, long nEntryPos, sal_uInt16 nId ); 212*cdf0e10cSrcweir /** Draws a pressed or unpressed border. */ 213*cdf0e10cSrcweir void DrawBorderRel( size_t nLevel, size_t nEntry, bool bPressed ); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir /** Draws the focus rectangle into the focused button. */ 216*cdf0e10cSrcweir void ShowFocus(); 217*cdf0e10cSrcweir /** Erases the focus rectangle from the focused button. */ 218*cdf0e10cSrcweir void HideFocus(); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir /** Scrolls the specified range of the window in entry-relative direction. */ 221*cdf0e10cSrcweir void ScrollRel( long nEntryDiff, long nEntryStart, long nEntryEnd ); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir protected: 224*cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect ); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir virtual void Resize(); 227*cdf0e10cSrcweir virtual void GetFocus(); 228*cdf0e10cSrcweir virtual void LoseFocus(); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir virtual void MouseMove( const MouseEvent& rMEvt ); 231*cdf0e10cSrcweir virtual void MouseButtonUp( const MouseEvent& rMEvt ); 232*cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir virtual void KeyInput( const KeyEvent& rKEvt ); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir public: 237*cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 238*cdf0e10cSrcweir }; 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir // ============================================================================ 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir #endif 244*cdf0e10cSrcweir 245