Przeglądaj źródła

Convert xganim from Motif to wxWidgets
Remove Motif, Xt checks and variables


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34342 15284696-431f-4ddb-bdfa-cd5b030d7da7

Glynn Clements 16 lat temu
rodzic
commit
f07ce4b8a7

Plik diff jest za duży
+ 732 - 940
configure


+ 0 - 33
configure.in

@@ -189,7 +189,6 @@ LOC_ARG_WITH(odbc, ODBC, no)
 LOC_ARG_WITH(fftw, FFTW)
 LOC_ARG_WITH(blas, BLAS, no)
 LOC_ARG_WITH(lapack, LAPACK, no)
-LOC_ARG_WITH(motif, Motif, no)
 LOC_ARG_WITH(cairo, Cairo, no)
 LOC_ARG_WITH(freetype, FreeType, no)
 LOC_ARG_WITH(nls, NLS, no)
@@ -261,9 +260,6 @@ LOC_ARG_WITH_LIB(blas, BLAS)
 LOC_ARG_WITH_INC(lapack, LAPACK)
 LOC_ARG_WITH_LIB(lapack, LAPACK)
 
-LOC_ARG_WITH_INC(motif, Motif)
-LOC_ARG_WITH_LIB(motif, Motif)
-
 LOC_ARG_WITH_INC(cairo, cairo)
 LOC_ARG_WITH_LIB(cairo, cairo)
 LOC_ARG_WITH_LDFLAGS(cairo, cairo)
@@ -1383,34 +1379,6 @@ AC_SUBST(LAPACKINC)
 
 # Done checking LAPACK
 
-# Enable Motif option
-
-LOC_CHECK_USE(motif,Motif,USE_MOTIF)
-
-XMINC=
-XMLIB=
-
-if test -n "$USE_MOTIF"; then
-
-# With Motif includes directory
-
-LOC_CHECK_INC_PATH(motif,Motif,XMINC)
-
-LOC_CHECK_INCLUDES(Xm/Xm.h,Motif,$XMINC $X_CFLAGS)
-
-# With Motif library directory
-
-LOC_CHECK_LIB_PATH(motif,Motif,XMLIB)
-
-LOC_CHECK_LIBS(Xm,XmStringCreate,Motif,$XMLIB,XMLIB,$X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS,,)
-
-fi # $USE_MOTIF
-
-AC_SUBST(XMINC)
-AC_SUBST(XMLIB)
-
-# Done checking Motif
-
 # Enable Cairo display driver option
 
 LOC_CHECK_USE(cairo,Cairo,USE_CAIRO)
@@ -1737,7 +1705,6 @@ LOC_MSG_USE(GDAL support,USE_GDAL)
 LOC_MSG_USE(JPEG support,USE_JPEG)
 LOC_MSG_USE(LAPACK support,USE_LAPACK)
 LOC_MSG_USE(Large File support (LFS), USE_LARGEFILES)
-LOC_MSG_USE(Motif support,USE_MOTIF)
 LOC_MSG_USE(MySQL support,USE_MYSQL)
 LOC_MSG_USE(NLS support,USE_NLS)
 LOC_MSG_USE(ODBC support,USE_ODBC)

+ 0 - 3
include/Make/Platform.make.in

@@ -92,11 +92,8 @@ LINK_FLAGS          = @LDFLAGS@
 
 DLLIB               = @DLLIB@
 XCFLAGS             = @X_CFLAGS@
-XMINC               = @XMINC@
 XLIBPATH            = @X_LIBS@
 XLIB                = @X_PRE_LIBS@ @XLIB@
-XTLIB               = @XTLIB@
-XMLIB               = @XMLIB@
 XEXTRALIBS          = @X_EXTRA_LIBS@
 USE_X11             = @USE_X11@
 

+ 0 - 323
visualization/xganim/Clr_table.c

