Пример #1
0
// Show box for rubber-banding
void backdrop_rubber_band(BackdropInfo *info,BOOL sel)
{
	UBYTE mode;
	struct RastPort *rp;

	// Do selections
	if (sel) backdrop_select_area(info,2);

	// Get rastport
	rp=info->window->RPort;

	// Save draw mode
	mode=rp->DrawMode;

	// Set complement and dash pattern
	SetDrMd(rp,COMPLEMENT);
	SetDrPt(rp,0xf0f0);

	// Draw rectangle
	Move(rp,info->select.MinX,info->select.MinY);
	Draw(rp,info->select.MaxX,info->select.MinY);
	Draw(rp,info->select.MaxX,info->select.MaxY);
	Draw(rp,info->select.MinX,info->select.MaxY);
	Draw(rp,info->select.MinX,info->select.MinY+((info->select.MinY<info->select.MaxY)?1:-1));

	// Restore old mode and pattern
	SetDrMd(rp,mode);
	SetDrPt(rp,0xffff);
}
Пример #2
0
VOID test_flood(struct Window *w)
{

    struct TmpRas tmpras;
    BYTE *buffer;
    
D(bug("Window layer: %p\n", w->WLayer));    

    buffer = AllocRaster(w->WLayer->Width, w->WLayer->Height);
D(bug("buffer: %p\n", buffer));    
    if (!buffer)
    	return;
	
    InitTmpRas(&tmpras, buffer, RASSIZE(w->WLayer->Width, w->WLayer->Height));
    w->RPort->TmpRas = &tmpras;
    
    SetOutlinePen(w->RPort, 1);
    SetAPen(w->RPort, 1);
    
    SetDrPt(w->RPort, ~0L);
    
    Move(w->RPort, 50, 50);
    Draw(w->RPort, 100, 100);
    Draw(w->RPort, 50,  100);
    Draw(w->RPort, 50, 50);
    
D(bug("Calling Flood()\n"));    
    Flood(w->RPort, 0, 70, 80);   /* outline mode */

    w->RPort->TmpRas = NULL;
    
}
Пример #3
0
/// DrawArea
Local
VOID DrawArea( FRAME *frame, Point *coords, WORD nPoints )
{
    struct Selection *selection = &frame->selection;
    DISPLAY *d = frame->disp;
    struct RastPort *rPort = d->win->RPort;
    struct IBox *abox;
    WORD x,y, winwidth, winheight, xoffset, yoffset;
    int i;

    if( selection->nVertices > 2 ) {
        GetAttr( AREA_AreaBox, d->RenderArea, (ULONG *) &abox );
        winwidth  = abox->Width;
        winheight = abox->Height;
        xoffset   = abox->Left;
        yoffset   = abox->Top;

        SetDrMd(rPort, COMPLEMENT);
        SetDrPt(rPort, (UWORD) frame->disp->selpt);    // Uses just lower 16 bits

        x = MULS16((selection->vertices[0].x - frame->zoombox.Left),winwidth) / frame->zoombox.Width + xoffset;
        y = MULS16((selection->vertices[0].y - frame->zoombox.Top),winheight) / frame->zoombox.Height + yoffset;

        Move( rPort, x, y );

        for( i = 1; i < selection->nVertices; i++ ) {
            x = MULS16((selection->vertices[i].x - frame->zoombox.Left),winwidth) / frame->zoombox.Width + xoffset;
            y = MULS16((selection->vertices[i].y - frame->zoombox.Top),winheight) / frame->zoombox.Height + yoffset;

            Draw( rPort, x, y );
        }
    }
}
Пример #4
0
// Draw an item in the listview
void listview_draw_item(
	Class *cl,
	struct Gadget *gadget,
	struct RastPort *rp,
	struct DrawInfo *drawinfo,
	ListViewData *data,
	struct Node *node,
	unsigned short line,
	struct IBox *user_box)
{
	short selected=0,tab_flag=0,high;
	unsigned short x,y,len=0,textlen,pos=0,tabpos=0,width,last_x=0;
	short fpen;
	struct TextExtent extent;
	struct IBox *box;
	char *name;

	// User-supplied box?
	if (user_box)
	{
		box=user_box;
		high=1;
	}
	else
	{
		box=&data->text_dims;
		high=(BOOL)(data->sel==data->top+line);
	}

	// Get y position
	y=((unsigned short)box->Top)+line*data->text_height;

	// Invalid item?
	if (!node || !node->ln_Succ)
	{
		// Fill item
		SetAPen(rp,drawinfo->dri_Pens[(high)?FILLPEN:BACKGROUNDPEN]);
		RectFill(rp,
			box->Left,
			y,
			box->Left+box->Width-1,
			y+data->text_height-1);
		return;
	}

	// Does this item need a highlight select?
	if (high)
	{
		if ((!(data->flags&LVF_CANCEL) && gadget->Flags&GFLG_SELECTED) ||
			(data->flags&LVF_SHOW_SELECTED && !(data->flags&LVF_SELECTED_CHECK)))
			selected=1;
	}

