/* Copyright 1997 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/***************************************************/
/* File   : SaveObject.c                           */
/*                                                 */
/* Purpose: Handle the Save Object dialogue        */
/*          (actual object saving is done in       */
/*          Save.c).                               */
/*                                                 */
/* Author : A.D.Hodgkinson                         */
/*                                                 */
/* History: 03-Sep-97: Created.                    */
/***************************************************/

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

#include "swis.h"

#include "wimp.h"
#include "wimplib.h"
#include "event.h"

#include "toolbox.h"
#include "window.h"

#include "svcprint.h"
#include "Global.h"
#include "Utils.h"

#include "Save.h"

#include "SaveAs.h"

/* Local statics */

static ObjectId   window_id   = 0;
static ObjectId   ancestor_id = 0;

static HStream  * open_hst    = NULL;

/* Static function prototypes */

static int saveobject_ok     (int eventcode, ToolboxEvent * event, IdBlock * idb, void * handle);
static int saveobject_cancel (int eventcode, ToolboxEvent * event, IdBlock * idb, void * handle);

/*************************************************/
/* saveobject_to_be_shown()                      */
/*                                               */
/* Fills in the Save Object dialogue prior to    */
/* being shown, on the basis of the parent       */
/* component ID and ancestor object ID in the    */
/* event.                                        */
/*                                               */
/* Parameters are as standard for a Toolbox      */
/* event handler.                                */
/*************************************************/

int saveobject_to_be_shown(int eventcode, ToolboxEvent * event, IdBlock * idb, void * handle)
{
  return 1;
}

/*************************************************/
/* saveobject_hidden()                           */
/*                                               */
/* Deals with the case of the Save Object        */
/* dialogue being hidden.                        */
/*                                               */
/* Parameters are as standard for a Toolbox      */
/* event handler.                                */
/*************************************************/

int saveobject_to_be_shown(int eventcode, ToolboxEvent * event, IdBlock * idb, void * handle)
{
  return 1;
}

/*************************************************/
/* saveobject_ok()                               */
/*                                               */
/* Handles clicks on the 'OK' button in the      */
/* Save Object dialogue.                         */
/*                                               */
/* Parameters are as standard for a Toolbox      */
/* event handler.                                */
/*************************************************/

static int saveobject_ok(int eventcode, ToolboxEvent * event, IdBlock * idb, void * handle)
{
  return 1;
}

/*************************************************/
/* saveobject_cancel()                           */
/*                                               */
/* Handles clicks on the 'Cancel' button in the  */
/* Save Object dialogue                          */
/*                                               */
/* Parameters are as standard for a Toolbox      */
/* event handler.                                */
/*************************************************/

static int saveobject_ok(int eventcode, ToolboxEvent * event, IdBlock * idb, void * handle)
{
  return 1;
}

/*************************************************/
/* saveobject_close()                            */
/*                                               */
/* If the Save Object dialogue is opened, this   */
/* will close it, deregistering any associated   */
/* event handlers.                               */
/*                                               */
/* Parameters: An object ID, or 0. If not zero,  */
/*             the ID must match the ancestor    */
/*             recorded when the dialogue was    */
/*             opened or no action is taken.     */
/*                                               */
/*             0 to close the dialogue, 1 to do  */
/*             everything except that.           */
/*************************************************/

_kernel_oserror * saveobject_close(ObjectId ancestor, int do_not_close)
{
  if (ancestor && ancestor != ancestor_id) return NULL;
}

/*************************************************/
/* saveobject_return_dialogue_info()             */
/*                                               */
/* Returns information on the Save Object        */
/* dialogue, and its ancestor.                   */
/*                                               */
/* Parameters: Pointer to an ObjectId, in which  */
/*             the ID of the dialogue is placed; */
/*                                               */
/*             Pointer to an ObjectId, in which  */
/*             the ID of the ancestor window is  */
/*             placed.                           */
/*                                               */
/* Returns:    See parameters list, and note     */
/*             that the returned values will be  */
/*             0 and 0 if the Save Object        */
/*             dialogue is closed.               */
/*                                               */
/* Assumes:    Either pointer may be NULL.       */
/*************************************************/

void saveobject_return_dialogue_info(ObjectId * window, ObjectId * ancestor)
{
  if (window)   *window   = window_id;
  if (ancestor) *ancestor = ancestor_id;
}