grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / muimaster / mui_addclipping.c
blob80ae5cc6dd439c10240fec8ad9a1878f456bbe65
1 /*
2 Copyright © 2002-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/graphics.h>
7 #include <proto/layers.h>
8 #include <proto/muimaster.h>
10 #include "support.h"
12 #include "mui.h"
13 #include "muimaster_intern.h"
15 /*****************************************************************************
17 NAME */
18 AROS_LH5(APTR, MUI_AddClipping,
20 /* SYNOPSIS */
21 AROS_LHA(struct MUI_RenderInfo *, mri, A0),
22 AROS_LHA(WORD, left, D0),
23 AROS_LHA(WORD, top, D1),
24 AROS_LHA(WORD, width, D2),
25 AROS_LHA(WORD, height, D3),
27 /* LOCATION */
28 struct Library *, MUIMasterBase, 28, MUIMaster)
30 /* FUNCTION
32 INPUTS
34 RESULT
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 *****************************************************************************/
48 AROS_LIBFUNC_INIT
50 struct Region *r;
51 struct Rectangle rect;
52 APTR handle;
54 if ((width >= MUI_MAXMAX) || (height >= MUI_MAXMAX))
55 return (APTR)-1;
57 if (mri->mri_rCount > 0)
59 if (isRegionWithinBounds(mri->mri_rArray[mri->mri_rCount-1],
60 left, top, width, height))
61 return (APTR)-1;
64 if ((r = NewRegion()) == NULL)
65 return (APTR)-1;
67 rect.MinX = left;
68 rect.MinY = top;
69 rect.MaxX = left + width - 1;
70 rect.MaxY = top + height - 1;
71 OrRectRegion(r, &rect);
73 handle = MUI_AddClipRegion(mri, r);
75 #if 0 /* MUI_AddClipRegion frees region itself upon failure */
76 if (handle == (APTR)-1)
78 DisposeRegion(r);
80 #endif
81 return handle;
83 AROS_LIBFUNC_EXIT
85 } /* MUIA_AddClipping */