Don't get OOPBase in this ugly way.
[tangerine.git] / rom / intuition / obtaingirport.c
blob8486f1637507078d99868de1e6b9b93022fbbeba
1 /*
2 Copyright © 1995-2003, 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
62 AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
64 struct RastPort *rp;
66 DEBUG_OBTAINGIRPORT(dprintf("ObtainGIRPort: GInfo 0x%lx Task 0x%lx <%s>\n",
67 gInfo, FindTask(NULL),
68 FindTask(NULL)->tc_Node.ln_Name ? FindTask(NULL)->tc_Node.ln_Name : "NULL"));
70 if (gInfo && gInfo->gi_RastPort)
72 rp = CloneRastPort (gInfo->gi_RastPort);
73 if (rp)
76 LOCKGADGET
77 /*bug("+++++++++++++ OBTAIN rp=%p lay=%p font=%p origfont=%p\n",rp,rp->Layer,rp->Font,gInfo->gi_RastPort->Font);*/
79 if (rp->Layer)
81 LockLayer(0,rp->Layer);
83 if (((GetPrivIBase(IntuitionBase)->BackupLayerContext.nestcount)++) == 0)
85 GetPrivIBase(IntuitionBase)->BackupLayerContext.scroll_x = rp->Layer->Scroll_X;
86 GetPrivIBase(IntuitionBase)->BackupLayerContext.scroll_y = rp->Layer->Scroll_Y;
88 rp->Layer->Scroll_X = 0;
89 rp->Layer->Scroll_Y = 0;
91 GetPrivIBase(IntuitionBase)->BackupLayerContext.clipregion = InstallClipRegion(rp->Layer, NULL);
94 SetWriteMask(rp, 0xFF);
95 #ifdef __MORPHOS__
96 SetRPAttrs(rp,RPTAG_DrMd,JAM1,RPTAG_PenMode,TRUE,TAG_DONE);
97 #else
98 SetRPAttrs(rp,RPTAG_DrMd,JAM1,TAG_DONE);
99 #endif /* __MORPHOS__ */
103 DEBUG_OBTAINGIRPORT(dprintf("ObtainGIRPort: RPort 0x%lx\n", rp));
104 return rp;
106 else
108 return NULL;
111 AROS_LIBFUNC_EXIT
112 } /* ObtainGIRPort */