Example #1
0
void browser_redraw( struct gui_window * gw )
{
	LGRECT bwrect;
	struct s_browser * b = gw->browser;
	short todo[4];
	struct rect clip;
	/* used for clipping of content redraw: */
	struct rect redraw_area;

	if( b->attached == false || b->bw->current_content == NULL ) {
		return;
	}

	browser_get_rect(gw, BR_CONTENT, &bwrect);

	plotter->resize(plotter, bwrect.g_w, bwrect.g_h);
	plotter->move(plotter, bwrect.g_x, bwrect.g_y );
	clip.x0 = 0;
	clip.y0 = 0;
	clip.x1 = bwrect.g_w;
	clip.y1 = bwrect.g_h;
	plotter->set_clip( plotter, &clip );
	if( plotter->lock(plotter) == 0 )
		return;

	if( b->scroll.required == true && b->bw->current_content != NULL) {
		browser_process_scroll( gw, bwrect );
		b->scroll.required = false;
	}

	if ((b->redraw.areas_used > 0) && b->bw->current_content != NULL ) {
		if( (plotter->flags & PLOT_FLAG_OFFSCREEN) == 0 ) {

			int i;
			GRECT area;
			GRECT fbwork;
			short wf_top[4];
			todo[0] = bwrect.g_x;
			todo[1] = bwrect.g_y;
			todo[2] = todo[0] + bwrect.g_w-1;
			todo[3] = todo[1] + bwrect.g_h-1;
			vs_clip(plotter->vdi_handle, 1, (short*)&todo[0]);

			wind_get( 0, WF_TOP, &wf_top[0], &wf_top[1],
						&wf_top[2], &wf_top[3] );

			if( wf_top[0] == gw->root->handle->handle
				&& wf_top[1] == _AESapid ){
				/* The window is on top, so there is no need to walk the 	*/
				/* AES rectangle list. 										*/
				for( i=0; i<b->redraw.areas_used; i++ ){
					fbwork.g_x = todo[0] - bwrect.g_x;
					fbwork.g_y = todo[1] - bwrect.g_y;
					if( fbwork.g_x < 0 ){
						fbwork.g_w = todo[2] + todo[0];
						fbwork.g_x = 0;
					} else {
						fbwork.g_w = todo[2];
					}
					if( fbwork.g_y < 0 ){
						fbwork.g_h = todo[3] + todo[1];
						fbwork.g_y = 0;
					} else {
						fbwork.g_h = todo[3];
					}
					area.g_x = b->redraw.areas[i].x0;
					area.g_y = b->redraw.areas[i].y0;
					area.g_w = b->redraw.areas[i].x1 - b->redraw.areas[i].x0;
					area.g_h = b->redraw.areas[i].y1 - b->redraw.areas[i].y0;
					if (rc_intersect((GRECT *)&fbwork,(GRECT *)&area)) {
						redraw_area.x0 = area.g_x;
						redraw_area.y0 = area.g_y;
						redraw_area.x1 = area.g_x + area.g_w;
						redraw_area.y1 = area.g_y + area.g_h;
						browser_redraw_content( gw, 0, 0, &redraw_area );
					} else {
						/* the area should be kept scheduled for later redraw,*/
						/* but because this is onscreen plotter, it doesn't   */
						/* make much sense anyway...						  */
					}
				}
			} else {
				/* walk the AES rectangle list: */
				if( wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
								&todo[0], &todo[1], &todo[2], &todo[3] )!=0 ) {
					while (todo[2] && todo[3]) {
						/* convert screen to framebuffer coords: */
						fbwork.g_x = todo[0] - bwrect.g_x;
						fbwork.g_y = todo[1] - bwrect.g_y;
						if( fbwork.g_x < 0 ){
							fbwork.g_w = todo[2] + todo[0];
							fbwork.g_x = 0;
						} else {
							fbwork.g_w = todo[2];
						}
						if( fbwork.g_y < 0 ){
							fbwork.g_h = todo[3] + todo[1];
							fbwork.g_y = 0;
						} else {
							fbwork.g_h = todo[3];
						}
						/* walk the redraw requests: */
						for( i=0; i<b->redraw.areas_used; i++ ){
							area.g_x = b->redraw.areas[i].x0;
							area.g_y = b->redraw.areas[i].y0;
							area.g_w = b->redraw.areas[i].x1 - b->redraw.areas[i].x0;
							area.g_h = b->redraw.areas[i].y1 - b->redraw.areas[i].y0;
							if (rc_intersect((GRECT *)&fbwork,(GRECT *)&area)) {
								redraw_area.x0 = area.g_x;
								redraw_area.y0 = area.g_y;
								redraw_area.x1 = area.g_x + area.g_w;
								redraw_area.y1 = area.g_y + area.g_h;
								browser_redraw_content( gw, 0, 0, &redraw_area );
							} else {
								/* the area should be kept scheduled for later redraw,*/
								/* but because this is onscreen plotter, it doesn't   */
								/* make much sense anyway...						  */
							}

						}
						if (wind_get(gw->root->handle->handle, WF_NEXTXYWH,
								&todo[0], &todo[1], &todo[2], &todo[3])==0) {
							break;
						}
					}
				}
			}


			vs_clip(plotter->vdi_handle, 0, (short*)&todo);
		} else {

			/* its save to do a complete redraw without knowledge about GEM windows :) */
			/* walk the redraw requests: */
			int i;
			for( i=0; i<b->redraw.areas_used; i++ ){
				struct redraw_context ctx = {
					.interactive = true,
					.background_images = true,
					.plot = &atari_plotters
				};
				browser_window_redraw( b->bw, -b->scroll.current.x,
						-b->scroll.current.y, &b->redraw.areas[i], &ctx );
			}
			GRECT area;
			area.g_x = bwrect.g_x;
			area.g_y = bwrect.g_y;
			area.g_w = bwrect.g_w;
			area.g_h = bwrect.g_h;
			//plotter->blit( plotter, &area );
		}
		b->redraw.areas_used = 0;
	}
	if( b->caret.redraw == true && 	b->bw->current_content != NULL ) {
		LGRECT area;
		todo[0] = bwrect.g_x;
		todo[1] = bwrect.g_y;
		todo[2] = todo[0] + bwrect.g_w;
		todo[3] = todo[1] + bwrect.g_h;
		area.g_x = bwrect.g_x;
		area.g_y = bwrect.g_y;
		area.g_w = bwrect.g_w;
		area.g_h = bwrect.g_h;
		vs_clip(plotter->vdi_handle, 1, (short*)&todo[0]);
		browser_redraw_caret( gw, &area );
		vs_clip(plotter->vdi_handle, 0, (short*)&todo[0]);
		b->caret.redraw = false;
	}
	plotter->unlock(plotter);
	/* TODO: if we use offscreen bitmap, trigger content redraw here */
}

