home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xcu16.zip / bin / wlmInclMake < prev    next >
Text File  |  1991-10-03  |  5KB  |  161 lines

  1. #!/bin/sh
  2. #
  3. # Copyright 1991 Cornell University
  4. #
  5. # Permission to use, copy, modify, and distribute this software and its
  6. # documentation for any purpose and without fee is hereby granted, provided
  7. # that the above copyright notice appear in all copies and that both that
  8. # copyright notice and this permission notice appear in supporting
  9. # documentation, and that the name of Cornell U. not be used in advertising
  10. # or publicity pertaining to distribution of the software without specific,
  11. # written prior permission.  Cornell U. makes no representations about the
  12. # suitability of this software for any purpose.  It is provided "as is"
  13. # without express or implied warranty.
  14. #
  15. # CORNELL UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  16. # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  17. # EVENT SHALL CORNELL UNIVERSITY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  18. # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  19. # USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  20. # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  21. # PERFORMANCE OF THIS SOFTWARE.
  22. #
  23. # Author:  Gene W. Dykes, Program of Computer Graphics
  24. #          580 Theory Center, Cornell University, Ithaca, NY 14853
  25. #          (607) 255-6713   gwd@graphics.cornell.edu
  26. #
  27.  
  28.  
  29. # This script works for inputs of the form XidWidgetClass, where Xid
  30. # is the directory of the appropriate include files. (id is the prefix
  31. # used by the widgets of a toolkit). This is the convention for Motif
  32. # style widgets.
  33. #
  34. # Note that HP widgets violate intrinsics naming conventions, so
  35. # a special test is needed for these.  The special test is also needed
  36. # to include the special "Xw/Xw.h".
  37. #
  38. # Also, Athena widgets are treated specially.  They have elected not to
  39. # retrofit their widgets to a rational nomenclature.  All widget classes
  40. # that don't start with "Xid" are assumed to be Athena widgets.
  41. #
  42. # Undoubtedly, there will be other widgets that will need special treatment.
  43. # elif's can be added as appropriate.
  44.  
  45. # if you switch to X11R4, then change the 3 to a 4 in the next line...
  46.  
  47. X11R=3
  48. hp_present=0
  49.  
  50. echo "#include <X11/Xcu/WlmP.h>"
  51. for i in $* ; do
  52.  
  53.     # Grab the first letter.
  54.  
  55.     trail=`echo $i | sed 's/.//'`
  56.     x=`basename $i $trail`
  57.  
  58.     # Find out if it is a widget that follows toolkit nomenclature.
  59.     # For now, this decision is based solely on whether the class name
  60.     # starts with an "X".  If it doesn't, we have to assume it is an
  61.     # Athena widget.
  62.  
  63.     if [ "$x" = "X" ] ; then
  64.     i=$trail
  65.     trail=`echo $i | sed 's/[a-z]*//'`
  66.     id=`basename $i $trail`
  67.     else
  68.     x=""
  69.  
  70.     # YUCKO!!!
  71.     if [ "$i" = "AsciiString" -o "$i" = "AsciiDisk" ] ; then
  72.         i=AsciiText
  73.     fi
  74.     #
  75.  
  76.     trail=$i
  77.     if [ $X11R -eq 3 ] ; then
  78.         id="11"
  79.     else
  80.         id="aw"
  81.     fi
  82.     fi
  83.  
  84.     if [ "$id" = "w" ] ; then        # test for HP widgets
  85.     if [ $hp_present -eq 0 ] ; then # only include this once if needed
  86.         echo "#include <Xw/Xw.h>"
  87.         hp_present=1
  88.     fi
  89.     # elif [ "$x" = "otherId" ] ; then    # future test for other special widgets
  90.     fi
  91.  
  92.     # We now have the include file basename in $trail, BUT
  93.     # if it is longer than 9 characters we have to truncate it down.
  94.     # The algorithm for this is to strip off the lower case letters,
  95.     # a word at a time, starting with the trailing words, until the basename
  96.     # is 9 characters or fewer.  Example:
  97.     #    VeryLongWidgetName.h (too long)
  98.     #   VeryLongWidgetN.h (still too long)
  99.     #   VeryLongWN.h (still too long)
  100.     #   VeryLWN.h (okay now)
  101.     # But, when down to the last word, only strip just enough letters.
  102.     # Examples:
  103.     #   AtrociouslyLongWidgetName.h -> AtrociLWN.h
  104.     #   Supercallifragilistic.h -> Supercall.h
  105.     #
  106.     # Athena widgets, however, just strip down to 9 letters.
  107.     #
  108.     # I'm sure truncation could be done in the shell, too, but somehow
  109.     # I think it'll be quicker to do this part with a small C program.
  110.  
  111.     trail=`incl_trunc $trail`
  112.  
  113.     echo "#include <X11/X${id}/${trail}.h>"
  114. done
  115.  
  116. echo ""
  117. echo "void"
  118. echo "make_tag_class_list (ww)"
  119. echo "    XcuWlmWidget ww ;"
  120. echo "{"
  121. echo "XcuWlmTagClassList *list = NULL ;"
  122. echo "XcuWlmTagClassList *save ;"
  123. echo ""
  124.  
  125. for i in $* ; do
  126.     echo "save = list ;"
  127.     echo 'list = (XcuWlmTagClassList *) XtMalloc(sizeof (XcuWlmTagClassList)) ;'
  128.     echo "list->quark = XrmStringToQuark (\"$i\") ;"
  129.  
  130.     trail=`echo $i | sed 's/.//'`
  131.     x=`basename $i $trail`
  132.  
  133.     if [ "$x" = "X" ] ; then
  134.     x="x"
  135.     i=$trail
  136.     trail=`echo $i | sed 's/[a-z]*//'`
  137.     id=`basename $i $trail`
  138.     else
  139.     x=""
  140.     trail=`echo $i | sed 's/.//'`
  141.     first=`basename $i $trail`
  142.     first=`echo $first | tr "[A-Z]" "[a-z]"`
  143.     id="$first"    # Athena widgets don't prepend the ID
  144.             # instead, use the lowercase of the first letter
  145.     fi
  146.  
  147.     if [ "$id" = "w" ] ; then    # test for HP violations
  148.     x="X"
  149.     fi
  150.  
  151.     echo "list->class = ${x}${id}${trail}WidgetClass ;"
  152.     echo "list->next = save ;"
  153.     echo ""
  154. done
  155.  
  156. echo "ww->wlm.tag_class_list = list ;"
  157. echo "return ;"
  158. echo "}"
  159. echo ""
  160.  
  161.