Esempio n. 1
0
File: List.c Progetto: aosm/X11
/*
 * Implementation
 */
static void
GetGCs(Widget w)
{
    XGCValues	values;
    ListWidget lw = (ListWidget)w;

    values.foreground	= lw->list.foreground;
    values.font		= lw->list.font->fid;

    if (lw->simple.international == True)
	lw->list.normgc = XtAllocateGC(w, 0, GCForeground, &values, GCFont, 0);
    else
	lw->list.normgc = XtGetGC(w, GCForeground | GCFont, &values);

    values.foreground	= lw->core.background_pixel;

    if (lw->simple.international == True)
	lw->list.revgc = XtAllocateGC(w, 0, GCForeground, &values, GCFont, 0);
    else
	lw->list.revgc = XtGetGC(w, GCForeground | GCFont, &values);

    values.tile       = XmuCreateStippledPixmap(XtScreen(w), 
						lw->list.foreground,
						lw->core.background_pixel,
						lw->core.depth);
    values.fill_style = FillTiled;

    if (lw->simple.international == True)
	lw->list.graygc = XtAllocateGC(w, 0, GCTile | GCFillStyle,
				       &values, GCFont, 0);
    else
	lw->list.graygc = XtGetGC(w, GCFont | GCTile | GCFillStyle, &values);
}
Esempio n. 2
0
File: Logo.c Progetto: aosm/X11
static void 
create_gcs(LogoWidget w)
{
    XGCValues v;

#ifdef XRENDER
    w->logo.fgpixel = w->logo.fg.pixel;
#endif

    v.foreground = w->logo.fgpixel;
    w->logo.foreGC = XtGetGC ((Widget) w, GCForeground, &v);
    v.foreground = w->core.background_pixel;
    w->logo.backGC = XtGetGC ((Widget) w, GCForeground, &v);
}
Esempio n. 3
0
/*
 * Function:
 *	CreateGC
 *
 * Parameters:
 *	w     - strip chart widget
 *	which - GC's to create
 *
 * Description:
 *	Creates the GC's
 */
static void
CreateGC(StripChartWidget w, unsigned int which)
{
    XGCValues myXGCV;

    if (which & FOREGROUND) {
	myXGCV.foreground = w->strip_chart.fgpixel;
	w->strip_chart.fgGC = XtGetGC((Widget)w, GCForeground, &myXGCV);
    }

    if (which & HIGHLIGHT) {
	myXGCV.foreground = w->strip_chart.hipixel;
	w->strip_chart.hiGC = XtGetGC((Widget)w, GCForeground, &myXGCV);
    }
}
Esempio n. 4
0
static Boolean
SetValues(
          Widget cw,
          Widget WXUNUSED(rw),
          Widget nw,
          ArgList WXUNUSED(args),
          Cardinal *WXUNUSED(num_args) )
{
    XmGaugeWidget cgw = (XmGaugeWidget)cw;
    XmGaugeWidget ngw = (XmGaugeWidget)nw;

    Boolean redraw = False;
    if(cgw->primitive.foreground != ngw->primitive.foreground) {
        XGCValues values;

        redraw = True;
        XtReleaseGC(nw, ngw->gauge.gc);
        values.foreground = ngw->primitive.foreground;
        ngw->gauge.gc = XtGetGC(nw, GCForeground, &values);
    }
    if(cgw->gauge.value != ngw->gauge.value) {
        redraw = True;
    }
    return redraw;
}
Esempio n. 5
0
static void
GetGrayGC(LabelWidget lw)
{
    XGCValues	values;

    values.foreground = lw->label.foreground;
    values.background = lw->core.background_pixel;
    values.font	      = lw->label.font->fid;
    values.fill_style = FillTiled;
    values.tile       = XmuCreateStippledPixmap(XtScreen((Widget)lw),
						lw->label.foreground,
						lw->core.background_pixel,
						lw->core.depth);
    values.graphics_exposures = False;

    lw->label.stipple = values.tile;
    if (lw->simple.international == True)
	/* Since Xmb/wcDrawString eats the font, I must use XtAllocateGC */
	lw->label.gray_GC = XtAllocateGC((Widget)lw, 0,
					 GCForeground | GCBackground |
					 GCTile | GCFillStyle |
					 GCGraphicsExposures,
					 &values, GCFont, 0);
	else
	    lw->label.gray_GC = XtGetGC((Widget)lw,
					GCForeground | GCBackground |
					GCFont | GCTile | GCFillStyle |
					GCGraphicsExposures,
					&values);
}
Esempio n. 6
0
void draw_pixmap(Widget w, XtPointer client_data, XtPointer call_data)
{
    GC gc; XGCValues vals;
    XpmImage *xpmImage = (XpmImage*) client_data;
//    Pixmap pixmap;
    XImage *image, *si;

    gc=XtGetGC(w, 0 ,&vals);


    XpmCreateImageFromXpmImage(XtDisplay(w), xpmImage, &image, &si, NULL);

    XPutImage(XtDisplay(w), XtWindow(w), gc, image, 0, 0, 0, 0,
              xpmImage->width, xpmImage->height);

    XDestroyImage(image);

//    XpmCreatePixmapFromXpmImage(XtDisplay(w), XtWindow(w),
//                                xpmImage, &pixmap, NULL, NULL);
//    XCopyArea(XtDisplay(w),pixmap,XtWindow(w), gc, 0, 0,
//              xpmImage->width, xpmImage->height, 0, 0);
//    XFreePixmap(XtDisplay(w),pixmap);

    XtReleaseGC(w, gc);

}
Esempio n. 7
0
static GC _gadgetParentBottomShadowGC(XmLabelGadget _label)
{
    XGCValues gcValues;
    XtGCMask	mask;
    XFontStruct *fs;
    XmManagerWidget parent = (XmManagerWidget)XtParent(_label);

    mask = GCForeground | GCBackground;
    gcValues.foreground = MANAGER(parent).bottom_shadow_color;
    gcValues.background = MANAGER(parent).foreground;

    if ((MANAGER(parent).bottom_shadow_pixmap != None) &&
	(MANAGER(parent).bottom_shadow_pixmap != XmUNSPECIFIED_PIXMAP))
    {
	mask |= GCFillStyle | GCTile;
	gcValues.fill_style = FillTiled;
	gcValues.tile = MANAGER(parent).bottom_shadow_pixmap;
    }

    _XmFontListGetDefaultFont(LABEL(_label).font, &fs);
    if (fs != 0)
    {
	mask |= GCFont;
	gcValues.font = fs->fid;
    }

    return XtGetGC ((Widget)parent,  mask, &gcValues);
}
Esempio n. 8
0
static GC _bottomShadowGC(XmLabelWidget _label)
{
    XGCValues gcValues;
    XtGCMask	mask;
    XFontStruct *fs;

    mask = GCForeground | GCBackground;
    gcValues.foreground = PRIM(_label).bottom_shadow_color;
    gcValues.background = PRIM(_label).foreground;

    if ((PRIM(_label).bottom_shadow_pixmap != None) &&
	(PRIM(_label).bottom_shadow_pixmap != XmUNSPECIFIED_PIXMAP))
    {
	mask |= GCFillStyle | GCTile;
	gcValues.fill_style = FillTiled;
	gcValues.tile = PRIM(_label).bottom_shadow_pixmap;
    }

    _XmFontListGetDefaultFont(LABEL(_label).font, &fs);
    if (fs != 0)
    {
	mask |= GCFont;
	gcValues.font = fs->fid;
    }

    return XtGetGC ((Widget)_label,  mask, &gcValues);
}
Esempio n. 9
0
static void AddObject (  GraphicsObject *object )
{
    DrawingFunction  temp;
    
    XGCValues values;
    
   /* 
    * Check for space.
    */
    
    if ( nextSlot >= MAXOBJECTS )
    {
        fprintf ( stderr, "Warning: Display List is full\n" );
        return;
    }
    
   /*
    * Copy the information into the next available slot
    * in the display list.
    */

    displayList[nextSlot].x1         = object->x1;
    displayList[nextSlot].y1         = object->y1;
    displayList[nextSlot].x2         = object->x2;
    displayList[nextSlot].y2         = object->y2;
    displayList[nextSlot].figureType = object->figureType;
    displayList[nextSlot].foreground = object->foreground;
   /*
    * Get a GC for this color. Using XtGetGC() ensures that
    * only as many GCÕs will be created as there are colors.
    * Objects with the same color will share a GC.
    */

    values.foreground = object->foreground;
    values.background = background;
    
    displayList[nextSlot].gc = XtGetGC ( canvas, 
                                         GCBackground | GCForeground,
                                         &values );
    
    displayList[nextSlot].func = TypeToFunction ( object->figureType );
    
  /*
   * For all figures expect a line, permantly correct the bounding
   * box to allowing easy picking. For a line, the coordinates
   * canot be changed wihtout changing the appearance of the figure.
   */

    if (object->figureType != LINE )
        FixDataOrdering ( &displayList[nextSlot].x1, 
                          &displayList[nextSlot].y1,
                          &displayList[nextSlot].x2,
                          &displayList[nextSlot].y2 );
   /*
    * Increment the next position index.
    */
    
    nextSlot++;
}
Esempio n. 10
0
static GC get_gc(Widget w, Pixel fg)
{
  XGCValues     values;
  TRACE(2,"background fill color: %x", fg );

  values.foreground   = fg;
  return XtGetGC(w, GCForeground, &values);
}
Esempio n. 11
0
/* ARGSUSED */
static void Initialize (Widget greq, Widget gnew,
			ArgList args, Cardinal *num_args)
{
    ClockWidget w = (ClockWidget)gnew;
    XtGCMask	valuemask;
    XGCValues	myXGCV;
    int shape_event_base, shape_error_base;

    valuemask = GCForeground;

    if (w->clock.transparent)
    {
	;
    }
    else
    {
    	myXGCV.foreground = w->clock.minute;
    	w->clock.minuteGC = XtGetGC(gnew, valuemask, &myXGCV);

    	myXGCV.foreground = w->clock.hour;
    	w->clock.hourGC = XtGetGC(gnew, valuemask, &myXGCV);

    	myXGCV.foreground = w->clock.jewel;
    	w->clock.jewelGC = XtGetGC(gnew, valuemask, &myXGCV);

    	myXGCV.foreground = w->core.background_pixel;
    	w->clock.eraseGC = XtGetGC(gnew, valuemask, &myXGCV);
    }

    /* wait for Realize to add the timeout */
    w->clock.interval_id = 0;

    if (w->clock.shape_window && !XShapeQueryExtension (XtDisplay (w),
							&shape_event_base,
							&shape_error_base))
    w->clock.shape_window = False;
    w->clock.shape_mask = 0;
    w->clock.shapeGC = NULL;
    w->clock.shape_width = 0;
    w->clock.shape_height = 0;
    w->clock.polys_valid = 0;
}
Esempio n. 12
0
int UIInquireVector(Widget widget, XEvent *event, int x0, int y0, int *x1, int *y1) {
    XSetWindowAttributes xswa;
    XGCValues xgcv;
    static GC gc = (GC) NULL;
    static Cursor cursor[2] = {(Cursor) NULL, (Cursor) NULL};
    static int inLoop, cont, ret;

    if (cursor[0] == (Cursor) NULL) cursor[0] = XCreateFontCursor(XtDisplay(widget), XC_hand2);
    if (cursor[1] == (Cursor) NULL) cursor[1] = XCreateFontCursor(XtDisplay(widget), XC_top_left_arrow);
    if (gc == (GC) NULL) {
        xgcv.function = GXinvert;
        gc = XtGetGC(widget, GCFunction, &xgcv);
    }
    if (inLoop == false) {
        if (event->type != ButtonPress) return (false);
        inLoop = cont = true;
        ret = false;
        xswa.cursor = cursor[0];
        XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
        *x1 = event->xbutton.x;
        *y1 = event->xbutton.y;
        XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
        do {
            XtAppNextEvent(UIApplicationContext(), event);
            XtDispatchEvent(event);
        } while (cont);
        XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
        xswa.cursor = cursor[1];
        XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
        inLoop = false;
        return (ret);
    }
    else
        switch (event->type) {
            case ButtonRelease:
                xswa.cursor = cursor[1];
                XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
                ret = true;
                cont = false;
                break;
            case MotionNotify:
                XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
                *x1 = event->xmotion.x;
                *y1 = event->xmotion.y;
                XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
                break;
            case LeaveNotify:
                ret = false;
                cont = false;
                break;
        }
    return (false);
}
Esempio n. 13
0
static void
Initialize(Widget WXUNUSED(req), Widget new_w, ArgList WXUNUSED(args), Cardinal *WXUNUSED(num_args ))
{
    XmGaugeWidget gw = (XmGaugeWidget)new_w;
#define THIS gw->gauge
    XGCValues values;

    values.foreground = gw->primitive.foreground;
    THIS.gc = XtGetGC(new_w, GCForeground, &values);

#undef THIS

}
Esempio n. 14
0
/******************************************************************************
 *
 *  CreateGC:
 *      Called by Initialize and by SetValues.
 *
 *****************************************************************************/
static void 
CreateGC (
        Widget w
         )
{
 ExmSimpleWidget sw = (ExmSimpleWidget)w;
 XGCValues   values;
 XtGCMask    valueMask;
 Arg         args[2];
 Pixmap      insensitiveStippleBitmap;

 /* This function creates two GC's: one to render a sensitive widget
    and the other to render an insensitive widget. */


 /* First, create the sensitive GC (named normal_GC). */ 
   valueMask = GCForeground | GCBackground | GCGraphicsExposures;
   values.foreground = sw->primitive.foreground;
   values.background = sw->core.background_pixel;
   values.graphics_exposures = False;
   sw->simple.normal_gc = XtGetGC ((Widget)sw, valueMask, &values);

 /* Next, create the insensitive GC.  This GC will share the same
    foreground, background, and graphics exposures as the sensitive
    GC, but will hold a different fill style and stipple pattern. 
    The stipple pattern is stored in the XmNinsensitiveStippleBitmap
    resource of XmScreen. */
   valueMask |= GCFillStyle | GCStipple;
   values.fill_style = FillStippled;

 /* Gather the Motif-appropriate insensitive stipple bitmap. */
   XtSetArg(args[0], XmNinsensitiveStippleBitmap, &insensitiveStippleBitmap); 
   XtGetValues(XmGetXmScreen(XtScreen(w)), args, 1);
   values.stipple = insensitiveStippleBitmap;

   sw->simple.insensitive_gc = XtGetGC((Widget)sw, valueMask, &values);
}
Esempio n. 15
0
void InitGraphics ( Widget w )
{
    XGCValues values;

   /* 
    * Remember the given widget for use by other functions.
    * Retrieve the display and colormap for later use.
    */

    canvas  = w; 
    display = XtDisplay ( canvas );
    XtVaGetValues ( canvas, XmNcolormap, &colormap, NULL );
    
   /*
    * Register a callback to redraw the display list when the
    * window is exposed, and event handlers to handle adding
    * new objects to the display list interactively
    */

    XtAddCallback ( canvas, XmNexposeCallback, Redisplay, NULL );
    XtAddEventHandler ( canvas, ButtonPressMask, FALSE,
                        StartRubberBand, NULL );
    XtAddEventHandler ( canvas, ButtonMotionMask, FALSE,
                        TrackRubberBand, NULL );
    XtAddEventHandler ( canvas, ButtonReleaseMask, FALSE,
                        EndRubberBand, NULL );
   /*
    * Get the colors of the canvas. 
    */
    
    XtVaGetValues ( canvas, 
                    XmNforeground, &currentForeground,
                    XmNbackground, &background,
                    NULL );
   /*
    * Fill in the values structure
    */  
    
    values.foreground = currentForeground ^ background;
    values.function   = GXxor;
    
   /*
    * Set the rubber band gc to use XOR mode. 
    */
    
    xorGC =  XtGetGC ( canvas, 
                       GCForeground | GCFunction, 
                       &values );
}    
Esempio n. 16
0
File: Tree.c Progetto: aosm/X11libs
static GC
get_tree_gc(TreeWidget w)
{
    XtGCMask valuemask = GCBackground | GCForeground;
    XGCValues values;

    values.background = w->core.background_pixel;
    values.foreground = w->tree.foreground;
    if (w->tree.line_width != 0) {
	valuemask |= GCLineWidth;
	values.line_width = w->tree.line_width;
    }

    return XtGetGC ((Widget) w, valuemask, &values);
}
Esempio n. 17
0
static GC CreateGC(int width, char *fg, char *bg, int style)
{
    XtGCMask value_mask = GCLineWidth | GCLineStyle | GCForeground
      | GCBackground | GCFunction | GCPlaneMask;
    XGCValues gc_values;

    gc_values.plane_mask = AllPlanes;
    gc_values.line_width = width;
    gc_values.line_style = style;
    gc_values.function = GXcopy;

    gc_values.foreground = MakeColor(fg);
    gc_values.background = MakeColor(bg);

    return XtGetGC(evalGraphShell, value_mask, &gc_values);
}
Esempio n. 18
0
static GC CreateGC(Widget w)
{
   XGCValues values;

   XtVaGetValues(w, XmNforeground, &values.foreground, 
                 XmNbackground, &values.background, NULL);
   // Set the fg to the XOR of the fg and bg, so if it is
   // XOR'ed with bg, the result will be fg and vice-versa.
   // This effectively achieves inverse video for the line.
    
   values.foreground = values.foreground ^ values.background;
   // Set the rubber band gc to use XOR mode and draw a dashed line.

   values.function   = GXxor;
   values.subwindow_mode  = IncludeInferiors;
   return (XtGetGC(w, GCForeground | GCBackground |
                   GCSubwindowMode | GCFunction, &values));
}
Esempio n. 19
0
/*****
* Name: 		checkGC
* Return Type: 	void
* Description: 	creates a GC for us to use;
* In: 
*	BALLOON:	XmBalloonWidget id;
* Returns:
*	nothing.
*****/
static void
checkGC(BALLOON)
{
	XGCValues xgc;

	xgc.foreground = ATTR(foreground);
	xgc.background = balloon->core.background_pixel;
	xgc.fill_style = FillSolid; 

#if XtSpecificationRelease < 5	
	xgc.font = ATTR(font->fid); 
#endif

	if(ATTR(gc))
		XtReleaseGC((Widget)balloon, ATTR(gc));
	ATTR(gc) = XtGetGC((Widget)balloon,
		GCForeground|GCBackground|GCFillStyle, &xgc);
}
Esempio n. 20
0
static void 
ResetXorGC(XmPannerWidget pw)		/* used when resources change */
{
    if (XmPanner_xor_gc(pw)) 
	XtReleaseGC ((Widget) pw, XmPanner_xor_gc(pw));

    if (XmPanner_rubber_band(pw)) {
	XtGCMask valuemask = (GCForeground | GCFunction);
	XGCValues values;

	values.foreground = (pw->primitive.foreground ^
			     pw->core.background_pixel);
	values.function = GXxor;
	XmPanner_xor_gc(pw) = XtGetGC ((Widget) pw, valuemask, &values);
    } else {
	XmPanner_xor_gc(pw) = NULL;
    }
}
Esempio n. 21
0
void CGWindow::setupGC()
{
  int foreground,background;
  XGCValues vals;
  Arg al[10];
  int ac;
  
  /* get the current fg and bg colors. */
  ac=0;
  XtSetArg(al[ac],XmNforeground,&foreground); ac++;
  XtSetArg(al[ac],XmNbackground,&background); ac++;
  XtGetValues(m_DrawingArea,al,ac);

  /* create the gc. */
  vals.foreground = foreground;
  vals.background = background;
  m_GC=XtGetGC(m_DrawingArea,GCForeground | GCBackground,&vals);
}
Esempio n. 22
0
static void
CreateGC (Widget w)
{
    ScrollbarWidget sbw = (ScrollbarWidget) w;
    XGCValues gcValues;
    XtGCMask mask;
    unsigned int depth = 1;

    if (sbw->scrollbar.thumb == XtUnspecifiedPixmap) {
        sbw->scrollbar.thumb = XmuCreateStippledPixmap (XtScreen(w),
					(Pixel) 1, (Pixel) 0, depth);
    } else if (sbw->scrollbar.thumb != None) {
	Window root;
	int x, y;
	unsigned int width, height, bw;
	if (XGetGeometry (XtDisplay(w), sbw->scrollbar.thumb, &root, &x, &y,
			 &width, &height, &bw, &depth) == 0) {
	    XtAppError (XtWidgetToApplicationContext (w),
	       "Scrollbar Widget: Could not get geometry of thumb pixmap.");
	}
    }

    gcValues.foreground = sbw->scrollbar.foreground;
    gcValues.background = sbw->core.background_pixel;
    mask = GCForeground | GCBackground;

    if (sbw->scrollbar.thumb != None) {
	if (depth == 1) {
	    gcValues.fill_style = FillOpaqueStippled;
	    gcValues.stipple = sbw->scrollbar.thumb;
	    mask |= GCFillStyle | GCStipple;
	}
	else {
	    gcValues.fill_style = FillTiled;
	    gcValues.tile = sbw->scrollbar.thumb;
	    mask |= GCFillStyle | GCTile;
	}
    }
    /* the creation should be non-caching, because */
    /* we now set and clear clip masks on the gc returned */
    sbw->scrollbar.gc = XtGetGC (w, mask, &gcValues);
}
Esempio n. 23
0
static void
GetNormalGC(LabelWidget lw)
{
    XGCValues	values;

    values.foreground	= lw->label.foreground;
    values.background	= lw->core.background_pixel;
    values.font		= lw->label.font->fid;
    values.graphics_exposures = False;

    if (lw->simple.international == True)
    /* Since Xmb/wcDrawString eats the font, I must use XtAllocateGC */
	lw->label.normal_GC = XtAllocateGC((Widget)lw, 0,
					   GCForeground | GCBackground |
					   GCGraphicsExposures,
					   &values, GCFont, 0);
    else
	lw->label.normal_GC = XtGetGC((Widget)lw,
				      GCForeground | GCBackground | GCFont |
				      GCGraphicsExposures, &values);
}
static void
CreateGC(Widget w)
{
    ScrollbarWidget sbw = (ScrollbarWidget)w;
    XGCValues gcValues;
    XtGCMask mask;
    unsigned int depth = 1;

    if (sbw->scrollbar.thumb == XtUnspecifiedPixmap)
	sbw->scrollbar.thumb = XmuCreateStippledPixmap(XtScreen(w),
						       (Pixel)1, (Pixel)0,
						       depth);
    else if (sbw->scrollbar.thumb != None) {
	Window root;
	int x, y;
	unsigned int width, height, bw;

	XGetGeometry(XtDisplay(w), sbw->scrollbar.thumb, &root, &x, &y,
		     &width, &height, &bw, &depth);
    }

    gcValues.foreground = sbw->scrollbar.foreground;
    gcValues.background = sbw->core.background_pixel;
    mask = GCForeground | GCBackground;

    if (sbw->scrollbar.thumb != None) {
	if (depth == 1) {
	    gcValues.fill_style = FillOpaqueStippled;
	    gcValues.stipple = sbw->scrollbar.thumb;
	    mask |= GCFillStyle | GCStipple;
	}
	else {
	    gcValues.fill_style = FillTiled;
	    gcValues.tile = sbw->scrollbar.thumb;
	    mask |= GCFillStyle | GCTile;
	}
    }
    sbw->scrollbar.gc = XtGetGC(w, mask, &gcValues);
}
Esempio n. 25
0
File: Command.c Progetto: aosm/X11
/*
 * Implementation
 */
