Commit 784a5ca6 authored by Neil Turton's avatar Neil Turton
Browse files

Import from cleaned 360 CD

parents
No related merge requests found
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
c/** gitlab-language=c linguist-language=c linguist-detectable=true
h/** gitlab-language=c linguist-language=c linguist-detectable=true
cmhg/** gitlab-language=cmhg linguist-language=cmhg linguist-detectable=true
*,fe1 gitlab-language=make linguist-language=make linguist-detectable=true
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
# Project: DCS_Quit
# Toolflags:
CCflags = -c -depend !Depend -IC: -throwback -zM -fah -Ddebugging=1 -DDEBUG_MEMORY -zps1
C++flags = -c -depend !Depend -throwback -IC:
Pascalflags = -c -depend !Depend -throwback -IP:
Linkflags = -m -c++ -o $@
ObjAsmflags = -depend !Depend -ThrowBack -Stamp -quit -CloseExec
CMHGflags =
LibFileflags = -c -o $@
Squeezeflags = -o $@
AAsmflags = -depend !Depend -quit -CloseExec -To $@ -From
# Final targets:
@.DCS_Quit: @.o.create @.o.delete @.o.events @.o.hide @.o.miscop \
@.o.show @.o.task @.o.Modhdr c:o.stubs @.o.main @.^.common.debuglib \
@.o.getstate @.o.dcsres @.o.dcsmess @.o.quitres @.o.quitmess
link $(linkflags) @.o.create @.o.delete @.o.events @.o.hide \
@.o.miscop @.o.show @.o.task @.o.Modhdr c:o.stubs @.o.main \
@.^.common.debuglib @.o.getstate @.o.dcsres @.o.dcsmess @.o.quitres @.o.quitmess
# User-editable dependencies:
@.o.dcsmess: @.Messages.DCS
resgen dcsmess_file @.o.dcsmess @.Messages.DCS Resources.DCS.Messages
@.o.dcsres: @.Resources.DCS
resgen dcsres_file @.o.dcsres @.Resources.DCS Resources.DCS.Res
@.o.quitmess: @.Messages.quit
resgen quitmess_file @.o.quitmess @.Messages.quit Resources.Quit.Messages
@.o.quitres: @.Resources.quit
resgen quitres_file @.o.quitres @.Resources.quit Resources.Quit.Res
# Static dependencies:
@.o.copy: @.c.copy
cc $(ccflags) -o @.o.copy @.c.copy
@.o.create: @.c.create
cc $(ccflags) -o @.o.create @.c.create
@.o.delete: @.c.delete
cc $(ccflags) -o @.o.delete @.c.delete
@.o.events: @.c.events
cc $(ccflags) -o @.o.events @.c.events
@.o.hide: @.c.hide
cc $(ccflags) -o @.o.hide @.c.hide
@.o.miscop: @.c.miscop
cc $(ccflags) -o @.o.miscop @.c.miscop
@.o.show: @.c.show
cc $(ccflags) -o @.o.show @.c.show
@.o.task: @.c.task
cc $(ccflags) -o @.o.task @.c.task
@.o.Modhdr: @.cmhg.Modhdr
cmhg @.cmhg.Modhdr -o @.o.Modhdr
@.o.main: @.c.main
cc $(ccflags) -o @.o.main @.c.main
@.o.getstate: @.c.getstate
cc $(ccflags) -o @.o.getstate @.c.getstate
# Dynamic dependencies:
# Makefile for DCS
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 06-Jan-94 AMcC Created
#
#
# Component specific options:
#
COMPONENT = DCS
ROM_MODULE = aof.${COMPONENT}
#
# Export Paths for Messages module
#
RESDIR = <resource$dir>.Resources2
#
# Generic options:
#
MKDIR = cdir
CC = cc
CMHG = cmhg
CP = copy
LD = link
RM = remove
WIPE = -wipe
CPFLAGS = ~cfr~v
WFLAGS = ~c~v
CFLAGS = -c -depend !Depend ${INCLUDES} -zM -ffah -zps1 ${DFLAGS}
DFLAGS = -DROM
INCLUDES = -Itbox:,C:
#
# Libraries
#
ANSILIB = CLib:o.ansilib
CLIB = CLIB:o.stubs
RLIB = RISCOSLIB:o.risc_oslib
ROMCSTUBS = RISCOSLIB:o.romcstubs
ABSSYM = RISC_OSLib:o.abssym
TBOXLIB = tbox:tboxlib
OBJS =\
o.ModNoDebug\
o.create\
o.delete\
o.events\
o.getstate\
o.hide\
o.main\
o.miscop\
o.show\
o.task
#
# Rule patterns
#
.c.o:; ${CC} ${CFLAGS} -o $@ $<
.cmhg.o:; ${CMHG} -O $@ $<
#
# Main rules:
#
#
rom: ${ROM_MODULE}
@echo ${COMPONENT}: Module built (ROM)
install_rom: ${ROM_MODULE}
${CP} ${ROM_MODULE} ${INSTDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: Module installed (ROM)
resources: Messages.DCS Resources.DCS Messages.Quit Resources.Quit
${MKDIR} ${RESDIR}.DCS
${CP} Messages.DCS ${RESDIR}.DCS.Messages ${CPFLAGS}
${CP} Resources.DCS ${RESDIR}.DCS.Res ${CPFLAGS}
|
${MKDIR} ${RESDIR}.Quit
${CP} Messages.Quit ${RESDIR}.Quit.Messages ${CPFLAGS}
${CP} Resources.Quit ${RESDIR}.Quit.Res ${CPFLAGS}
|
@echo ${COMPONENT}: resource files copied to Messages module
clean:
${WIPE} o.* ${WFLAGS}
${WIPE} aof ${WFLAGS}
${WIPE} linked ${WFLAGS}
${WIPE} map ${WFLAGS}
@echo ${COMPONENT}: cleaned
${ROM_MODULE}: ${OBJS} ${TBOXLIB} ${ROMCSTUBS}
${MKDIR} aof
${LD} -o $@ -aof ${OBJS} ${TBOXLIB} ${ROMCSTUBS}
# final link for ROM Image (using given base address)
rom_link:
${MKDIR} linked
${MKDIR} map
${LD} -o linked.${COMPONENT} -bin -base ${ADDRESS} ${ROM_MODULE} ${ABSSYM} \
-map > map.${COMPONENT}
truncate map.${COMPONENT} linked.${COMPONENT}
${CP} linked.${COMPONENT} ${LINKDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: rom_link complete
#---------------------------------------------------------------------------
# Dynamic dependencies:
# Project: DCSQuit
# Toolflags:
CCflags = -c -depend !Depend -IC: -throwback -zM -ffah -zps1
C++flags = -c -depend !Depend -throwback -IC:
Pascalflags = -c -depend !Depend -throwback -IP:
Linkflags = -m -c++ -o $@
ObjAsmflags = -depend !Depend -ThrowBack -Stamp -quit -CloseExec
CMHGflags =
LibFileflags = -c -o $@
Squeezeflags = -o $@
AAsmflags = -depend !Depend -quit -CloseExec -To $@ -From
# Final targets:
@.DCS_Quit: @.o.copy @.o.create @.o.delete @.o.events @.o.getstate @.o.hide \
@.o.main @.o.miscop @.o.show @.o.task c:o.stubs @.^.common.tboxlib @.o.modnodebug \
@.o.dcsmess @.o.dcsres @.o.quitmess @.o.quitres
link $(linkflags) @.o.copy @.o.create @.o.delete @.o.events \
@.o.getstate @.o.hide @.o.main @.o.miscop @.o.show @.o.task c:o.stubs @.^.common.tboxlib \
@.o.modnodebug @.o.dcsmess @.o.dcsres @.o.quitmess @.o.quitres
# User-editable dependencies:
@.o.dcsmess: @.Messages.DCS
resgen dcsmess_file @.o.dcsmess @.Messages.DCS Resources.DCS.Messages
@.o.dcsres: @.Resources.DCS
resgen dcsres_file @.o.dcsres @.Resources.DCS Resources.DCS.Res
@.o.quitmess: @.Messages.quit
resgen quitmess_file @.o.quitmess @.Messages.quit Resources.Quit.Messages
@.o.quitres: @.Resources.quit
resgen quitres_file @.o.quitres @.Resources.quit Resources.Quit.Res
# Static dependencies:
@.o.copy: @.c.copy
cc $(ccflags) -o @.o.copy @.c.copy
@.o.create: @.c.create
cc $(ccflags) -o @.o.create @.c.create
@.o.delete: @.c.delete
cc $(ccflags) -o @.o.delete @.c.delete
@.o.events: @.c.events
cc $(ccflags) -o @.o.events @.c.events
@.o.getstate: @.c.getstate
cc $(ccflags) -o @.o.getstate @.c.getstate
@.o.hide: @.c.hide
cc $(ccflags) -o @.o.hide @.c.hide
@.o.main: @.c.main
cc $(ccflags) -o @.o.main @.c.main
@.o.miscop: @.c.miscop
cc $(ccflags) -o @.o.miscop @.c.miscop
@.o.show: @.c.show
cc $(ccflags) -o @.o.show @.c.show
@.o.task: @.c.task
cc $(ccflags) -o @.o.task @.c.task
@.o.modnodebug: @.cmhg.modnodebug
cmhg @.cmhg.modnodebug -o @.o.modnodebug
# Dynamic dependencies:
# 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.
#
# Makefile for DCS
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 06-Jan-94 AMcC Created
#
#
# Component specific options:
#
COMPONENT = DCS
ROM_MODULE = aof.${COMPONENT}
#
# Export Paths for Messages module
#
RESDIR = <resource$dir>.Resources2
#
# Generic options:
#
MKDIR = cdir
CC = cc
CMHG = cmhg
CP = copy
LD = link
RM = remove
WIPE = -wipe
CPFLAGS = ~cfr~v
WFLAGS = ~c~v
CFLAGS = -c -depend !Depend ${INCLUDES} -zM -ffah -zps1 ${DFLAGS}
DFLAGS = -DROM
INCLUDES = -Itbox:,C:
#
# Libraries
#
ANSILIB = CLib:o.ansilib
CLIB = CLIB:o.stubs
RLIB = RISCOSLIB:o.risc_oslib
ROMCSTUBS = RISCOSLIB:o.romcstubs
ABSSYM = RISC_OSLib:o.abssym
TBOXLIB = tbox:tboxlib
OBJS =\
o.ModNoDebug\
o.create\
o.delete\
o.events\
o.getstate\
o.hide\
o.main\
o.miscop\
o.show\
o.task
#
# Rule patterns
#
.c.o:; ${CC} ${CFLAGS} -o $@ $<
.cmhg.o:; ${CMHG} -O $@ $<
#
# Main rules:
#
#
rom: ${ROM_MODULE}
@echo ${COMPONENT}: Module built (ROM)
install_rom: ${ROM_MODULE}
${CP} ${ROM_MODULE} ${INSTDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: Module installed (ROM)
resources: Messages.DCS Resources.DCS Messages.Quit Resources.Quit
${MKDIR} ${RESDIR}.DCS
${CP} Messages.DCS ${RESDIR}.DCS.Messages ${CPFLAGS}
${CP} Resources.DCS ${RESDIR}.DCS.Res ${CPFLAGS}
|
${MKDIR} ${RESDIR}.Quit
${CP} Messages.Quit ${RESDIR}.Quit.Messages ${CPFLAGS}
${CP} Resources.Quit ${RESDIR}.Quit.Res ${CPFLAGS}
|
@echo ${COMPONENT}: resource files copied to Messages module
clean:
${WIPE} o.* ${WFLAGS}
${WIPE} aof ${WFLAGS}
${WIPE} linked ${WFLAGS}
${WIPE} map ${WFLAGS}
@echo ${COMPONENT}: cleaned
${ROM_MODULE}: ${OBJS} ${TBOXLIB} ${ROMCSTUBS}
${MKDIR} aof
${LD} -o $@ -aof ${OBJS} ${TBOXLIB} ${ROMCSTUBS}
# final link for ROM Image (using given base address)
rom_link:
${MKDIR} linked
${MKDIR} map
${LD} -o linked.${COMPONENT} -bin -base ${ADDRESS} ${ROM_MODULE} ${ABSSYM} \
-map > map.${COMPONENT}
truncate map.${COMPONENT} linked.${COMPONENT}
${CP} linked.${COMPONENT} ${LINKDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: rom_link complete
#---------------------------------------------------------------------------
# Dynamic dependencies:
# Messages file for the DCS Object Module
E01:Memory allocation failed.
E02:There are still DCS tasks active.
# Messages file for the Quit Object Module
File added
File added
/* 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.
*/
/* Title: create.c
* Purpose: create a Generic Object
* Author: IDJ
* History: 7-Oct-93: IDJ: created
*
*/
#include <stdio.h>
#include "stdlib.h"
#include "stddef.h"
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objsupport.h"
#include "slist.h"
#include "string32.h"
#include "objects.toolbox.h"
#include "objects.window.h"
#include "objects.dcs.h"
#include "objects.quit.h"
#include "object.h"
#include "task.h"
#include "create.h"
extern _kernel_oserror *create_object (_kernel_swi_regs *r, TaskDescriptor *t,int class)
{
/*
* request to create an object
* R0 = 0
* R1 = Object ID
* R2 = 0 (will be internal handle for other SWIs
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* bit 0 set => create from memory
* R1 -> description block
*/
/*
* The Toolbox has already checked that this is not just a create
* call for a shared Object which already exists.
* We create a new Object, and add it to the list of Objects for this
* task.
* We need to remember the ObjectID passed to us by the Toolbox, so
* that we can identify this Object if we are given an ID from the
* client's "id block".
* Note that if any template names are held in the Object, then we
* create an Object from that template, and store its ID.
* Note also that the Toolbox has changed the client's R1 to point
* at an in-core template, if it wasn't already!
*/
_kernel_swi_regs *user_regs = USER_REGS(r);
ObjectTemplateHeader *obj_template = (ObjectTemplateHeader *)(user_regs->r[1]);
DCSTemplate *dcs_template = (DCSTemplate *)(obj_template->body);
_kernel_oserror *er=NULL;
char *name,*title,*template;
char buf[256];
Object *new;
int len,temp;
/* all gadgets begin at class base x 0x10 */
int Message_Gadget = (class<<4) +0;
new = (Object *) slist_add_new((void *) &(t->object_list),sizeof(Object),"New DCS/Quit object");
if (!new) goto error2;
new->window = r->r[0];
new->flags = dcs_template->flags | ((class == DCS_ObjectClass) ? 0 : QClass);
new->id = (ObjectID) r->r[1];
/* create the window, allowing for alternative window, note that DCS and Quit have same templates
and this is widely assumed. If this ceases to be, then the code will need separating out. */
if ((name = dcs_template->window) == NULL) {
if (class == DCS_ObjectClass) name = "_DCS";
else name = "_Quit";
}
if ((template = copy_template(name)) == NULL) goto error2;
/* set the title ... */
len = dcs_template->max_title;
if ((title = dcs_template->title) == NULL) {
/* if we are using the default title, then set max_len to
* maximum(template->max_len,actual_length)
*/
title = buf;
_swix(Toolbox_GetSysInfo, _IN(0) | _IN(1) | _IN(2), 0, title,256);
temp = 1+string_length(title);
if (temp > len) len = temp;
}
DEBUG debug_output("create","Setting title of DCS/Quit object to %s\n",title);
if(new->flags & DCS_GenerateDialogueCompleted) zap_window(template,flags,
Window_AutoOpen | Window_AutoClose | Window_GenerateHasBeenHidden );
else
zap_window(template,flags,Window_AutoOpen | Window_AutoClose);
zap_window(template,window.title.indirect_text.buffer,title);
zap_window(template,window.title.indirect_text.buff_len,len);
/* set the message */
len = dcs_template->max_message;
if (dcs_template->message) {
zap_gadget(template,Button,Message_Gadget,value,dcs_template->message);
} else {
/* len = maximum (len,template_length) */
temp = *(read_gadget(template,Button,Message_Gadget,max_value));
if (temp > len) len = temp;
}
zap_gadget(template,Button,Message_Gadget,max_value,len);
if ((er=create_from_template(template, &new->window)) != NULL) goto error;
_swix(Toolbox_SetClientHandle, _IN(0) |_IN(1) |_IN(2), 0,new->window, new);
r->r[0] = (int) new;
return NULL;
error2:
er = make_error(DCS_NoMemory,0);
error:
if (new) slist_delete_member((void *) &(t->object_list),new);
return er;
}
/* 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.
*/
/* Title: delete.c
* Purpose: delete a Generic Object
* Author: IDJ
* History: 7-Oct-93: IDJ: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "slist.h"
#include "objects.toolbox.h"
#include "objects.dcs.h"
#include "object.h"
#include "task.h"
#include "delete.h"
extern _kernel_oserror *delete_object (_kernel_swi_regs *r, TaskDescriptor *t,int class)
{
/*
* request to delete an object
* R0 = 1
* R1 = Object ID
* R2 = internal handle returned when Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* bit 0 set => do not recursively delete the object
* R1 = Object ID
*/
/*
* The Toolbox has already checked that this is not just a delete
* call for a shared Object.
* We delete Object from the list of Objects for this
* task.
* If recursive delete is requested then we also call Toolbox_Delete
* for any Objects "attached" to this Object.
*/
ObjectID win = ((Object *)(r->r[2])) ->window;
slist_delete_member((void *) &(t->object_list),(void *) (r->r[2]));
return (_swix(Toolbox_DeleteObject,_IN(0)|_IN(1),0,win));
}
void _delete_object(Object *obj)
{
_swix(Toolbox_DeleteObject,_IN(0)|_IN(1),0,obj->window);
}
/* 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.
*/
/* Title: events.c
* Purpose: filters registered with the Toolbox. Events are delivered here.
* Author: IDJ
* History: 7-Oct-93: IDJ: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "slist.h"
#include "objects.toolbox.h"
#include "objects.dcs.h"
#include "objects.quit.h"
#include "object.h"
#include "events.h"
#include "task.h"
static Object *show_obj=NULL;
static DCSAboutToBeShownEvent show_ev;
static int r4,r5;
static int dcs_events[] = {DCS_DialogueCompleted,DCS_Discard,DCS_Cancel,DCS_Save};
static int quit_events[] = {Quit_DialogueCompleted,Quit_Cancel,Quit_Quit};
static _kernel_oserror *events_raise_event(ObjectID obj,ComponentID comp, int * ev_array)
{
_kernel_swi_regs regs;
ToolboxEvent event;
regs.r[0] = 0;
regs.r[1] = (int) obj;
regs.r[2] = (int) comp;
regs.r[3] = (int) &event;
event.hdr.size = sizeof(ToolboxEventHeader);
event.hdr.event_code = ev_array[comp & 0xff];
event.hdr.flags = 0;
return _kernel_swi(Toolbox_RaiseToolboxEvent,&regs,&regs);
}
extern _kernel_oserror *events_postfilter (_kernel_swi_regs *r)
{
/*
* called from the main Toolbox postfilter, when an event happens which
* this module has expressed an interest in.
* R0 = Wimp event reason code
* R1 ->client's Wimp event block
* R2 = Task Descriptor of task interested in the event
* R3 ->6-word "ID block" as passed to Toolbox_Initialise
*
*/
/*
* This function gets a pointer to the task interested in the event in
* R2 (since this was the value passed to Toolbox_RegisterPostFilter).
* If the event is dealt with by this module (eg ID block gets updated).
* then set R0 to non-null before return.
*/
int event_code = r->r[0];
TaskDescriptor *t = (TaskDescriptor *) r->r[2];
IDBlock *id_block = (IDBlock *)r->r[3];
wimp_PollBlock *poll_block = (wimp_PollBlock *)r->r[1];
/* we're only interested in toolbox events on our windows */
if (event_code != wimp_ETOOLBOX_EVENT)
return NULL;
switch (poll_block->toolbox_event.hdr.event_code) {
case ActionButton_Selected:
if (!(slist_find_member((void *) &(t->object_list),0,id_block->self_id)))
return NULL;
/* need to raise appropriate events */
{
Object *obj;
/* make sure its hidden */
_swix(Toolbox_HideObject, _IN(0) |_IN(1), 0, id_block->self_id);
/* we use the underlying window's client handle for storing the object */
_swix(Toolbox_GetClientHandle, _IN(0) | _IN(1) | _OUT(0), 0, id_block->self_id, &obj);
if (obj ->flags & QClass)
events_raise_event(obj->id,id_block->self_component,quit_events);
else events_raise_event(obj->id,id_block->self_component,dcs_events);
break;
}
case DCS_AboutToBeShown:
case Quit_AboutToBeShown:
/* have we got an about to be shown event ? No need to check for object validity
as these events should only be raised on DCS/Quit objects */
show_obj = slist_find_member((void *) &(t->object_list),1,id_block->self_id);
r4 = id_block->parent_id;
r5 = id_block->parent_component;
/* don't need to distinguish between Quit and DCS */
show_ev = *((DCSAboutToBeShownEvent *) (&poll_block->toolbox_event));
break;
case Window_HasBeenHidden:
{
/* need to get window -> dcs/quit object, then raise hidden event */
Object *obj;
if (!(slist_find_member((void *) &(t->object_list),0,id_block->self_id)))
return NULL;
/* we use the underlying window's client handle for storing the object */
_swix(Toolbox_GetClientHandle, _IN(0) | _IN(1) | _OUT(0), 0, id_block->self_id, &obj);
if (obj ->flags & QClass)
events_raise_event(obj->id,0,quit_events);
else events_raise_event(obj->id,0,dcs_events);
break;
}
default:
break;
}
return NULL;
}
extern _kernel_oserror *events_prefilter (_kernel_swi_regs *r)
{
/*
* called from the main Toolbox prefilter, when Wimp_Poll is called.
* R0 = mask passed to Wimp_Poll
* R1 ->client's poll block passed to Wimp_Poll
* R2 = Task Descriptor.
*
*/
/*
* This function gets a pointer to the current task in
* R2 (since this was the value passed to Toolbox_RegisterPreFilter).
* This function can enable additional events by zero-ing bits in
* r->r[0]
*/
/* if the previous call to the postfilter was for an about to be shown event,
then we now do the show */
if (show_obj) {
_kernel_swi_regs regs,dummy;
DEBUG debug_output("events","In prefilter, about to show object %8x\n",show_obj);
regs.r[0] = show_ev.hdr.flags;
regs.r[2] = show_ev.r2;
regs.r[3] = (int) &(show_ev.r3);
regs.r[4] = r4;
regs.r[5] = r5;
dummy.r[4] = (int) &regs;
show_do_show(&dummy,show_obj);
show_obj = NULL;
}
return NULL;
}
/* 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.
*/
/* Title: getstate.c
* Purpose: return state for a Generic Object
* Author: IDJ
* History: 7-Oct-93: IDJ: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.generic.h"
#include "object.h"
#include "task.h"
#include "getstate.h"
extern _kernel_oserror *getstate_object (_kernel_swi_regs *r, TaskDescriptor *t,int class)
{
/*
* request for info about an object
* R0 = 5
* R1 = Object ID
* R2 = internal handle returned when Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* R1 = Object ID
*/
/*
* return state in R0
*
*/
_kernel_swi_regs *user_regs = USER_REGS(r);
t=t; class =class;
return _swix(Toolbox_GetObjectState, _IN(0) | _IN(1) | _OUT(0), user_regs->r[0],
((Object *) (r->r[2])) ->window, &(r->r[0]));
}
/* 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.
*/
/* Title: hide.c
* Purpose: hide a Generic Object
* Author: IDJ
* History: 7-Oct-93: IDJ: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.generic.h"
#include "object.h"
#include "task.h"
#include "hide.h"
extern _kernel_oserror *hide_object (_kernel_swi_regs *r, TaskDescriptor *t, int class)
{
/*
* request to hide an object
* R0 = 4
* R1 = Object ID
* R2 = internal handle returned when Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* R1 = Object ID
*
*/
/*
* Remove the object from view. For efficiency, we should stop expressing
* interest in any events which can't happen whilst the Object is
* hidden.
*
*/
_kernel_swi_regs regs;
Object *obj = (Object *) r->r[2];
regs.r[0] = 0;
regs.r[1] = (int) obj->window; /* id of window */
return _kernel_swi(Toolbox_HideObject,&regs,&regs);
task_remove_filters(t);
}
/* 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.
*/
/* Title: main.c
* Purpose: main module of a DCS Object module
* Author: IDJ
* History: 7-Oct-93: IDJ: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "rmensure.h"
#include "objects.toolbox.h"
#include "objects.DCS.h"
#include "objects.Quit.h"
#include "object.h"
#include "create.h"
#include "delete.h"
#include "show.h"
#include "hide.h"
#include "getstate.h"
#include "miscop.h"
#include "events.h"
#include "task.h"
#include "main.h"
#define MAX_CLASS_SWI_METHODS 7
static _kernel_oserror *(*class_swi_methods [MAX_CLASS_SWI_METHODS])(_kernel_swi_regs *r, TaskDescriptor *t,int class) =
{
create_object,
delete_object,
NULL,
show_object,
hide_object,
getstate_object,
miscop_object
};
/* +++++++++++++++++++++++++++++++++ finalisation code +++++++++++++++++++++++++++++++++ */
#ifdef ROM
static _kernel_oserror *__ROM;
#endif
extern _kernel_oserror *DCS_final (int fatal, int podule, void *pw)
{
_kernel_swi_regs regs;
_kernel_oserror *e;
#ifndef ROM
extern int dcsmess_file(void);
extern int dcsres_file(void);
extern int quitmess_file(void);
extern int quitres_file(void);
#endif
IGNORE(fatal);
IGNORE(podule);
IGNORE(pw);
/*
* if tasks are active or modules registered, refuse to die
*/
if (task_any_active())
{
e = make_error (DCS_TasksActive, 0);
DEBUG debug_output ("finalise", "W:failed to finalise %s\n", e->errmess);
return e;
}
/*
* close our messages file
*/
messages_file_close();
#ifndef ROM
/*
* ... and deregister from ResourceFS
*/
regs.r[0] = dcsmess_file();
_kernel_swi (ResourceFS_DeregisterFiles, &regs, &regs);
regs.r[0] = dcsres_file();
_kernel_swi (ResourceFS_DeregisterFiles, &regs, &regs);
regs.r[0] = quitmess_file();
_kernel_swi (ResourceFS_DeregisterFiles, &regs, &regs);
regs.r[0] = quitres_file();
_kernel_swi (ResourceFS_DeregisterFiles, &regs, &regs);
#endif
/*
* ... and deregister from Toolbox
*/
regs.r[0] = 0;
regs.r[1] = DCS_ObjectClass;
_kernel_swi (Toolbox_DeRegisterObjectModule, &regs, &regs);
regs.r[0] = 0;
regs.r[1] = Quit_ObjectClass;
_kernel_swi (Toolbox_DeRegisterObjectModule, &regs, &regs);
/*
* free up memory we may have left allocated
*/
mem_free_all ();
#ifdef ROM
if(!__ROM) _swix(0xa2c41, 0);
#endif
return NULL;
}
/* ++++++++++++++++++++++++++++++++ initialisation code +++++++++++++++++++++++++++++++ */
_kernel_oserror *register_with_toolbox(void)
{
_kernel_swi_regs regs;
char *res_filename;
_kernel_oserror *e;
if (getenv ("DCS$Path") == NULL)
res_filename = "Resources:Resources.DCS.Res";
else
res_filename = "DCS:Res";
regs.r[0] = 0;
regs.r[1] = DCS_ObjectClass;
regs.r[2] = DCS_ClassSWI;
regs.r[3] = (int) res_filename;
if ((e = _kernel_swi (Toolbox_RegisterObjectModule, &regs, &regs)) != NULL)
return e;
/* register here with the Toolbox as an Object Module */
DEBUG debug_output ("init", "Registering with Toolbox\n");
if (getenv ("Quit$Path") == NULL)
res_filename = "Resources:Resources.Quit.Res";
else
res_filename = "Quit:Res";
regs.r[0] = 0;
regs.r[1] = Quit_ObjectClass;
regs.r[2] = Quit_ClassSWI;
regs.r[3] = (int) res_filename;
return( _kernel_swi (Toolbox_RegisterObjectModule, &regs, &regs));
}
extern _kernel_oserror *DCS_init(char *cmd_tail, int podule_base, void *pw)
{
char *messages_filename;
_kernel_oserror *e;
#ifndef ROM
_kernel_swi_regs regs;
extern int dcsmess_file(void);
extern int dcsres_file(void);
extern int quitmess_file(void);
extern int quitres_file(void);
#endif
IGNORE(cmd_tail);
IGNORE(podule_base);
IGNORE(pw);
#ifdef ROM
__ROM = _swix(0xa2c43, _IN(0), pw);
#endif
if ((e=rmensure("Window","Toolbox.Window","1.10")) !=NULL) return e;
DEBUG debug_set_var_name("DCS$Debug");
#ifndef ROM
/*
* register our resources with ResourceFS
*/
DEBUG debug_output ("init", "Registering messages files\n");
regs.r[0] = dcsmess_file();
if ((e = _kernel_swi (ResourceFS_RegisterFiles, &regs, &regs)) != NULL)
return e;
regs.r[0] = quitmess_file();
if ((e = _kernel_swi (ResourceFS_RegisterFiles, &regs, &regs)) != NULL)
return e;
DEBUG debug_output ("init", "Registering resource files\n");
regs.r[0] = dcsres_file();
if ((e = _kernel_swi (ResourceFS_RegisterFiles, &regs, &regs)) != NULL)
return e;
regs.r[0] = quitres_file();
if ((e = _kernel_swi (ResourceFS_RegisterFiles, &regs, &regs)) != NULL)
return e;
#endif
/*
* register our messages file with MessageTrans
*/
if (getenv ("DCS$Path") == NULL)
messages_filename = "Resources:Resources.DCS.Messages";
else
messages_filename = "DCS:Messages";
if ((e = messages_file_open (messages_filename)) != NULL)
return e;
/* /* Hmm what the **** do we do about two message files ??? */
/* register here with the Toolbox as an Object Module */
DEBUG debug_output ("init", "Registering with Toolbox\n");
return (register_with_toolbox());
}
/* +++++++++++++++++++++++++++++++++ service handler code ++++++++++++++++++++++++++++++ */
extern void DCS_services(int service_number, _kernel_swi_regs *r, void *pw)
{
IGNORE(pw);
switch (service_number)
{
case Service_ToolboxStarting:
register_with_toolbox();
break;
case Service_ToolboxTaskDied:
/*
* task dying - r0 holds task handle
*/
task_remove (r->r[0]);
break;
case Service_ToolboxTaskBorn:
/* Toolbox task has just started R0 == wimp task handle */
/*
* create a new "task descriptor"
*/
task_add (r->r[0]);
break;
default:
break;
}
}
/* ++++++++++++++++++++++++++++++++++++++ SWI code +++++++++++++++++++++++++++++++++++++ */
extern _kernel_oserror *DCS_SWI_handler(int swi_no, _kernel_swi_regs *r, void *pw)
{
_kernel_oserror *e = NULL;
TaskDescriptor *t;
IGNORE(pw);
switch (swi_no + DCS_SWIChunkBase)
{
case DCS_ClassSWI:
case Quit_ClassSWI:
if (r->r[0] < 0 || r->r[0] >= MAX_CLASS_SWI_METHODS)
{
/* /* make an error here */
}
else
{
t = task_find (r->r[3]);
if (t == NULL)
{
/* /* make an error here */
}
e = (*class_swi_methods[r->r[0]])(r, t,swi_no + DCS_SWIChunkBase);
}
break;
case DCS_PostFilter:
e = events_postfilter (r);
break;
case DCS_PreFilter:
e = events_prefilter (r);
break;
default:
break;
}
return e;
}
#if debugging
/* ++++++++++++++++++++++++++++++++++++++ star commands ++++++++++++++++++++++++++++++++++++*/
extern _kernel_oserror *DCS_commands(char *arg_string, int argc, int cmd_no, void *pw)
{
IGNORE(argc);
IGNORE(pw);
IGNORE(arg_string);
switch (cmd_no)
{
case 0:
mem_print_list();
break;
default:
break;
}
return NULL;
}
#endif
/* 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.
*/
/* Title: miscop.c
* Purpose: miscellanaous operations on a Generic Object
* Author: IDJ
* History: 7-Oct-93: IDJ: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.window.h"
#include "objects.dcs.h"
#include "object.h"
#include "task.h"
#include "miscop.h"
extern _kernel_oserror *miscop_object (_kernel_swi_regs *r, TaskDescriptor *t,int class)
{
/*
* do a "miscellaneous (ie object-specific) operation on an object
* R0 = 6
* R1 = Object ID
* R2 = internal handle returned when Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* R1 = Object ID
* R2 = method code
* R3-R9 method-specific data
*/
/*
* This is the routine which deals with all object-specific operations.
*
*
*/
/* it just so happens that Quit and DCS have the same methods */
_kernel_swi_regs *user_regs = USER_REGS(r);
_kernel_swi_regs regs;
_kernel_oserror *e= NULL;
regs = * user_regs;
regs.r[1] = ((Object *) r->r[2]) ->window; /* set object id to window id, as we pass most on */
switch(regs.r[2]) {
case DCS_GetWindowID:
user_regs->r[0] = regs.r[1];
break;
case DCS_SetMessage:
regs.r[2] = Button_SetValue;
regs.r[4] = regs.r[3];
regs.r[3] = class<<4; /* Cid of text */
return _kernel_swi(Toolbox_ObjectMiscOp,&regs,&regs);
break;
case DCS_GetMessage:
regs.r[2] = Button_GetValue;
regs.r[5] = regs.r[4];
regs.r[4] = regs.r[3];
regs.r[3] = class<<4; /* Cid of text */
e = _kernel_swi(Toolbox_ObjectMiscOp,&regs,&regs);
if (!e) user_regs->r[4] = regs.r[5]; /* update len */
break;
case DCS_SetTitle:
regs.r[2] = Window_SetTitle;
e = _kernel_swi(Toolbox_ObjectMiscOp,&regs,&regs);
break;
case DCS_GetTitle:
regs.r[2] = Window_GetTitle;
e = _kernel_swi(Toolbox_ObjectMiscOp,&regs,user_regs);
/* note user_regs, so R4 gets updated */
break;
default:
break;
}
return e;
}
/* 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.
*/
/* Title: show.c
* Purpose: show a Generic Object
* Author: IDJ
* History: 7-Oct-93: IDJ: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "strings.h"
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.dcs.h"
#include "objects.quit.h"
#include "object.h"
#include "task.h"
#include "show.h"
_kernel_oserror *show_do_show(_kernel_swi_regs *r,Object *obj)
{
_kernel_swi_regs regs;
memcpy(&regs, (_kernel_swi_regs*) r->r[4], sizeof(regs));
regs.r[1] = (int) obj->window; /* id of window */
return _kernel_swi(Toolbox_ShowObject,&regs,&regs);
}
extern _kernel_oserror *show_object (_kernel_swi_regs *r, TaskDescriptor *t,int class)
{
/*
* request to show an object
* R0 = 3
* R1 = Object ID
* R2 = internal handle returned when Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* R1 = Object ID
* R2 = "show type"
* 0 => default place
* 1 => R3 points to buffer with full data for showing
* 2 => R3 points to buffer with coordinates
* R3 = 0
* OR R3 -> buffer giving Object-specific data for showing this
* Object
* R4 = Parent Object ID
* R5 = Parent Component ID
*/
/*
* Function to "display" an Object on the screen. If R2 == 0, then
* display in default place.
* If Object has bit set to say warn before show, then we should just
* send Toolbox Event, and wait for the next call to Wimp_Poll after
* the event is delivered before the Object is actually shown
* (ie catch it in the prefilter).
*
*/
_kernel_swi_regs new, *user_regs = USER_REGS(r);
int coord[6];
Object *obj = (Object *) r->r[2];
IGNORE(t);
if (class == DCS_ObjectClass && (user_regs->r[2] ==0)) {
/* show DCS as default, ie. close to pointer */
new = *user_regs;
r->r[4] = (int) &new;
_swix(Wimp_GetPointerInfo, _IN(1),&coord);
coord[0] -= 60;
coord[1] += 60;
new.r[2] = Toolbox_ShowObject_TopLeft;
new.r[3] = (int) &coord;
}
if (((class == DCS_ObjectClass ) && (obj->flags & DCS_GenerateAboutToBeShown)) ||
((class == Quit_ObjectClass ) && (obj->flags & Quit_GenerateAboutToBeShown))) {
_kernel_swi_regs regs;
DCSAboutToBeShownEvent event;
int size;
regs.r[0] =0;
regs.r[1] = (int) obj->id;
regs.r[2] = 0;
regs.r[3] = (int) &event;
event.hdr.size = sizeof(event);
event.hdr.event_code = (class == DCS_ObjectClass ) ? DCS_AboutToBeShown : Quit_AboutToBeShown;
event.hdr.flags = user_regs->r[0];
event.r2 = user_regs->r[2];
if (event.r2 == Toolbox_ShowObject_Default) size = 0;
else if (event.r2 == Toolbox_ShowObject_TopLeft) size = 8;
else if (event.r2 == Toolbox_ShowObject_FullSpec) size = sizeof(event.r3);
memcpy(&event.r3, (void *) (user_regs->r[3]), size);
return _kernel_swi(Toolbox_RaiseToolboxEvent,&regs,&regs);
}
else show_do_show(r,obj);
return NULL;
}
/* 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.
*/
/* Title: task.c
* Purpose: task handling for the DCS module
* Author: IDJ
* History: 7-Oct-93: IDJ: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "slist.h"
#include "objects.toolbox.h"
#include "objects.dcs.h"
#include "objects.quit.h"
#include "objects.window.h"
#include "object.h"
#include "task.h"
static EventInterest toolbox_events_of_interest[] =
{{DCS_AboutToBeShown , DCS_ObjectClass},
{Quit_AboutToBeShown , Quit_ObjectClass},
{ActionButton_Selected , Window_ObjectClass},
{Window_HasBeenHidden , Window_ObjectClass},
{ -1, -1}
};
void task_add_filters(TaskDescriptor *t)
{
_kernel_swi_regs regs;
regs.r[0] = 0;
regs.r[1] = DCS_PostFilter;
regs.r[2] = (int) t;
regs.r[3] = Toolbox_RegisterPostFilter_ToolboxEvent;
regs.r[4] = (int)toolbox_events_of_interest;
_kernel_swi (Toolbox_RegisterPostFilter, &regs, &regs);
/*
* Add a prefilter
*/
regs.r[0] = 0;
regs.r[1] = DCS_PreFilter;
regs.r[2] = (int) t;
_kernel_swi (Toolbox_RegisterPreFilter, &regs, &regs);
}
void task_remove_filters(TaskDescriptor *t)
{
_kernel_swi_regs regs;
regs.r[0] = Toolbox_RegisterPostFilter_Remove;
regs.r[1] = DCS_PostFilter;
regs.r[2] = (int)t;
regs.r[3] = Toolbox_RegisterPostFilter_ToolboxEvent;
regs.r[4] = (int)toolbox_events_of_interest;
_kernel_swi (Toolbox_RegisterPostFilter, &regs, &regs);
regs.r[0] = Toolbox_RegisterPreFilter_Remove;
regs.r[1] = DCS_PreFilter;
regs.r[2] = (int)t;
_kernel_swi (Toolbox_RegisterPreFilter, &regs, &regs);
}
/*
* This module has a linked list of client tasks.
* task_add gets called when a Service_ToolboxTaskBorn
* service call goes round.
* The task is removed when the Service_WimpCloseDown is
* received.
* Each task keeps an Object list
*/
static TaskDescriptor *task__list = NULL;
int task_any_active(void)
{
return (task__list != NULL);
}
extern TaskDescriptor *task_find (int task_handle)
{
/*
* Function to return a TaskDescriptor corresponding to
* a task with a given Wimp handle
*/
return ((TaskDescriptor *) slist_find_member((void *) &task__list,0,task_handle));
}
extern void task_remove (int task_handle)
{
/*
* Function to remove a task descriptor from the list, given its
* Wimp task handle. Memory is freed, and we also delete any objects
* owned by the exiting task.
*/
_kernel_swi_regs regs;
TaskDescriptor *t = task__list;
extern void _delete_object(void *obj);
t = (TaskDescriptor *) slist_find_member((void *) &task__list,0,task_handle);
if (t) {
/*
* /* remove this task's object's list
*/
slist_delete_and_call((void *) &(t->object_list),_delete_object);
/* toolbox will probably do this, but lets be nice! */
task_remove_filters(t);
slist_delete_member((void *) &task__list,(void *) t);
}
}
extern void task_add (int task_handle)
{
/*
* Function to add a task descriptor to the list of active
* Toolbox tasks.
*/
/*
* extra safety check, we make sure that the task is not already there!
*/
TaskDescriptor *new_t;
if (task_find (task_handle) != NULL)
return;
/*
* add task to list
*/
if ((new_t = slist_add_new ((void *) &task__list,sizeof(TaskDescriptor), "task descriptor")) == NULL)
{
/* can't report an error really (cos we're in a service call) so just return! */
return;
}
new_t->task_handle = task_handle;
new_t->object_list = NULL;
task_add_filters(new_t);
}
; 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.
;
; Title: cmhg.toolbox
; Purpose: module header for a DCS Object module
; Author: NK
; History: 21-Jun-94: NK : version 1.00
;
initialisation-code: DCS_init
finalisation-code: DCS_final
service-call-handler: DCS_services 0x44ec1,0x44ec2,0x44ec3
title-string: DCS
help-string: DCS_Object 1.06
swi-chunk-base-number: 0x82a80
swi-handler-code: DCS_SWI_handler
swi-decoding-table: DCS, ClassSWI, PostFilter, PreFilter
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment