Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras » Apple][e/PD/BOB/ARMBOB/!ArmBob/progs/h/wimp/templates

Apple][e/PD/BOB/ARMBOB/!ArmBob/progs/h/wimp/templates

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras
Filename: Apple][e/PD/BOB/ARMBOB/!ArmBob/progs/h/wimp/templates
Read OK:
File size: 0421 bytes
Load address: 0000
Exec address: 0000
File contents
/***********************************************************
 * templates                   GCW 02/03/94
 * window_handle = templates(template_file, window_name);
 * template_file is template file
 * window_name is a vector of window names
 * window_handle is the corresponding vector of handles
 ***********************************************************/

templates(template_file, window_name)
{
 local r, handle, n, i, padded;
 handle = newvector(n = sizeof(window_name));
 (r = newvector(8))[1] = template_file+0;
 swi("Wimp_OpenTemplate",r);
 for(i=0;i<n;i++)
 {
  r[1] = r[2] = r[3] = 0;
  r[4] = -1;
  r[5] = padded = pad(window_name[i],12,0);
  swi("Wimp_LoadTemplate",r);
  r[1] = newstring(r[1]);
  r[2] = newstring(r[2]);
  r[3] = @(r[2])+sizeof(r[2]);
  r[5] = padded;
  r[6] = 0;
  swi("Wimp_LoadTemplate",r);
  swi("Wimp_CreateWindow",r);
  handle[i] = r[0];
 }
 swi("Wimp_CloseTemplate",r);
 return(handle);
}

/* pad out s to length n with trailing character c's  */
pad(s,n,c)
{
 local len;
 while (sizeof(s)<n)
    s += c;
 return (s);
}
00000000  2f 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |/***************|
00000010  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00000030  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 0a 20 2a 20  |************. * |
00000040  74 65 6d 70 6c 61 74 65  73 20 20 20 20 20 20 20  |templates       |
00000050  20 20 20 20 20 20 20 20  20 20 20 20 47 43 57 20  |            GCW |
00000060  30 32 2f 30 33 2f 39 34  0a 20 2a 20 77 69 6e 64  |02/03/94. * wind|
00000070  6f 77 5f 68 61 6e 64 6c  65 20 3d 20 74 65 6d 70  |ow_handle = temp|
00000080  6c 61 74 65 73 28 74 65  6d 70 6c 61 74 65 5f 66  |lates(template_f|
00000090  69 6c 65 2c 20 77 69 6e  64 6f 77 5f 6e 61 6d 65  |ile, window_name|
000000a0  29 3b 0a 20 2a 20 74 65  6d 70 6c 61 74 65 5f 66  |);. * template_f|
000000b0  69 6c 65 20 69 73 20 74  65 6d 70 6c 61 74 65 20  |ile is template |
000000c0  66 69 6c 65 0a 20 2a 20  77 69 6e 64 6f 77 5f 6e  |file. * window_n|
000000d0  61 6d 65 20 69 73 20 61  20 76 65 63 74 6f 72 20  |ame is a vector |
000000e0  6f 66 20 77 69 6e 64 6f  77 20 6e 61 6d 65 73 0a  |of window names.|
000000f0  20 2a 20 77 69 6e 64 6f  77 5f 68 61 6e 64 6c 65  | * window_handle|
00000100  20 69 73 20 74 68 65 20  63 6f 72 72 65 73 70 6f  | is the correspo|
00000110  6e 64 69 6e 67 20 76 65  63 74 6f 72 20 6f 66 20  |nding vector of |
00000120  68 61 6e 64 6c 65 73 0a  20 2a 2a 2a 2a 2a 2a 2a  |handles. *******|
00000130  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00000160  2a 2a 2a 2a 2f 0a 0a 74  65 6d 70 6c 61 74 65 73  |****/..templates|
00000170  28 74 65 6d 70 6c 61 74  65 5f 66 69 6c 65 2c 20  |(template_file, |
00000180  77 69 6e 64 6f 77 5f 6e  61 6d 65 29 0a 7b 0a 20  |window_name).{. |
00000190  6c 6f 63 61 6c 20 72 2c  20 68 61 6e 64 6c 65 2c  |local r, handle,|
000001a0  20 6e 2c 20 69 2c 20 70  61 64 64 65 64 3b 0a 20  | n, i, padded;. |
000001b0  68 61 6e 64 6c 65 20 3d  20 6e 65 77 76 65 63 74  |handle = newvect|
000001c0  6f 72 28 6e 20 3d 20 73  69 7a 65 6f 66 28 77 69  |or(n = sizeof(wi|
000001d0  6e 64 6f 77 5f 6e 61 6d  65 29 29 3b 0a 20 28 72  |ndow_name));. (r|
000001e0  20 3d 20 6e 65 77 76 65  63 74 6f 72 28 38 29 29  | = newvector(8))|
000001f0  5b 31 5d 20 3d 20 74 65  6d 70 6c 61 74 65 5f 66  |[1] = template_f|
00000200  69 6c 65 2b 30 3b 0a 20  73 77 69 28 22 57 69 6d  |ile+0;. swi("Wim|
00000210  70 5f 4f 70 65 6e 54 65  6d 70 6c 61 74 65 22 2c  |p_OpenTemplate",|
00000220  72 29 3b 0a 20 66 6f 72  28 69 3d 30 3b 69 3c 6e  |r);. for(i=0;i<n|
00000230  3b 69 2b 2b 29 0a 20 7b  0a 20 20 72 5b 31 5d 20  |;i++). {.  r[1] |
00000240  3d 20 72 5b 32 5d 20 3d  20 72 5b 33 5d 20 3d 20  |= r[2] = r[3] = |
00000250  30 3b 0a 20 20 72 5b 34  5d 20 3d 20 2d 31 3b 0a  |0;.  r[4] = -1;.|
00000260  20 20 72 5b 35 5d 20 3d  20 70 61 64 64 65 64 20  |  r[5] = padded |
00000270  3d 20 70 61 64 28 77 69  6e 64 6f 77 5f 6e 61 6d  |= pad(window_nam|
00000280  65 5b 69 5d 2c 31 32 2c  30 29 3b 0a 20 20 73 77  |e[i],12,0);.  sw|
00000290  69 28 22 57 69 6d 70 5f  4c 6f 61 64 54 65 6d 70  |i("Wimp_LoadTemp|
000002a0  6c 61 74 65 22 2c 72 29  3b 0a 20 20 72 5b 31 5d  |late",r);.  r[1]|
000002b0  20 3d 20 6e 65 77 73 74  72 69 6e 67 28 72 5b 31  | = newstring(r[1|
000002c0  5d 29 3b 0a 20 20 72 5b  32 5d 20 3d 20 6e 65 77  |]);.  r[2] = new|
000002d0  73 74 72 69 6e 67 28 72  5b 32 5d 29 3b 0a 20 20  |string(r[2]);.  |
000002e0  72 5b 33 5d 20 3d 20 40  28 72 5b 32 5d 29 2b 73  |r[3] = @(r[2])+s|
000002f0  69 7a 65 6f 66 28 72 5b  32 5d 29 3b 0a 20 20 72  |izeof(r[2]);.  r|
00000300  5b 35 5d 20 3d 20 70 61  64 64 65 64 3b 0a 20 20  |[5] = padded;.  |
00000310  72 5b 36 5d 20 3d 20 30  3b 0a 20 20 73 77 69 28  |r[6] = 0;.  swi(|
00000320  22 57 69 6d 70 5f 4c 6f  61 64 54 65 6d 70 6c 61  |"Wimp_LoadTempla|
00000330  74 65 22 2c 72 29 3b 0a  20 20 73 77 69 28 22 57  |te",r);.  swi("W|
00000340  69 6d 70 5f 43 72 65 61  74 65 57 69 6e 64 6f 77  |imp_CreateWindow|
00000350  22 2c 72 29 3b 0a 20 20  68 61 6e 64 6c 65 5b 69  |",r);.  handle[i|
00000360  5d 20 3d 20 72 5b 30 5d  3b 0a 20 7d 0a 20 73 77  |] = r[0];. }. sw|
00000370  69 28 22 57 69 6d 70 5f  43 6c 6f 73 65 54 65 6d  |i("Wimp_CloseTem|
00000380  70 6c 61 74 65 22 2c 72  29 3b 0a 20 72 65 74 75  |plate",r);. retu|
00000390  72 6e 28 68 61 6e 64 6c  65 29 3b 0a 7d 0a 0a 2f  |rn(handle);.}../|
000003a0  2a 20 70 61 64 20 6f 75  74 20 73 20 74 6f 20 6c  |* pad out s to l|
000003b0  65 6e 67 74 68 20 6e 20  77 69 74 68 20 74 72 61  |ength n with tra|
000003c0  69 6c 69 6e 67 20 63 68  61 72 61 63 74 65 72 20  |iling character |
000003d0  63 27 73 20 20 2a 2f 0a  70 61 64 28 73 2c 6e 2c  |c's  */.pad(s,n,|
000003e0  63 29 0a 7b 0a 20 6c 6f  63 61 6c 20 6c 65 6e 3b  |c).{. local len;|
000003f0  0a 20 77 68 69 6c 65 20  28 73 69 7a 65 6f 66 28  |. while (sizeof(|
00000400  73 29 3c 6e 29 0a 20 20  20 20 73 20 2b 3d 20 63  |s)<n).    s += c|
00000410  3b 0a 20 72 65 74 75 72  6e 20 28 73 29 3b 0a 7d  |;. return (s);.}|
00000420  0a                                                |.|
00000421