home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xaw / AsciiText.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-12  |  8.3 KB  |  273 lines

  1. /* $XConsortium: AsciiText.c,v 1.44 91/07/12 11:27:23 converse Exp $ */
  2.  
  3. /*
  4. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  5. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  6.  
  7.                         All Rights Reserved
  8.  
  9. Permission to use, copy, modify, and distribute this software and its 
  10. documentation for any purpose and without fee is hereby granted, 
  11. provided that the above copyright notice appear in all copies and that
  12. both that copyright notice and this permission notice appear in 
  13. supporting documentation, and that the names of Digital or MIT not be
  14. used in advertising or publicity pertaining to distribution of the
  15. software without specific, written prior permission.  
  16.  
  17. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  19. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24.  
  25. */
  26.  
  27. /***********************************************************************
  28.  *
  29.  * AsciiText Widget
  30.  *
  31.  ***********************************************************************/
  32.  
  33. /*
  34.  * AsciiText.c - Source code for AsciiText Widget.
  35.  *
  36.  * This Widget is intended to be used as a simple front end to the 
  37.  * text widget with an ascii source and ascii sink attached to it.
  38.  *
  39.  * Date:    June 29, 1989
  40.  *
  41.  * By:      Chris D. Peterson
  42.  *          MIT X Consortium 
  43.  *          kit@expo.lcs.mit.edu
  44.  */
  45.  
  46. #include <stdio.h>
  47. #include <X11/IntrinsicP.h>
  48. #include <X11/StringDefs.h>
  49.  
  50. #include <X11/Xaw/XawInit.h>
  51. #include <X11/Xaw/Cardinals.h>
  52. #include <X11/Xaw/AsciiTextP.h>
  53. #include <X11/Xaw/AsciiSrc.h>
  54. #include <X11/Xaw/AsciiSink.h>
  55.  
  56. #define TAB_COUNT 32
  57.  
  58. static void Initialize(), Destroy();
  59.  
  60. AsciiTextClassRec asciiTextClassRec = {
  61.   { /* core fields */
  62.     /* superclass       */      (WidgetClass) &textClassRec,
  63.     /* class_name       */      "Text",
  64.     /* widget_size      */      sizeof(AsciiRec),
  65.     /* class_initialize */      XawInitializeWidgetSet,
  66.     /* class_part_init  */    NULL,
  67.     /* class_inited     */      FALSE,
  68.     /* initialize       */      Initialize,
  69.     /* initialize_hook  */    NULL,
  70.     /* realize          */      XtInheritRealize,
  71.     /* actions          */      NULL,
  72.     /* num_actions      */      0,
  73.     /* resources        */      NULL,
  74.     /* num_resource     */      0,
  75.     /* xrm_class        */      NULLQUARK,
  76.     /* compress_motion  */      TRUE,
  77.     /* compress_exposure*/      XtExposeGraphicsExpose | XtExposeNoExpose,
  78.     /* compress_enterleave*/    TRUE,
  79.     /* visible_interest */      FALSE,
  80.     /* destroy          */      Destroy,
  81.     /* resize           */      XtInheritResize,
  82.     /* expose           */      XtInheritExpose,
  83.     /* set_values       */      NULL,
  84.     /* set_values_hook  */    NULL,
  85.     /* set_values_almost*/    XtInheritSetValuesAlmost,
  86.     /* get_values_hook  */    NULL,
  87.     /* accept_focus     */      XtInheritAcceptFocus,
  88.     /* version          */    XtVersion,
  89.     /* callback_private */      NULL,
  90.     /* tm_table         */      XtInheritTranslations,
  91.     /* query_geometry    */    XtInheritQueryGeometry
  92.   },
  93.   { /* Simple fields */
  94.     /* change_sensitive    */    XtInheritChangeSensitive
  95.   },
  96.   { /* text fields */
  97.     /* empty            */      0
  98.   },
  99.   { /* ascii fields */
  100.     /* empty            */      0
  101.   }
  102. };
  103.  
  104. WidgetClass asciiTextWidgetClass = (WidgetClass)&asciiTextClassRec;
  105.  
  106.  
  107. static void
  108. Initialize(request, new, args, num_args)
  109. Widget request, new;
  110. ArgList args;
  111. Cardinal *num_args;
  112. {
  113.   AsciiWidget w = (AsciiWidget) new;
  114.   int i;
  115.   int tabs[TAB_COUNT], tab;
  116.  
  117.   /* superclass Initialize can't set the following,
  118.    * as it didn't know the source or sink when it was called */
  119.   if (request->core.height == DEFAULT_TEXT_HEIGHT)
  120.     new->core.height = DEFAULT_TEXT_HEIGHT;
  121.  
  122.   w->text.source = XtCreateWidget( "textSource", asciiSrcObjectClass,
  123.                   new, args, *num_args );
  124.   w->text.sink = XtCreateWidget( "textSink", asciiSinkObjectClass,
  125.                 new, args, *num_args );
  126.  
  127.   if (w->core.height == DEFAULT_TEXT_HEIGHT)
  128.     w->core.height = VMargins(w) + XawTextSinkMaxHeight(w->text.sink, 1);
  129.  
  130.   for (i=0, tab=0 ; i < TAB_COUNT ; i++) 
  131.     tabs[i] = (tab += 8);
  132.   
  133.   XawTextSinkSetTabs(w->text.sink, TAB_COUNT, tabs);
  134.  
  135.   XawTextDisableRedisplay(new);
  136.   XawTextEnableRedisplay(new);
  137. }
  138.  
  139. static void 
  140. Destroy(w)
  141. Widget w;
  142. {
  143.     if (w == XtParent(((AsciiWidget)w)->text.source))
  144.     XtDestroyWidget( ((AsciiWidget)w)->text.source );
  145.  
  146.     if (w == XtParent(((AsciiWidget)w)->text.sink))
  147.     XtDestroyWidget( ((AsciiWidget)w)->text.sink );
  148. }
  149.  
  150. #ifdef ASCII_STRING
  151.  
  152. /************************************************************
  153.  *
  154.  * Ascii String Compatibility Code.
  155.  *
  156.  ************************************************************/
  157.  
  158. AsciiStringClassRec asciiStringClassRec = {
  159.   { /* core fields */
  160.     /* superclass       */      (WidgetClass) &asciiTextClassRec,
  161.     /* class_name       */      "Text",
  162.     /* widget_size      */      sizeof(AsciiStringRec),
  163.     /* class_initialize */      NULL,
  164.     /* class_part_init  */    NULL,
  165.     /* class_inited     */      FALSE,
  166.     /* initialize       */      NULL,
  167.     /* initialize_hook  */    NULL,
  168.     /* realize          */      XtInheritRealize,
  169.     /* actions          */      NULL,
  170.     /* num_actions      */      0,
  171.     /* resources        */      NULL,
  172.     /* num_ resource    */      0,
  173.     /* xrm_class        */      NULLQUARK,
  174.     /* compress_motion  */      TRUE,
  175.     /* compress_exposure*/      XtExposeGraphicsExpose,
  176.     /* compress_enterleave*/    TRUE,
  177.     /* visible_interest */      FALSE,
  178.     /* destroy          */      NULL,
  179.     /* resize           */      XtInheritResize,
  180.     /* expose           */      XtInheritExpose,
  181.     /* set_values       */      NULL,
  182.     /* set_values_hook  */    NULL,
  183.     /* set_values_almost*/    XtInheritSetValuesAlmost,
  184.     /* get_values_hook  */    NULL,
  185.     /* accept_focus     */      XtInheritAcceptFocus,
  186.     /* version          */    XtVersion,
  187.     /* callback_private */      NULL,
  188.     /* tm_table         */      XtInheritTranslations,
  189.     /* query_geometry    */    XtInheritQueryGeometry
  190.   },
  191.   { /* Simple fields */
  192.     /* change_sensitive    */    XtInheritChangeSensitive
  193.   },
  194.   { /* text fields */
  195.     /* empty            */      0
  196.   },
  197.   { /* ascii fields */
  198.     /* empty            */      0
  199.   }
  200. };
  201.  
  202. WidgetClass asciiStringWidgetClass = (WidgetClass)&asciiStringClassRec;
  203.  
  204. #endif /* ASCII_STRING */
  205.  
  206. #ifdef ASCII_DISK
  207.  
  208. /************************************************************
  209.  *
  210.  * Ascii Disk Compatibility Code.
  211.  *
  212.  ************************************************************/
  213.  
  214. AsciiDiskClassRec asciiDiskClassRec = {
  215.   { /* core fields */
  216.     /* superclass       */      (WidgetClass) &asciiTextClassRec,
  217.     /* class_name       */      "Text",
  218.     /* widget_size      */      sizeof(AsciiDiskRec),
  219.     /* class_initialize */      NULL,
  220.     /* class_part_init  */    NULL,
  221.     /* class_inited     */      FALSE,
  222.     /* initialize       */      NULL,
  223.     /* initialize_hook  */    NULL,
  224.     /* realize          */      XtInheritRealize,
  225.     /* actions          */      NULL,
  226.     /* num_actions      */      0,
  227.     /* resources        */      NULL,
  228.     /* num_ resource    */      0,
  229.     /* xrm_class        */      NULLQUARK,
  230.     /* compress_motion  */      TRUE,
  231.     /* compress_exposure*/      XtExposeGraphicsExpose,
  232.     /* compress_enterleave*/    TRUE,
  233.     /* visible_interest */      FALSE,
  234.     /* destroy          */      NULL,
  235.     /* resize           */      XtInheritResize,
  236.     /* expose           */      XtInheritExpose,
  237.     /* set_values       */      NULL,
  238.     /* set_values_hook  */    NULL,
  239.     /* set_values_almost*/    XtInheritSetValuesAlmost,
  240.     /* get_values_hook  */    NULL,
  241.     /* accept_focus     */      XtInheritAcceptFocus,
  242.     /* version          */    XtVersion,
  243.     /* callback_private */      NULL,
  244.     /* tm_table         */      XtInheritTranslations,
  245.     /* query_geometry    */    XtInheritQueryGeometry
  246.   },
  247.   { /* Simple fields */
  248.     /* change_sensitive    */    XtInheritChangeSensitive
  249.   },
  250.   { /* text fields */
  251.     /* empty            */      0
  252.   },
  253.   { /* ascii fields */
  254.     /* empty            */      0
  255.   }
  256. };
  257.  
  258. WidgetClass asciiDiskWidgetClass = (WidgetClass)&asciiDiskClassRec;
  259.  
  260. #endif /* ASCII_DISK */
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.