toolbox 10.9 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/* Copyright 1996 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* File:    Toolbox.h
 * Purpose: The RISC OS Toolbox module
 * Author:  Ian Johnson
 * History: 8-Dec-93: IDJ: created
 *          18-Apr-94: IDJ: removed options string from object hdr.
Kevin Bracey's avatar
Kevin Bracey committed
20
 *          02-Feb-97: EPW: Added Toolbox_ShowObject_AtPointer
Neil Turton's avatar
Neil Turton committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
 *
 */


#ifndef __toolbox_h
#define __toolbox_h


/* --------------------------------------- fundamental types ------------------------------------------ */

typedef int            ObjectID;                 /* abstract Object ID (as used by client apps). */
typedef int            ComponentID;              /* component ID within an Object (eg gadget in Window) */
typedef int            ObjectClass;              /* the abstract class of an Object */

#define NULL_ObjectID    (ObjectID)0
#define NULL_ComponentID (ComponentID)-1


typedef struct                                   /* block filled in by Toolbox on Wimp Poll */
{
        ObjectID    ancestor_id;                 /* object's "ancestor" */
        ComponentID ancestor_component;
        ObjectID    parent_id;                   /* object's "parent" */
        ComponentID parent_component;
        ObjectID    self_id;                     /* object on which an event occurred */
        ComponentID self_component;
} IDBlock;



typedef struct
{
        int data [4];
} MessagesFD;                                    /* a MessageTrans file descriptor */





/* ----------------------------------------- Object templates ----------------------------------------- */

#define MAX_OBJECT_NAME 12

/* flags */

#define Object_CreateOnLoad      0x00000001
#define Object_ShowOnCreate      0x00000002
#define Object_Shared            0x00000004
#define Object_Ancestor          0x00000008

#define Object_ValidFlags        0x0000000f

/* template definition */

typedef struct                                    /* an object template header (after relocation) */
{
    ObjectClass        class;                     /* class of the object */
    int                flags;                     /* generic flags (see above) */
    int                version;                   /* object class module version */
    char               name[MAX_OBJECT_NAME];     /* name given to template for use in Toolbox_ObjectCreate */
    int                total_size;                /* size of whole object (inc header) */
    void              *body;                      /* object body (defined by object class module) */
    int                body_size;                 /* sizeof *body */
} ObjectTemplateHeader;


/* --------------------------------- Resource file format --------------------------------------------- */

#define ResourceFileVersion 101


typedef int StringReference;           /* offset into Object's string table */
typedef int MessageReference;          /* offset into Object's messages table */

/* relocations */

/* directives */

#define Relocate_StringReference     1
#define Relocate_MsgReference        2
#define Relocate_SpriteAreaReference 3
#define Relocate_ObjectOffset        4

typedef struct
{
        int             word_to_relocate;
        int             directive;

} Relocation;

typedef struct
{
        int             num_relocations;
        Relocation      relocations[1];
} RelocationTable;




/* Resource file header */

typedef struct
{
        int             file_id;         /* should be 'RESF' */
        int             version_number;  /* resource file version number * 100, eg 1.32 is 132 */
        int             object_offset;   /* byte offset of first template from start of file */
} ResourceFileHeader;


/* Resource file Object template */

typedef struct
{
        int                  string_table_offset;
        int                  message_table_offset;
        int                  relocation_table_offset;
        ObjectTemplateHeader hdr;

} ResourceFileObjectTemplateHeader;

/* ------------------------------------------- Toolbox SWIs ------------------------------------------- */

#define Toolbox_SWIChunkBase    0x44ec0

/* SWI Numbers */

#define Toolbox_CreateObject           (Toolbox_SWIChunkBase + 0)
#define Toolbox_DeleteObject           (Toolbox_SWIChunkBase + 1)
#define Toolbox_CopyObject             (Toolbox_SWIChunkBase + 2)
#define Toolbox_ShowObject             (Toolbox_SWIChunkBase + 3)
#define Toolbox_HideObject             (Toolbox_SWIChunkBase + 4)
#define Toolbox_GetObjectState         (Toolbox_SWIChunkBase + 5)
#define Toolbox_ObjectMiscOp           (Toolbox_SWIChunkBase + 6)
#define Toolbox_SetClientHandle        (Toolbox_SWIChunkBase + 7)
#define Toolbox_GetClientHandle        (Toolbox_SWIChunkBase + 8)
#define Toolbox_GetObjectClass         (Toolbox_SWIChunkBase + 9)
#define Toolbox_GetParent              (Toolbox_SWIChunkBase + 10)
#define Toolbox_GetAncestor            (Toolbox_SWIChunkBase + 11)
#define Toolbox_GetTemplateName        (Toolbox_SWIChunkBase + 12)
#define Toolbox_RaiseToolboxEvent      (Toolbox_SWIChunkBase + 13)
#define Toolbox_GetSysInfo             (Toolbox_SWIChunkBase + 14)
#define Toolbox_Initialise             (Toolbox_SWIChunkBase + 15)
#define Toolbox_LoadResources          (Toolbox_SWIChunkBase + 16)

#define Toolbox_DeRegisterObjectModule (Toolbox_SWIChunkBase + 58)
#define Toolbox_TemplateLookUp         (Toolbox_SWIChunkBase + 59)
#define Toolbox_GetInternalHandle      (Toolbox_SWIChunkBase + 60)
#define Toolbox_RegisterObjectModule   (Toolbox_SWIChunkBase + 61)
#define Toolbox_RegisterPreFilter      (Toolbox_SWIChunkBase + 62)
#define Toolbox_RegisterPostFilter     (Toolbox_SWIChunkBase + 63)


/* flags for Toolbox_GetSysInfo */

#define Toolbox_GetSysInfo_TaskName                      0
#define Toolbox_GetSysInfo_MessagesFD                    1
#define Toolbox_GetSysInfo_DirName                       2
#define Toolbox_GetSysInfo_TaskHandle                    3
#define Toolbox_GetSysInfo_SpriteArea                    4


/* flags for Toolbox_CreateObject */

#define Toolbox_CreateObject_InCore             0x00000001


/* flags for Toolbox_DeleteObject */

#define Toolbox_DeleteObject_DontRecurse        0x00000001


/* flags for Toolbox_CopyObject */

#define Toolbox_CopyObject_DontRecurse          0x00000001


/* return values for Toolbox_GetObjectState */

#define Toolbox_GetObjectState_Showing         0x00000001


/* flags for Toolbox_RegisterPreFilter */

#define Toolbox_RegisterPreFilter_Remove        0x00000001


/* flags and types for Toolbox_RegisterPostFilter */

#define Toolbox_RegisterPostFilter_Remove       0x00000001
#define Toolbox_RegisterPostFilter_WimpEvent             1
#define Toolbox_RegisterPostFilter_WimpMessage           2
#define Toolbox_RegisterPostFilter_ToolboxEvent          3

#define Toolbox_RegisterPostFilter_AnyClass            (-1)
#define Toolbox_RegisterPostFilter_WimpObject            0

typedef struct
{
        int          code;                       /* pair of event code and object class */
        ObjectClass  class;                      /* used in Toolbox_RegisterPostFilter  */
} EventInterest;



/* flags and types for Toolbox_ShowObject */

#define Toolbox_ShowObject_AsMenu               0x00000001
#define Toolbox_ShowObject_AsSubMenu            0x00000002
Kevin Bracey's avatar
Kevin Bracey committed
229
#define Toolbox_ShowObject_AsSubWindow		0x00000004
Neil Turton's avatar
Neil Turton committed
230 231 232 233

#define Toolbox_ShowObject_Default                       0
#define Toolbox_ShowObject_FullSpec                      1
#define Toolbox_ShowObject_TopLeft                       2
Kevin Bracey's avatar
Kevin Bracey committed
234 235
#define Toolbox_ShowObject_Centre                        3
#define Toolbox_ShowObject_AtPointer                     4
Neil Turton's avatar
Neil Turton committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342

typedef struct
{
        int x;
        int y;
} TopLeft;



/* ------------------------------------------- Toolbox Events ----------------------------------------- */

/* event codes */


#define Toolbox_Error             (Toolbox_SWIChunkBase + 0)
#define Toolbox_ObjectAutoCreated (Toolbox_SWIChunkBase + 1)
#define Toolbox_ObjectDeleted     (Toolbox_SWIChunkBase + 2)


typedef struct
{
        unsigned int     size;
        int              reference_number;
        unsigned int     event_code;
        unsigned int     flags;
} ToolboxEventHeader;


typedef struct
{
        ToolboxEventHeader hdr;
        union
        {
            char bytes [212];
            int  words [53];
        } data;

} ToolboxEvent;    /* generic structure of a Toolbox Event block */

typedef struct
{
        ObjectID     self;
        ComponentID  component;
        ToolboxEvent event;
} ToolboxEventMsg;


/* a Toolbox error event */

typedef struct
{
        ToolboxEventHeader hdr;
        int                errnum;
        char               errmess [256-20-sizeof(ToolboxEventHeader)-sizeof(ObjectID)-sizeof(ComponentID)-sizeof(int)];
} ToolboxErrorEvent;


/* object has been auto-created event */

typedef struct
{
        ToolboxEventHeader hdr;
        char               template_name [256-20-sizeof(ToolboxEventHeader)-sizeof(ObjectID)-sizeof(ComponentID)];
} ToolboxObjectAutoCreatedEvent;

/* object has been deleted */

typedef struct
{
        ToolboxEventHeader hdr;
} ToolboxObjectDeletedEvent;




/* ----------------------------------------- Toolbox Error Numbers ------------------------------------ */

#define Program_Error               0x1b000000

#define Toolbox_ErrorBase           (Program_Error | 0x80cb00)

#define Toolbox_NoMem               (Toolbox_ErrorBase + 0)
#define Toolbox_BadSWI              (Toolbox_ErrorBase + 1)
#define Toolbox_InvalidObjectID     (Toolbox_ErrorBase + 2)
#define Toolbox_NotaToolboxTask     (Toolbox_ErrorBase + 3)
#define Toolbox_NoDirName           (Toolbox_ErrorBase + 4)
#define Toolbox_NoMsgsFD            (Toolbox_ErrorBase + 5)
#define Toolbox_NoIDBlock           (Toolbox_ErrorBase + 6)
#define Toolbox_BadResFile          (Toolbox_ErrorBase + 7)
#define Toolbox_TasksActive         (Toolbox_ErrorBase + 8)
#define Toolbox_TemplateNotFound    (Toolbox_ErrorBase + 9)
#define Toolbox_NoSuchPreFilter     (Toolbox_ErrorBase + 0xa)
#define Toolbox_NotaResFile         (Toolbox_ErrorBase + 0xb)
#define Toolbox_BadResFileVersion   (Toolbox_ErrorBase + 0xc)
#define Toolbox_BadFlags            (Toolbox_ErrorBase + 0xd)
#define Toolbox_BadGetSysInfoReason (Toolbox_ErrorBase + 0xe)


/* ------------------------------------------- Toolbox Service Calls ---------------------------------- */

#define Service_ToolboxBase         (Toolbox_SWIChunkBase+1)

#define Service_ToolboxStarting     (Service_ToolboxBase + 0)
#define Service_ToolboxTaskBorn     (Service_ToolboxBase + 1)
#define Service_ToolboxTaskDied     (Service_ToolboxBase + 2)

#endif