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

    File:    Dialog.Show.c
    Author:  Copyright  1993 Tim Browse and Jason Williams
    Version: 1.00 (10 Jul 1993)
    Purpose: Very high level window (dialogue) handling -
             Showing non-permanent (menu) dialogues
*/


#include "Desk.Wimp.h"
#include "Desk.WimpSWIs.h"

#include "Desk.Dialog.h"
#include "Desk.Screen.h"


extern void Desk_Dialog_Show(dialog dbox)
/* Open the window in the centre of the screen as a menu */
{
  Desk_window_state  state;
  Desk_wimp_point    Desk_win_size, pos;

  dbox->state.isstatic = Desk_bool_FALSE;

  /* Get the window size */
  Desk_Wimp_eGetWindowState(dbox->window, &state);
  Desk_win_size.x = state.openblock.screenrect.max.x -
                 state.openblock.screenrect.min.x;
  Desk_win_size.y = state.openblock.screenrect.max.y -
                 state.openblock.screenrect.min.y;

  /*  Open it as a Menu so that clicks outside it and hitting escape will
   *  close it. Open it in the centre of the screen
   */
  pos.x = (Desk_screen_size.x - Desk_win_size.x) / 2;
  pos.y = (Desk_screen_size.y + Desk_win_size.y) / 2;
  Desk_Wimp_eCreateMenu((Desk_menu_block *) dbox->window, pos.x, pos.y);

  dbox->state.stillopen = Desk_bool_TRUE;
}

