home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
p
/
popups
/
!PopUpTest
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1993-05-24
|
16KB
|
447 lines
>!PopUpTest.!RunImage
Test/Demonstration application for PopUps
Find a Wimp_OpenTemplate/LoadTemplate/CreateWindow/OpenWindow
call in this program if you can!
By Jason Williams 1993
This code is (truly) Public Domain
(You may use useful portions of this code in your own programs)
26,4,7:
"PopUpTest quitting due to error: ";
$;" /";
--- Global constants -----------------------------------------------------
OPopUpAsWindow = 0 :
Application flags - standalone MENU PopUp
LPopUpAsSubmenu = 1 :
- SubMenu MENU PopUp
FPopUpIsStatic = 2 :
- STATIC PopUp
:Message_Quit = 0 :
Wimp message numbers
Message_DataSave = 1
Message_DataSaveAck = 2
Message_DataLoad = 3
!Message_MenuWarn = &400C0
!Message_PopUpRequest = &46D40
!Message_PopUpState = &46D41
OSaveAs_OKClick = %00000001 :
Save-As returned flagword bits
$SaveAs_ShiftDown = %00000010
Report_CancelOnly = 1
Report_OKOnly = 2
Report_OKAndCancel = 3
--- PopUp data -----------------------------------------------------------
popup% 256 :
Block for PopUp data
F%=0
250
4 :
Which we clear out (I'm a tidy chap ;-)
popup%!F% = 0
*.popuphandle% = 0 :
No valid popup
,:MagMul% = 1:MagDiv% = 1 :
Default Magnifier settings
.JDefaultSaveName$ = "PopUpFile" :
Name to put in SaveAs writable icon
0QNewWimpColour% = 7 :
WimpColour initially defaults to colour 7 (black)
2AColourFormat% = 0 :
TrueColour initially defaults to:
3FNewTrueColour% = 0 :
Colour = black, specified as RGB value
4/NewTransparent% = 0 :
NO transparency
--- Wimp initialisation --------------------------------------------------
b% 256, m% 256
$b%="TASK"
"Wimp_Initialise", 200, !b%, "PopUp Tester"
,taskhandle%
--- Ensure PopUp Manager/Server running ----------------------------------
?C*RMEnsure PopUpManager 0.86 WimpTask Run <PopUpServer$Dir>.!Run
--- Create IconBar icon --------------------------------------------------
CHb%!0 = -1: b%!4 = 0: b%!8 = 0: b%!12 = 68: b%!16 = 68: b%!20 = &3002
D@$(b%+24) = "!PopUpTest":
"Wimp_CreateIcon",,b%
baricon%
--- Wimp_Poll loop -------------------------------------------------------
quit%=
"Wimp_Poll", 1, b%
reasoncode%
reasoncode%
MK
6:
click -------------------------------
N6
b%!12 < 0
b%!16 = baricon%
createmenu
PK
9:
menu choice -------------------------
!b%
R,
7:
"Quit"
quit%=
U<
:
"Info" and the demo PopUps.
VM
User clicked on the menu item instead of following the arrow.
WO
We thus open the PopUp conveniently under the pointer position.
Y.
"Wimp_GetPointerInfo",,b% + 4
Z?
popup(b%!0, b%!4 - 64, b%!8 + 64, PopUpAsWindow)
]K
17, 18:
Incoming message --------------------
b%!16
Message_Quit:
quit% =
b"
Message_DataSaveAck:
cN
Our SaveAs procedure has sent a DataSave message to the filer,
dF
and this is the reply telling us to go ahead and save.
e3
The full file pathname is at b%+44.
g+
savedata(
zerostring(b%+44))
Message_MenuWarn:
j;
Menu Warning (A submenu needs to be opened)
kG
b%!20 = the sublink number we gave in Wimp_CreateMenu
l@
b%!24, b%!28 = x,y position to open submenu at
mK
b%!32... list of menu selection values terminated by a -1
o9
popup(b%!32, b%!24, b%!28, PopUpAsSubmenu)
q#
Message_PopUpRequest:
rJ
Request from the PopUp Manager for us to attach its window
sL
to our menu tree. Simply call CreateSubMenu with the data it
t+
has sent us in the message.
v:
"Wimp_CreateSubMenu",,b%!20, b%!24, b%!28
x!
Message_PopUpState:
y=
A PopUp is trying to return new values to us.
zH
The following is the handle we were given - this is only
{B
important, however, if the PopUp is a STATIC PopUp
|" PopUpHandle% = b%!20
~%
zerostring(b%+24)
"Magnify":
! MagMul% = b%!36
! MagDiv% = b%!40
26, 4, 7
N
"PopUpTest: New Magnification is ";MagMul%;":";MagDiv%;" "
"Print":
+ NumCopiesToPrint% = b%!36
26, 4, 7
M
"PopUpTest: Time to print ";NumCopiesToPrint%;" copies! "
C
"Report" handled separately in PROCreport() below
"SaveAs":
savefile
"WimpColour":
) NewWimpColour% = b%?36
26, 4, 7
C
"PopUpTest: New colour is ";NewWimpColour%;" "
"TrueColour":
) ColourFormat% = b%!36
) NewTrueColour% = b%!40
) NewTransparent% = b%!44
quit%
"Wimp_CloseDown"
--------------------------------------------------------------------------
createmenu :
Show our iconbar menu
$(m%) = "PopUp Test"
m%!12 = &70207
m%!16 = 16 * 12
m%!20 = 44
m%!24 = 0
Menu flags used below: 8 = Warn on submenu opening, } 8 + 2 = &0A
2 = followed by dotted line }
80 = last item in the menu
Menu flags Sublink Icon flags Text
~~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
M p%=m%+28: p%!0 = &0A: p%!4 = 1: p%!8 = &7000021: $(p% + 12) = "Info"
P p%+=24: p%!0 = &08: p%!4 = 2: p%!8 = &7000021: $(p% + 12) = "Magnify"
N p%+=24: p%!0 = &08: p%!4 = 3: p%!8 = &7000021: $(p% + 12) = "Print"
Q p%+=24: p%!0 = &08: p%!4 = 4: p%!8 = &7000021: $(p% + 12) = "ProgInfo"
R p%+=24: p%!0 = &00: p%!4 = -1: p%!8 = &7000021: $(p% + 12) = "Report..."
O p%+=24: p%!0 = &08: p%!4 = 6: p%!8 = &7000021: $(p% + 12) = "SaveAs"
S p%+=24: p%!0 = &0A: p%!4 = 7: p%!8 = &7000021: $(p% + 12) = "WimpColour"
M p%+=24: p%!0 = &80: p%!4 = -1: p%!8 = &7000021: $(p% + 12) = "Quit"
& numitems% = (p% - (m% + 4)) / 24
"Wimp_CreateMenu",,m%, b%!0 - 64, 96 + (2 * 24) + (44 * numitems%)
--------------------------------------------------------------------------
popup(mainitem%, x%, y%, flags%)
fillpopupblock(x%, y%, flags%)
mainitem%
0: :
"Info" menu item
7 $popup% = "ProgInfo" :
PopUp Name
( $(popup% + &18) = "PopUp tester"
. $(popup% + &38) = "Test PopUp modules"
7 $(popup% + &58) = "
Copyright 1993 J.Williams"
, $(popup% + &78) = "2.00 (21 May 93)"
1: :
"Magnify" menu item
7 $(popup%) = "Magnify" :
Popup Name
J popup%!24 = MagMul% :
Default multiplier icon value
G popup%!28 = MagDiv% :
Default divisor icon value
H popup%!32 = 1 :
} Multiplier must be in the
G popup%!36 = 100 :
} range 1 to 100 inclusive
E popup%!40 = 1 :
} Divisor must be in the
E popup%!44 = 4 :
} range 1 to 4 inclusive
F $(popup% + 48) = "Ratio" :
Text for window title bar
2: :
"Print" menu item
7 $popup% = "Print" :
PopUp Name
F popup%!24 = 1 :
Number of copies to print
3: :
"ProgInfo" menu item
7 $popup% = "ProgInfo" :
PopUp Name
1 $(popup% + &18) = "ProgInfo PopUp Sample"
7 $(popup% + &38) = "(A display-only MENU PopUp)"
7 $(popup% + &58) = "
Copyright 1993 J.Williams"
, $(popup% + &78) = "1.00 (01 Jan 01)"
4: :
"Report ..." menu item
x message$ = "Please do not choose that menu item again. Click 'Continue' to continue, or 'Abort' to continue ;-)"
F
report(Report_OKAndCancel, "Continue", "Abort", message$)
H
26,4,7:
"PopUpTest: You opted to CONTINUE. Am I right? ;-) "
L
26,4,7:
"PopUpTest: I will ignore that and continue anyway ;-) "