Exemplo n.º 1
0
void DiagramWindow::DrawBase(
    const unsigned int index,
    const RNAStructure::Base base,
    const float centerX,
    const float centerY,
    const float angleBase,
    const float angleDelta,
    const float radius)
{
    float angle1 = angleBase - (float)index * angleDelta;
    float xPosn1 = centerX + cos(angle1) * radius;
    float yPosn1 = centerY - sin(angle1) * radius - fl_descent() + 0.5 * fl_height();

    fl_color(128, 128, 128);
    switch (base)
    {
	case RNAStructure::A:
	    fl_draw("A", xPosn1 - fl_width('A') * 0.5f, yPosn1);
	    break;
	case RNAStructure::C:
	    fl_draw("C", xPosn1 - fl_width('C') * 0.5f, yPosn1);
	    break;
	case RNAStructure::G:
	    fl_draw("G", xPosn1 - fl_width('G') * 0.5f, yPosn1);
	    break;
	case RNAStructure::U:
	    fl_draw("U", xPosn1 - fl_width('U') * 0.5f, yPosn1);
	    break;
    }
}
Exemplo n.º 2
0
void 
SpectrumView::draw_semilog ( void )
{
    int W = w() - padding_right;
    int H = h() - padding_bottom;
    char label[50];

    fl_line_style(FL_SOLID,0);
    fl_font( FL_HELVETICA_ITALIC, 7 );

    //Db grid is easy, it is just a linear spacing
    for(int i=0; i<16; ++i) {
        int level = y()+H*i/16.0;
        fl_line(x(), level, x()+W, level);

        float value = (1-i/16.0)*(_dbmax-_dbmin) + _dbmin;
        sprintf(label, "%.1f", value);
        fl_draw(label, x() + 4, level + 3, w() - 8, 7, FL_ALIGN_LEFT );
    }

    //The frequency grid is defined with points at
    //10,11,12,...,18,19,20,30,40,50,60,70,80,90,100,200,400,...
    //Thus we find each scale that we cover and draw the nine lines unique to
    //that scale
    float lb = 1.0f / logf( 10 );
    const int min_base = logf(_fmin)*lb;
    const int max_base = logf(_fmax)*lb;
    const float b = logf(_fmin)*lb;
    const float a = logf(_fmax)*lb-b;
    for(int i=min_base; i<=max_base; ++i) {
        for(int j=1; j<10; ++j) {
            const float freq = pow(10.0, i)*j;
            const float xloc = (logf(freq)*lb-b)/a;
            if(xloc<1.0 && xloc > -0.001)
            {
                fl_line(xloc*W+x(), y(), xloc*W+x(), y()+H);
            
                if ( j == 1 || j == 2 || j == 5 )
                {
                    sprintf(label, "%0.f%s", freq < 1000.0 ? freq : freq / 1000.0, freq < 1000.0 ? "" : "k" );
                    int sx = x() + xloc*W + 1;
                    if ( sx < x() * W - 20 )
                        fl_draw(label, sx, y()+h());
                }
            }
        }
    }

    /* draw 0dB line */
    {
        fl_line_style(FL_DASH,0);
        float i = ((_dbmax-_dbmin)+_dbmin) / (_dbmax-_dbmin);
        
        int level = y()+H*i;
                
        fl_color(fl_color_add_alpha(fl_rgb_color(240,240,240), 60 ));
        fl_line(x(), level, x()+W, level);
        fl_line_style(FL_SOLID,0);
    }
}
Exemplo n.º 3
0
void gMuteChannel::draw() {

	baseDraw();

	/* print label */

	fl_color(COLOR_BG_1);
	fl_font(FL_HELVETICA, 12);
	fl_draw("mute", x()+4, y(), w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_CENTER));

	/* draw "on" and "off" labels. Must stay in background */

	fl_color(COLOR_BG_1);
	fl_font(FL_HELVETICA, 9);
	fl_draw("on",  x()+4, y(),        w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_TOP));
	fl_draw("off", x()+4, y()+h()-14, w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_TOP));

	/* draw on-off points. On = higher rect, off = lower rect. It always
	 * starts with a note_off */

	fl_color(COLOR_BG_2);

	int pxOld = x()+1;
	int pxNew = 0;
	int py    = y()+h()-5;
	int pyDot = py-6;

	for (unsigned i=0; i<points.size; i++) {

		/* next px */

		pxNew = points.at(i).x+x();

		/* draw line from pxOld to pxNew.
		 * i % 2 == 0: first point, mute_on
		 * i % 2 != 0: second point, mute_off */

		fl_line(pxOld, py, pxNew, py);
		pxOld = pxNew;

		py = i % 2 == 0 ? y()+4 : y()+h()-5;

		/* draw dots (handles) */

		fl_line(pxNew, y()+h()-5, pxNew, y()+4);

		if (selectedPoint == (int) i) {
			fl_color(COLOR_BD_1);
			fl_rectf(pxNew-3, pyDot, 7, 7);
			fl_color(COLOR_BG_2);
		}
		else
			fl_rectf(pxNew-3, pyDot, 7, 7);
	}

	/* last section */

	py = y()+h()-5;
	fl_line(pxNew+3, py, pParent->coverX+x()-1, py);
}
Exemplo n.º 4
0
void gChoice::draw() {
	fl_rectf(x(), y(), w(), h(), COLOR_BG_0);              // bg
	fl_rect(x(), y(), w(), h(), (Fl_Color) COLOR_BD_0);    // border
	if (angle)
		fl_polygon(x()+w()-8, y()+h()-1, x()+w()-1, y()+h()-8, x()+w()-1, y()+h()-1);

	/* pick up the text() from the selected item (value()) and print it in
	 * the box and avoid overflows */

	fl_color(!active() ? COLOR_BD_0 : COLOR_TEXT_0);
	if (value() != -1) {
		if (fl_width(text(value())) < w()-8) {
			fl_draw(text(value()), x(), y(), w(), h(), FL_ALIGN_CENTER);
		}
		else {
			std::string tmp = text(value());
			int size        = tmp.size();
			while (fl_width(tmp.c_str()) >= w()-16) {
				tmp.resize(size);
				size--;
			}
			tmp += "...";
			fl_draw(tmp.c_str(), x(), y(), w(), h(), FL_ALIGN_CENTER);
		}

	}
}
Exemplo n.º 5
0
	void draw(){
		int wt, wb, wc;
		wt = y() + 24;// wave top
		wb = y() + h() - 10;// wave bottom
		wc = (w() - 20) * sh / (sh + sl) + x() + 10;// wave change

		fl_color(FL_BLACK);
		fl_rectf(x(), y(), w(), h());
		if(sh == 0 && sl == 0){
			return;
		}
		fl_color(FL_GREEN);
		fl_xyline(x(), wb, x() + 10);
		fl_yxline(x() + 10, wt, wb);
		fl_xyline(x() + 10, wt, wc);
		fl_yxline(wc, wt, wb);
		fl_xyline(wc, wb, x() + w() - 10);
		fl_yxline(x() + w() - 10, wt, wb);
		fl_xyline(x() + w() - 10, wt, x() + w());
		
		fl_color(FL_WHITE);
		fl_font(FL_HELVETICA, 10);
		fl_draw(t, x(), y() + 10);
		sprintf(buf, "%dusec", sh);
		fl_draw(buf, x() + 12, wt - 2);
		sprintf(buf, "%dusec", sl);
		fl_draw(buf, wc + 2, wb - 2);
	}
