v04i006: Dragon, Patch1 (Part2)

Dan Heller argv at island.uu.net
Wed May 24 17:40:49 AEST 1989


Submitted-by: Gary Barnes <uunet!igor!amber!geb>
Posting-number: Volume 4, Issue 6
Archive-name: Dragon/patch1 (Part2)

*** ../dragon/Imakefile	Tue May 23 00:05:20 1989
--- Imakefile	Mon May 22 23:55:26 1989
***************
*** 1,7 ****
!            SRCS = main.c board.c button.c icon.c tile.c tile_bits.c
!            OBJS = main.o board.o button.o icon.o tile.o tile_bits.o
         PROGRAMS = dragon
!         DEFINES =
         INCLUDES = 
    SYS_LIBRARIES = -lXaw -lXmu -lXt -lX11
  
--- 1,8 ----
!            SRCS = main.c board.c button.c draw.c icon.c tile.c tile_bits.c
!            OBJS = main.o board.o button.o draw.o icon.o tile.o tile_bits.o
         PROGRAMS = dragon
!        LINTOPTS = -uxz
!         DEFINES = -DWANTDEBUG
         INCLUDES = 
    SYS_LIBRARIES = -lXaw -lXmu -lXt -lX11
  
***************
*** 13,19 ****
--- 14,27 ----
          $(USRLIBDIR)/libXt.a \
          $(USRLIBDIR)/libX11.a
  
+ lint:
+ 	$(LINT) $(LINTFLAGS) $(SRCS)
+ 
  MakeBug:
  	cp Makefile MakeBug.bak
  	make -f MakeBug.bak Makefile
  	rm MakeBug.bak
+ 
+ tar:
+ 	tar cf - . > ../dragon.tar
+ 	compress -v ../dragon.tar
*** ../dragon/Makefile	Tue May 23 00:05:21 1989
--- Makefile	Mon May 22 23:55:28 1989
***************
*** 1,4 ****
!             TOP = /usr/src/X11R3
          UTILSRC = $(TOP)/util
         IMAKESRC = $(UTILSRC)/imake
            IMAKE = $(IMAKESRC)/imake
--- 1,4 ----
!             TOP = /src/x
          UTILSRC = $(TOP)/util
         IMAKESRC = $(UTILSRC)/imake
            IMAKE = $(IMAKESRC)/imake
*** ../dragon/README	Tue May 23 00:03:36 1989
--- README	Mon May 22 23:55:30 1989
***************
*** 1,9 ****
! 04/19/89
  
  Dragon is a game.  It implements a version of the ancient game of Mah-Jongg.
  
! Dragon is known to work on a Sun 3/60 running SunOS 3.5 with X11R3 from MIT.
! It compiles with the Sun compiler and with gcc version 1.31.
  
  As of this writing, the Athena Dialog widget has a bug that can cause Dragon
  to get a segmentation/memory error.  There is code in X11R3/lib/Xaw/Dialog.c
--- 1,24 ----
! 05/18/89
  
  Dragon is a game.  It implements a version of the ancient game of Mah-Jongg.
  
! Dragon is known to work on a Sun 3/60 running SunOS 3.5 with X11R3 from
! MIT.  It compiles with the Sun compiler and with gcc version 1.31.
! 
! I have been told that the current version (this one right here) runs
! correctly on monochrome, gray-scale, and color DEC equipment.  Presumably
! it will run correctly on most servers at this point.
! 
! Dragon is a "monochrome" application; it uses two colors; the default
! "foreground" color and the default "background" color as defined and
! determined by the X Toolkit.
! 
! If you do a "make all" initially then the Makefile will be rebuilt using
! the MIT imake program.  If you do not have the MIT imake program (or don't
! want to use it) then rename the Makefile.Canned file to be Makefile and
! hand-edit it for use at your site.
! 
! 04/19/89
  
  As of this writing, the Athena Dialog widget has a bug that can cause Dragon
  to get a segmentation/memory error.  There is code in X11R3/lib/Xaw/Dialog.c
*** ../dragon/button.c	Tue May 23 00:04:00 1989
--- button.c	Mon May 22 23:55:36 1989
***************
*** 4,9 ****
--- 4,12 ----
  * Author: Gary E. Barnes	March 1989
  *
  * button.c - Deals with the command buttons on the board
+ ******************************************************************************
+ *  4/24/89 GEB 	- When "Other" pressed, if "Samples" is on then turn it off
+ *		-  before changing button menus.
  ******************************************************************************/
  
  #include "main.h"
***************
*** 57,62 ****
--- 60,66 ----
      { "New Game",   New_Game,	  FALSE   },
      { "Restart",    Restart_Game, FALSE  },
      { "Save",	    Save_Game,    FALSE   },
+ #define OTHER_BUTTON 3
      { "Other",	    Other,	  TRUE    },
  
      { "Hint",	    Hints,	  FALSE   },
