How can I prevent a flick effects when I redrav many “build in” PtArc
widgets in the next example:
// LH Arc’s Test Demo
//
#include <Pt.h>
PtWidget_t *small_ellipse_widget, *arc_widget[10][28];
int timer_cb( PtWidget_t *, void *,PtCallbackInfo_t *);
int count_draw_s = 0;
PtWidget_t *group_widget;
int main( int argc, char *argv[] )
{
PtWidget_t *window;
PtArg_t args[10];
PtWidget_t *timer_widget;
PhPoint_t point_arc[2];
PhArea_t area;
int count_p, count_s;
short angle_start, angle_end;
if ((window = PtAppInit(NULL, &argc, argv, 0, NULL)) == NULL)
exit(1);
// Create Group (Container ) Widget
PtSetArg( &args[0], Pt_ARG_GROUP_ORIENTATION, Pt_GROUP_ASIS, 0 );
group_widget = PtCreateWidget( PtGroup, window, 1, args );
// Create All Arc Widgets
//-----------------------
PtSetArg( &args[0], Pt_ARG_ARC_TYPE, Pt_ARC_PIE, 0 );
PtSetArg( &args[1], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0 );
PtSetArg( &args[2], Pt_ARG_COLOR, Pg_BLACK, 0 );
PtSetArg( &args[3], Pt_ARG_BORDER_WIDTH, 0, 0 );
for( count_p = 0; count_p < 10; count_p++ )
{
point_arc[0].x = 19 * count_p;
point_arc[0].y = 19 * count_p;
point_arc[1].x = 680 - 19 * count_p;
point_arc[1].y = 680 - 19 * count_p;
for( count_s = 0 ; count_s < 28; count_s++ )
{
PtSetArg( &args[4], Pt_ARG_POINTS, &point_arc[0], 2 );
// ? Ú <R
angle_start = (short)(3600. / 28 * count_s );
angle_end = (short)(3600. / 28 * (count_s+1) );
PtSetArg( &args[5], Pt_ARG_ARC_START, angle_start, 0 );
PtSetArg( &args[6], Pt_ARG_ARC_END, angle_end, 0 );
arc_widget[count_p][count_s] = PtCreateWidget( PtArc, group_widget, 7,
&args[0] );
}
}
// Small Ellipse Widget
area.size.w = area.size.h = 300;
area.pos.x = area.pos.y = 190;
PtSetArg( &args[0], Pt_ARG_AREA, &area, 0);
PtSetArg( &args[1], Pt_ARG_FILL_COLOR, Pg_GREY, 0 );
small_ellipse_widget = PtCreateWidget(PtEllipse, group_widget, 2, args);
// Timer Widget
PtSetArg( &args[0], Pt_ARG_TIMER_INITIAL, 1000, 0);
PtSetArg( &args[1], Pt_ARG_TIMER_REPEAT, 1000, 0 );
timer_widget = PtCreateWidget(PtTimer, window, 2, args);
PtAddCallback(timer_widget, Pt_CB_TIMER_ACTIVATE, &timer_cb, NULL );
PtRealizeWidget(window);
PtMainLoop();
return (EXIT_SUCCESS);
}
int timer_cb( PtWidget_t *widget, void *apinfo, PtCallbackInfo_t *cbinfo )
{
int count_p, count_s;
int color;
PtArg_t args[1];
/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
count_s = count_draw_s++;
if( count_s >= 28 )
count_s %= 28;
PtHold();
// Change Arc’c Fill Colors
for( count_p = 0; count_p < 10; count_p++ )
{
color = count_p * 20 + count_draw_s * 10;
if( color > 255 )
color %= 255;
PtSetArg( &args[0], Pt_ARG_FILL_COLOR, PgRGB( 255, color, color), 0 );
PtSetResources( arc_widget[count_p][count_s], 1, &args[0] );
}
PtReRealizeWidget( group_widget );
PtRelease();
return( Pt_CONTINUE );
}
Thank you