wxRuby Documentation Home

Wx::Grid

Grid and its related classes are used for displaying and editing tabular data. They provide a rich set of features for display, editing, and interacting with a variety of data sources. For simple applications, and to help you get started, Grid is the only class you need to refer to directly. It will set up default instances of the other classes and manage them for you. For more complex applications you can derive your own classes for custom grid views, grid data tables, cell editors and renderers. The Grid classes overview has examples of simple and more complex applications, explains the relationship between the various grid classes and has a summary of the keyboard shortcuts and mouse functions provided by Grid.

Derived from

ScrolledWindow

Window

EvtHandler

Object

Window styles

There are presently no specific window styles for Grid.

Event handling

gridevt.inc

The event handler for the following functions takes a GridSizeEvent parameter. The …CMD... variants also take a window identifier.

evt_grid_col_size() { | event | ... } The user resized a column by dragging it. Processes a EVT_GRID_COL_SIZE.
evt_grid_row_size() { | event | ... } The user resized a row by dragging it. Processes a EVT_GRID_ROW_SIZE.
evt_grid_cmd_col_size() { | event | ... } The user resized a column by dragging it; variant taking a window identifier. Processes a EVT_GRID_COL_SIZE.
evt_grid_cmd_row_size() { | event | ... } The user resized a row by dragging it; variant taking a window identifier. Processes a EVT_GRID_ROW_SIZE.

The event handler for the following functions takes a GridRangeSelectEvent parameter. The …CMD... variant also takes a window identifier.

evt_grid_range_select() { | event | ... } The user selected a group of contiguous cells. Processes a EVT_GRID_RANGE_SELECT.
evt_grid_cmd_range_select(id) { | event | ... } The user selected a group of contiguous cells; variant taking a window identifier. Processes a EVT_GRID_RANGE_SELECT.

The event handler for the following functions takes a GridEditorCreatedEvent parameter. The …CMD... variant also takes a window identifier.

evt_grid_editor_created() { | event | ... } The editor for a cell was created. Processes a EVT_GRID_EDITOR_CREATED.
evt_grid_cmd_editor_created(id) { | event | ... } The editor for a cell was created; variant taking a window identifier. Processes a EVT_GRID_EDITOR_CREATED.

See also

Grid overview

Methods

Grid.new

Grid.new(Window parent,  Integer id, 
         Point pos = DEFAULT_POSITION, 
         Size size = DEFAULT_SIZE, 
         Integer style = WANTS_CHARS, 
         String name = PanelNameStr)

Constructor to create a grid object. Call either Grid#create_grid or Grid#set_table directly after this to initialize the grid before using it.

Grid#append_cols

Boolean append_cols(Integer numCols = 1,  Boolean updateLabels = true)

Appends one or more new columns to the right of the grid and returns true if successful. The updateLabels argument is not used at present.

If you are using a derived grid table class you will need to override GridTableBase#append_cols. See Grid#insert_cols for further information.

Grid#append_rows

Boolean append_rows(Integer numRows = 1,  Boolean updateLabels = true)

Appends one or more new rows to the bottom of the grid and returns true if successful. The updateLabels argument is not used at present.

If you are using a derived grid table class you will need to override GridTableBase#append_rows. See Grid#insert_rows for further information.

Grid#auto_size

auto_size()

Automatically sets the height and width of all rows and columns to fit their contents.

Note

Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.

Grid#auto_size_col_or_row

auto_size_col_or_row(Integer n,  Boolean setAsMin, 
                     Boolean column)

Common part of AutoSizeColumn/Row() or row?

Grid#auto_size_column

auto_size_column(Integer col,  Boolean setAsMin = true)

Automatically sizes the column to fit its contents. If setAsMin is true the calculated width will also be set as the minimal width for the column.

Note

Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.

Grid#auto_size_columns

auto_size_columns(Boolean setAsMin = true)

Automatically sizes all columns to fit their contents. If setAsMin is true the calculated widths will also be set as the minimal widths for the columns.

Note

Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.

Grid#auto_size_row

auto_size_row(Integer row,  Boolean setAsMin = true)

Automatically sizes the row to fit its contents. If setAsMin is true the calculated height will also be set as the minimal height for the row.

Note

Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.

Grid#auto_size_rows

auto_size_rows(Boolean setAsMin = true)

Automatically sizes all rows to fit their contents. If setAsMin is true the calculated heights will also be set as the minimal heights for the rows.

Note

Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.

Grid#begin_batch

begin_batch()

Increments the grid’s batch count. When the count is greater than zero repainting of the grid is suppressed. Each call to BeginBatch must be matched by a later call to Grid#end_batch. Code that does a lot of grid modification can be enclosed between BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will cause the grid to be repainted.

Grid#block_to_device_rect

Rect block_to_device_rect(Array topLeft, 
                                           Array bottomRight)

This function returns the rectangle that encloses the block of cells limited by TopLeft and BottomRight cell in device coords and clipped to the client size of the grid window.

The top-left and bottom-right positions should be passed in as two element arrays, each representing a row, col grid coordinate; for example:

block_to_device_rect( [1, 1], [4, 2] )

Grid#can_drag_col_move

Boolean can_drag_col_move()

Returns true if columns can be moved by dragging with the mouse. Columns can be moved by dragging on their labels.

Grid#can_drag_col_size

Boolean can_drag_col_size()

Returns true if columns can be resized by dragging with the mouse. Columns can be resized by dragging the edges of their labels. If grid line dragging is enabled they can also be resized by dragging the right edge of the column in the grid cell area (see Grid#enable_drag_grid_size).

Grid#can_drag_row_size

Boolean can_drag_row_size()

Returns true if rows can be resized by dragging with the mouse. Rows can be resized by dragging the edges of their labels. If grid line dragging is enabled they can also be resized by dragging the lower edge of the row in the grid cell area (see Grid#enable_drag_grid_size).

Grid#can_drag_grid_size

Boolean can_drag_grid_size()

Return true if the dragging of grid lines to resize rows and columns is enabled or false otherwise.

Grid#can_enable_cell_control

Boolean can_enable_cell_control()

Returns true if the in-place edit control for the current grid cell can be used and false otherwise (e.g. if the current cell is read-only).

Grid#can_have_attributes

Boolean can_have_attributes()

Do we have some place to store attributes in?

Grid#cell_to_rect

Rect cell_to_rect(Integer row,  Integer col)

Return the rectangle corresponding to the grid cell’s size and position in logical coordinates.

Grid#clear_grid

clear_grid()

Clears all data in the underlying grid table and repaints the grid. The table is not deleted by this function. If you are using a derived table class then you need to override GridTableBase#clear for this function to have any effect.

Grid#clear_selection

clear_selection()

Deselects all cells that are currently selected.

Grid#create_grid

Boolean create_grid(Integer numRows,  Integer numCols, 
                    Grid::GridSelectionModes selmode = Wx::Grid::GridSelectCells)

Creates a grid with the specified initial number of rows and columns. Call this directly after the grid constructor. When you use this function Grid will create and manage a simple table of string values for you. All of the grid data will be stored in memory.

For applications with more complex data types or relationships, or for dealing with very large datasets, you should derive your own grid table class and pass a table object to the grid with Grid#set_table.

Grid#delete_cols

Boolean delete_cols(Integer pos = 0,  Integer numCols = 1, 
                    Boolean updateLabels = true)

Deletes one or more columns from a grid starting at the specified position and returns true if successful. The updateLabels argument is not used at present.

If you are using a derived grid table class you will need to override GridTableBase#delete_cols. See Grid#insert_cols for further information.

Grid#delete_rows

Boolean delete_rows(Integer pos = 0,  Integer numRows = 1, 
                    Boolean updateLabels = true)

Deletes one or more rows from a grid starting at the specified position and returns true if successful. The updateLabels argument is not used at present.

If you are using a derived grid table class you will need to override GridTableBase#delete_rows. See Grid#insert_rows for further information.

Grid#disable_cell_edit_control

disable_cell_edit_control()

Disables in-place editing of grid cells. Equivalent to calling EnableCellEditControl(false).

Grid#disable_drag_col_move

disable_drag_col_move()

Disables column moving by dragging with the mouse. Equivalent to passing false to Grid#enable_drag_col_move.

Grid#disable_drag_col_size

disable_drag_col_size()

Disables column sizing by dragging with the mouse. Equivalent to passing false to Grid#enable_drag_col_size.

Grid#disable_drag_grid_size

disable_drag_grid_size()

Disable mouse dragging of grid lines to resize rows and columns. Equivalent to passing false to Grid#enable_drag_grid_size

Grid#disable_drag_row_size

disable_drag_row_size()

Disables row sizing by dragging with the mouse. Equivalent to passing false to Grid#enable_drag_row_size.

Grid#enable_cell_edit_control

enable_cell_edit_control(Boolean enable = true)

Enables or disables in-place editing of grid cell data. The grid will issue either a EVT_GRID_EDITOR_SHOWN or EVT_GRID_EDITOR_HIDDEN event.

Grid#enable_drag_col_size

enable_drag_col_size(Boolean enable = true)

Enables or disables column sizing by dragging with the mouse.

Grid#enable_drag_col_move

enable_drag_col_move(Boolean enable = true)

Enables or disables column moving by dragging with the mouse.

Grid#enable_drag_grid_size

enable_drag_grid_size(Boolean enable = true)

Enables or disables row and column resizing by dragging gridlines with the mouse.

Grid#enable_drag_row_size

enable_drag_row_size(Boolean enable = true)

Enables or disables row sizing by dragging with the mouse.

Grid#enable_editing

enable_editing(Boolean edit)

If the edit argument is false this function sets the whole grid as read-only. If the argument is true the grid is set to the default state where cells may be editable. In the default state you can set single grid cells and whole rows and columns to be editable or read-only via GridCellAttribute#set_read_only. For single cells you can also use the shortcut function Grid#set_read_only.

For more information about controlling grid cell attributes see the GridCellAttr cell attribute class and the Grid classes overview.

Grid#enable_grid_lines

enable_grid_lines(Boolean enable = true)

Turns the drawing of grid lines on or off.

Grid#end_batch

end_batch()

Decrements the grid’s batch count. When the count is greater than zero repainting of the grid is suppressed. Each previous call to Grid#begin_batch must be matched by a later call to EndBatch. Code that does a lot of grid modification can be enclosed between BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will cause the grid to be repainted.

Grid#fit

fit()

Overridden Window method.

Grid#force_refresh

force_refresh()

Causes immediate repainting of the grid. Use this instead of the usual Window::Refresh.

Grid#get_batch_count

Integer get_batch_count()

Returns the number of times that Grid#begin_batch has been called without (yet) matching calls to Grid#end_batch. While the grid’s batch count is greater than zero the display will not be updated.

Grid#get_cell_alignment

Array get_cell_alignment(Integer row,  Integer col)

Returns a two-element array containing constants for the horizontal and vertical alignment setting of the specified cell.

Horizontal alignment will be one of Wx::ALIGN_LEFT, Wx::ALIGN_CENTRE or Wx::ALIGN_RIGHT.

Vertical alignment will be one of Wx::ALIGN_TOP, Wx::ALIGN_CENTRE or Wx::ALIGN_BOTTOM.

Grid#get_cell_background_colour

Colour get_cell_background_colour(Integer row,  Integer col)

Returns the background colour of the cell at the specified location.

Grid#get_cell_editor

GridCellEditor get_cell_editor(Integer row, 
                                 Integer col)

Returns a pointer to the editor for the cell at the specified location.

See GridCellEditor and the Grid overview for more information about cell editors and renderers.

Grid#get_cell_font

Font get_cell_font(Integer row,  Integer col)

Returns the font for text in the grid cell at the specified location.

Grid#get_cell_renderer

GridCellRenderer get_cell_renderer(Integer row, 
                                     Integer col)

Returns the renderer for the grid cell at the specified location.

See GridCellRenderer and the Grid overview for more information about cell editors and renderers.

Grid#get_cell_text_colour

Colour get_cell_text_colour(Integer row,  Integer col)

Returns the text colour for the grid cell at the specified location.

Grid#get_cell_value

String get_cell_value(Integer row,  Integer col)

Returns the string contained in the cell at the specified location. For simple applications where a grid object automatically uses a default grid table of string values you use this function together with Grid#set_cell_value to access cell values.

For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values.

See GridTableBase#can_get_value_as and the Grid overview for more information.

Grid#get_col_at

Integer get_col_at(Integer colPos)

Returns the column ID of the specified column position.

Grid#get_col_left

Integer get_col_left(Integer col)

Grid#get_col_label_alignment

Array get_col_label_alignment()

Gets the current column label alignment values as a two-element array of constants for the horizontal and vertical alignment.

Horizontal alignment will be one of Wx::ALIGN_LEFT, Wx::ALIGN_CENTRE or Wx::ALIGN_RIGHT.

Vertical alignment will be one of Wx::ALIGN_TOP, Wx::ALIGN_CENTRE or Wx::ALIGN_BOTTOM.

Grid#get_col_label_size

Integer get_col_label_size()

Returns the current height of the column labels.

Grid#get_col_label_value

String get_col_label_value(Integer col)

Returns the specified column label. The default grid table class provides column labels of the form A,B…Z,AA,AB…ZZ,AAA… If you are using a custom grid table you can override GridTableBase#get_col_label_value to provide your own labels.

Grid#get_col_minimal_acceptable_width

Integer get_col_minimal_acceptable_width()

This returns the value of the lowest column width that can be handled correctly. See member set_col_minimal_acceptable_width for details.

Grid#get_col_minimal_width

Integer get_col_minimal_width(Integer col)

Get the minimal width of the given column/row.

Grid#get_col_pos

Integer get_col_pos(Integer colID)

Returns the position of the specified column.

Grid#get_col_right

Integer get_col_right(Integer col)

Grid#get_col_size

Integer get_col_size(Integer col)

Returns the width of the specified column.

Grid#get_default_cell_alignment

get_default_cell_alignment(Integer horiz,  Integer vert)

Sets the arguments to the current default horizontal and vertical text alignment values.

Horizontal alignment will be one of ALIGN_LEFT, ALIGN_CENTRE or ALIGN_RIGHT.

Vertical alignment will be one of ALIGN_TOP, ALIGN_CENTRE or ALIGN_BOTTOM.

Grid#get_default_cell_background_colour

Colour get_default_cell_background_colour()

Returns the current default background colour for grid cells.

Grid#get_default_cell_font

Font get_default_cell_font()

Returns the current default font for grid cell text.

Grid#get_default_cell_text_colour

Colour get_default_cell_text_colour()

Returns the current default colour for grid cell text.

Grid#get_default_col_label_size

Integer get_default_col_label_size()

Returns the default height for column labels.

Grid#get_default_col_size

Integer get_default_col_size()

Returns the current default width for grid columns.

Grid#get_default_editor

GridCellEditor get_default_editor()

Returns a pointer to the current default grid cell editor.

See GridCellEditor and the Grid overview for more information about cell editors and renderers.

Grid#get_default_editor_for_cell

GridCellEditor get_default_editor_for_cell(Integer row, 
                                             Integer col)

Grid#get_default_editor_for_type

GridCellEditor get_default_editor_for_type(String typeName)

Grid#get_default_renderer

GridCellRenderer get_default_renderer()

Returns a pointer to the current default grid cell renderer.

See GridCellRenderer and the Grid overview for more information about cell editors and renderers.

Grid#get_default_renderer_for_cell

GridCellRenderer get_default_renderer_for_cell(Integer row, 
                                                 Integer col)

Grid#get_default_renderer_for_type

GridCellRenderer get_default_renderer_for_type(String typeName)

Grid#get_default_row_label_size

Integer get_default_row_label_size()

Returns the default width for the row labels.

Grid#get_default_row_size

Integer get_default_row_size()

Returns the current default height for grid rows.

Grid#get_grid_cursor_col

Integer get_grid_cursor_col()

Returns the current grid cell column position.

Grid#get_grid_cursor_row

Integer get_grid_cursor_row()

Returns the current grid cell row position.

Grid#get_grid_line_colour

Colour get_grid_line_colour()

Returns the colour used for grid lines.

See also

get_default_grid_line_pen()()

Grid#get_default_grid_line_pen

Pen get_default_grid_line_pen()

Returns the pen used for grid lines. This virtual function may be overridden in derived classes in order to change the appearance of grid lines. Note that currently the pen width must be $1$.

See also

get_col_grid_line_pen()(),

get_row_grid_line_pen()()

Grid#get_row_grid_line_pen

Pen get_row_grid_line_pen(Integer row)

Returns the pen used for horizontal grid lines. This virtual function may be overridden in derived classes in order to change the appearance of individual grid line for the given row row.

Example:

\\

// in a grid displaying music notation, use a solid black pen between
// octaves (C0=row 127, C1=row 115 etc.)
Pen MidiGrid::GetRowGridLinePen(int row)
{
    if ( row          return Pen(BLACK, 1, SOLID);
    else 
       return GetDefaultGridLinePen();
}

Grid#get_col_grid_line_pen

Pen *get_col_grid_line_pen(Integer col)

Returns the pen used for vertical grid lines. This virtual function may be overridden in derived classes in order to change the appearance of individual grid lines for the given column col.

See get_row_grid_line_pen()() for an example.

Grid#grid_lines_enabled

Boolean grid_lines_enabled()

Returns true if drawing of grid lines is turned on, false otherwise.

Grid#get_label_background_colour

Colour get_label_background_colour()

Returns the colour used for the background of row and column labels.

Grid#get_label_font

Font get_label_font()

Returns the font used for row and column labels.

Grid#get_label_text_colour

Colour get_label_text_colour()

Returns the colour used for row and column label text.

Grid#get_number_cols

Integer get_number_cols()

Returns the total number of grid columns (actually the number of columns in the underlying grid table).

Grid#get_number_rows

Integer get_number_rows()

Returns the total number of grid rows (actually the number of rows in the underlying grid table).

Grid#get_or_create_cell_attr

GridCellAttr get_or_create_cell_attr(Integer row, 
                                       Integer col)

Grid#get_row_minimal_acceptable_height

Integer get_row_minimal_acceptable_height()

This returns the value of the lowest row width that can be handled correctly. See member set_row_minimal_acceptable_height for details.

Grid#get_row_minimal_height

Integer get_row_minimal_height(Integer col)

Grid#get_row_label_alignment

Array get_row_label_alignment()

Returns a two-element array containing constants for the horizontal and vertical alignment of row labels.

Horizontal alignment will be one of Wx::ALIGN_LEFT, Wx::ALIGN_CENTRE or Wx::ALIGN_RIGHT.

Vertical alignment will be one of Wx::ALIGN_TOP, Wx::ALIGN_CENTRE or Wx::ALIGN_BOTTOM.

Grid#get_row_label_size

Integer get_row_label_size()

Returns the current width of the row labels.

Grid#get_row_label_value

String get_row_label_value(Integer row)

Returns the specified row label. The default grid table class provides numeric row labels. If you are using a custom grid table you can override GridTableBase#get_row_label_value to provide your own labels.

Grid#get_row_size

Integer get_row_size(Integer row)

Returns the height of the specified row.

Grid#get_scroll_line_x

Integer get_scroll_line_x()

Returns the number of pixels per horizontal scroll increment. The default is 15.

See also

Grid#get_scroll_line_y, Grid#set_scroll_line_x, Grid#set_scroll_line_y

Grid#get_scroll_line_y

Integer get_scroll_line_y()

Returns the number of pixels per vertical scroll increment. The default is 15.

See also

Grid#get_scroll_line_x, Grid#set_scroll_line_x, Grid#set_scroll_line_y

Grid#get_selection_mode

Integer get_selection_mode()

Returns the current selection mode as a constant, see Grid#set_selection_mode.

Grid#get_selected_cells

Array get_selected_cells()

Returns an array of singly selected cells, each represented by a two-element array containing the row and column position.

Note that only cells selected singly in sequence (eg, by CTRL-clicking) will be returned; block selections will not be included. To find block selections, use get_selection_block_top_left and get_selection_block_bottom_right

Grid#get_selected_cols

Array get_selected_cols()

Returns an array of selected cols.

Grid#get_selected_rows

Array get_selected_rows()

Returns an array of selected rows.

Grid#get_selection_background

Colour get_selection_background()

Access or update the selection fore/back colours

Grid#get_selection_block_top_left

Array get_selection_block_top_left()

Returns an array of the top left corners of blocks of selected cells. The corner of each block is represented as a two-element array containing the row and column of the cell.

The corresponding bottom right corner of each block selection can be got by Grid#get_selection_block_bottom_right.

Note that both these methods return only block-selected cells, not singly-selected ones. To find singly-selected cells, use Grid#get_selected_Cells

Grid#get_selection_block_bottom_right

Array get_selection_block_bottom_right()

Returns an array of the bottom right corners of blocks of selected cells, see Grid#get_selection_block_top_left.

Grid#get_selection_foreground

Colour get_selection_foreground()

Grid#get_table

GridTableBase get_table()

Returns a base pointer to the current table object.

Grid#get_view_width

Integer get_view_width()

Returned number of whole cols visible.

Grid#hide_cell_edit_control

hide_cell_edit_control()

Hides the in-place cell edit control.

Grid#init_col_widths

init_col_widths()

Init the m_colWidths/Rights arrays

Grid#init_row_heights

init_row_heights()

NB: never access m_row/col arrays directly because they are created on demand, always use accessor functions instead!

Init the m_rowHeights/Bottoms arrays with default values.

Grid#insert_cols

Boolean insert_cols(Integer pos = 0,  Integer numCols = 1, 
                    Boolean updateLabels = true)

Inserts one or more new columns into a grid with the first new column at the specified position and returns true if successful. The updateLabels argument is not used at present.

The sequence of actions begins with the grid object requesting the underlying grid table to insert new columns. If this is successful the table notifies the grid and the grid updates the display. For a default grid (one where you have called Grid#create_grid) this process is automatic. If you are using a custom grid table (specified with Grid#set_table) then you must override GridTableBase#insert_cols in your derived table class.

Grid#insert_rows

Boolean insert_rows(Integer pos = 0,  Integer numRows = 1, 
                    Boolean updateLabels = true)

Inserts one or more new rows into a grid with the first new row at the specified position and returns true if successful. The updateLabels argument is not used at present.

The sequence of actions begins with the grid object requesting the underlying grid table to insert new rows. If this is successful the table notifies the grid and the grid updates the display. For a default grid (one where you have called Grid#create_grid) this process is automatic. If you are using a custom grid table (specified with Grid#set_table) then you must override GridTableBase#insert_rows in your derived table class.

Grid#is_cell_edit_control_enabled

Boolean is_cell_edit_control_enabled()

Returns true if the in-place edit control is currently enabled.

Grid#is_current_cell_read_only

Boolean is_current_cell_read_only()

Returns true if the current cell has been set to read-only (see Grid#set_read_only).

Grid#is_editable

Boolean is_editable()

Returns false if the whole grid has been set as read-only or true otherwise. See Grid#enable_editing for more information about controlling the editing status of grid cells.

Grid#is_in_selection

Boolean is_in_selection(Integer row,  Integer col)

Is this cell currently selected.

Grid#is_read_only

Boolean is_read_only(Integer row,  Integer col)

Returns true if the cell at the specified location can’t be edited. See also Grid#is_read_only.

Grid#is_selection

Boolean is_selection()

Returns true if there are currently rows, columns or blocks of cells selected.

Grid#is_visible

Boolean is_visible(Integer row,  Integer col, 
                   Boolean wholeCellVisible = true)

Returns true if a cell is either wholly visible (the default) or at least partially visible in the grid window.

Grid#make_cell_visible

make_cell_visible(Integer row,  Integer col)

Brings the specified cell into the visible grid cell area with minimal scrolling. Does nothing if the cell is already visible.

Grid#move_cursor_down

Boolean move_cursor_down(Boolean expandSelection)

Moves the grid cursor down by one row. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.

Keyboard

This function is called for Down cursor key presses or Shift+Down to expand a selection.

Grid#move_cursor_left

Boolean move_cursor_left(Boolean expandSelection)

Moves the grid cursor left by one column. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.

Keyboard

This function is called for Left cursor key presses or Shift+Left to expand a selection.

Grid#move_cursor_right

Boolean move_cursor_right(Boolean expandSelection)

Moves the grid cursor right by one column. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.

Keyboard

This function is called for Right cursor key presses or Shift+Right to expand a selection.

Grid#move_cursor_up

Boolean move_cursor_up(Boolean expandSelection)

Moves the grid cursor up by one row. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.

Keyboard

This function is called for Up cursor key presses or Shift+Up to expand a selection.

Grid#move_cursor_down_block

Boolean move_cursor_down_block(Boolean expandSelection)

Moves the grid cursor down in the current column such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.

Keyboard

This function is called for the Ctrl+Down key combination. Shift+Ctrl+Down expands a selection.

Grid#move_cursor_left_block

Boolean move_cursor_left_block(Boolean expandSelection)

Moves the grid cursor left in the current row such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.

Keyboard

This function is called for the Ctrl+Left key combination. Shift+Ctrl+left expands a selection.

Grid#move_cursor_right_block

Boolean move_cursor_right_block(Boolean expandSelection)

Moves the grid cursor right in the current row such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.

Keyboard

This function is called for the Ctrl+Right key combination. Shift+Ctrl+Right expands a selection.

Grid#move_cursor_up_block

Boolean move_cursor_up_block(Boolean expandSelection)

Moves the grid cursor up in the current column such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.

Keyboard

This function is called for the Ctrl+Up key combination. Shift+Ctrl+Up expands a selection.

Grid#move_page_down

Boolean move_page_down()

Moves the grid cursor down by some number of rows so that the previous bottom visible row becomes the top visible row.

Keyboard

This function is called for PgDn keypresses.

Grid#move_page_up

Boolean move_page_up()

Moves the grid cursor up by some number of rows so that the previous top visible row becomes the bottom visible row.

Keyboard

This function is called for PgUp keypresses.

Grid#register_data_type

register_data_type(String typeName,  GridCellRenderer renderer, 
                   GridCellEditor editor)

Methods for a registry for mapping data types to Renderers/Editors

Grid#save_edit_control_value

save_edit_control_value()

Sets the value of the current grid cell to the current in-place edit control value. This is called automatically when the grid cursor moves from the current cell to a new cell. It is also a good idea to call this function when closing a grid since any edits to the final cell location will not be saved otherwise.

Grid#select_all

select_all()

Selects all cells in the grid.

Grid#select_block

select_block(Integer topRow,  Integer leftCol, 
            Integer bottomRow, 
             Integer rightCol, 
             Boolean addToSelected = false)

Selects a rectangular block of cells. If addToSelected is false then any existing selection will be deselected; if true the column will be added to the existing selection.

Grid#select_col

select_col(Integer col,  Boolean addToSelected = false)

Selects the specified column. If addToSelected is false then any existing selection will be deselected; if true the column will be added to the existing selection.

Grid#selection_to_device_rect

Rect selection_to_device_rect()

This function returns the rectangle that encloses the selected cells in device coords and clipped to the client size of the grid window.

Grid#select_row

select_row(Integer row,  Boolean addToSelected = false)

Selects the specified row. If addToSelected is false then any existing selection will be deselected; if true the row will be added to the existing selection.

Grid#set_cell_alignment

set_cell_alignment(Integer row,  Integer col,  Integer horiz, 
                   Integer vert)
set_cell_alignment(Integer align,  Integer row,  Integer col)

Sets the horizontal and vertical alignment for grid cell text at the specified location.

Horizontal alignment should be one of ALIGN_LEFT, ALIGN_CENTRE or ALIGN_RIGHT.

Vertical alignment should be one of ALIGN_TOP, ALIGN_CENTRE or ALIGN_BOTTOM.

Grid#set_cell_background_colour

set_cell_background_colour(Integer row,  Integer col, 
                           Colour colour)

Grid#set_cell_editor

set_cell_editor(Integer row,  Integer col, 
                GridCellEditor editor)

Sets the editor for the grid cell at the specified location. The grid will take ownership of the pointer.

See GridCellEditor and the Grid overview for more information about cell editors and renderers.

Grid#set_cell_font

set_cell_font(Integer row,  Integer col,  Font font)

Sets the font for text in the grid cell at the specified location.

Grid#set_cell_renderer

set_cell_renderer(Integer row,  Integer col, 
                  GridCellRenderer renderer)

Sets the renderer for the grid cell at the specified location. The grid will take ownership of the pointer.

See GridCellRenderer and the Grid overview for more information about cell editors and renderers.

Grid#set_cell_text_colour

set_cell_text_colour(Integer row,  Integer col, 
                     Colour colour)
set_cell_text_colour(Colour colour)

Sets the text colour for the grid cell at the specified location.

Grid#set_cell_value

set_cell_value(Integer row,  Integer col,  String s)

Sets the string value for the cell at the specified location. For simple applications where a grid object automatically uses a default grid table of string values you use this function together with Grid#get_cell_value to access cell values.

For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values.

See GridTableBase#can_set_value_as and the Grid overview for more information.

Grid#set_col_attr

set_col_attr(Integer col,  GridCellAttr attr)

Sets the cell attributes for all cells in the specified column.

For more information about controlling grid cell attributes see the GridCellAttr cell attribute class and the Grid classes overview.

Grid#set_col_format_bool

set_col_format_bool(Integer col)

Sets the specified column to display boolean values. Grid displays boolean values with a checkbox.

Grid#set_col_format_number

set_col_format_number(Integer col)

Sets the specified column to display integer values.

Grid#set_col_format_float

set_col_format_float(Integer col,  Integer width = -1, 
                     Integer precision = -1)

Sets the specified column to display floating point values with the given width and precision.

Grid#set_col_format_custom

set_col_format_custom(Integer col,  String typeName)

Sets the specified column to display data in a custom format. See the Grid overview for more information on working with custom data types.

Grid#set_col_label_alignment

set_col_label_alignment(Integer horiz,  Integer vert)

Sets the horizontal and vertical alignment of column label text.

Horizontal alignment should be one of ALIGN_LEFT, ALIGN_CENTRE or ALIGN_RIGHT.

Vertical alignment should be one of ALIGN_TOP, ALIGN_CENTRE or ALIGN_BOTTOM.

Grid#set_col_label_size

set_col_label_size(Integer height)

Sets the height of the column labels.

Grid#set_col_label_value

set_col_label_value(Integer col,  String value)

Set the value for the given column label. If you are using a derived grid table you must override GridTableBase#set_col_label_value for this to have any effect.

Grid#set_col_minimal_width

set_col_minimal_width(Integer col,  Integer width)

Sets the minimal width for the specified column. This should normally be called when creating the grid because it will not resize a column that is already narrower than the minimal width. The width argument must be higher than the minimimal acceptable column width, see Grid#get_col_minimal_acceptable_width.

Grid#set_col_minimal_acceptable_width

set_col_minimal_acceptable_width(Integer width)

This modifies the minimum column width that can be handled correctly. Specifying a low value here allows smaller grid cells to be dealt with correctly. Specifying a value here which is much smaller than the actual minimum size will incur a performance penalty in the functions which perform grid cell index lookup on the basis of screen coordinates. This should normally be called when creating the grid because it will not resize existing columns with sizes smaller than the value specified here.

Grid#set_col_pos

set_col_pos(Integer colID,  Integer newPos)

Sets the position of the specified column.

Grid#set_col_size

set_col_size(Integer col,  Integer width)

Sets the width of the specified column.

This function does not refresh the grid. If you are calling it outside of a BeginBatch / EndBatch block you can use Grid#force_refresh to see the changes.

Automatically sizes the column to fit its contents. If setAsMin is true the calculated width will also be set as the minimal width for the column.

Note

Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.

Grid#set_default_cell_alignment

set_default_cell_alignment(Integer horiz,  Integer vert)

Sets the default horizontal and vertical alignment for grid cell text.

Horizontal alignment should be one of ALIGN_LEFT, ALIGN_CENTRE or ALIGN_RIGHT.

Vertical alignment should be one of ALIGN_TOP, ALIGN_CENTRE or ALIGN_BOTTOM.

Grid#set_default_cell_background_colour

set_default_cell_background_colour(Colour colour)

Sets the default background colour for grid cells.

Grid#set_default_cell_font

set_default_cell_font(Font font)

Sets the default font to be used for grid cell text.

Grid#set_default_cell_text_colour

set_default_cell_text_colour(Colour colour)

Sets the current default colour for grid cell text.

Grid#set_default_editor

set_default_editor(GridCellEditor editor)

Sets the default editor for grid cells. The grid will take ownership of the pointer.

See GridCellEditor and the Grid overview for more information about cell editors and renderers.

Grid#set_default_renderer

set_default_renderer(GridCellRenderer renderer)

Sets the default renderer for grid cells. The grid will take ownership of the pointer.

See GridCellRenderer and the Grid overview for more information about cell editors and renderers.

Grid#set_default_col_size

set_default_col_size(Integer width,  Boolean resizeExistingCols = false)

Sets the default width for columns in the grid. This will only affect columns subsequently added to the grid unless resizeExistingCols is true.

Grid#set_default_row_size

set_default_row_size(Integer height,  Boolean resizeExistingRows = false)

Sets the default height for rows in the grid. This will only affect rows subsequently added to the grid unless resizeExistingRows is true.

Grid#set_grid_cursor

set_grid_cursor(Integer row,  Integer col)

Set the grid cursor to the specified cell. This function calls Grid#make_cell_visible.

Grid#set_grid_line_colour

set_grid_line_colour(Colour colour)

Sets the colour used to draw grid lines.

Grid#set_label_background_colour

set_label_background_colour(Colour colour)

Sets the background colour for row and column labels.

Grid#set_label_font

set_label_font(Font font)

Sets the font for row and column labels.

Grid#set_label_text_colour

set_label_text_colour(Colour colour)

Sets the colour for row and column label text.

Grid#set_margins

set_margins(Integer extraWidth,  Integer extraHeight)

A grid may occupy more space than needed for its rows/columns. This function allows to set how big this extra space is

Grid#set_or_calc_column_sizes

Integer set_or_calc_column_sizes(Boolean calcOnly, 
                                 Boolean setAsMin = true)

Common part of AutoSizeColumn/Row() and GetBestSize()

Grid#set_or_calc_row_sizes

Integer set_or_calc_row_sizes(Boolean calcOnly,  Boolean setAsMin = true)

Grid#set_read_only

set_read_only(Integer row,  Integer col, 
              Boolean isReadOnly = true)

Makes the cell at the specified location read-only or editable. See also Grid#is_read_only.

Grid#set_row_attr

set_row_attr(Integer row,  GridCellAttr attr)

Sets the cell attributes for all cells in the specified row. See the GridCellAttr class for more information about controlling cell attributes.

Grid#set_row_label_alignment

set_row_label_alignment(Integer horiz,  Integer vert)

Sets the horizontal and vertical alignment of row label text.

Horizontal alignment should be one of ALIGN_LEFT, ALIGN_CENTRE or ALIGN_RIGHT.

Vertical alignment should be one of ALIGN_TOP, ALIGN_CENTRE or ALIGN_BOTTOM.

Grid#set_row_label_size

set_row_label_size(Integer width)

Sets the width of the row labels.

Grid#set_row_label_value

set_row_label_value(Integer row,  String value)

Set the value for the given row label. If you are using a derived grid table you must override GridTableBase#set_row_label_value for this to have any effect.

Grid#set_row_minimal_height

set_row_minimal_height(Integer row,  Integer height)

Sets the minimal height for the specified row. This should normally be called when creating the grid because it will not resize a row that is already shorter than the minimal height. The height argument must be higher than the minimimal acceptable row height, see Grid#get_row_minimal_acceptable_height.

Grid#set_row_minimal_acceptable_height

set_row_minimal_acceptable_height(Integer height)

This modifies the minimum row width that can be handled correctly. Specifying a low value here allows smaller grid cells to be dealt with correctly. Specifying a value here which is much smaller than the actual minimum size will incur a performance penalty in the functions which perform grid cell index lookup on the basis of screen coordinates. This should normally be called when creating the grid because it will not resize existing rows with sizes smaller than the value specified here.

Grid#set_row_size

set_row_size(Integer row,  Integer height)

Sets the height of the specified row.

This function does not refresh the grid. If you are calling it outside of a BeginBatch / EndBatch block you can use Grid#force_refresh to see the changes.

Automatically sizes the column to fit its contents. If setAsMin is true the calculated width will also be set as the minimal width for the column.

Note

Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.

Grid#set_scroll_line_x

set_scroll_line_x(Integer x)

Sets the number of pixels per horizontal scroll increment. The default is 15. Sometimes Grid has trouble setting the scrollbars correctly due to rounding errors: setting this to 1 can help.

See also

Grid#get_scroll_line_x, Grid#get_scroll_line_y, Grid#set_scroll_line_y

Grid#set_scroll_line_y

set_scroll_line_y(Integer y)

Sets the number of pixels per vertical scroll increment. The default is 15. Sometimes Grid has trouble setting the scrollbars correctly due to rounding errors: setting this to 1 can help.

See also

Grid#get_scroll_line_x, Grid#get_scroll_line_y, Grid#set_scroll_line_x

Grid#set_selection_background

set_selection_background(Colour c)

Grid#set_selection_foreground

set_selection_foreground(Colour c)

Grid#set_selection_mode

set_selection_mode(Integer selmode)

Set the selection behaviour of the grid. The parameter should be one of the following integer constants:

Parameters

Grid#set_table

Boolean set_table(GridTableBase table,
                  Grid::GridSelectionModes selmode = Wx::Grid::GridSelectCells)

Passes to a custom grid table to be used by the grid. This should be called after the grid constructor and before using the grid object. Use this function instead of Grid#create_grid when your application involves complex or non-string data or data sets that are too large to fit wholly in memory.

The table should be an instance of a subclass of GridTableBase which provides a set of methods for retrieving the size of the grid, cell data and optionally other row, column and cell information such as labels and attributes. See that class and the sample for more information on the required methods.

Grid#show_cell_edit_control

show_cell_edit_control()

Displays the in-place cell edit control for the current cell.

Grid#xto_col

Integer xto_col(Integer x,  Boolean clipToMinMax = false)

Parameters

Return value The grid column that corresponds to the logical x coordinate. Returns NOT_FOUND if there is no column at the x position.

Grid#xto_edge_of_col

Integer xto_edge_of_col(Integer x)

Returns the column whose right hand edge is close to the given logical x position. If no column edge is near to this position NOT_FOUND is returned.

Grid#yto_edge_of_row

Integer yto_edge_of_row(Integer y)

Returns the row whose bottom edge is close to the given logical y position. If no row edge is near to this position NOT_FOUND is returned.

Grid#yto_row

Integer yto_row(Integer y)

Returns the grid row that corresponds to the logical y coordinate. Returns NOT_FOUND if there is no row at the y position.

[This page automatically generated from the Textile source at Wed Sep 09 02:21:09 +0100 2009]