Exemplo n.º 6
0
void WidgetTable::draw_cell(TableContext context,
	int R, int C, int X, int Y, int W, int H)
{
	switch (context)
	{
	case CONTEXT_STARTPAGE:
		fl_font(FL_HELVETICA, 12);		// font used by all headers
		col_width_all(50);				// sets the width of the columns
		break;

	case CONTEXT_RC_RESIZE:
	{
		int X, Y, W, H;
		int index = 0;
		for (int r = 0; r<rows(); r++)
		{
			for (int c = 0; c<cols(); c++)
			{
				if (index >= children()) break;
				find_cell(CONTEXT_TABLE, r, c, X, Y, W, H);
				child(index++)->resize(X, Y, W, H);
			}
		}
		init_sizes();			// tell group children resized
		return;
	}

	case CONTEXT_ROW_HEADER:
		fl_push_clip(X, Y, W, H);
		{
			static char s[40];
			sprintf(s, "Row %d", R);
			fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, row_header_color());
			fl_color(FL_BLACK);
			fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER);
		}
		fl_pop_clip();
		return;

	case CONTEXT_COL_HEADER:
		fl_push_clip(X, Y, W, H);
		{
			static char s[40];
			sprintf(s, "Column %d", C);
			fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, col_header_color());
			fl_color(FL_BLACK);
			fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER);
		}
		fl_pop_clip();
		return;

	case CONTEXT_CELL:
		return;		// fltk handles drawing the widgets

	default:
		return;
	}
}
void RulerWindow::draw()
{
	char szText[256];

	if (m_dRangeMax != FLT_MAX && m_dRangeMin != FLT_MIN) {
		switch (m_flcColor) {
		case FL_CYAN:
		case FL_GREEN:
			fl_rectf(0, 0, w(), h(), 0, 0, 0);
			break;
		default:
			fl_rectf(0, 0, w(), h(), 255, 255, 255);
			break;
		}

		double dRange = m_dRangeMax - m_dRangeMin;
		int iWindowLen = m_byType == RW_HORIZONTAL ? w() : h();
		const int k_iAvgLongMarkLen = 15;

		int iLongMarkCount = iWindowLen / k_iAvgLongMarkLen;

		if (iLongMarkCount > 0 && iWindowLen > 0) {
			// Computer the long mark length so that it's 10^i where i is an integer
			double dLongMarkLength = dRange / (double)iLongMarkCount;
			double dLongMarkLengthPow = log10(dLongMarkLength);
			int iLongMarkLengthPow = (int)ceil(dLongMarkLengthPow);
			dLongMarkLength = pow(10.0, (double)iLongMarkLengthPow);

			int iStart = (int)ceil(m_dRangeMin / dLongMarkLength);
			int iMarkPos;

			fl_color(m_flcColor);
			fl_font(FL_HELVETICA, 10);
			do {
				iMarkPos = (int)(((double)iStart * dLongMarkLength - m_dRangeMin) / dRange * (double)iWindowLen + 0.5);

				snprintDecimal(szText, 256, iStart, iLongMarkLengthPow);
				if (m_byType == RW_HORIZONTAL) {
					fl_line(iMarkPos, 0, iMarkPos, h() / 2);
					fl_draw(szText, iMarkPos + 2, h() - 1);
				}
				else {
					fl_line(0, h() - iMarkPos, w() / 2, h() - iMarkPos);
					fl_draw(szText, 2, h() - iMarkPos - 2);
				}

				++iStart;
			} while (iMarkPos < iWindowLen);
		}
	}
	else {
		// disabled
		fl_rectf(0, 0, w(), h(), 128, 128, 128);
	}
}
Exemplo n.º 8
0
void Fl_Labeltype_::draw(const char* label,
	int X, int Y, int W, int H,
	Fl_Color color, Fl_Flags flags) const
{
	if (flags & FL_INACTIVE)
	{
		fl_color(FL_LIGHT2);
		fl_draw(label, X+1, Y+1, W, H, flags);
		color = fl_inactive(color);
	}
	fl_color(color);
	fl_draw(label, X, Y, W, H, flags);
}
Exemplo n.º 9
0
void
Fl_Arc_Dial::draw ( void )
{
    int X = x();
    int Y = y();
    int W = w();
    int H = h();

    draw_box();
    draw_label();

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

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

    fl_line_style( FL_SOLID, W / 6 );

    X += W / 8;
    Y += H / 8;
    W -= W / 4;
    H -= H / 4;

    if ( box() == FL_NO_BOX )
    {
        /* draw backgrond arc */
        fl_color( fl_color_average( FL_BLACK, selection_color(), 0.80f ) );
        fl_arc( X, Y, W, H, 270 - angle1(), 270 - angle2() );
    }

    fl_color( selection_color() );
//    fl_color( fl_color_average( FL_RED, selection_color(), ( value() - minimum() ) / ( maximum() - minimum() ) ) );


    if ( type() == FL_FILL_DIAL )
        fl_arc( X, Y, W, H, 270 - angle1(), 270 - angle  );
    else
    {
        const int d = 6;

        /* account for edge conditions */
        angle = angle < angle1() + d ? angle1() + d : angle;
        angle = angle > angle2() - d ? angle2() - d : angle;

        fl_arc( X, Y, W, H, 270 - (angle - d), 270 - (angle + d) );
    }

    fl_line_style( FL_SOLID, 0 );

    fl_color( labelcolor() );

    char s[10];

    fl_font( FL_HELVETICA, 8 );

    snprintf( s, sizeof( s ), "%.1f", value() );
    fl_draw( s, X, Y, W, H, FL_ALIGN_BOTTOM );
}
Exemplo n.º 10
0
Arquivo: draw.C Projeto: imv/non
int
gui_draw_string ( int x, int y, int w, int h, int color, const char *s, bool draw )
{
    int rw;

    if ( ! s )
        return 0;

    fl_font( FL_COURIER, min( h, 18 ) );

    rw = fl_width( s );

    if ( fl_not_clipped( x, y, rw, h ) && draw )
    {
        gui_clear_area( x, y, w, h );

        if ( color )
            fl_color( velocity_colors[ color ] );
        else
            fl_color( FL_DARK_CYAN );

        fl_draw( s, x, y + h / 2 + fl_descent() );
    }

    return rw;
}
Exemplo n.º 11
0
Arquivo: ntk-perf.C Projeto: 0mk/non
   void draw ( void )
        {          
            if ( use_cairo )
                fl_push_use_cairo(true);

            fl_rectf( x(), y(), w(), h(), FL_BLACK );

            unsigned long long then = get_ts();

            fl_push_clip( x(), y(), w(), h() );

            int count = 400;

            /* draw stuff */
            int i = 0;
            for ( ; i < count; ++i )
                fl_draw_box( boxtype, x(), y(), w(), h(), fl_lighter( FL_BLACK ) );

            fl_pop_clip();

            unsigned long long now = get_ts();

            double elapsedms = (now - then) / 1000.0;

            static char text[256];
            sprintf( text, "Drew %i boxes in in %fms", i, elapsedms );

            fl_color( FL_RED );
            fl_draw( text, x(), y(), w(), h(), FL_ALIGN_CENTER | FL_ALIGN_INSIDE );

            draw_label();

            if ( use_cairo )
                fl_pop_use_cairo();
        }
