fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / inc / csvruler.hxx
blob44f8a765bddb3aba4628b9398e21874f0093c555
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_UI_INC_CSVRULER_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_CSVRULER_HXX
23 #include <vcl/virdev.hxx>
24 #include "csvcontrol.hxx"
25 #include "csvsplits.hxx"
26 #include "scdllapi.h"
28 class ScAccessibleCsvControl;
30 /** A ruler control for the CSV import dialog. Supports setting and moving
31 splits (which divide lines of data into several columns). */
32 class SC_DLLPUBLIC ScCsvRuler : public ScCsvControl
34 private:
35 ScopedVclPtrInstance<VirtualDevice> maBackgrDev;/// Ruler background, scaling.
36 ScopedVclPtrInstance<VirtualDevice> maRulerDev; /// Ruler with splits and cursor.
38 Color maBackColor; /// Background color.
39 Color maActiveColor; /// Color for active part of ruler.
40 Color maTextColor; /// Text and scale color.
41 Color maSplitColor; /// Split area color.
43 ScCsvSplits maSplits; /// Vector with split positions.
44 ScCsvSplits maOldSplits; /// Old state for cancellation.
46 sal_Int32 mnPosCursorLast; /// Last valid position of cursor.
47 sal_Int32 mnPosMTStart; /// Start position of mouse tracking.
48 sal_Int32 mnPosMTCurr; /// Current position of mouse tracking.
49 bool mbPosMTMoved; /// Tracking: Anytime moved to another position?
51 Size maWinSize; /// Size of the control.
52 Rectangle maActiveRect; /// The active area of the ruler.
53 sal_Int32 mnSplitSize; /// Size of a split circle.
55 public:
56 explicit ScCsvRuler( ScCsvControl& rParent );
57 virtual ~ScCsvRuler();
58 virtual void dispose() SAL_OVERRIDE;
60 // common ruler handling --------------------------------------------------
61 public:
62 /** Sets position and size of the ruler. The height is calculated internally. */
63 virtual void setPosSizePixel(
64 long nX, long nY,
65 long nWidth, long nHeight,
66 PosSizeFlags nFlags = PosSizeFlags::All ) SAL_OVERRIDE;
68 /** Apply current layout data to the ruler. */
69 void ApplyLayout( const ScCsvLayoutData& rOldData );
71 private:
72 /** Reads colors from system settings. */
73 SAL_DLLPRIVATE void InitColors();
74 /** Initializes all data dependent from the control's size. */
75 SAL_DLLPRIVATE void InitSizeData();
77 /** Moves cursor to a new position.
78 @param bScroll sal_True = The method may scroll the ruler. */
79 SAL_DLLPRIVATE void MoveCursor( sal_Int32 nPos, bool bScroll = true );
80 /** Moves cursor to the given direction. */
81 SAL_DLLPRIVATE void MoveCursorRel( ScMoveMode eDir );
82 /** Sets cursor to an existing split, according to eDir. */
83 SAL_DLLPRIVATE void MoveCursorToSplit( ScMoveMode eDir );
84 /** Scrolls data grid vertically. */
85 SAL_DLLPRIVATE void ScrollVertRel( ScMoveMode eDir );
87 // split handling ---------------------------------------------------------
88 public:
89 /** Returns the split array. */
90 inline const ScCsvSplits& GetSplits() const { return maSplits; }
91 /** Returns the number of splits. */
92 inline sal_uInt32 GetSplitCount() const
93 { return maSplits.Count(); }
94 /** Returns the position of the specified split. */
95 inline sal_Int32 GetSplitPos( sal_uInt32 nIndex ) const
96 { return maSplits[ nIndex ]; }
97 /** Finds a position nearest to nPos which does not cause scrolling the visible area. */
98 sal_Int32 GetNoScrollPos( sal_Int32 nPos ) const;
100 /** Returns true if at position nPos is a split. */
101 inline bool HasSplit( sal_Int32 nPos ) const { return maSplits.HasSplit( nPos ); }
102 /** Inserts a split. */
103 void InsertSplit( sal_Int32 nPos );
104 /** Removes a split. */
105 void RemoveSplit( sal_Int32 nPos );
106 /** Moves a split from nPos to nNewPos. */
107 void MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos );
108 /** Removes all splits of the ruler. */
109 void RemoveAllSplits();
111 private:
112 /** Finds next position without a split. */
113 SAL_DLLPRIVATE sal_Int32 FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const;
115 /** Moves split and cursor to nNewPos and commits event. */
116 SAL_DLLPRIVATE void MoveCurrSplit( sal_Int32 nNewPos );
117 /** Moves split and cursor to the given direction and commits event. */
118 SAL_DLLPRIVATE void MoveCurrSplitRel( ScMoveMode eDir );
120 // event handling ---------------------------------------------------------
121 protected:
122 virtual void Resize() SAL_OVERRIDE;
123 virtual void GetFocus() SAL_OVERRIDE;
124 virtual void LoseFocus() SAL_OVERRIDE;
125 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
127 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
128 virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
129 virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
131 virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
133 private:
134 /** Starts tracking at the specified position. */
135 SAL_DLLPRIVATE void StartMouseTracking( sal_Int32 nPos );
136 /** Moves tracking to a new position. */
137 SAL_DLLPRIVATE void MoveMouseTracking( sal_Int32 nPos );
138 /** Applies tracking action for the current tracking position.
139 @param bApply sal_True = apply action, sal_False = cancel action. */
140 SAL_DLLPRIVATE void EndMouseTracking( bool bApply );
142 // painting ---------------------------------------------------------------
143 protected:
144 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& ) SAL_OVERRIDE;
146 public:
147 /** Redraws the entire ruler. */
148 void ImplRedraw();
150 private:
151 /** Returns the width of the control. */
152 inline sal_Int32 GetWidth() const { return maWinSize.Width(); }
153 /** Returns the height of the control. */
154 inline sal_Int32 GetHeight() const { return maWinSize.Height(); }
156 /** Draws the background and active area to maBackgrDev (only the given X range). */
157 SAL_DLLPRIVATE void ImplDrawArea( sal_Int32 nPosX, sal_Int32 nWidth );
158 /** Draws the entire ruler background with scaling to maBackgrDev. */
159 SAL_DLLPRIVATE void ImplDrawBackgrDev();
161 /** Draws a split to maRulerDev. */
162 SAL_DLLPRIVATE void ImplDrawSplit( sal_Int32 nPos );
163 /** Erases a split from maRulerDev. */
164 SAL_DLLPRIVATE void ImplEraseSplit( sal_Int32 nPos );
165 /** Draws the ruler background, all splits and the cursor to maRulerDev. */
166 SAL_DLLPRIVATE void ImplDrawRulerDev();
168 /** Inverts the cursor bar at the specified position in maRulerDev. */
169 SAL_DLLPRIVATE void ImplInvertCursor( sal_Int32 nPos );
170 /** Draws directly tracking rectangle to the column with the specified index. */
171 SAL_DLLPRIVATE void ImplDrawTrackingRect();
173 /** Sets arrow or horizontal split pointer. */
174 SAL_DLLPRIVATE void ImplSetMousePointer( sal_Int32 nPos );
176 // accessibility ----------------------------------------------------------
177 protected:
178 /** Creates a new accessible object. */
179 virtual ScAccessibleCsvControl* ImplCreateAccessible() SAL_OVERRIDE;
182 #endif
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */