home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1993-01-27 | 9.2 KB | 329 lines |
- >EditorSrc
- Demonstration of use of FontWindow module
- Multi-document application, windows with anti-aliased title bars
- Windows are demand-created
- Look for REM### to see where I've put the FontModule code
- documents are kept in a simple linked list
- 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(FontWindow, Title$)
- = &8000+64*1024
- Debug% =
- q% 256
- $q%="TASK"
- "Wimp_Initialise",200,!q%, Title$
- , TaskHandle%
- need local error handlers before poll loop...
- ### --- note the 1,1 see docs
- FontWindow
- Q
- "FontWindow_Initialise", TaskHandle%, 0,0, 1,1, 0, 0, 100
- FontTable%
- =
- FontTable% 256:
- i%= 0
- 255:FontTable%?i% = 0:
- Documents 4 :
- pointer to pointer to linked list of'em
- #$ !Documents = 0
- $L DocNumber = 1 :
- so can tell documents apart visually
- Each document is stored in the following structure:
- (E Doc_Next = 0 << 2 :
- pointer to next in linked list
- )9 Doc_Window = 1 << 2 :
- wimp window handle
- *R Doc_Title = 2 << 2 :
- pointer to indirected title bar icon buffer
- sizeof_Doc = 3 << 2
- loadtemplates
- makemenus
- makeiconbaricon
- reporterror
- 5"
- "Wimp_Poll",&31,q%
- 7%
- "Wimp_OpenWindow",, q%
- closewindow
- mouseclick
- menuselect
- 17,18:
- message
- <
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- closewindow
- docwindow_p(doc, !q%)
- quitdocument(doc)
- G"
- "Wimp_CloseWindow",, q%
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- createdocument
- doc, dx, dy, len
- doc sizeof_Doc :
- claim memory [kludge]
- we now redirect the indirected data
- this is a kludge (a bad one) because only redirect the title bar
- should be re-directing all the indirected icons as well...
- len = Document_WDef%!80
- doc!Doc_Title len
- U' Document_WDef%!72 = doc!Doc_Title
- putz(doc!Doc_Title,
- "Document number "+
- (DocNumber), len-1))
- DocNumber += 1
- ### -- note the TO parameter in the next line
- FontWindow
- Zb
- "FontWindow_CreateWindow", TaskHandle%, Document_WDef%, doc+Doc_Window
- doc!Doc_Window
- \@
- "Wimp_CreateWindow",, Document_WDef%
- doc!Doc_Window
- !q% = doc!Doc_Window
- "Wimp_GetWindowState",, q%
- `D dx = (
- (64) - &1F) * 16 :
- so not on top of eachother!
- dy = (
- (64) - &1F) * 16
- q%!4 += dx
- q%!8 += dy
- q%!12 += dx
- q%!16 += dy
- q%!28 = -1
- "Wimp_OpenWindow",, q% :
- no need to fontwindow_openwindow, although could
- doc!Doc_Next = !Documents
- jG !Documents = doc :
- new head of linked list
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- quitdocument(doc)
- parent
- parent = Documents
- !parent <> doc
- s% parent = (!parent) + Doc_Next
- FontWindow
- wA
- "FontWindow_DeleteWindow", TaskHandle%, doc+Doc_Window
- y/
- "Wimp_DeleteWindow",, doc+Doc_Window
- !parent = doc!Doc_Next
- <release memory used by document>
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- returns TRUE if window belongs to a document, setting doc
- if true
- docwindow_p(
- doc, w%)
- rc% =
- doc = !Documents
- doc
- # rc% = (doc!Doc_Window = w%)
- $
- rc%
- doc = doc!Doc_Next
- = rc%
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- closedown
- !Documents
- !
- quitdocument(!Documents)
- FontWindow
- 4
- "FontWindow_CloseDown", TaskHandle%,
- i%=0
-
- FontTable%?i%
- #
- "XFont_LoseFont", i%
- FontTable%?i% -= 1
-
- "Wimp_CloseDown"
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- doesn't actually load window, but saves definition in memory
- if make multiple clones of a windows then need to redirect
- all of the indirected data...
- loadtemplate(name$,
- wh%)
- siz, i, pos
- $q% = name$+
- "Wimp_LoadTemplate",, buf%, indrove%, ind%+bufsiz%, FontTable%, q%, 0
- ,, indrove%,,,, pos
- pos=0
- 1, "Can't find template "+ name$
- siz = 88+((buf%!84)*32)
- wh% siz
- i = 0
- siz-1
- wh%!i = buf%!i
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- message_modechange
- FontWindow
- /
- "FontWindow_ModeChange", TaskHandle%
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- message_menuwarning
- x% = q%!24
- y% = q%!28
- item% = q%!32
- item%
- ProgInfo_WDef%
-
- ProgInfo_WPtr% 4
-
- FontWindow
- g
- "FontWindow_CreateWindow", TaskHandle%, ProgInfo_WDef%, ProgInfo_WPtr%
- !ProgInfo_WPtr%
-
- E
- "Wimp_CreateWindow",, ProgInfo_WDef%
- !ProgInfo_WPtr%
-
- 5 ProgInfo_WDef% = 0 :
- release memory
-
-
- FontWindow
- E
- "FontWindow_UpdateWindow", TaskHandle%, ProgInfo_WPtr%
-
-
- 9
- "Wimp_CreateSubMenu",, !ProgInfo_WPtr%, x%, y%
- SaveAs_WDef%
-
- SaveAs_WPtr% 4
-
- FontWindow
- a
- "FontWindow_CreateWindow", TaskHandle%, SaveAs_WDef%, SaveAs_WPtr%
- !SaveAs_WPtr%
-
- A
- "Wimp_CreateWindow",, SaveAs_WDef%
- !SaveAs_WPtr%
-
- 3 SaveAs_WDef% = 0 :
- release memory
-
-
- FontWindow
- C
- "FontWindow_UpdateWindow", TaskHandle%, SaveAs_WPtr%
-
-
- 7
- "Wimp_CreateSubMenu",, !SaveAs_WPtr%, x%, y%
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- mouseclick
- (q%!12 = -2)
- (q%!16 = IconBarIcon%)
- (q%!8
- L
- "Wimp_CreateMenu",, Menu%, q%!0 - ((Menu%!16)>>1), 96+44*3+24*0
-
-
- createdocument
-
- menuselect
- !q% = 2
- closedown
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 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_WDef%)
- loadtemplate("SaveAs", SaveAs_WDef%)
- loadtemplate("Document", Document_WDef%)
- the following window will not be cached, as it contains no
- anti-aliased fonts.
- loadtemplate("Query", Query_WDef%)
- "Wimp_CreateWindow",, Query_WDef%
- Query_W%
- "Wimp_CloseTemplate"
- free buf% memory
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- makemenus
- menusiz% = 10*1024
- Menu% menusiz%
- menu% = Menu%
- menutitle(Title$)
- menuitem("Info", 1 << 3, &8004)
- menuitem("Save as", 1 << 3, &8004)
- menuitem("Quit", 1 << 7, -1)
- menutitle(title$)
- $menu% = title$
- menu%?12 = 7
- menu%?13 = 2
- menu%?14 = 7
- menu%?15 = 0
- menu%!16 = 11*16
- menu%!20 = 44
- menu%!24 = 0
- menu% += 28
- menuitem(item$, flags%, data%)
- menu%!0 = flags%
- menu%!4 = data%
- menu%!8 = &07000021
- <& $(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%
- _!
- $+ ", ["+
- )+ "]"
- getz(q%)
- ?q%:V$+=
- (?q%):q%+=1:
- putz(z%, z$)
- $z% = z$
- z%?
- z$ = 0
-