mirror of
https://github.com/Airr/nim-cocoa.git
synced 2025-05-10 02:32:08 +00:00
Added NSTabView
This commit is contained in:
parent
6841f17071
commit
956af62b41
7
src/cocoa/NSTabView.nim
Normal file
7
src/cocoa/NSTabView.nim
Normal file
@ -0,0 +1,7 @@
|
||||
{.compile: "widgets/tabview.m".}
|
||||
|
||||
import NSFunctions
|
||||
|
||||
proc newTabBox*(parent: ID, label: cstring; left: cint; top: cint; width: cint; height: cint): ID {.cdecl, importc: "createTabView".}
|
||||
|
||||
proc addTab*(parent: ID, label: cstring) {.cdecl, importc: "addTab".}
|
32
src/cocoa/widgets/tabview.m
Normal file
32
src/cocoa/widgets/tabview.m
Normal file
@ -0,0 +1,32 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "col.h"
|
||||
|
||||
|
||||
id createTabView(id parent, const char *label, int x, int y, int width, int height) {
|
||||
NSString *str = [NSString stringWithUTF8String:label];
|
||||
NSArray *items = [str componentsSeparatedByString: @"|"];
|
||||
|
||||
id *widget = [[[NSTabView alloc] initWithFrame:NSMakeRect(x,y,width,height)] autorelease];
|
||||
|
||||
|
||||
for(NSString *x in items) {
|
||||
id *tabwidget = [[[NSTabViewItem alloc] initWithIdentifier: x ] autorelease];
|
||||
[tabwidget setLabel: x];
|
||||
[widget addTabViewItem: tabwidget];
|
||||
}
|
||||
|
||||
[[parent contentView] addSubview:widget];
|
||||
return widget;
|
||||
}
|
||||
|
||||
void addTab(id parent, const char *name) {
|
||||
NSString *str = [NSString stringWithUTF8String:name];
|
||||
NSArray *items = [str componentsSeparatedByString: @"|"];
|
||||
|
||||
for(NSString *x in items){
|
||||
id *widget = [[[NSTabViewItem alloc] initWithIdentifier: x ] autorelease];
|
||||
[widget setLabel: x];
|
||||
[parent addTabViewItem: widget];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user