/* Copyright (C) Acorn Computers Ltd 1994 */

/* include standard C definitions */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "kernel.h"
#include "swis.h"

/* include event lib declarations */

#include "event.h"

/* include toolbox lib declarations */

#include "toolbox.h"
#include "fileinfo.h"
#include "comps.h"
#include "wimplib.h"
#include "wimp.h"

/* include application definitions */

#include "hyper.h"
#include "button.h"
#include "draw.h"
#include "events.h"
#include "utils.h"
#include "file.h"
#include "view.h"

Viewer *load_hcl_file(char *name)
{
  return new_viewer(name);
}

int file_loader(WimpMessage *message, void *handle)
{
        /* only interested in HCL files */
  WimpMessage msg;
  IGNORE(handle);

  if (message->data.data_open.file_type != 0xfac) return 0;

  msg = *message;

  msg.hdr.your_ref = msg.hdr.my_ref;

  load_hcl_file(msg.data.data_load_ack.leaf_name);

  if (message->hdr.action_code == Wimp_MDataLoad)
      msg.hdr.action_code = Wimp_MDataLoadAck;
  wimp_send_message(Wimp_EUserMessage, &msg, msg.hdr.sender,0,0);

  return 1;
}

int commands_size(Viewer *view);

int fileinfo_show(int event_code, ToolboxEvent  *event, IdBlock *id_block,
                   void  *handle)
{
    Viewer *view ;

    IGNORE(handle);
    IGNORE(event);
    IGNORE(event_code);

    toolbox_get_client_handle(0,id_block->ancestor_id, (void **) &view);

    fileinfo_set_modified(0,id_block->self_id,view->flags & ViewerFlag_FileModified);
    fileinfo_set_file_name(0,id_block->self_id,view->filename);
    fileinfo_set_file_size(0,id_block->self_id,commands_size(view));

    return 1;
}


