Ejemplo n.º 1
0
void CairoBox::draw(void) 
  {
  // using fltk functions, set up white background with thin black frame
  fl_push_no_clip();            /* remove any clipping region set by the expose events... */
  fl_push_clip(x(), y(), w(), h());
  fl_color(FL_WHITE);
  fl_rectf(x(), y(), w(), h());
  fl_color(FL_BLACK);
  fl_rect(x(), y(), w(), h());

  // set up cairo structures
  surface = set_surface(w(), h());
  cr      = cairo_create(surface);
  /* All Cairo co-ordinates are shifted by 0.5 pixels to correct anti-aliasing */
  cairo_translate(cr, 0.5, 0.5);
  cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); // set drawing color to black
  cairo_new_path(cr);

  // virtual function defined in driver program
  graphic(cr, x(), y(), w(), h());

  // release the cairo context
  cairo_destroy(cr);
  cairo_surface_destroy(surface);
//  cr = NULL;

  // remove clip regions
  fl_pop_clip();                          // local clip region
  fl_pop_clip();                          // "no_clip" region
  }
Ejemplo n.º 2
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;
	}
}
Ejemplo n.º 3
0
void Fl_Tool_Bar::draw()
{
    int n;

    if(opened())
    {
        // make it not draw the inside label:
        int saved = flags(); align(FL_ALIGN_TOP);

        if(damage() & ~FL_DAMAGE_CHILD) {
            draw_frame();
            fl_push_clip(box()->dx(), box()->dy(), w()-box()->dw()-(m_menubut->visible()?20:0), h()-box()->dh());
            for (n = children(); n--;) draw_child(*child(n));
            draw_box();
            draw_inside_label();
            fl_pop_clip();

            if(m_menubut->visible()) {
                fl_push_clip(w()-box()->dw()-(m_menubut->visible()?20:0), box()->dy(), 30, h()-box()->dh());
                draw_child(*m_menubut);
                draw_box();
                fl_pop_clip();
            }

            for (n = 0; n < children(); n++) draw_outside_label(*child(n));
        } else {
            fl_push_clip(box()->dx(), box()->dy(), w()-box()->dw()-(m_menubut->visible()?20:0), h()-box()->dh());

            for(n = 0; n < children(); n++) {
                Fl_Widget& w = *child(n);
                if (w.damage() & FL_DAMAGE_CHILD_LABEL) {
                    draw_outside_label(w);
                    w.set_damage(w.damage() & ~FL_DAMAGE_CHILD_LABEL);
                }
                update_child(w);
            }

            fl_pop_clip();
        }

        flags(saved);

        if (damage() & (FL_DAMAGE_EXPOSE|FL_DAMAGE_HIGHLIGHT|FL_DAMAGE_ALL))
        {
            Fl_Flags f = 0;
            if (pushed) f.set(FL_VALUE);
            if (highlighted) f.set(FL_HIGHLIGHT);
            draw_glyph(0, 0, 0, glyph_size(), h(), f);
        }

    } else
        Fl_Bar::draw();
}
Ejemplo n.º 4
0
Archivo: ntk-perf.C Proyecto: 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();
        }
Ejemplo n.º 5
0
void Fl_MIDIKeyboard::draw(void) {                          // fltk draw() override
    Fl_Scroll::draw();

    fl_push_clip(x()+Fl::box_dx(box()), y()+Fl::box_dy(box()), w()-Fl::box_dw(box()), h()-Fl::box_dh(box()));
    int X = keyboard->x(), Y = keyboard->y();
    int press_diam = _b_width-2;
    int press_w_h_offs = _b_height + (_key_height - _b_height - press_diam) / 2;
    int press_w_w_offs = (int)((_key_width-press_diam) / 2);
    int press_b_h_offs = _b_height - press_diam - 2;
    uchar bk = is_black(_bottomkey) ? _bottomkey-1 : _bottomkey;    // need to begin with a white key

    fl_color(FL_BLACK);
    if (_type == MKB_HORIZONTAL) {
        int y_b_offs = Y + _b_height;
        for (int i = bk, cur_x = X + keyscoord[bk]; i <= _topkey; i++, cur_x = X + keyscoord[i]) {
            if (is_black(i)) {
                fl_rectf(cur_x, Y, _b_width, _b_height);
                if (pressed_keys[i]) {
                    fl_color(FL_RED);
                    fl_pie(cur_x, Y + press_b_h_offs, press_diam, press_diam, 0, 360);
                    fl_color(FL_BLACK);
                }
            }
            else {
                if (pressed_keys[i]) {
                    fl_color(FL_RED);
                    fl_pie(cur_x + press_w_w_offs, Y + press_w_h_offs, press_diam, press_diam, 0, 360);
                    fl_color(FL_BLACK);
                }
                isCF(i) ? fl_line(cur_x, Y, cur_x, Y + _key_height) :
                          fl_line(cur_x, y_b_offs, cur_x, Y + _key_height);

            }
        }
    }
    else {
        Y += keyboard->h();
        int x_b_offs = X + _b_height;
        for (int i = bk, cur_y = Y - keyscoord[bk]; i <= _topkey; i++, cur_y = Y - keyscoord[i]) {
            if (is_black(i)) {
                fl_rectf(X, cur_y - _b_width, _b_height, _b_width);
                if (pressed_keys[i]) {
                    fl_color(FL_RED);
                    fl_pie(X + press_b_h_offs, cur_y - press_diam,  press_diam, press_diam, 0, 360);
                    fl_color(FL_BLACK);
                }
            }
            else {
                if (pressed_keys[i]) {
                    fl_color(FL_RED);
                    fl_pie(X + press_w_h_offs, cur_y - press_w_w_offs - press_diam, press_diam, press_diam, 0, 360);
                    fl_color(FL_BLACK);
                }
                isCF(i) ? fl_line(X, cur_y, X + _key_height, cur_y) :
                          fl_line(x_b_offs, cur_y, X + _key_height, cur_y);
            }
        }
    }
    fl_pop_clip();
}
Ejemplo n.º 6
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();
}
Ejemplo n.º 7
0
void Flu_Wrap_Group :: draw()
{
  // we first try to fit all children assuming no scrollbar. if they do not all fit,
  // we have to turn the scrollbar on and try again
  if( layout( false, false ) )
    {
      scrollbar.show();
      layout( true, false );
    }
  else
    scrollbar.hide();

  // hack to look right when resizing smaller
  if( scrollbar.value() > scrollbar.maximum() )
    {
      ((Fl_Valuator*)&scrollbar)->value( scrollbar.maximum() );
      layout( scrollbar.visible(), scrollTo!=NULL );
    }
  else if( scrollTo )
    layout( scrollbar.visible(), true );

  scrollTo = NULL;

  if( damage() & ~FL_DAMAGE_CHILD)
    {
      draw_box();
      draw_label();
    }
  fl_push_clip( x()+Fl::box_dx(box()), y()+Fl::box_dy(box()),
		w()-Fl::box_dw(box()), h()-Fl::box_dh(box()) );
  draw_children();
  fl_pop_clip();
}
Ejemplo n.º 8
0
void PanelButton::draw()
{
    Fl_Boxtype box = up;
    Fl_Flags flags;
    Fl_Color color;

    if (belowmouse())
    {
        // Highlight button when below mouse
        flags = FL_HIGHLIGHT;
        color = highlight_color();
        if (!color) color = this->color();
//        box = down;
    } else {
        flags = 0;
        color = this->color();
    }
    
    if (value()) box=down; // Push down button when pressed

    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);
}
void Fl_ImageViewer::draw()
{
    fl_push_clip( x(), y(), w(), h() );
    Fl_Scroll::draw();

    if ( isdrawruler == true )
    {
        fl_color( FL_BLUE );
        fl_line_style( 0, 3, NULL );

        fl_line( coordclicked_x, coordclicked_y, coordmoving_x, coordmoving_y );
    }
    else
    if ( isdrawclickpointer == true )
    {
        fl_color( colorclicked );
        fl_line_style( 0, 1, NULL );

        fl_line( coordclicked_x , y() , coordclicked_x, coordclicked_y - 1 );
        fl_line( coordclicked_x, coordclicked_y + 1 , coordclicked_x, y() + h() );
        fl_line( x(), coordclicked_y, coordclicked_x - 1, coordclicked_y );
        fl_line( coordclicked_x + 1, coordclicked_y, x() + w(), coordclicked_y );
    }

    fl_pop_clip();
}
Ejemplo n.º 10
0
void Flcc_ValueBox::draw()
{
    int d = damage();
    int x1 = 0; int y1 = 0; int w1 = w(); int h1 = h();

    box()->inset(x1,y1,w1,h1);

    Fl_Color_Chooser* c = (Fl_Color_Chooser*)parent();
    c->hsv2rgb(c->hue(), c->saturation(), 1.0f, tr, tg, tb);

    if(d & FL_DAMAGE_ALL) {
        draw_frame();
        generate();     
    }

    if (d == FL_DAMAGE_VALUE) fl_push_clip(x1,y1+py,w1,6);
    bg->draw(x1,y1,w1,h1);
    if (d == FL_DAMAGE_VALUE) fl_pop_clip();

    int Y = int((1-c->v()) * (h1-6));
    if (Y < 0) Y = 0; else if (Y > h1-6) Y = h1-6;
    button_box()->draw(x1, y1+Y, w1, 6, color(), 0);

    py = Y;
}
Ejemplo n.º 11
0
void Flcc_HueBox::draw()
{
    if (damage() & FL_DAMAGE_ALL) {
        draw_frame();
    }

    int x1 = 0; int y1 = 0; int w1 = w(); int h1 = h();
    box()->inset(x1,y1,w1,h1);

    if (damage() == FL_DAMAGE_VALUE) fl_push_clip(x1+px,y1+py,BUTTON_SIZE,BUTTON_SIZE);
    if(bg) bg->draw(x1,y1,w1,h1);
    if (damage() == FL_DAMAGE_VALUE) fl_pop_clip();

    Fl_Color_Chooser* c = (Fl_Color_Chooser*)parent();

#ifdef CIRCLE
    int X = int(.5f*(cos(c->hue()*float(M_PI/3.0))*c->saturation()+1) * (w1-BUTTON_SIZE));
    int Y = int(.5f*(1-sin(c->hue()*float(M_PI/3.0))*c->saturation()) * (h1-BUTTON_SIZE));
#else
    int X = int(c->hue()/6.0f*(w1-BUTTON_SIZE));
    int Y = int((1-c->saturation())*(h1-BUTTON_SIZE));
#endif

    if (X < 0) X = 0; else if (X > w1-BUTTON_SIZE) X = w1-BUTTON_SIZE;
    if (Y < 0) Y = 0; else if (Y > h1-BUTTON_SIZE) Y = h1-BUTTON_SIZE;

    button_box()->draw(x1+X, y1+Y, BUTTON_SIZE, BUTTON_SIZE, button_color(), 0);
    px = X;
    py = Y;
}
Ejemplo n.º 12
0
void
Track::draw ( void )
{
    fl_push_clip( x(), y(), w(), h() );
    
    Fl_Color saved_color = color();

    if ( ! Track::colored_tracks )
        color( FL_GRAY );

    if ( _selected )
    {
        Fl_Color c = color();

        color( FL_RED );

        Fl_Group::draw();

        color( c );
    }
    else
        Fl_Group::draw();

    if ( ((Track_Header*)child(0))->input_connector_handle == receptive_to_drop )
    {
        Fl_Widget *o = ((Track_Header*)child(0))->input_connector_handle;
        fl_draw_box( FL_OVAL_BOX, o->x(), o->y(), o->w(), o->h(), fl_color_add_alpha( FL_GREEN, 127 ) );
    }

    if ( ! Track::colored_tracks )
        color( saved_color );

    fl_pop_clip();
}
Ejemplo n.º 13
0
void Flu_Choice_Group :: draw()
{
  int i;

  // make sure the selected child is still a child
  bool found = false;
  for( i = 1; i < children(); i++ )
    if( child(i) == selected )
      {
	found = true;
	break;
      }
  if( !found )
    selected = NULL;

  if( !selected && children() > 1 )
    value( child(1) );

  int lblW = 0, lblH = 0, X;

  for( i = 1; i < children(); i++ )
    {
      int W = 0, H;
      fl_measure( child(i)->label(), W, H );
      if( W > lblW )
	lblW = W;
      if( H > lblH )
	lblH = H;
    }

  lblW += 26;
  lblH += 6;

  // 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() );

  // clip and draw the children
  choice->resize( choice->x(), choice->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() );
  choice->resize( x()+X+2, y(), lblW, lblH );
  draw_child( *choice );
}
Ejemplo n.º 14
0
Archivo: Module.C Proyecto: 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();
}
Ejemplo n.º 15
0
    void draw() {
        if(!(damage()&FL_DAMAGE_ALL)) return;

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

        if(image()) {
            draw_frame();
            fl_push_clip(X,Y,W,H);

            Fl_Image *im = image();

            W=im->width();
            H=im->height();
            int pbw = w() - 10;
            int pbh = h() - 10;
            if(W > pbw || H > pbh) {
                W = pbw;
                H = W * im->height() / im->width();
                if(H > pbh) {
                    H = pbh;
                    W = H * im->width() / im->height();
                }
            }
            X=(w()/2)-W/2;
            Y=(h()/2)-H/2;
            if(X<5) X=5;
            if(Y<5) Y=5;

            im->mask_type(MASK_NONE);
            im->draw(X,Y,W,H,FL_ALIGN_SCALE);

            fl_clip_out(X,Y,W,H);

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

            fl_color(color());
            fl_rectf(X,Y,W,H);

            fl_pop_clip();

        } else {

            draw_box();

            if(w()<=120) label_size(8);
            if(w()>120) label_size(10);
            if(w()>180) label_size(12);
            if(w()>250) label_size(14);

            if(label()[0]=='?'&&label()[1]=='\0') label_size(100);

            draw_label(X, Y, W, H, align());
        }
    }
Ejemplo n.º 16
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();
}
Ejemplo n.º 17
0
void Ca_Canvas::draw(){

  uchar damage_= damage();
  // int _b=border_/2;
  // int _x=x()+_b;
  // int _y=y()+_b;
  // int _w=w()-2*_b;
  // int _h=h()-2*_b;
  int replot=0;

  Ca_Axis_ *axis = last_axis_;

  /// something similar will go in the future into the lauout layer...
  while (axis){
    replot |= axis->update();
    axis=axis->previous_axis_;
  }
  ///
  if(damage_!=CA_DAMAGE_ADD)
    draw_box();

  if((damage_!=CA_DAMAGE_ADD)||replot){
    last_plotted_=0;
    axis=last_axis_;
    while(axis){
      if(!(axis->grid_visible()&CA_FRONT)&&(axis->visible()||(axis->grid_visible()&CA_ALWAYS_VISIBLE)))
        axis->draw_grid();
      axis=axis->previous_axis_;
    }
  }

  fl_clip(x()+Fl::box_dx(box())+dx_, y()+Fl::box_dy(box())+border_+dy_, w()-Fl::box_dw(box()) - dw_, h()-Fl::box_dh(box()) - dh_);
  if (last_plotted_)
    last_plotted_=last_plotted_->next;
  else
    last_plotted_=first_object_;
  while(last_plotted_){
    last_plotted_->object->draw();
    last_plotted_=last_plotted_->next;
  }
  last_plotted_=last_object_;
  fl_pop_clip();

  axis=last_axis_;
  while(axis){
    if((axis->grid_visible()&CA_FRONT)&&(axis->visible()||(axis->grid_visible()&CA_ALWAYS_VISIBLE)))
      axis->draw_grid();
    axis=axis->previous_axis_;
  }


  if (damage_&FL_DAMAGE_ALL)
    draw_label();
};
Ejemplo n.º 18
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();
    }

}
Ejemplo n.º 19
0
void Flu_Collapsable_Group :: draw()
{
  int X;

  FluSimpleString l = open() ? "- " : "+ ";
  l += label();
  button.label( l.c_str() );

  // force fit the button if necessary
  if( _fit )
    button.size( w()-12, button.labelsize()+6 );
  else
    {
      // otherwise make it as big as its label
      int W = 0, H = 0;
      fl_font( button.labelfont(), button.labelsize() );
      fl_measure( button.label(), W, H );
      button.size( W+6, button.h() );
    }

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

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

  // clip and draw the internal group
  fl_clip( x()+2, y()+button.h()+1, w()-4, h()-button.h()-3 );
  if( _changing )
    {
      if( !_open )
	group.resize( x(), y()-_originalHeight+(int)_currentHeight+_BUTTON_HEIGHT, w(), _originalHeight );
      else
	group.resize( x(), y()-_newHeight+(int)_currentHeight+_BUTTON_HEIGHT, w(), _newHeight );
    }
  draw_child( group );
  fl_pop_clip();

  // clear behind the button, resize, and draw
  fl_color( color() );
  fl_rectf( x()+X, y(), button.w()+4, button.h() );
  button.position( x()+X+2, y() );
  draw_child( button );

  button.label( 0 );
}
Ejemplo n.º 20
0
//extern Fl_Ext * fl_ext;
void Fl_Gdi::draw(Fl_Widget * w)
{
    Fl_Device *t = fl_current_dev;
    fl_current_dev = this;
    Fl::flush(); // cleaning ...
    HDC o = fl_gc;
    fl_gc = gc_;
    SelectClipRgn(fl_gc, 0);
    fl_push_no_clip(); //i am not sure why, but it is required...
    w->redraw(); // making dirty
    w->draw();
    fl_pop_clip();
    fl_gc = o;
    fl_current_dev = t;
}
Ejemplo n.º 21
0
void Fl_Shaded_Box::draw(int x, int y, int w, int h,
                        Fl_Color color, Fl_Flags flags) const
{
    frame->draw(x,y,w,h,color, FL_INVISIBLE|flags);

    if(flags&FL_INVISIBLE) return;

    Fl_Boxtype box;
    if((frame==FL_HIGHLIGHT_BOX && flags&FL_HIGHLIGHT) //hack :)
       || frame!=FL_HIGHLIGHT_BOX)
        frame->inset(x,y,w,h);
    fl_push_clip(x,y,w,h);
    if(vertical) box = FL_VERT_SHADE_FLAT_BOX;
    else box = FL_HOR_SHADE_FLAT_BOX;
    box->draw(x,y,w,h,color,flags);
    fl_pop_clip();
}
Ejemplo n.º 22
0
 void draw() {
   fl_push_clip(0, 0, w(), h());
   fl_color(FL_DARK3);
   fl_rectf(0, 0, w(), h());
   fl_push_matrix();
   //    if (args[6]) {
     fl_translate(w()/2.0f, h()/2.0f);
     fl_rotate(args[6]);
     fl_translate(-w()/2.0f, -h()/2.0f);
     //}
   fl_arc(args[0],args[1],args[2],args[3],args[4],args[5]);
   fl_closepath();
   fl_arc(120,120,40,40,0,-360);
   fl_ellipse(20,20,args[2],args[3]); // hardware circle
   fl_color(FL_WHITE);
   fl_fill_stroke(FL_RED);
   fl_pop_matrix();
   fl_pop_clip();
 }
Ejemplo n.º 23
0
void
Module::draw_box ( void )
{
    fl_color( fl_contrast( FL_FOREGROUND_COLOR, color() ) );

    int tw, th, tx, ty;

    tw = w();
    th = h();
    ty = y();
    tx = x();

    fl_push_clip( tx, ty, tw, th );

    Fl_Color c = is_default() ? FL_BLACK : color();

    c = active() && ! bypass() ? c : fl_inactive( c );

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

    if ( this == Fl::focus() )
    {
        fl_draw_box( FL_UP_FRAME, x(), y(), w(), h(), selection_color() );
    }

    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 ) );
        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_Group::draw_children();

    fl_pop_clip();
}
Ejemplo n.º 24
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);
}
Ejemplo n.º 25
0
void TaskButton::draw(void) {
	Fl_Color col = value() ? selection_color() : color();
	draw_box(value() ? (down_box() ? down_box() : fl_down(box())) : box(), col);

	if(image()) {
		int X, Y, lw, lh;

		X = x() + 5;
		Y = (y() + h() / 2) - (image()->h() / 2);
		image()->draw(X, Y);

		X += image()->w() + 5;

		if(label()) {
			fl_font(labelfont(), labelsize());
			fl_color(labelcolor());

			lw = lh = 0;
			fl_measure(label(), lw, lh, 0);

			/* use clipping so long labels do not be drawn on the right border, which looks ugly */
			fl_push_clip(x() + Fl::box_dx(box()), 
						 y() + Fl::box_dy(box()), 
						 w() - Fl::box_dw(box()) - 5, 
						 h() - Fl::box_dh(box()));

			Y = (y() + h() / 2) - (lh / 2);
			fl_draw(label(), X, Y, lw, lh, align(), 0, 0);

			fl_pop_clip();
		}
	} else {
		draw_label();
	}

	if(Fl::focus() == this)
		draw_focus();
}
Ejemplo n.º 26
0
void
Chain::draw_connections ( Module *m )
{
    int spacing;
    int offset;

    int X, Y, W, H;

    ((Fl_Packscroller*)chain_tab->child( 0 ))->bbox( X, Y, W, H );

    fl_push_clip( X, Y, W, H );

    Fl_Color c = FL_FOREGROUND_COLOR;
    fl_color( c );

    if ( m->ninputs() )
    {
        spacing = w() / m->ninputs();
        offset = spacing / 2;

        for ( int i = m->ninputs(); i--; )
            fl_rectf( m->x() + offset + ( spacing * i ), m->y() - 3, 2, 3 );
    }

    fl_color( fl_darker( c ) );

    if ( m->noutputs() )
    {
        spacing = w() / m->noutputs();
        offset = spacing / 2;
        for ( int i = m->noutputs(); i--; )
            fl_rectf( m->x() + offset + ( spacing * i ), m->y() + m->h(), 2, 3 );
    }

    fl_pop_clip();
}
Ejemplo n.º 27
0
Archivo: Chain.C Proyecto: imv/non
void
Chain::draw_connections ( Module *m )
{
    int spacing;
    int offset;

    int X, Y, W, H;

    ((Fl_Packscroller*)chain_tab->child( 0 ))->bbox( X, Y, W, H );

    fl_push_clip( X, Y, W, H );

    Fl_Color c =fl_color_average( FL_WHITE, FL_YELLOW, 0.50 );
    fl_color( c );

    if ( m->ninputs() )
    {
        spacing = w() / m->ninputs();
        offset = spacing / 2;

        for ( int i = m->ninputs(); i--; )
            fl_rectf( m->x() + offset + ( spacing * i ), m->y() - 5, 2, 5 );
    }

    fl_color( fl_darker( c ) );

    if ( m->noutputs() )
    {
        spacing = w() / m->noutputs();
        offset = spacing / 2;
        for ( int i = m->noutputs(); i--; )
            fl_rectf( m->x() + offset + ( spacing * i ), m->y() + m->h(), 2, 5 );
    }

    fl_pop_clip();
}
Ejemplo n.º 28
0
void ItemTableView::draw_cell(TableContext context,
	int r, int c, int x, int y, int w, int h
) {
	static char s[(NAME_LENGTH+1)];
	memset(s, 0x00, (NAME_LENGTH+1)*sizeof(char));

	_ITEM_TABLE* item = NULL;

	switch(context) {
		case CONTEXT_STARTPAGE:
			fl_font(FL_HELVETICA, 16);
			return;
		case CONTEXT_COL_HEADER:
			switch(c) {
				case 0: strcpy(s, "Filename"); break;
				//case 0: strcpy(s, "Num");     break;
				//case 1: strcpy(s, "strName"); break;
			}

			fl_push_clip(x, y, w, h);
			{
				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_ROW_HEADER:
			sprintf(s, "%d", r+1);

			fl_push_clip(x, y, w, h);
			{
				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_CELL:
			switch(c) {
				case 0: sprintf(s, "%s", disp_files[r]); break;
			}
			/*
			item = ItemTableMap.GetData(r);
			switch(c) {
				case 0: sprintf(s, "  %d", item->m_iNum);  break;
				case 1: sprintf(s, "  %s", item->m_sName); break;
			}
			*/

			fl_push_clip(x, y, w, h);
			{
				fl_color(row_selected(r) ? selection_color() : cell_bgcolor);
				fl_rectf(x, y, w, h);
				fl_color(cell_fgcolor);
				fl_draw(s, x, y, w, h, FL_ALIGN_LEFT);
				fl_color(color());
				fl_rect(x, y, w, h);
			}
			fl_pop_clip();
			return;
		case CONTEXT_TABLE:
			printf("Table Context Called?\n");
			return;
		case CONTEXT_ENDPAGE:
		case CONTEXT_RC_RESIZE:
		case CONTEXT_NONE:
			return;
	}
}
Ejemplo n.º 29
0
/*
============================================================================
Our custom draw routine
============================================================================
*/
void VTTpddServerLog::draw(void)
{
	int				xMargin = 7;
	int				topEntry, lines, line, idx;
	int				dataIdx, x, count, tempRef = m_nextRef;
	int				wx, wy, dataStart, labelStart, dataX, labelX, asciiX;
	char			str[10];
	VTTpddLogEntry*	pEntry, rxEntry, txEntry;

	// Do default FLTK stuff
	Fl_Double_Window::draw();

	// Push a clipping rect
	fl_push_clip(m_pLog->x(), m_pLog->y(), m_pLog->w(), m_pLog->h());

	// Draw the log background
	fl_color(m_colors.background);
	fl_font(FL_COURIER, m_fontSize);
	fl_rectf(m_pLog->x(), m_pLog->y(), m_pLog->w(), m_pLog->h());

	// Calculate the number of lines that fit in the window
	lines = m_pLog->h() / m_height;
	wy = m_pLog->y();
	wx = m_pLog->x();

	// Get the top entry of the display
	topEntry = m_pScroll->value();

	// Create fake rx and tx entries
	rxEntry.m_ref = tempRef;
	if (m_rxCount > 0)
		tempRef++;
	rxEntry.m_pData = m_rxBuffer;
	rxEntry.m_rxTx = 0;
	rxEntry.m_count = m_rxCount;

	txEntry.m_ref = tempRef;
	txEntry.m_pData = m_txBuffer;
	txEntry.m_rxTx = 1;
	txEntry.m_count = m_txCount;

	// Precalculate x offsets
	labelStart = 6;
	dataStart = labelStart + 4;
	labelX = labelStart * m_width + wx + xMargin;
	dataX = dataStart * m_width + wx + xMargin;
	asciiX = dataX + (2 + m_bytesPerLine * 3) * m_width;

	// Loop for all lines that can be displayed
	line = 1;
	idx = 0;

	count = m_log.GetSize();
	while (line <= lines && topEntry + idx < count + 2)
	{
		// Get the next log item to be displayed
		if (topEntry + idx == count)
			pEntry = &rxEntry;
		else if (topEntry + idx == count+1)
			pEntry = &txEntry;
		else
			pEntry = (VTTpddLogEntry *) m_log[topEntry + idx];
		dataIdx = 0;

		// Draw RX or TX as per the entry
		if (pEntry->m_count > 0)
		{
			// Draw the reference number
			if (pEntry->m_ref != -1)
			{
				// Print the reference number
				fl_color(m_colors.ref);
				sprintf(str, "%4d:", pEntry->m_ref);
				fl_draw(str, wx + xMargin, wy + line * m_height);
			}

			// Draw either TX or RX
			if (pEntry->m_rxTx)
			{
				// It's a TX entry
				fl_color(m_colors.txLabel);
				fl_draw("TX:", labelX, wy + line * m_height);
				fl_color(m_colors.txHex);
			}
			else
			{
				// It's an RX entry
				fl_color(m_colors.rxLabel);
				fl_draw("RX:", labelX, wy + line * m_height);
				fl_color(m_colors.rxHex);
			}
		}

		// Loop for all data
		while (dataIdx < pEntry->m_count && line <= lines)
		{
			// Select the proper color
			if (pEntry->m_rxTx)
				fl_color(m_colors.txHex);
			else
				fl_color(m_colors.rxHex);

			// Draw bytesPerLine hex values on the current line
			int c = 0;
			for (x = dataIdx; x < pEntry->m_count && c < m_bytesPerLine; x++)
			{
				// Format the data  to draw the HEX data
				sprintf(str, "%02X", (unsigned char) pEntry->m_pData[x]);
				fl_draw(str, dataX + c++ * m_width*3, wy + line * m_height);
			}

			// Select the proper color
			if (pEntry->m_rxTx)
				fl_color(m_colors.txAscii);
			else
				fl_color(m_colors.rxAscii);

			// Draw bytesPerLine ASCII values
			c = 0;
			for (x = dataIdx; x < pEntry->m_count && c < m_bytesPerLine; x++)
			{
				// Format the data  to draw the HEX data
				if (pEntry->m_pData[x] >= ' ' && pEntry->m_pData[x] <= '~')
					sprintf(str, "%c", pEntry->m_pData[x]);
				else
					strcpy(str, ".");
				fl_draw(str, asciiX + c++ * m_width, wy + line * m_height);
			}

			// Increment to next dataIdx
			dataIdx = x;
			line++;
		}

		// Advance to next entry
		idx++;
	}

	// Pop the clipping rect
	fl_pop_clip();
}
Ejemplo n.º 30
0
void Fl_Rotated_Text::draw(int x, int y, int W, int H, int cx, int cy){
  
  if(!text_) return;
  if(!rot_){ // standard drawing)
    int olf_font = fl_font();
    int old_size = fl_size();
    fl_font(font_,size_);
    fl_push_clip(x, y, W-cx, H-cy);
    fl_draw(text_, x - cx, y - cy, w(), h(), (Fl_Align)align_, (Fl_Image *) 0, 0);
    fl_pop_clip();
    fl_font(olf_font, old_size);
    return;
  }
  if(!array){ // not drawn yet, building rotated bitmap "cache"
    int w_, h_;
    if(rot_ & 1){
      w_ = h();
      h_ = w();
    }else{
      w_ = w();
      h_ = h();
    }
    int bsize = ((w()+7)/8)  * h();
    array = ar2 = new uchar[bsize];
    alloc_array = 1;
    //memset(ar2, 0, bsize);

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

    Fl_Color old_color = fl_color();
    Fl_Offscreen offscreen = fl_create_offscreen(w_,h_);
    fl_begin_offscreen(offscreen);
    fl_color(0x000000);
    fl_rectf(0,0,w_,h_);
    fl_font(font_, size_);
    fl_color(0x00FF0000); // we use green color to plot to the offscreen

    fl_draw(text_,0, 0, w_, h_, (Fl_Align)align_, (Fl_Image *)0, 0);
    uchar * rgb = fl_read_image(0, 0, 0, w_, h_, 0);
    fl_end_offscreen();
    fl_delete_offscreen(offscreen);
    fl_font(old_font, old_size);
    fl_color(old_color);

    int i,j;

    uchar * start = rgb;
    int i_iter = 0;
    int j_iter = 0;
    switch(rot_){
    case 3:
      start +=  w_ * (h_ - 1)*3 + 1;
      i_iter = - w_ * 3;
      j_iter =  3;
      break;
    case 2:
      start +=  (w_ * h_ - 1)*3 + 1;
      i_iter = -3;
      j_iter = - w_ * 3;
      break;
    case 1:
      start +=  (w_ - 1)*3 + 1;
      i_iter = w_ * 3;
      j_iter = -3;
      break;
    }

    uchar * stj = start;
    uchar c;
    uchar * where;
    uchar * sti;

    for(j = 0; j< h(); j++, stj += j_iter){
      uchar val = 0;
      c = 8;
      where = ar2 + j*((w()+7)/8);
      for(i = 0, sti = stj; i< w(); i++, sti +=i_iter){
        if(*sti >127) val |= c;
        if(c & (uchar)128){ // pushing value to the array
          *where = val;
          where++;
          c =1;
          val = 0;
        }else
          c <<=1;
      }
      if(w() % 8){ //need to push last byte
        * where = val;
        where++;
      }
    }
    
    delete[] rgb;
  }

  Fl_Bitmap::draw(x, y, W, H, cx, cy); // finaly drawing the bitmap

};