Beispiel #1
0
void
fli_draw_button( FL_OBJECT * obj )
{
    FL_Coord dh,
             dw,
             ww,
             absbw = FL_abs( obj->bw );
    int off2 = 0;
    FL_BUTTON_STRUCT *sp = obj->spec;
    FL_COLOR col = sp->val ? obj->col2 : obj->col1;

    if ( obj->belowmouse && obj->active )
    {
        if ( col == FL_BUTTON_COL1 )
            col = FL_BUTTON_MCOL1;
        else if ( col == FL_BUTTON_COL2 )
            col = FL_BUTTON_MCOL2;
    }

    if ( FL_IS_UPBOX( obj->boxtype ) && ( sp->val || sp->is_pushed ) )
        fl_draw_box( FL_TO_DOWNBOX( obj->boxtype ), obj->x, obj->y, obj->w,
                     obj->h, col, obj->bw );
    else
        fl_draw_box( obj->boxtype, obj->x, obj->y, obj->w, obj->h, col,
                     obj->bw );

    dh = FL_crnd( 0.6 * obj->h );
    dw = FL_crnd( FL_min( 0.6 * obj->w, dh ) );

    ww = FL_crnd( 0.75 * obj->h );
    if ( ww < dw + absbw + 1 + ( obj->bw > 0 ) )
        ww = dw + absbw + 1 + ( obj->bw > 0 );

    if ( obj->type == FL_RETURN_BUTTON )
    {
        fl_draw_text( 0, obj->x + obj->w - ww, FL_crnd( obj->y + 0.2 * obj->h ),
                      dw, dh, obj->lcol, 0, 0, "@returnarrow" );
        off2 = dw - 2;
    }

    if ( obj->type == FL_MENU_BUTTON && obj->boxtype == FL_UP_BOX )
    {
        int dbh = FL_max( absbw - 1, 1 );

        dw = FL_max( 0.11 * obj->w, 13 );
        dh = FL_max( 6 + (obj->bw > 0 ), obj->h * 0.1 );

        fl_draw_box( FL_UP_BOX, obj->x + obj->w - dw - absbw - 2,
                     obj->y + ( obj->h - dh ) / 2, dw, dh, obj->col1, -dbh );
        off2 = dw - 1;
    }

    if ( obj->type == FL_MENU_BUTTON || obj->type == FL_RETURN_BUTTON )
    {
        obj->w -= off2;
        fl_draw_object_label( obj );
        obj->w += off2;
    }
    else if ( obj->boxtype & FLI_BROKEN_BOX || ISTABBOX( obj->boxtype ) )
    {
        fl_set_text_clipping( obj->x + 3, obj->y, obj->w - 6, obj->h );
        fl_draw_object_label( obj );
        fl_unset_text_clipping( );
    }
    else
        fl_draw_object_label( obj );
}
Beispiel #2
0
/// Draw this item and its children.
void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, 
                        const Fl_Tree_Prefs &prefs, int lastchild) {
    if ( ! _visible ) return; 
    fl_font(_labelfont, _labelsize);
    int H = _labelsize + fl_descent() + prefs.linespacing();
    // Colors, fonts
    Fl_Color fg = _selected ? prefs.bgcolor()     : _labelfgcolor;
    Fl_Color bg = _selected ? prefs.selectcolor() : _labelbgcolor;
    if ( ! _active ) {
	fg = fl_inactive(fg);
	if ( _selected ) bg = fl_inactive(bg);
    }
    // Update the xywh of this item
    _xywh[0] = X;
    _xywh[1] = Y;
    _xywh[2] = W;
    _xywh[3] = H;
    // Text size
    int textw=0, texth=0;
    fl_measure(_label, textw, texth, 0);
    int textycenter = Y+(H/2);
    int &icon_x = _collapse_xywh[0] = X-1;
    int &icon_y = _collapse_xywh[1] = textycenter - (prefs.openicon()->h()/2);
    int &icon_w = _collapse_xywh[2] = prefs.openicon()->w();
    _collapse_xywh[3] = prefs.openicon()->h();
    // Horizontal connector values
    int hstartx  = X+icon_w/2-1;
    int hendx    = hstartx + prefs.connectorwidth();
    int hcenterx = X + icon_w + ((hendx - (X + icon_w)) / 2);

    // See if we should draw this item
    //    If this item is root, and showroot() is disabled, don't draw.
    //
    char drawthis = ( is_root() && prefs.showroot() == 0 ) ? 0 : 1;
    if ( drawthis ) {
	// Draw connectors
	if ( prefs.connectorstyle() != FL_TREE_CONNECTOR_NONE ) {
	    // Horiz connector between center of icon and text
	    draw_horizontal_connector(hstartx, hendx, textycenter, prefs);
	    if ( has_children() && is_open() ) {
		// Small vertical line down to children
		draw_vertical_connector(hcenterx, textycenter, Y+H, prefs);
	    }
	    // Connectors for last child
	    if ( ! is_root() ) {
		if ( lastchild ) {
		    draw_vertical_connector(hstartx, Y, textycenter, prefs);
		} else {
		    draw_vertical_connector(hstartx, Y, Y+H, prefs);
		}
	    }
	} 
	// Draw collapse icon
	if ( has_children() && prefs.showcollapse() ) {
	    // Draw icon image
	    if ( is_open() ) {
		prefs.closeicon()->draw(icon_x,icon_y);
	    } else {
		prefs.openicon()->draw(icon_x,icon_y);
	    }
	}
	// Background for this item
	int &bx = _label_xywh[0] = X+(icon_w/2-1+prefs.connectorwidth());
	int &by = _label_xywh[1] = Y;
	int &bw = _label_xywh[2] = W-(icon_w/2-1+prefs.connectorwidth());
	int &bh = _label_xywh[3] = texth;
	// Draw bg only if different from tree's bg
	if ( bg != tree->color() || is_selected() ) {
	    if ( is_selected() ) {
		// Selected? Use selectbox() style
		fl_draw_box(prefs.selectbox(), bx, by, bw, bh, bg);
	    } else {
		// Not Selected? use plain filled rectangle
		fl_color(bg);
		fl_rectf(bx, by, bw, bh);
	    }
	}
	// Draw user icon (if any)
	int useroff = (icon_w/2-1+prefs.connectorwidth());
	if ( usericon() ) {
	    // Item has user icon? Use it
	    useroff += prefs.usericonmarginleft();
	    usericon()->draw(X+useroff,icon_y);
	    useroff += usericon()->w();
	} else if ( prefs.usericon() ) {
	    // Prefs has user icon? Use it
	    useroff += prefs.usericonmarginleft();
	    prefs.usericon()->draw(X+useroff,icon_y);
	    useroff += prefs.usericon()->w();
	}
	useroff += prefs.labelmarginleft();
	// Draw label
	if ( widget() ) {
	    // Widget? Draw it
	    int lx = X+useroff;
	    int ly = by;
	    int lw = widget()->w();
	    int lh = bh;
	    if ( widget()->x() != lx || widget()->y() != ly ||
		 widget()->w() != lw || widget()->h() != lh ) {
		widget()->resize(lx, ly, lw, lh);		// fltk will handle drawing this
	    }
	} else {
	    // No label widget? Draw text label
	    if ( _label ) {
		fl_color(fg);
		fl_draw(_label, X+useroff, Y+H-fl_descent()-1);
	    }
	}
	Y += H;
    }			// end drawthis
    // Draw children
    if ( has_children() && is_open() ) {
	int child_x = drawthis ? 			// offset children to right,
	              (hcenterx - (icon_w/2) + 1) : X;	// unless didn't drawthis
	int child_w = W - (child_x-X);
	int child_y_start = Y;
	for ( int t=0; t<children(); t++ ) {
	    int lchild = ((t+1)==children()) ? 1 : 0;
	    _children[t]->draw(child_x, Y, child_w, tree, prefs, lchild);
	}
	if ( has_children() && is_open() ) {
	    Y += prefs.openchild_marginbottom();	// offset below open child tree
	}
	if ( ! lastchild ) {
	    draw_vertical_connector(hstartx, child_y_start, Y, prefs);
	}
    }
}
Beispiel #3
0
Datei: draw.C Projekt: imv/non
void
gui_draw_shape ( int x, int y, int w, int h, int shape, int state, int flags, int color  )
{
    /* take advantage of FLTK's clipping */
    if ( ! fl_not_clipped( x, y, w, h ) )
        return;

    if ( flags & F_PLAYHEAD )
    {
        state = state == FULL ? HIT : PLAYHEAD;
        flags &= ~ F_SELECTION;
    }

    Fl_Color c1, c2;

    if ( state == FULL && color  )
    {
        c1 = velocity_colors[ color ];
        c2 = velocity2_colors[ color ];
    }
    else
    {
        c1 = state_colors[ state ];
        c2 = fl_color_average( FL_WHITE, c1, 0.1 );
    }
        
    if ( flags & F_SELECTION )
        fl_color( fl_darker( fl_color() ) );

    int bw = 1;

    switch ( shape )
    {
        case SQUARE:
//            fl_rectf( x, y, w, h, FL_BLACK );

            fl_color( c1 );
            fl_rectf( x + bw, y + bw, w - bw * 2, h - bw * 2 );
            if ( draw_borders )
            {
                fl_color( c2 );
                fl_line_style( FL_SOLID, 2 );
                fl_rect( x + bw + 1, y + bw + 1, w - (bw+1) * 2, h - (bw+1) * 2 );
                fl_line_style( FL_SOLID, 0 );
            }
            break;
        case BOX:
            fl_draw_box( FL_THIN_UP_BOX, x + bw, y + bw, w - bw * 2, h - bw * 2, c1 );
            break;
        default:
            ASSERTION( "unknown shape" );
            break;
    }

    if ( flags & F_P1 || flags & F_P2 )
    {
        if ( flags & F_P1 )
            fl_color( FL_GREEN );
        else
            fl_color( FL_RED );

        int rw = w / 4;
        int rh = h / 4;

        fl_rectf( x + (w / 2) - (rw / 2), y + (h / 2) - (rh / 2), rw, rh );
    }
}
void Flu_Toggle_Group :: draw()
{
  int lblW = 0, lblH, X, i;

  if( label() == 0 )
    lblW = lblH = 0;
  else if( strlen( label() ) == 0 )
    lblW = lblH = 0;
  else
    {
      measure_label( lblW, lblH );
      lblW += 18;
      lblH += 2;
    }

  // align the label
  if( align() & FL_ALIGN_LEFT )
    X = 4;
  else if( align() & FL_ALIGN_RIGHT )
    X = w() - lblW - 8;
  else
    X = w()/2 - lblW/2 - 2;

  // draw the main group box
  if( damage() & ~FL_DAMAGE_CHILD )
    fl_draw_box( box(), x(), y()+lblH/2, w(), h()-lblH/2, color() );

  unsigned char *active = 0;
  if( !chkBtn->value() )
    {
      active = (unsigned char*)malloc( children() );
      for( i = 1; i < children(); i++ )
	{
	  active[i-1] = child(i)->active();
	  child(i)->deactivate();
	}
    }

  // clip and draw the children
  chkBtn->resize( chkBtn->x(), chkBtn->y(), 0, 0 );
  fl_clip( x()+2, y()+lblH+1, w()-4, h()-lblH-3 );
  draw_children();
  fl_pop_clip();

  // clear behind the button and draw it
  fl_color( color() );
  fl_rectf( x()+X, y(), lblW+4, lblH );
  fl_color( labelcolor() );
  chkBtn->label( label() );
  chkBtn->resize( x()+X+2, y(), lblW, lblH );
  draw_child( *chkBtn );

  if( !chkBtn->value() )
    {
      for( i = 1; i < children(); i++ )
	{
	  if( active[i-1] )
	    child(i)->activate();
	  else
	    child(i)->deactivate();
	}
      free( active );
    }
}
Beispiel #5
0
 FL_EXPORT_C(void,flc_draw_box)(Fl_Boxtype boxtype,int x,int y,int w,int h,Fl_Color color){
   fl_draw_box(boxtype,x,y,w,h,color);
 }
