summaryrefslogtreecommitdiff
path: root/xts5/Xt8
diff options
context:
space:
mode:
Diffstat (limited to 'xts5/Xt8')
-rw-r--r--xts5/Xt8/XtConfigureWidget/XtConfigureWidget.m934
-rw-r--r--xts5/Xt8/XtMakeGeometryRequest/XtMakeGeometryRequest.m531
-rw-r--r--xts5/Xt8/XtMakeResizeRequest/XtMakeResizeRequest.m649
-rw-r--r--xts5/Xt8/XtMoveWidget/XtMoveWidget.m798
-rw-r--r--xts5/Xt8/XtQueryGeometry/XtQueryGeometry.m905
-rw-r--r--xts5/Xt8/XtQueryGeometry/tqrygomty.c780
-rw-r--r--xts5/Xt8/XtResizeWidget/XtResizeWidget.m862
-rw-r--r--xts5/Xt8/XtResizeWindow/XtResizeWindow.m759
8 files changed, 6218 insertions, 0 deletions
diff --git a/xts5/Xt8/XtConfigureWidget/XtConfigureWidget.m b/xts5/Xt8/XtConfigureWidget/XtConfigureWidget.m
new file mode 100644
index 00000000..3d68df04
--- /dev/null
+++ b/xts5/Xt8/XtConfigureWidget/XtConfigureWidget.m
@@ -0,0 +1,934 @@
+Copyright (c) 2005 X.Org Foundation LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+$Header: /cvs/xtest/xtest/xts5/tset/Xt8/XtConfigureWidget/XtConfigureWidget.m,v 1.1 2005-02-12 14:38:22 anderson Exp $
+
+Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995
+Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993
+All Rights Reserved.
+
+>>#
+>># Project: VSW5
+>>#
+>># File: tset/Xt8/XtConfigureWidget/XtConfigureWidget.m
+>>#
+>># Description:
+>># Tests for XtConfigureWidget()
+>>#
+>># Modifications:
+>># $Log: tconwidgt.m,v $
+>># Revision 1.1 2005-02-12 14:38:22 anderson
+>># Initial revision
+>>#
+>># Revision 8.0 1998/12/23 23:36:54 mar
+>># Branch point for Release 5.0.2
+>>#
+>># Revision 7.0 1998/10/30 22:59:47 mar
+>># Branch point for Release 5.0.2b1
+>>#
+>># Revision 6.0 1998/03/02 05:28:01 tbr
+>># Branch point for Release 5.0.1
+>>#
+>># Revision 5.0 1998/01/26 03:24:35 tbr
+>># Branch point for Release 5.0.1b1
+>>#
+>># Revision 4.0 1995/12/15 09:17:50 tbr
+>># Branch point for Release 5.0.0
+>>#
+>># Revision 3.1 1995/12/15 01:22:07 andy
+>># Prepare for GA Release
+>>#
+>>EXTERN
+#include <X11/IntrinsicP.h>
+#include <X11/ConstrainP.h>
+#include <X11/CoreP.h>
+#include <xt/SquareCelP.h>
+
+XtAppContext app_ctext;
+Widget topLevel, panedw, boxw1, boxw2;
+Widget labelw, rowcolw, click_quit;
+
+/*
+ * SquareCell.c - Square Widget
+ */
+#define INTERNAL_WIDTH 2
+#define INTERNAL_HEIGHT 4
+#define DEFAULT_PIXMAP_WIDTH 1 /* in cells */
+#define DEFAULT_PIXMAP_HEIGHT 1 /* in cells */
+#define DEFAULT_CELL_SIE 20 /* in pixels */
+/* values for instance variable is_drawn */
+#define DRAWN 1
+#define UNDRAWN 0
+/* modes for drawing */
+#define DRAW 1
+#define UNDRAW 0
+#define MAXLINES 10 /* max of horiz or vertical cells */
+#define SCROLLBARWIDTH 15
+#define DEFAULTWIDTH 300 /* widget size when show_all is False */
+#define offset(field) XtOffsetOf(SquareCellRec, field)
+static XtResource resources[] = {
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(squareCell.foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XavsNtoggleCallback,
+ XavsCToggleCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(squareCell.callback),
+ XtRCallback,
+ NULL
+ },
+ {
+ XavsNcellSizeInPixels,
+ XavsCCellSizeInPixels,
+ XtRInt, sizeof(int),
+ offset(squareCell.cell_size_in_pixels),
+ XtRImmediate,
+ (XtPointer)DEFAULT_CELL_SIE
+ },
+ {
+ XavsNpixmapWidthInCells,
+ XavsCPixmapWidthInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_width_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_WIDTH
+ },
+ {
+ XavsNpixmapHeightInCells,
+ XavsCPixmapHeightInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_height_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_HEIGHT
+ },
+ {
+ XavsNcurX,
+ XavsCCurX,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_x),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcurY,
+ XavsCCurY,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_y),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcellArray,
+ XavsCCellArray,
+ XtRString,
+ sizeof(String),
+ offset(squareCell.cell),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNshowEntireBitmap,
+ XavsCShowEntireBitmap,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(squareCell.show_all),
+ XtRImmediate,
+ (XtPointer) TRUE
+ },
+};
+/* Declaration of methods */
+static void Initialize();
+static void Redisplay();
+static void Destroy();
+static void Resize();
+static Boolean SetValues();
+static XtGeometryResult QueryGeometry();
+/* these Core methods not needed by SquareCell:
+ *
+ * static void ClassInitialize();
+ * static void Realize();
+ */
+/* the following are private functions unique to SquareCell */
+static void DrawPixmaps(), DoCell(), ChangeCellSize();
+/* the following are actions of SquareCell */
+static void DrawCell(), UndrawCell(), ToggleCell();
+/* The following are public functions of SquareCell, declared extern
+ * in the public include file: */
+char *SquareCellGetArray();
+static char defaultTranslations[] =
+ "<Btn1Down>: DrawCell() \n\
+ <Btn2Down>: UndrawCell() \n\
+ <Btn3Down>: ToggleCell() \n\
+ <Btn1Motion>: DrawCell() \n\
+ <Btn2Motion>: UndrawCell() \n\
+ <Btn3Motion>: ToggleCell()";
+static XtActionsRec actions[] = {
+ {"DrawCell", DrawCell},
+ {"UndrawCell", UndrawCell},
+ {"ToggleCell", ToggleCell},
+};
+/* definition in SquareCell.h */
+static SquareCellPointInfo info;
+SquareCellClassRec squareCellClassRec = {
+ {
+ /* core_class fields */
+ /* superclass */ (WidgetClass) &coreClassRec,
+ /* class_name */ "SquareCell",
+ /* widget_size */ sizeof(SquareCellRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ {/* simple_class fields */
+ /* change_sensitive */ XtInheritChangeSensitive,
+ },
+ {
+ /* extension */ 0,
+ },
+};
+WidgetClass squareCellWidgetClass = (WidgetClass) & squareCellClassRec;
+static void
+GetDrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground | GCDashOffset |
+ GCDashList | GCLineStyle;
+ /*
+ * Setting foreground and background to 1 and 0 looks like a
+ * kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied with a
+ * separate GC when the pixmap is copied into the window.
+ */
+ values.foreground = 1;
+ values.background = 0;
+ values.dashes = 1;
+ values.dash_offset = 0;
+ values.line_style = LineOnOffDash;
+ cw->squareCell.draw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetUndrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ /* this looks like a kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied as the
+ * pixmap is copied into the window.
+ */
+ values.foreground = 0;
+ values.background = 1;
+ cw->squareCell.undraw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetCopyGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ values.foreground = cw->squareCell.foreground;
+ values.background = cw->core.background_pixel;
+ cw->squareCell.copy_gc = XtGetGC((Widget)cw, mask, &values);
+}
+static void
+Initialize(treq, tnew, args, num_args)
+Widget treq, tnew;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget new = (SquareCellWidget) tnew;
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ /*
+ * Check instance values set by resources that may be invalid.
+ */
+ if ((new->squareCell.pixmap_width_in_cells < 1) ||
+ (new->squareCell.pixmap_height_in_cells < 1)) {
+ XtWarning("SquareCell: pixmapWidth and/or pixmapHeight is too small (using 10 x 10)");
+ new->squareCell.pixmap_width_in_cells = 10;
+ new->squareCell.pixmap_height_in_cells = 10;
+ }
+ if (new->squareCell.cell_size_in_pixels < 5) {
+ XtWarning("SquareCell: cellSize is too small (using 5)");
+ new->squareCell.cell_size_in_pixels = 5;
+ }
+ if ((new->squareCell.cur_x < 0) || (new->squareCell.cur_y < 0)) {
+ XtWarning("SquareCell: cur_x and cur_y must be non-negative (using 0, 0)");
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ }
+ if (new->squareCell.cell == NULL)
+ new->squareCell.cell = XtCalloc(
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.pixmap_height_in_cells, sizeof(char));
+ else
+ new->squareCell.user_allocated = True; /* user supplied cell array */
+ new->squareCell.pixmap_width_in_pixels =
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ new->squareCell.pixmap_height_in_pixels =
+ new->squareCell.pixmap_height_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ if (new->core.width == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.width = (new->squareCell.pixmap_width_in_pixels
+ > DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_width_in_pixels);
+ else
+ new->core.width = new->squareCell.pixmap_width_in_pixels;
+ }
+ if (new->core.height == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.height =
+ (new->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_height_in_pixels);
+ else
+ new->core.height = new->squareCell.pixmap_height_in_pixels;
+ }
+ CreateBigPixmap(new);
+ GetDrawGC(new);
+ GetUndrawGC(new);
+ GetCopyGC(new);
+ DrawIntoBigPixmap(new);
+}
+static void
+Redisplay(w, event)
+Widget w;
+XExposeEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ register int x, y;
+ unsigned int width, height;
+ if (!XtIsRealized((Widget)cw))
+ return;
+ if (event) { /* called from btn-event or expose */
+ x = event->x;
+ y = event->y;
+ width = event->width;
+ height = event->height;
+ }
+ else { /* called because complete redraw */
+ x = 0;
+ y = 0;
+ width = cw->squareCell.pixmap_width_in_pixels;
+ height = cw->squareCell.pixmap_height_in_pixels;
+ }
+ if (DefaultDepthOfScreen(XtScreen((Widget)cw)) == 1)
+ XCopyArea(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y);
+ else
+ XCopyPlane(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y, 1);
+}
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget curcw = (SquareCellWidget) current;
+ SquareCellWidget newcw = (SquareCellWidget) new;
+ Boolean do_redisplay = False;
+ /*
+ ** XtSetValues invoked procedure SetValues
+ */
+ if (curcw->squareCell.foreground != newcw->squareCell.foreground) {
+ XtReleaseGC((Widget)curcw, curcw->squareCell.copy_gc);
+ GetCopyGC(newcw);
+ do_redisplay = True;
+ }
+ if ((curcw->squareCell.cur_x != newcw->squareCell.cur_x) ||
+ (curcw->squareCell.cur_y != newcw->squareCell.cur_y))
+ do_redisplay = True;
+ if (curcw->squareCell.cell_size_in_pixels !=
+ newcw->squareCell.cell_size_in_pixels) {
+ ChangeCellSize(curcw, newcw->squareCell.cell_size_in_pixels);
+ do_redisplay = True;
+ }
+ if (curcw->squareCell.pixmap_width_in_cells !=
+ newcw->squareCell.pixmap_width_in_cells) {
+ newcw->squareCell.pixmap_width_in_cells =
+ curcw->squareCell.pixmap_width_in_cells;
+ XtWarning("SquareCell: pixmap_width_in_cells cannot be set by XtSetValues.\n");
+ }
+ if (curcw->squareCell.pixmap_height_in_cells !=
+ newcw->squareCell.pixmap_height_in_cells) {
+ newcw->squareCell.pixmap_height_in_cells =
+ curcw->squareCell.pixmap_height_in_cells;
+ XtWarning("SquareCell: pixmap_height_in_cells cannot be set by XtSetValues.\n");
+ }
+ return do_redisplay;
+}
+static void
+Destroy(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ if (cw->squareCell.big_picture)
+ XFreePixmap(XtDisplay(cw), cw->squareCell.big_picture);
+ if (cw->squareCell.draw_gc)
+ XFreeGC(XtDisplay(cw), cw->squareCell.draw_gc);
+ if (cw->squareCell.undraw_gc)
+ XFreeGC(XtDisplay(cw), cw->squareCell.undraw_gc);
+ if (cw->squareCell.copy_gc)
+ XFreeGC(XtDisplay(cw), cw->squareCell.copy_gc);
+ /* Free memory allocated with Calloc. This was done
+ * only if application didn't supply cell array.
+ */
+ if (!cw->squareCell.user_allocated)
+ XtFree(cw->squareCell.cell);
+}
+static void
+DrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.draw_gc, DRAW, cw, event);
+}
+static void
+UndrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.undraw_gc, UNDRAW, cw, event);
+}
+static void
+ToggleCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ static int oldx = -1, oldy = -1;
+ GC gc;
+ int mode;
+ int newx, newy;
+ /* This is strictly correct, but doesn't
+ * seem to be necessary */
+ if (event->type == ButtonPress) {
+ newx = (cw->squareCell.cur_x + ((XButtonEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XButtonEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ else {
+ newx = (cw->squareCell.cur_x + ((XMotionEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XMotionEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ if ((mode = cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells]) == DRAWN) {
+ gc = cw->squareCell.undraw_gc;
+ mode = UNDRAW;
+ }
+ else {
+ gc = cw->squareCell.draw_gc;
+ mode = DRAW;
+ }
+ if (oldx != newx || oldy != newy) {
+ oldx = newx;
+ oldy = newy;
+ DrawPixmaps(gc, mode, cw, event);
+ }
+}
+static void
+DrawPixmaps(gc, mode, w, event)
+GC gc;
+int mode;
+Widget w;
+XButtonEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int newx = (cw->squareCell.cur_x + event->x) /
+ cw->squareCell.cell_size_in_pixels;
+ int newy = (cw->squareCell.cur_y + event->y) /
+ cw->squareCell.cell_size_in_pixels;
+ XExposeEvent fake_event;
+ /* if already done, return */
+ if (cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] == mode)
+ return;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay(cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels*newx + 2,
+ cw->squareCell.cell_size_in_pixels*newy + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+ cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] = mode;
+ info.mode = mode;
+ info.newx = newx;
+ info.newy = newy;
+ fake_event.x = cw->squareCell.cell_size_in_pixels * newx - cw->squareCell.cur_x;
+ fake_event.y = cw->squareCell.cell_size_in_pixels * newy - cw->squareCell.cur_y;
+ fake_event.width = cw->squareCell.cell_size_in_pixels;
+ fake_event.height = cw->squareCell.cell_size_in_pixels;
+ Redisplay(cw, &fake_event);
+ XtCallCallbacks((Widget)cw, XavsNtoggleCallback, &info);
+}
+CreateBigPixmap(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* always a 1 bit deep pixmap, regardless of screen depth */
+ cw->squareCell.big_picture = XCreatePixmap(XtDisplay((Widget)cw),
+ RootWindow(XtDisplay((Widget)cw), DefaultScreen(XtDisplay((Widget)cw))),
+ cw->squareCell.pixmap_width_in_pixels + 2,
+ cw->squareCell.pixmap_height_in_pixels + 2, 1);
+}
+DrawIntoBigPixmap(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int n_horiz_segments, n_vert_segments;
+ XSegment segment[MAXLINES];
+ register int x, y;
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ cw->squareCell.undraw_gc, 0, 0,
+ cw->squareCell.pixmap_width_in_pixels
+ + 2, cw->squareCell.pixmap_height_in_pixels + 2);
+ n_horiz_segments = cw->squareCell.pixmap_height_in_cells + 1;
+ n_vert_segments = cw->squareCell.pixmap_width_in_cells + 1;
+ for (x = 0; x < n_horiz_segments; x++) {
+ segment[x].x1 = 0;
+ segment[x].x2 = (short) cw->squareCell.pixmap_width_in_pixels;
+ segment[x].y1 = (short) cw->squareCell.cell_size_in_pixels * x;
+ segment[x].y2 = (short) cw->squareCell.cell_size_in_pixels * x;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_horiz_segments);
+ for (y = 0; y < n_vert_segments; y++) {
+ segment[y].x1 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].x2 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].y1 = 0;
+ segment[y].y2 = (short) cw->squareCell.pixmap_height_in_pixels;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_vert_segments);
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+/* A Public function, not static */
+char *
+SquareCellGetArray(w, width_in_cells, height_in_cells)
+Widget w;
+int *width_in_cells, *height_in_cells;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ *width_in_cells = cw->squareCell.pixmap_width_in_cells;
+ *height_in_cells = cw->squareCell.pixmap_height_in_cells;
+ return (cw->squareCell.cell);
+}
+static void
+Resize(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ avs_set_event(1,1);
+ /* resize does nothing unless new size is bigger than entire pixmap */
+ if ((cw->core.width > cw->squareCell.pixmap_width_in_pixels) &&
+ (cw->core.height > cw->squareCell.pixmap_height_in_pixels)) {
+ /*
+ * Calculate the maximum cell size that will allow the
+ * entire bitmap to be displayed.
+ */
+ Dimension w_temp_cell_size_in_pixels, h_temp_cell_size_in_pixels;
+ Dimension new_cell_size_in_pixels;
+
+ w_temp_cell_size_in_pixels = cw->core.width / cw->squareCell.pixmap_width_in_cells;
+ h_temp_cell_size_in_pixels = cw->core.height / cw->squareCell.pixmap_height_in_cells;
+
+ if (w_temp_cell_size_in_pixels < h_temp_cell_size_in_pixels)
+ new_cell_size_in_pixels = w_temp_cell_size_in_pixels;
+ else
+ new_cell_size_in_pixels = h_temp_cell_size_in_pixels;
+
+ /* if size change mandates a new pixmap, make one */
+ if (new_cell_size_in_pixels != cw->squareCell.cell_size_in_pixels)
+ ChangeCellSize(cw, new_cell_size_in_pixels);
+ }
+}
+static void
+ChangeCellSize(w, new_cell_size)
+Widget w;
+int new_cell_size;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int x, y;
+ cw->squareCell.cell_size_in_pixels = new_cell_size;
+ /* recalculate variables based on cell size */
+ cw->squareCell.pixmap_width_in_pixels =
+ cw->squareCell.pixmap_width_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+ cw->squareCell.pixmap_height_in_pixels =
+ cw->squareCell.pixmap_height_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+
+ /* destroy old and create new pixmap of correct size */
+ XFreePixmap(XtDisplay((Widget)cw), cw->squareCell.big_picture);
+ CreateBigPixmap(cw);
+
+ /* draw lines into new pixmap */
+ DrawIntoBigPixmap(cw);
+
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+static void
+DoCell(w, x, y, gc)
+Widget w;
+int x, y;
+GC gc;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels * x + 2,
+ cw->squareCell.cell_size_in_pixels * y + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+}
+static XtGeometryResult QueryGeometry(w, proposed, answer)
+Widget w;
+XtWidgetGeometry *proposed, *answer;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* set fields we care about */
+ answer->request_mode = CWWidth | CWHeight;
+ /* initial width and height */
+ if (cw->squareCell.show_all == True)
+ answer->width = cw->squareCell.pixmap_width_in_pixels;
+ else
+ answer->width = (cw->squareCell.pixmap_width_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_width_in_pixels;
+ if (cw->squareCell.show_all == True)
+ answer->height = cw->squareCell.pixmap_height_in_pixels;
+ else
+ answer->height = (cw->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_height_in_pixels;
+ if ( ((proposed->request_mode & (CWWidth | CWHeight))
+ == (CWWidth | CWHeight)) &&
+ proposed->width == answer->width &&
+ proposed->height == answer->height)
+ return XtGeometryYes;
+ else if (answer->width == cw->core.width &&
+ answer->height == cw->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
+>>SET tpstartup avs_alloc_sem
+>>SET tpcleanup avs_free_sem
+>>TITLE XtConfigureWidget Xt8
+void
+XtConfigureWidget(w, x, y, width, height, border_width)
+>>ASSERTION Good A
+A successful call to
+void XtConfigureWidget(w, x, y, width, height, border_width)
+when at least one of
+.A x,
+.A y,
+.A width,
+.A height,
+or
+.A border_width
+is different from its corresponding value in the
+object
+.A w
+shall write the specified values into the object.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+pid_t pid2;
+int x, y, width, height, border_width;
+
+ FORK(pid2);
+ avs_xt_hier("Tconwidgt1", "XtConfigureWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Change geometry fields of squarew widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(squarew, &intended, &geom);
+ x = geom.x + 10;
+ y = geom.y + 10;
+ width = geom.width + 10;
+ height = geom.height + 10;
+ border_width = geom.border_width + 1;
+ tet_infoline("TEST: Call XtConfigureWidget");
+ XtConfigureWidget(squarew, x, y, width, height, border_width);
+ tet_infoline("TEST: Square widget geometry values");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(x, geometry_good.x, "x");
+ check_dec(y, geometry_good.y, "y");
+ check_dec(width, geometry_good.width, "width");
+ check_dec(height, geometry_good.height, "height");
+ check_dec(border_width, geometry_good.border_width,
+ "border_width");
+ KROF(pid2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When
+.A w
+is a widget that is realized and at least one of
+.A x
+or
+.A y
+is different from its corresponding value in the
+widget a call to
+void XtConfigureWidget(w, x, y, width, height, border_width)
+shall move the widget to the position specified by
+.A x
+and
+.A y.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+pid_t pid2;
+int x, y, width, height, border_width;
+
+ /*should be tested with screen capture*/
+ FORK(pid2);
+ avs_xt_hier("Tconwidgt1", "XtConfigureWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Change geometry fields of squarew widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(squarew, &intended, &geom);
+ x = geom.x + 10;
+ y = geom.y + 10;
+ width = geom.width + 10;
+ height = geom.height + 10;
+ border_width = geom.border_width + 1;
+ tet_infoline("TEST: Call XtConfigureWidget");
+ XtConfigureWidget(squarew, x, y, width, height, border_width);
+ tet_infoline("TEST: Square widget has been moved");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(x, geometry_good.x, "x");
+ check_dec(y, geometry_good.y, "y");
+ check_dec(width, geometry_good.width, "width");
+ check_dec(height, geometry_good.height, "height");
+ check_dec(border_width, geometry_good.border_width,
+ "border_width");
+ KROF(pid2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When
+.A w
+is a widget that is realized and at least one of
+.A width,
+.A height,
+or
+.A border_width
+is different from its corresponding value in the
+widget a call to
+void XtConfigureWidget(w, x, y, width, height, border_width)
+shall resize the widget to the specified values.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+pid_t pid2;
+int x, y, width, height, border_width;
+
+ /*should be tested with screen capture*/
+ FORK(pid2);
+ avs_xt_hier("Tconwidgt1", "XtConfigureWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Change geometry fields of squarew widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(squarew, &intended, &geom);
+ x = geom.x + 10;
+ y = geom.y + 10;
+ width = geom.width + 10;
+ height = geom.height + 10;
+ border_width = geom.border_width + 1;
+ tet_infoline("TEST: Call XtConfigureWidget");
+ XtConfigureWidget(squarew, x, y, width, height, border_width);
+ tet_infoline("TEST: Square widget has been resized");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(x, geometry_good.x, "x");
+ check_dec(y, geometry_good.y, "y");
+ check_dec(width, geometry_good.width, "width");
+ check_dec(height, geometry_good.height, "height");
+ check_dec(border_width, geometry_good.border_width,
+ "border_width");
+ KROF(pid2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A successful call to
+void XtConfigureWidget(w, x, y, width, height, border_width)
+when at least one of
+.A width,
+.A height,
+or
+.A border_width
+is different from its corresponding value in the
+object
+.A w
+shall invoke the resize procedure of the specified object.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+int x, y, width, height, border_width;
+int invoked = 0;
+pid_t pid2;
+
+ FORK(pid2);
+ avs_xt_hier("Tconwidgt2", "XtConfigureWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("TEST: Change height and width of squarew widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(squarew, &intended, &geom);
+ x = geom.x;
+ y = geom.y;
+ width = geom.width + 10;
+ height = geom.height + 10;
+ border_width = geom.border_width;
+ tet_infoline("TEST: Call XtConfigureWidget");
+ XtConfigureWidget(squarew, x, y, width, height, border_width);
+ tet_infoline("TEST: Square widget has been resized");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(width, geometry_good.width, "width");
+ check_dec(height, geometry_good.height, "height");
+ tet_infoline("TEST: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("TEST: Procedure Resize was invoked");
+ invoked = avs_get_event(1);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Procedure Resize was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ KROF(pid2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A call to
+void XtConfigureWidget(w, x, y, width, height, border_width)
+when
+.A x,
+.A y,
+.A width,
+.A height,
+and
+.A border_width
+are all equal to their corresponding values in the
+object
+.A w
+shall return immediately.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+int x, y, width, height, border_width;
+pid_t pid2;
+
+ FORK(pid2);
+ avs_xt_hier("Tconwidgt3", "XtConfigureWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("TEST: Put same geometry fields to squarew widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(squarew, &intended, &geom);
+ x = geom.x;
+ y = geom.y;
+ width = geom.width;
+ height = geom.height;
+ border_width = geom.border_width;
+ tet_infoline("TEST: Call XtConfigureWidget");
+ XtConfigureWidget(squarew, x, y, width, height, border_width);
+ tet_infoline("TEST: XtConfigureWidget returned immediately");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(x, geometry_good.x, "x");
+ check_dec(y, geometry_good.y, "y");
+ check_dec(width, geometry_good.width, "width");
+ check_dec(height, geometry_good.height, "height");
+ check_dec(border_width, geometry_good.border_width, "border_width");
+ KROF(pid2);
+ tet_result(TET_PASS);
diff --git a/xts5/Xt8/XtMakeGeometryRequest/XtMakeGeometryRequest.m b/xts5/Xt8/XtMakeGeometryRequest/XtMakeGeometryRequest.m
new file mode 100644
index 00000000..6f282cb6
--- /dev/null
+++ b/xts5/Xt8/XtMakeGeometryRequest/XtMakeGeometryRequest.m
@@ -0,0 +1,531 @@
+Copyright (c) 2005 X.Org Foundation LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+ $Header: /cvs/xtest/xtest/xts5/tset/Xt8/XtMakeGeometryRequest/XtMakeGeometryRequest.m,v 1.1 2005-02-12 14:38:23 anderson Exp $
+
+Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995
+Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993
+All Rights Reserved.
+
+>>#
+>># Project: VSW5
+>>#
+>># File: tset/Xt8/XtMakeGeometryRequest/XtMakeGeometryRequest.m
+>>#
+>># Description:
+>># Tests for XtMakeGeometryRequest()
+>>#
+>># Modifications:
+>># $Log: tmkgmreqt.m,v $
+>># Revision 1.1 2005-02-12 14:38:23 anderson
+>># Initial revision
+>>#
+>># Revision 8.0 1998/12/23 23:36:52 mar
+>># Branch point for Release 5.0.2
+>>#
+>># Revision 7.0 1998/10/30 22:59:45 mar
+>># Branch point for Release 5.0.2b1
+>>#
+>># Revision 6.1 1998/06/26 21:03:35 andy
+>># Changed test 5 so that modification to geometry of destroyed widget
+>># is done within destory callback. SR 188.
+>>#
+>># Revision 6.0 1998/03/02 05:27:59 tbr
+>># Branch point for Release 5.0.1
+>>#
+>># Revision 5.0 1998/01/26 03:24:33 tbr
+>># Branch point for Release 5.0.1b1
+>>#
+>># Revision 4.0 1995/12/15 09:17:40 tbr
+>># Branch point for Release 5.0.0
+>>#
+>># Revision 3.1 1995/12/15 01:21:55 andy
+>># Prepare for GA Release
+>>#
+>>EXTERN
+/*
+#include <X11/IntrinsicP.h>
+#include <X11/ConstrainP.h>
+#include <X11/CoreP.h>
+*/
+#include <AvsForm.h>
+#include <AvsForm2.h>
+#include <AvsForm3.h>
+
+void XtWMH_Proc(str1, str2, str3, str4, str5, car)
+String str1, str2, str3, str4, *str5;
+Cardinal *car;
+{
+ avs_set_event(1,1);
+}
+
+Widget labelw_msg1;
+
+XtWidgetGeometry intended5;
+XtWidgetGeometry geom5;
+
+/*destroy callback for test 5*/
+void XtCBP(w, client_data, call_data)
+Widget w;
+XtPointer client_data, call_data;
+{
+ XtGeometryResult result;
+ XtWidgetGeometry request;
+ XtWidgetGeometry reply_return;
+
+ tet_infoline("INFO: Inside destroy callback");
+ avs_set_event(2,1);
+ tet_infoline("PREP: Change geometry of labelw_msg1 widget");
+ request.request_mode = intended5.request_mode;
+ request.x = geom5.x + 10;
+ request.y = geom5.y + 10;
+ request.width = geom5.width + 10;
+ request.height = geom5.height + 10;
+ request.border_width = geom5.border_width + 1;
+ result = XtMakeGeometryRequest(labelw_msg1, &request, &reply_return);
+ tet_infoline("TEST: Return value is XtGeometryNo");
+ check_dec(XtGeometryNo, result, "XtGeometryNo");
+}
+
+XtAppContext app_ctext;
+Widget topLevel, panedw, boxw1, boxw2;
+Widget labelw, rowcolw, click_quit;
+
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/Logo.h>
+extern WidgetClass avsCompWidgetClass, avsWidgetClass;
+>>SET tpstartup avs_alloc_sem
+>>SET tpcleanup avs_free_sem
+>>TITLE XtMakeGeometryRequest Xt8
+XtGeometryResult
+XtMakeGeometryRequest(w, request, reply_return)
+>>ASSERTION Good A
+When the widget
+.A w
+is unmanaged a call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+shall change those geometry fields in the widget that are
+specified in the request_mode member of the structure pointed
+to by
+.A request
+to the corresponding values specified in other members of
+the structure and return XtGeometryYes.
+>>CODE
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Widget rowcolw_good;
+pid_t pid2;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkgmreqt1", "XtMakeGeometryRequest");
+ tet_infoline("PREP: Create rowcolw widget in boxw1 widget");
+ rowcolw_good = (Widget) CreateRowColWidget(boxw1);
+ tet_infoline("TEST: Change geometry of unmanaged widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(rowcolw_good, &intended, &geom);
+ request.request_mode = intended.request_mode;
+ request.x = geom.x + 10;
+ request.y = geom.y + 10;
+ request.width = geom.width + 10;
+ request.height = geom.height + 10;
+ request.border_width = geom.border_width + 1;
+ result = XtMakeGeometryRequest(rowcolw_good, &request, &reply_return);
+ tet_infoline("TEST: return value is XtGeometryYes");
+ check_dec(XtGeometryYes, result, "XtMakeGeometryRequest result");
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the parent of the widget
+.A w
+is not realized a call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+shall change those geometry fields in the widget that are
+specified in the request_mode member of the structure pointed
+to by
+.A request
+to the corresponding values specified in other members of
+the structure and return XtGeometryYes.
+>>CODE
+Widget rowcolw_good;
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+pid_t pid2;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkgmreqt1", "XtMakeGeometryRequest");
+ tet_infoline("TEST: Change geometry of unrealized widget");
+ rowcolw_good = (Widget) CreateRowColWidget(boxw1);
+ tet_infoline("PREP: Change geometry of rowcolw_good widget, parent widget");
+ tet_infoline("PREP: unrealized.");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(rowcolw_good, &intended, &geom);
+ request.request_mode = intended.request_mode;
+ request.x = geom.x + 10;
+ request.y = geom.y + 10;
+ request.width = geom.width + 10;
+ request.height = geom.height + 10;
+ request.border_width = geom.border_width + 1;
+ result = XtMakeGeometryRequest(rowcolw_good, &request, &reply_return);
+ tet_infoline("TEST: return value is XtGeometryYes");
+ check_dec(XtGeometryYes, result, "XtMakeGeometryRequest result");
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the class of the parent of the widget
+.A w
+is not a subclass of compositeWidgetClass a call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+shall issue an invalidParent error.
+>>CODE
+Widget labelw_good, labelw_good2;
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+pid_t pid2;
+int invoked;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkgmreqt6", "XtMakeGeometryRequest");
+ XtAppSetErrorMsgHandler(app_ctext, XtWMH_Proc);
+ tet_infoline("PREP: Create core class test widgets");
+ labelw_good = XtVaCreateWidget(
+ "labelw_good",
+ coreWidgetClass,
+ boxw1,
+ NULL
+ );
+ labelw_good2 = XtVaCreateWidget(
+ "labelw_good2",
+ coreWidgetClass,
+ labelw_good,
+ NULL
+ );
+ (void) ConfigureDimension(topLevel, labelw_good);
+ (void) ConfigureDimension(topLevel, labelw_good2);
+ tet_infoline("TEST: Call XtMakeGeometryRequest");
+ result = XtMakeGeometryRequest(labelw_good2, &request, &reply_return);
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_infoline("TEST: Error handler was invoked");
+ invoked = avs_get_event(1);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Error handler was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the geometry_manager field of the parent of the widget
+.A w
+is NULL a call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+shall issue an invalidGeometryManager error.
+>>CODE
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Widget formw_good, formw_good2, labelw_good;
+pid_t pid2;
+int invoked;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkgmreqt1", "XtMakeGeometryRequest");
+ XtAppSetErrorMsgHandler(app_ctext, XtWMH_Proc);
+ tet_infoline("PREP: Create avsform3 widget in avsform widget");
+ formw_good2 = XtCreateManagedWidget("avsform3",
+ avsform3WidgetClass,
+ boxw1,
+ NULL,
+ 0);
+ labelw_good = (Widget) CreateLabelWidget("Hello", formw_good2);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("TEST: Change geometry of labelw_good widget");
+ request.request_mode = 0;
+ request.x = 0;
+ request.y = 0;
+ request.width = 0;
+ request.height = 0;
+ request.border_width = 0;
+ result = XtMakeGeometryRequest(labelw_good, &request, &reply_return);
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_infoline("TEST: Error handler was invoked");
+ invoked = avs_get_event(1);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Error handler was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the being_destroyed field of the widget
+.A w
+is True a call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+shall return XtGeometryNo.
+>>CODE
+Widget labelw_msg;
+char *msg = "Test widget";
+pid_t pid2;
+int invoked;
+
+ avs_set_event(2,0);
+ FORK(pid2);
+ avs_xt_hier("Tmkgmreqt1", "XtMakeGeometryRequest");
+ tet_infoline("PREP: Create label widget in boxw1 widget");
+ labelw_msg1 = (Widget) CreateLabelWidget(msg, boxw1);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Add destroy callback procedure to labelw_msg1");
+ XtAddCallback(labelw_msg1,
+ XtNdestroyCallback,
+ XtCBP,
+ (XtPointer)NULL
+ );
+ tet_infoline("PREP: Get current geometry and destroy widget");
+ intended5.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(labelw_msg1, &intended5, &geom5);
+ XtDestroyWidget(labelw_msg1);
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ invoked = avs_get_event(2);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Destroy callback was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ } else
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the fields x, y, width, height, and the border_width of the
+widget
+.A w
+are all equal to their corresponding values in
+.A request
+a call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+shall return XtGeometryYes.
+>>CODE
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Widget rowcolw_good;
+pid_t pid2;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkgmreqt1", "XtMakeGeometryRequest");
+ tet_infoline("PREP: Create rowcolw widget in boxw1 widget");
+ rowcolw_good = (Widget) CreateRowColWidget(boxw1);
+ tet_infoline("TEST: Do not change geometry of unmanaged widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(rowcolw_good, &intended, &geom);
+ request.request_mode = intended.request_mode;
+ request.x = geom.x;
+ request.y = geom.y;
+ request.width = geom.width;
+ request.height = geom.height;
+ request.border_width = geom.border_width;
+ result = XtMakeGeometryRequest(rowcolw_good, &request, &reply_return);
+ tet_infoline("TEST: return value is XtGeometryYes");
+ check_dec(XtGeometryYes, result, "XtMakeGeometryRequest result");
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When at least one of x, y, width, height or the border_width
+field of the widget
+.A w
+is not equal to its corresponding value in
+.A request
+a call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+shall call the geometry_manager procedure of the specified widget's
+parent passing
+.A request
+and
+.A reply_return
+as arguments to it.
+>>CODE
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Widget formw_good, formw_good2, labelw_good;
+pid_t pid2;
+int invoked;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkgmreqt1", "XtMakeGeometryRequest");
+ tet_infoline("PREP: Create avsform widget in boxw1 widget");
+ formw_good = XtCreateManagedWidget("avsform",
+ avsformWidgetClass,
+ boxw1,
+ NULL,
+ 0);
+ tet_infoline("PREP: Create avsform2 widget in avsform widget");
+ formw_good2 = XtCreateManagedWidget("avsform2",
+ avsform2WidgetClass,
+ formw_good,
+ NULL,
+ 0);
+ labelw_good = (Widget) CreateLabelWidget("Hello", formw_good2);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("TEST: Change geometry of avsform2 widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(formw_good2, &intended, &geom);
+ request.request_mode = intended.request_mode;
+ request.x = geom.x + 10;
+ request.y = geom.y + 10;
+ request.width = geom.width + 10;
+ request.height = geom.height + 10;
+ request.border_width = geom.border_width + 1;
+ result = XtMakeGeometryRequest(formw_good2, &request, &reply_return);
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_infoline("TEST: Parent's Geometry manager was invoked");
+ invoked = avs_get_event(5);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Geometry manager was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good B 1
+On a call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+when the widget
+.A w
+is realized, at least one of x, y, width, height or the
+border_width field of the widget is not equal to its
+corresponding value in
+.A request,
+and the call to the geometry_manager procedure of
+the widget's parent returns XtGeometryYes with
+request->request_mode set to a value other than XtCWQueryOnly
+it shall call the XConfigureWindow Xlib function.
+>>ASSERTION Good A
+A call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+when the widget
+.A w
+is realized, at least one of x, y, width, height or the
+border_width field of the widget is not equal to its
+corresponding value in
+.A request,
+and the call to the geometry_manager procedure of the widget's
+parent returns XtGeometryDone shall return XtGeometryYes.
+>>CODE
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Widget formw_good, formw_good2, labelw_good;
+pid_t pid2;
+int invoked;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkgmreqt1", "XtMakeGeometryRequest");
+ tet_infoline("PREP: Create avsform widget in boxw1 widget");
+ formw_good = XtCreateManagedWidget("avsform",
+ avsformWidgetClass,
+ boxw1,
+ NULL,
+ 0);
+ tet_infoline("PREP: Create avsform2 widget in avsform widget");
+ formw_good2 = XtCreateManagedWidget("avsform2",
+ avsform2WidgetClass,
+ formw_good,
+ NULL,
+ 0);
+ labelw_good = (Widget) CreateLabelWidget("Hello", formw_good2);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("TEST: Change geometry of avsform2 widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(formw_good2, &intended, &geom);
+ request.request_mode = intended.request_mode;
+ request.x = geom.x + 10;
+ request.y = geom.y + 10;
+ request.width = geom.width + 10;
+ request.height = geom.height + 10;
+ request.border_width = geom.border_width + 1;
+ /*this forces the avsForm (parent) widget's geometry manager to
+ return XtMakeGeometryDone*/
+ avs_set_event(5, 77);
+ result = XtMakeGeometryRequest(formw_good2, &request, &reply_return);
+ tet_infoline("TEST: return value is XtGeometryYes");
+ check_dec(XtGeometryYes, result, "XtMakeGeometryRequest result");
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_infoline("TEST: Parent's Geometry manager was invoked");
+ invoked = avs_get_event(5);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Geometry manager was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+when the widget
+.A w
+is realized, at least one of x, y, width, height or the
+border_width field of the widget is not equal to its
+corresponding value in
+.A request,
+and the call to the geometry_manager procedure of the
+the widget's parent neither returns XtGeometryYes with
+request->request_mode set to a value other than XtCWQueryOnly
+nor returns XtGeometryDone shall return what the
+geometry_manager procedure returns.
+>>CODE
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Widget rowcolw_good;
+pid_t pid2;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkgmreqt1", "XtMakeGeometryRequest");
+ tet_infoline("PREP: Create rowcolw widget in boxw1 widget");
+ rowcolw_good = (Widget) CreateRowColWidget(boxw1);
+ tet_infoline("TEST: Change geometry of unmanaged widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(rowcolw_good, &intended, &geom);
+ request.request_mode = intended.request_mode;
+ request.x = geom.x + 10;
+ request.y = geom.y + 10;
+ request.width = geom.width + 10;
+ request.height = geom.height + 10;
+ request.border_width = geom.border_width + 1;
+ result = XtMakeGeometryRequest(rowcolw_good, &request, &reply_return);
+ tet_infoline("TEST: return value is XtGeometryYes");
+ check_dec(XtGeometryYes, result, "XtMakeGeometryRequest result");
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_result(TET_PASS);
+>>ASSERTION Good B 3
+When
+.A reply_return
+is NULL a call to
+XtGeometryResult XtMakeGeometryRequest(w, request, reply_return)
+shall not return XtGeometryAlmost.
diff --git a/xts5/Xt8/XtMakeResizeRequest/XtMakeResizeRequest.m b/xts5/Xt8/XtMakeResizeRequest/XtMakeResizeRequest.m
new file mode 100644
index 00000000..2a9e9f12
--- /dev/null
+++ b/xts5/Xt8/XtMakeResizeRequest/XtMakeResizeRequest.m
@@ -0,0 +1,649 @@
+Copyright (c) 2005 X.Org Foundation LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+$Header: /cvs/xtest/xtest/xts5/tset/Xt8/XtMakeResizeRequest/XtMakeResizeRequest.m,v 1.1 2005-02-12 14:38:23 anderson Exp $
+
+Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995
+Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993
+All Rights Reserved.
+
+>>#
+>># Project: VSW5
+>>#
+>># File: tset/Xt8/XtMakeResizeRequest/XtMakeResizeRequest.m
+>>#
+>># Description:
+>># Tests for XtMakeResizeRequest()
+>>#
+>># Modifications:
+>># $Log: tmkrsizrt.m,v $
+>># Revision 1.1 2005-02-12 14:38:23 anderson
+>># Initial revision
+>>#
+>># Revision 8.0 1998/12/23 23:36:53 mar
+>># Branch point for Release 5.0.2
+>>#
+>># Revision 7.0 1998/10/30 22:59:45 mar
+>># Branch point for Release 5.0.2b1
+>>#
+>># Revision 6.1 1998/06/26 21:24:34 andy
+>># In test 5, made geometry change for destroyed widget occur within
+>># destroy callback. SR #189.
+>>#
+>># Revision 6.0 1998/03/02 05:28:00 tbr
+>># Branch point for Release 5.0.1
+>>#
+>># Revision 5.1 1998/02/24 03:17:11 andy
+>># Made test 9 contingent on coverage
+>>#
+>># Revision 5.0 1998/01/26 03:24:34 tbr
+>># Branch point for Release 5.0.1b1
+>>#
+>># Revision 4.0 1995/12/15 09:17:42 tbr
+>># Branch point for Release 5.0.0
+>>#
+>># Revision 3.1 1995/12/15 01:21:57 andy
+>># Prepare for GA Release
+>>#
+>>EXTERN
+#include <X11/IntrinsicP.h>
+#include <X11/ConstrainP.h>
+#include <X11/CoreP.h>
+#include <AvsForm.h>
+#include <AvsForm2.h>
+#include <AvsForm3.h>
+
+XtAppContext app_ctext;
+Widget topLevel, panedw, boxw1, boxw2;
+Widget labelw, rowcolw, click_quit;
+
+Widget cooperative_widget5;
+XtWidgetGeometry intended5, geom5;
+
+/*destroy callback for test 5*/
+void XtCBP(w, client_data, call_data)
+Widget w;
+XtPointer client_data, call_data;
+{
+ XtGeometryResult result;
+ Dimension width, height;
+ Dimension width_return, height_return;
+
+ tet_infoline("INFO: Inside destroy callback");
+ avs_set_event(2,1);
+ tet_infoline("PREP: Change geometry of cooperative widget");
+ width = geom5.width + 10;
+ height = geom5.height + 10;
+ result = XtMakeResizeRequest(cooperative_widget5, width, height, &width_return, &height_return);
+ tet_infoline("TEST: Return value is XtGeometyNo");
+ check_dec(XtGeometryNo, result, "XtGeometryYes");
+}
+
+void XtWMH_Proc(str1, str2, str3, str4, str5, car)
+String str1, str2, str3, str4, *str5;
+Cardinal *car;
+{
+ avs_set_event(1,1);
+ exit(1);
+}
+
+extern WidgetClass avsWidgetClass, avsCompWidgetClass;
+
+>>SET tpstartup avs_alloc_sem
+>>SET tpcleanup avs_free_sem
+>>TITLE XtMakeResizeRequest Xt8
+XtGeometryResult
+XtMakeResizeRequest(w, width, height, width_return, height_return)
+>>ASSERTION Good A
+When the widget
+.A w
+is unmanaged a call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+shall change the width and the height of the widget
+to
+.A width
+and
+.A height
+respectively and return XtGeometryYes.
+>>CODE
+Widget cooperative_composite, cooperative_widget;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Dimension width, height;
+Dimension width_return, height_return;
+
+ avs_xt_hier("Tmkrsizrt1", "XtMakeResizeRequest");
+ tet_infoline("PREP: Createcooperative composite widget in boxw1");
+ cooperative_composite = XtCreateManagedWidget("cooperative_widget",
+ avsCompWidgetClass,
+ boxw1,
+ (ArgList) 0, 0);
+ tet_infoline("PREP: Create cooperative widget in cooperative composite");
+ cooperative_widget = XtCreateManagedWidget("cooperative_widget",
+ avsWidgetClass,
+ cooperative_composite,
+ (ArgList) 0, 0);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Query geometry of cooperative widget");
+ intended.request_mode = CWWidth|CWHeight;
+ XtQueryGeometry(cooperative_widget, &intended, &geom);
+ tet_infoline("PREP: Change geometry of cooperative widget");
+ width = geom.width + 10;
+ height = geom.height + 10;
+ result = XtMakeResizeRequest(cooperative_widget, width, height, &width_return, &height_return);
+ tet_infoline("TEST: Return value is XtGeometyYes");
+ check_dec(XtGeometryYes, result, "XtGeometryYes");
+ tet_infoline("TEST: Returned width and height");
+ check_dec(width, width_return, "width");
+ check_dec(height, height_return, "height");
+ tet_infoline("PREP: Request geometry of cooperative_widget widget");
+ intended.request_mode = CWWidth|CWHeight;
+ XtQueryGeometry(cooperative_widget, NULL, &geom);
+ tet_infoline("TEST: Cooperative_widget widget is resized");
+ check_dec(width, geom.width, "width");
+ check_dec(height, geom.height, "height");
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the parent of the widget
+.A w
+is not realized a call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+shall change the width and the height of the widget
+to
+.A width
+and
+.A height
+respectively and return XtGeometryYes.
+>>CODE
+Widget cooperative_composite, cooperative_widget;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Dimension width, height;
+Dimension width_return, height_return;
+
+ avs_xt_hier("Tmkrsizrt1", "XtMakeResizeRequest");
+ tet_infoline("PREP: Createcooperative composite widget in boxw1");
+ cooperative_composite = XtCreateManagedWidget("cooperative_widget",
+ avsCompWidgetClass,
+ boxw1,
+ (ArgList) 0, 0);
+ tet_infoline("PREP: Create cooperative widget in cooperative composite");
+ cooperative_widget = XtCreateManagedWidget("cooperative_widget",
+ avsWidgetClass,
+ cooperative_composite,
+ (ArgList) 0, 0);
+ tet_infoline("PREP: Query geometry of cooperative widget");
+ intended.request_mode = CWWidth|CWHeight;
+ XtQueryGeometry(cooperative_widget, &intended, &geom);
+ tet_infoline("PREP: Change geometry of cooperative widget");
+ width = geom.width + 10;
+ height = geom.height + 10;
+ result = XtMakeResizeRequest(cooperative_widget, width, height, &width_return, &height_return);
+ tet_infoline("TEST: Return value is XtGeometyYes");
+ check_dec(XtGeometryYes, result, "XtGeometryYes");
+ tet_infoline("TEST: Returned width and height");
+ check_dec(width, width_return, "width");
+ check_dec(height, height_return, "height");
+ tet_infoline("PREP: Request geometry of cooperative_widget widget");
+ intended.request_mode = CWWidth|CWHeight;
+ XtQueryGeometry(cooperative_widget, NULL, &geom);
+ tet_infoline("TEST: Cooperative_widget widget is resized");
+ check_dec(width, geom.width, "width");
+ check_dec(height, geom.height, "height");
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the class of the parent of the widget
+.A w
+is not a subclass of compositeWidgetClass a call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+shall issue an invalidParent error.
+>>CODE
+Widget cooperative_composite, cooperative_widget, cooperative_widget2;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Dimension width, height;
+Dimension width_return, height_return;
+Widget labelw_good, labelw_good2;
+pid_t pid2;
+int invoked;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkrsizrt3", "XtMakeResizeRequest");
+ XtAppSetErrorMsgHandler(app_ctext, XtWMH_Proc);
+ tet_infoline("PREP: Create test widgets");
+ labelw_good = XtVaCreateWidget(
+ "labelw_good",
+ coreWidgetClass,
+ boxw1,
+ NULL
+ );
+ labelw_good2 = XtVaCreateWidget(
+ "labelw_good2",
+ coreWidgetClass,
+ labelw_good,
+ NULL
+ );
+ (void) ConfigureDimension(topLevel, labelw_good);
+ (void) ConfigureDimension(topLevel, labelw_good2);
+ tet_infoline("TEST: Call XtMakeResizeRequest");
+ result = XtMakeResizeRequest(labelw_good2, width, height, &width_return, &height_return);
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_infoline("TEST: Error handler was invoked");
+ invoked = avs_get_event(1);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Error handler was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the geometry_manager field of the parent of the widget
+.A w
+is NULL a call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+shall issue an invalidGeometryManager error.
+>>CODE
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Widget formw_good, formw_good2, labelw_good;
+pid_t pid2;
+int invoked;
+Dimension width_return, height_return;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkrsizrt1", "XtMakeGeometryRequest");
+ XtAppSetErrorMsgHandler(app_ctext, XtWMH_Proc);
+ tet_infoline("PREP: Create avsform3 widget in avsform widget");
+ formw_good2 = XtCreateManagedWidget("avsform3",
+ avsform3WidgetClass,
+ boxw1,
+ NULL,
+ 0);
+ labelw_good = (Widget) CreateLabelWidget("Hello", formw_good2);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("TEST: Call XtMakeResizeRequest");
+ result = XtMakeResizeRequest(labelw_good, 10, 10, &width_return, &height_return);
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_infoline("TEST: Error handler was invoked");
+ invoked = avs_get_event(1);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Error handler was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the being_destroyed field of the widget
+.A w
+is True a call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+shall return XtGeometryNo.
+>>CODE
+int invoked;
+Widget cooperative_composite;
+pid_t pid2;
+
+ avs_set_event(2,0);
+ FORK(pid2);
+ avs_xt_hier("Tmkrsizrt1", "XtMakeResizeRequest");
+ tet_infoline("PREP: Createcooperative composite widget in boxw1");
+ cooperative_composite = XtCreateManagedWidget("cooperative_widget",
+ avsCompWidgetClass,
+ boxw1,
+ (ArgList) 0, 0);
+ tet_infoline("PREP: Create cooperative widget in cooperative composite");
+ cooperative_widget5 = XtCreateManagedWidget("cooperative_widget",
+ avsWidgetClass,
+ cooperative_composite,
+ (ArgList) 0, 0);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Query geometry of cooperative widget");
+ intended5.request_mode = CWWidth|CWHeight;
+ XtQueryGeometry(cooperative_widget5, &intended5, &geom5);
+ tet_infoline("PREP: Add destroy callback procedure to cooperative widget");
+ XtAddCallback(cooperative_widget5,
+ XtNdestroyCallback,
+ XtCBP,
+ (XtPointer)NULL
+ );
+ tet_infoline("PREP: Destroy cooperative widget");
+ XtDestroyWidget(cooperative_widget5);
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ invoked = avs_get_event(2);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Destroy callback was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ } else
+ tet_result(TET_PASS);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the width and the height fields of the
+widget
+.A w
+are equal to
+.A width
+and
+.A height
+respectively a call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+shall return XtGeometryYes.
+>>CODE
+Widget cooperative_composite, cooperative_widget;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Dimension width, height;
+Dimension width_return, height_return;
+
+ avs_xt_hier("Tmkrsizrt1", "XtMakeResizeRequest");
+ tet_infoline("PREP: Createcooperative composite widget in boxw1");
+ cooperative_composite = XtCreateManagedWidget("cooperative_widget",
+ avsCompWidgetClass,
+ boxw1,
+ (ArgList) 0, 0);
+ tet_infoline("PREP: Create cooperative widget in cooperative composite");
+ cooperative_widget = XtCreateManagedWidget("cooperative_widget",
+ avsWidgetClass,
+ cooperative_composite,
+ (ArgList) 0, 0);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Query geometry of cooperative widget");
+ intended.request_mode = CWWidth|CWHeight;
+ XtQueryGeometry(cooperative_widget, &intended, &geom);
+ tet_infoline("PREP: Do not change width and height of cooperative widget");
+ width = geom.width;
+ height = geom.height;
+ result = XtMakeResizeRequest(cooperative_widget, width, height, &width_return, &height_return);
+ tet_infoline("TEST: Return value is XtGeometyYes");
+ check_dec(XtGeometryYes, result, "XtGeometryYes");
+ tet_infoline("TEST: Returned width and height");
+ check_dec(width, width_return, "width");
+ check_dec(height, height_return, "height");
+ tet_infoline("PREP: Request geometry of cooperative_widget widget");
+ intended.request_mode = CWWidth|CWHeight;
+ XtQueryGeometry(cooperative_widget, NULL, &geom);
+ tet_infoline("TEST: Cooperative_widget widget is resized");
+ check_dec(width, geom.width, "width");
+ check_dec(height, geom.height, "height");
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When the width field of the widget
+.A w
+is not equal to
+.A width
+or the height field is not equal to
+.A height
+a call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+shall call the geometry_manager procedure of the specified
+widget's parent.
+>>CODE
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Widget formw_good, formw_good2, labelw_good;
+pid_t pid2;
+int invoked;
+Dimension width_return, height_return;
+Dimension width, height;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkrsizrt1", "XtMakeResizeRequest");
+ tet_infoline("PREP: Create avsform widget in boxw1 widget");
+ formw_good = XtCreateManagedWidget("avsform",
+ avsformWidgetClass,
+ boxw1,
+ NULL,
+ 0);
+ tet_infoline("PREP: Create avsform2 widget in avsform widget");
+ formw_good2 = XtCreateManagedWidget("avsform2",
+ avsform2WidgetClass,
+ formw_good,
+ NULL,
+ 0);
+ labelw_good = (Widget) CreateLabelWidget("Hello", formw_good2);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("TEST: Change size of avsform2 widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(formw_good2, &intended, &geom);
+ width = geom.width + 10;
+ height = geom.height + 10;
+ result = XtMakeResizeRequest(formw_good2, width, height, &width_return, &height_return);
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_infoline("TEST: Parent's Geometry manager was invoked");
+ invoked = avs_get_event(5);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Geometry manager was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good B 1
+On a call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+when the widget
+.A w
+is realized, the width field of the widget is not
+equal to
+.A width
+or the height field is not equal to
+.A height,
+and the call to the geometry_manager procedure of
+the widget's parent returns XtGeometryYes with
+request->request_mode set to a value other than XtCWQueryOnly
+it shall call the XConfigureWindow Xlib function.
+>>ASSERTION Good A
+A call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+when the widget
+.A w
+is realized, the width field of the widget is not
+equal to
+.A width
+or the height field is not equal to
+.A height,
+and the call to the geometry_manager procedure of the widget's
+parent returns XtGeometryDone shall return XtGeometryYes.
+>>CODE
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Widget formw_good, formw_good2, labelw_good;
+pid_t pid2;
+int invoked;
+Dimension width_return, height_return;
+Dimension width, height;
+
+/*this test does not pass prior do R6.4gamma due to issues with
+consistency of the spec, test suite, and sample code*/
+if (config.coverage < 2) {
+ FORK(pid2);
+ avs_xt_hier("Tmkrsizrt1", "XtMakeResizeRequest");
+ tet_infoline("PREP: Create avsform widget in boxw1 widget");
+ formw_good = XtCreateManagedWidget("avsform",
+ avsformWidgetClass,
+ boxw1,
+ NULL,
+ 0);
+ tet_infoline("PREP: Create avsform2 widget in avsform widget");
+ formw_good2 = XtCreateManagedWidget("avsform2",
+ avsform2WidgetClass,
+ formw_good,
+ NULL,
+ 0);
+ labelw_good = (Widget) CreateLabelWidget("Hello", formw_good2);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("TEST: Change geometry of avsform2 widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(formw_good2, &intended, &geom);
+ width = geom.width + 10;
+ height = geom.height + 10;
+ /*this forces the avsForm (parent) widget's geometry manager to
+ return XtMakeGeometryDone*/
+ avs_set_event(5, 77);
+ result = XtMakeResizeRequest(formw_good2, width, height, &width_return, &height_return);
+ tet_infoline("TEST: return value is XtGeometryYes");
+ check_dec(XtGeometryYes, result, "XtMakeGeometryRequest result");
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_infoline("TEST: Parent's Geometry manager was invoked");
+ invoked = avs_get_event(5);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Geometry manager was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+} else {
+ tet_infoline("INFO: Test surpressed due to XT_COVERAGE value");
+ tet_result(TET_UNTESTED);
+}
+>>ASSERTION Good A
+A call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+when the widget
+.A w
+is realized, the width field of the widget is not
+equal to
+.A width
+or the height field is not equal to
+.A height,
+and the call to the geometry_manager procedure of the
+the widget's parent neither returns XtGeometryYes with
+request->request_mode set to a value other than XtCWQueryOnly
+nor returns XtGeometryDone shall return what the geometry_manager
+procedure returns.
+>>CODE
+Widget cooperative_composite, cooperative_widget;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Dimension width, height;
+Dimension width_return, height_return;
+
+ avs_xt_hier("Tmkrsizrt1", "XtMakeResizeRequest");
+ tet_infoline("PREP: Createcooperative composite widget in boxw1");
+ cooperative_composite = XtCreateManagedWidget("cooperative_widget",
+ avsCompWidgetClass,
+ boxw1,
+ (ArgList) 0, 0);
+ tet_infoline("PREP: Create cooperative widget in cooperative composite");
+ cooperative_widget = XtCreateManagedWidget("cooperative_widget",
+ avsWidgetClass,
+ cooperative_composite,
+ (ArgList) 0, 0);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Query geometry of cooperative widget");
+ intended.request_mode = CWWidth|CWHeight;
+ XtQueryGeometry(cooperative_widget, &intended, &geom);
+ tet_infoline("PREP: Change width and height of cooperative widget");
+ width = geom.width+10;
+ height = geom.height+10;
+ result = XtMakeResizeRequest(cooperative_widget, width, height, &width_return, &height_return);
+ tet_infoline("TEST: Return value is XtGeometyYes");
+ check_dec(XtGeometryYes, result, "XtGeometryYes");
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+On a call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+when the return value is XtGeometryAlmost,
+.A width_return
+and
+.A height_return
+shall contain the compromise width and height respectively.
+>>CODE
+XtWidgetGeometry request;
+XtWidgetGeometry reply_return;
+XtWidgetGeometry intended, geom;
+XtGeometryResult result;
+Widget formw_good, formw_good2, labelw_good;
+pid_t pid2;
+int invoked;
+Dimension width_return, height_return;
+Dimension width, height;
+
+ FORK(pid2);
+ avs_xt_hier("Tmkrsizrt1", "XtMakeResizeRequest");
+ tet_infoline("PREP: Create avsform widget in boxw1 widget");
+ formw_good = XtCreateManagedWidget("avsform",
+ avsformWidgetClass,
+ boxw1,
+ NULL,
+ 0);
+ tet_infoline("PREP: Create avsform2 widget in avsform widget");
+ formw_good2 = XtCreateManagedWidget("avsform2",
+ avsform2WidgetClass,
+ formw_good,
+ NULL,
+ 0);
+ labelw_good = (Widget) CreateLabelWidget("Hello", formw_good2);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("TEST: Change geometry of avsform2 widget");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(formw_good2, &intended, &geom);
+ width = geom.width + 10;
+ height = geom.height + 10;
+ /*this forces the avsForm (parent) widget's geometry manager to
+ return XtMakeGeometryAlmost*/
+ avs_set_event(5, 88);
+ result = XtMakeResizeRequest(formw_good2, width, height, &width_return, &height_return);
+ tet_infoline("TEST: return value is XtGeometryAlmost");
+ check_dec(XtGeometryAlmost, result, "XtMakeGeometryRequest result");
+ tet_infoline("TEST: Returned width and height");
+ check_dec(88, width_return, "width");
+ check_dec(99, height_return, "height");
+ LKROF(pid2, AVSXTTIMEOUT-2);
+ tet_infoline("TEST: Parent's Geometry manager was invoked");
+ invoked = avs_get_event(5);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Geometry manager was not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good B 3
+When
+.A width
+and
+.A height
+are both NULL a call to
+XtGeometryResult XtMakeResizeRequest(w, width, height,
+width_return, height_return)
+shall not return XtGeometryAlmost.
diff --git a/xts5/Xt8/XtMoveWidget/XtMoveWidget.m b/xts5/Xt8/XtMoveWidget/XtMoveWidget.m
new file mode 100644
index 00000000..f72e8499
--- /dev/null
+++ b/xts5/Xt8/XtMoveWidget/XtMoveWidget.m
@@ -0,0 +1,798 @@
+Copyright (c) 2005 X.Org Foundation LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+$Header: /cvs/xtest/xtest/xts5/tset/Xt8/XtMoveWidget/XtMoveWidget.m,v 1.1 2005-02-12 14:38:23 anderson Exp $
+
+Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995
+Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993
+All Rights Reserved.
+
+>>#
+>># Project: VSW5
+>>#
+>># File: tset/Xt8/XtMoveWidget/XtMoveWidget.m
+>>#
+>># Description:
+>># Tests for XtMoveWidget()
+>>#
+>># Modifications:
+>># $Log: tmvwidget.m,v $
+>># Revision 1.1 2005-02-12 14:38:23 anderson
+>># Initial revision
+>>#
+>># Revision 8.0 1998/12/23 23:36:53 mar
+>># Branch point for Release 5.0.2
+>>#
+>># Revision 7.0 1998/10/30 22:59:46 mar
+>># Branch point for Release 5.0.2b1
+>>#
+>># Revision 6.0 1998/03/02 05:28:00 tbr
+>># Branch point for Release 5.0.1
+>>#
+>># Revision 5.0 1998/01/26 03:24:34 tbr
+>># Branch point for Release 5.0.1b1
+>>#
+>># Revision 4.0 1995/12/15 09:17:44 tbr
+>># Branch point for Release 5.0.0
+>>#
+>># Revision 3.1 1995/12/15 01:22:00 andy
+>># Prepare for GA Release
+>>#
+>>EXTERN
+#include <X11/IntrinsicP.h>
+#include <X11/ConstrainP.h>
+#include <X11/CoreP.h>
+#include <xt/SquareCelP.h>
+
+XtAppContext app_ctext;
+Widget topLevel, panedw, boxw1, boxw2;
+Widget labelw, rowcolw, click_quit;
+
+/*
+ * SquareCell.c - Square Widget
+ */
+#define INTERNAL_WIDTH 2
+#define INTERNAL_HEIGHT 4
+#define DEFAULT_PIXMAP_WIDTH 1 /* in cells */
+#define DEFAULT_PIXMAP_HEIGHT 1 /* in cells */
+#define DEFAULT_CELL_SIE 20 /* in pixels */
+/* values for instance variable is_drawn */
+#define DRAWN 1
+#define UNDRAWN 0
+/* modes for drawing */
+#define DRAW 1
+#define UNDRAW 0
+#define MAXLINES 10 /* max of horiz or vertical cells */
+#define SCROLLBARWIDTH 15
+#define DEFAULTWIDTH 300 /* widget size when show_all is False */
+#define offset(field) XtOffsetOf(SquareCellRec, field)
+static XtResource resources[] = {
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(squareCell.foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XavsNtoggleCallback,
+ XavsCToggleCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(squareCell.callback),
+ XtRCallback,
+ NULL
+ },
+ {
+ XavsNcellSizeInPixels,
+ XavsCCellSizeInPixels,
+ XtRInt, sizeof(int),
+ offset(squareCell.cell_size_in_pixels),
+ XtRImmediate,
+ (XtPointer)DEFAULT_CELL_SIE
+ },
+ {
+ XavsNpixmapWidthInCells,
+ XavsCPixmapWidthInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_width_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_WIDTH
+ },
+ {
+ XavsNpixmapHeightInCells,
+ XavsCPixmapHeightInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_height_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_HEIGHT
+ },
+ {
+ XavsNcurX,
+ XavsCCurX,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_x),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcurY,
+ XavsCCurY,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_y),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcellArray,
+ XavsCCellArray,
+ XtRString,
+ sizeof(String),
+ offset(squareCell.cell),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNshowEntireBitmap,
+ XavsCShowEntireBitmap,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(squareCell.show_all),
+ XtRImmediate,
+ (XtPointer) TRUE
+ },
+};
+/* Declaration of methods */
+static void Initialize();
+static void Redisplay();
+static void Destroy();
+static void Resize();
+static Boolean SetValues();
+static XtGeometryResult QueryGeometry();
+/* these Core methods not needed by SquareCell:
+ *
+ * static void ClassInitialize();
+ * static void Realize();
+ */
+/* the following are private functions unique to SquareCell */
+static void DrawPixmaps(), DoCell(), ChangeCellSize();
+/* the following are actions of SquareCell */
+static void DrawCell(), UndrawCell(), ToggleCell();
+/* The following are public functions of SquareCell, declared extern
+ * in the public include file: */
+char *SquareCellGetArray();
+static char defaultTranslations[] =
+ "<Btn1Down>: DrawCell() \n\
+ <Btn2Down>: UndrawCell() \n\
+ <Btn3Down>: ToggleCell() \n\
+ <Btn1Motion>: DrawCell() \n\
+ <Btn2Motion>: UndrawCell() \n\
+ <Btn3Motion>: ToggleCell()";
+static XtActionsRec actions[] = {
+ {"DrawCell", DrawCell},
+ {"UndrawCell", UndrawCell},
+ {"ToggleCell", ToggleCell},
+};
+/* definition in SquareCell.h */
+static SquareCellPointInfo info;
+SquareCellClassRec squareCellClassRec = {
+ {
+ /* core_class fields */
+ /* superclass */ (WidgetClass) &coreClassRec,
+ /* class_name */ "SquareCell",
+ /* widget_size */ sizeof(SquareCellRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ {/* simple_class fields */
+ /* change_sensitive */ XtInheritChangeSensitive,
+ },
+ {
+ /* extension */ 0,
+ },
+};
+WidgetClass squareCellWidgetClass = (WidgetClass) & squareCellClassRec;
+static void
+GetDrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground | GCDashOffset |
+ GCDashList | GCLineStyle;
+ /*
+ * Setting foreground and background to 1 and 0 looks like a
+ * kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied with a
+ * separate GC when the pixmap is copied into the window.
+ */
+ values.foreground = 1;
+ values.background = 0;
+ values.dashes = 1;
+ values.dash_offset = 0;
+ values.line_style = LineOnOffDash;
+ cw->squareCell.draw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetUndrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ /* this looks like a kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied as the
+ * pixmap is copied into the window.
+ */
+ values.foreground = 0;
+ values.background = 1;
+ cw->squareCell.undraw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetCopyGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ values.foreground = cw->squareCell.foreground;
+ values.background = cw->core.background_pixel;
+ cw->squareCell.copy_gc = XtGetGC((Widget)cw, mask, &values);
+}
+static void
+Initialize(treq, tnew, args, num_args)
+Widget treq, tnew;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget new = (SquareCellWidget) tnew;
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ /*
+ * Check instance values set by resources that may be invalid.
+ */
+ if ((new->squareCell.pixmap_width_in_cells < 1) ||
+ (new->squareCell.pixmap_height_in_cells < 1)) {
+ XtWarning("SquareCell: pixmapWidth and/or pixmapHeight is too small (using 10 x 10)");
+ new->squareCell.pixmap_width_in_cells = 10;
+ new->squareCell.pixmap_height_in_cells = 10;
+ }
+ if (new->squareCell.cell_size_in_pixels < 5) {
+ XtWarning("SquareCell: cellSize is too small (using 5)");
+ new->squareCell.cell_size_in_pixels = 5;
+ }
+ if ((new->squareCell.cur_x < 0) || (new->squareCell.cur_y < 0)) {
+ XtWarning("SquareCell: cur_x and cur_y must be non-negative (using 0, 0)");
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ }
+ if (new->squareCell.cell == NULL)
+ new->squareCell.cell = XtCalloc(
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.pixmap_height_in_cells, sizeof(char));
+ else
+ new->squareCell.user_allocated = True; /* user supplied cell array */
+ new->squareCell.pixmap_width_in_pixels =
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ new->squareCell.pixmap_height_in_pixels =
+ new->squareCell.pixmap_height_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ if (new->core.width == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.width = (new->squareCell.pixmap_width_in_pixels
+ > DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_width_in_pixels);
+ else
+ new->core.width = new->squareCell.pixmap_width_in_pixels;
+ }
+ if (new->core.height == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.height =
+ (new->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_height_in_pixels);
+ else
+ new->core.height = new->squareCell.pixmap_height_in_pixels;
+ }
+ CreateBigPixmap(new);
+ GetDrawGC(new);
+ GetUndrawGC(new);
+ GetCopyGC(new);
+ DrawIntoBigPixmap(new);
+}
+static void
+Redisplay(w, event)
+Widget w;
+XExposeEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ register int x, y;
+ unsigned int width, height;
+ if (!XtIsRealized((Widget)cw))
+ return;
+ if (event) { /* called from btn-event or expose */
+ x = event->x;
+ y = event->y;
+ width = event->width;
+ height = event->height;
+ }
+ else { /* called because complete redraw */
+ x = 0;
+ y = 0;
+ width = cw->squareCell.pixmap_width_in_pixels;
+ height = cw->squareCell.pixmap_height_in_pixels;
+ }
+ if (DefaultDepthOfScreen(XtScreen((Widget)cw)) == 1)
+ XCopyArea(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y);
+ else
+ XCopyPlane(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y, 1);
+}
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget curcw = (SquareCellWidget) current;
+ SquareCellWidget newcw = (SquareCellWidget) new;
+ Boolean do_redisplay = False;
+ /*
+ ** XtSetValues invoked procedure SetValues
+ */
+ if (curcw->squareCell.foreground != newcw->squareCell.foreground) {
+ XtReleaseGC((Widget)curcw, curcw->squareCell.copy_gc);
+ GetCopyGC(newcw);
+ do_redisplay = True;
+ }
+ if ((curcw->squareCell.cur_x != newcw->squareCell.cur_x) ||
+ (curcw->squareCell.cur_y != newcw->squareCell.cur_y))
+ do_redisplay = True;
+ if (curcw->squareCell.cell_size_in_pixels !=
+ newcw->squareCell.cell_size_in_pixels) {
+ ChangeCellSize((Widget)curcw, newcw->squareCell.cell_size_in_pixels);
+ do_redisplay = True;
+ }
+ if (curcw->squareCell.pixmap_width_in_cells !=
+ newcw->squareCell.pixmap_width_in_cells) {
+ newcw->squareCell.pixmap_width_in_cells =
+ curcw->squareCell.pixmap_width_in_cells;
+ XtWarning("SquareCell: pixmap_width_in_cells cannot be set by XtSetValues.\n");
+ }
+ if (curcw->squareCell.pixmap_height_in_cells !=
+ newcw->squareCell.pixmap_height_in_cells) {
+ newcw->squareCell.pixmap_height_in_cells =
+ curcw->squareCell.pixmap_height_in_cells;
+ XtWarning("SquareCell: pixmap_height_in_cells cannot be set by XtSetValues.\n");
+ }
+ return do_redisplay;
+}
+static void
+Destroy(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ if (cw->squareCell.big_picture)
+ XFreePixmap(XtDisplay((Widget)cw), cw->squareCell.big_picture);
+ if (cw->squareCell.draw_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.draw_gc);
+ if (cw->squareCell.undraw_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.undraw_gc);
+ if (cw->squareCell.copy_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.copy_gc);
+ /* Free memory allocated with Calloc. This was done
+ * only if application didn't supply cell array.
+ */
+ if (!cw->squareCell.user_allocated)
+ XtFree(cw->squareCell.cell);
+}
+static void
+DrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.draw_gc, DRAW, cw, event);
+}
+static void
+UndrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.undraw_gc, UNDRAW, cw, event);
+}
+static void
+ToggleCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ static int oldx = -1, oldy = -1;
+ GC gc;
+ int mode;
+ int newx, newy;
+ /* This is strictly correct, but doesn't
+ * seem to be necessary */
+ if (event->type == ButtonPress) {
+ newx = (cw->squareCell.cur_x + ((XButtonEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XButtonEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ else {
+ newx = (cw->squareCell.cur_x + ((XMotionEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XMotionEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ if ((mode = cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells]) == DRAWN) {
+ gc = cw->squareCell.undraw_gc;
+ mode = UNDRAW;
+ }
+ else {
+ gc = cw->squareCell.draw_gc;
+ mode = DRAW;
+ }
+ if (oldx != newx || oldy != newy) {
+ oldx = newx;
+ oldy = newy;
+ DrawPixmaps(gc, mode, cw, event);
+ }
+}
+static void
+DrawPixmaps(gc, mode, w, event)
+GC gc;
+int mode;
+Widget w;
+XButtonEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int newx = (cw->squareCell.cur_x + event->x) /
+ cw->squareCell.cell_size_in_pixels;
+ int newy = (cw->squareCell.cur_y + event->y) /
+ cw->squareCell.cell_size_in_pixels;
+ XExposeEvent fake_event;
+ /* if already done, return */
+ if (cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] == mode)
+ return;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay(cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels*newx + 2,
+ cw->squareCell.cell_size_in_pixels*newy + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+ cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] = mode;
+ info.mode = mode;
+ info.newx = newx;
+ info.newy = newy;
+ fake_event.x = cw->squareCell.cell_size_in_pixels * newx - cw->squareCell.cur_x;
+ fake_event.y = cw->squareCell.cell_size_in_pixels * newy - cw->squareCell.cur_y;
+ fake_event.width = cw->squareCell.cell_size_in_pixels;
+ fake_event.height = cw->squareCell.cell_size_in_pixels;
+ Redisplay(cw, &fake_event);
+ XtCallCallbacks((Widget)cw, XavsNtoggleCallback, &info);
+}
+CreateBigPixmap(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* always a 1 bit deep pixmap, regardless of screen depth */
+ cw->squareCell.big_picture = XCreatePixmap(XtDisplay((Widget)cw),
+ RootWindow(XtDisplay(cw), DefaultScreen(XtDisplay((Widget)cw))),
+ cw->squareCell.pixmap_width_in_pixels + 2,
+ cw->squareCell.pixmap_height_in_pixels + 2, 1);
+}
+DrawIntoBigPixmap(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int n_horiz_segments, n_vert_segments;
+ XSegment segment[MAXLINES];
+ register int x, y;
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ cw->squareCell.undraw_gc, 0, 0,
+ cw->squareCell.pixmap_width_in_pixels
+ + 2, cw->squareCell.pixmap_height_in_pixels + 2);
+ n_horiz_segments = cw->squareCell.pixmap_height_in_cells + 1;
+ n_vert_segments = cw->squareCell.pixmap_width_in_cells + 1;
+ for (x = 0; x < n_horiz_segments; x++) {
+ segment[x].x1 = 0;
+ segment[x].x2 = (short) cw->squareCell.pixmap_width_in_pixels;
+ segment[x].y1 = (short) cw->squareCell.cell_size_in_pixels * x;
+ segment[x].y2 = (short) cw->squareCell.cell_size_in_pixels * x;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_horiz_segments);
+ for (y = 0; y < n_vert_segments; y++) {
+ segment[y].x1 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].x2 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].y1 = 0;
+ segment[y].y2 = (short) cw->squareCell.pixmap_height_in_pixels;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_vert_segments);
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+/* A Public function, not static */
+char *
+SquareCellGetArray(w, width_in_cells, height_in_cells)
+Widget w;
+int *width_in_cells, *height_in_cells;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ *width_in_cells = cw->squareCell.pixmap_width_in_cells;
+ *height_in_cells = cw->squareCell.pixmap_height_in_cells;
+ return (cw->squareCell.cell);
+}
+static void
+Resize(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* resize does nothing unless new size is bigger than entire pixmap */
+ if ((cw->core.width > cw->squareCell.pixmap_width_in_pixels) &&
+ (cw->core.height > cw->squareCell.pixmap_height_in_pixels)) {
+ /*
+ * Calculate the maximum cell size that will allow the
+ * entire bitmap to be displayed.
+ */
+ Dimension w_temp_cell_size_in_pixels, h_temp_cell_size_in_pixels;
+ Dimension new_cell_size_in_pixels;
+
+ w_temp_cell_size_in_pixels = cw->core.width / cw->squareCell.pixmap_width_in_cells;
+ h_temp_cell_size_in_pixels = cw->core.height / cw->squareCell.pixmap_height_in_cells;
+
+ if (w_temp_cell_size_in_pixels < h_temp_cell_size_in_pixels)
+ new_cell_size_in_pixels = w_temp_cell_size_in_pixels;
+ else
+ new_cell_size_in_pixels = h_temp_cell_size_in_pixels;
+
+ /* if size change mandates a new pixmap, make one */
+ if (new_cell_size_in_pixels != cw->squareCell.cell_size_in_pixels)
+ ChangeCellSize(cw, new_cell_size_in_pixels);
+ }
+}
+static void
+ChangeCellSize(w, new_cell_size)
+Widget w;
+int new_cell_size;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int x, y;
+ cw->squareCell.cell_size_in_pixels = new_cell_size;
+ /* recalculate variables based on cell size */
+ cw->squareCell.pixmap_width_in_pixels =
+ cw->squareCell.pixmap_width_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+ cw->squareCell.pixmap_height_in_pixels =
+ cw->squareCell.pixmap_height_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+
+ /* destroy old and create new pixmap of correct size */
+ XFreePixmap(XtDisplay(cw), cw->squareCell.big_picture);
+ CreateBigPixmap(cw);
+
+ /* draw lines into new pixmap */
+ DrawIntoBigPixmap(cw);
+
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+static void
+DoCell(w, x, y, gc)
+Widget w;
+int x, y;
+GC gc;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels * x + 2,
+ cw->squareCell.cell_size_in_pixels * y + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+}
+static XtGeometryResult QueryGeometry(w, proposed, answer)
+Widget w;
+XtWidgetGeometry *proposed, *answer;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* set fields we care about */
+ answer->request_mode = CWWidth | CWHeight;
+ /* initial width and height */
+ if (cw->squareCell.show_all == True)
+ answer->width = cw->squareCell.pixmap_width_in_pixels;
+ else
+ answer->width = (cw->squareCell.pixmap_width_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_width_in_pixels;
+ if (cw->squareCell.show_all == True)
+ answer->height = cw->squareCell.pixmap_height_in_pixels;
+ else
+ answer->height = (cw->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_height_in_pixels;
+ if ( ((proposed->request_mode & (CWWidth | CWHeight))
+ == (CWWidth | CWHeight)) &&
+ proposed->width == answer->width &&
+ proposed->height == answer->height)
+ return XtGeometryYes;
+ else if (answer->width == cw->core.width &&
+ answer->height == cw->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
+>>TITLE XtMoveWidget Xt8
+void
+XtMoveWidget(w, x, y)
+>>ASSERTION Good A
+A successful call to
+void XtMoveWidget(w, x, y)
+when at least one of
+.A x
+or
+.A y
+is different from its corresponding value in the
+object
+.A w
+shall write the specified values into the object.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+int x, y;
+
+ avs_xt_hier("Tmvwidget1", "XtMoveWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Change x, y geometry fields of squarew widget");
+ intended.request_mode = CWX|CWY;
+ XtQueryGeometry(squarew, &intended, &geom);
+ x = geom.x + 10;
+ y = geom.y + 10;
+ XtMoveWidget(squarew, x, y );
+ tet_infoline("TEST: Values have been changed");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(x, geometry_good.x, "x");
+ check_dec(y, geometry_good.y, "y");
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A call to
+void XtMoveWidget(w, x, y)
+when
+.A x
+and
+.A y
+are both equal to their corresponding values in the
+object
+.A w
+shall return immediately.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+int x, y;
+
+ avs_xt_hier("Tmvwidget2", "XtMoveWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Put same x, y fields to squarew widget");
+ intended.request_mode = CWX|CWY;
+ XtQueryGeometry(squarew, &intended, &geom);
+ x = geom.x;
+ y = geom.y;
+ XtMoveWidget(squarew, x, y);
+ tet_infoline("TEST: XtMoveWidget returned immediately with same");
+ tet_infoline("TEST: geometry fields");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(x, geometry_good.x, "x");
+ check_dec(y, geometry_good.y, "y");
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When
+.A w
+is a widget that is realized and at least one of
+.A x
+or
+.A y
+is different from its corresponding value in the
+widget a call to
+void XtMoveWidget(w, x, y)
+shall move the widget window to the position specified
+by
+.A x
+and
+.A y.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+int x, y;
+
+ /*should be verified with image capture*/
+ avs_xt_hier("Tmvwidget1", "XtMoveWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Change x, y geometry fields of squarew widget");
+ intended.request_mode = CWX|CWY;
+ XtQueryGeometry(squarew, &intended, &geom);
+ x = geom.x + 10;
+ y = geom.y + 10;
+ XtMoveWidget(squarew, x, y );
+ tet_infoline("TEST: Widget moved");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(x, geometry_good.x, "x");
+ check_dec(y, geometry_good.y, "y");
+ tet_result(TET_PASS);
diff --git a/xts5/Xt8/XtQueryGeometry/XtQueryGeometry.m b/xts5/Xt8/XtQueryGeometry/XtQueryGeometry.m
new file mode 100644
index 00000000..bd77aba7
--- /dev/null
+++ b/xts5/Xt8/XtQueryGeometry/XtQueryGeometry.m
@@ -0,0 +1,905 @@
+Copyright (c) 2005 X.Org Foundation LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+$Header: /cvs/xtest/xtest/xts5/tset/Xt8/XtQueryGeometry/XtQueryGeometry.m,v 1.1 2005-02-12 14:38:23 anderson Exp $
+
+Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995
+Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993
+All Rights Reserved.
+
+>>#
+>># Project: VSW5
+>>#
+>># File: tset/Xt8/XtQueryGeometry/XtQueryGeometry.m
+>>#
+>># Description:
+>># Tests for XtQueryGeometry()
+>>#
+>># Modifications:
+>># $Log: tqrygomty.m,v $
+>># Revision 1.1 2005-02-12 14:38:23 anderson
+>># Initial revision
+>>#
+>># Revision 8.0 1998/12/23 23:36:56 mar
+>># Branch point for Release 5.0.2
+>>#
+>># Revision 7.0 1998/10/30 22:59:48 mar
+>># Branch point for Release 5.0.2b1
+>>#
+>># Revision 6.0 1998/03/02 05:28:03 tbr
+>># Branch point for Release 5.0.1
+>>#
+>># Revision 5.0 1998/01/26 03:24:37 tbr
+>># Branch point for Release 5.0.1b1
+>>#
+>># Revision 4.0 1995/12/15 09:17:55 tbr
+>># Branch point for Release 5.0.0
+>>#
+>># Revision 3.1 1995/12/15 01:22:15 andy
+>># Prepare for GA Release
+>>#
+>>EXTERN
+#include <X11/IntrinsicP.h>
+#include <X11/ConstrainP.h>
+#include <X11/CoreP.h>
+#include <xt/SquareCelP.h>
+
+void test5A();
+void test6A();
+
+XtAppContext app_ctext;
+Widget topLevel, panedw, boxw1, boxw2;
+Widget labelw, rowcolw, click_quit;
+
+Dimension height_ret;
+Dimension width_ret;
+
+int test_for;
+
+/*
+ * SquareCell.c - Square Widget
+ */
+#define INTERNAL_WIDTH 2
+#define INTERNAL_HEIGHT 4
+#define DEFAULT_PIXMAP_WIDTH 1 /* in cells */
+#define DEFAULT_PIXMAP_HEIGHT 1 /* in cells */
+#define DEFAULT_CELL_SIE 20 /* in pixels */
+/* values for instance variable is_drawn */
+#define DRAWN 1
+#define UNDRAWN 0
+/* modes for drawing */
+#define DRAW 1
+#define UNDRAW 0
+#define MAXLINES 10 /* max of horiz or vertical cells */
+#define SCROLLBARWIDTH 15
+#define DEFAULTWIDTH 300 /* widget size when show_all is False */
+#define offset(field) XtOffsetOf(SquareCellRec, field)
+static XtResource resources[] = {
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(squareCell.foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XavsNtoggleCallback,
+ XavsCToggleCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(squareCell.callback),
+ XtRCallback,
+ NULL
+ },
+ {
+ XavsNcellSizeInPixels,
+ XavsCCellSizeInPixels,
+ XtRInt, sizeof(int),
+ offset(squareCell.cell_size_in_pixels),
+ XtRImmediate,
+ (XtPointer)DEFAULT_CELL_SIE
+ },
+ {
+ XavsNpixmapWidthInCells,
+ XavsCPixmapWidthInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_width_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_WIDTH
+ },
+ {
+ XavsNpixmapHeightInCells,
+ XavsCPixmapHeightInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_height_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_HEIGHT
+ },
+ {
+ XavsNcurX,
+ XavsCCurX,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_x),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcurY,
+ XavsCCurY,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_y),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcellArray,
+ XavsCCellArray,
+ XtRString,
+ sizeof(String),
+ offset(squareCell.cell),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNshowEntireBitmap,
+ XavsCShowEntireBitmap,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(squareCell.show_all),
+ XtRImmediate,
+ (XtPointer) TRUE
+ },
+};
+/* Declaration of methods */
+static void Initialize();
+static void Redisplay();
+static void Destroy();
+static void Resize();
+static Boolean SetValues();
+static XtGeometryResult QueryGeometry();
+/* these Core methods not needed by SquareCell:
+ *
+ * static void ClassInitialize();
+ * static void Realize();
+ */
+/* the following are private functions unique to SquareCell */
+static void DrawPixmaps(), DoCell(), ChangeCellSize();
+/* the following are actions of SquareCell */
+static void DrawCell(), UndrawCell(), ToggleCell();
+/* The following are public functions of SquareCell, declared extern
+ * in the public include file: */
+char *SquareCellGetArray();
+static char defaultTranslations[] =
+ "<Btn1Down>: DrawCell() \n\
+ <Btn2Down>: UndrawCell() \n\
+ <Btn3Down>: ToggleCell() \n\
+ <Btn1Motion>: DrawCell() \n\
+ <Btn2Motion>: UndrawCell() \n\
+ <Btn3Motion>: ToggleCell()";
+static XtActionsRec actions[] = {
+ {"DrawCell", DrawCell},
+ {"UndrawCell", UndrawCell},
+ {"ToggleCell", ToggleCell},
+};
+/* definition in SquareCell.h */
+static SquareCellPointInfo info;
+SquareCellClassRec squareCellClassRec = {
+ {
+ /* core_class fields */
+ /* superclass */ (WidgetClass) &coreClassRec,
+ /* class_name */ "SquareCell",
+ /* widget_size */ sizeof(SquareCellRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ {/* simple_class fields */
+ /* change_sensitive */ XtInheritChangeSensitive,
+ },
+ {
+ /* extension */ 0,
+ },
+};
+WidgetClass squareCellWidgetClass = (WidgetClass) & squareCellClassRec;
+static void
+GetDrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground | GCDashOffset |
+ GCDashList | GCLineStyle;
+ /*
+ * Setting foreground and background to 1 and 0 looks like a
+ * kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied with a
+ * separate GC when the pixmap is copied into the window.
+ */
+ values.foreground = 1;
+ values.background = 0;
+ values.dashes = 1;
+ values.dash_offset = 0;
+ values.line_style = LineOnOffDash;
+ cw->squareCell.draw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetUndrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ /* this looks like a kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied as the
+ * pixmap is copied into the window.
+ */
+ values.foreground = 0;
+ values.background = 1;
+ cw->squareCell.undraw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetCopyGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ values.foreground = cw->squareCell.foreground;
+ values.background = cw->core.background_pixel;
+ cw->squareCell.copy_gc = XtGetGC((Widget)cw, mask, &values);
+}
+static void
+Initialize(treq, tnew, args, num_args)
+Widget treq, tnew;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget new = (SquareCellWidget) tnew;
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ /*
+ * Check instance values set by resources that may be invalid.
+ */
+ if ((new->squareCell.pixmap_width_in_cells < 1) ||
+ (new->squareCell.pixmap_height_in_cells < 1)) {
+ XtWarning("SquareCell: pixmapWidth and/or pixmapHeight is too small (using 10 x 10)");
+ new->squareCell.pixmap_width_in_cells = 10;
+ new->squareCell.pixmap_height_in_cells = 10;
+ }
+ if (new->squareCell.cell_size_in_pixels < 5) {
+ XtWarning("SquareCell: cellSize is too small (using 5)");
+ new->squareCell.cell_size_in_pixels = 5;
+ }
+ if ((new->squareCell.cur_x < 0) || (new->squareCell.cur_y < 0)) {
+ XtWarning("SquareCell: cur_x and cur_y must be non-negative (using 0, 0)");
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ }
+ if (new->squareCell.cell == NULL)
+ new->squareCell.cell = XtCalloc(
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.pixmap_height_in_cells, sizeof(char));
+ else
+ new->squareCell.user_allocated = True; /* user supplied cell array */
+ new->squareCell.pixmap_width_in_pixels =
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ new->squareCell.pixmap_height_in_pixels =
+ new->squareCell.pixmap_height_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ if (new->core.width == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.width = (new->squareCell.pixmap_width_in_pixels
+ > DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_width_in_pixels);
+ else
+ new->core.width = new->squareCell.pixmap_width_in_pixels;
+ }
+ if (new->core.height == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.height =
+ (new->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_height_in_pixels);
+ else
+ new->core.height = new->squareCell.pixmap_height_in_pixels;
+ }
+ CreateBigPixmap(new);
+ GetDrawGC(new);
+ GetUndrawGC(new);
+ GetCopyGC(new);
+ DrawIntoBigPixmap(new);
+}
+static void
+Redisplay(w, event)
+Widget w;
+XExposeEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ register int x, y;
+ unsigned int width, height;
+ if (!XtIsRealized((Widget)cw))
+ return;
+ if (event) { /* called from btn-event or expose */
+ x = event->x;
+ y = event->y;
+ width = event->width;
+ height = event->height;
+ }
+ else { /* called because complete redraw */
+ x = 0;
+ y = 0;
+ width = cw->squareCell.pixmap_width_in_pixels;
+ height = cw->squareCell.pixmap_height_in_pixels;
+ }
+ if (DefaultDepthOfScreen(XtScreen((Widget)cw)) == 1)
+ XCopyArea(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y);
+ else
+ XCopyPlane(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y, 1);
+}
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget curcw = (SquareCellWidget) current;
+ SquareCellWidget newcw = (SquareCellWidget) new;
+ Boolean do_redisplay = False;
+ /*
+ ** XtSetValues invoked procedure SetValues
+ */
+ if (curcw->squareCell.foreground != newcw->squareCell.foreground) {
+ XtReleaseGC((Widget)curcw, curcw->squareCell.copy_gc);
+ GetCopyGC(newcw);
+ do_redisplay = True;
+ }
+ if ((curcw->squareCell.cur_x != newcw->squareCell.cur_x) ||
+ (curcw->squareCell.cur_y != newcw->squareCell.cur_y))
+ do_redisplay = True;
+ if (curcw->squareCell.cell_size_in_pixels !=
+ newcw->squareCell.cell_size_in_pixels) {
+ ChangeCellSize(curcw, newcw->squareCell.cell_size_in_pixels);
+ do_redisplay = True;
+ }
+ if (curcw->squareCell.pixmap_width_in_cells !=
+ newcw->squareCell.pixmap_width_in_cells) {
+ newcw->squareCell.pixmap_width_in_cells =
+ curcw->squareCell.pixmap_width_in_cells;
+ XtWarning("SquareCell: pixmap_width_in_cells cannot be set by XtSetValues.\n");
+ }
+ if (curcw->squareCell.pixmap_height_in_cells !=
+ newcw->squareCell.pixmap_height_in_cells) {
+ newcw->squareCell.pixmap_height_in_cells =
+ curcw->squareCell.pixmap_height_in_cells;
+ XtWarning("SquareCell: pixmap_height_in_cells cannot be set by XtSetValues.\n");
+ }
+ return do_redisplay;
+}
+static void
+Destroy(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ if (cw->squareCell.big_picture)
+ XFreePixmap(XtDisplay((Widget)cw), cw->squareCell.big_picture);
+ if (cw->squareCell.draw_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.draw_gc);
+ if (cw->squareCell.undraw_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.undraw_gc);
+ if (cw->squareCell.copy_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.copy_gc);
+ /* Free memory allocated with Calloc. This was done
+ * only if application didn't supply cell array.
+ */
+ if (!cw->squareCell.user_allocated)
+ XtFree(cw->squareCell.cell);
+}
+static void
+DrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.draw_gc, DRAW, cw, event);
+}
+static void
+UndrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.undraw_gc, UNDRAW, cw, event);
+}
+static void
+ToggleCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ static int oldx = -1, oldy = -1;
+ GC gc;
+ int mode;
+ int newx, newy;
+ /* This is strictly correct, but doesn't
+ * seem to be necessary */
+ if (event->type == ButtonPress) {
+ newx = (cw->squareCell.cur_x + ((XButtonEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XButtonEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ else {
+ newx = (cw->squareCell.cur_x + ((XMotionEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XMotionEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ if ((mode = cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells]) == DRAWN) {
+ gc = cw->squareCell.undraw_gc;
+ mode = UNDRAW;
+ }
+ else {
+ gc = cw->squareCell.draw_gc;
+ mode = DRAW;
+ }
+ if (oldx != newx || oldy != newy) {
+ oldx = newx;
+ oldy = newy;
+ DrawPixmaps(gc, mode, cw, event);
+ }
+}
+static void
+DrawPixmaps(gc, mode, w, event)
+GC gc;
+int mode;
+Widget w;
+XButtonEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int newx = (cw->squareCell.cur_x + event->x) /
+ cw->squareCell.cell_size_in_pixels;
+ int newy = (cw->squareCell.cur_y + event->y) /
+ cw->squareCell.cell_size_in_pixels;
+ XExposeEvent fake_event;
+ /* if already done, return */
+ if (cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] == mode)
+ return;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels*newx + 2,
+ cw->squareCell.cell_size_in_pixels*newy + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+ cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] = mode;
+ info.mode = mode;
+ info.newx = newx;
+ info.newy = newy;
+ fake_event.x = cw->squareCell.cell_size_in_pixels * newx - cw->squareCell.cur_x;
+ fake_event.y = cw->squareCell.cell_size_in_pixels * newy - cw->squareCell.cur_y;
+ fake_event.width = cw->squareCell.cell_size_in_pixels;
+ fake_event.height = cw->squareCell.cell_size_in_pixels;
+ Redisplay(cw, &fake_event);
+ XtCallCallbacks((Widget)cw, XavsNtoggleCallback, &info);
+}
+CreateBigPixmap(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* always a 1 bit deep pixmap, regardless of screen depth */
+ cw->squareCell.big_picture = XCreatePixmap(XtDisplay((Widget)cw),
+ RootWindow(XtDisplay((Widget)cw), DefaultScreen(XtDisplay((Widget)cw))),
+ cw->squareCell.pixmap_width_in_pixels + 2,
+ cw->squareCell.pixmap_height_in_pixels + 2, 1);
+}
+DrawIntoBigPixmap(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int n_horiz_segments, n_vert_segments;
+ XSegment segment[MAXLINES];
+ register int x, y;
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ cw->squareCell.undraw_gc, 0, 0,
+ cw->squareCell.pixmap_width_in_pixels
+ + 2, cw->squareCell.pixmap_height_in_pixels + 2);
+ n_horiz_segments = cw->squareCell.pixmap_height_in_cells + 1;
+ n_vert_segments = cw->squareCell.pixmap_width_in_cells + 1;
+ for (x = 0; x < n_horiz_segments; x++) {
+ segment[x].x1 = 0;
+ segment[x].x2 = (short) cw->squareCell.pixmap_width_in_pixels;
+ segment[x].y1 = (short) cw->squareCell.cell_size_in_pixels * x;
+ segment[x].y2 = (short) cw->squareCell.cell_size_in_pixels * x;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_horiz_segments);
+ for (y = 0; y < n_vert_segments; y++) {
+ segment[y].x1 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].x2 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].y1 = 0;
+ segment[y].y2 = (short) cw->squareCell.pixmap_height_in_pixels;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_vert_segments);
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+/* A Public function, not static */
+char *
+SquareCellGetArray(w, width_in_cells, height_in_cells)
+Widget w;
+int *width_in_cells, *height_in_cells;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ *width_in_cells = cw->squareCell.pixmap_width_in_cells;
+ *height_in_cells = cw->squareCell.pixmap_height_in_cells;
+ return (cw->squareCell.cell);
+}
+static void
+Resize(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* resize does nothing unless new size is bigger than entire pixmap */
+ if ((cw->core.width > cw->squareCell.pixmap_width_in_pixels) &&
+ (cw->core.height > cw->squareCell.pixmap_height_in_pixels)) {
+ /*
+ * Calculate the maximum cell size that will allow the
+ * entire bitmap to be displayed.
+ */
+ Dimension w_temp_cell_size_in_pixels, h_temp_cell_size_in_pixels;
+ Dimension new_cell_size_in_pixels;
+
+ w_temp_cell_size_in_pixels = cw->core.width / cw->squareCell.pixmap_width_in_cells;
+ h_temp_cell_size_in_pixels = cw->core.height / cw->squareCell.pixmap_height_in_cells;
+
+ if (w_temp_cell_size_in_pixels < h_temp_cell_size_in_pixels)
+ new_cell_size_in_pixels = w_temp_cell_size_in_pixels;
+ else
+ new_cell_size_in_pixels = h_temp_cell_size_in_pixels;
+
+ /* if size change mandates a new pixmap, make one */
+ if (new_cell_size_in_pixels != cw->squareCell.cell_size_in_pixels)
+ ChangeCellSize(cw, new_cell_size_in_pixels);
+ }
+}
+static void
+ChangeCellSize(w, new_cell_size)
+Widget w;
+int new_cell_size;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int x, y;
+ cw->squareCell.cell_size_in_pixels = new_cell_size;
+ /* recalculate variables based on cell size */
+ cw->squareCell.pixmap_width_in_pixels =
+ cw->squareCell.pixmap_width_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+ cw->squareCell.pixmap_height_in_pixels =
+ cw->squareCell.pixmap_height_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+
+ /* destroy old and create new pixmap of correct size */
+ XFreePixmap(XtDisplay((Widget)cw), cw->squareCell.big_picture);
+ CreateBigPixmap((Widget)cw);
+
+ /* draw lines into new pixmap */
+ DrawIntoBigPixmap((Widget)cw);
+
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+static void
+DoCell(w, x, y, gc)
+Widget w;
+int x, y;
+GC gc;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels * x + 2,
+ cw->squareCell.cell_size_in_pixels * y + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+}
+static XtGeometryResult QueryGeometry(w, proposed, answer)
+Widget w;
+XtWidgetGeometry *proposed, *answer;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+
+ if (test_for == 2) {
+ tet_infoline("TEST: request_mode passed to query_geometry procedure");
+ if (proposed->request_mode != 0) {
+ sprintf(ebuf, "ERROR: Expected request_mode = 0, is %d", proposed->request_mode);
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ }
+ avs_set_event(1,1);
+ /* set fields we care about */
+ answer->request_mode = CWWidth | CWHeight;
+ /* initial width and height */
+ if (cw->squareCell.show_all == True)
+ answer->width = cw->squareCell.pixmap_width_in_pixels;
+ else
+ answer->width = (cw->squareCell.pixmap_width_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_width_in_pixels;
+ if (cw->squareCell.show_all == True)
+ answer->height = cw->squareCell.pixmap_height_in_pixels;
+ else
+ answer->height = (cw->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_height_in_pixels;
+ height_ret = answer->height;
+ width_ret = answer->width;
+ if ( ((proposed->request_mode & (CWWidth | CWHeight))
+ == (CWWidth | CWHeight)) &&
+ proposed->width == answer->width &&
+ proposed->height == answer->height)
+ return XtGeometryYes;
+ else if (answer->width == cw->core.width &&
+ answer->height == cw->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
+>>SET tpstartup avs_alloc_sem
+>>SET tpcleanup avs_free_sem
+>>CFILES tqrygomty.c
+>>TITLE XtQueryGeometry Xt8
+XtGeometryResult
+XtQueryGeometry(w, intended, preferred_return)
+>>ASSERTION Good A
+A successful call to
+XtGeometryResult XtQueryGeometry(w, intended, preferred_return)
+when the query_geometry field of the widget
+.A w
+is not NULL shall invoke the procedure specified by this field,
+passing
+.A w,
+.A intended,
+and
+.A preferred_return
+as arguments, and return the value this procedure returns.
+>>CODE
+XtWidgetGeometry intended, geom;
+Widget squarew;
+int result;
+int invoked = 0;
+pid_t pid2;
+
+ FORK(pid2);
+ test_for = 1;
+ avs_xt_hier("Tqrygomty1", "XtQueryGeometry");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Call XtQueryGeometry");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ result = XtQueryGeometry(squarew, &intended, &geom);
+ KROF(pid2);
+ tet_infoline("TEST: Query_geometry procedure was invoked");
+ invoked = avs_get_event(1);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Procedure query_geometry not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A successful call to
+XtGeometryResult XtQueryGeometry(w, intended, preferred_return)
+when the query_geometry field of the widget
+.A w
+is not NULL and
+.A intended
+is NULL shall pass a pointer to an XtWidgetGeometry structure
+that has the request_mode set to zero as the request argument to
+the query_geometry procedure.
+>>CODE
+XtWidgetGeometry intended, geom;
+Widget squarew;
+int result;
+int invoked = 0;
+pid_t pid2;
+
+ FORK(pid2);
+ test_for = 2;
+ avs_xt_hier("Tqrygomty1", "XtQueryGeometry");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Call XtQueryGeometry");
+ result = XtQueryGeometry(squarew, NULL, &geom);
+ KROF(pid2);
+ tet_infoline("TEST: Query_geometry procedure was invoked");
+ invoked = avs_get_event(1);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Procedure query_geometry not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A successful call to
+XtGeometryResult XtQueryGeometry(w, intended, preferred_return)
+when the query_geometry field of the widget
+.A w
+is not NULL shall set the fields of
+.A preferred_return
+corresponding to bits that are not set in preferred_return->request_mode to
+the current values for the widget instance, with fields corresponding to
+bits set in
+.A preferred_return
+set to values by the widget's query_geometry procedure.
+>>CODE
+XtWidgetGeometry intended, geom;
+Widget squarew;
+int result;
+int invoked = 0;
+pid_t pid2;
+
+ FORK(pid2);
+ test_for = 3;
+ avs_xt_hier("Tqrygomty1", "XtQueryGeometry");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ memset(&geom, -1, sizeof(geom));
+ tet_infoline("PREP: Call XtQueryGeometry");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ result = XtQueryGeometry(squarew, &intended, &geom);
+ tet_infoline("TEST: preferred_return->request_mode");
+ check_dec(CWWidth | CWHeight, (long)geom.request_mode, "preferred_return->request_mode");
+ tet_infoline("TEST: Returned values");
+ check_dec((long)width_ret, (long)geom.width, "preferred_return.width");
+ check_dec((long)height_ret, (long)geom.height, "preferred_return.height");
+ check_not_dec(-1, (long)geom.x, "preferred_return.height");
+ check_not_dec(-1, (long)geom.y, "preferred_return.height");
+ check_not_dec(-1, (long)geom.border_width, "preferred_return.height");
+ KROF(pid2);
+ tet_infoline("TEST: Query_geometry procedure was invoked");
+ invoked = avs_get_event(1);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Procedure query_geometry not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A successful call to
+XtGeometryResult XtQueryGeometry(w, intended, preferred_return)
+when the query_geometry field of the widget
+.A w
+is not NULL and the query_geometry procedure does not set
+CWStackMode in preferred_return->return_mode shall set
+preferred_return.stack_mode to XtSMDontChange.
+>>CODE
+XtWidgetGeometry intended, geom;
+Widget squarew;
+int result;
+int invoked = 0;
+pid_t pid2;
+
+ FORK(pid2);
+ test_for = 4;
+ avs_xt_hier("Tqrygomty1", "XtQueryGeometry");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Call XtQueryGeometry");
+ intended.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
+ result = XtQueryGeometry(squarew, NULL, &geom);
+ tet_infoline("TEST: preferred_return.stack_mode");
+ check_dec(XtSMDontChange, (long)geom.stack_mode, "preferred_return.stack_mode");
+ KROF(pid2);
+ tet_infoline("TEST: Query_geometry procedure was invoked");
+ invoked = avs_get_event(1);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Procedure query_geometry not invoked");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A successful call to
+XtGeometryResult XtQueryGeometry(w, intended, preferred_return)
+when the query_geometry field of the widget
+.A w
+is NULL shall set all the fields in
+.A preferred_return
+to the current values for the widget instance
+and return XtGeometryYes.
+>>CODE
+
+ test_for = 5;
+ test5A();
+>>ASSERTION Good A
+A successful call to
+XtGeometryResult XtQueryGeometry(w, intended, preferred_return)
+when the query_geometry field of the widget
+.A w
+is NULL shall set preferred_return.stack_mode to XtSMDontChange.
+>>CODE
+
+ test_for = 6;
+ test6A();
diff --git a/xts5/Xt8/XtQueryGeometry/tqrygomty.c b/xts5/Xt8/XtQueryGeometry/tqrygomty.c
new file mode 100644
index 00000000..3f8713e7
--- /dev/null
+++ b/xts5/Xt8/XtQueryGeometry/tqrygomty.c
@@ -0,0 +1,780 @@
+/*
+Copyright (c) 2005 X.Org Foundation LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+/*$Header: /cvs/xtest/xtest/xts5/tset/Xt8/XtQueryGeometry/XtQueryGeometry.c,v 1.1 2005-02-12 14:38:23 anderson Exp $
+*
+* Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995
+* Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993
+* All Rights Reserved.
+*
+* Project: VSW5
+*
+* File: tset/Xt8/XtQueryGeometry/XtQueryGeometry.c
+*
+* Description:
+* Tests 5 and 6 for XtQueryGeometry()
+*
+* Modifications:
+* $Log: tqrygomty.c,v $
+* Revision 1.1 2005-02-12 14:38:23 anderson
+* Initial revision
+*
+* Revision 8.0 1998/12/23 23:36:55 mar
+* Branch point for Release 5.0.2
+*
+* Revision 7.0 1998/10/30 22:59:48 mar
+* Branch point for Release 5.0.2b1
+*
+* Revision 6.0 1998/03/02 05:28:02 tbr
+* Branch point for Release 5.0.1
+*
+* Revision 5.0 1998/01/26 03:24:36 tbr
+* Branch point for Release 5.0.1b1
+*
+* Revision 4.0 1995/12/15 09:17:57 tbr
+* Branch point for Release 5.0.0
+*
+* Revision 3.1 1995/12/15 01:22:13 andy
+* Prepare for GA Release
+*
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <XtTest.h>
+#include <X11/IntrinsicP.h>
+#include <X11/ConstrainP.h>
+#include <X11/CoreP.h>
+#include <xt/SquareCelP.h>
+
+/*error messages created here*/
+char ebuf[4096];
+
+XtAppContext app_ctext;
+Widget topLevel, panedw, boxw1, boxw2;
+Widget labelw, rowcolw, click_quit;
+
+Dimension height_ret;
+Dimension width_ret;
+
+int test_for;
+
+/*
+ * SquareCell.c - Square Widget
+ */
+#define INTERNAL_WIDTH 2
+#define INTERNAL_HEIGHT 4
+#define DEFAULT_PIXMAP_WIDTH 1 /* in cells */
+#define DEFAULT_PIXMAP_HEIGHT 1 /* in cells */
+#define DEFAULT_CELL_SIE 20 /* in pixels */
+/* values for instance variable is_drawn */
+#define DRAWN 1
+#define UNDRAWN 0
+/* modes for drawing */
+#define DRAW 1
+#define UNDRAW 0
+#define MAXLINES 10 /* max of horiz or vertical cells */
+#define SCROLLBARWIDTH 15
+#define DEFAULTWIDTH 300 /* widget size when show_all is False */
+#define offset(field) XtOffsetOf(SquareCellRec, field)
+static XtResource resources[] = {
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(squareCell.foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XavsNtoggleCallback,
+ XavsCToggleCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(squareCell.callback),
+ XtRCallback,
+ NULL
+ },
+ {
+ XavsNcellSizeInPixels,
+ XavsCCellSizeInPixels,
+ XtRInt, sizeof(int),
+ offset(squareCell.cell_size_in_pixels),
+ XtRImmediate,
+ (XtPointer)DEFAULT_CELL_SIE
+ },
+ {
+ XavsNpixmapWidthInCells,
+ XavsCPixmapWidthInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_width_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_WIDTH
+ },
+ {
+ XavsNpixmapHeightInCells,
+ XavsCPixmapHeightInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_height_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_HEIGHT
+ },
+ {
+ XavsNcurX,
+ XavsCCurX,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_x),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcurY,
+ XavsCCurY,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_y),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcellArray,
+ XavsCCellArray,
+ XtRString,
+ sizeof(String),
+ offset(squareCell.cell),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNshowEntireBitmap,
+ XavsCShowEntireBitmap,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(squareCell.show_all),
+ XtRImmediate,
+ (XtPointer) TRUE
+ },
+};
+/* Declaration of methods */
+static void Initialize();
+static void Redisplay();
+static void Destroy();
+static void Resize();
+static Boolean SetValues();
+static XtGeometryResult QueryGeometry();
+/* these Core methods not needed by SquareCell:
+ *
+ * static void ClassInitialize();
+ * static void Realize();
+ */
+/* the following are private functions unique to SquareCell */
+static void DrawPixmaps(), DoCell(), ChangeCellSize();
+/* the following are actions of SquareCell */
+static void DrawCell(), UndrawCell(), ToggleCell();
+/* The following are public functions of SquareCell, declared extern
+ * in the public include file: */
+char *SquareCellGetArray2();
+static char defaultTranslations[] =
+ "<Btn1Down>: DrawCell() \n\
+ <Btn2Down>: UndrawCell() \n\
+ <Btn3Down>: ToggleCell() \n\
+ <Btn1Motion>: DrawCell() \n\
+ <Btn2Motion>: UndrawCell() \n\
+ <Btn3Motion>: ToggleCell()";
+static XtActionsRec actions[] = {
+ {"DrawCell", DrawCell},
+ {"UndrawCell", UndrawCell},
+ {"ToggleCell", ToggleCell},
+};
+/* definition in SquareCell.h */
+static SquareCellPointInfo info;
+SquareCellClassRec squareCellClassRec2 = {
+ {
+ /* core_class fields */
+ /* superclass */ (WidgetClass) &coreClassRec,
+ /* class_name */ "SquareCell",
+ /* widget_size */ sizeof(SquareCellRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ NULL,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ {/* simple_class fields */
+ /* change_sensitive */ XtInheritChangeSensitive,
+ },
+ {
+ /* extension */ 0,
+ },
+};
+WidgetClass squareCellWidgetClass2 = (WidgetClass) & squareCellClassRec2;
+static void
+GetDrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground | GCDashOffset |
+ GCDashList | GCLineStyle;
+ /*
+ * Setting foreground and background to 1 and 0 looks like a
+ * kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied with a
+ * separate GC when the pixmap is copied into the window.
+ */
+ values.foreground = 1;
+ values.background = 0;
+ values.dashes = 1;
+ values.dash_offset = 0;
+ values.line_style = LineOnOffDash;
+ cw->squareCell.draw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetUndrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ /* this looks like a kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied as the
+ * pixmap is copied into the window.
+ */
+ values.foreground = 0;
+ values.background = 1;
+ cw->squareCell.undraw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetCopyGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ values.foreground = cw->squareCell.foreground;
+ values.background = cw->core.background_pixel;
+ cw->squareCell.copy_gc = XtGetGC((Widget)cw, mask, &values);
+}
+static void
+Initialize(treq, tnew, args, num_args)
+Widget treq, tnew;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget new = (SquareCellWidget) tnew;
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ /*
+ * Check instance values set by resources that may be invalid.
+ */
+ if ((new->squareCell.pixmap_width_in_cells < 1) ||
+ (new->squareCell.pixmap_height_in_cells < 1)) {
+ XtWarning("SquareCell: pixmapWidth and/or pixmapHeight is too small (using 10 x 10)");
+ new->squareCell.pixmap_width_in_cells = 10;
+ new->squareCell.pixmap_height_in_cells = 10;
+ }
+ if (new->squareCell.cell_size_in_pixels < 5) {
+ XtWarning("SquareCell: cellSize is too small (using 5)");
+ new->squareCell.cell_size_in_pixels = 5;
+ }
+ if ((new->squareCell.cur_x < 0) || (new->squareCell.cur_y < 0)) {
+ XtWarning("SquareCell: cur_x and cur_y must be non-negative (using 0, 0)");
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ }
+ if (new->squareCell.cell == NULL)
+ new->squareCell.cell = XtCalloc(
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.pixmap_height_in_cells, sizeof(char));
+ else
+ new->squareCell.user_allocated = True; /* user supplied cell array */
+ new->squareCell.pixmap_width_in_pixels =
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ new->squareCell.pixmap_height_in_pixels =
+ new->squareCell.pixmap_height_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ if (new->core.width == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.width = (new->squareCell.pixmap_width_in_pixels
+ > DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_width_in_pixels);
+ else
+ new->core.width = new->squareCell.pixmap_width_in_pixels;
+ }
+ if (new->core.height == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.height =
+ (new->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_height_in_pixels);
+ else
+ new->core.height = new->squareCell.pixmap_height_in_pixels;
+ }
+ CreateBigPixmap2(new);
+ GetDrawGC(new);
+ GetUndrawGC(new);
+ GetCopyGC(new);
+ DrawIntoBigPixmap2(new);
+}
+static void
+Redisplay(w, event)
+Widget w;
+XExposeEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ register int x, y;
+ unsigned int width, height;
+ if (!XtIsRealized((Widget)cw))
+ return;
+ if (event) { /* called from btn-event or expose */
+ x = event->x;
+ y = event->y;
+ width = event->width;
+ height = event->height;
+ }
+ else { /* called because complete redraw */
+ x = 0;
+ y = 0;
+ width = cw->squareCell.pixmap_width_in_pixels;
+ height = cw->squareCell.pixmap_height_in_pixels;
+ }
+ if (DefaultDepthOfScreen(XtScreen((Widget)cw)) == 1)
+ XCopyArea(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y);
+ else
+ XCopyPlane(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y, 1);
+}
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget curcw = (SquareCellWidget) current;
+ SquareCellWidget newcw = (SquareCellWidget) new;
+ Boolean do_redisplay = False;
+ /*
+ ** XtSetValues invoked procedure SetValues
+ */
+ if (curcw->squareCell.foreground != newcw->squareCell.foreground) {
+ XtReleaseGC((Widget)curcw, curcw->squareCell.copy_gc);
+ GetCopyGC(newcw);
+ do_redisplay = True;
+ }
+ if ((curcw->squareCell.cur_x != newcw->squareCell.cur_x) ||
+ (curcw->squareCell.cur_y != newcw->squareCell.cur_y))
+ do_redisplay = True;
+ if (curcw->squareCell.cell_size_in_pixels !=
+ newcw->squareCell.cell_size_in_pixels) {
+ ChangeCellSize(curcw, newcw->squareCell.cell_size_in_pixels);
+ do_redisplay = True;
+ }
+ if (curcw->squareCell.pixmap_width_in_cells !=
+ newcw->squareCell.pixmap_width_in_cells) {
+ newcw->squareCell.pixmap_width_in_cells =
+ curcw->squareCell.pixmap_width_in_cells;
+ XtWarning("SquareCell: pixmap_width_in_cells cannot be set by XtSetValues.\n");
+ }
+ if (curcw->squareCell.pixmap_height_in_cells !=
+ newcw->squareCell.pixmap_height_in_cells) {
+ newcw->squareCell.pixmap_height_in_cells =
+ curcw->squareCell.pixmap_height_in_cells;
+ XtWarning("SquareCell: pixmap_height_in_cells cannot be set by XtSetValues.\n");
+ }
+ return do_redisplay;
+}
+static void
+Destroy(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ if (cw->squareCell.big_picture)
+ XFreePixmap(XtDisplay((Widget)cw), cw->squareCell.big_picture);
+ if (cw->squareCell.draw_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.draw_gc);
+ if (cw->squareCell.undraw_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.undraw_gc);
+ if (cw->squareCell.copy_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.copy_gc);
+ /* Free memory allocated with Calloc. This was done
+ * only if application didn't supply cell array.
+ */
+ if (!cw->squareCell.user_allocated)
+ XtFree(cw->squareCell.cell);
+}
+static void
+DrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.draw_gc, DRAW, cw, event);
+}
+static void
+UndrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.undraw_gc, UNDRAW, cw, event);
+}
+static void
+ToggleCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ static int oldx = -1, oldy = -1;
+ GC gc;
+ int mode;
+ int newx, newy;
+ /* This is strictly correct, but doesn't
+ * seem to be necessary */
+ if (event->type == ButtonPress) {
+ newx = (cw->squareCell.cur_x + ((XButtonEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XButtonEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ else {
+ newx = (cw->squareCell.cur_x + ((XMotionEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XMotionEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ if ((mode = cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells]) == DRAWN) {
+ gc = cw->squareCell.undraw_gc;
+ mode = UNDRAW;
+ }
+ else {
+ gc = cw->squareCell.draw_gc;
+ mode = DRAW;
+ }
+ if (oldx != newx || oldy != newy) {
+ oldx = newx;
+ oldy = newy;
+ DrawPixmaps(gc, mode, cw, event);
+ }
+}
+static void
+DrawPixmaps(gc, mode, w, event)
+GC gc;
+int mode;
+Widget w;
+XButtonEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int newx = (cw->squareCell.cur_x + event->x) /
+ cw->squareCell.cell_size_in_pixels;
+ int newy = (cw->squareCell.cur_y + event->y) /
+ cw->squareCell.cell_size_in_pixels;
+ XExposeEvent fake_event;
+ /* if already done, return */
+ if (cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] == mode)
+ return;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels*newx + 2,
+ cw->squareCell.cell_size_in_pixels*newy + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+ cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] = mode;
+ info.mode = mode;
+ info.newx = newx;
+ info.newy = newy;
+ fake_event.x = cw->squareCell.cell_size_in_pixels * newx - cw->squareCell.cur_x;
+ fake_event.y = cw->squareCell.cell_size_in_pixels * newy - cw->squareCell.cur_y;
+ fake_event.width = cw->squareCell.cell_size_in_pixels;
+ fake_event.height = cw->squareCell.cell_size_in_pixels;
+ Redisplay(cw, &fake_event);
+ XtCallCallbacks((Widget)cw, XavsNtoggleCallback, &info);
+}
+CreateBigPixmap2(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* always a 1 bit deep pixmap, regardless of screen depth */
+ cw->squareCell.big_picture = XCreatePixmap(XtDisplay((Widget)cw),
+ RootWindow(XtDisplay((Widget)cw), DefaultScreen(XtDisplay((Widget)cw))),
+ cw->squareCell.pixmap_width_in_pixels + 2,
+ cw->squareCell.pixmap_height_in_pixels + 2, 1);
+}
+DrawIntoBigPixmap2(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int n_horiz_segments, n_vert_segments;
+ XSegment segment[MAXLINES];
+ register int x, y;
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ cw->squareCell.undraw_gc, 0, 0,
+ cw->squareCell.pixmap_width_in_pixels
+ + 2, cw->squareCell.pixmap_height_in_pixels + 2);
+ n_horiz_segments = cw->squareCell.pixmap_height_in_cells + 1;
+ n_vert_segments = cw->squareCell.pixmap_width_in_cells + 1;
+ for (x = 0; x < n_horiz_segments; x++) {
+ segment[x].x1 = 0;
+ segment[x].x2 = (short) cw->squareCell.pixmap_width_in_pixels;
+ segment[x].y1 = (short) cw->squareCell.cell_size_in_pixels * x;
+ segment[x].y2 = (short) cw->squareCell.cell_size_in_pixels * x;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_horiz_segments);
+ for (y = 0; y < n_vert_segments; y++) {
+ segment[y].x1 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].x2 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].y1 = 0;
+ segment[y].y2 = (short) cw->squareCell.pixmap_height_in_pixels;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_vert_segments);
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+/* A Public function, not static */
+char *
+SquareCellGetArray2(w, width_in_cells, height_in_cells)
+Widget w;
+int *width_in_cells, *height_in_cells;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ *width_in_cells = cw->squareCell.pixmap_width_in_cells;
+ *height_in_cells = cw->squareCell.pixmap_height_in_cells;
+ return (cw->squareCell.cell);
+}
+static void
+Resize(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* resize does nothing unless new size is bigger than entire pixmap */
+ if ((cw->core.width > cw->squareCell.pixmap_width_in_pixels) &&
+ (cw->core.height > cw->squareCell.pixmap_height_in_pixels)) {
+ /*
+ * Calculate the maximum cell size that will allow the
+ * entire bitmap to be displayed.
+ */
+ Dimension w_temp_cell_size_in_pixels, h_temp_cell_size_in_pixels;
+ Dimension new_cell_size_in_pixels;
+
+ w_temp_cell_size_in_pixels = cw->core.width / cw->squareCell.pixmap_width_in_cells;
+ h_temp_cell_size_in_pixels = cw->core.height / cw->squareCell.pixmap_height_in_cells;
+
+ if (w_temp_cell_size_in_pixels < h_temp_cell_size_in_pixels)
+ new_cell_size_in_pixels = w_temp_cell_size_in_pixels;
+ else
+ new_cell_size_in_pixels = h_temp_cell_size_in_pixels;
+
+ /* if size change mandates a new pixmap, make one */
+ if (new_cell_size_in_pixels != cw->squareCell.cell_size_in_pixels)
+ ChangeCellSize(cw, new_cell_size_in_pixels);
+ }
+}
+static void
+ChangeCellSize(w, new_cell_size)
+Widget w;
+int new_cell_size;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int x, y;
+ cw->squareCell.cell_size_in_pixels = new_cell_size;
+ /* recalculate variables based on cell size */
+ cw->squareCell.pixmap_width_in_pixels =
+ cw->squareCell.pixmap_width_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+ cw->squareCell.pixmap_height_in_pixels =
+ cw->squareCell.pixmap_height_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+
+ /* destroy old and create new pixmap of correct size */
+ XFreePixmap(XtDisplay((Widget)cw), cw->squareCell.big_picture);
+ CreateBigPixmap2((Widget)cw);
+
+ /* draw lines into new pixmap */
+ DrawIntoBigPixmap2((Widget)cw);
+
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+static void
+DoCell(w, x, y, gc)
+Widget w;
+int x, y;
+GC gc;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels * x + 2,
+ cw->squareCell.cell_size_in_pixels * y + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+}
+static XtGeometryResult QueryGeometry(w, proposed, answer)
+Widget w;
+XtWidgetGeometry *proposed, *answer;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+
+ if (test_for == 2) {
+ tet_infoline("TEST: request_mode");
+ if (proposed->request_mode != 0) {
+ sprintf(ebuf, "ERROR: Expected request_mode = 0, is %d", proposed->request_mode);
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ }
+ avs_set_event(1,1);
+ /* set fields we care about */
+ answer->request_mode = CWWidth | CWHeight;
+ /* initial width and height */
+ if (cw->squareCell.show_all == True)
+ answer->width = cw->squareCell.pixmap_width_in_pixels;
+ else
+ answer->width = (cw->squareCell.pixmap_width_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_width_in_pixels;
+ if (cw->squareCell.show_all == True)
+ answer->height = cw->squareCell.pixmap_height_in_pixels;
+ else
+ answer->height = (cw->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_height_in_pixels;
+ height_ret = answer->height;
+ width_ret = answer->width;
+ if ( ((proposed->request_mode & (CWWidth | CWHeight))
+ == (CWWidth | CWHeight)) &&
+ proposed->width == answer->width &&
+ proposed->height == answer->height)
+ return XtGeometryYes;
+ else if (answer->width == cw->core.width &&
+ answer->height == cw->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
+
+void test5A()
+{
+XtWidgetGeometry intended, geom;
+SquareCellWidget squarew;
+int result;
+int invoked = 0;
+pid_t pid2;
+
+ FORK(pid2);
+ test_for = 3;
+ avs_xt_hier("Tqrygomty1", "XtQueryGeometry");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = (SquareCellWidget)XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass2, boxw1, NULL);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ memset(&geom, -1, sizeof(geom));
+ tet_infoline("TEST: Call XtQueryGeometry");
+ result = XtQueryGeometry((Widget)squarew, &intended, &geom);
+ tet_infoline("TEST: Return value");
+ check_dec(XtGeometryYes, result, "return value");
+ tet_infoline("TEST: returned values");
+ check_not_dec(-1, (long)geom.x, "preferred_return.height");
+ check_not_dec(-1, (long)geom.y, "preferred_return.height");
+ check_not_dec(-1, (long)geom.border_width, "preferred_return.height");
+ check_not_dec(-1, (long)geom.width, "preferred_return.width");
+ check_not_dec(-1, (long)geom.height, "preferred_return.height");
+ KROF(pid2);
+ tet_result(TET_PASS);
+}
+
+void test6A()
+{
+XtWidgetGeometry intended, geom;
+SquareCellWidget squarew;
+int result;
+int invoked = 0;
+pid_t pid2;
+
+ FORK(pid2);
+ test_for = 3;
+ avs_xt_hier("Tqrygomty1", "XtQueryGeometry");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = (SquareCellWidget)XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass2, boxw1, NULL);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ geom.stack_mode = -1;
+ geom.request_mode = 0;
+ tet_infoline("TEST: Call XtQueryGeometry");
+ result = XtQueryGeometry((Widget)squarew, &intended, &geom);
+ tet_infoline("TEST: preferred_return.stack_mode");
+ check_dec(XtSMDontChange, (long)geom.stack_mode, "preferred_return.stack_mode");
+ KROF(pid2);
+ tet_result(TET_PASS);
+}
diff --git a/xts5/Xt8/XtResizeWidget/XtResizeWidget.m b/xts5/Xt8/XtResizeWidget/XtResizeWidget.m
new file mode 100644
index 00000000..60443604
--- /dev/null
+++ b/xts5/Xt8/XtResizeWidget/XtResizeWidget.m
@@ -0,0 +1,862 @@
+Copyright (c) 2005 X.Org Foundation LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+$Header: /cvs/xtest/xtest/xts5/tset/Xt8/XtResizeWidget/XtResizeWidget.m,v 1.1 2005-02-12 14:38:23 anderson Exp $
+
+Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995
+Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993
+All Rights Reserved.
+
+>>#
+>># Project: VSW5
+>>#
+>># File: tset/Xt8/XtResizeWidget/XtResizeWidget.m
+>>#
+>># Description:
+>># Tests for XtResizeWidget()
+>>#
+>># Modifications:
+>># $Log: trszewdgt.m,v $
+>># Revision 1.1 2005-02-12 14:38:23 anderson
+>># Initial revision
+>>#
+>># Revision 8.0 1998/12/23 23:36:54 mar
+>># Branch point for Release 5.0.2
+>>#
+>># Revision 7.0 1998/10/30 22:59:46 mar
+>># Branch point for Release 5.0.2b1
+>>#
+>># Revision 6.0 1998/03/02 05:28:01 tbr
+>># Branch point for Release 5.0.1
+>>#
+>># Revision 5.0 1998/01/26 03:24:35 tbr
+>># Branch point for Release 5.0.1b1
+>>#
+>># Revision 4.0 1995/12/15 09:17:47 tbr
+>># Branch point for Release 5.0.0
+>>#
+>># Revision 3.1 1995/12/15 01:22:03 andy
+>># Prepare for GA Release
+>>#
+>>EXTERN
+#include <X11/IntrinsicP.h>
+#include <X11/ConstrainP.h>
+#include <X11/CoreP.h>
+#include <xt/SquareCelP.h>
+
+XtAppContext app_ctext;
+Widget topLevel, panedw, boxw1, boxw2;
+Widget labelw, rowcolw, click_quit;
+
+
+/*
+ * SquareCell.c - Square Widget
+ */
+#define INTERNAL_WIDTH 2
+#define INTERNAL_HEIGHT 4
+#define DEFAULT_PIXMAP_WIDTH 1 /* in cells */
+#define DEFAULT_PIXMAP_HEIGHT 1 /* in cells */
+#define DEFAULT_CELL_SIE 20 /* in pixels */
+/* values for instance variable is_drawn */
+#define DRAWN 1
+#define UNDRAWN 0
+/* modes for drawing */
+#define DRAW 1
+#define UNDRAW 0
+#define MAXLINES 10 /* max of horiz or vertical cells */
+#define SCROLLBARWIDTH 15
+#define DEFAULTWIDTH 300 /* widget size when show_all is False */
+#define offset(field) XtOffsetOf(SquareCellRec, field)
+static XtResource resources[] = {
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(squareCell.foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XavsNtoggleCallback,
+ XavsCToggleCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(squareCell.callback),
+ XtRCallback,
+ NULL
+ },
+ {
+ XavsNcellSizeInPixels,
+ XavsCCellSizeInPixels,
+ XtRInt, sizeof(int),
+ offset(squareCell.cell_size_in_pixels),
+ XtRImmediate,
+ (XtPointer)DEFAULT_CELL_SIE
+ },
+ {
+ XavsNpixmapWidthInCells,
+ XavsCPixmapWidthInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_width_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_WIDTH
+ },
+ {
+ XavsNpixmapHeightInCells,
+ XavsCPixmapHeightInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_height_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_HEIGHT
+ },
+ {
+ XavsNcurX,
+ XavsCCurX,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_x),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcurY,
+ XavsCCurY,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_y),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcellArray,
+ XavsCCellArray,
+ XtRString,
+ sizeof(String),
+ offset(squareCell.cell),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNshowEntireBitmap,
+ XavsCShowEntireBitmap,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(squareCell.show_all),
+ XtRImmediate,
+ (XtPointer) TRUE
+ },
+};
+/* Declaration of methods */
+static void Initialize();
+static void Redisplay();
+static void Destroy();
+static void Resize();
+static Boolean SetValues();
+static XtGeometryResult QueryGeometry();
+/* these Core methods not needed by SquareCell:
+ *
+ * static void ClassInitialize();
+ * static void Realize();
+ */
+/* the following are private functions unique to SquareCell */
+static void DrawPixmaps(), DoCell(), ChangeCellSize();
+/* the following are actions of SquareCell */
+static void DrawCell(), UndrawCell(), ToggleCell();
+/* The following are public functions of SquareCell, declared extern
+ * in the public include file: */
+char *SquareCellGetArray();
+static char defaultTranslations[] =
+ "<Btn1Down>: DrawCell() \n\
+ <Btn2Down>: UndrawCell() \n\
+ <Btn3Down>: ToggleCell() \n\
+ <Btn1Motion>: DrawCell() \n\
+ <Btn2Motion>: UndrawCell() \n\
+ <Btn3Motion>: ToggleCell()";
+static XtActionsRec actions[] = {
+ {"DrawCell", DrawCell},
+ {"UndrawCell", UndrawCell},
+ {"ToggleCell", ToggleCell},
+};
+/* definition in SquareCell.h */
+static SquareCellPointInfo info;
+SquareCellClassRec squareCellClassRec = {
+ {
+ /* core_class fields */
+ /* superclass */ (WidgetClass) &coreClassRec,
+ /* class_name */ "SquareCell",
+ /* widget_size */ sizeof(SquareCellRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ {/* simple_class fields */
+ /* change_sensitive */ XtInheritChangeSensitive,
+ },
+ {
+ /* extension */ 0,
+ },
+};
+WidgetClass squareCellWidgetClass = (WidgetClass) & squareCellClassRec;
+static void
+GetDrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground | GCDashOffset |
+ GCDashList | GCLineStyle;
+ /*
+ * Setting foreground and background to 1 and 0 looks like a
+ * kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied with a
+ * separate GC when the pixmap is copied into the window.
+ */
+ values.foreground = 1;
+ values.background = 0;
+ values.dashes = 1;
+ values.dash_offset = 0;
+ values.line_style = LineOnOffDash;
+ cw->squareCell.draw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetUndrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ /* this looks like a kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied as the
+ * pixmap is copied into the window.
+ */
+ values.foreground = 0;
+ values.background = 1;
+ cw->squareCell.undraw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetCopyGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ values.foreground = cw->squareCell.foreground;
+ values.background = cw->core.background_pixel;
+ cw->squareCell.copy_gc = XtGetGC((Widget)cw, mask, &values);
+}
+static void
+Initialize(treq, tnew, args, num_args)
+Widget treq, tnew;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget new = (SquareCellWidget) tnew;
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ /*
+ * Check instance values set by resources that may be invalid.
+ */
+ if ((new->squareCell.pixmap_width_in_cells < 1) ||
+ (new->squareCell.pixmap_height_in_cells < 1)) {
+ XtWarning("SquareCell: pixmapWidth and/or pixmapHeight is too small (using 10 x 10).");
+ new->squareCell.pixmap_width_in_cells = 10;
+ new->squareCell.pixmap_height_in_cells = 10;
+ }
+ if (new->squareCell.cell_size_in_pixels < 5) {
+ XtWarning("SquareCell: cellSize is too small (using 5).");
+ new->squareCell.cell_size_in_pixels = 5;
+ }
+ if ((new->squareCell.cur_x < 0) || (new->squareCell.cur_y < 0)) {
+ XtWarning("SquareCell: cur_x and cur_y must be non-negative (using 0, 0).");
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ }
+ if (new->squareCell.cell == NULL)
+ new->squareCell.cell = XtCalloc(
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.pixmap_height_in_cells, sizeof(char));
+ else
+ new->squareCell.user_allocated = True; /* user supplied cell array */
+ new->squareCell.pixmap_width_in_pixels =
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ new->squareCell.pixmap_height_in_pixels =
+ new->squareCell.pixmap_height_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ if (new->core.width == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.width = (new->squareCell.pixmap_width_in_pixels
+ > DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_width_in_pixels);
+ else
+ new->core.width = new->squareCell.pixmap_width_in_pixels;
+ }
+ if (new->core.height == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.height =
+ (new->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_height_in_pixels);
+ else
+ new->core.height = new->squareCell.pixmap_height_in_pixels;
+ }
+ CreateBigPixmap(new);
+ GetDrawGC(new);
+ GetUndrawGC(new);
+ GetCopyGC(new);
+ DrawIntoBigPixmap(new);
+}
+static void
+Redisplay(w, event)
+Widget w;
+XExposeEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ register int x, y;
+ unsigned int width, height;
+ if (!XtIsRealized((Widget)cw))
+ return;
+ if (event) { /* called from btn-event or expose */
+ x = event->x;
+ y = event->y;
+ width = event->width;
+ height = event->height;
+ }
+ else { /* called because complete redraw */
+ x = 0;
+ y = 0;
+ width = cw->squareCell.pixmap_width_in_pixels;
+ height = cw->squareCell.pixmap_height_in_pixels;
+ }
+ if (DefaultDepthOfScreen(XtScreen((Widget)cw)) == 1)
+ XCopyArea(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y);
+ else
+ XCopyPlane(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y, 1);
+}
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget curcw = (SquareCellWidget) current;
+ SquareCellWidget newcw = (SquareCellWidget) new;
+ Boolean do_redisplay = False;
+ /*
+ ** XtSetValues invoked procedure SetValues
+ */
+ if (curcw->squareCell.foreground != newcw->squareCell.foreground) {
+ XtReleaseGC((Widget)curcw, curcw->squareCell.copy_gc);
+ GetCopyGC(newcw);
+ do_redisplay = True;
+ }
+ if ((curcw->squareCell.cur_x != newcw->squareCell.cur_x) ||
+ (curcw->squareCell.cur_y != newcw->squareCell.cur_y))
+ do_redisplay = True;
+ if (curcw->squareCell.cell_size_in_pixels !=
+ newcw->squareCell.cell_size_in_pixels) {
+ ChangeCellSize(curcw, newcw->squareCell.cell_size_in_pixels);
+ do_redisplay = True;
+ }
+ if (curcw->squareCell.pixmap_width_in_cells !=
+ newcw->squareCell.pixmap_width_in_cells) {
+ newcw->squareCell.pixmap_width_in_cells =
+ curcw->squareCell.pixmap_width_in_cells;
+ XtWarning("SquareCell: pixmap_width_in_cells cannot be set by XtSetValues.\n");
+ }
+ if (curcw->squareCell.pixmap_height_in_cells !=
+ newcw->squareCell.pixmap_height_in_cells) {
+ newcw->squareCell.pixmap_height_in_cells =
+ curcw->squareCell.pixmap_height_in_cells;
+ XtWarning("SquareCell: pixmap_height_in_cells cannot be set by XtSetValues.\n");
+ }
+ return do_redisplay;
+}
+static void
+Destroy(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ if (cw->squareCell.big_picture)
+ XFreePixmap(XtDisplay(cw), cw->squareCell.big_picture);
+ if (cw->squareCell.draw_gc)
+ XFreeGC(XtDisplay(cw), cw->squareCell.draw_gc);
+ if (cw->squareCell.undraw_gc)
+ XFreeGC(XtDisplay(cw), cw->squareCell.undraw_gc);
+ if (cw->squareCell.copy_gc)
+ XFreeGC(XtDisplay(cw), cw->squareCell.copy_gc);
+ /* Free memory allocated with Calloc. This was done
+ * only if application didn't supply cell array.
+ */
+ if (!cw->squareCell.user_allocated)
+ XtFree(cw->squareCell.cell);
+}
+static void
+DrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.draw_gc, DRAW, cw, event);
+}
+static void
+UndrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.undraw_gc, UNDRAW, cw, event);
+}
+static void
+ToggleCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ static int oldx = -1, oldy = -1;
+ GC gc;
+ int mode;
+ int newx, newy;
+ /* This is strictly correct, but doesn't
+ * seem to be necessary */
+ if (event->type == ButtonPress) {
+ newx = (cw->squareCell.cur_x + ((XButtonEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XButtonEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ else {
+ newx = (cw->squareCell.cur_x + ((XMotionEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XMotionEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ if ((mode = cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells]) == DRAWN) {
+ gc = cw->squareCell.undraw_gc;
+ mode = UNDRAW;
+ }
+ else {
+ gc = cw->squareCell.draw_gc;
+ mode = DRAW;
+ }
+ if (oldx != newx || oldy != newy) {
+ oldx = newx;
+ oldy = newy;
+ DrawPixmaps(gc, mode, cw, event);
+ }
+}
+static void
+DrawPixmaps(gc, mode, w, event)
+GC gc;
+int mode;
+Widget w;
+XButtonEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int newx = (cw->squareCell.cur_x + event->x) /
+ cw->squareCell.cell_size_in_pixels;
+ int newy = (cw->squareCell.cur_y + event->y) /
+ cw->squareCell.cell_size_in_pixels;
+ XExposeEvent fake_event;
+ /* if already done, return */
+ if (cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] == mode)
+ return;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels*newx + 2,
+ cw->squareCell.cell_size_in_pixels*newy + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+ cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] = mode;
+ info.mode = mode;
+ info.newx = newx;
+ info.newy = newy;
+ fake_event.x = cw->squareCell.cell_size_in_pixels * newx - cw->squareCell.cur_x;
+ fake_event.y = cw->squareCell.cell_size_in_pixels * newy - cw->squareCell.cur_y;
+ fake_event.width = cw->squareCell.cell_size_in_pixels;
+ fake_event.height = cw->squareCell.cell_size_in_pixels;
+ Redisplay(cw, &fake_event);
+ XtCallCallbacks((Widget)cw, XavsNtoggleCallback, &info);
+}
+CreateBigPixmap(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* always a 1 bit deep pixmap, regardless of screen depth */
+ cw->squareCell.big_picture = XCreatePixmap(XtDisplay((Widget)cw),
+ RootWindow(XtDisplay((Widget)cw), DefaultScreen(XtDisplay((Widget)cw))),
+ cw->squareCell.pixmap_width_in_pixels + 2,
+ cw->squareCell.pixmap_height_in_pixels + 2, 1);
+}
+DrawIntoBigPixmap(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int n_horiz_segments, n_vert_segments;
+ XSegment segment[MAXLINES];
+ register int x, y;
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ cw->squareCell.undraw_gc, 0, 0,
+ cw->squareCell.pixmap_width_in_pixels
+ + 2, cw->squareCell.pixmap_height_in_pixels + 2);
+ n_horiz_segments = cw->squareCell.pixmap_height_in_cells + 1;
+ n_vert_segments = cw->squareCell.pixmap_width_in_cells + 1;
+ for (x = 0; x < n_horiz_segments; x++) {
+ segment[x].x1 = 0;
+ segment[x].x2 = (short) cw->squareCell.pixmap_width_in_pixels;
+ segment[x].y1 = (short) cw->squareCell.cell_size_in_pixels * x;
+ segment[x].y2 = (short) cw->squareCell.cell_size_in_pixels * x;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_horiz_segments);
+ for (y = 0; y < n_vert_segments; y++) {
+ segment[y].x1 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].x2 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].y1 = 0;
+ segment[y].y2 = (short) cw->squareCell.pixmap_height_in_pixels;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_vert_segments);
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+/* A Public function, not static */
+char *
+SquareCellGetArray(w, width_in_cells, height_in_cells)
+Widget w;
+int *width_in_cells, *height_in_cells;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ *width_in_cells = cw->squareCell.pixmap_width_in_cells;
+ *height_in_cells = cw->squareCell.pixmap_height_in_cells;
+ return (cw->squareCell.cell);
+}
+static void
+Resize(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ avs_set_event(1,1);
+ /* resize does nothing unless new size is bigger than entire pixmap */
+ if ((cw->core.width > cw->squareCell.pixmap_width_in_pixels) &&
+ (cw->core.height > cw->squareCell.pixmap_height_in_pixels)) {
+ /*
+ * Calculate the maximum cell size that will allow the
+ * entire bitmap to be displayed.
+ */
+ Dimension w_temp_cell_size_in_pixels, h_temp_cell_size_in_pixels;
+ Dimension new_cell_size_in_pixels;
+
+ w_temp_cell_size_in_pixels = cw->core.width / cw->squareCell.pixmap_width_in_cells;
+ h_temp_cell_size_in_pixels = cw->core.height / cw->squareCell.pixmap_height_in_cells;
+
+ if (w_temp_cell_size_in_pixels < h_temp_cell_size_in_pixels)
+ new_cell_size_in_pixels = w_temp_cell_size_in_pixels;
+ else
+ new_cell_size_in_pixels = h_temp_cell_size_in_pixels;
+
+ /* if size change mandates a new pixmap, make one */
+ if (new_cell_size_in_pixels != cw->squareCell.cell_size_in_pixels)
+ ChangeCellSize(cw, new_cell_size_in_pixels);
+ }
+}
+static void
+ChangeCellSize(w, new_cell_size)
+Widget w;
+int new_cell_size;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int x, y;
+ cw->squareCell.cell_size_in_pixels = new_cell_size;
+ /* recalculate variables based on cell size */
+ cw->squareCell.pixmap_width_in_pixels =
+ cw->squareCell.pixmap_width_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+ cw->squareCell.pixmap_height_in_pixels =
+ cw->squareCell.pixmap_height_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+
+ /* destroy old and create new pixmap of correct size */
+ XFreePixmap(XtDisplay((Widget)cw), cw->squareCell.big_picture);
+ CreateBigPixmap(cw);
+
+ /* draw lines into new pixmap */
+ DrawIntoBigPixmap(cw);
+
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+static void
+DoCell(w, x, y, gc)
+Widget w;
+int x, y;
+GC gc;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels * x + 2,
+ cw->squareCell.cell_size_in_pixels * y + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+}
+static XtGeometryResult QueryGeometry(w, proposed, answer)
+Widget w;
+XtWidgetGeometry *proposed, *answer;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* set fields we care about */
+ answer->request_mode = CWWidth | CWHeight;
+ /* initial width and height */
+ if (cw->squareCell.show_all == True)
+ answer->width = cw->squareCell.pixmap_width_in_pixels;
+ else
+ answer->width = (cw->squareCell.pixmap_width_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_width_in_pixels;
+ if (cw->squareCell.show_all == True)
+ answer->height = cw->squareCell.pixmap_height_in_pixels;
+ else
+ answer->height = (cw->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_height_in_pixels;
+ if ( ((proposed->request_mode & (CWWidth | CWHeight))
+ == (CWWidth | CWHeight)) &&
+ proposed->width == answer->width &&
+ proposed->height == answer->height)
+ return XtGeometryYes;
+ else if (answer->width == cw->core.width &&
+ answer->height == cw->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
+>>SET tpstartup avs_alloc_sem
+>>SET tpcleanup avs_free_sem
+>>TITLE XtResizeWidget Xt8
+void
+XtResizeWidget(w, width, height, border_width)
+>>ASSERTION Good A
+A successful call to
+void XtResizeWidget(w, width, height, border_width)
+when at least one of
+.A width,
+.A height,
+or
+.A border_width
+is different from its corresponding value in the
+object
+.A w
+shall write the specified values into the object.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+int width, height, border_width;
+pid_t pid2;
+
+ FORK(pid2);
+ avs_xt_hier("Trszewdgt1", "XtResizeWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Change height width and border_width of squarew widget.");
+ intended.request_mode = CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(squarew, &intended, &geom);
+ width = geom.width + 10;
+ height = geom.height + 10;
+ border_width = geom.border_width + 1;
+ XtResizeWidget(squarew, width, height, border_width);
+ tet_infoline("TEST: Squarew widget has been resized.");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(width, geometry_good.width, "width");
+ check_dec(height, geometry_good.height, "height");
+ check_dec(border_width, geometry_good.border_width, "border_width");
+ KROF(pid2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+When
+.A w
+is a widget that is realized and at least one of
+.A width,
+.A height,
+or
+.A border_width
+is different from its corresponding value in the
+widget a call to
+void XtResizeWidget(w, width, height, border_width)
+shall resize the widget to the specified values.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+int width, height, border_width;
+pid_t pid2;
+
+ /*should be tested with image capture*/
+ FORK(pid2);
+ avs_xt_hier("Trszewdgt1", "XtResizeWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Change height width and border_width of squarew widget.");
+ intended.request_mode = CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(squarew, &intended, &geom);
+ width = geom.width + 10;
+ height = geom.height + 10;
+ border_width = geom.border_width + 1;
+ XtResizeWidget(squarew, width, height, border_width);
+ tet_infoline("TEST: Squarew widget has been resized.");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(width, geometry_good.width, "width");
+ check_dec(height, geometry_good.height, "height");
+ check_dec(border_width, geometry_good.border_width, "border_width");
+ KROF(pid2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A successful call to
+void XtResizeWidget(w, width, height, border_width)
+when at least one of
+.A width,
+.A height,
+or
+.A border_width
+is different from its corresponding value in the
+object
+.A w
+shall invoke the resize procedure of the specified object.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+int x, y, width, height, border_width;
+int invoked = 0;
+pid_t pid2;
+
+ FORK(pid2);
+ avs_xt_hier("Trszewdgt2", "XtResizeWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Change height and width of squarew widget.");
+ intended.request_mode = CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(squarew, &intended, &geom);
+ width = geom.width + 10;
+ height = geom.height + 10;
+ border_width = geom.border_width;
+ XtResizeWidget(squarew, width, height, border_width);
+ tet_infoline("TEST: Square widget has been resized.");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(width, geometry_good.width, "width");
+ check_dec(height, geometry_good.height, "height");
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("TEST: Check Procedure Resize was invoked.");
+ invoked = avs_get_event(1);
+ if (!invoked) {
+ sprintf(ebuf, "ERROR: Procedure Resize was not invoked.");
+ tet_infoline(ebuf);
+ tet_result(TET_FAIL);
+ }
+ KROF(pid2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A call to
+void XtResizeWidget(w, width, height, border_width)
+when
+.A width,
+.A height,
+and
+.A border_width
+are all same as their corresponding values in the
+object
+.A w
+shall return immediately.
+>>CODE
+XtWidgetGeometry intended, geom, geometry_good;
+Widget squarew;
+int x, y, width, height, border_width;
+pid_t pid2;
+
+ FORK(pid2);
+ avs_xt_hier("Trszewdgt3", "XtResizeWidget");
+ tet_infoline("PREP: Create Square Cell widget");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Put same geometry fields to squarew widget.");
+ intended.request_mode = CWWidth|CWHeight|CWBorderWidth;
+ XtQueryGeometry(squarew, &intended, &geom);
+ width = geom.width;
+ height = geom.height;
+ border_width = geom.border_width;
+ XtResizeWidget(squarew, width, height, border_width);
+ tet_infoline("TEST: XtResizeWidget returned immediately with same");
+ tet_infoline("TEST: geometry fields.");
+ XtQueryGeometry(squarew, &intended, &geometry_good);
+ check_dec(width, geometry_good.width, "width");
+ check_dec(height, geometry_good.height, "height");
+ check_dec(border_width, geometry_good.border_width, "border_width");
+ KROF(pid2);
+ tet_result(TET_PASS);
diff --git a/xts5/Xt8/XtResizeWindow/XtResizeWindow.m b/xts5/Xt8/XtResizeWindow/XtResizeWindow.m
new file mode 100644
index 00000000..acc03d75
--- /dev/null
+++ b/xts5/Xt8/XtResizeWindow/XtResizeWindow.m
@@ -0,0 +1,759 @@
+Copyright (c) 2005 X.Org Foundation LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+$Header: /cvs/xtest/xtest/xts5/tset/Xt8/XtResizeWindow/XtResizeWindow.m,v 1.1 2005-02-12 14:38:23 anderson Exp $
+
+Copyright (c) Applied Testing and Technology, Inc. 1993, 1994, 1995
+Copyright (c) 88open Consortium, Ltd. 1990, 1991, 1992, 1993
+All Rights Reserved.
+
+>>#
+>># Project: VSW5
+>>#
+>># File: tset/Xt8/XtResizeWindow/XtResizeWindow.m
+>>#
+>># Description:
+>># Tests for XtResizeWindow()
+>>#
+>># Modifications:
+>># $Log: trszwindw.m,v $
+>># Revision 1.1 2005-02-12 14:38:23 anderson
+>># Initial revision
+>>#
+>># Revision 8.0 1998/12/23 23:36:55 mar
+>># Branch point for Release 5.0.2
+>>#
+>># Revision 7.0 1998/10/30 22:59:47 mar
+>># Branch point for Release 5.0.2b1
+>>#
+>># Revision 6.0 1998/03/02 05:28:02 tbr
+>># Branch point for Release 5.0.1
+>>#
+>># Revision 5.0 1998/01/26 03:24:36 tbr
+>># Branch point for Release 5.0.1b1
+>>#
+>># Revision 4.0 1995/12/15 09:17:52 tbr
+>># Branch point for Release 5.0.0
+>>#
+>># Revision 3.1 1995/12/15 01:22:10 andy
+>># Prepare for GA Release
+>>#
+>>EXTERN
+#include <X11/IntrinsicP.h>
+#include <X11/ConstrainP.h>
+#include <X11/CoreP.h>
+#include <xt/SquareCelP.h>
+
+XtAppContext app_ctext;
+Widget topLevel, panedw, boxw1, boxw2;
+Widget labelw, rowcolw, click_quit;
+
+
+/*
+ * SquareCell.c - Square Widget
+ */
+#define INTERNAL_WIDTH 2
+#define INTERNAL_HEIGHT 4
+#define DEFAULT_PIXMAP_WIDTH 1 /* in cells */
+#define DEFAULT_PIXMAP_HEIGHT 1 /* in cells */
+#define DEFAULT_CELL_SIE 20 /* in pixels */
+/* values for instance variable is_drawn */
+#define DRAWN 1
+#define UNDRAWN 0
+/* modes for drawing */
+#define DRAW 1
+#define UNDRAW 0
+#define MAXLINES 10 /* max of horiz or vertical cells */
+#define SCROLLBARWIDTH 15
+#define DEFAULTWIDTH 300 /* widget size when show_all is False */
+#define offset(field) XtOffsetOf(SquareCellRec, field)
+static XtResource resources[] = {
+ {
+ XtNforeground,
+ XtCForeground,
+ XtRPixel,
+ sizeof(Pixel),
+ offset(squareCell.foreground),
+ XtRString,
+ XtDefaultForeground
+ },
+ {
+ XavsNtoggleCallback,
+ XavsCToggleCallback,
+ XtRCallback,
+ sizeof(XtPointer),
+ offset(squareCell.callback),
+ XtRCallback,
+ NULL
+ },
+ {
+ XavsNcellSizeInPixels,
+ XavsCCellSizeInPixels,
+ XtRInt, sizeof(int),
+ offset(squareCell.cell_size_in_pixels),
+ XtRImmediate,
+ (XtPointer)DEFAULT_CELL_SIE
+ },
+ {
+ XavsNpixmapWidthInCells,
+ XavsCPixmapWidthInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_width_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_WIDTH
+ },
+ {
+ XavsNpixmapHeightInCells,
+ XavsCPixmapHeightInCells,
+ XtRDimension,
+ sizeof(Dimension),
+ offset(squareCell.pixmap_height_in_cells),
+ XtRImmediate,
+ (XtPointer)DEFAULT_PIXMAP_HEIGHT
+ },
+ {
+ XavsNcurX,
+ XavsCCurX,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_x),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcurY,
+ XavsCCurY,
+ XtRInt,
+ sizeof(int),
+ offset(squareCell.cur_y),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNcellArray,
+ XavsCCellArray,
+ XtRString,
+ sizeof(String),
+ offset(squareCell.cell),
+ XtRImmediate,
+ (XtPointer) 0
+ },
+ {
+ XavsNshowEntireBitmap,
+ XavsCShowEntireBitmap,
+ XtRBoolean,
+ sizeof(Boolean),
+ offset(squareCell.show_all),
+ XtRImmediate,
+ (XtPointer) TRUE
+ },
+};
+/* Declaration of methods */
+static void Initialize();
+static void Redisplay();
+static void Destroy();
+static void Resize();
+static Boolean SetValues();
+static XtGeometryResult QueryGeometry();
+/* these Core methods not needed by SquareCell:
+ *
+ * static void ClassInitialize();
+ */
+static void Realize();
+/* the following are private functions unique to SquareCell */
+static void DrawPixmaps(), DoCell(), ChangeCellSize();
+/* the following are actions of SquareCell */
+static void DrawCell(), UndrawCell(), ToggleCell();
+/* The following are public functions of SquareCell, declared extern
+ * in the public include file: */
+char *SquareCellGetArray();
+static char defaultTranslations[] =
+ "<Btn1Down>: DrawCell() \n\
+ <Btn2Down>: UndrawCell() \n\
+ <Btn3Down>: ToggleCell() \n\
+ <Btn1Motion>: DrawCell() \n\
+ <Btn2Motion>: UndrawCell() \n\
+ <Btn3Motion>: ToggleCell()";
+static XtActionsRec actions[] = {
+ {"DrawCell", DrawCell},
+ {"UndrawCell", UndrawCell},
+ {"ToggleCell", ToggleCell},
+};
+/* definition in SquareCell.h */
+static SquareCellPointInfo info;
+SquareCellClassRec squareCellClassRec = {
+ {
+ /* core_class fields */
+ /* superclass */ (WidgetClass) &coreClassRec,
+ /* class_name */ "SquareCell",
+ /* widget_size */ sizeof(SquareCellRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ XtExposeCompressMultiple,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ {/* simple_class fields */
+ /* change_sensitive */ XtInheritChangeSensitive,
+ },
+ {
+ /* extension */ 0,
+ },
+};
+WidgetClass squareCellWidgetClass = (WidgetClass) & squareCellClassRec;
+static void Realize(w, valueMask, attributes)
+ register Widget w;
+ Mask *valueMask;
+ XSetWindowAttributes *attributes;
+{
+ attributes->bit_gravity = NorthWestGravity;
+ *valueMask |= CWBitGravity;
+ XtCreateWindow( w, (unsigned)InputOutput, (Visual *)CopyFromParent,
+ *valueMask, attributes);
+} /* Realize */
+static void
+GetDrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground | GCDashOffset |
+ GCDashList | GCLineStyle;
+ /*
+ * Setting foreground and background to 1 and 0 looks like a
+ * kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied with a
+ * separate GC when the pixmap is copied into the window.
+ */
+ values.foreground = 1;
+ values.background = 0;
+ values.dashes = 1;
+ values.dash_offset = 0;
+ values.line_style = LineOnOffDash;
+ cw->squareCell.draw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetUndrawGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ /* this looks like a kludge but isn't. This GC is used for drawing
+ * into a pixmap of depth one. Real colors are applied as the
+ * pixmap is copied into the window.
+ */
+ values.foreground = 0;
+ values.background = 1;
+ cw->squareCell.undraw_gc = XCreateGC(XtDisplay((Widget)cw),
+ cw->squareCell.big_picture, mask, &values);
+}
+static void
+GetCopyGC(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ XGCValues values;
+ XtGCMask mask = GCForeground | GCBackground;
+ values.foreground = cw->squareCell.foreground;
+ values.background = cw->core.background_pixel;
+ cw->squareCell.copy_gc = XtGetGC((Widget)cw, mask, &values);
+}
+static void
+Initialize(treq, tnew, args, num_args)
+Widget treq, tnew;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget new = (SquareCellWidget) tnew;
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ /*
+ * Check instance values set by resources that may be invalid.
+ */
+ if ((new->squareCell.pixmap_width_in_cells < 1) ||
+ (new->squareCell.pixmap_height_in_cells < 1)) {
+ XtWarning("SquareCell: pixmapWidth and/or pixmapHeight is too small (using 10 x 10)");
+ new->squareCell.pixmap_width_in_cells = 10;
+ new->squareCell.pixmap_height_in_cells = 10;
+ }
+ if (new->squareCell.cell_size_in_pixels < 5) {
+ XtWarning("SquareCell: cellSize is too small (using 5)");
+ new->squareCell.cell_size_in_pixels = 5;
+ }
+ if ((new->squareCell.cur_x < 0) || (new->squareCell.cur_y < 0)) {
+ XtWarning("SquareCell: cur_x and cur_y must be non-negative (using 0, 0)");
+ new->squareCell.cur_x = 0;
+ new->squareCell.cur_y = 0;
+ }
+ if (new->squareCell.cell == NULL)
+ new->squareCell.cell = XtCalloc(
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.pixmap_height_in_cells, sizeof(char));
+ else
+ new->squareCell.user_allocated = True; /* user supplied cell array */
+ new->squareCell.pixmap_width_in_pixels =
+ new->squareCell.pixmap_width_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ new->squareCell.pixmap_height_in_pixels =
+ new->squareCell.pixmap_height_in_cells *
+ new->squareCell.cell_size_in_pixels;
+ if (new->core.width == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.width = (new->squareCell.pixmap_width_in_pixels
+ > DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_width_in_pixels);
+ else
+ new->core.width = new->squareCell.pixmap_width_in_pixels;
+ }
+ if (new->core.height == 0) {
+ if (new->squareCell.show_all == False)
+ new->core.height =
+ (new->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ (new->squareCell.pixmap_height_in_pixels);
+ else
+ new->core.height = new->squareCell.pixmap_height_in_pixels;
+ }
+ CreateBigPixmap(new);
+ GetDrawGC(new);
+ GetUndrawGC(new);
+ GetCopyGC(new);
+ DrawIntoBigPixmap(new);
+}
+static void
+Redisplay(w, event)
+Widget w;
+XExposeEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ register int x, y;
+ unsigned int width, height;
+ if (!XtIsRealized((Widget)cw))
+ return;
+ if (event) { /* called from btn-event or expose */
+ x = event->x;
+ y = event->y;
+ width = event->width;
+ height = event->height;
+ }
+ else { /* called because complete redraw */
+ x = 0;
+ y = 0;
+ width = cw->squareCell.pixmap_width_in_pixels;
+ height = cw->squareCell.pixmap_height_in_pixels;
+ }
+ if (DefaultDepthOfScreen(XtScreen((Widget)cw)) == 1)
+ XCopyArea(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y);
+ else
+ XCopyPlane(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ XtWindow((Widget)cw), cw->squareCell.copy_gc, x +
+ cw->squareCell.cur_x, y + cw->squareCell.cur_y,
+ width, height, x, y, 1);
+}
+static Boolean
+SetValues(current, request, new, args, num_args)
+Widget current, request, new;
+ArgList args;
+Cardinal *num_args;
+{
+ SquareCellWidget curcw = (SquareCellWidget) current;
+ SquareCellWidget newcw = (SquareCellWidget) new;
+ Boolean do_redisplay = False;
+ /*
+ ** XtSetValues invoked procedure SetValues
+ */
+ if (curcw->squareCell.foreground != newcw->squareCell.foreground) {
+ XtReleaseGC((Widget)curcw, curcw->squareCell.copy_gc);
+ GetCopyGC(newcw);
+ do_redisplay = True;
+ }
+ if ((curcw->squareCell.cur_x != newcw->squareCell.cur_x) ||
+ (curcw->squareCell.cur_y != newcw->squareCell.cur_y))
+ do_redisplay = True;
+ if (curcw->squareCell.cell_size_in_pixels !=
+ newcw->squareCell.cell_size_in_pixels) {
+ ChangeCellSize(curcw, newcw->squareCell.cell_size_in_pixels);
+ do_redisplay = True;
+ }
+ if (curcw->squareCell.pixmap_width_in_cells !=
+ newcw->squareCell.pixmap_width_in_cells) {
+ newcw->squareCell.pixmap_width_in_cells =
+ curcw->squareCell.pixmap_width_in_cells;
+ XtWarning("SquareCell: pixmap_width_in_cells cannot be set by XtSetValues.\n");
+ }
+ if (curcw->squareCell.pixmap_height_in_cells !=
+ newcw->squareCell.pixmap_height_in_cells) {
+ newcw->squareCell.pixmap_height_in_cells =
+ curcw->squareCell.pixmap_height_in_cells;
+ XtWarning("SquareCell: pixmap_height_in_cells cannot be set by XtSetValues.\n");
+ }
+ return do_redisplay;
+}
+static void
+Destroy(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ if (cw->squareCell.big_picture)
+ XFreePixmap(XtDisplay((Widget)cw), cw->squareCell.big_picture);
+ if (cw->squareCell.draw_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.draw_gc);
+ if (cw->squareCell.undraw_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.undraw_gc);
+ if (cw->squareCell.copy_gc)
+ XFreeGC(XtDisplay((Widget)cw), cw->squareCell.copy_gc);
+ /* Free memory allocated with Calloc. This was done
+ * only if application didn't supply cell array.
+ */
+ if (!cw->squareCell.user_allocated)
+ XtFree(cw->squareCell.cell);
+}
+static void
+DrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.draw_gc, DRAW, cw, event);
+}
+static void
+UndrawCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ DrawPixmaps(cw->squareCell.undraw_gc, UNDRAW, cw, event);
+}
+static void
+ToggleCell(w, event)
+Widget w;
+XEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ static int oldx = -1, oldy = -1;
+ GC gc;
+ int mode;
+ int newx, newy;
+ /* This is strictly correct, but doesn't
+ * seem to be necessary */
+ if (event->type == ButtonPress) {
+ newx = (cw->squareCell.cur_x + ((XButtonEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XButtonEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ else {
+ newx = (cw->squareCell.cur_x + ((XMotionEvent *)event)->x) /
+ cw->squareCell.cell_size_in_pixels;
+ newy = (cw->squareCell.cur_y + ((XMotionEvent *)event)->y) /
+ cw->squareCell.cell_size_in_pixels;
+ }
+ if ((mode = cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells]) == DRAWN) {
+ gc = cw->squareCell.undraw_gc;
+ mode = UNDRAW;
+ }
+ else {
+ gc = cw->squareCell.draw_gc;
+ mode = DRAW;
+ }
+ if (oldx != newx || oldy != newy) {
+ oldx = newx;
+ oldy = newy;
+ DrawPixmaps(gc, mode, cw, event);
+ }
+}
+static void
+DrawPixmaps(gc, mode, w, event)
+GC gc;
+int mode;
+Widget w;
+XButtonEvent *event;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int newx = (cw->squareCell.cur_x + event->x) /
+ cw->squareCell.cell_size_in_pixels;
+ int newy = (cw->squareCell.cur_y + event->y) /
+ cw->squareCell.cell_size_in_pixels;
+ XExposeEvent fake_event;
+ /* if already done, return */
+ if (cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] == mode)
+ return;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels*newx + 2,
+ cw->squareCell.cell_size_in_pixels*newy + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+ cw->squareCell.cell[newx + newy * cw->squareCell.pixmap_width_in_cells] = mode;
+ info.mode = mode;
+ info.newx = newx;
+ info.newy = newy;
+ fake_event.x = cw->squareCell.cell_size_in_pixels * newx - cw->squareCell.cur_x;
+ fake_event.y = cw->squareCell.cell_size_in_pixels * newy - cw->squareCell.cur_y;
+ fake_event.width = cw->squareCell.cell_size_in_pixels;
+ fake_event.height = cw->squareCell.cell_size_in_pixels;
+ Redisplay(cw, &fake_event);
+ XtCallCallbacks((Widget)cw, XavsNtoggleCallback, &info);
+}
+CreateBigPixmap(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* always a 1 bit deep pixmap, regardless of screen depth */
+ cw->squareCell.big_picture = XCreatePixmap(XtDisplay((Widget)cw),
+ RootWindow(XtDisplay((Widget)cw), DefaultScreen(XtDisplay((Widget)cw))),
+ cw->squareCell.pixmap_width_in_pixels + 2,
+ cw->squareCell.pixmap_height_in_pixels + 2, 1);
+}
+DrawIntoBigPixmap(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int n_horiz_segments, n_vert_segments;
+ XSegment segment[MAXLINES];
+ register int x, y;
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture,
+ cw->squareCell.undraw_gc, 0, 0,
+ cw->squareCell.pixmap_width_in_pixels
+ + 2, cw->squareCell.pixmap_height_in_pixels + 2);
+ n_horiz_segments = cw->squareCell.pixmap_height_in_cells + 1;
+ n_vert_segments = cw->squareCell.pixmap_width_in_cells + 1;
+ for (x = 0; x < n_horiz_segments; x++) {
+ segment[x].x1 = 0;
+ segment[x].x2 = (short) cw->squareCell.pixmap_width_in_pixels;
+ segment[x].y1 = (short) cw->squareCell.cell_size_in_pixels * x;
+ segment[x].y2 = (short) cw->squareCell.cell_size_in_pixels * x;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_horiz_segments);
+ for (y = 0; y < n_vert_segments; y++) {
+ segment[y].x1 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].x2 = (short) y * cw->squareCell.cell_size_in_pixels;
+ segment[y].y1 = 0;
+ segment[y].y2 = (short) cw->squareCell.pixmap_height_in_pixels;
+ }
+ XDrawSegments(XtDisplay((Widget)cw), cw->squareCell.big_picture, cw->squareCell.draw_gc, segment, n_vert_segments);
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+/* A Public function, not static */
+char *
+SquareCellGetArray(w, width_in_cells, height_in_cells)
+Widget w;
+int *width_in_cells, *height_in_cells;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ *width_in_cells = cw->squareCell.pixmap_width_in_cells;
+ *height_in_cells = cw->squareCell.pixmap_height_in_cells;
+ return (cw->squareCell.cell);
+}
+static void
+Resize(w)
+Widget w;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ avs_set_event(1,1);
+ /* resize does nothing unless new size is bigger than entire pixmap */
+ if ((cw->core.width > cw->squareCell.pixmap_width_in_pixels) &&
+ (cw->core.height > cw->squareCell.pixmap_height_in_pixels)) {
+ /*
+ * Calculate the maximum cell size that will allow the
+ * entire bitmap to be displayed.
+ */
+ Dimension w_temp_cell_size_in_pixels, h_temp_cell_size_in_pixels;
+ Dimension new_cell_size_in_pixels;
+
+ w_temp_cell_size_in_pixels = cw->core.width / cw->squareCell.pixmap_width_in_cells;
+ h_temp_cell_size_in_pixels = cw->core.height / cw->squareCell.pixmap_height_in_cells;
+
+ if (w_temp_cell_size_in_pixels < h_temp_cell_size_in_pixels)
+ new_cell_size_in_pixels = w_temp_cell_size_in_pixels;
+ else
+ new_cell_size_in_pixels = h_temp_cell_size_in_pixels;
+
+ /* if size change mandates a new pixmap, make one */
+ if (new_cell_size_in_pixels != cw->squareCell.cell_size_in_pixels)
+ ChangeCellSize(cw, new_cell_size_in_pixels);
+ }
+}
+static void
+ChangeCellSize(w, new_cell_size)
+Widget w;
+int new_cell_size;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ int x, y;
+ cw->squareCell.cell_size_in_pixels = new_cell_size;
+ /* recalculate variables based on cell size */
+ cw->squareCell.pixmap_width_in_pixels =
+ cw->squareCell.pixmap_width_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+ cw->squareCell.pixmap_height_in_pixels =
+ cw->squareCell.pixmap_height_in_cells *
+ cw->squareCell.cell_size_in_pixels;
+
+ /* destroy old and create new pixmap of correct size */
+ XFreePixmap(XtDisplay((Widget)cw), cw->squareCell.big_picture);
+ CreateBigPixmap(cw);
+
+ /* draw lines into new pixmap */
+ DrawIntoBigPixmap(cw);
+
+ /* draw current cell array into pixmap */
+ for (x = 0; x < cw->squareCell.pixmap_width_in_cells; x++) {
+ for (y = 0; y < cw->squareCell.pixmap_height_in_cells; y++) {
+ if (cw->squareCell.cell[x + (y * cw->squareCell.pixmap_width_in_cells)] == DRAWN)
+ DoCell(cw, x, y, cw->squareCell.draw_gc);
+ else
+ DoCell(cw, x, y, cw->squareCell.undraw_gc);
+ }
+ }
+}
+static void
+DoCell(w, x, y, gc)
+Widget w;
+int x, y;
+GC gc;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* otherwise, draw or undraw */
+ XFillRectangle(XtDisplay((Widget)cw), cw->squareCell.big_picture, gc,
+ cw->squareCell.cell_size_in_pixels * x + 2,
+ cw->squareCell.cell_size_in_pixels * y + 2,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3,
+ (unsigned int)cw->squareCell.cell_size_in_pixels - 3);
+}
+static XtGeometryResult QueryGeometry(w, proposed, answer)
+Widget w;
+XtWidgetGeometry *proposed, *answer;
+{
+ SquareCellWidget cw = (SquareCellWidget) w;
+ /* set fields we care about */
+ answer->request_mode = CWWidth | CWHeight;
+ /* initial width and height */
+ if (cw->squareCell.show_all == True)
+ answer->width = cw->squareCell.pixmap_width_in_pixels;
+ else
+ answer->width = (cw->squareCell.pixmap_width_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_width_in_pixels;
+ if (cw->squareCell.show_all == True)
+ answer->height = cw->squareCell.pixmap_height_in_pixels;
+ else
+ answer->height = (cw->squareCell.pixmap_height_in_pixels >
+ DEFAULTWIDTH) ? DEFAULTWIDTH :
+ cw->squareCell.pixmap_height_in_pixels;
+ if ( ((proposed->request_mode & (CWWidth | CWHeight))
+ == (CWWidth | CWHeight)) &&
+ proposed->width == answer->width &&
+ proposed->height == answer->height)
+ return XtGeometryYes;
+ else if (answer->width == cw->core.width &&
+ answer->height == cw->core.height)
+ return XtGeometryNo;
+ else
+ return XtGeometryAlmost;
+}
+>>SET tpstartup avs_alloc_sem
+>>SET tpcleanup avs_free_sem
+>>TITLE XtResizeWindow Xt8
+void
+XtResizeWindow(w)
+>>ASSERTION Good A
+A successful all to
+void XtResizeWindow(w)
+shall resize the window of the widget
+.A w
+to match its width, height and border width.
+>>CODE
+pid_t pid2;
+
+ /*should be tested with image capture - just a touch test for now*/
+ FORK(pid2);
+ avs_xt_hier("Trszwindw1", "XtResizeWindow");
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ /*
+ ** unconditional changes
+ */
+ tet_infoline("TESTING: Resize labelw widget");
+ XtResizeWindow(labelw) ;
+ KROF(pid2);
+ tet_result(TET_PASS);
+>>ASSERTION Good A
+A call to
+void XtResizeWindow(w)
+shall not invoke the resize procedure of the widget
+.A w.
+>>CODE
+Widget squarew;
+int status;
+pid_t pid2;
+
+ FORK(pid2);
+ avs_xt_hier("Trszwindw2", "XtResizeWindow");
+ (void) ConfigureDimension(topLevel, boxw2);
+ tet_infoline("PREP: Invoke Realize and create widget's working window");
+ squarew = XtVaCreateManagedWidget("squarew",
+ squareCellWidgetClass, boxw1, NULL);
+ tet_infoline("PREP: Create windows for widgets and map them");
+ XtRealizeWidget(topLevel);
+ tet_infoline("PREP: Resize window");
+ XtResizeWindow(squarew);
+ tet_infoline("TEST: Procedure Resize was not invoked");
+ status = avs_get_event(1);
+ check_dec(0, status, "resize procedure invocations");
+ KROF(pid2);
+ tet_result(TET_PASS);