]> git.saurik.com Git - wxWidgets.git/blame - docs/doxygen/overviews/grid.h
Use UTF16 for text data object on Mac. Fixes #10902
[wxWidgets.git] / docs / doxygen / overviews / grid.h
CommitLineData
15b6757b 1/////////////////////////////////////////////////////////////////////////////
c33e257b 2// Name: grid.h
15b6757b
FM
3// Purpose: topic overview
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
880efa2a 9/**
36c9828f 10
928f1a07 11@page overview_grid wxGrid Overview
36c9828f 12
928f1a07 13Classes: wxGrid
36c9828f 14
928f1a07
FM
15@li @ref overview_grid_intro
16@li @ref overview_grid_simpleexample
17@li @ref overview_grid_complexexample
18@li @ref overview_grid_classrelations
19@li @ref overview_grid_keyboardmouse
36c9828f 20
c33e257b 21
928f1a07 22<hr>
c33e257b
FM
23
24
928f1a07 25@section overview_grid_intro Introduction
36c9828f 26
c7d4ca81
RR
27wxGrid and its related classes are used for displaying and editing tabular
28data. wxGrid supports custom attributes for the table cells, allowing to
e812c32f 29completely customize its appearance and uses a separate grid table
c7d4ca81
RR
30(wxGridTableBase-derived) class for the data management meaning that it
31can be used to display arbitrary amounts of data.
c33e257b 32
928f1a07 33@section overview_grid_simpleexample Getting started: a simple example
36c9828f 34
928f1a07
FM
35For simple applications you need only refer to the wxGrid class in your
36code. This example shows how you might create a grid in a frame or
37dialog constructor and illustrates some of the formatting functions.
36c9828f 38
928f1a07
FM
39@code
40 // Create a wxGrid object
36c9828f 41
928f1a07 42 grid = new wxGrid( this,
15b6757b
FM
43 -1,
44 wxPoint( 0, 0 ),
45 wxSize( 400, 300 ) );
36c9828f 46
928f1a07
FM
47 // Then we call CreateGrid to set the dimensions of the grid
48 // (100 rows and 10 columns in this example)
49 grid->CreateGrid( 100, 10 );
36c9828f 50
928f1a07
FM
51 // We can set the sizes of individual rows and columns
52 // in pixels
53 grid->SetRowSize( 0, 60 );
54 grid->SetColSize( 0, 120 );
36c9828f 55
928f1a07
FM
56 // And set grid cell contents as strings
57 grid->SetCellValue( 0, 0, "wxGrid is good" );
36c9828f 58
928f1a07
FM
59 // We can specify that some cells are read->only
60 grid->SetCellValue( 0, 3, "This is read->only" );
61 grid->SetReadOnly( 0, 3 );
36c9828f 62
928f1a07
FM
63 // Colours can be specified for grid cell contents
64 grid->SetCellValue(3, 3, "green on grey");
65 grid->SetCellTextColour(3, 3, *wxGREEN);
66 grid->SetCellBackgroundColour(3, 3, *wxLIGHT_GREY);
36c9828f 67
928f1a07
FM
68 // We can specify the some cells will store numeric
69 // values rather than strings. Here we set grid column 5
70 // to hold floating point values displayed with width of 6
71 // and precision of 2
72 grid->SetColFormatFloat(5, 6, 2);
73 grid->SetCellValue(0, 6, "3.1415");
74@endcode
36c9828f 75
c7d4ca81
RR
76Here is a list of classes related to wxGrid:
77
78@li wxGrid: The main grid control class itself.
79@li wxGridTableBase: The base class for grid data provider.
80@li wxGridStringTable: Simple wxGridTableBase implementation supporting only
81 string data items and storing them all in memory (hence suitable for not
82 too large grids only).
83@li wxGridCellAttr: A cell attribute, allowing to customize its appearance as
84 well as the renderer and editor used for displaying and editing it.
85@li wxGridCellAttrProvider: The object responsible for storing and retrieving
86 the cell attributes.
87@li wxGridColLabelWindow: The window showing the grid columns labels.
88@li wxGridRowLabelWindow: The window showing the grid rows labels.
89@li wxGridCornerLabelWindow: The window used in the upper left grid corner.
90@li wxGridWindow: The window representing the main part of the grid.
91@li wxGridCellRenderer: Base class for objects used to display a cell value.
92@li wxGridCellStringRenderer: Renderer showing the cell as a text string.
93@li wxGridCellNumberRenderer: Renderer showing the cell as an integer number.
94@li wxGridCellFloatRenderer: Renderer showing the cell as a floating point
95 number.
96@li wxGridCellBoolRenderer: Renderer showing the cell as checked or unchecked
97 box.
98@li wxGridCellEditor: Base class for objects used to edit the cell value.
99@li wxGridCellStringEditor: Editor for cells containing text strings.
100@li wxGridCellNumberEditor: Editor for cells containing integer numbers.
101@li wxGridCellFloatEditor: Editor for cells containing floating point numbers.
102@li wxGridCellBoolEditor: Editor for boolean-valued cells.
103@li wxGridCellChoiceEditor: Editor allowing to choose one of the predefined
104 strings (and possibly enter new one).
105@li wxGridEvent: The event sent by most of wxGrid actions.
106@li wxGridSizeEvent: The special event sent when a grid column or row is
107 resized.
108@li wxGridRangeSelectEvent: The special event sent when a range of cells is
109 selected in the grid.
110@li wxGridEditorCreatedEvent: The special event sent when a cell editor is
111 created.
112@li wxGridSelection: The object efficiently representing the grid selection.
113@li wxGridTypeRegistry: Contains information about the data types supported by
114 the grid.
36c9828f 115
928f1a07 116@section overview_grid_complexexample A more complex example
36c9828f 117
e812c32f 118@todo To be written
36c9828f 119
c33e257b 120
928f1a07 121@section overview_grid_classrelations How the wxGrid classes relate to each other
36c9828f 122
e812c32f 123@todo To be written
36c9828f 124
36c9828f 125
928f1a07 126@section overview_grid_keyboardmouse Keyboard and mouse actions
36c9828f 127
e812c32f 128@todo To be written
36c9828f 129
e812c32f
VZ
130@section overview_grid_resizing Column and row sizes
131
132@b NB: This section will discuss the resizing of wxGrid rows only to avoid
133repetitions but everything in it also applies to grid columns, just replace @c
134Row in the method names with @c Col.
135
136Initially all wxGrid rows have the same height, which can be modified for all
137of them at once using wxGrid::SetDefaultRowSize(). However, unlike simpler
138controls such as wxListBox or wxListCtrl, wxGrid also allows its rows to be
139individually resized to have their own height using wxGrid::SetRowSize() (as a
140special case, a row may be hidden entirely by setting its size to 0, which is
141done by a helper wxGrid::HideRow() method). It is also possible to resize a row
142to fit its contents with wxGrid::AutoSizeRow() or do it for all rows at once
143with wxGrid::AutoSizeRows().
36c9828f 144
e812c32f 145Additionally, by default the user can also drag the row separator lines to
82edfbe7
VZ
146resize the rows interactively. This can be forbidden completely by calling
147wxGrid::DisableDragRowSize() or just for the individual rows using
148wxGrid::DisableRowResize().
149
150If you do allow the user to resize the grid rows, it may be a good idea to save
151their heights and restore it when the grid is recreated the next time (possibly
152during a next program execution): the functions wxGrid::GetRowSizes() and
153wxGrid::SetRowSizes() can help with this, you will just need to serialize
154wxGridSizesInfo structure returned by the former in some way and deserialize it
155back before calling the latter.
e812c32f
VZ
156
157*/