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