2 Copyright © 2003-2007, The AROS Development Team. All rights reserved.
7 #include <clib/alib_protos.h>
8 #include <intuition/classusr.h>
9 #include <graphics/gfxmacros.h>
10 #include <cybergraphx/cybergraphics.h>
11 #include <proto/graphics.h>
12 #include <proto/intuition.h>
13 #include <proto/muimaster.h>
14 #include <proto/cybergraphics.h>
16 #include "muimaster_intern.h"
22 /*****************************************************************************
25 AROS_LH2(VOID
, MUI_Redraw
,
28 AROS_LHA(Object
*, obj
, A0
),
29 AROS_LHA(ULONG
, flags
, D0
),
32 struct Library
*, MUIMasterBase
, 17, MUIMaster
)
45 The function itself is a bug ;-) Remove it!
53 *****************************************************************************/
60 if (!(_flags(obj
) & MADF_CANDRAW
)) return;
62 if (_flags(obj
) & MADF_INVIRTUALGROUP
)
66 struct Region
*region
= NULL
;
68 get(obj
,MUIA_WindowObject
,&wnd
);
71 while (get(parent
,MUIA_Parent
,&parent
))
74 if (parent
== wnd
) break;
76 if (_flags(parent
) & MADF_ISVIRTUALGROUP
)
78 struct Rectangle rect
;
80 rect
.MinX
= _mleft(parent
);
81 rect
.MinY
= _mtop(parent
);
82 rect
.MaxX
= _mright(parent
);
83 rect
.MaxY
= _mbottom(parent
);
87 if ((region
= NewRegion()))
89 OrRectRegion(region
, &rect
);
93 AndRectRegion(region
, &rect
);
100 clip
= MUI_AddClipRegion(muiRenderInfo(obj
),region
);
103 } /* if object is in a virtual group */
107 struct Region
*region
;
108 struct Rectangle
*clip_rect
;
111 clip_rect
= &muiRenderInfo(obj
)->mri_ClipRect
;
113 if (muiRenderInfo(obj
)->mri_Window
)
115 l
= muiRenderInfo(obj
)->mri_Window
->WLayer
;
119 l
= muiRenderInfo(obj
)->mri_RastPort
->Layer
;
122 if (l
&& (region
= l
->ClipRegion
))
124 /* Maybe this should went to MUI_AddClipRegion() */
125 clip_rect
->MinX
= MAX(_left(obj
),region
->bounds
.MinX
);
126 clip_rect
->MinY
= MAX(_top(obj
),region
->bounds
.MinY
);
127 clip_rect
->MaxX
= MIN(_right(obj
),region
->bounds
.MaxX
);
128 clip_rect
->MaxY
= MIN(_bottom(obj
),region
->bounds
.MaxY
);
132 clip_rect
->MinX
= _left(obj
);
133 clip_rect
->MinY
= _top(obj
);
134 clip_rect
->MaxX
= _right(obj
);
135 clip_rect
->MaxY
= _bottom(obj
);
139 _flags(obj
) = (_flags(obj
) & ~MADF_DRAWFLAGS
) | (flags
& MADF_DRAWFLAGS
);
141 DoMethod(obj
, MUIM_Draw
, 0);
143 if (get(obj
, MUIA_Disabled
, &disabled
))
147 ULONG parentDisabled
;
148 if (get(_parent(obj
), MUIA_Disabled
, &parentDisabled
))
150 /* Let the parent draw the pattern... */
151 if (parentDisabled
) disabled
= FALSE
;
160 This aproach might be faster *provided* that the buffer is
161 allocated and filled *once* at startup of muimaster.library.
163 In reality, the WritePixelArray() call has quite a big
164 overhead, so you should only use this buffer if the gadget
165 completely fits inside, and fall back to allocating a new
166 buffer if the gadget is too big.
168 Perhaps a future optimization...
172 LONG
*buffer
= AllocVec(width
* height
* sizeof(LONG
), MEMF_ANY
);
175 memset(buffer
, 0xAA, width
* height
* sizeof(LONG
));
177 for (y
= 0; y
< _height(obj
); y
+= height
)
179 for (x
= 0; x
< _width(obj
); x
+= width
)
183 buffer
, 0, 0, width
* sizeof(LONG
),
184 _rp(obj
), _left(obj
) + x
, _top(obj
) + y
,
185 x
+ width
> _width(obj
) ? _width(obj
) - x
: width
,
186 y
+ height
> _height(obj
) ? _height(obj
) - y
: height
,
192 LONG width
= _width(obj
);
193 LONG height
= _height(obj
);
196 if (GetBitMapAttr(_rp(obj
)->BitMap
, BMA_DEPTH
) >= 15)
198 buffer
= AllocVec(width
* sizeof(LONG
), MEMF_ANY
);
203 memset(buffer
, 0xAA, width
* sizeof(LONG
));
208 _rp(obj
), _left(obj
), _top(obj
), width
, height
,
217 const static UWORD pattern
[] = { 0x8888, 0x2222, };
218 LONG fg
= muiRenderInfo(obj
)->mri_Pens
[MPEN_SHADOW
];
220 SetDrMd(_rp(obj
), JAM1
);
221 SetAPen(_rp(obj
), fg
);
222 SetAfPt(_rp(obj
), pattern
, 1);
223 RectFill(_rp(obj
), _left(obj
), _top(obj
), _right(obj
), _bottom(obj
));
224 SetAfPt(_rp(obj
), NULL
, 0);
227 } /* if (object is disabled) */
229 /* copy buffer to window */
230 if (muiRenderInfo(obj
)->mri_BufferBM
)
232 ClipBlit(&muiRenderInfo(obj
)->mri_BufferRP
, _left(obj
), _top(obj
),
233 muiRenderInfo(obj
)->mri_Window
->RPort
, _left(obj
), _top(obj
),
234 _width(obj
), _height(obj
), 0xc0);
237 if (clip
!= (APTR
)-1)
239 /* This call actually also frees the region */
240 MUI_RemoveClipRegion(muiRenderInfo(obj
), clip
);