/* ** ExtendedMatrix.h ** ** Copyright (c) 2003 ** ** Author: Yen-Ju Chen ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Try to handle the Drag & Drop and in-place editing. ** You have to register the pasteboard type in the ** delegate method (createRowForColumn:) of NSBrowser ** This is a specialized matrix for NSBrowser. */ #ifndef _Toolbox_H_ExtendedMatrix #define _Toolbox_H_ExtendedMatrix #include #include typedef enum _ExtendedMatrixDropOperation { ExtendedMatrixDropOn, ExtendedMatrixDropAbove } ExtendedMatrixDropOperation; @class NSCell; @class NSEvent; @class NSText; @class NSNotification; @interface ExtendedMatrix : NSMatrix { id _editorDelegate; int _editedRow; int _editedColumn; NSCell *_editedCell; int _newDropRow; ExtendedMatrixDropOperation _newDropOperation; } /* Delegate for editing and drag & drop */ - (void) setEditorDelegate: (id) delegate; - (id) editorDelegate; /* Editing */ - (void) editColumn: (int) columnIndex row: (int) rowIndex withEvent: (NSEvent *) theEvent select: (BOOL) flag; - (void) validateEditing; - (BOOL) abortEditing; - (NSText *) currentEditor; /* Drag Source */ - (void) startExternalDragOnEvent: (NSEvent *) event; - (NSDragOperation) draggingSourceOperationMaskForLocal: (BOOL) flag; /* Drag Destination */ /* Have to be coupled with NSBrowser. * Register PboardType when -createRows:inMatrix */ - (void) setDropRow: (int) row dropOperation: (ExtendedMatrixDropOperation) operation; - (NSDragOperation) draggingEntered: (id ) sender; - (NSDragOperation) draggingUpdated: (id ) sender; - (void) draggingExited: (id ) sender; - (BOOL) performDragOperation: (id ) sender; - (BOOL) prepareForDragOperation: (id ) sender; - (void) concludeDragOperation: (id ) sender; /* Text delegate methods */ - (BOOL) textShouldBeginEditing: (NSText *)textObject; - (void) textDidBeginEditing: (NSNotification *)aNotification; - (void) textDidChange: (NSNotification *)aNotification; - (BOOL) textShouldEndEditing: (NSText *)textObject; - (void) textDidEndEditing: (NSNotification *)aNotification; @end @interface NSObject (ExtendedMatrix) /* Drag & Drop */ - (BOOL) matrix: (ExtendedMatrix *) view writeRows: (int) row inColumn: (int) column toPasteboard: (NSPasteboard *) pboard; - (NSDragOperation) matrix: (ExtendedMatrix *) view validateDrop: (id ) info proposedRow: (int) row proposedDropOperation: (ExtendedMatrixDropOperation) operation; - (BOOL) matrix: (ExtendedMatrix *) view acceptDrop: (id ) info row: (int) row proposedDropOperation: (ExtendedMatrixDropOperation) operation; /* Editing */ - (void) matrix: (NSMatrix *) matrix setObjectValue: (id) object forRow: (int) row column: (int) column; @end #endif /* _Toolbox_H_ExtendedMatrix */