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