コード例 #1
0
ファイル: CCandidateView.cpp プロジェクト: XilongPei/Elastos5
void CCandidateView::ScrollToTarget()
{
    Int32 sx = 0;
    GetScrollX(&sx);
    if (mTargetScrollX > sx) {
        sx += SCROLL_PIXELS;
        if (sx >= mTargetScrollX) {
            sx = mTargetScrollX;
            RequestLayout();
        }
    }
    else {
        sx -= SCROLL_PIXELS;
        if (sx <= mTargetScrollX) {
            sx = mTargetScrollX;
            RequestLayout();
        }
    }
    Int32 tmp = 0;
    GetScrollY(&tmp);
    ScrollTo(sx, tmp);
    Invalidate();
}
コード例 #2
0
void MatrixControl::Draw (BRect restrictiveRect)
{

if (IsFocus() == false) showcursor=false;
Window()->Lock();

float orx = GetScrollX();
float ory = GetScrollY();

SetHighColor(0,0,0,255);
StrokeRect(BRect(orx,ory,Frame().Width()+orx,Frame().Height()+ory),B_SOLID_HIGH);

int i,k;
int32 a,b;
BString out;

escapement_delta delta;
delta.space = 0;
delta.nonspace = 0;


SetDrawingMode( B_OP_OVER );
SetFont( be_bold_font );

if ((CursorOnKoeff == true) && (cursoron == true)) 
	{
	SetHighColor(255,255,255,255);
	}

if (CursorOnKoeff) DrawString( edit->String() , BPoint(10,20), &delta); 
	else if (!DrawfromPulse) DrawString( extra::fStringOutOf( Koeffizient,GLOBAL_ACCURACY ).String()  , BPoint(10,20), &delta);


if /* A */ (DrawfromPulse == false)
	{

	for /* B */ (i=0;i<matrix_dimension;++i)
		{
		if (!DataEnterMode)
			{
			SetHighColor(255,40,40,255);
			FillRect(BRect( (i+1)*square_size-10, 20 ,(i+1)*square_size-5 , square_size * matrix_dimension), B_SOLID_HIGH );
			SetHighColor(40,40,255,255);
			FillRect(BRect( 20, (i+1)*square_size+5, square_size * (matrix_dimension+1) ,(i+1)*square_size+10  ), B_SOLID_HIGH );
			
			SetHighColor(0,0,0,255);
			StrokeRect(BRect( (i+1)*square_size-10, 20 ,(i+1)*square_size -5 , square_size * matrix_dimension), B_SOLID_HIGH );
			StrokeRect(BRect( 20, (i+1)*square_size+5, square_size * (matrix_dimension+1) ,(i+1)*square_size +10 ), B_SOLID_HIGH );
			}
				
		for /* C */(k=0;k<matrix_dimension;++k)
			{
			out.SetTo(extra::fStringOutOf(float_matrix[i*matrix_dimension +k],GLOBAL_ACCURACY).String());
			SetHighColor(255,50,127,255);
			if /* D */ ((showcursor == true) && (posx == k) && (posy == i) && (cursoron == true) && (CursorOnKoeff == false)) SetHighColor(255,255,255,255); // D
			
			a = (k+1)*square_size;
			b = (i+1)*square_size;
			DrawString(out.String(),BPoint(a,b), &delta);
			} // C
		} // B
	} // A
	else // A
	{
	 		//out.SetTo(extra::fStringOutOf(float_matrix[posy*matrix_dimension +posx],3).String());
	 		if (CursorOnKoeff == false)
	 		{
			bool optimizer;
			optimizer = ((showcursor == true) && (cursoron == true));
			
			SetHighColor(200,200,200,255);
			FillRect(BRect((posx+1)*square_size-10, posy*square_size+10, (posx+2)*square_size-10, (posy+1)*square_size+10));
			SetHighColor(255,50,127,255);
			DrawString(edit->String(),BPoint((posx+1)*square_size,(posy+1)*square_size), &delta);							
			if /* B */(optimizer == true) 
				{
				SetHighColor(255,255,255,255);
				DrawString("|", &delta);
				}// B
			}
	
	 } // A

Window()->Sync();
Window()->Unlock();
} 
コード例 #3
0
void MatrixControl::MouseDown( BPoint x )
{
if (IsFocus() == false) MakeFocus(true);

x.y += GetScrollY();
x.x += GetScrollX();

if (!DataEnterMode)
	{
	int32 i;
	BRect *rect;
	BMessage *nachricht;
		
	for (i=0; i<matrix_dimension; ++i)
		{
		rect = new BRect( (i+1)*square_size-10, 20 ,(i+1)*square_size -5 , square_size * matrix_dimension);
		
		if (rect->Contains(x)==true)
			{
			nachricht = new BMessage(CONST_dragcolumn);	
			
			nachricht->AddInt32("column",i);
			nachricht->AddPointer("matrix_control",this);
			
			DragMessage(nachricht,BRect( (i+1)*square_size-10, 20 ,(i+1)*square_size -5 , square_size * matrix_dimension),NULL);
			delete nachricht;
			//Drag around a data row
			return;
			}
	
		delete rect;
		
		rect = new BRect( 20, (i+1)*square_size+5, square_size * (matrix_dimension+1) ,(i+1)*square_size +10 );
		
		if (rect->Contains(x)==true)
			{
			nachricht = new BMessage(CONST_dragrow);	
			
			nachricht->AddInt32("row",i);
			nachricht->AddPointer("matrix_control",this);
			
			DragMessage(nachricht,BRect( 20, (i+1)*square_size+5, square_size * (matrix_dimension+1) ,(i+1)*square_size +10 ),NULL);
			delete nachricht;
			
			return;
			}
			
		delete rect;
		}
	}

if (DataEnterMode)
{
int half;
half = square_size / 2;
posx = int ((x.x  / square_size) - 1);
posy = int (((x.y + half) / square_size) - 1);


showcursor = true;
if ((posx < 0) || (posx >= matrix_dimension)) {MakeFocus(false);posx = 0;}
if ((posy < 0) || (posy >= matrix_dimension)) {MakeFocus(false);posy = 0;}

if (x.y < 40) 
	{
	CursorOnKoeff = true; 
	edit->SetTo(extra::fStringOutOf(Koeffizient,GLOBAL_ACCURACY).String());	
	}
else 
	{
	CursorOnKoeff = false;
	edit->SetTo(extra::fStringOutOf(float_matrix[posy*matrix_dimension +posx],GLOBAL_ACCURACY).String());
	}
} // If (DataEnterMode)


if (IsFocus() == true)
	{
	DrawfromPulse = false;
	Invalidate();
	}
	

}