Beispiel #1
0
static void Action(void)
{
    struct RastPort *rp;
    struct Region *reg;
    struct RegionRectangle *rr;
    WORD x, y, i, count = 0;
    
    puts("Activate the window whose visible region you want to see.\n");
    puts("You have 3 seconds of time!\n\n");
    
    Delay(3*50);

    win = IntuitionBase->ActiveWindow;
    scr = win->WScreen;
    
    if (!win) Cleanup("No active window!");
    
    if (!(rp = CloneRastPort(&win->WScreen->RastPort)))
    {
    	Cleanup("Can´t clone screen rastport!");
    }
    SetDrMd(rp,JAM1);
    
    lay = win->WLayer;
    
    reg = lay->VisibleRegion;
    rr = reg->RegionRectangle;
    while(rr)
    {
        WORD x1 = reg->bounds.MinX + rr->bounds.MinX;
        WORD y1 = reg->bounds.MinY + rr->bounds.MinY;
        WORD x2 = reg->bounds.MinX + rr->bounds.MaxX;
        WORD y2 = reg->bounds.MinY + rr->bounds.MaxY;
	
    	printf("#%04d (%4d,%4d) - (%4d, %4d)  Size: %4d x %4d\n",
		++count,
		x1,
		y1,
		x2,
		y2,
		x2 - x1 + 1,
		y2 - y1 + 1);
		
	for(i = 0; i < (Args[ARG_FAST] ? 1 : 8);i++)
	{
	    SetAPen(rp,1 + (i & 1));
	    RectFill(rp,x1,y1,x2,y1);
	    RectFill(rp,x2,y1,x2,y2);
	    RectFill(rp,x1,y2,x2,y2);
	    RectFill(rp,x1,y1,x1,y2);
	    
	    if (!Args[ARG_FAST]) Delay(10);
	}
	
	if (Args[ARG_NUMBERS])
	{
	    sprintf(s,"%d",count);
	    i = TextLength(rp,s,strlen(s));
	    
	    x = (x1 + x2 - i) / 2;
	    y = (y1 + y2 - rp->TxHeight) / 2;
	    
	    if (x < 0)
	    {
	    	x = 0;
	    } else if (x >= scr->Width - i)
	    {
	    	x = scr->Width - i - 1;
	    }
	  
	    if (y < 0)
	    {
	    	y = 0;
	    } else if (y >= scr->Height - rp->TxHeight)
	    {
	    	y = scr->Height - rp->TxHeight - 1;
	    }
	    
	    i = strlen(s);
	    
	    SetAPen(rp,1);
	    Move(rp,x + 1, y + 1 + rp->TxBaseline);
	    Text(rp,s,i);
	    
	    SetAPen(rp,2);
	    Move(rp,x, y + rp->TxBaseline);
	    Text(rp,s,i);
	}
    	rr = rr->Next;
    }
    
    FreeRastPort(rp);
}
Beispiel #2
0
BOOL MESA3DGLStandardInit(struct mesa3dgl_context * ctx, struct TagItem *tagList)
{
    LONG requestedwidth = 0, requestedheight = 0;
    LONG requestedright = 0, requestedbottom = 0;
    LONG defaultleft = 0, defaulttop = 0;
    LONG defaultright = 0, defaultbottom = 0;

    D(bug("[MESA3DGL] %s(ctx @ 0x%p, taglist @ 0x%p)\n", __PRETTY_FUNCTION__, ctx, tagList));

    /* Set the defaults based on window information */    
    if (ctx->window)
    {
        if(!(ctx->window->Flags & WFLG_GIMMEZEROZERO))
        {
            defaultleft     = ctx->window->BorderLeft;
            defaulttop      = ctx->window->BorderTop;
            defaultright    = ctx->window->BorderRight;
            defaultbottom   = ctx->window->BorderBottom;
        }
    }

    D(bug("[MESA3DGL] %s: Using RastPort @ 0x%p\n", __PRETTY_FUNCTION__, ctx->visible_rp));

    ctx->visible_rp = CloneRastPort(ctx->visible_rp);

    D(bug("[MESA3DGL] %s: Cloned RastPort @ 0x%p\n", __PRETTY_FUNCTION__, ctx->visible_rp));

    /* We assume left and top are given or if there is a window, set to border left/top 
       or if there is no window set to 0 */
    ctx->left = GetTagData(GLA_Left, defaultleft, tagList);
    ctx->top = GetTagData(GLA_Top, defaulttop, tagList);

    requestedright = GetTagData(GLA_Right, -1, tagList);
    requestedbottom = GetTagData(GLA_Bottom, -1, tagList);
    requestedwidth = GetTagData(GLA_Width, -1 , tagList);
    requestedheight = GetTagData(GLA_Height, -1 , tagList);

    /* Calculate rastport dimensions */
    ctx->visible_rp_width = 
        ctx->visible_rp->Layer->bounds.MaxX - ctx->visible_rp->Layer->bounds.MinX + 1;

    ctx->visible_rp_height = 
        ctx->visible_rp->Layer->bounds.MaxY - ctx->visible_rp->Layer->bounds.MinY + 1;

    /* right will be either passed or calculated from width or 0 */
    ctx->right = 0;
    if (requestedright < 0)
    {
        if (requestedwidth >= 0)
        {
            requestedright = ctx->visible_rp_width - ctx->left - requestedwidth;
            if (requestedright < 0) requestedright = 0;
        }
        else
            requestedright = defaultright; /* Set the default here, not in GetDataData */
    }
    ctx->right = requestedright;

    /* bottom will be either passed or calculated from height or 0 */
    ctx->bottom = 0;
    if (requestedbottom < 0)
    {
        if (requestedheight >= 0)
        {
            requestedbottom = ctx->visible_rp_height - ctx->top - requestedheight;
            if (requestedbottom < 0) requestedbottom = 0;
        }
        else
            requestedbottom = defaultbottom; /* Set the default here, not in GetDataData */
    }
    ctx->bottom = requestedbottom;

    /* Init screen information */
    if (ctx->Screen)
        ctx->BitsPerPixel  = GetCyberMapAttr(ctx->Screen->RastPort.BitMap, CYBRMATTR_BPPIX) * 8;

    D(bug("[MESA3DGL] %s: Context Base dimensions set -:\n", __PRETTY_FUNCTION__));
    D(bug("[MESA3DGL] %s:    ctx->visible_rp_width        = %d\n", __PRETTY_FUNCTION__, ctx->visible_rp_width));
    D(bug("[MESA3DGL] %s:    ctx->visible_rp_height       = %d\n", __PRETTY_FUNCTION__, ctx->visible_rp_height));
    D(bug("[MESA3DGL] %s:    ctx->left                    = %d\n", __PRETTY_FUNCTION__, ctx->left));
    D(bug("[MESA3DGL] %s:    ctx->right                   = %d\n", __PRETTY_FUNCTION__, ctx->right));
    D(bug("[MESA3DGL] %s:    ctx->top                     = %d\n", __PRETTY_FUNCTION__, ctx->top));
    D(bug("[MESA3DGL] %s:    ctx->bottom                  = %d\n", __PRETTY_FUNCTION__, ctx->bottom));

    return TRUE;
}
Beispiel #3
0
static void Action(void)
{
    struct RastPort *rp;
    struct Region *dr;
    struct RegionRectangle *rr;
    WORD x, y, x1, y1, x2, y2, i, count = 0;
    
    PutStr("Activate the window whose damagelist you want to see.\n");
    PutStr("You have 3 seconds of time!\n\n");
    
    Delay(3*50);

    win = IntuitionBase->ActiveWindow;
    if (!win) Cleanup("No active window!");

    scr = win->WScreen;

    lay = win->WLayer;

    dr = lay->DamageList;
    if (!dr) Cleanup("Layer does not have a damagelist!");
    rr = dr->RegionRectangle;
    if (!rr) Cleanup("Damagelist is empty!");
    
    if (!(rp = CloneRastPort(&win->WScreen->RastPort)))
    {
    	Cleanup("Can´t clone screen rastport!");
    }
    SetDrMd(rp,JAM1);
    
    while(rr)
    {
    	x1 = lay->bounds.MinX + dr->bounds.MinX + rr->bounds.MinX;
	y1 = lay->bounds.MinY + dr->bounds.MinY + rr->bounds.MinY;
	x2 = lay->bounds.MinX + dr->bounds.MinX + rr->bounds.MaxX;
	y2 = lay->bounds.MinY + dr->bounds.MinY + rr->bounds.MaxY;

    	Printf("#%04d (%4d,%4d) - (%4d, %4d)  Size: %4d x %4d\n",
		++count,
		x1,
		y1,
		x2,
		y2,
		x2 - x1 + 1,
		y2 - y1 + 1);

	
	for(i = 0; i < (Args[ARG_FAST] ? 1 : 8);i++)
	{
	    SetAPen(rp,1 + (i & 1));
	    
	    if (Args[ARG_RECTFILL])
	    {
	    	RectFill(rp,x1,y1,x2,y2);
	    } else {
		RectFill(rp,x1,y1,x2,y1);
		RectFill(rp,x2,y1,x2,y2);
		RectFill(rp,x1,y2,x2,y2);
		RectFill(rp,x1,y1,x1,y2);
	    }
	    
	    if (!Args[ARG_FAST]) Delay(10);
	}
	
	if (Args[ARG_NUMBERS])
	{
	    __sprintf(s,"%d",count);
	    i = TextLength(rp,s,strlen(s));
	    
	    x = (x1 + x2 - i) / 2;
	    y = (y1 + y2 - rp->TxHeight) / 2;
	    
	    if (x < 0)
	    {
	    	x = 0;
	    } else if (x >= scr->Width - i)
	    {
	    	x = scr->Width - i - 1;
	    }
	  
	    if (y < 0)
	    {
	    	y = 0;
	    } else if (y >= scr->Height - rp->TxHeight)
	    {
	    	y = scr->Height - rp->TxHeight - 1;
	    }
	    
	    i = strlen(s);
	    
	    SetAPen(rp,1);
	    Move(rp,x + 1, y + 1 + rp->TxBaseline);
	    Text(rp,s,i);
	    
	    SetAPen(rp,2);
	    Move(rp,x, y + rp->TxBaseline);
	    Text(rp,s,i);
	}
    	rr = rr->Next;
    }
    
    FreeRastPort(rp);
}