r4493@vps: verhaegs | 2007-04-19 14:44:00 -0400
[AROS.git] / rom / graphics / gfxassociate.c
blobe2f35414bf7bb5e53d3b819cd7d3061cd628165c
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <exec/types.h>
10 #include <exec/memory.h>
11 #include <graphics/gfxbase.h>
12 #include <graphics/monitor.h>
13 #include <graphics/view.h>
14 #include <graphics/gfxnodes.h>
15 #include <proto/exec.h>
16 #include <proto/graphics.h>
17 #include "graphics_intern.h"
19 /*****************************************************************************
21 NAME */
23 AROS_LH2( void , GfxAssociate,
25 /* SYNOPSIS */
27 AROS_LHA( void *, pointer, A0),
28 AROS_LHA( struct ExtendedNode *, node, A1),
30 /* LOCATION */
32 struct GfxBase *, GfxBase, 112, Graphics)
34 /* FUNCTION
35 Associate a special graphics extended data structure with another
36 structure via the other structure's pointer. Later, when you call
37 GfxLookUp() with the other structure's pointer you may receive
38 the pointer to this special graphics extended data structure, if it
39 is available
41 INPUTS
42 pointer = a pointer to a data structure
43 node = an ExtendedNode structure to associate with the pointer
45 RESULT
46 an association is created between the pointer and the node such
47 that given the pointer the node can be retrieved via GfxLookUp().
49 NOTES
50 Never associate one special graphics extended data structure to
51 several pointers. Only one pointer is allowed!
53 EXAMPLE
55 BUGS
57 SEE ALSO
58 graphics/gfxnodes.h GfxFree(), GfxNew(), GfxLookUp()
60 INTERNALS
62 HISTORY
64 ******************************************************************************/
66 AROS_LIBFUNC_INIT
68 LONG * Hash = GfxBase -> hash_table;
69 ULONG Index = CalcHashIndex((ULONG)pointer);
71 /* Whatever structure we get as node we put the pointer in the space
72 following immediately after the ExtendedNode structure.
73 ViewExtra -> View is equal to
74 ViewPortExtra -> ViewPort
77 ((struct ViewExtra *)node) -> View = pointer;
78 Forbid();
79 /* Insert the structure into a hash_list which is to be found
80 in the gfxlibrary */
81 if (0L != Hash[Index])
82 ((struct ExtendedNode *)Hash[Index]) -> xln_Pred = (struct Node *)node;
83 node -> xln_Succ = (struct Node *)Hash[Index];
84 node -> xln_Pred = (struct Node *)&Hash[Index];
85 Hash[Index] = (LONG)node;
86 Permit();
88 AROS_LIBFUNC_EXIT
89 } /* GfxAssociate */