Esempio n. 1
0
void Window::show(void) {
	image(Fl::scheme_bg_);

	if(Fl::scheme_bg_) {
		labeltype(FL_NORMAL_LABEL);
		align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
	} else {
		labeltype(FL_NO_LABEL);
	}

	Fl_Tooltip::exit(this);

	if(!shown()) {
		// Don't set background pixel for double-buffered windows...
		int background_pixel = -1;

		if(type() == FL_WINDOW && ((box() == 1) || ((box() & 2) && (box() <= 15)))) {
			background_pixel = int(fl_xpixel(color()));
		}

		window_xid_create(this, set_titlebar_icon, background_pixel);
	} else {
		XMapRaised(fl_display, fl_xid(this));
	}
}
Esempio n. 2
0
static void Blit1to1(BlitInfo *info)
{
    int width, height;
    uint8 *src, *map, *dst;
    int srcskip, dstskip;

    /* Set up some basic variables */
    width = info->d_width;
    height = info->d_height;
    src = info->s_pixels;
    srcskip = info->s_skip;
    dst = info->d_pixels;
    dstskip = info->d_skip;
    map = info->table;
    bool hw=info->hw_surface;

    while ( height-- ) {
        DUFFS_LOOP(
                   {
                       if(hw) *dst = fl_xpixel(map[*src]);
                       else *dst = map[*src];
                   }
                   dst++;
                   src++;
                   , width);
        src += srcskip;
        dst += dstskip;
    }
Esempio n. 3
0
void gl_color(Fl_Color i)
{
    #if USE_GL_OVERLAY
    #ifndef _WIN32
    if (fl_overlay) {glIndexi(int(fl_xpixel(i))); return;}
    #else
    if (fl_overlay && fl_overlay_depth)
    {
        i = fl_nearest_color(i); // convert to 8-bit color
        if (fl_overlay_depth < 8)
        {
            // only black & white produce the expected colors.  This could
            // be improved by fixing the colormap set in Fl_Gl_Overlay.cxx
            unsigned size = 1<<fl_overlay_depth;
            if (!i) glIndexi(size-2);
            else if (i >= size-2) glIndexi(size-1);
            else glIndexi(i);
        }
        else
        {
            glIndexi(i ? i : FL_GRAY_RAMP);
        }
        return;
    }
    #endif
    #endif
    Fl_Color c = fl_get_color(i);
    glColor3ub((uchar)(c>>24), (uchar)(c>>16), (uchar)(c>>8));
}
Esempio n. 4
0
static void figure_out_visual()
{
    beenhere = 1;
    if (!fl_visual->red_mask || !fl_visual->green_mask || !fl_visual->blue_mask)
    {
#if USE_COLORMAP
        fl_redmask = 0;
        // make sure black & white are allocated:
        fl_xpixel(FL_WHITE);
        fl_xpixel(FL_BLACK);
        return;
#else
        Fl::fatal("Requires TrueColor visual");
#endif
    }

    // get the bit masks into a more useful form:
    int i,j,m;

    for (i = 0, m = 1; m; i++, m<<=1) if (fl_visual->red_mask & m) break;
    for (j = i; m; j++, m<<=1) if (!(fl_visual->red_mask & m)) break;
    fl_redshift = j-8;
    fl_redbits = j-i; if (fl_redbits > 8) fl_redbits = 8;
    fl_redmask = 0xff << (8-fl_redbits);

    for (i = 0, m = 1; m; i++, m<<=1) if (fl_visual->green_mask & m) break;
    for (j = i; m; j++, m<<=1) if (!(fl_visual->green_mask & m)) break;
    fl_greenshift = j-8;
    fl_greenbits = j-i; if (fl_greenbits > 8) fl_greenbits = 8;
    fl_greenmask = 0xff << (8-fl_greenbits);

    for (i = 0, m = 1; m; i++, m<<=1) if (fl_visual->blue_mask & m) break;
    for (j = i; m; j++, m<<=1) if (!(fl_visual->blue_mask & m)) break;
    fl_blueshift = j-8;
    fl_bluebits = j-i; if (fl_bluebits > 8) fl_bluebits = 8;
    fl_bluemask = 0xff << (8-fl_bluebits);

    i = fl_redshift;
    if (fl_greenshift < i) i = fl_greenshift;
    if (fl_blueshift < i) i = fl_blueshift;
    if (i < 0) {
        fl_extrashift = -i;
        fl_redshift -= i; fl_greenshift -= i; fl_blueshift -= i;
    } else {
        fl_extrashift = 0;
    }
}
Esempio n. 5
0
int main(int argc, char **argv)
{
#if 0//ndef _WIN32
    int i = 1;
    if (Fl::args(argc,argv,i,arg) < argc) {
        fprintf(stderr," -v # : use visual\n%s\n",Fl::help);
        exit(1);
    }

    if (visid >= 0) {
        fl_open_display();
        XVisualInfo templt; int num;
        templt.visualid = visid;
        fl_visual = XGetVisualInfo(fl_display, VisualIDMask, &templt, &num);
        if (!fl_visual) {
            fprintf(stderr, "No visual with id %d, use one of:\n",visid);
            list_visuals();
            exit(1);
        }
        fl_colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen),
                                      fl_visual->visual, AllocNone);
        fl_xpixel(FL_BLACK); // make sure black is allocated in overlay visuals
    } else {
        Fl::visual(FL_RGB);
    }
#endif

    Fl_Renderer::system_init();
    //Fl_Double_Window window(300,300); ::w = &window;
    Fl_Window window(400,300); ::w = &window;
    char title[64];
    sprintf(title, "System byte order is '%s'", Fl_Renderer::big_endian()?"BIG-ENDIAN":"LIL-ENDIAN");
    window.label(title);

    Fl_Toggle_Button b(10,10,200,200,"Fl_Pixmap");
    //Fl_Box b(10,10,200,200,"Fl_Pixmap");
    //b.box(FL_ENGRAVED_BOX);
    ::b = &b;
    b.image(pixmap);
    b.tooltip("This Fl_Toggle_Button has:\n"
              "image() set to the Fl_Image class selected below.\n"
              "label() set to the name of that class.\n"
              "align() set to the flags selected below.\n"
              "Be sure to resize the window to see how it lays out");

#define BWIDTH 60
#define BHEIGHT 21

    Fl_Group controls(10, 300-3*BHEIGHT-20, 380, 3*BHEIGHT+10);
    controls.box(FL_ENGRAVED_BOX);

    Fl_Choice choice(5, 5, 110, BHEIGHT);
    choice.begin();
    Fl_Item i1("Fl_Bitmap");
    i1.callback(choice_cb, &bitmap);
    Fl_Item i2("Fl_Pixmap");
    i2.callback(choice_cb, &pixmap);
    Fl_Item i3("Fl_RGB_Image");
    i3.callback(choice_cb, &rgb_image);
    choice.end();
    choice.value(1); // set it to pixmap
    choice.tooltip("Subclass of Fl_Image to use");

    int y = 5+BHEIGHT;
    int x = 5;
    topb = new Fl_Check_Button(x, y, BWIDTH, BHEIGHT, "top"); x += BWIDTH;
    topb->callback(button_cb);
    topb->tooltip("FL_ALIGN_TOP");
    bottomb= new Fl_Check_Button(x, y, BWIDTH, BHEIGHT, "bottom");x += BWIDTH;
    bottomb->callback(button_cb);
    bottomb->tooltip("FL_ALIGN_BOTTOM");
    leftb = new Fl_Check_Button(x, y, BWIDTH, BHEIGHT, "left"); x += BWIDTH;
    leftb->callback(button_cb);
    leftb->tooltip("FL_ALIGN_LEFT");
    rightb = new Fl_Check_Button(x, y, BWIDTH, BHEIGHT, "right"); x += BWIDTH;
    rightb->callback(button_cb);
    rightb->tooltip("FL_ALIGN_RIGHT");
    scaleb = new Fl_Check_Button(x, y, BWIDTH, BHEIGHT, "scale"); x += BWIDTH;
    scaleb->callback(button_cb);
    scaleb->tooltip("FL_ALIGN_SCALE");
    y += BHEIGHT;
    x = 5;
    insideb= new Fl_Check_Button(x, y, BWIDTH, BHEIGHT, "inside");x += BWIDTH;
    insideb->callback(button_cb);
    insideb->tooltip("FL_ALIGN_INSIDE");
    clipb= new Fl_Check_Button(x, y, BWIDTH, BHEIGHT, "clip"); x += BWIDTH;
    clipb->callback(button_cb);
    clipb->tooltip("FL_ALIGN_CLIP");
    wrapb= new Fl_Check_Button(x, y, BWIDTH, BHEIGHT, "wrap"); x += BWIDTH;
    wrapb->callback(button_cb);
    wrapb->tooltip("FL_ALIGN_WRAP");
    tileb= new Fl_Check_Button(x, y, BWIDTH, BHEIGHT, "tile"); x += BWIDTH;
    tileb->callback(button_cb);
    tileb->tooltip("FL_ALIGN_TILED");

    controls.end();

/*    Fl_Box box(10,0,290,controls.y());
    box.hide();
    window.resizable(box);*/
    
    p2 = new Fl_Button(10,0,290,controls.y(),"Print to file");
    p2->callback(print,&controls);

    
    window.end();
    window.show(argc, argv);

    return Fl::run();
}