home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / bascompress / bascompress_1 / Examples_Wimp_Wimp (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1994-11-27  |  6.2 KB  |  190 lines

  1.   >Wimp
  2. : Typical wimp library routine examples for BasCompress
  3. C Note that use 
  4. eval() rather than 
  5. .  This is a simple routine
  6. ? that, depending on a debugging variable, traps any errors.
  7.   Query ONLY brought up by PROC_Stop_Action, this routine called when
  8.   main wimp poll detected a mouse click inside the Query window.
  9. _Mouse_Click_Query(x%, y%, b%, icon%)
  10. _Cancel_Stop
  11. H  x% = 
  12. eval("FN_Stop_Action_"+ query_action$+ "("+ 
  13. (icon%=0)+ ")")
  14. _Stop_Action_(pressed_YES%)
  15. _Wimp_Error(Wimp_Error_Fatal%, "Illegal click in unclaimed query window")
  16. _Load_Template_Extra(id$, rove%, sprite_pointer%, routine$)
  17.  result%, r0%, C%
  18. &  $template_name% = id$+ "*"+ 
  19.  "XWimp_LoadTemplate",, template_file%, rove%, inddata_end%, -1, template_name%, 0 
  20.  r0%,, indrove%; C%
  21. _PSR_V_Set(C%) 
  22. _Wimp_Error_Block(r0%)
  23. _Wimp_CloseDown
  24. getname(template_name%)<>id$ 
  25. +    
  26. _Set_Message_String("Reason", id$)
  27. 2    
  28. _Wimp_Error(Wimp_Error_Fatal%, 
  29. LEMsg(3))
  30. _Wimp_CloseDown
  31. !)  template_file%!64 = sprite_pointer%
  32.  routine$<>"" 
  33. eval("FN"+ routine$)
  34.  "Wimp_CreateWindow",, template_file% 
  35.  result%
  36. = result%
  37.   Called from main wimp poll loop
  38.   Allow multiple routines
  39. _Null_Reason_Code
  40.  n%, r$
  41.   n% = n_null%
  42.  n%>0
  43.     n% -= 1
  44.     r$ = null_q$(n%)
  45.  r$<>Null$ 
  46. 0*      
  47. eval("FN_Null_Reason_"+ r$) 
  48. 1"        
  49.  null_q$(n%)<>Null$ 
  50.           n_null% -= 1
  51.         
  52.       
  53. 5        
  54. _User_Drag_Box
  55. <)  x% = 
  56. eval("FN_Dragged_"+ dragged$)
  57.  dragged_button%<>(1*16) 
  58. _Close_All_Menus
  59.  "Wimp_DragBox",, -1 : dragged$ = ""
  60.  *********************************************************************
  61.  This can be used to drag anything
  62.  When the pointer leaves the window the window's scrolled in the
  63.  opposite direction
  64.  w%                  window
  65.  b%                  current mouse buttons
  66.  type%               type of drag to perform (5, 6, or 7)
  67.  xmin...ymax%        box to drag (screen)
  68.  Xmin...Ymax%        parent box (screen)
  69.  Wxmin..Wxmax%       windows' work area extent, (0=>find out)
  70.  routine$            call FN_Dragged_<routine$> at end
  71. _DragBoxScrollWindow(w%, b%, type%, xmin%, ymin%, xmax%, ymax%, Xmin%, Ymin%, Xmax%, Ymax%, Wxmin%, Wymin%, Wxmax%, Wymax%, routine$)
  72.  P%, l%
  73.   l% = 64
  74.   P% = 
  75. _Claim_Stack(l%)
  76.   P%!00 = type%
  77.   P%!04 = xmin%
  78.   P%!08 = ymin%
  79.   P%!12 = xmax%
  80.   P%!16 = ymax%
  81.   P%!20 = Xmin%
  82.   P%!24 = Ymin%
  83.   P%!28 = Xmax%
  84.   P%!32 = Ymax%
  85.   P%!36 = Wxmin%
  86.   P%!40 = Wymin%
  87.   P%!44 = Wxmax%
  88.   P%!48 = Wymax%
  89.  "CAssembler_Window", Window_DragBoxScroll, w%, P%
  90. b)  dragged_BoxScrollWindow$ = routine$
  91. c2  dragged$                 = "BoxScrollWindow"
  92. d#  dragged_button%          = b%
  93. _Release_Stack(P%, l%)
  94. _Dragged_BoxScrollWindow
  95. eval("FN_Dragged_"+ dragged_BoxScrollWindow$)
  96.  *********************************************************************
  97.  This can be used to drag a window about, usually dragging "background"
  98.  It will scroll in the direction the mouse moves in
  99.  w%                  window
  100.  b%                  current mouse buttons
  101.  x%, y%              current mouse x, y
  102.  xmin..ymax%         windows' work area extent, (0=>find out)
  103.  routine$            call FN_Dragged_<routine$> at end
  104. _DragScrollWindow(w%,b%, x%,y%, xmin%,ymin%,xmax%,ymax%, routine$)
  105.  "CAssembler_Window",Window_DragScroll,w%,x%,y%,xmin%,ymin%,xmax%,ymax%
  106. w'  dragged_ScrollWindow$  = routine$
  107. x-  dragged$               = "ScrollWindow"
  108. y!  dragged_button%        = b%
  109. _Dragged_ScrollWindow
  110.  dragged_ScrollWindow$<>"" 
  111. ~5    
  112. eval("FN_Dragged_"+ dragged_ScrollWindow$)
  113. _Message_RAM_Transmit
  114.  W%!12<>RAM_Load_Ref% 
  115. _Wimp_Error(Wimp_Error%, "Unexpected RAM_Transmit message")
  116. H   RAM_Load_Size% += W%!24                      :
  117.  #bytes transfered
  118.  (W%!24)=RAM_Load_Buffer_Length% 
  119. @     
  120. _RAM_Load                              :
  121.  Ask for more
  122.      :
  123. A     : 
  124.   Buffer not full, so all loaded - end communications
  125.      :
  126. Z     
  127. eval("FN_RAM_Load_Completed_"+ RAM_Load_Routine$+ "("+
  128. (RAM_Load_Size%)+")") 
  129.        
  130. _Wimp_LError(6)
  131.      
  132.   Called to request that the application reserve some memory for more
  133.   of a file to be loaded via the RAM transfer protocol
  134. _RAM_Load
  135.  RAM_start%
  136. eval("FN_RAM_Load_"+ RAM_Load_Routine$+ "("+
  137. (RAM_Load_Size%)+", "+
  138. (RAM_Load_Buffer_Length%)+", RAM_start%)") 
  139.  RAM_Load_Size%<>0 
  140.       
  141. _Wimp_LError(7)
  142.         
  143. ;      
  144. eval("FN_RAM_Load_Failed_"+ RAM_Load_Routine$)
  145. @      
  146. _RAM_WimpScrap_Load                   :
  147.  Try this way
  148.         
  149.     W%!12 = W%!8
  150. E    W%!16 = 6                                   :
  151.  Send RAM_Fetch
  152.     W%!20 = RAM_start%
  153. '    W%!24 = RAM_Load_Buffer_Length%
  154. C    
  155.  "Wimp_SendMessage", 18, W%, W%!4        :
  156.  Send recorded
  157.     RAM_Load_Ref% = W%!8
  158. _Message_RAM_Fetch
  159.  x, RAM_start%, RAM_length%
  160.  W%!12<>save_ref% 
  161. _Wimp_LError(9)
  162.  RAM_Save_Routine$="" 
  163.      :
  164. L     : 
  165.   Application won't handle RAM transfer - the external task will
  166. I     : 
  167.   notice this when don't reply here - and initiate the normal
  168. #     : 
  169.   <Wimp$Scrap> protocol
  170.      :
  171. y     
  172. eval("FN_RAM_Save_"+ RAM_Save_Routine$+ "("+
  173. (RAM_Save_Offset%)+", "+
  174. (W%!24)+", RAM_start%, RAM_length%)") 
  175. B       
  176.   If no response, then other program will report error
  177.      
  178. *       RAM_Save_Offset% += RAM_length%
  179. V       
  180.  "Wimp_TransferBlock", Task_Handle%, RAM_start%, W%!4, W%!20, RAM_length%
  181.        W%!12 = W%!8
  182. @       W%!16 = 7                        :
  183.  Send RAM_Transmit
  184.        W%!24 = RAM_length%
  185. F       
  186.  "Wimp_SendMessage", 17 - (RAM_length%=(W%!24)), W%, W%!4
  187. =       save_ref% = W%!8                 :
  188.  Multi-messages
  189.      
  190.