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 #ifndef INCLUDED_SC_SOURCE_UI_INC_OLINEWIN_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_OLINEWIN_HXX
22 
23 #include <vcl/window.hxx>
24 #include "viewdata.hxx"
25 
26 class ScOutlineEntry;
27 class ScOutlineArray;
28 
30 
34 {
35 private:
38  bool mbHoriz;
41 
43  long mnHeaderSize;
44  long mnHeaderPos;
47 
48  size_t mnMTLevel;
49  size_t mnMTEntry;
50  bool mbMTActive;
51  bool mbMTPressed;
52 
54  size_t mnFocusLevel;
55  size_t mnFocusEntry;
57 
58 public:
60  vcl::Window* pParent,
61  ScOutlineMode eMode,
62  ScViewData* pViewData,
63  ScSplitPos eWhich );
64  virtual ~ScOutlineWindow() override;
65  virtual void dispose() override;
66 
68  void SetHeaderSize( long nNewSize );
70  long GetDepthSize() const;
71 
73  void ScrollPixel( long nDiff );
74 
75  using Window::ShowFocus;
76 
77 private:
79  void InitSettings();
80 
82  ScDocument& GetDoc() const { return mrViewData.GetDocument(); }
84  SCTAB GetTab() const { return mrViewData.GetTabNo(); }
86  const ScOutlineArray* GetOutlineArray() const;
88  const ScOutlineEntry* GetOutlineEntry( size_t nLevel, size_t nEntry ) const;
89 
91  bool IsHidden( SCCOLROW nColRowIndex ) const;
93  bool IsFiltered( SCCOLROW nColRowIndex ) const;
95  bool IsFirstVisible( SCCOLROW nColRowIndex ) const;
97  void GetVisibleRange( SCCOLROW& rnColRowStart, SCCOLROW& rnColRowEnd ) const;
98 
100  Point GetPoint( long nLevelPos, long nEntryPos ) const;
103  long nLevelStart, long nEntryStart,
104  long nLevelEnd, long nEntryEnd ) const;
105 
107  long GetOutputSizeLevel() const;
109  long GetOutputSizeEntry() const;
110 
112  size_t GetLevelCount() const;
114  long GetLevelPos( size_t nLevel ) const;
116  size_t GetLevelFromPos( long nLevelPos ) const;
117 
119  long GetColRowPos( SCCOLROW nColRowIndex ) const;
121  long GetHeaderEntryPos() const;
124  bool GetEntryPos(
125  size_t nLevel, size_t nEntry,
126  long& rnStartPos, long& rnEndPos, long& rnImagePos ) const;
131  bool GetImagePos( size_t nLevel, size_t nEntry, Point& rPos ) const;
133  bool IsButtonVisible( size_t nLevel, size_t nEntry ) const;
134 
137  bool ItemHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry, bool& rbButton ) const;
140  bool ButtonHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const;
143  bool LineHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const;
144 
148  void DoFunction( size_t nLevel, size_t nEntry ) const;
150  void DoExpand( size_t nLevel, size_t nEntry ) const;
152  void DoCollapse( size_t nLevel, size_t nEntry ) const;
153 
155  bool IsFocusButtonVisible() const;
156 
160  bool ImplMoveFocusByEntry( bool bForward, bool bFindVisible );
163  bool ImplMoveFocusByLevel( bool bForward );
167  bool ImplMoveFocusByTabOrder( bool bForward );
168 
170  void ImplMoveFocusToVisible( bool bForward );
171 
173  void MoveFocusByEntry( bool bForward );
175  void MoveFocusByLevel( bool bForward );
177  void MoveFocusByTabOrder( bool bForward );
178 
180  void StartMouseTracking( size_t nLevel, size_t nEntry );
182  bool IsMouseTracking() const { return mbMTActive; }
184  void EndMouseTracking();
185 
187  void SetEntryAreaClipRegion();
189  void DrawLineRel(
190  long nLevelStart, long nEntryStart,
191  long nLevelEnd, long nEntryEnd );
193  void DrawRectRel(
194  long nLevelStart, long nEntryStart,
195  long nLevelEnd, long nEntryEnd );
197  void DrawImageRel(long nLevelPos, long nEntryPos, const OUString& rId);
199  void DrawBorderRel(size_t nLevel, size_t nEntry, bool bPressed);
200 
202  void ShowFocus();
204  void HideFocus();
205 
207  void ScrollRel( long nEntryDiff, long nEntryStart, long nEntryEnd );
208 
209 protected:
210  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
211 
212  virtual void Resize() override;
213  virtual void GetFocus() override;
214  virtual void LoseFocus() override;
215 
216  virtual void MouseMove( const MouseEvent& rMEvt ) override;
217  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
218  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
219 
220  virtual void KeyInput( const KeyEvent& rKEvt ) override;
221 
222 public:
223  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
224 };
225 
226 #endif
227 
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool mbMirrorEntries
true = Horizontal orientation.
Definition: olinewin.hxx:39
size_t mnMTLevel
Last position of main area in entry direction.
Definition: olinewin.hxx:48
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:353
bool mbMirrorLevels
true = mirror the order of entries (including header)
Definition: olinewin.hxx:40
const ScOutlineArray * GetOutlineArray() const
Returns the outline array of the corresponding document.
Definition: olinewin.cxx:157
virtual void dispose() override
Definition: olinewin.cxx:74
bool mbHoriz
Which area in split window.
Definition: olinewin.hxx:38
size_t mnFocusLevel
Focus rectangle on screen.
Definition: olinewin.hxx:54
bool ImplMoveFocusByEntry(bool bForward, bool bFindVisible)
Calculates index of next/previous focus button in the current level (no paint).
Definition: olinewin.cxx:761
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
bool ImplMoveFocusByTabOrder(bool bForward)
Calculates position of focus button in tab order.
Definition: olinewin.cxx:854
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
bool IsHidden(SCCOLROW nColRowIndex) const
Returns true, if the column/row is hidden.
Definition: olinewin.cxx:170
void DoCollapse(size_t nLevel, size_t nEntry) const
Collapses the specified entry (does nothing with header entries).
Definition: olinewin.cxx:481
virtual void Resize() override
Definition: olinewin.cxx:488
bool IsMouseTracking() const
Returns whether mouse tracking mode is active.
Definition: olinewin.hxx:182
size_t mnMTEntry
Mouse tracking: Level of active button.
Definition: olinewin.hxx:49
void EndMouseTracking()
Ends mouse tracking.
Definition: olinewin.cxx:932
long GetDepthSize() const
Returns the width/height the window needs to show all levels.
Definition: olinewin.cxx:98
Color maLineColor
true = mirror the order of levels, including the border
Definition: olinewin.hxx:42
void DrawRectRel(long nLevelStart, long nEntryStart, long nLevelEnd, long nEntryEnd)
Converts coordinates to real window points and draws the rectangle.
Definition: olinewin.cxx:525
void SetHeaderSize(long nNewSize)
Sets the size of the header area (width/height dep.
Definition: olinewin.cxx:83
void DrawBorderRel(size_t nLevel, size_t nEntry, bool bPressed)
Draws a pressed or unpressed border.
Definition: olinewin.cxx:549
ScSplitPos
Definition: viewdata.hxx:45
Point GetPoint(long nLevelPos, long nEntryPos) const
Returns the point in the window of the specified position.
Definition: olinewin.cxx:209
long GetOutputSizeLevel() const
Returns the window size for the level coordinate.
Definition: olinewin.cxx:220
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:449
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:335
void SetEntryAreaClipRegion()
Sets a clip region for the window area without header.
Definition: olinewin.cxx:512
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
long GetHeaderEntryPos() const
Returns the entry position of header images.
Definition: olinewin.cxx:263
size_t mnFocusEntry
Level of focused button.
Definition: olinewin.hxx:55
bool ButtonHit(const Point &rPos, size_t &rnLevel, size_t &rnEntry) const
Returns true, if rPos is inside of a button.
Definition: olinewin.cxx:442
virtual void LoseFocus() override
Definition: olinewin.cxx:916
void DoFunction(size_t nLevel, size_t nEntry) const
Performs an action with the specified item.
Definition: olinewin.cxx:456
bool GetEntryPos(size_t nLevel, size_t nEntry, long &rnStartPos, long &rnEndPos, long &rnImagePos) const
Calculates the coordinates the outline entry takes in the window.
Definition: olinewin.cxx:268
ScViewData & mrViewData
Definition: olinewin.hxx:36
bool mbMTActive
Mouse tracking: Entry index of active button.
Definition: olinewin.hxx:50
void GetVisibleRange(SCCOLROW &rnColRowStart, SCCOLROW &rnColRowEnd) const
Returns the currently visible column/row range.
Definition: olinewin.cxx:191
long mnMainLastPos
First position of main area in entry direction.
Definition: olinewin.hxx:46
bool IsFiltered(SCCOLROW nColRowIndex) const
Returns true, if the column/row is filtered.
Definition: olinewin.cxx:177
long mnMainFirstPos
Position of the header area in entry direction.
Definition: olinewin.hxx:45
void MoveFocusByEntry(bool bForward)
Focuses next/previous button in the current level.
Definition: olinewin.cxx:889
void HideFocus()
Erases the focus rectangle from the focused button.
Definition: olinewin.cxx:590
virtual void GetFocus() override
Definition: olinewin.cxx:910
size_t GetLevelFromPos(long nLevelPos) const
Returns the level of the passed pixel position.
Definition: olinewin.cxx:246
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: olinewin.cxx:967
void ScrollPixel(long nDiff)
Scrolls the window content by the specified amount of pixels.
Definition: olinewin.cxx:106
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: olinewin.cxx:499
void ScrollRel(long nEntryDiff, long nEntryStart, long nEntryEnd)
Scrolls the specified range of the window in entry-relative direction.
Definition: olinewin.cxx:138
tools::Rectangle maFocusRect
Mouse tracking: Button currently drawn pressed?
Definition: olinewin.hxx:53
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: olinewin.cxx:939
size_t GetLevelCount() const
Returns the count of levels of the outline array.
Definition: olinewin.cxx:232
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: olinewin.cxx:616
ScDocument & GetDoc() const
Returns the calc document.
Definition: olinewin.hxx:82
virtual ~ScOutlineWindow() override
Definition: olinewin.cxx:69
void DrawImageRel(long nLevelPos, long nEntryPos, const OUString &rId)
Draws the specified image unpressed.
Definition: olinewin.cxx:539
void ShowFocus()
Draws the focus rectangle into the focused button.
Definition: olinewin.cxx:565
ScOutlineWindow(vcl::Window *pParent, ScOutlineMode eMode, ScViewData *pViewData, ScSplitPos eWhich)
Do not redraw focus in next Paint().
Definition: olinewin.cxx:39
ScOutlineMode
Definition: olinewin.hxx:29
bool mbDontDrawFocus
Entry index of focused button.
Definition: olinewin.hxx:56
The window left of or above the spreadsheet containing the outline groups and controls to expand/coll...
Definition: olinewin.hxx:33
long mnHeaderPos
Size of the header area in entry direction.
Definition: olinewin.hxx:44
bool IsFirstVisible(SCCOLROW nColRowIndex) const
Returns true, if all columns/rows before nColRowIndex are hidden.
Definition: olinewin.cxx:183
long GetColRowPos(SCCOLROW nColRowIndex) const
Returns the start coordinate of the specified column/row in the window.
Definition: olinewin.cxx:255
long GetOutputSizeEntry() const
Returns the window size for the entry coordinate.
Definition: olinewin.cxx:226
bool mbMTPressed
Mouse tracking active?
Definition: olinewin.hxx:51
bool ImplMoveFocusByLevel(bool bForward)
Calculates position of focus button in next/previous level (no paint).
Definition: olinewin.cxx:803
bool IsFocusButtonVisible() const
Returns true, if the focused button is visible in the window.
Definition: olinewin.cxx:756
long GetLevelPos(size_t nLevel) const
Returns the pixel position of the specified level.
Definition: olinewin.cxx:239
void InitSettings()
Initializes color and image settings.
Definition: olinewin.cxx:149
tools::Rectangle GetRectangle(long nLevelStart, long nEntryStart, long nLevelEnd, long nEntryEnd) const
Returns the rectangle in the window of the specified position.
Definition: olinewin.cxx:214
ScSplitPos meWhich
View data containing the document.
Definition: olinewin.hxx:37
void StartMouseTracking(size_t nLevel, size_t nEntry)
Starts mouse tracking after click on a button.
Definition: olinewin.cxx:924
SCTAB GetTab() const
Returns the current sheet index.
Definition: olinewin.hxx:84
void DrawLineRel(long nLevelStart, long nEntryStart, long nLevelEnd, long nEntryEnd)
Converts coordinates to real window points and draws the line.
Definition: olinewin.cxx:519
void MoveFocusByTabOrder(bool bForward)
Focuses next/previous button in tab order.
Definition: olinewin.cxx:903
long mnHeaderSize
Line color for expanded groups.
Definition: olinewin.hxx:43
void MoveFocusByLevel(bool bForward)
Focuses button in next/previous level.
Definition: olinewin.cxx:896
void DoExpand(size_t nLevel, size_t nEntry) const
Expands the specified entry (does nothing with header entries).
Definition: olinewin.cxx:474
const ScOutlineEntry * GetOutlineEntry(size_t nLevel, size_t nEntry) const
Returns the specified outline entry.
Definition: olinewin.cxx:164
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: olinewin.cxx:992
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: olinewin.cxx:954
sal_Int16 SCTAB
Definition: types.hxx:23
void ImplMoveFocusToVisible(bool bForward)
If the focused entry is invisible, tries to move to visible position.
Definition: olinewin.cxx:879
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:371