summaryrefslogtreecommitdiff
path: root/xc
diff options
context:
space:
mode:
authorfaith <faith>2002-04-16 04:54:19 +0000
committerfaith <faith>2002-04-16 04:54:19 +0000
commit62344e4bd7a6a124ad34c0c7233f817271c568aa (patch)
tree895bb57b2ec809fe2874a6ffd4c0171452b3f0fa /xc
parent0a965cb4c6e0e34abf9f6eda44ffcb5f7d10db25 (diff)
Basic widget with even callbacks, suitable for drawing
Diffstat (limited to 'xc')
-rw-r--r--xc/programs/Xserver/hw/dmx/config/Canvas.c223
-rw-r--r--xc/programs/Xserver/hw/dmx/config/Canvas.h40
-rw-r--r--xc/programs/Xserver/hw/dmx/config/CanvasP.h18
3 files changed, 92 insertions, 189 deletions
diff --git a/xc/programs/Xserver/hw/dmx/config/Canvas.c b/xc/programs/Xserver/hw/dmx/config/Canvas.c
index 72310e448..7ff3600eb 100644
--- a/xc/programs/Xserver/hw/dmx/config/Canvas.c
+++ b/xc/programs/Xserver/hw/dmx/config/Canvas.c
@@ -35,167 +35,98 @@ in this Software without prior written authorization from The Open Group.
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
-#include <X11/Xaw/CanvasP.h>
+#include "CanvasP.h"
-/*
- * Class Methods
- */
-static void CanvasInitialize(Widget, Widget, ArgList, Cardinal*);
+static void CanvasInitialize(Widget request, Widget w,
+ ArgList args, Cardinal *num_args)
+{
+}
-/*
- * Prototypes
- */
-static Bool CanvasFunction(CanvasWidget, int, int, Bool);
+static void CanvasExpose(Widget w, XEvent *event, Region region)
+{
+ CanvasExposeDataRec data = {w, event, region};
+
+ if (!XtIsRealized(w)) return;
+ XtCallCallbacks(w, XtNcanvasExposeCallback, (XtPointer)&data);
+}
-/*
- * Actions
- */
-static void CanvasAction(Widget, XEvent*, String*, Cardinal*);
+static void CanvasResize(Widget w)
+{
+ if (!XtIsRealized(w)) return;
+ XtCallCallbacks(w, XtNcanvasResizeCallback, (XtPointer)w);
+}
-/*
- * Initialization
- */
-#define offset(field) XtOffsetOf(CanvasRec, template.field)
+static void CanvasAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ XtCallCallbacks(w, XtNcallback, (XtPointer)event);
+}
+
+#define offset(field) XtOffsetOf(CanvasRec, canvas.field)
static XtResource resources[] = {
-/*{
- name,
- class,
- type,
- size,
- offset,
- default_type,
- default_addr
- },*/
- {
- XtNtemplateResource,
- XtCCanvasResource,
- XtRCanvasResource,
- sizeof(char*),
- offset(resource),
- XtRString,
- (XtPointer)"default"
- },
+ { XtNcallback, XtCCallback, XtRCallback,
+ sizeof(XtCallbackList), offset(input_callback), XtRCallback, NULL },
+ { XtNcanvasExposeCallback, XtCcanvasExposeCallback, XtRCallback,
+ sizeof(XtCallbackList), offset(expose_callback), XtRCallback, NULL },
+ { XtNcanvasResizeCallback, XtCcanvasResizeCallback, XtRCallback,
+ sizeof(XtCallbackList), offset(resize_callback), XtRCallback, NULL },
};
#undef offset
static XtActionsRec actions[] =
{
- /*{name, procedure},*/
- {"template", CanvasAction},
+ {"canvas", CanvasAction},
};
static char translations[] =
-"<Key>:" "template()\n"
+"<Key>: canvas()\n\
+<Motion>: canvas()\n\
+<BtnDown>: canvas()\n\
+<BtnUp>: canvas()\n\
+"
;
#define Superclass (&widgetClassRec)
-CanvasClassRec templateClassRec = {
- /* core */
- {
- (WidgetClass)Superclass, /* superclass */
- "Canvas", /* class_name */
- sizeof(CanvasRec), /* widget_size */
- NULL, /* class_initialize */
- NULL, /* class_part_initialize */
- False, /* class_inited */
- CanvasInitialize, /* initialize */
- NULL, /* initialize_hook */
- XtInheritRealize, /* realize */
- actions, /* actions */
- XtNumber(actions), /* num_actions */
- resources, /* resources */
- XtNumber(resources), /* num_resources */
- NULLQUARK, /* xrm_class */
- True, /* compress_motion */
- True, /* compress_exposure */
- True, /* compress_enterleave */
- False, /* visible_interest */
- NULL, /* destroy */
- NULL, /* resize */
- NULL, /* expose */
- NULL, /* set_values */
- NULL, /* set_values_hook */
- XtInheritSetValuesAlmost, /* set_values_almost */
- NULL, /* get_values_hook */
- NULL, /* accept_focus */
- XtVersion, /* version */
- NULL, /* callback_private */
- translations, /* tm_table */
- XtInheritQueryGeometry, /* query_geometry */
- XtInheritDisplayAccelerator, /* display_accelerator */
- NULL, /* extension */
- },
- /* template */
- {
- NULL, /* extension */
- }
+CanvasClassRec canvasClassRec = {
+ /* core */
+ {
+ (WidgetClass)Superclass, /* superclass */
+ "Canvas", /* class_name */
+ sizeof(CanvasRec), /* widget_size */
+ NULL, /* class_initialize */
+ NULL, /* class_part_initialize */
+ False, /* class_inited */
+ CanvasInitialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ True, /* compress_motion */
+ True, /* compress_exposure */
+ True, /* compress_enterleave */
+ False, /* visible_interest */
+ NULL, /* destroy */
+ CanvasResize, /* resize */
+ CanvasExpose, /* expose */
+ NULL, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ translations, /* tm_table */
+ XtInheritQueryGeometry, /* query_geometry */
+ XtInheritDisplayAccelerator, /* display_accelerator */
+ NULL, /* extension */
+ },
+ /* canvas */
+ {
+ NULL, /* extension */
+ }
};
-WidgetClass templateWidgetClass = (WidgetClass)&templateClassRec;
-
-/*
- * Implementation
- */
-/*
- * Function:
- * CanvasInitialize
- *
- * Parameters:
- * request - requested widget
- * w - the widget
- * args - arguments
- * num_args - number of arguments
- *
- * Description:
- * Initializes widget instance.
- */
-/*ARGSUSED*/
-static void
-CanvasInitialize(Widget request, Widget w, ArgList args, Cardinal *num_args)
-{
- CanvasWidget tw = (CanvasWidget)w;
-
- tw->template.private = NULL;
-}
-
-/*
- * Function:
- * CanvasFunction
- *
- * Parameters:
- * tw - template widget
- * x - x coordinate
- * y - y coordinate
- * force - force action
- *
- * Description:
- * This function does nothing.
- *
- * Return:
- * Parameter force
- */
-/*ARGSUSED*/
-static Bool
-CanvasFunction(CanvasWidget tw, int x, int y, Bool force)
-{
- return (force);
-}
-
-/*
- * Function:
- * CanvasAction
- *
- * Parameters:
- * w - template widget
- * event - event that caused this action
- * params - parameters
- * num_params - number of parameters
- *
- * Description:
- * This function does nothing.
- */
-/*ARGSUSED*/
-static void
-CanvasAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
-{
-}
+WidgetClass canvasWidgetClass = (WidgetClass)&canvasClassRec;
diff --git a/xc/programs/Xserver/hw/dmx/config/Canvas.h b/xc/programs/Xserver/hw/dmx/config/Canvas.h
index 3c9c32a09..a36851a6d 100644
--- a/xc/programs/Xserver/hw/dmx/config/Canvas.h
+++ b/xc/programs/Xserver/hw/dmx/config/Canvas.h
@@ -38,39 +38,19 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Intrinsic.h>
-/****************************************************************
- *
- * Canvas widget
- *
- ****************************************************************/
-
-/* Resources:
-
- Name Class RepType Default Value
- ---- ----- ------- -------------
- background Background Pixel XtDefaultBackground
- border BorderColor Pixel XtDefaultForeground
- borderWidth BorderWidth Dimension 1
- destroyCallback Callback Pointer NULL
- height Height Dimension 0
- mappedWhenManaged MappedWhenManaged Boolean True
- sensitive Sensitive Boolean True
- width Width Dimension 0
- x Position Position 0
- y Position Position 0
-
-*/
-
-/* define any special resource names here that are not in <X11/StringDefs.h> */
-#define XtNcanvasResource "canvasResource"
-
-#define XtCCanvasResource "CanvasResource"
+#define XtNcanvasExposeCallback "canvasExposeCallback"
+#define XtCcanvasExposeCallback "CanvasExposeCallback"
+#define XtNcanvasResizeCallback "canvasResizeCallback"
+#define XtCcanvasResizeCallback "CanvasResizeCallback"
-/* declare specific CanvasWidget class and instance datatypes */
typedef struct _CanvasClassRec *CanvasWidgetClass;
typedef struct _CanvasRec *CanvasWidget;
-
-/* declare the class constant */
extern WidgetClass canvasWidgetClass;
+typedef struct _CanvasExposeDataRec {
+ Widget w;
+ XEvent *event;
+ Region region;
+} CanvasExposeDataRec, *CanvasExposeDataPtr;
+
#endif /* _Canvas_h */
diff --git a/xc/programs/Xserver/hw/dmx/config/CanvasP.h b/xc/programs/Xserver/hw/dmx/config/CanvasP.h
index 63b33798d..98f95b94e 100644
--- a/xc/programs/Xserver/hw/dmx/config/CanvasP.h
+++ b/xc/programs/Xserver/hw/dmx/config/CanvasP.h
@@ -36,14 +36,11 @@ in this Software without prior written authorization from The Open Group.
#ifndef _CanvasP_h
#define _CanvasP_h
-#include <X11/Xaw/Canvas.h>
+#include "Canvas.h"
/* include superclass private header file */
#include <X11/CoreP.h>
-/* define unique representation types not found in <X11/StringDefs.h> */
-#define XtRCanvasResource "CanvasResource"
-
typedef struct {
XtPointer extension;
} CanvasClassPart;
@@ -56,19 +53,14 @@ typedef struct _CanvasClassRec {
extern CanvasClassRec canvasClassRec;
typedef struct {
- /* resources */
- char* resource;
- /* private */
- char *private;
+ XtCallbackList input_callback;
+ XtCallbackList expose_callback;
+ XtCallbackList resize_callback;
} CanvasPart;
typedef struct _CanvasRec {
- CorePart core;
-#if defined(__cplusplus) || defined(c_plusplus)
- CanvasPart c_canvas;
-#else
+ CorePart core;
CanvasPart canvas;
-#endif
} CanvasRec;
#endif /* _CanvasP_h */