Back to index

plt-scheme  4.2.1
xwTools3d.h
Go to the documentation of this file.
00001 /*
00002  */
00003 
00004 /***********************************************************
00005 Copyright 2004-2009 PLT Scheme Inc.
00006 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
00007 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
00008 Copyright 1995 by Markus Holzem
00009 
00010                         All Rights Reserved
00011 
00012 Permission to use, copy, modify, and distribute this software and its 
00013 documentation for any purpose and without fee is hereby granted, 
00014 provided that the above copyright notice appear in all copies and that
00015 both that copyright notice and this permission notice appear in 
00016 supporting documentation, and that the names of Digital, MIT, or Kaleb 
00017 Keithley not be used in advertising or publicity pertaining to distribution 
00018 of the software without specific, written prior permission.  
00019 
00020 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
00021 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
00022 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
00023 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00024 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
00025 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00026 SOFTWARE.
00027 
00028 ******************************************************************/
00029 
00030 /* Values for MixType mix of Xaw3dAllocPixmap */
00031 typedef enum _e_MixType {
00032     LIGHTER,                /* Pixmap shall be lighter than background */
00033     DARKER,                 /* Pixmap shall be darker than background */
00034     GRAY                    /* Pixmap shall seem as gray */
00035 } MixType;
00036 
00037 /*
00038  * Xaw3dAllocPixmap creates a pixmap, that seems LIGHTER or DARKER than
00039  * the background color or that seems GRAY
00040  */
00041 Pixmap Xaw3dAllocPixmap(
00042     Widget  w,                     /* widget, that needs the new color value */
00043     Pixel   bg,                    /* background pixel of widget */
00044     MixType mix             /* how to mix fore- and background */
00045 );
00046 
00047 #ifndef __sgi
00048 /*
00049  * Xaw3dAllocPixel allocates a new color in 'contrast' to the background
00050  * color. Use values 0.5 <= contrast <= 1.5 to get good results.
00051  * A good triple is 0.6/0.85/1.2 for darker/something between/lighter.
00052  */
00053 Pixel Xaw3dAllocPixel(
00054     Widget w,               /* widget, that needs the new color value */
00055     Pixel  bg,                     /* background pixel of widget */
00056     float  contrast         /* contrast of new color to background */
00057 );
00058 #endif
00059 
00060 /*
00061  * Xaw3dGetGC gets a read-only GC with pxmap as tile or pixel as foreground
00062  * depending on be_nice_to_cmap. It is a good style to use (Pixmap)0 or 
00063  * (Pixel)0 for unnecessary values.
00064  */
00065 GC Xaw3dGetGC(
00066     Widget  w,                     /* widget, that needs the new color value */
00067     Boolean be_nice_to_cmap,       /* True: GC uses pxmap, False: GC uses pixel */
00068     Pixmap  pxmap,          /* Pixmap for GC */
00069     Pixel   pixel           /* Pixel for GC */
00070 );
00071 
00072 GC Xaw3dRecomputeGC(
00073     Widget  new,
00074     Boolean be_nice_to_cmap,
00075     Pixmap  new_pxmap,
00076     Pixel   new_pixel,
00077     Widget  old,
00078     Pixmap  old_pxmap,
00079     Pixel   old_pixel,
00080     GC      old_GC
00081 );
00082 
00083 /*
00084  * Xaw3dFreePixmap(widget, pixmap)
00085  * Xaw3dFreePixel(widget, pixel)   <--- I don't know if it is useful
00086  * Xaw3dReleaseGC(widget, gc)
00087  * for consistency use this functions instead of XFreePixmap, XFreeColors
00088  * and XtReleaseGC
00089  */
00090 #define Xaw3dFreePixmap(w,p) {\
00091     if (p) { XFreePixmap(XtDisplay((Widget)w), p); p = (Pixmap)0; } }
00092 #define Xaw3dFreePixel(w,p) {\
00093     XFreeColors(XtDisplay((Widget)w), \
00094               DefaultColormapOfScreen(XtScreen((Widget)w)), &p, 1, 0); \
00095     p = (Pixel)-1; }
00096 #define Xaw3dReleaseGC(w,g) {\
00097     XtReleaseGC((Widget)w, g); }
00098 
00099 /* Values for ShadowType needed in 3d drawing functions */
00100 typedef enum _e_ShadowType {
00101     XAW3D_BACKGROUND = 1,   /* for Xaw3dDrawRectangle to erase shadow */
00102     XAW3D_OUT = 2,          /*                                        */
00103     XAW3D_IN = 3,           /*               OUT        IN            */
00104     XAW3D_ETCHED_OUT = 4,   /*            ________                    */
00105     XAW3D_ETCHED_IN = 5,    /*           /        \  \________/       */
00106     XAW3D_ETCHED_OUT_DASH = 6,     /*                         ______         */
00107     XAW3D_ETCHED_IN_DASH = 7,      /*  ETCHED   /\______/\  \/      \/       */
00108     XAW3D_SINGLE_LINE = 8,  /*                                        */
00109     XAW3D_DOUBLE_LINE = 9,  /*  DASH:   line is dashed                */
00110     XAW3D_SINGLE_LINE_DASH = 10,/*  SINGLE: single line 2d                */
00111     XAW3D_DOUBLE_LINE_DASH = 11,/*  DOUBLE: double line 2d                */
00112     XAW3D_NO_LINE = 12,            /*  NO:     do not draw the line          */
00113     XAW3D_XED = 13,
00114     XAW3D_OUT_HARD = 14,
00115     XAW3D_IN_HARD = 15
00116 } ShadowType;
00117 
00118 /*
00119  * Xaw3dDrawRectangle draws a shadow-rectangle, ie top-left part and
00120  * bottom-right part in different colors (light and shadow) to make
00121  * the appearence of 3d.
00122  * Expected values for shadow_type:
00123  *   XAW3D_IN, XAW3D_OUT, XAW3D_ETCHED_IN, XAW3d_ETCHED_OUT,
00124  *   XAW3D_BACKGROUND (special for erasing shadow with backgroundGC)
00125  */
00126 void Xaw3dDrawRectangle(
00127     Display    *dpy,        /* Display for drawing */
00128     Window     win,         /* Window for drawing */
00129     GC         lightGC,            /* GC for light color */
00130     GC         shadowGC,    /* GC for shadow color */
00131     GC         backgroundGC,       /* GC for background color */
00132     GC         fgGC,
00133     int        x,
00134     int        y,           /* upper left corner of rectangle */
00135     unsigned   width,
00136     unsigned   height,             /* width and height of rectangle */
00137     int        thickness,   /* thickness of shadow */
00138     ShadowType shadow_type  /* type of shadow */
00139 );
00140 /*
00141  * Xaw3dDrawLine draws a line that may have a 3d-appearence.
00142  * Expected values for shadow_type:
00143  *   XAW3D_NO_LINE, (do not draw the line),
00144  *   XAW3D_ETCHED_IN, XAW3D_ETCHED_OUT, XAW3D_ETCHED_IN_DASH,
00145  *   XAW3D_ETCHED_OUT_DASH, (3d-line solid or dashed, in or out),
00146  *   XAW3D_SINGLE_LINE, XAW3D_SINGLE_LINE_DASH, XAW3D_DOUBLE_LINE,
00147  *   XAW3D_DOUBLE_LINE_DASH, (2d-line single or double, solid or dashed).
00148  */
00149 void Xaw3dDrawLine(
00150     Display    *dpy,        /* Display for drawing */
00151     Window     win,         /* Window for drawing */
00152     GC         lightGC,            /* GC for light color */
00153     GC         shadowGC,    /* GC for shadow color */
00154     GC         foregroundGC,       /* GC for foreground color */
00155     int        x,
00156     int        y,           /* upper left corner of line */
00157     unsigned   length,             /* length of line */
00158     int        thickness,   /* thickness of line */
00159     Boolean    vertical,    /* shall line be drawn vertical? */
00160     ShadowType shadow_type  /* type of shadow */
00161 );
00162 
00163 /*
00164  * Xaw3dDrawToggle draws a toggle set or unset in a square of
00165  * size width * width.
00166  */
00167 void Xaw3dDrawToggle(
00168     Display    *dpy,        /* Display for drawing */
00169     Window     win,         /* Window for drawing */
00170     GC         lightGC,            /* GC for light color */
00171     GC         shadowGC,    /* GC for shadow color */
00172     GC         inGC,        /* GC for pushed/set toggle */
00173     GC         outGC,              /* GC for released/unset toggle */
00174     GC         fgGC,            /* GC for checkmark */
00175     int        x,
00176     int        y,           /* upper left corner */
00177     unsigned   width,              /* width of toggle square */
00178     int        thickness,   /* thickness of shadow */
00179     Boolean    pushed              /* is toggle pushed(in) or released(out) */
00180 );
00181 
00182 /*
00183  * Xaw3dDrawRadio draws a radio button set or unset in a square of
00184  * size width * width.
00185  */
00186 void Xaw3dDrawRadio(
00187     Display    *dpy,        /* Display for drawing */
00188     Window     win,         /* Window for drawing */
00189     GC         lightGC,            /* GC for light color */
00190     GC         shadowGC,    /* GC for shadow color */
00191     GC         inGC,        /* GC for pushed/set radio */
00192     GC         outGC,              /* GC for released/unset readio */
00193     GC         fgGC,            /* GC for dot */
00194     int        x,
00195     int        y,           /* upper left corner */
00196     unsigned   width,              /* width of radio button */
00197     int        thickness,   /* thickness of shadow */
00198     Boolean    pushed              /* is radio pushed(in) or released(out) */
00199 );
00200 
00201 /* Values for ArrowType needed in Xaw3dDrawArrow*/
00202 typedef enum _e_ArrowType {
00203     LEFT, RIGHT, UP, DOWN   /* Direction of arrow */
00204 } ArrowType;
00205 
00206 /*
00207  * Xaw3dDrawArrow draws an arrow pushed or released in an square
00208  * with size width * width.
00209  */
00210 void Xaw3dDrawArrow(
00211     Display    *dpy,        /* Display for drawing */
00212     Window     win,         /* Window for drawing */
00213     GC         lightGC,            /* GC for light color */
00214     GC         shadowGC,    /* GC for shadow color */
00215     GC         inGC,        /* GC for pushed arrow */
00216     GC         outGC,              /* GC for released arrow */
00217     int        x,
00218     int        y,           /* upper left corner */
00219     unsigned   width,              /* width of arrow */
00220     unsigned   height,             /* height of arrow */
00221     int        thickness,   /* thickness of shadow */
00222     ArrowType  arrow_type,  /* LEFT, RIGHT, UP or DOWN arrow */
00223     Boolean    pushed              /* is radio pushed(in) or released(out) */
00224 );