Exemplo n.º 12
0
static void
label_draw(const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align)
{
  fl_font(o->font, o->size);
  fl_color((Fl_Color)o->color);
  fl_draw(o->value, X+MENU_ICON_W+3, Y, W-MENU_ICON_W-3, H, align);
}
Exemplo n.º 13
0
	void Box::draw_lines() const{
		if(fill_color().visibility()) {    // fill
			fl_color(fill_color().as_int());
			fl_rectf(point(0).x + r, point(0).y, w - r - r, h);								// 丸角四角形内の縦の長方形
			fl_rectf(point(0).x, point(0).y + r, w, h - r - r);								// 丸角四角形内の横の長方形
			fl_pie(point(0).x + w - r - r, point(0).y, r + r, r + r, 0, 90);				// 右上円
			fl_pie(point(0).x, point(0).y, r + r, r + r, 90, 180);							// 左上円
			fl_pie(point(0).x, point(0).y + h - r - r, r + r, r + r, 180, 270);				// 左下円
			fl_pie(point(0).x + w - r - r, point(0).y + h - r - r, r + r, r + r, 270, 360);	// 右下円
			fl_color(color().as_int());    // reset color
		}

		if(color().visibility()) {    // lines on top of fill
			fl_color(color().as_int());
			fl_line(point(0).x + r, point(0).y, point(0).x + w - r, point(0).y);			// 上線
			fl_line(point(0).x + r, point(0).y + h, point(0).x + w - r, point(0).y + h);	// 下線
			fl_line(point(0).x, point(0).y + r, point(0).x, point(0).y + h - r);			// 左線
			fl_line(point(0).x + w, point(0).y + r, point(0).x + w, point(0).y + h - r);	// 右線
			fl_arc(point(0).x + w - r - r, point(0).y, r + r, r + r, 0, 90);				// 右上角丸
			fl_arc(point(0).x, point(0).y, r + r, r + r, 90, 180);							// 左上角丸
			fl_arc(point(0).x, point(0).y + h - r - r, r + r, r + r, 180, 270);				// 左下角丸
			fl_arc(point(0).x + w - r - r, point(0).y + h - r - r, r + r, r + r, 270, 360);	// 右下角丸
		}

		int ofnt = fl_font();
		int osz = fl_size();
		fl_font(fnt.as_int(), fnt_sz);
		fl_draw(lab.c_str(), point(0).x + r, point(0).y + h - r);
		fl_font(ofnt, osz);
	}
