/* $Id: PlotterP.h,v 1.1 91/05/20 15:15:22 gnb Exp $ */
/* $Source: /export/sources/x/At/Plotter/tmp/RCS/PlotterP.h,v $ */

/*

Copyright 1990,1991 by the Massachusetts Institute of Technology

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 the Massachusetts
Institute of Technology (M.I.T.) not be used in advertising or publicity
pertaining to distribution of the software without specific, written
prior permission.

M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
M.I.T. 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.

*/

/*
 * $Log:	PlotterP.h,v $
 * Revision 1.1  91/05/20  15:15:22  gnb
 * Initial revision
 * 
 * 
 */

#ifndef _PlotterP_h
#define _PlotterP_h    

#include <X11/IntrinsicP.h>
#include <X11/ConstrainP.h>

#ifdef _AtDevelopment_
#include "Plotter.h"
#include "Text.h"
#else
#include <At/Plotter.h>
#include <At/Text.h>
#endif

typedef struct ranking{ /* A private data structure */
  AtPlotWidget child;
  int rank_order;
  struct ranking *prev;
  struct ranking *next;
} Rank;

typedef struct {
     double xmin, xmax;
     double ymin, ymax;
     double y2min, y2max;
} PlotterBoundingBox;
    
/*
 * x-axis length is x2 - x1.  x-axis drawn at (x1, y2)
 * y-axis length is y2 - y1.  y-axis drawn at (x1, y2)
 * y2-axis length is y2 - y1.  y2-axis drawn at (x2,y2)
 */
typedef struct {
     short x1, y1, x2, y2;		/* the plotting area */
     short width, height;		/* the size of same */
     short title_x, title_y;		/* where the title goes */
     short legend_x, legend_y; 	/* where the legend goes */
     short legend_width, legend_height; /* Size of legend */
} PlotterLayout;

typedef struct _AtPlotterPart {    
    /* resources */
    String font_family;
    String title;
    String legend_title;
    int title_size;
    int legend_title_size;
    int legend_size;
    Pixel title_color;
    Pixel legend_color;
    Boolean auto_scale;
    Boolean force_square;
    Boolean force_aspect;
    Boolean floating_x;
    Boolean floating_y;
    Boolean framed_axes;
    Boolean show_legend;
    short default_legend_width;
    short legend_spacing;
    short margin_width;
    short margin_height;
    Boolean rank_children;
    int double_click_interval;
    XtCallbackList motion_callback;
    XtCallbackList click_callback;
    XtCallbackList drag_callback;
    XtCallbackList select_callback;
    XtCallbackList double_select_callback;
    XtCallbackList error_callback;

    /* 
     * Private widgets.  They are also children, numbered
     *  (in order) 0-5 
     */ 

    AtAxisObject xaxis;
    AtAxisObject yaxis;
    AtAxisObject y2axis;
    AtAxisObject xframeaxis;
    AtAxisObject yframeaxis;
    AtAxisObject y2frameaxis;

    /* private state */

    Rank *ordered_children;    /* rank ordered list of all children */
    AtFontFamily *ff;
    GC titleGC, legendGC, dragGC;
    AtText *title_text;
    AtText *legend_title_text;
    PlotterLayout layout;
    short selection_mode;
    Boolean dragging;
    short clickx, clicky, dragwidth, dragheight;
    Time lastclick;
    short legend_item;		/* Number of child selected in legend */
    short legend_item_y;	/* Y posn of selected child in legend
				   relative to legend_y */
    PlotterBoundingBox bounding_box;

    /* The state for the redraw processing */
    short expose_requested;
#define ER_NONE 0		/* No redraw requested */
#define ER_SYNTH 1		/* A synthetic expose has been generated */
#define ER_PHYS	2		/* A physical expose has been generated */
#define ER_MASK 03
#define ER_NEEDCLEAR 8		/* or-d in if syth sent but need a clear */

    Boolean redraw_required;
    Boolean rescale_required;
    Boolean layout_required;
    } AtPlotterPart;

typedef struct _AtPlotterRec {
    CorePart core;
    CompositePart composite;
    ConstraintPart constraint;
    AtPlotterPart plotter;
} AtPlotterRec;

typedef struct _AtPlotterClassPart {
    int peek_a_boo;
} AtPlotterClassPart;

typedef struct _AtPlotterClassRec {
    CoreClassPart core_class;
    CompositeClassPart composite_class;
    ConstraintClassPart constraint_class;
    AtPlotterClassPart AtPlotter_class;
} AtPlotterClassRec;

extern AtPlotterClassRec atPlotterClassRec;

/*
 * A linked list of from,to pairs for the extended list
 */
typedef struct _ExtendedList {
     struct _ExtendedList *next;
     int from, to;
} ExtendedList;

typedef struct _AtPlotterConstraintsPart {
    /* resources */
    Boolean displayed;
    String legend_name;
    Boolean use_y2_axis;
    int rank_order;

    /* private state */
    AtText *legend_text;
    BoundingBox bounding_box;

    /* This is the state kept for the redraw routine */
    Boolean needs_refresh;
    ExtendedList *extended_list; 
} AtPlotterConstraintsPart;

typedef struct {
    AtPlotterConstraintsPart plotter;
} AtPlotterConstraintsRec, *AtPlotterConstraints;


/*
 * This is the number of children that are "private" children - we
 * keep them as composite's children them so XtNameToWidget can
 * process them! 
 */
#define FIRST_PUBLIC_CHILD 6
#define CHILD_XAXIS 0
#define CHILD_YAXIS 1
#define CHILD_Y2AXIS 2
#define CHILD_XFRAMEAXIS 3
#define CHILD_YFRAMEAXIS 4
#define CHILD_Y2FRAMEAXIS 5

#endif
