Article View: comp.sys.sun
Article #11475Re: need help with pw_copy
From: David England
Date: Mon, 13 Mar 1989 18:45
Date: Mon, 13 Mar 1989 18:45
87 lines
2663 bytes
2663 bytes
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@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);
}
Technical Details
Message-ID:
<11663.8903091051@dcl-jupiter.comp.lancs.ac.uk>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-requestShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: de%COMP.LANCS.AC.UK@cunyvm.cuny.edu (David England) Newsgroups: comp.sys.sun Subject: Re: need help with pw_copy Keywords: Windows Message-ID: <11663.8903091051@dcl-jupiter.comp.lancs.ac.uk> Date: 13 Mar 89 18:45:24 GMT Sender: usenet@rice.edu Organization: Sun-Spots Lines: 87 Approved: Sun-Spots@rice.edu Original-Date: Thu, 9 Mar 89 10:51:21 GMT X-Sun-Spots-Digest: Volume 7, Issue 194, message 4 of 15