Home » Archimedes archive » Archimedes World » archimedes_world_volume_14_issue_12_scp.adf » !AcornAns_AcornAns » !Brolly/c/wimp_misc
!Brolly/c/wimp_misc
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 » Archimedes World » archimedes_world_volume_14_issue_12_scp.adf » !AcornAns_AcornAns |
Filename: | !Brolly/c/wimp_misc |
Read OK: | ✔ |
File size: | 0754 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
#include "wimpt.h" #include "win.h" #include "event.h" #include "bbc.h" #include "kernel.h" #include "swis.h" static idle_count=0; void open_window(wimp_openstr *o) { /* Just pass the open request on to the wimp */ wimpt_noerr(wimp_open_wind(o)); } void release_idle_events(void) { if (--idle_count>0) return; idle_count=0; win_claim_idle_events((wimp_w)-1); /*release idle events*/ event_setmask(event_getmask() | wimp_EMNULL); /*mask out idle events*/ return; } void claim_idle_events(wimp_w w) { idle_count++; event_setmask(event_getmask() & ~wimp_EMNULL); /*allow idle events*/ win_claim_idle_events(w); /*claim idle events*/ return; } void pointer_restrict(wimp_w w) { char buf[9]; int i; buf[0]=1; if (w==(wimp_w)-1) { buf[1]=buf[2]=buf[3]=buf[4]=0; i=bbc_vduvar(bbc_XWindLimit) << bbc_vduvar(bbc_XEigFactor); buf[5]=i&255; buf[6]=i>>8; i=bbc_vduvar(bbc_YWindLimit) << bbc_vduvar(bbc_YEigFactor); buf[7]=i&255; buf[8]=i>>8; } else { wimp_wstate s; wimpt_complain(wimp_get_wind_state(w, &s)); i=s.o.box.x0-1; buf[1]=i&255; buf[2]=i>>8; i=s.o.box.y0-1; buf[3]=i&255; buf[4]=i>>8; i=s.o.box.x1; buf[5]=i&255; buf[6]=i>>8; i=s.o.box.y1; buf[7]=i&255; buf[8]=i>>8; } wimpt_complain(os_word(21, buf)); } void force_icon_slabbing(wimp_w w, wimp_i i) { _kernel_swi_regs r; wimp_emask old_mask=event_getmask(); /*slab the button*/ wimpt_complain(wimp_set_icon_state(w, i, wimp_ISELECTED, wimp_ISELECTED)); do /*-- read mouse state until buttons are released --*/ { _kernel_swi(OS_Mouse,&r,&r); event_process(); /*-- let wimp get on with life while we wait for button release --*/ } while(r.r[2] != 0); event_setmask(old_mask); wimpt_complain(wimp_set_icon_state(w, i, 0, wimp_ISELECTED)); }
00000000 23 69 6e 63 6c 75 64 65 20 22 77 69 6d 70 74 2e |#include "wimpt.| 00000010 68 22 0a 23 69 6e 63 6c 75 64 65 20 22 77 69 6e |h".#include "win| 00000020 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 22 65 76 |.h".#include "ev| 00000030 65 6e 74 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 |ent.h".#include | 00000040 22 62 62 63 2e 68 22 0a 23 69 6e 63 6c 75 64 65 |"bbc.h".#include| 00000050 20 22 6b 65 72 6e 65 6c 2e 68 22 0a 0a 23 69 6e | "kernel.h"..#in| 00000060 63 6c 75 64 65 20 22 73 77 69 73 2e 68 22 0a 0a |clude "swis.h"..| 00000070 73 74 61 74 69 63 20 69 64 6c 65 5f 63 6f 75 6e |static idle_coun| 00000080 74 3d 30 3b 0a 0a 76 6f 69 64 20 6f 70 65 6e 5f |t=0;..void open_| 00000090 77 69 6e 64 6f 77 28 77 69 6d 70 5f 6f 70 65 6e |window(wimp_open| 000000a0 73 74 72 20 2a 6f 29 0a 7b 0a 20 20 2f 2a 20 4a |str *o).{. /* J| 000000b0 75 73 74 20 70 61 73 73 20 74 68 65 20 6f 70 65 |ust pass the ope| 000000c0 6e 20 72 65 71 75 65 73 74 20 6f 6e 20 74 6f 20 |n request on to | 000000d0 74 68 65 20 77 69 6d 70 20 2a 2f 0a 20 20 77 69 |the wimp */. wi| 000000e0 6d 70 74 5f 6e 6f 65 72 72 28 77 69 6d 70 5f 6f |mpt_noerr(wimp_o| 000000f0 70 65 6e 5f 77 69 6e 64 28 6f 29 29 3b 0a 7d 0a |pen_wind(o));.}.| 00000100 0a 76 6f 69 64 20 72 65 6c 65 61 73 65 5f 69 64 |.void release_id| 00000110 6c 65 5f 65 76 65 6e 74 73 28 76 6f 69 64 29 0a |le_events(void).| 00000120 7b 0a 20 20 69 66 20 28 2d 2d 69 64 6c 65 5f 63 |{. if (--idle_c| 00000130 6f 75 6e 74 3e 30 29 20 72 65 74 75 72 6e 3b 0a |ount>0) return;.| 00000140 20 20 69 64 6c 65 5f 63 6f 75 6e 74 3d 30 3b 0a | idle_count=0;.| 00000150 20 20 77 69 6e 5f 63 6c 61 69 6d 5f 69 64 6c 65 | win_claim_idle| 00000160 5f 65 76 65 6e 74 73 28 28 77 69 6d 70 5f 77 29 |_events((wimp_w)| 00000170 2d 31 29 3b 20 20 20 20 20 20 20 20 20 20 20 20 |-1); | 00000180 2f 2a 72 65 6c 65 61 73 65 20 69 64 6c 65 20 65 |/*release idle e| 00000190 76 65 6e 74 73 2a 2f 0a 20 20 65 76 65 6e 74 5f |vents*/. event_| 000001a0 73 65 74 6d 61 73 6b 28 65 76 65 6e 74 5f 67 65 |setmask(event_ge| 000001b0 74 6d 61 73 6b 28 29 20 7c 20 77 69 6d 70 5f 45 |tmask() | wimp_E| 000001c0 4d 4e 55 4c 4c 29 3b 20 2f 2a 6d 61 73 6b 20 6f |MNULL); /*mask o| 000001d0 75 74 20 69 64 6c 65 20 65 76 65 6e 74 73 2a 2f |ut idle events*/| 000001e0 0a 20 20 72 65 74 75 72 6e 3b 0a 7d 0a 0a 76 6f |. return;.}..vo| 000001f0 69 64 20 63 6c 61 69 6d 5f 69 64 6c 65 5f 65 76 |id claim_idle_ev| 00000200 65 6e 74 73 28 77 69 6d 70 5f 77 20 77 29 0a 7b |ents(wimp_w w).{| 00000210 0a 20 20 69 64 6c 65 5f 63 6f 75 6e 74 2b 2b 3b |. idle_count++;| 00000220 0a 20 20 65 76 65 6e 74 5f 73 65 74 6d 61 73 6b |. event_setmask| 00000230 28 65 76 65 6e 74 5f 67 65 74 6d 61 73 6b 28 29 |(event_getmask()| 00000240 20 26 20 7e 77 69 6d 70 5f 45 4d 4e 55 4c 4c 29 | & ~wimp_EMNULL)| 00000250 3b 20 2f 2a 61 6c 6c 6f 77 20 69 64 6c 65 20 65 |; /*allow idle e| 00000260 76 65 6e 74 73 2a 2f 0a 20 20 77 69 6e 5f 63 6c |vents*/. win_cl| 00000270 61 69 6d 5f 69 64 6c 65 5f 65 76 65 6e 74 73 28 |aim_idle_events(| 00000280 77 29 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 |w); | 00000290 20 20 20 20 20 20 20 20 20 2f 2a 63 6c 61 69 6d | /*claim| 000002a0 20 69 64 6c 65 20 65 76 65 6e 74 73 2a 2f 0a 20 | idle events*/. | 000002b0 20 72 65 74 75 72 6e 3b 0a 7d 0a 0a 76 6f 69 64 | return;.}..void| 000002c0 20 70 6f 69 6e 74 65 72 5f 72 65 73 74 72 69 63 | pointer_restric| 000002d0 74 28 77 69 6d 70 5f 77 20 77 29 0a 7b 0a 20 20 |t(wimp_w w).{. | 000002e0 63 68 61 72 20 62 75 66 5b 39 5d 3b 0a 20 20 69 |char buf[9];. i| 000002f0 6e 74 20 69 3b 0a 20 20 62 75 66 5b 30 5d 3d 31 |nt i;. buf[0]=1| 00000300 3b 0a 20 20 69 66 20 28 77 3d 3d 28 77 69 6d 70 |;. if (w==(wimp| 00000310 5f 77 29 2d 31 29 20 7b 0a 20 20 20 20 62 75 66 |_w)-1) {. buf| 00000320 5b 31 5d 3d 62 75 66 5b 32 5d 3d 62 75 66 5b 33 |[1]=buf[2]=buf[3| 00000330 5d 3d 62 75 66 5b 34 5d 3d 30 3b 0a 20 20 20 20 |]=buf[4]=0;. | 00000340 69 3d 62 62 63 5f 76 64 75 76 61 72 28 62 62 63 |i=bbc_vduvar(bbc| 00000350 5f 58 57 69 6e 64 4c 69 6d 69 74 29 20 3c 3c 20 |_XWindLimit) << | 00000360 62 62 63 5f 76 64 75 76 61 72 28 62 62 63 5f 58 |bbc_vduvar(bbc_X| 00000370 45 69 67 46 61 63 74 6f 72 29 3b 0a 20 20 20 20 |EigFactor);. | 00000380 62 75 66 5b 35 5d 3d 69 26 32 35 35 3b 0a 20 20 |buf[5]=i&255;. | 00000390 20 20 62 75 66 5b 36 5d 3d 69 3e 3e 38 3b 0a 20 | buf[6]=i>>8;. | 000003a0 20 20 20 69 3d 62 62 63 5f 76 64 75 76 61 72 28 | i=bbc_vduvar(| 000003b0 62 62 63 5f 59 57 69 6e 64 4c 69 6d 69 74 29 20 |bbc_YWindLimit) | 000003c0 3c 3c 20 62 62 63 5f 76 64 75 76 61 72 28 62 62 |<< bbc_vduvar(bb| 000003d0 63 5f 59 45 69 67 46 61 63 74 6f 72 29 3b 0a 20 |c_YEigFactor);. | 000003e0 20 20 20 62 75 66 5b 37 5d 3d 69 26 32 35 35 3b | buf[7]=i&255;| 000003f0 0a 20 20 20 20 62 75 66 5b 38 5d 3d 69 3e 3e 38 |. buf[8]=i>>8| 00000400 3b 0a 20 20 7d 0a 20 20 65 6c 73 65 20 7b 0a 20 |;. }. else {. | 00000410 20 20 20 77 69 6d 70 5f 77 73 74 61 74 65 20 73 | wimp_wstate s| 00000420 3b 0a 20 20 20 20 77 69 6d 70 74 5f 63 6f 6d 70 |;. wimpt_comp| 00000430 6c 61 69 6e 28 77 69 6d 70 5f 67 65 74 5f 77 69 |lain(wimp_get_wi| 00000440 6e 64 5f 73 74 61 74 65 28 77 2c 20 26 73 29 29 |nd_state(w, &s))| 00000450 3b 0a 20 20 20 20 69 3d 73 2e 6f 2e 62 6f 78 2e |;. i=s.o.box.| 00000460 78 30 2d 31 3b 0a 20 20 20 20 62 75 66 5b 31 5d |x0-1;. buf[1]| 00000470 3d 69 26 32 35 35 3b 0a 20 20 20 20 62 75 66 5b |=i&255;. buf[| 00000480 32 5d 3d 69 3e 3e 38 3b 0a 20 20 20 20 69 3d 73 |2]=i>>8;. i=s| 00000490 2e 6f 2e 62 6f 78 2e 79 30 2d 31 3b 0a 20 20 20 |.o.box.y0-1;. | 000004a0 20 62 75 66 5b 33 5d 3d 69 26 32 35 35 3b 0a 20 | buf[3]=i&255;. | 000004b0 20 20 20 62 75 66 5b 34 5d 3d 69 3e 3e 38 3b 0a | buf[4]=i>>8;.| 000004c0 20 20 20 20 69 3d 73 2e 6f 2e 62 6f 78 2e 78 31 | i=s.o.box.x1| 000004d0 3b 0a 20 20 20 20 62 75 66 5b 35 5d 3d 69 26 32 |;. buf[5]=i&2| 000004e0 35 35 3b 0a 20 20 20 20 62 75 66 5b 36 5d 3d 69 |55;. buf[6]=i| 000004f0 3e 3e 38 3b 0a 20 20 20 20 69 3d 73 2e 6f 2e 62 |>>8;. i=s.o.b| 00000500 6f 78 2e 79 31 3b 0a 20 20 20 20 62 75 66 5b 37 |ox.y1;. buf[7| 00000510 5d 3d 69 26 32 35 35 3b 0a 20 20 20 20 62 75 66 |]=i&255;. buf| 00000520 5b 38 5d 3d 69 3e 3e 38 3b 0a 20 20 7d 0a 20 20 |[8]=i>>8;. }. | 00000530 77 69 6d 70 74 5f 63 6f 6d 70 6c 61 69 6e 28 6f |wimpt_complain(o| 00000540 73 5f 77 6f 72 64 28 32 31 2c 20 62 75 66 29 29 |s_word(21, buf))| 00000550 3b 0a 7d 0a 0a 76 6f 69 64 20 66 6f 72 63 65 5f |;.}..void force_| 00000560 69 63 6f 6e 5f 73 6c 61 62 62 69 6e 67 28 77 69 |icon_slabbing(wi| 00000570 6d 70 5f 77 20 77 2c 20 77 69 6d 70 5f 69 20 69 |mp_w w, wimp_i i| 00000580 29 0a 7b 0a 20 20 5f 6b 65 72 6e 65 6c 5f 73 77 |).{. _kernel_sw| 00000590 69 5f 72 65 67 73 20 72 3b 0a 20 20 77 69 6d 70 |i_regs r;. wimp| 000005a0 5f 65 6d 61 73 6b 20 6f 6c 64 5f 6d 61 73 6b 3d |_emask old_mask=| 000005b0 65 76 65 6e 74 5f 67 65 74 6d 61 73 6b 28 29 3b |event_getmask();| 000005c0 0a 20 20 2f 2a 73 6c 61 62 20 74 68 65 20 62 75 |. /*slab the bu| 000005d0 74 74 6f 6e 2a 2f 0a 20 20 77 69 6d 70 74 5f 63 |tton*/. wimpt_c| 000005e0 6f 6d 70 6c 61 69 6e 28 77 69 6d 70 5f 73 65 74 |omplain(wimp_set| 000005f0 5f 69 63 6f 6e 5f 73 74 61 74 65 28 77 2c 20 69 |_icon_state(w, i| 00000600 2c 20 77 69 6d 70 5f 49 53 45 4c 45 43 54 45 44 |, wimp_ISELECTED| * 00000620 29 29 3b 0a 20 20 64 6f 20 2f 2a 2d 2d 20 72 65 |));. do /*-- re| 00000630 61 64 20 6d 6f 75 73 65 20 73 74 61 74 65 20 75 |ad mouse state u| 00000640 6e 74 69 6c 20 62 75 74 74 6f 6e 73 20 61 72 65 |ntil buttons are| 00000650 20 72 65 6c 65 61 73 65 64 20 2d 2d 2a 2f 0a 20 | released --*/. | 00000660 20 7b 0a 20 20 20 20 5f 6b 65 72 6e 65 6c 5f 73 | {. _kernel_s| 00000670 77 69 28 4f 53 5f 4d 6f 75 73 65 2c 26 72 2c 26 |wi(OS_Mouse,&r,&| 00000680 72 29 3b 0a 20 20 20 20 65 76 65 6e 74 5f 70 72 |r);. event_pr| 00000690 6f 63 65 73 73 28 29 3b 20 20 2f 2a 2d 2d 20 6c |ocess(); /*-- l| 000006a0 65 74 20 77 69 6d 70 20 67 65 74 20 6f 6e 20 77 |et wimp get on w| 000006b0 69 74 68 20 6c 69 66 65 20 77 68 69 6c 65 20 77 |ith life while w| 000006c0 65 20 77 61 69 74 20 66 6f 72 20 62 75 74 74 6f |e wait for butto| 000006d0 6e 20 72 65 6c 65 61 73 65 20 2d 2d 2a 2f 0a 20 |n release --*/. | 000006e0 20 7d 20 77 68 69 6c 65 28 72 2e 72 5b 32 5d 20 | } while(r.r[2] | 000006f0 21 3d 20 30 29 3b 0a 20 20 65 76 65 6e 74 5f 73 |!= 0);. event_s| 00000700 65 74 6d 61 73 6b 28 6f 6c 64 5f 6d 61 73 6b 29 |etmask(old_mask)| 00000710 3b 0a 20 20 77 69 6d 70 74 5f 63 6f 6d 70 6c 61 |;. wimpt_compla| 00000720 69 6e 28 77 69 6d 70 5f 73 65 74 5f 69 63 6f 6e |in(wimp_set_icon| 00000730 5f 73 74 61 74 65 28 77 2c 20 69 2c 20 30 2c 20 |_state(w, i, 0, | 00000740 77 69 6d 70 5f 49 53 45 4c 45 43 54 45 44 29 29 |wimp_ISELECTED))| 00000750 3b 0a 7d 0a |;.}.| 00000754