Ejemplo n.º 1
0
int main(int argc, char **argv) {
  Fl_Window *window = new Fl_Window(400,350);

  int y = 10;
  input[0] = new Fl_Input(70,y,300,23,"Normal:"); y += 27;
  input[0]->tooltip("Normal input field");
  // input[0]->cursor_color(FL_SELECTION_COLOR);
  //  input[0]->maximum_size(20);
  // input[0]->static_value("this is a testgarbage");
  input[1] = new Fl_Float_Input(70,y,300,23,"Float:"); y += 27;
  input[1]->tooltip("Input field for floating-point number");
  input[2] = new Fl_Int_Input(70,y,300,23,"Int:"); y += 27;
  input[2]->tooltip("Input field for integer number");
  input[3] = new Fl_Secret_Input(70,y,300,23,"Secret:"); y += 27;
  input[3]->tooltip("Input field for password");
  input[4] = new Fl_Wordwrap_Input(70,y,300,100,"Wordwrap:"); y += 105;
  input[4]->tooltip("Input field for short text with newlines");

  for (int i = 0; i < 4; i++) {
    input[i]->when(0); input[i]->callback(cb);
  }
  int y1 = y;

  Fl_Button *b;
  b = new Fl_Toggle_Button(10,y,200,23,"FL_WHEN_&CHANGED");
  b->tooltip("Do callback each time the text changes");
  b->callback(toggle_cb, FL_WHEN_CHANGED); y += 23;
  b = new Fl_Toggle_Button(10,y,200,23,"FL_WHEN_&RELEASE");
  b->callback(toggle_cb, FL_WHEN_RELEASE); y += 23;
  b->tooltip("Do callback when widget loses focus");
  b = new Fl_Toggle_Button(10,y,200,23,"FL_WHEN_&ENTER_KEY");
  b->callback(toggle_cb, FL_WHEN_ENTER_KEY); y += 23;
  b->tooltip("Do callback when user hits Enter key");
  b = new Fl_Toggle_Button(10,y,200,23,"FL_WHEN_&NOT_CHANGED");
  b->callback(toggle_cb, FL_WHEN_NOT_CHANGED); y += 23;
  b->tooltip("Do callback even if the text is not changed");
  y += 5;
  b = new Fl_Button(10,y,200,23,"&print changed()");
  b->callback(button_cb);
  b->tooltip("Print widgets that have changed() flag set");

  b = new Fl_Button(220,y1,100,23,"color"); y1 += 23;
  b->color(input[0]->color()); b->callback(color_cb, (void*)0);
  b->label_color(fl_contrast(FL_BLACK,b->color()));
  b->tooltip("Color behind the text");
  b = new Fl_Button(220,y1,100,23,"selection_color"); y1 += 23;
  b->color(input[0]->selection_color()); b->callback(color_cb, (void*)1);
  b->label_color(fl_contrast(FL_BLACK,b->color()));
  b->tooltip("Color behind selected text");
  b = new Fl_Button(220,y1,100,23,"text_color"); y1 += 23;
  b->color(input[0]->text_color()); b->callback(color_cb, (void*)2);
  b->label_color(fl_contrast(FL_BLACK,b->color()));
  b->tooltip("Color of the text");

  window->resizable(window);
  window->end();
  window->show(argc,argv);
// CET - FIXME - crashes windows  Fl::lock();
  return Fl::run();
}
Ejemplo n.º 2
0
void color_cb(Fl_Widget* button, void* v) {
  Fl_Style& s = *Fl_Input::default_style;
  Fl_Color c;
  
  switch ((long)v) {
    case 0: c = s.color; break;
    case 1: c = s.selection_color; break;
    default: c = s.text_color; break;
  }
  c = fl_show_colormap(c);
  switch ((long)v) {
    case 0: s.color = c; break;
    case 1: s.selection_color = c; break;
    default: s.text_color = c; break;
  }
  s.selection_text_color = fl_contrast(s.text_color, s.selection_color);
  button->color(c);
  button->label_color(fl_contrast(FL_BLACK,(Fl_Color)c));
  Fl::redraw();
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
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.º 5
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.º 6
0
 FL_EXPORT_C(Fl_Color, fl_contrastC)(Fl_Color fg, Fl_Color bg) { return fl_contrast(fg,bg);}
Ejemplo n.º 7
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 );
    }
}
Ejemplo n.º 8
0
Archivo: Module.C Proyecto: 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;
}