home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
utilities
/
utilsd
/
examine
/
!Examine
/
Examine
(
.txt
)
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
RISC OS BBC BASIC V Source
|
1993-04-22
|
33.7 KB
|
1,369 lines
> Examine
This is a multitasking magnifier
Copyright Erik de Kort 1993 (Read the !Help file for conditions)
Main
1 :
Make sure the WimpSlot is not too small
_Initialise
+ &2000
_ReInitialise
B :
More initialisation, but done here to make you notice it
"OS_ReadMonotonicTime"
NextTime% : TimeStep% = 4
Mask% =
(&603FF)
?
"Wimp_PollIdle",Mask%,PollBlock%,NextTime%
reason%
)
PointerInWindow%
_SetPointer
reason%
,
0 :
_NullReason(PollBlock%)
.
1 :
_RedrawWindow(PollBlock%)
,
2 :
_OpenWindow(PollBlock%)
.
3 :
_CloseWindow(!PollBlock%)
/
4 :
_PointerLeave(!PollBlock%)
/
5 :
_PointerEnter(!PollBlock%)
d
6 :
_MouseClick(PollBlock%!0,PollBlock%!4,PollBlock%!8,PollBlock%!12,PollBlock%!16)
!
7 :
_UserDragBox
/
8 :
_KeyPressed(PollBlock%!24)
/
9 :
_MenuSelection(PollBlock%)
!-
17,18 :
_UserMessage(PollBlock%)
"
#F
"OS_ReadMonotonicTime"
NextTime% : NextTime% += TimeStep%
The program should *NEVER* get here!
_CloseDown:
++++++++++ Wimp_Poll routines ++++++++++
_NullReason(block%)
DisplayOpen%
/
(drag%)
_DragWindow
0%
_UpdateWindow(UpdateWindow%)
This procedure is called as NullReason
But it is also called from RedrawWindow for the display
_UpdateWindow(SWI%)
MinX%,MaxY%
PWhandle%,Ihandle%
CWhandle%,Xoff%,Yoff%,Cflags%
more%
"WASP_PointerInfo"
PWhandle%,Ihandle%,Mx%,My%,buttons%
"WASP_CaretInfo"
CWhandle%,,Xoff%,Yoff%,Cflags%
FocusX% = Mx%
FocusY% = My%
C) :
Check if: - we follow caret AND
D0 :
- the caret is displayed AND
E/ :
- the caret is in a window
FollowCaret%
(Cflags%<>-1)
(CWhandle%<>-1)
G6
"WASP_WindowInfo",CWhandle%
MinX%,,,MaxY%
HD :
Is the pointer is inside the window with the caret ? AND
IA :
Is the pointer within the display of the window ? AND
J/ :
Has the user released all buttons ?
K. :
OR do we follow caret regardless ?
LZ
(((CWhandle% = PWhandle%)
(-1 <= Ihandle%))
AlwaysCaret%)
(buttons% = 0)
M! FocusX% = Xoff% + MinX%
N: FocusY% = Yoff% + MaxY% + ((Cflags%
&FFFF)>>1)
O
_GrabSprite(FocusX%,FocusY%,Mx%,My%)
_GetWindowInfo
U# Xoff% = Wminx% + ScaledWidth%
V$ Yoff% = Wminy% + ScaledHeight%
WG :
Updating is sort of ugly now, but it works and isn't too slow
X, :
if the magnification is reasonable
Y! buffer%!00 = DisplayHandle%
buffer%!04 = 0
buffer%!08 = -YLimit%
buffer%!12 = XLimit%
buffer%!16 = 0
SWI%,,buffer%
more%
more%
16,0
aD :
Clipping is on, so actual width and height not important
b*
Wminx%,Yoff%,XLimit%,YLimit%
c*
Xoff%,Wminy%,XLimit%,YLimit%
dM
"OS_SpriteOp",256+52,SpriteArea%,SpriteName$,Wminx%,Wminy%,,Scale%
e/
"Wimp_GetRectangle",,buffer%
more%
Open the display window
_OpenWindow(block%)
First open the window
"Wimp_OpenWindow",,block%
Next open pane on top
(!block% = DisplayHandle%)
_ReOpenPane : DisplayOpen% =
This one is called whenever the DisplayWindow is opened
The variable ShowPane% determines if the pane should be opened
_ReOpenPane :
(ShowPane%)
Dx%,Dy%,behind%
{* :
Get coordinates from main window
"WASP_WindowInfo",DisplayHandle%
Dx%,Dy%,,,,,behind%
buffer%!00 = PaneHandle%
buffer%!04 = Dx%
+ buffer%!08 = Dy% - PaneHeight% - Yos%
# buffer%!12 = Dx% + PaneWidth%
buffer%!16 = Dy% - Yos%
buffer%!20 = 0
buffer%!24 = 0
! :
Open over displaywindow
buffer%!28 = behind%
"Wimp_OpenWindow",,buffer%
Reopen a window (either where it was, or where indicated)
_ReOpenWindow(handle%,where%)
= buffer%!0 = handle% :
"Wimp_GetWindowState",,buffer%
where% < 0
buffer%!28 = where%
_OpenWindow(buffer%)
Close a window
_CloseWindow(handle%)
"WASP_CloseWindow",handle%
handle% = DisplayHandle%
)
"WASP_CloseWindow",PaneHandle%
DisplayOpen% =
Standard window redraw except for the display
_RedrawWindow(block%)
block%!0 = DisplayHandle%
_UpdateWindow(RedrawWindow%)
(
RedrawWindow%,,block%
more%
more%
0
"Wimp_GetRectangle",,block%
more%
Restore the pointer to it's normal state
_PointerLeave(handle%)
handle%=DisplayHandle%
PointerInWindow% =
Pointer% = 0
_SetPointer
In the display area, I want to change the pointer
_PointerEnter(handle%)
handle%=DisplayHandle%
PointerInWindow% =
_SetPointer
Mouseclicks
_MouseClick(Mx%,My%,Buttons%,Window%,Icon%)
SelAdj%,Update%
Update% =
Buttons%
Select% : SelAdj% = 1
Adjust% : SelAdj% = -1
: SelAdj% = 0
Window%
-2 :
Iconbar
Buttons%
O
Select%,Adjust% :
_ReOpenWindow(DisplayHandle%,Buttons%=Select%)
L
Menu% :
CreateMenu(MenuHandle%,Mx%-64,96+44*7+24*2)
DisplayHandle%
(Buttons%
&F0)
drag% = PreDrag%
E
"WASP_WindowInfo",DisplayHandle%
,,,,,,BehindWindow%
:
7 :
Store pointerposition relative to edges
; RelMx1% = Wminx% - Mx% : RelMy1% = Wminy% - My%
; RelMx2% = Wmaxx% - Mx% : RelMy2% = Wmaxy% - My%
:
@
_InitiateDrag(DisplayHandle%,7,0,0,XLimit%,YLimit%)
:
Q :
Next I might receive a dragevent, therefore store info on pointer
PreDrag% = Pointer%
Buttons%
;
Select% :
_ReOpenWindow(DisplayHandle%,-1)
@
Menu% :
CreateMenu(MenuHandle%,Mx%-64,My%-32)
PaneHandle%
5
(Buttons%
Menu%)
No menu in pane
Icon%
+
2 : scalemul% += SelAdj%
+
3 : scalediv% += SelAdj%
: Update% =
&
Update%
_ReInitialise
OptionsHandle%
Icon%
1
1 : ShowPane% =
(ShowPane%)
4
2 : ShowPointer% =
(ShowPointer%)
5
3 : CrossPointer% =
(CrossPointer%)
4
4 : FollowCaret% =
(FollowCaret%)
4
5 : AlwaysCaret% =
(AlwaysCaret%)
5
6 : BlankDisplay% =
(BlankDisplay%)
)
10 : scalemul% += SelAdj%
)
11 : scalemul% -= SelAdj%
)
12 : scalediv% += SelAdj%
)
13 : scalediv% -= SelAdj%
: Update% =
$
Update%
_ReInitialise
InfoHandle%
?
Icon% = 4
CreateMenu(MoneyHandle%,Mx%-64,My%-32)
CloseMenus
=
Icon% = 4
"WASP_OpenWindow",MoneyHandle%,
End the move/resize of the display
_UserDragBox
! :
Last call to DragWindow
_DragWindow
drag% = 0
; Pointer% = 0 :
_SetPointer :
not pretty, fast hack
The following hot-keys are implemented:
- shift-TAB : raise window with caret, and move the pointer
to the caret (as in MENON!)
_KeyPressed(key%)
handle%,windx%,windy%,scx%,scy%,Xoff%,Yoff%,Cflags%
key%
&19A :
= Shift_TAB
:
Get info on caret
<
"WASP_CaretInfo"
handle%,,Xoff%,Yoff%,Cflags%
/
(handle% <> -1)
(Cflags% <> -1)
:
1 :
Find out about window and pointer
D
"WASP_WindowInfo",handle%
windx%,,,windy%,scx%,scy%
-
"WASP_PointerInfo"
,,Mx%,My%
:
> :
Send OpenWindow (on top) message to the window
D buffer%!00 = handle% :
"Wimp_GetWindowState",,buffer%
!J buffer%!28 = -1 :
"Wimp_SendMessage",2,buffer%,handle%
:
#" :
And move the mouse
Xoff% += windx%
%6 Yoff% += windy% + ((Cflags%
&FFFF) >> 1)
&*
(Xoff%<>Mx%)
(Yoff%<>My%)
'&
Mx% > Xoff%
Mx% -= 1
(&
Mx% < Xoff%
Mx% += 1
)&
My% > Yoff%
My% -= 1
*&
My% < Yoff%
My% += 1
Mx%,My%
.%
"Wimp_ProcessKey",key%
Menus (lots of code from Jan Herman at the end of this file)
_MenuSelection(block%)
MouseX%,MouseY%,Buttons%,f%
"WASP_PointerInfo"
,,MouseX%,MouseY%,Buttons%
!block%
9>
0 :
CreateMenu(InfoHandle%,MouseX%-64,MouseY%+32)
:A
1 :
CreateMenu(OptionsHandle%,MouseX%-64,MouseY%-32)
;H
CloseMenus :
Dirty trick to get the right position
<:
"WASP_OpenWindow",OptionsHandle%,
2 :
Save Options
>. f% =
(TaskPath$+"Options")
?I
#f%,BlankDisplay%,FollowCaret%,ShowPointer%,ShowPane%
@<
#f%,Wwidth%,Wheight%,scalemul%,scalediv%
A2
#f%,AlwaysCaret%,CrossPointer%
C*
3,4 : buffer%!0 = DisplayHandle%
D4
"Wimp_GetWindowState",,buffer%
E2 buffer%!28 = -1 - (!block% = 3)
F(
_OpenWindow(buffer%)
G.
5 :
_CloseWindow(DisplayHandle%)
6 :
_CloseDown
K& :
Reopen menutree after adjust
(Buttons%
Adjust%)
CreateMenu(LastMenuHdl%,LastMenuX%,LastMenuY%)
Usermessages
_UserMessage(message%)
message%!16
0 :
_CloseDown
U*
10 :
_DeskSave(message%!20)
V#
&502 :
_Help(message%)
W!
&400C1 :
_ReInitialise
---------- Wimp_Poll routines ----------
Resizing and moving the display
_DragWindow
nx0%,nx1%,ny0%,ny1%
w%,h%
Mx%,My%,Mz%
f! :
Store window parameters
g" w% = Wwidth% : h% = Wheight%
h# nx0% = Wminx% : nx1% = Wmaxx%
i# ny0% = Wminy% : ny1% = Wmaxy%
drag%
l,
Move% : nx0% = RelMx1% + Mx%
m/ nx1% = RelMx2% + Mx%
n/ ny0% = RelMy1% + My%
o/ ny1% = RelMy2% + My%
pC
TopLeft% : nx0% = RelMx1% + Mx% : ny1% = RelMy2% + My%
qR
nx0% + (Border%*4) > nx1%
nx0% = nx1% - (Border%*4)
rR
ny0% + (Border%*4) > ny1%
ny1% = ny0% + (Border%*4)
sC
TopRight% : nx1% = RelMx2% + Mx% : ny1% = RelMy2% + My%
tR
nx0% + (Border%*4) > nx1%
nx1% = nx0% + (Border%*4)
uR
ny0% + (Border%*4) > ny1%
ny1% = ny0% + (Border%*4)
vC
BottomRight%: nx1% = RelMx2% + Mx% : ny0% = RelMy1% + My%
wR
nx0% + (Border%*4) > nx1%
nx1% = nx0% + (Border%*4)
xR
ny0% + (Border%*4) > ny1%
ny0% = ny1% - (Border%*4)
yC
BottomLeft% : nx0% = RelMx1% + Mx% : ny0% = RelMy1% + My%
zR
nx0% + (Border%*4) > nx1%
nx0% = nx1% - (Border%*4)
{R
ny0% + (Border%*4) > ny1%
ny0% = ny1% - (Border%*4)
drag%<>Move%
#
nx0% < 0
nx0% = 0
)
nx1% > XLimit%
nx1% = XLimit%
#
ny0% < 0
ny0% = 0
)
ny1% > YLimit%
ny1% = YLimit%
< Wminx% = nx0%
(Xos%-1) : Wmaxx% = nx1%
(Xos%-1)
< Wminy% = ny0%
(Xos%-1) : Wmaxy% = ny1%
(Xos%-1)
& Wwidth% = Wmaxx% - Wminx% + Xos%
& Wheight%= Wmaxy% - Wminy% + Yos%
(w%<>Wwidth%)
(h%<>Wheight%)
_InitSprite
! buffer%!00 = DisplayHandle%
buffer%!04 = Wminx%
buffer%!08 = Wminy%
buffer%!12 = Wmaxx%
buffer%!16 = Wmaxy%
buffer%!20 = 0
buffer%!24 = 0
buffer%!28 = BehindWindow%
_OpenWindow(buffer%)
++++++++++ Sprite routines ++++++++++
Try to claim the memory needed for the sprite
_InitSprite
twidth%,theight%
N :
Wimpslot expansion technique from Jan-Herman Buining (clever indeed)
_SetSpriteInfo
"XWimp_SlotSize",(
-&8000)+SpriteSize%,-1
SlotSize%
SlotSize% -= (
-&8000)
SlotSize% < &400
V
_ShowError(0,"Can't claim memory for internal sprite, must exit immediately")
_CloseDown
5 :
If there is less memory then we require ...
SlotSize% < SpriteSize%
3 :
... we will simply use a smaller sprite
C :
The (crude) method is simply to take the largest square
9 :
area that will fit inside the slot allocated.
:
: :
First calculate the square root of the maximum
:
number of OSunits
I theight% =
((SlotSize% << (3 + Xeigen% + Yeigen%) ) >> Log2BPP%)
A :
To cater for "spilled" bits, width should be adjusted
9 twidth% = theight% - ((64 >> Log2BPP%)<<Xeigen%)
4 :
Finally assign the new width and height,
( :
but only if they are smaller
= :
(Note that some memory may be unused after this!)
=
twidth%<Swidth%
Swidth% = twidth%
(Xos%-1)
=
theight%<Sheight%
Sheight% = theight%
(Yos%-1)
9 SpriteSize% = 44 +
_SpriteSize(Swidth%,Sheight%)
; :
Initialise the spritearea (use the full slotsize)
SpriteArea% =
SpriteArea%!0 = SlotSize%
SpriteArea%!8 = 16
"OS_SpriteOp",256+9,SpriteArea%
K ScaledWidth% = (Xos% + (Swidth%*scalemul%)
scalediv%)
(Xos%-1)
K ScaledHeight% = (Yos% + (Sheight%*scalemul%)
scalediv%)
(Yos%-1)
calculate all there is to know about the sprite:
- calculate bounding box of sprite ( = windowsize/scaling )
- calculate size of sprite
_SetSpriteInfo
* :
Calculate width/height of sprite
J Swidth% = (Xos% - 1 + (Wwidth% *scalediv%)
scalemul%)
(Xos%-1)
J Sheight% = (Yos% - 1 + (Wheight%*scalediv%)
scalemul%)
(Yos%-1)
* :
Sprite may not exceed screensize
Swidth% > XLimit%
Swidth% = XLimit%
Sheight%> YLimit%
Sheight%= YLimit%
+ :
Calculate areasize for the sprite
7 SpriteSize% = 44 +
_SpriteSize(Swidth%,Sheight%)
SpriteName$ = "display"
Grab sprite around (x%,y%)
_GrabSprite(x%,y%,MouseX%,MouseY%)
LOCAL LB%,BB%,RB%,TB%,R1,R2,R3
:
Calculate bounding box
- LB% = (x% - (Swidth% >> 1))
(Xos%-1)
- TB% = (y% - (Sheight%>> 1))
(Yos%-1)
RB% = LB% + Swidth%
BB% = TB% + Sheight%
4 :
Move/resize the box inside the screen area
LB%<0
RB%-=LB% : LB%=0
TB%<0
BB%-=TB% : TB%=0
RB%>XLimit%
LB%-=RB%-XLimit% : RB%=XLimit% :
LB%<0
LB%=0
BB%>YLimit%
TB%-=BB%-YLimit% : BB%=YLimit% :
TB%<0
TB%=0
And grab sprite
"OS_SpriteOp",256+16,SpriteArea%,SpriteName$,,LB%,TB%,RB%,BB%
% :
Redirect output into sprite
"OS_SpriteOp",&13C,SpriteArea%,SpriteName$,0
,R1,R2,R3
BlankDisplay%
16,0 :
Wminx%-LB%,Wminy%-TB%,Wwidth%-Xos%*2,Wheight%-Yos%*2
ShowPointer%
) :
Paint a pointer inside sprite
LB% = MouseX% - LB%
TB% = MouseY% - TB%
CrossPointer%
3,15
!
LB%-16,TB%,LB%+16,TB%
!
LB%,TB%-16,LB%,TB%+16
X
"OS_SpriteOp",&122,sparea%,"ptr"+ModeSuffix$,LB%,TB%-((31*Yos%)>>Yeigen%),3
"OS_SpriteOp",&13C,R1,R2,R3
calculate spritesize (width, height in OS units!)
_SpriteSize(width%,height%)
bits%
5 :
Worst case: The sprite covers an area using
9 :
the rightmost bit of the first word
< :
upto the leftmost bit of the last word
/ :
Therefore: Add 31 bits to both sides
? bits% = ((
_OStoPixel(width%+Xos%,Xeigen%)<<Log2BPP%)+62)
2= bits%*
_OStoPixel(height%+Yos%,Yeigen%) >> 3
Convert OSunits to pixels
_OStoPixel(osunits%,eigen%)
1 :
Make sure that the # of pixels at least
$ :
covers the area in OSunits
4 :
(the parameter may not be OSunit aligned!)
+= (osunits% + (1<<eigen%) -1) >> eigen%
---------- Sprite routines ----------
++++++++++ Miscelaneous support +++++++++++
Support routine which starts a dragbox, called from DragWindow
_InitiateDrag(handle%,type%,x0%,y0%,x1%,y1%)
buffer%!00 = handle%
buffer%!04 = type%
buffer%!24 = x0%
buffer%!28 = y0%
buffer%!32 = x1%
buffer%!36 = y1%
"Wimp_DragBox",,buffer%
Reinitialise all (eg. after modechange or resize)
_ReInitialise
/( :
Reinit pane and options window
_UpdateOptions
2) :
Setup scaleblock for spriteplot
3! Scale%!00 = scalemul% :
4! Scale%!04 = scalemul% :
5! Scale%!08 = scalediv% :
6! Scale%!12 = scalediv% :
_GetModeInfo
Black% = (1<<Log2BPP%)-1
_GetWindowInfo
_InitSprite
buffer%!00 = 0
buffer%!04 =-YLimit%
buffer%!08 = XLimit%
buffer%!12 = 0
"Wimp_SetExtent",DisplayHandle%,buffer%
_UpdateWindow(UpdateWindow%)
Read information about screenmode
_GetModeInfo
"WASP_ModeInfo"
XLimit%,YLimit%,Xeigen%,Yeigen%
"OS_ReadModeVariable",-1,9
,,Log2BPP%
Xos% = 1<<Xeigen%
Yos% = 1<<Yeigen%
N0 XLimit% = (XLimit% + Xos% - 1)
(Xos%-1)
O0 YLimit% = (YLimit% + Yos% - 1)
(Yos%-1)
(Xeigen%<2)
(Yeigen%<2)
ModeSuffix$ = "22"
ModeSuffix$ = ""
Get info about window
_GetWindowInfo
"WASP_WindowInfo",DisplayHandle%
Wminx%,Wminy%,Wmaxx%,Wmaxy%,,,BehindWindow%
Y' Wwidth% = Wmaxx% - Wminx% + Xos%
Z' Wheight% = Wmaxy% - Wminy% + Yos%
Determine pointershape relative to display window
_SetPointerInfo
half%
Mx%,My%,Mz%
d( :
Move is assumed (largest area)
Pointer% = Move%
fB :
If it should be resize, set it according to the location
Wwidth% < Wheight%
half% = Wwidth%>>1
half% = Wheight%>>1
h$ :
check left side of display
(My% > Wmaxy%-half%+Mx%-Wminx%)
Pointer% = TopLeft%
(My% < Wminy%+half%-Mx%+Wminx%)
Pointer% = BottomLeft%
k% :
check right side of display
(My% > Wmaxy%-half%-Mx%+Wmaxx%)
Pointer% = TopRight%
(My% < Wminy%+half%+Mx%-Wmaxx%)
Pointer% = BottomRight%
Set pointer to shape relating to screenarea
_SetPointer
PointerInWindow%
_SetPointerInfo
u. :
In a drag, the pointer never changes
drag%
Pointer% = drag%
w/ :
(Re)set the pointer if it has changed
Pointer%<>OldPointer%
Pointer%
Move%
{J
"OS_SpriteOp",256+36,sparea%,"ptr_hand"+ModeSuffix$,&22,8,8
|7
TopLeft%,TopRight%,BottomRight%,BottomLeft%
}`
"OS_SpriteOp",256+36,sparea%,"ptr_resize"+ModeSuffix$,&22,16>>Xeigen%,16>>Yeigen%
/
"OS_SpriteOp",256+36,-1,,&31,0,0
OldPointer% = Pointer%
_UpdateOptions
3 :
Check and perhaps justify scaling factors
scalemul% < 1
scalemul% = 1
scalediv% < 1
scalediv% = 1
scalemul% > 32
scalemul% = 32
scalediv% > 32
scalediv% = 32
( :
Update icons in Options window
_UpdateButton(1,ShowPane%)
_UpdateButton(2,ShowPointer%)
"WASP_Select",OptionsHandle%,3,CrossPointer%
_UpdateButton(4,FollowCaret%)
"WASP_Select",OptionsHandle%,5,AlwaysCaret%
_UpdateButton(6,BlankDisplay%)
"WASP_SetIconText",OptionsHandle%,8,
scalemul%
"WASP_SetIconText",OptionsHandle%,9,
scalediv%
% :
Update icons in Pane window
"WASP_SetIconText",PaneHandle%,0,
scalemul%
"WASP_SetIconText",PaneHandle%,1,
scalediv%
ShowPane%
DisplayOpen%
_ReOpenPane
_CloseWindow(PaneHandle%)
(Re)set button in Options window
_UpdateButton(nr%,on%) :
Valid%,Colour%,OldValid%
"WASP_IconValid",OptionsHandle%,nr%
OldValid%
on%
Colour% = &E7 : Valid% =
"2" :
Colour% = &17 : Valid% =
OldValid%?1 <> Valid%
OldValid%?1 = Valid%
G
"WASP_SetIconState",OptionsHandle%,nr%,Colour%<<24,&FF000000
Get position for next CLI argument
_CLINextArg(instr%,len%)
(instr% <= len%)
+
CLI$,instr%,1) <> " "
= instr%
instr% += 1
= instr%
Read integer value following CLI argument
_CLIargs(arg$,
value%)
arg%,instr%,I%,len%,ch%
instr% =
CLI$,arg$)
instr% = 0
len% =
(CLI$)
, I% =
_CLINextArg(instr%+
(arg$),len%)
arg% = 0
(I% <= len%)
# ch% =
CLI$,I%,1)) -
D
(0 <= ch%)
(ch% < 10)
arg% = 10*arg% + ch%
I% = len%
I% += 1
arg% <> 0
value% = arg%
Return option value on/off, according to "+' or "-".
No "+" or "-" will return default%.
_CLIonoff(search$,default%)
result%
result% =
CLI$,search$)
result%>1
result% = (
CLI$,result%-1,1) = "+")
result% = default%
= result%
---------- Miscelaneous support -----------
++++++++++ Startup/Closedown/Error routines +++++++++++
_Initialise
I TaskName$ = "Examine" : TaskPath$ =
ExpandString("<Examine$Dir>.")
"WASP_Initialise",200,TaskName$
WimpVersion%,TaskHandle%
_ShowError(
,"Line "+
)+" ("+
$+")")
_GetModeInfo
"OS_SWINumberFromString",,"Wimp_UpdateWindow"
UpdateWindow%
"OS_SWINumberFromString",,"Wimp_RedrawWindow"
RedrawWindow%
PollBlock% 256 , Scale% 16, buffer% 80
IndirSize% = 900
IndirPtr% IndirSize%
( IndirEnd% = IndirPtr% + IndirSize%
, :
Set up defaults for display window
Border% = 32
Declare mouse buttons
Adjust% = 1
Menu% = 2
Select% = 4
# :
Information about pointer
PointerInWindow% =
Pointer% = 0
OldPointer% = 0
dragtypes in Display
drag% = 0
Move% = 1
TopLeft% = 2
TopRight% = 3
BottomLeft% = 4
BottomRight%= 5
_LoadResources
"Wimp_OpenTemplate",,TaskPath$+"TemplRO"+
(WimpVersion%
100)
"WASP_LoadWindow","Display" ,sparea%,IndirPtr%,IndirEnd%,-1
DisplayHandle%,,IndirPtr%
"WASP_LoadWindow","ProgInfo",sparea%,IndirPtr%,IndirEnd%,-1
InfoHandle%,,IndirPtr%
"WASP_LoadWindow","Options" ,sparea%,IndirPtr%,IndirEnd%,-1
OptionsHandle%,,IndirPtr%
"WASP_LoadWindow","Pane" ,sparea%,IndirPtr%,IndirEnd%,-1
PaneHandle%,,IndirPtr%
"WASP_LoadWindow","Money" ,sparea%,IndirPtr%,IndirEnd%,-1
MoneyHandle%,,IndirPtr%
"Wimp_CloseTemplate"
: IndirPtr% = (IndirPtr%+3)
&FFFFFFFC :
word align
MenuHandle% =
CreateMenu("!Examine,Info>InfoHandle%,Options>OptionsHandle%,Save options,_Back,Front,Close,_Quit",IndirPtr%,IndirEnd%)
"WASP_Iconbar","!Examine",
# :
read command line options
"OS_GetEnv"
CLI$
. ShowPane% =
_CLIonoff("pane" ,
. ShowPointer% =
_CLIonoff("pointer",
. CrossPointer% =
_CLIonoff("cross" ,
- FollowCaret% =
_CLIonoff("caret" ,
- AlwaysCaret% =
_CLIonoff("always" ,
. BlankDisplay% =
_CLIonoff("blank" ,
_CLIargs("-width", Wwidth%)
_CLIargs("-height",Wheight%)
_CLIargs("-mul", scalemul%)
_CLIargs("-div", scalediv%)
DisplayOpen% =
' :
Determine size of pane window
"WASP_WindowInfo",PaneHandle%
Wminx%,Wminy%,Wmaxx%,Wmaxy%
# PaneWidth% = Wmaxx% - Wminx%
# PaneHeight% = Wmaxy% - Wminy%
! buffer%!00 = DisplayHandle%
" buffer%!04 = XLimit%-Wwidth%
# buffer%!08 = YLimit%-Wheight%
buffer%!12 = XLimit%
buffer%!16 = YLimit%
buffer%!20 = 0
buffer%!24 = 0
buffer%!28 = -1
_OpenWindow(buffer%)
"WASP_SetIconText",InfoHandle%,3,"0.25
(21 Apr 1993)"
_LoadResources
f%,l%
Load the sprites
"OS_File",13,"Sprites",,,TaskPath$
f%,,,,l% : l% += &4
(f% = 1)
sparea% l%
*9
"WASP_LoadSprites",TaskPath$+"Sprites",sparea%
,5
_ShowError(0,"Task sprites cannot be found")
-$
_CloseDown :
Always fatal
Load options (if any)
"OS_File",13,"Options",,,TaskPath$
f%,,,,l%
(f% = 1)
(l% = 50)
2# f% =
(TaskPath$+"Options")
3>
#f%,BlankDisplay%,FollowCaret%,ShowPointer%,ShowPane%
41
#f%,Wwidth%,Wheight%,scalemul%,scalediv%
5'
#f%,AlwaysCaret%,CrossPointer%
Wwidth% = 300
Wheight% = 300
scalemul% = 3
scalediv% = 1
_CloseDown
"XOS_Exit"
A! :
Reset the spritepointer
"XOS_SpriteOp",256+36,-1,,&31,0,0
"XWimp_CloseDown",TaskHandle%,&4B534154
"XOS_Exit"
_ShowError(Err%,Err$)
click%
"XOS_Exit"
PollBlock%!0 = Err%
$(PollBlock%+4)= Err$
"XWimp_ReportError",PollBlock%,1,TaskName$
,click%
_CloseDown
Q7: +++++++++++++ UserMessage responds ++++++++++++++
_Help(message%)
help$ : help$ = ""
message%!32
DisplayHandle%
WW help$ = " the window by moving the mouse,|mwhile holding \s or \a depressed."
Pointer%
Y4
Move% : help$ = "You can move" + help$
Z1
: help$ = "You can resize" + help$
PaneHandle%
]] help$ = "|mmagnification = multiplier/divisor (now "+
scalemul%+"/"+
scalediv%+")."
message%!36
_9
0 : help$ = "This is the multiplier:"+help$
`6
1 : help$ = "This is the divisor:"+help$
aZ
2 : help$ = "Press \s to increase, and \a to decrease the multiplier:"+help$
bW
3 : help$ = "Press \s to increase, and \a to decrease the divisor:"+help$
: help$ = ""
OptionsHandle%
message%!36
-1,0
hZ
1 : help$ = "With this button you control the pane\w below the display \w."
iM
2 : help$ = "This button toggles a pointer in the display \w."
j~
3 : help$ = "This button toggles the pointer in the display \w|min either a crosshair or in an actual pointer."
4 : help$ = "With this button you can make the display \w focus on the caret.|mYou can sometimes move the pointer to the caret by pressing
TAB."
l~
5 : help$ = "This button makes the display \w focus on the caret at all times,|mif 'follow caret' is selected."
my
6 : help$ = "When you select this button, the display \w is treated|mas an empty \w during magnification."
nD
help$ = "Zoom in or out using the up and down arrows."
q4 help$ = "This \w belongs to !Examine.|m"+help$
r( message%!0 = (24 +
(help$))
message%!12 = message%!8
message%!16 = &503
u! $(message%+20) = help$+
"Wimp_SendMessage",17,message%,message%!4
Respond to DeskSave message
_DeskSave(file%)
#file%,"BASIC -quit "+TaskPath$+"!RunImage";
_DeskSaveOption(file%,ShowPane% ,"pane")
_DeskSaveOption(file%,ShowPointer% ,"pointer")
_DeskSaveOption(file%,CrossPointer%,"cross")
_DeskSaveOption(file%,FollowCaret% ,"caret")
_DeskSaveOption(file%,AlwaysCaret% ,"always")
_DeskSaveOption(file%,BlankDisplay%,"blank")
#file%," -width "+
Wwidth%;
#file%," -height "+
Wheight%;
#file%," -mul "+
scalemul%;
#file%," -div "+
scalediv%
_DeskSaveOption(file%,option%,s$)
option%
#file%," +"+s$;
#file%," -"+s$;
7: ------------- UserMessage responds --------------
!General
Last modified 06-Mar-1990
!General Library
Jan-Herman Buining
NOT complete: only FNs and PROCs that I use,
also, I've changed the menuproc slightly
Wimp Application Support Module
Jan-Herman Buining
Global variables
MenuPtr%, MenuSize%, MenuEnd%
LastMenuHdl%, LastMenuX%, LastMenuY%
+++++ BIT HANDLING +++++
NFlag(Flags%)
=((Flags%
%1000)=%1000)
ZFlag(Flags%)
=((Flags%
%0100)=%0100)
CFlag(Flags%)
=((Flags%
%0010)=%0010)
VFlag(Flags%)
=((Flags%
%0001)=%0001)
----- BIT HANDLING -----
+++++ MENU CREATION +++++
CreateMenu(Menu$,
MenuPtr%,
MenuEnd%)
D
Menu$ = Creation string, menu items are seperated by a ','
$
First item : Title
=
Next items : Normal (Normal text
E
@Ticked (Tick prefixes icon)
U
_Dotted (UNDER dotted line -- Change by EdK)
K
#Shaded (Icon can not be selected)
J
Tick, Dot or Shade may also prefix the following items :
?
Submenu>Handle (Submenu icon)
L
Submenu>!Handle (id. but generates message)
N
String$Size$Valid (Writeable icon [Size$Valid])
"
StartPtr%,Title$,MaxLen%
StartPtr%=MenuPtr%
C
(StartPtr%+28)>MenuEnd%
_ShowError(0,"Menu area full")
&
Split(Menu$,",",Title$,Menu$)
Title$=
Title$,11)
MaxLen%=
(Title$)-2
$StartPtr%=Title$
StartPtr%!12=&00070207
MenuPtr%+=28
'
Split(Menu$,",",Left$,Menu$)
?
MenuItem(Left$,Menu$,StartPtr%+28,MenuPtr%,MenuEnd%)
/
(Left$)>MaxLen%
MaxLen%=
(Left$)
Menu$=""
% StartPtr%!16=(MaxLen%*&10)+&C
StartPtr%!20=44
StartPtr%!24=0
=StartPtr%
MenuItem(
Left$,Menu$,FirstEntry%,
MenuPtr%,
MenuEnd%)
&
Loc%,Mid$,Right$,Validation%
B
(MenuPtr%+24)>MenuEnd%
_ShowError(0,"Menu area full")
6
Menu$=""
MenuPtr%!00=&80
MenuPtr%!00=&00
Validation%=
MenuPtr%!08=&07000001
Left$,1)
" Left$=
Left$,
(Left$)-1)
, MenuPtr%!00=(MenuPtr%!00
(1<<0))
" Left$=
Left$,
(Left$)-1)
L
MenuPtr%<>FirstEntry%
MenuPtr%!(-24)=(MenuPtr%!(-24)
(1<<1))
" Left$=
Left$,
(Left$)-1)
- MenuPtr%!08=(MenuPtr%!08
(1<<22))
Loc%=
Left$,">")
Loc%>0
Right$ = ""
(
Split(Left$,">",Left$,Right$)
Right$,1)="!"
' Right$=
Right$,
(Right$)-1)
. MenuPtr%!00=(MenuPtr%!00
(1<<3))
MenuPtr%!04=
(Right$)
MenuPtr%!04=-1
Loc%=
Left$,"$")
Loc%>0
*
Split(Left$,"$",Left$,Right$)
Validation%=
. MenuPtr%!00=(MenuPtr%!00
(1<<2))
*
(Left$)<13
(Validation%))
$(MenuPtr%+12)=Left$
, MenuPtr%!08=(MenuPtr%!08
(1<<8))
Validation%
*
Split(Right$,"$",Mid$,Right$)
9
(MenuEnd%-(
(Right$)+
(Mid$)+2))<MenuPtr%
-
_ShowError(0,"Menu area full")
! MenuEnd%-=(
(Mid$)+1)
' $(MenuEnd%)=
Left$,
(Mid$))
MenuPtr%!12=MenuEnd%
# MenuEnd%-=(
(Right$)+1)
$(MenuEnd%)=Right$
MenuPtr%!16=MenuEnd%
! MenuPtr%!20=
(Mid$)+1
(Mid$)<10
! Left$=
(Mid$)," ")
3 Left$=
10," ") :
Standard max width
0
(MenuEnd%-(
(Left$)+1))<MenuPtr%
-
_ShoeError(0,"Menu area full")
" MenuEnd%-=(
(Left$)+1)
$(MenuEnd%)=Left$
MenuPtr%!12=MenuEnd%
MenuPtr%!16=-1
" MenuPtr%!20=
(Left$)+1
MenuPtr%+=24
----- MENU CREATION -----
+++++ MENU HANDLING +++++
CloseMenus
#
Closes all open menu's
$!
"XWimp_CreateMenu",,-1
CreateMenu(MenuHdl%,X%,Y%)
(< :
Shade the "Close" entry if the display is closed
)5
"WASP_Shade",MenuHandle%,5,
(DisplayOpen%)
*@
Create a menu, this acts as the first in the menu tree
LastMenuHdl%=MenuHdl%
LastMenuX%=X%
LastMenuY%=Y%
.-
"XWimp_CreateMenu",,MenuHdl%,X%,Y%
CreateSubMenu(MenuHdl%,X%,Y%)
2C
Create a submenu when this is needed after a menu warning
30
"XWimp_CreateSubMenu",,MenuHdl%,X%,Y%
----- MENU HANDLING -----
+++++ STRING HANDLING +++++
ExpandString(String$)
;2
Expands a string containing OS variables
Dummy$,Flags%
Dummy$=
255," ")
>C
"XOS_GSTrans",String$,Dummy$,
(Dummy$)
,Dummy$ ;Flags%
?,
CFlag(Flags%))
String$=Dummy$
=String$
Split(String$,Seperator$,
Left$,
Right$)
C.
Splits a string in two pieces at the
D+
first occurrence of the seperator
Loc%
F! Loc%=
String$,Seperator$)
Loc%>0
H" Left$=
String$,1,Loc%-1)
I* Right$=
String$,
(String$)-Loc%)
J
Left$=String$
Right$=""
M
----- STRING HANDLING -----