Exemplo n.º 14
0
	void draw(){
		int i;
		int pitch, level;

		fl_color(FL_BLACK);
		fl_rectf(x(), y(), w(), h());
		if(c <= 0){
			return;
		}
		pitch = w() / c;

		fl_color(FL_GREEN);
		for(i = 0; i < c; i++){
			level = (center - s[i]) / 2 + h() / 2 + y();
			fl_rectf(
				i * pitch + x(),
				level,
				pitch > 1 ? pitch - 1 : pitch,
				h() + y() - level);
		}
		fl_color(FL_WHITE);
		fl_line(x(), h() / 2 + y(), w() + x(), h() / 2 + y());
		fl_font(FL_HELVETICA, 10);
		fl_draw(buf, x(), y() + 10);
	}
Exemplo n.º 15
0
void
Sequence_Region::draw_label ( const char *label, Fl_Align align, Fl_Color color, int xo, int yo )
{
    fl_color( FL_WHITE );
    fl_font( FL_HELVETICA_ITALIC, 10 );
    fl_draw( label, line_x() + Fl::box_dx( box() ), y() + Fl::box_dy( box() ), abs_w() - Fl::box_dw( box() ), h() - Fl::box_dh( box() ), align );
}
Exemplo n.º 16
0
void Fl_ProgressBar::draw()
{
    int bdx, bdy;
    double pct;
    if(damage() & FL_DAMAGE_ALL) draw_box();

    int X = 0, Y = 0;
    bdx = box()->dx();
    bdy = box()->dy();

    fl_color(selection_color());
    if(mPresent > mMax)
        mPresent = mMax;
    if(mPresent < mMin)
        mPresent = mMin;
    pct = (mPresent - mMin) / mMax;
    fl_rectf(X + bdx, Y + bdy, (int)(((double)w() - 2*bdx) * pct), h() - (2*bdy + 1));
    if(mShowPct)
    {
        char buffer[30];
        sprintf(buffer, "%d%%", (int) (pct * 100));
        fl_color(textcolor());
        fl_font(this->label_font(), this->label_size());
        fl_draw(buffer, X + (w() - fl_width(buffer))/2, Y + fl_height() + (((h() - 2*bdy) - fl_height())/2));
    }
}
Exemplo n.º 17
0
void draw_mark(Point xy, char c)
{
	static const int dx = 4;
	static const int dy = 4;
	string m(1,c);
	fl_draw(m.c_str(),xy.x-dx,xy.y+dy);
}
Exemplo n.º 18
0
void shape_window::draw() {
  fl_color(0);
  fl_rectf(0,0,w(),h());
  fl_font(0,20);
  fl_color(7);
  fl_draw("This requires GL",0,0,w(),h(),FL_ALIGN_CENTER);
}
Exemplo n.º 19
0
void FontDisplay::draw() {
  draw_box();
  int ix = 0, iy = 0, iw = w(), ih = h();
  box()->inset(ix, iy, iw, ih);
  fl_push_clip(ix, iy, iw, ih);
  const char* saved_encoding = fl_encoding();
  if (encoding) fl_encoding(encoding);
  fl_font(font, size);
  fl_color(FL_BLACK);
  char buffer[32];
//#if HAVE_XUTF8
  char outbuf[64];
//#endif
  for (int Y = 1; Y < 8; Y++) {
      for (int X = 0; X < 32; X++) buffer[X] = (32*Y+X);
//#if HAVE_XUTF8
      int len = fl_latin12utf((uint8*)buffer, 32, outbuf);
      fl_draw(outbuf, len, 3, 3+fl_height()*Y);
//#else
//      fl_draw(buffer, 32, 3, 3+fl_height()*Y);
//#endif
  }
  fl_encoding(saved_encoding);
  fl_pop_clip();
}
Exemplo n.º 20
0
void Text::draw_lines() const
{
    int ofnt = fl_font();
    int osz = fl_size();
    fl_font(fnt.as_int(),fnt_sz);
    fl_draw(lab.c_str(),point(0).x,point(0).y);
    fl_font(ofnt,osz);
}
Exemplo n.º 21
0
void DrawMessage(const std::string& text, const Point<float>& point)
{
  fl_draw(text.c_str(), point.x(), point.y());
  /*glRasterPos3f(point.x(), point.y(), point.z());

  for (int i = 0; i < text.length(); i++){
    glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, text.data()[i]);
  }*/
}
Exemplo n.º 22
0
void Icon::draw()
{
    Fl_Flags f=0;
    Fl_Image *im = icon_im;
    if(focused()) {
        f=FL_SELECTED;
    }

    if(im)
        im->draw(0, 0, w(), h(),f);
    else {
        fl_color(FL_RED);
        fl_rect(0,0,w(),h());
        fl_color(FL_BLACK);
        fl_rectf(1,1,w()-2,h()-2);
        fl_color(FL_WHITE);
        fl_font(label_font()->bold(), 10);
        fl_draw("NO ICON FOUND!", 1, 1, w()-2, h()-2, FL_ALIGN_TOP|FL_ALIGN_LEFT|FL_ALIGN_WRAP);
    }

    int X = w()-(w()/2)-(lwidth/2);
    int Y = h()+2;

    if(!label_trans) {
        fl_color(label_background);
        fl_rectf(X,Y,lwidth,lheight);
    }

    if(focused()) {
        focus_box()->draw(X, Y, lwidth, lheight, color(), 0);
    }

    fl_font(label_font(), label_size());

    // A little shadow, from Dejan's request :)
    // SUCKS!
    /*fl_color(fl_darker(label_color()));
    fl_draw(label(), X-1, Y+1, lwidth, lheight, flags());
    fl_draw(label(), X, Y+1, lwidth, lheight, flags());
    */

    fl_color(label_color());
    fl_draw(label(), X, Y, lwidth, lheight, flags());
}
Exemplo n.º 23
0
void gActionChannel::draw() {

	/* draw basic boundaries (+ beat bars) and hide the unused area. Then
	 * draw the children (the actions) */

	baseDraw();

	/* print label */

	fl_color(COLOR_BG_1);
	fl_font(FL_HELVETICA, 12);
	if (active())
		fl_draw("actions", x()+4, y(), w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_CENTER));  /// FIXME h() is too much!
	else
		fl_draw("actions (disabled)", x()+4, y(), w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_CENTER));  /// FIXME h() is too much!

	fl_rectf(pParent->coverX, y()+1, pParent->totalWidth-pParent->coverX+x(), h()-2, COLOR_BG_1);

	draw_children();
}
Exemplo n.º 24
0
void MapsWindow::MapArea::MapInfoWin::draw()
{
    draw_box(FL_BORDER_BOX, 0, 0, w(), h(), Fl_Tooltip::color());
    fl_color(Fl_Tooltip::textcolor());
    fl_font(Fl_Tooltip::font(), Fl_Tooltip::size());

    int X = MARGIN;
    int Y = MARGIN;
    int W = w() - (MARGIN*2);
    int H = h() - (MARGIN*2);
    fl_draw(info_.c_str(), X, Y, W, H, Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_WRAP));
}
Exemplo n.º 25
0
    void draw()
    {
        static int oX=0, oY=0;

        if(!tW) {
            fl_font(FL_HELVETICA_BOLD, 14);
            tW = int(fl_width(str));
        }

        if(!backing->get_offscreen())
            backing->draw(0,0);

        Pixmap id = backing->get_offscreen();

        int tX = (w()/2)-(tW/2);
        int bW = ball->width();
        int bH = ball->height();

        if(damage()!=FL_DAMAGE_VALUE) {

            fl_copy_offscreen(0, 0, w(), h(), id, 0, 0);

        } else {

            // Erase bg under text
            fl_copy_offscreen(tX, tY, tW, int(fl_height()), id, tX, tY);

            // Erase only area affected, by moving ball!
            int DX = dX>0 ? dX : -dX;
            int DY = dY>0 ? dY : -dY;
            DX+=2; DY+=2;

            // X axis
            if(dX>0) fl_copy_offscreen(oX,   Y-DY, dX,  bH+(DY*2), id, oX, Y-DY);
            else     fl_copy_offscreen(X+bW, Y-DY, -dX, bH+(DY*2), id, X+bW, Y-DY);

            // Y axis
            if(dY>0) fl_copy_offscreen(oX, oY,   bW+DX,  dY, id, oX, oY);
            else     fl_copy_offscreen(oX, Y+bH, bW+DX, -dY, id, oX, Y+bH);
        }

        if(blended) delete blended;
        // Do alphablend and draw it to screen
        if( (blended = ball->blend(backing, X,Y)) ) {
            blended->draw(X, Y);
        }

        // Draw string
        fl_draw(str, float(tX), float(tY+int(fl_height())));

        oX=X; oY=Y;
    }
