Commit 6a4d16d8 authored by Ben Avison's avatar Ben Avison
Browse files

Initial import on vendor branch for public releases of Desk library.

Detail:
  This is identical to the pre-built archive of Desk 3.2.5. In order to
  comply with the licence conditions, this must only be updated in line with
  further public releases of Desk issued by the official Desk moderator.
  Files required to integrate this with the RISC OS build environment are
  included on the trunk only.
Admin:
  Has received only brief testing in a RISC OS ROM build.

Version 3.2.5. Tagged as 'Desk-3_2_5-import'
parents
IconSprites <Obey$Dir>.!Sprites
Set Desk$Dir <Obey$Dir>
Set Desk$Path <Desk$Dir>.
Set DeskBin$Dir <Obey$Dir>.Tools.bin
Set DeskBin$Path <DeskBin$Dir>.
Set DeskDevel$Dir <Desk$Dir>.Build
Set DeskDevel$Path <DeskDevel$Dir>.
/<Obey$Dir>.!Boot
IfThere Desk:Docs.!Help Then Filer_Run Desk:Docs.!Help
Filer_OpenDir Desk:Examples
Filer_OpenDir Desk:Docs
Obey <Obey$Dir>.!Boot
Filer_OpenDir <Desk$Dir>.Docs
#ifndef __Desk_BackTrace_h
#define __Desk_BackTrace_h
#include <stdio.h>
#include "kernel.h"
#ifdef __cplusplus
extern "C" {
#endif
void Desk_BackTrace_SupportCurrentFrame( _kernel_unwindblock *frame);
void Desk_BackTrace_OutputToStdErr( void);
void Desk_BackTrace_OutputToStreamWithPrefix( FILE* stream, const char* prefix);
typedef int (*Desk_backtrace_printf_fn)( void* reference, const char* format, ...);
void Desk_BackTrace_OutputToFFunctionWithPrefix( Desk_backtrace_printf_fn fn, void* reference, const char* prefix);
extern unsigned int Desk_BackTrace_GetPC( void);
extern unsigned int Desk_BackTrace_GetSL( void);
extern unsigned int Desk_BackTrace_GetPC2(void);
int Desk_BackTrace_GetNestingDepth( void);
typedef struct {
int n;
unsigned int** functions;
}
Desk_BackTrace_functionlist;
#define Desk_BackTrace_MAXFNS 256
const Desk_BackTrace_functionlist* Desk_BackTrace_GetCurrentFunctions( void);
const char* Desk_BackTrace_GetFunctionName( const void* ptr);
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_Clear_h
#define __Desk_Clear_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __Desk_Wimp_h
#include "Wimp.h"
#endif
typedef struct
{
char *creator;
unsigned creatorversion;
unsigned width,
height;
unsigned bpp;
Desk_palette_entry *palette;
unsigned char *bitmap;
} Desk_clear_picture;
void Desk_Clear_Init(char *creator, unsigned version);
Desk_clear_picture *Desk_Clear_Load(char *filename);
void Desk_Clear_Save(Desk_clear_picture *picture, char *filename);
Desk_clear_picture *Desk_Clear_Create(unsigned width, unsigned height, unsigned bpp);
void Desk_Clear_Free(Desk_clear_picture *picture);
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_ColourMenu_h
#define __Desk_ColourMenu_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __Desk_Menu_h
#include "Desk.Menu.h"
#endif
extern Desk_menu_ptr Desk_ColourMenu_Create(char *name);
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_ColourTran_h
#define __Desk_ColourTran_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __Desk_Core_h
#include "Core.h"
#endif
extern void Desk_ColourTrans_SetGCOL( int palette, int flag, int gcolaction);
#define Desk_ColourTrans_RGB( r, g, b) \
( ( (unsigned)(r)<<8 | (unsigned)(g)<<16 | (unsigned)(b)<<24))
#define Desk_ColourTrans_SetGCOL2( palette) \
Desk_ColourTrans_SetGCOL( palette, 1<<8, 0)
#define Desk_ColourTrans_SetGCOL3( r, g, b) \
Desk_ColourTrans_SetGCOL2( Desk_ColourTrans_RGB( r, g, b))
extern void Desk_ColourTrans_InvalidateCache(void);
extern void Desk_ColourTrans_SelectTable(int Desk_src_mode, int *Desk_src_pal,
int Desk_dst_mode, int *Desk_dst_pal,
char *table);
typedef struct
{
int font;
int back;
int fore;
int max;
} Desk_colourtrans_fontblock;
extern void Desk_ColourTrans_ReturnFontColours(Desk_colourtrans_fontblock *fontcols);
extern int Desk_ColourTrans_ReturnColourNumberForMode(int palette, int mode,
int *pal);
extern int Desk_ColourTrans_ReturnColourNumber(int entry);
extern int Desk_ColourTrans_ReturnGCOL(int entry);
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_Coord_h
#define __Desk_Coord_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __Desk_core_h
#include "Core.h"
#endif
#ifndef __Desk_Wimp_h
#include "Wimp.h"
#endif
typedef struct
{
Desk_wimp_rect screenrect;
Desk_wimp_point scroll;
} Desk_convert_block;
extern Desk_bool Desk_Coord_PointInRect( const Desk_wimp_point *point, const Desk_wimp_rect *rect);
extern Desk_bool Desk_Coord_RectContained( const Desk_wimp_rect *InsideRect,
const Desk_wimp_rect *OutsideRect);
extern Desk_bool Desk_Coord_RectsOverlap( const Desk_wimp_rect *rect1, const Desk_wimp_rect *rect2);
#define Desk_Coord_RectsIntersect(r1, r2) (Desk_Coord_RectsOverlap(r1, r2) && \
!Desk_Coord_RectContained(r1, r2) && \
!Desk_Coord_RectContained(r2, r1))
extern void Desk_Coord_WindowOrigin( Desk_wimp_point *origin, const Desk_convert_block *convert);
#define Desk_Coord_XToScreen(X, C) \
(((X) - (C)->scroll.x) + (C)->screenrect.min.x)
#define Desk_Coord_YToScreen(Y, C) \
( ((Y) - (C)->scroll.y) + (C)->screenrect.max.y )
extern void Desk_Coord_PointToScreen(Desk_wimp_point *point, const Desk_convert_block *convert);
extern void Desk_Coord_RectToScreen(Desk_wimp_rect *rect, const Desk_convert_block *convert);
#define Desk_Coord_XToWorkArea(X, C) (((X)-(C)->screenrect.min.x)+(C)->scroll.x)
#define Desk_Coord_YToWorkArea(Y, C) (((Y)-(C)->screenrect.max.y)+(C)->scroll.y)
extern void Desk_Coord_PointToWorkArea(Desk_wimp_point *point,
const Desk_convert_block *convert);
extern void Desk_Coord_RectToWorkArea(Desk_wimp_rect *rect, const Desk_convert_block *convert);
extern void Desk_Coord_RectUnion(Desk_wimp_rect *dest,
Desk_wimp_rect *src1, Desk_wimp_rect *src2);
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_Core_h
#define __Desk_Core_h
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
Desk_bool_FALSE = 0,
Desk_FALSE = 0,
Desk_bool_TRUE = 1,
Desk_TRUE = 1
}
Desk_bool;
#include <stddef.h>
#if (defined(__CC_NORCROFT) || defined(__GNUC__))
#include "kernel.h"
typedef _kernel_oserror Desk_os_error;
#else
typedef struct
{
int errnum;
char errmess[252];
}
Desk_os_error;
#endif
#define Desk_UNUSED_ARG(x) ((x) = (x))
#define Desk_UNUSED(x) ((x) = (x))
#ifndef Desk_MAX
#define Desk_MAX(x, y) ((x) > (y) ? (x) : (y))
#define Desk_MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
#if defined( Desk_SDLS_CLIENT) || defined( _DLL)
#define Desk__using_SDLS
#endif
#if defined( Desk__MODULE_CLIENT) || defined( _DLL)
#define Desk__Zm
#endif
#ifdef _DLL
#define __wimp_h
#define __os_h
#include "DLLLib.dll.h"
#define Desk_SDLS_dllEntry( FnName) _dllEntry( FnName)
#define Desk_SDLS_PtrFn( staticextern, returntype, FnName) \
extern returntype _dllEntry( FnName) ; \
extern returntype FnName
#else
#define Desk_SDLS_dllEntry( FnName) FnName
#define Desk_SDLS_PtrFn( staticextern, returntype, FnName) \
staticextern returntype FnName
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_Debug_h
#define __Desk_Debug_h
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdarg.h>
#ifndef __Desk_Core_h
#include "Desk.Core.h"
#endif
typedef void (*Desk_debug_signalhandlerfn)( int sig, void *reference);
#if !defined( Desk_DEBUG) && !defined( Desk__making_Debug)
#define Desk_Debug_Initialise()
#define Desk_Debug_InitialiseSignal()
#define Desk_Debug_ClaimSignal( fn, reference)
#define Desk_Debug_ReleaseSignal()
#define Desk_Debug_Finalise()
#define Desk_Debug_Assert( expression)
#define Desk_Debug_Error_CheckFatal( errfn) Desk_Error_CheckFatal( errfn)
#define Desk_Debug_Print( text)
#define Desk_Debug_DumpRegistersToFile()
#define Desk_Debug_SetNestingIndentation( indentstring)
#define Desk_Debug_DescribeError2( error)
#define Desk_Debug_SetLevel( level)
#define Desk_Debug_BackTrace()
#define Desk_Debug_PrintMemory( start, size)
#define Desk_Debug_Printf Desk_Debug_Dummyf
#define Desk_Debug1_Printf Desk_Debug_Dummyf
#define Desk_Debug2_Printf Desk_Debug_Dummyf
#define Desk_Debug3_Printf Desk_Debug_Dummyf
#define Desk_Debug4_Printf Desk_Debug_Dummyf
#define Desk_Debug5_Printf Desk_Debug_Dummyf
#define Desk_Debug_VPrintf Desk_Debug_Dummyf
#define Desk_Debug1_VPrintf Desk_Debug_Dummyf
#define Desk_Debug2_VPrintf Desk_Debug_Dummyf
#define Desk_Debug3_VPrintf Desk_Debug_Dummyf
#define Desk_Debug4_VPrintf Desk_Debug_Dummyf
#define Desk_Debug5_VPrintf Desk_Debug_Dummyf
#define Desk_Debug_RedirectToFilename( filename)
#else
void Desk_Debug_Initialise( void);
void Desk_Debug_Finalise( void);
void Desk_Debug_InitialiseSignal( void);
void Desk_Debug_ClaimSignal( Desk_debug_signalhandlerfn fn, void *reference);
void Desk_Debug_ReleaseSignal( void);
int Desk_Debug_Printf( const char *format, ...);
int Desk_Debug_VPrintf( const char *format, va_list va);
void Desk_Debug_Print( const char *text);
void Desk_Debug_DumpRegistersToFile( void);
void Desk_Debug_SetNestingIndentation( const char* prefix);
struct Desk_error2_block;
void Desk_Debug_DescribeError2( const struct Desk_error2_block* error);
#define Desk_Debug_SetLevel( level) Desk_debug_level = (level)
int Desk_Debug_PrintfRef( void* reference, const char *format, ...);
void Desk_Debug_BackTrace( void);
#define Desk_Debug_Error_CheckFatal( errfn) \
do { \
Desk_os_error *Desk_debug__e = errfn; \
if ( Desk_debug__e) { \
Desk_Error_ReportFatal( \
Desk_debug__e->errnum, \
Desk_error_PLACE "%s", \
Desk_debug__e->errmess \
); \
} \
} \
while (0)
void Desk_Debug__Assert( const char *expression, const char *sourcefile, int line);
void Desk_Debug_PrintMemory( void* start, int size);
void Desk_Debug_RedirectToFilename( const char* filename);
#define Desk_Debug_Assert( expression) \
( \
(expression) \
? \
(void) 0 \
: \
Desk_Debug__Assert( #expression, __FILE__, __LINE__) \
)
#define Desk_Debug1_Printf (Desk_debug_level<1) ? 0 : Desk_Debug_Printf
#define Desk_Debug2_Printf (Desk_debug_level<2) ? 0 : Desk_Debug_Printf
#define Desk_Debug3_Printf (Desk_debug_level<3) ? 0 : Desk_Debug_Printf
#define Desk_Debug4_Printf (Desk_debug_level<4) ? 0 : Desk_Debug_Printf
#define Desk_Debug5_Printf (Desk_debug_level<5) ? 0 : Desk_Debug_Printf
#endif
#define Desk_Debug_Dummyf (Desk_bool_TRUE) ? 0 : printf
extern int Desk_debug_level;
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_DeskMem_h
#define __Desk_DeskMem_h
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stddef.h>
#ifndef __Desk_Core_h
#include "Desk.Core.h"
#endif
void *Desk_DeskMem_Malloc( size_t size);
void *Desk_DeskMem_Calloc( size_t num, size_t size);
void *Desk_DeskMem_Realloc( void *ptr, size_t size);
void Desk_DeskMem_Free( void *ptr);
#define Desk_DeskMem_MallocType( type) (type *) Desk_DeskMem_Malloc( sizeof( type))
#define Desk_DeskMem_CallocType( n, type) ((type *) Desk_DeskMem_Calloc( n, sizeof( type)))
typedef struct Desk_deskmem_errorblock {
size_t size;
void* ptr;
}
Desk_deskmem_errorblock;
#ifdef Desk__using_SDLS
extern Desk_deskmem_errorblock* Desk_DeskMem__Ref_errorblock( void);
#endif
#if defined( Desk__using_SDLS) && !defined( Desk__making_DeskMem)
#define Desk_deskmem_globalerror (*Desk_DeskMem__Ref_errorblock())
#else
extern Desk_deskmem_errorblock Desk_deskmem_globalerror;
#endif
#ifdef Desk_DeskLib_DEBUG
extern int Desk_deskmem_debuglevel;
#endif
typedef void* (*Desk_deskmem_mallocfn) ( size_t);
typedef void* (*Desk_deskmem_reallocfn) ( void *, size_t);
typedef void* (*Desk_deskmem_callocfn) ( size_t, size_t);
typedef void (*Desk_deskmem_freefn) ( void *);
typedef struct {
Desk_deskmem_mallocfn malloc;
Desk_deskmem_reallocfn realloc;
Desk_deskmem_callocfn calloc;
Desk_deskmem_freefn free;
}
Desk_deskmem_functionsblock;
void Desk_DeskMem_SetAllocFunctions(
Desk_deskmem_mallocfn m,
Desk_deskmem_reallocfn r,
Desk_deskmem_callocfn c,
Desk_deskmem_freefn f,
Desk_deskmem_functionsblock* oldfunctions
);
#ifdef Desk__using_SDLS
extern Desk_deskmem_functionsblock* Desk_DeskMem__Ref_functionsblock( void);
#endif
#if defined( Desk__using_SDLS) && !defined( Desk__making_DeskMem)
#define Desk_deskmem__functions (*Desk_DeskMem__Ref_functionsblock())
#else
extern Desk_deskmem_functionsblock Desk_deskmem__functions;
#endif
#define Desk_DeskMem_RawMalloc( size) (Desk_deskmem__functions.malloc( size))
#define Desk_DeskMem_RawRealloc( ptr, size) (Desk_deskmem__functions.realloc( ptr, size))
#define Desk_DeskMem_RawCalloc( num, size) (Desk_deskmem__functions.calloc( num, size))
#define Desk_DeskMem_RawFree( ptr) (Desk_deskmem__functions.free( ptr))
typedef struct {
void* data;
int size;
int datasize;
int increment;
}
Desk_deskmem_buffer;
void Desk_DeskMem_BufferInit( Desk_deskmem_buffer* buffer, int increment);
void Desk_DeskMem_BufferFree( Desk_deskmem_buffer* buffer);
void Desk_DeskMem_BufferEnsure( Desk_deskmem_buffer* buffer, int min);
void Desk_DeskMem_BufferEnsureExtra( Desk_deskmem_buffer *buffer, int extra);
#define Desk_DeskMem_BufferGetSize( buffer) ( (buffer)->size)
#define Desk_DeskMem_BufferGetDataSize( buffer) ( (buffer)->datasize)
#define Desk_DeskMem_BufferGetString( buffer) ( (char*) (buffer)->data)
#define Desk_DeskMem_BufferGetIntArray( buffer) ( (int*) (buffer)->data)
#define Desk_DeskMem_BufferGetDoubleArray( buffer) ( (double*) (buffer)->data)
void Desk_DeskMem_BufferStrCat( Desk_deskmem_buffer* buffer, const char* extra);
void Desk_DeskMem_BufferStrNCat( Desk_deskmem_buffer* buffer, const char* extra, int extralen);
void Desk_DeskMem_BufferStrCpy( Desk_deskmem_buffer* buffer, const char* s);
void Desk_DeskMem_BufferMidExtend( Desk_deskmem_buffer* buffer, int at, int by);
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_Dialog_h
#define __Desk_Dialog_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __Desk_Wimp_h
#include "Wimp.h"
#endif
#ifndef __Desk_Window_h
#include "Window.h"
#endif
typedef struct
{
Desk_window_handle window;
Desk_icon_handle lastclicked;
Desk_button_state button;
struct
{
unsigned int stillopen : 1;
unsigned int persist : 1;
unsigned int isstatic : 1;
} state;
} Desk_dialog_record;
#ifdef Desk_COMPATABILITY
typedef Desk_dialog_record *dialog;
#endif
#define Desk_dialog_CLOSE ((Desk_icon_handle) -1)
#define Desk_dialog_NOCHOICE ((Desk_icon_handle) -2)
extern Desk_dialog_record * Desk_Dialog_Create(char *Desk_template_name, int maxtitlesize);
extern void Desk_Dialog_Destroy(Desk_dialog_record * d);
extern void Desk_Dialog_Show(Desk_dialog_record * d);
extern void Desk_Dialog_ShowAt(Desk_dialog_record * d, int x, int y);
extern void Desk_Dialog_ShowStatic(Desk_dialog_record * d, Desk_window_openpos openpos);
extern void Desk_Dialog_Hide(Desk_dialog_record * d);
extern int Desk_Dialog_WaitForClick(Desk_dialog_record * d);
#define Desk_Dialog_WindowHandle(d) ((d)->window)
#define Desk_Dialog_Persist(D) ((D)->state.persist && (D)->lastclicked >= 0)
#define Desk_Dialog_LastClicked(D) ((D)->lastclicked)
#define Desk_Dialog_StillOpen(D) ((D)->state.stillopen)
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_Dialog2_h
#define __Desk_Dialog2_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __Desk_Wimp_h
#include "Wimp.h"
#endif
#ifndef __Desk_Window_h
#include "Window.h"
#endif
typedef enum {
Desk_dialog2_type_CLOSED = 0,
Desk_dialog2_type_MENULEAF,
Desk_dialog2_type_MENU,
Desk_dialog2_type_STATIC
}
Desk_dialog2_dialog2type;
typedef struct Desk_dialog2_block *Desk_dialog2_blockptr;
typedef void (*Desk_dialog2_openfn)( Desk_dialog2_blockptr);
typedef void (*Desk_dialog2_okfn)( Desk_dialog2_blockptr);
typedef struct Desk_dialog2_block {
void *reference;
const char *templatename;
Desk_window_handle window;
Desk_dialog2_openfn openfn;
Desk_dialog2_okfn okfn;
union {
int value;
struct {
unsigned int type : 2;
unsigned int keepwindow : 1;
unsigned int notifyclose : 1;
int okbutton : 9;
int cancelbutton : 9;
int maxtitlesize : 10;
}
data;
}
flags;
}
Desk_dialog2_block;
Desk_dialog2_block *Desk_Dialog2_CreateDialogBlock(
const char *templatename,
Desk_icon_handle okbutton,
Desk_icon_handle cancelbutton,
Desk_dialog2_openfn openfn,
Desk_dialog2_okfn okfn,
void *reference
);
void Desk_Dialog2_OpenDialogMenuLeaf( Desk_event_pollblock *event, Desk_dialog2_block *dialog2);
void Desk_Dialog2_OpenDialogMenu( Desk_dialog2_block *dialog2, Desk_window_openpos openpos);
void Desk_Dialog2_OpenDialogStatic( Desk_dialog2_block *dialog2, Desk_window_openpos openpos);
void Desk_Dialog2_CloseDialog( Desk_dialog2_block *dialog2);
void Desk_Dialog2_DeleteDialog( Desk_dialog2_block *dialog2);
#ifdef Desk__using_SDLS
extern Desk_dialog2_block **Desk_Dialog2__Ref_menublock( void);
#endif
#if defined( Desk__using_SDLS) && !defined( Desk__making_Dialog2)
#define Desk_dialog2_menublock (*Desk_Dialog2__Ref_menublock())
#else
extern Desk_dialog2_block *Desk_dialog2_menublock;
#endif
void Desk_Dialog2_Window_GetWindowOpenPos(
Desk_wimp_point *pos, Desk_window_openpos openpos, Desk_window_handle window
);
void Desk_Dialog2_EnsureWindowHandle( Desk_dialog2_block *dialog2);
#define Desk_Dialog2_ChangeCloseNotification( dialog2, x) (dialog2)->flags.data.notifyclose = (x)
#define Desk_Dialog2_NotifyClose( dialog2) Desk_Dialog2_ChangeCloseNotification( dialog2, 1)
#define Desk_Dialog2_DontNotifyClose( dialog2) Desk_Dialog2_ChangeCloseNotification( dialog2, 0)
#define Desk_Dialog2_ChangeKeepWindow( dialog2, x) (dialog2)->flags.data.keepwindow = (x)
#define Desk_Dialog2_KeepWindow( dialog2) Desk_Dialog2_ChangeKeepWindow( dialog2, 1)
#define Desk_Dialog2_DontKeepWindow( dialog2) Desk_Dialog2_ChangeKeepWindow( dialog2, 0)
#define Desk_Dialog2_ChangeTitleSize( dialog2, x) (dialog2)->flags.data.maxtitlesize = (x)
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_Dispatch_h
#define __Desk_Dispatch_h
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*Desk_dispatch_proc)();
extern int Dispatch(int value, int size, int table[],
Desk_dispatch_proc functions[],
int arg0, int arg1, int arg2, int arg3);
#ifdef __cplusplus
}
#endif
#endif
#ifndef __Desk_Drag_h
#define __Desk_Drag_h
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __Desk_Core_h
#include "Core.h"
#endif
extern void Desk_Drag_Initialise(Desk_bool attachNULLhandler);
typedef void (* Desk_drag_handler) (void *userdata);
extern Desk_drag_handler Desk_drag_currentupdate;
extern Desk_drag_handler Desk_drag_currentcomplete;
extern void *Desk_drag_currentuserdata;
extern void Desk_Drag_SetHandlers(Desk_drag_handler uproc, Desk_drag_handler cproc,