home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kyūkyoku!! X68000 Emulator
/
X68000Book.dat
/
mac
/
OLS
/
X68000
/
Ko-Window
/
kow142s.lzh
/
wsrv
/
window.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-09-08
|
24KB
|
1,061 lines
#include <stdio.h>
#include <stdlib.h>
#include <sys_doslib.h>
#define _K_WINDOW
#include "clip.h"
#include "window.h"
#include "vram.h"
#include "manager.h"
#define WINDOW_OPEN_ID 1234
#define NOREDRAW (WindowAttrTra|WindowAttrInvisible)
int (*SendEventExec)();
int (*WindowError)();
static WindowClass *RootWindowPtr ;
/*
proto -s window.c > temp
*/
static void _WindowPop( WindowClass*, WindowClass*, ClipClass* );
static void _WindowScroll( WindowClass*, ClipClass*, WindowClass*, int, int );
static void __WindowScroll( WindowClass*, ClipClass*, int, int );
static void WindowDrawOffset( WindowClass*, DrawBuf*, int, int, int, int );
static void _WindowDraw( DrawBuf*, int, ClipClass*, WindowClass*, int, int );
static void SendEventRedraw( WindowClass* );
static void SendEventRedrawClip( WindowClass*, ClipClass* );
static void WindowRedrawAll( WindowClass*, WindowClass*, ClipClass*, int );
static void WindowDeleteList( WindowClass* );
static void WindowAppendList( WindowClass* );
static void WindowClipSet( ClipClass*, WindowClass*, ClipClass* );
static int SetUpClip( ClipClass*, ClipClass*, ClipClass* );
static int SetDownClip( ClipClass*, ClipClass*, ClipClass* );
static int SetLeftClip( ClipClass*, ClipClass*, ClipClass* );
static int SetRightClip( ClipClass*, ClipClass*, ClipClass* );
void WindowSet( wp, x, y, h, v, parent, id, event )
WindowClass *wp ;
int x, y, h, v ;
WindowClass *parent ;
int id ;
int (*event)();
{
ClipSet( (ClipClass*)wp, x, y, h, v );
wp->window.type = WindowType ;
wp->window.check = WINDOW_OPEN_ID ;
wp->window.client = 0 ;
wp->window.clientp = NULL ;
wp->window.ownerid = -1 ;
wp->window.attr = WindowAttrTra ;
wp->window.eventattr = EventAttrDefault ;
ClipSet( &(wp->window.curclip), 0, 0, h, v );
wp->window.hx = wp->window.hy = 0 ;
wp->window.parent = parent ;
wp->window.childtop = NULL ;
wp->window.childbottom = NULL ;
wp->window.id = id ;
wp->window.event = event ;
if ( parent == NULL )
{
VramClipPtr = (ClipClass*)wp ;
RootWindowPtr = wp ;
}
else
WindowAppendList( wp );
}
/* âEâCâôâhâEé╠âNâìü[âY */
void WindowClose( wp )
WindowClass *wp ;
{
WindowClass *parent ;
/* DrawBuf buf[1] ; */ /* 19950804 Copel */
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowClose" );
/*
if ( wp->window.attr & WindowAttrGraphicUse )
{
DrawSetGraphicClear( buf, 0 );
WindowDraw( wp, buf, 1 );
}
*/
while( wp->window.childtop != NULL )
WindowClose( wp->window.childtop );
if ( wp->window.parent != NULL )
{
WindowDeleteList( wp );
if ( ( wp->window.attr & NOREDRAW ) == 0 )
{
parent = wp->window.parent ;
WindowRedrawAll( parent, wp->window.next, (ClipClass*)wp, TRUE );
}
if ( wp->window.ownerid != -1 )
WindowMemoryFree( wp );
}
wp->window.check = 0 ;
}
/* âNâëâCâAâôâgâfü[â^é╠É▌ÆΦ */
void WindowSetClientData( wp, n, p )
WindowClass *wp ;
int n ;
void *p ;
{
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowSetClientData" );
wp->window.client = n ;
wp->window.clientp = p ;
}
/* âEâCâôâhâEé╠æ«É½É▌ÆΦ */
void WindowSetAttr( wp, attr )
WindowClass *wp ;
int attr ;
{
int old ;
/* DrawBuf buf[1] ; */ /* 19950804 Copel */
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowSetAttr" );
old = wp->window.attr ;
wp->window.attr = attr ;
if ( ! ( old & WindowAttrTra ) )
{
if ( ! ( old & WindowAttrInvisible ) && ( attr & WindowAttrInvisible ) )
{
/*
if ( wp->window.attr & WindowAttrGraphicUse )
{
DrawSetGraphicClear( buf, 0 );
WindowDraw( wp, buf, 1 );
}
*/
WindowRedrawAll( wp->window.parent, wp->window.next, (ClipClass*)wp, TRUE );
}
else if ( ( old & WindowAttrInvisible ) && ! ( attr & WindowAttrInvisible ) )
{
SendEventRedraw( wp );
}
}
}
/* âEâCâôâhâEé╠âCâxâôâgæ«É½ */
void WindowSetEventAttr( wp, attr )
WindowClass *wp ;
int attr ;
{
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowSetEventAttr" );
wp->window.eventattr = attr ;
}
/* âEâCâôâhâEé╠â|âbâv */
void WindowPop( wp )
WindowClass *wp ;
{
WindowClass *last ;
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowPop" );
if ( wp->window.last != NULL )
{
last = wp->window.last ;
WindowDeleteList( wp );
WindowAppendList( wp );
if ( ( wp->window.attr & NOREDRAW ) == 0 ){
ClipClass oldwin= {wp->clip}; /* 1993 COR. */
/* _WindowPop( wp, last, (ClipClass*)&(wp->clip) );*/
_WindowPop( wp, last, &oldwin );
}
}
}
static void _WindowPop( wp, last, oldwin )
WindowClass *wp, *last ;
ClipClass *oldwin ;
{
int x, y, h, v, vx, vy, ph, pv, n ;
WindowClass *parent ;
ClipClass clip, localclip, *savecp ;
x = wp->clip.x1 ;
y = wp->clip.y1 ;
parent = wp->window.parent ;
if ( ( wp->window.attr & WindowAttrGraphicUse ) == 0 &&
ClipOverlap( &clip, oldwin, &(parent->window.curclip) ) )
{
if( (int)wp != (int)oldwin ){ /* 1993 COR.*/
if( x != oldwin->clip.x1 || y != oldwin->clip.y1 ){
ClipClass vramclip;
WindowClipSet( &vramclip, parent, &clip );
VramMove( x + vramclip.clip.x1 - oldwin->clip.x1,
y + vramclip.clip.y1 - oldwin->clip.y1, &vramclip );
}
}
savecp = VramClipPtr ;
VramClipPtr = &clip ;
ClipGetSize( &(parent->window.curclip), &ph, &pv );
ClipGetSize( (ClipClass*)wp, &h, &v );
if ( oldwin->clip.y1 < 0 )
{
ClipSet( &clip, x, y, h, - oldwin->clip.y1 );
ClipSet( &localclip, 0, 0, h, - oldwin->clip.y1 );
SendEventRedrawClip( wp, &localclip );
y += - oldwin->clip.y1 ;
oldwin->clip.y1 = 0 ;
}
if ( oldwin->clip.y2 >= pv )
{
n = oldwin->clip.y2 - pv + 1 ;
ClipSet( &clip, x, y + v - n, h, n );
ClipSet( &localclip, 0, v - n, h, n );
SendEventRedrawClip( wp, &localclip );
oldwin->clip.y2 = pv - 1 ;
}
if ( oldwin->clip.x1 < 0 )
{
ClipSet( &clip, x, y, - oldwin->clip.x1 , v );
ClipSet( &localclip, 0, 0, - oldwin->clip.x1, v );
SendEventRedrawClip( wp, &localclip );
x += - oldwin->clip.x1 ;
oldwin->clip.x1 = 0 ;
}
if ( oldwin->clip.x2 >= ph )
{
n = oldwin->clip.x2 - ph + 1 ;
ClipSet( &clip, x + h - n, y, n, v );
ClipSet( &localclip, h - n, 0, n, v );
SendEventRedrawClip( wp, &localclip );
oldwin->clip.y2 = ph - 1 ;
}
if ( last != NULL )
{
vx = x - oldwin->clip.x1 ;
vy = y - oldwin->clip.y1 ;
while( last != wp )
{
if ( ClipOverlap( &clip, (ClipClass*)oldwin, (ClipClass*)&(last->clip) ) )
{
clip.clip.x1 += vx ;
clip.clip.y1 += vy ;
clip.clip.x2 += vx ;
clip.clip.y2 += vy ;
localclip = clip ;
ClipMove( &localclip, clip.clip.x1 - wp->clip.x1,
clip.clip.y1 - wp->clip.y1 );
SendEventRedrawClip( wp, &localclip );
}
last = last->window.last ;
}
}
VramClipPtr = savecp ;
}
else
SendEventRedraw( wp );
}
/* âEâCâôâhâEé╠âvâbâVâà */
void WindowPush( wp )
WindowClass *wp ;
{
WindowClass *parent, *last, *next ;
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowPush" );
if ( wp->window.next != NULL )
{
parent = wp->window.parent ;
next = wp->window.next ;
WindowDeleteList( wp );
/* ò`é½Æ╝é╡ */
if ( ( wp->window.attr & NOREDRAW ) == 0 )
WindowRedrawAll( parent, next, (ClipClass*)wp, FALSE );
/* âEâCâôâhâEâèâXâgé╔ÿAîï */
wp->window.last = parent->window.childbottom ;
if ( wp->window.last != NULL )
{
last = wp->window.last ;
last->window.next = wp ;
}
wp->window.next = NULL ;
parent->window.childbottom = wp ;
if ( parent->window.childtop == NULL )
parent->window.childtop = wp ;
}
}
/* âEâCâôâhâEé╠ò`é½Æ╝é╡ */
void WindowRedraw( wp )
WindowClass *wp ;
{
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowRedraw" );
if ( ! ( wp->window.attr & WindowAttrInvisible ) )
SendEventRedraw( wp );
}
/* âEâCâôâhâEé╠ê┌ô« */
void WindowMove( wp, x, y )
WindowClass *wp ;
int x, y ;
{
WindowClass *next, *last ;
ClipClass oldwin ;
/* DrawBuf buf[1] ; */ /* 19950804 Copel */
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowMove" );
/*
if ( wp->window.attr & WindowAttrGraphicUse )
{
DrawSetGraphicClear( buf, 0 );
WindowDraw( wp, buf, 1 );
}
*/
next = wp->window.next ;
last = wp->window.last ;
oldwin.clip = wp->clip ;
ClipMove( (ClipClass*)wp, x, y );
if ( last != NULL )
{
WindowDeleteList( wp );
WindowAppendList( wp );
}
if ( ( wp->window.attr & NOREDRAW ) == 0 )
{
_WindowPop( wp, last, &oldwin );
WindowRedrawAll( wp->window.parent, next, &oldwin, TRUE );
}
}
/* âEâCâôâhâEé╠ò╧î` */
void WindowResize( wp, x, y, h, v )
WindowClass *wp ;
int x, y, h, v ;
{
ClipClass clip ;
/* DrawBuf buf[1] ; */ /* 19950804 Copel */
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowResize" );
/*
if ( wp->window.attr & WindowAttrGraphicUse )
{
DrawSetGraphicClear( buf, 0 );
WindowDraw( wp, buf, 1 );
}
*/
clip.clip = wp->clip ;
ClipSet( (ClipClass*)wp, x, y, h, v );
ClipSet( &(wp->window.curclip), 0, 0, h, v );
if ( ( wp->window.attr & NOREDRAW ) == 0 )
{
SendEventRedraw( wp );
WindowRedrawAll( wp->window.parent, wp->window.next, &clip, TRUE );
}
}
/* âzü[âÇê╩Æué╠É▌ÆΦ */
void WindowSetHome( wp, hx, hy )
WindowClass *wp ;
int hx, hy ;
{
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowSetHome" );
wp->window.hx = hx ;
wp->window.hy = hy ;
}
/* âEâCâôâhâEé╠âXâNâìü[âï */
void WindowScroll( wp, dx, dy )
WindowClass *wp ;
int dx, dy ;
{
ClipClass clip ;
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowScroll" );
wp->window.hx += dx ;
wp->window.hy += dy ;
if ( ( dx & 15 ) != 0 || ( wp->window.attr & WindowAttrGraphicUse ) ) /* ADDITION 19950804 Copel */
{
/* SendEventRedraw( wp ); */
SendEventRedrawClip( wp , &( wp->window.curclip ) ) ; /* MODIFICATION 19950804 Copel */
return ;
}
if ( wp->window.childbottom == NULL )
{
int x, y;
clip = wp->window.curclip ;
x = wp->clip.x1 ;
y = wp->clip.y1 ;
clip.clip.x1 += x ;
clip.clip.y1 += y ;
clip.clip.x2 += x ;
clip.clip.y2 += y ;
_WindowScroll( wp, &clip, wp, dx, dy );
}
else
{
int h, v ;
WindowClass window ;
WindowGetViewSize( wp, &h, &v );
ClipSet( &clip, 0, 0, h, v );
window.window.last = wp->window.childbottom ;
_WindowScroll( wp, &clip, &window, dx, dy );
}
}
static void _WindowScroll( wp, cp, overwp, dx, dy )
WindowClass *wp, *overwp ;
ClipClass *cp ;
int dx, dy ;
{
ClipClass clip ;
while( overwp->window.last != NULL )
{
overwp = overwp->window.last ;
if ( ( overwp->window.attr & NOREDRAW ) == 0 )
{
if ( ClipOverlap( &clip, cp, (ClipClass*)overwp ) )
{
if ( SetUpClip( &clip, cp, (ClipClass*)overwp ) )
_WindowScroll( wp, &clip, overwp, dx, dy );
if ( SetLeftClip( &clip, cp, (ClipClass*)overwp ) )
_WindowScroll( wp, &clip, overwp, dx, dy );
if ( SetRightClip( &clip, cp, (ClipClass*)overwp ) )
_WindowScroll( wp, &clip, overwp, dx, dy );
if ( SetDownClip( &clip, cp, (ClipClass*)overwp ) )
_WindowScroll( wp, &clip, overwp, dx, dy );
return ;
}
}
}
overwp = overwp->window.parent ;
if ( overwp == NULL )
{
__WindowScroll( wp, cp, dx, dy );
}
else
{
int h, v;
WindowGetViewSize( overwp, &h, &v );
ClipSet( &clip, 0, 0, h, v );
if ( ClipOverlap( &clip, &clip, cp ) )
{
int x, y;
x = overwp->clip.x1 + overwp->window.curclip.clip.x1 ;
y = overwp->clip.y1 + overwp->window.curclip.clip.y1 ;
clip.clip.x1 += x ;
clip.clip.y1 += y ;
clip.clip.x2 += x ;
clip.clip.y2 += y ;
_WindowScroll( wp, &clip, overwp, dx, dy );
}
}
}
static void __WindowScroll( wp, cp, dx, dy )
WindowClass *wp ;
ClipClass *cp ;
int dx, dy ;
{
int h, v ;
ClipClass clip, localclip, *saveclip ;
WindowClipSet( &clip, (wp->window.parent), (ClipClass*)&(wp->clip) );
ClipGetSize( cp, &h, &v );
ClipSet( &localclip, cp->clip.x1 - clip.clip.x1, cp->clip.y1 - clip.clip.y1, h, v );
saveclip = VramClipPtr ;
clip = *cp ;
VramClipPtr = & clip ;
if ( - h < dx && dx < h && - v < dy && dy < v )
{
VramScroll( cp, dx, dy );
if ( dx > 0 )
{
VramClipPtr->clip.x1 = VramClipPtr->clip.x2 - dx + 1 ;
localclip.clip.x1 = localclip.clip.x2 - dx + 1 ;
}
else if ( dx < 0 )
{
VramClipPtr->clip.x2 = VramClipPtr->clip.x1 - dx - 1 ;
localclip.clip.x2 = localclip.clip.x1 - dx - 1 ;
}
else if ( dy > 0 )
{
VramClipPtr->clip.y1 = VramClipPtr->clip.y2 - dy + 1 ;
localclip.clip.y1 = localclip.clip.y2 - dy + 1 ;
}
else if ( dy < 0 )
{
VramClipPtr->clip.y2 = VramClipPtr->clip.y1 - dy - 1 ;
localclip.clip.y2 = localclip.clip.y1 - dy - 1 ;
}
}
SendEventRedrawClip( wp, &localclip );
VramClipPtr = saveclip ;
}
/*
* âEâCâôâhâEé╓é╠ò`ëµ
*/
void WindowDrawAbs( wp, buf, n )
WindowClass *wp ;
DrawBuf *buf ;
int n ;
{
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowDrawAbs" );
WindowDrawOffset( wp, buf, n, 0, 0, TRUE );
}
void WindowDraw( wp, buf, n )
WindowClass *wp ;
DrawBuf *buf ;
int n ;
{
ErrorCheck( wp->window.check == WINDOW_OPEN_ID, "WindowDraw" );
WindowDrawOffset( wp, buf, n, - wp->window.hx, - wp->window.hy, FALSE );
}
static void WindowDrawOffset( wp, buf, n, ox, oy, flag )
WindowClass *wp ;
DrawBuf *buf ;
int n ;
int ox, oy ;
int flag ;
{
WindowClass window ;
ClipClass clip ;
int x, y, h, v ;
if ( wp->window.attr & WindowAttrInvisible )
return ;
if ( wp->window.childbottom == NULL || flag )
{
if ( flag )
{
clip = *(ClipClass*)wp ;
ox += wp->clip.x1 ;
oy += wp->clip.y1 ;
}
else
{
clip = wp->window.curclip ;
x = wp->clip.x1 ;
y = wp->clip.y1 ;
ox += x + wp->window.curclip.clip.x1 ;
oy += y + wp->window.curclip.clip.y1 ;
clip.clip.x1 += x ;
clip.clip.y1 += y ;
clip.clip.x2 += x ;
clip.clip.y2 += y ;
}
}
else
{
WindowGetViewSize( wp, &h, &v );
ClipSet( &clip, 0, 0, h, v );
window.window.last = wp->window.childbottom ;
window.window.parent = wp ;
wp = &window ;
}
if ( wp->window.parent == RootWindowPtr )
{
if ( ClipOverlap( &clip, &clip, VramClipPtr ) == FALSE )
return ;
}
_WindowDraw( buf, n, &clip, wp, ox, oy );
}
static void _WindowDraw( buf, n, cp, overwp, ox, oy )
DrawBuf *buf ;
int n ;
ClipClass *cp ;
WindowClass *overwp ;
int ox, oy ;
{
ClipClass clip ;
while( overwp->window.last != NULL )
{
overwp = overwp->window.last ;
if ( ( overwp->window.attr & NOREDRAW ) == 0 )
{
if ( ClipOverlap( &clip, cp, (ClipClass*)overwp ) )
{
if ( SetUpClip( &clip, cp, (ClipClass*)overwp ) )
_WindowDraw( buf, n, &clip, overwp, ox, oy );
if ( SetLeftClip( &clip, cp, (ClipClass*)overwp ) )
_WindowDraw( buf, n, &clip, overwp, ox, oy );
if ( SetRightClip( &clip, cp, (ClipClass*)overwp ) )
_WindowDraw( buf, n, &clip, overwp, ox, oy );
if ( SetDownClip( &clip, cp, (ClipClass*)overwp ) )
_WindowDraw( buf, n, &clip, overwp, ox, oy );
return ;
}
}
}
overwp = overwp->window.parent ;
if ( overwp == NULL )
{
VramDraw( buf, n, cp, ox, oy );
}
else
{
int x, y, h, v ;
WindowGetViewSize( overwp, &h, &v );
ClipSet( &clip, 0, 0, h, v );
if ( ClipOverlap( &clip, &clip, cp ) )
{
x = overwp->clip.x1 + overwp->window.curclip.clip.x1 ;
y = overwp->clip.y1 + overwp->window.curclip.clip.y1 ;
clip.clip.x1 += x ;
clip.clip.y1 += y ;
clip.clip.x2 += x ;
clip.clip.y2 += y ;
_WindowDraw( buf, n, &clip, overwp, ox+x, oy+y );
}
}
}
/*
* âEâCâôâhâEÅεò±é╠èmò█
*/
int WindowGetEventAttr( wp )
WindowClass *wp ;
{
return( wp->window.eventattr );
}
/* append 1994 9/8 H.Ogasawra (COR.) */
int WindowGetAttr( wp )
WindowClass *wp ;
{
return( wp->window.attr );
}
int WindowGetClientData( wp )
WindowClass *wp ;
{
return( wp->window.client );
}
void *WindowGetClientPointer( wp )
WindowClass *wp ;
{
return( wp->window.clientp );
}
void WindowGetPosition( wp, xp, yp )
WindowClass *wp ;
int *xp, *yp ;
{
*xp = wp->clip.x1 ;
*yp = wp->clip.y1 ;
}
void WindowGetViewPosition( wp, xp, yp )
WindowClass *wp ;
int *xp, *yp ;
{
*xp = wp->window.curclip.clip.x1 ;
*yp = wp->window.curclip.clip.y1 ;
}
void WindowGetScreenPosition( wp, xp, yp )
WindowClass *wp ;
int *xp, *yp ;
{
*xp = 0 ;
*yp = 0 ;
while( wp->window.parent != NULL )
{
*xp += wp->window.curclip.clip.x1 + wp->clip.x1 ;
*yp += wp->window.curclip.clip.y1 + wp->clip.y1 ;
wp = wp->window.parent ;
}
}
void WindowGetViewSize( wp, hp, vp )
WindowClass *wp ;
int *hp, *vp ;
{
ClipGetSize( &(wp->window.curclip), hp, vp );
}
void WindowGetHome( wp, xp, yp )
WindowClass *wp ;
int *xp, *yp ;
{
*xp = wp->window.hx ;
*yp = wp->window.hy ;
}
WindowClass *WindowGetParent( wp )
WindowClass *wp ;
{
return( wp->window.parent );
}
WindowClass *WindowGetNext( wp )
WindowClass *wp ;
{
do
{
wp = wp->window.next ;
}
while( wp != NULL && wp->window.attr & WindowAttrInvisible );
return( wp );
}
WindowClass *WindowGetLast( wp )
WindowClass *wp ;
{
do
{
wp = wp->window.last ;
}
while( wp != NULL && wp->window.attr & WindowAttrInvisible );
return( wp );
}
WindowClass *WindowGetChildTop( wp )
WindowClass *wp ;
{
wp = wp->window.childtop ;
while( wp != NULL && wp->window.attr & WindowAttrInvisible )
wp = wp->window.next ;
return( wp );
}
WindowClass *WindowGetChildBottom( wp )
WindowClass *wp ;
{
wp = wp->window.childbottom ;
while( wp != NULL && wp->window.attr & WindowAttrInvisible )
wp = wp->window.last ;
return( wp );
}
WindowClass *WindowGetChild( wp, info )
WindowClass *wp ;
EventInfo *info ;
{
int x, y ;
wp = wp->window.childtop ;
x = info->x ;
y = info->y ;
while( wp != NULL )
{
if ( ! ( wp->window.attr & WindowAttrInvisible ) && ClipInner( (ClipClass*)wp, x, y ) )
{
info->x = x - wp->clip.x1 ;
info->y = y - wp->clip.y1 ;
return( wp );
}
wp = wp->window.next ;
}
return( NULL );
}
/*
* âCâxâôâgÅεò±
*/
int SendEvent( id, event, wp, info )
int id ;
int (*event)();
WindowClass *wp ;
EventInfo *info ;
{
if ( wp == NULL || wp->window.eventattr & ( 1 << info->option ) )
{
if ( id == -1 )
{
return( (*event)( wp, info ) );
}
else
{
return( (*SendEventExec)( id, event, wp, info ) );
}
}
return( FALSE );
}
int WindowSendEvent( wp, info )
WindowClass *wp ;
EventInfo *info ;
{
if ( wp == NULL )
return( FALSE );
else
return( SendEvent( wp->window.id, wp->window.event, wp, info ) );
}
int WindowSendEventAll( id, info )
int id ;
EventInfo *info ;
{
int ret ;
WindowClass *wp ;
void **wpp ;
ret = TRUE ;
wpp = &( RootWindowPtr->window.childtop );
while( *wpp != NULL )
{
wp = *wpp ;
if ( wp->window.ownerid == id )
ret = ret && WindowSendEvent( wp, info );
if ( wp == *wpp )
wpp = &( wp->window.next );
}
return( ret );
}
/*
* âìü[âJâïè╓Éö
*/
/* ò`é½Æ╝é╡âCâxâôâgé╠ö¡É╢ */
static void SendEventRedraw( wp )
WindowClass *wp ;
{
EventInfo RedrawEvent ;
RedrawEvent.option = EventRedraw ;
RedrawEvent.x = 0 ;
RedrawEvent.y = 0 ;
RedrawEvent.h = wp->clip.x2 - wp->clip.x1 + 1 ;
RedrawEvent.v = wp->clip.y2 - wp->clip.y1 + 1 ;
SendEvent( wp->window.id, wp->window.event, wp, & RedrawEvent );
}
static void SendEventRedrawClip( wp, cp )
WindowClass *wp ;
ClipClass *cp ;
{
EventInfo RedrawEvent ;
RedrawEvent.option = EventRedraw ;
RedrawEvent.x = cp->clip.x1 ;
RedrawEvent.y = cp->clip.y1 ;
RedrawEvent.h = cp->clip.x2 - cp->clip.x1 + 1 ;
RedrawEvent.v = cp->clip.y2 - cp->clip.y1 + 1 ;
SendEvent( wp->window.id, wp->window.event, wp, & RedrawEvent );
}
/* âEâCâôâhâEé╠ò`é½Æ╝é╡ */
static void WindowRedrawAll( parent, wp, cp, flag )
WindowClass *parent, *wp ;
ClipClass *cp ;
int flag ;
{
ClipClass *saveclip, clip, localclip ;
saveclip = VramClipPtr ;
if ( parent->window.parent == NULL )
VramClipPtr = cp ;
else
{
VramClipPtr = &clip ;
WindowClipSet( VramClipPtr, parent, cp );
}
if ( flag )
{
SendEventRedrawClip( parent, cp );
}
while( wp != NULL )
{
if ( ! ( wp->window.attr & WindowAttrInvisible ) &&
ClipOverlap( &localclip, cp, (ClipClass*)wp ) )
{
localclip.clip.x1 -= wp->clip.x1 ;
localclip.clip.x2 -= wp->clip.x1 ;
localclip.clip.y1 -= wp->clip.y1 ;
localclip.clip.y2 -= wp->clip.y1 ;
SendEventRedrawClip( wp, &localclip );
}
wp = wp->window.next ;
}
VramClipPtr = saveclip ;
}
/* âEâCâôâhâEâèâXâgé⌐éτé╠ìφÅ£ */
static void WindowDeleteList( wp )
WindowClass *wp ;
{
WindowClass *parent, *last, *next ;
parent = wp->window.parent ;
if ( wp->window.last == NULL )
parent->window.childtop = wp->window.next ;
else
{
last = wp->window.last ;
last->window.next = wp->window.next ;
}
if ( wp->window.next == NULL )
parent->window.childbottom = wp->window.last ;
else
{
next = wp->window.next ;
next->window.last = wp->window.last ;
}
}
/* âEâCâôâhâEâèâXâgé╠ɵô¬é╓é╠Æ╟ë┴ */
static void WindowAppendList( wp )
WindowClass *wp ;
{
WindowClass *parent, *next ;
parent = wp->window.parent ;
wp->window.next = parent->window.childtop ;
if ( wp->window.next != NULL )
{
next = wp->window.next ;
next->window.last = wp ;
}
wp->window.last = NULL ;
parent->window.childtop = wp ;
if ( parent->window.childbottom == NULL )
parent->window.childbottom = wp ;
}
/* ârâàü[â|ü[âgé╠âZâbâg */
static void WindowClipSet( ret, wp, vp )
ClipClass *ret, *vp ;
WindowClass *wp ;
{
int x, y ;
*ret = *vp ;
while( wp != NULL )
{
x = wp->clip.x1 + wp->window.curclip.clip.x1 ;
y = wp->clip.y1 + wp->window.curclip.clip.y1 ;
ret->clip.x1 += x ;
ret->clip.y1 += y ;
ret->clip.x2 += x ;
ret->clip.y2 += y ;
wp = wp->window.parent ;
}
}
static int SetUpClip( ret, vp1, vp2 )
ClipClass *ret, *vp1, *vp2 ;
{
if ( vp2->clip.y1 > vp1->clip.y1 )
{
ret->clip.y1 = vp1->clip.y1 ;
ret->clip.y2 = vp2->clip.y1 - 1 ;
ret->clip.x1 = vp1->clip.x1 ;
ret->clip.x2 = vp1->clip.x2 ;
return( TRUE );
}
else
return( FALSE );
}
static int SetDownClip( ret, vp1, vp2 )
ClipClass *ret, *vp1, *vp2 ;
{
if ( vp2->clip.y2 < vp1->clip.y2 )
{
ret->clip.y1 = vp2->clip.y2 + 1 ;
ret->clip.y2 = vp1->clip.y2 ;
ret->clip.x1 = vp1->clip.x1 ;
ret->clip.x2 = vp1->clip.x2 ;
return( TRUE );
}
else
return( FALSE );
}
static int SetLeftClip( ret, vp1, vp2 )
ClipClass *ret, *vp1, *vp2 ;
{
if ( vp2->clip.x1 > vp1->clip.x1 )
{
ret->clip.x1 = vp1->clip.x1 ;
ret->clip.x2 = vp2->clip.x1 - 1 ;
ret->clip.y1 = max( vp1->clip.y1, vp2->clip.y1 );
ret->clip.y2 = min( vp1->clip.y2, vp2->clip.y2 );
return( TRUE );
}
else
return( FALSE );
}
static int SetRightClip( ret, vp1, vp2 )
ClipClass *ret, *vp1, *vp2 ;
{
if ( vp2->clip.x2 < vp1->clip.x2 )
{
ret->clip.x1 = vp2->clip.x2 + 1 ;
ret->clip.x2 = vp1->clip.x2 ;
ret->clip.y1 = max( vp1->clip.y1, vp2->clip.y1 );
ret->clip.y2 = min( vp1->clip.y2, vp2->clip.y2 );
return( TRUE );
}
else
return( FALSE );
}
/*
* âGâëü[â`âFâbâN
*/
void _ErrorCheck( msg )
char *msg ;
{
if ( WindowError == NULL ){
errput( "âGâëü[é¬ö¡É╢é╡é▄é╡é╜: " ); /* 1991 COR. */
errput( msg );
errput( "\n" );
EXIT2( 1 );
}else
(*WindowError)( msg );
}
#if 0
void ErrorCheck( flag, msg )
int flag ;
char *msg ;
{
if ( ! flag )
{
if ( WindowError == NULL )
{
errput( "âGâëü[é¬ö¡É╢é╡é▄é╡é╜: " ); /* 1991 COR. */
errput( msg );
putc( '\n', stderr );
exit( 1 );
}
else
(*WindowError)( msg );
}
}
#endif