/*
 * $Id: AxisCoreP.h,v 1.0 91/08/22 15:33:53 gnb Exp $ 
 * $Source: /export/data/sources/x/At/Plotter/RCS/AxisCoreP.h,v $
 * 
 * $Log:	AxisCoreP.h,v $
 * Revision 1.0  91/08/22  15:33:53  gnb
 * Initial revision
 * 
 * 
 */

/*

Copyright 1991 by Burdett, Buckeridge & Young Ltd.

All rights reserved.

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Burdett, Buckeridge &
Young Ltd. (BBY) not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.

BBY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
BBY BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

*/
/*
 * The core axis resources.  This class is the superclass of all Axis
 * objects.
 * 
 */

#ifndef _AxisCoreP_h
#define _AxisCoreP_h

#ifdef _AtDevelopment_
#include "PlotP.h"
#include "AxisCore.h"
#else
#include <At/PlotP.h>
#include <At/AxisCore.h>
#endif 

typedef void (*AtAxisRangeProc) P((AtAxisCoreWidget, double *minp,
				   double *maxp, double *tip, 
				   int *nwp));
typedef void (*AtAxisCalcProc) P((AtAxisCoreWidget));

typedef struct {
     AtAxisRangeProc	range_proc;
     AtAxisCalcProc	calc_proc;
} AtAxisCoreClassPart;

#define XtInheritRangeProc	((AtAxisRangeProc)_XtInherit)
#define XtInheritCalcProc	((AtAxisCalcProc)_XtInherit)

typedef struct _AtAxisCoreClassRec {
     ObjectClassPart	object_class;
     AtPlotClassPart	plot_class; 
     AtAxisCoreClassPart	axiscore_class;
} AtAxisCoreClassRec;

extern AtAxisCoreClassRec atAxisCoreClassRec;

typedef struct {
     /* Resources */
     double	min;
     double	max;
     double	tic_interval;
     Boolean	vertical;
     Boolean	mirror;
     
     /* The label */
     String	font_family;
     String	label;
     int	label_size;
     int	label_style;
     Pixel	label_color;

     /* The Numbers */
     int	number_size;
     int	number_style;
     Pixel	number_color;
     
     /* The callbacks */
     XtCallbackList	range_callback;

     /* What-to-do resources */
     Boolean	tics_inside;
     Boolean	tics_outside;
     Dimension	tic_length;
     Dimension	subtic_length;
     
     Boolean	draw_numbers;
     Boolean	numbers_outside;
     Boolean	draw_grid;
     
     /* **************** Internal Stuff **************** */
     AtScale		*scale;
     Dimension		x1, y1, x2, y2, grid_length;
     int		max_num_width; /* As decided by callbacks etc */
     int		actual_num_width; /* Computed as text generated */
     int		axis_width; /* includes tics, label & numbers */

     
     /* label stuff */
     AtFontFamily	*ff;
     GC			label_gc;
     AtText		*label_text;
     Dimension		label_line; /* Start drawing the label at this pos */

     GC			number_gc;
     GC			grid_gc;
     
     /*
      * Keep track of what sort of recalc is required.  The
      * plot.recalc routine uses these to aboud extra work.  I hope.
      */
     Boolean		numbers_changed;
     Boolean		position_changed;
     /*
      * Subclasses are responsable for allocating and filling these
      * elements in their axiscore.recalc routines, but they are drawn and 
      * free'd by this class.
      */
     double		*tic_values; /* Axis coords of major tics */
     String		*tic_label_string; /* Label to go with each */
     Cardinal		num_tics; /* How many tics & labels */
     double		*subtic_values;	/* Axis coord of subtics */
     Cardinal		num_subtics; /* How many IN TOTAL */
     
     /* 
      * The pixel positions of the above are calculated by this class
      * and stuck in here by the plot.recalc routine (usually from
      * this class; subclasses would inherit it).
      */
     XSegment		*segments;
     Cardinal		num_segments;
     Dimension		*tic_pos;	/* The position of each label */
     Dimension		tic_label_line;	/* Is on this line somewhere */
     XSegment		*grid_segments;	/* Is num_tics of these */
     AtText		**tic_label_text; /* And num_tics of these */
} AtAxisCorePart;

typedef struct _AtAxisCoreRec {
     ObjectPart		object;
     AtPlotPart		plot;
     AtAxisCorePart	axiscore;
} AtAxisCoreRec;


#endif /* _AxisCoreP_h */
