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

    File:    Pane.h
    Author:  Copyright  1994 Ainsley Pereira. Complete revision by Keith Hall
    Version: 1.11 (30th March 1994)
    Purpose: Handles windows with panes.
*/

/*
 * Implementation notes
 * --------------------
 * The offset of the pane from the master window is taken from their initial
 * positions, so make sure that they are in the right places relative to each
 * other when you save them from Glazier (or FormEd if you have a pet
 * triceratops ;-)
 * Another point is that the relative positions are kept constant from the top
 * left of the visible area. This only matters if the master window is
 * resizeable. The top left was chosen as most panes are either in fixed size
 * windows (eg. Options windows) or are down the top left of a window (eg.
 * Artworks, Draw etc.)
 * If you want to do something like StrongEd's status bar then you'll have to
 * a) Alter Desk_pane_data.offset.y everytime you resize the window, or
 * b) Alter the code to use xxxxx.min.y - yyyyy.min.y (although then you can't
 *    have the Artworks/Draw style panes).
 */

#ifndef __Desk_Pane_h
#define __Desk_Pane_h

#ifdef __cplusplus
	extern "C" {
#endif


#ifndef __Desk_Wimp_h
	#include "Desk.Wimp.h"
#endif

#ifndef __Desk_Window_h
	#include "Desk.Window.h"
#endif

#ifndef __Desk_WimpSWIs_h
	#include "Desk.WimpSWIs.h"
#endif

typedef struct
{
  Desk_window_handle master;
  Desk_window_handle pane;
  Desk_wimp_point    offset;
  Desk_wimp_point    size;
  union
  {
    int value;
    struct
    {
      unsigned int isopen :1;  /* master/pane pair currently displaying */
      unsigned int fixed  :1;  /* pane sticks to position relative to top of master */
      unsigned int resize :1;  /* pane shrinks with relation to size of master */
      unsigned int horiz  :1;  /* pane is horizontal (shrinks to left when resize flag set
                                  and window gets resized (like !StrongEd toolbar) */
      unsigned int vert   :1;  /* pane is horizontal (shrinks to top when resize flag set
                                  and window moves (like !Draw) */
      unsigned int dummy  :27;
    } data;
  } flags;
} Desk_pane_data;

#define Desk_pane_OPEN   0x0001
#define Desk_pane_FIXED  0x0002
#define Desk_pane_RESIZE 0x0004
#define Desk_pane_HORIZ  0x0008
#define Desk_pane_VERT   0x0010


extern Desk_bool Desk_Pane_OpenEventHandler(Desk_event_pollblock *event, void *reference);
/*
 * Install as a handler for Desk_event_OPEN on the master window.
 * It opens the pane at the correct offset at the correct size.
 */


extern Desk_pane_data *Desk_Pane_GetSysHandle(Desk_window_handle master);
/*
 * 
 * Returns a pointer to the Desk_pane_data structure associated with the 'master' window.
 * Returns NULL if the master window isn't linked.
 */


extern int Desk_Pane_SetFlags(Desk_window_handle master, int flags);
/*
 * Sets the flags of the Pane/Master window relationship.
 * Returns the current flags if 'flags' is -1.
 * Returns NULL if the master window isn't linked.
 */


extern void Desk_Pane_Link(Desk_window_handle mast, Desk_window_handle pane,
                      Desk_wimp_point *offset, Desk_wimp_point *size, int flags);
/*
 * 
 * Links the pane window handle to the master window handle.
 * if offset or size == NULL then the data is taken from the template
 */


extern Desk_window_handle Desk_Pane_CreateAndLink(char *mastname, char *panename,
                                        int mastmaxsize, int panemaxsize,
                                        Desk_wimp_point *offset, Desk_wimp_point *size, int flags);
/*
 * Creates the windows using Desk_Window_Create and then Desk_Pane_Links them together.
 * returns window handle of the master window
 * if offset or size == NULL then the data is taken from the template
 */

extern void Desk_Pane_Show(Desk_window_handle window, Desk_window_openpos openpos);
/*
 * Simply calls Desk_Window_Show for the master window and the pane.
 */


extern void Desk_Pane_Delete(Desk_window_handle window);
/*
 * Calls Desk_Window_Delete for the master window and the pane and de-links them
 */


extern void Desk_Pane_Hide(Desk_window_handle window);
/*
 *
 * Simply calls Desk_Window_Hide for the master window and the pane.
 */

#ifdef __cplusplus
}
#endif


#endif
