/* The routines in this file are copyright (c) 1987 by Helene (Lee) Taran. * Permission is granted for use and free distribution as long as the * original author's name is included with the code. */ #include "spline.h" extern struct Window *Window; extern struct Screen *Screen; extern struct PopUp_Menu CurveMenu, PointMenu; DLIST_ELEMENT Control_Points; main() { OpenLibraries(); SetupEnvironment(); Init_List(&Control_Points); Create_ControlPoints(); Init_GValues(); /* sets up the Gvalues for interpolating splines */ while(1) /* Main Loop */ { struct IntuiMessage *message, *GetMsg(); struct IntuiMessage mcopy; /* Wait until something happens and then respond to it */ Wait(1 << Window->UserPort->mp_SigBit); /* Now, one or more input events have arrived. Respond to ALL */ while (message = GetMsg(Window->UserPort)) { mcopy = *message; /* make a copy of the message */ ReplyMsg(message); /* reply to it immediately */ ProcessMessage(&mcopy); /* react to the message */ } } } /* ProcessMessage processes an input event given */ ProcessMessage(msg) struct IntuiMessage *msg; { switch (msg->Class) { case CLOSEWINDOW : close_things(); exit(0); case MOUSEBUTTONS : if (msg->Code == SELECTDOWN) { DLISTPTR p,Select_ControlPoint(); if (p = Select_ControlPoint(msg->MouseX,msg->MouseY)) Edit_ControlPoint(Window,p); else Edit_CurveStyle(Window); } break; } } Create_ControlPoints() { DLISTPTR p; void *calloc(); REAL_POINT *c; p = (DLISTPTR)calloc(1,sizeof(DLIST_ELEMENT)); c = (REAL_POINT *)calloc(1,sizeof(REAL_POINT)); c->x = 300; c->y = 200; p->contents = c; INSERT_FIRST(p,&Control_Points); p = (DLISTPTR)calloc(1,sizeof(DLIST_ELEMENT)); c = (REAL_POINT *)calloc(1,sizeof(REAL_POINT)); c->x = 155; c->y = 30; p->contents = c; INSERT_FIRST(p,&Control_Points); p = (DLISTPTR)calloc(1,sizeof(DLIST_ELEMENT)); c = (REAL_POINT *)calloc(1,sizeof(REAL_POINT)); c->x = 20; c->y = 175; p->contents = c; INSERT_FIRST(p,&Control_Points); Draw_ControlPoints(Window); Draw_Natural_Bspline(Window,&Control_Points); }