[qwaq] Support resizing the table view

This commit is contained in:
Bill Currie 2020-03-31 22:03:56 +09:00
parent 0da92e33f6
commit beecdcadbf
3 changed files with 30 additions and 1 deletions

View file

@ -87,7 +87,8 @@
locals_data = [[LocalsData withTarget:target] retain];
locals_view = [TableView withRect:{{1, 1}, {38, 8}}];
[locals_view addColumn:[TableViewColumn named:"name" width:12]];
[locals_view addColumn:[TableViewColumn named:"value" width:26]];
[locals_view addColumn:[[TableViewColumn named:"value" width:26]
setGrowMode:gfGrowHiX]];
ScrollBar *sb = [ScrollBar vertical:8 at:{39, 1}];
[locals_view setVerticalScrollBar:sb];
[locals_view setDataSource:locals_data];

View file

@ -21,9 +21,14 @@
{
string name;
int width;
int growMode; // Y flags ignored
}
+(TableViewColumn *)named:(string)name;
+(TableViewColumn *)named:(string)name width:(int)width;
-setGrowMode: (int) mode;
-(int)growMode;
-(string)name;
-(int)width;
@end

View file

@ -23,6 +23,17 @@
return [[[self alloc] initWithName:name width:width] autorelease];
}
-setGrowMode: (int) mode
{
growMode = mode;
return self;
}
-(int)growMode
{
return growMode;
}
-(string)name
{
return name;
@ -38,6 +49,14 @@
self.width = width;
return self;
}
-grow:(Extent)delta
{
if (growMode & gfGrowHiX) {
width += delta.width;
}
return self;
}
@end
@implementation TableView
@ -51,6 +70,7 @@
buffer = [[DrawBuffer buffer:size] retain];
[buffer bkgd:' '];
[onViewScrolled addListener:self :@selector(onScroll:)];
growMode = gfGrowHi;
return self;
}
@ -85,6 +105,9 @@
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;
}