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