/*
    ####             #    #     # #
    #   #            #    #       #          The FreeWare C library for 
    #   #  ##   ###  #  # #     # ###             RISC OS machines
    #   # #  # #     # #  #     # #  #   ___________________________________
    #   # ####  ###  ##   #     # #  #                                      
    #   # #        # # #  #     # #  #    Please refer to the accompanying
    ####   ### ####  #  # ##### # ###    documentation for conditions of use
    ________________________________________________________________________

    File:    PopUp.Show.c
    Author:  Copyright  1993 Jason Williams
    Version: 1.00 (20 May 1993)
    Purpose: High(er)-level support for opening PopUps
*/


#include <string.h>

#include "Desk.WimpSWIs.h"
#include "Desk.PopUp.h"

static Desk_popup_handle DoShow(Desk_popup_block *block, char *name,
                           Desk_popup_data *definition)
{
  strcpy(block->header.name, name);
  memcpy(&block->data, definition, sizeof(Desk_popup_data));
  block->header.reserved1 = block->header.reserved2 =
                            block->header.reserved3 = 0;
  return(Desk_PopUp_Open(block));
}


extern Desk_popup_handle Desk_PopUp_ShowPtr(char *name, Desk_bool isstatic,
                                  Desk_popup_data *definition)
{
  Desk_popup_block temp;
  Desk_mouse_block ptr;

  Desk_Wimp_GetPointerInfo(&ptr);
  temp.header.openpos.x = ptr.pos.x - 64;
  temp.header.openpos.y = ptr.pos.y + 64;
  if (isstatic)
    temp.header.flags = Desk_popup_STATIC;
  else
    temp.header.flags = Desk_popup_STANDALONE;
  return(DoShow(&temp, name, definition));
}


extern Desk_popup_handle Desk_PopUp_ShowMenuLeaf(char *name, Desk_popup_data *definition,
                                       Desk_message_menuwarn *msg)
{
  Desk_popup_block temp;

  temp.header.openpos = msg->openpos;
  temp.header.flags = Desk_popup_MENULEAF;
  return(DoShow(&temp, name, definition));
}
