Blame lib/Xm/DrHiDash.c

Packit b099d7
/* $XConsortium: DrHiDash.c /main/5 1995/07/15 20:50:42 drk $ */
Packit b099d7
/*
Packit b099d7
 * Motif
Packit b099d7
 *
Packit b099d7
 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
Packit b099d7
 *
Packit b099d7
 * These libraries and programs are free software; you can
Packit b099d7
 * redistribute them and/or modify them under the terms of the GNU
Packit b099d7
 * Lesser General Public License as published by the Free Software
Packit b099d7
 * Foundation; either version 2 of the License, or (at your option)
Packit b099d7
 * any later version.
Packit b099d7
 *
Packit b099d7
 * These libraries and programs are distributed in the hope that
Packit b099d7
 * they will be useful, but WITHOUT ANY WARRANTY; without even the
Packit b099d7
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Packit b099d7
 * PURPOSE. See the GNU Lesser General Public License for more
Packit b099d7
 * details.
Packit b099d7
 *
Packit b099d7
 * You should have received a copy of the GNU Lesser General Public
Packit b099d7
 * License along with these librararies and programs; if not, write
Packit b099d7
 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
Packit b099d7
 * Floor, Boston, MA 02110-1301 USA
Packit b099d7
 * 
Packit b099d7
 */
Packit b099d7
/*
Packit b099d7
 * HISTORY
Packit b099d7
 */
Packit b099d7
Packit b099d7
#ifdef HAVE_CONFIG_H
Packit b099d7
#include <config.h>
Packit b099d7
#endif
Packit b099d7
Packit b099d7
Packit b099d7
#include "XmI.h"
Packit b099d7
#include "DrawI.h"
Packit b099d7
Packit b099d7
/****************************_XmDrawHighlight***************************
Packit b099d7
 *
Packit b099d7
 * This function modifies the given gc, which therefore needs to be created
Packit b099d7
 *   using XCreateGC or XtAllocateGC.
Packit b099d7
 *
Packit b099d7
 ***************************************************************************/
Packit b099d7
Packit b099d7
void _XmDrawHighlight(Display *display, Drawable d, 
Packit b099d7
			  GC gc, 
Packit b099d7
#if NeedWidePrototypes
Packit b099d7
                          int x, int y, 
Packit b099d7
			  int width, int height,
Packit b099d7
			  int highlight_thickness,
Packit b099d7
#else
Packit b099d7
                          Position x, Position y, 
Packit b099d7
			  Dimension width, Dimension height,
Packit b099d7
			  Dimension highlight_thickness,
Packit b099d7
#endif /* NeedWidePrototypes */
Packit b099d7
                   int line_style)
Packit b099d7
{
Packit b099d7
   XSegment seg[4];
Packit b099d7
   register Dimension half_hl = highlight_thickness/2 ;
Packit b099d7
   register Dimension cor = highlight_thickness % 2 ;
Packit b099d7
   XGCValues gcvalues;
Packit b099d7
Packit b099d7
   if (!d || !highlight_thickness || !width || !height) return ;
Packit b099d7
Packit b099d7
   /* the XmList dash case relies on this particular order of X segments */
Packit b099d7
   
Packit b099d7
   seg[0].x1 = seg[2].x1 = x ;
Packit b099d7
   seg[0].y1 = seg[0].y2 = y + half_hl ;
Packit b099d7
   seg[0].x2 = x + width - highlight_thickness ;
Packit b099d7
   seg[1].x1 = seg[1].x2 = x + width - half_hl - cor;
Packit b099d7
   seg[1].y1 = seg[3].y1 = y ;
Packit b099d7
   seg[3].y2 = y + height - half_hl;
Packit b099d7
   seg[2].y1 = seg[2].y2 = y + height - half_hl - cor;
Packit b099d7
   seg[3].x1 = seg[3].x2 = x + half_hl ;
Packit b099d7
   seg[2].x2 = x + width ;
Packit b099d7
   seg[1].y2 = y + height ;
Packit b099d7
Packit b099d7
   /* first save the current values we want to change */
Packit b099d7
   XGetGCValues(display, gc,
Packit b099d7
		GCLineWidth|GCLineStyle|GCCapStyle|GCJoinStyle,
Packit b099d7
		&gcvalues);
Packit b099d7
   /* change them and draw the lines */
Packit b099d7
   XSetLineAttributes(display, gc,  highlight_thickness, line_style, 
Packit b099d7
		      CapButt, JoinMiter);
Packit b099d7
   XDrawSegments (display, d, gc, seg, 4);
Packit b099d7
Packit b099d7
   /* put them back */
Packit b099d7
   XSetLineAttributes(display, gc,  
Packit b099d7
		      gcvalues.line_width, gcvalues.line_style, 
Packit b099d7
		      gcvalues.cap_style, gcvalues.join_style);
Packit b099d7
  
Packit b099d7
   /** note that the above is a hack, a read-only GC shoudl not 
Packit b099d7
     be modified, period */
Packit b099d7
}