@@ -1,323 +0,0 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <X11/Xos.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include <grass/colors.h>
-#include "local_proto.h"
-
-Display *dpy;
-Window grwin;
-int scrn;
-Colormap fixedcmap;
-
-static int NCOLORS;
-static unsigned long *xpixels;
-
-static int Red[256], Grn[256], Blu[256];
-static int Gray[256];
-
-static int r_pos, g_pos, b_pos;
-static int r_size, g_size, b_size;
-static int r_scale, g_scale, b_scale;
-
-
-static void get_shifts(unsigned long mask, int *pos, int *size, int *scale)
-{
-    int i, j;
-
-    for (i = 0; (mask & 1) == 0; i++)
-	mask >>= 1;
-    if (pos)
-	*pos = i;
-
-    for (j = i; (mask & 1) != 0; j++)
-	mask >>= 1;
-    if (size)
-	*size = j - i;
-    if (scale)
-	*scale = 8 - (j - i);
-}
-
-static int get_rgb_shifts(void)
-{
-    get_shifts(use_visual->red_mask, &r_pos, &r_size, &r_scale);
-    get_shifts(use_visual->green_mask, &g_pos, &g_size, &g_scale);
-    get_shifts(use_visual->blue_mask, &b_pos, &b_size, &b_scale);
-
-    return (1 << r_size) * (1 << g_size) * (1 << b_size);
-}
-
-static unsigned long
-find_color_gray(unsigned int r, unsigned int g, unsigned int b)
-{
-    unsigned int y = (r + g + b) / 3;
-
-    return xpixels[Gray[y]];
-}
-
-static unsigned long
-find_color_indexed(unsigned int r, unsigned int g, unsigned int b)
-{
-    return xpixels[Red[r] + Grn[g] + Blu[b]];
-}
-
-static unsigned long
-find_color_rgb(unsigned int r, unsigned int g, unsigned int b)
-{
-    unsigned int rr = r >> r_scale;
-    unsigned int gg = g >> g_scale;
-    unsigned int bb = b >> b_scale;
-
-    return (rr << r_pos) + (gg << g_pos) + (bb << b_pos);
-}
-
-unsigned long find_color(unsigned int r, unsigned int g, unsigned int b)
-{
-
-    switch (use_visual->class) {
-    case StaticGray:
-    case GrayScale:
-	return find_color_gray(r, g, b);
-    case StaticColor:
-    case PseudoColor:
-	return find_color_indexed(r, g, b);
-    case TrueColor:
-    case DirectColor:
-	return find_color_rgb(r, g, b);
-    default:
-	G_fatal_error(_("Unknown visual class [%d]."), use_visual->class);
-	return 0;
-    }
-}
-
-static void get_max_levels(int n_colors, int *rr, int *gg, int *bb)
-{
-    int r, g, b, i;
-
-    for (i = 0; i * i * i < n_colors; i++) ;
-
-    for (r = g = b = i;;) {
-	if (r * g * b <= n_colors)
-	    break;
-	b--;
-	if (r * g * b <= n_colors)
-	    break;
-	r--;
-	if (r * g * b <= n_colors)
-	    break;
-	g--;
-    }
-
-    *rr = r;
-    *gg = g;
-    *bb = b;
-}
-
-static int get_fewer_levels(int *rr, int *gg, int *bb)
-{
-    int r = *rr;
-    int g = *gg;
-    int b = *bb;
-
-    /* 888 -> 887 -> 787 -> 777 -> ... */
-
-    if (r > b)			/* 887 -> 787 */
-	r--;
-    else if (g > b)		/* 787 -> 777 */
-	g--;
-    else			/* 888 -> 888 */
-	b--;
-
-    *rr = r;
-    *gg = g;
-    *bb = b;
-
-    return r >= 2 && g >= 2 && b >= 2;
-}
-
-static int try_get_colors(Colormap cmap, int nr, int ng, int nb)
-{
-    XColor xcolor;
-    int n_pixels;
-    int r, g, b;
-
-    xpixels = (unsigned long *)G_realloc(xpixels,
-					 nr * ng * nb *
-					 sizeof(unsigned long));
-    n_pixels = 0;
-
-    xcolor.flags = DoRed | DoGreen | DoBlue;
-
-    for (r = 0; r < nr; r++) {
-	for (g = 0; g < ng; g++) {
-	    for (b = 0; b < nb; b++) {
-		xcolor.red = (unsigned short)(r * 0xFFFF / (nr - 1));
-		xcolor.green = (unsigned short)(g * 0xFFFF / (ng - 1));
-		xcolor.blue = (unsigned short)(b * 0xFFFF / (nb - 1));
-		if (!XAllocColor(dpy, cmap, &xcolor)) {
-		    XFreeColors(dpy, cmap, xpixels, n_pixels,
-				(unsigned long)0);
-		    return 0;
-		}
-
-		xpixels[n_pixels++] = xcolor.pixel;
-	    }
-	}
-    }
-
-    return 1;
-}
-
-static int try_get_grays(Colormap cmap, int ny)
-{
-    XColor xcolor;
-    int n_pixels;
-    int y;
-
-    xpixels = (unsigned long *)G_realloc(xpixels, ny * sizeof(unsigned long));
-    n_pixels = 0;
-
-    xcolor.flags = DoRed | DoGreen | DoBlue;
-
-    for (y = 0; y < ny; y++) {
-	unsigned short v = (unsigned short)(y * 0xFFFF / (ny - 1));
-
-	xcolor.red = v;
-	xcolor.green = v;
-	xcolor.blue = v;
-
-	if (!XAllocColor(dpy, cmap, &xcolor)) {
-	    XFreeColors(dpy, cmap, xpixels, n_pixels, (unsigned long)0);
-	    return y;
-	}
-
-	xpixels[n_pixels++] = xcolor.pixel;
-    }
-
-    return ny;
-}
-
-static Colormap ramp_colormap(void)
-{
-    int n_colors = use_visual->map_entries;
-    Colormap cmap = XCreateColormap(dpy, RootWindow(dpy, scrn),
-				    use_visual, AllocAll);
-    int i;
-
-    for (i = 0; i < n_colors; i++) {
-	unsigned int k = i * 65535 / (n_colors - 1);
-	unsigned int l = i * 255 / (n_colors - 1);
-	XColor xcolor;
-
-	xcolor.flags = DoRed | DoGreen | DoBlue;
-	xcolor.blue = k;
-	xcolor.green = k;
-	xcolor.red = k;
-	xcolor.pixel = find_color_rgb(l, l, l);
-
-	XStoreColor(dpy, cmap, &xcolor);
-    }
-
-    return cmap;
-}
-
-Colormap InitColorTableFixed(Colormap cmap)
-{
-    int n_colors = use_visual->map_entries;
-    int r, g, b, y, i;
-
-    switch (use_visual->class) {
-    case StaticGray:
-    case GrayScale:
-	/* determine how many levels of gray we can actually get */
-	y = try_get_grays(cmap, n_colors);
-	if (y > 2 && y < n_colors)
-	    y = try_get_grays(cmap, y);
-	if (y < 2)
-	    G_fatal_error(_("Unable to get sufficient gray shades."));
-
-	NCOLORS = y;
-
-	for (i = 0; i < 256; i++)
-	    Gray[i] = i * y / 256;
-
-	break;
-
-    case StaticColor:
-    case PseudoColor:
-	/* determine how many levels of r, g, and b are possible */
-	get_max_levels(n_colors, &r, &g, &b);
-
-	/* now see how many we can actually get */
-	while (!try_get_colors(cmap, r, g, b))
-	    if (!get_fewer_levels(&r, &g, &b))
-		G_fatal_error(_("Unable to get sufficient colors."));
-
-	NCOLORS = r * g * b;
-
-	for (i = 0; i < 256; i++) {
-	    Red[i] = (i * r / 256) * g * b;
-	    Grn[i] = (i * g / 256) * b;
-	    Blu[i] = (i * b / 256);
-	}
-
-	break;
-
-    case DirectColor:
-	G_warning(_("Using private colormap for DirectColor visual."));
-
-	/* free any previously-allocated Colormap */
-	if (cmap != DefaultColormap(dpy, scrn))
-	    XFreeColormap(dpy, cmap);
-
-	/* get shift factors for R,G,B masks */
-	NCOLORS = get_rgb_shifts();
-
-	/* create colormap (emulates TrueColor visual) */
-	cmap = ramp_colormap();
-	break;
-
-    case TrueColor:
-	/* get shift factors for R,G,B masks */
-	NCOLORS = get_rgb_shifts();
-	break;
-
-    default:
-	G_fatal_error(_("Unknown visual class [%d]."), use_visual->class);
-	break;
-    }
-
-    return cmap;
-}
-
-int _get_lookup_for_color(unsigned int r, unsigned int g, unsigned int b)
-{
-    switch (use_visual->class) {
-    case StaticGray:
-    case GrayScale:
-	return Gray[(r + g + b) / 3];
-	break;
-
-    case StaticColor:
-    case PseudoColor:
-	return Red[r] + Grn[g] + Blu[b];
-	break;
-
-    case DirectColor:
-    case TrueColor:
-	return find_color_rgb(r, g, b);
-	break;
-
-    default:
-	G_fatal_error(_("Unknown visual class [%d]."), use_visual->class);
-	break;
-    }
-
-    return -1;
-}

+ 5 - 3
visualization/xganim/Makefile

@@ -2,13 +2,15 @@ MODULE_TOPDIR = ../..
 
 PGM = xganim
 
-EXTRA_CFLAGS=$(XCFLAGS) $(XMINC)
+EXTRA_CFLAGS = $(WXWIDGETSCXXFLAGS) -DWXINTL_NO_GETTEXT_MACRO
 
-LIBES = $(GISLIB) $(XLIBPATH) $(XMLIB) $(XTLIB) $(XLIB) $(XEXTRALIBS)
+LIBES = $(GISLIB) $(WXWIDGETSLIB)
 DEPENDENCIES = $(GISDEP)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make
 
-ifneq ($(strip $(XMLIB)),)
+ifneq ($(USE_WXWIDGETS),)
+ifneq ($(strip $(CXX)),)
 default: cmd
 endif
+endif

+ 0 - 389
visualization/xganim/gui.c

@@ -1,389 +0,0 @@
-/* Written by Bill Brown, USACERL (brown@zorro.cecer.army.mil)
- * May 2-12, 1994
- *
- * This code is in the public domain. Specifically, we give to the public
- * domain all rights for future licensing of the source code, all resale
- * rights, and all publishing rights.
- * 
- * We ask, but do not require, that the following message be included in
- * all derived works:
- *     "Portions developed at the US Army Construction Engineering 
- *     Research Laboratories, Champaign, Illinois."
- * 
- * USACERL GIVES NO WARRANTY, EXPRESSED OR IMPLIED,
- * FOR THE SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT
- * LIMITATION, WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A
- * PARTICULAR PURPOSE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "bitmaps/rewind.xbm"
-#include "bitmaps/rplay.xbm"
-#include "bitmaps/stepb.xbm"
-#include "bitmaps/stop.xbm"
-#include "bitmaps/stepf.xbm"
-#include "bitmaps/play.xbm"
-#include "bitmaps/loop.xbm"
-#include "bitmaps/swing.xbm"
-#include "bitmaps/snail.xbm"
-#include "bitmaps/rabbit.xbm"
-
-#include "gui.h"
-
-
-/* callback procs */
-static void rewind_callback(Widget w, XtPointer data, XtPointer cbs);
-static void rplay_callback(Widget w, XtPointer data, XtPointer cbs);
-static void stepb_callback(Widget w, XtPointer data, XtPointer cbs);
-static void stop_callback(Widget w, XtPointer data, XtPointer cbs);
-static void stepf_callback(Widget w, XtPointer data, XtPointer cbs);
-static void play_callback(Widget w, XtPointer data, XtPointer cbs);
-static void loop_callback(Widget w, XtPointer data, XtPointer cbs);
-static void swing_callback(Widget w, XtPointer data, XtPointer cbs);
-static void exit_callback(Widget w, XtPointer data, XtPointer cbs);
-static void names_callback(Widget w, XtPointer data, XtPointer cbs);
-static void slower_callback(Widget w, XtPointer data, XtPointer cbs);
-static void faster_callback(Widget w, XtPointer data, XtPointer cbs);
-
-/* global variables */
-static Widget rew, rplay, stepb, stop, stepf, play, loop, swing;
-static Widget slower, faster;
-static struct gui_data *cd;
-
-
-void make_buttons(struct gui_data *data, Widget trc, Screen * scr)
-{
-    unsigned int n;
-    Arg wargs[10];
-    Widget shnames, doexit;
-
-    cd = data;
-
-    /***************** rewind */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    rew = XtCreateManagedWidget("rd", xmPushButtonWidgetClass, trc, wargs, n);
-
-    /***************** rplay */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    rplay = XtCreateManagedWidget("ry", xmPushButtonWidgetClass,
-				  trc, wargs, n);
-
-    /***************** stepb */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    stepb = XtCreateManagedWidget("sb", xmPushButtonWidgetClass,
-				  trc, wargs, n);
-
-    /***************** stop */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    stop = XtCreateManagedWidget("sp", xmPushButtonWidgetClass,
-				 trc, wargs, n);
-
-    /***************** stepf */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    stepf = XtCreateManagedWidget("sf", xmPushButtonWidgetClass,
-				  trc, wargs, n);
-
-    /***************** play */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    play = XtCreateManagedWidget("py", xmPushButtonWidgetClass,
-				 trc, wargs, n);
-
-    /***************** loop */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    loop = XtCreateManagedWidget("lp", xmToggleButtonWidgetClass,
-				 trc, wargs, n);
-
-    /***************** swing */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    swing = XtCreateManagedWidget("sw", xmToggleButtonWidgetClass,
-				  trc, wargs, n);
-
-    /***************** slower */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    slower = XtCreateManagedWidget("Sl", xmPushButtonWidgetClass,
-				   trc, wargs, n);
-
-    /***************** faster */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    faster = XtCreateManagedWidget("Fa", xmPushButtonWidgetClass,
-				   trc, wargs, n);
-
-    /***************** shownames */
-    n = 0;
-    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
-    n++;
-    XtSetArg(wargs[n], XmNheight, 30);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, 30);
-    n++;
-    XtSetArg(wargs[n], XmNset, TRUE);
-    n++;
-    shnames = XtCreateManagedWidget("names", xmPushButtonWidgetClass,
-				    trc, wargs, n);
-    XtAddCallback(shnames, XmNactivateCallback,
-		  (XtCallbackProc) names_callback, (XtPointer) NULL);
-
-    n = 0;
-    XtSetArg(wargs[n], XmNmarginLeft, 0);
-    n++;
-    doexit = XtCreateManagedWidget("Exit", xmPushButtonWidgetClass,
-				   trc, wargs, n);
-    XtAddCallback(doexit, XmNactivateCallback, (XtCallbackProc) exit_callback,
-		  (XtPointer) NULL);
-}
-
-void set_buttons_pixmap(Display * display, Drawable d)
-{
-    Pixel fg, bg;
-    unsigned int depth;
-    Pixmap button_pix;
-
-    XtVaGetValues(rew, XmNforeground, &fg,
-		  XmNbackground, &bg, XmNdepth, &depth, NULL);
-    button_pix = XCreatePixmapFromBitmapData(display,
-					     d, rewind_bits, rewind_width,
-					     rewind_height, fg, bg, depth);
-    XtVaSetValues(rew, XmNlabelType, XmPIXMAP, XmNlabelPixmap, button_pix,
-		  NULL);
-    XtAddCallback(rew, XmNactivateCallback, (XtCallbackProc) rewind_callback,
-		  (XtPointer) NULL);
-
-    XtVaGetValues(rplay, XmNforeground, &fg,
-		  XmNbackground, &bg, XmNdepth, &depth, NULL);
-    button_pix = XCreatePixmapFromBitmapData(display,
-					     d, rplay_bits, rplay_width,
-					     rplay_height, fg, bg, depth);
-    XtVaSetValues(rplay, XmNlabelType, XmPIXMAP, XmNlabelPixmap, button_pix,
-		  NULL);
-    XtAddCallback(rplay, XmNactivateCallback, (XtCallbackProc) rplay_callback,
-		  (XtPointer) NULL);
-
-    XtVaGetValues(stepb, XmNforeground, &fg,
-		  XmNbackground, &bg, XmNdepth, &depth, NULL);
-    button_pix = XCreatePixmapFromBitmapData(display,
-					     d, stepb_bits, stepb_width,
-					     stepb_height, fg, bg, depth);
-    XtVaSetValues(stepb, XmNlabelType, XmPIXMAP, XmNlabelPixmap, button_pix,
-		  NULL);
-    XtAddCallback(stepb, XmNactivateCallback, (XtCallbackProc) stepb_callback,
-		  (XtPointer) NULL);
-
-    XtVaGetValues(stop, XmNforeground, &fg,
-		  XmNbackground, &bg, XmNdepth, &depth, NULL);
-    button_pix = XCreatePixmapFromBitmapData(display,
-					     d, stop_bits, stop_width,
-					     stop_height, fg, bg, depth);
-    XtVaSetValues(stop, XmNlabelType, XmPIXMAP, XmNlabelPixmap, button_pix,
-		  NULL);
-    XtAddCallback(stop, XmNactivateCallback, (XtCallbackProc) stop_callback,
-		  (XtPointer) NULL);
-
-    XtVaGetValues(stepf, XmNforeground, &fg,
-		  XmNbackground, &bg, XmNdepth, &depth, NULL);
-    button_pix = XCreatePixmapFromBitmapData(display,
-					     d, stepf_bits, stepf_width,
-					     stepf_height, fg, bg, depth);
-    XtVaSetValues(stepf, XmNlabelType, XmPIXMAP, XmNlabelPixmap, button_pix,
-		  NULL);
-    XtAddCallback(stepf, XmNactivateCallback, (XtCallbackProc) stepf_callback,
-		  (XtPointer) NULL);
-
-    XtVaGetValues(play, XmNforeground, &fg,
-		  XmNbackground, &bg, XmNdepth, &depth, NULL);
-    button_pix = XCreatePixmapFromBitmapData(display,
-					     d, play_bits, play_width,
-					     play_height, fg, bg, depth);
-    XtVaSetValues(play, XmNlabelType, XmPIXMAP, XmNlabelPixmap, button_pix,
-		  NULL);
-    XtAddCallback(play, XmNactivateCallback, (XtCallbackProc) play_callback,
-		  (XtPointer) NULL);
-
-    XtVaGetValues(loop, XmNforeground, &fg,
-		  XmNbackground, &bg, XmNdepth, &depth, NULL);
-    button_pix = XCreatePixmapFromBitmapData(display,
-					     d, loop_bits, loop_width,
-					     loop_height, fg, bg, depth);
-    XtVaSetValues(loop, XmNlabelType, XmPIXMAP, XmNlabelPixmap, button_pix,
-		  NULL);
-    XtAddCallback(loop, XmNvalueChangedCallback,
-		  (XtCallbackProc) loop_callback, (XtPointer) NULL);
-
-    XtVaGetValues(swing, XmNforeground, &fg,
-		  XmNbackground, &bg, XmNdepth, &depth, NULL);
-    button_pix = XCreatePixmapFromBitmapData(display,
-					     d, swing_bits, swing_width,
-					     swing_height, fg, bg, depth);
-    XtVaSetValues(swing, XmNlabelType, XmPIXMAP, XmNlabelPixmap, button_pix,
-		  NULL);
-    XtAddCallback(swing, XmNvalueChangedCallback,
-		  (XtCallbackProc) swing_callback, (XtPointer) NULL);
-
-    XtVaGetValues(faster, XmNforeground, &fg,
-		  XmNbackground, &bg, XmNdepth, &depth, NULL);
-    button_pix = XCreatePixmapFromBitmapData(display,
-					     d, rabbit_bits, rabbit_width,
-					     rabbit_height, fg, bg, depth);
-    XtVaSetValues(faster, XmNlabelType, XmPIXMAP, XmNlabelPixmap, button_pix,
-		  NULL);
-    XtAddCallback(faster, XmNactivateCallback,
-		  (XtCallbackProc) faster_callback, (XtPointer) NULL);
-
-    XtVaGetValues(slower, XmNforeground, &fg,
-		  XmNbackground, &bg, XmNdepth, &depth, NULL);
-    button_pix = XCreatePixmapFromBitmapData(display,
-					     d, snail_bits, snail_width,
-					     snail_height, fg, bg, depth);
-    XtVaSetValues(slower, XmNlabelType, XmPIXMAP, XmNlabelPixmap, button_pix,
-		  NULL);
-    XtAddCallback(slower, XmNactivateCallback,
-		  (XtCallbackProc) slower_callback, (XtPointer) NULL);
-
-}
-
-static void rewind_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-
-    cd->step = 0;
-    cd->stop = 1;
-    cd->rewind = 1;
-
-}
-
-static void rplay_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    cd->step = 0;
-    cd->stop = 0;
-    cd->direction = -1;
-    cd->curframe = cd->prevframe + cd->direction;
-
-}
-
-static void stepb_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    cd->step = 1;
-    cd->direction = -1;
-    cd->curframe = cd->prevframe + cd->direction;
-}
-
-static void stop_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    cd->stop = 1;
-}
-
-static void stepf_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    cd->step = 1;
-    cd->direction = 1;
-    cd->curframe = cd->prevframe + cd->direction;
-}
-
-static void play_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    cd->step = 0;
-    cd->stop = 0;
-    cd->direction = 1;
-    cd->curframe = cd->prevframe + cd->direction;
-}
-
-static void loop_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    cd->loop = XmToggleButtonGetState(loop);
-    cd->swing = 0;
-    XmToggleButtonSetState(swing, 0, False);
-    cd->stop = !cd->loop;
-}
-
-static void swing_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    cd->swing = XmToggleButtonGetState(swing);
-    cd->loop = 0;
-    XmToggleButtonSetState(loop, 0, False);
-    cd->stop = !cd->swing;
-}
-
-static void slower_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    if (cd->speed) {
-	if (cd->speed < 200000)
-	    cd->speed *= 3;
-    }
-    else
-	cd->speed = 1;
-}
-
-static void faster_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    if (cd->speed > 1)
-	cd->speed /= 3;
-}
-
-static void names_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    cd->shownames = (1 + cd->shownames) % 3;
-}
-
-static void exit_callback(Widget w, XtPointer data, XtPointer cbs)
-{
-    exit(0);
-}