***************
*** 68,73 ****
--- 72,78 ----
  Button_Rec	Buttons2[NBUTTONS] = {
      { "Redraw",	    Redraw_All,	  FALSE   },
      { "Sides",	    Sides,	  FALSE   },
+ #define SAMPLES_BUTTON 2
      { "Samples",    Show_Samples, TRUE    },
      { "Other",	    Other,	  TRUE    },
  
***************
*** 107,114 ****
  {
  #undef SETARG
  #define SETARG(name,value) \
!     if (argi >= XtNumber(args)) {fprintf(stderr,"BS args overrun!\n");} \
!     XtSetArg( args[argi], name,  value ); ++argi;
  
      Arg		args[10];
      int		argi;
--- 112,119 ----
  {
  #undef SETARG
  #define SETARG(name,value) \
!     DEBUG_ERROR(argi >= XtNumber(args),"BS args overrun!\n" ); \
!     XtSetArg( args[argi], name,  (XtArgVal)value ); ++argi;
  
      Arg		args[10];
      int		argi;
***************
*** 218,226 ****
      if (All_Buttons == &Buttons1[0]) {
  	All_Buttons = &Buttons2[0];
      } else {
  	All_Buttons = &Buttons1[0];
      }
!     All_Buttons[3].hilite = !All_Buttons[3].hilite;
      XClearArea( XtDisplay(Board), XtWindow(w),
  	        0, 0, 0, (unsigned)(2*Tile_Height-Side_Y-Shadow_Y-1), FALSE );
      Button_Expose( w, event, params, num_params );
--- 223,236 ----
      if (All_Buttons == &Buttons1[0]) {
  	All_Buttons = &Buttons2[0];
      } else {
+ 	/*--Turn off Samples mode if we are changing menus. */
+ 	if (Buttons2[SAMPLES_BUTTON].hilite) {
+ 	    (*(Buttons2[SAMPLES_BUTTON].action))(w, event, params, num_params);
+ 	    Buttons2[SAMPLES_BUTTON].hilite = FALSE;
+ 	}
  	All_Buttons = &Buttons1[0];
      }
!     All_Buttons[OTHER_BUTTON].hilite = !All_Buttons[OTHER_BUTTON].hilite;
      XClearArea( XtDisplay(Board), XtWindow(w),
  	        0, 0, 0, (unsigned)(2*Tile_Height-Side_Y-Shadow_Y-1), FALSE );
      Button_Expose( w, event, params, num_params );
***************
*** 259,266 ****
      FILE	*file;
  
      DEBUG_CALL(Restore_Game);
!     strcpy( &name[0], getenv( "HOME" ) );
!     strcat( &name[0], "/.dragon-save" );
      file = fopen( &name[0], "r" );
      if (file == (FILE*)NULL) {
  	Complain( "Cannot open the $HOME/.dragon-save file." );
--- 269,276 ----
      FILE	*file;
  
      DEBUG_CALL(Restore_Game);
!     (void)strcpy( &name[0], getenv( "HOME" ) );
!     (void)strcat( &name[0], "/.dragon-save" );
      file = fopen( &name[0], "r" );
      if (file == (FILE*)NULL) {
  	Complain( "Cannot open the $HOME/.dragon-save file." );
***************
*** 289,296 ****
      FILE	*file;
  
      DEBUG_CALL(Save_Game);
!     strcpy( &name[0], getenv( "HOME" ) );
!     strcat( &name[0], "/.dragon-save" );
      file = fopen( &name[0], "w" );
      if (file == (FILE*)NULL) {
  	Complain( "Cannot open the $HOME/.dragon-save file." );
--- 299,306 ----
      FILE	*file;
  
      DEBUG_CALL(Save_Game);
!     (void)strcpy( &name[0], getenv( "HOME" ) );
!     (void)strcat( &name[0], "/.dragon-save" );
      file = fopen( &name[0], "w" );
      if (file == (FILE*)NULL) {
  	Complain( "Cannot open the $HOME/.dragon-save file." );
***************
*** 401,408 ****
  	    if (but[i].text == NULL) { goto Next_Button; }
  	    l = strlen(but[i].text);
  	    if (l > 8) {
! 		fprintf( stderr, "Button name too long: %s\n",
! 			 but[i].text );
  		l = 8;
  	    }
  	    but[i].x = x;
--- 411,418 ----
  	    if (but[i].text == NULL) { goto Next_Button; }
  	    l = strlen(but[i].text);
  	    if (l > 8) {
! 		(void)fprintf( stderr, "Button name too long: %s\n",
! 			       but[i].text );
  		l = 8;
  	    }
  	    but[i].x = x;
***************
*** 463,469 ****
  * Called to draw the vector text in some button.
  ******************************************************************************/
  {
!     static char pntserr[] = "DT pnts overflow!\n";
      XPoint	pnts[50];
      int		pnti;
      int		h1;
--- 473,481 ----
  * Called to draw the vector text in some button.
  ******************************************************************************/
  {
! #ifdef WANTDEBUG
!     static char *pntserr = "DT pnts overflow!\n";
! #endif
      XPoint	pnts[50];
      int		pnti;
      int		h1;
***************
*** 471,477 ****
  
  #undef PNT
  #define PNT(X,Y) \
!     if (pnti >= XtNumber(pnts)){fprintf(stderr,pntserr);} \
      pnts[pnti].x = X; pnts[pnti].y = Y; ++pnti
      ;
  
--- 483,489 ----
  
  #undef PNT
  #define PNT(X,Y) \
!     DEBUG_ERROR( pnti >= XtNumber(pnts), pntserr ); \
      pnts[pnti].x = X; pnts[pnti].y = Y; ++pnti
      ;
  
***************
*** 500,512 ****
  		PNT( 0,		h26	);
  		PNT( w6,	h6	);
  		PNT( w6,	h6	);
! 		PNT( 2*w6,	0	);
  		PNT( w6,	-h6	);
  		PNT( w6,	-h6	);
  		PNT( 0,		-h26	);
  		PNT( -w6,	-h6	);
  		PNT( -w6,	-h6	);
! 		PNT( -2*w6,	0	);
  		PNT( -w6,	h6	);
  		PNT( -w6,	h6	);
  		break;
--- 512,524 ----
  		PNT( 0,		h26	);
  		PNT( w6,	h6	);
  		PNT( w6,	h6	);
! 		PNT( w1-4*w6,	0	);
  		PNT( w6,	-h6	);
  		PNT( w6,	-h6	);
  		PNT( 0,		-h26	);
  		PNT( -w6,	-h6	);
  		PNT( -w6,	-h6	);
! 		PNT( -(w1-4*w6),0	);
  		PNT( -w6,	h6	);
  		PNT( -w6,	h6	);
  		break;
*** ../dragon/dragon.man	Tue May 23 00:03:54 1989
--- dragon.man	Mon May 22 23:55:37 1989
***************
*** 8,16 ****
--- 8,18 ----
  [-icongeometry geometry]
  [-/+iconic]
  [-iconname name]
+ [-geometry geometry]
  [-/+reverse]
  [-/+shadows]
  [-sides type]
+ [-/+sticky]
  .SH DESCRIPTION
  \fIDragon\fP plays a version of the game of Mah-Jongg.
  
***************
*** 73,78 ****
--- 75,85 ----
  250 milliseconds.  Clicks further apart than this will be treated as
  separate single clicks instead of one double click.
  .TP 8
+ .B \-geometry geometry
+ Use this option to specify the geometry to be used for the
+ \fIdragon\fP window.  There are five sizes that \fIdragon\fP prefers,
+ 450x340, 650x500, 870x660, 1080x820, and 1290x980.
+ .TP 8
  .B \-icongeometry geometry
  Use this option to specify the geometry to be used for the
  \fIdragon\fP icon.  There are two sizes that \fIdragon\fP prefers,
***************
*** 97,102 ****
--- 104,116 ----
  .B \-sides type
  This option can be used to specify the way that tile sides are drawn.
  There are four possiblities.  "gray" (the default), "black", and "line".
+ .TP 8
+ .B \-sticky
+ By default, the first selection is "sticky" (+sticky) which means that
+ attempts to select a second tile that is free but which doesn't match
+ the first are rejected.  If the first selection is not sticky
+ (-sticky), an attempt to select a free tile that doesn't match the first
+ will deselect the first tile and leave only the second selected.
  .SH MOUSE BUTTONS
  Click button 1 on any tile to select it.  Click on any menu button to activate
  it.
***************
*** 176,181 ****
--- 190,201 ----
  Specifies the maximum time to allow between the two clicks that form a
  double-click.  The default is 250.
  .TP 8
+ .B "geometry (\fPclass\fB Geometry)"
+ Use this option to specify the geometry to be used for the
+ \fIdragon\fP window.  There are five sizes that \fIdragon\fP prefers,
+ 450x340, 650x500, 870x660, 1080x820, and 1290x980.  The default is
+ "450x340".
+ .TP 8
  .B "iconGeometry (\fPclass\fB IconGeometry)"
  Specifies the geometry of the \fIdragon\fB icon.  Preferred sizes are
  32x32 and 64x64.  The default is "64x64".
***************
*** 190,195 ****
--- 210,219 ----
  .B "reverseVideo (\fPclass\fB ReverseVideo)"
  Specifies TRUE for reverse-video effects and FALSE for normal-video.
  The default is FALSE.
+ .TP 8
+ .B "stickyTile \(fPclass\fB StickyTile)|
+ Specify TRUE for first tile selected to be sticky (default), FALSE for
+ selection follows click.
  .TP 8
  .B "tileShadows (\fPclass\fB TileShadows)"
  Specifies TRUE if tiles are to have 3-D shadows and FALSE if not.  The
*** ../dragon/icon.c	Tue May 23 00:04:01 1989
--- icon.c	Mon May 22 23:55:41 1989
***************
*** 13,19 ****
  
  extern char * malloc();
  extern        free();
- extern Pixmap XCreateTile();
  
  
  GC	Icon_GC = (GC)0;		/* GC used for Icon window. */
--- 13,18 ----
***************
*** 58,70 ****
   *  preexisting Icon images. */
  
      if (Icon_GC == (GC)0) {
! 	if (Dragon_Resources.Reverse_Video) {
! 	    gcv.background = BlackPixelOfScreen(XtScreen(w));
! 	    gcv.foreground = WhitePixelOfScreen(XtScreen(w));
! 	} else {
! 	    gcv.foreground = BlackPixelOfScreen(XtScreen(w));
! 	    gcv.background = WhitePixelOfScreen(XtScreen(w));
! 	}
  	Icon_GC = XtGetGC( w, GCForeground|GCBackground, &gcv );
      }
      ximage.height  = size;
--- 57,64 ----
   *  preexisting Icon images. */
  
      if (Icon_GC == (GC)0) {
! 	gcv.foreground = Dragon_Resources.Foreground;
! 	gcv.background = Dragon_Resources.Background;
  	Icon_GC = XtGetGC( w, GCForeground|GCBackground, &gcv );
      }
      ximage.height  = size;
***************
*** 115,122 ****
      int	  	 scr;
  
  #define SETARG(name,value) \
!     if (*argi >= argn) {fprintf(stderr,"IS args overrun!\n");} \
!     XtSetArg( args[*argi], name,  value ); ++*argi;
  
  /*--If we've been asked to set up the Icon geometry then do that. */
  
--- 109,116 ----
      int	  	 scr;
  
  #define SETARG(name,value) \
!     DEBUG_ERROR( *argi >= argn, "IS args overrun!\n" ); \
!     XtSetArg( args[*argi], name,  (XtArgVal)value ); ++*argi;
  
  /*--If we've been asked to set up the Icon geometry then do that. */
  
***************
*** 172,183 ****
  		    ic[i].min_height <= size &&
  		    size-ic[i].min_height & ic[i].height_inc == 0) {
  		    Icon_Pixmap =		/* Size is perfect */
! 		      XCreateTile( XtDisplay(Dragon),
! 				   RootWindowOfScreen(XtScreen(Dragon)),
! 				   (size == 64
! 				    ? &dragon_icon64_bits[0]
! 				    : &dragon_icon32_bits[0]), 
! 				   size, size );
  		}
  	    }
  	    if (Icon_Pixmap != (Pixmap)NULL || 	/* Stop on success */
--- 166,181 ----
  		    ic[i].min_height <= size &&
  		    size-ic[i].min_height & ic[i].height_inc == 0) {
  		    Icon_Pixmap =		/* Size is perfect */
! 		      XCreatePixmapFromBitmapData
! 			( XtDisplay(Dragon),
! 			  RootWindowOfScreen(XtScreen(Dragon)),
! 			  (size == 64
! 			   ? &dragon_icon64_bits[0]
! 			   : &dragon_icon32_bits[0]), 
! 			  (unsigned int)size, (unsigned int)size,
! 			  Dragon_Resources.Foreground,
! 			  Dragon_Resources.Background,
! 			  DefaultDepthOfScreen(XtScreen(Dragon)) );
  		}
  	    }
  	    if (Icon_Pixmap != (Pixmap)NULL || 	/* Stop on success */
***************
*** 193,199 ****
  	    char	*data;
  	    char	*orig;
  	    char	*ptr;
! 	    int		 w, wb, h, hb;
  	    int		 inc;
  
  /*--Figure out which of our pixmaps we will copy into this odd pixmap. */
--- 191,197 ----
  	    char	*data;
  	    char	*orig;
  	    char	*ptr;
! 	    unsigned int w, wb, h, hb;
  	    int		 inc;
  
  /*--Figure out which of our pixmaps we will copy into this odd pixmap. */
***************
*** 235,243 ****
  /*--Create the pixmap and free up the data area. */
  
  	    Icon_Pixmap =
! 	      XCreateTile( XtDisplay(Dragon),
! 			   RootWindowOfScreen(XtScreen(Dragon)),
! 			   data, w, h );
  	    free( data );
  	}
  	XFree( ic );
--- 233,243 ----
  /*--Create the pixmap and free up the data area. */
  
  	    Icon_Pixmap =
! 	      XCreatePixmapFromBitmapData
! 		( XtDisplay(Dragon), RootWindowOfScreen(XtScreen(Dragon)),
! 		  data, w, h,
! 		  Dragon_Resources.Foreground, Dragon_Resources.Background,
! 		  DefaultDepthOfScreen(XtScreen(Dragon)) );
  	    free( data );
  	}
  	XFree( ic );
***************
*** 262,270 ****
  	Widget		Icon_Core;
  
  #define LCLARG(name,value) \
! 	if (SomeArgsi >= XtNumber(SomeArgs)) \
! 	  {fprintf(stderr,"IS SomeArgs overrun!\n");} \
! 	XtSetArg( SomeArgs[SomeArgsi], name,  value ); ++SomeArgsi;
          ;
  
  /*--Create a shell to contain the Icon window. */
--- 262,270 ----
  	Widget		Icon_Core;
  
  #define LCLARG(name,value) \
! 	DEBUG_ERROR( SomeArgsi >= XtNumber(SomeArgs), \
! 		     "IS SomeArgs overrun!\n" ); \
! 	XtSetArg( SomeArgs[SomeArgsi], name,  (XtArgVal)value ); ++SomeArgsi;
          ;
  
  /*--Create a shell to contain the Icon window. */
*** ../dragon/main.c	Tue May 23 00:04:03 1989
--- main.c	Mon May 22 23:55:43 1989
***************
*** 38,57 ****
       XtRString, (caddr_t)default}
  #define INT(name,class,field,default) \
      {name, class, XtRInt, sizeof(int), offset(field), XtRInt, (caddr_t)default}
  #define STRING(name,class,field,default) \
      {name, class, XtRString, sizeof(String), offset(field), XtRString, \
       (caddr_t)default}
  
  static XtResource dragon_resources[] = {
    CURSOR ( "cursor",        XtCCursor,       Cursor,	         "hand2"     ),
    BOOLEAN( "debug",	    "Debug",	     Debug,		 &def_FALSE  ),
    INT    ( "doubleClick",   "DoubleClick",   Double_Click_Time,  &def_DCTime ),
!   STRING ( XtNgeometry,     XtCGeometry,     Geometry,		 "444x339"   ),
    STRING ( "iconGeometry",  "IconGeometry",  Icon_Geometry,      "64x64"     ),
    BOOLEAN( "iconic",        "Iconic",        Iconic,             &def_FALSE  ),
    STRING ( XtNiconName,	    XtCIconName,     Icon_Name,		 NULL 	     ),
    BOOLEAN( XtNreverseVideo, XtCReverseVideo, Reverse_Video,      &def_FALSE  ),
!   BOOLEAN( "tileShadows",   "TileShadows",   Tile_Shadows,	 &def_TRUE  ),
    STRING ( "tileSides",	    "TileSides",     Tile_Sides,	 "gray"	     ),
  };
  
--- 38,65 ----
       XtRString, (caddr_t)default}
  #define INT(name,class,field,default) \
      {name, class, XtRInt, sizeof(int), offset(field), XtRInt, (caddr_t)default}
+ #define PIXEL(name,class,field,default) \
+     {name, class, XtRPixel, sizeof(Pixel), \
+      offset(field), XtRString, (caddr_t)default}
  #define STRING(name,class,field,default) \
      {name, class, XtRString, sizeof(String), offset(field), XtRString, \
       (caddr_t)default}
  
  static XtResource dragon_resources[] = {
+   PIXEL  ( XtNbackground,   XtCBackground,   Background,
+ 	   XtExtdefaultbackground ),
    CURSOR ( "cursor",        XtCCursor,       Cursor,	         "hand2"     ),
    BOOLEAN( "debug",	    "Debug",	     Debug,		 &def_FALSE  ),
    INT    ( "doubleClick",   "DoubleClick",   Double_Click_Time,  &def_DCTime ),
!   PIXEL  ( XtNforeground,   XtCForeground,   Foreground,
! 	   XtExtdefaultforeground ),
!   STRING ( XtNgeometry,     XtCGeometry,     Geometry,		 "450x340"   ),
    STRING ( "iconGeometry",  "IconGeometry",  Icon_Geometry,      "64x64"     ),
    BOOLEAN( "iconic",        "Iconic",        Iconic,             &def_FALSE  ),
    STRING ( XtNiconName,	    XtCIconName,     Icon_Name,		 NULL 	     ),
    BOOLEAN( XtNreverseVideo, XtCReverseVideo, Reverse_Video,      &def_FALSE  ),
!   BOOLEAN( "stickyTile",    "StickyTile",    Sticky_Tile,	 &def_TRUE   ),
!   BOOLEAN( "tileShadows",   "TileShadows",   Tile_Shadows,	 &def_TRUE   ),
    STRING ( "tileSides",	    "TileSides",     Tile_Sides,	 "gray"	     ),
  };
  
***************
*** 80,85 ****
--- 88,95 ----
  {"-shadows",	 ".tileShadows",     XrmoptionNoArg,   (caddr_t)"off"  },
  {"+shadows",	 ".tileShadows",     XrmoptionNoArg,   (caddr_t)"on" },
  {"-sides",	 ".tileSides",	     XrmoptionSepArg,  (caddr_t)"line"},
+ {"-sticky",	 ".stickyTile",      XrmoptionNoArg,   (caddr_t)"off" },
+ {"+sticky",	 ".stickyTile",      XrmoptionNoArg,   (caddr_t)"on" },
  };
  
  typedef struct {
***************
*** 100,105 ****
--- 110,116 ----
  {"-/+reverse",		 "turn on/off reverse video"},
  {"-/+shadows",		 "turn on/off tile shadows"},
  {"-sides line/black/gray","set the style for tile sides"},
+ {"-/+sticky",		 "first tile selected sticky"},
  { NULL, NULL }
  };
  
***************
*** 157,195 ****
  } /* Command_Line_Help */
  
  
- Pixmap XCreateTile( display, d, data, width, height )
-      Display	    *display;
-      Drawable	     d;
-      char	    *data;
-      unsigned int    width, height;
- /******************************************************************************
- * Converted form of XCreatePixmapFromBitmapData.  Use our GC and don't bother
- * the Server for another one.
- ******************************************************************************/
- {
-     XImage ximage;
-     Pixmap pix;
- 
-     pix = XCreatePixmap( display, d, width, height, 1 );
-     if (pix == (Pixmap)0) return (Pixmap)0;
- 
-     ximage.height = height;
-     ximage.width = width;
-     ximage.depth = 1;
-     ximage.xoffset = 0;
-     ximage.format = XYBitmap;
-     ximage.data = data;
-     ximage.byte_order = LSBFirst;
-     ximage.bitmap_unit = 8;
-     ximage.bitmap_bit_order = LSBFirst;
-     ximage.bitmap_pad = 8;
-     ximage.bytes_per_line = (width+7)/8;
- 
-     XPutImage( display, pix, Normal_GC, &ximage, 0, 0, 0, 0, width, height );
-     return pix;
- } /* XCreateTile */
- 
- 
  static void GC_Setup()
  /******************************************************************************
  * Set up the GC's that we will be using for drawing.
--- 168,173 ----
***************
*** 198,208 ****
      XGCValues	gcv;
      Pixel	pix;
  
! /*--Xor_GC - fg = black, bg = white, func = xor */
  
      gcv.function = GXxor;
!     gcv.foreground = BlackPixelOfScreen(XtScreen(Dragon));
!     gcv.background = WhitePixelOfScreen(XtScreen(Dragon));
      Xor_GC = XtGetGC( Dragon,
  		      GCFunction|GCForeground|GCBackground,
  		      &gcv );
--- 176,187 ----
      XGCValues	gcv;
      Pixel	pix;
  
! /*--Xor_GC - fg = black, bg = white, func = xor; flops colors between the
!  *  foreground and the background when applied. */
  
      gcv.function = GXxor;
!     gcv.foreground = Dragon_Resources.Foreground ^ Dragon_Resources.Background;
!     gcv.background = (Pixel)0;	/* pixel value with all bits "off" */
      Xor_GC = XtGetGC( Dragon,
  		      GCFunction|GCForeground|GCBackground,
  		      &gcv );
***************
*** 210,227 ****
  /*--Normal_GC - fg = black, bg = white, func = copy */
  
      gcv.function = GXcopy;
!     if (Dragon_Resources.Reverse_Video) {
! 	gcv.background = BlackPixelOfScreen(XtScreen(Dragon));
! 	gcv.foreground = WhitePixelOfScreen(XtScreen(Dragon));
!     }
      Normal_GC = XtGetGC( Dragon, GCFunction|GCForeground|GCBackground, &gcv );
  
  /*--Gray_GC - fg = black, bg = white, func = copy, tile = Gray */
  
!     gcv.tile = XCreateTile( XtDisplay(Board), XtWindow(Board),
! 			    gray_bits, gray_width, gray_height );
!     if (gcv.tile == None) {
! 	fprintf( stderr, "Can't allocate gray pixmap.\n" );
  	exit(1);
      }
      gcv.fill_style = FillTiled;
--- 189,208 ----
  /*--Normal_GC - fg = black, bg = white, func = copy */
  
      gcv.function = GXcopy;
!     gcv.foreground = Dragon_Resources.Foreground;
!     gcv.background = Dragon_Resources.Background;
      Normal_GC = XtGetGC( Dragon, GCFunction|GCForeground|GCBackground, &gcv );
  
  /*--Gray_GC - fg = black, bg = white, func = copy, tile = Gray */
  
!     gcv.tile =
!       XCreatePixmapFromBitmapData
! 	( XtDisplay(Board), XtWindow(Board),
! 	  gray_bits, gray_width, gray_height,
! 	  Dragon_Resources.Foreground, Dragon_Resources.Background,
! 	  DefaultDepthOfScreen(XtScreen(Board)) );
!     if (gcv.tile == (Pixmap)0L) {
! 	(void)fprintf( stderr, "Can't allocate gray pixmap.\n" );
  	exit(1);
      }
      gcv.fill_style = FillTiled;
***************
*** 229,259 ****
  		       GCFunction|GCForeground|GCBackground|GCTile|GCFillStyle,
  		       &gcv );
  
! /*--Over_GC - fg = black, bg = white, func = or */
  
!     if (Dragon_Resources.Reverse_Video) {
! 	gcv.function = GXand;
!     } else {
! 	gcv.function = GXor;
!     }
!     gcv.tile =
!       XCreateTile( XtDisplay(Board), XtWindow(Board),
! 		   shadow_bits, shadow_width, shadow_height );
!     if (gcv.tile == None) {
! 	fprintf( stderr, "Can't allocate shadow pixmap.\n" );
  	exit(1);
      }
!     gcv.fill_style = FillTiled;
      Over_GC = XtGetGC( Dragon,
! 		       GCFunction|GCForeground|GCBackground|GCTile|GCFillStyle,
  		       &gcv );
  
  /*--Reverse_GC - fg = white, bg = black, func = copy */
  
      gcv.function = GXcopy;
!     pix = gcv.background;
!     gcv.background = gcv.foreground;
!     gcv.foreground = pix;
      Reverse_GC = XtGetGC( Dragon, GCFunction|GCForeground|GCBackground, &gcv );
  
  } /* GC_Setup */
--- 210,237 ----
  		       GCFunction|GCForeground|GCBackground|GCTile|GCFillStyle,
  		       &gcv );
  
! /*--Over_GC - fg = black xor white, bg = 0, func = copy */
  
