Added NSTableView support

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22985 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott 2003-08-18 02:12:42 +00:00
parent d1bab56647
commit 2e024d8690
3 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,32 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSTableDataSource.h
// Purpose: wxCocoaNSTableDataSource Objective-C class
// Author: David Elliott
// Modified by:
// Created: 2003/08/05
// RCS-ID: $Id$
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSTABLEDATASOURCE_H__
#define __WX_COCOA_NSTABLEDATASOURCE_H__
#import <Foundation/NSObject.h>
// ============================================================================
// @class wxCocoaNSTableDataSource
// ============================================================================
@interface wxCocoaNSTableDataSource : NSObject
{
}
// NSTableDataSource is a loosely defined protocol consisting of the
// following two message implementations
- (int)numberOfRowsInTableView: (NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn: (NSTableColumn *)tableColumn
row: (int)rowIndex;
@end // wxCocoaNSTableDataSource
#endif // _WX_COCOA_NSTABLEDATASOURCE_H_

View File

@ -0,0 +1,29 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSTableView.h
// Purpose: wxCocoaNSTableView class
// Author: David Elliott
// Modified by:
// Created: 2003/08/05
// RCS-ID: $Id$
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSTABLEVIEW_H__
#define __WX_COCOA_NSTABLEVIEW_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
WX_DECLARE_OBJC_HASHMAP(NSTableView);
class wxCocoaNSTableView
{
WX_DECLARE_OBJC_INTERFACE(NSTableView)
public:
virtual int CocoaDataSource_numberOfRows() = 0;
virtual struct objc_object* CocoaDataSource_objectForTableColumn(
WX_NSTableColumn tableColumn, int rowIndex) = 0;
};
#endif // _WX_COCOA_NSTABLEVIEW_H_

58
src/cocoa/NSTableView.mm Normal file
View File

@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cocoa/NSTableView.mm
// Purpose: wxCocoaNSTableView / wxCocoaNSTableDataSource
// Author: David Elliott
// Modified by:
// Created: 2003/08/05
// RCS-ID: $Id$
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#endif // WX_PRECOMP
#include "wx/cocoa/ObjcPose.h"
#include "wx/cocoa/NSTableDataSource.h"
#include "wx/cocoa/NSTableView.h"
#import <AppKit/NSTableView.h>
// ----------------------------------------------------------------------------
// globals
// ----------------------------------------------------------------------------
WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSTableView)
// ============================================================================
// @class wxCocoaNSTableDataSource
// ============================================================================
@implementation wxCocoaNSTableDataSource : NSObject
- (int)numberOfRowsInTableView: (NSTableView *)tableView
{
wxCocoaNSTableView *wxView = wxCocoaNSTableView::GetFromCocoa(tableView);
wxCHECK_MSG(wxView, 0, "No associated wx object");
return wxView->CocoaDataSource_numberOfRows();
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn: (NSTableColumn *)tableColumn
row: (int)rowIndex
{
wxCocoaNSTableView *wxView = wxCocoaNSTableView::GetFromCocoa(tableView);
wxCHECK_MSG(wxView, nil, "No associated wx object");
return wxView->CocoaDataSource_objectForTableColumn(tableColumn,rowIndex);
}
@end // implementation wxCocoaNSTableDataSource