home *** CD-ROM | disk | FTP | other *** search
- /* Copyright 1992 H.Ogasawara (COR.) */
- /* MonoGusaLib -> Mglib*/
-
- #include "corlib.h"
- #include <winop.h>
- #include "MgProg.h"
-
- MgLibPack *__Mg_Dummy;
-
- void
- __Mg_SendKeyString( wp, info, p )
- WindowID wp;
- EventInfo *info;
- unsigned char *p;
- {
- while( *p ){
- info->KeyCode= *p++;
- info->ShiftStat= 0;
- info->option= EventKey;
- WindowSendEvent( wp, info );
- }
- }
-
- static
- DExec( wp, info )
- WindowID wp;
- EventInfo *info;
- {
- MgLibPack *dp;
- if( info->option == EventOpen ){
- WindowSetClientData( wp, 0, dp= __Mg_Dummy );
- }else
- dp= WindowGetClientPointer( wp );
- switch( info->option ){
- case EventOpen:
- if( dp->attr & WindowAttrGraphicUse ){
- DefGraphicInit( &dp->gra,
- dp->attr & WindowAttrGraphicUse,
- DefGraphicSleep, (void*)-1 );
- WindowSetAttr( wp, dp->attr & WindowAttrGraphicUse );
- WindowSetEventAttr( wp, EventAttrDefault|EventUserON|
- EventGraphicON|EventPopON|EventMoveON );
- GposInit( wp );
- }else
- WindowSetEventAttr( wp, EventAttrDefault|EventUserON );
- if( !(*dp->exec)( wp, info ) )
- WindowRedraw( wp );
- return TRUE;
- case EventRedraw:
- if( dp->attr & WindowAttrGraphicUse ){
- if( DefGraphicRedraw( &dp->gra, wp, info ) )
- return TRUE;
- DefGraphicPalet( &dp->gra );
- }
- if( !(*dp->exec)( wp, info ) ){
- DrawBuf dbuf[1];
- DrawSetClear( dbuf, 1 );
- WindowDraw( wp, dbuf, 1 );
- }
- return TRUE;
- case EventClose:
- if( !(*dp->exec)( wp, info ) ){
- WindowClose( wp );
- WindowConnectionClose();
- }
- free( dp );
- return TRUE;
- case EventIconify:
- if( !(*dp->exec)( wp, info ) )
- IconEnt( wp, (char*)GetTitleAddress(wp), AttrDefault, 12 );
- return TRUE;
- case EventUser:
- if( !(*dp->exec)( wp, info ) ){
- char **pp;
- switch( info->ComData ){
- default:
- return FALSE;
- case UserStrings:
- for( pp= info->ComBuffer ; *pp ;)
- __Mg_SendKeyString( wp, info, *pp++ );
- case UserString:
- case UserPaste:
- __Mg_SendKeyString( wp, info, info->ComBuffer );
- }
- }
- return TRUE;
- case EventMove:
- case EventPop:
- case EventGraphic:
- if( !(*dp->exec)( wp, info ) )
- return DefGraphicEnt( &dp->gra, wp, info );
- return TRUE;
- default:
- return (*dp->exec)( wp, info );
- }
- return FALSE;
- }
-
- WindowID
- MgWindowDefaultOpen( x, y, h, v, title, mode, Exec )
- char *title;
- int (*Exec)();
- {
- if( !(__Mg_Dummy= (MgLibPack*)malloc( sizeof( MgLibPack ) )) )
- return NULL;
-
- __Mg_Dummy->exec= Exec;
- __Mg_Dummy->attr= (mode>>8) & WindowAttrGraphicUse;
- return WindowTitleOpen( x, y, h, v, NULL, title,
- Close|Push|(mode&MgTitleItem), DExec );
- }
-
- WindowID
- MgWindowDefaultOpenArgs( x, y, h, v, title, argc, argv, mode, Exec )
- char *title, **argv;
- int (*Exec)();
- {
- if( mode & MgSwitchHV)
- AnalyzeArgs( argc, argv, &x, &y, &h, &v );
- else
- AnalyzeArgs( argc, argv, &x, &y, NULL, NULL );
- return MgWindowDefaultOpen( x, y, h, v, title, mode, Exec );
- }
-
-