home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
pocketbk
/
pictures
/
picdraw1
/
PICDRAW.OPL
< prev
next >
Wrap
Text File
|
1993-01-12
|
13KB
|
699 lines
app PicDraw
type 2
path "\opd"
ext "pic"
icon "\opd\picdraw.pic"
enda
proc PicDraw:
global PDrName$(128)
global menu$(20)
rem For GetEvent
global a%(6)
rem Coordinates of icon and cursor
global orgx%, orgy%, height%, width%
global curx%, cury%, pos%
global copybx%,copyby%,copyex%,copyey%
global wId%, statId%,copyId%
global stMode%,stCut%
gSetWin 0,0,180,80
Screen 30,9,1,1
menu$ = "OSRNXCVPABWYMDLITHZ"
PDrName$=Cmd$(2)
rem Default values
wId%=0 :statId%=0 :stMode%=3 :pos%=1
width%=24 : height%=24
DrawStat:(1)
if DoFile:(Cmd$(3)) = 1
rem Inicialization of Icon window
DrawWin:(24,24)
endif
do
ReadKey:
until 0
endp
proc DoFile:(t$) :rem Create or Open File
if t$="C"
NewIcon:
return 1
elseif t$="O"
OpenIcon:
return 0
elseif t$="X"
SaveIcon:
return 1
endif
if Err
Cls : Print Err$(Err)
Get : Stop
endif
PutName:(PDrName$)
endp
proc ReadKey:
local k%,mod%,a$(5),t$(1)
GetEvent a%()
if a%(1)=$404
PDrName$=GetCmd$
t$=Left$(PDrName$, 1)
PDrName$=Mid$(PDrName$,2,128)
if t$="X"
SaveIcon:
Stop
elseif t$="C" or t$="O"
DoFile:(t$)
endif
endif
mod%=a%(2) and $00ff
if a%(1)=$122
mInit
mCard "File","New Icon",%N,"Open Icon",%O,"Save Icon",%S,"Merge Icon",%R,"Exit",%X
mCard "Modes","Move",%M,"Draw",%D,"Clear",%L,"Invert",%I
mCard "Region","Copy",%C,"Cut",%V,"Paste",%P
mCard "Scroll","Insert Row",%A,"Insert Column",%B,"Delete Row",%W,"Delete Column",%Y
mCard "Text","Add Text...",%T
mCard "Settings","Change Settings...",%H,"Zoom",%Z
k%=menu
if k% and intf(loc(menu$, chr$(k%)))
a$="proc"+chr$(k%)
if @(a$): = 0
return k%
endif
endif
elseif a%(1) and $200
k%=(a%(1)-$200)
k%=loc(menu$, chr$(k%))
if k%
a$="proc"+mid$(menu$,k%,1)
if @(a$): = 0
return k%
endif
else
giPrint "Unknown option "+chr$(2)+"-"+chr$(a%(1))
endif
elseif a%(1)=27 : rem clear on/off
if stMode% < 4
procl:
endif
elseif a%(1)=32 : rem plot pixel
PutPixel:(0)
elseif a%(1)=8 : rem clear pixel
PutPixel:(1)
elseif a%(1)=9 : rem invert pixel
PutPixel:(2)
elseif a%(1)=13 : rem draw on/off
if stMode% < 4
procd:
else : rem selected a region to copy
copyex%=curx%+1
copyey%=cury%+1
CopyIcon:
gIPrint "Copied"
stMode%=3
DrawStat:(0)
endif
elseif (a%(1)=261) :rem pgdn
cury%=height%-1
DrawCur:
elseif (a%(1)=260):rem pgup
cury%=0
DrawCur:
elseif (a%(1)=262) :rem home
curx%=0
DrawCur:
elseif (a%(1)=263) :rem end
curx%=width%-1
DrawCur:
elseif a%(1)=258 and (mod% and 4)
curx%=curx%+4
if curx% > width% - 1
curx%=0
endif
DrawCur:
elseif a%(1)=259 and (mod% and 4)
curx%=curx%-4
if curx% < 0
curx% = width%-1
endif
DrawCur:
elseif a%(1)=257 and (mod% and 4)
cury%=cury%+4
if cury% > height% - 1
cury%=0
endif
DrawCur:
elseif a%(1)=256 and (mod% and 4)
cury%=cury%-4
if cury% < 0
cury%=height%-1
endif
DrawCur:
elseif a%(1)=258
if curx% < width% - 1
curx%=curx%+1
else curx%=0
endif
DrawCur:
elseif a%(1)=259
if curx% > 0
curx%=curx%-1
else curx% = width%-1
endif
DrawCur:
elseif a%(1)=257
if cury% < height% - 1
cury%=cury%+1
else cury%=0
endif
DrawCur:
elseif a%(1)=256
if cury% > 0
cury%=cury%-1
else cury%=height%-1
endif
DrawCur:
elseif a%(1)=291
ShowHelp:
endif
return a%(1)
endp
proc PutPixel:(mode%)
if stMode% < 4
gGMode mode%
gLineBy 0,0
if stMode%<>3
gGMode stMode%
endif
endif
endp
proc DrawCur:
gUpdate Off
gUse statId%
gAt 6,60
gPrintB gen$(curx%,3)+gen$(cury%,-3),48,3,1,1,1
gUse wId%
gAt curx%,cury%
if stMode%<3
gGMode stMode%
gLineBy 0,0
endif
gUpdate On
endp
proc DrawWin:(wx%,wy%)
if wx% > 178 or wy% > 78
raise -2
endif
gUpdate Off
width%=wx% : height%=wy%
if pos%=1 : rem centred
orgx%=(180-wx%)/2
orgy%= (80-wy%)/2
else : rem top left
orgx%=1 : orgy%=2
endif
gUse 1
gOrder 1,1
gCls
gAt orgx%-1,orgy%-1
gGMode 0
gBox width%+2,height%+2
if wId% <> 0
gClose wId%
endif
wId% = gCreate(orgx%,orgy%,width%,height%,1)
gOrder wId%,1
gUse wId%
Cursor wId%,0,1,1
DrawCur:
endp
proc DrawStat:(mode%)
local s$(6),tempid%,fname$(128)
gUpdate Off
if mode%=1 : rem New Status Window
fname$="\app\picdraw.pic"
if exist(fname$)
tempid%=gLoadBit(fname$,0)
else
fname$="\opd\picdraw.pic"
if exist(fname$)
tempid%=gLoadBit(fname$,0)
else
tempid%=gCreateBit(24,24)
gCls
gAt 0,12
gPrintB "Pic",24,3
gAt 0,20
gPrintB "Draw",24,3
endif
endif
if statId% <> 0
gClose statId%
endif
statId%=gCreate(181,0,59,80,1)
gBorder 0
gFont 1
gStyle 4
gAt 18,12
gCopy tempid%,0,0,24,24,3
gClose tempid%
endif
vector stMode%+1
lab1,lab2,lab3,lab4
lab5
endv
s$="None"
goto labx
lab1::
s$="Draw"
goto labx
lab2::
s$="Clear"
goto labx
lab3::
s$="Invert"
goto labx
lab4::
s$="Move"
goto labx
lab5::
s$="Select"
labx::
gUse statId%
gAt 6,72
gPrintB s$,48,3,1,1,1
if wId%<>0
gUse wId%
endif
gUpdate On
endp
proc ShowHelp:
start::
dInit
dText "","Help: PicDraw",$302
dText "","þMovement",$500
dText "","þModes",$500
dText "","þRegions",$500
dText "","þScrolling",$500
dText "","þText",$500
dText "","þAbout",$500
vector dialog-1
lab1,lab2,lab3,lab4,lab5
lab6
endv
return 1
lab1::
dInit
dText "","Help: Movement",$302
dText "","Use cursor keys to move around; if you"
dText "","press Control, cursor moves faster."
dText "","Space plots a pixel, Delete clears a pixel."
dText "","Tab inverts the pixel at the cursor."
goto labx
lab2::
dInit
dText "","Help: Modes",$302
dText "","Enter toggles the ""Draw"" mode, Esc"
dText "","toggles the ""Clear"" mode."
dText "","Psion-I toggles the ""Invert"" mode; this"
dText "","is useful for some special effects."
dText "","Press Psion-M to restore ""Move"" mode."
dText "","The mode affects ""Paste"" and ""Merge Icon""."
goto labx
lab3::
dInit
dText "","Help: Regions",$302
dText "","Selecting ""Copy"" or ""Cut"" enters ""Select"""
dText "","mode; current cursor position is top left,"
dText "","move cursor to bottom right, press Enter"
dText "","to select region to copy. ""Paste"" puts the"
dText "","the selected region on the curr. position."
dText "","""Cut"" also clears the original region."
goto labx
lab4::
dInit
dText "","Help: Scrolling",$302
dText "","Scrolling takes effect from the current"
dText "","position; ""Insert Row"" moves down, ""Insert"
dText "","Column"" moves right, ""Delete Row"""
dText "","moves up and ""Delete Column"" moves left."
goto labx
lab5::
dInit
dText "","Help: Text",$302
dText "","Text is inserted at the current position,"
dText "","and the cursor moves to the right of the"
dText "","inserted text. Type the text in the"
dText "","dialog box and select font, style and"
dText "","mode (overwrite, clear or invert)."
dText "","Text is not reeditable; you must retype it."
goto labx
lab6::
dInit
dText "","About PicDraw v. 1.0",$302
dText "", "(c) 1993 by Lu¡s Miguel Sequeira",2
dText "", "(bc@fccn01.fccn.pt)",2
dText "", " "
dText "", "This program is freeware;",2
dText "", "feel free to copy and give it away!",2
labx::
if dialog=0
goto start
endif
return 1
endp
proc NewIcon:
if wId% <> 0
gUse wId%
gCls
endif
curx%=0 :cury%=0
endp
proc procn: rem New Icon
Lock On
dInit "New Icon"
dButtons "No",%N,"Yes",%Y
if dialog = %y
NewIcon:
endif
Lock Off
return 1
endp
proc OpenIcon:
local tempId%,th%,tw%
if exist(PDrName$)
Busy "Loading..."
PutName:(PDrName$)
tempId%=gLoadBit(PDrName$)
else
tempId%=gCreateBit(width%,height%)
endif
curx%=0 :cury%=0
th%=min(gHeight,78) :tw%=min(gWidth,178)
Dra