Home » Archimedes archive » Acorn User » AU 1996-12 B.adf » Features » PCA/!Processed/c/Processed

PCA/!Processed/c/Processed

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 1996-12 B.adf » Features
Filename: PCA/!Processed/c/Processed
Read OK:
File size: 4671 bytes
Load address: 0000
Exec address: 0000
File contents
#include <stdlib.h>
#include <stdio.h>
#include "wimp.h"
#include "toolbox.h"
#include "event.h"
#include "wimplib.h"
#include "gadgets.h"
#include "window.h"
#include "sprite.h"
#include "ProgInfo.h"
#include "menu.h"
#include "swis.h"

#include <string.h>
#include <stdarg.h>

#include "pca.h"
#include "flex.h"




#define WimpVersion    310

static  WimpPollBlock  poll_block;
static  MessagesFD     messages;
static  IdBlock        id_block;
static  ObjectId       toolmenu;
static  ObjectId       mainmenu;


int OtherTask,ThisTask;

int handlers_attached=0;

    sprite_area * spblock;
    sprite_id     id;
    char * sname ="tester";

    BOOL VALID=FALSE;
    BOOL SHORTCUT=FALSE;
    char Display[255];
    int count=0;
    char *names[64];
    int   task[64][2];
    int *fake;
    BOOL ACCEPT_INPLACE=TRUE;
    BOOL HOOKED=FALSE;
    int hooked_w;
    int hooked_t;
    int hooked_r;
    void * invisible;
    tag *anch;

int quit_event(int event_code, ToolboxEvent *event, IdBlock *id_block,void *handle);
int quit_message(WimpMessage *message,void *handle);
int attach_handlers(int event_code,ToolboxEvent *event,IdBlock *id_block, void *handle);
void werr(int fatal, char* format, ...);
int redraw_window(int event_code, WimpPollBlock *event,IdBlock *id_block,void *v);
void invalidate_addresses(void);
int WhosAbout_message(WimpMessage *message,void *handle);
void blockmoved(BOOL b4,void *handle);
int do_the_free(int event_code, ToolboxEvent *event, IdBlock *id_block,void *handle);
int set_status(int event_code, ToolboxEvent *event, IdBlock *id_block,void *handle);
int setup_menu(int event_code, ToolboxEvent *event, IdBlock *id_block,void *handle);
int changed(WimpMessage *message,void *handle);
int hereIam(int event_code, ToolboxEvent *event, IdBlock *id_block,void *handle);
int update_window(int w_handle,BBox *box);
void os_byte(int code,int * x,int *y);
int akbd_pollsh(void);
int akbd_pollctl(void);
int button(int event_code, WimpPollBlock *event,IdBlock *id_block,void *v);
void screen_to_sprite(WimpMouseClickEvent * c);
int open(int event_code, WimpPollBlock *event,IdBlock *id_block,void *v);
void store_gadget(char* Template,ObjectId Oid,ComponentId g);
void create_gadget(ObjectId Oid,ComponentId g);
void kill_gadget(ObjectId Oid,ComponentId g);





/*
 * Event handler to be called when toolbox event 1
 * is generated (by click on the 'Quit' entry of
 * the iconbar menu.)
 */

int quit_event(int event_code, ToolboxEvent *event, IdBlock *id_block,void *handle)
{
  _kernel_swi_regs r;
  event_code = event_code;
  event = event;
  id_block = id_block;
  handle = handle;
  invalidate_addresses();
  r.r[0]=(int)anch;
_kernel_swi(PCA_DeleteTag,&r,&r);
  exit(0);
  return(1);
}






/*
 * Message handler to be called on receipt of a
 * Quit or PreQuit message from the Wimp.
 */

int quit_message(WimpMessage *message,void *handle)
{
  _kernel_swi_regs r;
  message = message;
  handle = handle;
  invalidate_addresses();
r.r[0]=(int)anch;
_kernel_swi(PCA_DeleteTag,&r,&r);




  exit(0);
  return(1);
}



/* Called on receipt of a WhosAbout message. Add the new task to the
   utilities menu
*/

int WhosAbout_message(WimpMessage *message,void *handle)

{
imhere_block *e;
MenuTemplateEntry Entry = {0};
int temp;
char* q;
handle=handle;

e=(imhere_block *)message->data.words;

temp=strlen(e->menu);
q=(char*)malloc(temp+1);
if (q==0) return(0);
names[count]=q;
strcpy(names[count],e->menu);
task[count][0]=message->hdr.sender;
task[count][1]=e->flags;
Entry.click_event = 0x300;
Entry.text = names[count];
Entry.max_text = strlen (Entry.text) +1;
Entry.component_id = (ComponentId) count++;
menu_add_entry(0,(ObjectId)handle ,Menu_AddEntryAtEnd,(char *) &Entry,0);
menu_set_fade(0,mainmenu,0,0);

return(FALSE);
}



/* Called on receipt of an open window request. If acting as a local to
   an in place editor, keep it informed of windows position
*/

int open(int event_code, WimpPollBlock *event,IdBlock *id_block,void *v)
{
objectpos_block *e;

WimpMessage message;

if(HOOKED)
{
   e=(objectpos_block *)message.data.words;
   message.hdr.your_ref=hooked_r;
   message.hdr.size=64;
   message.hdr.action_code=Message_ObjectPosition;
   message.hdr.sender=ThisTask;
   e->tagptr=anch;

   e->handle=hooked_w;
   e->toolbarhandle=-1;
   e->zero=0;
   e->xlow=event->open_window_request.visible_area.xmin;
   e->ylow=event->open_window_request.visible_area.ymin;
   e->xscale=1<<16;
   e->yscale=1<<16;
   e->xlowu=event->open_window_request.visible_area.xmin;
   e->ylowu=event->open_window_request.visible_area.ymin;
   wimp_send_message(17,&message,task[hooked_t][0],0,NULL);

 }
wimp_open_window((WimpOpenWindowBlock*)event);

return(TRUE);
}


int close(int event_code, WimpPollBlock *event,IdBlock *id_block,void *v)
{
invalidate_addresses();
HOOKED=FALSE;
VALID=FALSE;
wimp_close_window((int*)event);
return FALSE;
}

void store_gadget(char* Template,ObjectId Oid,ComponentId g)
{
void *v,*t;
int s;
v=malloc(sizeof(ObjectTemplateHeader));
t=malloc(sizeof(Button) +sizeof(GadgetHeader));
if ((!t)||(!v)) werr(TRUE,"Fatal error: Insufficient memory");
toolbox_template_lookup(0,Template,&v);
window_extract_gadget_info(0,v,g,&t,&s);
invisible=malloc(s);
if (!invisible) werr(TRUE,"Fatal error: Insufficient memory");
*(Gadget*)invisible=*(Gadget*)t;
window_remove_gadget(0,Oid,g);

}

void create_gadget(ObjectId Oid,ComponentId g)
{
window_add_gadget(0,Oid,invisible,&g);
}

void kill_gadget(ObjectId Oid,ComponentId g)
{
window_remove_gadget(0,Oid,g);
}



/*
   A HookMe message has been received. Set the invisible icon's
   button type to that requested by the linked tool.
*/

int hookme_message(WimpMessage *message,void *handle)

{
hookme_block *e;
objectpos_block *f;
int w;
int clear,eor;
ObjectId Oid;
WimpGetWindowStateBlock state;


Oid=(ObjectId)handle;
create_gadget(Oid,0);

e=(hookme_block *)message->data.words;

eor=e->flags >> 16;
clear=0xf000;
button_set_flags (0,Oid,0,clear,eor);


hooked_w=e->handle;
message->hdr.your_ref=message->hdr.my_ref;
hooked_r=message->hdr.your_ref;
message->hdr.size=64;
message->hdr.action_code=Message_ObjectPosition;

window_get_wimp_handle(0,Oid ,&w);
state.window_handle = w;
wimp_get_window_state(&state);

f=(objectpos_block*) e;
f->handle=w;
f->zero=0;
f->toolbarhandle=-1;
f->xlow=state.visible_area.xmin;
f->ylow=state.visible_area.ymin;
f->xscale=1<<16;
f->yscale=1<<16;
f->xlowu=state.visible_area.xmin;
f->ylowu=state.visible_area.ymin;

wimp_send_message      (17,message,task[hooked_t][0],0,NULL);
HOOKED=TRUE;

return(FALSE);
}




/*
   Unhook and kill gadget
*/

int unhookme_message(WimpMessage *message,void *handle)
{

ObjectId Oid;

Oid=(ObjectId)handle;


kill_gadget(Oid,0);
HOOKED=FALSE;

return(FALSE);
}






/* Registered callback function. Called when our flex block moves.
   Called twice, once before the move and once after. We are only interested
   in the call after.
*/

void blockmoved(BOOL b4,void *handle)
{

if (!b4)
  {

   id.tag=sprite_id_name;
   id.s.addr=sname;
   sprite_select_rp(spblock,&id,&id.s.addr);
   id.tag=sprite_id_addr;
   anch->base=(int*)spblock;
   }
}



/* If the dummy block has not yet been freed, do it now. This will cause our
   main block to move, thus calling the registered callback handler.
*/


int do_the_free(int event_code, ToolboxEvent *event, IdBlock *id_block,void *handle)

{
if(fake!=NULL)
  {
      flex_free((flex_ptr)&fake);
      fake=NULL;
   }

/* There's only one dummy block to delete, so once it's been done,
   fade the menu entry.
*/


menu_set_fade(0,mainmenu,1,1);


return(TRUE);
}



/*
    Toggle user option to accept in place editing.
*/

int set_status(int event_code, ToolboxEvent *event, IdBlock *id_block,void *handle)

{

ACCEPT_INPLACE=!ACCEPT_INPLACE;

if(ACCEPT_INPLACE)
    menu_set_tick(0,mainmenu,2,1);
else
menu_set_tick(0,mainmenu,2,0);

return(TRUE);


}



/* Main menu about to be shown. Send messages to find out who's about.
   Utility menu created by function handling responses.
*/

int setup_menu(int event_code, ToolboxEvent *event, IdBlock *id_block,void *handle)
{
whosabout_block *e;
WimpMessage w;

int i;
menu_set_fade(0,mainmenu,0,1);
for (i=0;i<count;i++)
     {
     menu_remove_entry(0,(ObjectId)handle,i);
     free(names[i]);
     }
count=0;
e=(whosabout_block *)&w.data;
w.hdr.size=64;
w.hdr.action_code=Message_WhosAbout;
w.hdr.my_ref=0;
w.hdr.your_ref=0;
w.hdr.sender=ThisTask;

e->tagptr=anch;
e->filetype=0xff9;
wimp_send_message      (17,&w,0,0,NULL);

if(ACCEPT_INPLACE) menu_set_tick(0,mainmenu,2,1); else menu_set_tick(0,mainmenu,2,0);

return(FALSE);
}




/*  A remote application has modified the picture */


int changed(WimpMessage *message,void *handle)

{
ObjectId Oid;
BBox b;
updatearea_block *e;
int w;

e=(updatearea_block *)message->data.words;

Oid=(ObjectId)handle;

if (message->hdr.action_code==Message_DoneMyStuff)
   {
      b.xmin=0;
      b.xmax=1000;
      b.ymin=-398;
      b.ymax=-00;

   }
else
   {
     b.xmin=e->r.xlow;
     b.xmax=e->r.xhi;
     b.ymin=e->r.ylow-398;
     b.ymax=e->r.yhi-398;
   }

window_get_wimp_handle(0,Oid ,&w);
update_window(w,&b);


return(TRUE);
}




int returned_message(WimpMessage *message,void *handle)

{
handle=handle;

if ((message->hdr.sender==ThisTask) && SHORTCUT)
{

SHORTCUT=FALSE;
toolbox_show_object(1,toolmenu,0,NULL,NULL,NULL);


}
return(FALSE);
}











/* link to selected remote */

int hereIam(int event_code, ToolboxEvent *event, IdBlock *id_block,void *handle)
{
doyourstuff_block *e;
WimpMessage w;

e=(doyourstuff_block *)&w.data;

w.hdr.size=64;
w.hdr.action_code=Message_DoYourStuff;
w.hdr.my_ref=0;
w.hdr.your_ref=0;
w.hdr.sender=ThisTask;
e->toolid=1;
e->flags=task[id_block->self_component][1];
if (!ACCEPT_INPLACE) e->flags =  e->flags & !Flag_remote;
strcpy(e->name,"Gee-gee");

e->tagptr=anch;
e->filetype=0xff9;
hooked_t=id_block->self_component;
wimp_send_message      (17,&w,task[id_block->self_component][0],0,NULL);
VALID=TRUE;
return(FALSE);
}



/* The picture is about to disappear, so warn remotes that the address they
   have will not longer be valid.
*/




void invalidate_addresses(void)
{
deselect_block *e;
WimpMessage w;

e=(deselect_block *)&w.data;

w.hdr.size=64;
w.hdr.action_code=Message_Deselect;
w.hdr.my_ref=0;
w.hdr.your_ref=0;
w.hdr.sender=ThisTask;

e->tagptr=anch;
e->filetype=0xff9;
wimp_send_message      (17,&w,0,0,NULL);
VALID=FALSE;
}




int main()
{
    int    toolbox_events = 0,
           wimp_messages = 0,
           event_code;
     _kernel_swi_regs r;


    /*
     * register ourselves with the Toolbox.
     */

    toolbox_initialise (0, WimpVersion, &wimp_messages, &toolbox_events, "<Processed$Dir>",
                        &messages, &id_block, 0, &ThisTask, 0);


   /* Initialise flex with dynamic areas active */

    flex_initx("Processed",(int*)&messages,TRUE,1024*1024,FALSE);


    /*
     * initialise the event library.
     */

    event_initialise (&id_block);
    event_set_mask (1+256);


    /*
     * register handler for toolbox event 1,
     * which is generated by the 'Quit' option on the
     * iconbar menu.  Also register message handlers
     * to quit properly when quit messages are
     * received from the wimp.
     */

      event_register_toolbox_handler(-1,1,quit_event,0);
      event_register_message_handler(Wimp_MQuit,quit_message,0);
      event_register_message_handler(Wimp_MPreQuit,quit_message,0);
      event_register_toolbox_handler(-1,Toolbox_ObjectAutoCreated,attach_handlers,NULL);





    /* Allocate a block before the one containing the sprite. When this is later
       freed, it will cause the sprite to move.
    */

     flex_alloc((flex_ptr)&fake,100*1024);


    if (flex_alloc((flex_ptr)&spblock,300*1024)==0) werr(TRUE,"Fatal error. No room for sprite area");


     sprite_area_initialise(spblock, 1024*300);
     sprite_area_load(spblock, "<Processed$Dir>.Testfile");
     id.tag=sprite_id_name;
     id.s.addr=sname;
     sprite_select_rp(spblock,&id,&id.s.addr);
     id.tag=sprite_id_addr;
     flex_register((flex_ptr)&spblock,blockmoved,NULL);

     r.r[1]=(int)spblock;
     r.r[2]=(int)id.s.addr-(int)spblock;
     _kernel_swi(PCA_CreateTag,&r,&r);
     anch=(tag*)r.r[0];


    /*
     * poll loop
     */

    while (TRUE)
    {
        event_poll (&event_code, &poll_block, 0);
    }
}



int attach_handlers(int event_code,ToolboxEvent *event,IdBlock *id_block, void *handle)
{
  /* This function has been called as a result of an object being
   * auto-created. For this example that means our iconbar object
   * so we can now register all our other handlers for the rest
   * of our objects
   */


  ObjectClass     obj_class;
  char buffer[32];
  int dum;



  toolbox_get_object_class(0,id_block->self_id,&obj_class);
  toolbox_get_template_name(0,id_block->self_id,buffer,32,&dum);


  switch(obj_class)
  {
    case Window_ObjectClass:

   if ((!handlers_attached) && (strcmp(buffer,"Window")==0) )
      {
     event_register_wimp_handler(id_block->self_id,Wimp_ERedrawWindow,redraw_window,NULL);
     event_register_wimp_handler(-1,Wimp_EOpenWindow,open,(void*)id_block->self_id );
      event_register_wimp_handler(-1,Wimp_ECloseWindow,close,(void*)id_block->self_id );
     event_register_wimp_handler(id_block->self_id,Wimp_EMouseClick,button,(void*)id_block->self_id );
     event_register_message_handler(Message_DoneMyStuff,changed,(void*)id_block->self_id );
     event_register_message_handler(Message_UpdateArea,changed,(void*)id_block->self_id );
     event_register_message_handler(Message_WhosAbout,returned_message,(void*)id_block->self_id );
     event_register_message_handler(Message_HookMe,hookme_message,(void*)id_block->self_id );
     event_register_message_handler(Message_UnhookMe,unhookme_message,(void*)id_block->self_id );
     store_gadget("Window",id_block->self_id,0);


            handlers_attached=1;
       }
     break;

   case ProgInfo_ObjectClass:

      proginfo_set_version (0,id_block->self_id, "0.02 " __DATE__);
      break;

   case Menu_ObjectClass:
      if (strcmp(buffer,"Menu")==0)

             {

           toolmenu=id_block->self_id;
           event_register_toolbox_handler(id_block->self_id,0x300,hereIam,(void*)toolmenu);
           event_register_message_handler(Message_WhosAbout,returned_message,(void*)toolmenu );

             }
    if ((strcmp(buffer,"Main")==0) && (toolmenu!=0))

         {
         mainmenu=id_block->self_id;
         event_register_toolbox_handler(id_block->self_id,0x200,setup_menu,(void*)toolmenu);
         event_register_message_handler(Message_ImHere,WhosAbout_message,(void*)toolmenu);
         event_register_toolbox_handler(-1,0x500,do_the_free,(void*)mainmenu);
         event_register_toolbox_handler(-1,0x501,set_status,(void*)mainmenu);
         }


      break;


  }


  return 1;
}







void werr(int fatal, char* format, ...)
{
   va_list va;
   _kernel_oserror e;

   e.errnum = 0;
   va_start(va, format);
   vsprintf(&e.errmess[0], format, va);
   va_end(va);
   wimp_report_error(&e, 0, "Processed",0,0,0);
   if (fatal) exit(1);
}



/*
   A mouse button has been pressed. If in place editing is active, pass
   the mouse click to the remote. Otherwise, look for the keyboard
   short cut.
*/


int button(int event_code, WimpPollBlock *event,IdBlock *id_block,void *v)
{

ObjectId Oid;

ToolboxEvent t;
Oid=(ObjectId)v;

if(HOOKED)

{

screen_to_sprite((WimpMouseClickEvent *)event);

event->mouse_click.window_handle=hooked_w;
event->mouse_click.icon_handle=-(0x414350);
wimp_send_message(6,event,task[hooked_t][0],0,NULL);


}

else
{

   if (akbd_pollsh() && akbd_pollctl())
   {
        t.hdr.size=16;
        t.hdr.event_code=0x200;
        t.hdr.flags=0;
        toolbox_raise_toolbox_event(0,mainmenu,NULL,&t);
        SHORTCUT=TRUE;
     }

}



return(TRUE);
}


/*
  Convert mouse coordinates to an ofset into the sprite.
*/


void screen_to_sprite(WimpMouseClickEvent * c)
{

WimpGetWindowStateBlock state;
int x,y;



state.window_handle = c->window_handle;
wimp_get_window_state(&state);

x = (state.visible_area.xmin - state.xscroll);
y = (state.visible_area.ymax - state.yscroll);



c->mouse_x-=x;
c->mouse_y=y-c->mouse_y;
c->mouse_y=398-c->mouse_y;



}






int redraw_window(int event_code, WimpPollBlock *event,IdBlock *id_block,void *v)
{
   int more,height,x,y;
   WimpGetWindowStateBlock state;
   WimpRedrawWindowBlock block;
   BBox extent;


   state.window_handle = event->redraw_window_request.window_handle;
   block.window_handle = event->redraw_window_request.window_handle;

   wimp_get_window_state(&state);

   window_get_extent(0, state.window_handle,&extent);
   height = extent.ymax -extent.ymin;


   x = (state.visible_area.xmin - state.xscroll);
   y = (state.visible_area.ymax - state.yscroll);

   wimp_redraw_window(&block,&more);
   while (more)
   {
      if(spblock!=NULL) sprite_put_in_current(spblock, &id, 0,x, y-398);


       wimp_get_rectangle (&block,&more);
   }

   return 1;
}




int update_window(int w_handle,BBox *box)
{
   int more,x,y;
   WimpGetWindowStateBlock state;
   WimpRedrawWindowBlock block;

   state.window_handle = w_handle;
   wimp_get_window_state(&state);

   x = (state.visible_area.xmin - state.xscroll);
   y = (state.visible_area.ymax - state.yscroll);

   block.window_handle=w_handle;
   block.visible_area.xmin=box->xmin;
   block.visible_area.xmax=box->xmax;
   block.visible_area.ymin=box->ymin;
   block.visible_area.ymax=box->ymax;



   wimp_update_window(&block,&more);
   while (more)
   {
      if(spblock!=NULL) sprite_put_in_current(spblock, &id, 0,x, y-398);


       wimp_get_rectangle (&block,&more);
   }

   return 1;
}


