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