!     gcv.function = GXcopy;
!     gcv.stipple =		/* stipple operations are always depth 1 */
!       XCreateBitmapFromData
! 	( XtDisplay(Board), XtWindow(Board),
! 	  shadow_bits, shadow_width, shadow_height );
!     if (gcv.stipple == (Pixmap)0L) {
! 	(void)fprintf( stderr, "Can't allocate shadow pixmap.\n" );
  	exit(1);
      }
!     gcv.fill_style = FillStippled;
      Over_GC = XtGetGC( Dragon,
! 		       GCFunction|GCForeground|GCBackground|
! 		          GCStipple|GCFillStyle,
  		       &gcv );
  
  /*--Reverse_GC - fg = white, bg = black, func = copy */
  
      gcv.function = GXcopy;
!     gcv.background = Dragon_Resources.Foreground;
!     gcv.foreground = Dragon_Resources.Background;
      Reverse_GC = XtGetGC( Dragon, GCFunction|GCForeground|GCBackground, &gcv );
  
  } /* GC_Setup */
***************
*** 271,278 ****
  
  #undef SETARG
  #define SETARG(name,value) \
!     if (argi >= XtNumber(args)) {fprintf(stderr,"main, args overrun!\n");} \
!     XtSetArg( args[argi], name,  value ); ++argi;
  
  /*--Start up the toolkit.  This creates a shell widget.  Unfortunately the
   *  only way the toolkit allows you to specify default application resources
--- 249,256 ----
  
  #undef SETARG
  #define SETARG(name,value) \
!     DEBUG_ERROR(argi >= XtNumber(args), "main, args overrun!\n" ); \
!     XtSetArg( args[argi], name,  (XtArgVal)value ); ++argi;
  
  /*--Start up the toolkit.  This creates a shell widget.  Unfortunately the
   *  only way the toolkit allows you to specify default application resources
***************
*** 323,335 ****
      SETARG( XtNmaxAspectX,	1333 );
      SETARG( XtNmaxAspectY,	1000 );
      SETARG( XtNgeometry,	Dragon_Resources.Geometry );
!     if (Dragon_Resources.Reverse_Video) {
! 	SETARG( XtNbackground, BlackPixelOfScreen(XtScreen(Dragon)) );
! 	SETARG( XtNforeground, WhitePixelOfScreen(XtScreen(Dragon)) );
!     } else {
! 	SETARG( XtNforeground, BlackPixelOfScreen(XtScreen(Dragon)) );
! 	SETARG( XtNbackground, WhitePixelOfScreen(XtScreen(Dragon)) );
!     }
  
      SETARG( XtNallowShellResize, TRUE );
      SETARG( XtNinput,		 TRUE );
--- 301,308 ----
      SETARG( XtNmaxAspectX,	1333 );
      SETARG( XtNmaxAspectY,	1000 );
      SETARG( XtNgeometry,	Dragon_Resources.Geometry );
!     SETARG( XtNforeground, Dragon_Resources.Foreground );
!     SETARG( XtNbackground, Dragon_Resources.Background );
  
      SETARG( XtNallowShellResize, TRUE );
      SETARG( XtNinput,		 TRUE );
***************
*** 352,358 ****
      } else if (strcmp( Dragon_Resources.Tile_Sides, "gray" ) == 0) {
  	Tile_Control |= BLACKSIDE | GRAYSIDE;
      } else if (strcmp( Dragon_Resources.Tile_Sides, "line" ) != 0) {
! 	fprintf(stderr,"-side option not given line, gray, or black value.\n");
      }
  
  /*--Create the board that we will be using; realize it too. */
--- 325,332 ----
      } else if (strcmp( Dragon_Resources.Tile_Sides, "gray" ) == 0) {
  	Tile_Control |= BLACKSIDE | GRAYSIDE;
      } else if (strcmp( Dragon_Resources.Tile_Sides, "line" ) != 0) {
! 	(void)fprintf( stderr,
! 		       "-side option not given line, gray, or black value.\n");
      }
  
  /*--Create the board that we will be using; realize it too. */
***************
*** 368,378 ****
  /*--Now make it all appear in front of the user. */
  
      {	Pixmap	pix;
! 	pix = XCreateTile( XtDisplay(Board), XtWindow(Board),
! 			   background_bits, background_width,
! 			   background_height);
! 	if (pix == None) {
! 	    fprintf( stderr, "Can't allocate background pixmap.\n" );
  	    exit(1);
  	}
  	XSetWindowBackgroundPixmap( XtDisplay(Board), XtWindow(Board), pix );
--- 342,356 ----
  /*--Now make it all appear in front of the user. */
  
      {	Pixmap	pix;
! 	pix =
! 	  XCreatePixmapFromBitmapData
! 	    ( XtDisplay(Board), XtWindow(Board),
! 	      background_bits, background_width, background_height,
! 	      Dragon_Resources.Foreground, Dragon_Resources.Background,
! 	      DefaultDepthOfScreen(XtScreen(Board)) );
! 					  
! 	if (pix == (Pixmap)0L) {
! 	    (void)fprintf( stderr, "Can't allocate background pixmap.\n" );
  	    exit(1);
  	}
  	XSetWindowBackgroundPixmap( XtDisplay(Board), XtWindow(Board), pix );
***************
*** 384,399 ****
      XtMainLoop();
  
  } /* main */
- 
- #if 0
- */* print out the name of a widget; NOTE: no \n printed so printout is not
- * * flushed until our caller does one. */
- *
- *void spit(w)
- *     Widget	w;
- *{
- *    if (w == NULL) return;
- *    spit( w->core.parent );
- *    fprintf( stderr, ".%s", w->core.name );
- *}
- #endif /* 0 */
--- 362,364 ----
*** ../dragon/main.h	Tue May 23 00:04:05 1989
--- main.h	Mon May 22 23:55:44 1989
***************
*** 15,22 ****
--- 15,24 ----
  #include <X11/Simple.h>
  #include <X11/StringDefs.h>
  
+ #ifndef TRUE
  #define TRUE	1
  #define FALSE	0
+ #endif
  
  #ifdef _MAIN_C_
  #define VAR(A)		A
***************
*** 32,37 ****
--- 34,41 ----
  ******************************************************************************/
  
  typedef struct _Dragon_Resources_Rec{
+     Pixel		Foreground;		/* Default foreground color */
+     Pixel		Background;		/* Default background color */
      Cursor		Cursor;			/* Name of cursor to use */
      Boolean		Debug;			/* Debug printouts */
      int			Double_Click_Time;	/* Time (ms) between clicks */
***************
*** 40,61 ****
      Boolean		Iconic;			/* Do we start as an icon? */
      String		Icon_Name;		/* Name for the icon */
      Boolean		Reverse_Video;		/* Do all in reverse? */
      Boolean		Tile_Shadows;		/* Want shadows? */
      String		Tile_Sides;		/* What side type? */
  } Dragon_Resources_Rec, *Dragon_Resources_Ptr;
  
  #define DEBUG_CALL(Name) \
    if (Dragon_Resources.Debug) { \
!     fprintf( stderr, "Name call\n" ); fflush(stderr); \
    }
  #define DEBUG_RETURN(Name) \
    if (Dragon_Resources.Debug) { \
!     fprintf( stderr, "Name return\n" ); fflush(stderr); \
    }
  #define DEBUG_OTHER(Name,Other) \
    if (Dragon_Resources.Debug) { \
!     fprintf( stderr, "Name Other\n" ); fflush(stderr); \
    }
  
  /******************************************************************************
  * Bitmap/Image Initialization Structure
--- 44,75 ----
      Boolean		Iconic;			/* Do we start as an icon? */
      String		Icon_Name;		/* Name for the icon */
      Boolean		Reverse_Video;		/* Do all in reverse? */
+     Boolean		Sticky_Tile;		/* Is first tile sticky? */
      Boolean		Tile_Shadows;		/* Want shadows? */
      String		Tile_Sides;		/* What side type? */
  } Dragon_Resources_Rec, *Dragon_Resources_Ptr;
  
