[qwaq] Add a proxy view class

The idea is that the view can be switched out readily: the proxy simply
passes all messages to its view object.
This commit is contained in:
Bill Currie 2020-03-24 21:02:54 +09:00
parent 05e377c3ac
commit fd0700f9ae
3 changed files with 56 additions and 0 deletions

View file

@ -32,6 +32,7 @@ qwaq_app_dat_src= \
qwaq-garray.r \ qwaq-garray.r \
qwaq-group.r \ qwaq-group.r \
qwaq-listener.r \ qwaq-listener.r \
qwaq-proxyview.r \
qwaq-rect.r \ qwaq-rect.r \
qwaq-screen.r \ qwaq-screen.r \
qwaq-textcontext.r \ qwaq-textcontext.r \

View file

@ -0,0 +1,17 @@
#ifndef __qwaq_proxyview_h
#define __qwaq_proxyview_h
#include "qwaq-view.h"
@interface ProxyView : Object
{
View *view;
}
-initWithView:(View *) view;
-setView: (View *) view;
@end
@interface ProxyView (View) <View, TextContext>
@end
#endif//__qwaq_proxyview_h

View file

@ -0,0 +1,38 @@
#include "qwaq-proxyview.h"
@implementation ProxyView
- (void) forward: (SEL) sel : (@va_list) args
{
if (!view) {
return;
}
obj_msg_sendv (view, sel, args);
}
-initWithView:(View *) view
{
if (!(self = [super init])) {
return nil;
}
self.view = view;
return self;
}
-setView:(View *) view
{
int state = [self.view state];
if (state & sfInFocus) {
[self.view loseFocus];
[self.view hide];
}
self.view = view;
if (state & sfDrawn) {
[view draw];
}
if (state & sfInFocus) {
[view takeFocus];
}
return self;
}
@end