Beispiel #6
0
void Plugin_Table::draw_cell(TableContext context, 
			  int R, int C, int X, int Y, int W, int H)
{
    const char *headings[] = { "Fav.", "Name", "Author", "Type", "In", "Out" };
 
    static char s[40];

    switch ( context )
    {
	case CONTEXT_STARTPAGE:
	    fl_font(FL_HELVETICA, 12);
	    return;

	case CONTEXT_COL_HEADER:
	    fl_push_clip(X, Y, W, H);
	    {
	        fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, col_header_color());
	        fl_color(FL_FOREGROUND_COLOR);
		fl_draw(headings[C], X, Y, W, H, FL_ALIGN_CENTER);
	    }
	    fl_pop_clip();
	    return;

	case CONTEXT_ROW_HEADER:
	    return;

	case CONTEXT_CELL:
	{
            fl_font(FL_HELVETICA, 12);
	  
            const char *s2 = (char*)s;
            Fl_Align a = FL_ALIGN_CENTER;
            int symbol = 0;
            Fl_Color c = FL_FOREGROUND_COLOR;
            switch ( C ) 
            {
                case 0:
                    sprintf( s, "%s", "@circle" );
                    c = _plugin_rows[R]->favorite ? FL_LIGHT2 : FL_BLACK;
                    symbol = 1;
                    fl_font(FL_HELVETICA, 9 );
                    break;
                case 1:
                    a = FL_ALIGN_LEFT;
                    s2 = _plugin_rows[R]->name.c_str();
                    break;
                case 2:
                    a = FL_ALIGN_LEFT;
                    s2 = _plugin_rows[R]->author.c_str();
                    break;
                case 3:
                    s2 = _plugin_rows[R]->type;
                    break;
                case 4:
                    sprintf( s, "%i", _plugin_rows[R]->audio_inputs );
                    break;
                case 5:
                    sprintf( s, "%i", _plugin_rows[R]->audio_outputs );
                    break;
            }

            fl_color( row_selected(R) ? selection_color() : FL_DARK1);
            fl_rectf(X, Y, W, H);
            fl_color(color()); 
            fl_rect(X, Y, W, H);

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

	    fl_push_clip(X, Y, W, H);
	    
            fl_color(c);
            fl_draw(s2, X, Y, W, H, a, 0, symbol );

            fl_pop_clip();
	    return;
	}

	case CONTEXT_TABLE:
	    fprintf(stderr, "TABLE CONTEXT CALLED\n");
	    return;

	case CONTEXT_ENDPAGE:
	case CONTEXT_RC_RESIZE:
	case CONTEXT_NONE:
	    return;
    }
}