1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SC_OLINEWIN_HXX
21 #define SC_OLINEWIN_HXX
23 #include "viewdata.hxx"
29 // ============================================================================
31 enum ScOutlineMode
{ SC_OUTLINE_HOR
, SC_OUTLINE_VER
};
34 // ----------------------------------------------------------------------------
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
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
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.
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?
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().
68 ScViewData
* pViewData
,
70 virtual ~ScOutlineWindow();
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;
77 /** Scrolls the window content by the specified amount of pixels. */
78 void ScrollPixel( long nDiff
);
80 using Window::ShowFocus
;
83 /** Initializes color and image settings. */
86 /** Returns the calc document. */
87 inline ScDocument
& GetDoc() const { return *mrViewData
.GetDocument(); }
88 /** Returns the current sheet index. */
89 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;
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;
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;
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;
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;
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). */
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;
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;
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;
159 /** Returns true, if the focused button is visible in the window. */
160 bool IsFocusButtonVisible() const;
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
);
174 /** If the focused entry is invisible, tries to move to visible position. */
175 void ImplMoveFocusToVisible( bool bForward
);
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
);
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 inline bool IsMouseTracking() const { return mbMTActive
; }
188 /** Ends mouse tracking. */
189 void EndMouseTracking();
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. */
195 long nLevelStart
, long nEntryStart
,
196 long nLevelEnd
, long nEntryEnd
);
197 /** Converts coordinates to real window points and draws the rectangle. */
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
);
206 /** Draws the focus rectangle into the focused button. */
208 /** Erases the focus rectangle from the focused button. */
211 /** Scrolls the specified range of the window in entry-relative direction. */
212 void ScrollRel( long nEntryDiff
, long nEntryStart
, long nEntryEnd
);
215 virtual void Paint( const Rectangle
& rRect
);
217 virtual void Resize();
218 virtual void GetFocus();
219 virtual void LoseFocus();
221 virtual void MouseMove( const MouseEvent
& rMEvt
);
222 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
223 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
225 virtual void KeyInput( const KeyEvent
& rKEvt
);
228 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
232 // ============================================================================
236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */