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