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

    File:    Menu.PopUp.c
    Author:  Copyright  1994 Tony Houghton
    Version: 1.00 (25 Sep 1994)
    Purpose: Pop up a menu to the right of a button icon.
*/

#include "Desk.Menu.h"
#include "Desk.WimpSWIs.h"
#include "Desk.Coord.h"


void Desk_Menu_PopUp(Desk_menu_ptr menu, Desk_window_handle window, Desk_icon_handle icon)
{
  Desk_window_state wstate;
  Desk_icon_block istate;

  /* Find position of icon on screen */
  Desk_Wimp_eGetWindowState(window, &wstate);
  Desk_Wimp_eGetIconState(window, icon, &istate);
  Desk_Coord_PointToScreen(&istate.workarearect.max,
                      (Desk_convert_block *) &wstate.openblock.screenrect);

  /* Open menu here (Desk_Menu_Show subtracts 64 from X xoord) */
  Desk_Menu_Show(menu, istate.workarearect.max.x+64, istate.workarearect.max.y);
}
