From fd0700f9ae1654c40b0434b82f45ea25776ab222 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 24 Mar 2020 21:02:54 +0900 Subject: [PATCH] [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. --- ruamoko/qwaq/Makefile.am | 1 + ruamoko/qwaq/qwaq-proxyview.h | 17 ++++++++++++++++ ruamoko/qwaq/qwaq-proxyview.r | 38 +++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 ruamoko/qwaq/qwaq-proxyview.h create mode 100644 ruamoko/qwaq/qwaq-proxyview.r diff --git a/ruamoko/qwaq/Makefile.am b/ruamoko/qwaq/Makefile.am index 182ed2565..c61fbafb7 100644 --- a/ruamoko/qwaq/Makefile.am +++ b/ruamoko/qwaq/Makefile.am @@ -32,6 +32,7 @@ qwaq_app_dat_src= \ qwaq-garray.r \ qwaq-group.r \ qwaq-listener.r \ + qwaq-proxyview.r \ qwaq-rect.r \ qwaq-screen.r \ qwaq-textcontext.r \ diff --git a/ruamoko/qwaq/qwaq-proxyview.h b/ruamoko/qwaq/qwaq-proxyview.h new file mode 100644 index 000000000..7789678fc --- /dev/null +++ b/ruamoko/qwaq/qwaq-proxyview.h @@ -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) +@end + +#endif//__qwaq_proxyview_h diff --git a/ruamoko/qwaq/qwaq-proxyview.r b/ruamoko/qwaq/qwaq-proxyview.r new file mode 100644 index 000000000..a29b1dedd --- /dev/null +++ b/ruamoko/qwaq/qwaq-proxyview.r @@ -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