mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 14:10:44 +00:00
Browser and TableView initialization added
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@11443 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6d20d72c87
commit
eaa63cd496
1 changed files with 164 additions and 1 deletions
|
@ -25,11 +25,174 @@
|
|||
#include <AppKit/AppKit.h>
|
||||
#include "../../Gorm.h"
|
||||
|
||||
|
||||
@class NSBrowserDelegate;
|
||||
|
||||
NSBrowserDelegate * browserDelegate;
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* NSBrowser Delegate
|
||||
*/
|
||||
@interface NSBrowserDelegate: NSObject
|
||||
{
|
||||
}
|
||||
|
||||
- (int) browser: (NSBrowser *)sender numberOfRowsInColumn: (int)column;
|
||||
- (NSString *) browser: (NSBrowser *)sender titleOfColumn: (int)column;
|
||||
- (void) browser: (NSBrowser *)sender willDisplayCell: (id)cell
|
||||
atRow: (int)row column: (int)column;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSBrowserDelegate
|
||||
|
||||
- (int) browser: (NSBrowser *)sender numberOfRowsInColumn: (int)column
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSString *) browser: (NSBrowser *)sender titleOfColumn: (int)column
|
||||
{
|
||||
return (column==0) ? @"Browser" : @"";
|
||||
}
|
||||
|
||||
- (void) browser: (NSBrowser *)sender
|
||||
willDisplayCell: (id)cell
|
||||
atRow: (int)row
|
||||
column: (int)column
|
||||
{
|
||||
NSDebugLog(@"<%@ %x>: browser %x will display %@ %x at %d,%d",[self class],self,sender,[cell class],cell,row,column);
|
||||
// This code should never be called because there is no row
|
||||
// in our browser. But just in case...
|
||||
[cell setLeaf:YES];
|
||||
[cell setStringValue: @""];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* NSTableView data source
|
||||
*/
|
||||
|
||||
@interface NSTableViewDataSource: NSObject
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSTableViewDataSource
|
||||
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
|
||||
{
|
||||
return [NSString stringWithFormat:@"%d",rowIndex];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Containers Palette Display
|
||||
*/
|
||||
|
||||
@interface ContainersPalette: IBPalette
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation ContainersPalette
|
||||
@end
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(browserDelegate);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) finishInstantiate
|
||||
{
|
||||
|
||||
NSView *contents;
|
||||
NSTableView *tv;
|
||||
NSTableColumn *tc;
|
||||
NSSize contentSize;
|
||||
id v;
|
||||
|
||||
window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 272, 192)
|
||||
styleMask: NSBorderlessWindowMask
|
||||
backing: NSBackingStoreRetained
|
||||
defer: NO];
|
||||
contents = [window contentView];
|
||||
|
||||
/*******************/
|
||||
/* First Column... */
|
||||
/*******************/
|
||||
|
||||
|
||||
// NSBrowser
|
||||
// 124 is the minimum width. Below that the browser doesn't display !!
|
||||
v = [[NSBrowser alloc] initWithFrame: NSMakeRect(10, 38, 124, 116)];
|
||||
|
||||
browserDelegate = [[NSBrowserDelegate alloc] init];
|
||||
[v setDelegate:browserDelegate];
|
||||
|
||||
[v setHasHorizontalScroller: YES];
|
||||
[v setTitled: YES];
|
||||
[v loadColumnZero];
|
||||
|
||||
//[v setTitle: @"Browser" ofColumn:0];
|
||||
//[v setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
// browserDelegate = [[NSBrowserDelegate alloc] init];
|
||||
//[v setDelegate:browserDelegate];
|
||||
// [v setMaxVisibleColumns: 3];
|
||||
//[v setAllowsMultipleSelection:NO];
|
||||
// [v setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
||||
|
||||
/********************/
|
||||
/* Second Column... */
|
||||
/********************/
|
||||
|
||||
|
||||
// NSTableView
|
||||
v = [[NSScrollView alloc] initWithFrame: NSMakeRect(136, 38, 124, 116)];
|
||||
|
||||
[v setHasVerticalScroller: YES];
|
||||
[v setHasHorizontalScroller: NO];
|
||||
//[v setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
||||
contentSize = [v contentSize];
|
||||
|
||||
tv = [[NSTableView alloc] initWithFrame:
|
||||
NSMakeRect(0,0,contentSize.width, contentSize.height)];
|
||||
// [tv setDataSource: [[NSTableViewDataSource alloc] init]];
|
||||
[tv setAutoresizesAllColumnsToFit: YES];
|
||||
[v setDocumentView: tv];
|
||||
RELEASE(tv);
|
||||
|
||||
tc = [[NSTableColumn alloc] initWithIdentifier: @"table"];
|
||||
[[tc headerCell] setStringValue: @" "];
|
||||
[tc setWidth: contentSize.width/2];
|
||||
[tc setResizable: YES];
|
||||
[tc setEditable: YES];
|
||||
[tv addTableColumn: tc];
|
||||
RELEASE(tc);
|
||||
|
||||
tc = [[NSTableColumn alloc] initWithIdentifier: @"view"];
|
||||
[[tc headerCell] setStringValue: @" "];
|
||||
[tc setMinWidth: contentSize.width/2];
|
||||
[tc setResizable: YES];
|
||||
[tc setEditable: YES];
|
||||
[tv addTableColumn: tc];
|
||||
RELEASE(tc);
|
||||
[tv setFrame: NSMakeRect(0,0,contentSize.width, contentSize.height)];
|
||||
|
||||
[v setDocumentView: tv];
|
||||
[contents addSubview: v];
|
||||
RELEASE(tv);
|
||||
RELEASE(v);
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue