/* Generated by wbuild from "Icon.w"
** (generator version $Revision: 2.0 $ of $Date: 93/07/06 16:08:04 $)
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/extensions/shape.h>
#include <stdio.h>
#include "IconP.h"
static void activate(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);

static XtActionsRec actionsList[] = {
{"activate", activate},
};

static char defaultTranslations[] = "\
<Btn1Down>,<Btn1Up>: activate() \n\
<Key>Return: activate() \n\
";
static void _resolve_inheritance(
#if NeedFunctionPrototypes
WidgetClass
#endif
);
static void initialize(
#if NeedFunctionPrototypes
Widget ,Widget,ArgList ,Cardinal *
#endif
);
static void expose(
#if NeedFunctionPrototypes
Widget,XEvent *,Region 
#endif
);
static Boolean  set_values(
#if NeedFunctionPrototypes
Widget ,Widget ,Widget,ArgList ,Cardinal *
#endif
);
static void realize(
#if NeedFunctionPrototypes
Widget,XtValueMask *,XSetWindowAttributes *
#endif
);
static void create_image_gc(
#if NeedFunctionPrototypes
Widget
#endif
);
/*ARGSUSED*/static void create_image_gc(self)Widget self;
{
    Dimension wd, ht;
    Position x, y;
    XtGCMask mask = GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
    XGCValues values;

    if (((XfwfIconWidget)self)->xfwfIcon.image_gc != NULL) XtReleaseGC(self, ((XfwfIconWidget)self)->xfwfIcon.image_gc);
    ((XfwfIconWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &wd, &ht);
    if (((XfwfIconWidget)self)->xfwfIcon.image && ((XfwfIconWidget)self)->xfwfIcon.image->pixmap != None) {
	values.tile = ((XfwfIconWidget)self)->xfwfIcon.image->pixmap;
	mask |= GCTile;
    }
    values.fill_style = FillTiled;
    values.ts_x_origin = x;
    values.ts_y_origin = y;
    ((XfwfIconWidget)self)->xfwfIcon.image_gc = XtGetGC(self, mask, &values);
}

static XtResource resources[] = {
{XtNimage,XtCImage,XtRIcon,sizeof(((XfwfIconRec*)NULL)->xfwfIcon.image),XtOffsetOf(XfwfIconRec,xfwfIcon.image),XtRImmediate,(XtPointer)NULL },
{XtNactivate,XtCActivate,XtRCallback,sizeof(((XfwfIconRec*)NULL)->xfwfIcon.activate),XtOffsetOf(XfwfIconRec,xfwfIcon.activate),XtRImmediate,(XtPointer)NULL },
{XtNframeWidth,XtCFrameWidth,XtRDimension,sizeof(((XfwfIconRec*)NULL)->xfwfFrame.frameWidth),XtOffsetOf(XfwfIconRec,xfwfFrame.frameWidth),XtRImmediate,(XtPointer)0 },
};

XfwfIconClassRec xfwfIconClassRec = {
{ /* core_class part */
(WidgetClass) &xfwfBoardClassRec,
"Icon",
sizeof(XfwfIconRec),
NULL,
_resolve_inheritance,
FALSE,
initialize,
NULL,
realize,
actionsList,
1,
resources,
3,
NULLQUARK,
False ,
FALSE ,
False ,
False ,
NULL,
XtInheritResize,
expose,
set_values,
NULL,
XtInheritSetValuesAlmost,
NULL,
XtInheritAcceptFocus,
XtVersion,
NULL,
defaultTranslations,
XtInheritQueryGeometry,
XtInheritDisplayAccelerator,
NULL 
},
{ /* composite_class part */
XtInheritGeometryManager,
XtInheritChangeManaged,
XtInheritInsertChild,
XtInheritDeleteChild,
NULL
},
{ /* XfwfCommon_class part */
XtInherit_compute_inside,
XtInherit_highlight_border,
XtInherit_unhighlight_border,
XtInherit_would_accept_focus,
XtInherit_traverse,
XtInherit_choose_color,
XtInherit_lighter_color,
XtInherit_darker_color,
NULL ,
},
{ /* XfwfFrame_class part */
0
},
{ /* XfwfBoard_class part */
XtInherit_set_abs_location,
},
{ /* XfwfIcon_class part */
0
},
};
WidgetClass xfwfIconWidgetClass = (WidgetClass) &xfwfIconClassRec;
/*ARGSUSED*/
static void activate(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
    XtCallCallbackList(self, ((XfwfIconWidget)self)->xfwfIcon.activate, event);
}

static void _resolve_inheritance(class)
WidgetClass class;
{
  XfwfIconWidgetClass c = (XfwfIconWidgetClass) class;
  XfwfIconWidgetClass super;
  static CompositeClassExtensionRec extension_rec = {
    NULL, NULLQUARK, XtCompositeExtensionVersion,
    sizeof(CompositeClassExtensionRec), True};
  CompositeClassExtensionRec *ext;
  ext = (XtPointer)XtMalloc(sizeof(*ext));
  *ext = extension_rec;
  ext->next_extension = c->composite_class.extension;
  c->composite_class.extension = ext;
  if (class == xfwfIconWidgetClass) return;
  super = (XfwfIconWidgetClass)class->core_class.superclass;
}
/*ARGSUSED*/static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    Dimension dummy1, dummy2;
    Position x, y;

    ((XfwfIconWidget)self)->xfwfIcon.image_gc = NULL;
    create_image_gc(self);
    if (((XfwfIconWidget)self)->xfwfIcon.image && (((XfwfIconWidget)self)->xfwfIcon.image->attributes.valuemask & XpmSize) != 0) {
	((XfwfIconWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &dummy1, &dummy2);
	XtVaSetValues(self, XtNwidth, ((XfwfIconWidget)self)->xfwfIcon.image->attributes.width + 2*x,
		      XtNheight, ((XfwfIconWidget)self)->xfwfIcon.image->attributes.height + 2*y, NULL);
    }
}
/*ARGSUSED*/static void expose(self,event,region)Widget self;XEvent * event;Region  region;
{
    Dimension wd, ht;
    Position x, y;

    if (! XtIsRealized(self)) return;
    if (((XfwfIconWidget)self)->xfwfIcon.image && ((XfwfIconWidget)self)->xfwfIcon.image->pixmap != None) {
	((XfwfIconWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &wd, &ht);
	XFillRectangle(XtDisplay(self), XtWindow(self), ((XfwfIconWidget)self)->xfwfIcon.image_gc, x, y, wd, ht);
    }
    xfwfBoardClassRec.core_class.expose(self, event, region);
}
/*ARGSUSED*/static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    Dimension dummy1, dummy2;
    Position x, y;
    Boolean need_redraw = False;

    if (((XfwfIconWidget)old)->xfwfFrame.frameWidth != ((XfwfIconWidget)self)->xfwfFrame.frameWidth
	|| ((XfwfIconWidget)old)->xfwfFrame.outerOffset != ((XfwfIconWidget)self)->xfwfFrame.outerOffset
	|| ((XfwfIconWidget)old)->xfwfIcon.image != ((XfwfIconWidget)self)->xfwfIcon.image) {
	create_image_gc(self);
	need_redraw = True;
    }
    if (((XfwfIconWidget)old)->xfwfIcon.image != ((XfwfIconWidget)self)->xfwfIcon.image && ((XfwfIconWidget)self)->xfwfIcon.image) {
	((XfwfIconWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &dummy1, &dummy2);
	if ((((XfwfIconWidget)self)->xfwfIcon.image->attributes.valuemask & XpmSize) != 0)
	    ((XfwfIconWidgetClass)self->core.widget_class)->xfwfBoard_class.set_abs_location(self, CWWidth | CWHeight, 0, 0,
			      ((XfwfIconWidget)self)->xfwfIcon.image->attributes.width + 2*x,
			      ((XfwfIconWidget)self)->xfwfIcon.image->attributes.height + 2*y);
	if (((XfwfIconWidget)self)->xfwfIcon.image->mask != None && XtIsRealized(self))
	    XShapeCombineMask(XtDisplay(self), XtWindow(self), ShapeBounding,
			      x, y, ((XfwfIconWidget)self)->xfwfIcon.image->mask, ShapeSet);
	need_redraw = True;
    }
    return need_redraw;
}
/*ARGSUSED*/static void realize(self,mask,attributes)Widget self;XtValueMask * mask;XSetWindowAttributes * attributes;
{
    Dimension wd, ht;
    Position x, y;

    xfwfBoardClassRec.core_class.realize(self, mask, attributes);
    ((XfwfIconWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &wd, &ht);
    if (((XfwfIconWidget)self)->xfwfIcon.image && ((XfwfIconWidget)self)->xfwfIcon.image->mask != None)
	XShapeCombineMask(XtDisplay(self), XtWindow(self), ShapeBounding,
			  x, y, ((XfwfIconWidget)self)->xfwfIcon.image->mask, ShapeSet);
}
