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

    File:    Pane2.h
    Author:  Copyright  1995 Andrew Sellors.
    Version: 1.04 (4th August 1995)
    Purpose: Handles windows with panes.
    Mods:    1.02 -> 1.04
             Added pane2_MAINRIGHT, Pane2_GetMainHandle, Pane2_GetPaneNumber, 
             Pane2_OpenWindow, Pane2_ReadVars, Pane2_SetVars.
*/
/*
   NOTES:

   pane2_PANETOP   attaches the pane to the main window using the top left of the pane
                   window rather than the bottom left corner.
   pane2_MAINTOP   makes the pane move relative to the top of the main window rather than
                   the bottom corner.
   pane2_MAINRIGHT makes the pane move relative to the right of the main window rather
                   than the left.
   pane2_FIXED     forces the offset between the pane and the main windows to be constant,
                   the pane is not allowed to move relative, with it off you get !ArtWork
                   style pane windows.
   pane2_HRESIZE   makes the right and side of the pane be cliped to the right hand side
                   of the main window if the main window is smaller than the pane.
   pane2_HSTRETCH  when used in conjunction with pane2_HRESIZE makes the right hand side
                   of the pane always follow the right hand side of the main window.
   pane2_VRESIZE   is like pane2_HREISZE except in the horizontal direction.
   pane2_VSTRETCH  is like pane2_HSTRETCH except in the horizontal direction.
   pane2_HSCROLL   makes the pane scroll with the main window in the horizontal direction.
   pane2_VSCROLL   makes the pane scroll with the main window in the vertical direction.
    
*/

#ifndef __dl_pane2_h
#define __dl_pane2_h

