mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
ab8692bd96
This was easy to achieve in v6p progs because all return values passed through .return and thus could not be lost. However, Ruamoko progs use a return pointer which can wind up pointed into the void (the return buffer) and thus cause the return value to be lost. Using @return on obj_msg_sendv bounces the return pointer through to the called function. In addition, nil is returned when the forwarding target is nil.
58 lines
954 B
R
58 lines
954 B
R
#include "ruamoko/qwaq/ui/group.h"
|
|
#include "ruamoko/qwaq/ui/proxyview.h"
|
|
|
|
@implementation ProxyView
|
|
+(ProxyView *)withView:(View *)view
|
|
{
|
|
return [[[self alloc] initWithView:view] autorelease];
|
|
}
|
|
|
|
- (void) forward: (SEL) sel : (@va_list) args
|
|
{
|
|
if (!view) {
|
|
@return nil;
|
|
}
|
|
@return obj_msg_sendv (view, sel, args);
|
|
}
|
|
|
|
-initWithView:(View *) view
|
|
{
|
|
if (!(self = [super init])) {
|
|
return nil;
|
|
}
|
|
self.view = [view retain];
|
|
return self;
|
|
}
|
|
|
|
-setOwner:(Group *)owner
|
|
{
|
|
self.owner = owner;
|
|
return [view setOwner:owner];
|
|
}
|
|
|
|
-setView:(View *) view
|
|
{
|
|
int state = [self.view state];
|
|
|
|
if (state & sfInFocus) {
|
|
[self.view loseFocus];
|
|
}
|
|
[self.view hide];
|
|
[self.view setContext:nil];
|
|
[self.view setOwner:nil];
|
|
|
|
[view retain];
|
|
[self.view release];
|
|
self.view = view;
|
|
|
|
[view setOwner:owner];
|
|
[view setContext:[owner context]];
|
|
if (state & sfDrawn) {
|
|
[view draw];
|
|
}
|
|
if (state & sfInFocus) {
|
|
[view takeFocus];
|
|
}
|
|
return self;
|
|
}
|
|
@end
|