\chapter{Introduction}\label{introduction}
\pagenumbering{arabic}%
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
\setfooter{\thepage}{}{}{}{}{\thepage}%

The wxGrid class is a window designed for displaying data in tabular
format. Possible uses include:

\begin{itemize}\itemsep=0pt
\item Displaying database tables;
\item building spreadsheet applications;
\item displaying files and their attributes;
\item use as a more sophisticated listbox where different fonts and colours are required.
\end{itemize}

This manual currently describes the version of wxGrid that operates
under Windows and Motif, implementing using generic wxWindows code.
Under Motif, wxGrid can also be compiled using the public domain Xbae
matrix widget, included in the wxGrid distribution. However, some work
still needs to be done to provide full wxGrid functionality. 

\section{The appearance and behaviour of a wxGrid}\label{appearance}

The following screenshot shows the initial appearance of the sample wxGrid application.

$$\image{8cm;0cm}{grid1.eps}$$\\

The wxGrid class is a panel that provides a text editing area, and a grid with scrollbars.
The grid has horizontal and vertical label areas whose colours may be changed independently
from the cell area. The text editing area, and the label areas, may be switched off
if desired.

The user navigates the grid using the mouse to click on cells and scroll around the
virtual grid area (no keyboard navigation is possible as yet). If the edit
control is enabled, it always has the focus for the currently selected cell
and the user can type into it. The text in the edit control will be reflected
in the currently selected cell.

If the row and column label areas are enabled, the user can drag on the label divisions
to resize a row or column.

The sample application allows the user to change various aspects of the grid using
the wxGrid API. These include:

\begin{itemize}\itemsep=0pt
\item Changing the background and foreground colour of labels and cells;
\item toggling row and column label areas on and off independently;
\item toggling the edit control on and off;
\item toggling the light grey cell dividers on and off;
\item changing cell alignment.
\end{itemize}

There are various other aspects that can be controlled via the API, including
changing individual cell font and colour properties.


\chapter{Files}\label{files}
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
\setfooter{\thepage}{}{}{}{}{\thepage}%

The wxGrid class library comprises the following files.

UNIX files:

\begin{itemize}\itemsep=0pt
\item caption.c
\item clip.c
\item matrix.c
\item caption.h
\item captionp.h
\item clip.h
\item clipp.h
\item matrix.h
\item matrixp.h
\item wxgridm.cc
\item wxgridm.h
\end{itemize}

Generic files:

\begin{itemize}\itemsep=0pt
\item wxgridg.h (generic implementation)
\item wxgridg.cc
\item wxgrid.h (includes wxgridw.h or wxgridm.h as necessary)
\item test.h (test application)
\item test.cc
\end{itemize}

\chapter{Implementation issues}\label{implementation}
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
\setfooter{\thepage}{}{}{}{}{\thepage}%

This is an assortment of wxGrid implementation issues.

\section{wxMotifGrid}

wxMotifGrid version needs to be implemented in terms the Xbae matrix widget.
A start has been made: see wxgridm.h, wxgridm.cc. Probably not all
of the API of wxGenericGrid can be emulated using Xbae.

\section{wxGenericGrid}

\subsection{To do}

\begin{itemize}\itemsep=0pt
\item Keyboard functionality (see Problems).
\item Selection of multiple cells, rows, columns by dragging or
clicking on row/column labels.
\item Interception of left, right, middle mouse clicks by application.
\item Optimization of painting code: for instance, all columns and rows
are painted from the cursor position, although some may be hidden. Under
Windows, ::ScrollWindow could be used to help reduce flicker.
\end{itemize}

\subsection{Problems}

It will be tricky to make wxGenericGrid responsive to cursor key movement,
because at present the wxText item always has the focus (in editable mode)
and absorbs cursor key presses.

One possible solution is {\it not} to have the focus always set on the wxText item.
When the user clicks on a cell, the focus is on the cell. When the user presses Return
or double-clicks, the focus is set to the wxItem and text may be typed in. Immediately after the
user has single-clicked on a cell, cursor keys can be used to navigate
around the grid.

In non-editable mode, focus is always on the current cell, and therefore all cursor movements
are immediately interpreted as navigation requests.

\section{Other platforms}

Other platforms, such as XView, should try to use wxGenericGrid
unless free platform-specific grid widgets are available.
However, the XView version of wxWindows has problems with user painting
of panels so this needs investigating.
