Index: src_plugins/hid_lesstif/xm_tree_table_priv.c =================================================================== --- src_plugins/hid_lesstif/xm_tree_table_priv.c (revision 23002) +++ src_plugins/hid_lesstif/xm_tree_table_priv.c (revision 23003) @@ -119,13 +119,6 @@ XCopyArea(XtDisplay(w), pxinfo.pix, XtWindow(w), gc, 0, 0, pxinfo.width, pxinfo.height, px, y - pxinfo.height); } } -/* -Translate a position (POS) of a row/column on the virtual canvas of dimension (FILED_DIMENSION) -according to a scrollbar position (SCROLL_POS) that is provided in a range [SC_MIN, SC_MAX], -so that on increase of SCROLL_POS, the returned position decreases (V-scroll goes down, the "canvas" goes up). -*/ -#define SCROLL_TR(POS, FIELD_DIMENSION, SCROLL_POS, SC_MIN, SC_MAX) \ - (POS - ((FIELD_DIMENSION) * (SCROLL_POS - SC_MIN)/(SC_MAX - SC_MIN))) static void draw_ttwidget_header(Widget aw) { @@ -166,7 +159,7 @@ struct render_target_s *s = &(w->tree_table.render_attr); XRectangle clip = s->geom; - tt_entry_t *begin_entry = NULL; + tt_entry_t *entry = NULL; unsigned char b_with_header = 0; if (!tt->table) return; @@ -190,8 +183,8 @@ xm_clip_rectangle((Widget)w, clip); XFillRectangle(dsp, XtWindow(w), w->tree_table.gc_highlight, clip.x, clip.y, clip.width, clip.height); - begin_entry = (tt_entry_t *)gdl_first(tt->table); - if (!begin_entry) + entry = (tt_entry_t *)gdl_first(tt->table); + if (!entry) return; if (s->visible_items_vector && s->visible_items_capacity > 0) memset(s->visible_items_vector, 0x00, sizeof(item_desc_t) * s->visible_items_capacity); @@ -201,7 +194,6 @@ int y = 0; long hidden_shift = 0; long occupied_height = 0; - tt_entry_t *entry = begin_entry; item_desc_t* desc = NULL; tt_cb_draw_t *ddata = &(((XmTreeTableWidget)w)->tree_table.draw_event_data); ddata->user_data = tt->user_data; @@ -427,9 +419,7 @@ vsb->lo = 0; vsb->size = TTBL_MAX(1, s->geom.height * s->geom.height / tt->virtual_canvas_size.height); vsb->hi = s->geom.height + vsb->size; - vsb->incr = s->vertical_stride; - if (vsb->incr * s->geom.height < tt->virtual_canvas_size.height) - vsb->incr = TTBL_MIN(s->geom.height, tt->virtual_canvas_size.height / s->geom.height); + vsb->incr = 1; vsb->cur = TTBL_CLAMP(vsb->cur, vsb->lo, vsb->hi - vsb->size); vsb->prev = TTBL_CLAMP(vsb->prev, vsb->lo, vsb->hi - vsb->size); XtVaSetValues(vsb->sbar, XmNvalue, vsb->cur, XmNsliderSize, vsb->size, XmNpageIncrement, 1, XmNminimum, vsb->lo, XmNmaximum, vsb->hi, NULL); @@ -440,11 +430,7 @@ hsb->lo = 0; hsb->size = TTBL_MAX(1, s->geom.width * s->geom.width / tt->virtual_canvas_size.width); hsb->hi = s->geom.width + hsb->size; - - hsb->incr = tt->n_max_pixmap_height; - if (hsb->incr * s->geom.width < tt->virtual_canvas_size.width) - hsb->incr = TTBL_MIN(s->geom.width, tt->virtual_canvas_size.width / s->geom.width); - + hsb->incr = 1; hsb->cur = TTBL_CLAMP(hsb->cur, hsb->lo, hsb->hi - hsb->size); hsb->prev = TTBL_CLAMP(hsb->prev, hsb->lo, hsb->hi - hsb->hi); XtVaSetValues(hsb->sbar, XmNvalue, hsb->cur, XmNsliderSize, hsb->size, XmNpageIncrement, 1, XmNminimum, hsb->lo, XmNmaximum, hsb->hi, NULL); Index: src_plugins/hid_lesstif/xm_tree_table_priv.h =================================================================== --- src_plugins/hid_lesstif/xm_tree_table_priv.h (revision 23002) +++ src_plugins/hid_lesstif/xm_tree_table_priv.h (revision 23003) @@ -198,4 +198,13 @@ #define XtNleafPixmap "leafPixmap" #define XtNleafOpenPixmap "leafOpenPixmap" +/* +Translate a position (POS) of a row/column on the virtual canvas of dimension (FILED_DIMENSION) +according to a scrollbar position (SCROLL_POS) that is provided in a range [SC_MIN, SC_MAX], +so that on increase of SCROLL_POS, the returned position decreases (V-scroll goes down, the "canvas" goes up). +*/ +#define SCROLL_TR(POS, FIELD_DIMENSION, SCROLL_POS, SC_MIN, SC_MAX) \ + (POS - ((FIELD_DIMENSION) * (SCROLL_POS - SC_MIN)/(SC_MAX - SC_MIN))) + + #endif /* XM_TREE_TABLE_DRAW_ROUTINES_H */ Index: src_plugins/hid_lesstif/xm_tree_table_widget.c =================================================================== --- src_plugins/hid_lesstif/xm_tree_table_widget.c (revision 23002) +++ src_plugins/hid_lesstif/xm_tree_table_widget.c (revision 23003) @@ -550,17 +550,38 @@ int xm_tree_table_focus_row(Widget w, int row_index) { int ret = -1; - int rows_to_scroll = 0; - XM_TT_LOCKED_CODE(w, tw, tp, - struct render_target_s *s = &tp->render_attr; - int row_at_half_screen = xm_find_row_pointed_by_mouse(w, s->geom.y + s->geom.height / 2); - if (row_at_half_screen < 0) + XM_TT_LOCKED_CODE(w, tw, tt, + struct render_target_s *s = &tt->render_attr; + int idx = 0; + if (row_index < 0 || !tt->table) break; + /* check if it's already visible*/ + for(; idx < (int)s->len; ++idx) { - rows_to_scroll = row_at_half_screen - row_index; + item_desc_t* ds = s->visible_items_vector + idx; + if (ds->item && ds->item->row_index == row_index) + break; } + if (idx == row_index) { + ret = 0; + break;/* it's already visible*/ + } + else { + long occupied_height = 0; + tt_entry_t* et = (tt_entry_t *)gdl_first(tt->table); + tt->w_vert_sbar.cur = tt->w_vert_sbar.lo; + /* find the position */ + for(; et && et->row_index < row_index; et = (tt_entry_t *)gdl_next(tt->table, (void *)et)) { + tt->w_vert_sbar.cur += !et->flags.is_hidden; + } + /* rewind half of the screen back. */ + for(; et && occupied_height < s->geom.height / 2; et = (tt_entry_t *)gdl_prev(tt->table, (void *)et)) { + occupied_height += (!et->flags.is_hidden) * + (et->n_text_lines * s->vertical_stride + tt->n_grid_y_gap_pixels); + tt->w_vert_sbar.cur -= !et->flags.is_hidden; + } + } ) - (void)rows_to_scroll; return ret; }