You need to log in to create posts and topics.
Spreadsheet
1,678 Posts
#1 · September 10, 2011, 10:54 am
Quote from Forum Archives on September 10, 2011, 10:54 amPosted by: svanvoorst <svanvoorst@...>
This demo creates a spreadsheet with 65000 cells, each with a unique tag.'----- start ------/*Written by S. Van Voorst {20110910}Demonstrates embedding a matrix in an NSView,which is then embedded in a ScrollView,which is then made the contentView of a window.Creates a spreadsheet with each cell having a unique tag.Tab is functional.*/compile as "Objective-C"if system(_sysVers) < 1060 then stop "Requires OS 10.6 or newer"BeginCCode{NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];[NSApplication sharedApplication];[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];// ******* Menubar ******* //id menubar = [[NSMenu new] autorelease];id appMenuItem = [[NSMenuItem new] autorelease];[menubar addItem:appMenuItem];[NSApp setMainMenu:menubar];// ******* Menu ******** //id appMenu = [[NSMenu new] autorelease];id quitMenuItem = [[[NSMenuItem alloc] initWithTitle:@"Quit"action:@selector(terminate:) keyEquivalent:@"q"] autorelease];[appMenu addItem:quitMenuItem];[appMenuItem setSubmenu:appMenu];// ****** Window ******** //#define _wndW 330#define _wndH 300id window = [ [ NSWindow alloc ]initWithContentRect:NSMakeRect( 0, 0, _wndW, _wndH )styleMask: NSClosableWindowMask | NSTitledWindowMask | NSResizableWindowMaskbacking:NSBackingStoreBuffereddefer:NO];[window center];[window setTitle: @"NSScrollView with embedded matrix" ];// create control view with a frame the size of the matrixNSView *ctrlView=[[NSView alloc] initWithFrame:NSMakeRect( 0, 0, 10000, 13000 )];// ----- NSMatrix ----- ////Use NSActionCell so that we can set tag for eachNSActionCell *cell = [[NSActionCell alloc]init];[cell setBordered:YES];[cell setType:NSTextCellType];[cell setEditable:YES];// Dimensions not critical if sizeToCells is used!id matrix = [[NSMatrix alloc] initWithFrame:NSMakeRect( 0, 0, 0, 0 )mode:NSTrackModeMatrixprototype:cellnumberOfRows:650numberOfColumns:100];[matrix setCellSize:NSMakeSize( 101, 21 )];[matrix setIntercellSpacing: NSMakeSize( -1, -1 )];[matrix sizeToCells];[ctrlView addSubview:matrix];[cell release];[matrix release];int n;NSArray *cellArray = [matrix cells];for( n = 0; n <= 64999 ; n++ ){[[cellArray objectAtIndex: n ] setTitle:[NSString stringWithFormat:@"%d", n+1] ];[[cellArray objectAtIndex: n ] setTag: n + 1 ];}// create the scroll view so that it fills the entire windowNSScrollView *scrollView = [[NSScrollView alloc] initWithFrame: [[window contentView] frame]];[scrollView setHasVerticalScroller:YES];[scrollView setHasHorizontalScroller:YES];[scrollView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];// set ctrlView as the documentView of the scroll view[scrollView setDocumentView:ctrlView];// set the scrollView as the window's contentView[window setContentView:scrollView];[scrollView release];[window makeKeyAndOrderFront:nil];[NSApp activateIgnoringOtherApps:YES];[NSApp run];[pool drain];}EndC'------ end -----Steve Van Voorst
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Posted by: svanvoorst <svanvoorst@...>
This demo creates a spreadsheet with 65000 cells, each with a unique tag.
'----- start ------
/*
Written by S. Van Voorst {20110910}
Demonstrates embedding a matrix in an NSView,
which is then embedded in a ScrollView,
which is then made the contentView of a window.
Creates a spreadsheet with each cell having a unique tag.
Tab is functional.
*/
compile as "Objective-C"
if system(_sysVers) < 1060 then stop "Requires OS 10.6 or newer"
BeginCCode
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
[NSApplication sharedApplication];
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
// ******* Menubar ******* //
id menubar = [[NSMenu new] autorelease];
id appMenuItem = [[NSMenuItem new] autorelease];
[menubar addItem:appMenuItem];
[NSApp setMainMenu:menubar];
// ******* Menu ******** //
id appMenu = [[NSMenu new] autorelease];
id quitMenuItem = [[[NSMenuItem alloc] initWithTitle:@"Quit"
action:@selector(terminate:) keyEquivalent:@"q"] autorelease];
[appMenu addItem:quitMenuItem];
[appMenuItem setSubmenu:appMenu];
// ****** Window ******** //
#define _wndW 330
#define _wndH 300
id window = [ [ NSWindow alloc ]
initWithContentRect:NSMakeRect( 0, 0, _wndW, _wndH )
styleMask: NSClosableWindowMask | NSTitledWindowMask | NSResizableWindowMask
backing:NSBackingStoreBuffered
defer:NO];
[window center];
[window setTitle: @"NSScrollView with embedded matrix" ];
// create control view with a frame the size of the matrix
NSView *ctrlView=[[NSView alloc] initWithFrame:NSMakeRect( 0, 0, 10000, 13000 )];
// ----- NSMatrix ----- //
//Use NSActionCell so that we can set tag for each
NSActionCell *cell = [[NSActionCell alloc]init];
[cell setBordered:YES];
[cell setType:NSTextCellType];
[cell setEditable:YES];
// Dimensions not critical if sizeToCells is used!
id matrix = [[NSMatrix alloc] initWithFrame:NSMakeRect( 0, 0, 0, 0 )
mode:NSTrackModeMatrix
prototype:cell
numberOfRows:650
numberOfColumns:100];
[matrix setCellSize:NSMakeSize( 101, 21 )];
[matrix setIntercellSpacing: NSMakeSize( -1, -1 )];
[matrix sizeToCells];
[ctrlView addSubview:matrix];
[cell release];
[matrix release];
int n;
NSArray *cellArray = [matrix cells];
for( n = 0; n <= 64999 ; n++ )
{
[[cellArray objectAtIndex: n ] setTitle:[NSString stringWithFormat:@"%d", n+1] ];
[[cellArray objectAtIndex: n ] setTag: n + 1 ];
}
// create the scroll view so that it fills the entire window
NSScrollView *scrollView = [[NSScrollView alloc] initWithFrame: [[window contentView] frame]];
[scrollView setHasVerticalScroller:YES];
[scrollView setHasHorizontalScroller:YES];
[scrollView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
// set ctrlView as the documentView of the scroll view
[scrollView setDocumentView:ctrlView];
// set the scrollView as the window's contentView
[window setContentView:scrollView];
[scrollView release];
[window makeKeyAndOrderFront:nil];
[NSApp activateIgnoringOtherApps:YES];
[NSApp run];
[pool drain];
}
EndC
'------ end -----
Steve Van Voorst
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Click for thumbs down.0Click for thumbs up.0