LibreOffice Module sc (master)  1
olinewin.hxx
Go to the documentation of this file.
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 #pragma once
21 
22 #include <vcl/window.hxx>
23 #include "viewdata.hxx"
24 
25 class ScOutlineEntry;
26 class ScOutlineArray;
27 
29 
33 {
34 private:
37  bool mbHoriz;
40 
46 
47  size_t mnMTLevel;
48  size_t mnMTEntry;
49  bool mbMTActive;
50  bool mbMTPressed;
51 
53  size_t mnFocusLevel;
54  size_t mnFocusEntry;
56 
57 public:
59  vcl::Window* pParent,
60  ScOutlineMode eMode,
61  ScViewData* pViewData,
62  ScSplitPos eWhich );
63  virtual ~ScOutlineWindow() override;
64  virtual void dispose() override;
65 
67  void SetHeaderSize( tools::Long nNewSize );
69  tools::Long GetDepthSize() const;
70 
72  void ScrollPixel( tools::Long nDiff );
73 
74  using Window::ShowFocus;
75 
76 private:
78  void InitSettings();
79 
81  ScDocument& GetDoc() const { return mrViewData.GetDocument(); }
83  SCTAB GetTab() const { return mrViewData.GetTabNo(); }
85  const ScOutlineArray* GetOutlineArray() const;
87  const ScOutlineEntry* GetOutlineEntry( size_t nLevel, size_t nEntry ) const;
88 
90  bool IsHidden( SCCOLROW nColRowIndex ) const;
92  bool IsFiltered( SCCOLROW nColRowIndex ) const;
94  bool IsFirstVisible( SCCOLROW nColRowIndex ) const;
96  void GetVisibleRange( SCCOLROW& rnColRowStart, SCCOLROW& rnColRowEnd ) const;
97 
99  Point GetPoint( tools::Long nLevelPos, tools::Long nEntryPos ) const;
102  tools::Long nLevelStart, tools::Long nEntryStart,
103  tools::Long nLevelEnd, tools::Long nEntryEnd ) const;
104 
109 
111  size_t GetLevelCount() const;
113  tools::Long GetLevelPos( size_t nLevel ) const;
115  size_t GetLevelFromPos( tools::Long nLevelPos ) const;
116 
118  tools::Long GetColRowPos( SCCOLROW nColRowIndex ) const;
123  bool GetEntryPos(
124  size_t nLevel, size_t nEntry,
125  tools::Long& rnStartPos, tools::Long& rnEndPos, tools::Long& rnImagePos ) const;
130  bool GetImagePos( size_t nLevel, size_t nEntry, Point& rPos ) const;
132  bool IsButtonVisible( size_t nLevel, size_t nEntry ) const;
133 
136  bool ItemHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry, bool& rbButton ) const;
139  bool ButtonHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const;
142  bool LineHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const;
143 
147  void DoFunction( size_t nLevel, size_t nEntry ) const;
149  void DoExpand( size_t nLevel, size_t nEntry ) const;
151  void DoCollapse( size_t nLevel, size_t nEntry ) const;
152 
154  bool IsFocusButtonVisible() const;
155 
159  bool ImplMoveFocusByEntry( bool bForward, bool bFindVisible );
162  bool ImplMoveFocusByLevel( bool bForward );
166  bool ImplMoveFocusByTabOrder( bool bForward );
167 
169  void ImplMoveFocusToVisible( bool bForward );
170 
172  void MoveFocusByEntry( bool bForward );
174  void MoveFocusByLevel( bool bForward );
176  void MoveFocusByTabOrder( bool bForward );
177 
179  void StartMouseTracking( size_t nLevel, size_t nEntry );
181  bool IsMouseTracking() const { return mbMTActive; }
183  void EndMouseTracking();
184 
186  void SetEntryAreaClipRegion();
188  void DrawLineRel(
189  tools::Long nLevelStart, tools::Long nEntryStart,
190  tools::Long nLevelEnd, tools::Long nEntryEnd );
192  void DrawRectRel(
193  tools::Long nLevelStart, tools::Long nEntryStart,
194  tools::Long nLevelEnd, tools::Long nEntryEnd );
196  void DrawImageRel(tools::Long nLevelPos, tools::Long nEntryPos, const OUString& rId);
198  void DrawBorderRel(size_t nLevel, size_t nEntry, bool bPressed);
199 
201  void ShowFocus();
203  void HideFocus();
204 
206  void ScrollRel( tools::Long nEntryDiff, tools::Long nEntryStart, tools::Long nEntryEnd );
207 
208 protected:
209  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
210 
211  virtual void Resize() override;
212  virtual void GetFocus() override;
213  virtual void LoseFocus() override;
214 
215  virtual void MouseMove( const MouseEvent& rMEvt ) override;
216  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
217  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
218 
219  virtual void KeyInput( const KeyEvent& rKEvt ) override;
220 
221 public:
222  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
223 };
224 
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool mbMirrorEntries
true = Horizontal orientation.
Definition: olinewin.hxx:38
size_t mnMTLevel
Last position of main area in entry direction.
Definition: olinewin.hxx:47
bool IsButtonVisible(size_t nLevel, size_t nEntry) const
Returns true, if the button of the specified entry is visible in the window.
Definition: olinewin.cxx:355
bool mbMirrorLevels
true = mirror the order of entries (including header)
Definition: olinewin.hxx:39
const ScOutlineArray * GetOutlineArray() const
Returns the outline array of the corresponding document.
Definition: olinewin.cxx:159
void ScrollPixel(tools::Long nDiff)
Scrolls the window content by the specified amount of pixels.
Definition: olinewin.cxx:108
virtual void dispose() override
Definition: olinewin.cxx:76
bool mbHoriz
Which area in split window.
Definition: olinewin.hxx:37
void DrawLineRel(tools::Long nLevelStart, tools::Long nEntryStart, tools::Long nLevelEnd, tools::Long nEntryEnd)
Converts coordinates to real window points and draws the line.
Definition: olinewin.cxx:521
void SetHeaderSize(tools::Long nNewSize)
Sets the size of the header area (width/height dep.
Definition: olinewin.cxx:85
size_t mnFocusLevel
Focus rectangle on screen.
Definition: olinewin.hxx:53
long Long
tools::Long GetColRowPos(SCCOLROW nColRowIndex) const
Returns the start coordinate of the specified column/row in the window.
Definition: olinewin.cxx:257
void ScrollRel(tools::Long nEntryDiff, tools::Long nEntryStart, tools::Long nEntryEnd)
Scrolls the specified range of the window in entry-relative direction.
Definition: olinewin.cxx:140
bool ImplMoveFocusByEntry(bool bForward, bool bFindVisible)
Calculates index of next/previous focus button in the current level (no paint).
Definition: olinewin.cxx:763
SCTAB GetTabNo() const
Definition: viewdata.hxx:394
bool ImplMoveFocusByTabOrder(bool bForward)
Calculates position of focus button in tab order.
Definition: olinewin.cxx:856
ScDocument & GetDocument() const
Definition: viewdata.hxx:379
bool IsHidden(SCCOLROW nColRowIndex) const
Returns true, if the column/row is hidden.
Definition: olinewin.cxx:172
void DoCollapse(size_t nLevel, size_t nEntry) const
Collapses the specified entry (does nothing with header entries).
Definition: olinewin.cxx:483
virtual void Resize() override
Definition: olinewin.cxx:490
bool IsMouseTracking() const
Returns whether mouse tracking mode is active.
Definition: olinewin.hxx:181
size_t mnMTEntry
Mouse tracking: Level of active button.
Definition: olinewin.hxx:48
void EndMouseTracking()
Ends mouse tracking.
Definition: olinewin.cxx:934
Color maLineColor
true = mirror the order of levels, including the border
Definition: olinewin.hxx:41
void DrawBorderRel(size_t nLevel, size_t nEntry, bool bPressed)
Draws a pressed or unpressed border.
Definition: olinewin.cxx:551
ScSplitPos
Definition: viewdata.hxx:44
bool LineHit(const Point &rPos, size_t &rnLevel, size_t &rnEntry) const
Returns true, if rPos is over the line of an expanded group.
Definition: olinewin.cxx:451
tools::Long GetDepthSize() const
Returns the width/height the window needs to show all levels.
Definition: olinewin.cxx:100
bool GetImagePos(size_t nLevel, size_t nEntry, Point &rPos) const
Calculates the absolute position of the image of the specified outline entry.
Definition: olinewin.cxx:337
void SetEntryAreaClipRegion()
Sets a clip region for the window area without header.
Definition: olinewin.cxx:514
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
void DrawRectRel(tools::Long nLevelStart, tools::Long nEntryStart, tools::Long nLevelEnd, tools::Long nEntryEnd)
Converts coordinates to real window points and draws the rectangle.
Definition: olinewin.cxx:527
tools::Long mnMainFirstPos
Position of the header area in entry direction.
Definition: olinewin.hxx:44
size_t mnFocusEntry
Level of focused button.
Definition: olinewin.hxx:54
Point GetPoint(tools::Long nLevelPos, tools::Long nEntryPos) const
Returns the point in the window of the specified position.
Definition: olinewin.cxx:211
bool ButtonHit(const Point &rPos, size_t &rnLevel, size_t &rnEntry) const
Returns true, if rPos is inside of a button.
Definition: olinewin.cxx:444
virtual void LoseFocus() override
Definition: olinewin.cxx:918
void DoFunction(size_t nLevel, size_t nEntry) const
Performs an action with the specified item.
Definition: olinewin.cxx:458
ScViewData & mrViewData
Definition: olinewin.hxx:35
bool mbMTActive
Mouse tracking: Entry index of active button.
Definition: olinewin.hxx:49
void GetVisibleRange(SCCOLROW &rnColRowStart, SCCOLROW &rnColRowEnd) const
Returns the currently visible column/row range.
Definition: olinewin.cxx:193
tools::Long GetHeaderEntryPos() const
Returns the entry position of header images.
Definition: olinewin.cxx:265
bool IsFiltered(SCCOLROW nColRowIndex) const
Returns true, if the column/row is filtered.
Definition: olinewin.cxx:179
void MoveFocusByEntry(bool bForward)
Focuses next/previous button in the current level.
Definition: olinewin.cxx:891
void HideFocus()
Erases the focus rectangle from the focused button.
Definition: olinewin.cxx:592
virtual void GetFocus() override
Definition: olinewin.cxx:912
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: olinewin.cxx:969
size_t GetLevelFromPos(tools::Long nLevelPos) const
Returns the level of the passed pixel position.
Definition: olinewin.cxx:248
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: olinewin.cxx:501
tools::Long GetOutputSizeLevel() const
Returns the window size for the level coordinate.
Definition: olinewin.cxx:222
tools::Rectangle maFocusRect
Mouse tracking: Button currently drawn pressed?
Definition: olinewin.hxx:52
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: olinewin.cxx:941
size_t GetLevelCount() const
Returns the count of levels of the outline array.
Definition: olinewin.cxx:234
tools::Long mnMainLastPos
First position of main area in entry direction.
Definition: olinewin.hxx:45
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: olinewin.cxx:618
ScDocument & GetDoc() const
Returns the calc document.
Definition: olinewin.hxx:81
tools::Long mnHeaderPos
Size of the header area in entry direction.
Definition: olinewin.hxx:43
virtual ~ScOutlineWindow() override
Definition: olinewin.cxx:71
void ShowFocus()
Draws the focus rectangle into the focused button.
Definition: olinewin.cxx:567
ScOutlineWindow(vcl::Window *pParent, ScOutlineMode eMode, ScViewData *pViewData, ScSplitPos eWhich)
Do not redraw focus in next Paint().
Definition: olinewin.cxx:41
ScOutlineMode
Definition: olinewin.hxx:28
bool mbDontDrawFocus
Entry index of focused button.
Definition: olinewin.hxx:55
The window left of or above the spreadsheet containing the outline groups and controls to expand/coll...
Definition: olinewin.hxx:32
bool IsFirstVisible(SCCOLROW nColRowIndex) const
Returns true, if all columns/rows before nColRowIndex are hidden.
Definition: olinewin.cxx:185
bool mbMTPressed
Mouse tracking active?
Definition: olinewin.hxx:50
bool ImplMoveFocusByLevel(bool bForward)
Calculates position of focus button in next/previous level (no paint).
Definition: olinewin.cxx:805
bool IsFocusButtonVisible() const
Returns true, if the focused button is visible in the window.
Definition: olinewin.cxx:758
tools::Rectangle GetRectangle(tools::Long nLevelStart, tools::Long nEntryStart, tools::Long nLevelEnd, tools::Long nEntryEnd) const
Returns the rectangle in the window of the specified position.
Definition: olinewin.cxx:216
tools::Long mnHeaderSize
Line color for expanded groups.
Definition: olinewin.hxx:42
void InitSettings()
Initializes color and image settings.
Definition: olinewin.cxx:151
void DrawImageRel(tools::Long nLevelPos, tools::Long nEntryPos, const OUString &rId)
Draws the specified image unpressed.
Definition: olinewin.cxx:541
tools::Long GetLevelPos(size_t nLevel) const
Returns the pixel position of the specified level.
Definition: olinewin.cxx:241
ScSplitPos meWhich
View data containing the document.
Definition: olinewin.hxx:36
void StartMouseTracking(size_t nLevel, size_t nEntry)
Starts mouse tracking after click on a button.
Definition: olinewin.cxx:926
SCTAB GetTab() const
Returns the current sheet index.
Definition: olinewin.hxx:83
void MoveFocusByTabOrder(bool bForward)
Focuses next/previous button in tab order.
Definition: olinewin.cxx:905
void MoveFocusByLevel(bool bForward)
Focuses button in next/previous level.
Definition: olinewin.cxx:898
void DoExpand(size_t nLevel, size_t nEntry) const
Expands the specified entry (does nothing with header entries).
Definition: olinewin.cxx:476
tools::Long GetOutputSizeEntry() const
Returns the window size for the entry coordinate.
Definition: olinewin.cxx:228
const ScOutlineEntry * GetOutlineEntry(size_t nLevel, size_t nEntry) const
Returns the specified outline entry.
Definition: olinewin.cxx:166
bool GetEntryPos(size_t nLevel, size_t nEntry, tools::Long &rnStartPos, tools::Long &rnEndPos, tools::Long &rnImagePos) const
Calculates the coordinates the outline entry takes in the window.
Definition: olinewin.cxx:270
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: olinewin.cxx:994
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: olinewin.cxx:956
sal_Int16 SCTAB
Definition: types.hxx:22
void ImplMoveFocusToVisible(bool bForward)
If the focused entry is invisible, tries to move to visible position.
Definition: olinewin.cxx:881
bool ItemHit(const Point &rPos, size_t &rnLevel, size_t &rnEntry, bool &rbButton) const
Returns true, if rPos is inside of a button or over the line of an expanded group.
Definition: olinewin.cxx:373