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

    File:    WimpSWIs.h
    Author:  Copyright  1992, 1993, 1994 John Winters and Jason Williams
    Version: 1.07 (22 Oct 1994)
    Purpose: Prototypes for Wimp SWI calls defined in the Wimp library
             (Basic SWI-level interface to the Wimp)
    
    Mods:    19 Mar 1995 Julian Smith
             Added macros to make calls to Wimp_Poll(Idle) actually
             call Straylight equivalents, when compilataion is for dynamic 
             linking.
             08 Jul 1995 - JPS - Removed #include of kernel.h, and changed
                                 Wimp_SpriteOp prototype, to make
                                 DeskLib usable without Acorn headers

             13 Jul 1995 Sergio Monesi
             Added Wimp_StartTask3 and Wimp_GetWindowInfoNoIcons (for
             RISC OS 3.10 or later).
             
*/


#ifndef __dl_wimpswis_h
#define __dl_wimpswis_h

#ifdef __cplusplus
extern "C" {
#endif


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

/*
#ifndef __kernel_h
#include "kernel.h"
#endif
*/

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


/* Task handling: init, closedown, messages, transfers, etc. */

extern os_error *Wimp_Initialise(unsigned int *version,
                                 char         *name,
                                 task_handle  *task,
                                 int          *messages);
extern os_error *Wimp_CloseDown(task_handle task);

extern os_error *Wimp_StartTask(char *command);

extern os_error *Wimp_StartTask3(char *command, task_handle *newtask);
 /*  Wimp_StartTask3
  *  RISC OS 3 version of Wimp_StartTask that returns the task handle of
  *  the started task if it is still alive or 0 if it isn't
  */

extern os_error *Wimp_SlotSize(int *currentslot, int *nextslot, int *freepool);
extern os_error *Wimp_TransferBlock(task_handle  sourcetask,
                                    void         *sourcebuffer,
                                    task_handle  desttask,
                                    void         *destbuffer,
                                    unsigned int length);

extern os_error *Wimp_ReportError(os_error *error, int flags, char *name);
 /*  Wimp_ReportError
  *  Reports an error in the standard WIMP non-multitasking error box.
  *  Avoid (by using your own multitasking error box) where possible!
  *  See also Wimp_ReportErrorR
  */


extern int Wimp_ReportErrorR(os_error *error, int flags, char *name);
 /*  Wimp_ReportErrorR
  *  Identical to Wimp_ReportError, except this version returns the flags
  *  that are returned by the SWI. That is, the return code from this
  *  function is 1 if OK was pressed or 2 if Cancel was pressed.
  */


extern os_error *Wimp_SendMessage (event_type       eventtype,
                                   message_block    *message,
                                   message_destinee destinee,
                                   icon_handle      icon);


/* window handling */

extern os_error *Wimp_OpenTemplate(char *name);
extern os_error *Wimp_CloseTemplate(void);
extern os_error *Wimp_LoadTemplate(template_block *wtemplate);

extern os_error *Wimp_CreateWindow(window_block *block, window_handle *window);
extern os_error *Wimp_OpenWindow(window_openblock *block);
extern os_error *Wimp_CloseWindow(window_handle window);
extern os_error *Wimp_DeleteWindow(window_handle window);

extern os_error *Wimp_RedrawWindow(window_redrawblock *block, BOOL *more);
extern os_error *Wimp_UpdateWindow(window_redrawblock *block, BOOL *more);
extern os_error *Wimp_GetRectangle(window_redrawblock *block, BOOL *more);

extern os_error *Wimp_GetWindowState(window_handle window,window_state *state);

extern os_error *Wimp_GetWindowInfo(window_info *info);
/*
 *  NOTE that this call returns a window_info PLUS icon data following it.
 *  It will therefore overwrite past the end of a normal window_info block.
 *  Use Window_GetInfo in preference.
 */

extern os_error *Wimp_GetWindowInfoNoIcons(window_info *info);
/*
 *  This call returns only the window_info, NOT the icons data. It only
 *  works with RISC OS 3.10 or later
 */

extern os_error *Wimp_GetWindowOutline(window_outline *outline);
extern os_error *Wimp_SetExtent(window_handle window, wimp_box *newextent);
extern os_error *Wimp_ForceRedraw(window_redrawblock *block);



/* Icon handling */

extern os_error *Wimp_CreateIcon(icon_createblock *block, icon_handle *icon);
extern os_error *Wimp_DeleteIcon(window_handle window, icon_handle icon);
extern os_error *Wimp_SetIconState(window_handle window,
                                   icon_handle   icon,
                                   int           value,
                                   int           mask);
extern os_error *Wimp_GetIconState(window_handle window,
                                   icon_handle   icon,
                                   icon_block    *iconinfo);
extern os_error *Wimp_WhichIcon(window_handle    window,
                                   icon_handle   *icons,
                                   int           mask,
                                   int           settings);
extern os_error *Wimp_PlotIcon(icon_block *fakeicon);



/*  Poll handling */
/*  DeskLib 2.04:
 *  WimpSWIs.s.Poll has been updated to handle passing a WIMP pollword
 *  under RISC OS 3. The new Poll functions have been named Poll3 and
 *  PollIdle3 so that you can't accidentally link with the new forms
 *  of the functions.
 *  Poll and PollIdle are now macros that map Poll calls onto the new
 *  Poll3 functions (passing a zero for the pollword). So long as you
 *  only try to use pollwords under RISC OS 3 onwards, you should be fine!
 *
 *  If you wish to specifically use the pollword, then call the Poll3 functions
 *  directly, using the new parameter.
 */

#define Wimp_Poll(mask, evt) Wimp_Poll3(mask, evt, 0)
#define Wimp_PollIdle(mask, evt, time) Wimp_PollIdle3(mask, evt, time, 0)

extern os_error *Wimp_Poll3(event_pollmask mask, event_pollblock *event,
                            void *pollword);
extern os_error *Wimp_PollIdle3(event_pollmask mask, event_pollblock *block,
                                int earliest, void *pollword);



/*
Some macro stuff to make sure the SDLS Wimp_Poll veneers are 
called if compilation is for a DLL.
*/


#ifdef _DeskLib_SDLS

extern event_type _dll_wimpPoll( 
		event_pollmask	mask, 
		event_data	*data, 
		int		dummy, 
		void		*pollword
		);
/*
This SDLS function preserves the Straylight DLL handle in case a new
application starts before Wimp_Poll returns.
Only used if compilation is for a SDLS client application.
*/

extern event_type _dll_wimpPollIdle( 
		event_pollmask	mask, 
		event_data	*data, 
		int		earliest, 
		void		*pollword
		);
/*
This SDLS function preserves the Straylight DLL handle in case a new
application starts before Wimp_Poll returns.
Only used if compilation is for a SDLS client application.
*/

extern os_error *Wimp_Poll3_DLL( event_pollmask mask, event_pollblock *event,
                                 void *pollword);
/*
A DeskLib-style veneer onto the Straylight DLL handle-preserving function.
Only used if compilation is for a SDLS client application.
*/

extern os_error *Wimp_PollIdle3_DLL( event_pollmask mask, event_pollblock *block,
                                       int earliest, void *pollword);
/*
A DeskLib-style veneer onto the Straylight DLL handle-preserving function.
Only used if compilation is for a SDLS client application.
*/

#define Wimp_Poll3 Wimp_Poll3_DLL
#define Wimp_PollIdle3 Wimp_PollIdle3_DLL


#endif





extern os_error *Wimp_SaveFPStateOnPoll(void);
extern os_error *Wimp_CorruptFPStateOnPoll(void);


/* Pointer/Mouse handling */

extern os_error *Wimp_GetPointerInfo(mouse_block *ptrinfo);
extern os_error *Wimp_SetPointerShape(pointer_shapeblock *shape);

extern os_error *Wimp_DragBox(drag_block *draginfo);


/* Caret handling */

extern os_error *Wimp_SetCaretPosition(caret_block *caret);
extern os_error *Wimp_GetCaretPosition(caret_block *caret);


/* Menu handling */

extern os_error *Wimp_CreateMenu(menu_ptr menu, int xpos, int ypos);
extern os_error *Wimp_CreateSubMenu(menu_ptr menu, int xpos, int ypos);
extern os_error *Wimp_DecodeMenu(menu_ptr menu,
                                 int      *selections,
                                 char     *result);
/*
Note that this makes a CR-terminated string.
*/


/* Keyboard handling */

extern os_error *Wimp_ProcessKey(int character);


/* Graphics/Screen handling */

extern os_error *Wimp_SetMode(int mode);
extern os_error *Wimp_SetColour(int colour);
extern os_error *Wimp_ReadPalette(palette_block *palette);
extern os_error *Wimp_SetPalette(palette_block *palette);
extern os_error *Wimp_ReadPixTrans(int         areaindex,
                                   void        *area,
                                   void        *sprite,
                                   scale_block *scaleblock,
                                   char        *transblock);
extern os_error *Wimp_SetFontColours(int foreground, int background);


extern os_error *Wimp_SpriteOp( int r[10]);
/*
r = should be a pointer to an array of 10 ints
This used to be:
extern os_error *Wimp_SpriteOp(_kernel_swi_regs *registers);
*/

extern os_error *Wimp_BaseOfSprites(void **rom_base, void **ram_base);

extern os_error *Wimp_BlockCopy(window_handle window, wimp_box *source,
                                                      int x, int y);

extern os_error *Wimp_CommandWindow(int);

#ifdef __cplusplus
}
#endif


#endif
