home *** CD-ROM | disk | FTP | other *** search
/ Kyūkyoku!! X68000 Emulator / X68000Book.dat / mac / OLS / X68000 / Ko-Window / kow142s.lzh / wsrv / kanji.c < prev    next >
C/C++ Source or Header  |  1995-11-25  |  3KB  |  149 lines

  1. #include    <stdio.h>
  2. #include    <microstr.h>
  3. #include    <sys_doslib.h>
  4. #include    <iocslib.h>
  5.  
  6. #include    "clip.h"
  7. #include    "window.h"
  8. #include    "simple.h"
  9. #include    "manager.h"
  10. #include    "screen.h"
  11. #include    "wopen.h"
  12.  
  13. /* 1994 11/26 WindowSetHenDsp Æ╟ë┴é╔éµéΘæσò¥Åæé½è╖骠H.Ogasawara (COR.) */
  14.  
  15. int        HenDsp( int, int, char* );
  16.  
  17. int        HenDspEntry();
  18. void    HenEchoLock();
  19. void    HenEchoUnlock();
  20.  
  21. static    int        HposX= 4,
  22.                 HposY= -26;
  23.  
  24. #define    NKOUHOWIN    1
  25. #define    FONT        16
  26. #define    FONTX        8
  27. #define    IWINCHAR    80
  28. #define    IWINSIZE    (IWINCHAR*FONTX)
  29. #define    MWINCHAR    10
  30.  
  31. static SimpleClass    ModeWP, InputWP;
  32. static int            (*DefaultHenDsp)(),
  33.                     (*WindowHenDspEnt)()= HenDspEntry;
  34.  
  35. extern int    ScreenH,
  36.             ScreenV;
  37.  
  38. void *
  39. WindowSetHenDsp( ent )
  40. void    *ent;
  41. {
  42.     return    (void*)INTVCS( 0xff18, WindowHenDspEnt= ent );
  43. }
  44.  
  45. void
  46. KanjiInit()
  47. {
  48.     if( !DefaultHenDsp ){
  49.         HenEchoLock();
  50.         DefaultHenDsp= (void*)INTVCS( 0xff18, (void*)WindowHenDspEnt );
  51.     }
  52. }
  53.  
  54. void
  55. KanjiQuit()
  56. {
  57.     if( DefaultHenDsp ){
  58.         INTVCS( 0xff18, (void*)DefaultHenDsp );
  59.         HenEchoUnlock();
  60.         DefaultHenDsp= NULL;
  61.     }
  62. }
  63.  
  64. static int
  65. HenkanExec( wp, info )
  66. SimpleClass    *wp;
  67. EventInfo    *info;
  68. {
  69.     static    DrawBuf    buf[1];
  70.     switch( info->option ){
  71.         case EventRedraw:
  72.             DrawSetClear( buf, 1 );
  73.             WindowDraw( wp, buf, 1 );
  74.             break;
  75.         case EventClose:
  76.             WindowClose( wp );
  77.             break;
  78.         case EventMouseSwitch:
  79.             if( info->LeftON || info->RightON ){
  80.                 MoveOperation( wp, info );
  81.                 if( wp == &InputWP ){
  82.                     WindowGetPosition( wp, &HposX, &HposY );
  83.                     HposX -= HomeX;
  84.                     HposY -= HomeY+ScreenV;
  85.                 }
  86.             }
  87.     }
  88.     return    TRUE;
  89. }
  90.  
  91. int
  92. HenDsp( mode, pos, str )
  93. int        mode, pos;
  94. char    *str;
  95. {
  96.     SimpleClass    *wp= &InputWP;
  97.     DrawBuf        buf[1];
  98.     int            HenkanX= HposX+ HomeX;
  99.     int            HenkanY= HposY+ ScreenV +HomeY ;
  100.     int            x= pos*8 +4;
  101.  
  102.     switch( mode ){
  103.         case 0: /* mode open */
  104.             (*systemfunc[SimpleType].setfunc)(
  105.                         &ModeWP, HenkanX+IWINSIZE+26, HenkanY,
  106.                         MWINCHAR*FONTX+8, FONT+4, &RootWindow, -1,HenkanExec);
  107.             WindowRedraw( &ModeWP );
  108.             return    MWINCHAR+2;
  109.         case 1:    /* mode draw */
  110.         case 2:    /* mode R draw */
  111.             if( pos < 3 )
  112.                 goto    length_ret;
  113.             wp= &ModeWP;
  114.             x-= 24;    /* pos-= 3 */
  115.         case 5: /* input draw */
  116.         case 6: /* input R draw */
  117.         case 9: /* kouho draw */
  118.         case 10:/* kouho R draw */
  119.             if( *str ){
  120.                 DrawSetSymbol( buf, x, 2, str,
  121.                                 (mode&1) ? AttrDefault : 1, FONT );
  122.                 WindowDraw( wp, buf, 1 );
  123.             }
  124.         length_ret:
  125.             return    pos+n_strlen( str );
  126.         case 3: /* mode close */
  127.             WindowClose( &ModeWP );
  128.             WindowClose( &InputWP );
  129.             break;
  130.         case 4: /* input open */
  131.             (*systemfunc[SimpleType].setfunc)( &InputWP, HenkanX, HenkanY,
  132.                         IWINSIZE+8, FONT+4, &RootWindow,-1, HenkanExec );
  133.             WindowRedraw( &InputWP );
  134.             return    IWINCHAR;
  135.         case 7: /* input erase */
  136.             DrawSetLine( buf, x, 2, IWINSIZE+8, 17, 1, OptionFill );
  137.             WindowDraw( &InputWP, buf, 1 );
  138.             break;
  139.         case 8:  /* kouho open */
  140.         case 11: /* kouho close */
  141.             DrawSetClear( buf, 1 );
  142.             WindowDraw( &InputWP, buf, 1 );
  143.             return    IWINCHAR;
  144.     }
  145.     return    0;
  146. }
  147.  
  148. /* :vi:se ts=4 sw=4: */
  149.