void os_byte(int code,int * x,int *y)
{
_swi(OS_Byte,_IN(0)|_IN(1)|_IN(2)|_OUT(1)|_OUT(2),code,*x,*y,x,y);
}


int akbd_pollsh(void)
{
  int x = -1;
  int y = 255;
  os_byte(129, &x, &y);
  return(x==255 && y==255);
}

int akbd_pollctl(void)
{
  int x = -2;
  int y = 255;
  os_byte(129, &x, &y);
  return(x==255 && y==255);
}




00000000  0a 23 69 6e 63 6c 75 64  65 20 3c 73 74 64 6c 69  |.#include <stdli|
00000010  62 2e 68 3e 0a 23 69 6e  63 6c 75 64 65 20 3c 73  |b.h>.#include <s|
00000020  74 64 69 6f 2e 68 3e 0a  23 69 6e 63 6c 75 64 65  |tdio.h>.#include|
00000030  20 22 77 69 6d 70 2e 68  22 0a 23 69 6e 63 6c 75  | "wimp.h".#inclu|
00000040  64 65 20 22 74 6f 6f 6c  62 6f 78 2e 68 22 0a 23  |de "toolbox.h".#|
00000050  69 6e 63 6c 75 64 65 20  22 65 76 65 6e 74 2e 68  |include "event.h|
00000060  22 0a 23 69 6e 63 6c 75  64 65 20 22 77 69 6d 70  |".#include "wimp|
00000070  6c 69 62 2e 68 22 0a 23  69 6e 63 6c 75 64 65 20  |lib.h".#include |
00000080  22 67 61 64 67 65 74 73  2e 68 22 0a 23 69 6e 63  |"gadgets.h".#inc|
00000090  6c 75 64 65 20 22 77 69  6e 64 6f 77 2e 68 22 0a  |lude "window.h".|
000000a0  23 69 6e 63 6c 75 64 65  20 22 73 70 72 69 74 65  |#include "sprite|
000000b0  2e 68 22 0a 23 69 6e 63  6c 75 64 65 20 22 50 72  |.h".#include "Pr|
000000c0  6f 67 49 6e 66 6f 2e 68  22 0a 23 69 6e 63 6c 75  |ogInfo.h".#inclu|
000000d0  64 65 20 22 6d 65 6e 75  2e 68 22 0a 23 69 6e 63  |de "menu.h".#inc|
000000e0  6c 75 64 65 20 22 73 77  69 73 2e 68 22 0a 0a 23  |lude "swis.h"..#|
000000f0  69 6e 63 6c 75 64 65 20  3c 73 74 72 69 6e 67 2e  |include <string.|
00000100  68 3e 0a 23 69 6e 63 6c  75 64 65 20 3c 73 74 64  |h>.#include <std|
00000110  61 72 67 2e 68 3e 0a 0a  23 69 6e 63 6c 75 64 65  |arg.h>..#include|
00000120  20 22 70 63 61 2e 68 22  0a 23 69 6e 63 6c 75 64  | "pca.h".#includ|
00000130  65 20 22 66 6c 65 78 2e  68 22 0a 0a 0a 0a 0a 23  |e "flex.h".....#|
00000140  64 65 66 69 6e 65 20 57  69 6d 70 56 65 72 73 69  |define WimpVersi|
00000150  6f 6e 20 20 20 20 33 31  30 0a 0a 73 74 61 74 69  |on    310..stati|
00000160  63 20 20 57 69 6d 70 50  6f 6c 6c 42 6c 6f 63 6b  |c  WimpPollBlock|
00000170  20 20 70 6f 6c 6c 5f 62  6c 6f 63 6b 3b 0a 73 74  |  poll_block;.st|
00000180  61 74 69 63 20 20 4d 65  73 73 61 67 65 73 46 44  |atic  MessagesFD|
00000190  20 20 20 20 20 6d 65 73  73 61 67 65 73 3b 0a 73  |     messages;.s|
000001a0  74 61 74 69 63 20 20 49  64 42 6c 6f 63 6b 20 20  |tatic  IdBlock  |
000001b0  20 20 20 20 20 20 69 64  5f 62 6c 6f 63 6b 3b 0a  |      id_block;.|
000001c0  73 74 61 74 69 63 20 20  4f 62 6a 65 63 74 49 64  |static  ObjectId|
000001d0  20 20 20 20 20 20 20 74  6f 6f 6c 6d 65 6e 75 3b  |       toolmenu;|
000001e0  0a 73 74 61 74 69 63 20  20 4f 62 6a 65 63 74 49  |.static  ObjectI|
000001f0  64 20 20 20 20 20 20 20  6d 61 69 6e 6d 65 6e 75  |d       mainmenu|
00000200  3b 0a 0a 0a 69 6e 74 20  4f 74 68 65 72 54 61 73  |;...int OtherTas|
00000210  6b 2c 54 68 69 73 54 61  73 6b 3b 0a 0a 69 6e 74  |k,ThisTask;..int|
00000220  20 68 61 6e 64 6c 65 72  73 5f 61 74 74 61 63 68  | handlers_attach|
00000230  65 64 3d 30 3b 0a 0a 20  20 20 20 73 70 72 69 74  |ed=0;..    sprit|
00000240  65 5f 61 72 65 61 20 2a  20 73 70 62 6c 6f 63 6b  |e_area * spblock|
00000250  3b 0a 20 20 20 20 73 70  72 69 74 65 5f 69 64 20  |;.    sprite_id |
00000260  20 20 20 20 69 64 3b 0a  20 20 20 20 63 68 61 72  |    id;.    char|
00000270  20 2a 20 73 6e 61 6d 65  20 3d 22 74 65 73 74 65  | * sname ="teste|
00000280  72 22 3b 0a 0a 20 20 20  20 42 4f 4f 4c 20 56 41  |r";..    BOOL VA|
00000290  4c 49 44 3d 46 41 4c 53  45 3b 0a 20 20 20 20 42  |LID=FALSE;.    B|
000002a0  4f 4f 4c 20 53 48 4f 52  54 43 55 54 3d 46 41 4c  |OOL SHORTCUT=FAL|
000002b0  53 45 3b 0a 20 20 20 20  63 68 61 72 20 44 69 73  |SE;.    char Dis|
000002c0  70 6c 61 79 5b 32 35 35  5d 3b 0a 20 20 20 20 69  |play[255];.    i|
000002d0  6e 74 20 63 6f 75 6e 74  3d 30 3b 0a 20 20 20 20  |nt count=0;.    |
000002e0  63 68 61 72 20 2a 6e 61  6d 65 73 5b 36 34 5d 3b  |char *names[64];|
000002f0  0a 20 20 20 20 69 6e 74  20 20 20 74 61 73 6b 5b  |.    int   task[|
00000300  36 34 5d 5b 32 5d 3b 0a  20 20 20 20 69 6e 74 20  |64][2];.    int |
00000310  2a 66 61 6b 65 3b 0a 20  20 20 20 42 4f 4f 4c 20  |*fake;.    BOOL |
00000320  41 43 43 45 50 54 5f 49  4e 50 4c 41 43 45 3d 54  |ACCEPT_INPLACE=T|
00000330  52 55 45 3b 0a 20 20 20  20 42 4f 4f 4c 20 48 4f  |RUE;.    BOOL HO|
00000340  4f 4b 45 44 3d 46 41 4c  53 45 3b 0a 20 20 20 20  |OKED=FALSE;.    |
00000350  69 6e 74 20 68 6f 6f 6b  65 64 5f 77 3b 0a 20 20  |int hooked_w;.  |
00000360  20 20 69 6e 74 20 68 6f  6f 6b 65 64 5f 74 3b 0a  |  int hooked_t;.|
00000370  20 20 20 20 69 6e 74 20  68 6f 6f 6b 65 64 5f 72  |    int hooked_r|
00000380  3b 0a 20 20 20 20 76 6f  69 64 20 2a 20 69 6e 76  |;.    void * inv|
00000390  69 73 69 62 6c 65 3b 0a  20 20 20 20 74 61 67 20  |isible;.    tag |
000003a0  2a 61 6e 63 68 3b 0a 0a  69 6e 74 20 71 75 69 74  |*anch;..int quit|
000003b0  5f 65 76 65 6e 74 28 69  6e 74 20 65 76 65 6e 74  |_event(int event|
000003c0  5f 63 6f 64 65 2c 20 54  6f 6f 6c 62 6f 78 45 76  |_code, ToolboxEv|
000003d0  65 6e 74 20 2a 65 76 65  6e 74 2c 20 49 64 42 6c  |ent *event, IdBl|
000003e0  6f 63 6b 20 2a 69 64 5f  62 6c 6f 63 6b 2c 76 6f  |ock *id_block,vo|
000003f0  69 64 20 2a 68 61 6e 64  6c 65 29 3b 0a 69 6e 74  |id *handle);.int|
00000400  20 71 75 69 74 5f 6d 65  73 73 61 67 65 28 57 69  | quit_message(Wi|
00000410  6d 70 4d 65 73 73 61 67  65 20 2a 6d 65 73 73 61  |mpMessage *messa|
00000420  67 65 2c 76 6f 69 64 20  2a 68 61 6e 64 6c 65 29  |ge,void *handle)|
00000430  3b 0a 69 6e 74 20 61 74  74 61 63 68 5f 68 61 6e  |;.int attach_han|
00000440  64 6c 65 72 73 28 69 6e  74 20 65 76 65 6e 74 5f  |dlers(int event_|
00000450  63 6f 64 65 2c 54 6f 6f  6c 62 6f 78 45 76 65 6e  |code,ToolboxEven|
00000460  74 20 2a 65 76 65 6e 74  2c 49 64 42 6c 6f 63 6b  |t *event,IdBlock|
00000470  20 2a 69 64 5f 62 6c 6f  63 6b 2c 20 76 6f 69 64  | *id_block, void|
00000480  20 2a 68 61 6e 64 6c 65  29 3b 0a 76 6f 69 64 20  | *handle);.void |
00000490  77 65 72 72 28 69 6e 74  20 66 61 74 61 6c 2c 20  |werr(int fatal, |
000004a0  63 68 61 72 2a 20 66 6f  72 6d 61 74 2c 20 2e 2e  |char* format, ..|
000004b0  2e 29 3b 0a 69 6e 74 20  72 65 64 72 61 77 5f 77  |.);.int redraw_w|
000004c0  69 6e 64 6f 77 28 69 6e  74 20 65 76 65 6e 74 5f  |indow(int event_|
000004d0  63 6f 64 65 2c 20 57 69  6d 70 50 6f 6c 6c 42 6c  |code, WimpPollBl|
000004e0  6f 63 6b 20 2a 65 76 65  6e 74 2c 49 64 42 6c 6f  |ock *event,IdBlo|
000004f0  63 6b 20 2a 69 64 5f 62  6c 6f 63 6b 2c 76 6f 69  |ck *id_block,voi|
00000500  64 20 2a 76 29 3b 0a 76  6f 69 64 20 69 6e 76 61  |d *v);.void inva|
00000510  6c 69 64 61 74 65 5f 61  64 64 72 65 73 73 65 73  |lidate_addresses|
00000520  28 76 6f 69 64 29 3b 0a  69 6e 74 20 57 68 6f 73  |(void);.int Whos|
00000530  41 62 6f 75 74 5f 6d 65  73 73 61 67 65 28 57 69  |About_message(Wi|
00000540  6d 70 4d 65 73 73 61 67  65 20 2a 6d 65 73 73 61  |mpMessage *messa|
00000550  67 65 2c 76 6f 69 64 20  2a 68 61 6e 64 6c 65 29  |ge,void *handle)|
00000560  3b 0a 76 6f 69 64 20 62  6c 6f 63 6b 6d 6f 76 65  |;.void blockmove|
00000570  64 28 42 4f 4f 4c 20 62  34 2c 76 6f 69 64 20 2a  |d(BOOL b4,void *|
00000580  68 61 6e 64 6c 65 29 3b  0a 69 6e 74 20 64 6f 5f  |handle);.int do_|
00000590  74 68 65 5f 66 72 65 65  28 69 6e 74 20 65 76 65  |the_free(int eve|
000005a0  6e 74 5f 63 6f 64 65 2c  20 54 6f 6f 6c 62 6f 78  |nt_code, Toolbox|
000005b0  45 76 65 6e 74 20 2a 65  76 65 6e 74 2c 20 49 64  |Event *event, Id|
000005c0  42 6c 6f 63 6b 20 2a 69  64 5f 62 6c 6f 63 6b 2c  |Block *id_block,|
000005d0  76 6f 69 64 20 2a 68 61  6e 64 6c 65 29 3b 0a 69  |void *handle);.i|
000005e0  6e 74 20 73 65 74 5f 73  74 61 74 75 73 28 69 6e  |nt set_status(in|
000005f0  74 20 65 76 65 6e 74 5f  63 6f 64 65 2c 20 54 6f  |t event_code, To|
00000600  6f 6c 62 6f 78 45 76 65  6e 74 20 2a 65 76 65 6e  |olboxEvent *even|
00000610  74 2c 20 49 64 42 6c 6f  63 6b 20 2a 69 64 5f 62  |t, IdBlock *id_b|
00000620  6c 6f 63 6b 2c 76 6f 69  64 20 2a 68 61 6e 64 6c  |lock,void *handl|
00000630  65 29 3b 0a 69 6e 74 20  73 65 74 75 70 5f 6d 65  |e);.int setup_me|
00000640  6e 75 28 69 6e 74 20 65  76 65 6e 74 5f 63 6f 64  |nu(int event_cod|
00000650  65 2c 20 54 6f 6f 6c 62  6f 78 45 76 65 6e 74 20  |e, ToolboxEvent |
00000660  2a 65 76 65 6e 74 2c 20  49 64 42 6c 6f 63 6b 20  |*event, IdBlock |
00000670  2a 69 64 5f 62 6c 6f 63  6b 2c 76 6f 69 64 20 2a  |*id_block,void *|
00000680  68 61 6e 64 6c 65 29 3b  0a 69 6e 74 20 63 68 61  |handle);.int cha|
00000690  6e 67 65 64 28 57 69 6d  70 4d 65 73 73 61 67 65  |nged(WimpMessage|
000006a0  20 2a 6d 65 73 73 61 67  65 2c 76 6f 69 64 20 2a  | *message,void *|
000006b0  68 61 6e 64 6c 65 29 3b  0a 69 6e 74 20 68 65 72  |handle);.int her|
000006c0  65 49 61 6d 28 69 6e 74  20 65 76 65 6e 74 5f 63  |eIam(int event_c|
000006d0  6f 64 65 2c 20 54 6f 6f  6c 62 6f 78 45 76 65 6e  |ode, ToolboxEven|
000006e0  74 20 2a 65 76 65 6e 74  2c 20 49 64 42 6c 6f 63  |t *event, IdBloc|
000006f0  6b 20 2a 69 64 5f 62 6c  6f 63 6b 2c 76 6f 69 64  |k *id_block,void|
00000700  20 2a 68 61 6e 64 6c 65  29 3b 0a 69 6e 74 20 75  | *handle);.int u|
00000710  70 64 61 74 65 5f 77 69  6e 64 6f 77 28 69 6e 74  |pdate_window(int|
00000720  20 77 5f 68 61 6e 64 6c  65 2c 42 42 6f 78 20 2a  | w_handle,BBox *|
00000730  62 6f 78 29 3b 0a 76 6f  69 64 20 6f 73 5f 62 79  |box);.void os_by|
00000740  74 65 28 69 6e 74 20 63  6f 64 65 2c 69 6e 74 20  |te(int code,int |
00000750  2a 20 78 2c 69 6e 74 20  2a 79 29 3b 0a 69 6e 74  |* x,int *y);.int|
00000760  20 61 6b 62 64 5f 70 6f  6c 6c 73 68 28 76 6f 69  | akbd_pollsh(voi|
00000770  64 29 3b 0a 69 6e 74 20  61 6b 62 64 5f 70 6f 6c  |d);.int akbd_pol|
00000780  6c 63 74 6c 28 76 6f 69  64 29 3b 0a 69 6e 74 20  |lctl(void);.int |
00000790  62 75 74 74 6f 6e 28 69  6e 74 20 65 76 65 6e 74  |button(int event|
000007a0  5f 63 6f 64 65 2c 20 57  69 6d 70 50 6f 6c 6c 42  |_code, WimpPollB|
000007b0  6c 6f 63 6b 20 2a 65 76  65 6e 74 2c 49 64 42 6c  |lock *event,IdBl|
000007c0  6f 63 6b 20 2a 69 64 5f  62 6c 6f 63 6b 2c 76 6f  |ock *id_block,vo|
000007d0  69 64 20 2a 76 29 3b 0a  76 6f 69 64 20 73 63 72  |id *v);.void scr|
000007e0  65 65 6e 5f 74 6f 5f 73  70 72 69 74 65 28 57 69  |een_to_sprite(Wi|
000007f0  6d 70 4d 6f 75 73 65 43  6c 69 63 6b 45 76 65 6e  |mpMouseClickEven|
00000800  74 20 2a 20 63 29 3b 0a  69 6e 74 20 6f 70 65 6e  |t * c);.int open|
00000810  28 69 6e 74 20 65 76 65  6e 74 5f 63 6f 64 65 2c  |(int event_code,|
00000820  20 57 69 6d 70 50 6f 6c  6c 42 6c 6f 63 6b 20 2a  | WimpPollBlock *|
00000830  65 76 65 6e 74 2c 49 64  42 6c 6f 63 6b 20 2a 69  |event,IdBlock *i|
00000840  64 5f 62 6c 6f 63 6b 2c  76 6f 69 64 20 2a 76 29  |d_block,void *v)|
00000850  3b 0a 76 6f 69 64 20 73  74 6f 72 65 5f 67 61 64  |;.void store_gad|
00000860  67 65 74 28 63 68 61 72  2a 20 54 65 6d 70 6c 61  |get(char* Templa|
00000870  74 65 2c 4f 62 6a 65 63  74 49 64 20 4f 69 64 2c  |te,ObjectId Oid,|
00000880  43 6f 6d 70 6f 6e 65 6e  74 49 64 20 67 29 3b 0a  |ComponentId g);.|
00000890  76 6f 69 64 20 63 72 65  61 74 65 5f 67 61 64 67  |void create_gadg|
000008a0  65 74 28 4f 62 6a 65 63  74 49 64 20 4f 69 64 2c  |et(ObjectId Oid,|
000008b0  43 6f 6d 70 6f 6e 65 6e  74 49 64 20 67 29 3b 0a  |ComponentId g);.|
000008c0  76 6f 69 64 20 6b 69 6c  6c 5f 67 61 64 67 65 74  |void kill_gadget|
000008d0  28 4f 62 6a 65 63 74 49  64 20 4f 69 64 2c 43 6f  |(ObjectId Oid,Co|
000008e0  6d 70 6f 6e 65 6e 74 49  64 20 67 29 3b 0a 0a 0a  |mponentId g);...|
000008f0  0a 0a 0a 2f 2a 0a 20 2a  20 45 76 65 6e 74 20 68  |.../*. * Event h|
00000900  61 6e 64 6c 65 72 20 74  6f 20 62 65 20 63 61 6c  |andler to be cal|
00000910  6c 65 64 20 77 68 65 6e  20 74 6f 6f 6c 62 6f 78  |led when toolbox|
00000920  20 65 76 65 6e 74 20 31  0a 20 2a 20 69 73 20 67  | event 1. * is g|
00000930  65 6e 65 72 61 74 65 64  20 28 62 79 20 63 6c 69  |enerated (by cli|
00000940  63 6b 20 6f 6e 20 74 68  65 20 27 51 75 69 74 27  |ck on the 'Quit'|
00000950  20 65 6e 74 72 79 20 6f  66 0a 20 2a 20 74 68 65  | entry of. * the|
00000960  20 69 63 6f 6e 62 61 72  20 6d 65 6e 75 2e 29 0a  | iconbar menu.).|
00000970  20 2a 2f 0a 0a 69 6e 74  20 71 75 69 74 5f 65 76  | */..int quit_ev|
00000980  65 6e 74 28 69 6e 74 20  65 76 65 6e 74 5f 63 6f  |ent(int event_co|
00000990  64 65 2c 20 54 6f 6f 6c  62 6f 78 45 76 65 6e 74  |de, ToolboxEvent|
000009a0  20 2a 65 76 65 6e 74 2c  20 49 64 42 6c 6f 63 6b  | *event, IdBlock|
000009b0  20 2a 69 64 5f 62 6c 6f  63 6b 2c 76 6f 69 64 20  | *id_block,void |
000009c0  2a 68 61 6e 64 6c 65 29  0a 7b 0a 20 20 5f 6b 65  |*handle).{.  _ke|
000009d0  72 6e 65 6c 5f 73 77 69  5f 72 65 67 73 20 72 3b  |rnel_swi_regs r;|
000009e0  0a 20 20 65 76 65 6e 74  5f 63 6f 64 65 20 3d 20  |.  event_code = |
000009f0  65 76 65 6e 74 5f 63 6f  64 65 3b 0a 20 20 65 76  |event_code;.  ev|
00000a00  65 6e 74 20 3d 20 65 76  65 6e 74 3b 0a 20 20 69  |ent = event;.  i|
00000a10  64 5f 62 6c 6f 63 6b 20  3d 20 69 64 5f 62 6c 6f  |d_block = id_blo|
00000a20  63 6b 3b 0a 20 20 68 61  6e 64 6c 65 20 3d 20 68  |ck;.  handle = h|
00000a30  61 6e 64 6c 65 3b 0a 20  20 69 6e 76 61 6c 69 64  |andle;.  invalid|
00000a40  61 74 65 5f 61 64 64 72  65 73 73 65 73 28 29 3b  |ate_addresses();|
00000a50  0a 20 20 72 2e 72 5b 30  5d 3d 28 69 6e 74 29 61  |.  r.r[0]=(int)a|
00000a60  6e 63 68 3b 0a 5f 6b 65  72 6e 65 6c 5f 73 77 69  |nch;._kernel_swi|
00000a70  28 50 43 41 5f 44 65 6c  65 74 65 54 61 67 2c 26  |(PCA_DeleteTag,&|
00000a80  72 2c 26 72 29 3b 0a 20  20 65 78 69 74 28 30 29  |r,&r);.  exit(0)|
00000a90  3b 0a 20 20 72 65 74 75  72 6e 28 31 29 3b 0a 7d  |;.  return(1);.}|
00000aa0  0a 0a 0a 0a 0a 0a 0a 2f  2a 0a 20 2a 20 4d 65 73  |......./*. * Mes|
00000ab0  73 61 67 65 20 68 61 6e  64 6c 65 72 20 74 6f 20  |sage handler to |
00000ac0  62 65 20 63 61 6c 6c 65  64 20 6f 6e 20 72 65 63  |be called on rec|
00000ad0  65 69 70 74 20 6f 66 20  61 0a 20 2a 20 51 75 69  |eipt of a. * Qui|
00000ae0  74 20 6f 72 20 50 72 65  51 75 69 74 20 6d 65 73  |t or PreQuit mes|
00000af0  73 61 67 65 20 66 72 6f  6d 20 74 68 65 20 57 69  |sage from the Wi|
00000b00  6d 70 2e 0a 20 2a 2f 0a  0a 69 6e 74 20 71 75 69  |mp.. */..int qui|
00000b10  74 5f 6d 65 73 73 61 67  65 28 57 69 6d 70 4d 65  |t_message(WimpMe|
00000b20  73 73 61 67 65 20 2a 6d  65 73 73 61 67 65 2c 76  |ssage *message,v|
00000b30  6f 69 64 20 2a 68 61 6e  64 6c 65 29 0a 7b 0a 20  |oid *handle).{. |
00000b40  20 5f 6b 65 72 6e 65 6c  5f 73 77 69 5f 72 65 67  | _kernel_swi_reg|
00000b50  73 20 72 3b 0a 20 20 6d  65 73 73 61 67 65 20 3d  |s r;.  message =|
00000b60  20 6d 65 73 73 61 67 65  3b 0a 20 20 68 61 6e 64  | message;.  hand|
00000b70  6c 65 20 3d 20 68 61 6e  64 6c 65 3b 0a 20 20 69  |le = handle;.  i|
00000b80  6e 76 61 6c 69 64 61 74  65 5f 61 64 64 72 65 73  |nvalidate_addres|
00000b90  73 65 73 28 29 3b 0a 72  2e 72 5b 30 5d 3d 28 69  |ses();.r.r[0]=(i|
00000ba0  6e 74 29 61 6e 63 68 3b  0a 5f 6b 65 72 6e 65 6c  |nt)anch;._kernel|
00000bb0  5f 73 77 69 28 50 43 41  5f 44 65 6c 65 74 65 54  |_swi(PCA_DeleteT|
00000bc0  61 67 2c 26 72 2c 26 72  29 3b 0a 0a 0a 0a 0a 20  |ag,&r,&r);..... |
00000bd0  20 65 78 69 74 28 30 29  3b 0a 20 20 72 65 74 75  | exit(0);.  retu|
00000be0  72 6e 28 31 29 3b 0a 7d  0a 0a 0a 0a 2f 2a 20 43  |rn(1);.}..../* C|
00000bf0  61 6c 6c 65 64 20 6f 6e  20 72 65 63 65 69 70 74  |alled on receipt|
00000c00  20 6f 66 20 61 20 57 68  6f 73 41 62 6f 75 74 20  | of a WhosAbout |
00000c10  6d 65 73 73 61 67 65 2e  20 41 64 64 20 74 68 65  |message. Add the|
00000c20  20 6e 65 77 20 74 61 73  6b 20 74 6f 20 74 68 65  | new task to the|
00000c30  0a 20 20 20 75 74 69 6c  69 74 69 65 73 20 6d 65  |.   utilities me|
00000c40  6e 75 0a 2a 2f 0a 0a 69  6e 74 20 57 68 6f 73 41  |nu.*/..int WhosA|
00000c50  62 6f 75 74 5f 6d 65 73  73 61 67 65 28 57 69 6d  |bout_message(Wim|
00000c60  70 4d 65 73 73 61 67 65  20 2a 6d 65 73 73 61 67  |pMessage *messag|
00000c70  65 2c 76 6f 69 64 20 2a  68 61 6e 64 6c 65 29 0a  |e,void *handle).|
00000c80  0a 7b 0a 69 6d 68 65 72  65 5f 62 6c 6f 63 6b 20  |.{.imhere_block |
00000c90  2a 65 3b 0a 4d 65 6e 75  54 65 6d 70 6c 61 74 65  |*e;.MenuTemplate|
00000ca0  45 6e 74 72 79 20 45 6e  74 72 79 20 3d 20 7b 30  |Entry Entry = {0|
00000cb0  7d 3b 0a 69 6e 74 20 74  65 6d 70 3b 0a 63 68 61  |};.int temp;.cha|
00000cc0  72 2a 20 71 3b 0a 68 61  6e 64 6c 65 3d 68 61 6e  |r* q;.handle=han|
00000cd0  64 6c 65 3b 0a 0a 65 3d  28 69 6d 68 65 72 65 5f  |dle;..e=(imhere_|
00000ce0  62 6c 6f 63 6b 20 2a 29  6d 65 73 73 61 67 65 2d  |block *)message-|
00000cf0  3e 64 61 74 61 2e 77 6f  72 64 73 3b 0a 0a 74 65  |>data.words;..te|
00000d00  6d 70 3d 73 74 72 6c 65  6e 28 65 2d 3e 6d 65 6e  |mp=strlen(e->men|
00000d10  75 29 3b 0a 71 3d 28 63  68 61 72 2a 29 6d 61 6c  |u);.q=(char*)mal|
00000d20  6c 6f 63 28 74 65 6d 70  2b 31 29 3b 0a 69 66 20  |loc(temp+1);.if |
00000d30  28 71 3d 3d 30 29 20 72  65 74 75 72 6e 28 30 29  |(q==0) return(0)|
00000d40  3b 0a 6e 61 6d 65 73 5b  63 6f 75 6e 74 5d 3d 71  |;.names[count]=q|
00000d50  3b 0a 73 74 72 63 70 79  28 6e 61 6d 65 73 5b 63  |;.strcpy(names[c|
00000d60  6f 75 6e 74 5d 2c 65 2d  3e 6d 65 6e 75 29 3b 0a  |ount],e->menu);.|
00000d70  74 61 73 6b 5b 63 6f 75  6e 74 5d 5b 30 5d 3d 6d  |task[count][0]=m|
00000d80  65 73 73 61 67 65 2d 3e  68 64 72 2e 73 65 6e 64  |essage->hdr.send|
00000d90  65 72 3b 0a 74 61 73 6b  5b 63 6f 75 6e 74 5d 5b  |er;.task[count][|
00000da0  31 5d 3d 65 2d 3e 66 6c  61 67 73 3b 0a 45 6e 74  |1]=e->flags;.Ent|
00000db0  72 79 2e 63 6c 69 63 6b  5f 65 76 65 6e 74 20 3d  |ry.click_event =|
00000dc0  20 30 78 33 30 30 3b 0a  45 6e 74 72 79 2e 74 65  | 0x300;.Entry.te|
00000dd0  78 74 20 3d 20 6e 61 6d  65 73 5b 63 6f 75 6e 74  |xt = names[count|
00000de0  5d 3b 0a 45 6e 74 72 79  2e 6d 61 78 5f 74 65 78  |];.Entry.max_tex|
00000df0  74 20 3d 20 73 74 72 6c  65 6e 20 28 45 6e 74 72  |t = strlen (Entr|
00000e00  79 2e 74 65 78 74 29 20  2b 31 3b 0a 45 6e 74 72  |y.text) +1;.Entr|
00000e10  79 2e 63 6f 6d 70 6f 6e  65 6e 74 5f 69 64 20 3d  |y.component_id =|
00000e20  20 28 43 6f 6d 70 6f 6e  65 6e 74 49 64 29 20 63  | (ComponentId) c|
00000e30  6f 75 6e 74 2b 2b 3b 0a  6d 65 6e 75 5f 61 64 64  |ount++;.menu_add|
00000e40  5f 65 6e 74 72 79 28 30  2c 28 4f 62 6a 65 63 74  |_entry(0,(Object|
00000e50  49 64 29 68 61 6e 64 6c  65 20 2c 4d 65 6e 75 5f  |Id)handle ,Menu_|
00000e60  41 64 64 45 6e 74 72 79  41 74 45 6e 64 2c 28 63  |AddEntryAtEnd,(c|
00000e70  68 61 72 20 2a 29 20 26  45 6e 74 72 79 2c 30 29  |har *) &Entry,0)|
00000e80  3b 0a 6d 65 6e 75 5f 73  65 74 5f 66 61 64 65 28  |;.menu_set_fade(|
00000e90  30 2c 6d 61 69 6e 6d 65  6e 75 2c 30 2c 30 29 3b  |0,mainmenu,0,0);|
00000ea0  0a 0a 72 65 74 75 72 6e  28 46 41 4c 53 45 29 3b  |..return(FALSE);|
00000eb0  0a 7d 0a 0a 0a 0a 2f 2a  20 43 61 6c 6c 65 64 20  |.}..../* Called |
00000ec0  6f 6e 20 72 65 63 65 69  70 74 20 6f 66 20 61 6e  |on receipt of an|
00000ed0  20 6f 70 65 6e 20 77 69  6e 64 6f 77 20 72 65 71  | open window req|
00000ee0  75 65 73 74 2e 20 49 66  20 61 63 74 69 6e 67 20  |uest. If acting |
00000ef0  61 73 20 61 20 6c 6f 63  61 6c 20 74 6f 0a 20 20  |as a local to.  |
00000f00  20 61 6e 20 69 6e 20 70  6c 61 63 65 20 65 64 69  | an in place edi|
00000f10  74 6f 72 2c 20 6b 65 65  70 20 69 74 20 69 6e 66  |tor, keep it inf|
00000f20  6f 72 6d 65 64 20 6f 66  20 77 69 6e 64 6f 77 73  |ormed of windows|
00000f30  20 70 6f 73 69 74 69 6f  6e 0a 2a 2f 0a 0a 69 6e  | position.*/..in|
00000f40  74 20 6f 70 65 6e 28 69  6e 74 20 65 76 65 6e 74  |t open(int event|
00000f50  5f 63 6f 64 65 2c 20 57  69 6d 70 50 6f 6c 6c 42  |_code, WimpPollB|
00000f60  6c 6f 63 6b 20 2a 65 76  65 6e 74 2c 49 64 42 6c  |lock *event,IdBl|
00000f70  6f 63 6b 20 2a 69 64 5f  62 6c 6f 63 6b 2c 76 6f  |ock *id_block,vo|
00000f80  69 64 20 2a 76 29 0a 7b  0a 6f 62 6a 65 63 74 70  |id *v).{.objectp|
00000f90  6f 73 5f 62 6c 6f 63 6b  20 2a 65 3b 0a 0a 57 69  |os_block *e;..Wi|
00000fa0  6d 70 4d 65 73 73 61 67  65 20 6d 65 73 73 61 67  |mpMessage messag|
00000fb0  65 3b 0a 0a 69 66 28 48  4f 4f 4b 45 44 29 0a 7b  |e;..if(HOOKED).{|
00000fc0  0a 20 20 20 65 3d 28 6f  62 6a 65 63 74 70 6f 73  |.   e=(objectpos|
00000fd0  5f 62 6c 6f 63 6b 20 2a  29 6d 65 73 73 61 67 65  |_block *)message|
00000fe0  2e 64 61 74 61 2e 77 6f  72 64 73 3b 0a 20 20 20  |.data.words;.   |
00000ff0  6d 65 73 73 61 67 65 2e  68 64 72 2e 79 6f 75 72  |message.hdr.your|
00001000  5f 72 65 66 3d 68 6f 6f  6b 65 64 5f 72 3b 0a 20  |_ref=hooked_r;. |
00001010  20 20 6d 65 73 73 61 67  65 2e 68 64 72 2e 73 69  |  message.hdr.si|
00001020  7a 65 3d 36 34 3b 0a 20  20 20 6d 65 73 73 61 67  |ze=64;.   messag|
00001030  65 2e 68 64 72 2e 61 63  74 69 6f 6e 5f 63 6f 64  |e.hdr.action_cod|
00001040  65 3d 4d 65 73 73 61 67  65 5f 4f 62 6a 65 63 74  |e=Message_Object|
00001050  50 6f 73 69 74 69 6f 6e  3b 0a 20 20 20 6d 65 73  |Position;.   mes|
00001060  73 61 67 65 2e 68 64 72  2e 73 65 6e 64 65 72 3d  |sage.hdr.sender=|
00001070  54 68 69 73 54 61 73 6b  3b 0a 20 20 20 65 2d 3e  |ThisTask;.   e->|
00001080  74 61 67 70 74 72 3d 61  6e 63 68 3b 0a 0a 20 20  |tagptr=anch;..  |
00001090  20 65 2d 3e 68 61 6e 64  6c 65 3d 68 6f 6f 6b 65  | e->handle=hooke|
000010a0  64 5f 77 3b 0a 20 20 20  65 2d 3e 74 6f 6f 6c 62  |d_w;.   e->toolb|
000010b0  61 72 68 61 6e 64 6c 65  3d 2d 31 3b 0a 20 20 20  |arhandle=-1;.   |
000010c0  65 2d 3e 7a 65 72 6f 3d  30 3b 0a 20 20 20 65 2d  |e->zero=0;.   e-|
000010d0  3e 78 6c 6f 77 3d 65 76  65 6e 74 2d 3e 6f 70 65  |>xlow=event->ope|
000010e0  6e 5f 77 69 6e 64 6f 77  5f 72 65 71 75 65 73 74  |n_window_request|
000010f0  2e 76 69 73 69 62 6c 65  5f 61 72 65 61 2e 78 6d  |.visible_area.xm|
00001100  69 6e 3b 0a 20 20 20 65  2d 3e 79 6c 6f 77 3d 65  |in;.   e->ylow=e|
00001110  76 65 6e 74 2d 3e 6f 70  65 6e 5f 77 69 6e 64 6f  |vent->open_windo|
00001120  77 5f 72 65 71 75 65 73  74 2e 76 69 73 69 62 6c  |w_request.visibl|
00001130  65 5f 61 72 65 61 2e 79  6d 69 6e 3b 0a 20 20 20  |e_area.ymin;.   |
00001140  65 2d 3e 78 73 63 61 6c  65 3d 31 3c 3c 31 36 3b  |e->xscale=1<<16;|
00001150  0a 20 20 20 65 2d 3e 79  73 63 61 6c 65 3d 31 3c  |.   e->yscale=1<|
00001160  3c 31 36 3b 0a 20 20 20  65 2d 3e 78 6c 6f 77 75  |<16;.   e->xlowu|
00001170  3d 65 76 65 6e 74 2d 3e  6f 70 65 6e 5f 77 69 6e  |=event->open_win|
00001180  64 6f 77 5f 72 65 71 75  65 73 74 2e 76 69 73 69  |dow_request.visi|
00001190  62 6c 65 5f 61 72 65 61  2e 78 6d 69 6e 3b 0a 20  |ble_area.xmin;. |
000011a0  20 20 65 2d 3e 79 6c 6f  77 75 3d 65 76 65 6e 74  |  e->ylowu=event|
000011b0  2d 3e 6f 70 65 6e 5f 77  69 6e 64 6f 77 5f 72 65  |->open_window_re|
000011c0  71 75 65 73 74 2e 76 69  73 69 62 6c 65 5f 61 72  |quest.visible_ar|
000011d0  65 61 2e 79 6d 69 6e 3b  0a 20 20 20 77 69 6d 70  |ea.ymin;.   wimp|
000011e0  5f 73 65 6e 64 5f 6d 65  73 73 61 67 65 28 31 37  |_send_message(17|
000011f0  2c 26 6d 65 73 73 61 67  65 2c 74 61 73 6b 5b 68  |,&message,task[h|
00001200  6f 6f 6b 65 64 5f 74 5d  5b 30 5d 2c 30 2c 4e 55  |ooked_t][0],0,NU|
00001210  4c 4c 29 3b 0a 0a 20 7d  0a 77 69 6d 70 5f 6f 70  |LL);.. }.wimp_op|
00001220  65 6e 5f 77 69 6e 64 6f  77 28 28 57 69 6d 70 4f  |en_window((WimpO|
00001230  70 65 6e 57 69 6e 64 6f  77 42 6c 6f 63 6b 2a 29  |penWindowBlock*)|
00001240  65 76 65 6e 74 29 3b 0a  0a 72 65 74 75 72 6e 28  |event);..return(|
00001250  54 52 55 45 29 3b 0a 7d  0a 0a 0a 69 6e 74 20 63  |TRUE);.}...int c|
00001260  6c 6f 73 65 28 69 6e 74  20 65 76 65 6e 74 5f 63  |lose(int event_c|
00001270  6f 64 65 2c 20 57 69 6d  70 50 6f 6c 6c 42 6c 6f  |ode, WimpPollBlo|
00001280  63 6b 20 2a 65 76 65 6e  74 2c 49 64 42 6c 6f 63  |ck *event,IdBloc|
00001290  6b 20 2a 69 64 5f 62 6c  6f 63 6b 2c 76 6f 69 64  |k *id_block,void|
000012a0  20 2a 76 29 0a 7b 0a 69  6e 76 61 6c 69 64 61 74  | *v).{.invalidat|
000012b0  65 5f 61 64 64 72 65 73  73 65 73 28 29 3b 0a 48  |e_addresses();.H|
000012c0  4f 4f 4b 45 44 3d 46 41  4c 53 45 3b 0a 56 41 4c  |OOKED=FALSE;.VAL|
000012d0  49 44 3d 46 41 4c 53 45  3b 0a 77 69 6d 70 5f 63  |ID=FALSE;.wimp_c|
000012e0  6c 6f 73 65 5f 77 69 6e  64 6f 77 28 28 69 6e 74  |lose_window((int|
000012f0  2a 29 65 76 65 6e 74 29  3b 0a 72 65 74 75 72 6e  |*)event);.return|
00001300  20 46 41 4c 53 45 3b 0a  7d 0a 0a 76 6f 69 64 20  | FALSE;.}..void |
00001310  73 74 6f 72 65 5f 67 61  64 67 65 74 28 63 68 61  |store_gadget(cha|
00001320  72 2a 20 54 65 6d 70 6c  61 74 65 2c 4f 62 6a 65  |r* Template,Obje|
00001330  63 74 49 64 20 4f 69 64  2c 43 6f 6d 70 6f 6e 65  |ctId Oid,Compone|
00001340  6e 74 49 64 20 67 29 0a  7b 0a 76 6f 69 64 20 2a  |ntId g).{.void *|
00001350  76 2c 2a 74 3b 0a 69 6e  74 20 73 3b 0a 76 3d 6d  |v,*t;.int s;.v=m|
00001360  61 6c 6c 6f 63 28 73 69  7a 65 6f 66 28 4f 62 6a  |alloc(sizeof(Obj|
00001370  65 63 74 54 65 6d 70 6c  61 74 65 48 65 61 64 65  |ectTemplateHeade|
00001380  72 29 29 3b 0a 74 3d 6d  61 6c 6c 6f 63 28 73 69  |r));.t=malloc(si|
00001390  7a 65 6f 66 28 42 75 74  74 6f 6e 29 20 2b 73 69  |zeof(Button) +si|
000013a0  7a 65 6f 66 28 47 61 64  67 65 74 48 65 61 64 65  |zeof(GadgetHeade|
000013b0  72 29 29 3b 0a 69 66 20  28 28 21 74 29 7c 7c 28  |r));.if ((!t)||(|
000013c0  21 76 29 29 20 77 65 72  72 28 54 52 55 45 2c 22  |!v)) werr(TRUE,"|
000013d0  46 61 74 61 6c 20 65 72  72 6f 72 3a 20 49 6e 73  |Fatal error: Ins|
000013e0  75 66 66 69 63 69 65 6e  74 20 6d 65 6d 6f 72 79  |ufficient memory|
000013f0  22 29 3b 0a 74 6f 6f 6c  62 6f 78 5f 74 65 6d 70  |");.toolbox_temp|
00001400  6c 61 74 65 5f 6c 6f 6f  6b 75 70 28 30 2c 54 65  |late_lookup(0,Te|
00001410  6d 70 6c 61 74 65 2c 26  76 29 3b 0a 77 69 6e 64  |mplate,&v);.wind|
00001420  6f 77 5f 65 78 74 72 61  63 74 5f 67 61 64 67 65  |ow_extract_gadge|
00001430  74 5f 69 6e 66 6f 28 30  2c 76 2c 67 2c 26 74 2c  |t_info(0,v,g,&t,|
00001440  26 73 29 3b 0a 69 6e 76  69 73 69 62 6c 65 3d 6d  |&s);.invisible=m|
00001450  61 6c 6c 6f 63 28 73 29  3b 0a 69 66 20 28 21 69  |alloc(s);.if (!i|
00001460  6e 76 69 73 69 62 6c 65  29 20 77 65 72 72 28 54  |nvisible) werr(T|
00001470  52 55 45 2c 22 46 61 74  61 6c 20 65 72 72 6f 72  |RUE,"Fatal error|
00001480  3a 20 49 6e 73 75 66 66  69 63 69 65 6e 74 20 6d  |: Insufficient m|
00001490  65 6d 6f 72 79 22 29 3b  0a 2a 28 47 61 64 67 65  |emory");.*(Gadge|
000014a0  74 2a 29 69 6e 76 69 73  69 62 6c 65 3d 2a 28 47  |t*)invisible=*(G|
000014b0  61 64 67 65 74 2a 29 74  3b 0a 77 69 6e 64 6f 77  |adget*)t;.window|
000014c0  5f 72 65 6d 6f 76 65 5f  67 61 64 67 65 74 28 30  |_remove_gadget(0|
000014d0  2c 4f 69 64 2c 67 29 3b  0a 0a 7d 0a 0a 76 6f 69  |,Oid,g);..}..voi|
000014e0  64 20 63 72 65 61 74 65  5f 67 61 64 67 65 74 28  |d create_gadget(|
000014f0  4f 62 6a 65 63 74 49 64  20 4f 69 64 2c 43 6f 6d  |ObjectId Oid,Com|
00001500  70 6f 6e 65 6e 74 49 64  20 67 29 0a 7b 0a 77 69  |ponentId g).{.wi|
00001510  6e 64 6f 77 5f 61 64 64  5f 67 61 64 67 65 74 28  |ndow_add_gadget(|
00001520  30 2c 4f 69 64 2c 69 6e  76 69 73 69 62 6c 65 2c  |0,Oid,invisible,|
00001530  26 67 29 3b 0a 7d 0a 0a  76 6f 69 64 20 6b 69 6c  |&g);.}..void kil|
00001540  6c 5f 67 61 64 67 65 74  28 4f 62 6a 65 63 74 49  |l_gadget(ObjectI|
00001550  64 20 4f 69 64 2c 43 6f  6d 70 6f 6e 65 6e 74 49  |d Oid,ComponentI|
00001560  64 20 67 29 0a 7b 0a 77  69 6e 64 6f 77 5f 72 65  |d g).{.window_re|
00001570  6d 6f 76 65 5f 67 61 64  67 65 74 28 30 2c 4f 69  |move_gadget(0,Oi|
00001580  64 2c 67 29 3b 0a 7d 0a  0a 0a 0a 2f 2a 0a 20 20  |d,g);.}..../*.  |
00001590  20 41 20 48 6f 6f 6b 4d  65 20 6d 65 73 73 61 67  | A HookMe messag|
000015a0  65 20 68 61 73 20 62 65  65 6e 20 72 65 63 65 69  |e has been recei|
000015b0  76 65 64 2e 20 53 65 74  20 74 68 65 20 69 6e 76  |ved. Set the inv|
000015c0  69 73 69 62 6c 65 20 69  63 6f 6e 27 73 0a 20 20  |isible icon's.  |
000015d0  20 62 75 74 74 6f 6e 20  74 79 70 65 20 74 6f 20  | button type to |
000015e0  74 68 61 74 20 72 65 71  75 65 73 74 65 64 20 62  |that requested b|
000015f0  79 20 74 68 65 20 6c 69  6e 6b 65 64 20 74 6f 6f  |y the linked too|
00001600  6c 2e 0a 2a 2f 0a 0a 69  6e 74 20 68 6f 6f 6b 6d  |l..*/..int hookm|
00001610  65 5f 6d 65 73 73 61 67  65 28 57 69 6d 70 4d 65  |e_message(WimpMe|
00001620  73 73 61 67 65 20 2a 6d  65 73 73 61 67 65 2c 76  |ssage *message,v|
00001630  6f 69 64 20 2a 68 61 6e  64 6c 65 29 0a 0a 7b 0a  |oid *handle)..{.|
00001640  68 6f 6f 6b 6d 65 5f 62  6c 6f 63 6b 20 2a 65 3b  |hookme_block *e;|
00001650  0a 6f 62 6a 65 63 74 70  6f 73 5f 62 6c 6f 63 6b  |.objectpos_block|
00001660  20 2a 66 3b 0a 69 6e 74  20 77 3b 0a 69 6e 74 20  | *f;.int w;.int |
00001670  63 6c 65 61 72 2c 65 6f  72 3b 0a 4f 62 6a 65 63  |clear,eor;.Objec|
00001680  74 49 64 20 4f 69 64 3b  0a 57 69 6d 70 47 65 74  |tId Oid;.WimpGet|
00001690  57 69 6e 64 6f 77 53 74  61 74 65 42 6c 6f 63 6b  |WindowStateBlock|
000016a0  20 73 74 61 74 65 3b 0a  0a 0a 4f 69 64 3d 28 4f  | state;...Oid=(O|
000016b0  62 6a 65 63 74 49 64 29  68 61 6e 64 6c 65 3b 0a  |bjectId)handle;.|
000016c0  63 72 65 61 74 65 5f 67  61 64 67 65 74 28 4f 69  |create_gadget(Oi|
000016d0  64 2c 30 29 3b 0a 0a 65  3d 28 68 6f 6f 6b 6d 65  |d,0);..e=(hookme|
000016e0  5f 62 6c 6f 63 6b 20 2a  29 6d 65 73 73 61 67 65  |_block *)message|
000016f0  2d 3e 64 61 74 61 2e 77  6f 72 64 73 3b 0a 0a 65  |->data.words;..e|
00001700  6f 72 3d 65 2d 3e 66 6c  61 67 73 20 3e 3e 20 31  |or=e->flags >> 1|
00001710  36 3b 0a 63 6c 65 61 72  3d 30 78 66 30 30 30 3b  |6;.clear=0xf000;|
00001720  0a 62 75 74 74 6f 6e 5f  73 65 74 5f 66 6c 61 67  |.button_set_flag|
00001730  73 20 28 30 2c 4f 69 64  2c 30 2c 63 6c 65 61 72  |s (0,Oid,0,clear|
00001740  2c 65 6f 72 29 3b 0a 0a  0a 68 6f 6f 6b 65 64 5f  |,eor);...hooked_|
00001750  77 3d 65 2d 3e 68 61 6e  64 6c 65 3b 0a 6d 65 73  |w=e->handle;.mes|
00001760  73 61 67 65 2d 3e 68 64  72 2e 79 6f 75 72 5f 72  |sage->hdr.your_r|
00001770  65 66 3d 6d 65 73 73 61  67 65 2d 3e 68 64 72 2e  |ef=message->hdr.|
00001780  6d 79 5f 72 65 66 3b 0a  68 6f 6f 6b 65 64 5f 72  |my_ref;.hooked_r|
00001790  3d 6d 65 73 73 61 67 65  2d 3e 68 64 72 2e 79 6f  |=message->hdr.yo|
000017a0  75 72 5f 72 65 66 3b 0a  6d 65 73 73 61 67 65 2d  |ur_ref;.message-|
000017b0  3e 68 64 72 2e 73 69 7a  65 3d 36 34 3b 0a 6d 65  |>hdr.size=64;.me|
000017c0  73 73 61 67 65 2d 3e 68  64 72 2e 61 63 74 69 6f  |ssage->hdr.actio|
000017d0  6e 5f 63 6f 64 65 3d 4d  65 73 73 61 67 65 5f 4f  |n_code=Message_O|
000017e0  62 6a 65 63 74 50 6f 73  69 74 69 6f 6e 3b 0a 0a  |bjectPosition;..|
000017f0  77 69 6e 64 6f 77 5f 67  65 74 5f 77 69 6d 70 5f  |window_get_wimp_|
00001800  68 61 6e 64 6c 65 28 30  2c 4f 69 64 20 2c 26 77  |handle(0,Oid ,&w|
00001810  29 3b 0a 73 74 61 74 65  2e 77 69 6e 64 6f 77 5f  |);.state.window_|
00001820  68 61 6e 64 6c 65 20 3d  20 77 3b 0a 77 69 6d 70  |handle = w;.wimp|
00001830  5f 67 65 74 5f 77 69 6e  64 6f 77 5f 73 74 61 74  |_get_window_stat|
00001840  65 28 26 73 74 61 74 65  29 3b 0a 0a 66 3d 28 6f  |e(&state);..f=(o|
00001850  62 6a 65 63 74 70 6f 73  5f 62 6c 6f 63 6b 2a 29  |bjectpos_block*)|
00001860  20 65 3b 0a 66 2d 3e 68  61 6e 64 6c 65 3d 77 3b  | e;.f->handle=w;|
00001870  0a 66 2d 3e 7a 65 72 6f  3d 30 3b 0a 66 2d 3e 74  |.f->zero=0;.f->t|
00001880  6f 6f 6c 62 61 72 68 61  6e 64 6c 65 3d 2d 31 3b  |oolbarhandle=-1;|
00001890  0a 66 2d 3e 78 6c 6f 77  3d 73 74 61 74 65 2e 76  |.f->xlow=state.v|
000018a0  69 73 69 62 6c 65 5f 61  72 65 61 2e 78 6d 69 6e  |isible_area.xmin|
000018b0  3b 0a 66 2d 3e 79 6c 6f  77 3d 73 74 61 74 65 2e  |;.f->ylow=state.|
000018c0  76 69 73 69 62 6c 65 5f  61 72 65 61 2e 79 6d 69  |visible_area.ymi|
000018d0  6e 3b 0a 66 2d 3e 78 73  63 61 6c 65 3d 31 3c 3c  |n;.f->xscale=1<<|
000018e0  31 36 3b 0a 66 2d 3e 79  73 63 61 6c 65 3d 31 3c  |16;.f->yscale=1<|
000018f0  3c 31 36 3b 0a 66 2d 3e  78 6c 6f 77 75 3d 73 74  |<16;.f->xlowu=st|
00001900  61 74 65 2e 76 69 73 69  62 6c 65 5f 61 72 65 61  |ate.visible_area|
00001910  2e 78 6d 69 6e 3b 0a 66  2d 3e 79 6c 6f 77 75 3d  |.xmin;.f->ylowu=|
00001920  73 74 61 74 65 2e 76 69  73 69 62 6c 65 5f 61 72  |state.visible_ar|
00001930  65 61 2e 79 6d 69 6e 3b  0a 0a 77 69 6d 70 5f 73  |ea.ymin;..wimp_s|
00001940  65 6e 64 5f 6d 65 73 73  61 67 65 20 20 20 20 20  |end_message     |
00001950  20 28 31 37 2c 6d 65 73  73 61 67 65 2c 74 61 73  | (17,message,tas|
00001960  6b 5b 68 6f 6f 6b 65 64  5f 74 5d 5b 30 5d 2c 30  |k[hooked_t][0],0|
00001970  2c 4e 55 4c 4c 29 3b 0a  48 4f 4f 4b 45 44 3d 54  |,NULL);.HOOKED=T|
00001980  52 55 45 3b 0a 0a 72 65  74 75 72 6e 28 46 41 4c  |RUE;..return(FAL|
00001990  53 45 29 3b 0a 7d 0a 0a  0a 0a 0a 2f 2a 0a 20 20  |SE);.}...../*.  |
000019a0  20 55 6e 68 6f 6f 6b 20  61 6e 64 20 6b 69 6c 6c  | Unhook and kill|
000019b0  20 67 61 64 67 65 74 0a  2a 2f 0a 0a 69 6e 74 20  | gadget.*/..int |
000019c0  75 6e 68 6f 6f 6b 6d 65  5f 6d 65 73 73 61 67 65  |unhookme_message|
000019d0  28 57 69 6d 70 4d 65 73  73 61 67 65 20 2a 6d 65  |(WimpMessage *me|
000019e0  73 73 61 67 65 2c 76 6f  69 64 20 2a 68 61 6e 64  |ssage,void *hand|
000019f0  6c 65 29 0a 7b 0a 0a 4f  62 6a 65 63 74 49 64 20  |le).{..ObjectId |
00001a00  4f 69 64 3b 0a 0a 4f 69  64 3d 28 4f 62 6a 65 63  |Oid;..Oid=(Objec|
00001a10  74 49 64 29 68 61 6e 64  6c 65 3b 0a 0a 0a 6b 69  |tId)handle;...ki|
00001a20  6c 6c 5f 67 61 64 67 65  74 28 4f 69 64 2c 30 29  |ll_gadget(Oid,0)|
00001a30  3b 0a 48 4f 4f 4b 45 44  3d 46 41 4c 53 45 3b 0a  |;.HOOKED=FALSE;.|
00001a40  0a 72 65 74 75 72 6e 28  46 41 4c 53 45 29 3b 0a  |.return(FALSE);.|
00001a50  7d 0a 0a 0a 0a 0a 0a 0a  2f 2a 20 52 65 67 69 73  |}......./* Regis|
00001a60  74 65 72 65 64 20 63 61  6c 6c 62 61 63 6b 20 66  |tered callback f|
00001a70  75 6e 63 74 69 6f 6e 2e  20 43 61 6c 6c 65 64 20  |unction. Called |
00001a80  77 68 65 6e 20 6f 75 72  20 66 6c 65 78 20 62 6c  |when our flex bl|
00001a90  6f 63 6b 20 6d 6f 76 65  73 2e 0a 20 20 20 43 61  |ock moves..   Ca|
00001aa0  6c 6c 65 64 20 74 77 69  63 65 2c 20 6f 6e 63 65  |lled twice, once|
00001ab0  20 62 65 66 6f 72 65 20  74 68 65 20 6d 6f 76 65  | before the move|
00001ac0  20 61 6e 64 20 6f 6e 63  65 20 61 66 74 65 72 2e  | and once after.|
00001ad0  20 57 65 20 61 72 65 20  6f 6e 6c 79 20 69 6e 74  | We are only int|
00001ae0  65 72 65 73 74 65 64 0a  20 20 20 69 6e 20 74 68  |erested.   in th|
00001af0  65 20 63 61 6c 6c 20 61  66 74 65 72 2e 0a 2a 2f  |e call after..*/|
00001b00  0a 0a 76 6f 69 64 20 62  6c 6f 63 6b 6d 6f 76 65  |..void blockmove|
00001b10  64 28 42 4f 4f 4c 20 62  34 2c 76 6f 69 64 20 2a  |d(BOOL b4,void *|
00001b20  68 61 6e 64 6c 65 29 0a  7b 0a 0a 69 66 20 28 21  |handle).{..if (!|
00001b30  62 34 29 0a 20 20 7b 0a  0a 20 20 20 69 64 2e 74  |b4).  {..   id.t|
00001b40  61 67 3d 73 70 72 69 74  65 5f 69 64 5f 6e 61 6d  |ag=sprite_id_nam|
00001b50  65 3b 0a 20 20 20 69 64  2e 73 2e 61 64 64 72 3d  |e;.   id.s.addr=|
00001b60  73 6e 61 6d 65 3b 0a 20  20 20 73 70 72 69 74 65  |sname;.   sprite|
00001b70  5f 73 65 6c 65 63 74 5f  72 70 28 73 70 62 6c 6f  |_select_rp(spblo|
00001b80  63 6b 2c 26 69 64 2c 26  69 64 2e 73 2e 61 64 64  |ck,&id,&id.s.add|
00001b90  72 29 3b 0a 20 20 20 69  64 2e 74 61 67 3d 73 70  |r);.   id.tag=sp|
00001ba0  72 69 74 65 5f 69 64 5f  61 64 64 72 3b 0a 20 20  |rite_id_addr;.  |
00001bb0  20 61 6e 63 68 2d 3e 62  61 73 65 3d 28 69 6e 74  | anch->base=(int|
00001bc0  2a 29 73 70 62 6c 6f 63  6b 3b 0a 20 20 20 7d 0a  |*)spblock;.   }.|
00001bd0  7d 0a 0a 0a 0a 2f 2a 20  49 66 20 74 68 65 20 64  |}..../* If the d|
00001be0  75 6d 6d 79 20 62 6c 6f  63 6b 20 68 61 73 20 6e  |ummy block has n|
00001bf0  6f 74 20 79 65 74 20 62  65 65 6e 20 66 72 65 65  |ot yet been free|
00001c00  64 2c 20 64 6f 20 69 74  20 6e 6f 77 2e 20 54 68  |d, do it now. Th|
00001c10  69 73 20 77 69 6c 6c 20  63 61 75 73 65 20 6f 75  |is will cause ou|
00001c20  72 0a 20 20 20 6d 61 69  6e 20 62 6c 6f 63 6b 20  |r.   main block |
00001c30  74 6f 20 6d 6f 76 65 2c  20 74 68 75 73 20 63 61  |to move, thus ca|
00001c40  6c 6c 69 6e 67 20 74 68  65 20 72 65 67 69 73 74  |lling the regist|
00001c50  65 72 65 64 20 63 61 6c  6c 62 61 63 6b 20 68 61  |ered callback ha|
00001c60  6e 64 6c 65 72 2e 0a 2a  2f 0a 0a 0a 69 6e 74 20  |ndler..*/...int |
00001c70  64 6f 5f 74 68 65 5f 66  72 65 65 28 69 6e 74 20  |do_the_free(int |
00001c80  65 76 65 6e 74 5f 63 6f  64 65 2c 20 54 6f 6f 6c  |event_code, Tool|
00001c90  62 6f 78 45 76 65 6e 74  20 2a 65 76 65 6e 74 2c  |boxEvent *event,|
00001ca0  20 49 64 42 6c 6f 63 6b  20 2a 69 64 5f 62 6c 6f  | IdBlock *id_blo|
00001cb0  63 6b 2c 76 6f 69 64 20  2a 68 61 6e 64 6c 65 29  |ck,void *handle)|
00001cc0  0a 0a 7b 0a 69 66 28 66  61 6b 65 21 3d 4e 55 4c  |..{.if(fake!=NUL|
00001cd0  4c 29 0a 20 20 7b 0a 20  20 20 20 20 20 66 6c 65  |L).  {.      fle|
00001ce0  78 5f 66 72 65 65 28 28  66 6c 65 78 5f 70 74 72  |x_free((flex_ptr|
00001cf0  29 26 66 61 6b 65 29 3b  0a 20 20 20 20 20 20 66  |)&fake);.      f|
00001d00  61 6b 65 3d 4e 55 4c 4c  3b 0a 20 20 20 7d 0a 0a  |ake=NULL;.   }..|
00001d10  2f 2a 20 54 68 65 72 65  27 73 20 6f 6e 6c 79 20  |/* There's only |
00001d20  6f 6e 65 20 64 75 6d 6d  79 20 62 6c 6f 63 6b 20  |one dummy block |
00001d30  74 6f 20 64 65 6c 65 74  65 2c 20 73 6f 20 6f 6e  |to delete, so on|
00001d40  63 65 20 69 74 27 73 20  62 65 65 6e 20 64 6f 6e  |ce it's been don|
00001d50  65 2c 0a 20 20 20 66 61  64 65 20 74 68 65 20 6d  |e,.   fade the m|
00001d60  65 6e 75 20 65 6e 74 72  79 2e 0a 2a 2f 0a 0a 0a  |enu entry..*/...|
00001d70  6d 65 6e 75 5f 73 65 74  5f 66 61 64 65 28 30 2c  |menu_set_fade(0,|
00001d80  6d 61 69 6e 6d 65 6e 75  2c 31 2c 31 29 3b 0a 0a  |mainmenu,1,1);..|
00001d90  0a 72 65 74 75 72 6e 28  54 52 55 45 29 3b 0a 7d  |.return(TRUE);.}|
00001da0  0a 0a 0a 0a 2f 2a 0a 20  20 20 20 54 6f 67 67 6c  |..../*.    Toggl|
00001db0  65 20 75 73 65 72 20 6f  70 74 69 6f 6e 20 74 6f  |e user option to|
00001dc0  20 61 63 63 65 70 74 20  69 6e 20 70 6c 61 63 65  | accept in place|
00001dd0  20 65 64 69 74 69 6e 67  2e 0a 2a 2f 0a 0a 69 6e  | editing..*/..in|
00001de0  74 20 73 65 74 5f 73 74  61 74 75 73 28 69 6e 74  |t set_status(int|
00001df0  20 65 76 65 6e 74 5f 63  6f 64 65 2c 20 54 6f 6f  | event_code, Too|
00001e00  6c 62 6f 78 45 76 65 6e  74 20 2a 65 76 65 6e 74  |lboxEvent *event|
00001e10  2c 20 49 64 42 6c 6f 63  6b 20 2a 69 64 5f 62 6c  |, IdBlock *id_bl|
00001e20  6f 63 6b 2c 76 6f 69 64  20 2a 68 61 6e 64 6c 65  |ock,void *handle|
00001e30  29 0a 0a 7b 0a 0a 41 43  43 45 50 54 5f 49 4e 50  |)..{..ACCEPT_INP|
00001e40  4c 41 43 45 3d 21 41 43  43 45 50 54 5f 49 4e 50  |LACE=!ACCEPT_INP|
00001e50  4c 41 43 45 3b 0a 0a 69  66 28 41 43 43 45 50 54  |LACE;..if(ACCEPT|
00001e60  5f 49 4e 50 4c 41 43 45  29 0a 20 20 20 20 6d 65  |_INPLACE).    me|
00001e70  6e 75 5f 73 65 74 5f 74  69 63 6b 28 30 2c 6d 61  |nu_set_tick(0,ma|
00001e80  69 6e 6d 65 6e 75 2c 32  2c 31 29 3b 0a 65 6c 73  |inmenu,2,1);.els|
00001e90  65 0a 6d 65 6e 75 5f 73  65 74 5f 74 69 63 6b 28  |e.menu_set_tick(|
00001ea0  30 2c 6d 61 69 6e 6d 65  6e 75 2c 32 2c 30 29 3b  |0,mainmenu,2,0);|
00001eb0  0a 0a 72 65 74 75 72 6e  28 54 52 55 45 29 3b 0a  |..return(TRUE);.|
00001ec0  0a 0a 7d 0a 0a 0a 0a 2f  2a 20 4d 61 69 6e 20 6d  |..}..../* Main m|
00001ed0  65 6e 75 20 61 62 6f 75  74 20 74 6f 20 62 65 20  |enu about to be |
00001ee0  73 68 6f 77 6e 2e 20 53  65 6e 64 20 6d 65 73 73  |shown. Send mess|
00001ef0  61 67 65 73 20 74 6f 20  66 69 6e 64 20 6f 75 74  |ages to find out|
00001f00  20 77 68 6f 27 73 20 61  62 6f 75 74 2e 0a 20 20  | who's about..  |
00001f10  20 55 74 69 6c 69 74 79  20 6d 65 6e 75 20 63 72  | Utility menu cr|
00001f20  65 61 74 65 64 20 62 79  20 66 75 6e 63 74 69 6f  |eated by functio|
00001f30  6e 20 68 61 6e 64 6c 69  6e 67 20 72 65 73 70 6f  |n handling respo|
00001f40  6e 73 65 73 2e 0a 2a 2f  0a 0a 69 6e 74 20 73 65  |nses..*/..int se|
00001f50  74 75 70 5f 6d 65 6e 75  28 69 6e 74 20 65 76 65  |tup_menu(int eve|
00001f60  6e 74 5f 63 6f 64 65 2c  20 54 6f 6f 6c 62 6f 78  |nt_code, Toolbox|
00001f70  45 76 65 6e 74 20 2a 65  76 65 6e 74 2c 20 49 64  |Event *event, Id|
00001f80  42 6c 6f 63 6b 20 2a 69  64 5f 62 6c 6f 63 6b 2c  |Block *id_block,|
00001f90  76 6f 69 64 20 2a 68 61  6e 64 6c 65 29 0a 7b 0a  |void *handle).{.|
00001fa0  77 68 6f 73 61 62 6f 75  74 5f 62 6c 6f 63 6b 20  |whosabout_block |
00001fb0  2a 65 3b 0a 57 69 6d 70  4d 65 73 73 61 67 65 20  |*e;.WimpMessage |
00001fc0  77 3b 0a 0a 69 6e 74 20  69 3b 0a 6d 65 6e 75 5f  |w;..int i;.menu_|
00001fd0  73 65 74 5f 66 61 64 65  28 30 2c 6d 61 69 6e 6d  |set_fade(0,mainm|
00001fe0  65 6e 75 2c 30 2c 31 29  3b 0a 66 6f 72 20 28 69  |enu,0,1);.for (i|
00001ff0  3d 30 3b 69 3c 63 6f 75  6e 74 3b 69 2b 2b 29 0a  |=0;i<count;i++).|
00002000  20 20 20 20 20 7b 0a 20  20 20 20 20 6d 65 6e 75  |     {.     menu|
00002010  5f 72 65 6d 6f 76 65 5f  65 6e 74 72 79 28 30 2c  |_remove_entry(0,|
00002020  28 4f 62 6a 65 63 74 49  64 29 68 61 6e 64 6c 65  |(ObjectId)handle|
00002030  2c 69 29 3b 0a 20 20 20  20 20 66 72 65 65 28 6e  |,i);.     free(n|
00002040  61 6d 65 73 5b 69 5d 29  3b 0a 20 20 20 20 20 7d  |ames[i]);.     }|
00002050  0a 63 6f 75 6e 74 3d 30  3b 0a 65 3d 28 77 68 6f  |.count=0;.e=(who|
00002060  73 61 62 6f 75 74 5f 62  6c 6f 63 6b 20 2a 29 26  |sabout_block *)&|
00002070  77 2e 64 61 74 61 3b 0a  77 2e 68 64 72 2e 73 69  |w.data;.w.hdr.si|
00002080  7a 65 3d 36 34 3b 0a 77  2e 68 64 72 2e 61 63 74  |ze=64;.w.hdr.act|
00002090  69 6f 6e 5f 63 6f 64 65  3d 4d 65 73 73 61 67 65  |ion_code=Message|
000020a0  5f 57 68 6f 73 41 62 6f  75 74 3b 0a 77 2e 68 64  |_WhosAbout;.w.hd|
000020b0  72 2e 6d 79 5f 72 65 66  3d 30 3b 0a 77 2e 68 64  |r.my_ref=0;.w.hd|
000020c0  72 2e 79 6f 75 72 5f 72  65 66 3d 30 3b 0a 77 2e  |r.your_ref=0;.w.|
000020d0  68 64 72 2e 73 65 6e 64  65 72 3d 54 68 69 73 54  |hdr.sender=ThisT|
000020e0  61 73 6b 3b 0a 0a 65 2d  3e 74 61 67 70 74 72 3d  |ask;..e->tagptr=|
000020f0  61 6e 63 68 3b 0a 65 2d  3e 66 69 6c 65 74 79 70  |anch;.e->filetyp|
00002100  65 3d 30 78 66 66 39 3b  0a 77 69 6d 70 5f 73 65  |e=0xff9;.wimp_se|
00002110  6e 64 5f 6d 65 73 73 61  67 65 20 20 20 20 20 20  |nd_message      |
00002120  28 31 37 2c 26 77 2c 30  2c 30 2c 4e 55 4c 4c 29  |(17,&w,0,0,NULL)|
00002130  3b 0a 0a 69 66 28 41 43  43 45 50 54 5f 49 4e 50  |;..if(ACCEPT_INP|
00002140  4c 41 43 45 29 20 6d 65  6e 75 5f 73 65 74 5f 74  |LACE) menu_set_t|
00002150  69 63 6b 28 30 2c 6d 61  69 6e 6d 65 6e 75 2c 32  |ick(0,mainmenu,2|
00002160  2c 31 29 3b 20 65 6c 73  65 20 6d 65 6e 75 5f 73  |,1); else menu_s|
00002170  65 74 5f 74 69 63 6b 28  30 2c 6d 61 69 6e 6d 65  |et_tick(0,mainme|
00002180  6e 75 2c 32 2c 30 29 3b  0a 0a 72 65 74 75 72 6e  |nu,2,0);..return|
00002190  28 46 41 4c 53 45 29 3b  0a 7d 0a 0a 0a 0a 0a 2f  |(FALSE);.}...../|
000021a0  2a 20 20 41 20 72 65 6d  6f 74 65 20 61 70 70 6c  |*  A remote appl|
000021b0  69 63 61 74 69 6f 6e 20  68 61 73 20 6d 6f 64 69  |ication has modi|
000021c0  66 69 65 64 20 74 68 65  20 70 69 63 74 75 72 65  |fied the picture|
000021d0  20 2a 2f 0a 0a 0a 69 6e  74 20 63 68 61 6e 67 65  | */...int change|
000021e0  64 28 57 69 6d 70 4d 65  73 73 61 67 65 20 2a 6d  |d(WimpMessage *m|
000021f0  65 73 73 61 67 65 2c 76  6f 69 64 20 2a 68 61 6e  |essage,void *han|
00002200  64 6c 65 29 0a 0a 7b 0a  4f 62 6a 65 63 74 49 64  |dle)..{.ObjectId|
00002210  20 4f 69 64 3b 0a 42 42  6f 78 20 62 3b 0a 75 70  | Oid;.BBox b;.up|
00002220  64 61 74 65 61 72 65 61  5f 62 6c 6f 63 6b 20 2a  |datearea_block *|
00002230  65 3b 0a 69 6e 74 20 77  3b 0a 0a 65 3d 28 75 70  |e;.int w;..e=(up|
00002240  64 61 74 65 61 72 65 61  5f 62 6c 6f 63 6b 20 2a  |datearea_block *|
00002250  29 6d 65 73 73 61 67 65  2d 3e 64 61 74 61 2e 77  |)message->data.w|
00002260  6f 72 64 73 3b 0a 0a 4f  69 64 3d 28 4f 62 6a 65  |ords;..Oid=(Obje|
00002270  63 74 49 64 29 68 61 6e  64 6c 65 3b 0a 0a 69 66  |ctId)handle;..if|
00002280  20 28 6d 65 73 73 61 67  65 2d 3e 68 64 72 2e 61  | (message->hdr.a|
00002290  63 74 69 6f 6e 5f 63 6f  64 65 3d 3d 4d 65 73 73  |ction_code==Mess|
000022a0  61 67 65 5f 44 6f 6e 65  4d 79 53 74 75 66 66 29  |age_DoneMyStuff)|
000022b0  0a 20 20 20 7b 0a 20 20  20 20 20 20 62 2e 78 6d  |.   {.      b.xm|
000022c0  69 6e 3d 30 3b 0a 20 20  20 20 20 20 62 2e 78 6d  |in=0;.      b.xm|
000022d0  61 78 3d 31 30 30 30 3b  0a 20 20 20 20 20 20 62  |ax=1000;.      b|
000022e0  2e 79 6d 69 6e 3d 2d 33  39 38 3b 0a 20 20 20 20  |.ymin=-398;.    |
000022f0  20 20 62 2e 79 6d 61 78  3d 2d 30 30 3b 0a 0a 20  |  b.ymax=-00;.. |
00002300  20 20 7d 0a 65 6c 73 65  0a 20 20 20 7b 0a 20 20  |  }.else.   {.  |
00002310  20 20 20 62 2e 78 6d 69  6e 3d 65 2d 3e 72 2e 78  |   b.xmin=e->r.x|
00002320  6c 6f 77 3b 0a 20 20 20  20 20 62 2e 78 6d 61 78  |low;.     b.xmax|
00002330  3d 65 2d 3e 72 2e 78 68  69 3b 0a 20 20 20 20 20  |=e->r.xhi;.     |
00002340  62 2e 79 6d 69 6e 3d 65  2d 3e 72 2e 79 6c 6f 77  |b.ymin=e->r.ylow|
00002350  2d 33 39 38 3b 0a 20 20  20 20 20 62 2e 79 6d 61  |-398;.     b.yma|
00002360  78 3d 65 2d 3e 72 2e 79  68 69 2d 33 39 38 3b 0a  |x=e->r.yhi-398;.|
00002370  20 20 20 7d 0a 0a 77 69  6e 64 6f 77 5f 67 65 74  |   }..window_get|
00002380  5f 77 69 6d 70 5f 68 61  6e 64 6c 65 28 30 2c 4f  |_wimp_handle(0,O|
00002390  69 64 20 2c 26 77 29 3b  0a 75 70 64 61 74 65 5f  |id ,&w);.update_|
000023a0  77 69 6e 64 6f 77 28 77  2c 26 62 29 3b 0a 0a 0a  |window(w,&b);...|
000023b0  72 65 74 75 72 6e 28 54  52 55 45 29 3b 0a 7d 0a  |return(TRUE);.}.|
000023c0  0a 0a 0a 0a 69 6e 74 20  72 65 74 75 72 6e 65 64  |....int returned|
000023d0  5f 6d 65 73 73 61 67 65  28 57 69 6d 70 4d 65 73  |_message(WimpMes|
000023e0  73 61 67 65 20 2a 6d 65  73 73 61 67 65 2c 76 6f  |sage *message,vo|
000023f0  69 64 20 2a 68 61 6e 64  6c 65 29 0a 0a 7b 0a 68  |id *handle)..{.h|
00002400  61 6e 64 6c 65 3d 68 61  6e 64 6c 65 3b 0a 0a 69  |andle=handle;..i|
00002410  66 20 28 28 6d 65 73 73  61 67 65 2d 3e 68 64 72  |f ((message->hdr|
00002420  2e 73 65 6e 64 65 72 3d  3d 54 68 69 73 54 61 73  |.sender==ThisTas|
00002430  6b 29 20 26 26 20 53 48  4f 52 54 43 55 54 29 0a  |k) && SHORTCUT).|
00002440  7b 0a 0a 53 48 4f 52 54  43 55 54 3d 46 41 4c 53  |{..SHORTCUT=FALS|
00002450  45 3b 0a 74 6f 6f 6c 62  6f 78 5f 73 68 6f 77 5f  |E;.toolbox_show_|
00002460  6f 62 6a 65 63 74 28 31  2c 74 6f 6f 6c 6d 65 6e  |object(1,toolmen|
00002470  75 2c 30 2c 4e 55 4c 4c  2c 4e 55 4c 4c 2c 4e 55  |u,0,NULL,NULL,NU|
00002480  4c 4c 29 3b 0a 0a 0a 7d  0a 72 65 74 75 72 6e 28  |LL);...}.return(|
00002490  46 41 4c 53 45 29 3b 0a  7d 0a 0a 0a 0a 0a 0a 0a  |FALSE);.}.......|
000024a0  0a 0a 0a 0a 0a 2f 2a 20  6c 69 6e 6b 20 74 6f 20  |...../* link to |
000024b0  73 65 6c 65 63 74 65 64  20 72 65 6d 6f 74 65 20  |selected remote |
000024c0  2a 2f 0a 0a 69 6e 74 20  68 65 72 65 49 61 6d 28  |*/..int hereIam(|
000024d0  69 6e 74 20 65 76 65 6e  74 5f 63 6f 64 65 2c 20  |int event_code, |
000024e0  54 6f 6f 6c 62 6f 78 45  76 65 6e 74 20 2a 65 76  |ToolboxEvent *ev|
000024f0  65 6e 74 2c 20 49 64 42  6c 6f 63 6b 20 2a 69 64  |ent, IdBlock *id|
00002500  5f 62 6c 6f 63 6b 2c 76  6f 69 64 20 2a 68 61 6e  |_block,void *han|
00002510  64 6c 65 29 0a 7b 0a 64  6f 79 6f 75 72 73 74 75  |dle).{.doyourstu|
00002520  66 66 5f 62 6c 6f 63 6b  20 2a 65 3b 0a 57 69 6d  |ff_block *e;.Wim|
00002530  70 4d 65 73 73 61 67 65  20 77 3b 0a 0a 65 3d 28  |pMessage w;..e=(|
00002540  64 6f 79 6f 75 72 73 74  75 66 66 5f 62 6c 6f 63  |doyourstuff_bloc|
00002550  6b 20 2a 29 26 77 2e 64  61 74 61 3b 0a 0a 77 2e  |k *)&w.data;..w.|
00002560  68 64 72 2e 73 69 7a 65  3d 36 34 3b 0a 77 2e 68  |hdr.size=64;.w.h|
00002570  64 72 2e 61 63 74 69 6f  6e 5f 63 6f 64 65 3d 4d  |dr.action_code=M|
00002580  65 73 73 61 67 65 5f 44  6f 59 6f 75 72 53 74 75  |essage_DoYourStu|
00002590  66 66 3b 0a 77 2e 68 64  72 2e 6d 79 5f 72 65 66  |ff;.w.hdr.my_ref|
000025a0  3d 30 3b 0a 77 2e 68 64  72 2e 79 6f 75 72 5f 72  |=0;.w.hdr.your_r|
000025b0  65 66 3d 30 3b 0a 77 2e  68 64 72 2e 73 65 6e 64  |ef=0;.w.hdr.send|
000025c0  65 72 3d 54 68 69 73 54  61 73 6b 3b 0a 65 2d 3e  |er=ThisTask;.e->|
000025d0  74 6f 6f 6c 69 64 3d 31  3b 0a 65 2d 3e 66 6c 61  |toolid=1;.e->fla|
000025e0  67 73 3d 74 61 73 6b 5b  69 64 5f 62 6c 6f 63 6b  |gs=task[id_block|
000025f0  2d 3e 73 65 6c 66 5f 63  6f 6d 70 6f 6e 65 6e 74  |->self_component|
00002600  5d 5b 31 5d 3b 0a 69 66  20 28 21 41 43 43 45 50  |][1];.if (!ACCEP|
00002610  54 5f 49 4e 50 4c 41 43  45 29 20 65 2d 3e 66 6c  |T_INPLACE) e->fl|
00002620  61 67 73 20 3d 20 20 65  2d 3e 66 6c 61 67 73 20  |ags =  e->flags |
00002630  26 20 21 46 6c 61 67 5f  72 65 6d 6f 74 65 3b 0a  |& !Flag_remote;.|
00002640  73 74 72 63 70 79 28 65  2d 3e 6e 61 6d 65 2c 22  |strcpy(e->name,"|
00002650  47 65 65 2d 67 65 65 22  29 3b 0a 0a 65 2d 3e 74  |Gee-gee");..e->t|
00002660  61 67 70 74 72 3d 61 6e  63 68 3b 0a 65 2d 3e 66  |agptr=anch;.e->f|
00002670  69 6c 65 74 79 70 65 3d  30 78 66 66 39 3b 0a 68  |iletype=0xff9;.h|
00002680  6f 6f 6b 65 64 5f 74 3d  69 64 5f 62 6c 6f 63 6b  |ooked_t=id_block|
00002690  2d 3e 73 65 6c 66 5f 63  6f 6d 70 6f 6e 65 6e 74  |->self_component|
000026a0  3b 0a 77 69 6d 70 5f 73  65 6e 64 5f 6d 65 73 73  |;.wimp_send_mess|
000026b0  61 67 65 20 20 20 20 20  20 28 31 37 2c 26 77 2c  |age      (17,&w,|
000026c0  74 61 73 6b 5b 69 64 5f  62 6c 6f 63 6b 2d 3e 73  |task[id_block->s|
000026d0  65 6c 66 5f 63 6f 6d 70  6f 6e 65 6e 74 5d 5b 30  |elf_component][0|
000026e0  5d 2c 30 2c 4e 55 4c 4c  29 3b 0a 56 41 4c 49 44  |],0,NULL);.VALID|
000026f0  3d 54 52 55 45 3b 0a 72  65 74 75 72 6e 28 46 41  |=TRUE;.return(FA|
00002700  4c 53 45 29 3b 0a 7d 0a  0a 0a 0a 2f 2a 20 54 68  |LSE);.}..../* Th|
00002710  65 20 70 69 63 74 75 72  65 20 69 73 20 61 62 6f  |e picture is abo|
00002720  75 74 20 74 6f 20 64 69  73 61 70 70 65 61 72 2c  |ut to disappear,|
00002730  20 73 6f 20 77 61 72 6e  20 72 65 6d 6f 74 65 73  | so warn remotes|
00002740  20 74 68 61 74 20 74 68  65 20 61 64 64 72 65 73  | that the addres|
00002750  73 20 74 68 65 79 0a 20  20 20 68 61 76 65 20 77  |s they.   have w|
00002760  69 6c 6c 20 6e 6f 74 20  6c 6f 6e 67 65 72 20 62  |ill not longer b|
00002770  65 20 76 61 6c 69 64 2e  0a 2a 2f 0a 0a 0a 0a 0a  |e valid..*/.....|
00002780  76 6f 69 64 20 69 6e 76  61 6c 69 64 61 74 65 5f  |void invalidate_|
00002790  61 64 64 72 65 73 73 65  73 28 76 6f 69 64 29 0a  |addresses(void).|
000027a0  7b 0a 64 65 73 65 6c 65  63 74 5f 62 6c 6f 63 6b  |{.deselect_block|
000027b0  20 2a 65 3b 0a 57 69 6d  70 4d 65 73 73 61 67 65  | *e;.WimpMessage|
000027c0  20 77 3b 0a 0a 65 3d 28  64 65 73 65 6c 65 63 74  | w;..e=(deselect|
000027d0  5f 62 6c 6f 63 6b 20 2a  29 26 77 2e 64 61 74 61  |_block *)&w.data|
000027e0  3b 0a 0a 77 2e 68 64 72  2e 73 69 7a 65 3d 36 34  |;..w.hdr.size=64|
000027f0  3b 0a 77 2e 68 64 72 2e  61 63 74 69 6f 6e 5f 63  |;.w.hdr.action_c|
00002800  6f 64 65 3d 4d 65 73 73  61 67 65 5f 44 65 73 65  |ode=Message_Dese|
00002810  6c 65 63 74 3b 0a 77 2e  68 64 72 2e 6d 79 5f 72  |lect;.w.hdr.my_r|
00002820  65 66 3d 30 3b 0a 77 2e  68 64 72 2e 79 6f 75 72  |ef=0;.w.hdr.your|
00002830  5f 72 65 66 3d 30 3b 0a  77 2e 68 64 72 2e 73 65  |_ref=0;.w.hdr.se|
00002840  6e 64 65 72 3d 54 68 69  73 54 61 73 6b 3b 0a 0a  |nder=ThisTask;..|
00002850  65 2d 3e 74 61 67 70 74  72 3d 61 6e 63 68 3b 0a  |e->tagptr=anch;.|
00002860  65 2d 3e 66 69 6c 65 74  79 70 65 3d 30 78 66 66  |e->filetype=0xff|
00002870  39 3b 0a 77 69 6d 70 5f  73 65 6e 64 5f 6d 65 73  |9;.wimp_send_mes|
00002880  73 61 67 65 20 20 20 20  20 20 28 31 37 2c 26 77  |sage      (17,&w|
00002890  2c 30 2c 30 2c 4e 55 4c  4c 29 3b 0a 56 41 4c 49  |,0,0,NULL);.VALI|
000028a0  44 3d 46 41 4c 53 45 3b  0a 7d 0a 0a 0a 0a 0a 69  |D=FALSE;.}.....i|
000028b0  6e 74 20 6d 61 69 6e 28  29 0a 7b 0a 20 20 20 20  |nt main().{.    |
000028c0  69 6e 74 20 20 20 20 74  6f 6f 6c 62 6f 78 5f 65  |int    toolbox_e|
000028d0  76 65 6e 74 73 20 3d 20  30 2c 0a 20 20 20 20 20  |vents = 0,.     |
000028e0  20 20 20 20 20 20 77 69  6d 70 5f 6d 65 73 73 61  |      wimp_messa|
000028f0  67 65 73 20 3d 20 30 2c  0a 20 20 20 20 20 20 20  |ges = 0,.       |
00002900  20 20 20 20 65 76 65 6e  74 5f 63 6f 64 65 3b 0a  |    event_code;.|
00002910  20 20 20 20 20 5f 6b 65  72 6e 65 6c 5f 73 77 69  |     _kernel_swi|
00002920  5f 72 65 67 73 20 72 3b  0a 0a 0a 20 20 20 20 2f  |_regs r;...    /|
00002930  2a 0a 20 20 20 20 20 2a  20 72 65 67 69 73 74 65  |*.     * registe|
00002940  72 20 6f 75 72 73 65 6c  76 65 73 20 77 69 74 68  |r ourselves with|
00002950  20 74 68 65 20 54 6f 6f  6c 62 6f 78 2e 0a 20 20  | the Toolbox..  |
00002960  20 20 20 2a 2f 0a 0a 20  20 20 20 74 6f 6f 6c 62  |   */..    toolb|
00002970  6f 78 5f 69 6e 69 74 69  61 6c 69 73 65 20 28 30  |ox_initialise (0|
00002980  2c 20 57 69 6d 70 56 65  72 73 69 6f 6e 2c 20 26  |, WimpVersion, &|
00002990  77 69 6d 70 5f 6d 65 73  73 61 67 65 73 2c 20 26  |wimp_messages, &|
000029a0  74 6f 6f 6c 62 6f 78 5f  65 76 65 6e 74 73 2c 20  |toolbox_events, |
000029b0  22 3c 50 72 6f 63 65 73  73 65 64 24 44 69 72 3e  |"<Processed$Dir>|
000029c0  22 2c 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  |",.             |
000029d0  20 20 20 20 20 20 20 20  20 20 20 26 6d 65 73 73  |           &mess|
000029e0  61 67 65 73 2c 20 26 69  64 5f 62 6c 6f 63 6b 2c  |ages, &id_block,|
000029f0  20 30 2c 20 26 54 68 69  73 54 61 73 6b 2c 20 30  | 0, &ThisTask, 0|
00002a00  29 3b 0a 0a 0a 20 20 20  2f 2a 20 49 6e 69 74 69  |);...   /* Initi|
00002a10  61 6c 69 73 65 20 66 6c  65 78 20 77 69 74 68 20  |alise flex with |
00002a20  64 79 6e 61 6d 69 63 20  61 72 65 61 73 20 61 63  |dynamic areas ac|
00002a30  74 69 76 65 20 2a 2f 0a  0a 20 20 20 20 66 6c 65  |tive */..    fle|
00002a40  78 5f 69 6e 69 74 78 28  22 50 72 6f 63 65 73 73  |x_initx("Process|
00002a50  65 64 22 2c 28 69 6e 74  2a 29 26 6d 65 73 73 61  |ed",(int*)&messa|
00002a60  67 65 73 2c 54 52 55 45  2c 31 30 32 34 2a 31 30  |ges,TRUE,1024*10|
00002a70  32 34 2c 46 41 4c 53 45  29 3b 0a 0a 0a 20 20 20  |24,FALSE);...   |
00002a80  20 2f 2a 0a 20 20 20 20  20 2a 20 69 6e 69 74 69  | /*.     * initi|
00002a90  61 6c 69 73 65 20 74 68  65 20 65 76 65 6e 74 20  |alise the event |
00002aa0  6c 69 62 72 61 72 79 2e  0a 20 20 20 20 20 2a 2f  |library..     */|
00002ab0  0a 0a 20 20 20 20 65 76  65 6e 74 5f 69 6e 69 74  |..    event_init|
00002ac0  69 61 6c 69 73 65 20 28  26 69 64 5f 62 6c 6f 63  |ialise (&id_bloc|
00002ad0  6b 29 3b 0a 20 20 20 20  65 76 65 6e 74 5f 73 65  |k);.    event_se|
00002ae0  74 5f 6d 61 73 6b 20 28  31 2b 32 35 36 29 3b 0a  |t_mask (1+256);.|
00002af0  0a 0a 20 20 20 20 2f 2a  0a 20 20 20 20 20 2a 20  |..    /*.     * |
00002b00  72 65 67 69 73 74 65 72  20 68 61 6e 64 6c 65 72  |register handler|
00002b10  20 66 6f 72 20 74 6f 6f  6c 62 6f 78 20 65 76 65  | for toolbox eve|
00002b20  6e 74 20 31 2c 0a 20 20  20 20 20 2a 20 77 68 69  |nt 1,.     * whi|
00002b30  63 68 20 69 73 20 67 65  6e 65 72 61 74 65 64 20  |ch is generated |
00002b40  62 79 20 74 68 65 20 27  51 75 69 74 27 20 6f 70  |by the 'Quit' op|
00002b50  74 69 6f 6e 20 6f 6e 20  74 68 65 0a 20 20 20 20  |tion on the.    |
00002b60  20 2a 20 69 63 6f 6e 62  61 72 20 6d 65 6e 75 2e  | * iconbar menu.|
00002b70  20 20 41 6c 73 6f 20 72  65 67 69 73 74 65 72 20  |  Also register |
00002b80  6d 65 73 73 61 67 65 20  68 61 6e 64 6c 65 72 73  |message handlers|
00002b90  0a 20 20 20 20 20 2a 20  74 6f 20 71 75 69 74 20  |.     * to quit |
00002ba0  70 72 6f 70 65 72 6c 79  20 77 68 65 6e 20 71 75  |properly when qu|
00002bb0  69 74 20 6d 65 73 73 61  67 65 73 20 61 72 65 0a  |it messages are.|
00002bc0  20 20 20 20 20 2a 20 72  65 63 65 69 76 65 64 20  |     * received |
00002bd0  66 72 6f 6d 20 74 68 65  20 77 69 6d 70 2e 0a 20  |from the wimp.. |
00002be0  20 20 20 20 2a 2f 0a 0a  20 20 20 20 20 20 65 76  |    */..      ev|
00002bf0  65 6e 74 5f 72 65 67 69  73 74 65 72 5f 74 6f 6f  |ent_register_too|
00002c00  6c 62 6f 78 5f 68 61 6e  64 6c 65 72 28 2d 31 2c  |lbox_handler(-1,|
00002c10  31 2c 71 75 69 74 5f 65  76 65 6e 74 2c 30 29 3b  |1,quit_event,0);|
00002c20  0a 20 20 20 20 20 20 65  76 65 6e 74 5f 72 65 67  |.      event_reg|
00002c30  69 73 74 65 72 5f 6d 65  73 73 61 67 65 5f 68 61  |ister_message_ha|
00002c40  6e 64 6c 65 72 28 57 69  6d 70 5f 4d 51 75 69 74  |ndler(Wimp_MQuit|
00002c50  2c 71 75 69 74 5f 6d 65  73 73 61 67 65 2c 30 29  |,quit_message,0)|
00002c60  3b 0a 20 20 20 20 20 20  65 76 65 6e 74 5f 72 65  |;.      event_re|
00002c70  67 69 73 74 65 72 5f 6d  65 73 73 61 67 65 5f 68  |gister_message_h|
00002c80  61 6e 64 6c 65 72 28 57  69 6d 70 5f 4d 50 72 65  |andler(Wimp_MPre|
00002c90  51 75 69 74 2c 71 75 69  74 5f 6d 65 73 73 61 67  |Quit,quit_messag|
00002ca0  65 2c 30 29 3b 0a 20 20  20 20 20 20 65 76 65 6e  |e,0);.      even|
00002cb0  74 5f 72 65 67 69 73 74  65 72 5f 74 6f 6f 6c 62  |t_register_toolb|
00002cc0  6f 78 5f 68 61 6e 64 6c  65 72 28 2d 31 2c 54 6f  |ox_handler(-1,To|
00002cd0  6f 6c 62 6f 78 5f 4f 62  6a 65 63 74 41 75 74 6f  |olbox_ObjectAuto|
00002ce0  43 72 65 61 74 65 64 2c  61 74 74 61 63 68 5f 68  |Created,attach_h|
00002cf0  61 6e 64 6c 65 72 73 2c  4e 55 4c 4c 29 3b 0a 0a  |andlers,NULL);..|
00002d00  0a 0a 0a 0a 20 20 20 20  2f 2a 20 41 6c 6c 6f 63  |....    /* Alloc|
00002d10  61 74 65 20 61 20 62 6c  6f 63 6b 20 62 65 66 6f  |ate a block befo|
00002d20  72 65 20 74 68 65 20 6f  6e 65 20 63 6f 6e 74 61  |re the one conta|
00002d30  69 6e 69 6e 67 20 74 68  65 20 73 70 72 69 74 65  |ining the sprite|
00002d40  2e 20 57 68 65 6e 20 74  68 69 73 20 69 73 20 6c  |. When this is l|
00002d50  61 74 65 72 0a 20 20 20  20 20 20 20 66 72 65 65  |ater.       free|
00002d60  64 2c 20 69 74 20 77 69  6c 6c 20 63 61 75 73 65  |d, it will cause|
00002d70  20 74 68 65 20 73 70 72  69 74 65 20 74 6f 20 6d  | the sprite to m|
00002d80  6f 76 65 2e 0a 20 20 20  20 2a 2f 0a 0a 20 20 20  |ove..    */..   |
00002d90  20 20 66 6c 65 78 5f 61  6c 6c 6f 63 28 28 66 6c  |  flex_alloc((fl|
00002da0  65 78 5f 70 74 72 29 26  66 61 6b 65 2c 31 30 30  |ex_ptr)&fake,100|
00002db0  2a 31 30 32 34 29 3b 0a  0a 0a 20 20 20 20 69 66  |*1024);...    if|
00002dc0  20 28 66 6c 65 78 5f 61  6c 6c 6f 63 28 28 66 6c  | (flex_alloc((fl|
00002dd0  65 78 5f 70 74 72 29 26  73 70 62 6c 6f 63 6b 2c  |ex_ptr)&spblock,|
00002de0  33 30 30 2a 31 30 32 34  29 3d 3d 30 29 20 77 65  |300*1024)==0) we|
00002df0  72 72 28 54 52 55 45 2c  22 46 61 74 61 6c 20 65  |rr(TRUE,"Fatal e|
00002e00  72 72 6f 72 2e 20 4e 6f  20 72 6f 6f 6d 20 66 6f  |rror. No room fo|
00002e10  72 20 73 70 72 69 74 65  20 61 72 65 61 22 29 3b  |r sprite area");|
00002e20  0a 0a 0a 20 20 20 20 20  73 70 72 69 74 65 5f 61  |...     sprite_a|
00002e30  72 65 61 5f 69 6e 69 74  69 61 6c 69 73 65 28 73  |rea_initialise(s|
00002e40  70 62 6c 6f 63 6b 2c 20  31 30 32 34 2a 33 30 30  |pblock, 1024*300|
00002e50  29 3b 0a 20 20 20 20 20  73 70 72 69 74 65 5f 61  |);.     sprite_a|
00002e60  72 65 61 5f 6c 6f 61 64  28 73 70 62 6c 6f 63 6b  |rea_load(spblock|
00002e70  2c 20 22 3c 50 72 6f 63  65 73 73 65 64 24 44 69  |, "<Processed$Di|
00002e80  72 3e 2e 54 65 73 74 66  69 6c 65 22 29 3b 0a 20  |r>.Testfile");. |
00002e90  20 20 20 20 69 64 2e 74  61 67 3d 73 70 72 69 74  |    id.tag=sprit|
00002ea0  65 5f 69 64 5f 6e 61 6d  65 3b 0a 20 20 20 20 20  |e_id_name;.     |
00002eb0  69 64 2e 73 2e 61 64 64  72 3d 73 6e 61 6d 65 3b  |id.s.addr=sname;|
00002ec0  0a 20 20 20 20 20 73 70  72 69 74 65 5f 73 65 6c  |.     sprite_sel|
00002ed0  65 63 74 5f 72 70 28 73  70 62 6c 6f 63 6b 2c 26  |ect_rp(spblock,&|
00002ee0  69 64 2c 26 69 64 2e 73  2e 61 64 64 72 29 3b 0a  |id,&id.s.addr);.|
00002ef0  20 20 20 20 20 69 64 2e  74 61 67 3d 73 70 72 69  |     id.tag=spri|
00002f00  74 65 5f 69 64 5f 61 64  64 72 3b 0a 20 20 20 20  |te_id_addr;.    |
00002f10  20 66 6c 65 78 5f 72 65  67 69 73 74 65 72 28 28  | flex_register((|
00002f20  66 6c 65 78 5f 70 74 72  29 26 73 70 62 6c 6f 63  |flex_ptr)&spbloc|
00002f30  6b 2c 62 6c 6f 63 6b 6d  6f 76 65 64 2c 4e 55 4c  |k,blockmoved,NUL|
00002f40  4c 29 3b 0a 0a 20 20 20  20 20 72 2e 72 5b 31 5d  |L);..     r.r[1]|
00002f50  3d 28 69 6e 74 29 73 70  62 6c 6f 63 6b 3b 0a 20  |=(int)spblock;. |
00002f60  20 20 20 20 72 2e 72 5b  32 5d 3d 28 69 6e 74 29  |    r.r[2]=(int)|
00002f70  69 64 2e 73 2e 61 64 64  72 2d 28 69 6e 74 29 73  |id.s.addr-(int)s|
00002f80  70 62 6c 6f 63 6b 3b 0a  20 20 20 20 20 5f 6b 65  |pblock;.     _ke|
00002f90  72 6e 65 6c 5f 73 77 69  28 50 43 41 5f 43 72 65  |rnel_swi(PCA_Cre|
00002fa0  61 74 65 54 61 67 2c 26  72 2c 26 72 29 3b 0a 20  |ateTag,&r,&r);. |
00002fb0  20 20 20 20 61 6e 63 68  3d 28 74 61 67 2a 29 72  |    anch=(tag*)r|
00002fc0  2e 72 5b 30 5d 3b 0a 0a  0a 20 20 20 20 2f 2a 0a  |.r[0];...    /*.|
00002fd0  20 20 20 20 20 2a 20 70  6f 6c 6c 20 6c 6f 6f 70  |     * poll loop|
00002fe0  0a 20 20 20 20 20 2a 2f  0a 0a 20 20 20 20 77 68  |.     */..    wh|
00002ff0  69 6c 65 20 28 54 52 55  45 29 0a 20 20 20 20 7b  |ile (TRUE).    {|
00003000  0a 20 20 20 20 20 20 20  20 65 76 65 6e 74 5f 70  |.        event_p|
00003010  6f 6c 6c 20 28 26 65 76  65 6e 74 5f 63 6f 64 65  |oll (&event_code|
00003020  2c 20 26 70 6f 6c 6c 5f  62 6c 6f 63 6b 2c 20 30  |, &poll_block, 0|
00003030  29 3b 0a 20 20 20 20 7d  0a 7d 0a 0a 0a 0a 69 6e  |);.    }.}....in|
00003040  74 20 61 74 74 61 63 68  5f 68 61 6e 64 6c 65 72  |t attach_handler|
00003050  73 28 69 6e 74 20 65 76  65 6e 74 5f 63 6f 64 65  |s(int event_code|
00003060  2c 54 6f 6f 6c 62 6f 78  45 76 65 6e 74 20 2a 65  |,ToolboxEvent *e|
00003070  76 65 6e 74 2c 49 64 42  6c 6f 63 6b 20 2a 69 64  |vent,IdBlock *id|
00003080  5f 62 6c 6f 63 6b 2c 20  76 6f 69 64 20 2a 68 61  |_block, void *ha|
00003090  6e 64 6c 65 29 0a 7b 0a  20 20 2f 2a 20 54 68 69  |ndle).{.  /* Thi|
000030a0  73 20 66 75 6e 63 74 69  6f 6e 20 68 61 73 20 62  |s function has b|
000030b0  65 65 6e 20 63 61 6c 6c  65 64 20 61 73 20 61 20  |een called as a |
000030c0  72 65 73 75 6c 74 20 6f  66 20 61 6e 20 6f 62 6a  |result of an obj|
000030d0  65 63 74 20 62 65 69 6e  67 0a 20 20 20 2a 20 61  |ect being.   * a|
000030e0  75 74 6f 2d 63 72 65 61  74 65 64 2e 20 46 6f 72  |uto-created. For|
000030f0  20 74 68 69 73 20 65 78  61 6d 70 6c 65 20 74 68  | this example th|
00003100  61 74 20 6d 65 61 6e 73  20 6f 75 72 20 69 63 6f  |at means our ico|
00003110  6e 62 61 72 20 6f 62 6a  65 63 74 0a 20 20 20 2a  |nbar object.   *|
00003120  20 73 6f 20 77 65 20 63  61 6e 20 6e 6f 77 20 72  | so we can now r|
00003130  65 67 69 73 74 65 72 20  61 6c 6c 20 6f 75 72 20  |egister all our |
00003140  6f 74 68 65 72 20 68 61  6e 64 6c 65 72 73 20 66  |other handlers f|
00003150  6f 72 20 74 68 65 20 72  65 73 74 0a 20 20 20 2a  |or the rest.   *|
00003160  20 6f 66 20 6f 75 72 20  6f 62 6a 65 63 74 73 0a  | of our objects.|
00003170  20 20 20 2a 2f 0a 0a 0a  20 20 4f 62 6a 65 63 74  |   */...  Object|
00003180  43 6c 61 73 73 20 20 20  20 20 6f 62 6a 5f 63 6c  |Class     obj_cl|
00003190  61 73 73 3b 0a 20 20 63  68 61 72 20 62 75 66 66  |ass;.  char buff|
000031a0  65 72 5b 33 32 5d 3b 0a  20 20 69 6e 74 20 64 75  |er[32];.  int du|
000031b0  6d 3b 0a 0a 0a 0a 20 20  74 6f 6f 6c 62 6f 78 5f  |m;....  toolbox_|
000031c0  67 65 74 5f 6f 62 6a 65  63 74 5f 63 6c 61 73 73  |get_object_class|
000031d0  28 30 2c 69 64 5f 62 6c  6f 63 6b 2d 3e 73 65 6c  |(0,id_block->sel|
000031e0  66 5f 69 64 2c 26 6f 62  6a 5f 63 6c 61 73 73 29  |f_id,&obj_class)|
000031f0  3b 0a 20 20 74 6f 6f 6c  62 6f 78 5f 67 65 74 5f  |;.  toolbox_get_|
00003200  74 65 6d 70 6c 61 74 65  5f 6e 61 6d 65 28 30 2c  |template_name(0,|
00003210  69 64 5f 62 6c 6f 63 6b  2d 3e 73 65 6c 66 5f 69  |id_block->self_i|
00003220  64 2c 62 75 66 66 65 72  2c 33 32 2c 26 64 75 6d  |d,buffer,32,&dum|
00003230  29 3b 0a 0a 0a 20 20 73  77 69 74 63 68 28 6f 62  |);...  switch(ob|
00003240  6a 5f 63 6c 61 73 73 29  0a 20 20 7b 0a 20 20 20  |j_class).  {.   |
00003250  20 63 61 73 65 20 57 69  6e 64 6f 77 5f 4f 62 6a  | case Window_Obj|
00003260  65 63 74 43 6c 61 73 73  3a 0a 0a 20 20 20 69 66  |ectClass:..   if|
00003270  20 28 28 21 68 61 6e 64  6c 65 72 73 5f 61 74 74  | ((!handlers_att|
00003280  61 63 68 65 64 29 20 26  26 20 28 73 74 72 63 6d  |ached) && (strcm|
00003290  70 28 62 75 66 66 65 72  2c 22 57 69 6e 64 6f 77  |p(buffer,"Window|
000032a0  22 29 3d 3d 30 29 20 29  0a 20 20 20 20 20 20 7b  |")==0) ).      {|
000032b0  0a 20 20 20 20 20 65 76  65 6e 74 5f 72 65 67 69  |.     event_regi|
000032c0  73 74 65 72 5f 77 69 6d  70 5f 68 61 6e 64 6c 65  |ster_wimp_handle|
000032d0  72 28 69 64 5f 62 6c 6f  63 6b 2d 3e 73 65 6c 66  |r(id_block->self|
000032e0  5f 69 64 2c 57 69 6d 70  5f 45 52 65 64 72 61 77  |_id,Wimp_ERedraw|
000032f0  57 69 6e 64 6f 77 2c 72  65 64 72 61 77 5f 77 69  |Window,redraw_wi|
00003300  6e 64 6f 77 2c 4e 55 4c  4c 29 3b 0a 20 20 20 20  |ndow,NULL);.    |
00003310  20 65 76 65 6e 74 5f 72  65 67 69 73 74 65 72 5f  | event_register_|
00003320  77 69 6d 70 5f 68 61 6e  64 6c 65 72 28 2d 31 2c  |wimp_handler(-1,|
00003330  57 69 6d 70 5f 45 4f 70  65 6e 57 69 6e 64 6f 77  |Wimp_EOpenWindow|
00003340  2c 6f 70 65 6e 2c 28 76  6f 69 64 2a 29 69 64 5f  |,open,(void*)id_|
00003350  62 6c 6f 63 6b 2d 3e 73  65 6c 66 5f 69 64 20 29  |block->self_id )|
00003360  3b 0a 20 20 20 20 20 20  65 76 65 6e 74 5f 72 65  |;.      event_re|
00003370  67 69 73 74 65 72 5f 77  69 6d 70 5f 68 61 6e 64  |gister_wimp_hand|
00003380  6c 65 72 28 2d 31 2c 57  69 6d 70 5f 45 43 6c 6f  |ler(-1,Wimp_EClo|
00003390  73 65 57 69 6e 64 6f 77  2c 63 6c 6f 73 65 2c 28  |seWindow,close,(|
000033a0  76 6f 69 64 2a 29 69 64  5f 62 6c 6f 63 6b 2d 3e  |void*)id_block->|
000033b0  73 65 6c 66 5f 69 64 20  29 3b 0a 20 20 20 20 20  |self_id );.     |
000033c0  65 76 65 6e 74 5f 72 65  67 69 73 74 65 72 5f 77  |event_register_w|
000033d0  69 6d 70 5f 68 61 6e 64  6c 65 72 28 69 64 5f 62  |imp_handler(id_b|
000033e0  6c 6f 63 6b 2d 3e 73 65  6c 66 5f 69 64 2c 57 69  |lock->self_id,Wi|
000033f0  6d 70 5f 45 4d 6f 75 73  65 43 6c 69 63 6b 2c 62  |mp_EMouseClick,b|
00003400  75 74 74 6f 6e 2c 28 76  6f 69 64 2a 29 69 64 5f  |utton,(void*)id_|
00003410  62 6c 6f 63 6b 2d 3e 73  65 6c 66 5f 69 64 20 29  |block->self_id )|
00003420  3b 0a 20 20 20 20 20 65  76 65 6e 74 5f 72 65 67  |;.     event_reg|
00003430  69 73 74 65 72 5f 6d 65  73 73 61 67 65 5f 68 61  |ister_message_ha|
00003440  6e 64 6c 65 72 28 4d 65  73 73 61 67 65 5f 44 6f  |ndler(Message_Do|
00003450  6e 65 4d 79 53 74 75 66  66 2c 63 68 61 6e 67 65  |neMyStuff,change|
00003460  64 2c 28 76 6f 69 64 2a  29 69 64 5f 62 6c 6f 63  |d,(void*)id_bloc|
00003470  6b 2d 3e 73 65 6c 66 5f  69 64 20 29 3b 0a 20 20  |k->self_id );.  |
00003480  20 20 20 65 76 65 6e 74  5f 72 65 67 69 73 74 65  |   event_registe|
00003490  72 5f 6d 65 73 73 61 67  65 5f 68 61 6e 64 6c 65  |r_message_handle|
000034a0  72 28 4d 65 73 73 61 67  65 5f 55 70 64 61 74 65  |r(Message_Update|
000034b0  41 72 65 61 2c 63 68 61  6e 67 65 64 2c 28 76 6f  |Area,changed,(vo|
000034c0  69 64 2a 29 69 64 5f 62  6c 6f 63 6b 2d 3e 73 65  |id*)id_block->se|
000034d0  6c 66 5f 69 64 20 29 3b  0a 20 20 20 20 20 65 76  |lf_id );.     ev|
000034e0  65 6e 74 5f 72 65 67 69  73 74 65 72 5f 6d 65 73  |ent_register_mes|
000034f0  73 61 67 65 5f 68 61 6e  64 6c 65 72 28 4d 65 73  |sage_handler(Mes|
00003500  73 61 67 65 5f 57 68 6f  73 41 62 6f 75 74 2c 72  |sage_WhosAbout,r|
00003510  65 74 75 72 6e 65 64 5f  6d 65 73 73 61 67 65 2c  |eturned_message,|
00003520  28 76 6f 69 64 2a 29 69  64 5f 62 6c 6f 63 6b 2d  |(void*)id_block-|
00003530  3e 73 65 6c 66 5f 69 64  20 29 3b 0a 20 20 20 20  |>self_id );.    |
00003540  20 65 76 65 6e 74 5f 72  65 67 69 73 74 65 72 5f  | event_register_|
00003550  6d 65 73 73 61 67 65 5f  68 61 6e 64 6c 65 72 28  |message_handler(|
00003560  4d 65 73 73 61 67 65 5f  48 6f 6f 6b 4d 65 2c 68  |Message_HookMe,h|
00003570  6f 6f 6b 6d 65 5f 6d 65  73 73 61 67 65 2c 28 76  |ookme_message,(v|
00003580  6f 69 64 2a 29 69 64 5f  62 6c 6f 63 6b 2d 3e 73  |oid*)id_block->s|
00003590  65 6c 66 5f 69 64 20 29  3b 0a 20 20 20 20 20 65  |elf_id );.     e|
000035a0  76 65 6e 74 5f 72 65 67  69 73 74 65 72 5f 6d 65  |vent_register_me|
000035b0  73 73 61 67 65 5f 68 61  6e 64 6c 65 72 28 4d 65  |ssage_handler(Me|
000035c0  73 73 61 67 65 5f 55 6e  68 6f 6f 6b 4d 65 2c 75  |ssage_UnhookMe,u|
000035d0  6e 68 6f 6f 6b 6d 65 5f  6d 65 73 73 61 67 65 2c  |nhookme_message,|
000035e0  28 76 6f 69 64 2a 29 69  64 5f 62 6c 6f 63 6b 2d  |(void*)id_block-|
000035f0  3e 73 65 6c 66 5f 69 64  20 29 3b 0a 20 20 20 20  |>self_id );.    |
00003600  20 73 74 6f 72 65 5f 67  61 64 67 65 74 28 22 57  | store_gadget("W|
00003610  69 6e 64 6f 77 22 2c 69  64 5f 62 6c 6f 63 6b 2d  |indow",id_block-|
00003620  3e 73 65 6c 66 5f 69 64  2c 30 29 3b 0a 0a 0a 20  |>self_id,0);... |
00003630  20 20 20 20 20 20 20 20  20 20 20 68 61 6e 64 6c  |           handl|
00003640  65 72 73 5f 61 74 74 61  63 68 65 64 3d 31 3b 0a  |ers_attached=1;.|
00003650  20 20 20 20 20 20 20 7d  0a 20 20 20 20 20 62 72  |       }.     br|
00003660  65 61 6b 3b 0a 0a 20 20  20 63 61 73 65 20 50 72  |eak;..   case Pr|
00003670  6f 67 49 6e 66 6f 5f 4f  62 6a 65 63 74 43 6c 61  |ogInfo_ObjectCla|
00003680  73 73 3a 0a 0a 20 20 20  20 20 20 70 72 6f 67 69  |ss:..      progi|
00003690  6e 66 6f 5f 73 65 74 5f  76 65 72 73 69 6f 6e 20  |nfo_set_version |
000036a0  28 30 2c 69 64 5f 62 6c  6f 63 6b 2d 3e 73 65 6c  |(0,id_block->sel|
000036b0  66 5f 69 64 2c 20 22 30  2e 30 32 20 22 20 5f 5f  |f_id, "0.02 " __|
000036c0  44 41 54 45 5f 5f 29 3b  0a 20 20 20 20 20 20 62  |DATE__);.      b|
000036d0  72 65 61 6b 3b 0a 0a 20  20 20 63 61 73 65 20 4d  |reak;..   case M|
000036e0  65 6e 75 5f 4f 62 6a 65  63 74 43 6c 61 73 73 3a  |enu_ObjectClass:|
000036f0  0a 20 20 20 20 20 20 69  66 20 28 73 74 72 63 6d  |.      if (strcm|
00003700  70 28 62 75 66 66 65 72  2c 22 4d 65 6e 75 22 29  |p(buffer,"Menu")|
00003710  3d 3d 30 29 0a 0a 20 20  20 20 20 20 20 20 20 20  |==0)..          |
00003720  20 20 20 7b 0a 0a 20 20  20 20 20 20 20 20 20 20  |   {..          |
00003730  20 74 6f 6f 6c 6d 65 6e  75 3d 69 64 5f 62 6c 6f  | toolmenu=id_blo|
00003740  63 6b 2d 3e 73 65 6c 66  5f 69 64 3b 0a 20 20 20  |ck->self_id;.   |
00003750  20 20 20 20 20 20 20 20  65 76 65 6e 74 5f 72 65  |        event_re|
00003760  67 69 73 74 65 72 5f 74  6f 6f 6c 62 6f 78 5f 68  |gister_toolbox_h|
00003770  61 6e 64 6c 65 72 28 69  64 5f 62 6c 6f 63 6b 2d  |andler(id_block-|
00003780  3e 73 65 6c 66 5f 69 64  2c 30 78 33 30 30 2c 68  |>self_id,0x300,h|
00003790  65 72 65 49 61 6d 2c 28  76 6f 69 64 2a 29 74 6f  |ereIam,(void*)to|
000037a0  6f 6c 6d 65 6e 75 29 3b  0a 20 20 20 20 20 20 20  |olmenu);.       |
000037b0  20 20 20 20 65 76 65 6e  74 5f 72 65 67 69 73 74  |    event_regist|
000037c0  65 72 5f 6d 65 73 73 61  67 65 5f 68 61 6e 64 6c  |er_message_handl|
000037d0  65 72 28 4d 65 73 73 61  67 65 5f 57 68 6f 73 41  |er(Message_WhosA|
000037e0  62 6f 75 74 2c 72 65 74  75 72 6e 65 64 5f 6d 65  |bout,returned_me|
000037f0  73 73 61 67 65 2c 28 76  6f 69 64 2a 29 74 6f 6f  |ssage,(void*)too|
00003800  6c 6d 65 6e 75 20 29 3b  0a 0a 20 20 20 20 20 20  |lmenu );..      |
00003810  20 20 20 20 20 20 20 7d  0a 20 20 20 20 69 66 20  |       }.    if |
00003820  28 28 73 74 72 63 6d 70  28 62 75 66 66 65 72 2c  |((strcmp(buffer,|
00003830  22 4d 61 69 6e 22 29 3d  3d 30 29 20 26 26 20 28  |"Main")==0) && (|
00003840  74 6f 6f 6c 6d 65 6e 75  21 3d 30 29 29 0a 0a 20  |toolmenu!=0)).. |
00003850  20 20 20 20 20 20 20 20  7b 0a 20 20 20 20 20 20  |        {.      |
00003860  20 20 20 6d 61 69 6e 6d  65 6e 75 3d 69 64 5f 62  |   mainmenu=id_b|
00003870  6c 6f 63 6b 2d 3e 73 65  6c 66 5f 69 64 3b 0a 20  |lock->self_id;. |
00003880  20 20 20 20 20 20 20 20  65 76 65 6e 74 5f 72 65  |        event_re|
00003890  67 69 73 74 65 72 5f 74  6f 6f 6c 62 6f 78 5f 68  |gister_toolbox_h|
000038a0  61 6e 64 6c 65 72 28 69  64 5f 62 6c 6f 63 6b 2d  |andler(id_block-|
000038b0  3e 73 65 6c 66 5f 69 64  2c 30 78 32 30 30 2c 73  |>self_id,0x200,s|
000038c0  65 74 75 70 5f 6d 65 6e  75 2c 28 76 6f 69 64 2a  |etup_menu,(void*|
000038d0  29 74 6f 6f 6c 6d 65 6e  75 29 3b 0a 20 20 20 20  |)toolmenu);.    |
000038e0  20 20 20 20 20 65 76 65  6e 74 5f 72 65 67 69 73  |     event_regis|
000038f0  74 65 72 5f 6d 65 73 73  61 67 65 5f 68 61 6e 64  |ter_message_hand|
00003900  6c 65 72 28 4d 65 73 73  61 67 65 5f 49 6d 48 65  |ler(Message_ImHe|
00003910  72 65 2c 57 68 6f 73 41  62 6f 75 74 5f 6d 65 73  |re,WhosAbout_mes|
00003920  73 61 67 65 2c 28 76 6f  69 64 2a 29 74 6f 6f 6c  |sage,(void*)tool|
00003930  6d 65 6e 75 29 3b 0a 20  20 20 20 20 20 20 20 20  |menu);.         |
00003940  65 76 65 6e 74 5f 72 65  67 69 73 74 65 72 5f 74  |event_register_t|
00003950  6f 6f 6c 62 6f 78 5f 68  61 6e 64 6c 65 72 28 2d  |oolbox_handler(-|
00003960  31 2c 30 78 35 30 30 2c  64 6f 5f 74 68 65 5f 66  |1,0x500,do_the_f|
00003970  72 65 65 2c 28 76 6f 69  64 2a 29 6d 61 69 6e 6d  |ree,(void*)mainm|
00003980  65 6e 75 29 3b 0a 20 20  20 20 20 20 20 20 20 65  |enu);.         e|
00003990  76 65 6e 74 5f 72 65 67  69 73 74 65 72 5f 74 6f  |vent_register_to|
000039a0  6f 6c 62 6f 78 5f 68 61  6e 64 6c 65 72 28 2d 31  |olbox_handler(-1|
000039b0  2c 30 78 35 30 31 2c 73  65 74 5f 73 74 61 74 75  |,0x501,set_statu|
000039c0  73 2c 28 76 6f 69 64 2a  29 6d 61 69 6e 6d 65 6e  |s,(void*)mainmen|
000039d0  75 29 3b 0a 20 20 20 20  20 20 20 20 20 7d 0a 0a  |u);.         }..|
000039e0  0a 20 20 20 20 20 20 62  72 65 61 6b 3b 0a 0a 0a  |.      break;...|
000039f0  20 20 7d 0a 0a 0a 20 20  72 65 74 75 72 6e 20 31  |  }...  return 1|
00003a00  3b 0a 7d 0a 0a 0a 0a 0a  0a 0a 0a 76 6f 69 64 20  |;.}........void |
00003a10  77 65 72 72 28 69 6e 74  20 66 61 74 61 6c 2c 20  |werr(int fatal, |
00003a20  63 68 61 72 2a 20 66 6f  72 6d 61 74 2c 20 2e 2e  |char* format, ..|
00003a30  2e 29 0a 7b 0a 20 20 20  76 61 5f 6c 69 73 74 20  |.).{.   va_list |
00003a40  76 61 3b 0a 20 20 20 5f  6b 65 72 6e 65 6c 5f 6f  |va;.   _kernel_o|
00003a50  73 65 72 72 6f 72 20 65  3b 0a 0a 20 20 20 65 2e  |serror e;..   e.|
00003a60  65 72 72 6e 75 6d 20 3d  20 30 3b 0a 20 20 20 76  |errnum = 0;.   v|
00003a70  61 5f 73 74 61 72 74 28  76 61 2c 20 66 6f 72 6d  |a_start(va, form|
00003a80  61 74 29 3b 0a 20 20 20  76 73 70 72 69 6e 74 66  |at);.   vsprintf|
00003a90  28 26 65 2e 65 72 72 6d  65 73 73 5b 30 5d 2c 20  |(&e.errmess[0], |
00003aa0  66 6f 72 6d 61 74 2c 20  76 61 29 3b 0a 20 20 20  |format, va);.   |
00003ab0  76 61 5f 65 6e 64 28 76  61 29 3b 0a 20 20 20 77  |va_end(va);.   w|
00003ac0  69 6d 70 5f 72 65 70 6f  72 74 5f 65 72 72 6f 72  |imp_report_error|
00003ad0  28 26 65 2c 20 30 2c 20  22 50 72 6f 63 65 73 73  |(&e, 0, "Process|
00003ae0  65 64 22 2c 30 2c 30 2c  30 29 3b 0a 20 20 20 69  |ed",0,0,0);.   i|
00003af0  66 20 28 66 61 74 61 6c  29 20 65 78 69 74 28 31  |f (fatal) exit(1|
00003b00  29 3b 0a 7d 0a 0a 0a 0a  2f 2a 0a 20 20 20 41 20  |);.}..../*.   A |
00003b10  6d 6f 75 73 65 20 62 75  74 74 6f 6e 20 68 61 73  |mouse button has|
00003b20  20 62 65 65 6e 20 70 72  65 73 73 65 64 2e 20 49  | been pressed. I|
00003b30  66 20 69 6e 20 70 6c 61  63 65 20 65 64 69 74 69  |f in place editi|
00003b40  6e 67 20 69 73 20 61 63  74 69 76 65 2c 20 70 61  |ng is active, pa|
00003b50  73 73 0a 20 20 20 74 68  65 20 6d 6f 75 73 65 20  |ss.   the mouse |
00003b60  63 6c 69 63 6b 20 74 6f  20 74 68 65 20 72 65 6d  |click to the rem|
00003b70  6f 74 65 2e 20 4f 74 68  65 72 77 69 73 65 2c 20  |ote. Otherwise, |
00003b80  6c 6f 6f 6b 20 66 6f 72  20 74 68 65 20 6b 65 79  |look for the key|
00003b90  62 6f 61 72 64 0a 20 20  20 73 68 6f 72 74 20 63  |board.   short c|
00003ba0  75 74 2e 0a 2a 2f 0a 0a  0a 69 6e 74 20 62 75 74  |ut..*/...int but|
00003bb0  74 6f 6e 28 69 6e 74 20  65 76 65 6e 74 5f 63 6f  |ton(int event_co|
00003bc0  64 65 2c 20 57 69 6d 70  50 6f 6c 6c 42 6c 6f 63  |de, WimpPollBloc|
00003bd0  6b 20 2a 65 76 65 6e 74  2c 49 64 42 6c 6f 63 6b  |k *event,IdBlock|
00003be0  20 2a 69 64 5f 62 6c 6f  63 6b 2c 76 6f 69 64 20  | *id_block,void |
00003bf0  2a 76 29 0a 7b 0a 0a 4f  62 6a 65 63 74 49 64 20  |*v).{..ObjectId |
00003c00  4f 69 64 3b 0a 0a 54 6f  6f 6c 62 6f 78 45 76 65  |Oid;..ToolboxEve|
00003c10  6e 74 20 74 3b 0a 4f 69  64 3d 28 4f 62 6a 65 63  |nt t;.Oid=(Objec|
00003c20  74 49 64 29 76 3b 0a 0a  69 66 28 48 4f 4f 4b 45  |tId)v;..if(HOOKE|
00003c30  44 29 0a 0a 7b 0a 0a 73  63 72 65 65 6e 5f 74 6f  |D)..{..screen_to|
00003c40  5f 73 70 72 69 74 65 28  28 57 69 6d 70 4d 6f 75  |_sprite((WimpMou|
00003c50  73 65 43 6c 69 63 6b 45  76 65 6e 74 20 2a 29 65  |seClickEvent *)e|
00003c60  76 65 6e 74 29 3b 0a 0a  65 76 65 6e 74 2d 3e 6d  |vent);..event->m|
00003c70  6f 75 73 65 5f 63 6c 69  63 6b 2e 77 69 6e 64 6f  |ouse_click.windo|
00003c80  77 5f 68 61 6e 64 6c 65  3d 68 6f 6f 6b 65 64 5f  |w_handle=hooked_|
00003c90  77 3b 0a 65 76 65 6e 74  2d 3e 6d 6f 75 73 65 5f  |w;.event->mouse_|
00003ca0  63 6c 69 63 6b 2e 69 63  6f 6e 5f 68 61 6e 64 6c  |click.icon_handl|
00003cb0  65 3d 2d 28 30 78 34 31  34 33 35 30 29 3b 0a 77  |e=-(0x414350);.w|
00003cc0  69 6d 70 5f 73 65 6e 64  5f 6d 65 73 73 61 67 65  |imp_send_message|
00003cd0  28 36 2c 65 76 65 6e 74  2c 74 61 73 6b 5b 68 6f  |(6,event,task[ho|
00003ce0  6f 6b 65 64 5f 74 5d 5b  30 5d 2c 30 2c 4e 55 4c  |oked_t][0],0,NUL|
00003cf0  4c 29 3b 0a 0a 0a 7d 0a  0a 65 6c 73 65 0a 7b 0a  |L);...}..else.{.|
00003d00  0a 20 20 20 69 66 20 28  61 6b 62 64 5f 70 6f 6c  |.   if (akbd_pol|
00003d10  6c 73 68 28 29 20 26 26  20 61 6b 62 64 5f 70 6f  |lsh() && akbd_po|
00003d20  6c 6c 63 74 6c 28 29 29  0a 20 20 20 7b 0a 20 20  |llctl()).   {.  |
00003d30  20 20 20 20 20 20 74 2e  68 64 72 2e 73 69 7a 65  |      t.hdr.size|
00003d40  3d 31 36 3b 0a 20 20 20  20 20 20 20 20 74 2e 68  |=16;.        t.h|
00003d50  64 72 2e 65 76 65 6e 74  5f 63 6f 64 65 3d 30 78  |dr.event_code=0x|
00003d60  32 30 30 3b 0a 20 20 20  20 20 20 20 20 74 2e 68  |200;.        t.h|
00003d70  64 72 2e 66 6c 61 67 73  3d 30 3b 0a 20 20 20 20  |dr.flags=0;.    |
00003d80  20 20 20 20 74 6f 6f 6c  62 6f 78 5f 72 61 69 73  |    toolbox_rais|
00003d90  65 5f 74 6f 6f 6c 62 6f  78 5f 65 76 65 6e 74 28  |e_toolbox_event(|
00003da0  30 2c 6d 61 69 6e 6d 65  6e 75 2c 4e 55 4c 4c 2c  |0,mainmenu,NULL,|
00003db0  26 74 29 3b 0a 20 20 20  20 20 20 20 20 53 48 4f  |&t);.        SHO|
00003dc0  52 54 43 55 54 3d 54 52  55 45 3b 0a 20 20 20 20  |RTCUT=TRUE;.    |
00003dd0  20 7d 0a 0a 7d 0a 0a 0a  0a 72 65 74 75 72 6e 28  | }..}....return(|
00003de0  54 52 55 45 29 3b 0a 7d  0a 0a 0a 2f 2a 0a 20 20  |TRUE);.}.../*.  |
00003df0  43 6f 6e 76 65 72 74 20  6d 6f 75 73 65 20 63 6f  |Convert mouse co|
00003e00  6f 72 64 69 6e 61 74 65  73 20 74 6f 20 61 6e 20  |ordinates to an |
00003e10  6f 66 73 65 74 20 69 6e  74 6f 20 74 68 65 20 73  |ofset into the s|
00003e20  70 72 69 74 65 2e 0a 2a  2f 0a 0a 0a 76 6f 69 64  |prite..*/...void|
00003e30  20 73 63 72 65 65 6e 5f  74 6f 5f 73 70 72 69 74  | screen_to_sprit|
00003e40  65 28 57 69 6d 70 4d 6f  75 73 65 43 6c 69 63 6b  |e(WimpMouseClick|
00003e50  45 76 65 6e 74 20 2a 20  63 29 0a 7b 0a 0a 57 69  |Event * c).{..Wi|
00003e60  6d 70 47 65 74 57 69 6e  64 6f 77 53 74 61 74 65  |mpGetWindowState|
00003e70  42 6c 6f 63 6b 20 73 74  61 74 65 3b 0a 69 6e 74  |Block state;.int|
00003e80  20 78 2c 79 3b 0a 0a 0a  0a 73 74 61 74 65 2e 77  | x,y;....state.w|
00003e90  69 6e 64 6f 77 5f 68 61  6e 64 6c 65 20 3d 20 63  |indow_handle = c|
00003ea0  2d 3e 77 69 6e 64 6f 77  5f 68 61 6e 64 6c 65 3b  |->window_handle;|
00003eb0  0a 77 69 6d 70 5f 67 65  74 5f 77 69 6e 64 6f 77  |.wimp_get_window|
00003ec0  5f 73 74 61 74 65 28 26  73 74 61 74 65 29 3b 0a  |_state(&state);.|
00003ed0  0a 78 20 3d 20 28 73 74  61 74 65 2e 76 69 73 69  |.x = (state.visi|
00003ee0  62 6c 65 5f 61 72 65 61  2e 78 6d 69 6e 20 2d 20  |ble_area.xmin - |
00003ef0  73 74 61 74 65 2e 78 73  63 72 6f 6c 6c 29 3b 0a  |state.xscroll);.|
00003f00  79 20 3d 20 28 73 74 61  74 65 2e 76 69 73 69 62  |y = (state.visib|
00003f10  6c 65 5f 61 72 65 61 2e  79 6d 61 78 20 2d 20 73  |le_area.ymax - s|
00003f20  74 61 74 65 2e 79 73 63  72 6f 6c 6c 29 3b 0a 0a  |tate.yscroll);..|
00003f30  0a 0a 63 2d 3e 6d 6f 75  73 65 5f 78 2d 3d 78 3b  |..c->mouse_x-=x;|
00003f40  0a 63 2d 3e 6d 6f 75 73  65 5f 79 3d 79 2d 63 2d  |.c->mouse_y=y-c-|
00003f50  3e 6d 6f 75 73 65 5f 79  3b 0a 63 2d 3e 6d 6f 75  |>mouse_y;.c->mou|
00003f60  73 65 5f 79 3d 33 39 38  2d 63 2d 3e 6d 6f 75 73  |se_y=398-c->mous|
00003f70  65 5f 79 3b 0a 0a 0a 0a  7d 0a 0a 0a 0a 0a 0a 0a  |e_y;....}.......|
00003f80  69 6e 74 20 72 65 64 72  61 77 5f 77 69 6e 64 6f  |int redraw_windo|
00003f90  77 28 69 6e 74 20 65 76  65 6e 74 5f 63 6f 64 65  |w(int event_code|
00003fa0  2c 20 57 69 6d 70 50 6f  6c 6c 42 6c 6f 63 6b 20  |, WimpPollBlock |
00003fb0  2a 65 76 65 6e 74 2c 49  64 42 6c 6f 63 6b 20 2a  |*event,IdBlock *|
00003fc0  69 64 5f 62 6c 6f 63 6b  2c 76 6f 69 64 20 2a 76  |id_block,void *v|
00003fd0  29 0a 7b 0a 20 20 20 69  6e 74 20 6d 6f 72 65 2c  |).{.   int more,|
00003fe0  68 65 69 67 68 74 2c 78  2c 79 3b 0a 20 20 20 57  |height,x,y;.   W|
00003ff0  69 6d 70 47 65 74 57 69  6e 64 6f 77 53 74 61 74  |impGetWindowStat|
00004000  65 42 6c 6f 63 6b 20 73  74 61 74 65 3b 0a 20 20  |eBlock state;.  |
00004010  20 57 69 6d 70 52 65 64  72 61 77 57 69 6e 64 6f  | WimpRedrawWindo|
00004020  77 42 6c 6f 63 6b 20 62  6c 6f 63 6b 3b 0a 20 20  |wBlock block;.  |
00004030  20 42 42 6f 78 20 65 78  74 65 6e 74 3b 0a 0a 0a  | BBox extent;...|
00004040  20 20 20 73 74 61 74 65  2e 77 69 6e 64 6f 77 5f  |   state.window_|
00004050  68 61 6e 64 6c 65 20 3d  20 65 76 65 6e 74 2d 3e  |handle = event->|
00004060  72 65 64 72 61 77 5f 77  69 6e 64 6f 77 5f 72 65  |redraw_window_re|
00004070  71 75 65 73 74 2e 77 69  6e 64 6f 77 5f 68 61 6e  |quest.window_han|
00004080  64 6c 65 3b 0a 20 20 20  62 6c 6f 63 6b 2e 77 69  |dle;.   block.wi|
00004090  6e 64 6f 77 5f 68 61 6e  64 6c 65 20 3d 20 65 76  |ndow_handle = ev|
000040a0  65 6e 74 2d 3e 72 65 64  72 61 77 5f 77 69 6e 64  |ent->redraw_wind|
000040b0  6f 77 5f 72 65 71 75 65  73 74 2e 77 69 6e 64 6f  |ow_request.windo|
000040c0  77 5f 68 61 6e 64 6c 65  3b 0a 0a 20 20 20 77 69  |w_handle;..   wi|
000040d0  6d 70 5f 67 65 74 5f 77  69 6e 64 6f 77 5f 73 74  |mp_get_window_st|
000040e0  61 74 65 28 26 73 74 61  74 65 29 3b 0a 0a 20 20  |ate(&state);..  |
000040f0  20 77 69 6e 64 6f 77 5f  67 65 74 5f 65 78 74 65  | window_get_exte|
00004100  6e 74 28 30 2c 20 73 74  61 74 65 2e 77 69 6e 64  |nt(0, state.wind|
00004110  6f 77 5f 68 61 6e 64 6c  65 2c 26 65 78 74 65 6e  |ow_handle,&exten|
00004120  74 29 3b 0a 20 20 20 68  65 69 67 68 74 20 3d 20  |t);.   height = |
00004130  65 78 74 65 6e 74 2e 79  6d 61 78 20 2d 65 78 74  |extent.ymax -ext|
00004140  65 6e 74 2e 79 6d 69 6e  3b 0a 0a 0a 20 20 20 78  |ent.ymin;...   x|
00004150  20 3d 20 28 73 74 61 74  65 2e 76 69 73 69 62 6c  | = (state.visibl|
00004160  65 5f 61 72 65 61 2e 78  6d 69 6e 20 2d 20 73 74  |e_area.xmin - st|
00004170  61 74 65 2e 78 73 63 72  6f 6c 6c 29 3b 0a 20 20  |ate.xscroll);.  |
00004180  20 79 20 3d 20 28 73 74  61 74 65 2e 76 69 73 69  | y = (state.visi|
00004190  62 6c 65 5f 61 72 65 61  2e 79 6d 61 78 20 2d 20  |ble_area.ymax - |
000041a0  73 74 61 74 65 2e 79 73  63 72 6f 6c 6c 29 3b 0a  |state.yscroll);.|
000041b0  0a 20 20 20 77 69 6d 70  5f 72 65 64 72 61 77 5f  |.   wimp_redraw_|
000041c0  77 69 6e 64 6f 77 28 26  62 6c 6f 63 6b 2c 26 6d  |window(&block,&m|
000041d0  6f 72 65 29 3b 0a 20 20  20 77 68 69 6c 65 20 28  |ore);.   while (|
000041e0  6d 6f 72 65 29 0a 20 20  20 7b 0a 20 20 20 20 20  |more).   {.     |
000041f0  20 69 66 28 73 70 62 6c  6f 63 6b 21 3d 4e 55 4c  | if(spblock!=NUL|
00004200  4c 29 20 73 70 72 69 74  65 5f 70 75 74 5f 69 6e  |L) sprite_put_in|
00004210  5f 63 75 72 72 65 6e 74  28 73 70 62 6c 6f 63 6b  |_current(spblock|
00004220  2c 20 26 69 64 2c 20 30  2c 78 2c 20 79 2d 33 39  |, &id, 0,x, y-39|
00004230  38 29 3b 0a 0a 0a 20 20  20 20 20 20 20 77 69 6d  |8);...       wim|
00004240  70 5f 67 65 74 5f 72 65  63 74 61 6e 67 6c 65 20  |p_get_rectangle |
00004250  28 26 62 6c 6f 63 6b 2c  26 6d 6f 72 65 29 3b 0a  |(&block,&more);.|
00004260  20 20 20 7d 0a 0a 20 20  20 72 65 74 75 72 6e 20  |   }..   return |
00004270  31 3b 0a 7d 0a 0a 0a 0a  0a 69 6e 74 20 75 70 64  |1;.}.....int upd|
00004280  61 74 65 5f 77 69 6e 64  6f 77 28 69 6e 74 20 77  |ate_window(int w|
00004290  5f 68 61 6e 64 6c 65 2c  42 42 6f 78 20 2a 62 6f  |_handle,BBox *bo|
000042a0  78 29 0a 7b 0a 20 20 20  69 6e 74 20 6d 6f 72 65  |x).{.   int more|
000042b0  2c 78 2c 79 3b 0a 20 20  20 57 69 6d 70 47 65 74  |,x,y;.   WimpGet|
000042c0  57 69 6e 64 6f 77 53 74  61 74 65 42 6c 6f 63 6b  |WindowStateBlock|
000042d0  20 73 74 61 74 65 3b 0a  20 20 20 57 69 6d 70 52  | state;.   WimpR|
000042e0  65 64 72 61 77 57 69 6e  64 6f 77 42 6c 6f 63 6b  |edrawWindowBlock|
000042f0  20 62 6c 6f 63 6b 3b 0a  0a 20 20 20 73 74 61 74  | block;..   stat|
00004300  65 2e 77 69 6e 64 6f 77  5f 68 61 6e 64 6c 65 20  |e.window_handle |
00004310  3d 20 77 5f 68 61 6e 64  6c 65 3b 0a 20 20 20 77  |= w_handle;.   w|
00004320  69 6d 70 5f 67 65 74 5f  77 69 6e 64 6f 77 5f 73  |imp_get_window_s|
00004330  74 61 74 65 28 26 73 74  61 74 65 29 3b 0a 0a 20  |tate(&state);.. |
00004340  20 20 78 20 3d 20 28 73  74 61 74 65 2e 76 69 73  |  x = (state.vis|
00004350  69 62 6c 65 5f 61 72 65  61 2e 78 6d 69 6e 20 2d  |ible_area.xmin -|
00004360  20 73 74 61 74 65 2e 78  73 63 72 6f 6c 6c 29 3b  | state.xscroll);|
00004370  0a 20 20 20 79 20 3d 20  28 73 74 61 74 65 2e 76  |.   y = (state.v|
00004380  69 73 69 62 6c 65 5f 61  72 65 61 2e 79 6d 61 78  |isible_area.ymax|
00004390  20 2d 20 73 74 61 74 65  2e 79 73 63 72 6f 6c 6c  | - state.yscroll|
000043a0  29 3b 0a 0a 20 20 20 62  6c 6f 63 6b 2e 77 69 6e  |);..   block.win|
000043b0  64 6f 77 5f 68 61 6e 64  6c 65 3d 77 5f 68 61 6e  |dow_handle=w_han|
000043c0  64 6c 65 3b 0a 20 20 20  62 6c 6f 63 6b 2e 76 69  |dle;.   block.vi|
000043d0  73 69 62 6c 65 5f 61 72  65 61 2e 78 6d 69 6e 3d  |sible_area.xmin=|
000043e0  62 6f 78 2d 3e 78 6d 69  6e 3b 0a 20 20 20 62 6c  |box->xmin;.   bl|
000043f0  6f 63 6b 2e 76 69 73 69  62 6c 65 5f 61 72 65 61  |ock.visible_area|
00004400  2e 78 6d 61 78 3d 62 6f  78 2d 3e 78 6d 61 78 3b  |.xmax=box->xmax;|
00004410  0a 20 20 20 62 6c 6f 63  6b 2e 76 69 73 69 62 6c  |.   block.visibl|
00004420  65 5f 61 72 65 61 2e 79  6d 69 6e 3d 62 6f 78 2d  |e_area.ymin=box-|
00004430  3e 79 6d 69 6e 3b 0a 20  20 20 62 6c 6f 63 6b 2e  |>ymin;.   block.|
00004440  76 69 73 69 62 6c 65 5f  61 72 65 61 2e 79 6d 61  |visible_area.yma|
00004450  78 3d 62 6f 78 2d 3e 79  6d 61 78 3b 0a 0a 0a 0a  |x=box->ymax;....|
00004460  20 20 20 77 69 6d 70 5f  75 70 64 61 74 65 5f 77  |   wimp_update_w|
00004470  69 6e 64 6f 77 28 26 62  6c 6f 63 6b 2c 26 6d 6f  |indow(&block,&mo|
00004480  72 65 29 3b 0a 20 20 20  77 68 69 6c 65 20 28 6d  |re);.   while (m|
00004490  6f 72 65 29 0a 20 20 20  7b 0a 20 20 20 20 20 20  |ore).   {.      |
000044a0  69 66 28 73 70 62 6c 6f  63 6b 21 3d 4e 55 4c 4c  |if(spblock!=NULL|
000044b0  29 20 73 70 72 69 74 65  5f 70 75 74 5f 69 6e 5f  |) sprite_put_in_|
000044c0  63 75 72 72 65 6e 74 28  73 70 62 6c 6f 63 6b 2c  |current(spblock,|
000044d0  20 26 69 64 2c 20 30 2c  78 2c 20 79 2d 33 39 38  | &id, 0,x, y-398|
000044e0  29 3b 0a 0a 0a 20 20 20  20 20 20 20 77 69 6d 70  |);...       wimp|
000044f0  5f 67 65 74 5f 72 65 63  74 61 6e 67 6c 65 20 28  |_get_rectangle (|
00004500  26 62 6c 6f 63 6b 2c 26  6d 6f 72 65 29 3b 0a 20  |&block,&more);. |
00004510  20 20 7d 0a 0a 20 20 20  72 65 74 75 72 6e 20 31  |  }..   return 1|
00004520  3b 0a 7d 0a 0a 0a 76 6f  69 64 20 6f 73 5f 62 79  |;.}...void os_by|
00004530  74 65 28 69 6e 74 20 63  6f 64 65 2c 69 6e 74 20  |te(int code,int |
00004540  2a 20 78 2c 69 6e 74 20  2a 79 29 0a 7b 0a 5f 73  |* x,int *y).{._s|
00004550  77 69 28 4f 53 5f 42 79  74 65 2c 5f 49 4e 28 30  |wi(OS_Byte,_IN(0|
00004560  29 7c 5f 49 4e 28 31 29  7c 5f 49 4e 28 32 29 7c  |)|_IN(1)|_IN(2)||
00004570  5f 4f 55 54 28 31 29 7c  5f 4f 55 54 28 32 29 2c  |_OUT(1)|_OUT(2),|
00004580  63 6f 64 65 2c 2a 78 2c  2a 79 2c 78 2c 79 29 3b  |code,*x,*y,x,y);|
00004590  0a 7d 0a 0a 0a 69 6e 74  20 61 6b 62 64 5f 70 6f  |.}...int akbd_po|
000045a0  6c 6c 73 68 28 76 6f 69  64 29 0a 7b 0a 20 20 69  |llsh(void).{.  i|
000045b0  6e 74 20 78 20 3d 20 2d  31 3b 0a 20 20 69 6e 74  |nt x = -1;.  int|
000045c0  20 79 20 3d 20 32 35 35  3b 0a 20 20 6f 73 5f 62  | y = 255;.  os_b|
000045d0  79 74 65 28 31 32 39 2c  20 26 78 2c 20 26 79 29  |yte(129, &x, &y)|
000045e0  3b 0a 20 20 72 65 74 75  72 6e 28 78 3d 3d 32 35  |;.  return(x==25|
000045f0  35 20 26 26 20 79 3d 3d  32 35 35 29 3b 0a 7d 0a  |5 && y==255);.}.|
00004600  0a 69 6e 74 20 61 6b 62  64 5f 70 6f 6c 6c 63 74  |.int akbd_pollct|
00004610  6c 28 76 6f 69 64 29 0a  7b 0a 20 20 69 6e 74 20  |l(void).{.  int |
00004620  78 20 3d 20 2d 32 3b 0a  20 20 69 6e 74 20 79 20  |x = -2;.  int y |
00004630  3d 20 32 35 35 3b 0a 20  20 6f 73 5f 62 79 74 65  |= 255;.  os_byte|
00004640  28 31 32 39 2c 20 26 78  2c 20 26 79 29 3b 0a 20  |(129, &x, &y);. |
00004650  20 72 65 74 75 72 6e 28  78 3d 3d 32 35 35 20 26  | return(x==255 &|
00004660  26 20 79 3d 3d 32 35 35  29 3b 0a 7d 0a 0a 0a 0a  |& y==255);.}....|
00004670  0a                                                |.|
00004671