Exemplo n.º 1
0
void Ca_Line::draw(){
  fl_color(color);
  fl_line_style(line_style,line_width);
  fl_begin_line();
  int i;
  if(data_2){
    for(i=0;i<n;i++)
      fl_vertex(x_axis_->position(data[i]),y_axis_->position(data_2[i]));
    fl_end_line();
    fl_line_style(0,0);
    for(i=0;i<n;i++){
      x=data[i];
      y=data_2[i];
      Ca_Point::draw();
    }
  }else{
    for(i=0;i<n;i++)
      fl_vertex(x_axis_->position(data[2*i]),y_axis_->position(data[2*i+1]));
    fl_end_line();
    for(i=0;i<n;i++){
      x=data[2*i];
      y=data[2*i+1];
      Ca_Point::draw();
    }
  }
  fl_line_style(0,0);

};
Exemplo n.º 2
0
void PolyObject::drawPolyLine(float polyOriginX, float polyOriginY, float pixelsPerCell, float cellsPerMeter) {
    fl_begin_loop();

    for(unsigned i = 0; i < points.size(); i++) {
        float pointOffsetX = SiteObject::worldToScreen(points[i].x, pixelsPerCell, cellsPerMeter);
        float pointOffsetY = SiteObject::worldToScreen(points[i].y, pixelsPerCell, cellsPerMeter);

        float pointX = polyOriginX + pointOffsetX;
        float pointY = polyOriginY - pointOffsetY;

        fl_vertex(pointX, pointY);
    }

    if(nextPoint) {
        float pointOffsetX = SiteObject::worldToScreen(nextPoint->x, pixelsPerCell, cellsPerMeter);
        float pointOffsetY = SiteObject::worldToScreen(nextPoint->y, pixelsPerCell, cellsPerMeter);

        float pointX = polyOriginX + pointOffsetX;
        float pointY = polyOriginY - pointOffsetY;

        fl_vertex(pointX, pointY);
    }

    fl_end_loop();


}
Exemplo n.º 3
0
void Ca_PolyLine::draw(){
  Ca_Point::draw();
  if(next) return;
  Ca_PolyLine * temp;
  int c=color;
  int style=line_style;
  int size=line_width;
  fl_color(c);
  fl_line_style(style,size);
  fl_begin_line();
  fl_vertex(x_axis_->position(x),y_axis_->position(y));
  temp=(Ca_PolyLine *)previous;
  while(temp){
    fl_vertex(temp->x_axis_->position(temp->x),temp->y_axis_->position(temp->y));
    if((temp->line_style != style)||(temp->color!=c)||(temp->line_width!=size)){
      fl_end_line();
      c=temp->color;
      style=temp->line_style;
      size=temp->line_width;
      fl_color(c);
      fl_line_style(style,size);
      fl_begin_line();
      fl_vertex(temp->x_axis_->position(x),temp->y_axis_->position(y));
    }
    temp=(Ca_PolyLine *)(temp->previous);
  }
  fl_end_line();
  fl_line_style(0,0);
};
Exemplo n.º 4
0
static inline void ca_rectf(double x, double y, double w, double h){
  fl_begin_polygon();
  fl_vertex(x,y);
  fl_vertex(x+w,y);
  fl_vertex(x+w,y+h);
  fl_vertex(x,y+h);
  fl_end_polygon();
};
Exemplo n.º 5
0
static inline void ca_rect(double x, double y, double w, double h){
  fl_begin_loop();
  fl_vertex(x,y);
  fl_vertex(x+w,y);
  fl_vertex(x+w,y+h);
  fl_vertex(x,y+h);
  fl_end_loop();
};
Exemplo n.º 6
0
void
SpectrumView::draw ( void ) 
{
    //Clear Widget
    Fl_Box::draw();

    int W = w() - padding_right;
    int H = h() - padding_bottom;

    if ( !_bands ) {
        analyze_data( W );
    }

    //Draw grid
    fl_color(fl_color_add_alpha(fl_rgb_color( 100,100,100), 50 ));

    draw_semilog();

    fl_push_clip( x(),y(),W,H);

            
    fl_color(fl_color_add_alpha( selection_color(), 20 ));
   
    fl_push_matrix();
    fl_translate( x(), y() + 2 );
    fl_scale( W,H- 2 );

    fl_begin_polygon();
    
    fl_vertex(0.0,1.0);

    draw_curve();

    fl_vertex(1.0,1.0);
                  
    fl_end_polygon();

    fl_color(fl_color_add_alpha( selection_color(), 100 ));
    fl_begin_line();
    fl_line_style(FL_SOLID,2);
    
    /* fl_vertex(0.0,1.0); */

    draw_curve();

    /* fl_vertex(1.0,1.0); */

    fl_end_line();
    
    fl_pop_matrix();

    fl_line_style(FL_SOLID,0);

    fl_pop_clip();
}
Exemplo n.º 7
0
void Fl_Diamond_Box::draw(int x, int y, int w, int h,
Fl_Color c, Fl_Flags f) const
{
    int x1 = x+w/2;
    if (w&1) w--; else {w -= 2; x++;}
    int y1 = y+h/2;
    if (h&1) h--; else {h -= 2; y++;}
    const char* s = (f & FL_VALUE) ? down->data() : data();
    char buf[26]; if (f&FL_INACTIVE && Fl_Style::draw_boxes_inactive)
    {
        fl_to_inactive(s, buf); s = buf;
    }
    const char* t;
    if (*s == '2')
    {
        t = s+1; s += 3;
    }
    else
    {
        t = s+2;
    }
    while (*s && *t && w > 0 && h > 0)
    {
        // draw upper-right line:
        fl_color(*s++ + (FL_GRAY_RAMP-'A'));
        fl_line(x+w, y1, x1, y);
        // draw upper-left line:
        fl_color(*s++ + (FL_GRAY_RAMP-'A'));
        fl_line(x1, y, x, y1);
        if (*s)
           s += 2;
        // draw lower-left line:
        fl_color(*t++ + (FL_GRAY_RAMP-'A'));
        fl_line(x, y1, x1, y+h);
        // draw lower-right line:
        fl_color(*t++ + (FL_GRAY_RAMP-'A'));
        fl_line(x1, y+h, x+w, y1);
        t += 2;
        x++; y++; w -= 2; h -= 2;
    }
    if (w > 0 && h > 0 && !(f & FL_INVISIBLE))
    {
        // draw the interior, assumming the edges are the same thickness
        // as the normal square box:
        fl_newpath();
        fl_vertex(x, y1);
        fl_vertex(x1, y);
        fl_vertex(x+w,y1);
        fl_vertex(x1,y+h);
        fl_color(c);
        fl_fill_stroke(c);
    }
}
Exemplo n.º 8
0
void Ca_LinePoint::draw(){
  Ca_Point::draw();
  if(previous){
    fl_color(color);
    fl_line_style(0,line_width);
    fl_begin_line();
    fl_vertex(previous->x_axis_->position(previous->x),previous->y_axis_->position(previous->y));
    fl_vertex(x_axis_->position(x),y_axis_->position(y));
    fl_end_line();
    fl_line_style(0,0);
  }

};
Exemplo n.º 9
0
void Drawing::draw() {
  draw_box();
  fl_push_matrix();
  fl_translate(w()/2, h()/2);
  fl_scale(w()/2, h()/2);
  fl_color(FL_BLACK);
  for (int i = 0; i < 20; i++) {
      for (int j = i+1; j < 20; j++) {
          fl_vertex(cosf(M_PI*i/10+.1), sinf(M_PI*i/10+.1));
          fl_vertex(cosf(M_PI*j/10+.1), sinf(M_PI*j/10+.1));
      fl_stroke();
    }
  }
  fl_pop_matrix();
}
Exemplo n.º 10
0
void Parallelogram::draw_lines() const
{
   /* if (fill_color().visibility()) {    // fill
        fl_color(fill_color().as_int());
        fl_paraf(point(0).tl,point(0).tr,point(0).bl,point(0).br);
        fl_color(color().as_int());    // reset color
    }

    if (color().visibility()) {    // lines on top of fill
        fl_color(color().as_int());
        fl_rect(point(0).tl,point(0).tr,point(0).bl,point(0).br);
    }
    */
        if (fill_color().visibility()) {
        fl_color(fill_color().as_int());
        fl_begin_complex_polygon();
        for(int i=0; i<number_of_points(); ++i){
            fl_vertex(point(i).x, point(i).y);
        }
        fl_end_complex_polygon();
        fl_color(color().as_int());    // reset color
    }
    if (color().visibility())
    Shape::draw_lines();
}
Exemplo n.º 11
0
void SoftBox::draw_lines() const
{

	if (fill_color().visibility()) {
		fl_color(fill_color().as_int());

		fl_begin_polygon();

			fl_vertex(point(0).x - (w/2) + r, point(0).y - (h/2));
			fl_vertex(point(0).x + (w/2) - r, point(0).y - (h/2));
			
			fl_vertex(point(0).x + (w/2), point(0).y - (h/2) + r);
			fl_vertex(point(0).x + (w/2), point(0).y + (h/2) - r);
			
			fl_vertex(point(0).x + (w/2) - r, point(0).y + (h/2));
			fl_vertex(point(0).x - (w/2) + r, point(0).y + (h/2));
			
			fl_vertex(point(0).x - (w/2),     point(0).y + (h/2) - r);
			fl_vertex(point(0).x - (w/2),     point(0).y - (h/2) + r);
					
		fl_end_polygon();

		fl_pie(point(0).x - (w/2),         point(0).y - (h/2),         r+r-1,r+r-1,90,180);
		fl_pie(point(0).x + (w/2) - r - r, point(0).y - (h/2),         r+r-1,r+r-1,0,90);
		fl_pie(point(0).x - (w/2),         point(0).y + (h/2) - r - r, r+r-1,r+r-1,180,270);
		fl_pie(point(0).x + (w/2) - r - r, point(0).y + (h/2) - r - r, r+r-1,r+r-1,270,360);

		fl_color(color().as_int());

	}

	if (color().visibility()){

		fl_color(color().as_int());

		// Draw Lines
		fl_line(point(0).x - (w/2) + r, point(0).y - (h/2),     point(0).x + (w/2) - r, point(0).y - (h/2));
		fl_line(point(0).x - (w/2),     point(0).y - (h/2) + r, point(0).x - (w/2),     point(0).y + (h/2) - r);
		fl_line(point(0).x - (w/2) + r, point(0).y + (h/2),     point(0).x + (w/2) - r, point(0).y + (h/2));
		fl_line(point(0).x + (w/2),     point(0).y - (h/2) + r, point(0).x + (w/2),     point(0).y + (h/2) - r);
		
		// Draw Arcs
		fl_arc(point(0).x - (w/2),         point(0).y - (h/2),         r+r,r+r,90,180);
		fl_arc(point(0).x + (w/2) - r - r, point(0).y - (h/2),         r+r,r+r,0,90);
		fl_arc(point(0).x - (w/2),         point(0).y + (h/2) - r - r, r+r,r+r,180,270);
		fl_arc(point(0).x + (w/2) - r - r, point(0).y + (h/2) - r - r, r+r,r+r,270,360);

	}

}
Exemplo n.º 12
0
void Regular_polygon::draw_lines() const
{

	if (fill_color().visibility()) {
		fl_color(fill_color().as_int());

		fl_begin_polygon();

		for (int i = 1; i < s + 1; i++){
			fl_vertex((int)std::round(point(0).x + w * (cos(2.0*PI*(double)i/(double)s + ar))),
				(int)std::round(point(0).y + w * (sin(2.0*PI*(double)i/(double)s + ar))));

		}

		fl_vertex((int)std::round(point(0).x + w * (cos(2.0*PI*1/(double)s + ar))),
			(int)std::round(point(0).y + w * (sin(2.0*PI*1/(double)s + ar))));

		fl_end_polygon();

		fl_color(color().as_int());

	}

	if (color().visibility()){

		fl_color(color().as_int());

		for (int i = 1; i < s + 1; i++){
			fl_line((int)std::round(point(0).x + w * (cos(2.0*PI*(double)i/(double)s + ar))),
				(int)std::round(point(0).y + w * (sin(2.0*PI*(double)i/(double)s + ar))),
				(int)std::round(point(0).x + w * (cos(2.0*PI*(double)(i+1)/(double)s + ar))),
				(int)std::round(point(0).y + w * (sin(2.0*PI*(double)(i+1)/(double)s + ar))));


		}

	}
}
Exemplo n.º 13
0
void
SpectrumView::draw_curve ( void )
{
    if ( !_bands )
        return;

    int W = w() - padding_right;

    //Build lines
    float inc = 1.0f / (float)W;

    float fx = 0;
    for(  int i = 0; i < W; i++, fx += inc )
        fl_vertex(fx, 1.0f - _bands[i]);
}
Exemplo n.º 14
0
void Open_polyline::draw_lines() const
{
    if (fill_color().visibility()) {
        fl_color(fill_color().as_int());
        fl_begin_complex_polygon();
        for(int i=0; i<number_of_points(); ++i){
            fl_vertex(point(i).x, point(i).y);
        }
        fl_end_complex_polygon();
        fl_color(color().as_int());    // reset color
    }
    
    if (color().visibility())
        Shape::draw_lines();
}
Exemplo n.º 15
0
void Regular_hexagon::draw_lines() const
{

	if (fill_color().visibility()) {
		fl_color(fill_color().as_int());

		fl_begin_polygon();

			fl_vertex(point(0).x - w, 		point(0).y);
			fl_vertex(point(0).x - (w/2), 	point(0).y - y_off);
			
			fl_vertex(point(0).x + (w/2), 	point(0).y - y_off);
			fl_vertex(point(0).x + w, 		point(0).y);
			
			fl_vertex(point(0).x + (w/2), 	point(0).y + y_off);
			fl_vertex(point(0).x - (w/2), 	point(0).y + y_off);
			fl_vertex(point(0).x - w, 		point(0).y);

		fl_end_polygon();

		fl_color(color().as_int());

	}

	if (color().visibility()){

		fl_color(color().as_int());

		// Draw Lines
		fl_line(point(0).x - w, 		point(0).y,     		point(0).x - (w/2), 	point(0).y - y_off);
		fl_line(point(0).x - (w/2), 	point(0).y - y_off,     point(0).x + (w/2), 	point(0).y - y_off);
		fl_line(point(0).x + (w/2), 	point(0).y - y_off,		point(0).x + w, 		point(0).y);

		fl_line(point(0).x + w, 		point(0).y,     		point(0).x + (w/2), 	point(0).y + y_off);
		fl_line(point(0).x + (w/2), 	point(0).y + y_off,     point(0).x - (w/2), 	point(0).y + y_off);
		fl_line(point(0).x - (w/2), 	point(0).y + y_off,		point(0).x - w, 		point(0).y);

	}
}
Exemplo n.º 16
0
static inline void ca_loop(double x1, double y1, double x2, double y2, double x3, double y3){
  fl_begin_loop();
  fl_vertex(x1,y1); fl_vertex(x2,y2); fl_vertex(x3,y3);
  fl_end_loop();
};
Exemplo n.º 17
0
void custom_graphics(ValueType vt, float val,int W,int H)
{
    int x0,y0,i;
    int _w, _h;
    float x,y,p;
    custom_graph_dimensions(vt, _w, _h);
    x0 = W / 2 - (_w / 2);
    y0 = H;

    switch(vt)
    {
    case VC_FilterVelocitySense:
    {
        p = powf(8.0f,(64.0f-(int)val)/64.0f);

        /* Grid */
        grid(x0,y0,_w,_h, 4);
        /*Function curve*/
        fl_color(FL_BLUE);
        if ((int)val == 127)
        {   // in this case velF will always return 1.0
            y = y0 - _h;
            fl_line(x0, y, x0 + _w, y);
        }
        else
        {
            fl_begin_line();
            for(i = 0; i < _w; i++)
            {
                x = (float)i / (float)_w;
                y = powf(x,p) * _h;
                fl_vertex((float)x0 + i, (float)y0 - y);
            }
            fl_end_line();
        }
        break;
    }
    case VC_FormFilterClearness:
    {
        p = powf(10.0f, (val - 32.0f) / 48.0f); //clearness param
        grid(x0,y0,_w,_h,10);
        fl_color(FL_BLUE);
        fl_begin_line();
        x = 0;
        float frac = 1.0f / (float)_w;
        for(i = 0; i < _w; i++)
        {
            y = (atanf((x * 2.0f - 1.0f) * p) / atanf(p) + 1.0f) * 0.5f * _h;
            fl_vertex((float)x0 + i, (float)y0 - y);
            x += frac;
        }
        fl_end_line();
        break;
    }
    case VC_SubBandwidthScale:
    {
        /* The scale centers around the factor 1 vertically
           and is logarithmic in both dimensions. */

        int margin = 28;
        _h -= margin;
        _w -= margin * 2;
        x0 += margin * 1.25;
        y0 -= margin * 0.75;

        float cy = y0 - _h / 2;

        int j = 1;
        const float lg1020 = log10(20); /* Lower bound = 20hz*/
        const float rx = _w / (log10(20000) - lg1020); /* log. width ratio */
        const float ry = (_h / 2) / log10(100000);

        string hzMarkers[] = {"20", "100", "1k", "10k"};
        string xMarkers[] = {"x10","x100","x1k","x10k","10%","1%","0.1%","0.01%"};

        /* Scale lines */

        fl_font(fl_font(),8);
        fl_line_style(0);
        for(i = 0; i < 4; i++) /* 10x / 10%, 100x / 1% ... */
        {
            y = ry * (i + 1);
            fl_color(169,169,169);
            fl_line(x0, cy - y, x0 + _w, cy - y);
            fl_line(x0, cy + y, x0 + _w, cy + y);
            fl_color(0,0,0);
            fl_draw(xMarkers[i].c_str(), x0 - 28, (cy - y - 4), 24, 12,
                    Fl_Align(FL_ALIGN_RIGHT));
            fl_draw(xMarkers[i + 4].c_str(), x0 - 28, (cy + y - 4), 24, 12,
                    Fl_Align(FL_ALIGN_RIGHT));
        }

        /* Hz lines */

        fl_color(196,196,196); /* Lighter inner lines*/

        for(i = 10;i != 0; i *= 10)
        {
            for(j = 2; j < 10; j++)
            {
                x = x0 + rx * (log10(i * j) - lg1020) + 1;
                fl_line(x, y0, x, y0 - _h);
                if(i * j >= 20000)
                {
                    i = 0;
                    break;
                }
            }
        }

        fl_font(fl_font(),10);
        for(i = 0; i < 4; i++) /* 20, 100, 1k, 10k */
        {
            x = x0 + (i == 0 ?  0 : ((float)i + 1 - lg1020) * rx);
            fl_color(127,127,127); /* Darker boundary lines */
            fl_line(x, y0, x, y0 - _h);
            fl_color(FL_BLACK);
            fl_draw(hzMarkers[i].c_str(), x - 20, y0 + 4, 40, 12,
                    Fl_Align(FL_ALIGN_CENTER));
        }
        /* Unit marker at the lower right of the graph */
        fl_draw("Hz", x0 + _w, y0 + 4, 20, 12, Fl_Align(FL_ALIGN_LEFT));

        /* Vertical center line */
        fl_color(64,64,64);
        fl_line(x0 - margin, cy, x0 + _w, cy);

        /* Function curve */
        fl_color(FL_BLUE);
        if((int)val == 0)
        {
            fl_line(x0, cy, x0 + _w, cy);
        }
        else
        {
            const float p = ((int)val / 64.0f) * 3.0;

            /* Cairo not necessary, but makes it easier to read the graph */
            cairo_t *cr;
            cairo_surface_t* Xsurface = cairo_xlib_surface_create
                (fl_display, fl_window, fl_visual->visual,
                 Fl_Window::current()->w(), Fl_Window::current()->h());
            cr = cairo_create (Xsurface);

            cairo_set_source_rgb(cr, 1, 0, 0);
            cairo_set_line_width(cr, 1.5);
            cairo_move_to(cr, x0, cy - ry * log10(powf(50, p)));
            cairo_line_to(cr, x0 + _w, cy - ry * log10(powf(0.05, p)));
            cairo_stroke(cr);

            cairo_surface_destroy(Xsurface);  cairo_destroy(cr);
        }
        break;
    }
    default:
        break;
    }
}
Exemplo n.º 18
0
void DesktopIcon::draw(void) { 
	// draw_box(FL_UP_BOX, FL_BLACK);

	if(image() && (damage() & FL_DAMAGE_ALL)) {
		Fl_Image* im = image();

		/* center image in the box */
		int ix = (w()/2) - (im->w()/2);
		int iy = (h()/2) - (im->h()/2);
		ix += x();
		iy += y();

		/* darker_img is always present if image() is present */
		if(is_focused())
			darker_img->draw(ix, iy);
		else
			im->draw(ix, iy);

		E_DEBUG(E_STRLOC ": DesktopIcon icon redraw\n");
	}

	if(gsettings->label_draw && (damage() & (FL_DAMAGE_ALL | EDAMAGE_CHILD_LABEL))) {
		int X = x() + w()-(w()/2)-(lwidth/2);
		int Y = y() + h() + LABEL_OFFSET;

		Fl_Color old = fl_color();

		if(!gsettings->label_transparent) {
			fl_color(gsettings->label_background);
			fl_rectf(X, Y, lwidth, lheight);
		}

		int old_font = fl_font();
		int old_font_sz = fl_size();

		/* draw with icon's font */
		fl_font(labelfont(), labelsize());

		/* pseudo-shadow */
		fl_color(FL_BLACK);
		fl_draw(label(), X+1, Y+1, lwidth, lheight, align(), 0, 0);

		fl_color(gsettings->label_foreground);
		fl_draw(label(), X, Y, lwidth, lheight, align(), 0, 0);

		/* restore old font */
		fl_font(old_font, old_font_sz);

		if(is_focused()) {
			/* draw focused box on our way so later this can be used to draw customised boxes */
			fl_color(gsettings->label_foreground);
			fl_line_style(FL_DOT);

			fl_push_matrix();
			fl_begin_loop();
				fl_vertex(X, Y);
				fl_vertex(X + lwidth, Y);
				fl_vertex(X + lwidth, Y + lheight);
				fl_vertex(X, Y + lheight);
				fl_vertex(X, Y);
			fl_end_loop();
			fl_pop_matrix();

			/* revert to default line style */
			fl_line_style(0);
		}

		/* revert to old color whatever that be */
		fl_color(old);
		E_DEBUG(E_STRLOC ": DesktopIcon label redraw\n");
	}
}
Exemplo n.º 19
0
void Fl_Dial::draw()
{
    int X = 0; int Y = 0; int W = w(); int H = h();
    if (!(type() == FILL && box() == FL_OVAL_BOX))
    {
        if (damage()&FL_DAMAGE_ALL) draw_box();
        box()->inset(X,Y,W,H);
    }
    Fl_Color fillcolor = selection_color();
    Fl_Color linecolor = highlight_color();
    if (!active_r())
    {
        fillcolor = fl_inactive(fillcolor);
        linecolor = fl_inactive(linecolor);
    }
    double angle = (a2-a1)*(value()-minimum())/(maximum()-minimum()) + a1;
    if (type() == FILL)
    {
        if (damage()&FL_DAMAGE_EXPOSE && box() == FL_OVAL_BOX)
        {
            fl_push_clip(0, 0, w(), h());
            parent()->draw_group_box();
            fl_pop_clip();
        }
        fl_color(color());
        fl_pie(X, Y, W-1, H-1, 270-a1, angle > a1 ? 360+270-angle : 270-360-angle);
        fl_color(fillcolor);
        fl_pie(X, Y, W-1, H-1, 270-angle, 270-a1);
        if (box() == FL_OVAL_BOX)
        {
            fl_ellipse(X, Y, W-1, H-1);
            fl_color(linecolor); fl_stroke();
        }
    }
    else
    {
        if (!(damage()&FL_DAMAGE_ALL))
        {
            fl_ellipse(X+1, Y+1, W-2, H-2);
            fl_color(color()); fl_fill();
        }
        fl_push_matrix();
        fl_translate(X+W/2-.5, Y+H/2-.5);
        fl_scale(W-1, H-1);
        fl_rotate(45-angle);
        if (type() == LINE)
        {
            fl_vertex(0.0,   0.0);
            fl_vertex(-0.04, 0.0);
            fl_vertex(-0.25, 0.25);
            fl_vertex(0.0,   0.04);
        }
        else
        {
            fl_circle(-0.20, 0.20, 0.07);
        }
        fl_color(fillcolor); fl_fill_stroke(linecolor);
        fl_pop_matrix();
    }
    if (focused())
    {
        fl_ellipse(X+2, Y+2, W-5, H-5);
        fl_color(linecolor);
        fl_line_style(FL_DASH);
        fl_stroke();
        fl_line_style(0);
    }
}
Exemplo n.º 20
0
void WidgetPDial::draw()
{
#ifdef NTK_GUI
    box( FL_NO_BOX );

    Fl_Dial::draw();
    
    return;
#else
    const int cx = x(), cy = y(), sx = w(), sy = h();
    const double a1 = angle1(), a2 = angle2();
    const double val = (value() - minimum()) / (maximum() - minimum());
    // even radius produces less artifacts if no antialiasing is avail
    const int rad = (sx > sy ? sy : sx) &~1;

    /* clears the button background */
    pdialcolor(160, 160, 160);
    fl_pie(cx - 2, cy - 2, rad + 4, rad + 4, 0, 360);

    /* dark outline */
    fl_color(60, 60, 60);
    fl_pie(cx - 1, cy - 1, rad + 2, rad + 2, 0, 360);

    /* Draws the button faceplate, min/max */
    pdialcolor(110, 110, 115);
    fl_pie(cx, cy, rad, rad, 270 - a2, 270 - a1);

    /* knob center */
    if (rad > 8) {
        pdialcolor(140, 140, 145);
        fl_pie(cx + 4, cy + 4, rad - 8, rad - 8, 0, 360);
    }

    /* value circle */
    double a = -(a2 - a1) * val - a1;
    fl_line_style(0, 2, 0);
    pdialcolor(0, 200, 0);
    fl_arc(cx + 1, cy + 1, rad - 2, rad - 2, a - 90, a1 - 180);
    fl_line_style(0);

    /* draw value line */
    int ll = rad/4;
    if (ll < 2) ll = 2;

    fl_push_matrix();

    fl_translate(cx + rad / 2, cy + rad / 2);
    fl_rotate(a - 90.0f);

    fl_translate(rad / 2, 0);

    fl_begin_polygon();
    pdialcolor(0, 0, 0);
    fl_vertex(-ll, 0);
    fl_vertex(0, 0);
    fl_end_polygon();

    fl_pop_matrix();

#endif
}
Exemplo n.º 21
0
 FL_EXPORT_C(void,flc_vertex)(double x,double y){
   fl_vertex(x,y);
 }
Exemplo n.º 22
0
// Draw the block window...
void BlockWindow::draw() {
	int		j, k, xx, yy;
	Block		*b;
	Column	*c;

	// Draw the blocks...
	fl_color(FL_BLACK);
	fl_rectf(0, 0, w(), h());

	// Draw the blocks...
	for (j = num_columns_, c = columns_; j > 0; j --, c ++)
		for (k = c->num_blocks, b = c->blocks; k > 0; k --, b ++) {
			xx = w() - c->x;
			yy = h() - BLOCK_SIZE - b->y;

			if (b->color >= BLOCK_BLAST) {
				b->color ++;
				blast_pixmap.draw(xx, yy);
			} else if (b->color < 0) {
				if (b->bomb) bomb_pixmaps[-b->color - 1]->draw(xx, yy);
				else normal_pixmaps[-b->color - 1]->draw(xx, yy);
			} else {
				if (b->bomb) bomb_pixmaps[b->color - 1]->draw(xx, yy);
				else normal_pixmaps[b->color - 1]->draw(xx, yy);
			}
		}

	if (interval_ < 0.0 || paused_) {
		fl_color(FL_BLACK);
		screen_tile.draw(0, 0, w(), h(), 0, 0);
	}

	// Redraw the widgets...
	play_button_->redraw();
	help_button_->redraw();
	draw_children();

	// Draw any paused/game over/new game message...
	if ((paused_ || interval_ < 0.0) && play_button_->w() == 80) {
		const char *s;

		if (help_) {
			s = "Click on adjacent blocks of the same color. Clear all blocks "
				"before they reach the left side.";

			fl_font(FL_HELVETICA_BOLD, 24);
			fl_color(FL_BLACK);
			fl_draw(s, 171, 3, w() - 250, h() - 6,
					(Fl_Align)(FL_ALIGN_WRAP | FL_ALIGN_LEFT));

			fl_color(FL_YELLOW);
			fl_draw(s, 168, 0, w() - 250, h(),
					(Fl_Align)(FL_ALIGN_WRAP | FL_ALIGN_LEFT));
		} else {
			if (interval_ < 0.0) {
#ifdef DEBUG
				// Show sample waveform...
				short *sample_ptr;

				for (i = 0; i < 2; i ++)
				{
					fl_color(FL_RED + i);
					fl_begin_line();
					for (j = 0, sample_ptr = sound_->sample_data + i;
							j < sound_->sample_size;
							j ++, sample_ptr += 2)
						fl_vertex(j * w() / sound_->sample_size,
								*sample_ptr * h() / 4 / 65534 + h() / 2);
					fl_end_line();
				}
#endif // DEBUG

				if (num_columns_ && (time(NULL) & 7) < 4) s = "Game Over";
				else s = "Block Attack!\nby Michael R Sweet";
			} else s = "Paused";

			fl_font(FL_HELVETICA_BOLD, 32);
			fl_color(FL_BLACK);
			fl_draw(s, 6, 6, w() - 6, h() - 6, FL_ALIGN_CENTER);

			fl_color(FL_YELLOW);
			fl_draw(s, 0, 0, w(), h(), FL_ALIGN_CENTER);
		}
	}

	// Draw the scores and level...
	char s[255];

	sprintf(s, " Score: %d", score_);
	fl_color(FL_WHITE);
	fl_font(FL_HELVETICA, 14);
	fl_draw(s, 40, 0, w() - 40, 20, FL_ALIGN_LEFT);

	sprintf(s, "High Score: %d ", high_score_);
	fl_draw(s, 0, 0, w(), 20, FL_ALIGN_RIGHT);

	if (level_ > 1 || title_y_ <= 0)
	{
		sprintf(s, "Level: %d ", level_);
		fl_draw(s, 0, 0, w(), 20, FL_ALIGN_CENTER);
	}

	if (title_y_ > 0 && interval_ > 0.0)
	{
		int sz = 14 + title_y_ * 86 / h();

		fl_font(FL_HELVETICA_BOLD, sz);
		fl_color(FL_YELLOW);
		fl_draw(title_, 0, title_y_, w(), sz, FL_ALIGN_CENTER);
	}
}
Exemplo n.º 23
0
void Ca_Y_Axis::draw_grid(){
  if(!valid_)return;
  if(max_==min_)return;
  int tick_index=-1;
  double tick_value;
  int tick_order;
  double _interval=0;
  int l1,l2;

  int BD = 0;
  Fl_Widget * W_ = this;
  if(canvas_){
    BD = canvas_->border();
    W_ = canvas_;
  }else if(widget_){
    W_ = widget_;
  }
  l1=W_->x()+Fl::box_dx(W_->box());
  l2=W_->x()+W_->w()+Fl::box_dx(W_->box())-Fl::box_dw(W_->box());
  int tcl;
  if(!(tcl=tick_length_))
    tcl=label_font_size_;
  while(next_tick(tick_index, tick_value, tick_order,_interval)){
    double _pos=position(tick_value);
    if(scale_&CA_REV){
      if(_pos<min_pos_-BD) continue;
      if(_pos>max_pos_+BD) break;
    }else{
      if(_pos<max_pos_-BD) break;
      if(_pos>min_pos_+BD) continue;
    }
    int grt;
    if((grt=grid_visible_&CA_LABEL_GRID) && !(tick_index % label_step_)){
      fl_color(label_grid_color_);
      fl_line_style(label_grid_style_,label_grid_width_);
      if(grt==CA_LABEL_GRID){
        fl_begin_loop();
        fl_vertex(l1,_pos);
        fl_vertex(l2,_pos);
        fl_end_loop();

      }else{
        if(grt&CA_LEFT_LABEL_TICK){
          fl_begin_loop();
          fl_vertex(l1,_pos);
          fl_vertex(l1+tcl,_pos);
          fl_end_loop();
        }
        if(grt&CA_RIGHT_LABEL_TICK){
          fl_begin_loop();
          fl_vertex(l2-tcl,_pos);
          fl_vertex(l2,_pos);
          fl_end_loop();
        }
      }
    }else if((grt=grid_visible_&CA_MAJOR_GRID) && !(tick_index % major_step_)){
      fl_color(major_grid_color_);
      fl_line_style(major_grid_style_,major_grid_width_);
      if(grt==CA_MAJOR_GRID){
        fl_begin_loop();
        fl_vertex(l1,_pos);
        fl_vertex(l2,_pos);
        fl_end_loop();

      }else{
        if(grt&CA_LEFT_MAJOR_TICK){
          fl_begin_loop();
          fl_vertex(l1,_pos);
          fl_vertex(l1+tcl,_pos);
          fl_end_loop();
        }
        if(grt&CA_RIGHT_MAJOR_TICK){
          fl_begin_loop();
          fl_vertex(l2-tcl,_pos);
          fl_vertex(l2,_pos);
          fl_end_loop();
        }
      }
    }else if((grt=(grid_visible_&CA_MINOR_GRID))){
      fl_color(minor_grid_color_);
      fl_line_style(minor_grid_style_,minor_grid_width_);
      if(grt==CA_MINOR_GRID){
        fl_begin_loop();
        fl_vertex(l1,_pos);
        fl_vertex(l2,_pos);
        fl_end_loop();

      }else{
        if(grt&CA_LEFT_MINOR_TICK){
          fl_begin_loop();
          fl_vertex(l1,_pos);
          fl_vertex(l1+tcl/2,_pos);
          fl_end_loop();
        }
        if(grt&CA_RIGHT_MINOR_TICK){
          fl_begin_loop();
          fl_vertex(l2-tcl/2,_pos);
          fl_vertex(l2,_pos);
          fl_end_loop();
        }
      }
    }
  }

  fl_line_style(0,0);
  fl_color(FL_BLACK);
};
Exemplo n.º 24
0
static inline void ca_polygon(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){
  fl_begin_polygon();
  fl_vertex(x1,y1); fl_vertex(x2,y2); fl_vertex(x3,y3); fl_vertex(x4,y4);
  fl_end_polygon();
};
Exemplo n.º 25
0
void Ca_Y_Axis::draw(){
  if(min_==max_) return;
  int BD = 0;
  Fl_Widget * W_ = this;
  if(canvas_){
    BD = canvas_->border();
    W_ = canvas_;
  }else if(widget_){
    W_ = widget_;
  }
  int tick_index=-1;
  double tick_value;
  int tick_order;//,tick_number;
  double _interval=0;
  const char * label_format=label_format_;
  //    if(damage()|FL_DAMAGE_ALL)
  //        draw_label();
  if (damage()&(FL_DAMAGE_ALL|CA_DAMAGE_ALL)){
    update();
    if (box()==FL_NO_BOX){
      fl_color(parent()->color());
      fl_rectf(x(),y(),w(),h());
    }else
      draw_box();
    if(!valid_) return;
    fl_font(label_font_face_,label_font_size_);
    int l1=0; int l2=0; int m1=0; int m2=0; int l=0; int _x=0; int _w,_h; //temporary coordinates for ticks
    double _pos,_y;
    //fl_clip(x()+Fl::box_dx(box()),y()+Fl::box_dy(box()),w()-Fl::box_dw(box()),h()-Fl::box_dh(box()));
    fl_color(axis_color_);
    int a=x()+Fl::box_dx(box())+border_;
    int b=a+w()-Fl::box_dw(box())-2*border_;
    switch(axis_align_ & CA_ALIGNMENT){
            case CA_RIGHT:
              l=l1=m1=a;
              if(axis_align_&CA_NO_TICS)
                m2=m1;
              else
                if (tick_length_)
                  m2=m1+tick_length_;
                else
                  m2=m1+label_font_size_;
              l2=(l1+m2)/2;
              break;
            case CA_LEFT:
              l=l2=m2=b-1;
              if(axis_align_&CA_NO_TICS)
                m1=m2;
              else
                if (tick_length_)
                  m1=m2-tick_length_;
                else
                  m1=m2-label_font_size_;
              l1=(m1+m2)/2;
              break;
            case CA_CENTER:
              m1=a;
              m2=b;
              l=(a+b)/2;
              l1=(a+l)/2;
              l2=(l+b)/2;
              break;
    }
    fl_line_style(FL_SOLID|FL_CAP_FLAT,tick_width_);
    //		double minp,maxp;
    double start_tick;
    double end_tick;
    bool tick_not_started = 1;


    while(next_tick(tick_index, tick_value, tick_order, _interval)){
      _pos=position(tick_value);
      if(scale_&CA_REV){
        if((_pos+1)<min_pos_-BD) continue;
        if((_pos-1)>max_pos_+BD) break;
      }else{
        if((_pos+1)<max_pos_-BD) break;
        if((_pos-1)>min_pos_+BD) continue;
      }
      if(!(axis_align_&CA_NO_TICS)){
        fl_begin_loop();
        if(tick_index % major_step_){
          fl_vertex(l1,_pos);
          fl_vertex(l2,_pos);
        }else{
          fl_vertex(m1,_pos);
          fl_vertex(m2,_pos);
        }
        fl_end_loop();
        if(tick_not_started){
          tick_not_started = 0;
          start_tick = _pos;
        }
        end_tick = _pos;
      }
      if(!((tick_index % label_step_)|(axis_align_&CA_NO_LABELS))){
        char label[MAX_LABEL_LENGTH];
        char _label_format[MAX_LABEL_FORMAT];
        if(!label_format){
          int _tick_order;
          if (tick_order>=0)
            _tick_order=0;
          else
            _tick_order=-tick_order - 1;
          sprintf(_label_format,"%s.%if","%",_tick_order);
        }
        else
          strcpy(_label_format,label_format);
        sprintf(label, _label_format,tick_value);
        fl_measure(label,_w,_h);
        _y=_pos+_h/3;
        switch (axis_align_ & CA_ALIGNMENT){
                    case CA_LEFT:
                      _x=m1-_h/3-_w;
                      break;
                    case CA_RIGHT:
                      _x=m2+_h/3;
                      break;
                    case CA_CENTER:
                      _x=(m1+m2)/2-_w/2;
                      Fl_Color _color=fl_color();
                      fl_color(color());
                      ca_rectf(_x-_h/6,_pos-_h/2,_w+_h/3,_h);
                      fl_color(_color);
                      break;
        }
        ca_text(label,_x,_y);
      }
    }
    if((axis_align_ & CA_LINE) && !tick_not_started){
      fl_begin_line();
      fl_vertex(l,start_tick);
      fl_vertex(l,end_tick);
      //fl_vertex(l,W_->y()+Fl::box_dy(W_->box()));
      //fl_vertex(l,W_->y()+W_->h()+Fl::box_dy(W_->box())-Fl::box_dh(W_->box()));

      fl_end_line();
    }
    fl_line_style(0);
    //fl_pop_clip();
  }
};
Exemplo n.º 26
0
void Fl_Gauge::draw(void)
{
    int X = x();
    int Y = y();
    int W = w();
    int H = h();

    draw_box();

    X += Fl::box_dx(box());
    Y += Fl::box_dy(box());
    W -= Fl::box_dw(box());
    H -= Fl::box_dh(box());

    double frac = (value() - minimum()) / (maximum() - minimum());
    double angle = (angle2() - angle1()) * frac +  angle1();

    float cx = X + W/2.0f;
    float cy = Y + H/2.0f;

    float d = (float)((W < H)? W : H);

    double num_major_ticks = (maximum() - minimum()) / major_step_size;
    double num_minor_ticks = (maximum() - minimum()) / minor_step_size;

    double minor_angle = (angle2() - angle1()) / num_minor_ticks;
    double major_angle = (angle2() - angle1()) / num_major_ticks;
    int i;

    fl_color(FL_WHITE);
    fl_line_style(FL_SOLID, 1);

/* minor ticks */
    fl_push_matrix();
    fl_color(FL_WHITE);
    fl_translate(cx, cy);
    fl_scale(d, d);
    fl_rotate(-angle1());
    for (i = 0; i <= num_minor_ticks; i++) {
        fl_begin_line();
        fl_vertex(0, 0.40);
        fl_vertex(0, 0.45);
        fl_end_line();
        fl_rotate(-minor_angle);
    }
    fl_pop_matrix();

/* major ticks */
    fl_push_matrix();
    fl_color(FL_WHITE);
    fl_line_style(FL_SOLID, 3);
    fl_translate(cx, cy);
    fl_scale(d, d);
    fl_rotate(-angle1());
    for (i = 0; i <= num_major_ticks; i++) {
        fl_begin_line();
        fl_vertex(0, 0.40);
        fl_vertex(0, 0.47);
        fl_end_line();
        fl_rotate(-major_angle);
    }
    fl_pop_matrix();

/* tick labels */
    char buf[128];
    fl_color(FL_WHITE);
    for (i = 0; i <= num_major_ticks; i++) {
        snprintf(buf, sizeof(buf), "%.0lf", minimum() + i * major_step_size);
        double angle = 360.0 + -angle1() - 90 - i * major_angle;
        double rad = angle * M_PI/180.0;
        int width = 0;
        int height = 0;
        fl_measure(buf, width, height);
        if (width < 1) {
            width = 9;
        }
        if (height < 1) {
            height = 16;
        }
        double radius = d / 3;
        double x = cx + radius * cos(rad);
        double y = cy - radius * sin(rad);
        if (rad < M_PI/2.0 || rad > 3 * M_PI/2.0) {
            x = cx + (radius - width/2.0) * cos(rad);
        }
        x -= width/2.0;
        fl_draw(buf, x, y + height/2.0);
    }

    fl_push_matrix();
    fl_translate(cx, cy);
    fl_scale(d, d);

    fl_color(FL_WHITE);

    fl_rotate(-angle);

/* arrow */
    fl_begin_polygon();
    fl_vertex(-0.02, 0.03);
    fl_vertex(-0.02, 0.35);
    fl_vertex( 0.00, 0.37);
    fl_vertex( 0.02, 0.35);
    fl_vertex( 0.02, 0.03);
    fl_end_polygon();

/* border */
    fl_begin_loop();
    fl_circle(0.0, 0.0, 0.48);
    fl_end_loop();

    fl_pop_matrix();

    fl_color(FL_GRAY);
    fl_pie(cx - d * 0.05, cy - d * 0.05, d * 0.1, d * 0.1, 0, 360.0);
    fl_color(FL_BLACK);
    fl_pie(cx - d * 0.025, cy - d * 0.025, d * 0.05, d * 0.05, 0, 360.0);

    draw_label();
}