ShapeWidg.c File Reference

#include <X11/IntrinsicP.h>
#include <X11/extensions/shape.h>
#include "Converters.h"
#include "Drawing.h"
#include "Misc.h"

Include dependency graph for ShapeWidg.c:

Go to the source code of this file.

Functions

static void ShapeEllipseOrRoundedRectangle (Widget, Bool, int, int)
static void ShapeError (Widget)
static void ShapeOval (Widget)
static void ShapeRectangle (Widget)
Boolean XmuReshapeWidget (Widget w, int shape_style, int corner_width, int corner_height)


Function Documentation

static void ShapeEllipseOrRoundedRectangle ( Widget  ,
Bool  ,
int  ,
int   
) [static]

Definition at line 194 of file ShapeWidg.c.

References dpy, gc, height, p, width, and XmuFillRoundedRectangle().

Referenced by XmuReshapeWidget().

00195 {
00196     Display *dpy = XtDisplay(w);
00197   unsigned width = w->core.width;
00198   unsigned height = w->core.height;
00199   Pixmap p;
00200     XGCValues values;
00201     GC gc;
00202   unsigned long mask;
00203 
00204   if (width < 3 || width < 3)
00205     return;
00206   width += w->core.border_width << 1;
00207   height += w->core.border_width << 1;
00208 
00209   mask = GCForeground | GCLineWidth;
00210   p = XCreatePixmap(dpy, XtWindow(w), width, height, 1);
00211 
00212     values.foreground = 0;
00213   values.line_width = 2;
00214 
00215   gc = XCreateGC(dpy, p, mask, &values);
00216   XFillRectangle(dpy, p, gc, 0, 0, width, height);
00217   XSetForeground(dpy, gc, 1);
00218     if (!ellipse)
00219     XmuFillRoundedRectangle(dpy, p, gc, 1, 1, width - 2, height - 2, ew, eh);
00220     else
00221     {
00222       XDrawArc(dpy, p, gc, 1, 1, width - 2, height - 2, 0, 360 * 64);
00223       XFillArc(dpy, p, gc, 2, 2, width - 4, height - 4, 0, 360 * 64);
00224     }
00225   XShapeCombineMask(dpy, XtWindow(w), ShapeBounding,
00226                     -(int)w->core.border_width, -(int)w->core.border_width,
00227                     p, ShapeSet);
00228   if (w->core.border_width)
00229     {
00230       XSetForeground(dpy, gc, 0);
00231       XFillRectangle(dpy, p, gc, 0, 0, width, height);
00232       XSetForeground(dpy, gc, 1);
00233         if (!ellipse)
00234         XmuFillRoundedRectangle(dpy, p, gc, 1, 1,
00235                                 w->core.width - 2, w->core.height - 2,
00236                                 ew, eh);
00237       else
00238         XFillArc(dpy, p, gc, 0, 0, w->core.width, w->core.height,
00239                  0, 360 * 64);
00240       XShapeCombineMask(dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet);
00241     }
00242   else
00243     XShapeCombineMask(XtDisplay(w), XtWindow(w),
00244                       ShapeClip, 0, 0, None, ShapeSet);
00245 
00246   XFreePixmap(dpy, p);
00247   XFreeGC(dpy, gc);
00248 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void ShapeError ( Widget   )  [static]

Definition at line 72 of file ShapeWidg.c.

Referenced by XmuReshapeWidget().

00073 {
00074     String params[1];
00075     Cardinal num_params = 1;
00076 
00077     params[0] = XtName(w);
00078   XtAppWarningMsg(XtWidgetToApplicationContext(w),
00079                      "shapeUnknown", "xmuReshapeWidget", "XmuLibrary",
00080                      "Unsupported shape style for Command widget \"%s\"",
00081                   params, &num_params);
00082 }

Here is the caller graph for this function:

static void ShapeOval ( Widget   )  [static]

Definition at line 109 of file ShapeWidg.c.

References dpy, gc, height, Min, p, and width.

Referenced by XmuReshapeWidget().

00110 {
00111     Display *dpy = XtDisplay(w);
00112     int width = w->core.width;
00113     int height = w->core.height;
00114     Pixmap p;
00115     XGCValues values;
00116     GC gc;
00117     int rad;
00118 
00119     if (width < 3 || height < 3)
00120       return;
00121     width += w->core.border_width << 1;
00122     height += w->core.border_width << 1;
00123 
00124     p = XCreatePixmap(dpy, XtWindow(w), width, height, 1);
00125     values.foreground = 0;
00126     values.background = 1;
00127     values.cap_style = CapRound;
00128     values.line_width = Min(width, height);
00129     gc = XCreateGC(dpy, p,
00130                     GCForeground | GCBackground | GCLineWidth | GCCapStyle,
00131                     &values);
00132     XFillRectangle(dpy, p, gc, 0, 0, width, height);
00133     XSetForeground(dpy, gc, 1);
00134 
00135     if (width < height)
00136       {
00137         rad = width >> 1;
00138         XDrawLine(dpy, p, gc, rad, rad, rad, height - rad - 1);
00139       }
00140     else
00141       {
00142         rad = height >> 1;
00143         XDrawLine(dpy, p, gc, rad, rad, width - rad - 1, rad);
00144     }
00145     XShapeCombineMask(dpy, XtWindow(w), ShapeBounding, 
00146                       -(int)w->core.border_width, -(int)w->core.border_width,
00147                       p, ShapeSet);
00148     if (w->core.border_width)
00149       {
00150         XSetForeground(dpy, gc, 0);
00151         XFillRectangle(dpy, p, gc, 0, 0, width, height);
00152         values.line_width = Min(w->core.width, w->core.height);
00153         values.foreground = 1;
00154         XChangeGC(dpy, gc, GCLineWidth | GCForeground, &values);
00155         if (w->core.width < w->core.height)
00156           {
00157             rad = w->core.width >> 1;
00158             XDrawLine(dpy, p, gc, rad, rad, rad, w->core.height - rad - 1);
00159           }
00160         else
00161           {
00162             rad = w->core.height >> 1;
00163             XDrawLine(dpy, p, gc, rad, rad, w->core.width - rad - 1, rad);
00164         }
00165         XShapeCombineMask(dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet);
00166     }
00167     else
00168       XShapeCombineMask(XtDisplay(w), XtWindow(w),
00169                         ShapeClip, 0, 0, None, ShapeSet);
00170 
00171     XFreePixmap(dpy, p);
00172     XFreeGC(dpy, gc);
00173 }

Here is the caller graph for this function:

static void ShapeRectangle ( Widget   )  [static]

Definition at line 85 of file ShapeWidg.c.

Referenced by XmuReshapeWidget().

00086 {
00087   XShapeCombineMask(XtDisplay(w), XtWindow(w),
00088                     ShapeBounding, 0, 0, None, ShapeSet);
00089   XShapeCombineMask(XtDisplay(w), XtWindow(w),
00090                     ShapeClip, 0, 0, None, ShapeSet);
00091 }

Here is the caller graph for this function:

Boolean XmuReshapeWidget ( Widget  w,
int  shape_style,
int  corner_width,
int  corner_height 
)

Definition at line 48 of file ShapeWidg.c.

References ShapeEllipseOrRoundedRectangle(), ShapeError(), ShapeOval(), ShapeRectangle(), XmuShapeEllipse, XmuShapeOval, XmuShapeRectangle, and XmuShapeRoundedRectangle.

Referenced by ShapeButton().

00050 {
00051   switch (shape_style)
00052     {
00053       case XmuShapeRectangle:
00054         ShapeRectangle(w);
00055         break;
00056       case XmuShapeOval:
00057         ShapeOval(w);
00058         break;
00059       case XmuShapeEllipse:
00060       case XmuShapeRoundedRectangle:
00061       ShapeEllipseOrRoundedRectangle(w, shape_style == XmuShapeEllipse,
00062                                      corner_width, corner_height);
00063         break;
00064       default:
00065         ShapeError(w);
00066       return (False);
00067     }
00068   return (True);
00069 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Sun Mar 4 16:04:17 2007 for Scilab [trunk] by  doxygen 1.5.1