home *** CD-ROM | disk | FTP | other *** search
/ ftp.eri.u-tokyo.ac.jp / 2014.03.ftp.eri.u-tokyo.ac.jp.zip / ftp.eri.u-tokyo.ac.jp / pub / seisv / src / 3.02 / graph.c < prev    next >
C/C++ Source or Header  |  1999-11-10  |  30KB  |  1,253 lines

  1. /*  SeisView alone/client    Copyright (C) 1992,1999  K.Koketsu
  2.              <history>
  3.          99-11-12  Remove the color cell short warning.
  4.          99-01-08  Specify the WinSock version explicitly.
  5.          98-11-25  Check no adobe fonts automatically.
  6.          98-11-03  Remove CR.
  7.          98-10-06  Printers appear again.
  8.                    Some global variables are replaced by constants.
  9.          98-10-02  MONOCHROME drops from the support list.
  10.          98-02-25  Abandon DOS, but take Windows 95/NT.
  11.          96-06-19  floating color values.                */
  12.  
  13. #include <string.h>
  14. #include <stdio.h>
  15. #include "seis.h"
  16. #include "ctlname.h"
  17.  
  18. extern char  VERSION[];
  19. extern char  fk[61*3+1];              /* display strings for function keys   */
  20. extern char  z$[11], w$[81];                      /* work string             */
  21. extern char  prn$[5], drvo$[65];
  22.  
  23. #define FontHeight    16
  24. #define SmallFontHeight    14
  25. #define MenuFontHeight    14
  26. #define FontWidth     8
  27. #define LineHeight    (FontHeight+1)
  28. #define Lines        24
  29. #define XOffset         4
  30. #define YOffset      7
  31. #define XExtra         9
  32. #ifdef UNIX
  33. #define    YExtra         0
  34. #else /* Title bar and borders should be included on Windows.*/
  35. #define    YExtra        26
  36. #endif
  37. #define HeaderHeight    38
  38. #define WindowWidth    640+XOffset+XExtra
  39. #define WindowHeight    YPixels+HeaderHeight+YOffset+YExtra
  40.  
  41. #define Color8         130
  42. /* 190 is not appropriate for the Windows 256-color mode. */
  43. #define Color9         192
  44. #define Color10        230
  45.  
  46. struct xycoord { short xcoord; short ycoord; };
  47.  
  48. short   xo = 0, yo = 0;
  49. int     psflag = 0;
  50. short   xoff = 0, yoff = 0;
  51. short   forecolor = 7;
  52. short   fontmode = 0;
  53.  
  54. /* Naming Convention
  55.     pfunction(xp, yp): xp, yp = window coordinates.
  56.     _function(x_, y_): x_, y_ = application coordinates (x_ = xp - offset).
  57.     xfunction(xx, yx): xx, yx = column-row coordinates. */
  58.    
  59. void    pmoveto(), plineto(), windows_menu(),
  60.     pouttext(), _menu_font(), _lineto(), _moveto();
  61. int    mouse2key(), menux1[10], menux2[10], oldfunc;
  62. int    menuy1 = 1, menuy2 = LineHeight - 1;
  63. char    menuitem[10][10] = {"Select", "Browse", "Print", "saVe", "soRt",
  64.                 "Map", "Time", "maGnitude", "Option", "Exit" };
  65. int    barx1[10], barx2[10];
  66. int    bary1 = LineHeight + 4, bary2 = LineHeight*2 + 4;
  67.  
  68. /******************* Windows routines *********************/
  69. #ifdef WIN32
  70.  
  71. #define    MouseX    LOWORD(lParam)
  72. #define MouseY  HIWORD(lParam)
  73.  
  74. #define MAX_PEN_BRUSH 13
  75.  
  76. LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
  77. void  main();
  78.  
  79. char       szWinName[] = "SeisView";
  80. HINSTANCE  hInst;
  81. HWND       hwnd;
  82. HDC       hdc, hdc2, memdc;
  83. extern HDC pmemdc;
  84. LPARAM       lParam;
  85. DWORD       ThreadID;
  86. HANDLE       hSema;
  87. HBITMAP       hbit;
  88. HPEN       hPen[MAX_PEN_BRUSH]  ;
  89. HBRUSH       hBrush[MAX_PEN_BRUSH];
  90. LOGFONT    lFont;
  91. HFONT      hFont, hSmallFont, hMenuFont;
  92. HCURSOR       hCursor0, hCursor1;
  93. int       ScreenWidth, ScreenHeight;
  94. int       cursor = 0;
  95.  
  96. int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
  97.                    LPSTR lpszArgs, int nWinMode)
  98. {
  99.     HWND    hwnd;
  100.     MSG        msg;
  101.     WNDCLASSEX    wcl;
  102.  
  103.     hInst = hThisInst;
  104.     wcl.hInstance = hThisInst;
  105.     wcl.lpszClassName = szWinName;
  106.     wcl.lpfnWndProc = WindowFunc;
  107.     wcl.style = 0;
  108.     wcl.cbSize = sizeof( WNDCLASSEX );
  109.     wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  110.     wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
  111.     wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
  112.     wcl.lpszMenuName = 0;
  113.     wcl.cbClsExtra = 0;
  114.     wcl.cbWndExtra = 0;
  115.     wcl.hbrBackground = GetStockObject( LTGRAY_BRUSH );
  116.  
  117.     if(!RegisterClassEx(&wcl)) return 0;
  118.  
  119.     hwnd = CreateWindow(
  120.         szWinName, VERSION,
  121.         WS_OVERLAPPEDWINDOW,
  122.         CW_USEDEFAULT, CW_USEDEFAULT,
  123.         WindowWidth, WindowHeight,
  124.         HWND_DESKTOP, NULL, hThisInst, NULL
  125.         );
  126.  
  127.     ShowWindow(hwnd, nWinMode);
  128.     UpdateWindow(hwnd);
  129.     while(GetMessage(&msg, NULL, 0, 0))    {
  130.     TranslateMessage(&msg);
  131.     DispatchMessage(&msg);
  132.     }
  133.     return msg.wParam;
  134. }
  135.  
  136. short  key, cflag = 0;
  137. char str[255];
  138.  
  139. LRESULT CALLBACK WindowFunc(HWND hwndD, UINT message,
  140.                 WPARAM wParam, LPARAM lParamD)
  141. {
  142.     short  scancode;
  143.     PAINTSTRUCT paintstruct;
  144.  
  145.     hwnd   = hwndD;
  146.     lParam = lParamD;
  147.  
  148.     switch(message) {
  149.     case WM_CREATE:
  150.         hSema = CreateSemaphore(NULL, 1, 1, "mysem");
  151.         WaitForSingleObject(hSema, INFINITE);
  152.         CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)main,
  153.                      NULL, 0, &ThreadID);
  154.         break;
  155.  
  156.     case WM_KEYDOWN:
  157.         scancode = ((lParam & 0xff0000) >> 16) + 0x100;
  158.         if(scancode == Ctrl) { cflag = 1; break; }
  159.         if((lParam & 0x01000000) || (scancode>=F1 && scancode<=F9)) {
  160.         key = scancode;
  161.         cflag = 0;
  162.         ReleaseSemaphore(hSema, 1, NULL);
  163.         WaitForSingleObject(hSema, INFINITE);
  164.         }
  165.         break;
  166.  
  167.     case WM_RBUTTONDOWN:
  168.     case WM_LBUTTONDOWN:
  169.         key = mouse2key();
  170.         cflag = 0;
  171.  
  172.     case WM_CHAR:
  173.         if(message == WM_CHAR) {
  174.         key = wParam;
  175.         if(key==cr && cflag)  key = CtlM;
  176.         cflag = 0;
  177.         }
  178.         ReleaseSemaphore(hSema, 1, NULL);
  179.         WaitForSingleObject(hSema, INFINITE);
  180.         break;
  181.  
  182.     case WM_SETCURSOR:
  183.         if( cursor )  SetCursor( hCursor1 );
  184.         else  SetCursor( hCursor0 );
  185.         break;
  186.  
  187.      case WM_PAINT:
  188.         hdc2 = BeginPaint(hwnd, &paintstruct);
  189.         BitBlt(hdc2, 0, 0, ScreenWidth, ScreenHeight, memdc, 0, 0,SRCCOPY);
  190.         EndPaint(hwnd, &paintstruct);
  191.         break;
  192.  
  193.     case WM_DESTROY:
  194.          /* PostQuitMessage() must be posted within this thread, but
  195.            DestroyWindow() exists for this problem. See win_finish().*/
  196.         PostQuitMessage(0);
  197.         break;
  198.  
  199.     default:
  200.         return DefWindowProc(hwnd, message, wParam, lParam);
  201.     }
  202.     return 0;
  203. }
  204.  
  205. /*
  206. int exitbox()
  207. { return( MessageBox(hwnd, "Quit SeisView?", "Exit", MB_YESNO) ); }
  208. */
  209.  
  210. color2RGB( color )
  211. int  color;
  212. {
  213.     int  rgb;
  214.  
  215.     switch( color ) {
  216.     case  8: rgb = RGB(Color8 ,Color8 ,Color8 ); break;
  217.     case  9: rgb = RGB(Color9 ,Color9 ,Color9 ); break;
  218.     case 10: rgb = RGB(Color10,Color10,Color10); break;
  219.     case 11: rgb = RGB(     0 ,     0 ,Color8 ); break;
  220.     default: rgb = (color & 1) * 0xff0000;
  221.          if(color & 2) rgb = rgb | 0x00ff00;
  222.          if(color & 4) rgb = rgb | 0x0000ff;
  223.          break;
  224.     }
  225.     return( rgb );
  226. }
  227.  
  228. RGB2color( rgb )
  229. COLORREF  rgb;
  230. {
  231.     int  color;
  232.  
  233.     switch( rgb ) {
  234.         case RGB(Color8 ,Color8 ,Color8 ): color =  8; break;
  235.     case RGB(Color9 ,Color9 ,Color9 ): color =  9; break;
  236.     case RGB(Color10,Color10,Color10): color = 10; break;
  237.     case RGB(     0 ,     0 ,Color8 ): color = 11; break;
  238.     default: color = 0;
  239.          if(rgb & 0xff0000) color = color | 1;
  240.          if(rgb & 0x00ff00) color = color | 2;
  241.          if(rgb & 0x0000ff) color = color | 4;
  242.          break;
  243.     }
  244.     return( color );
  245. }
  246.  
  247. void win_init()
  248. {
  249.     int     i;
  250.     WORD    wVersionRequested;
  251.     WSADATA wsaData;
  252.  
  253.     ScreenWidth  = GetSystemMetrics( SM_CXSCREEN );
  254.     ScreenHeight = GetSystemMetrics( SM_CYSCREEN );
  255.     hdc = GetDC( hwnd );
  256.     memdc = CreateCompatibleDC( hdc );
  257.     hbit = CreateCompatibleBitmap(hdc, ScreenWidth, ScreenHeight);
  258.     SelectObject(memdc, hbit);
  259.     PatBlt(memdc, 0, 0, ScreenWidth, ScreenHeight, PATCOPY);
  260.     SetBkColor(memdc, color2RGB(9));
  261.  
  262.     for(i=0; i<MAX_PEN_BRUSH-1; i++) {
  263.     hPen[i]    = CreatePen(PS_SOLID, 1, color2RGB(i));
  264.     hBrush[i]  = CreateSolidBrush( color2RGB(i) );
  265.     }
  266.     hBrush[MAX_PEN_BRUSH-1]  = GetStockObject( HOLLOW_BRUSH );
  267.  
  268.     memset(&lFont, 0, sizeof(LOGFONT));
  269.     lFont.lfHeight = FontHeight;
  270.     lFont.lfHeight = FontHeight;
  271.     strcpy((LPSTR)&(lFont.lfFaceName), "Courier New");
  272.     hFont = CreateFontIndirect( &lFont );
  273.     SelectObject(memdc, hFont);
  274.     lFont.lfHeight = SmallFontHeight;
  275.     strcpy((LPSTR)&(lFont.lfFaceName), "Courier New");
  276.     hSmallFont = CreateFontIndirect( &lFont );
  277.     lFont.lfHeight = MenuFontHeight;
  278.     strcpy((LPSTR)&(lFont.lfFaceName), "Modern");
  279.     hMenuFont = CreateFontIndirect( &lFont );
  280.  
  281.     hCursor0 = LoadCursor(NULL, IDC_ARROW);
  282.     hCursor1 = LoadCursor(NULL, IDC_CROSS);
  283.  
  284.     /* Version 1.1: This is required for 98 and NT (1999-01-08). */
  285.     wVersionRequested = MAKEWORD(1, 1);
  286.     WSAStartup(wVersionRequested, &wsaData);
  287. }
  288.  
  289. void win_finish() {
  290.     int  i;
  291.  
  292.     ReleaseDC(hwnd, hdc);
  293.     DeleteDC( memdc ); /* Delete, not release a created DC. */
  294.     for(i=0; i<MAX_PEN_BRUSH; i++){
  295.     DeleteObject( hPen[i] );
  296.     DeleteObject( hBrush[i] );
  297.     }
  298.     DestroyCursor( hCursor0 );
  299.     DestroyCursor( hCursor1 );
  300.     DestroyWindow( hwnd );
  301.  
  302.     WSACleanup();
  303. }
  304.  
  305. void pmoveto(x, y) short  x, y; { xo = x; yo = y;
  306.   MoveToEx(hdc, x, y, NULL); MoveToEx(memdc, x, y, NULL); }
  307.  
  308. void plineto(x, y) short  x, y;
  309. { LineTo(hdc, x, y); LineTo(memdc, x, y); }
  310.  
  311. void _setcolor( color )
  312. short  color;
  313. {
  314.     forecolor = color;
  315.     SelectObject(hdc  , hPen[color]);
  316.     SelectObject(memdc, hPen[color]);
  317.     SetTextColor(  hdc, (COLORREF)color2RGB(color));
  318.     SetTextColor(memdc, (COLORREF)color2RGB(color));
  319. }
  320.  
  321. void _setbkcolor( color ) /* color = 12 for hollow background */
  322. short  color;
  323. {
  324.     SelectObject(hdc  , hBrush[color]);
  325.     SelectObject(memdc, hBrush[color]);
  326.     if(color < 12) {
  327.     SetBkColor(  hdc, (COLORREF)color2RGB(color));
  328.     SetBkColor(memdc, (COLORREF)color2RGB(color));
  329.     }
  330. }
  331.  
  332. void beep() { MessageBeep( MB_OK); }
  333.  
  334. void prectangle(flag, x1, y1, x2, y2)
  335. short flag, x1, y1, x2, y2;
  336. {
  337.     if(flag == 1) _setbkcolor( forecolor );
  338.     else _setbkcolor( 12 );
  339.     Rectangle(hdc  , x1, y1, x2, y2);
  340.     Rectangle(memdc, x1, y1, x2, y2);
  341. }
  342.  
  343. short getcchr()
  344. {
  345.     short  c;
  346.  
  347.     WaitForSingleObject(hSema, INFINITE);
  348.     c = key;
  349.     ReleaseSemaphore(hSema, 1, NULL);
  350.     return ( c );
  351. }
  352.  
  353. void _setviewport(x1, y1, x2, y2)
  354. short  x1, y1, x2, y2;
  355. {
  356.     HRGN hrgn;
  357.     int  left, right, top, bottom;
  358.  
  359.     if(x1==0 && y1==0 && x2==639 && y2==YPixels-1) { /* Full Screen */
  360.     left   = 0;
  361.     top    = 0;
  362.     right  = WindowWidth;
  363.     bottom = WindowHeight;
  364.     }
  365.     else {
  366.     left   = xx( x1 );
  367.     top    = yy( y1 );
  368.     right  = xx( x2 );
  369.     bottom = yy( y2 );
  370.     }
  371.     hrgn = CreateRectRgn(left, top, right, bottom);
  372.     SelectClipRgn(hdc  , hrgn);
  373.     SelectClipRgn(memdc, hrgn);
  374.     xoff = x1;
  375.     yoff = y1;
  376. }
  377.  
  378. void _setpixel(x, y)
  379. int  x, y;
  380. {
  381.     SetPixel(hdc  , xx(x), yy(y), (COLORREF)color2RGB(forecolor));
  382.     SetPixel(memdc, xx(x), yy(y), (COLORREF)color2RGB(forecolor));
  383. }
  384.  
  385. void _getimage() {}
  386.  
  387. int _getpixel(x, y)
  388. int  x, y;
  389. {
  390.     COLORREF rgb;
  391.     rgb = GetPixel(hdc, xx(x), yy(y));
  392.     return( RGB2color( rgb ) );
  393. }
  394.  
  395. void _circle(flag, x, y, r)
  396. short  flag, x, y, r;
  397. {
  398.     if(flag == 1) _setbkcolor( forecolor );
  399.     else _setbkcolor( 12 );
  400.     if(r <= 1) _setpixel(x, y);
  401.     else {
  402.         Ellipse(hdc  , xx(x)-r, yy(y)-r, xx(x)+r, yy(y)+r);
  403.     Ellipse(memdc, xx(x)-r, yy(y)-r, xx(x)+r, yy(y)+r);
  404.     }
  405. }
  406.  
  407. void _fillpolygon(pq, n)
  408. short  n;
  409. struct xycoord *pq;
  410. {
  411.     POINT  qr[10]; /* # of points should be less than 11.*/
  412.     short  i;
  413.  
  414.     for(i=0; i<n; i++) {
  415.     qr[i].x = xx(pq[i].xcoord);
  416.     qr[i].y = yy(pq[i].ycoord);
  417.     }
  418.     _setbkcolor( forecolor );
  419.     Polygon(hdc  , qr, n);
  420.     Polygon(memdc, qr, n);
  421. }
  422.  
  423. void _settextmode( mode )
  424. int  mode;
  425. {
  426.     if(mode > 0) {
  427.     SetBkMode(hdc  , OPAQUE);
  428.     SetBkMode(memdc, OPAQUE);
  429.     }
  430.     else {
  431.     SetBkMode(hdc  , TRANSPARENT);
  432.     SetBkMode(memdc, TRANSPARENT);
  433.     }
  434. }
  435.  
  436. void pouttext(x, y, s)
  437. int  x, y;
  438. char *s;
  439. {
  440.     TextOut(hdc  , x, y, s, strlen(s));
  441.     TextOut(memdc, x, y, s, strlen(s));
  442. }
  443.  
  444. void _normal_font() 
  445. {
  446.     SelectObject(hdc  , hFont);
  447.     SelectObject(memdc, hFont);
  448. }
  449.  
  450. void _small_font()
  451. {
  452.     SelectObject(hdc  , hSmallFont);
  453.     SelectObject(memdc, hSmallFont);
  454. }
  455.  
  456. void _menu_font()
  457. {
  458.     SelectObject(hdc  , hMenuFont);
  459.     SelectObject(memdc, hMenuFont);
  460. }
  461.  
  462. _gettextextent( s )
  463. char  *s;
  464. {
  465.     SIZE size;
  466.     GetTextExtentPoint32(memdc, s, strlen(s), &size);
  467.     return( size.cx );
  468. }
  469.  
  470. void gcursor(kx0, ky0, kx1, ky1, xo, yo, flg)
  471. int  kx0, ky0, kx1, ky1, *xo, *yo, flg;
  472. {
  473.     POINT   point;
  474.     int  x, y, crx, cry;
  475.  
  476.     cursor = 1;
  477.     point.x = xx( *xo );
  478.     point.y = yy( *yo );
  479.     ClientToScreen(hwnd, &point);
  480.     SetCursorPos(point.x, point.y);
  481.     crx = 5;  cry = 5;
  482.  
  483.     *xo = -2;
  484.     for(;;) {
  485.     if(getcchr() >= 0x200) {
  486.         GetCursorPos( &point );
  487.         ScreenToClient(hwnd, &point);
  488.         x = point.x - xoff - XOffset;
  489.         y = point.y - yoff - YOffset - HeaderHeight;
  490.         if(x<kx0 || x>kx1 || y<ky0 || y>ky1) beep();
  491.         else {
  492.         *xo = x;
  493.         *yo = y;
  494.         }
  495.     }
  496.     if(*xo > -2)  break;
  497.     }
  498.  
  499.     if( flg ) {
  500.     _setcolor( 2 );
  501.     _moveto(*xo, *yo-cry);  _lineto(*xo, *yo+cry);
  502.     _moveto(*xo-crx, *yo);  _lineto(*xo+crx, *yo);
  503.     }
  504.     cursor = 0;
  505. }
  506.  
  507. void xflush(){}
  508.  
  509. /****************** X Window routines **********************/
  510. #else
  511.  
  512. #include <X11/X.h>
  513. #include <X11/Xlib.h>
  514. #include <X11/Xutil.h>
  515. #include <X11/Xatom.h>
  516. #include <X11/keysym.h>
  517. #include <X11/cursorfont.h>
  518.  
  519. #define     MouseX      ev.xbutton.x
  520. #define  MouseY      ev.xbutton.y
  521.  
  522. Display  *d;
  523. Window   w;
  524. Pixmap   p;
  525. GC       gc;
  526. XEvent   ev;
  527. XImage   *im;
  528. Cursor   cs;
  529. Font     ft, nft, sft, mft;
  530. int      fh, nfh, sfh, mfh;
  531. unsigned long  mycolor, bkcolor;
  532. unsigned long  color2RGB();
  533. int      mywidth = 1;
  534. int      mystyle = LineSolid;
  535. int      textmode  = 1;
  536.  
  537. int ehandler(d, e)
  538. Display *d;
  539. XErrorEvent *e;
  540. {
  541.     if(e->error_code==15 && e->request_code==45) {
  542.     fontmode = 1;
  543.     nft = XLoadFont(d, "7x14");
  544.     mft = XLoadFont(d, "6x13");
  545.     }
  546. }
  547.  
  548. void win_init()
  549. {
  550.     XWMHints  hints;
  551.     XFontStruct *fs;
  552.     Colormap  cmap;
  553.     unsigned long  pixels[12], planes[1];
  554.     int            rc;
  555.  
  556.     XSetErrorHandler( ehandler );
  557.     d = XOpenDisplay( 0 );
  558.     if(d == NULL) {
  559.     puts( "You are not in the X Window environment!" );
  560.     exit( 1 );
  561.     }
  562.  
  563.     w = XCreateSimpleWindow(d, DefaultRootWindow(d), 0, 0,
  564.                 WindowWidth, WindowHeight,
  565.                 5, color2RGB(9), color2RGB(9));
  566.     XSelectInput(d, w, ExposureMask | KeyPressMask | ButtonPressMask);
  567.     XChangeProperty(d, w, XA_WM_NAME, XA_STRING, 8, PropModeReplace,
  568.             VERSION, strlen(VERSION));
  569.     hints.flags = InputHint;
  570.     hints.input = True;
  571.     XSetWMHints(d, w, &hints);
  572.  
  573.     XMapWindow(d, w);
  574.     gc = XCreateGC(d, w, 0, 0);
  575.     p  = XCreatePixmap(d, w, WindowWidth, WindowHeight, DefaultDepth(d,0));
  576.     cmap = DefaultColormap(d, 0);
  577.  
  578.     nft = XLoadFont(d, "*-courier-medium-r-*-14-*");
  579.     sft = XLoadFont(d, "7x14");
  580.     mft = XLoadFont(d, "*-palatino-medium-r-*-12-*");
  581.     fs  = XQueryFont(d, nft);
  582.     nfh = (*fs).max_bounds.ascent;
  583.     fs  = XQueryFont(d, sft);
  584.     sfh = (*fs).max_bounds.ascent;
  585.     fs  = XQueryFont(d, mft);
  586.     mfh = (*fs).max_bounds.ascent - 1;
  587.  
  588.     cs = XCreateFontCursor(d, XC_arrow);
  589.     XDefineCursor(d, w, cs);
  590.  
  591.     do  XNextEvent(d, &ev); /* Wait for exposure */
  592.     while(ev.type != Expose);
  593. }
  594.  
  595. void win_finish(){}
  596.  
  597. void pmoveto(x, y)
  598. short  x, y;
  599. { xo = x;  yo = y; }
  600.  
  601. void plineto(x, y)
  602. short  x, y;
  603. {
  604.     XDrawLine(d, w, gc, xo, yo, x, y);
  605.     XDrawLine(d, p, gc, xo, yo, x, y);
  606.     pmoveto(x, y);
  607. }
  608.  
  609. prectangle(flag, x1, y1, x2, y2)
  610. short flag, x1, y1, x2, y2;
  611. {
  612.     if(flag == 1) {
  613.     XFillRectangle(d, w, gc, x1, y1, x2-x1, y2-y1);
  614.     XFillRectangle(d, p, gc, x1, y1, x2-x1, y2-y1);
  615.     }
  616.     else {
  617.     XDrawRectangle(d, w, gc, x1, y1, x2-x1, y2-y1);
  618.     XDrawRectangle(d, p, gc, x1, y1, x2-x1, y2-y1);
  619.     }
  620. }
  621.  
  622. void _circle(flag, x, y, r)
  623. short  flag, x, y, r;
  624. {
  625.     if(r == 0)  XDrawPoint(d, w, gc, xx(x), yy(y));
  626.     else {
  627.     if(flag) XFillArc(d, w, gc, xx(x)-r, yy(y)-r, r*2, r*2, 0, 360*64);
  628.     else     XDrawArc(d, w, gc, xx(x)-r, yy(y)-r, r*2, r*2, 0, 360*64);
  629.     }
  630. }
  631.  
  632. _fillpolygon(pq, n)
  633. short  n;
  634. struct xycoord *pq;
  635. {
  636.     XPoint  qr[10]; /* # of points should be less than 11.*/
  637.     short   i;
  638.  
  639.     for(i=0; i<n; i++) {
  640.     qr[i].x = xx(pq[i].xcoord);
  641.     qr[i].y = yy(pq[i].ycoord);
  642.     }
  643.     XFillPolygon(d, w, gc, qr, n, Nonconvex, CoordModeOrigin);
  644.     XFillPolygon(d, p, gc, qr, n, Nonconvex, CoordModeOrigin);
  645. }
  646.  
  647. int _gettextextent( s )
  648. char  *s;
  649. {
  650.     XFontStruct *fs;
  651.     XCharStruct  cs;
  652.     int  dir, ascent, descent;
  653.  
  654.     fs = XQueryFont(d, ft);
  655.     XTextExtents(fs, s, strlen(s), &dir, &ascent, &descent, &cs);
  656.     return(cs.rbearing - cs.lbearing);
  657. }
  658.  
  659. _setviewport(x1, y1, x2, y2)
  660. short  x1, y1, x2, y2;
  661. {
  662.     XRectangle  rec;
  663.  
  664.     if(x1==0 && y1==0 && x2==639 && y2==YPixels-1) { /* Full Screen */
  665.     rec.x = 0;
  666.     rec.y = 0;
  667.     rec.width  = WindowWidth;
  668.     rec.height = WindowHeight;
  669.     }
  670.     else {
  671.     rec.x = xx( x1 );
  672.     rec.y = yy( y1 );
  673.     rec.width  = x2 - x1;
  674.     rec.height = y2 - y1;
  675.     }
  676.     XSetClipRectangles(d, gc, 0, 0, &rec, 1, Unsorted);
  677.     xoff = x1;
  678.     yoff = y1;
  679. }
  680.  
  681. void _setcolor( color )
  682. short  color;
  683. {
  684.     char  s[9];
  685.  
  686.     forecolor = color;
  687.     mycolor = color2RGB( color );
  688.     MyLineAttributes();
  689. }
  690.  
  691. void _setbkcolor( color )
  692. short  color;
  693. {
  694.     char  s[9];
  695.  
  696.     bkcolor = color2RGB( color );
  697.     MyLineAttributes();
  698. }
  699.  
  700. void _getimage()
  701. { im = XGetImage(d, w, 0, 0, WindowWidth, WindowHeight, -1, XYPixmap); }
  702.  
  703. int _getpixel(x, y)
  704. int  x, y;
  705. {
  706.     unsigned long  pixel;
  707.  
  708.     pixel = XGetPixel(im, xx(x), yy(y));
  709.     if(pixel == BlackPixel(d,0))  return( 0 );
  710.     else  return( 1 );
  711. }
  712.  
  713. void _normal_font() {
  714.     fh = nfh; ft = nft;
  715.     XSetFont(d, gc, ft);
  716. }
  717. void _small_font() {
  718.     fh = sfh; ft = sft;
  719.     XSetFont(d, gc, ft);
  720. }
  721. void _menu_font() {
  722.     fh = mfh; ft = mft;
  723.     XSetFont(d, gc, ft);
  724. }
  725.  
  726. void _settextmode( mode ) int mode; { textmode = mode; }
  727.  
  728. void pouttext(x, y, s)
  729. int  x, y;
  730. char *s;{
  731.     /* The base is defined to be the bottom on X Window. */
  732.     if(textmode == 0) {
  733.     XDrawString(d, w, gc, x, y+fh, s, strlen(s));
  734.     XDrawString(d, p, gc, x, y+fh, s, strlen(s));
  735.     }
  736.     else {
  737.     XDrawImageString(d, w, gc, x, y+fh, s, strlen(s));
  738.     XDrawImageString(d, p, gc, x, y+fh, s, strlen(s));
  739.     }
  740. }
  741.  
  742. void xflush() { XFlush( d ); }
  743.  
  744. short getcchr()
  745. {
  746.     KeySym  key;
  747.     char    buf[2];
  748.     short   c, flag, cflag;
  749.  
  750.     flag  = 0;
  751.     cflag = 0;
  752.     for(;;) {
  753.     XNextEvent(d, &ev);
  754.     switch( ev.type ) {
  755.         case Expose:
  756.                 XCopyArea(d, p, w, gc, 0, 0,
  757.                   WindowWidth, WindowHeight, 0, 0);
  758.             break;
  759.         case ButtonPress:
  760.             return( mouse2key() );
  761.         case KeyPress:
  762.             XLookupString(&ev.xkey, buf, 2, &key, NULL);
  763.             flag = 1;
  764.             switch( key ) {
  765.             case XK_Control_L:
  766.             case XK_Control_R: cflag = 1;
  767.             case XK_Shift_R  :
  768.             case XK_Shift_L  : flag = 0 ; break;
  769.             case XK_Left     : c = LEFT ; break;
  770.             case XK_Right    : c = RIGHT; break;
  771.             case XK_Up       : c = UP   ; break;
  772.             case XK_Down     : c = DOWN ; break;
  773.             default:
  774.               if(IsFunctionKey(key)) c = key - XK_F1 + F1;
  775.               else { c = buf[0]; if(c==cr && cflag) c = CtlM; }
  776.             }
  777.             if( flag )  return( c );
  778.     }
  779.     }
  780. }
  781.  
  782. void beep() { XBell(d, 0); }
  783.  
  784. XColor RGB(r, g, b)
  785. unsigned short  r, g, b;
  786. {
  787.     XColor  c;
  788.     c.red   = r * 255;
  789.     c.green = g * 255;
  790.     c.blue  = b * 255;
  791.     return( c );
  792. }
  793.  
  794. unsigned long color2RGB( color )
  795. int  color;
  796. {
  797.     Colormap cmap;
  798.     XColor   c, c0;
  799.     Status   rc;
  800.  
  801.     cmap = DefaultColormap(d, 0);
  802.     switch( color ) {
  803.     case  8: c = RGB(Color8 ,Color8 ,Color8 ); break;
  804.     case  9: c = RGB(Color9 ,Color9 ,Color9 ); break;
  805.     case 10: c = RGB(Color10,Color10,Color10); break;
  806.     case 11: c = RGB(     0 ,     0 ,Color8 ); break;
  807.     default: c = RGB((color&4)/4*255, (color&2)/2*255, (color&1)*255);
  808.          break;
  809.     }
  810.     rc = XAllocColor(d, cmap, &c);
  811.     if(rc == 0) {
  812.     switch( color ) {
  813.         case 11:
  814.         case  1: rc = XAllocNamedColor(d, cmap, "blue"   , &c, &c0); break;
  815.         case  2: rc = XAllocNamedColor(d, cmap, "green"  , &c, &c0); break;
  816.         case  3: rc = XAllocNamedColor(d, cmap, "cyan"   , &c, &c0); break;
  817.         case  4: rc = XAllocNamedColor(d, cmap, "red"    , &c, &c0); break;
  818.         case  5: rc = XAllocNamedColor(d, cmap, "magenta", &c, &c0); break;
  819.         case  6: rc = XAllocNamedColor(d, cmap, "yellow" , &c, &c0); break;
  820.         case  7: rc = XAllocNamedColor(d, cmap, "white"  , &c, &c0); break;
  821.         case  8:
  822.         case  9:
  823.         case 10: rc = XAllocNamedColor(d, cmap, "gray"   , &c, &c0); break;
  824.         }
  825.     }
  826.     return( c.pixel );
  827. }
  828.  
  829. MyLineAttributes()
  830. {
  831.     XGCValues gv;
  832.  
  833.     gv.foreground = mycolor;
  834.     gv.background = bkcolor;
  835.     gv.line_width = mywidth;
  836.     gv.line_style = mystyle;
  837.     gv.cap_style  = CapProjecting;
  838.     gv.arc_mode = ArcChord;
  839.     XChangeGC(d, gc, GCBackground |GCForeground |
  840.           GCLineWidth | GCLineStyle | GCCapStyle | GCArcMode, &gv);
  841. }
  842.  
  843. void gcursor(kx0, ky0, kx1, ky1, xo, yo, flg)
  844. int  kx0, ky0, kx1, ky1, *xo, *yo, flg;
  845. {
  846.     int  x, y, crx, cry;
  847.  
  848.     cs = XCreateFontCursor(d, XC_tcross);
  849.     XDefineCursor(d, w, cs);
  850.     XWarpPointer(d, None, w, 0, 0, 0, 0, xx(*xo), yy(*yo));
  851.     crx = 5;  cry = 5;
  852.  
  853.     for(;;) {
  854.     XNextEvent(d, &ev);
  855.     if(ev.type == Expose) XCopyArea(d, p, w, gc, 0, 0,
  856.                     WindowWidth, WindowHeight, 0, 0);
  857.     if(ev.type == ButtonPress) {
  858.         x = ev.xbutton.x - xoff - XOffset;
  859.         y = ev.xbutton.y - yoff - YOffset - HeaderHeight;
  860.         if(x<kx0 || x>kx1 || y<ky0 || y>ky1) beep();
  861.         else {
  862.         *xo = x;  *yo = y;  break;
  863.         }
  864.     }
  865.     }
  866.  
  867.     if( flg ) {
  868.     _setcolor( 2 );
  869.     _moveto(*xo, *yo-cry);  _lineto(*xo, *yo+cry);
  870.     _moveto(*xo-crx, *yo);  _lineto(*xo+crx, *yo);
  871.     }
  872.     cs = XCreateFontCursor(d, XC_arrow);
  873.     XDefineCursor(d, w, cs);
  874. }
  875.  
  876. #endif
  877.  
  878. /****************** common routines **********************/
  879. void psviewport(), psmoveto(), pslineto(), psbox(), pscircle(),
  880.      pstext(), psnormal_font(), pssmall_font();
  881.  
  882. short xx( x ) short x;
  883. { return( x + xoff + XOffset ); }
  884.  
  885. short yy( y ) short y;
  886. { return( y + yoff + YOffset + HeaderHeight ); }
  887.  
  888. void _moveto(x, y) short x, y; { pmoveto(xx(x), yy(y)); }
  889. void _lineto(x, y) short x, y; { plineto(xx(x), yy(y)); }
  890.  
  891. int _getcolor() { return( forecolor ); }
  892.  
  893. void _outgtext( s )
  894. char *s;
  895. { pouttext(xo, yo, s); }
  896.  
  897. void _rectangle(flag, x1, y1, x2, y2)
  898. short flag, x1, y1, x2, y2;
  899. { prectangle(flag, xx(x1), yy(y1), xx(x2), yy(y2)); }
  900.  
  901. int  widespace = 0;
  902. void _wide_spacing() { widespace = 1; }
  903. void _normal_spacing() {widespace = 0; }
  904.  
  905. void xouttext(row, col, s)
  906. short  row, col;
  907. char   *s;
  908. {
  909.     int    yw, xw;
  910.  
  911.     if( widespace )  yw = yy(row * LineHeight);
  912.     else  yw = yy(row * FontHeight);
  913.     xw = xx(col *  FontWidth);
  914.     pouttext(xw, yw, s);
  915. }
  916.  
  917. void physical_clear( clr )
  918. int  clr;
  919. {
  920.     _setcolor( clr );
  921.     prectangle(1, 0, yy(0), WindowWidth, WindowHeight);
  922. }
  923.  
  924. void gviewport(x1, y1, x2, y2)
  925. short  x1, y1, x2, y2;
  926. {
  927.     if( psflag )  psviewport(x1, y1, x2, y2);
  928.     else  _setviewport(x1, y1, x2, y2);
  929. }
  930.  
  931. void gmoveto(x, y) { if(psflag) psmoveto(x, y);  else _moveto(x, y); }
  932. void glineto(x, y) { if(psflag) pslineto(x, y);  else _lineto(x, y); }
  933.  
  934. void gbox(flag, x1, y1, x2, y2)
  935. short flag, x1, y1, x2, y2;
  936. {
  937.     if( psflag )  psbox(flag, x1, y1, x2, y2);
  938.     else {
  939.     if( flag ) _rectangle(1, x1, y1, x2, y2);
  940.     else       _rectangle(0, x1, y1, x2, y2);
  941.     }
  942. }
  943.  
  944. void gcircle(flag, x, y, r)
  945. short  flag, x, y, r;
  946. {
  947.     if( psflag )  pscircle(x, y, r);
  948.     else  _circle(flag, x, y, r);
  949. }
  950.  
  951. void gfillpolygon(p, q, n)
  952. int  p[], q[], n;
  953. {
  954.     struct  xycoord  pq[10]; /* # of points should be less than 11.*/
  955.     short   i;
  956.  
  957.     for(i=0; i<n; i++) {
  958.     pq[i].xcoord = p[i];  pq[i].ycoord = q[i];
  959.     }
  960.     _fillpolygon(pq, n);
  961. }
  962.  
  963. void gsymbol(x, y, r, style)
  964. short  x, y, r, style;
  965. {
  966.     int  a;
  967.     /* Symbols correspond to colors. */
  968.     switch( style ) {
  969.     case  4: gcircle(0, x, y, r);  break;
  970.     case  5: a = (int)(0.9*r+0.5);
  971.              gbox(0, x-a, y-a, x+a, y+a); break;
  972.     case  6: a = (int)(1.13*r+0.5); gmoveto(x-a,y); glineto(x,y-a);
  973.              glineto(x+a,y); glineto(x,y+a); glineto(x-a,y); break;
  974.     case  2: a = r; gmoveto(x-a,y+a);
  975.              glineto(x+a,y+a); glineto(x,y-a); glineto(x-a,y+a); break;
  976.     case  3: a = r; gmoveto(x-a,y-a);
  977.              glineto(x+a,y-a); glineto(x,y+a); glineto(x-a,y-a); break;
  978.     case  1: a = (int)(0.85*r+0.5); gmoveto(x-a,y+a); glineto(x+a,y-a-1);
  979.              gmoveto(x-a,y-a); glineto(x+a,y+a+1); break;
  980.     case  7: a = (int)(1.1*r+0.5); gmoveto(x-a+1,y); glineto(x+a,y);
  981.              gmoveto(x,y-a); glineto(x,y+a); break;
  982.     default: gcircle(0, x, y, r);  break;
  983.     }
  984. }
  985.  
  986. void gfprint(x, y, str, clr)
  987. int   x, y, clr;
  988. char *str;
  989. {
  990.     gmoveto(x, y);
  991.     if( psflag )  pstext(x, y, str);
  992.     else {
  993.     _setcolor( clr );  _outgtext( str );
  994.     }
  995. }
  996.  
  997. void gnormal_font()
  998. {
  999.     if( psflag )  psnormal_font();
  1000.     else  _normal_font();
  1001. }
  1002.  
  1003. void gprint(x, y, str, clr)
  1004. int   x, y, clr;
  1005. char *str;
  1006. { gfprint((x-1)*8, (y-1)*RowPixels, str, clr); }
  1007.  
  1008. void gsmall_font()
  1009. {
  1010.     if( psflag )  pssmall_font();
  1011.     else  _small_font();
  1012. }
  1013.  
  1014. int fgkey(key, flg)
  1015. int   key, flg;
  1016. {
  1017.     int   i;
  1018.     char  s[61];
  1019.  
  1020.     if( psflag ) { pshcopy( psflag );  psflag = 0; }
  1021.  
  1022.     strncpy(s, fk+key*49, 49);
  1023.     strncpy(s, "hcpyL ", 6); strncpy(s+6, "hcpyS ", 6);
  1024.     strcpy(s+48, " help "); strcat(s, "Enter ");
  1025.     windows_toolbar( s );
  1026.     _normal_font();
  1027.     _setcolor( 7 );
  1028.  
  1029.     for(;;) {
  1030.     i = getcchr();
  1031.     switch( i ) {
  1032.         case cr: if(flg) return(F6); else return(i);
  1033.         case CtlE: check_exit(); break;
  1034.         case F1:
  1035.         case F2:
  1036.             blueF1_2( i-F1+1 );
  1037.             if(lpinit()) { psflag = i-F1+1; psinit(); return(F1); }
  1038.             else  return( 0 );
  1039.         case F3:
  1040.         case F6:  return(i);
  1041.         case F8:  if(key == 1)  return(i);  else beep(); break;
  1042.         default:  beep();
  1043.     }
  1044.     }
  1045. }
  1046.  
  1047. void inputarea(col, row, len)
  1048. int  col, row, len;
  1049. {
  1050.     int    yw, xw;
  1051.  
  1052.     yw = yy(row * LineHeight) - 2;
  1053.     xw = xx(col * FontWidth ) - 1;
  1054.     _setcolor( 7 );
  1055.     prectangle(1, xw, yw+1, xw+len*FontWidth+1, yw+FontHeight+1);
  1056.     _setcolor( 10 );
  1057.     prectangle(0, xw, yw+1, xw+len*FontWidth+1, yw+FontHeight+1);
  1058.     _setcolor( 0 );
  1059.     pmoveto(xw, yw+FontHeight);
  1060.     plineto(xw, yw+1);
  1061.     plineto(xw+len*FontWidth, yw+1);
  1062. }
  1063.  
  1064. void check_exit()
  1065. { windows_menu( EXIT );  finish(); }
  1066.  
  1067. void menu_init()
  1068. {
  1069.     int  i, x, dx;
  1070.  
  1071.     _menu_font();
  1072.     x = 10;
  1073.     for(i=0; i<10; i++) {
  1074.         dx = _gettextextent( menuitem[i] );
  1075.     menux1[i] = x - 1;
  1076.     menux2[i] = x + dx + 1;
  1077.     x = x + dx + 16;
  1078.     }
  1079. }
  1080.  
  1081. void windows_menu( func )
  1082. int  func;
  1083. {
  1084.     int  i;
  1085.  
  1086.     _setcolor( 9 );
  1087.     prectangle(1, 0, menuy1-1, WindowWidth, menuy2+4);
  1088.     _menu_font();
  1089.     for(i=SELECT; i<=EXIT; i++) {
  1090.     if(i == func) {
  1091.         _setcolor( 11 );
  1092.         prectangle(1, (menux1[i]-8<4)?4:menux1[i]-8, menuy1-1,
  1093.                    menux2[i]+8, menuy2+1);
  1094.         _setcolor( 7 );
  1095.         _setbkcolor( 11 );
  1096.     }
  1097.     else {
  1098.         _setcolor( 0 );
  1099.         _setbkcolor( 9 );
  1100.     }
  1101.     if(func>=SELECT && i!=func && i<EXIT) {
  1102.         _settextmode( 0 );
  1103.         _setcolor( 7 );
  1104.         pouttext(menux1[i]+2, menuy1+1, menuitem[i]);
  1105.         _setcolor( 8 );
  1106.         pouttext(menux1[i]+1, menuy1, menuitem[i]);
  1107.         _settextmode( 1 );
  1108.     }
  1109.     else pouttext(menux1[i]+1, menuy1, menuitem[i]);
  1110.     }
  1111.  
  1112.     _setcolor( 8 );
  1113.     pmoveto(XOffset, menuy2+2);
  1114.     plineto(FontWidth*80, menuy2+2);
  1115.     _setcolor( 7 );
  1116.     pmoveto(XOffset, menuy2+3);
  1117.     plineto(FontWidth*80, menuy2+3);
  1118.     if(func != EXIT)  oldfunc = func;
  1119. }
  1120.  
  1121. void windows_toolbar( s )
  1122. char *s;
  1123. {
  1124.     int      i, x, dx;
  1125.     unsigned j;
  1126.     char     baritem[11];
  1127.  
  1128.     _setcolor( 9 );
  1129.     prectangle(1, 0, bary1-1, WindowWidth, bary2+7);
  1130.  
  1131.     if(*s != 0) {
  1132.     _menu_font();
  1133.     x = 10;
  1134.     for(i=0; i<10; i++) {
  1135.         strncpy(baritem, s+i*6, 6);  baritem[6] = 0;
  1136.         if(strcmp(baritem,"      ")!=0 && i<9) {
  1137.         for(j=strlen(baritem); j>0; j--) {
  1138.             if(baritem[j-1] == ' ') baritem[j-1] = 0;
  1139.             else  break;
  1140.         }
  1141.         for(j=0; j<strlen(baritem); j++) {
  1142.             if(baritem[j] == ' ') strcpy(baritem, baritem+j+1);
  1143.             else  break;
  1144.         }
  1145.         *baritem = *baritem - ('a'-'A');
  1146.         sprintf(baritem+strlen(baritem), ":F%1d", i+1);
  1147.         }
  1148.         else  strcat(baritem, "   ");
  1149.  
  1150.         dx = _gettextextent( baritem );
  1151.         barx1[i] = x - 4;
  1152.         barx2[i] = x + dx + 2;
  1153.         x = x + dx + 14;
  1154.         if(i == 8)  x += 15;
  1155.  
  1156.         standend();
  1157.         if( fontmode )  pouttext(barx1[i]+4, bary1+3, baritem);
  1158.         else  pouttext(barx1[i]+4, bary1+1, baritem);
  1159.         _setcolor( 8 );
  1160.         prectangle(0, barx1[i], bary1+1, barx2[i]+1, bary2);
  1161.         if(strcmp(baritem,"         ") != 0) {
  1162.         _setcolor(0);
  1163.         prectangle(0, barx1[i]-1, bary1, barx2[i]+2, bary2+1);
  1164.         _setcolor(7);
  1165.         pmoveto(barx1[i]-1, bary2-1);
  1166.         plineto(barx1[i]-1, bary1);
  1167.         plineto(barx2[i]+1, bary1);
  1168.         _setcolor(10);
  1169.         pmoveto(barx1[i], bary2-2);
  1170.         plineto(barx1[i], bary1+1);
  1171.         plineto(barx2[i], bary1+1);
  1172.         }
  1173.     }
  1174.     }
  1175.  
  1176.     _setcolor( 8 );
  1177.     pmoveto(XOffset, bary2+2);
  1178.     plineto(FontWidth*80, bary2+2);
  1179.     _setcolor( 7 );
  1180.     pmoveto(XOffset, bary2+3);
  1181.     plineto(FontWidth*80, bary2+3);
  1182. }
  1183.  
  1184. mouse2key()
  1185. {
  1186.     int  i;
  1187.  
  1188.     for(i=0; i<10; i++) {
  1189.     if(MouseX>=menux1[i] && MouseX<=menux2[i] &&
  1190.        MouseY>=menuy1    && MouseY<=menuy2) {
  1191.         switch( i ) {
  1192.         case 0: return( CtlS );
  1193.         case 1: return( CtlB );
  1194.         case 2: return( CtlP );
  1195.         case 3: return( CtlV );
  1196.         case 4: return( CtlR );
  1197.         case 5: return( CtlM );
  1198.         case 6: return( CtlT );
  1199.         case 7: return( CtlG );
  1200.         case 8: return( CtlO );
  1201.         case 9: return( CtlE );
  1202.         }
  1203.     }
  1204.     }
  1205.  
  1206.     for(i=0; i<10; i++) {
  1207.     if(MouseX>=barx1[i] && MouseX<=barx2[i] &&
  1208.        MouseY>=bary1    && MouseY<=bary2) {
  1209.         if(i == 9)  return( cr );
  1210.         else  return(F1 + i);
  1211.     }
  1212.     }
  1213.  
  1214.     if(MouseX>=XOffset && MouseX<=WindowWidth &&
  1215.        MouseY>=YOffset+HeaderHeight && MouseY<=WindowHeight)
  1216.         return( 0x200 + (MouseX-XOffset)/FontWidth
  1217.               + (MouseY-YOffset-HeaderHeight)/LineHeight*80 );
  1218.     return( -1 );
  1219. }
  1220.  
  1221. void restore_box(oldx, oldy)
  1222. int  oldx, oldy;
  1223. {
  1224.     if(_iswritable(oldy,oldx)) {
  1225.     if(_iswritable(oldy,oldx-1))_setcolor(7); else _setcolor(0);
  1226.         pmoveto(xx(oldx*FontWidth)-1, yy(oldy*LineHeight)+ 2);
  1227.     plineto(xx(oldx*FontWidth)-1, yy(oldy*LineHeight)+14);
  1228.     }
  1229.     if(oldx>0 && _iswritable(oldy,oldx-1) && !_iswritable(oldy,oldx)) {
  1230.     _setcolor( 10 );
  1231.         pmoveto(xx(oldx*FontWidth)-1, yy(oldy*LineHeight)+1);
  1232.     plineto(xx(oldx*FontWidth)-1, yy(oldy*LineHeight)+FontHeight+1);
  1233.     }
  1234. }
  1235.  
  1236. void blueF1_2( key )
  1237. int  key;
  1238. {
  1239.     char  s[10];  int bx;
  1240.  
  1241.     _menu_font();
  1242.     _setcolor( 7 );
  1243.     _setbkcolor( 11 );
  1244.     switch( key ) {
  1245.     case 0: bx = barx1[0]; strcpy(s, "Hcopy:F1" ); break;
  1246.     case 1: bx = barx1[0]; strcpy(s, "HcopyL:F1"); break;
  1247.     case 2: bx = barx1[1]; strcpy(s, "HcopyS:F2"); break;
  1248.     }
  1249.     if( fontmode )  pouttext(bx, bary1+3, s);
  1250.     else  pouttext(bx, bary1+1, s);
  1251.     xflush();
  1252. }
  1253.