mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-12-02 17:12:55 +00:00
6d5ffa9f8e
There's still some cleanup to do, but everything seems to be working nicely: `make -j` works, `make distcheck` passes. There is probably plenty of bitrot in the package directories (RPM, debian), though. The vc project files have been removed since those versions are way out of date and quakeforge is pretty much dependent on gcc now anyway. Most of the old Makefile.am files are now Makemodule.am. This should allow for new Makefile.am files that allow local building (to be added on an as-needed bases). The current remaining Makefile.am files are for standalone sub-projects.a The installable bins are currently built in the top-level build directory. This may change if the clutter gets to be too much. While this does make a noticeable difference in build times, the main reason for the switch was to take care of the growing dependency issues: now it's possible to build tools for code generation (eg, using qfcc and ruamoko programs for code-gen).
146 lines
2.5 KiB
R
146 lines
2.5 KiB
R
#include <Array.h>
|
|
#include "ruamoko/qwaq/ui/listener.h"
|
|
#include "ruamoko/qwaq/ui/tableview.h"
|
|
|
|
@implementation TableViewColumn
|
|
-initWithName:(string)name width:(int)width
|
|
{
|
|
if (!(self = [super init])) {
|
|
return nil;
|
|
}
|
|
self.name = name;
|
|
self.width = width;
|
|
return self;
|
|
}
|
|
|
|
+(TableViewColumn *)named:(string)name
|
|
{
|
|
return [[[self alloc] initWithName:name width:-1] autorelease];
|
|
}
|
|
|
|
+(TableViewColumn *)named:(string)name width:(int)width
|
|
{
|
|
return [[[self alloc] initWithName:name width:width] autorelease];
|
|
}
|
|
|
|
-setGrowMode: (int) mode
|
|
{
|
|
growMode = mode;
|
|
return self;
|
|
}
|
|
|
|
-(int)growMode
|
|
{
|
|
return growMode;
|
|
}
|
|
|
|
-(string)name
|
|
{
|
|
return name;
|
|
}
|
|
|
|
-(int)width
|
|
{
|
|
return width;
|
|
}
|
|
|
|
-setWidth:(int)width
|
|
{
|
|
self.width = width;
|
|
return self;
|
|
}
|
|
|
|
-grow:(Extent)delta
|
|
{
|
|
if (growMode & gfGrowHiX) {
|
|
width += delta.width;
|
|
}
|
|
return self;
|
|
}
|
|
@end
|
|
|
|
@implementation TableView
|
|
-initWithRect:(Rect)rect
|
|
{
|
|
if (!(self = [super initWithRect:rect])) {
|
|
return nil;
|
|
}
|
|
options = ofCanFocus | ofRelativeEvents;
|
|
columns = [[Array array] retain];
|
|
buffer = [[DrawBuffer buffer:size] retain];
|
|
[buffer bkgd:' '];
|
|
[onViewScrolled addListener:self :@selector(onScroll:)];
|
|
growMode = gfGrowHi;
|
|
return self;
|
|
}
|
|
|
|
-(void)dealloc
|
|
{
|
|
[columns release];
|
|
[buffer release];
|
|
[dataSource release];
|
|
[super dealloc];
|
|
}
|
|
|
|
+(TableView *)withRect:(Rect)rect
|
|
{
|
|
return [[[self alloc] initWithRect:rect] autorelease];
|
|
}
|
|
|
|
-addColumn:(TableViewColumn *)column
|
|
{
|
|
[columns addObject:column];
|
|
columns_dirty = 1;
|
|
return self;
|
|
}
|
|
|
|
-setDataSource:(id<TableViewDataSource>)dataSource
|
|
{
|
|
self.dataSource = [dataSource retain];
|
|
return self;
|
|
}
|
|
|
|
-resize:(Extent)delta
|
|
{
|
|
Extent size = self.size;
|
|
[super resize:delta];
|
|
[buffer resizeTo:self.size];
|
|
for (int i = [columns count]; i-- > 0; ) {
|
|
[[columns objectAtIndex: i] grow: delta];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-draw
|
|
{
|
|
View *cell;
|
|
TableViewColumn *col;
|
|
[super draw];
|
|
int numCols = [columns count];
|
|
int numRows = [dataSource numberOfRows:self];
|
|
[buffer clear];
|
|
for (int y = 0; y < ylen; y++) {
|
|
for (int i = 0, x = 0; i < numCols; i++) {
|
|
int row = base.y + y;
|
|
if (row >= numRows) {
|
|
break;
|
|
}
|
|
col = [columns objectAtIndex:i];
|
|
cell = [dataSource tableView:self forColumn:col row:row];
|
|
[[[cell setContext:buffer] moveTo:{x, y}] draw];
|
|
x += [col width];
|
|
}
|
|
}
|
|
[textContext blitFromBuffer:buffer to:pos from:[buffer rect]];
|
|
return self;
|
|
}
|
|
|
|
-(void)onScroll:(id)sender
|
|
{
|
|
if (base.y != scroll.y) {
|
|
base.y = scroll.y;
|
|
[self redraw];
|
|
}
|
|
}
|
|
|
|
@end
|