template 4.94 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 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
/* 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.
 */
/****************************************************************************
 * This source file was written by Acorn Computers Limited. It is part of   *
 * the RISCOS library for writing applications in C for RISC OS. It may be  *
 * used freely in the creation of programs for Archimedes. It should be     *
 * used with Acorn's C Compiler Release 3 or later.                         *
 *                                                                          *
 ***************************************************************************/

/*
 * Title:    template.h
 * Purpose:  template file management
 *
 */

/*
 * This file contains functions used for loading/manipulating templates
 * (typically set up using the template editor). The templates are assumed
 * to be held in a file "Templates" in the application's directory.
 * The dialogue box module of the "wimp" library, uses these templates when
 * creating dialogue boxes.
 *
 */

#ifndef __template_h
#define __template_h

#ifndef BOOL
#define BOOL int
#define TRUE 1
#define FALSE 0
#endif

typedef  struct template__str
{
  struct template__str *next;
  char * workspace;
  int workspacesize;
  char *font;
  char name[12];
  wimp_wind window;
} template;


/* ----------------------------- template_copy -----------------------------
 * Description:   Create a copy of a template.
 *
 * Parameters:    template *from -- the original template
 * Returns:       a pointer to a copy of "from".
 * Other Info:    Copying also includes fixing up pointers into workspace for
 *                indirected icons/title.  Also includes allocation of this
 *                space.
 *
 */

template *template_copy (template *from);


/* -------------------------- template_readfile ----------------------------
 * Description:   Reads the template file into a linked list of templates.
 *
 * Parameters:    char *name -- name of template file
 * Other Info:    Note that a call is made to resspr_area(), in order to
 *                fix up a window's sprite pointers, so you must have
 *                already called resspr_init.
 *
 */

#define template_readfile(s) template_init()


/* ----------------------------- template_find -----------------------------
 * Description:   Finds a named template in the template list.
 *
 * Parameters:    char *name -- the name of the template (as given in FormEd)
 * Returns:       a pointer to the found template.
 * Other Info:    none.
 *
 */

template *template_find(char *name);


/* ---------------------------- template_loaded ----------------------------
 * Description:   Sees if there is anything in the template list.
 *
 * Parameters:    void
 * Returns:       Non-zero if there is something in the template list.
 * Other Info:    none.
 *
 */

BOOL template_loaded(void);


/* ---------------------------- template_use_fancyfonts --------------------
 * Description:   Provides a font usage array for loading templates which
 *                use fonts other than 'system font'
 *
 * Parameters:    void.
 * Returns:       void.
 * Other Info:    This function should be called once BEFORE template_init.
 *                It allocates a font usage array, which it uses to 'lose'
 *                any fancy fonts used, when your program exits.
 *                It installs a C exit handler to do this.
 *                This function is useful if your dialogue boxes use fonts
 *                other than system font.
 *
 */

void template_use_fancyfonts(void);


/* ---------------------------- template_init ------------------------------
 * Description:   Initialise ready for use of templates.
 *
 * Parameters:
 * Returns:       void.
 * Other Info:    Should be called before any ops which use templates
 *                (eg dialogue box creation).
 *                The amount of space used is optimised to be the least
 *                possible.
 *
 */

void  template_init(void);


/* --------------------------- template_syshandle --------------------------
 * Description:   Get a pointer to the underlying window used to create a
 *                template.
 *
 * Parameters:    char *templatename.
 * Returns:       Pointer to template's underlying window (0 if template
 *                not found).
 * Other Info:    Any changes made to the wimp_wind structure will affect
 *                future windows generated using this template.
 *
 */

wimp_wind *template_syshandle(char *name);

#endif

/* end template.h */