home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / apa16 / apa16IO.c < prev    next >
C/C++ Source or Header  |  1991-12-30  |  7KB  |  223 lines

  1. /***********************************************************
  2.         Copyright IBM Corporation 1987,1988
  3.  
  4.                       All Rights Reserved
  5.  
  6. Permission to use, copy, modify, and distribute this software and its 
  7. documentation for any purpose and without fee is hereby granted, 
  8. provided that the above copyright notice appear in all copies and that
  9. both that copyright notice and this permission notice appear in 
  10. supporting documentation, and that the name of IBM not be
  11. used in advertising or publicity pertaining to distribution of the
  12. software without specific, written prior permission.  
  13.  
  14. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  15. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  16. IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  17. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  18. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  19. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  20. SOFTWARE.
  21.  
  22. ******************************************************************/
  23. /***********************************************************
  24. Copyright 1989,1991 by the Massachusetts Institute of Technology
  25.  
  26.                      All rights reserved.
  27.  
  28. Permission to use, copy, modify, and distribute this software and its
  29. documentation for any purpose and without fee is hereby granted,
  30. provided that the above copyright notice appear in all copies and that
  31. both that copyright notice and this permission notice appear in
  32. supporting documentation, and that the name of the Massachusetts
  33. Institute of Technology (M.I.T.) not be used in advertising or publicity
  34. pertaining to distribution of the software without specific, written
  35. prior permission.
  36.  
  37. M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  38. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  39. M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  40. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  41. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  42. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  43. SOFTWARE.
  44.  
  45. ******************************************************************/
  46.  
  47. /* $Source: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/apa16/RCS/apa16IO.c,v $ */
  48.  
  49. #ifndef lint
  50. static char *rcsid = "$Id: apa16IO.c,v 5.0 1991/12/30 19:22:51 jfc Exp $";
  51. #endif
  52.  
  53. #include "X.h"
  54. #include "screenint.h"
  55. #include "scrnintstr.h"
  56. #include "cursorstr.h"
  57. #include "pixmapstr.h"
  58. #include "miscstruct.h"
  59. #include "input.h"
  60. #include "colormapst.h"
  61. #include "resource.h"
  62. #include "mibstore.h"
  63.  
  64. #include "mfb.h"
  65.  
  66. #include "OScompiler.h"
  67.  
  68. #include "ibmColor.h"
  69. #include "ibmScreen.h"
  70. #include "ibmTrace.h"
  71. #include "ibmIO.h"
  72.  
  73. #include "apa16Hdwr.h"
  74. #include "apa16Decls.h"
  75.  
  76. #include "OSio.h"
  77. #include "OScursor.h"
  78.  
  79.  
  80. extern    void    miRecolorCursor();
  81. extern    void    ibmQueryBestSize();
  82.  
  83. extern    void    apa16SaveAreas();
  84. extern    void    apa16RestoreAreas();
  85.  
  86. miBSFuncRec apa16BSFuncRec = {
  87.     mfbSaveAreas,
  88.     mfbRestoreAreas,
  89.     (void (*)()) 0,
  90.     (PixmapPtr (*)()) 0,
  91.     (PixmapPtr (*)()) 0,
  92. };
  93.  
  94. int apa16FontPrivateIndex;
  95.  
  96. static Bool
  97. apa16SaveScreen (pScreen, on)
  98.     ScreenPtr pScreen;
  99.     int on;
  100. {
  101.     if (on != SCREEN_SAVER_ON)
  102.     {VIDEO_ON();}
  103.     else
  104.     {VIDEO_OFF();}
  105.     return TRUE;
  106. }
  107.  
  108.  
  109. /***==================================================================***/
  110.  
  111. Bool
  112. apa16ScreenInit(index, pScreen, argc, argv)
  113.     int index;
  114.     ScreenPtr pScreen;
  115.     int argc;        /* these two may NOT be changed */
  116.     char **argv;
  117. {
  118.     Bool retval;
  119.     static int been_here;
  120.  
  121.     extern apa16ScreenClose() ;
  122.     extern mfbRealizeCursor() ;
  123.     extern mfbUnrealizeCursor() ;
  124.     extern mfbDisplayCursor() ;
  125.     extern mfbResolveColorMono() ;
  126.     extern mfbCreateDefColormap() ;
  127.     extern mfbCreateStaticGrayColormap();
  128.  
  129.  
  130.     TRACE(("apa16ScreenInit( index= %d, pScreen= 0x%x, argc= %d, argv= 0x%x )\n",index,pScreen,argc,argv));
  131.  
  132.     if (!been_here) {
  133.     if ( ibmScreenFD(index) < 0)
  134.     {
  135.             ErrorF(  "apa16 file descriptor is invalid\n");
  136.             return FALSE; 
  137.     } 
  138.     been_here= TRUE;
  139.     }
  140.  
  141.     if (ibmScreenState(index)!=SCREEN_INACTIVE) {
  142.     QUEUE_INIT();
  143.     WHITE_ON_BLACK();
  144.     SET_MERGE_MODE(MERGE_COPY);
  145.     }
  146.  
  147.     retval = mfbScreenInit(pScreen, APA16_BASE, 
  148.                APA16_WIDTH, APA16_HEIGHT, 80,80, APA16_WIDTH);
  149.     apa16CursorInit(index);
  150.  
  151.     /*
  152.      * Re-initialze those items that mfbScreenInit() initializes and
  153.      * have been re-located by miInitializeBackingStore() (which was
  154.      * called from mfbScreenInit.)
  155.      */
  156.     pScreen->CloseScreen=        apa16ScreenClose ;
  157.     pScreen->GetImage=            mfbGetImage;
  158.     pScreen->GetSpans=            mfbGetSpans;
  159.     pScreen->ChangeWindowAttributes=    mfbChangeWindowAttributes;
  160.     pScreen->CreateGC=            mfbCreateGC;
  161.     pScreen->DestroyWindow=        mfbDestroyWindow;
  162.  
  163.     /*
  164.      * Re-initialize other routines to use IBM routines instead of the
  165.      * mfb routines.
  166.      */
  167.     pScreen->SaveScreen=        apa16SaveScreen;
  168.     pScreen->RealizeCursor=        apa16RealizeCursor;
  169.     pScreen->UnrealizeCursor=        apa16UnrealizeCursor;
  170.     pScreen->DisplayCursor=        apa16DisplayCursor;
  171.  
  172.     pScreen->SetCursorPosition=        OS_SetCursorPosition;
  173.     pScreen->CursorLimits=        OS_CursorLimits;
  174.     pScreen->PointerNonInterestBox=    OS_PointerNonInterestBox;
  175.     pScreen->ConstrainCursor=        OS_ConstrainCursor;
  176.     pScreen->RecolorCursor=        miRecolorCursor;
  177.  
  178.     pScreen->RealizeFont=        apa16RealizeFont;
  179.     pScreen->UnrealizeFont=        apa16UnrealizeFont;
  180.  
  181.     pScreen->BlockHandler=        OS_BlockHandler;
  182.     pScreen->WakeupHandler=        OS_WakeupHandler;
  183.  
  184.     if (ibmUseHardware) {
  185.     pScreen->CreateGC=            apa16CreateGC;
  186.         pScreen->ChangeWindowAttributes=    apa16ChangeWindowAttributes;
  187.     pScreen->PaintWindowBackground =     apa16PaintWindow;
  188.     pScreen->PaintWindowBorder=        apa16PaintWindow;
  189.     pScreen->CopyWindow=             apa16CopyWindow;
  190.     pScreen->GetImage=            apa16GetImage;
  191.     pScreen->GetSpans=            apa16GetSpans;
  192.  
  193.     apa16BSFuncRec.SaveAreas=        apa16SaveAreas;
  194.     apa16BSFuncRec.RestoreAreas=        apa16RestoreAreas;
  195.     }
  196.  
  197. /*** XXX ***/
  198.     /***
  199.      *** The following should be re-done properly with argument parsing.
  200.      ***/
  201.     pScreen->blackPixel = 0;
  202.     pScreen->whitePixel = 1;
  203. /*** XXX ***/
  204.  
  205.     miInitializeBackingStore(pScreen, &apa16BSFuncRec);
  206.  
  207.     mfbCreateDefColormap(pScreen);
  208.     ibmScreen(index)= pScreen;
  209.  
  210.     apa16FontPrivateIndex = AllocateFontPrivateIndex();
  211.     apa16InitFontCache();
  212.     return(retval);
  213. }
  214.  
  215. apa16ScreenClose( index, pScreen )
  216. int        index;
  217. ScreenPtr    pScreen;
  218. {
  219.     TRACE(("apa16ScreenClose( index= 0x%x, pScreen= 0x%x )\n",index,pScreen));
  220.     /* let mfb clean up anything it has to... */
  221.     return mfbCloseScreen(index, pScreen);
  222. }
  223.