Пример #1
0
void NeoWindow::CenterOnCoords( int x, int y ) { // Coords are coords of cell, not cell*scale
   int scale = neo->scale;
   int size = (int) neo->terrain_size;
   x *= scale; y *= scale;
   int w = (int) mainWin->mainCanvas->w;
   int h = (int) mainWin->mainCanvas->h;
   fl_set_scrollbar_value( mainWin->scroll_h, (double) ( x - w / 2 ) / ( size * scale ) );
   fl_set_scrollbar_value( mainWin->scroll_v, (double) ( y - h / 2 ) / ( size * scale ) );
   HandleScrollbars( NULL );
}
Пример #2
0
int
fl_set_formbrowser_xoffset( FL_OBJECT * ob,
                            int         offset )
{
    FLI_FORMBROWSER_SPEC *sp;
    int current;

    if ( ! IsFormBrowserClass( ob ) )
    {
        M_err( "fl_set_formbrowser_xoffset", "%s not a formbrowser",
               ob ? ob->label : "null" );
        return 0;
    }

    sp = ob->spec;
    current = sp->left_edge;

    if ( sp->max_width < sp->canvas->w )
        offset = 0;
    if ( offset < 0 )
        offset = 0;
    if ( offset > sp->max_width - sp->canvas->w )
        offset = sp->max_width - sp->canvas->w;

    sp->left_edge = offset;
    sp->old_hval = ( double ) sp->left_edge / ( sp->max_width - sp->canvas->w );
    fl_set_scrollbar_value( sp->hsl, sp->old_hval );

    return current;
}
Пример #3
0
FL_FORM *
fl_set_formbrowser_topform_bynumber( FL_OBJECT * ob,
                                     int         n )
{
    FLI_FORMBROWSER_SPEC *sp = ob->spec;
    FL_FORM *form = NULL;

    if ( n > 0 && n <= sp->nforms )
    {
        int h,
            f;

        sp->top_form = n - 1;
        sp->top_edge = 0;
        form = sp->form[ sp->top_form ];
        display_forms( sp );

        for ( h = f = 0; f < sp->top_form; f++ )
            h += sp->form[ f ]->h;

        sp->old_vval = ( double ) h / ( sp->max_height - sp->canvas->h );
        fl_set_scrollbar_value( sp->vsl, sp->old_vval );
    }

    return form;
}
Пример #4
0
int
fl_set_formbrowser_yoffset( FL_OBJECT * ob,
                            int         offset )
{
    FLI_FORMBROWSER_SPEC *sp;
    int current;
    int h,
        f;

    if ( ! IsFormBrowserClass( ob ) )
    {
        M_err( "fl_set_formbrowser_yoffset", "%s not a formbrowser",
               ob ? ob->label : "null" );
        return 0;
    }

    sp = ob->spec;
    current = fl_get_formbrowser_yoffset( ob );

    if ( sp->max_height < sp->canvas->h )
        offset = 0;
    if ( offset < 0 )
        offset = 0;
    if ( offset > sp->max_height - sp->canvas->h )
        offset = sp->max_height - sp->canvas->h;

    h = sp->max_height;
    for ( f = sp->nforms - 1; f >= 0 && offset < h; f-- )
        h -= sp->form[ f ]->h;

    sp->top_form = ++f;
    sp->top_edge = offset - h;

    sp->old_vval = ( double ) offset / ( sp->max_height - sp->canvas->h );
    fl_set_scrollbar_value( sp->vsl, sp->old_vval );

    return current;
}
Пример #5
0
FL_OBJECT *
fl_create_formbrowser( int          type,
                       FL_Coord     x,
                       FL_Coord     y,
                       FL_Coord     w,
                       FL_Coord     h,
                       const char * label )
{
    FL_OBJECT *ob;
    FLI_FORMBROWSER_SPEC *sp;
    int absbw, oldu = fl_get_coordunit( );
    int D;

    ob = fl_make_object( FL_FORMBROWSER, type, x, y, w, h, label,
                         handle_formbrowser );
    fl_set_coordunit( FL_COORD_PIXEL );
    ob->boxtype    = FL_FORMBROWSER_BOXTYPE;
    ob->align      = FL_FORMBROWSER_ALIGN;
    ob->col1       = FL_FORMBROWSER_COL1;
    ob->col2       = FL_BLACK;
    ob->set_return = set_formbrowser_return;
    ob->spec       = sp = fl_calloc( 1, sizeof *sp );

    absbw = FL_abs( ob->bw );

    sp->form   = NULL;
    sp->parent = ob;
    sp->scroll = FL_SMOOTH_SCROLL;
    sp->vw_def = sp->hh_def = D = fli_get_default_scrollbarsize( ob );
    sp->canvas = fl_create_canvas( FL_CANVAS,
                                   ob->x + absbw, ob->y + absbw,
                                   ob->w - 2 * absbw - sp->vw_def,
                                   ob->h - 2 * absbw - sp->hh_def,
                                   label );

    sp->canvas->u_vdata = sp;

    fl_modify_canvas_prop( sp->canvas, NULL, NULL, canvas_cleanup );

    fl_set_object_color( sp->canvas, ob->col1, ob->col2 );
    fl_set_object_bw( sp->canvas, ob->bw );

    fl_set_object_boxtype( sp->canvas,
                           fli_boxtype2frametype( ob->boxtype ) );
    fl_add_canvas_handler( sp->canvas, Expose, canvas_handler, NULL );

    sp->v_pref = sp->h_pref = FL_AUTO;

    sp->hsl = fl_create_scrollbar( FL_HOR_THIN_SCROLLBAR, ob->x,
                                   y + h - D, w - D, D, "" );
    fl_set_scrollbar_value( sp->hsl, sp->old_hval = 0.0 );
    fl_set_object_boxtype( sp->hsl, ob->boxtype );
    sp->hsl->visible = sp->h_pref == FL_ON;
    sp->hsl->resize = FL_RESIZE_X;
    fl_set_object_callback( sp->hsl, hcb, 0 );

    sp->vsl = fl_create_scrollbar( FL_VERT_THIN_SCROLLBAR,
                                   x + w - D, y, D, h - D, "" );
    fl_set_object_boxtype( sp->vsl, ob->boxtype );
    sp->vsl->visible = sp->v_pref == FL_ON;
    fl_set_scrollbar_value( sp->vsl, sp->old_hval = 0.0 );
    sp->vsl->resize = FL_RESIZE_Y;
    fl_set_object_callback( sp->vsl, vcb, 0 );

    fl_add_child( ob, sp->canvas );
    fl_add_child( ob, sp->hsl );
    fl_add_child( ob, sp->vsl );

    fl_set_coordunit( oldu );

    /* Set default return policy for the object */

    fl_set_object_return( ob, FL_RETURN_NONE );

    return ob;
}