#ifdef __cplusplus
extern "C" {
#endif

#ifndef __dl_wimpswis_h
#include "WimpSWIs.h"
#endif

#ifndef __dl_window_h
#include "Window.h"
#endif

#ifndef __dl_core_h
#include "Core.h"
#endif

#ifndef __dl_wimp_h
#include "Wimp.h"
#endif


typedef union {
    int value;
    struct {
      unsigned int panetop   :1; /* pane is linked using the top of the pane window */
                                /* else bottom is used */
      unsigned int maintop   :1; /* pane is fixed to top of main else fixed to bottom */
      unsigned int fixed     :1; /* pane cannot be moved relative to main window */
      unsigned int hresize   :1; /* pane is resized to match width of main window up to */
                                /* pane width */
      unsigned int hstretch  :1; /* pane width is ignored when resizing */
      unsigned int vresize   :1; /* pane is resized to match height of main window up */
                                /* to pane height */
      unsigned int vstretch  :1; /* pane height is ignored when resizing */
      unsigned int hscroll   :1; /* pane scrolls horizontally with the main window */
      unsigned int vscroll   :1; /* pane scrolls vertically with the main window */
      unsigned int mainright :1; /* pane is fixed to right of main instead of left */
      unsigned int dummy     :22;
    } data;
} pane2_flags;

#define pane2_PANETOP   0x0001
#define pane2_MAINTOP   0x0002
#define pane2_FIXED     0x0004
#define pane2_HRESIZE   0x0008
#define pane2_HSTRETCH  0x0010
#define pane2_VRESIZE   0x0020
#define pane2_VSTRETCH  0x0040
#define pane2_HSCROLL   0x0080
#define pane2_VSCROLL   0x0100
#define pane2_MAINRIGHT 0x0200

 /*
  * initialises 'mainwindow' with the library as a main window that can have
  * panes attached to it.
  */
extern BOOL Pane2_AddMain(window_handle mainwindow);


 /*
  * Creates window as Window_Create and initialises it with the library as a
  * main window that can have panes attached to it.
  * The window handle is returned or 0 if window cannot be created.
  */
extern window_handle Pane2_CreateAndAddMain(char *windowname, int maxtitlesize);


 /*
  * Adds the pane window 'panewindow' to the main window 'mainwindow'.
  * If 'paneoffset' is not NULL then this is taken as the offset between the
  * pane and the main window instead of the positions in the template.
  * If 'panesize' is not NULL then this is taken as the size of the pane
  * instead of the size in the template.
  */
extern BOOL Pane2_AddPane(window_handle mainwindow, window_handle panewindow,
                          wimp_point *paneoffset, wimp_point *panesize, int flags);


 /*
  * Creates pane window as Window_Create and adds to the main window
  * 'mainwindow'.
  * If 'paneoffset' is not NULL then this is taken as the offset between the
  * pane and the main window instead of the positions in the template.
  * If 'panesize' is not NULL then this is taken as the size of the pane
  * instead of the size in the template.
  * The window handle is returned or 0 if window cannot be created.
  */
extern window_handle Pane2_CreateAndAddPane(char *windowname, int maxtitlesize,
                                            window_handle mainwindow,
                                            wimp_point *paneoffset,
                                            wimp_point *panesize,
                                            int flags);


 /*
  * Opens the main window 'mainwindow' and all it's attached pane windows
  * according to 'openpos'
  * Use in the same manner to Window_Show
  */
extern void Pane2_Show(window_handle mainwindow, window_openpos openpos);


 /*
  * Closes the window 'mainwindow' (removes it from screen) and all it's panes
  * Use in the same manner to Window_Hide
  */
extern void Pane2_Hide(window_handle mainwindow);


 /*
  * This hides and deletes the window 'mainwindow' and all it's panes
  * Use in the same manner to Window_Delete
  */
extern void Pane2_Delete(window_handle mainwindow);


 /*
  * Calculates the pane offset and size so that the pane will be in the same
  * position and size as the icon in the window.
  * If 'panewindow' is the name of the pane window in the template file then the
  * presence of any scroll bars or the window title bar is taken into accound
  * when calculating the position and size of the pane, set it to NULL and no
  * action is taken.
  * Need to use pane2_MAINTOP and pane2_PANETOP flags.
  */
extern void Pane2_ReadIcon(window_handle window, icon_handle icon, char *panewindow,
                           wimp_point *paneoffset, wimp_point *panesize);

 /*
  * Sets flags of 'panenumber'th pane attached to the window 'main' or NULL
  * if the 'panenumber' is invalid.
  * First pane is number 1.
  * Returns flags and if 'flags' is -1 then they are left unchanged
  */
extern int Pane2_SetFlags(window_handle mainwindow, int panenumber, int flags);


 /*
  * Returns window handle of 'panenumber'th pane attached to the window 'main'
  * or 0 if not found.
  */
extern window_handle Pane2_GetPaneHandle(window_handle mainwindow, int panenumber);


 /*
  * Returns window handle of main window which 'panewindow' is attached to
  * or 0 if not found.
  */
extern window_handle Pane2_GetMainHandle(window_handle panewindow);


 /*
  * Returns pane number of 'panewindow' attatched to 'mainwindow' or 0 if the
  * window was not found.
  */
extern int Pane2_GetPaneNumber(window_handle mainwindow, window_handle panewindow);


 /*
  * This hides and deletes the 'panenumber'th pane attached to the window
  * 'mainwindow' 
  */
extern void Pane2_DeletePane(window_handle mainwindow, int panenumber);


 /*
  * Calls Wimp_OpenWindow for the mainwindow and all its panes as if it was
  * send an openwindow request.
  * If 'openblock' is NULL then the current state of the main window is used.
  * Supplying an openblock allows the main window to be changed and the panes to be
  * altered to match.
  * Can be used to make a pane window appear that has been added to an open mainwindow.
  */
extern BOOL Pane2_OpenWindow(window_handle mainwindow, window_openblock *openblock);


 /*
  * Returns paneoffset if 'paneoffset' is not NULL and panesize if 'panesize' is
  * not NULL for the 'panenumber'th pane attatched to 'mainwindow'.
  * TRUE is returned for success.
  */
extern BOOL Pane2_ReadVars(window_handle mainwindow, int panenumber,
                           wimp_point *paneoffset, 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'.
  * TRUE is returned for success.
  * After changing the variables, Pane2_OpenWindow must be used to make the
  * windows on screen exhibit the changes.
  */
extern BOOL Pane2_SetVars(window_handle mainwindow, int panenumber,
                           wimp_point *paneoffset, wimp_point *panesize);

#ifdef __cplusplus
}
#endif


#endif
