AsciiText.c

Go to the documentation of this file.
00001 /* $XConsortium: AsciiText.c,v 1.47 95/06/06 20:50:30 kaleb Exp $ */
00002 
00003 /*
00004 
00005 Copyright (c) 1987, 1988, 1994  X Consortium
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy
00008 of this software and associated documentation files (the "Software"), to deal
00009 in the Software without restriction, including without limitation the rights
00010 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011 copies of the Software, and to permit persons to whom the Software is
00012 furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00020 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023 
00024 Except as contained in this notice, the name of the X Consortium shall not be
00025 used in advertising or otherwise to promote the sale, use or other dealings
00026 in this Software without prior written authorization from the X Consortium.
00027 
00028 
00029 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
00030 
00031                         All Rights Reserved
00032 
00033 Permission to use, copy, modify, and distribute this software and its 
00034 documentation for any purpose and without fee is hereby granted, 
00035 provided that the above copyright notice appear in all copies and that
00036 both that copyright notice and this permission notice appear in 
00037 supporting documentation, and that the name of Digital not be
00038 used in advertising or publicity pertaining to distribution of the
00039 software without specific, written prior permission.  
00040 
00041 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
00042 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
00043 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
00044 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00045 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
00046 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00047 SOFTWARE.
00048 
00049 */
00050 
00051 /***********************************************************************
00052  *
00053  * AsciiText Widget
00054  *
00055  ***********************************************************************/
00056 
00057 /*
00058  * AsciiText.c - Source code for AsciiText Widget.
00059  *
00060  * This Widget is intended to be used as a simple front end to the 
00061  * text widget with an ascii source and ascii sink attached to it.
00062  *
00063  * Date:    June 29, 1989
00064  *
00065  * By:      Chris D. Peterson
00066  *          MIT X Consortium 
00067  *          kit@expo.lcs.mit.edu
00068  */
00069 
00070 #include <stdio.h>
00071 #include <X11/IntrinsicP.h>
00072 #include <X11/StringDefs.h>
00073 
00074 #include <X11/Xaw3d/XawInit.h>
00075 #include <X11/Xaw3d/Cardinals.h>
00076 #include <X11/Xaw3d/AsciiTextP.h>
00077 #include <X11/Xaw3d/AsciiSrc.h>
00078 #include <X11/Xaw3d/AsciiSink.h>
00079 #include <X11/Xaw3d/MultiSrc.h>
00080 #include <X11/Xaw3d/MultiSinkP.h>
00081 #include <X11/Xaw3d/XawImP.h>
00082 
00083 #define TAB_COUNT 32
00084 
00085 static void Initialize(), Destroy();
00086 
00087 AsciiTextClassRec asciiTextClassRec = {
00088   { /* core fields */
00089     /* superclass       */      (WidgetClass) &textClassRec,
00090     /* class_name       */      "Text",
00091     /* widget_size      */      sizeof(AsciiRec),
00092     /* class_initialize */      XawInitializeWidgetSet,
00093     /* class_part_init  */      NULL,
00094     /* class_inited     */      FALSE,
00095     /* initialize       */      Initialize,
00096     /* initialize_hook  */      NULL,
00097     /* realize          */      XtInheritRealize,
00098     /* actions          */      NULL,
00099     /* num_actions      */      0,
00100     /* resources        */      NULL,
00101     /* num_resource     */      0,
00102     /* xrm_class        */      NULLQUARK,
00103     /* compress_motion  */      TRUE,
00104     /* compress_exposure*/      XtExposeGraphicsExpose | XtExposeNoExpose,
00105     /* compress_enterleave*/    TRUE,
00106     /* visible_interest */      FALSE,
00107     /* destroy          */      Destroy,
00108     /* resize           */      XtInheritResize,
00109     /* expose           */      XtInheritExpose,
00110     /* set_values       */      NULL,
00111     /* set_values_hook  */      NULL,
00112     /* set_values_almost*/      XtInheritSetValuesAlmost,
00113     /* get_values_hook  */      NULL,
00114     /* accept_focus     */      XtInheritAcceptFocus,
00115     /* version          */      XtVersion,
00116     /* callback_private */      NULL,
00117     /* tm_table         */      XtInheritTranslations,
00118     /* query_geometry   */      XtInheritQueryGeometry
00119   },
00120   { /* Simple fields */
00121     /* change_sensitive */      XtInheritChangeSensitive
00122   },
00123   { /* text fields */
00124     /* empty            */      0
00125   },
00126   { /* ascii fields */
00127     /* empty            */      0
00128   }
00129 };
00130 
00131 WidgetClass asciiTextWidgetClass = (WidgetClass)&asciiTextClassRec;
00132 
00133 
00134 static void
00135 Initialize(request, new, args, num_args)
00136 Widget request, new;
00137 ArgList args;
00138 Cardinal *num_args;
00139 {
00140   AsciiWidget w = (AsciiWidget) new;
00141   int i;
00142   int tabs[TAB_COUNT], tab;
00143 
00144   MultiSinkObject sink;
00145 
00146   /* superclass Initialize can't set the following,
00147    * as it didn't know the source or sink when it was called */
00148 
00149   if (request->core.height == DEFAULT_TEXT_HEIGHT)
00150     new->core.height = DEFAULT_TEXT_HEIGHT;
00151 
00152 
00153   /* This is the main change for internationalization.  */
00154 
00155   if ( w->simple.international == True ) { /* The multi* are international. */
00156 
00157       w->text.source = XtCreateWidget( "textSource", multiSrcObjectClass,
00158                                   new, args, *num_args );
00159       w->text.sink = XtCreateWidget( "textSink", multiSinkObjectClass,
00160                                 new, args, *num_args );
00161   }
00162   else { 
00163 
00164       w->text.source = XtCreateWidget( "textSource", asciiSrcObjectClass,
00165                                   new, args, *num_args );
00166       w->text.sink = XtCreateWidget( "textSink", asciiSinkObjectClass,
00167                                 new, args, *num_args );
00168   }
00169 
00170   if (w->core.height == DEFAULT_TEXT_HEIGHT)
00171     w->core.height = VMargins(w) + XawTextSinkMaxHeight(w->text.sink, 1);
00172 
00173   for (i=0, tab=0 ; i < TAB_COUNT ; i++) 
00174     tabs[i] = (tab += 8);
00175   
00176   XawTextSinkSetTabs(w->text.sink, TAB_COUNT, tabs);
00177 
00178   XawTextDisableRedisplay(new);
00179   XawTextEnableRedisplay(new);
00180 
00181 
00182   /* If we are using a MultiSink we need to tell the input method stuff. */
00183 
00184   if ( w->simple.international == True ) {
00185     Arg list[4];
00186     Cardinal ac = 0;
00187 
00188     sink = (MultiSinkObject)w->text.sink;
00189     _XawImRegister( new );
00190     XtSetArg (list[ac], XtNfontSet, sink->multi_sink.fontset); ac++;
00191     XtSetArg (list[ac], XtNinsertPosition, w->text.insertPos); ac++;
00192     XtSetArg (list[ac], XtNforeground, sink->text_sink.foreground); ac++;
00193     XtSetArg (list[ac], XtNbackground, sink->text_sink.background); ac++;
00194     _XawImSetValues(new, list, ac);
00195   }
00196 }
00197 
00198 static void 
00199 Destroy(w)
00200 Widget w;
00201 {
00202     /* Disconnect input method */
00203 
00204     if ( ((AsciiWidget)w)->simple.international == True )
00205         _XawImUnregister( w );
00206 
00207     if (w == XtParent(((AsciiWidget)w)->text.source))
00208         XtDestroyWidget( ((AsciiWidget)w)->text.source );
00209 
00210     if (w == XtParent(((AsciiWidget)w)->text.sink))
00211         XtDestroyWidget( ((AsciiWidget)w)->text.sink );
00212 }
00213 
00214 #ifdef ASCII_STRING
00215 
00216 /************************************************************
00217  *
00218  * Ascii String Compatibility Code.
00219  *
00220  ************************************************************/
00221 
00222 AsciiStringClassRec asciiStringClassRec = {
00223   { /* core fields */
00224     /* superclass       */      (WidgetClass) &asciiTextClassRec,
00225     /* class_name       */      "Text",
00226     /* widget_size      */      sizeof(AsciiStringRec),
00227     /* class_initialize */      NULL,
00228     /* class_part_init  */      NULL,
00229     /* class_inited     */      FALSE,
00230     /* initialize       */      NULL,
00231     /* initialize_hook  */      NULL,
00232     /* realize          */      XtInheritRealize,
00233     /* actions          */      NULL,
00234     /* num_actions      */      0,
00235     /* resources        */      NULL,
00236     /* num_ resource    */      0,
00237     /* xrm_class        */      NULLQUARK,
00238     /* compress_motion  */      TRUE,
00239     /* compress_exposure*/      XtExposeGraphicsExpose,
00240     /* compress_enterleave*/    TRUE,
00241     /* visible_interest */      FALSE,
00242     /* destroy          */      NULL,
00243     /* resize           */      XtInheritResize,
00244     /* expose           */      XtInheritExpose,
00245     /* set_values       */      NULL,
00246     /* set_values_hook  */      NULL,
00247     /* set_values_almost*/      XtInheritSetValuesAlmost,
00248     /* get_values_hook  */      NULL,
00249     /* accept_focus     */      XtInheritAcceptFocus,
00250     /* version          */      XtVersion,
00251     /* callback_private */      NULL,
00252     /* tm_table         */      XtInheritTranslations,
00253     /* query_geometry   */      XtInheritQueryGeometry
00254   },
00255   { /* Simple fields */
00256     /* change_sensitive */      XtInheritChangeSensitive
00257   },
00258   { /* text fields */
00259     /* empty            */      0
00260   },
00261   { /* ascii fields */
00262     /* empty            */      0
00263   }
00264 };
00265 
00266 WidgetClass asciiStringWidgetClass = (WidgetClass)&asciiStringClassRec;
00267 
00268 #endif /* ASCII_STRING */
00269 
00270 #ifdef ASCII_DISK
00271 
00272 /************************************************************
00273  *
00274  * Ascii Disk Compatibility Code.
00275  *
00276  ************************************************************/
00277 
00278 AsciiDiskClassRec asciiDiskClassRec = {
00279   { /* core fields */
00280     /* superclass       */      (WidgetClass) &asciiTextClassRec,
00281     /* class_name       */      "Text",
00282     /* widget_size      */      sizeof(AsciiDiskRec),
00283     /* class_initialize */      NULL,
00284     /* class_part_init  */      NULL,
00285     /* class_inited     */      FALSE,
00286     /* initialize       */      NULL,
00287     /* initialize_hook  */      NULL,
00288     /* realize          */      XtInheritRealize,
00289     /* actions          */      NULL,
00290     /* num_actions      */      0,
00291     /* resources        */      NULL,
00292     /* num_ resource    */      0,
00293     /* xrm_class        */      NULLQUARK,
00294     /* compress_motion  */      TRUE,
00295     /* compress_exposure*/      XtExposeGraphicsExpose,
00296     /* compress_enterleave*/    TRUE,
00297     /* visible_interest */      FALSE,
00298     /* destroy          */      NULL,
00299     /* resize           */      XtInheritResize,
00300     /* expose           */      XtInheritExpose,
00301     /* set_values       */      NULL,
00302     /* set_values_hook  */      NULL,
00303     /* set_values_almost*/      XtInheritSetValuesAlmost,
00304     /* get_values_hook  */      NULL,
00305     /* accept_focus     */      XtInheritAcceptFocus,
00306     /* version          */      XtVersion,
00307     /* callback_private */      NULL,
00308     /* tm_table         */      XtInheritTranslations,
00309     /* query_geometry   */      XtInheritQueryGeometry
00310   },
00311   { /* Simple fields */
00312     /* change_sensitive */      XtInheritChangeSensitive
00313   },
00314   { /* text fields */
00315     /* empty            */      0
00316   },
00317   { /* ascii fields */
00318     /* empty            */      0
00319   }
00320 };
00321 
00322 WidgetClass asciiDiskWidgetClass = (WidgetClass)&asciiDiskClassRec;
00323 
00324 #endif /* ASCII_DISK */
00325 
00326 
00327 
00328 
00329 
00330 
00331 
00332 
00333 
00334 
00335 
00336 

Generated on Sun Mar 4 15:03:55 2007 for Scilab [trunk] by  doxygen 1.5.1