#define _XT_CORE_C
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "IntrinsicP.h"
#include "EventI.h"
#include "ConvertI.h"
#include "TranslateI.h"
#include "ResourceI.h"
#include "RectObj.h"
#include "RectObjP.h"
#include "ThreadsI.h"
#include "StringDefs.h"
externaldef(xtinherittranslations) int _XtInheritTranslations = 0;
extern String XtCXtToolkitError;
static void XtCopyScreen(Widget, int, XrmValue *);
static XtResource resources[] = {
{XtNscreen, XtCScreen, XtRScreen, sizeof(Screen*),
XtOffsetOf(CoreRec,core.screen), XtRCallProc, (XtPointer)XtCopyScreen},
{XtNdepth, XtCDepth, XtRInt,sizeof(int),
XtOffsetOf(CoreRec,core.depth),
XtRCallProc, (XtPointer)_XtCopyFromParent},
{XtNcolormap, XtCColormap, XtRColormap, sizeof(Colormap),
XtOffsetOf(CoreRec,core.colormap),
XtRCallProc,(XtPointer)_XtCopyFromParent},
{XtNbackground, XtCBackground, XtRPixel,sizeof(Pixel),
XtOffsetOf(CoreRec,core.background_pixel),
XtRString, (XtPointer)"XtDefaultBackground"},
{XtNbackgroundPixmap, XtCPixmap, XtRPixmap, sizeof(Pixmap),
XtOffsetOf(CoreRec,core.background_pixmap),
XtRImmediate, (XtPointer)XtUnspecifiedPixmap},
{XtNborderColor, XtCBorderColor, XtRPixel,sizeof(Pixel),
XtOffsetOf(CoreRec,core.border_pixel),
XtRString,(XtPointer)"XtDefaultForeground"},
{XtNborderPixmap, XtCPixmap, XtRPixmap, sizeof(Pixmap),
XtOffsetOf(CoreRec,core.border_pixmap),
XtRImmediate, (XtPointer)XtUnspecifiedPixmap},
{XtNmappedWhenManaged, XtCMappedWhenManaged, XtRBoolean, sizeof(Boolean),
XtOffsetOf(CoreRec,core.mapped_when_managed),
XtRImmediate, (XtPointer)True},
{XtNtranslations, XtCTranslations, XtRTranslationTable,
sizeof(XtTranslations), XtOffsetOf(CoreRec,core.tm.translations),
XtRTranslationTable, (XtPointer)NULL},
{XtNaccelerators, XtCAccelerators, XtRAcceleratorTable,
sizeof(XtTranslations), XtOffsetOf(CoreRec,core.accelerators),
XtRTranslationTable, (XtPointer)NULL}
};
static void CoreInitialize(Widget, Widget, ArgList, Cardinal *);
static void CoreClassPartInitialize(WidgetClass);
static void CoreDestroy(Widget);
static void CoreRealize(Widget, XtValueMask *, XSetWindowAttributes *);
static Boolean CoreSetValues(Widget, Widget, Widget, ArgList, Cardinal *);
static void CoreSetValuesAlmost(Widget, Widget, XtWidgetGeometry *, XtWidgetGeometry *);
static RectObjClassRec unNamedObjClassRec = {
{
(WidgetClass)&rectObjClassRec,
"UnNamedObj",
0,
NULL,
NULL,
FALSE,
NULL,
NULL,
(XtProc)XtInheritRealize,
NULL,
0,
NULL,
0,
NULLQUARK,
FALSE,
FALSE,
FALSE,
FALSE,
NULL,
NULL,
NULL,
NULL,
NULL,
XtInheritSetValuesAlmost,
NULL,
NULL,
XtVersion,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
externaldef(widgetclassrec) WidgetClassRec widgetClassRec = {
{
(WidgetClass)&unNamedObjClassRec,
"Core",
sizeof(WidgetRec),
NULL,
CoreClassPartInitialize,
FALSE,
CoreInitialize,
NULL,
CoreRealize,
NULL,
0,
resources,
XtNumber(resources),
NULLQUARK,
FALSE,
TRUE,
FALSE,
FALSE,
CoreDestroy,
NULL,
NULL,
CoreSetValues,
NULL,
CoreSetValuesAlmost,
NULL,
NULL,
XtVersion,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
externaldef (WidgetClass) WidgetClass widgetClass = &widgetClassRec;
externaldef (WidgetClass) WidgetClass coreWidgetClass = &widgetClassRec;
static void XtCopyScreen(
Widget widget,
int offset,
XrmValue *value)
{
value->addr = (XPointer)(&widget->core.screen);
}
static void CoreClassPartInitialize(
register WidgetClass wc)
{
register WidgetClass super = wc->core_class.superclass;
LOCK_PROCESS;
if (wc->core_class.realize == XtInheritRealize) {
wc->core_class.realize = super->core_class.realize;
}
if (wc->core_class.accept_focus == XtInheritAcceptFocus) {
wc->core_class.accept_focus = super->core_class.accept_focus;
}
if (wc->core_class.display_accelerator == XtInheritDisplayAccelerator) {
wc->core_class.display_accelerator =
super->core_class.display_accelerator;
}
if (wc->core_class.tm_table == (char *) XtInheritTranslations) {
wc->core_class.tm_table =
wc->core_class.superclass->core_class.tm_table;
} else if (wc->core_class.tm_table != NULL) {
wc->core_class.tm_table =
(String)XtParseTranslationTable(wc->core_class.tm_table);
}
if (wc->core_class.actions != NULL) {
Boolean inPlace;
if (wc->core_class.version == XtVersionDontCheck)
inPlace = True;
else
inPlace = (wc->core_class.version < XtVersion) ? False : True;
wc->core_class.actions = (XtActionList) _XtInitializeActionData(
wc->core_class.actions, wc->core_class.num_actions, inPlace);
}
UNLOCK_PROCESS;
}
static void CoreInitialize(
Widget requested_widget,
register Widget new_widget,
ArgList args,
Cardinal *num_args)
{
XtTranslations save1, save2;
new_widget->core.event_table = NULL;
new_widget->core.tm.proc_table = NULL;
new_widget->core.tm.lastEventTime = 0;
save1 = (XtTranslations)new_widget->core.tm.current_state;
new_widget->core.tm.current_state = NULL;
save2 = new_widget->core.tm.translations;
LOCK_PROCESS;
new_widget->core.tm.translations =
(XtTranslations)new_widget->core.widget_class->core_class.tm_table;
UNLOCK_PROCESS;
if (save1)
_XtMergeTranslations(new_widget, save1, save1->operation);
if (save2)
_XtMergeTranslations(new_widget, save2, save2->operation);
}
static void CoreRealize(
Widget widget,
XtValueMask *value_mask,
XSetWindowAttributes *attributes)
{
XtCreateWindow(widget, (unsigned int) InputOutput,
(Visual *) CopyFromParent, *value_mask, attributes);
}
static void CoreDestroy (
Widget widget)
{
_XtFreeEventTable(&widget->core.event_table);
_XtDestroyTMData(widget);
XtUnregisterDrawable(XtDisplay(widget), widget->core.window);
if (widget->core.popup_list != NULL)
XtFree((char *)widget->core.popup_list);
}
static Boolean CoreSetValues(
Widget old, Widget reference, Widget new,
ArgList args,
Cardinal *num_args)
{
Boolean redisplay;
Mask window_mask;
XSetWindowAttributes attributes;
XtTranslations save;
redisplay = FALSE;
if (old->core.tm.translations != new->core.tm.translations) {
save = new->core.tm.translations;
new->core.tm.translations = old->core.tm.translations;
_XtMergeTranslations(new, save, XtTableReplace);
}
if (XtIsRealized(old)) {
window_mask = 0;
if (old->core.background_pixel != new->core.background_pixel
&& new->core.background_pixmap == XtUnspecifiedPixmap) {
attributes.background_pixel = new->core.background_pixel;
window_mask |= CWBackPixel;
redisplay = TRUE;
}
if (old->core.background_pixmap != new->core.background_pixmap) {
if (new->core.background_pixmap == XtUnspecifiedPixmap) {
window_mask |= CWBackPixel;
attributes.background_pixel = new->core.background_pixel;
}
else {
attributes.background_pixmap = new->core.background_pixmap;
window_mask &= ~CWBackPixel;
window_mask |= CWBackPixmap;
}
redisplay = TRUE;
}
if (old->core.border_pixel != new->core.border_pixel
&& new->core.border_pixmap == XtUnspecifiedPixmap) {
attributes.border_pixel = new->core.border_pixel;
window_mask |= CWBorderPixel;
}
if (old->core.border_pixmap != new->core.border_pixmap) {
if (new->core.border_pixmap == XtUnspecifiedPixmap) {
window_mask |= CWBorderPixel;
attributes.border_pixel = new->core.border_pixel;
}
else {
attributes.border_pixmap = new->core.border_pixmap;
window_mask &= ~CWBorderPixel;
window_mask |= CWBorderPixmap;
}
}
if (old->core.depth != new->core.depth) {
XtAppWarningMsg(XtWidgetToApplicationContext(old),
"invalidDepth","setValues",XtCXtToolkitError,
"Can't change widget depth", (String *)NULL, (Cardinal *)NULL);
new->core.depth = old->core.depth;
}
if (old->core.colormap != new->core.colormap) {
window_mask |= CWColormap;
attributes.colormap = new->core.colormap;
}
if (window_mask != 0) {
XChangeWindowAttributes(
XtDisplay(new), XtWindow(new), window_mask, &attributes);
}
if (old->core.mapped_when_managed != new->core.mapped_when_managed) {
Boolean mapped_when_managed = new->core.mapped_when_managed;
new->core.mapped_when_managed = !mapped_when_managed;
XtSetMappedWhenManaged(new, mapped_when_managed);
}
}
return redisplay;
}
static void CoreSetValuesAlmost(
Widget old,
Widget new,
XtWidgetGeometry *request,
XtWidgetGeometry *reply)
{
*request = *reply;
}