objsupport 2.66 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 20 21
/* 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:     objsupport.h
 * Purpose:  Standard Dialogue support library.
 * Author:   Neil Kelleher
 * History:  5-Jul-1994 : NK: created
 */

#include "stddef.h"
Richard Buckley's avatar
Richard Buckley committed
22 23
#include "objects.toolbox.h"
#include "objects.window.h"
Neil Turton's avatar
Neil Turton committed
24 25 26 27 28 29 30

/* copies named template to a buffer, returns NULL if can't find or no memory */

char *copy_template(char *name);

/* creates object from buffer then frees it */

31
_kernel_oserror *create_from_template(char *template_id, ObjectID *handle);
Neil Turton's avatar
Neil Turton committed
32 33 34 35

/* zaps gadget attributes, NOTE: use macro form below */

_kernel_oserror *__zap_gadget(char *tm,ComponentID id,int off,int val);
36
_kernel_oserror *__zap_gadget_string(char *tm,ComponentID id,int off,const char* val,int offlen);
Neil Turton's avatar
Neil Turton committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
int *__read_gadget(char *tm,ComponentID id,int off);

/* zaps window template, NOTE: use macro form below */

_kernel_oserror *__zap_window(char *tm,int off,int val);
int *__read_window(char *tm,int off);

/* deletes a gadget from a template */

_kernel_oserror *delete_gadget(char *tm,ComponentID id);

/* zap_gadget(char *template,typedef GadgetType, ComponentID component, structure member, value */

#define zap_gadget(a,b,c,d,e) __zap_gadget(a,c,sizeof(GadgetHeader) + offsetof(b,d),(int) (e))

52 53 54 55 56 57 58 59
/* zap_gadget_string(char *template,typedef GadgetType, ComponentID component, structure member, value, structure member (length)
 * This is used to up the max buffer length if the string was too long to fit in the buffer.
 * This avoids problems of too small buffer lengths in Res files causing problems.
 */

#define zap_gadget_string(a,b,c,d,e,f) __zap_gadget_string(a,c,sizeof(GadgetHeader) + offsetof(b,d),(e), sizeof(GadgetHeader)+offsetof(b,f))


Neil Turton's avatar
Neil Turton committed
60 61 62 63 64 65 66 67 68 69 70
#define zap_gadget_header(a,c,d,e) __zap_gadget(a,c, offsetof(GadgetHeader,d),(int) (e))

/* zap_window(char *template,WindowTemplate structure member,value) */

#define zap_window(a,d,e) __zap_window(a,offsetof(WindowTemplate,d),(int) (e))

#define read_gadget(a,b,c,d) __read_gadget(a,c,sizeof(GadgetHeader) + offsetof(b,d))

#define read_gadget_header(a,c,d) __read_gadget(a,c, offsetof(GadgetHeader,d))

#define read_window(a,d) __read_window(a,offsetof(WindowTemplate,d))