[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] Dialogs in windows
Hi
I have rewritten your example as attached.
As Draco pointed out, the FIRST/NEXT_XYWH loop gives you all the
visible rectangles. This is usefull if you want to update your
window contents yourself.
On a WM_REDRAW you must intersect all the rectangles with the
rectangle of the WM_REDRAW message.
This reduces the amount of repainted area considerably.
--
Groeten; Regards.
Henk Robbers. mailto:h.robbers@chello.nl
http://members.ams.chello.nl/h.robbers/Home.html
Interactive disassembler: TT-Digger; http://digger.atari.org
A GEM replacement for MiNT: XaAES; http://xaaes.atari.org
A Home Cooked teXt editor: AHCX
The free desktop: TERADESK
static
int min( int a, int b)
{ return a < b ? a : b; }
static
int max( int a, int b)
{ return a > b ? a : b; }
int rc_intersect(RECT *r1,RECT *r2)
{
int xl, yu, xr, yd; /* left, upper, right, down */
xl = max( r1->x, r2->x );
yu = max( r1->y, r2->y );
xr = min( r1->x + r1->w,
r2->x + r2->w );
yd = min( r1->y + r1->h,
r2->y + r2->h );
r2->x = xl;
r2->y = yu;
r2->w = xr - xl;
r2->h = yd - yu;
return( r2->w > 0 && r2->h > 0 );
}
/* x, y, w, h is the rectangle supplied by WM_REDRAW */
static
void redraw_mywindow( short my_window, short x, short y, short w, short h )
{
GRECT t1, t2, r;
wind_get_grect( my_window,
WF_WORKXYWH,
&r );
/* this is my infodialog that should be redrawn
infodialog->ob_x = r.g_x + 2;
infodialog->ob_y = r.g_y + 2;
infodialog->ob_width = r.g_w - 4;
infodialog->ob_height = r.g_h - 4;
t2.g_x = x;
t2.g_y = y;
t2.g_w = w;
t2.g_h = h;
wind_update( BEG_UPDATE );
wind_get( my_window, WF_FIRSTXYWH, &t1.g_x, &t1.g_y, &t1.g_w, &t1.g_h );
while ( t1.g_w && t1.g_h )
{
if ( rc_intersect( &t2, &t1 )
objc_draw( infodialog, ROOT, MAX_DEPTH,
t1.g_x, t1.g_y, t1.g_w, t1.g_h );
wind_get( my_window, WF_NEXTXYWH, &t1.g_x, &t1.g_y, &t1.g_w, &t1.g_h );
}
wind_update( END_UPDATE ); /* Fenstererneuerung beendet */
}