home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
x
/
volume8
/
xfig2.8
/
part03
/
grid.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-07-02
|
4KB
|
116 lines
/*
* FIG : Facility for Interactive Generation of figures
*
* Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
* January 1985.
* 1st revision : Aug 1985.
*
* %W% %G%
*/
#include "fig.h"
#include "resources.h"
#include "const.h"
#include "func.h"
#include "paintop.h"
static int cur_grid = -1;
extern int CANVAS_WIDTH, CANVAS_HEIGHT;
extern appresStruct appres;
#define null_width 32
#define null_height 32
static char null_bits[null_width * null_height / 8] = { 0 };
#define quarter_width 20
#define quarter_height 20
static char quarter_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x42, 0x08};
#define half_width 40
#define half_height 40
static char half_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0x42, 0x08, 0x21, 0x84};
#define half_cm_width 15
#define half_cm_height 15
static char half_cm_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x42, 0x00, 0x00};
static Pixmap null_pm, quarter_pm, half_pm, half_cm_pm;
init_grid()
{
unsigned long bg, fg;
Arg tmp_arg[3];
XtSetArg(tmp_arg[0], XtNbackground, &bg);
XtSetArg(tmp_arg[1], XtNforeground, &fg);
XtGetValues(canvas_sw, tmp_arg, 2);
null_pm = XCreatePixmapFromBitmapData(tool_d, canvas_win,
null_bits, null_width, null_height,
fg, bg, DefaultDepthOfScreen(tool_s));
quarter_pm = XCreatePixmapFromBitmapData(tool_d, canvas_win,
quarter_bits, quarter_width, quarter_height,
fg, bg, DefaultDepthOfScreen(tool_s));
half_pm = XCreatePixmapFromBitmapData(tool_d, canvas_win,
half_bits, half_width, half_height,
fg, bg, DefaultDepthOfScreen(tool_s));
half_cm_pm = XCreatePixmapFromBitmapData(tool_d, canvas_win,
half_cm_bits, half_cm_width, half_cm_height,
fg, bg, DefaultDepthOfScreen(tool_s));
}
/* grid in X11 is simply the background of the canvas */
setup_grid(grid)
int grid;
{
static Arg grid_args[] =
{
{ XtNbackgroundPixmap, (XtArgVal)NULL },
};
if (grid == cur_grid)
{
grid_args[0].value = (XtArgVal)null_pm;
grid = -1;
}
if( appres.INCHES )
{
if (grid == F_GRID1)
grid_args[0].value = (XtArgVal)quarter_pm;
else if (grid == F_GRID2)
grid_args[0].value = (XtArgVal)half_pm;
}else if (grid == F_GRID1 || grid == F_GRID2)
grid_args[0].value = (XtArgVal)half_cm_pm;
cur_grid = grid;
XtSetValues(canvas_sw, grid_args, XtNumber(grid_args));
}
redisplay_grid()
{
}