mirror of
https://github.com/Airr/nim-cocoa.git
synced 2024-11-24 09:45:30 +00:00
Implemented Add/Save for TableView
This commit is contained in:
parent
f4a06bf928
commit
27ebd03c48
@ -4,4 +4,6 @@ import NSFunctions
|
||||
|
||||
proc newTableview*(parent: ID, left, top, width, height: cint): ID {.cdecl, importc: "createTableView".}
|
||||
proc addColumn*(parent: ID, name: cstring) {.cdecl, importc: "newTableColumn".}
|
||||
proc addRow*(parent: ID, person: cstring) {.cdecl, importc: "addRow".}
|
||||
proc addRow*(parent: ID, person: cstring) {.cdecl, importc: "addRow".}
|
||||
proc saveTableView*(tview: ID, path: cstring) {.cdecl, importc: "tableviewSaveToFile".}
|
||||
proc loadTableView*(tview: ID, path: cstring) {.cdecl, importc: "tableviewLoadFromFile".}
|
@ -23,6 +23,7 @@
|
||||
|
||||
tbl = [[NSTableView alloc] initWithFrame: NSMakeRect(5,40,335,185)];
|
||||
[tbl setGridStyleMask: NSTableViewGridNone];
|
||||
[tbl setUsesAlternatingRowBackgroundColors: YES];
|
||||
[tbl setAllowsColumnSelection: YES];
|
||||
[tbl setAllowsColumnReordering: YES];
|
||||
[tbl setAllowsEmptySelection: NO];
|
||||
@ -112,4 +113,19 @@ void newTableColumn(id parent, const char *name) {
|
||||
[tCol setTitle: title];
|
||||
|
||||
[[parent tbl] addTableColumn: tCol];
|
||||
}
|
||||
|
||||
void tableviewSaveToFile(id tview, const char *path) {
|
||||
|
||||
[[tview db] writeToFile: NSSTR(path) atomically:YES];
|
||||
}
|
||||
|
||||
void tableviewLoadFromFile(id tview, const char *path) {
|
||||
NSArray *fileArrary = [NSArray arrayWithContentsOfFile: NSSTR(path)];
|
||||
[[tview db] removeAllObjects];
|
||||
for (NSMutableDictionary *x in fileArrary) {
|
||||
[[tview db] addObject: x];
|
||||
}
|
||||
|
||||
[[tview tbl] reloadData];
|
||||
}
|
Loading…
Reference in New Issue
Block a user