This is xtResponder.m in view mode; [Download] [Up]
// GNUStep category for Responder class
// Copyright (C) 1993 The Board of Trustees of
// The Leland Stanford Junior University. All Rights Reserved.
// Authors: Scott Francis, Paul Kunz, and Libing Wang
#include "Responder.h"
#include "xtResponder.h"
char *
ResponderInstanceName( void )
{
return "Responder";
}
@implementation Responder(ToolKit)
- makeNXEvent:(NXEvent *)nx fromXEvent:(XEvent *)event
/*
converts various fields to an NXEvent-type struct, that
actually is not quite an NXEvent, but has many of the same
fields to ease the transition from NeXT to X app.
*/
{
nx->flags = 0;
nx->type = event->type;
nx->location.x = event->xbutton.x;
nx->location.y = event->xbutton.y;
nx->time = (long)event->xbutton.time;
if (event->xbutton.state & ShiftMask) {
nx->flags |= NX_NEXTLSHIFTKEYMASK;
}
if (event->xbutton.state & ControlMask) {
nx->flags |= NX_NEXTCTRLKEYMASK;
}
// these if statements can be extended to handle a few more keys...
// Expose events
// The way this data is stored is a bit contrived, but I guess I'd
// rather do that then change the event structure. - adam
if (event->type == Expose) {
XExposeEvent *ex = (XExposeEvent *)event;
nx->location.x = ex->x;
nx->location.y = ex->y;
nx->data.compound.subtype = ex->count;
nx->data.compound.misc.L[0] = ex->width;
nx->data.compound.misc.L[1] = ex->height;
}
return self;
}
- (BOOL) isLastExposeEvent:(XEvent *)event
{
if ( event->type == Expose ) {
XExposeEvent *ex = (XExposeEvent *)event;
return (ex->count == 0) ? YES : NO;
}
return NO;
}
- _addArg:(const char *)name :(XtArgVal)value
{
Arg *args;
int i;
args = arglist;
for (i=0; i<numargs; i++) { /* already there? */
if (strcmp(args[i].name, name) == 0) {
args[i].value = (XtArgVal) value;
return self;
}
}
if ((numargs+=1) > allocedargs ) {
allocedargs = (allocedargs) ? 2*allocedargs : 10;
/* XtRealloc handles error checking and calling malloc if args
is NULL */
args = arglist = XtRealloc(arglist, (allocedargs)*sizeof(Arg));
}
XtSetArg(args[numargs-1], (char *)name, value);
return self;
}
- _setArg:(const char*)name to:(XtArgVal)value
{
if (widgetid) {
XtVaSetValues(widgetid, name, value, NULL);
} else {
[self _addArg:name :value];
}
return self;
}
- _getArg:(const char *)name into:(XtArgVal *)value
{
if (widgetid) {
XtVaGetValues(widgetid, name, value, NULL);
} else {
fprintf(stderr,"Responder: no widgetid in getarg\n");
}
return self;
}
- (void *)_arglist
{
return arglist;
}
- (int)_numargs
{
return numargs;
}
- _setnumargs:(int)val
{
numargs = val;
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.