home *** CD-ROM | disk | FTP | other *** search
- /* > $.CLIB.C.windowopen
- *
- * HASWIN Graphics Library
- * =========================
- *
- * Copyright (C) H.A.Shaw 1990.
- * Howard A. Shaw.
- * The Unit for Space Sciences,
- * Room 165,
- * Physics Building,
- * University of Kent at Canterbury.
- * Canterbury.
- * Kent. CT2 7NJ
- * You may use and distribute this code freely, however please leave
- * it alone. If you find bugs (and there will be many) please contact
- * me and the master source can be modified. If you keep me informed
- * of who you give copies of this to then I can get release upgrades
- * to them.
- *
- * window routines. This is mainly open and close routines. For
- * drawing see "pollwind" and for others see "window'
- */
- #include "includes.h"
-
- static void _haswin_closewindow(window *wptr) {
-
- _kernel_swi_regs regs;
- buffer buff;
-
- if ((int)wptr <=0 )
- return;
- buff.i[0] = wptr->handle;
- regs.r[1] = (int)&buff;
- if (!haswin_swi(HASWIN_Close_window, ®s))
- return;
- if (haswin_inactivelist(wptr->handle))
- haswin_removeactivelist(wptr->handle);
- if (wptr->win)
- ((int *)wptr->win)[7] &= ~WINDOW_OPEN;
- if (wptr->flags & WINDOW_TEMP)
- haswin_deletewindow(wptr);
- }
-
- void haswin_closewindow(window *wptr) {
-
- window *wptr1;
-
- if ((int)wptr <= 0)
- return;
- for (wptr1=wptr; wptr1->pane; wptr1=wptr1->pane)
- _haswin_closewindow(wptr1->pane);
- for (wptr1=wptr; wptr1->slide; wptr1=wptr1->slide)
- _haswin_closewindow(wptr1->slide);
- _haswin_closewindow(wptr);
- }
-
- static int _openwindow1(int dir, window *wptr, int xadj, int yadj, int bhandle) {
-
- _kernel_swi_regs regs;
- buffer buff;
-
- if (wptr == 0)
- return(HASWIN_TRUE);
- if ((int)wptr < 0)
- return(HASWIN_FALSE);
- buff.i[0] = wptr->handle;
- regs.r[1] = (int)&buff;
- haswin_swi(HASWIN_Get_window_state, ®s);
- regs.r[1] = (int)&buff;
- buff.i[1] += xadj;
- buff.i[2] += yadj;
- buff.i[3] += xadj;
- buff.i[4] += yadj;
- buff.i[7] = bhandle;
- if ((*wptr->openroutine) && (!((*wptr->openroutine)(wptr, &buff))))
- return(HASWIN_FALSE);
- if (dir) {
- if (!_openwindow1(dir, wptr->pane, xadj, yadj, bhandle))
- return(HASWIN_FALSE);
- haswin_swi(HASWIN_Open_window, ®s);
- haswin_updatewindowinfo(wptr);
- } else {
- haswin_swi(HASWIN_Open_window, ®s);
- haswin_updatewindowinfo(wptr);
- if (!_openwindow1(dir, wptr->pane, xadj, yadj, bhandle))
- return(HASWIN_FALSE);
- }
- return(HASWIN_TRUE);
- }
-
- static int _openwindow2(int dir, window *wptr, int xadj, int yadj,
- double sxadj, double syadj, int bhandle) {
-
- _kernel_swi_regs regs;
- buffer buff;
-
- if (wptr == 0)
- return(HASWIN_TRUE);
- if ((int)wptr < 0)
- return(HASWIN_FALSE);
- buff.i[0] = wptr->handle;
- regs.r[1] = (int)&buff;
- haswin_swi(HASWIN_Get_window_state, ®s);
- regs.r[1] = (int)&buff;
- buff.i[1] += xadj;
- buff.i[2] += yadj;
- buff.i[3] += xadj;
- buff.i[4] += yadj;
- buff.i[5] = (int)(sxadj*(double)(((int *)wptr->win)[12]-((int *)wptr->win)[10]))+((int *)wptr->win)[10];
- buff.i[6] = (int)(syadj*(double)(((int *)wptr->win)[11]-((int *)wptr->win)[13]))+((int *)wptr->win)[13];
- buff.i[7] = bhandle;
- if ((*wptr->openroutine) && (!((*wptr->openroutine)(wptr, &buff))))
- return(HASWIN_FALSE);
- if (dir) {
- if (!_openwindow2(dir, wptr->slide, xadj, yadj, sxadj, syadj,
- bhandle))
- return(HASWIN_FALSE);
- haswin_swi(HASWIN_Open_window, ®s);
- haswin_updatewindowinfo(wptr);
- } else {
- haswin_swi(HASWIN_Open_window, ®s);
- haswin_updatewindowinfo(wptr);
- if (!_openwindow2(dir, wptr->slide, xadj, yadj, sxadj, syadj,
- bhandle))
- return(HASWIN_FALSE);
- }
- return(HASWIN_TRUE);
- }
-
- int haswin_openwindow(window *wptr, int x0, int y0, int x1, int y1, int scx, int scy, int bhandle) {
-
- int xadj, yadj;
- double sxadj, syadj;
- _kernel_swi_regs regs;
- buffer buff;
-
- if ((int)wptr <= 0)
- return(HASWIN_FALSE);
-
- buff.i[0] = wptr->handle;
- regs.r[1] = (int)&buff;
- haswin_swi(HASWIN_Get_window_state, ®s);
- xadj = x0 - buff.i[1];
- yadj = y1 - buff.i[4];
- sxadj = (double)(scx-((int *)wptr->win)[10])/(double)(((int *)wptr->win)[12]-((int *)wptr->win)[10]);
- syadj = (double)(scy-((int *)wptr->win)[13])/(double)(((int *)wptr->win)[11]-((int *)wptr->win)[13]);
- buff.i[0] = wptr->handle;
- buff.i[1] = x0;
- buff.i[2] = y0;
- buff.i[3] = x1;
- buff.i[4] = y1;
- buff.i[5] = scx;
- buff.i[6] = scy;
- buff.i[7] = bhandle;
- regs.r[1] = (int)&buff;
- if ((*wptr->openroutine) && (!((*wptr->openroutine)(wptr, &buff))))
- return(HASWIN_FALSE);
- if (bhandle != -2) {
- /* if window is not to be opened at bottom then do panes and
- slides afterwards */
- haswin_swi(HASWIN_Open_window, ®s);
- haswin_updatewindowinfo(wptr);
- if (!_openwindow1(0, wptr->pane, xadj, yadj, bhandle))
- return(HASWIN_FALSE);
- if (!_openwindow2(0, wptr->slide, xadj, yadj, sxadj, syadj, bhandle))
- return(HASWIN_FALSE);
- } else {
- if (!_openwindow1(1, wptr->pane, xadj, yadj, bhandle))
- return(HASWIN_FALSE);
- if (!_openwindow2(1, wptr->slide, xadj, yadj, sxadj, syadj, bhandle))
- return(HASWIN_FALSE);
- haswin_swi(HASWIN_Open_window, ®s);
- haswin_updatewindowinfo(wptr);
- }
- return(HASWIN_TRUE);
- }
-
- int haswin_reopenwindow(window *wptr) {
-
- _kernel_swi_regs regs;
- buffer buff;
-
- if ((int)wptr <= 0)
- return(HASWIN_FALSE);
- buff.i[0] = wptr->handle;
- regs.r[1] = (int)&buff;
- haswin_swi(HASWIN_Get_window_state, ®s);
- if ((*wptr->openroutine) && (!((*wptr->openroutine)(wptr, &buff))))
- return(HASWIN_FALSE);
-
- if (buff.i[7] != -2) {
- /* if window is not to be opened at bottom then do panes and
- slides afterwards */
- haswin_swi(HASWIN_Open_window, ®s);
- haswin_updatewindowinfo(wptr);
- if (!_openwindow1(0, wptr->pane, 0, 0, buff.i[7]))
- return(HASWIN_FALSE);
- if (!_openwindow2(0, wptr->slide, 0, 0, 0.0, 0.0, buff.i[7]))
- return(HASWIN_FALSE);
- } else {
- if (!_openwindow1(1, wptr->pane, 0, 0, buff.i[7]))
- return(HASWIN_FALSE);
- if (!_openwindow2(1, wptr->slide, 0, 0, 0.0, 0.0, buff.i[7]))
- return(HASWIN_FALSE);
- haswin_swi(HASWIN_Open_window, ®s);
- haswin_updatewindowinfo(wptr);
- }
- return(HASWIN_TRUE);
- }
-
- int haswin_forceredraw(window *win, int x0, int x1, int y0, int y1) {
-
- _kernel_swi_regs regs;
-
- if (!win)
- regs.r[0] = -1;
- else
- regs.r[0] = win->handle;
- if (x0 || x1 || y0 || y1) {
- regs.r[1] = x0;
- regs.r[2] = y0;
- regs.r[3] = x1;
- regs.r[4] = y1;
- } else if ((win) && (win->win)) {
- haswin_updatewindowinfo(win);
- regs.r[1] = win->win[0];
- regs.r[2] = win->win[1];
- regs.r[3] = win->win[2];
- regs.r[4] = win->win[3];
- }
- haswin_swi(HASWIN_Force_redraw, ®s);
- return(HASWIN_TRUE);
- }
-
-