+ #ifdef WANTDEBUG
  #define DEBUG_CALL(Name) \
    if (Dragon_Resources.Debug) { \
!     (void)fprintf( stderr, "Name call\n" ); (void)fflush(stderr); \
    }
  #define DEBUG_RETURN(Name) \
    if (Dragon_Resources.Debug) { \
!     (void)fprintf( stderr, "Name return\n" ); (void)fflush(stderr); \
    }
  #define DEBUG_OTHER(Name,Other) \
    if (Dragon_Resources.Debug) { \
!     (void)fprintf( stderr, "Name Other\n" ); (void)fflush(stderr); \
    }
+ #define DEBUG_ERROR(Test,Msg) \
+   if (Test) { (void)fprintf(stderr,Msg); (void)fflush(stderr); }
+ #else
+ #define DEBUG_CALL(Name)
+ #define DEBUG_RETURN(Name)
+ #define DEBUG_OTHER(Name,Other)
+ #define DEBUG_ERROR(Test,Msg)
+ #endif /* WANTDEBUG */
  
  /******************************************************************************
  * Bitmap/Image Initialization Structure
***************
*** 96,98 ****
--- 110,116 ----
  VAR( GC			   Over_GC );		/* fg=blk, bg=wht, fcn=or */
  VAR( GC			   Reverse_GC );	/* fg=wht, bg=blk, fcn=copy */
  VAR( GC			   Xor_GC );		/* fg=blk, bg=wht, fcn=xor */
