>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User

# Classes

The basic grid class is jzgrid, and this provides facilities that should be required for any grid, including:

scrolling
mouse events
keyboard events
setting attributes, e.g. font, color, border, cell size

While the jzgrid class could in theory be used directly (for a very simple grid), there would typically be another class on top of the basic grid class that provides a specific type of grid, for example the watch class jwgrid. This would include data-related definitions such as providing formatted data for the grid and support for copying and editing.

As well as the grid classes, yet another class is needed for the Windows form definition. This will include

- the isigraph control to display the grid
- code to create the grid object from the grid classes to be used
- calls to grid event handlers

  If you create a new form using File|New Class, the Form Editor Wizard can be used to add the appropriate definitions.

  See Watch Example for a typical class structure.

  ### Watch Example

  The following example using the watch grid illustrates the class paths:

         dat=. ?30 30$100

  This defines some data to be watched.

         load 'jwatch'

  This loads the class jwatch into the jwatch locale, which in turn loads the scripts jwgrid and jinput, each into their own locale. jwgrid in turn loads the basic grid script, jzgrid. At this stage, all that has happened is that these scripts have been loaded, and the locale namelist looks like:

         conl ''
      +----+-+------+------+------+------+-+
      |base|j|jinput|jwatch|jwgrid|jzgrid|z|
      +----+-+------+------+------+------+-+

  No locale path settings have been made, so each locale has a path of z, as is the case with all new locales.

         a=. conew 'jwatch'

  This creates a new object (numbered locale) referenced by `a`. In a new session, it would be named '`0`' :

         conl''
      +-+----+-+------+------+------+------+-+
      |0|base|j|jinput|jwatch|jwgrid|jzgrid|z|
      +-+----+-+------+------+------+------+-+

  The new locale is empty, but has a locale path that includes jwatch and z.

         create__a 'dat'

  `create__a` is called in the new locale, and gets its definition from jwatch. This verb creates a new form to display the grid, and then itself calls `conew` to create a jwgrid object and sets its path to include jwgrid and jzgrid:

         grid=: ''conew'jwgrid'

  Therefore the locale list now includes two numbered locales:

         conl''
      +-+-+----+-+------+------+------+------+-+
      |0|1|base|j|jinput|jwatch|jwgrid|jzgrid|z|
      +-+-+----+-+------+------+------+------+-+

  The paths in these two numbered locales are:

         copath a           locale '0'
      +------+-+
      |jwatch|z|
      +------+-+

         copath grid__a     locale '1'
      +------+------+-+
      |jwgrid|jzgrid|z|
      +------+------+-+

  The structure of numbered locales is returned by `costate`:

         costate''
      +----+--+-------+---------------+
      |refs|id|creator|path           |
      +----+--+-------+---------------+
      |a   |0 |base   |jwatch z       |
      +----+--+-------+---------------+
      |    |1 |0      |jwgrid jzgrid z|
      +----+--+-------+---------------+

  Now suppose the mouse is clicked on one of the grid cells. The form is defined in locale `a`, so the mouse event handler `watch_grid_mbldown` will be called there. Since this locale has no event handlers of its own, the definition in the `jwatch` locale is used. This is defined as:

         watch_grid_mbldown=: 3 : 'mbldown__grid sysdata'

  Therefore the actual handler called is `mbldown` in the `grid` locale, which will pick its definition up from either `jwgrid` or `jzgrid`, whichever it sees first.

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User