home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
programs
/
fonts
/
a_q
/
fontpool
/
!Ex-BASIC
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1995-01-10
|
8KB
|
258 lines
BASIC-Example of FontPool v0.12
Author: Eirik Hansen 1994/1995
All procedures that call the FontPool module are located
at the end of the program (starting with DEF PROCSetUp).
Feel free to use this file as a framework for more
serious programs.
p% 256
SetUp
CloseDown
---------------
The main loop.
- - - - - - - -
CloseDown
"Wimp_Poll",0,p%
ResCode%
ResCode%
+
2 :
"Wimp_OpenWindow",,p%
3 :Quit%=
6 :
MouseClick
!
9 :
MenuSelection
17,18 :
Messages
Quit%
!5-------------------------------------------------
"4Determine the kind of message that was received?
#5- - - - - - - - - - - - - - - - - - - - - - - - -
Messages
p%!16
0 : Quit%=
&400C0 :
MenuWarning
---------------------
Creating the window..
- - - - - - - - - - -
CreateWindow
Temps%
"OS_Module",6,,,&800
,,Temps%
Indirect% &800
IndEnd%=Indirect%+&800
4"In$="<Ex-BASIC$Dir>.Templates"
"Wimp_OpenTemplate",,In$
"Wimp_LoadTemplate",,Temps%,Indirect%,IndEnd%,-1,"Work",0
,,Indirect%
FontIcon%=Temps%!108
ConfIcon%=Temps%!(108+8*32)
:!FontXIcon%=Temps%!(108+40*32)
;!FontYIcon%=Temps%!(108+41*32)
"Wimp_CreateWindow",,Temps%
WinH%
"Wimp_CloseTemplate",,In$
"OS_Module",7,,Temps%
A#-------------------------------
B"Creates the 'indirected' menu.
C#- - - - - - - - - - - - - - - -
CreateMenu
Menu% 128
P%=Menu%
[OPT 2
EQUS "FontPool"
EQUD 0
EQUB 7 ; Title fg
EQUB 2 ; Title bg
EQUB 7 ; WA fg
EQUB 0 ; WA bg
EQUD 180 ; ItemWdt
EQUD 44 ; ItemHgt
EQUD 0 ; Spacing
R ;--The relevant menu-item...
S@ EQUD 1<<3 ; Generate Msg_SubMenuWarning
TN.SubMenuPtr% EQUD 0 ; This word is later set up to point to the
U3 ; FontPool-menu.
V EQUD &7000001
EQUS "Font"
EQUD 0
EQUD 0
[F;--The rest are items that would normally be found in a font-menu.
\A;--They are present only as an 'illustration' and are shaded.
EQUD 0
EQUD 1000
EQUD &7400001
EQUS "Size"
EQUD 0
EQUD 0
EQUD 0
EQUD 1000
EQUD &7400001
EQUS "Foreground"
EQUB 0
EQUB 0
EQUD &80
EQUD 1000
EQUD &7400001
EQUS "Background"
EQUB 0
EQUB 0
---------------------------
Returns with
if Icon%
in Win% is selected, else
returns
- - - - - - - - - - - - - -
IsItSelected(Win%,Icon%)
X%,Y%
!p%=Win%
p%!4=Icon%
"Wimp_GetIconState",,p%
(p%!24
&200000)<>0 =
S===============================================================================
OThe procedures below all call the FontPool module. They should hopefully be
Qsufficiently commented to help build a 'real' program that utilizes FontPool.
PNote the SWIs that update the submenu-pointer in the 'parent-item'. They all
end with
...
!SubMenuPtr%
This pointer is only necessary to update if the font-menu is ever opened using 'FontPool_CreateSubMenu' - which most programs would do.
S-------------------------------------------------------------------------------
Setting up..
- - - - - - -
SetUp
In$,In%,Ext%,N%,Mask%
Quit%=
"Wimp_Initialise",200,&4B534154,"FontPool"
,TaskH%
CreateWindow
CreateMenu
FontH%=0
Font$=""
OpenMenu%=
---Initialising FontPool...
&B=Fg col on selected items
&0=Bg..
&5=Fg col on unselected items
&0=Bg..
&0C=How long the menu can get before it gets alphabetized.
The leftmost bit (&8...) must be set or the
config-word is ignored.
"FontPool_Hello",,&800C050B
!SubMenuPtr%
---Open the window.
!p%=WinH%
"Wimp_GetWindowState",,p%
"Wimp_OpenWindow",,p%
7---------------------------------------------------
A Msg_MenuWarning received..
7Opening the menu like this is only necessary if the
6font-menu is attached to a higher level menu-item.
6It gives FontPool a chance to re-build the menu if
6the Font$Path has changed since last time the menu
was open!
7- - - - - - - - - - - - - - - - - - - - - - - - - -
MenuWarning
p%!20
!SubMenuPtr%
G
"FontPool_CreateSubMenu",,Font$,p%!24,p%!28
!SubMenuPtr%
/-------------------------------------------
A mouse-click occurred.
.A click on the Reconfigure icon causes the
*menu to be recomputed because R2 is
.Also demonstrates how to use FontPool both
.directly (MENU) and indirectly (ADJUST) if
'the mouse-click was on the window's
work-area.
/- - - - - - - - - - - - - - - - - - - - - -
MouseClick
Config%
p%!16
7 :
The reconfigure icon..
Config%=
($ConfIcon%)
;
"FontPool_Configure",,Config%,
!SubMenuPtr%
39 :
The 'Use font on fontmenu' icon..
DoIChangeMenuFont
]
p%!8=2
"FontPool_CreateMenu",,Font$,!p%-100,p%!4+80
!SubMenuPtr%:OpenMenu%=0
N
p%!8=1
"Wimp_CreateMenu",,Menu%,!p%-100,p%!4+80:OpenMenu%=Menu%
------------------------------------------
,If 'Use font on fontmenu' is set, do it!
The format of FontSize% is
&xxxyyyhh where
xxx = x-size (*16)
yyy = y-size (*16)
) hh = menu item-height (0 here)
,So the <<24 and <<8 below multiplies the
given icon-values with 16.
-- - - - - - - - - - - - - - - - - - - - -
DoIChangeMenuFont
IsItSelected(WinH%, 39)=
9FontSize%=(
($FontXIcon%))<<24
($FontYIcon%))<<12
"FontPool_Configure",,,,Font$,FontSize%
!SubMenuPtr%
)-------------------------------------
(A menu-selection. Decide what to do!
)- - - - - - - - - - - - - - - - - - -
MenuSelection
---Lose the last font..
FontH%
"Font_LoseFont",FontH%
---Instruct 'FontPool' to deal with the menu-selection - passing
the correct 'root-menu' (OpenMenu%) to the SWI-routine.
Returns with Selection%=TRUE if something is selected in
the font-menu, and Font$ as the selected font-name.
"FontPool_MenuSelection",,OpenMenu%,p%,0
Selection%,,,Font$
---Now the application makes use of the
menu-selection that took place.
Selection%
SYS "Font_FindFont",,Font$,16<<4,16<<4,0,0 TO FontH%
$FontIcon%=Font$
5 $FontIcon%="No font selected (System font)"+
Font$=""
FontH%=0
---If the option is set, change the menu-font immediately.
DoIChangeMenuFont
---Force redraw of the 'Current-font' icon.
!p%=WinH%
p%!4=0
p%!8=0
p%!12=0
"Wimp_SetIconState",,p%
---If ADJUST was used when selecting, re-open the CORRECT menu.
"Wimp_GetPointerInfo",,p%
p%!8=1
"FontPool_CreateMenu",,Font$,,,OpenMenu%
!SubMenuPtr%
#-------------------------------
#Bye bye. Let's call it a day..
#- - - - - - - - - - - - - - - -
CloseDown
---This client is now history!!
"FontPool_Goodbye"
FontH%
"Font_LoseFont",FontH%
"Wimp_CloseDown",TaskH%,&4B534154