Пример #1
0
void Slider::Slide (Event& e) {
    IntCoord newleft, newbot, dummy;
    boolean control = e.control;

    Listen(allEvents);
    SlidingRect r(output, canvas, left, bottom, right, top, e.x, e.y);
    CalcLimits(e);
    do {
	switch (e.eventType) {
	    case MotionEvent:
		e.target->GetRelative(e.x, e.y, this);
		Constrain(e);
		r.Track(e.x, e.y);

                if ((syncScroll && !control) || (!syncScroll && control)) {
                    r.Erase();
                    r.GetCurrent(newleft, newbot, dummy, dummy);
                    Move(ViewX(newleft - left), ViewY(newbot - bottom));
                    interactor->Adjust(*shown);
                }

		break;
	    default:
		break;
	}
	Read(e);
    } while (e.eventType != UpEvent);

    r.GetCurrent(newleft, newbot, dummy, dummy);
    Move(ViewX(newleft - left), ViewY(newbot - bottom));
    Listen(input);
}
Пример #2
0
void stCurveView::AddKnob()
{
	stCurveKnob **tmp_knob;
	tmp_knob=new stCurveKnob*[knob_count+1];
	uint8 i;
	for (i=0;i<knob_count;i++)
		tmp_knob[i]=knob[i];

	tmp_knob[knob_count]=new stCurveKnob(knob[knob_count-1]->Position()+BPoint(10,0),BRect(knob[knob_count-1]->XPosition(),0,width,m_height),m_message);
	AddChild(tmp_knob[knob_count]);
	knob_count++;

	delete []knob;
	knob = tmp_knob;

	BPoint memory1;
	BPoint memory2;
	bool copy=false;
	for (i=0;i<knob_count;i++)
	{
		if (copy)
		{
			memory2=knob[i]->Position();
			knob[i]->MoveTo(memory1);
			memory1=memory2;
		}
		else if (knob[i]->IsFocus() && i!=knob_count-1)
		{
			copy=true;
			memory1=BPoint((knob[i+1]->Position().x+knob[i]->Position().x)/2,(knob[i+1]->Position().y+knob[i]->Position().y)/2);
		}
	}
	CalcLimits();
	UpdateIndices();
}
Пример #3
0
stCurveView::stCurveView(BRect bounds, const char *name, BMessage *message)
	: BView(bounds,"CurveView",B_FOLLOW_NONE,B_NAVIGABLE/*_JUMP*/+B_WILL_DRAW)
{
	m_name = name;
	BFont name_font(be_plain_font);
	font_height height;
	name_font.GetHeight(&height);
	m_name_pos = BPoint(bounds.Width() - name_font.StringWidth(name) - 1.0, height.ascent + 1.0);
	SetFont(&name_font);

	m_message = message;
	knob_count = 1;
	knob=new stCurveKnob*[knob_count];

	m_height=bounds.Height();
	width=bounds.Width();

	uint8 i;

	for (i=0;i<knob_count;i++)
		knob[i]=new stCurveKnob(BPoint(i,m_height),BRect(0,0,100,100),m_message);

	for (i=0;i<knob_count;i++)
		AddChild(knob[i]);

	CalcLimits();

	SetViewColor(B_TRANSPARENT_COLOR);
	SetLowColor(200,200,200);
	SetHighColor(136,136,234);
	UpdateIndices();
}
Пример #4
0
void stCurveView::DeleteKnob()
{
	if (knob_count==1) return;
	stCurveKnob **tmp_knob;
	tmp_knob=new stCurveKnob*[knob_count-1];
	uint8 i,j=0;
	bool removed=false;
	for (i=0;i<knob_count;i++)
	{
		if ((knob[i]->IsFocus() || i==knob_count-1) && !removed) // we don't want to remove more than one knob
		{ // if no knob has the focus we delete the last one
			if (i>0) knob[i-1]->MakeFocus();
			else knob[i+1]->MakeFocus();

			RemoveChild(knob[i]);
			removed=true;
			i++;
			if (i==knob_count) continue;
		}
		tmp_knob[j++]=knob[i];
	}
	knob_count--;

	delete []knob;
	knob=tmp_knob;
	CalcLimits();
	Invalidate();
	UpdateIndices();
}
Пример #5
0
void CMainFrame::AddNbrs ()
{
	int xlow,xhigh,ylow,yhigh;
	int c,r;
	CPoint* pCell;

	while (!m_pLive->IsEmpty ())
	{
		pCell=(CPoint*)m_pLive->RemoveHead ();
		c=pCell->x;
		r=pCell->y;
		delete pCell;
		CalcLimits(c,r,xlow,xhigh,ylow,yhigh);

		for(int x=xlow;x<=xhigh;++x)
			for(int y=ylow;y<=yhigh;++y)
				if( (x!=c)||(y!=r) )
				{

					m_nbrs[y][x]+=1;
					switch(m_nbrs[y][x])
					{
					case 1:
					case 2:break;

					case 3:
						if(m_world[y][x]==DEAD)
						{
							pCell=new CPoint(x,y);
							m_pNextLive->AddTail (pCell);
						}
						break;

					case 4:
						if(m_world[y][x]==ALIVE)
						{
							pCell=new CPoint(x,y);
							m_pNextDie->AddTail (pCell);
						}
						break;

					case 5:
					case 6:
					case 7:
					case 8:break;
					}
				}
	}
}