home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsd / evntshell / !EvntShell / Extensions / DrawLib (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1995-11-11  |  39.9 KB  |  1,228 lines

  1.  >Module DrawLib
  2.  -----------------------------------------------------------------------
  3.  DrawFile Handling Routines (version 1.04 11-Nov-95)
  4.  This library contains routines that handle the creation and display
  5.  of DrawFiles.
  6.  -----------------------------------------------------------------------
  7.  Public Methods Supported:
  8.    FNshell_DrawLoadFile
  9.    FNshell_DrawGetFileSize
  10.    FNshell_DrawTextCoord
  11.    PROCshell_DrawCreateFile
  12.    PROCshell_DrawOutlineFont
  13.    PROCshell_DrawSetPathWidth
  14.    PROCshell_DrawSetPathColour
  15.    PROCshell_DrawSetPathNoColour
  16.    PROCshell_DrawSetFillColour
  17.    PROCshell_DrawSetNoFillColour
  18.    PROCshell_DrawStartGroup
  19.    PROCshell_DrawEndGroup
  20.    PROCshell_DrawDestroyFile
  21.    PROCshell_DrawSaveFile
  22.    PROCshell_DrawEllipse
  23.    PROCshell_DrawCircle
  24.    PROCshell_DrawBox
  25.    PROCshell_DrawPathStart
  26.    PROCshell_DrawPathDrawTo
  27.    PROCshell_DrawPathEnd
  28.    PROCshell_DrawPathCloseLine
  29.    PROCshell_DrawLine
  30.    PROCshell_DrawSetFont
  31.    PROCshell_DrawInitFont
  32.    PROCshell_DrawSetUnitsMM
  33.    PROCshell_DrawSetUnitsCM
  34.    PROCshell_DrawSetUnitsIN
  35.    PROCshell_DrawSetUnitsOS
  36.    PROCshell_DrawSetUnitsPT
  37.    PROCshell_DrawSetPathPattern
  38.    PROCshell_DrawGetBoundingBox
  39.    PROCshell_DrawRenderFile
  40.    PROCshell_DrawSetEndCapNone
  41.    PROCshell_DrawSetEndCapRound
  42.    PROCshell_DrawSetEndCapSquare
  43.    PROCshell_DrawSetEndCapTriangle
  44.    PROCshell_DrawSetStartCapNone
  45.    PROCshell_DrawSetStartCapRound
  46.    PROCshell_DrawSetStartCapSquare
  47.    PROCshell_DrawSetStartCapTriangle
  48.    PROCshell_DrawSetScale
  49.    PROCshell_DrawGetScale
  50.    PROCshell_DrawResizeWindow
  51.    PROCshell_DrawScaleToWindow
  52.  Responses to events raised by other modules
  53.  Private Methods Supported:
  54.    FNshell_DrawFontName
  55.    PROCshell_DrawPutString
  56.    PROCshell_DrawPutCoords
  57.    PROCshell_DrawPutWord
  58.    PROCshell_DrawUpdateObjectBBox
  59.    PROCshell_DrawUpdateBounds
  60.    PROCshell_DrawUpdateGroupBounds
  61.    PROCshell_DrawTextSpace
  62.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  63.  Public routines..
  64.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  65. Q$*|Start PROCshell_DrawCreateFile
  66. shell_DrawCreateFile(
  67.  buffer%)
  68.  creator$,style_blk%,trans_matrix%
  69.  EvntShell drawfiles in memory have a 60 byte 'pre-header' which keeps
  70.  track of current settings. The 'pre-header' must not be saved to disk
  71.  as the file will not be a valid drawfile!
  72. W*buffer% = 
  73. shell_HeapBlockFetch(60+24)
  74. XIbuffer%!00   = -1      :
  75.  Number of current outline font (-1 if none)
  76. Y:buffer%!04   = 60      :
  77.  Size of EvntShell pre-header
  78. ZSbuffer%!08   = 0       :
  79.  File offset to next free address (from start of file)
  80. [O|(buffer%+12)=1814.1732:
  81.  Current unit multiplier factor (real nr, 5 bytes)
  82. \1buffer%!20   = 7       :
  83.  Current path colour
  84. ]1buffer%!24   = -1      :
  85.  Current fill colour
  86. ^Nbuffer%!28   = 0       :
  87.  File offset to start of current group definition
  88. _0buffer%!32   = 0       :
  89.  Current path width
  90. `-buffer%!36   = 0       :
  91.  Current end cap
  92. aMbuffer%!40   = -1      :
  93.  Number of outline fonts declared   (-1 if none)
  94. bVbuffer%!44   = -1      :
  95.  File offset to start of font table (-1 if no font table)
  96. cEbuffer%!48   = 0       :
  97.  Pointer to path style description block
  98. d,buffer%!52   = 
  99. shell_HeapBlockFetch(24)
  100. eG$(buffer% + (buffer%!04))= "Draw"  :
  101.  Required to tag as a drawfile
  102. f>buffer%!(buffer%!04 + 4) = 201     :
  103.  Major version number
  104. g>buffer%!(buffer%!04 + 8) = 0       :
  105.  Minor version number
  106. hW$(buffer% + (buffer%!04 + 12)) = 
  107. shell_StringPadTrailing(
  108. shell_GetAppName," ",11)
  109. iLbuffer%!08 = buffer%!04 + 24       :
  110.  24 is length of DrawFile so far...
  111.  Set extent words of DrawFile to be 0,0,1,1...
  112. shell_DrawPutWord(0,buffer%)
  113. shell_DrawPutWord(0,buffer%)
  114. shell_DrawPutWord(0,buffer%)
  115. shell_DrawPutWord(0,buffer%)
  116. o*buffer%!48 = 
  117. shell_HeapBlockFetch(16)
  118. style_blk% = buffer%!48
  119. style_blk%!00 = 0
  120. style_blk%!04 = 0
  121. style_blk%!08 = 0
  122. style_blk%!12 = 0
  123. u*buffer%!52 = 
  124. shell_HeapBlockFetch(24)
  125. trans_matrix% = buffer%!52
  126. w)trans_matrix%!00 = 1 << 16 :
  127.  x scale
  128. x*trans_matrix%!04 = 0       :
  129.  rotation
  130. y*trans_matrix%!08 = 0       :
  131.  rotation
  132. z)trans_matrix%!12 = 1 << 16 :
  133.  y scale
  134. {3trans_matrix%!16 = 0       :
  135.  x position offset
  136. |3trans_matrix%!20 = 0       :
  137.  y position offset
  138. ~"DRW_PATH_START%    = buffer%!8
  139. DRW_PATH_SCALE_FAC = 1
  140. DRW_PATH_XMIN = 0
  141. DRW_PATH_YMIN = 0
  142. DRW_PATH_XMAX = 0
  143. DRW_PATH_YMAX = 0
  144. #*|Stop PROCshell_DrawCreateFile
  145. %*|Start PROCshell_DrawOutlineFont
  146. shell_DrawOutlineFont(
  147.  buffer%,text$,ptsize,pthigh,xorigin%,yorigin%)
  148.  start%,ptr%,lx%,by%,rx%,ty%,font%,scl_fac
  149. scl_fac = |(buffer%+12)
  150. font% = !buffer%
  151.  text$ <> "" 
  152. 3  buffer% = 
  153. shell_HeapBlockExtend(buffer%,256)
  154. #  ptr%    = buffer% + buffer%!8
  155.   start%  = ptr%
  156. /  !ptr%   =   1              :
  157.  Text object
  158. D  ptr%    += 24              :
  159.  Skip size, object bounds for now
  160. $  lx%     = (xorigin% * scl_fac)
  161. $  by%     = (yorigin% * scl_fac)
  162.  PROCshell_Tracef0("DEBUG::font is "+STR$font%)
  163.  PROCshell_Tracef0("DEBUG::font is "+FNshell_DrawFontName(buffer%,font%))
  164.  "Font_FindFont",,
  165. shell_DrawFontName(buffer%,font%),ptsize * 16, pthigh * 16 
  166.  handle%
  167.  "Font_SetFont",handle%
  168.  "Font_StringBBox",,text$ 
  169.  ,r1%,r2%,r3%,r4%
  170.  "Font_LoseFont",handle%
  171.  PROCshell_Tracef0("DEBUG::r1% = "+STR$r1%)
  172.  PROCshell_Tracef0("DEBUG::r2% = "+STR$r2%)
  173.  PROCshell_Tracef0("DEBUG::r3% = "+STR$r3%)
  174.  PROCshell_Tracef0("DEBUG::r4% = "+STR$r4%)
  175. &  rx%     = lx% + ((r3%/1000)*640)
  176. &  ty%     = by% + ((r4%/1000)*640)
  177.  PROCshell_Tracef0("DEBUG::lx%="+STR$lx%)
  178.  PROCshell_Tracef0("DEBUG::by%="+STR$by%)
  179.  PROCshell_Tracef0("DEBUG::rx%="+STR$rx%)
  180.  PROCshell_Tracef0("DEBUG::ty%="+STR$ty%)
  181. shell_DrawPutCoords(start% + 8,lx%,by%,rx%,ty%)
  182. '  !ptr%   = buffer%!20   :ptr% += 4
  183. '  !ptr%   = buffer%!24   :ptr% += 4
  184. '  !ptr%   = font%        :ptr% += 4
  185. '  !ptr%   = ptsize * 640 :ptr% += 4
  186. '  !ptr%   = pthigh * 640 :ptr% += 4
  187. 2  !ptr%   = xorigin% * |(buffer%+12):ptr% += 4
  188. 2  !ptr%   = yorigin% * |(buffer%+12):ptr% += 4
  189. shell_DrawPutString(text$,ptr%)
  190.   start%!4 = ptr% - start%
  191. shell_DrawUpdateBounds(buffer%,lx%,by%,rx%,ty%)
  192. >  buffer% = 
  193. shell_HeapBlockExtend(buffer%,start%!4 - 256)
  194.   buffer%!8 += start%!4
  195. $*|Stop PROCshell_DrawOutlineFont
  196. &*|Start PROCshell_DrawSetPathWidth
  197. shell_DrawSetPathWidth(buffer%,width)
  198. 1buffer%!32 = 
  199. ((width * |(buffer%+12)) + 0.5)
  200. %*|Stop PROCshell_DrawSetPathWidth
  201. '*|Start PROCshell_DrawSetPathColour
  202. shell_DrawSetPathColour( buffer%, R%, G%, B% )
  203.  ( ( R% = -1 ) 
  204.  ( G% = -1 ) 
  205.  ( B% = -1 ) )
  206. shell_DrawSetPathNoColour( buffer% )
  207.   buffer%?20 = 0
  208.   buffer%?21 = R%
  209.   buffer%?22 = G%
  210.   buffer%?23 = B%
  211. &*|Stop PROCshell_DrawSetPathColour
  212. )*|Start PROCshell_DrawSetPathNoColour
  213. shell_DrawSetPathNoColour( buffer% )
  214. buffer%!20 = -1
  215. (*|Stop PROCshell_DrawSetPathNoColour
  216. '*|Start PROCshell_DrawSetFillColour
  217. shell_DrawSetFillColour( buffer%, R%, G%, B% )
  218.  ( ( R% = -1 ) 
  219.  ( G% = -1 ) 
  220.  ( B% = -1 ) ) 
  221. shell_DrawSetNoFillColour( buffer% )
  222.   buffer%?24 = 0
  223.   buffer%?25 = R%
  224.   buffer%?26 = G%
  225.   buffer%?27 = B%
  226. &*|Stop PROCshell_DrawSetFillColour
  227. )*|Start PROCshell_DrawSetNoFillColour
  228. shell_DrawSetNoFillColour( buffer% )
  229. buffer%!24 = -1
  230. (*|Stop PROCshell_DrawSetNoFillColour
  231. $*|Start PROCshell_DrawStartGroup
  232. shell_DrawStartGroup(
  233.  buffer%,name$)
  234.  next%
  235.  buffer%!28 > 0 
  236. shell_DrawEndGroup( buffer% )
  237. Kbuffer%!28 = buffer%!08:
  238.  Store file offset to current group definition
  239.  PROCshell_Tracef0("DEBUG::bb_offset = "+STR$~buffer%!28)
  240. shell_DrawPutWord(06,buffer%) :
  241.  Object type 6 (group)
  242. shell_DrawPutWord(36,buffer%) :
  243.  Current size of group object
  244. shell_DrawPutWord(-1,buffer%) :
  245.  Bounding box xmin
  246. shell_DrawPutWord(-1,buffer%) :
  247.  Bounding box ymin
  248. shell_DrawPutWord(1,buffer%)  :
  249.  Bounding box xmax
  250. shell_DrawPutWord(1,buffer%)  :
  251.  Bounding box ymax
  252. 0buffer% = 
  253. shell_HeapBlockExtend(buffer%,12)
  254.     "next%   = buffer% + buffer%!08
  255. $next%  = name$
  256. Abuffer%!08 += 12 :
  257.  Update file offset to next free address..
  258. #*|Stop PROCshell_DrawStartGroup
  259. "*|Start PROCshell_DrawEndGroup
  260. shell_DrawEndGroup( buffer% )
  261.  start%
  262.  buffer%!28 > 0 
  263. %  start% = buffer% + (buffer%!28)
  264. /  start%!4 = (buffer% + buffer%!8) - start%
  265.   buffer%!28 = 0
  266. !*|Stop PROCshell_DrawEndGroup
  267.  %*|Start PROCshell_DrawDestroyFile
  268. shell_DrawDestroyFile( buffer% )
  269. shell_HeapBlockExists(buffer%!48) 
  270. shell_HeapBlockReturn(buffer%!48)
  271. shell_HeapBlockReturn( buffer% )
  272. &$*|Stop PROCshell_DrawDestroyFile
  273. *"*|Start PROCshell_DrawSaveFile
  274. shell_DrawSaveFile(buffer%,file$)
  275.  Add some error trapping here...
  276. X% = 
  277. (file$)
  278.  PROCshell_Tracef0("DEBUG::size is "+STR$(buffer%!8 - buffer%!4))
  279.  "OS_GBPB",2,X%,buffer% + (buffer%!4),buffer%!8 - buffer%!4
  280. ("SetType "+file$+ " &AFF")
  281. 5!*|Stop PROCshell_DrawSaveFile
  282. 9 *|Start FNshell_DrawLoadFile
  283. shell_DrawLoadFile(name$)
  284.  buff%,X%,size%
  285. shell_DrawCreateFile(buff%)
  286. =,buff%!8 -= 40 :
  287.  don't need the header..
  288. >$size% = 
  289. shell_FileLength(name$)
  290. ?/buff% = 
  291. shell_HeapBlockExtend(buff%,size%)
  292. X% = 
  293. (name$)
  294.  "OS_GBPB",4,X%,buff% + buff%!4,size%
  295. buff%!8 = size% + buff%!4
  296. shell_DrawSetScale(buff%,1,1)
  297. = buff%
  298. *|Stop FNshell_DrawLoadFile
  299. K!*|Start PROCshell_DrawEllipse
  300. shell_DrawEllipse(
  301.  buffer%,X,Y,Xm,Ym)
  302.  start%,A,B,C,D,E,K,Xs,Ys
  303. start% = buffer%!8
  304. X  = X  * |(buffer%+12)
  305. Y  = Y  * |(buffer%+12)
  306. Xm = Xm * |(buffer%+12)
  307. Ym = Ym * |(buffer%+12)
  308.  PROCshell_Tracef0("DEBUG::X="+STR$X)
  309.  PROCshell_Tracef0("DEBUG::Y="+STR$Y)
  310.  PROCshell_Tracef0("DEBUG::Xm="+STR$Xm)
  311.  PROCshell_Tracef0("DEBUG::Ym="+STR$Ym)
  312.  Xm >= Ym 
  313.   A = Xm / Xm / 10 + 0.5
  314.  Xm / Ym < 2 
  315.  A = 0.7
  316.  Xm / Ym > 4.5 
  317.  A = 0.95
  318.   Xs = A * Xm
  319. \(  Ys = 
  320. (1 - Xs * Xs / Xm / Xm) * Ym
  321.  Ym > Xm 
  322.   A = Ym / Xm / 10 + 0.5
  323.  Ym / Xm < 2 
  324.  A = 0.7
  325.  Ym / Xm > 4.5 
  326.  A = 0.95
  327.   Ys = A * Ym
  328. c(  Xs = 
  329. (1 - Ys * Ys / Ym / Ym) * Xm
  330. B = Ym + (Ym - Ys) / 3
  331. f%K = Xs * Xs + (B - Ys) * (B - Ys)
  332. g.C = (
  333. (4 * Xs * Xs + 12 * K) - 2 * Xs) / 6
  334. D = Xm + (Xm - Xs) / 3
  335. i%K = Ys * Ys + (D - Xs) * (D - Xs)
  336. j.E = (
  337. (4 * Ys * Ys + 12 * K) - 2 * Ys) / 6
  338. shell_DrawPutWord(2,buffer%)           :
  339.  Object type 2 (path)
  340. shell_DrawPutWord(0,buffer%)           :
  341.  Size of object (dummy value)
  342. shell_DrawPutWord(X - Xm,buffer%):
  343.  Set size of bounding box xmin
  344. shell_DrawPutWord(Y - Ym,buffer%):
  345.  Set size of bounding box ymin
  346. shell_DrawPutWord(X + Xm,buffer%):
  347.  Set size of bounding box xmax
  348. shell_DrawPutWord(Y + Ym,buffer%):
  349.  Set size of bounding box ymax
  350. shell_DrawUpdateBounds(buffer%,X - Xm,Y - Ym,X + Xm,Y + Ym)
  351. shell_DrawPutWord(buffer%!24,buffer%)  :
  352.  Fill colour
  353. shell_DrawPutWord(buffer%!20,buffer%)  :
  354.  Path colour
  355. shell_DrawPutWord(buffer%!32,buffer%)  :
  356.  Path width
  357. shell_DrawPutWord(00,buffer%)          :
  358.  Pattern
  359. shell_DrawPutWord(2,buffer%)           :
  360.  Absolute move
  361. shell_DrawPutWord(X + Xs,buffer%)      :
  362.  x start
  363. shell_DrawPutWord(Y - Ys,buffer%)      :
  364.  y start
  365. shell_DrawPutWord(6,buffer%)
  366. shell_DrawPutWord(X + C,buffer%)
  367. shell_DrawPutWord(Y - B,buffer%)
  368. shell_DrawPutWord(X - C,buffer%)
  369. shell_DrawPutWord(Y - B,buffer%)
  370. shell_DrawPutWord(X - Xs,buffer%)
  371. shell_DrawPutWord(Y - Ys,buffer%)
  372. shell_DrawPutWord(6,buffer%)
  373. shell_DrawPutWord(X - D,buffer%)
  374. shell_DrawPutWord(Y - E,buffer%)
  375. shell_DrawPutWord(X - D,buffer%)
  376. shell_DrawPutWord(Y + E,buffer%)
  377. shell_DrawPutWord(X - Xs,buffer%)
  378. shell_DrawPutWord(Y + Ys,buffer%)
  379. shell_DrawPutWord(6,buffer%)
  380. shell_DrawPutWord(X - C,buffer%)
  381. shell_DrawPutWord(Y + B,buffer%)
  382. shell_DrawPutWord(X + C,buffer%)
  383. shell_DrawPutWord(Y + B,buffer%)
  384. shell_DrawPutWord(X + Xs,buffer%)
  385. shell_DrawPutWord(Y + Ys,buffer%)
  386. shell_DrawPutWord(6,buffer%)
  387. shell_DrawPutWord(X + D,buffer%)
  388. shell_DrawPutWord(Y + E,buffer%)
  389. shell_DrawPutWord(X + D,buffer%)
  390. shell_DrawPutWord(Y - E,buffer%)
  391. shell_DrawPutWord(X + Xs,buffer%)
  392. shell_DrawPutWord(Y - Ys,buffer%)
  393. shell_DrawPutWord(0,buffer%)               :
  394.  End of path
  395. J!(buffer% + start% + 4) = buffer%!8 - start%   :
  396.  Store size of object
  397.  *|Stop PROCshell_DrawEllipse
  398.  *|Start PROCshell_DrawCircle
  399. shell_DrawCircle(
  400.  buffer%,X,Y,R)
  401.  start%,A,B,C,style_blk%
  402. style_blk% = buffer%!48
  403. start% = buffer%!8
  404. X = X * |(buffer%+12)
  405. Y = Y * |(buffer%+12)
  406. R = R * |(buffer%+12)
  407. A = R / 
  408. B = A + R / 2.544
  409. C = A - R / 2.544
  410. shell_DrawPutWord(2,buffer%)               :
  411.  Object type 2 (path)
  412. shell_DrawPutWord(0,buffer%)               :
  413.  Size of object (dummy value)
  414. shell_DrawPutWord(X - R,buffer%)           :
  415.  Set size of bounding box xmin
  416. shell_DrawPutWord(Y - R,buffer%)           :
  417.  Set size of bounding box ymin
  418. shell_DrawPutWord(X + R,buffer%)           :
  419.  Set size of bounding box xmax
  420. shell_DrawPutWord(Y + R,buffer%)           :
  421.  Set size of bounding box ymax
  422. shell_DrawUpdateBounds(buffer%,X - R,Y - R,X + R,Y + R)
  423. shell_DrawPutWord(buffer%!24,buffer%)      :
  424.  Fill colour
  425. shell_DrawPutWord(buffer%!20,buffer%)      :
  426.  Path colour
  427. shell_DrawPutWord(buffer%!32,buffer%)      :
  428.  Path width
  429. shell_DrawPutWord(style_blk%!0,buffer%)    :
  430.  Style word
  431.  (style_blk%?0 
  432.  1 << 7) <> 0 
  433. shell_DrawPutWord(style_blk%!04,buffer%) :
  434.  Offset to pattern start
  435. shell_DrawPutWord(style_blk%!08,buffer%) :
  436.  Nr of elements in pattern
  437. shell_DrawPutWord(style_blk%!12,buffer%) :
  438.  Length of dash element
  439. shell_DrawPutWord(2,buffer%)               :
  440.  Absolute move
  441. shell_DrawPutWord(X + A,buffer%)           :
  442.  x start
  443. shell_DrawPutWord(Y - A,buffer%)           :
  444.  y start
  445. shell_DrawPutWord(6,buffer%)
  446. shell_DrawPutWord(X + C,buffer%)
  447. shell_DrawPutWord(Y - B,buffer%)
  448. shell_DrawPutWord(X - C,buffer%)
  449. shell_DrawPutWord(Y - B,buffer%)
  450. shell_DrawPutWord(X - A,buffer%)
  451. shell_DrawPutWord(Y - A,buffer%)
  452. shell_DrawPutWord(6,buffer%)
  453. shell_DrawPutWord(X - B,buffer%)
  454. shell_DrawPutWord(Y - C,buffer%)
  455. shell_DrawPutWord(X - B,buffer%)
  456. shell_DrawPutWord(Y + C,buffer%)
  457. shell_DrawPutWord(X - A,buffer%)
  458. shell_DrawPutWord(Y + A,buffer%)
  459. shell_DrawPutWord(6,buffer%)
  460. shell_DrawPutWord(X - C,buffer%)
  461. shell_DrawPutWord(Y + B,buffer%)
  462. shell_DrawPutWord(X + C,buffer%)
  463. shell_DrawPutWord(Y + B,buffer%)
  464. shell_DrawPutWord(X + A,buffer%)
  465. shell_DrawPutWord(Y + A,buffer%)
  466. shell_DrawPutWord(6,buffer%)
  467. shell_DrawPutWord(X + B,buffer%)
  468. shell_DrawPutWord(Y + C,buffer%)
  469. shell_DrawPutWord(X + B,buffer%)
  470. shell_DrawPutWord(Y - C,buffer%)
  471. shell_DrawPutWord(X + A,buffer%)
  472. shell_DrawPutWord(Y - A,buffer%)
  473. shell_DrawPutWord(0,buffer%)               :
  474.  End of path
  475. J!(buffer% + start% + 4) = buffer%!8 - start%   :
  476.  Store size of object
  477. *|Stop PROCshell_DrawCircle
  478. *|Start PROCshell_DrawBox
  479. shell_DrawBox(
  480.  buffer%,x0,y0,width,height)
  481.  start%,scl_fac
  482. start% = buffer%!8
  483. scl_fac = |(buffer%+12)
  484. x0     = x0     * scl_fac
  485. y0     = y0     * scl_fac
  486. width  = width  * scl_fac
  487. height = height * scl_fac
  488. shell_DrawPutWord(2,buffer%)          :
  489.  Object type 2 (path)
  490. shell_DrawPutWord(0,buffer%)          :
  491.  Size of object (dummy value)
  492. shell_DrawPutWord(x0,buffer%)         :
  493.  Set size of bounding box xmin
  494. shell_DrawPutWord(y0,buffer%)         :
  495.  Set size of bounding box ymin
  496. shell_DrawPutWord(x0 + width,buffer%) :
  497.  Set size of bounding box xmax
  498. shell_DrawPutWord(y0 + height,buffer%):
  499.  Set size of bounding box ymax
  500. shell_DrawUpdateBounds(buffer%,x0,y0,x0 + width,y0 + height)
  501. shell_DrawPutWord(buffer%!24,buffer%) :
  502.  Fill colour
  503. shell_DrawPutWord(buffer%!20,buffer%) :
  504.  Path colour
  505. shell_DrawPutWord(buffer%!32,buffer%) :
  506.  Path width
  507. shell_DrawPutWord(00,buffer%)         :
  508.  Pattern
  509. shell_DrawPutWord(02,buffer%)         :
  510.  Absolute move
  511. shell_DrawPutWord(x0,buffer%)         :
  512.  x start
  513. shell_DrawPutWord(y0,buffer%)         :
  514.  y start
  515. shell_DrawPutWord(08,buffer%)         :
  516.  Draw to absolute position
  517. shell_DrawPutWord(x0,buffer%)
  518. shell_DrawPutWord(y0 + height,buffer%)
  519. shell_DrawPutWord(08,buffer%)
  520. shell_DrawPutWord(x0 + width,buffer%)
  521. shell_DrawPutWord(y0 + height,buffer%)
  522. shell_DrawPutWord(08,buffer%)
  523. shell_DrawPutWord(x0 + width,buffer%)
  524. shell_DrawPutWord(y0,buffer%)
  525. shell_DrawPutWord(08,buffer%)
  526. shell_DrawPutWord(x0,buffer%)
  527. shell_DrawPutWord(y0,buffer%)
  528. shell_DrawPutWord(00,buffer%)           :
  529.  End of path
  530. G!(buffer% + start% + 4) = buffer%!8 - start%:
  531.  Store size of object
  532. *|Stop PROCshell_DrawBox
  533.  ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  534.  Path Object
  535.  ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  536. #*|Start PROCshell_DrawPathStart
  537. shell_DrawPathStart( 
  538.  buffer%, x_coord, y_coord )
  539.  Set up Module Globals..
  540. "DRW_PATH_START%    = buffer%!8
  541. *DRW_PATH_SCALE_FAC = |( buffer% + 12 )
  542. *x_coord = x_coord * DRW_PATH_SCALE_FAC
  543. *y_coord = y_coord * DRW_PATH_SCALE_FAC
  544.  DRW_PATH_XMIN = x_coord
  545.  DRW_PATH_YMIN = x_coord
  546.  DRW_PATH_XMAX = y_coord
  547.  DRW_PATH_YMAX = y_coord
  548. DRW_PATH_XMIN = x_coord
  549. DRW_PATH_YMIN = y_coord
  550. DRW_PATH_XMAX = -&7FFFFFFF
  551. DRW_PATH_YMAX = -&7FFFFFFF
  552. shell_DrawPutWord( 2,buffer% )  :
  553.  Object type 2 (path)
  554. shell_DrawPutWord( 0,buffer% )  :
  555.  Size of object (dummy value)
  556. shell_DrawPutWord( DRW_PATH_XMIN, buffer% ) :
  557.  Set size of bounding box xmin
  558. shell_DrawPutWord( DRW_PATH_YMIN, buffer% ) :
  559.  Set size of bounding box ymin
  560. shell_DrawPutWord( DRW_PATH_XMAX, buffer% ) :
  561.  Set size of bounding box xmax
  562. shell_DrawPutWord( DRW_PATH_YMAX, buffer% ) :
  563.  Set size of bounding box ymax
  564. shell_DrawPutWord( buffer%!24, buffer% ) :
  565.  Fill colour
  566. shell_DrawPutWord( buffer%!20, buffer% ) :
  567.  Path colour
  568. shell_DrawPutWord( buffer%!32, buffer% ) :
  569.  Path width
  570. shell_DrawPutWord( 00,buffer% )          :
  571.  Pattern
  572. shell_DrawPutWord( 02,buffer% )          :
  573.  Absolute move
  574. shell_DrawPutWord( x_coord, buffer% )    :
  575.  x start
  576. shell_DrawPutWord( y_coord, buffer% )    :
  577.  y start
  578. 6"*|Stop PROCshell_DrawPathStart
  579. :$*|Start PROCshell_DrawPathDrawTo
  580. shell_DrawPathDrawTo( 
  581.  buffer%, x_coord, y_coord )
  582. shell_DrawPutWord( 08, buffer% ) :
  583.  Draw to absolute position
  584. =*x_coord = x_coord * DRW_PATH_SCALE_FAC
  585. >*y_coord = y_coord * DRW_PATH_SCALE_FAC
  586. shell_DrawPutWord( x_coord, buffer% )
  587. shell_DrawPutWord( y_coord, buffer% )
  588. shell_DrawUpdateObjectBBox( buffer%, x_coord, y_coord )
  589. D#*|Stop PROCshell_DrawPathDrawTo
  590. H!*|Start PROCshell_DrawPathEnd
  591. shell_DrawPathEnd( 
  592.  buffer% )
  593. shell_DrawPutWord( 00, buffer% )
  594.  Store size of object..
  595. LD!( buffer% + DRW_PATH_START% + 4 ) = buffer%!8 - DRW_PATH_START%
  596. shell_DrawUpdateBounds( buffer%, DRW_PATH_XMIN, DRW_PATH_YMIN, DRW_PATH_XMAX, DRW_PATH_YMAX )
  597. P *|Stop PROCshell_DrawPathEnd
  598. T'*|Start PROCshell_DrawPathCloseLine
  599. shell_DrawPathCloseLine( 
  600.  buffer% )
  601. shell_DrawPutWord( 05, buffer% )
  602. shell_DrawPutWord( 00, buffer% )
  603.  Store size of object..
  604. YD!( buffer% + DRW_PATH_START% + 4 ) = buffer%!8 - DRW_PATH_START%
  605. shell_DrawUpdateBounds( buffer%, DRW_PATH_XMIN, DRW_PATH_YMIN, DRW_PATH_XMAX, DRW_PATH_YMAX )
  606. ]&*|Stop PROCshell_DrawPathCloseLine
  607. *|Start PROCshell_DrawLine
  608. shell_DrawLine(
  609.  buffer%,x0,y0,x1,y1)
  610.  start%,pat_blk%,scl_fac,style_blk%,p_width%,cap_width%,cap_len%
  611.  cap_width2%,cap_len2%,bbox_xmin,bbox_xmax,bbbox_ymin,bbox_ymax
  612. scl_fac = |(buffer%+12)
  613. start% = buffer%!8
  614. hHx0 = x0 * scl_fac :
  615.  Convert to draw units using stored scale factor
  616. y0 = y0 * scl_fac
  617. x1 = x1 * scl_fac
  618. y1 = y1 * scl_fac
  619. p_width%   = buffer%!32
  620. style_blk% = buffer%!48
  621.  x0 > x1 
  622.   bbox_xmin = x1
  623.   bbox_xmax = x0
  624.   bbox_xmin = x0
  625.   bbox_xmax = x1
  626.  y0 > y1 
  627.   bbox_ymin = y1
  628.   bbox_ymax = y0
  629.   bbox_ymin = y0
  630.   bbox_ymax = y1
  631.  PROCshell_Tracef0("DEBUG:: "+STR$(style_blk%?0 AND (1 << 2)))
  632.  PROCshell_Tracef0("DEBUG:: "+STR$(style_blk%?0 AND (1 << 3)))
  633.  (style_blk%?0 
  634.  %1100) 
  635.  (style_blk%?0 
  636.  %110000) <> 0 
  637.  Triangular end caps on the path, check the widths..
  638.  (style_blk%?0 
  639.  %1100) 
  640. 9    cap_width% = style_blk%?2:
  641.  1/16ths of path width
  642. 9    cap_len%   = style_blk%?3:
  643.  1/16ths of path width
  644. 3    cap_width% = (cap_width% * (p_width% / 16))
  645. 3    cap_len%   = (cap_len%   * (p_width% / 16))
  646.  (style_blk%?0 
  647.  %110000) 
  648. :    cap_width2% = style_blk%?4:
  649.  1/16ths of path width
  650. :    cap_len2%   = style_blk%?5:
  651.  1/16ths of path width
  652. 5    cap_width2% = (cap_width2% * (p_width% / 16))
  653. 5    cap_len2%   = (cap_len2%   * (p_width% / 16))
  654.  cap_width2% > cap_width% 
  655.  cap_width% = cap_width2%
  656.  cap_len2%   > cap_len%   
  657.  cap_len%   = cap_len2%
  658.  PROCshell_Tracef0("DEBUG:: cap_width% = "+STR$cap_width%)
  659.  PROCshell_Tracef0("DEBUG:: cap_len%   = "+STR$cap_len%)
  660. shell_DrawPutWord(2,buffer%)               :
  661.  Object type 2 (path)
  662. shell_DrawPutWord(0,buffer%)               :
  663.  Size of object (dummy value)
  664. shell_DrawPutWord(bbox_xmin-cap_len%,buffer%)                :
  665.  Set size of bounding box xmin
  666. shell_DrawPutWord(bbox_ymin-(p_width%/2)-cap_width%,buffer%) :
  667.  Set size of bounding box ymin
  668. shell_DrawPutWord(bbox_xmax+cap_len%,buffer%)                :
  669.  Set size of bounding box xmax
  670. shell_DrawPutWord(bbox_ymax+(p_width%/2)+cap_width%,buffer%) :
  671.  Set size of bounding box ymax
  672. shell_DrawUpdateBounds(buffer%,x0,y0,x1,y1):
  673.  Update DrawFile bounding box
  674. shell_DrawPutWord(buffer%!24,buffer%)      :
  675.  Fill colour (-1 = do not fill)
  676. shell_DrawPutWord(buffer%!20,buffer%)      :
  677.  Path colour (-1 = no outline)
  678. shell_DrawPutWord(buffer%!32,buffer%)      :
  679.  Path width
  680. shell_DrawPutWord(style_blk%!0,buffer%)    :
  681.  Style word
  682.  (style_blk%?0 
  683.  1 << 7) <> 0 
  684. shell_DrawPutWord(style_blk%!04,buffer%) :
  685.  Offset to pattern start
  686. shell_DrawPutWord(style_blk%!08,buffer%) :
  687.  Nr of elements in pattern
  688. shell_DrawPutWord(style_blk%!12,buffer%) :
  689.  Length of dash element
  690. shell_DrawPutWord(02,buffer%)              :
  691.  Absolute move
  692. shell_DrawPutWord(x0,buffer%)              :
  693.  x start
  694. shell_DrawPutWord(y0,buffer%)              :
  695.  y start
  696. shell_DrawPutWord(08,buffer%)              :
  697.  Draw to absolute position
  698. shell_DrawPutWord(x1,buffer%)              :
  699.  x finish
  700. shell_DrawPutWord(y1,buffer%)              :
  701.  y finish
  702. shell_DrawPutWord(00,buffer%)              :
  703.  End of path
  704. J!(buffer% + start% + 4) = buffer%!8 - start%   :
  705.  Store size of object
  706. *|Stop PROCshell_DrawLine
  707. !*|Start PROCshell_DrawSetFont
  708. shell_DrawSetFont(buffer%,font$)
  709.  ft_start%,ft_end%,f_handle%,ptr%,name$,found%
  710. found%    = 
  711. f_handle% = 0
  712.  font$ = "" 
  713. -  !buffer% = 0 :
  714.  Font 0 is system font..
  715.  Search font table to find internal font handle of requested font
  716.   ft_start% = buffer%!44
  717.  ft_start% = -1 
  718.  99,"No fonts have been initialised for this drawfile"
  719. F  ft_start% += buffer% :
  720.  Now points to start of font table object
  721.  PROCshell_Tracef0("DEBUG::font table size is = "+STR$(ft_start%!4))
  722. *  ft_end%    = ft_start%!4 + ft_start%
  723.    ptr%       = ft_start% + 8
  724. &    ft_handle% = ?ptr% : ptr% += 1
  725. &    name$ = 
  726. shell_GetString(ptr%)
  727. V    
  728.  PROCshell_Tracef0("DEBUG::font name found ("+STR$ft_handle%+") '"+name$+"'")
  729.     ptr% += 
  730.  name$ + 1
  731.  ptr% 
  732.  4 <> 0
  733.       ptr% +=1
  734.         
  735.  name$ = font$ 
  736. )      found% = 
  737.  : ptr% = ft_end% + 1
  738. R      
  739.  PROCshell_Tracef0("DEBUG::font name match, handle is "+STR$ft_handle%)
  740.         
  741. 0      
  742.  PROCshell_Tracef0("DEBUG::NO MATCH")
  743.         
  744.  ptr% >= ft_end%
  745.  found% 
  746.   !buffer% = ft_handle%
  747.  PROCshell_Tracef0("DEBUG::Setting font handle to "+STR$(!buffer%))
  748.  99,"Font '"+font$+"' has not been initialised"
  749.  *|Stop PROCshell_DrawSetFont
  750. "*|Start PROCshell_DrawInitFont
  751. shell_DrawInitFont(
  752.  buffer%,font_name$)
  753.  ft_start%,ptr%,def_start%
  754. shell_Fonts_FontIsAvailable(font_name$,12,12) 
  755. 6  buffer%    = 
  756. shell_HeapBlockExtend(buffer%,256)
  757. B  ptr%       = buffer% + buffer%!8   :
  758.  Next address in file..
  759.   def_start% = ptr%
  760.  buffer%!40 = -1 
  761. J    
  762.  This routine hasn't been called before, so create new font table
  763. T    buffer%!44 = buffer%!8           :
  764.  Store file offset to start of font table
  765. D    !ptr% = 0:ptr% += 4              :
  766.  Create font table object
  767. D    !ptr% = 0:ptr% += 4              :
  768.  Skip object size for now
  769. ?    buffer%!40 = 0                   :
  770.  Nr of defined fonts
  771. J  ft_start% = buffer% + buffer%!44   :
  772.  Start of font table definition
  773. @  buffer%!40 += 1                    :
  774.  Increment font count
  775. T  ?ptr% = buffer%!40                 :
  776.  Store internal font handle (starts at 1)
  777. F  $(ptr%+1) = font_name$             :
  778.  Store textual name of font
  779.   ptr% += 
  780. (font_name$) + 2
  781. G  ?(ptr% - 1) = 0                    :
  782.  Terminate name with CHR$(0)
  783.  ptr% 
  784.  4 <> 0              :
  785.  Pad with trailing spaces to a word boundary
  786.     ?ptr% = 0
  787.     ptr% += 1
  788. L  ft_start%!04   = ptr% - ft_start%  :
  789.  Update size of font table object
  790. C  buffer%!08 += ptr% - def_start%    :
  791.  Update size of DrawFile
  792.  Finally shrink heap block..
  793. H  buffer% = 
  794. shell_HeapBlockExtend(buffer%,(ptr% - ft_start%) - 256)
  795. h  void% = 
  796. shell_MessageWindow(
  797. shell_MessageOneArg("SHELLMSG31",font_name$),0,
  798. shell_GetAppName,"")
  799. !*|Stop PROCshell_DrawInitFont
  800. $*|Start PROCshell_DrawSetUnitsMM
  801. shell_DrawSetUnitsMM( buffer% )
  802. |(buffer% + 12) = 1814.1732
  803. #*|Stop PROCshell_DrawSetUnitsMM
  804. $*|Start PROCshell_DrawSetUnitsCM
  805. shell_DrawSetUnitsCM( buffer% )
  806. |(buffer% + 12) = 18141.732
  807. #*|Stop PROCshell_DrawSetUnitsCM
  808. $*|Start PROCshell_DrawSetUnitsIN
  809. shell_DrawSetUnitsIN( buffer% )
  810. |(buffer% + 12) = 46080
  811. #*|Stop PROCshell_DrawSetUnitsIN
  812. $*|Start PROCshell_DrawSetUnitsOS
  813. shell_DrawSetUnitsOS( buffer% )
  814. |(buffer% + 12) = 256
  815. "#*|Stop PROCshell_DrawSetUnitsOS
  816. &$*|Start PROCshell_DrawSetUnitsPT
  817. shell_DrawSetUnitsPT( buffer% )
  818. |(buffer% + 12) = 640
  819. +#*|Stop PROCshell_DrawSetUnitsPT
  820. /(*|Start PROCshell_DrawSetPathPattern
  821. shell_DrawSetPathPattern(buffer%,dashed%,offset,nr_el%,len)
  822.  pat_blk%,scl_fac
  823. pat_blk% = buffer%!48
  824. scl_fac  = |(buffer% + 12)
  825. 4$pat_blk%?0 = pat_blk%?0 
  826.  1 << 7
  827.  dashed% = 0 
  828. 6&  pat_blk%?0 = pat_blk%?0 
  829.  1 << 7
  830. 8"pat_blk%!04 = offset * scl_fac
  831. pat_blk%!08 = nr_el%
  832. :"pat_blk%!12 = len    * scl_fac
  833. ='*|Stop PROCshell_DrawSetPathPattern
  834. A(*|Start PROCshell_DrawGetBoundingBox
  835. shell_DrawGetBoundingBox(buffer%,
  836.  xpos,
  837.  ypos,
  838.  width,
  839.  height,os_units%)
  840.  drawfile_start%,drawfile_size%,bbox_blk%,trans_matrix%,div%
  841. D*drawfile_start%  = buffer% + buffer%!4
  842. E,drawfile_size%   = buffer%!8 - buffer%!4
  843. F!trans_matrix%    = buffer%!52
  844. trans_matrix%!20 = 0
  845. trans_matrix%!24 = 0
  846. I)bbox_blk% = 
  847. shell_HeapBlockFetch(16)
  848.  os_units% <> 0 
  849.  div% = 256 
  850.  div% = 1
  851.  "DrawFile_BBox",0,drawfile_start%,drawfile_size%,trans_matrix%,bbox_blk%
  852. L"xpos   = (bbox_blk%!00) / div%
  853. M"ypos   = (bbox_blk%!04) / div%
  854. N0width  = (bbox_blk%!08 - bbox_blk%!00)/ div%
  855. O0height = (bbox_blk%!12 - bbox_blk%!04)/ div%
  856. shell_HeapBlockReturn(bbox_blk%)
  857. R'*|Stop PROCshell_DrawGetBoundingBox
  858. V#*|Start FNshell_DrawGetFileSize
  859. shell_DrawGetFileSize( buffer% )
  860. = buffer%!8 - buffer%!4
  861. Z"*|Stop FNshell_DrawGetFileSize
  862. b$*|Start PROCshell_DrawRenderFile
  863. shell_DrawRenderFile(buffer%,x%,y%,q%,bound%)
  864.  drawsc%,draw%,drawlen%
  865.  bound%=-1 
  866.  bound% = 1 
  867.  bound% = 0
  868. drawsc%  = buffer%!52
  869. g"draw%    = buffer% + buffer%!4
  870. h$drawlen% = buffer%!8 - buffer%!4
  871. drawsc%!16 = x% * 256
  872. drawsc%!20 = y% * 256
  873.  "DrawFile_Render",bound%,draw%,drawlen%,drawsc%,q% + 28
  874. drawsc%!16 = 0
  875. drawsc%!20 = 0
  876. p#*|Stop PROCshell_DrawRenderFile
  877.  *|Start PROCshell_DrawRenderFile
  878.  DEF PROCshell_DrawRenderFile(buffer%,x%,y%,x_scl,y_scl,q%,bound%)
  879.  LOCAL drawsc%,draw%,drawlen%
  880.  IF bound%=-1 THEN bound% = 1 ELSE bound% = 0
  881.  drawsc%  = FNshell_HeapBlockFetch(24)
  882.  draw%    = buffer% + buffer%!4
  883.  drawlen% = buffer%!8 - buffer%!4
  884.  !drawsc% = INT(65536 * x_scl)
  885.  drawsc%!04 = 0
  886.  drawsc%!08 = 0
  887.  drawsc%!12 = INT(65536 * y_scl)
  888.  drawsc%!16 = x% * 256
  889.  drawsc%!20 = y% * 256
  890.  SYS "DrawFile_Render",bound%,draw%,drawlen%,drawsc%,q% + 28
  891.  PROCshell_HeapBlockReturn(drawsc%)
  892.  ENDPROC
  893.  *|Stop PROCshell_DrawRenderFile
  894. !*|Start FNshell_DrawTextCoord
  895. shell_DrawTextCoord(v%,r%,scale%) = (v% * scale% + r% +scale% / 2) / scale%
  896.  *|Stop FNshell_DrawTextCoord
  897. '*|Start PROCshell_DrawSetEndCapNone
  898. shell_DrawSetEndCapNone( buffer% )
  899.  style_blk%
  900. style_blk% = buffer%!48
  901. 6style_blk%?0 = style_blk%?0  
  902.  1 << 2 :
  903.  set bit 2
  904. 6style_blk%?0 = style_blk%?0  
  905.  1 << 3 :
  906.  set bit 3
  907. 7style_blk%?0 = style_blk%?0 
  908.  1 << 2 :
  909.  unset bit 2
  910. 7style_blk%?0 = style_blk%?0 
  911.  1 << 3 :
  912.  unset bit 3
  913. &*|Stop PROCshell_DrawSetEndCapNone
  914. (*|Start PROCshell_DrawSetEndCapRound
  915. shell_DrawSetEndCapRound( buffer% )
  916.  style_blk%
  917. style_blk% = buffer%!48
  918. 6style_blk%?0 = style_blk%?0  
  919.  1 << 2 :
  920.  set bit 2
  921. 6style_blk%?0 = style_blk%?0  
  922.  1 << 3 :
  923.  set bit 3
  924. 7style_blk%?0 = style_blk%?0 
  925.  1 << 3 :
  926.  unset bit 3
  927. '*|Stop PROCshell_DrawSetEndCapRound
  928. )*|Start PROCshell_DrawSetEndCapSquare
  929. shell_DrawSetEndCapSquare( buffer% )
  930.  style_blk%
  931. style_blk% = buffer%!48
  932. 6style_blk%?0 = style_blk%?0  
  933.  1 << 2 :
  934.  set bit 2
  935. 6style_blk%?0 = style_blk%?0  
  936.  1 << 3 :
  937.  set bit 3
  938. 7style_blk%?0 = style_blk%?0 
  939.  1 << 2 :
  940.  unset bit 2
  941. (*|Stop PROCshell_DrawSetEndCapSquare
  942. +*|Start PROCshell_DrawSetEndCapTriangle
  943. shell_DrawSetEndCapTriangle(buffer%,width%,len%)
  944.  style_blk%,path_width%
  945. !path_width% = buffer%!32 / 16
  946. style_blk%  = buffer%!48
  947. %width% = width% * |(buffer% + 12)
  948. %len%   = len%   * |(buffer% + 12)
  949. 6style_blk%?0 = style_blk%?0  
  950.  1 << 2 :
  951.  set bit 2
  952. 6style_blk%?0 = style_blk%?0  
  953.  1 << 3 :
  954.  set bit 3
  955. 'style_blk%?2 = width% / path_width%
  956. 'style_blk%?3 = len%   / path_width%
  957.  PROCshell_Tracef0("DEBUG:: path width is "+STR$path_width%)
  958. **|Stop PROCshell_DrawSetEndCapTriangle
  959. )*|Start PROCshell_DrawSetStartCapNone
  960. shell_DrawSetStartCapNone( buffer% )
  961.  style_blk%
  962. style_blk% = buffer%!48
  963. 6style_blk%?0 = style_blk%?0  
  964.  1 << 4 :
  965.  set bit 4
  966. 6style_blk%?0 = style_blk%?0  
  967.  1 << 5 :
  968.  set bit 5
  969. 7style_blk%?0 = style_blk%?0 
  970.  1 << 4 :
  971.  unset bit 4
  972. 7style_blk%?0 = style_blk%?0 
  973.  1 << 5 :
  974.  unset bit 5
  975. (*|Stop PROCshell_DrawSetStartCapNone
  976. **|Start PROCshell_DrawSetStartCapRound
  977. shell_DrawSetStartCapRound( buffer% )
  978.  style_blk%
  979. style_blk% = buffer%!48
  980. 6style_blk%?0 = style_blk%?0  
  981.  1 << 4 :
  982.  set bit 4
  983. 6style_blk%?0 = style_blk%?0  
  984.  1 << 5 :
  985.  set bit 5
  986. 7style_blk%?0 = style_blk%?0 
  987.  1 << 5 :
  988.  unset bit 5
  989. )*|Stop PROCshell_DrawSetStartCapRound
  990. +*|Start PROCshell_DrawSetStartCapSquare
  991. shell_DrawSetStartCapSquare( buffer% )
  992.  style_blk%
  993. style_blk% = buffer%!48
  994. 6style_blk%?0 = style_blk%?0  
  995.  1 << 4 :
  996.  set bit 4
  997. 6style_blk%?0 = style_blk%?0  
  998.  1 << 5 :
  999.  set bit 5
  1000. 7style_blk%?0 = style_blk%?0 
  1001.  1 << 4 :
  1002.  unset bit 4
  1003. **|Stop PROCshell_DrawSetStartCapSquare
  1004. -*|Start PROCshell_DrawSetStartCapTriangle
  1005. shell_DrawSetStartCapTriangle(buffer%,width%,len%)
  1006.  style_blk%,path_width%
  1007. style_blk%  = buffer%!48
  1008. !path_width% = buffer%!32 / 16
  1009. %width% = width% * |(buffer% + 12)
  1010. %len%   = len%   * |(buffer% + 12)
  1011. 6style_blk%?0 = style_blk%?0  
  1012.  1 << 4 :
  1013.  set bit 4
  1014. 6style_blk%?0 = style_blk%?0  
  1015.  1 << 5 :
  1016.  set bit 5
  1017. 'style_blk%?2 = width% / path_width%
  1018. 'style_blk%?3 = len%   / path_width%
  1019.  PROCshell_Tracef0("DEBUG:: path width is "+STR$path_width%)
  1020. ,*|Stop PROCshell_DrawSetStartCapTriangle
  1021. "*|Start PROCshell_DrawSetScale
  1022. shell_DrawSetScale(buffer%,xscl,yscl)
  1023.  matrix%
  1024. matrix%    = buffer%!52
  1025.  matrix%!00 = 
  1026. (65536 * xscl)
  1027.  matrix%!12 = 
  1028. (65536 * yscl)
  1029. !*|Stop PROCshell_DrawSetScale
  1030. "*|Start PROCshell_DrawGetScale
  1031. shell_DrawGetScale(buffer%,
  1032.  xscl,
  1033.  yscl)
  1034.  matrix%
  1035. matrix% = buffer%!52
  1036.  xscl    = matrix%!00 / 65536
  1037.  yscl    = matrix%!12 / 65536
  1038. !*|Stop PROCshell_DrawGetScale
  1039.  &*|Start PROCshell_DrawResizeWindow
  1040. shell_DrawResizeWindow(buffer%,wh%,lm%,bm%,rm%,tm%)
  1041.  xpos,ypos,width,height
  1042. shell_DrawGetBoundingBox(buffer%,xpos,ypos,width,height,
  1043. shell_WindowResize(wh%,0,- (tm% + bm% + height + ypos),width + lm% + rm%,0,0)
  1044. '%*|Stop PROCshell_DrawResizeWindow
  1045. +'*|Start PROCshell_DrawScaleToWindow
  1046. shell_DrawScaleToWindow(buffer%,wh%,lm%,bm%,rm%,tm%,
  1047.  xscl,
  1048.  yscl)
  1049.  xpos,ypos,width,height,w_blk%,w_width%,w_height%,o_xscl,o_yscl
  1050. shell_DrawSetScale(buffer%,o_xscl,o_yscl)
  1051. shell_DrawSetScale(buffer%,1,1)
  1052. shell_DrawGetBoundingBox(buffer%,xpos,ypos,width,height,
  1053. 1'w_blk%  = 
  1054. shell_HeapBlockFetch(36)
  1055. !w_blk% = wh%
  1056.  "Wimp_GetWindowState",,w_blk%
  1057. 4Aw_width%  = (w_blk%!12 - w_blk%!04 + w_blk%!20) - (lm% + rm%)
  1058. 5Aw_height% = (w_blk%!16 - w_blk%!08 + w_blk%!24) - (tm% + bm%)
  1059. 6*xscl      = (w_width%  / (width  - 0))
  1060. 7*yscl      = (w_height% / (height - 0))
  1061.  PROCshell_Tracef0(">>> "+STR$w_width%)
  1062.  PROCshell_Tracef0(">>> "+STR$width)
  1063.  PROCshell_Tracef0(">>> "+STR$w_height%)
  1064.  PROCshell_Tracef0(">>> "+STR$height)
  1065.  PROCshell_Tracef0(">>> xscl "+STR$xscl)
  1066.  PROCshell_Tracef0(">>> yscl "+STR$yscl)
  1067. shell_HeapBlockReturn(w_blk%)
  1068. shell_DrawSetScale(buffer%,o_xscl,o_yscl)
  1069. B&*|Stop PROCshell_DrawScaleToWindow
  1070.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1071.  Responses to events raised by other modules..
  1072.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1073.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1074.  Private module routines
  1075.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1076. U#*|Start PROCshell_DrawPutString
  1077. shell_DrawPutString(S$,
  1078.  ptr%)
  1079. $ptr% = S$
  1080. ptr% += 
  1081.   ?ptr% = 0
  1082.   ptr% += 1
  1083.  ptr% 
  1084.  4 = 0
  1085. _"*|Stop PROCshell_DrawPutString
  1086. c#*|Start PROCshell_DrawPutCoords
  1087. shell_DrawPutCoords(start%,lx%,by%,rx%,ty%)
  1088. start%!00 = lx%
  1089. start%!04 = by%
  1090. start%!08 = rx%
  1091. start%!12 = ty%
  1092. k"*|Stop PROCshell_DrawPutCoords
  1093. o!*|Start PROCshell_DrawPutWord
  1094. shell_DrawPutWord(k%,
  1095.  buffer%)
  1096.  next%
  1097. r/buffer% = 
  1098. shell_HeapBlockExtend(buffer%,4)
  1099. s next% = buffer% + buffer%!08
  1100. !next% = k%
  1101. buffer%!08 += 4
  1102. x *|Stop PROCshell_DrawPutWord
  1103. |**|Start PROCshell_DrawUpdateObjectBBox
  1104. shell_DrawUpdateObjectBBox( buffer%, x_coord, y_coord )
  1105.  x_coord < DRW_PATH_XMIN 
  1106.  DRW_PATH_XMIN = x_coord
  1107.  x_coord > DRW_PATH_XMAX 
  1108.  DRW_PATH_XMAX = x_coord
  1109.  y_coord < DRW_PATH_YMIN 
  1110.  DRW_PATH_YMIN = y_coord
  1111.  y_coord > DRW_PATH_YMAX 
  1112.  DRW_PATH_YMAX = y_coord
  1113. 7!( buffer% + DRW_PATH_START% + 08 ) = DRW_PATH_XMIN
  1114. 7!( buffer% + DRW_PATH_START% + 12 ) = DRW_PATH_YMIN
  1115. 7!( buffer% + DRW_PATH_START% + 16 ) = DRW_PATH_XMAX
  1116. 7!( buffer% + DRW_PATH_START% + 20 ) = DRW_PATH_YMAX
  1117. )*|Stop PROCshell_DrawUpdateObjectBBox
  1118. &*|Start PROCshell_DrawUpdateBounds
  1119. shell_DrawUpdateBounds(buffer%,x0,y0,x1,y1)
  1120.  bb_start%
  1121. #bb_start% = buffer% + buffer%!4
  1122.  x0 > x1 
  1123.  x0,x1
  1124.  y0 > y1 
  1125.  y0,y1
  1126.  (bb_start% + 32) = 0 
  1127.  !(bb_start% + 36) = 0 
  1128.   !(bb_start% + 24) = x0
  1129.   !(bb_start% + 28) = y0
  1130.   !(bb_start% + 32) = x1
  1131.   !(bb_start% + 36) = y1
  1132.  x0 < !(bb_start% + 24) 
  1133.  !(bb_start% + 24) = x0
  1134.  y0 < !(bb_start% + 28) 
  1135.  !(bb_start% + 28) = y0
  1136.  x1 > !(bb_start% + 32) 
  1137.  !(bb_start% + 32) = x1
  1138.  y1 > !(bb_start% + 36) 
  1139.  !(bb_start% + 36) = y1
  1140.  buffer%!28 > 0 
  1141. shell_DrawUpdateGroupBounds(buffer%,x0,y0,x1,y1)
  1142. %*|Stop PROCshell_DrawUpdateBounds
  1143. +*|Start PROCshell_DrawUpdateGroupBounds
  1144. shell_DrawUpdateGroupBounds(buffer%,x0,y0,x1,y1)
  1145.  bb_start%
  1146. $bb_start% = buffer% + buffer%!28
  1147.  PROCshell_Tracef0("DEBUG::bb_offset = "+STR$~buffer%!28)
  1148.  PROCshell_Tracef0("DEBUG::current x0 = "+STR$(!(bb_start% + 08)))
  1149.  !(bb_start% + 08) = -1 
  1150.   !(bb_start% + 08) = x0
  1151.  x0 < !(bb_start% + 08) 
  1152.  !(bb_start% + 08) = x0
  1153.  !(bb_start% + 12) = -1 
  1154.   !(bb_start% + 12) = y0
  1155.  y0 < !(bb_start% + 12) 
  1156.  !(bb_start% + 12) = y0
  1157.  x1 > !(bb_start% + 16) 
  1158.  !(bb_start% + 16) = x1
  1159.  y1 > !(bb_start% + 20) 
  1160.  !(bb_start% + 20) = y1
  1161.  PROCshell_Tracef0("DEBUG::x0 = "+STR$x0)
  1162.  PROCshell_Tracef0("DEBUG::y0 = "+STR$y0)
  1163.  PROCshell_Tracef0("DEBUG::x1 = "+STR$x1)
  1164.  PROCshell_Tracef0("DEBUG::y1 = "+STR$y1)
  1165.  PROCshell_Tracef0("")
  1166.  PROCshell_Tracef0("DEBUG::x0 = "+STR$(!(bb_start%+8)))
  1167. **|Stop PROCshell_DrawUpdateGroupBounds
  1168.  *|Start FNshell_DrawFontName
  1169. shell_DrawFontName(ptr%,font%)
  1170.  ft_table%,ft_end%,df_start%,font$,p%,ft_handle%,found%
  1171.  ptr%!44 = -1 
  1172.  99,"No fonts have been initialised for this drawfile"
  1173. df_start%  = ptr% + ptr%!4
  1174. ft_table%  = ptr%!44 + ptr%
  1175.  PROCshell_Tracef0("DEBUG::ft_table% = &"+STR$~ft_table%)
  1176.  PROCshell_Tracef0("DEBUG::df_start% = &"+STR$~df_start%)
  1177.  font% = 0 
  1178.   font$ = "System Font"
  1179.  PROCshell_Tracef0("DEBUG::font table size is = "+STR$(ft_table%!4))
  1180. *  ft_end%    = ft_table%!4 + ft_table%
  1181.    p%         = ft_table% + 8
  1182. "    ft_handle% = ?p% : p% += 1
  1183. $    font$ = 
  1184. shell_GetString(p%)
  1185.     p%   += 
  1186.  font$ + 1
  1187.  4 <> 0
  1188.       p% +=1
  1189.         
  1190.  ft_handle% = font% 
  1191. '      found% = 
  1192.  : p% = ft_end% + 1
  1193.         
  1194.   p% >= ft_end%
  1195.  found% = 0 
  1196.  99,"Font not found in font table"
  1197. = font$
  1198. *|Stop FNshell_DrawFontName
  1199. #*|Start PROCshell_DrawTextSpace
  1200. shell_DrawTextSpace(ptr%,text$,font%,ptsize,pthigh,
  1201.  lx%,
  1202.  by%,
  1203.  rx%,
  1204.  ty%)
  1205.  handle%,xscale%,yscale%,r1%,r2%,r3%,r4%
  1206.  font% > 0 
  1207.  "Font_FindFont",,
  1208. shell_DrawFontName(ptr%,font%),ptsize * 16, pthigh * 16 
  1209.  handle%
  1210.  "Font_SetFont",handle%
  1211.  "Font_StringBBox",,text$ 
  1212.  ,r1%,r2%,r3%,r4%
  1213.  "Font_ReadScaleFactor" 
  1214.  ,xscale%,yscale%
  1215.  "Font_LoseFont",handle%
  1216. 1  ty% = 
  1217. shell_DrawTextCoord(by%,r4%,yscale%)
  1218. 1  rx% = 
  1219. shell_DrawTextCoord(lx%,r3%,xscale%)
  1220. 1  by% = 
  1221. shell_DrawTextCoord(by%,r2%,yscale%)
  1222. 1  lx% = 
  1223. shell_DrawTextCoord(lx%,r1%,xscale%)
  1224. )  rx% = lx% + ptsize * 2.5 * 
  1225. (text$)
  1226.   ty% = by% + pthigh * 2.5
  1227. "*|Stop PROCshell_DrawTextSpace
  1228.