//__________________________________________________________________
void _HYPlatformGraphicPane::_SlidePane  (int dv, int dh)
{
	_HYGraphicPane* theParent = (_HYGraphicPane*)this;
	Rect r = {0,0,theParent->h,theParent->w};
	RgnHandle dummy = NewRgn();
	checkPointer (dummy);
	ScrollRect(&r,dh,dv,dummy);
	DisposeRgn (dummy);
}
//__________________________________________________________________
void _HYPlatformGraphicPane::_SlideRect (_HYRect& rct, int dv, int dh)
{
	_HYGraphicPane* theParent = (_HYGraphicPane*)this;
	Rect r;
	r.left = rct.left;
	r.top = rct.top;
	r.bottom = rct.bottom;
	r.right = rct.right;
	RgnHandle dummy = NewRgn();
	checkPointer (dummy);
	ScrollRect(&r,dh,dv,dummy);
	DisposeRgn (dummy);
}
Example #3
0
static void draw_scope(double *values)
{
    static int32 call_cnt;
    int offset, expose,i;
    RGBColor pixels[SCOPE_HEIGHT];
    double work[SCOPE_HEIGHT];
    int nze;
	Rect righthalf={0,SCOPE_WIDTH - SCROLL_THRESHOLD,
				SCOPE_HEIGHT, SCOPE_WIDTH },
		lefthalf={0,0,
				SCOPE_HEIGHT, SCOPE_WIDTH - SCROLL_THRESHOLD-1 };

	nze = 0;
    make_logspectrogram(values, work);
    if( win.show ){
		set_draw_pixel(work, pixels);

		expose = 0;

		SetPortWindowPort(win.ref);
		offset = call_cnt % SCROLL_THRESHOLD;
		if(offset == 0)
		{						//scroll the window
			EraseRect(&lefthalf);
			ScrollRect(&win.ref->portRect,
					-(SCOPE_WIDTH - SCROLL_THRESHOLD), 0, 0);
			EraseRect(&righthalf);
		}
			//draw
		for( i=0; i<SCOPE_HEIGHT; i++ ){
			RGBForeColor(&pixels[i]);
			MoveTo(SCOPE_WIDTH - SCROLL_THRESHOLD + offset,i);
			Line(0,0);
		}
	}
	if( skin_need_speana ){
		skin_draw_spectrum(work);
	    //ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "." );
	}
    if(nze)
	initialize_exp_hz_table(soundspec_zoom - 4 * nze);
    call_cnt++;
}
Example #4
0
void _scroll_window(
	short dy, 
	short rectangle_id, 
	short background_color_index)
{
	Rect *destination= _get_interface_rect(rectangle_id);
	RgnHandle updateRgn;
	RGBColor old_color, new_color;

	GetBackColor(&old_color);
	_get_interface_color(background_color_index, &new_color);
	RGBBackColor(&new_color);

	updateRgn= NewRgn();
	ScrollRect(destination, 0, dy, updateRgn);
	DisposeRgn(updateRgn);

	RGBBackColor(&old_color);
}
Example #5
0
int
TkScrollWindow(
    Tk_Window tkwin,		/* The window to be scrolled. */
    GC gc,			/* GC for window to be scrolled. */
    int x,			/* Position rectangle to be scrolled. */
    int y,
    int width,
    int height,
    int dx,			/* Distance rectangle should be moved. */
    int dy,
    TkRegion damageRgn)		/* Region to accumulate damage in. */
{
    MacDrawable *destDraw = (MacDrawable *) Tk_WindowId(tkwin);
    RgnHandle rgn = (RgnHandle) damageRgn;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    GWorldPtr destPort;
    Rect srcRect, scrollRect;
    
    destPort = TkMacGetDrawablePort(Tk_WindowId(tkwin));

    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);

    TkMacSetUpClippingRgn(Tk_WindowId(tkwin));

    /*
     * Due to the implementation below the behavior may be differnt
     * than X in certain cases that should never occur in Tk.  The 
     * scrollRect is the source rect extended by the offset (the union 
     * of the source rect and the offset rect).  Everything
     * in the extended scrollRect is scrolled.  On X, it's possible
     * to "skip" over an area if the offset makes the source and
     * destination rects disjoint and non-aligned.
     */
       
    SetRect(&srcRect, (short) (destDraw->xOff + x),
	    (short) (destDraw->yOff + y),
	    (short) (destDraw->xOff + x + width),
	    (short) (destDraw->yOff + y + height));
    scrollRect = srcRect;
    if (dx < 0) {
	scrollRect.left += dx;
    } else {
	scrollRect.right += dx;
    }
    if (dy < 0) {
	scrollRect.top += dy;
    } else {
	scrollRect.bottom += dy;
    }

    /*
     * Adjust clip region so that we don't copy any windows
     * that may overlap us.
     */
    RectRgn(rgn, &srcRect);
    DiffRgn(rgn, destPort->visRgn, rgn);
    OffsetRgn(rgn, dx, dy);
    DiffRgn(destPort->clipRgn, rgn, destPort->clipRgn);
    SetEmptyRgn(rgn);
    
    /*
     * When a menu is up, the Mac does not expect drawing to occur and
     * does not clip out the menu. We have to do it ourselves. This
     * is pretty gross.
     */

    if (tkUseMenuCascadeRgn == 1) {
    	Point scratch = {0, 0};
    	MacDrawable *macDraw = (MacDrawable *) Tk_WindowId(tkwin);

	LocalToGlobal(&scratch);
	CopyRgn(tkMenuCascadeRgn, rgn);
	OffsetRgn(rgn, -scratch.h, -scratch.v);
	DiffRgn(destPort->clipRgn, rgn, destPort->clipRgn);
	SetEmptyRgn(rgn);
	macDraw->toplevel->flags |= TK_DRAWN_UNDER_MENU;
    }
	
    ScrollRect(&scrollRect, dx, dy, rgn);
    
    SetGWorld(saveWorld, saveDevice);
    
    /*
     * Fortunantly, the region returned by ScrollRect is symanticlly
     * the same as what we need to return in this function.  If the
     * region is empty we return zero to denote that no damage was
     * created.
     */
    if (EmptyRgn(rgn)) {
	return 0;
    } else {
	return 1;
    }
}
Example #6
0
void reposition_slider_v_base(slider * s, int selected, int floater, int numbers)
{
	/* reposition the slider based on value v */
	double range;
	double foffset;
	int offset;
	double barwidth = s->sR.Xmax - s->sR.Xmin;
	point p;
	rect R;

	s->value = max(s->value, s->min);
	s->value = min(s->value, s->max);
#ifndef NOFLOATS
   if (floater)
	{
		long t;

		if (s->value > 0)
			t = (long) ((s->value + .00005) * 1000);
		else
			t = (long) ((s->value - .00005) * 1000);

		s->value = t / 1000.0;
	}
#endif

	if (s->value == s->old_value)
		return;


	range = s->max - s->min;
	foffset = s->value - s->min;
	offset = foffset / range * barwidth;




	/* Screw this XOR shit, just slide the whole box. */
	BackColor(selected == 2 ? ~BUTTONBACK : BUTTONBACK);

	p.X = s->sR.Xmin + offset;
	p.X = max(s->sR.Xmin + 5, p.X);
	p.X = min(s->sR.Xmax - 5, p.X);

	R.Xmin = p.X - s->bubblewidth / 2;
	R.Xmax = p.X + s->bubblewidth / 2 - 1;
	R.Ymin = s->sR.Ymin + 2;
	R.Ymax = s->sR.Ymax - 2;
	while (R.Xmin < s->sR.Xmin + 2)
		OffsetRect(&R, 1, 0);
	while (R.Xmax > s->sR.Xmax - 2)
		OffsetRect(&R, -1, 0);


	if (R.Xmin != s->bR.Xmin)
	{
		rect R1 = s->sR;

		ProtectRect(&R1);
		InsetRect(&R1, 1, 1);
		ClipRect(&R1);
		ScrollRect(&R1, -(s->bR.Xmin - R.Xmin), 0);
		ClipRect(&sR);
		ProtectOff();
	}
	s->bR = R;
	/* Now paint the new number in */
#ifndef NONUMBERS
   if (numbers)
	{
		PaintNumberBoxEntry(&s->TB, s->value, (floater) ? GS_FLOAT : GS_UNSIGNED);
	}
#endif
	s->old_value = s->value;

}
Example #7
0
void CCellView::ResizeRow(BPoint where, int rowNr)
{
	float y, minY;
	BPoint newP, lastP;
	BRect bounds(Bounds()), r, b;
	BRegion rgn;
	ulong buttons, cnt;
	bool multi;
	int mRow = rowNr;
	CRunArray backup(fCellHeights);
	
	StPenState save(this);
	ClearAnts();
	
	rgn.Include(bounds);

	cnt = fSelection.bottom-fSelection.top+1;

	while (where.y > fCellHeights[rowNr+1]+2)
		rowNr++;

	multi = fSelection.top != fSelection.bottom
					&& rowNr >= fSelection.top
					&& rowNr <= fSelection.bottom;

	if (rowNr <= fFrozen.v)
	{
		y = fBorderHeight+fCellHeights[rowNr];
		minY = fBorderHeight+fCellHeights[multi?fSelection.top-1:rowNr-1];
	}
	else
	{
		y = fBorderHeight+fCellHeights[rowNr]+fCellHeights[fFrozen.v]-
			fCellHeights[fPosition.v-1];
		minY = fBorderHeight+fCellHeights[fFrozen.v]-fCellHeights[fPosition.v-1]+
			fCellHeights[multi?fSelection.top-1:rowNr-1];
	}
	
	r.left = 0;
	r.right = fBorderWidth-1;
	r.top = minY+1;
	if (multi)
		r.bottom = minY+fCellHeights[fSelection.bottom]-
			fCellHeights[fSelection.top-1]-1;
	else
		r.bottom = minY+fCellHeights[rowNr]-fCellHeights[rowNr-1]-1;

	b = bounds;
	b.top = r.bottom;
	
	lastP = where;
	newP = where;
	do
	{
		if (newP.y != lastP.y)
		{
			float dy;
			int k = rowNr;
			
			dy = newP.y - lastP.y;

			if (lastP.y + dy < bounds.top + fBorderHeight)
				dy = std::min(lastP.y - bounds.top - fBorderHeight, (float)0);
			if (lastP.y + dy > bounds.bottom)
				dy = std::max(bounds.bottom - lastP.y, (float)0);
			
			if (multi && y + dy < minY)
				dy = minY - y;

			if (multi)
			{
				float h, t;
				
				h = y + dy - minY;
				if (h > 0)
					h = Round(h/(rowNr-fSelection.top+1));
				
				t = fCellHeights[fSelection.bottom];				
				fCellHeights.SetValue(fSelection.top, fSelection.bottom, h);
				dy = fCellHeights[fSelection.bottom] - t;
			}
			else if (y + dy < minY)
			{
				int t = k;
				
				fCellHeights.SetValue(rowNr, 0);

				while (k > 1 && backup[k - 1] + fBorderHeight >= y + dy)
					k--;

				ASSERT(k<rowNr);

				if (k <= mRow)
					while (mRow > k)
						fCellHeights.SetValue(mRow--, 0);
				else
				{
					t = mRow;
					for (; mRow < k; mRow++)
						fCellHeights.SetValue(mRow, backup[mRow] - backup[mRow - 1]);
				}

				float kh = y + dy - fBorderHeight;
				kh -= backup[k - 1];
				fCellHeights.SetValue(k, std::max(kh, (float)0));

				mRow = k;
				k = t;
			}
			else
			{
				k = mRow;
				for (; mRow < rowNr; mRow++)
					fCellHeights.SetValue(mRow, backup[mRow] - backup[mRow - 1]);

				fCellHeights.SetValue(rowNr, y + dy - minY);
			}
					
			if (dy != 0)
			{
				y += dy;
				lastP.y += dy;

				if (dy < 0)
					b.top += dy;
				
				StPenState save(this);
				StClipCells clip(this);
				ScrollRect(b, 0, dy);
				Window()->UpdateIfNeeded();
				
				if (dy > 0)
					b.top += dy;

				if (multi)
				{
					int v = fSelection.top;
					do
					{
						TouchLine(v);
						DrawBorderCell(v++, false);
					}
					while (v <= fSelection.bottom && bounds.top + fCellHeights[v] + fBorderHeight < bounds.bottom);
				}
				else
				{
					TouchLine(mRow);
					DrawBorderCell(mRow, false);
				}
				
				for (; k < rowNr; k++)
				{
					TouchLine(k);
					DrawBorderCell(k, false);
				}
			}
			
			if (dy < 0)
			{
				float Y;
				int v;
				
				Y = bounds.bottom + dy - fBorderHeight;
				v = fSelection.bottom;
				do v++;
				while (fCellHeights[v] < Y)
					;

				StPenState save(this);
				
				while (v <= kRowCount && bounds.top + fCellHeights[v] + fBorderHeight < bounds.bottom)
				{
					TouchLine(v);
					DrawBorderCell(v++, false);
				}
			}
			
			if (dy)
			{
				DrawAllLines();
				if (fFirstGraphic)
					fFirstGraphic->HandleUpdate(bounds);
			}
		}
		GetMouse(&newP, &buttons);
	}
	while (buttons);
	
	if (!(backup == fCellHeights))
	{
		CRunArray temp(fCellHeights);
		fCellHeights = backup;
		
		((CCellWindow*)Window())->RegisterCommand(new CResizeCommand(this, temp, true));
		((CCellWindow*)Window())->SetDirty(true);
	}
} /* ResizeRow */
Example #8
0
void CCellView::ResizeCol(BPoint where, int colNr)
{
	float x, minX, maxRow;
	BPoint newP, lastP;
	BRect bounds(Bounds()), r, b;
	ulong buttons, cnt;
	bool multi;
	int mCol = colNr;
	CRunArray backup(fCellWidths);

	StPenState save(this);
	ClearAnts();

	cnt = fSelection.right - fSelection.left + 1;

	while (fCellWidths[colNr + 1] == fCellWidths[colNr])
		colNr++;

	multi = fSelection.left != fSelection.right
					&& colNr >= fSelection.left
					&& colNr <= fSelection.right;

	if (colNr <= fFrozen.h)
	{
		x = fBorderWidth + fCellWidths[colNr];
		minX = fBorderWidth + fCellWidths[multi?fSelection.left - 1 : colNr - 1];
	}
	else
	{
		x = fBorderWidth + fCellWidths[colNr] + fCellWidths[fFrozen.h] - 
			fCellWidths[fPosition.h - 1];
		minX = fBorderWidth + fCellWidths[fFrozen.h] - fCellWidths[fPosition.h - 1] + 
			fCellWidths[multi?fSelection.left - 1 : colNr - 1];
	}
	
	r.top = 1;
	r.bottom = fBorderHeight - 1;
	r.left = minX + 1;
	if (multi)
		r.right = minX + fCellWidths[fSelection.right] - 
			fCellWidths[fSelection.left - 1] - 1;
	else
		r.right = minX + fCellWidths[colNr] - fCellWidths[colNr - 1] - 1;
		
	b = bounds;
	b.left = r.right;
	
	maxRow = fPosition.v;
	while (fCellHeights[++maxRow] - fCellHeights[fPosition.v] < bounds.bottom - fBorderHeight)
		;
	
	lastP = where;
	newP = where;
	do
	{
		if (newP.x != lastP.x)
		{
			float dx;
			int k = colNr;
			
			dx = newP.x - lastP.x;
			
			if (lastP.x + dx < bounds.left + fBorderWidth)
				dx = std::min(lastP.x - bounds.left - fBorderWidth, (float)0);
			if (lastP.x + dx > bounds.right)
				dx = std::max(bounds.right - lastP.x, (float)0);
			
			if (multi && x + dx < minX)
				dx = minX - x;

			if (multi)
			{
				float w, t;
				
				w = x + dx - minX;
				if (w > 0)
					w = Round(w / (colNr - fSelection.left + 1));
				
				t = fCellWidths[fSelection.right];				
				fCellWidths.SetValue(fSelection.left, fSelection.right, w);
				dx = fCellWidths[fSelection.right] - t;
			}
			else if (x + dx < minX)
			{
				int t = k;
				
				fCellWidths.SetValue(colNr, 0);

				while (k > 1 && backup[k - 1] + fBorderWidth >= x + dx)
					k--;

				ASSERT(k<colNr);

				if (k <= mCol)
					while (mCol > k)
						fCellWidths.SetValue(mCol--, 0);
				else
				{
					t = mCol;
					for (;mCol<k;mCol++)
						fCellWidths.SetValue(mCol, backup[mCol] - backup[mCol - 1]);
				}

				float kw = x + dx - fBorderWidth;
				kw -= backup[k - 1];
				fCellWidths.SetValue(k, std::max(kw, (float)0));

				mCol = k;
				k = t;
			}
			else
			{
				k = mCol;
				for (; mCol < colNr; mCol++)
					fCellWidths.SetValue(mCol, backup[mCol] - backup[mCol - 1]);

				fCellWidths.SetValue(colNr, x + dx - minX);
			}
					
			if (dx != 0)
			{
				x += dx;
				lastP.x += dx;

				if (dx < 0)
					b.left += dx;
				
				StPenState save(this);
				StClipCells clip(this);
				ScrollRect(b, dx, 0);
				Window()->UpdateIfNeeded();
				
				if (dx > 0)
					b.left += dx;
				
				if (multi)
				{
					int h = fSelection.left, v;
					do
					{
						for (v = 1; v < fFrozen.v; v++)
							DrawCell(cell(h, v));
						for (v = fPosition.v; v < maxRow; v++)
							DrawCell(cell(h, v));
						DrawBorderCell(h++, true);
					}
					while (h <= fSelection.right && bounds.left + fCellWidths[h] + fBorderWidth < bounds.right);
				}
				else
				{
					int v;
					for (v = 1; v < fFrozen.v; v++)
						DrawCell(cell(mCol, v));
					for (v = fPosition.v; v < maxRow; v++)
						DrawCell(cell(mCol, v));
					DrawBorderCell(mCol, true);
				}
				
				for (; k < colNr; k++)
				{
					int v;
					for (v = 1; v < fFrozen.v; v++)
						DrawCell(cell(k, v));
					for (v = fPosition.v; v < maxRow; v++)
						DrawCell(cell(k, v));
					DrawBorderCell(k, true);
				}
			}
			
			if (dx < 0)
			{
				float X;
				int h;
				
				X = bounds.right + dx - fBorderWidth;
				h = fSelection.right;
				do h++;
				while (fCellWidths[h] < X);
				
				while (h <= kColCount && bounds.left + fCellWidths[h] + fBorderWidth < bounds.right)
				{
					int v;
					for (v = 1; v < fFrozen.v; v++)
						DrawCell(cell(h, v));
					for (v = fPosition.v; v < maxRow; v++)
						DrawCell(cell(h, v));
					DrawBorderCell(h++, true);
				}
			}
			
			if (dx && fFirstGraphic)
				fFirstGraphic->HandleUpdate(bounds);
		}
		GetMouse(&newP, &buttons);
	}
	while (buttons);

	if (!(backup == fCellWidths))
	{
		CRunArray temp(fCellWidths);
		fCellWidths = backup;
		
		((CCellWindow*)Window())->RegisterCommand(new CResizeCommand(this, temp, false));
		((CCellWindow*)Window())->SetDirty(true);
	}
} /* ResizeCol */