1 /* 2 NSMatrix.h 3 4 Copyright (C) 1996-2015 Free Software Foundation, Inc. 5 6 Author: Ovidiu Predescu <ovidiu@net-community.com> 7 Date: March 1997 8 A completely rewritten version of the original source by Pascal Forget and 9 Scott Christley. 10 11 This file is part of the GNUstep GUI Library. 12 13 This library is free software; you can redistribute it and/or 14 modify it under the terms of the GNU Lesser General Public 15 License as published by the Free Software Foundation; either 16 version 2 of the License, or (at your option) any later version. 17 18 This library is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 Lesser General Public License for more details. 22 23 You should have received a copy of the GNU Lesser General Public 24 License along with this library; see the file COPYING.LIB. 25 If not, see <http://www.gnu.org/licenses/> or write to the 26 Free Software Foundation, 51 Franklin Street, Fifth Floor, 27 Boston, MA 02110-1301, USA. 28 */ 29 30 #ifndef _GNUstep_H_NSMatrix 31 #define _GNUstep_H_NSMatrix 32 #import <GNUstepBase/GSVersionMacros.h> 33 34 #import <AppKit/NSControl.h> 35 36 @class NSArray; 37 @class NSMutableArray; 38 @class NSNotification; 39 40 @class NSCell; 41 @class NSColor; 42 @class NSText; 43 @class NSEvent; 44 45 typedef enum _NSMatrixMode { 46 NSRadioModeMatrix, 47 NSHighlightModeMatrix, 48 NSListModeMatrix, 49 NSTrackModeMatrix 50 } NSMatrixMode; 51 52 @protocol NSMatrixDelegate <NSControlTextEditingDelegate> 53 @end 54 55 @interface NSMatrix : NSControl <NSCoding> 56 { 57 __strong id **_cells; 58 BOOL **_selectedCells; 59 NSInteger _maxRows; 60 NSInteger _maxCols; 61 NSInteger _numRows; 62 NSInteger _numCols; 63 NSZone *_myZone; 64 Class _cellClass; 65 id _cellPrototype; 66 IMP _cellNew; 67 IMP _cellInit; 68 NSMatrixMode _mode; 69 NSSize _cellSize; 70 NSSize _intercell; 71 NSColor *_backgroundColor; 72 NSColor *_cellBackgroundColor; 73 id _delegate; 74 NSText* _textObject; 75 BOOL _tabKeyTraversesCells; 76 id _target; 77 SEL _action; 78 SEL _doubleAction; 79 SEL _errorAction; 80 id _selectedCell; 81 NSInteger _selectedRow; 82 NSInteger _selectedColumn; 83 BOOL _allowsEmptySelection; 84 BOOL _selectionByRect; 85 BOOL _drawsBackground; 86 BOOL _drawsCellBackground; 87 BOOL _autosizesCells; 88 BOOL _autoscroll; 89 id _reserved1; 90 NSInteger _dottedRow; 91 NSInteger _dottedColumn; 92 } 93 94 /* 95 * Initializing the NSMatrix Class 96 */ 97 + (Class) cellClass; 98 + (void) setCellClass: (Class)classId; 99 100 /* 101 * Initializing an NSMatrix Object 102 */ 103 - (id) initWithFrame: (NSRect)frameRect; 104 - (id) initWithFrame: (NSRect)frameRect 105 mode: (NSMatrixMode)aMode 106 cellClass: (Class)classId 107 numberOfRows: (NSInteger)rowsHigh 108 numberOfColumns: (NSInteger)colsWide; 109 - (id) initWithFrame: (NSRect)frameRect 110 mode: (NSMatrixMode)aMode 111 prototype: (NSCell *)aCell 112 numberOfRows: (NSInteger)rowsHigh 113 numberOfColumns: (NSInteger)colsWide; 114 115 /* 116 * Setting the Selection Mode 117 */ 118 - (NSMatrixMode) mode; 119 - (void) setMode: (NSMatrixMode)aMode; 120 121 /* 122 * Configuring the NSMatrix 123 */ 124 - (BOOL) allowsEmptySelection; 125 - (BOOL) isSelectionByRect; 126 - (void) setAllowsEmptySelection: (BOOL)flag; 127 - (void) setSelectionByRect: (BOOL)flag; 128 129 /* 130 * Setting the Cell Class 131 */ 132 - (Class) cellClass; 133 - (id) prototype; 134 - (void) setCellClass: (Class)classId; 135 - (void) setPrototype: (NSCell *)aCell; 136 137 /* 138 * Laying Out the NSMatrix 139 */ 140 - (void) addColumn; 141 - (void) addColumnWithCells: (NSArray *)cellArray; 142 - (void) addRow; 143 - (void) addRowWithCells: (NSArray *)cellArray; 144 - (NSRect) cellFrameAtRow: (NSInteger)row 145 column: (NSInteger)column; 146 - (NSSize) cellSize; 147 - (void) getNumberOfRows: (NSInteger *)rowCount 148 columns: (NSInteger *)columnCount; 149 - (void) insertColumn: (NSInteger)column; 150 - (void) insertColumn: (NSInteger)column withCells: (NSArray *)cellArray; 151 - (void) insertRow: (NSInteger)row; 152 - (void) insertRow: (NSInteger)row withCells: (NSArray *)cellArray; 153 - (NSSize) intercellSpacing; 154 - (NSCell *) makeCellAtRow: (NSInteger)row 155 column: (NSInteger)column; 156 - (void) putCell: (NSCell *)newCell 157 atRow: (NSInteger)row 158 column: (NSInteger)column; 159 - (void) removeColumn: (NSInteger)column; 160 - (void) removeRow: (NSInteger)row; 161 - (void) renewRows: (NSInteger)newRows 162 columns: (NSInteger)newColumns; 163 - (void) setCellSize: (NSSize)aSize; 164 - (void) setIntercellSpacing: (NSSize)aSize; 165 - (void) sortUsingFunction: (NSComparisonResult (*)(id element1, id element2, void *userData))comparator 166 context: (void *)context; 167 - (void) sortUsingSelector: (SEL)comparator; 168 - (NSInteger) numberOfColumns; 169 - (NSInteger) numberOfRows; 170 171 /* 172 * Finding Matrix Coordinates 173 */ 174 - (BOOL) getRow: (NSInteger *)row 175 column: (NSInteger *)column 176 forPoint: (NSPoint)aPoint; 177 - (BOOL) getRow: (NSInteger *)row 178 column: (NSInteger *)column 179 ofCell: (NSCell *)aCell; 180 181 /* 182 * Modifying Individual Cells 183 */ 184 - (void) setState: (NSInteger)value 185 atRow: (NSInteger)row 186 column: (NSInteger)column; 187 188 /* 189 * Selecting Cells 190 */ 191 - (void) deselectAllCells; 192 - (void) deselectSelectedCell; 193 - (void) selectAll: (id)sender; 194 - (void) selectCellAtRow: (NSInteger)row 195 column: (NSInteger)column; 196 - (BOOL) selectCellWithTag: (NSInteger)anInt; 197 - (id) selectedCell; 198 - (NSArray *) selectedCells; 199 - (NSInteger) selectedColumn; 200 - (NSInteger) selectedRow; 201 - (void) setSelectionFrom: (NSInteger)startPos 202 to: (NSInteger)endPos 203 anchor: (NSInteger)anchorPos 204 highlight: (BOOL)flag; 205 206 /* 207 * Finding Cells 208 */ 209 - (id) cellAtRow: (NSInteger)row 210 column: (NSInteger)column; 211 - (id) cellWithTag: (NSInteger)anInt; 212 - (NSArray *) cells; 213 214 /* 215 * Modifying Graphic Attributes 216 */ 217 - (NSColor *) backgroundColor; 218 - (NSColor *) cellBackgroundColor; 219 - (BOOL) drawsBackground; 220 - (BOOL) drawsCellBackground; 221 - (void) setBackgroundColor: (NSColor *)aColor; 222 - (void) setCellBackgroundColor: (NSColor *)aColor; 223 - (void) setDrawsBackground: (BOOL)flag; 224 - (void) setDrawsCellBackground: (BOOL)flag; 225 226 /* 227 * Editing Text in Cells 228 */ 229 - (void) selectText: (id)sender; 230 - (id) selectTextAtRow: (NSInteger)row 231 column: (NSInteger)column; 232 - (void) textDidBeginEditing: (NSNotification *)aNotification; 233 - (void) textDidChange: (NSNotification *)aNotification; 234 - (void) textDidEndEditing: (NSNotification *)aNotification; 235 - (BOOL) textShouldBeginEditing: (NSText *)aTextObject; 236 - (BOOL) textShouldEndEditing: (NSText *)aTextObject; 237 238 /* 239 * Setting Tab Key Behavior 240 */ 241 - (id) keyCell; 242 - (void) setKeyCell: (NSCell *)aCell; 243 - (id) nextText; 244 - (id) previousText; 245 - (void) setNextText: (id)anObject; 246 - (void) setPreviousText: (id)anObject; 247 - (BOOL) tabKeyTraversesCells; 248 - (void) setTabKeyTraversesCells: (BOOL)flag; 249 250 /* 251 * Assigning a Delegate 252 */ 253 - (void) setDelegate: (id)anObject; 254 - (id) delegate; 255 256 /* 257 * Resizing the Matrix and Cells 258 */ 259 - (BOOL) autosizesCells; 260 - (void) setAutosizesCells: (BOOL)flag; 261 - (void) setValidateSize: (BOOL)flag; 262 - (void) sizeToCells; 263 264 /* 265 * Scrolling 266 */ 267 - (BOOL) isAutoscroll; 268 - (void) scrollCellToVisibleAtRow: (NSInteger)row 269 column: (NSInteger)column; 270 - (void) setAutoscroll: (BOOL)flag; 271 - (void) setScrollable: (BOOL)flag; 272 273 /* 274 * Displaying 275 */ 276 - (void) drawCellAtRow: (NSInteger)row 277 column: (NSInteger)column; 278 - (void) highlightCell: (BOOL)flag 279 atRow: (NSInteger)row 280 column: (NSInteger)column; 281 282 /* 283 *Target and Action 284 */ 285 - (void) setAction: (SEL)aSelector; 286 - (SEL) action; 287 - (void) setDoubleAction: (SEL)aSelector; 288 - (SEL) doubleAction; 289 - (void) setErrorAction: (SEL)aSelector; 290 - (SEL) errorAction; 291 - (BOOL) sendAction; 292 - (void) sendAction: (SEL)aSelector 293 to: (id)anObject 294 forAllCells: (BOOL)flag; 295 - (void) sendDoubleAction; 296 297 /* 298 * Handling Event and Action Messages 299 */ 300 - (BOOL) acceptsFirstMouse: (NSEvent *)theEvent; 301 - (void) mouseDown: (NSEvent *)theEvent; 302 - (NSInteger) mouseDownFlags; 303 - (BOOL) performKeyEquivalent: (NSEvent *)theEvent; 304 305 /* 306 * Managing the Cursor 307 */ 308 - (void) resetCursorRects; 309 310 /* 311 * Handling tool tips 312 */ 313 - (NSString *) toolTipForCell: (NSCell *)cell; 314 - (void) setToolTip: (NSString *)toolTipString forCell: (NSCell *)cell; 315 316 @end 317 318 #endif /* _GNUstep_H_NSMatrix */ 319