+ 305 - 0
visualization/xganim/gui.cc

@@ -0,0 +1,305 @@
+/* Written by Bill Brown, USACERL (brown@zorro.cecer.army.mil)
+ * May 2-12, 1994
+ *
+ * This code is in the public domain. Specifically, we give to the public
+ * domain all rights for future licensing of the source code, all resale
+ * rights, and all publishing rights.
+ * 
+ * We ask, but do not require, that the following message be included in
+ * all derived works:
+ *     "Portions developed at the US Army Construction Engineering 
+ *     Research Laboratories, Champaign, Illinois."
+ * 
+ * USACERL GIVES NO WARRANTY, EXPRESSED OR IMPLIED,
+ * FOR THE SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT
+ * LIMITATION, WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ */
+
+#include <stdlib.h>
+#include <wx/button.h>
+#include <wx/bmpbuttn.h>
+#include <wx/bitmap.h>
+#include <wx/sizer.h>
+#include <wx/strconv.h>
+#include <wx/event.h>
+#include <wx/dcclient.h>
+#include <wx/dc.h>
+#include <wx/colour.h>
+#include "gui.h"
+
+#include "bitmaps/rewind.xbm"
+#include "bitmaps/rplay.xbm"
+#include "bitmaps/stepb.xbm"
+#include "bitmaps/stop.xbm"
+#include "bitmaps/stepf.xbm"
+#include "bitmaps/play.xbm"
+#include "bitmaps/loop.xbm"
+#include "bitmaps/swing.xbm"
+#include "bitmaps/snail.xbm"
+#include "bitmaps/rabbit.xbm"
+
+enum {
+    MYID_REW,
+    MYID_RPLAY,
+    MYID_STEPB,
+    MYID_STOP,
+    MYID_STEPF,
+    MYID_PLAY,
+    MYID_LOOP,
+    MYID_SWING,
+    MYID_SLOWER,
+    MYID_FASTER,
+    MYID_SHNAMES,
+    MYID_DOEXIT,
+};
+
+BEGIN_EVENT_TABLE(MyCanvas, wxPanel)
+EVT_ERASE_BACKGROUND(MyCanvas::erase)
+END_EVENT_TABLE()
+
+MyCanvas::MyCanvas(wxWindow *parent, wxWindowID id, const wxSize &size)
+    : wxPanel(parent, id, wxDefaultPosition, size)
+{
+    SetBackgroundStyle(wxBG_STYLE_CUSTOM);
+}
+
+void MyCanvas::erase(wxEraseEvent &ev)
+{
+    ev.GetDC();
+}
+
+void MyCanvas::draw_image(wxBitmap *bmp)
+{
+    wxClientDC dc(this);
+
+    dc.DrawBitmap(*bmp, 0, 0, false);
+}
+
+void MyCanvas::draw_text(int style, int x, int y, const char *str)
+{
+    wxClientDC dc(this);
+
+    switch (style) {
+    case 1:
+	dc.SetTextBackground(*wxWHITE);
+	dc.SetTextForeground(*wxBLACK);
+	break;
+    case 2:
+	dc.SetTextBackground(*wxBLACK);
+	dc.SetTextForeground(*wxWHITE);
+	break;
+    default:
+	return;
+    }
+
+    dc.DrawText(wxString(str, wxConvISO8859_1), x, y);
+}
+
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+EVT_BUTTON(MYID_REW,     MyFrame::rewind_callback)
+EVT_BUTTON(MYID_RPLAY,   MyFrame::rplay_callback)
+EVT_BUTTON(MYID_STEPB,   MyFrame::stepb_callback)
+EVT_BUTTON(MYID_STOP,    MyFrame::stop_callback)
+EVT_BUTTON(MYID_STEPF,   MyFrame::stepf_callback)
+EVT_BUTTON(MYID_PLAY,    MyFrame::play_callback)
+EVT_BUTTON(MYID_LOOP,    MyFrame::loop_callback)
+EVT_BUTTON(MYID_SWING,   MyFrame::swing_callback)
+EVT_BUTTON(MYID_SLOWER,  MyFrame::slower_callback)
+EVT_BUTTON(MYID_FASTER,  MyFrame::faster_callback)
+EVT_BUTTON(MYID_SHNAMES, MyFrame::names_callback)
+EVT_BUTTON(MYID_DOEXIT,  MyFrame::exit_callback)
+END_EVENT_TABLE()
+
+void MyFrame::make_buttons(wxSizer *sizer)
+{
+    sizer->Add(new wxBitmapButton(this, MYID_REW   , wxBitmap(rewind_bits, rewind_width, rewind_height)));
+    sizer->Add(new wxBitmapButton(this, MYID_RPLAY , wxBitmap(rplay_bits , rplay_width , rplay_height )));
+    sizer->Add(new wxBitmapButton(this, MYID_STEPB , wxBitmap(stepb_bits , stepb_width , stepb_height )));
+    sizer->Add(new wxBitmapButton(this, MYID_STOP  , wxBitmap(stop_bits  , stop_width  , stop_height  )));
+    sizer->Add(new wxBitmapButton(this, MYID_STEPF , wxBitmap(stepf_bits , stepf_width , stepf_height )));
+    sizer->Add(new wxBitmapButton(this, MYID_PLAY  , wxBitmap(play_bits  , play_width  , play_height  )));
+    sizer->Add(new wxBitmapButton(this, MYID_LOOP  , wxBitmap(loop_bits  , loop_width  , loop_height  )));
+    sizer->Add(new wxBitmapButton(this, MYID_SWING , wxBitmap(swing_bits , swing_width , swing_height )));
+    sizer->Add(new wxBitmapButton(this, MYID_SLOWER, wxBitmap(snail_bits , snail_width , snail_height )));
+    sizer->Add(new wxBitmapButton(this, MYID_FASTER, wxBitmap(rabbit_bits, rabbit_width, rabbit_height)));
+    sizer->Add(new wxButton(this, MYID_SHNAMES, wxString("Names", wxConvISO8859_1)));
+    sizer->Add(new wxButton(this, MYID_DOEXIT,  wxString("Exit", wxConvISO8859_1)));
+}
+
+void MyFrame::rewind_callback(wxCommandEvent &event)
+{
+    cd->step = 0;
+    cd->stop = 1;
+    cd->rewind = 1;
+}
+
+void MyFrame::rplay_callback(wxCommandEvent &event)
+{
+    cd->step = 0;
+    cd->stop = 0;
+    cd->direction = -1;
+    cd->curframe = cd->prevframe + cd->direction;
+}
+
+void MyFrame::stepb_callback(wxCommandEvent &event)
+{
+    cd->step = 1;
+    cd->direction = -1;
+    cd->curframe = cd->prevframe + cd->direction;
+}
+
+void MyFrame::stop_callback(wxCommandEvent &event)
+{
+    cd->stop = 1;
+}
+
+void MyFrame::stepf_callback(wxCommandEvent &event)
+{
+    cd->step = 1;
+    cd->direction = 1;
+    cd->curframe = cd->prevframe + cd->direction;
+}
+
+void MyFrame::play_callback(wxCommandEvent &event)
+{
+    cd->step = 0;
+    cd->stop = 0;
+    cd->direction = 1;
+    cd->curframe = cd->prevframe + cd->direction;
+}
+
+void MyFrame::loop_callback(wxCommandEvent &event)
+{
+    cd->loop = !cd->loop;
+    cd->swing = 0;
+    cd->stop = !cd->loop;
+}
+
+void MyFrame::swing_callback(wxCommandEvent &event)
+{
+    cd->swing = !cd->swing;
+    cd->loop = 0;
+    cd->stop = !cd->swing;
+}
+
+void MyFrame::slower_callback(wxCommandEvent &event)
+{
+    if (cd->speed) {
+	if (cd->speed < 200000)
+	    cd->speed *= 3;
+    }
+    else
+	cd->speed = 1;
+}
+
+void MyFrame::faster_callback(wxCommandEvent &event)
+{
+    if (cd->speed > 1)
+	cd->speed /= 3;
+}
+
+void MyFrame::names_callback(wxCommandEvent &event)
+{
+    cd->shownames = (1 + cd->shownames) % 3;
+}
+
+void MyFrame::exit_callback(wxCommandEvent &event)
+{
+    exit(0);
+}
+
+void MyFrame::change_label(const char *label)
+{
+    flabel->SetLabel(wxString(label, wxConvISO8859_1));
+}
+
+#if 0
+
+void MyFrame::init_graphics()
+{
+/* global variables */
+    Widget canvas;
+    Display *theDisplay;
+    XImage *pic_array[MAXIMAGES];
+    GC invertGC, drawGC;
+
+    int scrn;
+    Display *dpy;
+    Window grwin;
+    Colormap fixedcmap;
+    unsigned long blackPix, whitePix;
+
+    unsigned int depth;
+    Visual *use_visual;
+
+    dpy = XtDisplay(canvas);
+    grwin = XtWindow(canvas);
+    scrn = DefaultScreen(dpy);
+    use_visual = DefaultVisual(dpy, scrn);
+#if 1
+    fixedcmap = XCreateColormap(dpy, grwin, use_visual, AllocNone);
+#else
+    fixedcmap = DefaultColormap(dpy, scrn);
+#endif
+    fixedcmap = InitColorTableFixed(fixedcmap);
+
+    XtVaGetValues(canvas, XmNdepth, &depth, NULL);
+
+    XtVaSetValues(toplevel, XmNcolormap, fixedcmap, NULL);
+    XtSetWMColormapWindows(toplevel, &canvas, 1);
+
+    /**************************************************************/
+
+    blackPix = _get_lookup_for_color(0, 0, 0);
+    whitePix = _get_lookup_for_color(255, 255, 255);
+
+    drawGC =
+	XCreateGC(XtDisplay(canvas), XtWindow(canvas), (unsigned long)0,
+		  NULL);
+
+    theDisplay = XtDisplay(toplevel);
+
+    XSetFunction(theDisplay, drawGC, GXcopy);
+    XSetForeground(theDisplay, drawGC, blackPix);
+    XSetBackground(theDisplay, drawGC, whitePix);
+
+    invertGC =
+	XCreateGC(XtDisplay(canvas), XtWindow(canvas), (unsigned long)0,
+		  NULL);
+    XSetFunction(theDisplay, invertGC, GXcopy);
+    XSetForeground(theDisplay, invertGC, whitePix);
+    XSetBackground(theDisplay, invertGC, blackPix);
+
+}
+
+#endif
+
+MyFrame::MyFrame(const wxString& title, int ncols, int nrows, struct gui_data *cd)
+    : wxFrame((wxFrame *)NULL, wxID_ANY, title), cd(cd)
+{
+    canvas = new MyCanvas(this, wxID_ANY, wxSize(ncols, nrows));
+
+    wxBoxSizer *sizer, *buttons;
+
+    if (ncols > nrows) {
+	sizer = new wxBoxSizer(wxVERTICAL);
+	buttons = new wxBoxSizer(wxHORIZONTAL);
+	sizer->Add(canvas);
+	sizer->Add(buttons);
+    }
+    else {
+	sizer = new wxBoxSizer(wxHORIZONTAL);
+	buttons = new wxBoxSizer(wxVERTICAL);
+	sizer->Add(canvas);
+	sizer->Add(buttons);
+    }
+
+    make_buttons(buttons);
+
+    flabel = new wxStaticText(this, wxID_ANY, wxString("00000", wxConvISO8859_1), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+    buttons->Add(flabel);
+
+    SetSizerAndFit(sizer);
+}
+

+ 66 - 19
visualization/xganim/gui.h

@@ -1,15 +1,13 @@
-#include <X11/Xlib.h>
-#include <X11/StringDefs.h>
-#include <X11/Intrinsic.h>
-#include <X11/Xutil.h>
-#include <Xm/Xm.h>
-#include <Xm/DrawingA.h>
-#include <Xm/RowColumn.h>
-#include <Xm/Form.h>
-#include <Xm/Label.h>
-#include <Xm/PushB.h>
-#include <Xm/ToggleB.h>
-#include <Xm/ArrowB.h>
+#include <wx/app.h>
+#include <wx/event.h>
+#include <wx/window.h>
+#include <wx/panel.h>
+#include <wx/frame.h>
+#include <wx/stattext.h>
+#include <wx/bitmap.h>
+
+#define MAXIMAGES 400
+#define MAXVIEWS    4
 
 struct gui_data
 {
@@ -18,12 +16,61 @@ struct gui_data
     int loop, swing, shownames;
 };
 
+class MyCanvas: public wxPanel
+{
+public:
+    MyCanvas(wxWindow *parent, wxWindowID id, const wxSize& size);
+    void erase(wxEraseEvent &ev);
+    void draw_image(wxBitmap *bmp);
+    void draw_text(int style, int x, int y, const char *str);
+
+    DECLARE_EVENT_TABLE()
+};
+
+class MyFrame: public wxFrame
+{
+public:
+    MyFrame(const wxString& title, int ncols, int nrows, struct gui_data *cd);
+    void change_label(const char *label);
+
+    MyCanvas *canvas;
+
+private:
+    struct gui_data *cd;
+    wxStaticText *flabel;
+
+    void make_buttons(wxSizer *);
 
-/* function prototypes */
-/* gui.c */
-void make_buttons(struct gui_data *data, Widget trc, Screen * scr);
-void set_buttons_pixmap(Display * display, Drawable d);
+    void rewind_callback(wxCommandEvent &);
+    void rplay_callback(wxCommandEvent &);
+    void stepb_callback(wxCommandEvent &);
+    void stop_callback(wxCommandEvent &);
+    void stepf_callback(wxCommandEvent &);
+    void play_callback(wxCommandEvent &);
+    void loop_callback(wxCommandEvent &);
+    void swing_callback(wxCommandEvent &);
+    void exit_callback(wxCommandEvent &);
+    void names_callback(wxCommandEvent &);
+    void slower_callback(wxCommandEvent &);
+    void faster_callback(wxCommandEvent &);
 
-/* Clr_table.c */
-Colormap InitColorTableFixed(Colormap cmap);
-int _get_lookup_for_color(unsigned int r, unsigned int g, unsigned int b);
+    DECLARE_EVENT_TABLE()
+};
+
+class MyApp: public wxApp
+{
+private:
+    wxBitmap *pic_array[MAXIMAGES];
+
+public:
+    virtual bool OnInit();
+
+private:
+    MyFrame *mainwin;
+    struct gui_data gd;
+
+    int load_files(void);
+    void do_run(wxIdleEvent &);
+
+    DECLARE_EVENT_TABLE()
+};

+ 0 - 1
visualization/xganim/local_proto.h

@@ -1 +0,0 @@
-extern Visual *use_visual;

+ 79 - 267
visualization/xganim/main.c

@@ -23,69 +23,47 @@
 #include <math.h>
 #include <limits.h>
 #include <unistd.h>
+
+#include <wx/image.h>
+#include <wx/bitmap.h>
+#include <wx/event.h>
+
+extern "C" {
 #include <grass/gis.h>
 #include <grass/glocale.h>
+}
+
 #include "gui.h"
-#include "local_proto.h"
 
-#define COLOR_OFFSET 0
-#define MAXIMAGES 400
 #define DEF_MAX 900
 #define DEF_MIN 600
-#define MAXVIEWS    4
 #define BORDER_W    2
 
-
-/* function prototypes */
-static int load_files();
-static Boolean do_run(XtPointer);
 static char **gee_wildfiles(char *wildarg, char *element, int *num);
-static void change_label(Widget wid, char *str);
-static void parse_command(struct Option **viewopts,
-			  char *vfiles[MAXVIEWS][MAXIMAGES],
-			  int *numviews, int *numframes);
+static void parse_command(
+    struct Option **viewopts, char *vfiles[MAXVIEWS][MAXIMAGES],
+    int *numviews, int *numframes);
 
+struct Option *viewopts[MAXVIEWS];
 
-/* global variables */
-Widget canvas, flabel;
-Display *theDisplay;
-XImage *pic_array[MAXIMAGES];
-GC invertGC, drawGC;
 unsigned int nrows, ncols;
+char *vfiles[MAXVIEWS][MAXIMAGES];
 int numviews;
+int frames;
 int Top = 0, Left = 0;
 char frame[MAXIMAGES][4];
-char *vfiles[MAXVIEWS][MAXIMAGES];
 int LabelPos[MAXVIEWS][2];
 
 float vscale, scale;		/* resampling scale factors */
 int irows, icols, vrows, vcols;
-int frames;
-
-unsigned int depth;
 
-Visual *use_visual;
+BEGIN_EVENT_TABLE(MyApp, wxApp)
+EVT_IDLE(MyApp::do_run)
+END_EVENT_TABLE()
 
 int main(int argc, char **argv)
 {
-    Widget toplevel, mainwin, trc;
-    int scrn;
-    Display *dpy;
-    Window grwin;
-    Colormap fixedcmap;
-
-    int i, j;
-    unsigned int *sdimp;
-    int longdim;
-    unsigned long blackPix, whitePix;
-
-    struct gui_data cd;
-
-    XtAppContext AppC;
-    Arg wargs[15];
-    unsigned int n;
-
-    struct Option *viewopts[MAXVIEWS];
+    int i;
 
     G_gisinit(argv[0]);
 
@@ -108,6 +86,15 @@ int main(int argc, char **argv)
 
     parse_command(viewopts, vfiles, &numviews, &frames);
 
+    return wxEntry(argc, argv);
+}
+
+bool MyApp::OnInit()
+{
+    int i, j;
+    unsigned int *sdimp;
+    int longdim;
+
     /* debug */
     if (G_verbose() > G_verbose_std()) {
 	for (i = 0; i < numviews; i++) {
@@ -158,11 +145,11 @@ int main(int argc, char **argv)
     if (numviews == 4)
 	vscale = scale / 2.;
 
-    nrows *= scale;
-    ncols *= scale;
+    nrows = (unsigned int) (nrows * scale);
+    ncols = (unsigned int) (ncols * scale);
     /* now nrows & ncols are the size of the combined - views image */
-    vrows *= vscale;
-    vcols *= vscale;
+    vrows = (int) (vrows * vscale);
+    vcols = (int) (vcols * vscale);
     /* now vrows & vcols are the size for each sub-image */
 
     /* add to nrows & ncols for borders */
@@ -172,172 +159,43 @@ int main(int argc, char **argv)
     nrows += (1 + (nrows / vrows)) * BORDER_W;
     ncols += (1 + (ncols / vcols)) * BORDER_W;
 
-    toplevel = XtAppInitialize(&AppC, "xganimate", NULL, 0,
-			       &argc, argv, NULL, wargs, 0);
-
-    theDisplay = XtDisplay(toplevel);
-
-    n = 0;
-    if (ncols > nrows) {
-	XtSetArg(wargs[n], XmNwidth, ncols);
-	n++;
-	XtSetArg(wargs[n], XmNheight, nrows + 60);
-	n++;
-    }
-    else {
-	XtSetArg(wargs[n], XmNwidth, ncols + 80);
-	n++;
-	XtSetArg(wargs[n], XmNheight, nrows);
-	n++;
-    }
-    mainwin = XtCreateManagedWidget("GRASS Animate", xmFormWidgetClass,
-				    toplevel, wargs, n);
-
-    cd.speed = 100;
-    cd.direction = 1;
-    cd.shownames = 1;
-
-    n = 0;
-    XtSetArg(wargs[n], XmNtopAttachment, XmATTACH_FORM);
-    n++;
-    XtSetArg(wargs[n], XmNleftAttachment, XmATTACH_FORM);
-    n++;
-    XtSetArg(wargs[n], XmNwidth, ncols);
-    n++;
-    XtSetArg(wargs[n], XmNheight, nrows);
-    n++;
-    canvas = XtCreateManagedWidget("canvas", xmDrawingAreaWidgetClass,
-				   mainwin, wargs, n);
-
-    n = 0;
-    if (ncols > nrows) {
-	XtSetArg(wargs[n], XmNorientation, XmHORIZONTAL);
-	n++;
-	XtSetArg(wargs[n], XmNleftAttachment, XmATTACH_FORM);
-	n++;
-	XtSetArg(wargs[n], XmNrightAttachment, XmATTACH_FORM);
-	n++;
-	XtSetArg(wargs[n], XmNbottomAttachment, XmATTACH_FORM);
-	n++;
-	XtSetArg(wargs[n], XmNtopAttachment, XmATTACH_WIDGET);
-	n++;
-	XtSetArg(wargs[n], XmNtopWidget, canvas);
-	n++;
-    }
-    else {
-	XtSetArg(wargs[n], XmNorientation, XmVERTICAL);
-	n++;
-	XtSetArg(wargs[n], XmNleftAttachment, XmATTACH_WIDGET);
-	n++;
-	XtSetArg(wargs[n], XmNleftWidget, canvas);
-	n++;
-	XtSetArg(wargs[n], XmNrightAttachment, XmATTACH_FORM);
-	n++;
-	XtSetArg(wargs[n], XmNbottomAttachment, XmATTACH_FORM);
-	n++;
-	XtSetArg(wargs[n], XmNtopAttachment, XmATTACH_FORM);
-	n++;
-    }
-    XtSetArg(wargs[n], XmNbackground, WhitePixelOfScreen(XtScreen(toplevel)));
-    n++;
-    XtSetArg(wargs[n], XmNadjustMargin, False);
-    n++;
-    trc = XtCreateManagedWidget("controls_rc",
-				xmRowColumnWidgetClass, mainwin, wargs, n);
-
-    make_buttons(&cd, trc, XtScreen(toplevel));
-
-    n = 0;
-    XtSetArg(wargs[n], XmNalignment, XmALIGNMENT_END);
-    n++;
-    flabel = XtCreateManagedWidget("cfr", xmLabelWidgetClass, trc, wargs, n);
-
-    XtRealizeWidget(toplevel);
-    set_buttons_pixmap(theDisplay, XtWindow(canvas));
-
-    /**************************************************************/
-
-    dpy = XtDisplay(canvas);
-    grwin = XtWindow(canvas);
-    scrn = DefaultScreen(dpy);
-    use_visual = DefaultVisual(dpy, scrn);
-#if 1
-    fixedcmap = XCreateColormap(dpy, grwin, use_visual, AllocNone);
-#else
-    fixedcmap = DefaultColormap(dpy, scrn);
-#endif
-    fixedcmap = InitColorTableFixed(fixedcmap);
-
-    XtVaGetValues(canvas, XmNdepth, &depth, NULL);
-
-    XtVaSetValues(toplevel, XmNcolormap, fixedcmap, NULL);
-    XtSetWMColormapWindows(toplevel, &canvas, 1);
-
-    /**************************************************************/
-
-    blackPix = _get_lookup_for_color(0, 0, 0);
-    whitePix = _get_lookup_for_color(255, 255, 255);
-
-    drawGC =
-	XCreateGC(XtDisplay(canvas), XtWindow(canvas), (unsigned long)0,
-		  NULL);
-    XSetFunction(theDisplay, drawGC, GXcopy);
-    XSetForeground(theDisplay, drawGC, blackPix);
-    XSetBackground(theDisplay, drawGC, whitePix);
-
-    invertGC =
-	XCreateGC(XtDisplay(canvas), XtWindow(canvas), (unsigned long)0,
-		  NULL);
-    XSetFunction(theDisplay, invertGC, GXcopy);
-    XSetForeground(theDisplay, invertGC, whitePix);
-    XSetBackground(theDisplay, invertGC, blackPix);
+    gd.speed = 100;
+    gd.direction = 1;
+    gd.shownames = 1;
 
+    mainwin = new MyFrame(wxString("GRASS Animate", wxConvISO8859_1), ncols, nrows, &gd);
+    mainwin->Show();
+    SetTopWindow(mainwin);
 
     for (j = 0; j < MAXIMAGES; j++)
 	sprintf(frame[j], "%2d", j + 1);
 
-    while (1) {			/* wait for window */
-	XEvent xev;
-
-	XNextEvent(theDisplay, &xev);
-	if (xev.type == MapNotify && xev.xmap.event == XtWindow(mainwin))
-	    break;
-    }
-
-    XtAppAddWorkProc(AppC, do_run, &cd);
-    XtAppMainLoop(AppC);
-
-    return 0;
+    return true;
 }
 
 
-static int load_files()
+int MyApp::load_files(void)
 {
-    CELL *cell;
-    FCELL *fcell;
     DCELL *dcell;
-    void *voidc = NULL;
     unsigned char *tr, *tg, *tb, *tset;
     int tsiz, coff;
     int rowoff, row, col, vxoff, vyoff;
     int cnt, ret, fd;
     int vnum;
-    XImage *pa;
-    char *mapset, name[BUFSIZ];
+    const char *name;
     struct Colors colors;
-    int rtype;
 
-    cell = G_allocate_c_raster_buf();
-    fcell = G_allocate_f_raster_buf();
     dcell = G_allocate_d_raster_buf();
 
     tsiz = G_window_cols();
 
     /* allocate memory */
-    tr = G_malloc(tsiz * sizeof(char));
-    tg = G_malloc(tsiz * sizeof(char));
-    tb = G_malloc(tsiz * sizeof(char));
-    tset = G_malloc(tsiz * sizeof(char));
+    tr   = (unsigned char *) G_malloc(tsiz * sizeof(char));
+    tg   = (unsigned char *) G_malloc(tsiz * sizeof(char));
+    tb   = (unsigned char *) G_malloc(tsiz * sizeof(char));
+    tset = (unsigned char *) G_malloc(tsiz * sizeof(char));
+
+    wxImage img(ncols, nrows);
 
     for (cnt = 0; cnt < frames; cnt++) {
 	if (cnt > MAXIMAGES) {
@@ -345,11 +203,6 @@ static int load_files()
 	    break;
 	}
 
-	pa = XCreateImage(theDisplay, use_visual, depth, ZPixmap,
-			  0, NULL, ncols, nrows, 8, 0);
-	pa->data = G_malloc((size_t) nrows * pa->bytes_per_line);
-	pic_array[cnt] = pa;
-
 	for (vnum = 0; vnum < numviews; vnum++) {
 	    if (icols == vcols) {
 		vxoff = BORDER_W;
@@ -375,83 +228,64 @@ static int load_files()
 		LabelPos[vnum][1] = vyoff + vrows - 1;
 	    }
 
-	    strcpy(name, vfiles[vnum][cnt]);
+	    name = vfiles[vnum][cnt];
 	    G_message(_("Reading file [%s]..."), name);
 
-	    mapset = G_find_cell2(name, "");
-	    if (mapset == NULL)
-		G_fatal_error(_("Raster map <%s> not found"), name);
-
-	    fd = G_open_cell_old(name, mapset);
+	    fd = G_open_cell_old(name, "");
 	    if (fd < 0)
 		G_fatal_error(_("Unable to open raster map <%s>"), name);
 	    /*
 	       strcpy(title[cnt],G_get_cell_title(name, mapset));
 	     */
 
-	    rtype = G_get_raster_map_type(fd);
-	    if (rtype == CELL_TYPE)
-		voidc = (CELL *) cell;
-	    else if (rtype == FCELL_TYPE)
-		voidc = (FCELL *) fcell;
-	    else if (rtype == DCELL_TYPE)
-		voidc = (DCELL *) dcell;
-	    else
-		/* should not reach here */
-		G_fatal_error(_("Unable to determine raster cell type"));
-
-	    ret = G_read_colors(name, mapset, &colors);
+	    ret = G_read_colors(name, "", &colors);
 	    if (ret < 0)
 		G_fatal_error(_("Unable to read color file"));
 
 	    for (row = 0; row < vrows; row++) {
-		if (G_get_raster_row
-		    (fd, (void *)voidc, (int)(row / vscale), rtype) < 0)
+		if (G_get_d_raster_row(fd, dcell, (int)(row / vscale)) < 0)
 		    G_fatal_error(_("Unable to read raster row"));
 
 		rowoff = (vyoff + row) * ncols;
-		G_lookup_raster_colors((void *)voidc, tr, tg, tb, tset, tsiz,
-				       &colors, rtype);
+		G_lookup_d_raster_colors(dcell, tr, tg, tb, tset, tsiz, &colors);
 
 		for (col = 0; col < vcols; col++) {
 		    coff = (int)(col / vscale);
 
 		    if (!tset[coff])
-			tr[coff] = tg[coff] = tb[coff] = 255;
-
-		    XPutPixel(pa, vxoff + col, vyoff + row,
-			      _get_lookup_for_color(tr[coff],
-						    tg[coff], tb[coff]));
+			img.SetRGB(vxoff + col, vyoff + row, 255, 255, 255);
+		    else
+			img.SetRGB(vxoff + col, vyoff + row, tr[coff], tg[coff], tb[coff]);
 		}
 	    }
 
 	    G_close_cell(fd);
 	}
 
-	XPutImage(theDisplay, XtWindow(canvas), drawGC, pa, 0, 0,
-		  Left, Top, ncols, nrows);
-	change_label(flabel, frame[cnt]);
+	wxBitmap *bmp = new wxBitmap(img);
+	pic_array[cnt] = bmp;
 
+	mainwin->canvas->draw_image(bmp);
+	mainwin->change_label(frame[cnt]);
     }
-    G_free(cell);
-    G_free(fcell);
+
     G_free(dcell);
     G_free(tr);
     G_free(tg);
     G_free(tb);
     G_free(tset);
 
-    return (cnt);
+    return cnt;
 }
 
 
 /* ###################################################### */
-static Boolean do_run(XtPointer p)
+
+void MyApp::do_run(wxIdleEvent &ev)
 {
     static int first = 1;
-    struct gui_data *cd = p;
+    struct gui_data *cd = &gd;
     int i, cnt;
-    Drawable dr;
 
     if (first) {
 	first = 0;
@@ -487,7 +321,7 @@ static Boolean do_run(XtPointer p)
 	cd->stop = 1;
 
     if (cd->stop && !cd->step)
-	return (False);
+	return;
 
     if (cd->curframe < cd->nframes && cd->curframe >= 0) {
 	/* little pause */
@@ -497,26 +331,17 @@ static Boolean do_run(XtPointer p)
 	    for (tf = 0.0; tf < cd->speed; tf += .01) ;
 	}
 
-	dr = XtWindow(canvas);
-	XPutImage(theDisplay, dr, drawGC, pic_array[cd->curframe], 0, 0,
-		  Left, Top, ncols, nrows);
+	mainwin->canvas->draw_image(pic_array[cd->curframe]);
 
 	/* draw labels */
-	if (cd->shownames == 1)
-	    for (i = 0; i < numviews; i++) {
-		XDrawString(theDisplay, dr, drawGC,
-			    LabelPos[i][0] + 5, LabelPos[i][1] - 5,
-			    vfiles[i][cd->curframe],
-			    (int)strlen(vfiles[i][cd->curframe]));
-	    }
-	else if (cd->shownames == 2)
-	    for (i = 0; i < numviews; i++) {
-		XDrawString(theDisplay, dr, invertGC,
-			    LabelPos[i][0] + 5, LabelPos[i][1] - 5,
-			    vfiles[i][cd->curframe],
-			    (int)strlen(vfiles[i][cd->curframe]));
-	    }
-	change_label(flabel, frame[cd->curframe]);
+	for (i = 0; i < numviews; i++) {
+	    mainwin->canvas->draw_text(
+		cd->shownames,
+		LabelPos[i][0] + 5, LabelPos[i][1] - 5,
+		vfiles[i][cd->curframe]);
+	}
+
+	mainwin->change_label(frame[cd->curframe]);
 
 	cd->prevframe = cd->curframe;
     }
@@ -527,13 +352,12 @@ static Boolean do_run(XtPointer p)
 	cd->step = 0;
 	cd->stop = 1;
     }
-
-    return False;		/* to keep it running */
 }
 
 
 /* ###################################################### */
-static char **gee_wildfiles(char *wildarg, char *element, int *num)
+
+char **gee_wildfiles(char *wildarg, char *element, int *num)
 {
     int n, cnt = 0;
     char path[GPATH_MAX], *mapset, cmd[GPATH_MAX], buf[512];
@@ -582,22 +406,7 @@ static char **gee_wildfiles(char *wildarg, char *element, int *num)
 
 
 /********************************************************************/
-/* to change label in label widget */
-
-static void change_label(Widget wid, char *str)
-{
-    Arg wargs[1];
-    XmString xmstr;
-
-    xmstr = XmStringCreateSimple(str);
-    XtSetArg(wargs[0], XmNlabelString, xmstr);
-    XtSetValues(wid, wargs, 1);
-    XmStringFree(xmstr);
-}
-
-
-/********************************************************************/
-static void parse_command(struct Option **viewopts,
+void parse_command(struct Option **viewopts,
 			  char *vfiles[MAXVIEWS][MAXIMAGES],
 			  int *numviews, int *numframes)
 {
@@ -630,3 +439,6 @@ static void parse_command(struct Option **viewopts,
 	}
     }
 }
+
+IMPLEMENT_APP_NO_MAIN(MyApp)
+