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.02a / graph.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  30KB  |  1,255 lines

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