static GC 
Get_GC(CommandWidget cbw, Pixel fg, Pixel bg)
{
    XGCValues	values;
  
    values.foreground	= fg;
    values.background	= bg;
    values.font		= cbw->label.font->fid;
    values.cap_style	= CapProjecting;
  
    if (cbw->command.highlight_thickness > 1)
	values.line_width = cbw->command.highlight_thickness;
    else 
	values.line_width = 0;
  
    if (cbw->simple.international == True)
	return (XtAllocateGC((Widget)cbw, 0,
			     GCForeground | GCBackground | GCLineWidth |
			     GCCapStyle, &values, GCFont, 0));
    else
	return (XtGetGC((Widget)cbw,
			GCForeground | GCBackground | GCFont | GCLineWidth |
			GCCapStyle, &values));
}
Esempio n. 26
0
/*-------------------------------------------------------------*/
void setup_display(Widget w)
{
    int i,j, cindex;
    int theScreen;
    XColor *colors = NULL;
    XGCValues     xgcv;
    Colormap      theColormap;
    XVisualInfo   *p_visinfo;
    XVisualInfo   *vis_list;
    XVisualInfo   vis_template;
    Widget *list_w = NULL;    /* List of widgets with its own colormap */

    theScreen = DefaultScreen(XtDisplay(w));
    vis_template.screen = theScreen;
    vis_list = XGetVisualInfo(XtDisplay(w),VisualScreenMask, &vis_template, &j);
    for (i=0, p_visinfo = vis_list; i<j;i++, p_visinfo++)
    {
    if(p_visinfo->class == PseudoColor && p_visinfo->depth == 8)
    { theVisual = p_visinfo->visual;
      vis_depth = p_visinfo->depth;
      break;
    }
    }

    theVisual = DefaultVisual(XtDisplay(w),theScreen);
    vis_depth = 8;  
    /* Create the XColor entries for the colormap */
    if((colors = (XColor *)calloc(COLORMAP_SIZE, sizeof(XColor))) == NULL) {
	fprintf(stderr, "No memory for setting up colormap\n");
	exit(1);
    }

    /* Set up the color cells to greyscale */
    for(cindex = 0; cindex < COLORMAP_SIZE; cindex++) {
	colors[cindex].red   = CSCALE * cindex;
	colors[cindex].green = CSCALE * cindex;
	colors[cindex].blue  = CSCALE * cindex;
	colors[cindex].pixel = cindex;
	colors[cindex].flags = DoRed | DoGreen | DoBlue;
    }

    /* Create the colormap */
    theColormap = XCreateColormap(XtDisplay(top_level), RootWindow(XtDisplay(top_level), theScreen),
				 theVisual, AllocAll);

    /* Store the colors into the colormap */
    XStoreColors(XtDisplay(top_level), theColormap, colors, COLORMAP_SIZE); 

    /* Set the background and foreground colors before free(colors) */
    bg = colors[0].pixel;
    fg = colors[255].pixel; 

    ysmap=XCopyColormapAndFree(XtDisplay(top_level), theColormap);

    /* Now we can release the memory used by the colors   */
    /* because the X server already has this information. */
    free(colors);

    /* Set background, foreground, visual_depth and colormap for draw_1 */
    argcount = 0;
    XtSetArg(args[argcount], XmNforeground, fg         ); argcount++;
    XtSetArg(args[argcount], XmNbackground, bg         ); argcount++;
    XtSetArg(args[argcount], XmNdepth     , vis_depth  ); argcount++;
    XtSetArg(args[argcount], XmNcolormap  , theColormap); argcount++; 
    XtSetValues(draw_1, args, argcount);

    /* Set background, foreground, visual_depth and colormap for draw_2 */
    argcount = 0;
    XtSetArg(args[argcount], XmNforeground, fg         ); argcount++;
    XtSetArg(args[argcount], XmNbackground, bg         ); argcount++;
    XtSetArg(args[argcount], XmNdepth     , vis_depth  ); argcount++;
    XtSetArg(args[argcount], XmNcolormap  , theColormap); argcount++; 
    XtSetValues(draw_2, args, argcount);
    
    /* Set the WM_COLORMAP_WINDOWS property so that the Motif */ 
    /* window manager knows about the windows that have their */
    /* own colormap.                                          */
    if(theColormap != DefaultColormap(XtDisplay(top_level), theScreen)) {
	list_w = (Widget *) malloc(2*sizeof(Widget));
	list_w[0] = draw_1;
	list_w[1] = draw_2;
	XtSetWMColormapWindows(top_level, list_w, (Cardinal) 2);
    } 
    
    /* Define a GC for both drawing areas with these colors */
    xgcv.foreground = fg;
    xgcv.background = bg;
    image_gc_1 = XCreateGC(XtDisplay(w), XtWindow(draw_1),
				(GCForeground | GCBackground), &xgcv);
    image_gc_2 = XCreateGC(XtDisplay(w), XtWindow(draw_2),
				(GCForeground | GCBackground), &xgcv);

    /* Define a GC to be used in editing image operations*/
    xgcv.foreground = fg ^ bg;
    xgcv.background = bg;
    xgcv.function = GXxor;
    xorGC = XtGetGC(draw_1, GCForeground | GCBackground | GCFunction, &xgcv);

    xgcv.foreground = fg;
    xgcv.background = bg;
    theGC = XtGetGC(draw_1, GCForeground | GCBackground, &xgcv);
}
Esempio n. 27
0
/*
 * Procedure Initialize() is called during the widget creation
 * process.  Initialize() load fonts and calculates window geometry.
 * The request parameter is filled in by parents to this widget.  The
 * wnew parameter is the request parameter plus data filled in by this
 * widget. All changes should be done to the wnew parameter.
 */
