749N/A/* $XConsortium: AsciiText.c,v 1.47 95/06/06 20:50:30 kaleb Exp $ */
749N/A
749N/A/*
749N/A
749N/ACopyright (c) 1987, 1988, 1994 X Consortium
749N/A
749N/APermission is hereby granted, free of charge, to any person obtaining a copy
749N/Aof this software and associated documentation files (the "Software"), to deal
749N/Ain the Software without restriction, including without limitation the rights
749N/Ato use, copy, modify, merge, publish, distribute, sublicense, and/or sell
749N/Acopies of the Software, and to permit persons to whom the Software is
749N/Afurnished to do so, subject to the following conditions:
749N/A
749N/AThe above copyright notice and this permission notice shall be included in
749N/Aall copies or substantial portions of the Software.
749N/A
749N/ATHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
749N/AIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
749N/AFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
749N/AX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
749N/AAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
749N/ACONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
749N/A
749N/AExcept as contained in this notice, the name of the X Consortium shall not be
749N/Aused in advertising or otherwise to promote the sale, use or other dealings
749N/Ain this Software without prior written authorization from the X Consortium.
749N/A
749N/A
749N/ACopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
749N/A
749N/A All Rights Reserved
749N/A
749N/APermission to use, copy, modify, and distribute this software and its
749N/Adocumentation for any purpose and without fee is hereby granted,
749N/Aprovided that the above copyright notice appear in all copies and that
749N/Aboth that copyright notice and this permission notice appear in
749N/Asupporting documentation, and that the name of Digital not be
749N/Aused in advertising or publicity pertaining to distribution of the
749N/Asoftware without specific, written prior permission.
749N/A
749N/ADIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
749N/AALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
749N/ADIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
749N/AANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
749N/AWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
749N/AARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
749N/ASOFTWARE.
749N/A
749N/A*/
749N/A
749N/A/***********************************************************************
749N/A *
749N/A * AsciiText Widget
749N/A *
749N/A ***********************************************************************/
749N/A
749N/A/*
749N/A * AsciiText.c - Source code for AsciiText Widget.
749N/A *
749N/A * This Widget is intended to be used as a simple front end to the
749N/A * text widget with an ascii source and ascii sink attached to it.
749N/A *
749N/A * Date: June 29, 1989
749N/A *
749N/A * By: Chris D. Peterson
749N/A * MIT X Consortium
749N/A * kit@expo.lcs.mit.edu
749N/A */
749N/A
749N/A#include <stdio.h>
749N/A#include <X11/IntrinsicP.h>
749N/A#include <X11/StringDefs.h>
749N/A
749N/A#include <X11/Xaw/XawInit.h>
749N/A#include <X11/Xaw/Cardinals.h>
749N/A#include <X11/Xaw/AsciiTextP.h>
749N/A#include <X11/Xaw/AsciiSrc.h>
749N/A#include <X11/Xaw/AsciiSink.h>
749N/A#include <X11/Xaw/MultiSrc.h>
749N/A#include <X11/Xaw/MultiSinkP.h>
749N/A#include <X11/Xaw/XawImP.h>
749N/A
749N/A#define TAB_COUNT 32
749N/A
749N/Astatic void Initialize(), Destroy();
749N/A
749N/AAsciiTextClassRec asciiTextClassRec = {
749N/A { /* core fields */
749N/A /* superclass */ (WidgetClass) &textClassRec,
749N/A /* class_name */ "Text",
749N/A /* widget_size */ sizeof(AsciiRec),
749N/A /* class_initialize */ XawInitializeWidgetSet,
749N/A /* class_part_init */ NULL,
749N/A /* class_inited */ FALSE,
749N/A /* initialize */ Initialize,
749N/A /* initialize_hook */ NULL,
749N/A /* realize */ XtInheritRealize,
749N/A /* actions */ NULL,
749N/A /* num_actions */ 0,
749N/A /* resources */ NULL,
749N/A /* num_resource */ 0,
749N/A /* xrm_class */ NULLQUARK,
749N/A /* compress_motion */ TRUE,
749N/A /* compress_exposure*/ XtExposeGraphicsExpose | XtExposeNoExpose,
749N/A /* compress_enterleave*/ TRUE,
749N/A /* visible_interest */ FALSE,
749N/A /* destroy */ Destroy,
749N/A /* resize */ XtInheritResize,
749N/A /* expose */ XtInheritExpose,
749N/A /* set_values */ NULL,
749N/A /* set_values_hook */ NULL,
749N/A /* set_values_almost*/ XtInheritSetValuesAlmost,
749N/A /* get_values_hook */ NULL,
749N/A /* accept_focus */ XtInheritAcceptFocus,
749N/A /* version */ XtVersion,
749N/A /* callback_private */ NULL,
749N/A /* tm_table */ XtInheritTranslations,
749N/A /* query_geometry */ XtInheritQueryGeometry
749N/A },
749N/A { /* Simple fields */
749N/A /* change_sensitive */ XtInheritChangeSensitive
749N/A },
749N/A { /* text fields */
749N/A /* empty */ 0
749N/A },
749N/A { /* ascii fields */
749N/A /* empty */ 0
749N/A }
749N/A};
749N/A
749N/AWidgetClass asciiTextWidgetClass = (WidgetClass)&asciiTextClassRec;
749N/A
749N/A
749N/Astatic void
749N/AInitialize(request, new, args, num_args)
749N/AWidget request, new;
749N/AArgList args;
749N/ACardinal *num_args;
749N/A{
749N/A AsciiWidget w = (AsciiWidget) new;
749N/A int i;
749N/A int tabs[TAB_COUNT], tab;
749N/A
749N/A MultiSinkObject sink;
749N/A
749N/A /* superclass Initialize can't set the following,
749N/A * as it didn't know the source or sink when it was called */
749N/A
749N/A if (request->core.height == DEFAULT_TEXT_HEIGHT)
749N/A new->core.height = DEFAULT_TEXT_HEIGHT;
749N/A
749N/A
749N/A /* This is the main change for internationalization. */
749N/A
749N/A if ( w->simple.international == True ) { /* The multi* are international. */
749N/A
749N/A w->text.source = XtCreateWidget( "textSource", multiSrcObjectClass,
749N/A new, args, *num_args );
749N/A w->text.sink = XtCreateWidget( "textSink", multiSinkObjectClass,
749N/A new, args, *num_args );
749N/A }
749N/A else {
749N/A
749N/A w->text.source = XtCreateWidget( "textSource", asciiSrcObjectClass,
749N/A new, args, *num_args );
749N/A w->text.sink = XtCreateWidget( "textSink", asciiSinkObjectClass,
749N/A new, args, *num_args );
749N/A }
749N/A
749N/A if (w->core.height == DEFAULT_TEXT_HEIGHT)
749N/A w->core.height = VMargins(w) + XawTextSinkMaxHeight(w->text.sink, 1);
749N/A
749N/A for (i=0, tab=0 ; i < TAB_COUNT ; i++)
749N/A tabs[i] = (tab += 8);
749N/A
749N/A XawTextSinkSetTabs(w->text.sink, TAB_COUNT, tabs);
749N/A
749N/A XawTextDisableRedisplay(new);
749N/A XawTextEnableRedisplay(new);
749N/A
749N/A
749N/A /* If we are using a MultiSink we need to tell the input method stuff. */
749N/A
749N/A if ( w->simple.international == True ) {
749N/A Arg list[4];
749N/A Cardinal ac = 0;
749N/A
749N/A sink = (MultiSinkObject)w->text.sink;
749N/A _XawImRegister( new );
749N/A XtSetArg (list[ac], XtNfontSet, sink->multi_sink.fontset); ac++;
749N/A XtSetArg (list[ac], XtNinsertPosition, w->text.insertPos); ac++;
749N/A XtSetArg (list[ac], XtNforeground, sink->text_sink.foreground); ac++;
749N/A XtSetArg (list[ac], XtNbackground, sink->text_sink.background); ac++;
749N/A _XawImSetValues(new, list, ac);
749N/A }
749N/A}
749N/A
749N/Astatic void
749N/ADestroy(w)
749N/AWidget w;
749N/A{
749N/A /* Disconnect input method */
749N/A
749N/A if ( ((AsciiWidget)w)->simple.international == True )
749N/A _XawImUnregister( w );
749N/A
749N/A if (w == XtParent(((AsciiWidget)w)->text.source))
749N/A XtDestroyWidget( ((AsciiWidget)w)->text.source );
749N/A
749N/A if (w == XtParent(((AsciiWidget)w)->text.sink))
749N/A XtDestroyWidget( ((AsciiWidget)w)->text.sink );
749N/A}
749N/A
749N/A#ifdef ASCII_STRING
749N/A
749N/A/************************************************************
749N/A *
749N/A * Ascii String Compatibility Code.
749N/A *
749N/A ************************************************************/
749N/A
749N/AAsciiStringClassRec asciiStringClassRec = {
749N/A { /* core fields */
749N/A /* superclass */ (WidgetClass) &asciiTextClassRec,
749N/A /* class_name */ "Text",
749N/A /* widget_size */ sizeof(AsciiStringRec),
749N/A /* class_initialize */ NULL,
749N/A /* class_part_init */ NULL,
749N/A /* class_inited */ FALSE,
749N/A /* initialize */ NULL,
749N/A /* initialize_hook */ NULL,
749N/A /* realize */ XtInheritRealize,
749N/A /* actions */ NULL,
749N/A /* num_actions */ 0,
749N/A /* resources */ NULL,
749N/A /* num_ resource */ 0,
749N/A /* xrm_class */ NULLQUARK,
749N/A /* compress_motion */ TRUE,
749N/A /* compress_exposure*/ XtExposeGraphicsExpose,
749N/A /* compress_enterleave*/ TRUE,
749N/A /* visible_interest */ FALSE,
749N/A /* destroy */ NULL,
749N/A /* resize */ XtInheritResize,
749N/A /* expose */ XtInheritExpose,
749N/A /* set_values */ NULL,
749N/A /* set_values_hook */ NULL,
749N/A /* set_values_almost*/ XtInheritSetValuesAlmost,
749N/A /* get_values_hook */ NULL,
749N/A /* accept_focus */ XtInheritAcceptFocus,
749N/A /* version */ XtVersion,
749N/A /* callback_private */ NULL,
749N/A /* tm_table */ XtInheritTranslations,
749N/A /* query_geometry */ XtInheritQueryGeometry
749N/A },
749N/A { /* Simple fields */
749N/A /* change_sensitive */ XtInheritChangeSensitive
749N/A },
749N/A { /* text fields */
749N/A /* empty */ 0
749N/A },
749N/A { /* ascii fields */
749N/A /* empty */ 0
749N/A }
749N/A};
749N/A
749N/AWidgetClass asciiStringWidgetClass = (WidgetClass)&asciiStringClassRec;
749N/A
749N/A#endif /* ASCII_STRING */
749N/A
749N/A#ifdef ASCII_DISK
749N/A
749N/A/************************************************************
749N/A *
749N/A * Ascii Disk Compatibility Code.
749N/A *
749N/A ************************************************************/
749N/A
749N/AAsciiDiskClassRec asciiDiskClassRec = {
749N/A { /* core fields */
749N/A /* superclass */ (WidgetClass) &asciiTextClassRec,
749N/A /* class_name */ "Text",
749N/A /* widget_size */ sizeof(AsciiDiskRec),
749N/A /* class_initialize */ NULL,
749N/A /* class_part_init */ NULL,
749N/A /* class_inited */ FALSE,
749N/A /* initialize */ NULL,
749N/A /* initialize_hook */ NULL,
749N/A /* realize */ XtInheritRealize,
749N/A /* actions */ NULL,
749N/A /* num_actions */ 0,
749N/A /* resources */ NULL,
749N/A /* num_ resource */ 0,
749N/A /* xrm_class */ NULLQUARK,
749N/A /* compress_motion */ TRUE,
749N/A /* compress_exposure*/ XtExposeGraphicsExpose,
749N/A /* compress_enterleave*/ TRUE,
749N/A /* visible_interest */ FALSE,
749N/A /* destroy */ NULL,
749N/A /* resize */ XtInheritResize,
749N/A /* expose */ XtInheritExpose,
749N/A /* set_values */ NULL,
749N/A /* set_values_hook */ NULL,
749N/A /* set_values_almost*/ XtInheritSetValuesAlmost,
749N/A /* get_values_hook */ NULL,
749N/A /* accept_focus */ XtInheritAcceptFocus,
749N/A /* version */ XtVersion,
749N/A /* callback_private */ NULL,
749N/A /* tm_table */ XtInheritTranslations,
749N/A /* query_geometry */ XtInheritQueryGeometry
749N/A },
749N/A { /* Simple fields */
749N/A /* change_sensitive */ XtInheritChangeSensitive
749N/A },
749N/A { /* text fields */
749N/A /* empty */ 0
749N/A },
749N/A { /* ascii fields */
749N/A /* empty */ 0
749N/A }
749N/A};
749N/A
749N/AWidgetClass asciiDiskWidgetClass = (WidgetClass)&asciiDiskClassRec;
749N/A
749N/A#endif /* ASCII_DISK */
749N/A
749N/A
749N/A
749N/A
749N/A
749N/A
749N/A
749N/A
749N/A
749N/A
749N/A
749N/A