// -------------------------------------------------------------------------------------
//  TableView
//  This software is without warranty of any kind.  Use at your own risk.
// -------------------------------------------------------------------------------------

#import <appkit/appkit.h>
#import <dbkit/dbkit.h>
#import <objc/objc.h>
#import <libc.h>
#import <stdlib.h>
#import <string.h>
#import <c.h>
#import <ctype.h>
#import <sys/param.h>
#import <sys/types.h>
#import <sys/time.h>
#import "DataTableView.h"

// -------------------------------------------------------------------------------------
@interface DBTableView(Private)
- mouseDownAt:(u_int)row :(u_int)column inView:aView onEvent:(NXEvent*) e;
- mouseStartedDragAt:(u_int)row :(u_int)column inView:aView onEvent:(NXEvent*)e;
- mouseDraggedTo:(u_int)row :(u_int)column inView:aView onEvent:(NXEvent*)e;
- mouseEndedDragAt:(u_int)row :(u_int)column inView:aView onEvent:(NXEvent*)e;
- mouseUpAt:(u_int)row :(u_int)column inView:aView onEvent:(NXEvent*)e;
@end

// -------------------------------------------------------------------------------------
@implementation TableView
// -------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------
// initialization

/* init */
- initFrame:(const NXRect *) newFrame
{
	id	rtn = [super initFrame:newFrame];
	lastMouseUpRow = -1;
	lastMouseUpColumn = -1;
	return rtn;
}

// -------------------------------------------------------------------------------------
// mouse method overrides

/* mouse up */
- mouseUpAt:(u_int)row :(u_int)column inView:aView onEvent:(NXEvent*)e
{
	if (aView == rowHeading) { lastMouseUpRow = row; lastMouseUpColumn = -1; } else
	if (aView == columnHeading) { lastMouseUpRow = -1; lastMouseUpColumn = row; } else
	if (aView == gridView) { lastMouseUpRow = row; lastMouseUpColumn = column; }
	else { lastMouseUpRow = -1; lastMouseUpColumn = -1; }
	return [super mouseUpAt:row:column inView:aView onEvent:e];
}

/* return last mouse up row */
- (int)selectedCellRow
{
	return lastMouseUpRow;
}

/* return last mouse up column */
- (int)selectedCellColumn
{
	return lastMouseUpColumn;
}

@end