static void Initialize(AngbandWidget request, AngbandWidget wnew)
{
	Display *dpy = XtDisplay(wnew);

	int depth = DefaultDepthOfScreen(XtScreen((Widget) wnew));

	XGCValues gcv;
	TopLevelShellWidget parent =
	(TopLevelShellWidget)XtParent((Widget) wnew);
	int i;

	/* Default background pixel */
	unsigned long bg = create_pixel(dpy,
	                                angband_color_table[0][1],
	                                angband_color_table[0][2],
	                                angband_color_table[0][3]);

	/* Default foreground pixel */
	unsigned long fg = create_pixel(dpy,
	                                angband_color_table[1][1],
	                                angband_color_table[1][2],
	                                angband_color_table[1][3]);

	/* Fix the background color */
	wnew->core.background_pixel = bg;

	/* Get some information about the font */
	wnew->angband.fnt = getFont(wnew, wnew->angband.font, TRUE);
	wnew->angband.fontheight = wnew->angband.fnt->ascent +
		wnew->angband.fnt->descent;
	wnew->angband.fontwidth = wnew->angband.fnt->max_bounds.width;
	wnew->angband.fontascent = wnew->angband.fnt->ascent;

	/* Create and initialize the graphics contexts */ /* GXset? */
	gcv.font = wnew->angband.fnt->fid;
	gcv.graphics_exposures = FALSE;
	gcv.background = bg;

	for (i = 0; i < NUM_COLORS; i++)
	{
		unsigned long pixel;

		/* Acquire Angband colors */
		wnew->angband.color[i][0] = angband_color_table[i][0];
		wnew->angband.color[i][1] = angband_color_table[i][1];
		wnew->angband.color[i][2] = angband_color_table[i][2];
		wnew->angband.color[i][3] = angband_color_table[i][3];

		if (depth > 1)
		{
			/* Create pixel */
			pixel = create_pixel(dpy,
			                     wnew->angband.color[i][1],
			                     wnew->angband.color[i][2],
			                     wnew->angband.color[i][3]);
		}
		else
		{
			/* Use background or foreground */
			pixel = ((i == 0) ? bg : fg);
		}

		gcv.foreground = pixel;

		/* Copy */
		gcv.function = 3;

		wnew->angband.gc[i] = XtGetGC((Widget)wnew,
		                              (GCFont | GCForeground | GCFunction |
		                               GCBackground | GCGraphicsExposures),
		                              &gcv);
	}

	/* Create a special GC for highlighting */
	gcv.foreground = (BlackPixelOfScreen(XtScreen((Widget)wnew)) ^
	                  WhitePixelOfScreen(XtScreen((Widget)wnew)));
	gcv.background = 0;

	gcv.function = GXxor;
	wnew->angband.gc[COLOR_XOR] = XtGetGC((Widget)wnew,
	                                      (GCFunction | GCForeground | GCBackground |
	                                       GCGraphicsExposures),
	                                      &gcv);

	/* Calculate window geometry */
	wnew->core.height = (wnew->angband.start_rows * wnew->angband.fontheight +
	                     2 * wnew->angband.internal_border);
	wnew->core.width = (wnew->angband.start_columns * wnew->angband.fontwidth +
	                    2 * wnew->angband.internal_border);

	/* We need to be able to resize the Widget if the user wants to */
	/* change font on the fly! */
	parent->shell.allow_shell_resize = TRUE;

	/* Calculates all the size hints */
	calculateSizeHints(wnew);
}
Esempio n. 28
0
static void StartRubberBand ( Widget    w,
                              XtPointer clientData,
                              XEvent   *event,
                              Boolean  *flag )
{

   /*
    * Ignore any events other than a button press for
    * mouse button one.
    */

    if ( event->xbutton.button != Button1 )
       return;
   
    if ( currentFunction )
    {

       /*
        * If there is a current drawing function, call it to
        * start positioning the new figure.
        */

        XGCValues values;
        
       /*
        * Get a GC for the current colors 
        */
        
        values.foreground = currentForeground;
        values.background = background;
        
        currentGC = XtGetGC ( w, 
                              GCBackground | GCForeground,
                              &values );
        
       /*
        * Store the starting point and draw the initial figure.
        */
        
        lastX = startX = event->xbutton.x;
        lastY = startY = event->xbutton.y;
        
        ( * ( currentFunction ) ) ( XtWindow ( w ), xorGC,
                                    startX, startY, 
                                    lastX, lastY );
    }
    else if ( !currentFunction && event->xbutton.button == Button1 )
    {
       /*
        * If there is no current function, treat Button1
        * as a pointer and find the graphics object the mouse
        * cursor is pointing to.
        */

        lastX = startX = event->xbutton.x;
        lastY = startY = event->xbutton.y;
        
        currentObject = PickObject ( event->xbutton.x,
                                     event->xbutton.y );
        if ( currentObject )
        {
           /*
            * If an object was found, any mouse motion will move
            * the object. Get a new graphics context whose colors
            * match the colors of the current object.
            */

            XGCValues values;
            
            XtReleaseGC ( w, xorGC );
            values.foreground = currentObject->foreground ^ 
                                background;
            values.function   = GXxor;
            
            /*
             * Change the color of the rubber band gc 
             */
            
            xorGC =  XtGetGC ( w,  GCForeground | GCFunction, 
                                   &values );
        }
    }
}
Esempio n. 29
0
void
XmLDrawnButtonSetType(Widget w,
		      int drawnType,
		      int drawnDir)
	{
	XmLDrawnBData *dd;
	XmDrawnButtonWidget b;
	XmString str;
	XmFontList fontlist;
	XGCValues values;
	XtGCMask mask;
	Dimension width, height, dim;
	Dimension highlightThickness, shadowThickness;
	Dimension marginWidth, marginHeight;
	Dimension marginTop, marginBottom, marginLeft, marginRight;

	if (!XtIsSubclass(w, xmDrawnButtonWidgetClass))
		{
		XmLWarning(w, "DrawnButtonSetType() - not an XmDrawnButton");
		return;
		}
	XtVaSetValues(w,
		XmNpushButtonEnabled, True,
		NULL);
	XtRemoveAllCallbacks(w, XmNexposeCallback);
	XtRemoveAllCallbacks(w, XmNresizeCallback);
	if (drawnType == XmDRAWNB_STRING && drawnDir == XmDRAWNB_RIGHT)
		{
		XtVaSetValues(w,
			XmNlabelType, XmSTRING,
			NULL);
		return;
		}
	b = (XmDrawnButtonWidget)w;
	dd = (XmLDrawnBData *)malloc(sizeof(XmLDrawnBData));
	dd->type = drawnType;
	dd->dir = drawnDir;
	dd->gc = 0;
	if (dd->type == XmDRAWNB_STRING)
		{
		XtVaGetValues(w,
			XmNlabelString, &str,
			XmNfontList, &fontlist,
			XmNhighlightThickness, &highlightThickness,
			XmNshadowThickness, &shadowThickness,
			XmNmarginHeight, &marginHeight,
			XmNmarginWidth, &marginWidth,
			XmNmarginTop, &marginTop,
			XmNmarginBottom, &marginBottom,
			XmNmarginLeft, &marginLeft,
			XmNmarginRight, &marginRight,
			NULL);
		if (!str && XtName(w))
			str = XmStringCreateSimple(XtName(w));
		if (!str)
			str = XmStringCreateSimple("");
		XmStringExtent(fontlist, str, &width, &height);
		XmStringFree(str);
		if (drawnDir == XmDRAWNB_UP || drawnDir == XmDRAWNB_DOWN)
			{
			dim = width;
			width = height;
			height = dim;
			}
		height += (highlightThickness + shadowThickness +
			marginHeight) * 2 + marginTop + marginBottom;
		width += (highlightThickness + shadowThickness +
			marginWidth) * 2 + marginLeft + marginRight;
		/* change to pixmap type so label string isnt drawn */
		XtVaSetValues(w,
			XmNlabelType, XmPIXMAP,
			NULL);
		XtVaSetValues(w,
			XmNwidth, width,
			XmNheight, height,
			NULL);
		XtAddCallback(w, XmNexposeCallback, XmLDrawnBDrawStringCB,
			(XtPointer)dd);
		XtAddCallback(w, XmNresizeCallback, XmLDrawnBDrawStringCB,
			(XtPointer)dd);
		}
	else
		{
		mask = GCForeground;
		values.foreground = b->primitive.foreground;
		dd->gc = XtGetGC(w, mask, &values);
		XtAddCallback(w, XmNexposeCallback, XmLDrawnBDrawCB, (XtPointer)dd);
		XtAddCallback(w, XmNresizeCallback, XmLDrawnBDrawCB, (XtPointer)dd);
		}
	XtAddCallback(w, XmNdestroyCallback, XmLDrawnBDestroyCB, (XtPointer)dd);
	}