static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * data)
{
	struct gui_window * gw = (struct gui_window *) data;
	CMP_BROWSER b = gw->browser;
	LGRECT work, lclip;

	browser_get_rect( gw, BR_CONTENT, &work );
	lclip = work;
	if ( !rc_lintersect( (LGRECT*)&buff[4], &lclip ) ) return;

	if( b->bw->current_content == NULL ){
		short pxy[4];
		pxy[0] = lclip.g_x;
		pxy[1] = lclip.g_y;
		pxy[2] = lclip.g_x + lclip.g_w - 1;
		pxy[3] = lclip.g_y + lclip.g_h - 1;
		vsf_color( gw->root->handle->graf->handle, WHITE );
		vsf_perimeter( gw->root->handle->graf->handle, 0);
		vsf_interior( gw->root->handle->graf->handle, FIS_SOLID );
		vsf_style( gw->root->handle->graf->handle, 1);
		v_bar( gw->root->handle->graf->handle, (short*)&pxy );
		return;
	}

	/* convert redraw coords to framebuffer coords: */
	lclip.g_x -= work.g_x;
	lclip.g_y -= work.g_y;

	if( lclip.g_x < 0 ) {
		lclip.g_w = work.g_w + lclip.g_x;
		lclip.g_x = 0;
	}

	if( lclip.g_y < 0 ) {
		lclip.g_h = work.g_h + lclip.g_y;
		lclip.g_y = 0;
	}

	if( lclip.g_h > 0 && lclip.g_w > 0 ) {

		if( gw->browser->reformat_pending == true ){
			LGRECT newsize;
			gw->browser->reformat_pending = false;
			browser_get_rect(gw, BR_CONTENT, &newsize);
			/* this call will also schedule an redraw for the complete */
			/* area. */
			/* Resize must be handled here, because otherwise */
			/* a redraw is scheduled twice (1. by the frontend, 2. by AES) */
			browser_window_reformat(b->bw, false, newsize.g_w, newsize.g_h );
		} else {
			browser_schedule_redraw( gw, lclip.g_x, lclip.g_y,
				lclip.g_x + lclip.g_w, lclip.g_y + lclip.g_h
			);
		}
	}

	return;
}
Example #2
0
static
void __CDECL evnt_sb_redraw( COMPONENT *c, long buff[8] )
{
	size_t i;
	struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app, c, CDT_OWNER);
	assert(gw != NULL);
	CMP_STATUSBAR sb = gw->root->statusbar;
	assert( sb != NULL );
	if( sb == NULL )
		return;

	if( sb->attached == false )
		return;

	LGRECT work, lclip;
	short pxy[8], d, pxyclip[4];

	mt_CompGetLGrect(&app, sb->comp, WF_WORKXYWH, &work);
	lclip = work;
	if ( !rc_lintersect( (LGRECT*)&buff[4], &lclip ) ) {
		return;
	}
	vsf_interior(atari_plot_vdi_handle, FIS_SOLID );
	vsl_color(atari_plot_vdi_handle, BLACK );
	vsl_type(atari_plot_vdi_handle, 1);
	vsl_width(atari_plot_vdi_handle, 1 );
	vst_color(atari_plot_vdi_handle, BLACK);

	vst_height(atari_plot_vdi_handle, atari_sysinfo.medium_sfont_pxh, &pxy[0], &pxy[1], &pxy[2], &pxy[3] );
	vst_alignment(atari_plot_vdi_handle, 0, 5, &d, &d );
	vst_effects(atari_plot_vdi_handle, 0 );
	pxyclip[0] = lclip.g_x;
	pxyclip[1] = lclip.g_y;
	pxyclip[2] = lclip.g_x + lclip.g_w-1;
	pxyclip[3] = lclip.g_y + lclip.g_h-1;

	vs_clip(atari_plot_vdi_handle, 1, (short*)&pxyclip );
	vswr_mode(atari_plot_vdi_handle, MD_REPLACE );

	if( lclip.g_y <= work.g_y ) {
		pxy[0] = work.g_x;
		pxy[1] = work.g_y;
		pxy[2] = MIN( work.g_x + work.g_w, lclip.g_x + lclip.g_w );
		pxy[3] = work.g_y;
		v_pline(atari_plot_vdi_handle, 2, (short*)&pxy );
	}

	if(app.nplanes > 2) {
		vsf_color(atari_plot_vdi_handle, LWHITE);
	} else {
		vsf_color(atari_plot_vdi_handle, WHITE );
	}

	pxy[0] = work.g_x;
	pxy[1] = work.g_y+1;
	pxy[2] = work.g_x + work.g_w-1;
	pxy[3] = work.g_y + work.g_h-1;
	v_bar(atari_plot_vdi_handle, pxy );


	if( sb->textlen > 0 ) {
		short curx;
		short vqw[4];
		char t[2];
		short cw = 8;
		t[1]=0;
		if( atari_sysinfo.sfont_monospaced ) {
			t[0]='A';
			int r = vqt_width(atari_plot_vdi_handle, t[0], &vqw[0], &vqw[1], &vqw[2] );
			cw = vqw[0];
		}
		vswr_mode(atari_plot_vdi_handle, MD_TRANS );
		for( curx = work.g_x + 2, i=0 ; (curx+cw < work.g_x+work.g_w ) && i < sb->textlen; i++ ){
			t[0] = sb->text[i];
			if( !atari_sysinfo.sfont_monospaced ) {
				vqt_width(atari_plot_vdi_handle, t[0], &vqw[0], &vqw[1], &vqw[2] );
				cw = vqw[0];
			}
			if( curx >= lclip.g_x - cw ) {
				v_gtext(atari_plot_vdi_handle, curx, work.g_y + 5, (char*)&t );
			}
			curx += cw;
			if( curx >= lclip.g_x + lclip.g_w )
				break;
		}
	}
	vswr_mode(atari_plot_vdi_handle, MD_REPLACE );
	pxy[0] = work.g_x + work.g_w;
	pxy[1] = work.g_y + work.g_h;
	pxy[2] = work.g_x + work.g_w;
	pxy[3] = work.g_y + work.g_h-work.g_h;
	v_pline(atari_plot_vdi_handle, 2, (short*)&pxy );

	vs_clip(atari_plot_vdi_handle, 0, (short*)&pxyclip );
	return;
}
Example #3
0
/*
	area: the browser canvas
*/
void browser_redraw_caret( struct gui_window * gw, LGRECT * area )
{
	// TODO: only redraw caret when window is topped.
	if( gw->browser->caret.redraw && gw->browser->caret.requested.g_w > 0 ){
		LGRECT caret;
		struct s_browser * b = gw->browser;
		struct rect old_clip;
		struct rect clip;

		if( b->caret.current.g_w > 0 && b->caret.background.fd_addr != NULL ){
			browser_restore_caret_background( gw, area );
		}

		caret = b->caret.requested;
		caret.g_x -= b->scroll.current.x - area->g_x;
		caret.g_y -= b->scroll.current.y - area->g_y;

		if( !rc_lintersect( area, &caret ) ) {
			return;
		}

		MFDB screen;
		short pxy[8];

		/* save background: */
		//assert( b->caret.background.fd_addr == NULL );
		init_mfdb( app.nplanes, caret.g_w, caret.g_h, 0,
					&b->caret.background );
		init_mfdb( 0, caret.g_w, caret.g_h, 0, &screen );
		pxy[0] = caret.g_x;
		pxy[1] = caret.g_y;
		pxy[2] = caret.g_x + caret.g_w - 1;
		pxy[3] = caret.g_y + caret.g_h - 1;
		pxy[4] = 0;
		pxy[5] = 0;
		pxy[6] = caret.g_w - 1;
		pxy[7] = caret.g_h - 1;
		/* hide the mouse */
		v_hide_c ( app.graf.handle);
		/* copy screen image */
		vro_cpyfm ( app.graf.handle, S_ONLY, pxy, &screen, &b->caret.background);
		/* draw caret: */
		caret.g_x -= area->g_x;
		caret.g_y -= area->g_y;
		clip.x0 = caret.g_x;
		clip.y0 = caret.g_y;
		clip.x1 = caret.g_x + caret.g_w-1;
		clip.y1 = caret.g_y + caret.g_h-1;
		/* store old clip before adjusting it: */
		plot_get_clip( &old_clip );
		/* clip to cursor: */
		plot_clip( &clip );
		plot_line( caret.g_x, caret.g_y, caret.g_x, caret.g_y + caret.g_h,
					plot_style_caret );
		/* restore old clip area: */
		plot_clip( &old_clip );
		/* restore the mouse */
		v_show_c ( app.graf.handle, 1);
		b->caret.current.g_x = caret.g_x + gw->browser->scroll.current.x;
		b->caret.current.g_y = caret.g_y + gw->browser->scroll.current.y;
		b->caret.current.g_w = caret.g_w;
		b->caret.current.g_h = caret.g_h;
	}
}