home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
programs
/
fonts
/
a_q
/
fontwindow
/
!Demo
/
NormalSrc
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1993-03-02
|
9KB
|
331 lines
>NormalSrc
Demonstration of use of FontWindow module
Simple dboxes + complicated menus
Windows are created at time of load.
Look for REM### to see where I've put FontModule code
Look for REM#++ to see menu code
MACHINE: Archimedes
LANGUAGE: BBC BASIC V (v1.05)
AUTHOR: Cy Booker,
86 Church View, Main Road, Crockenhill, Swanley, Kent.
BR8 8JW
apologies for the crappy coding, but it is done in a hurry
main(
, "Test Simple")
main(FontWindow, FontMenu, Title$)
= &8000+64*1024
Debug% =
q% 256
$q%="TASK"
"Wimp_Initialise",200,!q%, Title$
, TaskHandle%
need local error handlers before poll loop...
FontWindow
FontMenu
!I version = 110 :
latest version know about
"? flags = 1 << 16 :
all resolutions
#H flags = 1 << 17 :
high-rez (>= 90dpi) only
$F menufont = 0 :
default font for menus
%
version = 100
flags = 0
(6 menufont = 0 :
unused
)
*K malloc_routine = 0 :
default allocate RMA memory
+G free_routine = 0 :
default free RMA memory
,Y gethandle_routine = 0 :
default one for abstract == window handle
-Y recreate_routine = 0 :
default one for abstract == window handle
.6 routine_r12 = 0 :
unused
/C fonttable = 0 :
please allocate one
"FontWindow_Initialise", TaskHandle%, malloc_routine,free_routine, gethandle_routine,recreate_routine, routine_r12, fonttable, version
flags, menufont
FontTable%
2=
FontTable% 256:
i%= 0
255:FontTable%?i% = 0:
loadtemplates
makemenus
makeiconbaricon
reporterror
="
"Wimp_Poll",&31,q%
?%
"Wimp_OpenWindow",, q%
@&
"Wimp_CloseWindow",, q%
mouseclick
menuselect
17,18:
message
D
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
closedown
FontWindow
M4
"FontWindow_CloseDown", TaskHandle%,
i%=0
FontTable%?i%
Q#
"XFont_LoseFont", i%
FontTable%?i% -= 1
"Wimp_CloseDown"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
loadtemplate(name$,
wh%)
$q% = name$+
"Wimp_LoadTemplate",, buf%, indrove%, ind%+bufsiz%, FontTable%, q%, 0
,, indrove%,,,, pos%
pos%=0
1, "Can't find template "+ name$
FontWindow
bE
"FontWindow_CreateWindow", TaskHandle%, buf%, 0
wh%, qq%
d+
"Wimp_CreateWindow",, buf%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
message_modechange
FontWindow
m/
"FontWindow_ModeChange", TaskHandle%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
message_menuwarning
x% = q%!24
y% = q%!28
item% = q%!32
item%
FontWindow
{@
"FontWindow_UpdateWindow", TaskHandle%, ProgInfo_W%
|
}5
"Wimp_CreateSubMenu",, ProgInfo_W%, x%, y%
FontWindow
>
"FontWindow_UpdateWindow", TaskHandle%, SaveAs_W%
3
"Wimp_CreateSubMenu",, SaveAs_W%, x%, y%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mouseclick
(q%!12 = -2)
(q%!16 = IconBarIcon%)
(q%!8
(
menutick(Menu%, 2, FontMenus)
5
menutick(MenuColours%, CurrentColour%,
L
"Wimp_CreateMenu",, Menu%, q%!0 - ((Menu%!16)>>1), 96+44*5+24*0
!q% = Document_W%
'
"Wimp_GetWindowState",, q%
q%!28 = -1
FontWindow
D
"FontWindow_OpenWindow", TaskHandle%, q%, Document_W%
%
"Wimp_OpenWindow",, q%
menuselect
!q%
FontMenus
?
"FontWindow_DeRegisterMenu", TaskHandle%, Menu%,
F
"FontWindow_DeRegisterMenu", TaskHandle%, MenuColours%,
:
"FontWindow_RegisterMenu", TaskHandle%, Menu%
A
"FontWindow_RegisterMenu", TaskHandle%, MenuColours%
FontMenus =
FontMenus
&
menutick(Menu%, 2, FontMenus)
q%!4 >= 0
$
q%!4 <> CurrentColour%
6
menutick(MenuColours%, CurrentColour%,
! CurrentColour% = q%!4
4
menutick(MenuColours%, CurrentColour%,
closedown
"Wimp_GetPointerInfo",, q%
q%!8
$
"Wimp_CreateMenu",, Menu%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
reporterror
!q% =
Debug%
'
putz(q%+4,
$+ " code "+
putz(q%+4,
"Wimp_ReportError", q%, 3, Title$
, choice%
choice% = 2
closedown
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
loadtemplates
bufsiz% = 10*1024
buf% bufsiz% :
kludge
ind% bufsiz% :
kludge
indrove% = ind%
"Wimp_OpenTemplate",, "<DemoFontWindow$Dir>.Templates"
local error handler...
loadtemplate("ProgInfo", ProgInfo_W%)
loadtemplate("SaveAs", SaveAs_W%)
loadtemplate("Test", Document_W%)
the following window will not be cached, as it contains no
anti-aliased fonts.
loadtemplate("Query", Query_W%)
"Wimp_CloseTemplate"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
makemenus
col$, i
FontMenus = FontMenu
CurrentColour% = 0
col$ = "0123456789ABCDEF"
menusiz% = 10*1024
Menu% menusiz%
% MenuColours% =
maddr(Menu%, 5)
menu% = Menu%
menutitle(Title$)
menuitem("Info", 1 << 3, &8004)
menuitem("Save as", 1 << 3, &8004)
menuitem("Menu FONTS", 0, 0)
FontWindow =
menu%!-16 += 1 << 22
menuitem("Colours", 0, MenuColours%)
menuitem("Quit", 1 << 7, -1)
menutitle("Colours")
i= 0
menu%!0 = 0
menu%!4 = 0
fore
1 menu%!8 = (i << 28)
(fore << 24)
&129
menu%!12 =
strdup(
1
give menu item an "F" validation string
8
which will be used IF the item is anti-aliased
?
this validation string will be used by the FontWindow
)
when we DeRegister the sub/menu
:
B menu%!16 =
strdup("F"+
col$, i+1, 1)+
col$, fore+1, 1))
menu%!20 =
(i))+1
menu%+=24
menu%!-24 += 1 << 7
7,7,7,0, 0,0,0,0, 0,7,7,0, 7,0,7,7
FontWindow
FontMenu
:
"FontWindow_RegisterMenu", TaskHandle%, Menu%
A
"FontWindow_RegisterMenu", TaskHandle%, MenuColours%
strdup(s$)
(s$) + 1
$s = s$
maddr(base, item)
item >= 0
base += 28 + (item * 24)
= base
menutick(base, item, boolean)
boolean
boolean = 1 << 0
base =
maddr(base, item)
' base!0 = (base!0
boolean
menutitle(title$)
$menu% = title$
menu%?12 = 7
menu%?13 = 2
menu%?14 = 7
menu%?15 = 0
), menu%!16 = 11*16 :
width
menu%!20 = 44
menu%!24 = 0
menu% += 28
menuitem(item$, flags%, data%)
menu%!0 = flags%
menu%!4 = data%
menu%!8 = &07000021
3& $(menu%+12) = item$+
(13))
menu%+=24
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
makeiconbaricon
name% 13
$name% = "!demo"
q%!0 = -1
q%!4 = 0
q%!8 = 0
q%!12 = 68
q%!16 = 68
q%!20 = &07006102
q%!24 = name%
q%!28 = +1
q%!32 =
($name%) + 1
"Wimp_CreateIcon",, q%
IconBarIcon%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
message
q%!16
closedown
&400C0:
message_menuwarning
&400C1:
message_modechange
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Debug%
V!
$+ ", ["+
)+ "]"
getz(q%)
?q%:V$+=
(?q%):q%+=1:
putz(z%, z$)
$z% = z$
z%?
z$ = 0