define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / rom / intuition / obtaingirport.c
blob7f6fae03803d9d6737b4fea6e60b9959cdeaf3f5
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <proto/graphics.h>
8 #include <proto/layers.h>
9 #include <proto/exec.h>
10 #include <graphics/rpattr.h>
11 #include "intuition_intern.h"
13 /*****************************************************************************
15 NAME */
16 #include <graphics/rastport.h>
17 #include <intuition/cghooks.h>
18 #include <proto/intuition.h>
20 AROS_LH1(struct RastPort *, ObtainGIRPort,
22 /* SYNOPSIS */
23 AROS_LHA(struct GadgetInfo *, gInfo, A0),
25 /* LOCATION */
26 struct IntuitionBase *, IntuitionBase, 93, Intuition)
28 /* FUNCTION
29 This function sets up a RastPort for exclusive use by custom
30 gadget hook routines. Call this function each time a hook
31 routine needs to render into the gadget and ReleaseGIRPort()
32 immediately afterwards.
34 INPUTS
35 gInfo - Pointer to GadgetInfo structure, as passed to each
36 custom gadget hook function.
38 RESULT
39 Pointer to a RastPort you can render to. NULL if you aren't
40 allowed to render into this gadget.
42 NOTES
43 If a routine passes a RastPort, eg. GM_RENDER, ObtainGIRPort()
44 needn't be called.
46 EXAMPLE
48 BUGS
50 SEE ALSO
51 ReleaseGIRPort()
53 INTERNALS
55 HISTORY
56 29-10-95 digulla automatically created from
57 intuition_lib.fd and clib/intuition_protos.h
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
63 struct RastPort *rp;
65 DEBUG_OBTAINGIRPORT(dprintf("ObtainGIRPort: GInfo 0x%lx Task 0x%lx <%s>\n",
66 gInfo, FindTask(NULL),
67 FindTask(NULL)->tc_Node.ln_Name ? FindTask(NULL)->tc_Node.ln_Name : "NULL"));
69 if (gInfo && gInfo->gi_RastPort)
71 rp = CloneRastPort (gInfo->gi_RastPort);
72 if (rp)
75 LOCKGADGET
76 /*bug("+++++++++++++ OBTAIN rp=%p lay=%p font=%p origfont=%p\n",rp,rp->Layer,rp->Font,gInfo->gi_RastPort->Font);*/
78 if (rp->Layer)
80 LockLayer(0,rp->Layer);
82 if (((GetPrivIBase(IntuitionBase)->BackupLayerContext.nestcount)++) == 0)
84 GetPrivIBase(IntuitionBase)->BackupLayerContext.scroll_x = rp->Layer->Scroll_X;
85 GetPrivIBase(IntuitionBase)->BackupLayerContext.scroll_y = rp->Layer->Scroll_Y;
87 rp->Layer->Scroll_X = 0;
88 rp->Layer->Scroll_Y = 0;
90 GetPrivIBase(IntuitionBase)->BackupLayerContext.clipregion = InstallClipRegion(rp->Layer, NULL);
93 SetWriteMask(rp, 0xFF);
94 #ifdef __MORPHOS__
95 SetRPAttrs(rp,RPTAG_DrMd,JAM1,RPTAG_PenMode,TRUE,TAG_DONE);
96 #else
97 SetRPAttrs(rp,RPTAG_DrMd,JAM1,TAG_DONE);
98 #endif /* __MORPHOS__ */
102 DEBUG_OBTAINGIRPORT(dprintf("ObtainGIRPort: RPort 0x%lx\n", rp));
103 return rp;
105 else
107 return NULL;
110 AROS_LIBFUNC_EXIT
111 } /* ObtainGIRPort */