Exemplo n.º 26
0
void Icon::draw(void)
{
	Fl_Flags f = 0;
    if(is_focused()) 
		f = FL_SELECTED;

	if(icon_img)
		icon_img->draw(0, 0, w(), h(),f);
	else
	{
		fl_color(FL_RED);
		fl_rect(0,0,w(),h());
		fl_color(FL_BLACK);
		fl_rectf(1,1,w()-2,h()-2);
		fl_color(FL_WHITE);
		fl_font(label_font()->bold(), 10);
		fl_draw(_("NO ICON FOUND!"), 1, 1, w()-2, h()-2, FL_ALIGN_TOP|FL_ALIGN_LEFT|FL_ALIGN_WRAP);
		return;
	}

	if(globals->label_draw)
	{
    	int X = w()-(w()/2)-(lwidth/2);
		int Y = h()+2;
		if(!globals->label_transparent) 
		{
        	fl_color(globals->label_background);
			fl_rectf(X,Y,lwidth,lheight);
		}

    	if(is_focused())
			focus_box()->draw(X, Y, lwidth, lheight, color(), 0);

    	fl_font(label_font(), label_size());
		fl_color(label_color());
		fl_draw(label(), X, Y, lwidth, lheight, flags());
    }
}
Exemplo n.º 27
0
    void draw() {
        // COMPUTE NEW COORDS OF LINE
        static long start = time(NULL);
        long tick = time(NULL) - start;
        char secs[80]; sprintf(secs, "%02ld:%02ld", tick/60, tick%60);
		
		int val = getNumberGates(); 
		static char val_str[20]; 
		sprintf(val_str, "%d", val); 
		Fl_Chart::add(val, val_str, FL_GREEN); 
		Fl_Chart::draw(); 
		fl_color(FL_BLACK);
		fl_font(FL_HELVETICA,16);
		fl_draw(secs, x()+4, y()+h()-4); 
    }
