need help with pw_copy
David England
de%COMP.LANCS.AC.UK at cunyvm.cuny.edu
Tue Mar 14 04:45:24 AEST 1989
I don't think you can pw_copy into a canvas pixrect - isn't it just a
pointer with no memory allocated. Anyway, here's a program I gave to a
student who was having similar probelms. It draws a line, then copies the
canvas into a memory pirext and clears the canvas. Finally it copies back
the saved pixrect.
Dave
de at comp.lancs.ac.uk
#include <stdio.h>
#include <suntool/sunview.h>
#include <suntool/canvas.h>
#include <suntool/panel.h>
#include <pixrect/pixrect_hs.h
/* Compile with cc -g test.c -lsuntool -lsunwindow -lpixrect */
Pixwin *pw;
static struct pixrect *pr;
drawline()
{
pw_vector(pw, 0, 0, 50, 50, PIX_SRC, 1);
}
clear()
{
pw_read(pr,0, 0, 100, 100, PIX_SRC, pw, 0, 0);
pw_writebackground(pw, 0, 0, 100, 100, PIX_CLR );
}
redraw()
{
pw_write(pw,0, 0 ,100, 100, PIX_SRC, pr, 0, 0);
}
main()
{
Frame myframe;
Panel mypan;
Panel_item clearit, line, copyit;
Canvas mycan;
pr = mem_create(200,200,1);
myframe = window_create(NULL, FRAME,
0);
mypan = window_create(myframe,PANEL,
WIN_ROWS, 2,
WIN_COLUMNS, 20,
0);
line = panel_create_item(mypan, PANEL_BUTTON,
PANEL_LABEL_STRING, "line",
PANEL_NOTIFY_PROC, drawline,
0);
clearit = panel_create_item(mypan, PANEL_BUTTON,
PANEL_LABEL_STRING, "Clear",
PANEL_NOTIFY_PROC, clear,
0);
copyit = panel_create_item(mypan, PANEL_BUTTON,
PANEL_LABEL_STRING, "Redraw",
PANEL_NOTIFY_PROC, redraw,
0);
mycan = window_create(myframe, CANVAS,
WIN_HEIGHT, 100,
WIN_WIDTH ,100,
CANVAS_RETAINED, TRUE,
0);
pw = canvas_pixwin(mycan);
window_fit_width(myframe);
window_main_loop(myframe);
}
More information about the Comp.sys.sun
mailing list