Some problems with Wx::Grid

Recently I have been writing an app making some use of the Grid control,
and I have experienced some problems with it. After playing around with
the grid for a while I sometimes succeed to make the cells appear
outside of the window, as if the actual grid would be placed in the top
left corner of the screen, while it actually is in rather small window
in the center of th screen. I attach a screenshot for better clarity.
The occurance of the error is always accompanied by changing of the
cell “marker”/cursor from beeing thick black rectangle to beeing thin
grey rectangle, and can be provoked by inputing random data in the grid
and scrolling fast to the right by pressing down the left arrow key, and
repeting that couple of times. Im using Ruby 1.8.6 and WxRuby 1.9.5. I
know it may be hard to tell but if anyone sees any errors in my code I’d
be gratefull for pointing them out. Here is how the grid is made:

class ImageGrid < Grid
def initialize(parent, image)
@rows = 100;
@cols = 100
@img = image

    super(parent, -1)
    set_default_cell_alignment(ALIGN_CENTRE, ALIGN_CENTRE)

    # this event will actually come when text is entered in 1 cell
    evt_grid_range_select() do |e|
        # deselection gives whole table...
        top_row = e.get_top_row
        left_col = e.get_left_col
        bottom_row = e.get_bottom_row
        right_col = e.get_right_col
        # after cursor has left the cell... could be because of edit
        cur_row = get_grid_cursor_row
        cur_col = get_grid_cursor_col

        # input, not range selection
        if top_row == 0 and left_col == 0 and bottom_row == @rows-1

and right_col == @cols-1
# …
# range selection, not input
# …

    end # ...grid range select event
end # ...initialize

end # …class ImageGrid

Best regards,

Paul W Florczykowski

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs