Exemplo n.º 1
0
static void
init_canvas( FL_OBJECT * ob )
{
    FLI_CANVAS_SPEC *sp = ob->spec;
    static int nc;      /* number of canvases */
    char name[ 32 ];

    if ( ! sp->window || ! fl_winisvalid( sp->window ) )
    {
        /* Find the real parent of the canvas */

        sp->parent = fl_get_real_object_window( ob );
        sp->window = None;

        if ( sp->parent == None )
        {
            M_err( "init_canvas", "Internal Error" );
            exit( 0 );
        }

        if ( sp->init && sp->init( ob ) < 0 )
        {
            M_err( "init_canvas", "Unable to initialize canvas %s", ob->label );
            return;
        }

        /* Create the window */

        sp->window = XCreateWindow( flx->display, sp->parent,
                                    ob->x, ob->y, ob->w, ob->h, 0,
                                    sp->depth, InputOutput,
                                    sp->visual, sp->mask, &sp->xswa );

        if ( sp->user_mask )
            XChangeWindowAttributes( flx->display, sp->window,
                                     sp->user_mask, &sp->user_xswa );

#if FL_DEBUG >= ML_ERR
        M_warn( "init_canvas", "Depth = %d colormap = 0x%lx, WinID = %ld",
                sp->depth, sp->colormap, sp->window );
#endif

        /* Take over event handling */

        fli_set_preemptive_callback( sp->window, canvas_event_intercept, ob );

        if ( sp->activate && sp->activate( ob ) < 0 )
        {
            M_err( "init_canvas", "Can't initialize canvas %s", ob->label );
            return;
        }

        /* Record the name of the window */
        
        if ( *ob->label )
            XStoreName( flx->display, sp->window, ob->label );
        else
        {
            sprintf( name, "flcanvas%d", nc++ );
            XStoreName( flx->display, sp->window, name );
        }

        BegWMColormap( sp );

        XMapWindow( flx->display, sp->window );

        /* Save size */

        sp->x = ob->x;
        sp->y = ob->y;
        sp->w = ob->w;
        sp->h = ob->h;
    }

    /* Check if moved or resized */

    if ( Moved( ob, sp ) || Resized( ob, sp ) )
    {
        M_warn( "init_canvas", "Canvas: WinMoved\n" );
        XMoveResizeWindow( flx->display, sp->window, ob->x, ob->y,
                           ob->w, ob->h );
    }

    sp->x = ob->x;
    sp->y = ob->y;
    sp->w = ob->w;
    sp->h = ob->h;

    if ( ob->col1 != FL_NoColor )
        XClearWindow( flx->display, sp->window );

    sp->dec_type = fli_boxtype2frametype( ob->boxtype );
    fl_draw_frame( sp->dec_type, ob->x, ob->y, ob->w, ob->h, ob->col2, ob->bw );
}
Exemplo n.º 2
0
void draw_frame(float c1, float c2, float c3, float c4, float c5)
{
  fl_draw_frame(c1, c2, c3, c4, c5);
}