예제 #1
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());
        }
    }
예제 #2
0
void bg_image_input(Fl_Input *w, void *d)
{
    changed=true;

    Fl_String val(w->value());
    filename = fl_file_expand(val);

    if(mini_wpaper) { delete mini_wpaper; mini_wpaper=0; }
    if(mini_image)  { delete mini_image; mini_image=0; }

    Fl_Image *im = Fl_Image::read(filename);
    if(im) {
        im->system_convert();
        float scalew = (float)mini_image_box->w()/(float)desktop->w();
        float scaleh = (float)mini_image_box->h()/(float)desktop->h();
        mini_image = im->scale(int(im->width()*scalew), int(im->height()*scaleh));
        delete im;
    }

    if(mini_image) {
        mini_wpaper = make_image(color, mini_image,
                                 mini_image_box->w(), mini_image_box->h(),
                                 mode, opacity);
        mini_image_box->image(mini_wpaper);
    } else {
        mini_image_box->image(0);
    }

    image_input->value(filename);
    image_input->redraw();
    mini_image_box->redraw();
}
예제 #3
0
void desktop_properties(Fl_Widget *, void *arg)
{
    if(!shown) {
        make_desktop_properties();
        shown = true;
    }

    mode = desktop->bg_mode;
    color = desktop->bg_color;
    opacity = desktop->bg_opacity;
    use = desktop->bg_use;
    filename = desktop->bg_filename;

    if(bg_prop_window->visible()) {
        bg_prop_window->show();
        return;
    }

    if(mini_image) { delete mini_image; mini_image=0;  }
    if(mini_wpaper){ delete mini_wpaper; mini_wpaper=0;}

    color_button->selection_color(color);
    mini_image_box->color(color);
    opacity_slider->value(opacity);
    mode_choice->value(mode);
    use_button->value(use);
    image_input->value(filename);

    if(!desktop->bg_filename.empty())
    {
        Fl_Image *im = Fl_Image::read(desktop->bg_filename);
        if(im) {
	    im->system_convert();
            float scalew = (float)mini_image_box->w()/(float)desktop->w();
            float scaleh = (float)mini_image_box->h()/(float)desktop->h();
            mini_image = im->scale(int(im->width()*scalew), int(im->height()*scaleh));
            delete im;
        }
    }

    if(mini_image) {
        mini_wpaper = make_image(color, mini_image,
                                 mini_image_box->w(), mini_image_box->h(),
                                 mode, opacity);
        mini_image_box->image(mini_wpaper);
    } else
        mini_image_box->image(0);

    if(use)
        bg_image_group->activate();
    else {
        bg_image_group->deactivate();
        mini_image_box->image(0);
    }

    bg_prop_window->show();
}
예제 #4
0
MovableIcon::MovableIcon(Icon *i)
: Fl_Window(desktop->x()+i->x(), desktop->y()+i->y(), i->w(), i->h())
{
    icon = i;
    set_override();
    create();

    Fl_Image *im = i->icon_im;
    if(im)
    {
        Pixmap mask = im->create_mask(im->width(), im->height());
        XShapeCombineMask(fl_display, fl_xid(this), ShapeBounding, 0, 0, mask, ShapeSet);

        align(FL_ALIGN_INSIDE);
        image(im);
    }
}
예제 #5
0
MovableIcon::MovableIcon(Icon* i) : Fl_Window(i->x(), i->y(), i->w(), i->h()), icon(i)
{
	assert(icon != NULL);
	set_override();
	create();

	Fl_Image* img = icon->icon_image();
	if(img)
	{
#ifdef SHAPE
		Pixmap mask = img->create_mask(img->width(), img->height());
		XShapeCombineMask(fl_display, fl_xid(this), ShapeBounding, 0, 0, mask, ShapeSet);
#endif
		align(FL_ALIGN_INSIDE);
		image(img);
	}
}
예제 #6
0
void bg_image_browse(Fl_Button *w, void *d)
{
    changed=true;
    fc_initial_preview = true;
    const char *f=fl_select_file(image_input->value(),
                                 _("All Files, *,"
                                   "Png Images, *.png,"
                                   "Xpm Images, *.xpm,"
                                   "Jpeg Images, *.{jpg|jpeg},"
                                   "Gif Images, *.gif,"
                                   "Bmp Images, *.bmp"),
                                 _("Choose wallpaper:")
                                );

    if(f) {
        if(mini_wpaper) { delete mini_wpaper; mini_wpaper=0; }
        if(mini_image)  { delete mini_image; mini_image=0; }

        filename = f;

        Fl_Image *im = Fl_Image::read(f);
        if(im) {
            im->system_convert();
            float scalew = (float)mini_image_box->w()/(float)desktop->w();
            float scaleh = (float)mini_image_box->h()/(float)desktop->h();
            mini_image = im->scale(int(im->width()*scalew), int(im->height()*scaleh));
            delete im;
        }

        if(mini_image) {
            mini_wpaper = make_image(color, mini_image,
                                     mini_image_box->w(), mini_image_box->h(),
                                     mode, opacity);
            mini_image_box->image(mini_wpaper);
        } else
            mini_image_box->image(0);

        image_input->value(filename);
        image_input->redraw();
        mini_image_box->redraw();
        delete []f;
    }
}
예제 #7
0
Fl_Image *make_ball(int radius)
{
    uint8  trans, alphamask;
    int    range, addition;
    int    xdist, ydist;
    uint16 x, y;
    uint16 skip;
    uint32 pixel;
    Fl_Image *light;

#ifdef GENERATE_16BIT
    uint16 *buf;
    /* Create a 16 (4/4/4/4) bpp square with a full 4-bit alpha channel */
    /* Note: this isn't any faster than a 32 bit alpha surface */
    alphamask = 0x0000000F;
    light = new Fl_Image(2*radius, 2*radius, 16, 0, true,
                         0x0000F000, 0x00000F00, 0x000000F0, alphamask);
#else
    uint32 *buf;
    /* Create a 32 (8/8/8/8) bpp square with a full 8-bit alpha channel */
    alphamask = 0x000000FF;
    light = new Fl_Image(2*radius, 2*radius, 32, 0, true,
                         0xFF000000, 0x00FF0000, 0x0000FF00, alphamask);
#endif

    /* Fill with a light yellow-orange color */
    skip = light->pitch()-(light->width()*light->format()->bytespp);
#ifdef GENERATE_16BIT
    buf = (uint16 *)light->data();
#else
    buf = (uint32 *)light->data();
#endif
    /* Get a tranparent pixel value - we'll add alpha later */
    pixel = light->format()->map_rgba(0xFF, 0xDD, 0x88, 0);
    for ( y=0; y<light->height(); ++y ) {
        for ( x=0; x<light->width(); ++x ) {
            *buf++ = pixel;
        }
        buf += skip;	/* Almost always 0, but just in case... */
    }

    /* Calculate alpha values for the surface. */
#ifdef GENERATE_16BIT
    buf = (uint16 *)light->data();
#else
    buf = (uint32 *)light->data();
#endif
    for ( y=0; y<light->height(); ++y ) {
        for ( x=0; x<light->width(); ++x ) {
            /* Slow distance formula (from center of light) */
            xdist = x-(light->width()/2);
            ydist = y-(light->height()/2);
            range = (int)sqrt(xdist*xdist+ydist*ydist);

            /* Scale distance to range of transparency (0-255) */
            if ( range > radius ) {
                trans = alphamask;
            } else {
                /* Increasing transparency with distance */
                trans = (uint8)((range*alphamask)/radius);

                /* Lights are very transparent */
                addition = (alphamask+1)/16;
                if ( (int)trans+addition > alphamask ) {
                    trans = alphamask;
                } else {
                    trans += addition;
                }
            }
            /* We set the alpha component as the right N bits */
            *buf++ |= (255-trans);
        }
        buf += skip;	/* Almost always 0, but just in case... */
    }

    return light;
}