2 Copyright © 2002, The AROS Development Team.
10 #include <intuition/classes.h>
11 #include <clib/alib_protos.h>
12 #include <proto/exec.h>
13 #include <proto/intuition.h>
14 #include <proto/graphics.h>
15 #include <proto/keymap.h>
16 #include <proto/utility.h>
20 #include "muimaster_intern.h"
22 extern struct Library
*MUIMasterBase
;
24 /**************************************************************************
25 check if region is entirely within given bounds
26 **************************************************************************/
27 int isRegionWithinBounds(struct Region
*r
, int left
, int top
, int width
,
30 if ((left
<= r
->bounds
.MinX
) && (left
+ width
- 1 >= r
->bounds
.MaxX
)
31 && (top
<= r
->bounds
.MinY
) && (top
+ height
- 1 >= r
->bounds
.MaxY
))
38 /**************************************************************************
39 Converts a Rawkey to a vanillakey
40 **************************************************************************/
41 ULONG
ConvertKey(struct IntuiMessage
* imsg
)
43 struct InputEvent event
;
45 event
.ie_NextEvent
= NULL
;
46 event
.ie_Class
= IECLASS_RAWKEY
;
47 event
.ie_SubClass
= 0;
48 event
.ie_Code
= imsg
->Code
;
49 event
.ie_Qualifier
= imsg
->Qualifier
;
50 event
.ie_EventAddress
= (APTR
*) * ((IPTR
*) imsg
->IAddress
);
51 MapRawKey(&event
, &code
, 1, NULL
);
55 /**************************************************************************
56 Convenient way to get an attribute of an object easily. If the object
57 doesn't support the attribute this call returns an undefined value. So use
58 this call only if the attribute is known to be known by the object.
59 Implemented as a macro when compiling with GCC.
60 **************************************************************************/
62 IPTR
XGET(Object
* obj
, Tag attr
)
65 GetAttr(attr
, obj
, &storage
);
70 /**************************************************************************
71 Call the Setup Method of an given object, but before set the renderinfo
72 **************************************************************************/
73 IPTR
DoSetupMethod(Object
* obj
, struct MUI_RenderInfo
* info
)
75 /* MUI set the correct render info *before* it calls MUIM_Setup so please
76 * only use this function instead of DoMethodA() */
77 muiRenderInfo(obj
) = info
;
78 return DoMethod(obj
, MUIM_Setup
, (IPTR
) info
);
81 IPTR
DoShowMethod(Object
* obj
)
85 ret
= DoMethod(obj
, MUIM_Show
);
87 _flags(obj
) |= MADF_CANDRAW
;
91 IPTR
DoHideMethod(Object
* obj
)
93 _flags(obj
) &= ~MADF_CANDRAW
;
94 return DoMethod(obj
, MUIM_Hide
);
98 void *Node_Next(APTR node
)
102 if (((struct MinNode
*)node
)->mln_Succ
== NULL
)
104 if (((struct MinNode
*)node
)->mln_Succ
->mln_Succ
== NULL
)
106 return ((struct MinNode
*)node
)->mln_Succ
;
109 void *List_First(APTR list
)
111 if (!((struct MinList
*)list
)->mlh_Head
)
113 if (((struct MinList
*)list
)->mlh_Head
->mln_Succ
== NULL
)
115 return ((struct MinList
*)list
)->mlh_Head
;
118 /* subtract rectangle b from rectangle b. resulting rectangles will be put into
119 destrectarray which must have place for at least 4 rectangles. Returns number
120 of resulting rectangles */
122 WORD
SubtractRectFromRect(struct Rectangle
*a
, struct Rectangle
*b
,
123 struct Rectangle
*destrectarray
)
125 struct Rectangle intersect
;
126 BOOL intersecting
= FALSE
;
129 /* calc. intersection between a and b */
131 if (a
->MinX
<= b
->MaxX
)
133 if (a
->MinY
<= b
->MaxY
)
135 if (a
->MaxX
>= b
->MinX
)
137 if (a
->MaxY
>= b
->MinY
)
139 intersect
.MinX
= MAX(a
->MinX
, b
->MinX
);
140 intersect
.MinY
= MAX(a
->MinY
, b
->MinY
);
141 intersect
.MaxX
= MIN(a
->MaxX
, b
->MaxX
);
142 intersect
.MaxY
= MIN(a
->MaxY
, b
->MaxY
);
152 destrectarray
[numrects
++] = *a
;
154 } /* not intersecting */
157 if (intersect
.MinY
> a
->MinY
) /* upper */
159 destrectarray
->MinX
= a
->MinX
;
160 destrectarray
->MinY
= a
->MinY
;
161 destrectarray
->MaxX
= a
->MaxX
;
162 destrectarray
->MaxY
= intersect
.MinY
- 1;
168 if (intersect
.MaxY
< a
->MaxY
) /* lower */
170 destrectarray
->MinX
= a
->MinX
;
171 destrectarray
->MinY
= intersect
.MaxY
+ 1;
172 destrectarray
->MaxX
= a
->MaxX
;
173 destrectarray
->MaxY
= a
->MaxY
;
179 if (intersect
.MinX
> a
->MinX
) /* left */
181 destrectarray
->MinX
= a
->MinX
;
182 destrectarray
->MinY
= intersect
.MinY
;
183 destrectarray
->MaxX
= intersect
.MinX
- 1;
184 destrectarray
->MaxY
= intersect
.MaxY
;
190 if (intersect
.MaxX
< a
->MaxX
) /* right */
192 destrectarray
->MinX
= intersect
.MaxX
+ 1;
193 destrectarray
->MinY
= intersect
.MinY
;
194 destrectarray
->MaxX
= a
->MaxX
;
195 destrectarray
->MaxY
= intersect
.MaxY
;
207 ULONG
IsObjectVisible(Object
* child
, struct Library
* MUIMasterBase
)
215 while (get(obj
, MUIA_Parent
, &obj
))
222 if (_right(child
) < _mleft(obj
) || _left(child
) > _mright(obj
)
223 || _bottom(child
) < _mtop(obj
) || _top(child
) > _mbottom(obj
))