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
, int height
)
29 if ((left
<= r
->bounds
.MinX
) && (left
+ width
- 1 >= r
->bounds
.MaxX
)
30 && (top
<= r
->bounds
.MinY
) && (top
+ height
- 1 >= r
->bounds
.MaxY
))
37 /**************************************************************************
38 Converts a Rawkey to a vanillakey
39 **************************************************************************/
40 ULONG
ConvertKey(struct IntuiMessage
*imsg
)
42 struct InputEvent event
;
44 event
.ie_NextEvent
= NULL
;
45 event
.ie_Class
= IECLASS_RAWKEY
;
46 event
.ie_SubClass
= 0;
47 event
.ie_Code
= imsg
->Code
;
48 event
.ie_Qualifier
= imsg
->Qualifier
;
49 event
.ie_EventAddress
= (APTR
*) *((ULONG
*)imsg
->IAddress
);
50 MapRawKey(&event
, &code
, 1, NULL
);
54 /**************************************************************************
55 Convient way to get an attribute of an object easily. If the object
56 doesn't support the attribute this call returns an undefined value. So use
57 this call only if the attribute is known to be known by the object.
58 Implemented as a macro when compiling with GCC.
59 **************************************************************************/
61 IPTR
XGET(Object
*obj
, Tag attr
)
64 GetAttr(attr
, obj
, &storage
);
69 /**************************************************************************
70 Call the Setup Method of an given object, but before set the renderinfo
71 **************************************************************************/
72 IPTR
DoSetupMethod(Object
*obj
, struct MUI_RenderInfo
*info
)
74 /* MUI set the correct render info *before* it calls MUIM_Setup so please only use this function instead of DoMethodA() */
75 muiRenderInfo(obj
) = info
;
76 return DoMethod(obj
, MUIM_Setup
, (IPTR
)info
);
79 IPTR
DoShowMethod(Object
*obj
)
83 ret
= DoMethod(obj
, MUIM_Show
);
85 _flags(obj
) |= MADF_CANDRAW
;
89 IPTR
DoHideMethod(Object
*obj
)
91 _flags(obj
) &= ~MADF_CANDRAW
;
92 return DoMethod(obj
, MUIM_Hide
);
96 void *Node_Next(APTR node
)
98 if(node
== NULL
) return NULL
;
99 if(((struct MinNode
*)node
)->mln_Succ
== NULL
) return NULL
;
100 if(((struct MinNode
*)node
)->mln_Succ
->mln_Succ
== NULL
)
102 return ((struct MinNode
*)node
)->mln_Succ
;
105 void *List_First(APTR list
)
107 if( !((struct MinList
*)list
)->mlh_Head
) return NULL
;
108 if(((struct MinList
*)list
)->mlh_Head
->mln_Succ
== NULL
) return NULL
;
109 return ((struct MinList
*)list
)->mlh_Head
;
112 /* subtract rectangle b from rectangle b. resulting rectangles will be put into
113 destrectarray which must have place for at least 4 rectangles. Returns number
114 of resulting rectangles */
116 WORD
SubtractRectFromRect(struct Rectangle
*a
, struct Rectangle
*b
, struct Rectangle
*destrectarray
)
118 struct Rectangle intersect
;
119 BOOL intersecting
= FALSE
;
122 /* calc. intersection between a and b */
124 if (a
->MinX
<= b
->MaxX
)
126 if (a
->MinY
<= b
->MaxY
)
128 if (a
->MaxX
>= b
->MinX
)
130 if (a
->MaxY
>= b
->MinY
)
132 intersect
.MinX
= MAX(a
->MinX
, b
->MinX
);
133 intersect
.MinY
= MAX(a
->MinY
, b
->MinY
);
134 intersect
.MaxX
= MIN(a
->MaxX
, b
->MaxX
);
135 intersect
.MaxY
= MIN(a
->MaxY
, b
->MaxY
);
145 destrectarray
[numrects
++] = *a
;
147 } /* not intersecting */
150 if (intersect
.MinY
> a
->MinY
) /* upper */
152 destrectarray
->MinX
= a
->MinX
;
153 destrectarray
->MinY
= a
->MinY
;
154 destrectarray
->MaxX
= a
->MaxX
;
155 destrectarray
->MaxY
= intersect
.MinY
- 1;
161 if (intersect
.MaxY
< a
->MaxY
) /* lower */
163 destrectarray
->MinX
= a
->MinX
;
164 destrectarray
->MinY
= intersect
.MaxY
+ 1;
165 destrectarray
->MaxX
= a
->MaxX
;
166 destrectarray
->MaxY
= a
->MaxY
;
172 if (intersect
.MinX
> a
->MinX
) /* left */
174 destrectarray
->MinX
= a
->MinX
;
175 destrectarray
->MinY
= intersect
.MinY
;
176 destrectarray
->MaxX
= intersect
.MinX
- 1;
177 destrectarray
->MaxY
= intersect
.MaxY
;
183 if (intersect
.MaxX
< a
->MaxX
) /* right */
185 destrectarray
->MinX
= intersect
.MaxX
+ 1;
186 destrectarray
->MinY
= intersect
.MinY
;
187 destrectarray
->MaxX
= a
->MaxX
;
188 destrectarray
->MaxY
= intersect
.MaxY
;
200 ULONG
IsObjectVisible(Object
*child
, struct Library
*MUIMasterBase
)
208 while (get(obj
,MUIA_Parent
, &obj
))
211 if (obj
== wnd
) break;
213 if (_right(child
) < _mleft(obj
) || _left(child
) > _mright(obj
)
214 || _bottom(child
) < _mtop(obj
) || _top(child
) > _mbottom(obj
))