1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX 25 #define SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX 26 27 #include <sal/types.h> 28 #include <vcl/event.hxx> 29 #include <vcl/seleng.hxx> 30 31 #include "svtools/table/tabletypes.hxx" 32 #include "svtools/table/tablemodel.hxx" 33 34 class Pointer; 35 36 //...................................................................................................................... 37 namespace svt { namespace table 38 { 39 //...................................................................................................................... 40 41 //================================================================================================================== 42 //= TableControlAction 43 //================================================================================================================== 44 enum TableControlAction 45 { 46 /// moves the cursor in the table control one row up, if possible, by keeping the current column 47 cursorUp, 48 /// moves the cursor in the table control one row down, if possible, by keeping the current column 49 cursorDown, 50 /// moves the cursor in the table control one column to the left, if possible, by keeping the current row 51 cursorLeft, 52 /// moves the cursor in the table control one column to the right, if possible, by keeping the current row 53 cursorRight, 54 /// moves the cursor to the beginning of the current line 55 cursorToLineStart, 56 /// moves the cursor to the end of the current line 57 cursorToLineEnd, 58 /// moves the cursor to the first row, keeping the current column 59 cursorToFirstLine, 60 /// moves the cursor to the last row, keeping the current column 61 cursorToLastLine, 62 /// moves the cursor one page up, keeping the current column 63 cursorPageUp, 64 /// moves the cursor one page down, keeping the current column 65 cursorPageDown, 66 /// moves the cursor to the top-most, left-most cell 67 cursorTopLeft, 68 /// moves the cursor to the bottom-most, right-most cell 69 cursorBottomRight, 70 /// selects the row, where the actual cursor is 71 cursorSelectRow, 72 /// selects the rows, above the actual cursor is 73 cursorSelectRowUp, 74 /// selects the row, beneath the actual cursor is 75 cursorSelectRowDown, 76 /// selects the row, from the actual cursor till top 77 cursorSelectRowAreaTop, 78 /// selects the row, from the actual cursor till bottom 79 cursorSelectRowAreaBottom, 80 81 /// invalid and final enumeration value, not to be actually used 82 invalidTableControlAction 83 }; 84 85 //================================================================================================================== 86 //= TableCellArea 87 //================================================================================================================== 88 enum TableCellArea 89 { 90 CellContent, 91 ColumnDivider 92 }; 93 94 //================================================================================================================== 95 //= TableCell 96 //================================================================================================================== 97 struct TableCell 98 { 99 ColPos nColumn; 100 RowPos nRow; 101 TableCellArea eArea; 102 TableCellsvt::table::TableCell103 TableCell() 104 :nColumn( COL_INVALID ) 105 ,nRow( ROW_INVALID ) 106 ,eArea( CellContent ) 107 { 108 } 109 TableCellsvt::table::TableCell110 TableCell( ColPos const i_column, RowPos const i_row ) 111 :nColumn( i_column ) 112 ,nRow( i_row ) 113 ,eArea( CellContent ) 114 { 115 } 116 }; 117 118 //================================================================================================================== 119 //= ColumnMetrics 120 //================================================================================================================== 121 struct ColumnMetrics 122 { 123 /** the start of the column, in pixels. Might be negative, in case the column is scrolled out of the visible 124 area. 125 */ 126 long nStartPixel; 127 128 /** the end of the column, in pixels, plus 1. Effectively, this is the accumulated width of a all columns 129 up to the current one. 130 */ 131 long nEndPixel; 132 ColumnMetricssvt::table::ColumnMetrics133 ColumnMetrics() 134 :nStartPixel(0) 135 ,nEndPixel(0) 136 { 137 } 138 ColumnMetricssvt::table::ColumnMetrics139 ColumnMetrics( long const i_start, long const i_end ) 140 :nStartPixel( i_start ) 141 ,nEndPixel( i_end ) 142 { 143 } 144 }; 145 146 //================================================================================================================== 147 //= TableArea 148 //================================================================================================================== 149 enum TableArea 150 { 151 TableAreaColumnHeaders, 152 TableAreaRowHeaders, 153 TableAreaDataArea, 154 TableAreaAll 155 }; 156 157 //================================================================================================================== 158 //= ITableControl 159 //================================================================================================================== 160 /** defines a callback interface to be implemented by a concrete table control 161 */ 162 class SAL_NO_VTABLE ITableControl 163 { 164 public: 165 /** hides the cell cursor 166 167 The method cares for successive calls, that is, for every call to 168 ->hideCursor(), you need one call to ->showCursor. Only if the number 169 of both calls matches, the cursor is really shown. 170 171 @see showCursor 172 */ 173 virtual void hideCursor() = 0; 174 175 /** shows the cell cursor 176 177 @see hideCursor 178 */ 179 virtual void showCursor() = 0; 180 181 /** dispatches an action to the table control 182 183 @return 184 <TRUE/> if the action could be dispatched successfully, <FALSE/> otherwise. Usual 185 failure conditions include some other instance vetoing the action, or impossibility 186 to execute the action at all (for instance moving up one row when already positioned 187 on the very first row). 188 189 @see TableControlAction 190 */ 191 virtual bool dispatchAction( TableControlAction _eAction ) = 0; 192 193 /** returns selection engine*/ 194 virtual SelectionEngine* getSelEngine() = 0; 195 196 /** returns the table model 197 198 The returned model is guaranteed to not be <NULL/>. 199 */ 200 virtual PTableModel getModel() const = 0; 201 202 /// returns the index of the currently active column 203 virtual ColPos getCurrentColumn() const = 0; 204 205 /// returns the index of the currently active row 206 virtual RowPos getCurrentRow() const = 0; 207 208 /// activates the given cell 209 virtual bool activateCell( ColPos const i_col, RowPos const i_row ) = 0; 210 211 /// retrieves the size of the table window, in pixels 212 virtual ::Size getTableSizePixel() const = 0; 213 214 /// sets a new mouse pointer for the table window 215 virtual void setPointer( Pointer const & i_pointer ) = 0; 216 217 /// captures the mouse to the table window 218 virtual void captureMouse() = 0; 219 220 /// releases the mouse, after it had previously been captured 221 virtual void releaseMouse() = 0; 222 223 /// invalidates the table window 224 virtual void invalidate( TableArea const i_what ) = 0; 225 226 /// calculates a width, given in pixels, into a AppFont-based width 227 virtual long pixelWidthToAppFont( long const i_pixels ) const = 0; 228 229 /// shows a trackign rectangle 230 virtual void showTracking( Rectangle const & i_location, sal_uInt16 const i_flags ) = 0; 231 232 /// hides a prviously shown tracking rectangle 233 virtual void hideTracking() = 0; 234 235 /// does a hit test for the given pixel coordinates 236 virtual TableCell hitTest( const Point& rPoint ) const = 0; 237 238 /// retrieves the metrics for a given column 239 virtual ColumnMetrics getColumnMetrics( ColPos const i_column ) const = 0; 240 241 /// determines whether a given row is selected 242 virtual bool isRowSelected( RowPos _nRow ) const = 0; 243 ~ITableControl()244 virtual ~ITableControl() {}; 245 }; 246 247 //...................................................................................................................... 248 } } // namespace svt::table 249 //...................................................................................................................... 250 251 #endif // SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX 252