home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / c1 / c_impress / Sources / Wimp < prev    next >
Encoding:
Text File  |  1991-04-08  |  39.1 KB  |  28 lines

  1.  
  2. 3:ô  ><BasicV$Lib>.Wimp  :  REM  Library routines. v0.07
  3. 3ô  MACHINE:  Archimedes
  4. 3#ô  LANGUAGE: BBC BASIC V, v1.04
  5. 3"ô  AUTHOR:   Cy Booker,
  6. 3,Gô            86 Church View, Main Road, Crockenhill, Swanley, Kent.
  7. 36ô            BR8 8JW
  8. 3@ô  FUNCTIONS:
  9. 3Jô   Claim_Stack( size% )
  10. 3T%ô   Custom_Error( flags%, text$ )
  11. 3^Aô   Date                                              Version
  12. 3hô   FileSize( n% )
  13. 3rô   FixedFileSize( n% )
  14. 3|ô   getname( ptr% )
  15. 3ŷHô   PSR_V_set( flags% )                               After SYS call
  16. 3‘ô   PSR_V_Set( flags% )
  17. 3Œ,ô   Open_Window_Horz_Centered( window% )
  18. 3¤'ô   Open_Window_Centered( window% )
  19. 3®7ô   Query_Icon_BackCol_And_Delete( window%, icon% )
  20. 3¸+ô   Query_Icon_Shaded( window%, icon% )
  21. 3Â-ô   Query_Icon_Selected( window%, icon% )
  22. 3Ìô   leaf( f$ )
  23. 3Ö4ô   Load_Template( id$, rove%, sprite_pointer% )
  24. 3à)ô   Read_String_Val( window%, icon% )
  25. 3ê%ô   Read_String( window%, icon% )
  26. 3ô"ô   XSizeof_File( file_name$ )
  27. 3þKô   XSet_Colour( RETURN routine, RETURN colour )      ARM code producer
  28. 4ô  :
  29. 4ô  PROCEDURES:
  30. 4Cô   Activate_Wimp()                                   Main loop
  31. 4&1ô   alter_bit( RETURN word%, bit%, boolean% )
  32. 40ô   Cancel_Stop()
  33. 4:6ô   Check_Icon_In_Range( w%, icon%, mini%, maxi% )
  34. 4D$ô   Claim_Null_Reason( reason$ )
  35. 4Nô   Close_Window( window% )
  36. 4X8ô   dim_array( RETURN start%, length%, RETURN end% )
  37. 4bDô   Generic_Init_Wimp( name$, v%, s_v% )              Initialise
  38. 4l1ô   Initiate_Drag( window%, icon%, routine$ )
  39. 4vDô   Open_Pane_Underneath( window%, xmin%, ymin%, xmax%, stack% )
  40. 4€&ô   Open_Window( window%, stack% )
  41. 4⇩*ô   Query_Wimp_Global_Error( prefix$ )
  42. 4“Hô   Rename_Icon( window%, icon%, sprite$ )            Non-indirected
  43. 4fi&ô   Release_Null_Reason( reason$ )
  44. 4¨&ô   Release_Stack( start%, size% )
  45. 4²3ô   Send_Save( filetype%, file_name$, length% )
  46. 4¼*ô   SetCaretPosition( window%, icon% )
  47. 4Æ$ô   Set_Title( window%, title$ )
  48. 4Ð>ô   Set_Window_Extent( window%, width%, height%, resize% )
  49. 4Ú6ô   Set_Icon_Foreground( window%, icon%, colour% )
  50. 4ä2ô   Set_Shade_Icon( window%, icon%, boolean% )
  51. 4î3ô   Set_Select_Icon( window%, icon%, boolean% )
  52. 4ø'ô   unselect_icon( window%, icon% )
  53. 5%ô   select_icon( window%, icon% )
  54. 5 (ô   Stop_Action( string$, routine$ )
  55. 5<ô   Update_Icon( window%, icon%, number%, eor%, clear% )
  56. 5 +ô   Update_String( window%, icon%, s$ )
  57. 5*(ô   Wimp_Error_Block( error_block% )
  58. 54!ô   Wimp_Error( num%, text$ )
  59. 5>ô  :
  60. 5Hô  VARIABLES:
  61. 5R ô   Application$      "Edit"
  62. 5\.ô   Version$          "0.12 (17-Apr-1969)"
  63. 5f@ô   Wimp_Active%      Boolean, used in case of library error
  64. 5pô   Task_Handle%
  65. 5z5ô   W%                Wimp poll block (512 bytes)
  66. 5☓ô  :
  67. 5‰
  68. ô  NB:
  69. 5—Gô   This is not amenable to compiling, because use procedures names
  70. 5¢Jô   as string literals in the program to cope with drags/null reasons.
  71. 5¬;ô   But can compact to reduce variable names (I think).
  72. 5¶ô  :
  73. 5Àô  UPDATES:
  74. 5ÊFô   17.03.1991 CJB Added FN_Read_String_Val, FN_Query_Icon_Shaded,
  75. 5ÔIô                  PROC_Set_Select_Icon, PROC_Set_Shade_Icon, altered
  76. 5ÞBô                  FN_Query_Icon_Selected, so now should work!
  77. 5èGô                  Added XSet_Colour, Query_Icon_BackCol_And_Delete
  78. 5ò3ô                  Added PROC_Set_Window_Extent
  79. 5üLô   30.03.1991 CJB Removed all references to old prog. PROC_Stop_Action,
  80. 6?ô                  renamed, and now takes string parameter.
  81. 6Gô   05.04.1991 CJB Added PROC_Set_Icon_Foreground, Library version.
  82. 6Bô   06.04.1991 CJB Actually used 'em - so now slightly stable.
  83. 6$@ô                  So ProgInfo window can have sprites file.
  84. 6.Fô   07.04.1991 CJB If an error occured between Wimp_Initialise and
  85. 68Cô                  Init_Menus, would get stuck in loop.  Cured.
  86. 69Bô   08.04.1991 CJB Added FN_[Fixed]FileSize, PROC_Rename_Icon.
  87. 6B:
  88. 6LÝ ¤_Wimp_version  :  = 007
  89. 6V:
  90. 6`Ý ¤_hard_initialise_Wimp
  91. 6jê Ŷ
  92. 6t7î Ŷ ê ÷ Ŷ  :  ò_e( "%.Wimp: hard_initialise_Wimp" )
  93. 6~"  ç ¤_LibHandler_version<012 …
  94. 6⇦;    Ŷ 1, "Needs more recent version of the LibHandler."
  95. 6‹  Í
  96. 6†0  ò_load_library( "<BasicV$Lib>.Heap", 007 )
  97. 6¦  Wimp_Active% = £
  98. 6°   Wimp_Stack_End% = 4 * 1024
  99. 6º8  ò_Claim_Heap_Block( Wimp_Stack%, Wimp_Stack_End% )
  100. 6Ä$  Wimp_Stack_End% += Wimp_Stack%
  101. 6Î#  Wimp_Stack_Top% = Wimp_Stack%
  102. 6Ø#  ò_Claim_Heap_Block( W%, 512 )
  103. 6â  query_routine$ = ""
  104. 6ì  dragged$ = ""
  105. 6ö  dragged_button% = 0
  106. 7"  Application$ = "Application"
  107. 7
  108. )  Version$     = "0.00 (01-Jan-1900)"
  109. 7  Task_Handle% = -1
  110. 7  :
  111. 7(  Wimp_Error_Fatal% = &960
  112. 72  Wimp_Error%       = &961
  113. 7<= 0
  114. 7F:
  115. 7PKô *********************************************************************
  116. 7ZKô ***                 Handy library routines                        ***
  117. 7dKô *********************************************************************
  118. 7n:
  119. 7x Ý ¤_Date
  120. 7ŵê t$
  121. 7…  t$ = Á’$, 5, 11)
  122. 7„  Át$, 3, 1) = "-"
  123. 7   Át$, 7, 1) = "-"
  124. 7ª= t$
  125. 7´:
  126. 7¾*Ý ¤_XSet_Colour( ø routine, ø colour )
  127. 7È[OPT pass%
  128. 7ÒALIGN:.colour EQUD 0
  129. 7Ü .routine
  130. 7æ        STMFD   (sp)!, {R0}
  131. 7ð        LDR     R0, colour
  132. 7ú%        SWI     "XWimp_SetColour"
  133. 8,        BLVS    Write_Global_Error_Block
  134. 8        LDMFD   (sp)!, {R0}
  135. 8        MOV     pc, link
  136. 8"]
  137. 8,= 0
  138. 86:
  139. 8@E: ô  Explicitly sets / reset bit in a word, dependent on boolean.
  140. 8J,Ý ò_alter_bit( ø word%, bit%, boolean% )
  141. 8T   ç boolean% …
  142. 8^%      word% = word% ☓ (1 << bit%)
  143. 8h   Ì
  144. 8r&      word% = word% € ¬(1 << bit%)
  145. 8|   Í
  146. 8ŷá
  147. 8‘:
  148. 8ŒK: ô  If SYS ... TO ... ; C%, Then this function will test for overflow.
  149. 8¤Ý ¤_PSR_V_set( flags% )
  150. 8®= (flags% € 1)<>0
  151. 8¸:
  152. 8ÂÝ ¤_PSR_V_Set( flags% )
  153. 8Ì= (flags% € 1)<>0
  154. 8Ö:
  155. 8àD: ô  Reserve space for an array of length length%, but setting a
  156. 8ê>: ô  variable to the end so can easily check for overflow.
  157. 8ô,Ý ò_dim_array(ø start%, length%, ø end%)
  158. 8þ   Þ start% length%
  159. 9   end% = start% + length%
  160. 9á
  161. 9:
  162. 9&Kô *********************************************************************
  163. 90Kô ***                      Caret                                    ***
  164. 9:Kô *********************************************************************
  165. 9D:
  166. 9N*Ý ò_SetCaretPosition( window%, icon% )
  167. 9X^  È− "Wimp_SetCaretPosition", window%, icon%, -1, -1, -1, ©(¤_Read_String(window%, icon%))
  168. 9bá
  169. 9l:
  170. 9vKô *********************************************************************
  171. 9€Kô ***                        Windows                                ***
  172. 9⇩Kô *********************************************************************
  173. 9“:
  174. 9fi&Ý ò_Open_Window( window%, stack% )
  175. ê ptr%
  176. 9²!  ptr% = ¤_Claim_Stack( 128 )
  177. 9¼  !ptr% = window%
  178. 9Æ%  È− "Wimp_GetWindowState",, ptr%
  179. 9Р ptr%!28 = stack%
  180. 9Ú!  È− "Wimp_OpenWindow",, ptr%
  181. 9ä"  ò_Release_Stack( ptr%, 128 )
  182. 9îá
  183. 9ø:
  184. :Ý ò_Close_Window( window% )
  185. :
  186. ê ptr%
  187. :!  ptr% = ¤_Claim_Stack( 128 )
  188. :   !ptr% = window%
  189. :*"  È− "Wimp_CloseWindow",, ptr%
  190. :4"  ò_Release_Stack( ptr%, 128 )
  191. :>á
  192. :H:
  193. :R(Ý ò_Bring_Window_To_Front( window% )
  194. :\
  195. ê ptr%
  196. :f   ptr% = ¤_Claim_Stack( 64 )
  197. :p  !ptr% = window%
  198. :z%  È− "Wimp_GetWindowState",, ptr%
  199. :☓  ptr%!28 = -1
  200. :‰!  È− "Wimp_OpenWindow",, ptr%
  201. :—!  ò_Release_Stack( ptr%, 64 )
  202. :¢á
  203. :¬:
  204. :¶ Ý ò_ReOpen_Window( window% )
  205. ê ptr%
  206. :Ê   ptr% = ¤_Claim_Stack( 64 )
  207. :Ô  !ptr% = window%
  208. :Þ%  È− "Wimp_GetWindowState",, ptr%
  209. :è!  È− "Wimp_OpenWindow",, ptr%
  210. :ò!  ò_Release_Stack( ptr%, 64 )
  211. :üá
  212. ;:
  213. ;,Ý ¤_Open_Window_Horz_Centered( window% )
  214. ;ê ptr%, w%
  215. ;$#  ptr%   = ¤_Claim_Stack( 256 )
  216. ;.  ptr%!0 = window%
  217. ;8K  È− "Wimp_GetWindowInfo",, ptr%       :  ô  Get Template defininition.
  218. ;B  w% = ptr%!12 - ptr%!4
  219. ;L  ptr%!0  = window%
  220. ;V#  ptr%!4  = (logmaxx% - w%) Ŵ 2
  221. ;`  ptr%!12 = ptr%!4 + w%
  222. ;j  ptr%!20 = 0
  223. ;t  ptr%!24 = 0
  224. ;~K  ptr%!28 = -1                          :  ô  Open to front of display.
  225. ;⇦!  È− "Wimp_OpenWindow",, ptr%
  226. ;‹"  ò_Release_Stack( ptr%, 256 )
  227. ;†= ¹
  228. ;¦:
  229. ;°'Ý ¤_Open_Window_Centered( window% )
  230. ;ºê ptr%, w%, h%
  231. ;Ä#  ptr%   = ¤_Claim_Stack( 256 )
  232. ;Π ptr%!0 = window%
  233. ;ØK  È− "Wimp_GetWindowInfo",, ptr%       :  ô  Get Template defininition.
  234. ;â  w% = ptr%!12 - ptr%!4
  235. ;ì  h% = ptr%!16 - ptr%!8
  236. ;ö  ptr%!0  = window%
  237. <#  ptr%!4  = (logmaxx% - w%) Ŵ 2
  238. <
  239. #  ptr%!8  = (logmaxy% - h%) Ŵ 2
  240. <  ptr%!12 = ptr%!4 + w%
  241. <  ptr%!16 = ptr%!8 + h%
  242. <(  ptr%!20 = 0
  243. <2  ptr%!24 = 0
  244. <<K  ptr%!28 = -1                          :  ô  Open to front of display.
  245. <F!  È− "Wimp_OpenWindow",, ptr%
  246. <P"  ò_Release_Stack( ptr%, 256 )
  247. <Z= ¹
  248. <d:
  249. <nI: ô  To be used when reset the title explicitly, window title must be
  250. <x: ô  indirected!
  251. <ŵ$Ý ò_Set_Title( window%, title$ )
  252. <…
  253. ê ptr%
  254. <„" ptr%   = ¤_Claim_Stack( 256 )
  255. <  ptr%!0 = window%
  256. <ª" È− "Wimp_GetWindowInfo",,ptr%
  257. <´ $(ptr%!76) = title$
  258. <¾ ptr%!0     = window%
  259. <È& È− "Wimp_GetWindowOutline",, ptr%
  260. <ÒD È− "Wimp_ForceRedraw", -1, ptr%!4, ptr%!16-40, ptr%!12, ptr%!16
  261. <Ü! ò_Release_Stack( ptr%, 256 )
  262. <æá
  263. <ð:
  264. <úE: ô  Given a window, re-set extent to width% by height% OS units.
  265. =H: ô  If this would result in a smaller window then, if resize%, then
  266. =J: ô  re-open the window in the middle of where it is, but "full size".
  267. =:
  268. =">Ý ò_Set_Window_Extent( window%, width%, height%, resize% )
  269. =,ê ptr%, w%, h%, mask%
  270. =6"  ptr%  = ¤_Claim_Stack( 222 )
  271. =@  !ptr% = window%
  272. =J%  È− "Wimp_GetWindowState",, ptr%
  273. =T  w% = (ptr%!12) - (ptr%!4)
  274. =^  h% = (ptr%!16) - (ptr%!8)
  275. =h0  ç ((width%<w%) ☓ (height%<h%)) € resize% …
  276. =r    ç width%<w% …
  277. =|(      mask%   = ¬((1 << ltopx%) - 1)
  278. =ŷ>      ptr%!4  = ((ptr%!4)+ (w% Ŵ 2)- (width% Ŵ 2)) € mask%
  279. =‘/      ptr%!12 = ((ptr%!4) + width%) € mask%
  280. =Œ        Í
  281. =¤    ç height%<h% …
  282. =®(      mask%   = ¬((1 << ltopy%) - 1)
  283. =¸?      ptr%!8  = ((ptr%!8)+ (h% Ŵ 2)- (height% Ŵ 2)) € mask%
  284. =Â0      ptr%!16 = ((ptr%!8) + height%) € mask%
  285. =Ì        Í
  286. =ÖI    È− "Wimp_OpenWindow",, ptr%        :  ô  SetExtent doesnt resize.
  287. =à  Í
  288. =ê  !ptr%   = 0
  289. =ô/  ptr%!4  = -height% € ¬((1 << ltopy%) - 1)
  290. =þ-  ptr%!8  = width% € ¬((1 << ltopx%) - 1)
  291. >  ptr%!12 = 0
  292. >(  È− "Wimp_SetExtent", window%, ptr%
  293. >"  ò_Release_Stack( ptr%, 222 )
  294. >&á
  295. >0:
  296. >:DÝ ò_Open_Pane_Underneath( window%, xmin%, ymin%, xmax%, stack% )
  297. >D
  298. ê ptr%
  299. >N!  ptr% = ¤_Claim_Stack( 512 )
  300. >X  !ptr% = window%
  301. >b$  È− "Wimp_GetWindowInfo",, ptr%
  302. >l  ptr%!16 = ymin% - 44
  303. >v%  ptr%!8  = (ptr%!16) + (ptr%!48)
  304. >€  ptr%!4  = xmin%
  305. >⇩5  ptr%!12 = ¤_min_int( xmax%, xmin% + (ptr%!52) )
  306. >“?  ptr%!20 = ¤_max_int( 0, (xmin% + (ptr%!52)) - (ptr%!12) )
  307. >fi  ptr%!24 = 0
  308. >¨  ptr%!28 = stack%
  309. >²!  È− "Wimp_OpenWindow",, ptr%
  310. >¼"  ò_Release_Stack( ptr%, 512 )
  311. >Æá
  312. >Ð:
  313. >ÚKô *********************************************************************
  314. >äKô ***                        Icons                                  ***
  315. >îKô *********************************************************************
  316. >ø:
  317. ?'Ý ò_unselect_icon( window%, icon% )
  318. ?
  319. ê ptr%
  320. ?!  ptr% = ¤_Claim_Stack( 256 )
  321. ?   ptr%!00 = window%
  322. ?*  ptr%!04 = icon%
  323. ?4%  ptr%!08 = 0           :  ô  Eor
  324. ?>%  ptr%!12 = 1 << 21     :  ô  Bic
  325. ?H#  È− "Wimp_SetIconState",, ptr%
  326. ?R"  ò_Release_Stack( ptr%, 256 )
  327. ?\á
  328. ?f:
  329. ?p%Ý ò_select_icon( window%, icon% )
  330. ?z
  331. ê ptr%
  332. ?☓!  ptr% = ¤_Claim_Stack( 256 )
  333. ?‰  ptr%!00 = window%
  334. ?—  ptr%!04 = icon%
  335. ?¢%  ptr%!08 = 1 << 21     :  ô  Eor
  336. ?¬%  ptr%!12 = 1 << 21     :  ô  Bic
  337. ?¶#  È− "Wimp_SetIconState",, ptr%
  338. ?À"  ò_Release_Stack( ptr%, 256 )
  339. ?Êá
  340. ?Ô:
  341. ?Þ:Ý ò_Update_Icon(window%, icon%, number%, eor%, clear%)
  342. ê ptr%
  343. ?ò$   ptr%    = ¤_Claim_Stack( 16 )
  344. ?ü   ptr%!0  = window%
  345. @   ptr%!4  = icon%
  346. @    ptr%!8  = eor% << number%
  347. @"   ptr%!12 = clear% << number%
  348. @$$   È− "Wimp_SetIconState",, ptr%
  349. @."   ò_Release_Stack( ptr%, 16 )
  350. @8á
  351. @B:
  352. @L*: ô  Returns TRUE if icon is selected.
  353. @V-Ý ¤_Query_Icon_Selected( window%, icon% )
  354. @`ê ptr%, result%
  355. @j"  ptr%   = ¤_Claim_Stack( 64 )
  356. @t  !ptr%  = window%
  357. @~  ptr%!4 = icon%
  358. @⇦#  È− "Wimp_GetIconState",, ptr%
  359. @‹*  result% = ((ptr%!24) € (1 << 21))<>0
  360. @†!  ò_Release_Stack( ptr%, 64 )
  361. = result%
  362. @°:
  363. @º3Ý ò_Set_Select_Icon( window%, icon%, boolean% )
  364. ê ptr%
  365. @Î#  ptr%    = ¤_Claim_Stack( 16 )
  366. @Ø  !ptr%   = window%
  367. @â  ptr%!4  = icon%
  368. @ì)  ptr%!8  = (boolean%<>0) € (1 << 21)
  369. @ö  ptr%!12 = 1 << 21
  370. A#  È− "Wimp_SetIconState",, ptr%
  371. A
  372. !  ò_Release_Stack( ptr%, 16 )
  373. Aá
  374. A:
  375. A(2Ý ò_Set_Shade_Icon( window%, icon%, boolean% )
  376. A2
  377. ê ptr%
  378. A<#  ptr%    = ¤_Claim_Stack( 16 )
  379. AF  !ptr%   = window%
  380. AP  ptr%!4  = icon%
  381. AZ)  ptr%!8  = (boolean%<>0) € (1 << 22)
  382. Ad  ptr%!12 = 1 << 22
  383. An#  È− "Wimp_SetIconState",, ptr%
  384. Ax!  ò_Release_Stack( ptr%, 16 )
  385. Aŵá
  386. A…:
  387. A„+Ý ¤_Query_Icon_Shaded( window%, icon% )
  388. A ê ptr%, result%
  389. Aª"  ptr%   = ¤_Claim_Stack( 64 )
  390. A´  !ptr%  = window%
  391. A¾  ptr%!4 = icon%
  392. AÈ#  È− "Wimp_GetIconState",, ptr%
  393. AÒ%  result% = (ptr%!24) € (1 << 22)
  394. AÜ!  ò_Release_Stack( ptr%, 64 )
  395. Aæ= result%<>0
  396. Að:
  397. Aú7Ý ¤_Query_Icon_BackCol_And_Delete( window%, icon% )
  398. Bê result%, ptr%
  399. B!  ptr% = ¤_Claim_Stack( 512 )
  400. B  !ptr% = window%
  401. B"  ptr%!4 = icon%
  402. B,#  È− "Wimp_GetIconState",, ptr%
  403. B6   result% = (ptr%!24) >>> 28
  404. B@!  È− "Wimp_DeleteIcon",, ptr%
  405. BJ"  ò_Release_Stack( ptr%, 512 )
  406. BT
  407. = result%
  408. B^:
  409. Bh6Ý ò_Set_Icon_Foreground( window%, icon%, colour% )
  410. Br
  411. ê ptr%
  412. B|#  ptr%    = ¤_Claim_Stack( 64 )
  413. Bŷ  ptr%!0  = window%
  414. B‘  ptr%!4  = icon%
  415. BŒ1  ptr%!8  = (colour% € &F) << 24      : ô Eor
  416. B¤3  ptr%!12 = &F << 24                    : ô Bic
  417. B®#  È− "Wimp_SetIconState",, ptr%
  418. B¸!  ò_Release_Stack( ptr%, 64 )
  419. BÂá
  420. BÌ:
  421. BÖ6Ý ò_Check_Icon_In_Range( w%, icon%, mini%, maxi% )
  422. Bàê x%
  423. Bê(  x% = »(¤_Read_String( w%, icon% ))
  424. Bô  ç x%<mini% ☓ x%>maxi% …
  425. Bþ7    x% = ¤_min_int( maxi%, ¤_max_int( mini%, x% ) )
  426. C+    ò_Update_String( w%, icon%, Ã(x%) )
  427. C  Í
  428. Cá
  429. C&:
  430. C05: ô Place icon on the right hand side of icon bar
  431. C::
  432. CDÝ ò_Icon_Bar_Icon
  433. CN
  434. ê ptr%
  435. CX!  ptr% = ¤_Claim_Stack( 512 )
  436. Cb   ptr%!0  = -1 : ptr%!4  = 0
  437. Cl!  ptr%!8  = 0  : ptr%!12 = 68
  438. Cv$  ptr%!16 = 68 : ptr%!20 = &3002
  439. C€$  $(ptr%+24) = "!"+ Application$
  440. C⇩2  È− "Wimp_CreateIcon",, ptr% ¸ Icon_Bar_Icon%
  441. C“"  ò_Release_Stack( ptr%, 512 )
  442. Cfiá
  443. C¨:
  444. C²;: ô  The icon must be Sprite ONLY, NON-indirected data.
  445. C¼:
  446. CÆ.Ý ò_Rename_Icon( window%, icon%, sprite$ )
  447. CÐ0ê ptr%, xmin%, ymin%, xmax%, ymax%, xo%, yo%
  448. CÚ   ptr% = ¤_Claim_Stack( 64 )
  449. Cä  !ptr% = window%
  450. Cî  ptr%!4 = icon%
  451. Cø#  È− "Wimp_GetIconState",, ptr%
  452. D"  ç ((ptr%!24) € &103)<>&002 …
  453. D ;    Ŷ Wimp_Error_Fatal%, "Bad rename icon to "+ sprite$
  454. D  Í
  455. D !  È− "Wimp_DeleteIcon",, ptr%
  456. D*  $(ptr%+28) = sprite$
  457. D4  ptr%!4 = window%
  458. D>#  È− "Wimp_CreateIcon",, ptr%+4
  459. DHG  È− "Wimp_ForceRedraw", window%, ptr%!8, ptr%!12, ptr%!16, ptr%!20
  460. DR!  ò_Release_Stack( ptr%, 64 )
  461. D\á
  462. Df:
  463. Dp.: ô  A simple wrap around the system call.
  464. Dz:
  465. D☓Ý ¤_FixedFileSize( n% )
  466. D‰ê ptr%, result$
  467. D—   ptr% = ¤_Claim_Stack( 64 )
  468. D¢0  È− "OS_ConvertFixedFileSize", n%, ptr%, 64
  469. D¬   result$ = ¤getname( ptr% )
  470. D¶!  ò_Release_Stack( ptr%, 64 )
  471. = result$
  472. DÊ:
  473. DÔ.: ô  A simple wrap around the system call.
  474. DÞ:
  475. DèÝ ¤_FileSize( n% )
  476. Dòê ptr%, result$
  477. Dü   ptr% = ¤_Claim_Stack( 64 )
  478. E+  È− "OS_ConvertFileSize", n%, ptr%, 64
  479. E   result$ = ¤getname( ptr% )
  480. E!  ò_Release_Stack( ptr%, 64 )
  481. E$
  482. = result$
  483. E.:
  484. E8Kô *********************************************************************
  485. EBKô ***                          Errors                               ***
  486. ELKô *********************************************************************
  487. EV:
  488. E`G: ô  Should be called from a generic error handler, that relays the
  489. Ej1: ô  message via the standard wimp error box.
  490. Et7: ô  Exits after user has acknowledged the message.
  491. E~:
  492. E⇦!Ý ò_Wimp_Error( num%, text$ )
  493. E‹
  494. ê ptr%
  495. E†&  ptr%      = ¤_Claim_Stack( 300 )
  496. E¦  ptr%!0    = num%
  497. E°  $(ptr%+4) = text$+ ½(0)
  498. Eº   ò_Wimp_Error_Block( ptr% )
  499. EÄ"  ò_Release_Stack( ptr%, 300 )
  500. EÎá
  501. EØ:
  502. EâG: ô  Should be called from a generic error handler, that relays the
  503. Eì1: ô  message via the standard wimp error box.
  504. Eö7: ô  Exits after user has acknowledged the message.
  505. F:
  506. F
  507. (Ý ò_Wimp_Error_Block( error_block% )
  508. F
  509. ê ptr%
  510. F  ç Wimp_Active%<-1 …
  511. F(E    ò_Close_All_Menus                :  ô  Remove menus on error.
  512. F2  Í
  513. F<:  È− "Wimp_ReportError", error_block%, 1, Application$
  514. FFá
  515. FP:
  516. FZJ: ô  Use standard wimp error window, with window title "Message from "
  517. Fd: ô  + "<application>".
  518. Fn: ô  flags% == Bits
  519. Fx+: ô           0       provide an OK box
  520. Fŵ.: ô           1       provide a Cancel box
  521. F…D: ô           2       highlight Cancel (or OK if bit is cleared)
  522. F„I: ô           3       if error generated while a text-style window is
  523. F H: ô                   open (eg within a call to Wimp_CommandWindow),
  524. FªH: ô                   then don't produce the prompt "Press SPACE..."
  525. F´C: ô           4 {always} Don't prefix the application name with
  526. F¾7: ô                   "Error from" in the title bar
  527. FÈK: ô           5       If neither box is clicked return immediately with
  528. FÒ>: ô                   zero result, leaving the window open
  529. FÜJ: ô           6       Select one of the boxes according to bits 0 & 1,
  530. Fæ5: ô                   close the window and return
  531. Fð0: ô           7-31    reserved, must be zero
  532. Fú:
  533. G%Ý ¤_Custom_Error( flags%, text$ )
  534. Gê ptr%, result%
  535. GD  ò_Close_All_Menus                 :  ô  Remove menus on error.
  536. G"&  ptr%      = ¤_Claim_Stack( 260 )
  537. G,  !ptr%     = 0
  538. G6  $(ptr%+4) = text$+ ½(0)
  539. G@_  È− "Wimp_ReportError", ptr%, (%10000 ☓ flags%), "Message from "+ Application$ ¸ , result%
  540. GJ"  ò_Release_Stack( ptr%, 260 )
  541. GT
  542. = result%
  543. G^:
  544. GhI: ô  This is used to relay error message (probably) generated from an
  545. GrG: ô  ARM routine.  These all set global_error_block, so use this to
  546. G|: ô  report a system error.
  547. Gŷ:
  548. G‘*Ý ò_Query_Wimp_Global_Error( prefix$ )
  549. GŒê a%
  550. G¤  a% = !global_error_block
  551. G®  ç a%<>0 …
  552. G¸j    ò_Wimp_Error( 1, "A system error has occured: ("+ Ã(!a%)+ "): "+ prefix$+ ": "+ ¤getname(a% + 4) )
  553. G  Í
  554. GÌá
  555. GÖ:
  556. GàL: ô  This is MY error reporting system, as opposed to the above one.  It
  557. GêG: ô  uses the Query window found in the template file.  Because the
  558. Gô-: ô  mouse is restricted, should be safe.
  559. GþK: ô  The routine$ is the name of a function "FN_Stop_Action_"+ routine$
  560. HJ: ô  that gets passed TRUE for a click on YES, or FALSE for a click on
  561. H : ô  NO.
  562. H:
  563. H&(Ý ò_Stop_Action( string$, routine$ )
  564. H0*ê min_x%, min_y%, max_x%, max_y%, ptr%
  565. H:!  ptr% = ¤_Claim_Stack( 284 )
  566. HD-  ò_Update_String( Query_W%, 1, string$ )
  567. HN      ï 7
  568. HX0  !ptr% = ¤_Open_Window_Centered( Query_W% )
  569. Hb  !ptr% = Query_W%
  570. Hl%  È− "Wimp_GetWindowState",, ptr%
  571. Hv  min_x% = ptr%!4
  572. H€  min_y% = ptr%!8
  573. H⇩  max_x% = ptr%!12
  574. H“  max_y% = ptr%!16
  575. Hfi  ptr%?0 = 1
  576. H¨3  ptr%?1 = min_x% ◰ 256 : ptr%?2 = min_x% Ŵ 256
  577. H²3  ptr%?3 = min_y% ◰ 256 : ptr%?4 = min_y% Ŵ 256
  578. H¼3  ptr%?5 = max_x% ◰ 256 : ptr%?6 = max_x% Ŵ 256
  579. HÆ3  ptr%?7 = max_y% ◰ 256 : ptr%?8 = max_y% Ŵ 256
  580. HР È− "OS_Word", 21, ptr%
  581. HÚ"  ò_Release_Stack( ptr%, 284 )
  582. Hä  query_action$ = routine$
  583. Hîá
  584. Hø:
  585. II: ô  Internal routine, that restores mouse bounding box (well it sets
  586. I J: ô  it to the whole screen, which should be good enough), and deletes
  587. I: ô  the error box.
  588. I :
  589. I*Ý ò_Cancel_Stop
  590. I4
  591. ê ptr%
  592. I>!  ptr% = ¤_Claim_Stack( 256 )
  593. IH  ptr%?0 = 1
  594. IR  ptr%?1 = 0 : ptr%?2 = 0
  595. I\  ptr%?3 = 0 : ptr%?4 = 0
  596. If7  ptr%?5 = logmaxx% ◰ 256 : ptr%?6 = logmaxx% Ŵ 256
  597. Ip7  ptr%?7 = logmaxy% ◰ 256 : ptr%?8 = logmaxy% Ŵ 256
  598. Iz  È− "OS_Word", 21, ptr%
  599. I☓  !ptr% = Query_W%
  600. I‰"  È− "Wimp_CloseWindow",, ptr%
  601. I—"  ò_Release_Stack( ptr%, 256 )
  602. I¢á
  603. I¬:
  604. I¶L: ô  Query ONLY brought up by PROC_Stop_Action, this routine called when
  605. IÀG: ô  main wimp poll detected a mouse click inside the Query window.
  606. IÊ:
  607. IÔ.Ý ò_Mouse_Click_Query( x%, y%, b%, icon% )
  608. IÞê Ŷ
  609. Iè4î Ŷ ê ÷ Ŷ  :  ò_e( "%.Wimp: Mouse_Click_Query" )
  610. Iò  ò_Cancel_Stop
  611. IüG  x% =  ("FN_Stop_Action_"+ query_action$+ "( "+ Ã(icon%=0)+ " )" )
  612. Já
  613. J:
  614. J$Ý ¤_Stop_Action_( pressed_YES% )
  615. J$E  Ŷ Wimp_Error_Fatal%, "Illegal click in unclaimed query window."
  616. J.= £
  617. J8:
  618. JBH: ô Called when a "Save as" file name is invalid - because it has no
  619. JL5: ô leaf name (might be legal), or no period '.'.
  620. JVG: ô Brings up an error box (standard wimp) with a standard message.
  621. J`:
  622. JjÝ ò_Report_Bad_SaveAs
  623. JtX  x% = ¤_Custom_Error( %101, "To save, drag the file icon to a directory display." )
  624. J~á
  625. J⇦:
  626. J‹Kô *********************************************************************
  627. J†Kô ***                         Strings                               ***
  628. J¦Kô *********************************************************************
  629. J°:
  630. Jº+: ô  Wimp text string --> BASIC string.
  631. JÄ:
  632. JÎÝ ¤getname(p%)
  633. JØê p$:p$=""
  634. È” ?p%>31
  635. Jì  p$+=½(?p%):p%+=1
  636. JöÎ
  637. K=p$
  638. K
  639. :
  640. K0: ô  Returns string after last "." in input.
  641. K:
  642. K(Ý ¤leaf(f$)
  643. K2È” §f$,".")
  644. K<  f$=Áf$,§f$,".")+1)
  645. KFÎ
  646. KP=f$
  647. KZ:
  648. Kd<: ô  Updates an indirected Text Icon, then redraws it by
  649. Kn3: ô  Wimp_SetIconState with no change to flags.
  650. Kx:
  651. Kŵ+Ý ò_Update_String( window%, icon%, s$ )
  652. K…
  653. ê ptr%
  654. K„ ptr%=¤_Claim_Stack(256)
  655. K  ptr%!0=window%
  656. Kª ptr%!4=icon%
  657. K´! È− "Wimp_GetIconState",,ptr%
  658. K¾ $(ptr%!28)=s$
  659. KÈ' ò_Update_Icon(window%,icon%,1,0,0)
  660. KÒ% È− "Wimp_GetCaretPosition",,ptr%
  661. KÜ7 ç window%=ptr%!0 € icon%=ptr%!4 € ©(s$)<>ptr%!20 …
  662. KæG  È− "Wimp_SetCaretPosition",window%,icon%,-1,ptr%!12,ptr%!16,©(s$)
  663. Kð Í
  664. Kú! ò_Release_Stack( ptr%, 256 )
  665. Lá
  666. L:
  667. L&: ô  Get the indirected icon text.
  668. L":
  669. L,#Ý ¤_Read_String(window%, icon%)
  670. L6ê ptr%, s$
  671. L@   ptr%   =¤_Claim_Stack(256)
  672. LJ  ptr%!0 =window%
  673. LT  ptr%!4 =icon%
  674. L^"  È− "Wimp_GetIconState",,ptr%
  675. Lh  s$ = ¤getname(ptr%!28)
  676. Lr"  ò_Release_Stack( ptr%, 256 )
  677. L|=s$
  678. Lŷ:
  679. L‘4:  ô  Get the VALue of the indirected icon text.
  680. LŒ:
  681. L¤)Ý ¤_Read_String_Val( window%, icon% )
  682. L®(= »(¤_Read_String( window%, icon% ))
  683. L¸:
  684. LÂKô *********************************************************************
  685. LÌKô ***                       Templates                               ***
  686. LÖKô *********************************************************************
  687. Là:
  688. LêH: ô  Primitive to load a named window from the (open) template file.
  689. Lô:
  690. Lþ4Ý ¤_Load_Template( id$, rove%, sprite_pointer% )
  691. Mê result%, r0%, C%
  692. M&  $template_name% = id$+ "*"+ ½(0)
  693. Ml  È− "XWimp_LoadTemplate",, template_file%, rove%, inddata_end%, -1, template_name% ¸ r0%,, indrove%; C%
  694. M&5  ç ¤_PSR_V_Set( C% ) … Ŷ !r0%, ¤getname( r0%+4 )
  695. M0'  ç ¤getname(template_name%)<>id$ …
  696. M:g    Ŷ Wimp_Error_Fatal%, "Template file corrupt, couldn't find window with '"+ id$+ "' identifier."
  697. MD  Í
  698. MN)  template_file%!64 = sprite_pointer%
  699. MX7  È− "Wimp_CreateWindow",, template_file% ¸ result%
  700. Mb
  701. = result%
  702. Ml:
  703. MvJ: ô  This is used by template loader when loading in sprite / template
  704. M€-: ô  file, though can be used else where.
  705. M⇩L: ô  Returns length of file [0, &7FFFFFFF], or -1 if file doesn't exist.
  706. M“:
  707. Mfi"Ý ¤_XSizeof_File( file_name$ )
  708. M¨ê r0%, length%, c%
  709. M²9  È− "XOS_File", 17, file_name$ ¸ r0%,,,, length%; c%
  710. M¼  ç ¤_PSR_V_Set(c%) …
  711. MÆc    Ŷ Wimp_Error_Fatal%, "Couldn't load in "+ ¤leaf( file_name$ )+ " file: "+ ¤getname( r0%+4 )
  712. MР Í
  713. MÚ  ç r0%<>1 …
  714. Mä3    length% = -1        :  ô  Indicate missing.
  715. Mî  Í
  716. = length%
  717. N:
  718. N Kô *********************************************************************
  719. NKô ***                       Local Stacks                            ***
  720. N Kô *********************************************************************
  721. N*:
  722. N4Ý ¤_Claim_Stack( size% )
  723. N>
  724. ê result%
  725. NH1  ç (Wimp_Stack_Top%+size%)<Wimp_Stack_End% …
  726. NR)    result%         = Wimp_Stack_Top%
  727. N\     Wimp_Stack_Top% += size%
  728. Nf  Ì
  729. Np/    Ŷ Wimp_Error_Fatal%, "Wimp Stack full."
  730. Nz  Í
  731. N☓
  732. = result%
  733. N‰:
  734. N—&Ý ò_Release_Stack( start%, size% )
  735. N¢9  ç (start%<Wimp_Stack%) ☓ (start%>Wimp_Stack_End%) …
  736. N¬B    Ŷ Wimp_Error_Fatal%, "Release_Stack: Invalid stack chunk."
  737. N¶  Ì
  738. NÀ8    ç (size%<0) ☓ ((start%+size%)>Wimp_Stack_End%) …
  739. NÊC      Ŷ Wimp_Error_Fatal%, "Release_Stack: Invalid chunk size."
  740. NÔ        Ì
  741. NÞ"      Wimp_Stack_Top% -= size%
  742. Nè%      ç Wimp_Stack_Top%<>start% …
  743. Nò9        Ŷ Wimp_Error_Fatal%, "Release_Stack: Bad pop"
  744. Nü       Í
  745. O        Í
  746. O  Í
  747. Oá
  748. O$:
  749. O.Kô *********************************************************************
  750. O8Kô ***                   Generic Wimp Initialise                     ***
  751. OBKô *********************************************************************
  752. OLKô ***         CALLS                                                 ***
  753. OVKô ***                 PROC_Init_Menus                               ***
  754. O`Kô ***                 PROC_Init_Template                            ***
  755. OjKô ***         SETS                                                  ***
  756. OtKô ***                 Icon_Bar_Icon%                                ***
  757. O~Kô ***                 Application$                                  ***
  758. O⇦Kô ***                 Version$                                      ***
  759. O‹Kô ***                 Task_Handle%                                  ***
  760. O†Kô ***                 ProgInfo_W%                                   ***
  761. O¦Kô ***                 Query_W%                                      ***
  762. O°Kô ***                 Wimp_Poll_Mask%                               ***
  763. OºKô ***   ERROR Handler --> PROC_Wimp_Error( 0, REPORT$+ line )       ***
  764. OÄKô *********************************************************************
  765. OÎ3ô * IN   application name, version, sub-version
  766. OØCô *      day of month [1, 31], month [1, 12], year {2/4 digits}
  767. Oâ:
  768. OìAÝ ò_Generic_Init_Wimp( name$, v%, s_v%, day%, month%, year% )
  769. Oö=  Version$ = Ã(v%)+ "."+ Ã(s_v%)+ " ("+ Â"0"+ Ã(day%), 2)
  770. P  Version$ += "-"
  771. P
  772. I  Version$ += Á"CBJanFebMarAprMayJunJulAugSepOctNovDec", month%*3, 3)
  773. P/  Version$ += "-"+ Â"19"+ Ã(year%), 4)+ ")"
  774. P  :
  775. P(  Application$ = name$
  776. P2  :
  777. P<D  È− "Wimp_Initialise", 200, &4B534154, name$ ¸ v%, Task_Handle%
  778. PF#  î Ŷ ò_Generic_Init_Wimp_Error
  779. PP  ç v%<200 …
  780. PZ`    Ŷ Wimp_Error_Fatal%, "Application requires a more recent version of the Window Manager."
  781. Pd  Í
  782. Pn  Wimp_Active% = ¹
  783. Px  :
  784. Pŵ  ò_Generic_Init_Template
  785. P…  ò_Init_Menus
  786. P„  :
  787. P G  Wimp_Active% = -2             :  ô  Now valid to close all menus.
  788. Pª  :
  789. P´A  ò_Icon_Bar_Icon            :  ô  Ensure something on there.
  790. P¾;  ò_Init_Null_Reason         :  ô  Sets Wimp_Poll_Mask%
  791. PÈ  :
  792. PÒ1  ò_Update_String( ProgInfo_W%, 7, Version$ )
  793. PÜ  :
  794. Pæ@  my_ref%    = -1               :  ô  For message protocols.
  795. Pð  save_ref%  = -1
  796. Pú  scrap_ref% = -1
  797. Q  :
  798. Q<  ò_Message_ModeChange       :  ô  Set up any variables.
  799. Qá
  800. Q":
  801. Q,Ý ò_Generic_Init_Wimp_Error
  802. Q6;  ò_Wimp_Error( Wimp_Error_Fatal%, ö$+ " ["+ Ãfi+ "]." )
  803. Q@  ò_Wimp_CloseDown
  804. QJ  à
  805. QTá
  806. Q^:
  807. QhKô *********************************************************************
  808. QrKô ***                   Wimp Polling loop                           ***
  809. Q|Kô *********************************************************************
  810. QŷKô ***         CALLS                                                 ***
  811. Q‘Kô ***                 PROC_Null_Reason_Code           [internal]    ***
  812. QŒKô ***                 PROC_Redraw_Window_Request                    ***
  813. Q¤Kô ***                 PROC_Open_Window_Request                      ***
  814. Q®Kô ***                 PROC_Close_Window_Request                     ***
  815. Q¸Kô ***                 PROC_Pointer_Leaving_Window     [ignored]     ***
  816. QÂKô ***                 PROC_Pointer_Entering_Window    [ignored]     ***
  817. QÌKô ***                 PROC_Mouse_Click                              ***
  818. QÖKô ***                 PROC_User_Drag_Box              [internal]    ***
  819. QàKô ***                 PROC_Key_Pressed                              ***
  820. QêKô ***                 PROC_Menu_Selection                           ***
  821. QôKô ***                 PROC_Scroll_Request             [ignored]     ***
  822. QþKô ***                 PROC_Lose_Caret                 [ignored]     ***
  823. RKô ***                 PROC_Gain_Caret                 [ignored]     ***
  824. RKô ***                 PROC_User_Message               [internal]    ***
  825. RKô ***                 PROC_User_Message_Recorded      [internal]    ***
  826. R&Kô ***                 PROC_User_Message_Acknowledge   [ignored]     ***
  827. R0Kô ***         USES                                                  ***
  828. R:Kô ***                 Do_Wimp%                                      ***
  829. RDKô *********************************************************************
  830. RN:
  831. RXÝ ò_Activate_Wimp
  832. Rbê Action%, Do_Wimp%
  833. Rl  Do_Wimp% = ¹
  834. Rv  õ
  835. R€5    È− "Wimp_Poll", Wimp_Poll_Mask%, W% ¸ Action%
  836. R⇩    È‰ Action% Ê
  837. R“!    É 0  : ò_Null_Reason_Code
  838. Rfi&    É 1  : ò_Redraw_Window_Request
  839. R¨$    É 2  : ò_Open_Window_Request
  840. R²%    É 3  : ò_Close_Window_Request
  841. R¼'    É 4  : ò_Pointer_Leaving_Window
  842. RÆ(    É 5  : ò_Pointer_Entering_Window
  843. RР   É 6  : ò_Mouse_Click
  844. RÚ    É 7  : ò_User_Drag_Box
  845. Rä    É 8  : ò_Key_Pressed
  846. Rî    É 9  : ò_Menu_Selection
  847. Rø    É 10 : ò_Scroll_Request
  848. S    É 11 : ò_Lose_Caret
  849. S     É 12 : ò_Gain_Caret
  850. S    É 17 : ò_User_Message
  851. S &    É 18 : ò_User_Message_Recorded
  852. S*)    É 19 : ò_User_Message_Acknowledge
  853. S4        Ë
  854. S>  ý ¬(Do_Wimp%)
  855. SHá
  856. SR:
  857. S\: ô  +0  = Window.
  858. Sf:
  859. SpÝ ò_Pointer_Leaving_Window
  860. SzD  Ŷ Wimp_Error_Fatal%, "Unexpected Pointer_Leaving_Window poll."
  861. S☓á
  862. S‰:
  863. S—Ý ò_Pointer_Entering_Window
  864. S¢E  Ŷ Wimp_Error_Fatal%, "Unexpected Pointer_Entering_Window poll."
  865. S‡
  866. S¶:
  867. SÀ: ô  +0  = Window.
  868. SÊ1: ô  +4  = Visible area minimum x co-ordinate
  869. SÔ1: ô  +8  = Visible area minimum y co-ordinate
  870. SÞ1: ô  +12 = Visible area maximum x co-ordinate
  871. Sè1: ô  +16 = Visible area maximum y co-ordinate
  872. Sò;: ô  +20 = Scroll x offset relative to work area origin
  873. Sü;: ô  +24 = Scroll y offset relative to work area origin
  874. TG: ô  +28 = Handle to open window behind (-1 means top of the window
  875. T&: ô        stack, -2 means bottom)
  876. T!: ô  +32 = Scroll x direction
  877. T$!: ô  +36 = Scroll y direction
  878. T.: ô  These last two are
  879. T8I: ô           -2      Page left/down (click in scroll bar outer area)
  880. TB;: ô           -1      Left/down (click on scroll arrow)
  881. TL#: ô           0       No change
  882. TV:: ô           +1      Right/up (click on scroll arrow)
  883. T`H: ô           +2      Page right/up (click in scroll bar outer area)
  884. Tj:
  885. TtÝ ò_Scroll_Request
  886. T~<  Ŷ Wimp_Error_Fatal%, "Unexpected Scroll_Request poll."
  887. T⇦á
  888. T‹:
  889. T†B: ô  +0  = Window handle that had the input focus (-1 if none)
  890. T¦': ô  +4  = Icon handle (-1 if none)
  891. T°<: ô  +8  = X-offset of caret (relative to window origin)
  892. Tº<: ô  +12 = Y-offset of caret (relative to window origin)
  893. TÄ%: ô  +16 = Caret height and flags
  894. TÎL: ô  +20 = Index of caret into string (or -1 if not in a writeable icon)
  895. TØL: ô  Event not generated if the input focus only changes position within
  896. Tâ: ô  the same window.
  897. Tì:
  898. TöÝ ò_Lose_Caret
  899. U8  Ŷ Wimp_Error_Fatal%, "Unexpected Lose_Caret poll."
  900. U
  901. U:
  902. UÝ ò_Gain_Caret
  903. U(8  Ŷ Wimp_Error_Fatal%, "Unexpected Gain_Caret poll."
  904. U2á
  905. U<:
  906. UF Ý ò_User_Message_Acknowledge
  907. UPá
  908. UZ:
  909. UdKô *********************************************************************
  910. UnKô ***                 Generic Template loader                       ***
  911. UxKô *********************************************************************
  912. UŵKô *** Loads a Sprites file, if it exists, into the heap at          ***
  913. U…Kô *** W_Sprites%.  Next it loads in the template file, and reads in ***
  914. U„Kô *** the standard Query_W% and ProgInfo_W% windows, before passing ***
  915. U Kô *** control to PROC_Init_Template.  This routine should call      ***
  916. UªKô *** PROC_Load_Template( id$, indrove%, <sprites> ), where sprites ***
  917. U´Kô *** would be either W_Sprites% or +1 (for wimp sprites).          ***
  918. U¾Kô *********************************************************************
  919. UÈ:
  920. UÒÝ ò_Generic_Init_Template
  921. UÜ>ê inddata_end%, inddata%, indrove%, length%, r0%, c%, ptr%
  922. Uæ+ê template_file%, file$, template_name%
  923. Uð  :
  924. Uú2  file$   = "<"+ Application$+ "$Dir>.Sprites"
  925. V'  length% = ¤_XSizeof_File( file$ )
  926. V  ç length%>0 …
  927. V6    ò_Claim_Heap_Block( W_Sprites%, length% + 16 )
  928. V"$    W_Sprites%!0  = length% + 16
  929. V,    W_Sprites%!4  = 0
  930. V6    W_Sprites%!8  = 16
  931. V@    W_Sprites%!12 = 16
  932. VJ<    È− "XOS_SpriteOp", &20A, W_Sprites%, file$ ¸ r0%; c%
  933. VT    ç ¤_PSR_V_Set(c%) …
  934. V^U      Ŷ Wimp_Error_Fatal%, "Couldn't load in Sprites file: "+ ¤getname( r0%+4 ) )
  935. Vh        Í
  936. Vr  Ì
  937. V|    W_Sprites% = 0
  938. Vŷ  Í
  939. V‘  :
  940. VŒ4  file$   = "<"+ Application$+ "$Dir>.Templates"
  941. V¤'  length% = ¤_XSizeof_File( file$ )
  942. V®  ç length%<=0 …
  943. V¸<    Ŷ Wimp_Error_Fatal%, "Couldn't find Templates file."
  944. V  Í
  945. VÌ-  ò_Claim_Heap_Block( inddata%, length% )
  946. VÖ'  inddata_end% = inddata% + length%
  947. Và3  ò_Claim_Heap_Block( template_file%, length% )
  948. Vê.  ò_Claim_Heap_Block( template_name%, 16 )
  949. Vô/  È− "XWimp_OpenTemplate",, file$ ¸ r0%; c%
  950. Vþ  ç ¤_PSR_V_Set(c%) …
  951. WT     Ŷ Wimp_Error_Fatal%, "Couldn't load in Templates file: "+ ¤getname( r0%+4 )
  952. W  Í
  953. W  ç W_Sprites%>0 …
  954. W&I    ProgInfo_W% = ¤_Load_Template( "ProgInfo", inddata%, W_Sprites% )
  955. W0  Ì
  956. W:A    ProgInfo_W% = ¤_Load_Template( "ProgInfo", inddata%, +1 )
  957. WD  Í
  958. WN<  Query_W%    = ¤_Load_Template( "Query", indrove%, +1 )
  959. WX  ò_Init_Template
  960. Wb  È− "Wimp_CloseTemplate"
  961. Wl,  ò_Release_Heap_Block( template_name% )
  962. Wv,  ò_Release_Heap_Block( template_file% )
  963. Wۇ
  964. W⇩:
  965. W“Kô *********************************************************************
  966. WfiKô ***                 Null reason code handler                      ***
  967. W¨Kô *********************************************************************
  968. W²Kô *** A primitive "null reason" handler.  This allows an appl'tion  ***
  969. W¼Kô *** to have a queue of events to perform on a null reason.        ***
  970. WÆKô *** Better than nothing.                                          ***
  971. WÐKô *********************************************************************
  972. WÚ:
  973. WäÝ ò_Init_Null_Reason
  974. Wî  max_null_queue% = 10
  975. Wø-  Þ null_reason_queue$( max_null_queue% )
  976. X  null_reason$        = ""
  977. X   next_null_queue%    = 0
  978. X  do_next_null_queue% = 0
  979. X   :
  980. X*&  Wimp_Poll_Mask% = %1100000110001
  981. X4á
  982. X>:
  983. XHC: ô  Should really kill current null, or allow several at once.
  984. XR1: ô  This method is really a queueing system.
  985. X\H: ô  reason$ is the suffix of a function with a prefix _Null_Reason_
  986. XfI: ô  that should return TRUE if the routine should stop being called.
  987. Xp:
  988. Xz$Ý ò_Claim_Null_Reason( reason$ )
  989. X☓  ç null_reason$<>"" …
  990. X‰6    null_reason_queue$(next_null_queue%) = reason$
  991. X—,    ç next_null_queue%<max_null_queue% …
  992. X¢      next_null_queue% += 1
  993. X¬        Í
  994. X¶  Ì
  995. XÀ    null_reason$ = reason$
  996. XÊ2    Wimp_Poll_Mask% = Wimp_Poll_Mask% € (¬(1))
  997. XÔ  Í
  998. XÞá
  999. Xè:
  1000. Xò6: ô  Should really only ever be called internally.
  1001. Xü:
  1002. Y&Ý ò_Release_Null_Reason( reason$ )
  1003. Y  ç next_null_queue%>0 …
  1004. Y@    null_reason$ = null_reason_queue$( do_next_null_queue% )
  1005. Y$/    ç do_next_null_queue%<max_null_queue% …
  1006. Y."      do_next_null_queue% += 1
  1007. Y8        Í
  1008. YB0    ç do_next_null_queue%=next_null_queue% …
  1009. YL!      do_next_null_queue% = 0
  1010. YV!      next_null_queue%    = 0
  1011. Y`        Í
  1012. Yj  Ì
  1013. Yt!    ç null_reason$<>reason$ …
  1014. Y~N      Ŷ Wimp_Error_Fatal%, "Bad release null reason code ("+ reason$+ ")."
  1015. Y⇦        Í
  1016. Y‹    null_reason$ = ""
  1017. Y†-    Wimp_Poll_Mask% = Wimp_Poll_Mask% ☓ 1
  1018. Y¦  Í
  1019. Y°á
  1020. Yº:
  1021. YÄ): ô  Called from main wimp poll loop.
  1022. YÎ=: ô  Only allow one routine per poll, named null_reason$.
  1023. YØ:
  1024. YâÝ ò_Null_Reason_Code
  1025. Yìê Ŷ
  1026. Yö1î Ŷ ê ÷ Ŷ : ò_e( "%.Wimp: Null_Reason_Code" )
  1027. Z,  ç  ("FN_Null_Reason_"+ null_reason$) …
  1028. Z
  1029. -    ò_Release_Null_Reason( null_reason$ )
  1030. Z  Í
  1031. Zá
  1032. Z(:
  1033. Z2Ý ¤_Null_Reason_
  1034. Z<<  Ŷ Wimp_Error_Fatal%, "Bad Null Reason (not expected)."
  1035. ZF= 0
  1036. ZP:
  1037. ZZKô *********************************************************************
  1038. ZdKô ***               User Drag box handler code                      ***
  1039. ZnKô *********************************************************************
  1040. Zx:
  1041. ZŵÝ ò_User_Drag_Box
  1042. Z…ê x%
  1043. Z„ê Ŷ
  1044. Z *î Ŷ ê ÷ Ŷ : ò_e( "%.Wimp: User_Drag" )
  1045. Zª%  x% =  ("FN_Dragged_"+ dragged$)
  1046. Z´!  ç dragged_button%<>(1*16) …
  1047. Z¾    ò_Close_All_Menus
  1048. ZÈ  Í
  1049. ZÒ,  È− "Wimp_DragBox",, -1 : dragged$ = ""
  1050. ZÜá
  1051. Zæ:
  1052. ZðÝ ¤_Dragged_
  1053. Zúê ptr%, w%, i%
  1054. [@  Ŷ Wimp_Error_Fatal%, "Bad User_Drag, dragged$ not set up."
  1055. [= 0
  1056. [:
  1057. ["H: ô  Called when noticed a mouse click of a "drag" type over a valid
  1058. [,G: ô  icon, this will then cause "FN_Dragged_"+routine$ to be called
  1059. [6": ô  when user stops the drag.
  1060. [@:
  1061. [J:Ý ò_Initiate_Drag( window%, icon%, button%, routine$ )
  1062. [Tê ptr%, ptr2%, sx%, sy%
  1063. [^!  ptr%  = ¤_Claim_Stack( 64 )
  1064. [h"  ptr2% = ¤_Claim_Stack( 256 )
  1065. [r  ptr%!0 = window%
  1066. [|  ptr%!4 = icon%
  1067. [ŷ#  È− "Wimp_GetIconState",, ptr%
  1068. [‘  ptr2%!0 = window%
  1069. [Œ&  È− "Wimp_GetWindowState",, ptr2%
  1070. [¤  sx%     = ptr2%!20
  1071. [®  sy%     = ptr2%!24
  1072. [¸  ptr%!0  = window%
  1073. [  ptr%!4  = 5
  1074. [Ì;  ptr%!8  += ptr2%!4  - sx%           :  ô Min screen X
  1075. [Ö;  ptr%!12 += ptr2%!16 - sy%           :  ô Min screen Y
  1076. [à4  ptr%!16 += ptr2%!4  - sx%           :  ô Max X
  1077. [ê4  ptr%!20 += ptr2%!16 - sy%           :  ô Max Y
  1078. [ô  ptr%!24 = 0
  1079. [þ  ptr%!28 = 0
  1080. \  ptr%!32 = logmaxx%
  1081. \  ptr%!36 = logmaxy%
  1082. \  È− "Wimp_DragBox",, ptr%
  1083. \&#  ò_Release_Stack( ptr2%, 256 )
  1084. \0!  ò_Release_Stack( ptr%, 64 )
  1085. \:  dragged$ = routine$
  1086. \D  dragged_button% = button%
  1087. \Ná
  1088. \X:
  1089. \bKô *********************************************************************
  1090. \lKô ***                   Initiate a save                             ***
  1091. \vKô *********************************************************************
  1092. \€:
  1093. \⇩I: ô  Usually used after a user has dragged a file icon from a Save as
  1094. \“A: ô  sub-menu.  It is entered with the mouse pointer over the
  1095. \fi1: ô  destination, which gets set the message.
  1096. \¨:
  1097. \²8Ý ò_Send_Save( filetype%, file_name$, file_length% )
  1098. \¼"ê ptr%, window%, icon%, x%, y%
  1099. \Æ!  ptr% = ¤_Claim_Stack( 320 )
  1100. \Ð%  È− "Wimp_GetPointerInfo",, ptr%
  1101. \Ú  x%      = !ptr%
  1102. \ä  y%      = ptr%!4
  1103. \î  window% = ptr%!12
  1104. \ø  icon%   = ptr%!16
  1105. ])  !ptr%   = (©(file_name$) + 48) € -4
  1106. ]   ptr%!12 = 0
  1107. ]  ptr%!16 = 1
  1108. ]   ptr%!20 = window%
  1109. ]*  ptr%!24 = icon%
  1110. ]4  ptr%!28 = x%
  1111. ]>  ptr%!32 = y%
  1112. ]H  ptr%!36 = file_length%
  1113. ]R  ptr%!40 = filetype%
  1114. ]\$  $(ptr%+44) = file_name$ + ½(0)
  1115. ]f5  È− "Wimp_SendMessage", 17, ptr%, window%, icon%
  1116. ]p  save_ref% = ptr%!8
  1117. ]z"  ò_Release_Stack( ptr%, 320 )
  1118. ]☓á
  1119. ]‰:
  1120. ]—Kô *********************************************************************
  1121. ]¢Kô ***                 Wimp message handling                         ***
  1122. ]¬Kô *********************************************************************
  1123. ]¶Kô ***         CALLS                                                 ***
  1124. ]ÀKô ***                 PROC_Wimp_CloseDown                           ***
  1125. ]ÊKô ***                 PROC_Message_DataSave                         ***
  1126. ]ÔKô ***                 PROC_Message_DataSaveAck                      ***
  1127. ]ÞKô ***                 PROC_Message_DataLoad                         ***
  1128. ]èKô ***                 PROC_Message_DataLoadAck                      ***
  1129. ]òKô ***                 PROC_Message_DataOpen                         ***
  1130. ]üKô ***                 PROC_Message_PreQuit                          ***
  1131. ^Kô ***                 PROC_Message_Pallette           [ignored]     ***
  1132. ^Kô ***                 PROC_Message_Help                             ***
  1133. ^Kô ***                 PROC_Message_MenuWarning                      ***
  1134. ^$Kô ***                 PROC_Message_ModeChange                       ***
  1135. ^.Kô ***                 PROC_Message_SetSlot            [ignored]     ***
  1136. ^8Kô ***                 FN_Doc_Modified                               ***
  1137. ^BKô *********************************************************************
  1138. ^L:
  1139. ^VÝ ò_User_Message_Recorded
  1140. ^`ê Ŷ
  1141. ^j6î Ŷ ê ÷ Ŷ : ò_e( "%.Wimp: User_Message_Recorded" )
  1142. ^t  ò_User_Message
  1143. ^~á
  1144. ^⇦:
  1145. ^‹Ý ò_User_Message
  1146. ^†ê Ŷ
  1147. ^¦-î Ŷ ê ÷ Ŷ : ò_e( "%.Wimp: User_Message" )
  1148. ^°  È‰ W%!16 Ê
  1149. ^º#    É 0      : ò_Wimp_CloseDown
  1150. ^Ä%    É 1      : ò_Message_DataSave
  1151. ^Î(    É 2      : ò_Message_DataSaveAck
  1152. ^Ø%    É 3      : ò_Message_DataLoad
  1153. ^â(    É 4      : ò_Message_DataLoadAck
  1154. ^ì%    É 5      : ò_Message_DataOpen
  1155. ^ö$    É 8      : ò_Message_PreQuit
  1156. _%    É 9      : ò_Message_Pallette
  1157. _
  1158. !    É &502   : ò_Message_Help
  1159. _(    É &400C0 : ò_Message_MenuWarning
  1160. _'    É &400C1 : ò_Message_ModeChange
  1161. _($    É &400C5 : ò_Message_SetSlot
  1162. _2  Ë
  1163. _<á
  1164. _F:
  1165. _PÝ ò_Message_SetSlot
  1166. _Zá
  1167. _d:
  1168. _nÝ ò_Message_Pallette
  1169. _xá
  1170. _ŵ:
  1171. _…$ô Last line of <BasicV$Lib>.Wimp
  1172. ÿ