LibreOffice Module sc (master)  1
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
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 .
18  */
20 #pragma once
22 #include "csvcontrol.hxx"
23 #include "csvsplits.hxx"
25 #include <vcl/virdev.hxx>
28 class ScCsvTableBox;
32 class ScCsvRuler : public ScCsvControl
33 {
34 private:
48  sal_Int32 mnPosCursorLast;
49  sal_Int32 mnPosMTStart;
50  sal_Int32 mnPosMTCurr;
51  bool mbPosMTMoved;
55  sal_Int32 mnSplitSize;
56  bool mbTracking;
58 public:
59  explicit ScCsvRuler(const ScCsvLayoutData& rData, ScCsvTableBox* pTableBox);
60  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
62  virtual ~ScCsvRuler() override;
64  // common ruler handling --------------------------------------------------
65 public:
67  void ApplyLayout( const ScCsvLayoutData& rOldData );
69 private:
71  void InitColors();
73  void InitSizeData();
77  void MoveCursor( sal_Int32 nPos, bool bScroll = true );
79  void MoveCursorRel( ScMoveMode eDir );
81  void MoveCursorToSplit( ScMoveMode eDir );
83  void ScrollVertRel( ScMoveMode eDir );
85  // split handling ---------------------------------------------------------
86 public:
88  const ScCsvSplits& GetSplits() const { return maSplits; }
90  sal_uInt32 GetSplitCount() const
91  { return maSplits.Count(); }
93  sal_Int32 GetSplitPos( sal_uInt32 nIndex ) const
94  { return maSplits[ nIndex ]; }
96  sal_Int32 GetNoScrollPos( sal_Int32 nPos ) const;
99  bool HasSplit( sal_Int32 nPos ) const { return maSplits.HasSplit( nPos ); }
101  void InsertSplit( sal_Int32 nPos );
103  void RemoveSplit( sal_Int32 nPos );
105  void MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos );
107  void RemoveAllSplits();
109 private:
111  sal_Int32 FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const;
114  void MoveCurrSplit( sal_Int32 nNewPos );
116  void MoveCurrSplitRel( ScMoveMode eDir );
118  // event handling ---------------------------------------------------------
119 protected:
120  virtual void Resize() override;
121  virtual void GetFocus() override;
122  virtual void LoseFocus() override;
123  virtual void StyleUpdated() override;
125  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
126  virtual bool MouseMove( const MouseEvent& rMEvt ) override;
127  virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
129  virtual bool KeyInput( const KeyEvent& rKEvt ) override;
131  virtual tools::Rectangle GetFocusRect() override;
133 private:
135  void StartMouseTracking( sal_Int32 nPos );
137  void MoveMouseTracking( sal_Int32 nPos );
139  void EndMouseTracking();
141  // painting ---------------------------------------------------------------
142 protected:
143  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
145 public:
147  void ImplRedraw(vcl::RenderContext& rRenderContext);
149 private:
151  sal_Int32 GetWidth() const { return maWinSize.Width(); }
153  sal_Int32 GetHeight() const { return maWinSize.Height(); }
155  void UpdateSplitSize();
158  void ImplDrawArea( sal_Int32 nPosX, sal_Int32 nWidth );
160  void ImplDrawBackgrDev();
163  void ImplDrawSplit( sal_Int32 nPos );
165  void ImplEraseSplit( sal_Int32 nPos );
167  void ImplDrawRulerDev();
170  void ImplInvertCursor( sal_Int32 nPos );
173  void ImplSetMousePointer( sal_Int32 nPos );
175  // accessibility ----------------------------------------------------------
176 protected:
178  virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
179 };
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ScrollVertRel(ScMoveMode eDir)
Scrolls data grid vertically.
Definition: csvruler.cxx:249
Color maActiveColor
Background color.
Definition: csvruler.hxx:41
Color maTextColor
Color for active part of ruler.
Definition: csvruler.hxx:42
void InsertSplit(sal_Int32 nPos)
Inserts a split.
Definition: csvruler.cxx:287
void InitSizeData()
Initializes all data dependent from the control's size.
Definition: csvruler.cxx:171
void ImplRedraw(vcl::RenderContext &rRenderContext)
Redraws the entire ruler.
Definition: csvruler.cxx:528
Specifies which element should be used to perform an action.
Definition: csvcontrol.hxx:76
void StartMouseTracking(sal_Int32 nPos)
Starts tracking at the specified position.
Definition: csvruler.cxx:487
virtual bool KeyInput(const KeyEvent &rKEvt) override
Definition: csvruler.cxx:452
bool mbTracking
Size of a split circle.
Definition: csvruler.hxx:56
virtual void StyleUpdated() override
Definition: csvruler.cxx:394
ScCsvRuler(const ScCsvLayoutData &rData, ScCsvTableBox *pTableBox)
If currently mouse tracking.
Definition: csvruler.cxx:94
Base class for the CSV ruler and the data grid control.
Definition: csvcontrol.hxx:222
Accessible base class used for CSV controls.
A ruler control for the CSV import dialog.
Definition: csvruler.hxx:32
bool mbPosMTMoved
Current position of mouse tracking.
Definition: csvruler.hxx:51
void RemoveSplit(sal_Int32 nPos)
Removes a split.
Definition: csvruler.cxx:296
void ImplDrawBackgrDev()
Draws the entire ruler background with scaling to maBackgrDev.
Definition: csvruler.cxx:571
ScCsvTableBox * GetTableBox()
Definition: csvruler.hxx:61
void MoveCursorRel(ScMoveMode eDir)
Moves cursor to the given direction.
Definition: csvruler.cxx:199
constexpr tools::Long Width() const
void ImplSetMousePointer(sal_Int32 nPos)
Sets arrow or horizontal split pointer.
Definition: csvruler.cxx:652
sal_Int32 mnPosCursorLast
Old state for cancellation.
Definition: csvruler.hxx:48
ScCsvSplits maSplits
Split area color.
Definition: csvruler.hxx:45
void MoveSplit(sal_Int32 nPos, sal_Int32 nNewPos)
Moves a split from nPos to nNewPos.
Definition: csvruler.cxx:305
sal_Int32 GetSplitPos(sal_uInt32 nIndex) const
Returns the position of the specified split.
Definition: csvruler.hxx:93
void ImplEraseSplit(sal_Int32 nPos)
Erases a split from maRulerDev.
Definition: csvruler.cxx:618
bool HasSplit(sal_Int32 nPos) const
Returns true if at position nPos is a split.
Definition: csvsplits.cxx:66
void ImplInvertCursor(sal_Int32 nPos)
Inverts the cursor bar at the specified position in maRulerDev.
Definition: csvruler.cxx:642
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Creates a new accessible object.
Definition: csvruler.cxx:659
virtual void GetFocus() override
Definition: csvruler.cxx:378
Color maBackColor
Ruler with splits and cursor.
Definition: csvruler.hxx:40
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:418
ScCsvSplits maOldSplits
Vector with split positions.
Definition: csvruler.hxx:46
virtual tools::Rectangle GetFocusRect() override
Definition: csvruler.cxx:542
const ScCsvSplits & GetSplits() const
Returns the split array.
Definition: csvruler.hxx:88
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: csvruler.cxx:106
virtual ~ScCsvRuler() override
Definition: csvruler.cxx:126
virtual void LoseFocus() override
Definition: csvruler.cxx:387
A vector of column splits that supports inserting, removing and moving splits.
Definition: csvsplits.hxx:32
bool HasSplit(sal_Int32 nPos) const
Returns true if at position nPos is a split.
Definition: csvruler.hxx:99
ScCsvTableBox * mpTableBox
Definition: csvruler.hxx:35
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:402
sal_uInt32 GetSplitCount() const
Returns the number of splits.
Definition: csvruler.hxx:90
void MoveCursor(sal_Int32 nPos, bool bScroll=true)
Moves cursor to a new position.
Definition: csvruler.cxx:189
void RemoveAllSplits()
Removes all splits of the ruler.
Definition: csvruler.cxx:317
void MoveCurrSplitRel(ScMoveMode eDir)
Moves split and cursor to the given direction and commits event.
Definition: csvruler.cxx:359
void MoveCurrSplit(sal_Int32 nNewPos)
Moves split and cursor to nNewPos and commits event.
Definition: csvruler.cxx:351
void MoveCursorToSplit(ScMoveMode eDir)
Sets cursor to an existing split, according to eDir.
Definition: csvruler.cxx:227
void ImplDrawSplit(sal_Int32 nPos)
Draws a split to maRulerDev.
Definition: csvruler.cxx:605
ScopedVclPtrInstance< VirtualDevice > maBackgrDev
Grid Parent.
Definition: csvruler.hxx:37
The control in the CSV import dialog that contains a ruler and a data grid to visualize and modify th...
Definition: csvtablebox.hxx:43
sal_Int32 FindEmptyPos(sal_Int32 nPos, ScMoveMode eDir) const
Finds next position without a split.
Definition: csvruler.cxx:323
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: csvruler.cxx:523
constexpr tools::Long Height() const
virtual void Resize() override
Definition: csvruler.cxx:371
void ApplyLayout(const ScCsvLayoutData &rOldData)
Apply current layout data to the ruler.
Definition: csvruler.cxx:133
void MoveMouseTracking(sal_Int32 nPos)
Moves tracking to a new position.
Definition: csvruler.cxx:497
Size maWinSize
Tracking: Anytime moved to another position?
Definition: csvruler.hxx:53
sal_Int32 mnSplitSize
The active area of the ruler.
Definition: csvruler.hxx:55
Color maSplitColor
Text and scale color.
Definition: csvruler.hxx:43
void UpdateSplitSize()
Update the split size depending on the last width set by CSVCMD_SETCHARWIDTH.
Definition: csvruler.cxx:166
sal_Int32 GetNoScrollPos(sal_Int32 nPos) const
Finds a position nearest to nPos which does not cause scrolling the visible area. ...
Definition: csvruler.cxx:268
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:428
tools::Rectangle maActiveRect
Size of the control.
Definition: csvruler.hxx:54
ScopedVclPtrInstance< VirtualDevice > maRulerDev
Ruler background, scaling.
Definition: csvruler.hxx:38
void EndMouseTracking()
Applies tracking action for the current tracking position.
Definition: csvruler.cxx:513
void ImplDrawArea(sal_Int32 nPosX, sal_Int32 nWidth)
Draws the background and active area to maBackgrDev (only the given X range).
Definition: csvruler.cxx:550
sal_Int32 mnPosMTCurr
Start position of mouse tracking.
Definition: csvruler.hxx:50
sal_uInt32 Count() const
Returns the number of splits.
Definition: csvsplits.hxx:68
sal_Int32 GetWidth() const
Returns the width of the control.
Definition: csvruler.hxx:151
sal_Int32 mnPosMTStart
Last valid position of cursor.
Definition: csvruler.hxx:49
void InitColors()
Reads colors from system settings.
Definition: csvruler.cxx:156
void ImplDrawRulerDev()
Draws the ruler background, all splits and the cursor to maRulerDev.
Definition: csvruler.cxx:630
A structure containing all layout data valid for both ruler and data grid (i.e.
Definition: csvcontrol.hxx:111
sal_Int32 GetHeight() const
Returns the height of the control.
Definition: csvruler.hxx:153