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  */
23 #include "csvcontrol.hxx"
24 #include "csvsplits.hxx"
26 #include <vcl/virdev.hxx>
29 class ScCsvTableBox;
33 class ScCsvRuler : public ScCsvControl
34 {
35 private:
49  sal_Int32 mnPosCursorLast;
50  sal_Int32 mnPosMTStart;
51  sal_Int32 mnPosMTCurr;
52  bool mbPosMTMoved;
56  sal_Int32 mnSplitSize;
57  bool mbTracking;
59 public:
60  explicit ScCsvRuler(const ScCsvLayoutData& rData, ScCsvTableBox* pTableBox);
61  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
63  virtual ~ScCsvRuler() override;
65  // common ruler handling --------------------------------------------------
66 public:
68  void ApplyLayout( const ScCsvLayoutData& rOldData );
70 private:
72  void InitColors();
74  void InitSizeData();
78  void MoveCursor( sal_Int32 nPos, bool bScroll = true );
80  void MoveCursorRel( ScMoveMode eDir );
82  void MoveCursorToSplit( ScMoveMode eDir );
84  void ScrollVertRel( ScMoveMode eDir );
86  // split handling ---------------------------------------------------------
87 public:
89  const ScCsvSplits& GetSplits() const { return maSplits; }
91  sal_uInt32 GetSplitCount() const
92  { return maSplits.Count(); }
94  sal_Int32 GetSplitPos( sal_uInt32 nIndex ) const
95  { return maSplits[ nIndex ]; }
97  sal_Int32 GetNoScrollPos( sal_Int32 nPos ) const;
100  bool HasSplit( sal_Int32 nPos ) const { return maSplits.HasSplit( nPos ); }
102  void InsertSplit( sal_Int32 nPos );
104  void RemoveSplit( sal_Int32 nPos );
106  void MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos );
108  void RemoveAllSplits();
110 private:
112  sal_Int32 FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const;
115  void MoveCurrSplit( sal_Int32 nNewPos );
117  void MoveCurrSplitRel( ScMoveMode eDir );
119  // event handling ---------------------------------------------------------
120 protected:
121  virtual void Resize() override;
122  virtual void GetFocus() override;
123  virtual void LoseFocus() override;
124  virtual void StyleUpdated() override;
126  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
127  virtual bool MouseMove( const MouseEvent& rMEvt ) override;
128  virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
130  virtual bool KeyInput( const KeyEvent& rKEvt ) override;
132  virtual tools::Rectangle GetFocusRect() override;
134 private:
136  void StartMouseTracking( sal_Int32 nPos );
138  void MoveMouseTracking( sal_Int32 nPos );
140  void EndMouseTracking();
142  // painting ---------------------------------------------------------------
143 protected:
144  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
146 public:
148  void ImplRedraw(vcl::RenderContext& rRenderContext);
150 private:
152  sal_Int32 GetWidth() const { return maWinSize.Width(); }
154  sal_Int32 GetHeight() const { return maWinSize.Height(); }
156  void UpdateSplitSize();
159  void ImplDrawArea( sal_Int32 nPosX, sal_Int32 nWidth );
161  void ImplDrawBackgrDev();
164  void ImplDrawSplit( sal_Int32 nPos );
166  void ImplEraseSplit( sal_Int32 nPos );
168  void ImplDrawRulerDev();
171  void ImplInvertCursor( sal_Int32 nPos );
174  void ImplSetMousePointer( sal_Int32 nPos );
176  // accessibility ----------------------------------------------------------
177 protected:
179  virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
180 };
182 #endif
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ScrollVertRel(ScMoveMode eDir)
Scrolls data grid vertically.
Definition: csvruler.cxx:248
Color maActiveColor
Background color.
Definition: csvruler.hxx:42
Color maTextColor
Color for active part of ruler.
Definition: csvruler.hxx:43
void InsertSplit(sal_Int32 nPos)
Inserts a split.
Definition: csvruler.cxx:286
void InitSizeData()
Initializes all data dependent from the control's size.
Definition: csvruler.cxx:170
void ImplRedraw(vcl::RenderContext &rRenderContext)
Redraws the entire ruler.
Definition: csvruler.cxx:527
Specifies which element should be used to perform an action.
Definition: csvcontrol.hxx:77
void StartMouseTracking(sal_Int32 nPos)
Starts tracking at the specified position.
Definition: csvruler.cxx:486
virtual bool KeyInput(const KeyEvent &rKEvt) override
Definition: csvruler.cxx:451
bool mbTracking
Size of a split circle.
Definition: csvruler.hxx:57
virtual void StyleUpdated() override
Definition: csvruler.cxx:393
ScCsvRuler(const ScCsvLayoutData &rData, ScCsvTableBox *pTableBox)
If currently mouse tracking.
Definition: csvruler.cxx:93
Base class for the CSV ruler and the data grid control.
Definition: csvcontrol.hxx:223
Accessible base class used for CSV controls.
A ruler control for the CSV import dialog.
Definition: csvruler.hxx:33
bool mbPosMTMoved
Current position of mouse tracking.
Definition: csvruler.hxx:52
void RemoveSplit(sal_Int32 nPos)
Removes a split.
Definition: csvruler.cxx:295
void ImplDrawBackgrDev()
Draws the entire ruler background with scaling to maBackgrDev.
Definition: csvruler.cxx:570
ScCsvTableBox * GetTableBox()
Definition: csvruler.hxx:62
void MoveCursorRel(ScMoveMode eDir)
Moves cursor to the given direction.
Definition: csvruler.cxx:198
void ImplSetMousePointer(sal_Int32 nPos)
Sets arrow or horizontal split pointer.
Definition: csvruler.cxx:651
sal_Int32 mnPosCursorLast
Old state for cancellation.
Definition: csvruler.hxx:49
ScCsvSplits maSplits
Split area color.
Definition: csvruler.hxx:46
void MoveSplit(sal_Int32 nPos, sal_Int32 nNewPos)
Moves a split from nPos to nNewPos.
Definition: csvruler.cxx:304
sal_Int32 GetSplitPos(sal_uInt32 nIndex) const
Returns the position of the specified split.
Definition: csvruler.hxx:94
void ImplEraseSplit(sal_Int32 nPos)
Erases a split from maRulerDev.
Definition: csvruler.cxx:617
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:641
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Creates a new accessible object.
Definition: csvruler.cxx:658
virtual void GetFocus() override
Definition: csvruler.cxx:377
Color maBackColor
Ruler with splits and cursor.
Definition: csvruler.hxx:41
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:417
ScCsvSplits maOldSplits
Vector with split positions.
Definition: csvruler.hxx:47
virtual tools::Rectangle GetFocusRect() override
Definition: csvruler.cxx:541
const ScCsvSplits & GetSplits() const
Returns the split array.
Definition: csvruler.hxx:89
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: csvruler.cxx:105
virtual ~ScCsvRuler() override
Definition: csvruler.cxx:125
tools::Long Width() const
virtual void LoseFocus() override
Definition: csvruler.cxx:386
A vector of column splits that supports inserting, removing and moving splits.
Definition: csvsplits.hxx:33
bool HasSplit(sal_Int32 nPos) const
Returns true if at position nPos is a split.
Definition: csvruler.hxx:100
ScCsvTableBox * mpTableBox
Definition: csvruler.hxx:36
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:401
sal_uInt32 GetSplitCount() const
Returns the number of splits.
Definition: csvruler.hxx:91
void MoveCursor(sal_Int32 nPos, bool bScroll=true)
Moves cursor to a new position.
Definition: csvruler.cxx:188
void RemoveAllSplits()
Removes all splits of the ruler.
Definition: csvruler.cxx:316
void MoveCurrSplitRel(ScMoveMode eDir)
Moves split and cursor to the given direction and commits event.
Definition: csvruler.cxx:358
void MoveCurrSplit(sal_Int32 nNewPos)
Moves split and cursor to nNewPos and commits event.
Definition: csvruler.cxx:350
void MoveCursorToSplit(ScMoveMode eDir)
Sets cursor to an existing split, according to eDir.
Definition: csvruler.cxx:226
void ImplDrawSplit(sal_Int32 nPos)
Draws a split to maRulerDev.
Definition: csvruler.cxx:604
ScopedVclPtrInstance< VirtualDevice > maBackgrDev
Grid Parent.
Definition: csvruler.hxx:38
The control in the CSV import dialog that contains a ruler and a data grid to visualize and modify th...
Definition: csvtablebox.hxx:44
sal_Int32 FindEmptyPos(sal_Int32 nPos, ScMoveMode eDir) const
Finds next position without a split.
Definition: csvruler.cxx:322
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: csvruler.cxx:522
virtual void Resize() override
Definition: csvruler.cxx:370
void ApplyLayout(const ScCsvLayoutData &rOldData)
Apply current layout data to the ruler.
Definition: csvruler.cxx:132
void MoveMouseTracking(sal_Int32 nPos)
Moves tracking to a new position.
Definition: csvruler.cxx:496
Size maWinSize
Tracking: Anytime moved to another position?
Definition: csvruler.hxx:54
tools::Long Height() const
sal_Int32 mnSplitSize
The active area of the ruler.
Definition: csvruler.hxx:56
Color maSplitColor
Text and scale color.
Definition: csvruler.hxx:44
void UpdateSplitSize()
Update the split size depending on the last width set by CSVCMD_SETCHARWIDTH.
Definition: csvruler.cxx:165
sal_Int32 GetNoScrollPos(sal_Int32 nPos) const
Finds a position nearest to nPos which does not cause scrolling the visible area. ...
Definition: csvruler.cxx:267
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: csvruler.cxx:427
tools::Rectangle maActiveRect
Size of the control.
Definition: csvruler.hxx:55
ScopedVclPtrInstance< VirtualDevice > maRulerDev
Ruler background, scaling.
Definition: csvruler.hxx:39
void EndMouseTracking()
Applies tracking action for the current tracking position.
Definition: csvruler.cxx:512
void ImplDrawArea(sal_Int32 nPosX, sal_Int32 nWidth)
Draws the background and active area to maBackgrDev (only the given X range).
Definition: csvruler.cxx:549
sal_Int32 mnPosMTCurr
Start position of mouse tracking.
Definition: csvruler.hxx:51
sal_uInt32 Count() const
Returns the number of splits.
Definition: csvsplits.hxx:69
sal_Int32 GetWidth() const
Returns the width of the control.
Definition: csvruler.hxx:152
sal_Int32 mnPosMTStart
Last valid position of cursor.
Definition: csvruler.hxx:50
void InitColors()
Reads colors from system settings.
Definition: csvruler.cxx:155
void ImplDrawRulerDev()
Draws the ruler background, all splits and the cursor to maRulerDev.
Definition: csvruler.cxx:629
A structure containing all layout data valid for both ruler and data grid (i.e.
Definition: csvcontrol.hxx:112
sal_Int32 GetHeight() const
Returns the height of the control.
Definition: csvruler.hxx:154