46 #error ARB only needs the Motif flavour of this file
48 #define USE(x) (x)=(x)
50 #include <X11/IntrinsicP.h>
51 #include <X11/StringDefs.h>
55 #include <Xm/PrimitiveP.h>
64 #define GLwDrawingAreaWidget GLwMDrawingAreaWidget
65 #define GLwDrawingAreaClassRec GLwMDrawingAreaClassRec
66 #define glwDrawingAreaClassRec glwMDrawingAreaClassRec
67 #define glwDrawingAreaWidgetClass glwMDrawingAreaWidgetClass
68 #define GLwDrawingAreaRec GLwMDrawingAreaRec
71 #define ATTRIBLIST_SIZE 32
73 #define offset(field) XtOffset(GLwDrawingAreaWidget, glwDrawingArea.field)
79 static void Realize(
Widget w, Mask *valueMask, XSetWindowAttributes *attributes);
89 "<Key>osfHelp:PrimitiveHelp() \n"
91 "<KeyDown>: glwInput() \n"
92 "<KeyUp>: glwInput() \n"
93 "<BtnDown>: glwInput() \n"
94 "<BtnUp>: glwInput() \n"
95 "<BtnMotion>: glwInput() ";
165 { (
String)XmNhighlightThickness, (
String)XmCHighlightThickness, XmRHorizontalDimension,
sizeof(Dimension), XtOffset(
GLwDrawingAreaWidget, primitive.highlight_thickness), XmRImmediate, (XtPointer)0 },
178 { XtNcolormap, XtCColormap, XtRColormap,
sizeof(Colormap),
189 { XmNbackground, XmCBackground, XmRPixel,
191 XmRString, (XtPointer)
"lightgrey" },
193 { XmNbackgroundPixmap, XmCPixmap, XmRXmBackgroundPixmap,
195 XmRImmediate, (XtPointer)XmUNSPECIFIED_PIXMAP },
198 { XtNbackground, XtCBackground, XtRPixel,
sizeof(Pixel),
200 XtRString, (XtPointer)
"lightgrey" },
202 { XtNbackgroundPixmap, XtCPixmap, XtRPixmap,
sizeof(Pixmap),
204 XtRImmediate, (XtPointer)XtUnspecifiedPixmap },
214 static XtResource otherColorResources[] = {
215 { XmNforeground, XmCForeground, XmRPixel,
217 XmRString, (XtPointer)
"lighgrey" },
219 { XmNhighlightColor, XmCHighlightColor, XmRPixel,
sizeof(Pixel),
221 XmRString, (XtPointer)
"lightgrey" },
223 { XmNhighlightPixmap, XmCHighlightPixmap, XmRPrimHighlightPixmap,
226 XmRImmediate, (XtPointer)XmUNSPECIFIED_PIXMAP },
237 (WidgetClass) &xmPrimitiveClassRec,
238 (
String)
"GLwMDrawingArea",
239 #else // not __GLX_MOTIF
240 (WidgetClass) &widgetClassRec,
242 #endif // __GLX_MOTIF
264 XtInheritSetValuesAlmost,
270 XtInheritQueryGeometry,
271 XtInheritDisplayAccelerator,
276 XmInheritBorderHighlight,
277 XmInheritBorderUnhighlight,
278 XtInheritTranslations,
295 sprintf(buf,
"GLwMDrawingArea: %s\n",
string);
297 sprintf(buf,
"GLwDrawingArea: %s\n",
string);
299 XtAppError(XtWidgetToApplicationContext(w), buf);
306 sprintf (buf,
"GLwMDraw: %s\n",
string);
308 sprintf (buf,
"GLwDraw: %s\n",
string);
310 XtAppWarning(XtWidgetToApplicationContext(w), buf);
320 error((
Widget)w,
"Unable to allocate attribute list");
323 *ptr++ = GLX_BUFFER_SIZE;
330 *ptr++ = GLX_AUX_BUFFERS;
332 *ptr++ = GLX_RED_SIZE;
334 *ptr++ = GLX_GREEN_SIZE;
336 *ptr++ = GLX_BLUE_SIZE;
338 *ptr++ = GLX_ALPHA_SIZE;
340 *ptr++ = GLX_DEPTH_SIZE;
342 *ptr++ = GLX_STENCIL_SIZE;
344 *ptr++ = GLX_ACCUM_RED_SIZE;
346 *ptr++ = GLX_ACCUM_GREEN_SIZE;
348 *ptr++ = GLX_ACCUM_BLUE_SIZE;
350 *ptr++ = GLX_ACCUM_ALPHA_SIZE;
373 static struct cmapCache { Visual *visual; Colormap cmap; } *cmapCache;
374 static int cacheEntries=0;
375 static int cacheMalloced=0;
383 for (i=0; i<cacheEntries; i++) {
385 value->addr=(XtPointer)(&cmapCache[i].cmap);
391 if (cacheEntries >= cacheMalloced) {
396 if (cacheMalloced==0) {
398 cmapCache=(
struct cmapCache*)XtMalloc(
sizeof(
struct cmapCache));
402 cmapCache=(
struct cmapCache*)XtRealloc((
char*)cmapCache,
sizeof(
struct cmapCache)*cacheMalloced);
406 cmapCache[cacheEntries].cmap=XCreateColormap(XtDisplay(w),
407 RootWindow(XtDisplay(w),
412 value->addr=(XtPointer)(&cmapCache[cacheEntries++].cmap);
420 if (req->
core.width==0) neww->
core.width=100;
421 if (req->
core.height==0) neww->
core.width=100;
446 XtGetApplicationResources((
Widget)neww, neww, initializeResources, XtNumber(initializeResources), args, *num_args);
450 XtGetApplicationResources((
Widget)neww, neww, backgroundResources, XtNumber(backgroundResources), args, *num_args);
455 XtGetApplicationResources((
Widget)neww, neww, otherColorResources, XtNumber(otherColorResources), args, *num_args);
462 static void Realize(
Widget w, Mask *valueMask, XSetWindowAttributes *attributes) {
467 Window windows[2], *windowsReturn, *windowList;
474 *valueMask&=~CWBackPixel;
483 for (parentShell=XtParent(w); parentShell&&!XtIsShell(parentShell); parentShell=XtParent(parentShell)) ;
485 if (parentShell && XtWindow(parentShell)) {
488 status=XGetWMColormapWindows(XtDisplay(parentShell), XtWindow(parentShell), &windowsReturn, &countReturn);
492 windows[0]=XtWindow(w);
493 windows[1]=XtWindow(parentShell);
494 XSetWMColormapWindows(XtDisplay(parentShell), XtWindow(parentShell), windows, 2);
499 windowList=(Window *)XtMalloc((
sizeof(Window))*(countReturn+1));
500 windowList[0]=XtWindow(w);
501 for (i=0; i<countReturn; i++) windowList[i+1]=windowsReturn[i];
502 XSetWMColormapWindows(XtDisplay(parentShell), XtWindow(parentShell), windowList, countReturn+1);
503 XtFree((
char*)windowList);
504 XtFree((
char*)windowsReturn);
508 warning(w,
"Could not set colormap property on parent shell");
525 if (!XtIsRealized((
Widget)w))
return;
528 cb.
width = w->core.width;
529 cb.
height = w->core.height;
530 XtCallCallbackList((
Widget)w, w->glwDrawingArea.exposeCallback, &cb);
537 if (!XtIsRealized((
Widget)glw))
return;
540 cb.
width=glw->core.width;
541 cb.
height=glw->core.height;
542 XtCallCallbackList((
Widget)glw, glw->glwDrawingArea.resizeCallback, &cb);
548 Window *windowsReturn;
566 for (parentShell=XtParent(glw); parentShell&&!XtIsShell(parentShell); parentShell=XtParent(parentShell)) ;
568 if (parentShell && XtWindow(parentShell)) {
571 status=XGetWMColormapWindows(XtDisplay(parentShell), XtWindow(parentShell), &windowsReturn, &countReturn);
577 for (i=0; i<countReturn; i++) {
578 if (windowsReturn[i]==XtWindow(glw)) {
581 for (i++; i<countReturn; i++) { windowsReturn[i-1]=windowsReturn[i]; }
583 XSetWMColormapWindows(XtDisplay(parentShell), XtWindow(parentShell), windowsReturn, countReturn-1);
587 XtFree((
char *)windowsReturn);
610 glXMakeCurrent(XtDisplay(w), XtWindow(w), ctx);
615 Widget GLwCreateMDrawingArea(
Widget parent,
char *name, ArgList arglist, Cardinal argcount) {
617 return XtCreateWidget(name, glwMDrawingAreaWidgetClass, parent, arglist, argcount);
624 glXSwapBuffers(XtDisplay(w), XtWindow(w));
WidgetClass glwDrawingAreaWidgetClass
#define GLwCAccumAlphaSize
static void glwInput(GLwDrawingAreaWidget glw, XEvent *event, String *params, Cardinal *numParams)
static void warning(Widget w, const char *string)
static void Resize(GLwDrawingAreaWidget glw)
#define GLwCInstallColormap
#define GLwNresizeCallback
Boolean installBackground
#define GLwCInstallBackground
Boolean allocateOtherColors
void GLwDrawingAreaMakeCurrent(Widget w, GLXContext ctx)
static void Redraw(GLwDrawingAreaWidget w, XEvent *event, Region region)
static void createColormap(GLwDrawingAreaWidget w, int offset, XrmValue *value)
XtCallbackList ginitCallback
#define GLwNinputCallback
static void Initialize(GLwDrawingAreaWidget req, GLwDrawingAreaWidget neww, ArgList args, Cardinal *num_args)
static void createVisualInfo(GLwDrawingAreaWidget w)
static XtActionsRec actions[]
static void error(Widget w, const char *string)
GLwDrawingAreaPart glwDrawingArea
XtCallbackList inputCallback
#define GLwNaccumAlphaSize
#define GLwNaccumGreenSize
Boolean allocateBackground
GLwDrawingAreaClassRec glwDrawingAreaClassRec
static void createAttribList(GLwDrawingAreaWidget w)
#define GLwNginitCallback
#define GLwNaccumBlueSize
#define GLwCAccumColorSize
#define GLwNallocateOtherColors
#define GLwNinstallBackground
static BasicStatus status
struct _GLwDrawingAreaRec * GLwDrawingAreaWidget
#define GLwNinstallColormap
void GLwDrawingAreaSwapBuffers(Widget w)
static XtResource backgroundResources[]
#define GLwNallocateBackground
#define GLwNexposeCallback
#define GLwCAllocateColors
static XtResource resources[]
static XtResource initializeResources[]
static char defaultTranslations[]
static void Realize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
static void Destroy(GLwDrawingAreaWidget glw)
struct _GLwDrawingAreaRec GLwDrawingAreaRec
struct _WidgetRec * Widget