void Fl_Input_Browser::draw()
{
    Fl_Flags f = flags();
    if (!active_r()) f.set(FL_INACTIVE);
    //minw_ = w();
    if (damage()&FL_DAMAGE_ALL) draw_frame();
    int X = 0, Y = 0, W = w(), H = h(); box()->inset(X, Y, W, H);
    int W1 = H*4/5;
    if (damage()&(FL_DAMAGE_ALL|FL_DAMAGE_CHILD)) {
        input()->resize(X, Y, W-W1, H);
        input()->set_damage(FL_DAMAGE_ALL);
        input()->copy_style(style()); // force it to use this style
        input()->box(FL_FLAT_BOX);

        // fix for relative coordinates
        fl_push_matrix();
        fl_translate(X,Y);

        input()->draw();

        fl_pop_matrix();
        input()->set_damage(0);
    }
    if(damage()&(FL_DAMAGE_ALL|FL_DAMAGE_VALUE|FL_DAMAGE_HIGHLIGHT))
    {
        if(over_now) f.set(FL_HIGHLIGHT);
        X += W-W1;
        W = W1;
	button_box(FL_DIV_UP_BOX);
        // draw the little mark at the right:
        draw_glyph(FL_GLYPH_DOWN_BUTTON, X, Y, W, H, f);
        over_last = over_now;
    }
}
Exemple #2
0
void WidgetPDial::pdialcolor(int r, int g, int b)
{
    if(active_r())
        fl_color(r, g, b);
    else
        fl_color(160 - (160 - r) / 3, 160 - (160 - b) / 3, 160 - (160 - b) / 3);
}
void Flu_Spinner::draw()
{
  int W = w()*15/100;
  if( W < h()/2 )
    W = h()/2;
  int X = x()+w()-W, Y = y();

  // fltk 2.0 behavior
  bool refresh;
  if( step() >= 1.0 )
    {
      refresh = ( _input.type() != FL_INT_INPUT );
      _input.type( FL_INT_INPUT );
    }
  else
    {
      refresh = ( _input.type() != FL_FLOAT_INPUT );
      _input.type( FL_FLOAT_INPUT );
    }
  if( refresh )
    value_damage();

  // draw the up/down arrow buttons
  fl_draw_box( (Fl_Boxtype)_valbox[0], X, Y, W, h()/2, color() );
  fl_draw_box( (Fl_Boxtype)_valbox[1], X, Y+h()/2, W, h()/2, color() );
  fl_color( active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR) );
  fl_polygon( X+4, Y+h()/2-4, X+W/2, Y+4, X+W-4, Y+h()/2-4 );
  Y += h()/2;
  fl_polygon( X+4, Y+4, X+W/2, Y+h()/2-4, X+W-4, Y+4 );

  _input.resize( x(), y(), w()-h()/2-1, h() );
  _input.redraw();
}
Exemple #4
0
void Fl_Scrollbar::draw()
{
    if (damage()&FL_DAMAGE_ALL) draw_frame();

    int X=0; int Y=0; int W=w(); int H=h(); box()->inset(X,Y,W,H);
    int ix = X; int iy = Y; int iw = W; int ih = H;

    char pushed_ = this==Fl::pushed() ? which_pushed : NOTHING;
    char highlight_ = this==Fl::belowmouse() ? which_highlight : NOTHING;

    // 1 = left/top   2 = right/bottom   5 = slider button
    Fl_Flags f1 = 0, f2 = 0, f5 = 0;
    if (!active_r())
    {
        f1 = f2 = f5 = FL_INACTIVE;
    }
    else
    {
        if (pushed_ == UP_ARROW) f1 = FL_VALUE|FL_HIGHLIGHT;
        else if (highlight_ == UP_ARROW) f1 = FL_HIGHLIGHT;
        if (pushed_ == DOWN_ARROW) f2 = FL_VALUE|FL_HIGHLIGHT;
        else if (highlight_ == DOWN_ARROW) f2 = FL_HIGHLIGHT;
        if (pushed_ == SLIDER) f5 = FL_VALUE|FL_HIGHLIGHT;
        else if (highlight_ == SLIDER) f5 = FL_HIGHLIGHT;
    }

    if (vertical() && H >= 3*W)
    {
        if (damage()&FL_DAMAGE_ALL || last_ == UP_ARROW || highlight_ == UP_ARROW)
            draw_glyph(FL_GLYPH_UP_BUTTON, X, Y, W, W, f1);
        if (damage()&FL_DAMAGE_ALL || last_ ==DOWN_ARROW|| highlight_ ==DOWN_ARROW)
            draw_glyph(FL_GLYPH_DOWN_BUTTON, X, Y+H-W, W, W, f2);
        iy += W; ih -= 2*W;

    }                            // horizontal:
    else if (W >= 3*H)
    {
        if (damage()&FL_DAMAGE_ALL || last_ == UP_ARROW || highlight_ == UP_ARROW)
            draw_glyph(FL_GLYPH_LEFT_BUTTON, X, Y, H, H, f1);
        if (damage()&FL_DAMAGE_ALL || last_ ==DOWN_ARROW|| highlight_ ==DOWN_ARROW)
            draw_glyph(FL_GLYPH_RIGHT_BUTTON, X+W-H, Y, H, H, f2);
        ix += H; iw -= 2*H;
    }
    last_ = highlight_;

    if (Fl_Slider::draw(ix, iy, iw, ih, f5, false))
    {
        fl_color(color());
        fl_rectf(ix, iy, iw, ih);
        fl_pop_clip();
    }

}
//*****************************************************************************
// Vp_Value_Input_Spin::draw() -- Draw widget
void Vp_Value_Input_Spin::draw()
{
  int sxx = x(), syy = y(), sww = w(), shh = h();
  sxx += sww - buttonssize(); sww = buttonssize();
  Fl_Boxtype box1 = FL_BORDER_FRAME;
  //int border_size=Fl::box_dx(FL_BORDER_FRAME);
  int border_size=1;

  if (damage()&~FL_DAMAGE_CHILD) input.clear_damage(FL_DAMAGE_ALL);
  input.box(box());
  input.color(FL_WHITE, selection_color());
  Fl_Widget * draw_hack = &input;
  draw_hack->draw();
  input.clear_damage();
  sxx+=border_size;
  syy+=border_size;
  sww-=border_size*2;
  shh-=border_size*2;

  if (!box1) box1 = (Fl_Boxtype)(box()&-2);

  if((indrag || mouseobj) && deltadir!=0) {
     if(deltadir>0) {
       draw_box(down(box1),sxx,syy,sww,shh/2,color());
       draw_box(box1,sxx,syy+shh/2,sww,shh/2,color());
     } else {
       draw_box(box1,sxx,syy,sww,shh/2,color());
       draw_box(down(box1),sxx,syy+shh/2,sww,shh/2,color());
     }
  } else {
   draw_box(box1,sxx,syy,sww,shh/2,color());
   draw_box(box1,sxx,syy+shh/2,sww,shh/2,color());
  }
  sxx+=border_size;
  syy+=border_size;
  sww-=border_size*2;
  shh-=border_size*2;
  if (active_r()) {
        fl_color(labelcolor());
  } else {
        fl_color(labelcolor() | 8);
  }
  int w1 = (sww-1)|1; // use odd sizes only
  int X = sxx+w1/2;
  int W = w1/3;
  int h1 = shh/2-border_size-2;
  int Y= syy;
  fl_polygon(X, Y, X+W,Y+h1 , X-W, Y+h1);
  Y=syy+shh/2+border_size+1+h1;
  fl_polygon(X, Y, X-W, Y-h1, X+W, Y-h1);
  clear_damage();
}
void Flu_Combo_Box :: draw()
{
  int W = 18, H = h()-4;
  int X = x()+w()-W-2, Y = y()+2;

  fl_draw_box( box(), x(), y(), w(), h(), color() );

  // draw the arrow button
  fl_draw_box( (Fl_Boxtype)_valbox, X, Y, W, H, color() );
  fl_color( active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR) );
  fl_polygon( X+W/2-5, Y+H/2-2, X+W/2+3, Y+H/2-2, X+W/2-1, Y+H/2+2 );

  draw_child( input );
  if( Fl::focus() == this )
    draw_focus( FL_NO_BOX, input.x(), input.y(), input.w(), input.h() );
}
Exemple #7
0
int Flu_Button :: handle( int event )
{
  if( !active_r() )
    return Fl_Button::handle( event );

  switch( event )
    {
    case FL_MOVE:
      {
	checkLink();
	return 1;
      }
    case FL_ENTER:
      {
	if( active() )
	  {
	    Fl_Button::color( fl_lighter( col ) );
	    Fl_Button::selection_color( fl_lighter( sCol ) );
	  }
	checkLink();
	redraw();
	return 1;
      }
      break;
    case FL_LEAVE:
      {
	Fl_Button::color( col );
	Fl_Button::selection_color( sCol );
	checkLink();
	redraw();
	return 1;
	break;
      }
    }
  if( retBtn )
    {
      if( event == FL_SHORTCUT &&
	  (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter))
	{
	  do_callback();
	  return 1;
	}
    }
  return Fl_Button::handle( event );
}
Exemple #8
0
Fichier : Module.C Projet : 0mk/non
void
Module::draw_box ( int tx, int ty, int tw, int th )
{
    fl_color( fl_contrast( FL_FOREGROUND_COLOR, color() ) );

    fl_push_clip( tx, ty, tw, th );

    Fl_Color c = color();

    if ( ! active_r() )
        c = fl_inactive( c );

    int spacing = w() / instances();
    for ( int i = instances(); i--; )
    {
        fl_draw_box( box(), tx + (spacing * i), ty, tw / instances(), th, c );
    }


    if ( audio_input.size() && audio_output.size() )
    {
        /* maybe draw control indicators */
        if ( control_input.size() )
        {
            fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + 4, 5, 5, is_being_controlled() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );

            /* fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + th - 8, 5, 5, is_being_controlled_osc() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); */
        }

        if ( control_output.size() )
            fl_draw_box( FL_ROUNDED_BOX, tx + tw - 8, ty + 4, 5, 5, is_controlling() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );
    }

    fl_push_clip( tx + Fl::box_dx(box()), ty + Fl::box_dy(box()), tw - Fl::box_dw(box()), th - Fl::box_dh(box()) );

    Fl_Group::draw_children();

    fl_pop_clip();

    if ( focused_r( this ) )
        draw_focus_frame( tx,ty,tw,th, selection_color() );

    fl_pop_clip();
}
Exemple #9
0
void PanelMenu::draw()
{
    Fl_Boxtype box = up;
    Fl_Flags flags;
    Fl_Color color;

    if (!active_r()) {
        // Button is disabled
        flags = FL_INACTIVE;
        color = this->color();
    } else if (m_open) {
        // Menu is open, make the button pushed and highlighted
        flags = FL_HIGHLIGHT;
        color = highlight_color();
        if (!color) color = this->color();
        box = down;
    } else if (belowmouse()) {
        // Menu is not open, but button is below mouse - highlight
        flags = FL_HIGHLIGHT;
        color = highlight_color();
        if (!color) color = this->color();
    } else {
        // Plain
        flags = 0;
        color = this->color();
    }

    if(!box->fills_rectangle()) {
        fl_push_clip(0, 0, this->w(), this->h());
        parent()->draw_group_box();
        fl_pop_clip();
    }

    box->draw(0, 0, this->w(), this->h(), color, flags);

    int x,y,w,h;
    x = y = 0;
    w = this->w(); h = this->h();
    box->inset(x,y,w,h);
    draw_inside_label(x,y,w,h,flags);
}
Exemple #10
0
void Fl_Spin::draw() {

  int sxx = x(), syy = y(), sww = w(), shh = h(); 
  Fl_Boxtype box1 = (Fl_Boxtype)(box());
  int border_size=Fl::box_dx(box());

  if (damage()&~FL_DAMAGE_CHILD) clear_damage(FL_DAMAGE_ALL);

  if (!box1) box1 = (Fl_Boxtype)(box()&-2);

  if((indrag || mouseobj) && deltadir!=0) {
     if(deltadir>0) {
       draw_box(down(box1),sxx,syy,sww,shh/2,color());
       draw_box(box1,sxx,syy+shh/2,sww,shh/2,color());
     } else {
       draw_box(box1,sxx,syy,sww,shh/2,color());
       draw_box(down(box1),sxx,syy+shh/2,sww,shh/2,color());
     }
  } else {
   draw_box(box1,sxx,syy,sww,shh/2,color());
   draw_box(box1,sxx,syy+shh/2,sww,shh/2,color());
  }
  sxx+=border_size;
  syy+=border_size;
  sww-=border_size*2;  
  shh-=border_size*2;
  if (active_r()) {
        fl_color(selection_color());  
  } else {
        fl_color(selection_color() | 8);
  }    
  int w1 = (sww-1)|1; // use odd sizes only
  int X = sxx+w1/2;
  int W = w1/3;
  int h1 = shh/2-border_size-2;
  int Y= syy;
  fl_polygon(X, Y, X+W,Y+h1 , X-W, Y+h1);
  Y=syy+shh/2+border_size+1+h1; 
  fl_polygon(X, Y, X-W, Y-h1, X+W, Y-h1); 
  clear_damage();  
} 
Exemple #11
0
void MainMenu::draw()
{
    Fl_Boxtype box = this->box();
    Fl_Flags flags;
    Fl_Color color = this->color();
    Fl_Color lcolor = label_color();

    if (!active_r())
        flags = FL_INACTIVE;
    else if (m_open)
        flags = FL_VALUE;
    else
        flags = 0;

    if (belowmouse()) {
        flags = flags|FL_HIGHLIGHT;
        color = fl_lighter(color);
        lcolor = fl_lighter(label_color());
        if(!color) color = this->color();
        if(!lcolor) color = this->label_color();
    } 
    box->draw(0, 0, this->w(), this->h(), color, flags);

    int X=0, Y=0, W=w(), H=h();
    box->inset(X,Y,W,H);

    if(image()) {
        int imY = (h()/2)-(image()->height()/2);
        image()->draw(6, imY, image()->width(), image()->height(), flags);
        X+=image()->width()+6;
    } else {
        X += 4;
        W -= 4;
    }

    fl_font(label_font(), label_size());
    label_type()->draw(label(), X, Y, W-X, H, lcolor, flags|FL_ALIGN_LEFT);
}
int Flu_Spinner::handle(int event)
{
  int W = w()*15/100;
  if( W < h()/2 )
    W = h()/2;
  int X = x()+w()-W, Y = y();

  if( (align() & FL_ALIGN_INSIDE) || !_editable )
    {
      _input.readonly( true );
      _input.cursor_color( FL_WHITE );
    }
  else
    {
      _input.readonly( false );
      _input.cursor_color( FL_BLACK );
    }

  switch( event )
    {
    case FL_PUSH:
      _dragging = true;
      if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);
      _lastValue = value();
      _lastY = Fl::event_y();
      Fl::remove_timeout( repeat_callback, this );
      if( Fl::event_inside( X, Y, W, h()/2 ) ) // up button
	{
	  _pushed = true;
	  _valbox[0] = FL_DOWN_BOX;
	  _up = true;
	}
      if( Fl::event_inside( X, Y+h()/2, W, h()/2 ) ) // down button
	{
	  _pushed = true;
	  _valbox[1] = FL_DOWN_BOX;
	  _up = false;
	}
      if( _pushed )
	{
	  increment_cb();
	  _totalTime = _initialDelay;
	  if( _doRepeat )
	    Fl::add_timeout( _initialDelay, repeat_callback, this);
	  handle_push();
	  take_focus();
	  redraw();
	  return 1;
	}
      break;

    case FL_DRAG:
      {
	// only do the dragging if the last Y differs from the current Y by more than 3 pixels
	if( ABS(_lastY-Fl::event_y()) < 3 )
	  break;
	_dragging = true;
	_pushed = false;
	Fl::remove_timeout( repeat_callback, this );
	int oldWhen = when();
	_setvalue(increment(_lastValue,(_lastY-Fl::event_y())*(Fl::event_state(FL_SHIFT|FL_CTRL|FL_ALT)?10:1)));
	_valbox[0] = _valbox[1] = FL_DOWN_BOX;
	when( oldWhen );
	fl_cursor((Fl_Cursor)22);
	_input.redraw();
	redraw();
      }
      break;

    case FL_RELEASE:
      {
	bool doCB = ( ( when() & FL_WHEN_RELEASE ) || ( when() & FL_WHEN_RELEASE_ALWAYS ) ) &&
	  ( _pushed || ( _valbox[0] == FL_DOWN_BOX ^ _valbox[1] == FL_DOWN_BOX ) );
	_pushed = false;
	_dragging = false;
	Fl::remove_timeout( repeat_callback, this );
	_valbox[0] = _valbox[1] = FL_UP_BOX;
	fl_cursor(FL_CURSOR_DEFAULT);
	redraw();
	handle_release();
	if( doCB )
	  do_callback();
	_input.take_focus();
      }
      break;

    case FL_FOCUS:
    case FL_UNFOCUS:
      redraw();
      _input.take_focus();
      return 0;

    case FL_ENTER:
      if( Fl::event_inside( &_input ) )
	return _input.handle(event);
      else if( active_r() )
	{
	  fl_cursor(FL_CURSOR_DEFAULT);
	  return 1;
	}
      break;

    case FL_LEAVE:
      if( Fl::event_inside( &_input ) )
	return _input.handle(event);
      else if( active_r() )
	{
	  fl_cursor(FL_CURSOR_DEFAULT);
	  return 1;
	}
      break;

    case FL_KEYBOARD:
      switch( Fl::event_key() )
	{
	case FL_Down:
	  {
	    int oldWhen = when(); when( FL_WHEN_CHANGED );
	    _setvalue(increment(value(),-1*(Fl::event_state(FL_SHIFT|FL_CTRL|FL_ALT)?10:1)));
	    when( oldWhen );
	    redraw();
	    return 1;
	  }
	case FL_Up:
	  {
	    int oldWhen = when(); when( FL_WHEN_CHANGED );
	    _setvalue(increment(value(),1*(Fl::event_state(FL_SHIFT|FL_CTRL|FL_ALT)?10:1)));
	    when( oldWhen );
	    redraw();
	    return 1;
	  }
	}
      break;
    }

  return _input.handle(event);
}
Exemple #13
0
void Fl_Roller::draw()
{
    if (damage()&(FL_DAMAGE_ALL|FL_DAMAGE_HIGHLIGHT)) draw_box();
    int X=0; int Y=0; int W=w(); int H=h(); box()->inset(X,Y,W,H);
    if (W<=0 || H<=0) return;

    double s = step();
    if (!s) s = (maximum()-minimum())/100;
    int offset = int(value()/s);

    const double ARC = 1.5;      // 1/2 the number of radians visible
    const double delta = .2;     // radians per knurl
    if (type()==HORIZONTAL)
    {
        // draw shaded ends of wheel:
        int h1 = W/4+1;          // distance from end that shading starts
        fl_color(button_color()); fl_rectf(X+h1,Y,W-2*h1,H);
        for (int i=0; h1; i++)
        {
            fl_color((Fl_Color)(FL_GRAY-i-1));
            int h2 = FL_GRAY-i-1 > FL_DARK3 ? 2*h1/3+1 : 0;
            fl_rectf(X+h2,Y,h1-h2,H);
            fl_rectf(X+W-h1,Y,h1-h2,H);
            h1 = h2;
        }
        if (active_r())
        {
            // draw ridges:
            double junk;
            for (double y = -ARC+modf(offset*sin(ARC)/(W/2)/delta,&junk)*delta;;
                    y += delta)
            {
                int y1 = int((sin(y)/sin(ARC)+1)*W/2);
                if (y1 <= 0) continue; else if (y1 >= W-1) break;
                fl_color(FL_DARK3); fl_line(X+y1,Y+1,X+y1,Y+H-1);
                if (y < 0) y1--; else y1++;
                fl_color(FL_LIGHT1);fl_line(X+y1,Y+1,X+y1,Y+H-1);
            }
            // draw edges:
            h1 = W/8+1;          // distance from end the color inverts
            fl_color(FL_DARK2);
            fl_line(X+h1,Y+H-1,X+W-h1,Y+H-1);
            fl_color(FL_DARK3);
            fl_line(X,Y+H,X,Y);
            fl_line(X,Y,X+h1,Y);
            fl_line(X+W-h1,Y,X+W,Y);
            fl_color(FL_LIGHT2);
            fl_line(X+h1,Y,X+W-h1,Y);
            fl_line(X+W,Y,X+W,Y+H);
            fl_line(X+W,Y+H,X+W-h1,Y+H);
            fl_line(X+h1,Y+H,X,Y+H);
        }
    }                            // vertical one
    else
    {
        offset = (1-offset);
        // draw shaded ends of wheel:
        int h1 = H/4+1;          // distance from end that shading starts
        fl_color(button_color()); fl_rectf(X,Y+h1,W,H-2*h1);
        for (int i=0; h1; i++)
        {
            fl_color((Fl_Color)(FL_GRAY-i-1));
            int h2 = FL_GRAY-i-1 > FL_DARK3 ? 2*h1/3+1 : 0;
            fl_rectf(X,Y+h2,W,h1-h2);
            fl_rectf(X,Y+H-h1,W,h1-h2);
            h1 = h2;
        }
        if (active_r())
        {
            // draw ridges:
            double junk;
            for (double y = -ARC+modf(offset*sin(ARC)/(H/2)/delta,&junk)*delta;
                    ; y += delta)
            {
                int y1 = int((sin(y)/sin(ARC)+1)*H/2);
                if (y1 <= 0) continue; else if (y1 >= H-1) break;
                fl_color(FL_DARK3); fl_line(X+1,Y+y1,X+W-1,Y+y1);
                if (y < 0) y1--; else y1++;
                fl_color(FL_LIGHT1);fl_line(X+1,Y+y1,X+W-1,Y+y1);
            }
            // draw edges:
            h1 = H/8+1;          // distance from end the color inverts
            fl_color(FL_DARK2);
            fl_line(X+W-1,Y+h1,X+W-1,Y+H-h1);
            fl_color(FL_DARK3);
            fl_line(X+W,Y,X,Y);
            fl_line(X,Y,X,Y+h1);
            fl_line(X,Y+H-h1,X,Y+H);
            fl_color(FL_LIGHT2);
            fl_line(X,Y+h1,X,Y+H-h1);
            fl_line(X,Y+H,X+W,Y+H);
            fl_line(X+W,Y+H,X+W,Y+H-h1);
            fl_line(X+W,Y+h1,X+W,Y);
        }
    }
    if (focused())
    {
        focus_box()->draw(0,0,w(),h(), FL_BLACK, FL_INVISIBLE);
    }
}
Exemple #14
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);
    }
}
Exemple #15
0
void Fl_Slider::draw()
{
    // figure out the inner size of the box:
    Fl_Boxtype box = this->box();
    int ix = 0, iy = 0, iw = w(), ih = h();
    box->inset(ix,iy,iw,ih);

    // figure out where to draw the slider, leaving room for tick marks:
    int sx = ix, sy = iy, sw = iw, sh = ih;
    if (tick_size_ && (type()&TICK_BOTH))
    {
        if (horizontal())
        {
            sh -= tick_size_;
            switch (type()&TICK_BOTH)
            {
                case TICK_BOTH: sy += tick_size_/2; break;
                case TICK_ABOVE: sy += tick_size_; break;
            }
        }
        else
        {
            sw -= tick_size_;
            switch (type()&TICK_BOTH)
            {
                case TICK_BOTH: sx += tick_size_/2; break;
                case TICK_ABOVE: sx += tick_size_; break;
            }
        }
    }

    Fl_Flags flags = 0;
    if (!active_r())
    {
        flags.set(FL_INACTIVE);
    }
    else
    {
        if (Fl::pushed() == this) flags.set(FL_VALUE);
        if (belowmouse()) flags.set(FL_HIGHLIGHT);
    }

    if(!(fl_current_dev->capabilities() & Fl_Device::CAN_CLIPOUT)) {
        // draw the box or the visible parts of the window
        if (!box->fills_rectangle()) parent()->draw_group_box();
        box->draw(0, 0, w(), h(), color(), flags);
    }

    // minimal-update the slider, if it indicates the background needs
    // to be drawn, draw that. We draw the slot if the current box type
    // has no border:
    if (draw(sx, sy, sw, sh, flags, iy==0))
    {

        if(fl_current_dev->capabilities() & Fl_Device::CAN_CLIPOUT) {
            // draw the box or the visible parts of the window
            if (!box->fills_rectangle()) parent()->draw_group_box();
            box->draw(0, 0, w(), h(), color(), flags);
        }

        // draw the focus indicator inside the box:
        if (focused())
        {
            focus_box()->draw(ix+1, iy+1, iw-2, ih-2, label_color(), FL_INVISIBLE);
        }

        if (type() & TICK_BOTH)
        {
            if (horizontal())
            {
                switch (type()&TICK_BOTH)
                {
                    case TICK_ABOVE: ih = sy+sh/2-iy; break;
                    case TICK_BELOW: ih += iy; iy = sy+sh/2+(iy?0:3); ih -= iy; break;
                }
            }
            else
            {
                switch (type()&TICK_BOTH)
                {
                    case TICK_ABOVE: iw = sx+sw/2-ix; break;
                    case TICK_BELOW: iw += ix; ix = sx+sw/2+(iy?0:3); iw -= ix; break;
                }
            }
            Fl_Color color = text_color();
            if (!active_r()) color = fl_inactive(color);
            fl_color(color);
            draw_ticks(ix, iy, iw, ih, (slider_size_+1)/2);
        }

        fl_pop_clip();
    }
}
Exemple #16
0
Fichier : Module.C Projet : 0mk/non
void
Module::draw_label ( int tx, int ty, int tw, int th )
{
    bbox( tx, ty, tw, th );

    if ( ! label() )
        return;

    char *lab = strdup( label() );

    Fl_Color c = fl_contrast( FL_FOREGROUND_COLOR, color() );

    fl_color( active_r() && ! bypass() ? c : fl_inactive(c) );

    fl_font( FL_HELVETICA, labelsize() );

    char *di = strstr( lab, " -" );
    
    if ( ! di )
        di = strstr( lab, "  " );

    if ( di )
        *di = '\0';

    int LW = fl_width( lab );
    char *s = NULL;

    bool initial = true;
    if ( LW > tw )
    {
        s = new char[strlen(lab) + 1];
        char *sp = s;
        const char *lp = lab;

        for ( ; *lp; ++lp )
        {
            bool skip = false;

            switch ( *lp )
            {
                case ' ':
                    initial = true;
                    skip = false;
                    break;
                case 'i': case 'e': case 'o': case 'u': case 'a':
                    skip = ! initial;
                    initial = false;
                    break;
                default:
                    skip = false;
                    initial = false;
                    break;
            }
            
            if ( ! skip )
                *(sp++) = *lp;
        }
     
        *sp = '\0';
   
    }

    fl_draw( s ? s : lab, tx, ty, tw, th, align() | FL_ALIGN_CLIP );
    
    if ( bypass() )
    {
        fl_color( fl_color_add_alpha( fl_color(), 127 )  );
        fl_line_style( FL_SOLID, 2 );
        fl_line( tx, ty + th * 0.5, tx + tw, ty + th * 0.5 );
        fl_line_style( FL_SOLID, 0 );
    }


    free(lab);

    if ( s )
        delete[] s;
}
void EnvelopeFreeEdit::draw(void)
{
    int ox=x(),oy=y(),lx=w(),ly=h();
    //if (env->Pfreemode==0)
    //    env->converttofree();
    const int npoints=Penvpoints;

    if (active_r()) fl_color(FL_BLACK);
    else fl_color(90,90,90);
    if (!active_r()) currentpoint=-1;

    fl_rectf(ox,oy,lx,ly);

    //Margins
    ox+=5;oy+=5;lx-=10;ly-=10;

    //draw the lines
    fl_color(FL_GRAY);

    fl_line_style(FL_SOLID);
    fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);

    //draws the evelope points and lines
    Fl_Color alb=FL_WHITE;
    if (!active_r()) alb=fl_rgb_color(180,180,180);
    fl_color(alb);
    int oldxx=0,xx=0,oldyy=0,yy=getpointy(0);
    fl_rectf(ox-3,oy+yy-3,6,6);
    for (int i=1; i<npoints; ++i){
        oldxx=xx;oldyy=yy;
        xx=getpointx(i);yy=getpointy(i);
        if (i==currentpoint || (ctrldown && i==lastpoint))
            fl_color(FL_RED);
        else
            fl_color(alb);
        fl_line(ox+oldxx,oy+oldyy,ox+xx,oy+yy);
        fl_rectf(ox+xx-3,oy+yy-3,6,6);
    }

    //draw the last moved point point (if exists)
    if (lastpoint>=0){
        fl_color(FL_CYAN);
        fl_rectf(ox+getpointx(lastpoint)-5,oy+getpointy(lastpoint)-5,10,10);
    }

    //draw the sustain position
    if(Penvsustain>0){
        fl_color(FL_YELLOW);
        xx=getpointx(Penvsustain);
        fl_line(ox+xx,oy+0,ox+xx,oy+ly);
    }

    //Show the envelope duration and the current line duration
    fl_font(FL_HELVETICA|FL_BOLD,10);
    float time=0.0;
    if (currentpoint<=0 && (!ctrldown||lastpoint <= 0)){
        fl_color(alb);
        for(int i=1; i<npoints; ++i)
            time+=getdt(i);
    } else {
        fl_color(FL_RED);
        time=getdt(lastpoint);
    }
    char tmpstr[20];
    if (time<1000.0)
        snprintf((char *)&tmpstr,20,"%.1fms",time);
    else
        snprintf((char *)&tmpstr,20,"%.2fs",time/1000.0);
    fl_draw(tmpstr,ox+lx-20,oy+ly-10,20,10,FL_ALIGN_RIGHT,NULL,0);
    if (lastpoint>=0){
        snprintf((char *)&tmpstr,20,"%d", Penvval[lastpoint]);
        fl_draw(tmpstr,ox+lx-20,oy+ly-23,20,10,FL_ALIGN_RIGHT,NULL,0);
    }
}
Exemple #18
0
void
Fl_DialX::draw ( void )
{
    int X,Y,S;

    {
    int ox, oy, ww, hh, side;
    ox = x();
    oy = y();
    ww = w();
    hh = h();
    
    if (ww > hh)
    {
        side = hh;
        ox = ox + (ww - side) / 2;
    }
    else
    {
        side = ww;
        oy = oy + (hh - side) / 2;
    }
    side = w() > h() ? hh : ww;

    X = ox;
    Y = oy;
    S = side;
    }

    draw_box();
    draw_label();

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

    fl_draw_box( box(), X, Y, S, S, color() );
    
    /* shrink a bit */
    int OX = x();
    int OY = y();
    X += S / 8;
    Y += S / 8;
    int OS = S;
    S -= S / 4;
    
    fl_line_style( FL_SOLID, S / 12 );
        
    /* background arc */
    fl_color( fl_darker( color() ) );
    fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle2() );
        
    /* foreground arc */
    fl_color( selection_color() );
    fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle  );


    fl_line_style( FL_SOLID, 0 );
 
    if ( active_r() )
    {
        int W = OS;
        int H = OS;

        fl_push_matrix();
        fl_translate(OX+W/2, OY+H/2);
        fl_scale(W, H);
        fl_rotate(310+angle);
        fl_color( fl_color_add_alpha( FL_WHITE, 127 ));
        fl_begin_polygon(); fl_circle(-0.26, 0.26, 0.12); fl_end_polygon();
        fl_color( FL_WHITE );
        fl_begin_polygon(); fl_circle(-0.26, 0.26, 0.06); fl_end_polygon();
            
        fl_pop_matrix();
    }
    
    fl_color( fl_contrast( labelcolor(), color() ) );
 
    if ( Fl::belowmouse() == this )
    {
        char s[10];
    
        fl_font( FL_HELVETICA, 10 );
    
        snprintf( s, sizeof( s ), "%.1f", value() );

        fl_color( FL_FOREGROUND_COLOR );
        fl_draw( s, X, Y, S, S, FL_ALIGN_CENTER );
    }
}
Exemple #19
0
void myscroll::draw() {
	draw_box();

	int X = x()+Fl::box_dx(box());
	int Y = y()+Fl::box_dy(box());
	int W = w()-Fl::box_dw(box());
	int H = h()-Fl::box_dh(box());

	if (horizontal()) {
		if (W < 3*H) {Fl_Slider::draw(X,Y,W,H); return;}
		Fl_Slider::draw(X+H,Y,W-2*H,H);

		// Buttons
		draw_box(button1 ? fl_down(slider()) : slider(),
			 X, Y, H, H, selection_color());
		draw_box(button2 ? fl_down(slider()) : slider(),
			 X+W-H, Y, H, H, selection_color());
		if (active_r())
			fl_color(labelcolor());
		else
			fl_color(fl_inactive(labelcolor()));
		int w1 = (H-4)/3; if (w1 < 1) w1 = 1;
		int x1 = X+(H-w1-1)/2;
		int yy1 = Y+(H-2*w1-1)/2;
		if (Fl::scheme_ && !strcmp(Fl::scheme_, "gtk+")) {
			fl_polygon(x1, yy1+w1, x1+w1, yy1+2*w1, x1+w1-1, yy1+w1,
					x1+w1, yy1);
			x1 += (W-H);
			fl_polygon(x1, yy1, x1+1, yy1+w1, x1, yy1+2*w1, x1+w1,
					yy1+w1);
		} else {
			fl_polygon(x1, yy1+w1, x1+w1, yy1+2*w1, x1+w1, yy1);
			x1 += (W-H);
			fl_polygon(x1, yy1, x1, yy1+2*w1, x1+w1, yy1+w1);
		}
	} else { // vertical
		if (H < 3*W) {Fl_Slider::draw(X,Y,W,H); return;}
		Fl_Slider::draw(X,Y+W,W,H-2*W);

		// Buttons
		draw_box(button1 ? fl_down(slider()) : slider(),
			 X, Y, W, W, selection_color());
		draw_box(button2 ? fl_down(slider()) : slider(),
			 X, Y+H-W, W, W, selection_color());
		if (active_r())
			fl_color(labelcolor());
		else
			fl_color(fl_inactive(labelcolor()));
		int w1 = (W-4)/3; if (w1 < 1) w1 = 1;
		int x1 = X+(W-2*w1-1)/2;
		int yy1 = Y+(W-w1-1)/2;
		if (Fl::scheme_ && !strcmp(Fl::scheme_, "gtk+")) {
			fl_polygon(x1, yy1+w1, x1+w1, yy1+w1-1, x1+2*w1, yy1+w1, x1+w1,
					yy1);
			yy1 += H-W;
			fl_polygon(x1, yy1, x1+w1, yy1+1, x1+w1, yy1+w1);
			fl_polygon(x1+w1, yy1+1, x1+2*w1, yy1, x1+w1, yy1+w1);
		} else {
			fl_polygon(x1, yy1+w1, x1+2*w1, yy1+w1, x1+w1, yy1);
			yy1 += H-W;
			fl_polygon(x1, yy1, x1+w1, yy1+w1, x1+2*w1, yy1);
		}
	}
}
Exemple #20
0
// Anybody can call this to force the label to draw anywhere, this is
// used by Fl_Group and Fl_Tabs to draw outside labels:
void Fl_Widget::draw_label(int X, int Y, int W, int H, Fl_Flags flags) const
{
	fl_font(label_font(), float(label_size()));
	if (!active_r()) flags.set(FL_INACTIVE);

	Fl_Color color;
    // Figure out if alignment puts the label inside the widget:
	if (!(this->flags()&15) || (this->flags() & FL_ALIGN_INSIDE))
	{
        // yes, inside label is affected by selection or highlight:
		if (flags&FL_SELECTED)
			color = selection_text_color();
		else if (flags&FL_HIGHLIGHT && highlight_label_color())
		    color = highlight_label_color();
		else
			color = label_color();
		if (focused()) flags.set(FL_SELECTED);
	}
	else
	{
		color = label_color();
	}

	if (flags & FL_ALIGN_CLIP) fl_push_clip(X, Y, W, H);

	if (image_)
	{
		fl_color(fl_inactive(color, flags));

		if(flags & FL_ALIGN_TILED || flags & FL_ALIGN_SCALE) {
			image_->draw(X, Y, W, H, flags);
		} else {

			int w = W;
			int h = H;
			image_->measure(w, h);

            // If all the flags are off, draw the image and label centered "nicely"
            // by measuring their total size and centering that rectangle:
			if (!(flags & (FL_ALIGN_LEFT|FL_ALIGN_RIGHT|FL_ALIGN_TOP|FL_ALIGN_BOTTOM|
						FL_ALIGN_INSIDE)) && !label_.empty())
			{
				int d = (H-int(h+fl_height()))>>1;
				if (d >= 0)
				{
                    // put the image atop the text
                                    Y += d;
                                    H -= d;
                                    flags.set(FL_ALIGN_TOP);
				}
				else
				{
                    // put image to left
					int text_w = W; int text_h = H;
					fl_measure(label_.c_str(), text_w, text_h, flags);
					int d = (W-(h+text_w))>>1;
					if (d > 0) {X += d; W -= d;}
					flags.set(FL_ALIGN_LEFT);
				}
			}

			int cx,cy;               // point in image to put at X,Y

			if (flags & FL_ALIGN_RIGHT) {
				cx = w-W;
				if (flags & FL_ALIGN_LEFT && cx < 0) cx = 0;
			}
			else if (flags & FL_ALIGN_LEFT) cx = 0;
			else cx = w/2-W/2;

			if (flags & FL_ALIGN_BOTTOM) {
				cy = h-H;
				if (flags & FL_ALIGN_TOP && cy < 0) cy = 0;
			}
			else if (flags & FL_ALIGN_TOP) cy = 0;
			else cy = h/2-H/2;

			image_->draw(X-cx, Y-cy, W, H, 0,0,0,0,flags);

            // figure out the rectangle that remains for text:
			if (flags & FL_ALIGN_LEFT) { X += (w+2); W -= (w+4); }
			else if (flags & FL_ALIGN_RIGHT) W -= (w+4);
			else if (flags & FL_ALIGN_TOP) {Y += h; H -= h;}
			else if (flags & FL_ALIGN_BOTTOM) H -= h;
			else { /*flags |= FL_ALIGN_TOP;*/
				Y += (h-cy); H -= (h-cy);
			}
		}
	}
Exemple #21
0
// Draw button-like widgets with an optional glyph. The glyph is given
// a size (negative to put it on the right)
void Fl_Button::draw(int glyph, int glyph_width) const
{
    // Figure out the colors to use. The flags are used by the label and
    // glyph functions to figure out their colors:
    Fl_Flags flags;
    Fl_Color color;
    if (!active_r())
    {
        flags = FL_INACTIVE;
        color = this->color();
    }
    else if (belowmouse())
    {
        flags = FL_HIGHLIGHT;
        color = highlight_color();
        if (!color) color = this->color();
    }
    else
    {
        flags = 0;
        color = this->color();
    }
    Fl_Flags glyph_flags = flags;
    if (glyph_width)
    {
        if (this == held_down) flags.set(FL_VALUE);
        if (value()) glyph_flags.set(FL_VALUE);
    }
    else if (value())
    {
        flags.set(FL_VALUE);
        // Use the pushed-in color if the user has explicitly set it
        // on this widget:
        if (style()->selection_color)
        {
            color = style()->selection_color;
            flags.set(FL_SELECTED); // this makes label use selected_text_color()
        }
    }

    bool draw_label = true;
    int x = 0, y = 0, w = this->w(), h = this->h();

    if (box() == FL_NO_BOX)
    {
        // If the box is FL_NO_BOX we need to avoid drawing the label so
        // that it does not blink and does not draw multiple times (which
        // will make it look bold if antialiasing is on).
        /* if (!label()) {
          // don't do anything if no label, so buttons that are an image
          // only will redraw correctly and with minimum blinking.
                                       } else */
        if ((damage()&FL_DAMAGE_EXPOSE) ||
            (damage()&FL_DAMAGE_HIGHLIGHT) && !focused())
        {
            // erase the background behind where the label will draw:
            fl_push_clip(0, 0, w, h);
            parent()->draw_group_box();
            fl_pop_clip();
        }
        else
        {
            // Don't draw the label unnecessarily:
            draw_label = false;
        }
    }
    else
    {
        bool drawed = false;
        if(image() && !image()->get_mask()) {
            if((align()&FL_ALIGN_TILED || align()&FL_ALIGN_SCALE) &&
                ( !(align()&(FL_ALIGN_LEFT|FL_ALIGN_RIGHT|FL_ALIGN_TOP|FL_ALIGN_BOTTOM)) || (align()&FL_ALIGN_INSIDE) )
                ) {
                // We can draw only frame, if drawing image tiled or scale
                // And no mask defined to image...
                draw_frame();
                drawed = true;
            }
        }

        if(!drawed) {
            if (damage()&FL_DAMAGE_EXPOSE && !box()->fills_rectangle()) {
                fl_push_clip(0, 0, w, h);
                parent()->draw_group_box();
                fl_pop_clip();
            }
            // Draw the box:
            box()->draw(0, 0, w, h, color, flags);
        }

        box()->inset(x,y,w,h);
    }

    if (glyph_width < 0) {
        int g = -glyph_width;
        draw_glyph(glyph, x+w-g-3, y+((h-g)>>1), g, g, glyph_flags);
        if (draw_label) draw_inside_label(x, y, w-g-3, h, flags);
    }