示例#1
0
void Gate::draw_lines() const{
    if(t == Operand::NONE) return;
    
    Point ul(GATE_PADDING_SIDE + 2*SCALE*(p-4) - .4*SCALE,
             GATE_PADDING_TOP+SCALE*(p-4) -0.3*SCALE);
    
    fl_color(color().as_int());
    
    //Draw gate symbol
    if(t==Operand::AND){
        draw_AND_gate(ul);
    } else if (t==Operand::OR){
        draw_OR_gate(ul);
    } else if (t==Operand::NOT){
        draw_NOT_gate(ul);
    }
    
    //Draw lines to input lines
    int iny1 = GATE_PADDING_TOP + SCALE*((i1->p)-3) - .5*SCALE;
    int iny2 = 0;
    if(i2) iny2 = GATE_PADDING_TOP + SCALE*((i2->p)-3) - .5*SCALE;
    if(t == Operand::NOT){
        draw_one_line(ul, iny1);
    } else {
        draw_two_lines(ul, iny1, iny2);
    }
    fl_line(ul.x+(.8*SCALE)/2,ul.y+(.6*SCALE),ul.x+(.8*SCALE)/2,GATE_PADDING_TOP+SCALE/2+SCALE*(p-4));

}
示例#2
0
/********************************************************************
 Comment on RoundRect & TextMid!!!!
	RoundRect Uses width / height as 2nd and 3rd parameters.
	Text characters come out the color of the Fill, not stroke!!
*********************************************************************/
int MarqueeView::draw()
{	
	Control::draw();

	Stroke_l( border_color );		// box color
	StrokeWidth(4);

	Fill_l(background_color);		// 
	Rect( left, bottom, +width, +height );
	if (text==NULL) return 1;

	Fill_l(text_color);				// 
	int line_height = 1.25*text_size;
	int vertical    = height-line_height;
	char* ptr = text;

	if (style & CENTER_VERTICAL)
	{
		vertical = vertical / 2.0;	
	}
	
	do {
		ptr = draw_one_line( ptr, vertical );
		vertical -= line_height;
		if (vertical < 0)
			break;
	} while ( ptr ); 
	return 1;
}