+ 
+ #undef VAR
+ #undef VARI
+ 
*** ../dragon/tile.c	Tue May 23 00:03:57 1989
--- tile.c	Mon May 22 23:55:46 1989
***************
*** 122,129 ****
  /*--Make sure that our caller is rational. */
  
      if (size < 1 || size > 5) {
! 	fprintf( stderr, "Bad size given to Configure_Tiles in tile.c [%d].\n",
! 		 size );
  	size = 1;
      }
  
--- 122,130 ----
  /*--Make sure that our caller is rational. */
  
      if (size < 1 || size > 5) {
! 	(void)fprintf( stderr,
! 		       "Bad size given to Configure_Tiles in tile.c [%d].\n",
! 		       size );
  	size = 1;
      }
  
***************
*** 201,207 ****
  * Called to draw the number in the upper right corner of a numbered tile.
  ******************************************************************************/
  {
!     XPutImage( XtDisplay(Board), XtWindow(Board), Over_GC, image,
  	       0, 0, x + Number_X, y + Number_Y,
  	       (unsigned int)image->width, (unsigned int)image->height );
  } /* Draw_Number */
--- 202,208 ----
  * Called to draw the number in the upper right corner of a numbered tile.
  ******************************************************************************/
  {
!     XPutImage( XtDisplay(Board), XtWindow(Board), Xor_GC, image,
  	       0, 0, x + Number_X, y + Number_Y,
  	       (unsigned int)image->width, (unsigned int)image->height );
  } /* Draw_Number */
No differences encountered



More information about the Comp.sources.x mailing list