home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume18 / wclock / part01 / Outline.c < prev    next >
C/C++ Source or Header  |  1992-07-13  |  3KB  |  102 lines

  1.  
  2. /*
  3.  * This file hacked from Weekday.c in the xdiary distribution by RJC.
  4.  */
  5.  
  6. /*
  7.  * Original author: Jason Baietto, jason@ssd.csd.harris.com
  8.  *
  9.  * Permission to use, copy, modify, and distribute, this software and its
  10.  * documentation for any purpose is hereby granted without fee, provided that
  11.  * the above copyright notice appear in all copies and that both that
  12.  * copyright notice and this permission notice appear in supporting
  13.  * documentation, and that the name of the copyright holder be used in
  14.  * advertising or publicity pertaining to distribution of the software with
  15.  * specific, written prior permission, and that no fee is charged for further
  16.  * distribution of this software, or any modifications thereof.  The copyright
  17.  * holder makes no representations about the suitability of this software for
  18.  * any purpose.  It is provided "as is" without express or implied warranty.
  19.  *
  20.  * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  21.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND IN NO
  22.  * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  23.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ITS USE,
  24.  * LOSS OF DATA, PROFITS, QPA OR GPA, WHETHER IN AN ACTION OF CONTRACT,
  25.  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
  26.  * THE USE OR PERFORMANCE OF THIS SOFTWARE.
  27.  */
  28.  
  29. #include <stdio.h>
  30. #include <ctype.h>
  31. #include <X11/StringDefs.h>
  32. #include <X11/IntrinsicP.h>
  33. #include "OutlineP.h"
  34.  
  35. #define MAX_STRING_LEN 256
  36.  
  37. /*==========================================================================*/
  38. /*                                 Quarks:                                  */
  39. /*==========================================================================*/
  40. XrmQuark XtQNoOutline;
  41. XrmQuark XtQBitmap;
  42. XrmQuark XtQCircle;
  43.  
  44.  
  45. /*==========================================================================*/
  46. /*                         Outline Type Converter:                          */
  47. /*==========================================================================*/
  48. static void downcase_string(source, dest)
  49. char * source;
  50. char * dest;
  51. {
  52.    for (; *source != 0; source++, dest++) {
  53.       if ( isupper(*source) )
  54.       *dest = tolower(*source);
  55.       else
  56.       *dest = *source;
  57.    }
  58.    *dest = 0;
  59. }
  60.  
  61.  
  62.  
  63. /*ARGSUSED*/
  64. void OutlineConverter(args, num_args, fromVal, toVal)
  65. XrmValuePtr args;
  66. Cardinal    *num_args;
  67. XrmValuePtr fromVal;
  68. XrmValuePtr toVal;
  69. {
  70.    static int initialized = FALSE;
  71.    static XtOutline Outline;
  72.    XrmQuark q;
  73.    char lowerName[MAX_STRING_LEN];
  74.  
  75.    if (!initialized) {
  76.       /* Create quarks the first time we're called. */
  77.       XtQBitmap     = XrmStringToQuark(XtNbitmap);
  78.       XtQCircle   = XrmStringToQuark(XtNcircle);
  79.       XtQNoOutline   = XrmStringToQuark(XtNnoOutline);
  80.    }
  81.  
  82.    downcase_string((char*)fromVal->addr, lowerName);
  83.    q = XrmStringToQuark(lowerName);
  84.  
  85.    toVal->size = sizeof(XtOutline);
  86.    toVal->addr = (XtPointer) &Outline;
  87.  
  88.    if (q == XtQBitmap) {
  89.       Outline = Bitmap;
  90.    } else if (q == XtQCircle) {
  91.       Outline = Circle;
  92.    } else if (q == XtQNoOutline) {
  93.       Outline = NoOutline;
  94.    } else {
  95.       XtStringConversionWarning(fromVal->addr, "XtROutline");
  96.       toVal->addr = NULL;
  97.       toVal->size = 0;
  98.    }
  99. }
  100.  
  101.  
  102.