Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / toolkit / inc / controls / table / tablecontrolinterface.hxx
blob008fe9b2b2934372f96bd0663aff056dc2cbb9d5
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 #pragma once
22 #include <sal/types.h>
23 #include <vcl/seleng.hxx>
24 #include <vcl/window.hxx>
26 #include <controls/table/tabletypes.hxx>
27 #include <controls/table/tablemodel.hxx>
29 namespace svt::table
31 //= TableControlAction
32 enum TableControlAction
34 /// moves the cursor in the table control one row up, if possible, by keeping the current column
35 cursorUp,
36 /// moves the cursor in the table control one row down, if possible, by keeping the current column
37 cursorDown,
38 /// moves the cursor in the table control one column to the left, if possible, by keeping the current row
39 cursorLeft,
40 /// moves the cursor in the table control one column to the right, if possible, by keeping the current row
41 cursorRight,
42 /// moves the cursor to the beginning of the current line
43 cursorToLineStart,
44 /// moves the cursor to the end of the current line
45 cursorToLineEnd,
46 /// moves the cursor to the first row, keeping the current column
47 cursorToFirstLine,
48 /// moves the cursor to the last row, keeping the current column
49 cursorToLastLine,
50 /// moves the cursor one page up, keeping the current column
51 cursorPageUp,
52 /// moves the cursor one page down, keeping the current column
53 cursorPageDown,
54 /// moves the cursor to the top-most, left-most cell
55 cursorTopLeft,
56 /// moves the cursor to the bottom-most, right-most cell
57 cursorBottomRight,
58 /// selects the row, where the actual cursor is
59 cursorSelectRow,
60 /// selects the rows, above the actual cursor is
61 cursorSelectRowUp,
62 /// selects the row, beneath the actual cursor is
63 cursorSelectRowDown,
64 /// selects the row, from the actual cursor till top
65 cursorSelectRowAreaTop,
66 /// selects the row, from the actual cursor till bottom
67 cursorSelectRowAreaBottom,
69 /// invalid and final enumeration value, not to be actually used
70 invalidTableControlAction
74 //= TableCellArea
76 enum TableCellArea
78 CellContent,
79 ColumnDivider
83 //= TableCell
85 struct TableCell
87 ColPos nColumn;
88 RowPos nRow;
89 TableCellArea eArea;
91 TableCell( ColPos const i_column, RowPos const i_row )
92 :nColumn( i_column )
93 ,nRow( i_row )
94 ,eArea( CellContent )
100 //= ColumnMetrics
102 struct ColumnMetrics
104 /** the start of the column, in pixels. Might be negative, in case the column is scrolled out of the visible
105 area. Note: see below.
107 tools::Long nStartPixel;
109 /** the end of the column, in pixels, plus 1. Effectively, this is the accumulated width of all columns
110 up to the current one.
112 Huh? Earlier you said that the nStartPixel of columns
113 scrolled out (to the left) of the visible area is
114 negative. Also, where is the promise that there is no gap
115 between columns? The above claim would be true only if the
116 first column always started at zero, and there is never a
117 gap. So these doc comments are inconsistent. How
118 surprising.
120 tools::Long nEndPixel;
122 ColumnMetrics()
123 :nStartPixel(0)
124 ,nEndPixel(0)
128 ColumnMetrics( tools::Long const i_start, tools::Long const i_end )
129 :nStartPixel( i_start )
130 ,nEndPixel( i_end )
136 //= TableArea
138 enum class TableArea
140 ColumnHeaders,
141 RowHeaders,
146 //= ITableControl
148 /** defines a callback interface to be implemented by a concrete table control
150 class SAL_NO_VTABLE ITableControl
152 public:
153 /** hides the cell cursor
155 The method cares for successive calls, that is, for every call to
156 ->hideCursor(), you need one call to ->showCursor. Only if the number
157 of both calls matches, the cursor is really shown.
159 @see showCursor
161 virtual void hideCursor() = 0;
163 /** shows the cell cursor
165 @see hideCursor
167 virtual void showCursor() = 0;
169 /** dispatches an action to the table control
171 @return
172 <TRUE/> if the action could be dispatched successfully, <FALSE/> otherwise. Usual
173 failure conditions include some other instance vetoing the action, or impossibility
174 to execute the action at all (for instance moving up one row when already positioned
175 on the very first row).
177 @see TableControlAction
179 virtual bool dispatchAction( TableControlAction _eAction ) = 0;
181 /** returns selection engine*/
182 virtual SelectionEngine* getSelEngine() = 0;
184 /** returns the table model
186 The returned model is guaranteed to not be <NULL/>.
188 virtual PTableModel getModel() const = 0;
190 /// returns the index of the currently active column
191 virtual ColPos getCurrentColumn() const = 0;
193 /// returns the index of the currently active row
194 virtual RowPos getCurrentRow() const = 0;
196 /// activates the given cell
197 virtual void activateCell( ColPos const i_col, RowPos const i_row ) = 0;
199 /// retrieves the size of the table window, in pixels
200 virtual ::Size getTableSizePixel() const = 0;
202 /// sets a new mouse pointer for the table window
203 virtual void setPointer( PointerStyle i_pointer ) = 0;
205 /// captures the mouse to the table window
206 virtual void captureMouse() = 0;
208 /// releases the mouse, after it had previously been captured
209 virtual void releaseMouse() = 0;
211 /// invalidates the table window
212 virtual void invalidate( TableArea const i_what ) = 0;
214 /// calculates a width, given in pixels, into an AppFont-based width
215 virtual tools::Long pixelWidthToAppFont( tools::Long const i_pixels ) const = 0;
217 /// shows a tracking rectangle
218 virtual void showTracking( tools::Rectangle const & i_location, ShowTrackFlags const i_flags ) = 0;
220 /// hides a previously shown tracking rectangle
221 virtual void hideTracking() = 0;
223 /// does a hit test for the given pixel coordinates
224 virtual TableCell hitTest( const Point& rPoint ) const = 0;
226 /// retrieves the metrics for a given column
227 virtual ColumnMetrics getColumnMetrics( ColPos const i_column ) const = 0;
229 /// determines whether a given row is selected
230 virtual bool isRowSelected( RowPos _nRow ) const = 0;
232 virtual ~ITableControl() {};
235 } // namespace svt::table
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */