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.
There are presently no specific window styles for Grid.
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. |
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.
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.
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.
auto_size()
Automatically sets the height and width of all rows and columns to fit their contents.
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.
auto_size_col_or_row(Integer n, Boolean setAsMin,
Boolean column)
Common part of AutoSizeColumn/Row() or row?
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.
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.
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.
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.
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.
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.
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.
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.
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.
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] )
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.
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).
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).
Boolean can_drag_grid_size()
Return true if the dragging of grid lines to resize rows and columns is enabled or false otherwise.
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).
Boolean can_have_attributes()
Do we have some place to store attributes in?
Rect cell_to_rect(Integer row, Integer col)
Return the rectangle corresponding to the grid cell’s size and position in logical coordinates.
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.
clear_selection()
Deselects all cells that are currently selected.
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.
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.
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.
disable_cell_edit_control()
Disables in-place editing of grid cells. Equivalent to calling EnableCellEditControl(false).
disable_drag_col_move()
Disables column moving by dragging with the mouse. Equivalent to passing false to Grid#enable_drag_col_move.
disable_drag_col_size()
Disables column sizing by dragging with the mouse. Equivalent to passing false to Grid#enable_drag_col_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
disable_drag_row_size()
Disables row sizing by dragging with the mouse. Equivalent to passing false to Grid#enable_drag_row_size.
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.
enable_drag_col_size(Boolean enable = true)
Enables or disables column sizing by dragging with the mouse.
enable_drag_col_move(Boolean enable = true)
Enables or disables column moving by dragging with the mouse.
enable_drag_grid_size(Boolean enable = true)
Enables or disables row and column resizing by dragging gridlines with the mouse.
enable_drag_row_size(Boolean enable = true)
Enables or disables row sizing by dragging with the mouse.
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.
enable_grid_lines(Boolean enable = true)
Turns the drawing of grid lines on or off.
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.
fit()
Overridden Window method.
force_refresh()
Causes immediate repainting of the grid. Use this instead of the usual Window::Refresh.
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.
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.
Colour get_cell_background_colour(Integer row, Integer col)
Returns the background colour of the cell at the specified location.
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.
Font get_cell_font(Integer row, Integer col)
Returns the font for text in the grid cell at the specified location.
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.
Colour get_cell_text_colour(Integer row, Integer col)
Returns the text colour for the grid cell at the specified location.
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.
Integer get_col_at(Integer colPos)
Returns the column ID of the specified column position.
Integer get_col_left(Integer col)
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.
Integer get_col_label_size()
Returns the current height of the column labels.
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.
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.
Integer get_col_minimal_width(Integer col)
Get the minimal width of the given column/row.
Integer get_col_pos(Integer colID)
Returns the position of the specified column.
Integer get_col_right(Integer col)
Integer get_col_size(Integer col)
Returns the width of the specified column.
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.
Colour get_default_cell_background_colour()
Returns the current default background colour for grid cells.
Font get_default_cell_font()
Returns the current default font for grid cell text.
Colour get_default_cell_text_colour()
Returns the current default colour for grid cell text.
Integer get_default_col_label_size()
Returns the default height for column labels.
Integer get_default_col_size()
Returns the current default width for grid columns.
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.
GridCellEditor get_default_editor_for_cell(Integer row,
Integer col)
GridCellEditor get_default_editor_for_type(String typeName)
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.
GridCellRenderer get_default_renderer_for_cell(Integer row,
Integer col)
GridCellRenderer get_default_renderer_for_type(String typeName)
Integer get_default_row_label_size()
Returns the default width for the row labels.
Integer get_default_row_size()
Returns the current default height for grid rows.
Integer get_grid_cursor_col()
Returns the current grid cell column position.
Integer get_grid_cursor_row()
Returns the current grid cell row position.
Colour get_grid_line_colour()
Returns the colour used for grid lines.
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$.
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();
}
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.
Boolean grid_lines_enabled()
Returns true if drawing of grid lines is turned on, false otherwise.
Colour get_label_background_colour()
Returns the colour used for the background of row and column labels.
Font get_label_font()
Returns the font used for row and column labels.
Colour get_label_text_colour()
Returns the colour used for row and column label text.
Integer get_number_cols()
Returns the total number of grid columns (actually the number of columns in the underlying grid table).
Integer get_number_rows()
Returns the total number of grid rows (actually the number of rows in the underlying grid table).
GridCellAttr get_or_create_cell_attr(Integer row,
Integer col)
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.
Integer get_row_minimal_height(Integer col)
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.
Integer get_row_label_size()
Returns the current width of the row labels.
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.
Integer get_row_size(Integer row)
Returns the height of the specified row.
Integer get_scroll_line_x()
Returns the number of pixels per horizontal scroll increment. The default is 15.
Grid#get_scroll_line_y, Grid#set_scroll_line_x, Grid#set_scroll_line_y
Integer get_scroll_line_y()
Returns the number of pixels per vertical scroll increment. The default is 15.
Grid#get_scroll_line_x, Grid#set_scroll_line_x, Grid#set_scroll_line_y
Integer get_selection_mode()
Returns the current selection mode as a constant, see Grid#set_selection_mode.
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
Array get_selected_cols()
Returns an array of selected cols.
Array get_selected_rows()
Returns an array of selected rows.
Colour get_selection_background()
Access or update the selection fore/back colours
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
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.
Colour get_selection_foreground()
GridTableBase get_table()
Returns a base pointer to the current table object.
Integer get_view_width()
Returned number of whole cols visible.
hide_cell_edit_control()
Hides the in-place cell edit control.
init_col_widths()
Init the m_colWidths/Rights arrays
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.
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.
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.
Boolean is_cell_edit_control_enabled()
Returns true if the in-place edit control is currently enabled.
Boolean is_current_cell_read_only()
Returns true if the current cell has been set to read-only (see Grid#set_read_only).
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.
Boolean is_in_selection(Integer row, Integer col)
Is this cell currently selected.
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.
Boolean is_selection()
Returns true if there are currently rows, columns or blocks of cells selected.
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.
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.
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.
This function is called for Down cursor key presses or Shift+Down to expand a selection.
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.
This function is called for Left cursor key presses or Shift+Left to expand a selection.
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.
This function is called for Right cursor key presses or Shift+Right to expand a selection.
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.
This function is called for Up cursor key presses or Shift+Up to expand a selection.
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.
This function is called for the Ctrl+Down key combination. Shift+Ctrl+Down expands a selection.
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.
This function is called for the Ctrl+Left key combination. Shift+Ctrl+left expands a selection.
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.
This function is called for the Ctrl+Right key combination. Shift+Ctrl+Right expands a selection.
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.
This function is called for the Ctrl+Up key combination. Shift+Ctrl+Up expands a selection.
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.
This function is called for PgDn keypresses.
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.
This function is called for PgUp keypresses.
register_data_type(String typeName, GridCellRenderer renderer,
GridCellEditor editor)
Methods for a registry for mapping data types to Renderers/Editors
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.
select_all()
Selects all cells in the grid.
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.
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.
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.
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.
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.
set_cell_background_colour(Integer row, Integer col,
Colour colour)
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.
set_cell_font(Integer row, Integer col, Font font)
Sets the font for text in the grid cell at the specified location.
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.
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.
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.
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.
set_col_format_bool(Integer col)
Sets the specified column to display boolean values. Grid displays boolean values with a checkbox.
set_col_format_number(Integer col)
Sets the specified column to display integer values.
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.
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.
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.
set_col_label_size(Integer height)
Sets the height of the column labels.
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.
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.
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.
set_col_pos(Integer colID, Integer newPos)
Sets the position of the specified column.
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.
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.
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.
set_default_cell_background_colour(Colour colour)
Sets the default background colour for grid cells.
set_default_cell_font(Font font)
Sets the default font to be used for grid cell text.
set_default_cell_text_colour(Colour colour)
Sets the current default colour for grid cell text.
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.
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.
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.
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.
set_grid_cursor(Integer row, Integer col)
Set the grid cursor to the specified cell. This function calls Grid#make_cell_visible.
set_grid_line_colour(Colour colour)
Sets the colour used to draw grid lines.
set_label_background_colour(Colour colour)
Sets the background colour for row and column labels.
set_label_font(Font font)
Sets the font for row and column labels.
set_label_text_colour(Colour colour)
Sets the colour for row and column label text.
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
Integer set_or_calc_column_sizes(Boolean calcOnly,
Boolean setAsMin = true)
Common part of AutoSizeColumn/Row() and GetBestSize()
Integer set_or_calc_row_sizes(Boolean calcOnly, Boolean setAsMin = true)
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.
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.
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.
set_row_label_size(Integer width)
Sets the width of the row labels.
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.
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.
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.
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.
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.
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.
Grid#get_scroll_line_x, Grid#get_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.
Grid#get_scroll_line_x, Grid#get_scroll_line_y, Grid#set_scroll_line_x
set_selection_background(Colour c)
set_selection_foreground(Colour c)
set_selection_mode(Integer selmode)
Set the selection behaviour of the grid. The parameter should be one of the following integer constants:
Wx::Grid::GridSelectCells The default mode where individual cells are selected.Wx::Grid::GridSelectRows Selections will consist of whole rows.Wx::Grid::GridSelectColumns Selections will consist of whole columns.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.
show_cell_edit_control()
Displays the in-place cell edit control for the current cell.
Integer xto_col(Integer x, Boolean clipToMinMax = false)
NOT_FOUND if there is no column at the x position.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.
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.
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]