Exemplo n.º 28
0
void
Module::draw_label ( void )
{
    int tw, th, tx, ty;

    bbox( tx, ty, tw, th );

    const char *lp = label();

    int l = strlen( label() );

    Fl_Color c = FL_FOREGROUND_COLOR;

    if ( bypass() || ! active() )
        c = FL_BLACK;

    fl_color( fl_contrast( c, is_default() ? FL_BLACK : color() ) );

    char *s = NULL;

    if ( l > 10 )
    {
        s = new char[l];
        char *sp = s;

        for ( ; *lp; ++lp )
            switch ( *lp )
            {
                case 'i': case 'e': case 'o': case 'u': case 'a':
                    break;
                default:
                    *(sp++) = *lp;
            }
        *sp = '\0';

    }

    if ( l > 20 )
        fl_font( FL_HELVETICA, 10 );
    else
        fl_font( FL_HELVETICA, 14 );

    fl_draw( s ? s : lp, tx, ty, tw, th, (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP ) );

    if ( s )
        delete[] s;
}
Exemplo n.º 29
0
void gRadio::draw() {

	int color = !active() ? FL_INACTIVE_COLOR : COLOR_BD_0;

	if (value()) {
		fl_rect(x(), y(), 12, 12, (Fl_Color) color);
		fl_rectf(x(), y(), 12, 12, (Fl_Color) color);
	}
	else {
		fl_rectf(x(), y(), 12, 12, FL_BACKGROUND_COLOR);
		fl_rect(x(), y(), 12, 12, (Fl_Color) color);
	}

	fl_rectf(x()+20, y(), w(), h(), FL_BACKGROUND_COLOR);  // clearer
	fl_font(FL_HELVETICA, 11);
	fl_color(COLOR_TEXT_0);
	fl_draw(label(), x()+20, y(), w(), h(), (Fl_Align) (FL_ALIGN_LEFT | FL_ALIGN_TOP));
}
Exemplo n.º 30
0
// Fltk draw
void MyButton::draw() {
    Fl_OpButton::draw();

    // NOT CONNECTED, AND CONSTANT SET?
    //    Show its value to the left of the button.
    //
    if ( !IsConnected() && const_val != "" ) {
        int fontsize = 18;
        int align = FL_ALIGN_RIGHT|FL_ALIGN_INSIDE;                     // right justified
        fl_color(0xf0d0a000);
        fl_font(FL_HELVETICA_BOLD, fontsize);
        int X = x() - 40;
        int Y = y() + 2;
        int W = 40 - 5;
        int H = fontsize;
        fl_draw(const_val.c_str(), X,Y,W,H, Fl_Align(align));   // draw the constant next to the button
    }
}