#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/ShellP.h>
#include <X11/VendorP.h>
#include <X11/Xmu/Converters.h>
#include <X11/Xmu/Atoms.h>
#include <X11/Xmu/Editres.h>
#include <X11/Xmu/ExtAgent.h>
#include <X11/Xaw/VendorEP.h>
#include <X11/Xaw/XawImP.h>
static void XawVendorShellChangeManaged(Widget);
static Boolean XawCvtCompoundTextToString(Display*, XrmValuePtr, Cardinal*,
XrmValue*, XrmValue*, XtPointer*);
static void XawVendorShellClassInitialize(void);
static XtGeometryResult XawVendorShellGeometryManager(Widget,
XtWidgetGeometry*,
XtWidgetGeometry*);
static void XawVendorShellExtClassInitialize(void);
static void XawVendorShellExtDestroy(Widget);
static void XawVendorShellExtInitialize(Widget, Widget, ArgList, Cardinal*);
void XawVendorShellExtResize(Widget);
static Boolean XawVendorShellExtSetValues(Widget, Widget, Widget,
ArgList, Cardinal*);
static void XawVendorShellClassPartInit(WidgetClass);
static void XawVendorShellInitialize(Widget, Widget, ArgList, Cardinal*);
static void XawVendorShellRealize(Widget, Mask*, XSetWindowAttributes*);
static Boolean XawVendorShellSetValues(Widget, Widget, Widget,
ArgList, Cardinal*);
void XawVendorStructureNotifyHandler(Widget, XtPointer, XEvent*, Boolean*);
static XtResource resources[] = {
{XtNinput, XtCInput, XtRBool, sizeof(Bool),
XtOffsetOf(VendorShellRec, wm.wm_hints.input),
XtRImmediate, (XtPointer)True}
};
#if defined(__UNIXOS2__) || defined(__CYGWIN__) || defined(__MINGW32__)
extern WidgetClass vendorShellWidgetClass;
extern VendorShellClassRec _XawVendorShellClassRec;
extern void _XawFixupVendorShell();
#if defined(__UNIXOS2__)
unsigned long _DLL_InitTerm(unsigned long mod,unsigned long flag)
{
switch (flag) {
case 0:
_CRT_init();
vendorShellWidgetClass = (WidgetClass)(&_XawVendorShellClassRec);
_XawFixupVendorShell();
return 1;
case 1:
return 1;
default:
return 0;
}
}
#endif
#if defined(__CYGWIN__) || defined(__MINGW32__)
int __stdcall
DllMain(unsigned long mod_handle, unsigned long flag, void *routine)
{
switch (flag)
{
case 1:
vendorShellWidgetClass = (WidgetClass)(&_XawVendorShellClassRec);
_XawFixupVendorShell();
break;
case 0:
break;
}
return 1;
}
#endif
#define vendorShellClassRec _XawVendorShellClassRec
#endif
static CompositeClassExtensionRec vendorCompositeExt = {
NULL,
NULLQUARK,
XtCompositeExtensionVersion,
sizeof (CompositeClassExtensionRec),
TRUE,
FALSE
};
#define SuperClass (&wmShellClassRec)
externaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = {
{
(WidgetClass)SuperClass,
"VendorShell",
sizeof(VendorShellRec),
XawVendorShellClassInitialize,
XawVendorShellClassPartInit,
FALSE,
XawVendorShellInitialize,
NULL,
XawVendorShellRealize,
NULL,
0,
resources,
XtNumber(resources),
NULLQUARK,
FALSE,
TRUE,
FALSE,
FALSE,
NULL,
XawVendorShellExtResize,
NULL,
XawVendorShellSetValues,
NULL,
XtInheritSetValuesAlmost,
NULL,
NULL,
XtVersion,
NULL,
NULL,
NULL,
NULL,
NULL
},{
XawVendorShellGeometryManager,
XawVendorShellChangeManaged,
XtInheritInsertChild,
XtInheritDeleteChild,
(XtPointer) &vendorCompositeExt
},{
NULL
},{
NULL
},{
NULL
}
};
#ifndef __UNIXOS2__
externaldef(vendorshellwidgetclass) WidgetClass vendorShellWidgetClass =
(WidgetClass) (&vendorShellClassRec);
#endif
static XtResource ext_resources[] = {
{XtNinputMethod, XtCInputMethod, XtRString, sizeof(String),
XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.input_method),
XtRString, (XtPointer)NULL},
{XtNpreeditType, XtCPreeditType, XtRString, sizeof(String),
XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.preedit_type),
XtRString, (XtPointer)"OverTheSpot,OffTheSpot,Root"},
{XtNopenIm, XtCOpenIm, XtRBoolean, sizeof(Boolean),
XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.open_im),
XtRImmediate, (XtPointer)TRUE},
{XtNsharedIc, XtCSharedIc, XtRBoolean, sizeof(Boolean),
XtOffsetOf(XawVendorShellExtRec, vendor_ext.ic.shared_ic),
XtRImmediate, (XtPointer)FALSE}
};
externaldef(vendorshellextclassrec) XawVendorShellExtClassRec
xawvendorShellExtClassRec = {
{
(WidgetClass)&objectClassRec,
"VendorShellExt",
sizeof(XawVendorShellExtRec),
XawVendorShellExtClassInitialize,
NULL,
FALSE,
XawVendorShellExtInitialize,
NULL,
NULL,
NULL,
0,
ext_resources,
XtNumber(ext_resources),
NULLQUARK,
FALSE,
FALSE,
FALSE,
FALSE,
XawVendorShellExtDestroy,
NULL,
NULL,
XawVendorShellExtSetValues,
NULL,
NULL,
NULL,
NULL,
XtVersion,
NULL,
NULL,
NULL,
NULL,
NULL
},{
NULL
}
};
externaldef(xawvendorshellwidgetclass) WidgetClass
xawvendorShellExtWidgetClass = (WidgetClass) (&xawvendorShellExtClassRec);
static Boolean
XawCvtCompoundTextToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
XrmValue *fromVal, XrmValue *toVal,
XtPointer *cvt_data)
{
XTextProperty prop;
char **list;
int count;
static char *mbs = NULL;
int len;
prop.value = (unsigned char *)fromVal->addr;
prop.encoding = XA_COMPOUND_TEXT(dpy);
prop.format = 8;
prop.nitems = fromVal->size;
if(XmbTextPropertyToTextList(dpy, &prop, &list, &count) < Success) {
XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
"converter", "XmbTextPropertyToTextList", "XawError",
"conversion from CT to MB failed.", NULL, 0);
return False;
}
len = strlen(*list);
toVal->size = len;
mbs = XtRealloc(mbs, len + 1);
strcpy(mbs, *list);
XFreeStringList(list);
toVal->addr = (XtPointer)mbs;
return True;
}
static void
XawVendorShellClassInitialize(void)
{
static XtConvertArgRec screenConvertArg[] = {
{XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
sizeof(Screen *)}
};
XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor,
screenConvertArg, XtNumber(screenConvertArg));
XtAddConverter(XtRString, XtRBitmap, XmuCvtStringToBitmap,
screenConvertArg, XtNumber(screenConvertArg));
XtSetTypeConverter("CompoundText", XtRString, XawCvtCompoundTextToString,
NULL, 0, XtCacheNone, NULL);
}
static void
XawVendorShellClassPartInit(WidgetClass cclass)
{
CompositeClassExtension ext;
VendorShellWidgetClass vsclass = (VendorShellWidgetClass)cclass;
if ((ext = (CompositeClassExtension)
XtGetClassExtension (cclass,
XtOffsetOf(CompositeClassRec,
composite_class.extension),
NULLQUARK, 1L, (Cardinal) 0)) == NULL) {
ext = (CompositeClassExtension) XtNew (CompositeClassExtensionRec);
if (ext != NULL) {
ext->next_extension = vsclass->composite_class.extension;
ext->record_type = NULLQUARK;
ext->version = XtCompositeExtensionVersion;
ext->record_size = sizeof (CompositeClassExtensionRec);
ext->accepts_objects = TRUE;
ext->allows_change_managed_set = FALSE;
vsclass->composite_class.extension = (XtPointer) ext;
}
}
}
#if defined(__osf__) || defined(__UNIXOS2__) || defined(__CYGWIN__) || defined(__MINGW32__)
void _XawFixupVendorShell()
{
transientShellWidgetClass->core_class.superclass =
(WidgetClass) &vendorShellClassRec;
topLevelShellWidgetClass->core_class.superclass =
(WidgetClass) &vendorShellClassRec;
}
#endif
static void
XawVendorShellInitialize(Widget req, Widget cnew,
ArgList args, Cardinal *num_args)
{
XtAddEventHandler(cnew, (EventMask) 0, TRUE, _XEditResCheckMessages, NULL);
XtAddEventHandler(cnew, (EventMask) 0, TRUE, XmuRegisterExternalAgent, NULL);
XtCreateWidget("shellext", xawvendorShellExtWidgetClass,
cnew, args, *num_args);
}
static Boolean
XawVendorShellSetValues(Widget old, Widget ref, Widget cnew,
ArgList args, Cardinal *num_args)
{
return FALSE;
}
static void
XawVendorShellRealize(Widget wid, Mask *vmask, XSetWindowAttributes *attr)
{
WidgetClass super = wmShellWidgetClass;
(*super->core_class.realize) (wid, vmask, attr);
_XawImRealize(wid);
}
static void
XawVendorShellExtClassInitialize(void)
{
}
static void
XawVendorShellExtInitialize(Widget req, Widget cnew,
ArgList args, Cardinal *num_args)
{
_XawImInitialize(cnew->core.parent, cnew);
}
static void
XawVendorShellExtDestroy(Widget w)
{
_XawImDestroy( w->core.parent, w );
}
static Boolean
XawVendorShellExtSetValues(Widget old, Widget ref, Widget cnew,
ArgList args, Cardinal *num_args)
{
return FALSE;
}
void
XawVendorShellExtResize(Widget w)
{
ShellWidget sw = (ShellWidget) w;
Widget childwid;
Cardinal i;
int core_height;
_XawImResizeVendorShell( w );
core_height = _XawImGetShellHeight( w );
for( i = 0; i < sw->composite.num_children; i++ ) {
if( XtIsManaged( sw->composite.children[ i ] ) ) {
childwid = sw->composite.children[ i ];
XtResizeWidget( childwid, sw->core.width, core_height,
childwid->core.border_width );
}
}
}
void
XawVendorStructureNotifyHandler(Widget w, XtPointer closure, XEvent *event,
Boolean *continue_to_dispatch)
{
XawVendorShellExtResize(w);
}
static XtGeometryResult
XawVendorShellGeometryManager(Widget wid, XtWidgetGeometry *request,
XtWidgetGeometry *reply)
{
ShellWidget shell = (ShellWidget)(wid->core.parent);
XtWidgetGeometry my_request;
if(shell->shell.allow_shell_resize == FALSE && XtIsRealized(wid))
return(XtGeometryNo);
if (request->request_mode & (CWX | CWY))
return(XtGeometryNo);
my_request.request_mode = 0;
if (request->request_mode & CWWidth) {
my_request.width = request->width;
my_request.request_mode |= CWWidth;
}
if (request->request_mode & CWHeight) {
my_request.height = request->height
+ _XawImGetImAreaHeight( wid );
my_request.request_mode |= CWHeight;
}
if (request->request_mode & CWBorderWidth) {
my_request.border_width = request->border_width;
my_request.request_mode |= CWBorderWidth;
}
if (XtMakeGeometryRequest((Widget)shell, &my_request, NULL)
== XtGeometryYes) {
wid->core.width = shell->core.width;
wid->core.height = shell->core.height;
if (request->request_mode & CWBorderWidth) {
wid->core.x = wid->core.y = -request->border_width;
}
_XawImCallVendorShellExtResize(wid);
return XtGeometryYes;
} else return XtGeometryNo;
}
static void
XawVendorShellChangeManaged(Widget wid)
{
ShellWidget w = (ShellWidget) wid;
Widget* childP;
int i;
(*SuperClass->composite_class.change_managed)(wid);
for (i = w->composite.num_children, childP = w->composite.children;
i; i--, childP++) {
if (XtIsManaged(*childP)) {
XtSetKeyboardFocus(wid, *childP);
break;
}
}
}