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

    File:    Pane2.SetVars.c
    Author:  Copyright  1995 Andrew Sellors.
    Version: 1.04 (4th August 1995)
    Purpose: Handles windows with panes.
*/

#include "DeskLib:Pane2.h"
#include "Pane2Defs.h"
#include "Desklib:Event.h"
#include "Desk.Template.h"
#include "Desklib:EventMsg.h"
#include "Desklib:Error.h"

#include <stdlib.h>


/******************************************************************************/

extern Desk_bool Desk_Pane2_SetVars(Desk_window_handle mainwindow, int panenumber,
                           const Desk_wimp_point *paneoffset, const Desk_wimp_point *panesize)
{
 /*
  * Sets paneoffset if 'paneoffset' is not NULL and panesize if 'panesize' is
  * not NULL for the 'panenumber'th pane attatched to 'mainwindow'.
  * Desk_bool_TRUE is returned for success.
  * After changing the variables, Desk_Pane2_OpenWindow must be used to make the
  * windows on screen exhibit the changes.
  */
  Desk_main_listelement *mainelement;
  Desk_pane_listelement *paneelement;

 /*
  * find element for main window and return Desk_bool_FALSE if mainwindow not present
  */
  mainelement = Desk_Pane2__FindMainWindow(mainwindow);
  if(mainelement == NULL)
     return(Desk_bool_FALSE); /* not found */

 /*
  * find first pane window
  */
  paneelement = Desk_LinkList_FirstItem(&(mainelement->paneanchor));

  paneelement = Desk_Pane2__FindPaneWindow(mainelement, panenumber);

  if(paneelement != NULL){

     if(paneoffset != NULL)
         paneelement->paneoffset = *paneoffset;

     if(panesize != NULL)
         paneelement->panesize = *panesize;

     return(Desk_bool_TRUE);

  }
  else
    return(Desk_bool_FALSE); /* not found */

}
