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
)
52 *****************************************************************************/
59 if (!(_flags(obj
) & MADF_CANDRAW
)) return;
61 if (_flags(obj
) & MADF_INVIRTUALGROUP
)
65 struct Region
*region
= NULL
;
67 get(obj
,MUIA_WindowObject
,&wnd
);
70 while (get(parent
,MUIA_Parent
,&parent
))
73 if (parent
== wnd
) break;
75 if (_flags(parent
) & MADF_ISVIRTUALGROUP
)
77 struct Rectangle rect
;
79 rect
.MinX
= _mleft(parent
);
80 rect
.MinY
= _mtop(parent
);
81 rect
.MaxX
= _mright(parent
);
82 rect
.MaxY
= _mbottom(parent
);
86 if ((region
= NewRegion()))
88 OrRectRegion(region
, &rect
);
92 AndRectRegion(region
, &rect
);
99 clip
= MUI_AddClipRegion(muiRenderInfo(obj
),region
);
102 } /* if object is in a virtual group */
106 struct Region
*region
;
107 struct Rectangle
*clip_rect
;
110 clip_rect
= &muiRenderInfo(obj
)->mri_ClipRect
;
112 if (muiRenderInfo(obj
)->mri_Window
)
114 l
= muiRenderInfo(obj
)->mri_Window
->WLayer
;
118 l
= muiRenderInfo(obj
)->mri_RastPort
->Layer
;
121 if (l
&& (region
= l
->ClipRegion
))
123 /* Maybe this should went to MUI_AddClipRegion() */
124 clip_rect
->MinX
= MAX(_left(obj
),region
->bounds
.MinX
);
125 clip_rect
->MinY
= MAX(_top(obj
),region
->bounds
.MinY
);
126 clip_rect
->MaxX
= MIN(_right(obj
),region
->bounds
.MaxX
);
127 clip_rect
->MaxY
= MIN(_bottom(obj
),region
->bounds
.MaxY
);
131 clip_rect
->MinX
= _left(obj
);
132 clip_rect
->MinY
= _top(obj
);
133 clip_rect
->MaxX
= _right(obj
);
134 clip_rect
->MaxY
= _bottom(obj
);
138 _flags(obj
) = (_flags(obj
) & ~MADF_DRAWFLAGS
) | (flags
& MADF_DRAWFLAGS
);
140 DoMethod(obj
, MUIM_Draw
, 0);
142 if (get(obj
, MUIA_Disabled
, &disabled
))
146 Commented out, because group childs were drawn wrongly
147 when they have been disabled while window is open.
152 if (get(_parent(obj
), MUIA_Disabled
, &parentDisabled
))
154 /* Let the parent draw the pattern... */
155 if (parentDisabled
) disabled
= FALSE
;
165 This aproach might be faster *provided* that the buffer is
166 allocated and filled *once* at startup of muimaster.library.
168 In reality, the WritePixelArray() call has quite a big
169 overhead, so you should only use this buffer if the gadget
170 completely fits inside, and fall back to allocating a new
171 buffer if the gadget is too big.
173 Perhaps a future optimization...
177 LONG
*buffer
= AllocVec(width
* height
* sizeof(LONG
), MEMF_ANY
);
180 memset(buffer
, 0xAA, width
* height
* sizeof(LONG
));
182 for (y
= 0; y
< _height(obj
); y
+= height
)
184 for (x
= 0; x
< _width(obj
); x
+= width
)
188 buffer
, 0, 0, width
* sizeof(LONG
),
189 _rp(obj
), _left(obj
) + x
, _top(obj
) + y
,
190 x
+ width
> _width(obj
) ? _width(obj
) - x
: width
,
191 y
+ height
> _height(obj
) ? _height(obj
) - y
: height
,
197 LONG width
= _width(obj
);
198 LONG height
= _height(obj
);
201 if (GetBitMapAttr(_rp(obj
)->BitMap
, BMA_DEPTH
) >= 15)
203 buffer
= AllocVec(width
* sizeof(LONG
), MEMF_ANY
);
208 memset(buffer
, 0xAA, width
* sizeof(LONG
));
213 _rp(obj
), _left(obj
), _top(obj
), width
, height
,
222 const static UWORD pattern
[] = { 0x8888, 0x2222, };
223 LONG fg
= muiRenderInfo(obj
)->mri_Pens
[MPEN_SHADOW
];
225 SetDrMd(_rp(obj
), JAM1
);
226 SetAPen(_rp(obj
), fg
);
227 SetAfPt(_rp(obj
), pattern
, 1);
228 RectFill(_rp(obj
), _left(obj
), _top(obj
), _right(obj
), _bottom(obj
));
229 SetAfPt(_rp(obj
), NULL
, 0);
232 } /* if (object is disabled) */
234 /* copy buffer to window */
235 if (muiRenderInfo(obj
)->mri_BufferBM
)
237 ClipBlit(&muiRenderInfo(obj
)->mri_BufferRP
, _left(obj
), _top(obj
),
238 muiRenderInfo(obj
)->mri_Window
->RPort
, _left(obj
), _top(obj
),
239 _width(obj
), _height(obj
), 0xc0);
242 if (clip
!= (APTR
)-1)
244 /* This call actually also frees the region */
245 MUI_RemoveClipRegion(muiRenderInfo(obj
), clip
);