	// Highlight selection?
	if (high && !(gadget->Flags&GFLG_SELECTED) && data->flags&LVF_SELECTED_HIGH)
	{
		fpen=drawinfo->dri_Pens[HIGHLIGHTTEXTPEN];
	}

	// Highlight multi-select?
	else
	if (!(data->flags&LVF_NO_HIGHLIGHT) &&
		data->flags&LVF_MULTI_SELECT &&
		data->flags&LVF_SELECTED_HIGH &&
		node->lve_Flags&LVEF_SELECTED)
	{
		fpen=drawinfo->dri_Pens[HIGHLIGHTTEXTPEN];
	}

	// Custom pen supplied?
	else
	if (node->lve_Flags&LVEF_USE_PEN)
	{
		// If selected, check pen is different to background
		if (selected && node->lve_Pen==drawinfo->dri_Pens[FILLPEN])
			fpen=drawinfo->dri_Pens[FILLTEXTPEN];

		// Ok to use custom pen
		else fpen=node->lve_Pen;
	}

	// Normal entry
	else
	{
		fpen=drawinfo->dri_Pens[(selected)?FILLTEXTPEN:TEXTPEN];
	}

	SetAPen(rp,fpen);
	SetBPen(rp,drawinfo->dri_Pens[(selected)?FILLPEN:BACKGROUNDPEN]);
	SetDrMd(rp,JAM2);

	// Valid name?
	if (node->ln_Name)
	{
		// Get name pointer
		name=node->ln_Name;

		// Only show filenames?
		if (data->flags&LVF_SHOW_FILENAMES)
		{
			// Get filename pointer
			name=lv_FilePart(name);
		}

		// Get text length
		textlen=strlen(name);

		// Right-justify?
		if (data->flags&LVF_RIGHT_JUSTIFY)
		{
			char *dots=0;
			short dotlen=0;

			// Get length that will fit (from end backwards)
			len=TextFit(
				rp,
				name+textlen-1,textlen,
				&extent,
				0,-1,
				data->text_width,
				data->text_height);

			// Won't all fit?
			if (len<textlen)
			{
				// Get length of dots
				dots="...";
				dotlen=TextLength(rp,dots,3);

				// Get new length of string that will fit
				len=TextFit(
					rp,
					name+textlen-1,textlen,
					&extent,
					0,-1,
					data->text_width-dotlen,
					data->text_height);
			}

			// Draw text
			Move(rp,box->Left+data->text_offset,y+rp->TxBaseline);
			if (dots) Text(rp,dots,3);
			Text(rp,name+textlen-len,len);

			// Save x position
			last_x=data->text_offset+dotlen+extent.te_Width;
		}

		// Normal
		else
		{
			BOOL sep=0;

			// Get x position
			x=data->text_offset;

			// Show separators?
			if (data->flags&LVF_SHOW_SEPARATORS && strcmp(name,"---")==0)
				sep=1;

			// Go through string
			while (pos<textlen)
			{
				// Separator?
				if (sep)
				{
					// Get full size
					width=data->text_width-x;
				}

				// Need to parse
				else
				{
					// Look for tab
					for (tabpos=0;name[pos+tabpos];tabpos++)
						if (name[pos+tabpos]=='\t' ||
							name[pos+tabpos]=='\a' ||
							name[pos+tabpos]=='\v') break;

					// Get text size
					if (tabpos>0)
					{
						len=TextFit(
							rp,
							name+pos,tabpos,
							&extent,
							0,1,
							data->text_width-x,
							data->text_height);
						width=extent.te_Width;
					}
					else
					{
						len=0;
						width=0;
					}

					// Tab across if needed		
					if (tab_flag==1) x=data->text_width-width;
					else
					if (tab_flag==2) x=(data->text_width-width)>>1;
				}

				// Fill background if needed
				if (last_x && last_x<x)
				{
					SetAPen(rp,drawinfo->dri_Pens[(selected)?FILLPEN:BACKGROUNDPEN]);
					RectFill(rp,
						box->Left+last_x,
						y,
						box->Left+x-1,
						y+data->text_height-1);
					SetAPen(rp,fpen);
				}

				// Draw separator?
				if (sep)
				{
					short yp,xp;

					// Clear area under line
					SetAPen(rp,drawinfo->dri_Pens[(selected)?FILLPEN:BACKGROUNDPEN]);
					RectFill(rp,
						box->Left+x,
						y,
						(xp=box->Left+x+width-1),
						y+data->text_height-1);
					SetAPen(rp,fpen);

					// Get y position
					yp=y+(data->text_height>>1);

					// Draw line
					SetDrPt(rp,0xbbbb);
					Move(rp,box->Left+x,yp);
					Draw(rp,xp,yp);
					SetDrPt(rp,0xeeee);
					Move(rp,box->Left+x,yp+1);
					Draw(rp,xp,yp+1);
					SetDrPt(rp,0xffff);
				}

				// Draw text
				else
				if (len>0)
				{
					Move(rp,box->Left+x,y+rp->TxBaseline);
					Text(rp,name+pos,len);
				}

				// Save x position
				last_x=x+width;

				// Break if just did separator
				if (sep) break;

				// Bump buffer pointer
				pos+=tabpos+1;

				// Set tab flag
				if (pos>0)
				{
					if (name[pos-1]=='\t') tab_flag=1;
					else
					if (name[pos-1]=='\v') tab_flag=2;
					else
					if (name[pos-1]=='\a')
					{
						unsigned short tab;

						// Move text position across
						tab=(unsigned short)name[pos];
						x+=tab*rp->TxWidth;

						// Bump position
						++pos;
					}

					// Tab flag not set, bump position
					else x+=width;
				}
			}
		}
Пример #5
0
MazeDraw1(vertex_pt v0)                /* Draw borders or clear pathways */
{
   /* mazedraw = 1: Draw borders.  0 = erase pathways */
   
   if(!v0) return 0;

   MazeDraw1(v0->left);

   for(i=0;i<4;i++)
   {
      xr=(i==1)-(i==3);yr=(i==2)-(i==0);
      j=pathsize*xr,k=pathsize*yr;

      if ( v0->next[i] )
      {
       if(mazedraw) {path=pathsize;inc=pathsize<<1;}
       else         {path=pathsize-1;inc=1;}
  
       if (v0->x          <=maxx && v0->y          <=maxy
        && v0->next[i]->x <=maxx && v0->next[i]->y <=maxy)
       if (mazedraw) for(c=-path;c<=path;c+=inc)
       {
        Move(rastport,v0->x+yr*c+j,v0->y+xr*c+yr*pathsize);
        if(!(v0->code[i]&TUNNEL))
           Draw(rastport,v0->next[i]->x+yr*c-j,
                         v0->next[i]->y+xr*c-yr*pathsize);
        else                                 /* Special case for tunnels */
        {
           tx=(maxx+border)*(xr>0)+(minx-border)*(xr<0)+(v0->x+yr*c)*(!xr);
           ty=(maxy+border)*(yr>0)+(miny-border)*(yr<0)+(v0->y+xr*c)*(!yr);
           Draw(rastport,tx,ty);
        }
       }
       else /* Mazedraw == 0, so erase the edges */
       {
          SetOPen(rastport,PATHCOLOR);
          SetAPen(rastport,PATHCOLOR);
          if((i==1 || i==2) && !(v0->code[i]&TUNNEL))
             RectFill(rastport,v0->x-path,         v0->y-path,
                               v0->next[i]->x+path,v0->next[i]->y+path);
          else if (i==1 || i==2) /* Erase path for tunnel */
          {
             RectFill(rastport,v0->x-path,v0->y-path,
                               xr?border+maxx:v0->x+path,
                               yr?border+maxy:v0->y+path);
    
             RectFill(rastport,xr?minx-border:v0->next[i]->x-path,
                               yr?miny-border:v0->next[i]->y-path,
                               v0->next[i]->x+path,v0->next[i]->y+path);
          }
       }
      }                      /* End of block executed if there is a path */
      else if (mazedraw && !v0->next[i])
      {                                  /* Close up the NULL directions */
         Move(rastport,v0->x+j+k,v0->y+j+k);
         Draw(rastport,v0->x+j-k,v0->y-j+k);
      }
      /* Round the corners (?): */
      if(!mazedraw&& v0->next[i]&&v0->next[(i+1)&3]&& xfactor>4&&yfactor>4)
         WritePixel(rastport,v0->x+(i<2)*pathsize-(i>1)*pathsize
            ,v0->y-(((i+1)&3)<2)*pathsize+(((i+1)&3)>1)*pathsize);
      else if(!mazedraw && !v0->next[i] && !v0->next[(i+1)&3]
         && v0->next[(i+2)&3] && v0->next[(i+3)&3] && xfactor>4&&yfactor>4)
      {
          SetAPen(rastport,FILLCOLOR);
          WritePixel(rastport,v0->x+(i<2)*pathsize-(i>1)*pathsize
             ,v0->y-(((i+1)&3)<2)*pathsize+(((i+1)&3)>1)*pathsize);
          SetAPen(rastport,PATHCOLOR);
      }
   }
   for(i=0;i<4;i++)
   {
      if(!mazedraw && (/*(v0->next[i]==center_box && v0==top_box)
                       ||*/ ((v0->code[i]&GHOST_1WAY) && in_con)
                       || (v0->code[i]&FORBID)))
      {                     /* Make restrictive bar for "No trespassing" */
         xr=(i==1)-(i==3);yr=(i==2)-(i==0);
         j=pathsize*xr,k=pathsize*yr;
         if (!(v0->code[i] & FORBID))
           SetDrPt(rastport,0xAAAA)
         SetAPen(rastport,NOTRESCOLOR);
         Move(rastport,v0->x+j+k,v0->y+j+k);
         Draw(rastport,v0->x+j-k,v0->y-j+k);
         SetAPen(rastport,PATHCOLOR);
         SetDrPt(rastport,0xFFFF);
      }
   }
   MazeDraw1(v0->right);

   return 0;
}