/*---------------------------------------------------------------------------*/
/* Jean-Eloi Dussartre M.I.T. Project Athena. January 1990.                  */
/* Header file for compiling the Spreadsheet widget.                         */
/*---------------------------------------------------------------------------*/

/*
 * Preliminaries remark :
 *                          Cell Geometry
 *                                              > < linewidth
 *              ^      +-------------------------+ 
 * marginHeight |      |<->    marginWidth    <->|
 *              v      |                         |
 *              ^      |   <----------------->   |
 * RowAtt       |      |          ColAtt         |
 *              v      |                         |
 *              ^      |                         |
 * marginHeight |      |                         |v
 *              v      +-------------------------+  lineWidth
 *                                                ^
 *
 *                        Table Geometry
 *
 *            <------------------------------------------------------>
 *                       Visible columns
 *     +-------------------------------------------------------------+ ^
 *     |      COLUMN NAME                                            | | V
 *     |   R  XXXXXX <- Upper left corner                            | | i
 *     |   O                                                         | | s
 *     |   W                                                         | | i
 *     |                     CCCCCCCC <- Cursor                      | | b
 *     |   N                                                         | | l
 *     |   A                                                         | | e
 *     |   M                                                         | | 
 *     |   E                                                         | | R
 *     |                                                             | | o
 *     +-------------------------------------------------------------+ v w
 *      <> marginWidth
 *          <> marginWidth
 *        <> ColTitleW
 *
 *
 *                         Window Geometry.
 *                   Column index increasing from 0 to ncol.
 *                ------->
 *                   y pixel increasing form 0 to core.width.
 *               |
 *               | Row index increasing from 0 to nrow.
 *               V x pixel increasing form 0 to core.height.
 */




#ifndef _AtSpreadsheetP_h
#define _AtSpreadsheetP_h

#include <Xm/XmP.h>
#include <At/FontFamily.h>
#include <At/Text.h>
#include <Xm/Text.h>

#include "Table.h"
#include "Spreadsheet.h"



 /* AtSpreadsheetCellAtt : Spreadsheet cell attribute.
  * Each flag could takes the value default. In that case the default is used.
  * The Default value is coded 0.
  * If editable flags is FALSE (or 1) the cell is read only.
  * If editable flags is TRUE  (or 2) the cell is read and write, i.e. users
  * can modify the cell.
  * The fontid is either 1, 2, 3, 4 for normal, bold, italic, underline.
  * The justification field is either 1, 2, 3 for left, right, centered.
  */
 
typedef struct
{
  unsigned editable      : 2;        /* default, Editable,read only cell  */
  unsigned face          : 3;        /* default, normal, bold, italic...  */
  unsigned justification : 2;        /* default, left, right, centered    */
} AtSpreadsheetCellAtt;


typedef struct
{
  unsigned short width;
  unsigned long position;
  AtText *label;
  AtSpreadsheetCellAtt Att;
} Column;

typedef struct
{
  unsigned short height;
  unsigned long position;
  AtText *label;
  AtSpreadsheetCellAtt Att;
} Row;



typedef struct {int foo;} AtSpreadsheetClassPart;

typedef struct _AtSpreadsheetClassRec
{
  CoreClassPart core_class;
  AtSpreadsheetClassPart  spreadsheet_class;
} AtSpreadsheetClassRec;

extern AtSpreadsheetClassRec  atSpreadsheetClassRec;


/*  Full class record declaration                  */



typedef struct _AtSpreadsheetPart
{
				/*****        RESOURCES       *****/
  AtTableObject table;		/* reference for the data handler */
				/*****  ROW AND COLUMN INDEX  *****/
  short topRow;			/* Row anchor                     */
  short leftColumn;		/* Column anchor                  */
  short bottomRow;		/* Last fully exposable row       */
  short rightColumn;		/* Last fully exposable column    */
  short cursorRow;		/* Cursor Row position.           */
  short cursorColumn;		/* Cursor Column position.        */
  short visibleRows;		/* Number of visible at begin.    */
  short visibleColumns;		/* Number of column visible at beg*/
				/*****          FLAGS         *****/
  Boolean editable;		/* Read only /Read&Write Flag.    */
  Boolean verticalLines;	/* Draw vertical grid?            */
  Boolean horizontalLines;	/* Draw horizontal grid?          */
  Boolean scrollVertical;	/* display a vertical scrollbar?  */
  Boolean scrollHorizontal;	/* display a horizontal scrollbar?*/
				/***** FONT AND JUSTIFICATION *****/
  char *fontFamily;		/* Name of family font            */
  int fontSize;			/* Font size to be used           */
  short face;			/* default face to be used        */
  short justification;		/* Justification default.         */
  short rowLabelJustification;	/* Row label are justified...     */
  short columnLabelJustification; /* Column label are justified   */
				/*****   DRAWING INFORMATION  *****/
  short columnWidth;		/* Column width default (ems).    */
  short rowHeight;		/* Row Height default (pxl).      */
  short lineWidth;		/* Line width (pxl).              */
  short lineStyle;		/* Line style (solid, dashed).    */
  short dashList;		/* Dash list for dashed lines.    */
  short borderSpace;		/* Double line inner space.       */
  short marginHeight;		/* Margin height (cell).          */
  short marginWidth;		/* Margin width (cell).           */
  short columnNameHeight;	/* The height to write in top mar.*/
  short rowNameWidth;		/* The width of left column       */
  Pixel rowLabelColor;		/* Foreground for row label       */
  Pixel columnLabelColor;	/* Foreground for column label    */
  Pixel cellColor;		/* Foreground for cells           */
  Pixel lineColor;		/* Foreground for lines           */
				/*****       CALL BACKS       *****/
  XtCallbackList rangeChangedCallback; /* Call for a cell cahnged     */
  XtCallbackList cursorMovedCallback; /* Call for a cursor move      */
  XtCallbackList scrollCallback; /* Call back on a scrolling    */
  XtCallbackList entryVerifyCallback; /* Call to check an entry      */
  XtCallbackList rangeSelectedCallback;	/* Call for a select range.    */
				/*****     PRIVATE STATE      *****/
  int ncols;			/* The number of columns. */
  int nrows;			/* The number of rows. */
  Column *cols;			/* info about the cols */
  Row *rows;			/* info about the rows */
  short x0, y0;			/* start of first visible row/col */
  Widget cursor;		/*  */
  Widget vscroll;		/*  */
  Widget hscroll;		/*  */
  AtFontFamily *ff;		/* Font family pointer. */
  short emsize;			/* The max em-size in font. */
  short ascent;			/* The max ascent. */
  short descent;		/* The max descent. */
  GC gc;			/* I don't share GC. */
  GC gridGC;			/* GC for drawing grid */
  Boolean partialRow;		/* Partial row visible? */
  Boolean partialColumn;	/* Partial column visible? */
} AtSpreadsheetPart, *AtSpreadsheet;


typedef struct _AtSpreadsheetRec
{
  CorePart core;
  AtSpreadsheetPart spreadsheet;
} AtSpreadsheetRec;

#endif _AtSpreadsheetP_h
/* DON'T ADD ANYTHING AFTER THIS #endif */