Esempio n. 30
0
/*
** Create a new event display window
*/
SpaceWindow *CreatePanelSp(Display *display, int setsEventNum,
    int canOpenFiles, int canExit, char *windowTitle, char *eventSelectorText)
{
    Widget appShell, main, menuBar, form;
    SpaceWindow *window;
    static Atom wmpAtom, dwAtom = NULL;
    Arg al[20];
    int type, ac;
    XGCValues values;

    /* Allocate some memory for the new window data structure */
    window = (SpaceWindow *)XtMalloc(sizeof(SpaceWindow));
    
    /* Create an toplevel shell to hold the window */
    ac = 0;
    XtSetArg(al[ac], XmNtitle, windowTitle); ac++;
    XtSetArg(al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
    XtSetArg(al[ac], XmNiconName, windowTitle); ac++;
    /* Keep the phase name here, to same valid XDefaults.. */
    appShell = XtAppCreateShell ("phase", "Space",
		applicationShellWidgetClass, display, al, ac);
    	    
    /*
    ** create a main window holding a menu bar and a form with the rest of
    ** the window contents.
    */
    main = XmCreateMainWindow(appShell, "main", NULL, 0);
    XtManageChild(main);
    type = STDHEP_SPACE;
    menuBar = CreateMenuBar(main, (StdHepWindow *) window,
                                   canOpenFiles, canExit, type);
    XtManageChild(menuBar);
    form = createContents(main, window, setsEventNum, eventSelectorText);
    XtManageChild(form);

    /* add the window to the global window list */
    AddToWindowList((StdHepWindow *) window);
    
    /* realize all of the widgets in the new window */
    XtRealizeWidget(appShell);

    /* set up closeCB to be called when the user selects close from the
       window menu.  The close menu item usually activates f.kill which
       sends a WM_DELETE_WINDOW protocol request for the window. */
    if (dwAtom == NULL) {
    	wmpAtom = XmInternAtom(display, "WM_PROTOCOLS", TRUE);
    	dwAtom = XmInternAtom(display, "WM_DELETE_WINDOW", TRUE);
    }
    XmAddProtocolCallback(appShell, wmpAtom, dwAtom, closeCB, window);

    /* initialize window structure, including a read-only graphics contexts
       for drawing in scale area and highlighting in spin widget */
    window->shell = appShell;
    window->selectedTrack = NO_TRACK;
    window->trackWindowShell = NULL;
    window->btnRotationPanel = NULL;
    window->absRotationPanel = NULL;
    window->buttonRotateDegrees = INITIAL_ROT_INCR;
    window->event.nParticles = 0;
    window->event.particles = NULL;
    window->colorcode.nParticles = 0;
    window->colorcode.particles = NULL;
    window->nDetectorSegments = 0;
    window->detectorSegments = NULL;
    ac = 0;
    XtSetArg(al[ac], XmNbackground, &values.background); ac++;
    XtSetArg(al[ac], XmNforeground, &values.foreground); ac++;
    XtGetValues(window->scaleArea, al, ac);
    window->scaleGC =
    	XtGetGC(window->scaleArea, GCForeground|GCBackground, &values);
    window->highlightGC = SpinCopyGC(window->spin);
    XSetLineAttributes(display, window->highlightGC, 5, LineSolid,
    		       CapRound, JoinMiter);
    return window;
}