/*
    ####             #    #     # #
    #   #            #    #       #          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, Jason Williams
                                          Sergio Monesi, Julian Smith.
    Version: 1.08 (09 Sep 1995)
    Purpose: Prototypes for Wimp SWI calls defined in the Wimp library
             (Basic SWI-level interface to the Wimp)
    
    Mods:    19 Mar 1995 - JS - Added macros to make calls to 
                                Desk_Wimp_Poll(Idle) actually call Straylight 
                                equivalents, when compilataion is for 
                                dynamic linking.
             08 Jul 1995 - JS - Removed #include of kernel.h, and changed
                                Desk_Wimp_SpriteOp prototype, to make
                                DeskLib usable without Acorn headers

             13 Jul 1995 - SM - Added Desk_Wimp_StartTask3 and 
                                Desk_Wimp_GetWindowInfoNoIcons (for RISC OS 3.10 
                                or later).
             
             09 Sep 1995 - JS - Added Desk_Wimp_e* macros for each Wimp SWI. 
                                These call Desk_Error2_XHandle if the SWI returns 
                                an (Desk_os_error *).
             10 Nov 1995 - JS - Added Desk_Wimp_E* macros for each Wimp SWI. 
                                These call Desk_Error2_Handle if the SWI returns
                                an (Desk_os_error *).
             
*/


#ifndef __Desk_WimpSWIs_h
#define __Desk_WimpSWIs_h

#ifdef __cplusplus
extern "C" {
#endif


#ifndef __Desk_Core_h
	#include "Desk.Core.h"
#endif

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

#ifndef __Desk_Error2_h
	#include "Desk.Error2.h"
#endif


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

extern void	Desk_Wimp_Initialise(const unsigned int *version,
                                 const char         *name,
                                 Desk_task_handle  *task,
                                 const int          *messages);
/*
PRMs 3-87 5a-666
 */

extern void	Desk_Wimp_CloseDown(Desk_task_handle task);
/*
PRMs 3-175
 */
extern void	Desk_Wimp_StartTask(const char *command);
/*
PRMs 3-177
 */
extern void	Desk_Wimp_StartTask3(const char *command, Desk_task_handle *newtask);
 /*  Desk_Wimp_StartTask3
  *  RISC OS 3 version of Desk_Wimp_StartTask that returns the task handle of
  *  the started task if it is still alive or 0 if it isn't
PRMs 3-177
  */

extern void	Desk_Wimp_SlotSize(int *currentslot, int *nextslot, int *freepool);
/*
PRMs 3-206
 */

extern void	Desk_Wimp_TransferBlock(Desk_task_handle  sourcetask,
                                    void         *sourcebuffer,
                                    Desk_task_handle  desttask,
                                    void         *destbuffer,
                                    unsigned int length);
/*
PRMs 3-216 5a-41
 */
extern void	Desk_Wimp_ReportError(const Desk_os_error *error, int flags, const char *name);
 /*  Desk_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 Desk_Wimp_ReportErrorR
  *  'flags' should be as in the Desk_error_flags union.
PRMs 3-179 5a-492
  */

enum	{
	Desk_wimp_reporterror_button_NONE	= 0,
	Desk_wimp_reporterror_button_OK		= 1,
	Desk_wimp_reporterror_button_CANCEL	= 2
	};


extern int Desk_Wimp_ReportErrorR(const Desk_os_error *error, int flags, const char *name);
 /*  Desk_Wimp_ReportErrorR
  *  Identical to Desk_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 (see 
  *  Desk_wimp_reporterror_button_NONE, Desk_wimp_reporterror_button_OK,
  *  Desk_wimp_reporterror_button_CANCEL).
  *  'flags' should be as in the Desk_error_flags union.
PRMs 3-179 5a-492
  */

/*
extern int Desk_Wimp_ReportErrorR350( 
		const Desk_os_error	*error, 
		int			flags, 
		const char		*name, 
		const char*		spritename, 
		Desk_sprite_area	area, 
		const char*		text
		);
*/ /*  Identical to Desk_Wimp_ReportErrorR, except it supports
  *  the new parameters in RO3.5
  */





extern void	Desk_Wimp_SendMessage (Desk_event_type       eventtype,
                                   Desk_message_block    *message,
                                   Desk_message_destinee destinee,
                                   Desk_icon_handle      icon);
/*
PRMs 3-196
 */

/* window handling */

extern void	Desk_Wimp_OpenTemplate(const char *name);
/*
PRMs 3-168
 */

extern void	Desk_Wimp_CloseTemplate(void);
/*
PRMs 3-169
 */

extern void	Desk_Wimp_LoadTemplate(Desk_template_block *wtemplate);
/*
PRMs 3-170
 */

extern void	Desk_Wimp_CreateWindow(const Desk_window_block *block, Desk_window_handle *window);
/*
PRMs 3-89 5a-491
 */

extern void	Desk_Wimp_OpenWindow(const Desk_window_openblock *block);
/*
PRMs 3-112
 */

extern void	Desk_Wimp_CloseWindow(Desk_window_handle window);
/*
PRMs 3-114
 */

extern void	Desk_Wimp_DeleteWindow(Desk_window_handle window);
/*
PRMs 3-108
 */

extern void	Desk_Wimp_RedrawWindow(Desk_window_redrawblock *block, Desk_bool *more);
/*
PRMs 3-129
 */

extern void	Desk_Wimp_UpdateWindow(Desk_window_redrawblock *block, Desk_bool *more);
/*
PRMs 3-131
 */

extern void	Desk_Wimp_GetRectangle(Desk_window_redrawblock *block, Desk_bool *more);
/*
PRMs 3-133
 */

extern void	Desk_Wimp_GetWindowState(Desk_window_handle window, Desk_window_state *state);
/*
PRMs 3-135
 */

extern void	Desk_Wimp_GetWindowInfo(Desk_window_info *info);
/*
 *  NOTE that this call returns a Desk_window_info PLUS icon data following it.
 *  It will therefore overwrite past the end of a normal Desk_window_info block.
 *  Use Desk_Window_GetInfo in preference.
PRMs 3-137
 */

extern void	Desk_Wimp_GetWindowInfoNoIcons(Desk_window_info *info);
/*
 *  This call returns only the Desk_window_info, NOT the icons data. It only
 *  works with RISC OS 3.10 or later
PRMs 3-137
 */

extern void	Desk_Wimp_GetWindowOutline(Desk_window_outline *outline);
/*
PRMs 3-182
 */

extern void	Desk_Wimp_SetExtent(Desk_window_handle window, Desk_wimp_box *newextent);
/*
PRMs 3-164
 */

extern void	Desk_Wimp_ForceRedraw(const Desk_window_redrawblock *block);
/*
PRMs 3-150
 */


/* Icon handling */

extern void	Desk_Wimp_CreateIcon(const Desk_icon_createblock *block, Desk_icon_handle *icon);
/*
PRMs 3-96 5a-491 5a-667
 */

extern void	Desk_Wimp_DeleteIcon(Desk_window_handle window, Desk_icon_handle icon);
/*
PRMs 3-110
 */

extern void	Desk_Wimp_SetIconState(Desk_window_handle window,
                                   Desk_icon_handle   icon,
                                   int           value,
                                   int           mask);
/*
PRMs 3-139
 */

extern void	Desk_Wimp_GetIconState(Desk_window_handle window,
                                   Desk_icon_handle   icon,
                                   Desk_icon_block    *iconinfo);
/*
PRMs 3-141
 */

extern void	Desk_Wimp_WhichIcon(Desk_window_handle    window,
                                   Desk_icon_handle   *icons,
                                   int           mask,
                                   int           settings);
/*
PRMs 3-162
 */

extern void	Desk_Wimp_PlotIcon(Desk_icon_block *fakeicon);
/*
Don't call this except in a redraw loop. If not in a redraw loop, use
Desk_Wimp_PlotIcon2.

PRMs 3-186
 */

extern void	Desk_Wimp_PlotIcon2( Desk_icon_block *fakeicon, int xorigin, int yorigin);
/*
When not invoked in a redraw loop, Wimp_PlotIcon assumes origin at
(r4,r5). This is undocumented AFAIK, even in PRMs 5a, but see PRMs
5a-516.

I think Wimp_Plot ignores the current graphics origin in favour of
(r4,r5) when invoked outside a redraw loop, so you should include the
graphics origin explicitly using this call when redrawing to a sprite
for example.

If in a redraw loop, xorigin and yorigin are ignored by the underlying
SWI Wimp_PlotIcon, so you'll save a few ns by using Desk_Wimp_PlotIcon.

PRMs 3-186
 */



/*  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 Desk_Wimp_Poll(mask, evt) Desk_Wimp_Poll3(mask, evt, 0)
#define Desk_Wimp_PollIdle(mask, evt, time) Desk_Wimp_PollIdle3(mask, evt, time, 0)

extern void	Desk_Wimp_Poll3(Desk_event_pollmask mask, Desk_event_pollblock *event,
                            void *pollword);
/*
PRMs 3-115 5a-667
 */

extern void	Desk_Wimp_PollIdle3(Desk_event_pollmask mask, Desk_event_pollblock *block,
                                int earliest, void *pollword);
/*
PRMs 3-184
 */


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


#ifdef Desk__using_SDLS

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

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

extern void	Desk_Wimp_Poll3_DLL( Desk_event_pollmask mask, Desk_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 void	Desk_Wimp_PollIdle3_DLL( Desk_event_pollmask mask, Desk_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 Desk_Wimp_Poll3 Desk_Wimp_Poll3_DLL
#define Desk_Wimp_PollIdle3 Desk_Wimp_PollIdle3_DLL


#endif





extern void	Desk_Wimp_SaveFPStateOnPoll(void);
extern void	Desk_Wimp_CorruptFPStateOnPoll(void);


/* Pointer/Mouse handling */

extern void	Desk_Wimp_GetPointerInfo(Desk_mouse_block *ptrinfo);
/*
PRMs 3-143
 */

extern void	Desk_Wimp_SetPointerShape(const Desk_pointer_shapeblock *shape);
/*
PRMs 3-166
 */

extern void	Desk_Wimp_DragBox(Desk_drag_block *draginfo);
/*
PRMs 3-145
 */

/* Caret handling */

extern void	Desk_Wimp_SetCaretPosition(const Desk_caret_block *caret);
/*
PRMs 3-152
 */

extern void	Desk_Wimp_GetCaretPosition(const Desk_caret_block *caret);
/*
PRMs 3-154
 */

/* Menu handling */

extern void	Desk_Wimp_CreateMenu(Desk_menu_ptr menu, int xpos, int ypos);
/*
PRMs 3-156 5a-492
 */

extern void	Desk_Wimp_CreateSubMenu(Desk_menu_ptr menu, int xpos, int ypos);
/*
PRMs 3-199
 */

extern void	Desk_Wimp_DecodeMenu(Desk_menu_ptr menu,
                                 const int      *selections,
                                 char     *result);
/*
Note that this makes a CR-terminated string.

PRMs 3-161 5a-667
 */


/* Keyboard handling */

extern void	Desk_Wimp_ProcessKey(int character);
/*
PRMs 3-173
 */

/* Graphics/Screen handling */

extern void	Desk_Wimp_SetMode(int mode);
/*
PRMs 3-188 5a-118
 */

extern void	Desk_Wimp_SetColour(int colour);
/*
PRMs 3-194
 */

extern void	Desk_Wimp_ReadPalette(Desk_palette_block *palette);
/*
PRMs 3-192 5a-667
 */

extern void	Desk_Wimp_SetPalette(const Desk_palette_block *palette);
/*
PRMs 3-190
 */

extern void	Desk_Wimp_ReadPixTrans(int         areaindex,
                                   void        *area,
                                   void        *sprite,
                                   Desk_scale_block *scaleblock,
                                   char        *transblock);
/*
PRMs 3-208
 */

extern void	Desk_Wimp_SetFontColours(int foreground, int background);
/*
PRMs 3-220
 */

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

PRMs 3-201
 */

extern void	Desk_Wimp_BaseOfSprites(void **Desk_rom_base, void **Desk_ram_base);
/*
PRMs 3-203
 */

extern void	Desk_Wimp_BlockCopy(Desk_window_handle window, const Desk_wimp_box *source,
                                                      int x, int y);
/*
PRMs 3-204
 */

extern void	Desk_Wimp_CommandWindow(int);
/*
PRMs 3-W212
 */



#ifdef __cplusplus
}
#endif


#endif
