X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Foutput.h;h=398781f05f547fef57f429386e20af6da4993b31;hb=9b9cf504388f8e0a2225db3746e5cca39c479630;hp=9694fcb4d88bef10a0cd7395737d0e2fa556a1e4;hpb=a19b858e0ac3c69e4a28c0ca6d8674427268a863;p=pspp-builds.git diff --git a/src/output/output.h b/src/output/output.h index 9694fcb4..398781f0 100644 --- a/src/output/output.h +++ b/src/output/output.h @@ -1,115 +1,58 @@ -/* PSPP - computes sample statistics. - Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. - Written by Ben Pfaff . +/* PSPP - a program for statistical analysis. + Copyright (C) 1997-9, 2000, 2007, 2009 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program. If not, see . */ -#if !output_h -#define output_h 1 - -#include +#ifndef OUTPUT_OUTPUT_H +#define OUTPUT_OUTPUT_H 1 +#include #include - -/* A rectangle. */ -struct rect +/* Line styles. */ +enum outp_line_style { - int x1, y1; /* Upper left. */ - int x2, y2; /* Lower right, not part of the rectangle. */ + OUTP_L_NONE, /* No line. */ + OUTP_L_SINGLE, /* Single line. */ + OUTP_L_DOUBLE, /* Double line. */ + OUTP_L_COUNT }; -/* Color descriptor. */ -struct color +/* Text justification. */ +enum outp_justification { - int flags; /* 0=normal, 1=transparent (ignore r,g,b). */ - int r; /* Red component, 0-65535. */ - int g; /* Green component, 0-65535. */ - int b; /* Blue component, 0-65535. */ + OUTP_RIGHT, /* Right justification. */ + OUTP_LEFT, /* Left justification. */ + OUTP_CENTER, /* Center justification. */ }; -/* Mount positions for the four basic fonts. Do not change the values. */ -enum +enum outp_font { - OUTP_F_R, /* Roman font. */ - OUTP_F_I, /* Italic font. */ - OUTP_F_B, /* Bold font. */ - OUTP_F_BI /* Bold-italic font. */ - }; - -/* Line styles. These must match: - som.h:SLIN_* - ascii.c:ascii_line_*() - postscript.c:ps_line_*() */ -enum - { - OUTP_L_NONE = 0, /* No line. */ - OUTP_L_SINGLE = 1, /* Single line. */ - OUTP_L_DOUBLE = 2, /* Double line. */ - OUTP_L_SPECIAL = 3, /* Special line of driver-defined style. */ - - OUTP_L_COUNT /* Number of line styles. */ - }; - -/* Contains a line style for each part of an intersection. */ -struct outp_styles - { - int l; /* left */ - int t; /* top */ - int r; /* right */ - int b; /* bottom */ - }; - -/* Text display options. */ -enum - { - OUTP_T_NONE = 0, - - /* Must match tab.h:TAB_*. */ - OUTP_T_JUST_MASK = 00003, /* Justification mask. */ - OUTP_T_JUST_RIGHT = 00000, /* Right justification. */ - OUTP_T_JUST_LEFT = 00001, /* Left justification. */ - OUTP_T_JUST_CENTER = 00002, /* Center justification. */ - - OUTP_T_HORZ = 00010, /* Horizontal size is specified. */ - OUTP_T_VERT = 00020, /* (Max) vertical size is specified. */ - - OUTP_T_0 = 00140, /* Normal orientation. */ - OUTP_T_CC90 = 00040, /* 90 degrees counterclockwise. */ - OUTP_T_CC180 = 00100, /* 180 degrees counterclockwise. */ - OUTP_T_CC270 = 00140, /* 270 degrees counterclockwise. */ - OUTP_T_C90 = 00140, /* 90 degrees clockwise. */ - OUTP_T_C180 = 00100, /* 180 degrees clockwise. */ - OUTP_T_C270 = 00040, /* 270 degrees clockwise. */ - - /* Internal use by drivers only. */ - OUTP_T_INTERNAL_DRAW = 01000 /* 1=Draw the text, 0=Metrics only. */ + OUTP_FIXED, /* Fixed-width font. */ + OUTP_PROPORTIONAL, /* Proportional font. */ + OUTP_EMPHASIS, /* Proportional font used for emphasis. */ + OUTP_FONT_CNT /* Number of fonts. */ }; /* Describes text output. */ struct outp_text { - /* Public. */ - int options; /* What is specified. */ - struct fixed_string s; /* String. */ + enum outp_font font; + enum outp_justification justification; + struct substring string; int h, v; /* Horizontal, vertical size. */ int x, y; /* Position. */ - - /* Internal use only. */ - int w, l; /* Width, length. */ }; struct som_entity; @@ -119,61 +62,30 @@ struct chart; /* Defines a class of output driver. */ struct outp_class { - /* Basic class information. */ const char *name; /* Name of this driver class. */ - int magic; /* Driver-specific constant. */ int special; /* Boolean value. */ - /* Static member functions. */ - int (*open_global) (struct outp_class *); - int (*close_global) (struct outp_class *); - int *(*font_sizes) (struct outp_class *, int *n_valid_sizes); + bool (*open_driver) (const char *name, int types, + struct substring options); + bool (*close_driver) (struct outp_driver *); + + void (*open_page) (struct outp_driver *); + void (*close_page) (struct outp_driver *); - /* Virtual member functions. */ - int (*preopen_driver) (struct outp_driver *); - void (*option) (struct outp_driver *, const char *key, - const struct string *value); - int (*postopen_driver) (struct outp_driver *); - int (*close_driver) (struct outp_driver *); + void (*flush) (struct outp_driver *); - int (*open_page) (struct outp_driver *); - int (*close_page) (struct outp_driver *); + void (*output_chart) (struct outp_driver *, const struct chart *); - /* special != 0: Used to submit entities for output. */ + /* special != 0 only. */ void (*submit) (struct outp_driver *, struct som_entity *); - - /* special != 0: Methods below need not be defined. */ - - /* Line methods. */ - void (*line_horz) (struct outp_driver *, const struct rect *, - const struct color *, int style); - void (*line_vert) (struct outp_driver *, const struct rect *, - const struct color *, int style); - void (*line_intersection) (struct outp_driver *, const struct rect *, - const struct color *, - const struct outp_styles *style); - - /* Drawing methods. */ - void (*box) (struct outp_driver *, const struct rect *, - const struct color *bord, const struct color *fill); - void (*polyline_begin) (struct outp_driver *, const struct color *); - void (*polyline_point) (struct outp_driver *, int, int); - void (*polyline_end) (struct outp_driver *); - - /* Text methods. */ - void (*text_set_font_by_name) (struct outp_driver *, const char *s); - void (*text_set_font_by_position) (struct outp_driver *, int); - void (*text_set_font_family) (struct outp_driver *, const char *s); - const char *(*text_get_font_name) (struct outp_driver *); - const char *(*text_get_font_family) (struct outp_driver *); - int (*text_set_size) (struct outp_driver *, int); - int (*text_get_size) (struct outp_driver *, int *em_width); - void (*text_metrics) (struct outp_driver *, struct outp_text *); - void (*text_draw) (struct outp_driver *, struct outp_text *); - - void (*initialise_chart)(struct outp_driver *, struct chart *); - void (*finalise_chart)(struct outp_driver *, struct chart *); + /* special == 0 only. */ + void (*line) (struct outp_driver *, int x0, int y0, int x1, int y1, + enum outp_line_style top, enum outp_line_style left, + enum outp_line_style bottom, enum outp_line_style right); + void (*text_metrics) (struct outp_driver *, const struct outp_text *, + int *width, int *height); + void (*text_draw) (struct outp_driver *, const struct outp_text *); }; /* Device types. */ @@ -183,34 +95,26 @@ enum OUTP_DEV_LISTING = 001, /* Listing device. */ OUTP_DEV_SCREEN = 002, /* Screen device. */ OUTP_DEV_PRINTER = 004, /* Printer device. */ - OUTP_DEV_DISABLED = 010 /* Broken device. */ }; /* Defines the configuration of an output driver. */ struct outp_driver { - struct outp_class *class; /* Driver class. */ + struct ll node; /* Node in list of drivers. */ + const struct outp_class *class; /* Driver class. */ char *name; /* Name of this driver. */ - int driver_open; /* 1=driver is open, 0=driver is closed. */ - int page_open; /* 1=page is open, 0=page is closed. */ - - struct outp_driver *next, *prev; /* Next, previous output driver in list. */ - + bool page_open; /* 1=page is open, 0=page is closed. */ int device; /* Zero or more of OUTP_DEV_*. */ - int res, horiz, vert; /* Device resolution. */ - int width, length; /* Page size. */ - int cp_x, cp_y; /* Current position. */ + + int width, length; /* Page size. */ int font_height; /* Default font character height. */ int prop_em_width; /* Proportional font em width. */ int fixed_width; /* Fixed-pitch font character width. */ int horiz_line_width[OUTP_L_COUNT]; /* Width of horizontal lines. */ int vert_line_width[OUTP_L_COUNT]; /* Width of vertical lines. */ - int horiz_line_spacing[1 << OUTP_L_COUNT]; - int vert_line_spacing[1 << OUTP_L_COUNT]; void *ext; /* Private extension record. */ - void *prc; /* Per-procedure extension record. */ }; /* Option structure for the keyword recognizer. */ @@ -221,31 +125,21 @@ struct outp_option int subcat; /* Subcategory. */ }; -/* Information structure for the keyword recognizer. */ -struct outp_option_info - { - char *initial; /* Initial characters. */ - struct outp_option **options; /* Search starting points. */ - }; - -/* A list of driver classes. */ -struct outp_driver_class_list - { - int ref_count; - struct outp_class *class; - struct outp_driver_class_list *next; - }; - -/* List of configured output drivers. */ -extern struct outp_driver *outp_driver_list; /* Title, subtitle. */ extern char *outp_title; extern char *outp_subtitle; void outp_init (void); -void outp_read_devices (void); void outp_done (void); +void outp_read_devices (void); +void outp_configure_driver_line (struct substring); + +struct outp_driver *outp_allocate_driver (const struct outp_class *class, + const char *name, int types); +void outp_free_driver (struct outp_driver *); +void outp_register_driver (struct outp_driver *); +void outp_unregister_driver (struct outp_driver *); void outp_configure_clear (void); void outp_configure_add (char *); @@ -253,20 +147,33 @@ void outp_configure_macro (char *); void outp_list_classes (void); -void outp_enable_device (int enable, int device); +void outp_enable_device (bool enable, int device); struct outp_driver *outp_drivers (struct outp_driver *); -int outp_match_keyword (const char *, struct outp_option *, - struct outp_option_info *, int *); +bool outp_parse_options (const char *driver_name, struct substring options, + bool (*callback) (void *aux, const char *key, + const struct string *value), + void *aux); +int outp_match_keyword (const char *, const struct outp_option *, int *); -int outp_evaluate_dimension (char *, char **); -int outp_get_paper_size (char *, int *h, int *v); +int outp_evaluate_dimension (const char *); +bool outp_get_paper_size (const char *, int *h, int *v); -int outp_eject_page (struct outp_driver *); +void outp_open_page (struct outp_driver *); +void outp_close_page (struct outp_driver *); +void outp_eject_page (struct outp_driver *); +void outp_flush (struct outp_driver *); -int outp_string_width (struct outp_driver *, const char *); +int outp_string_width (struct outp_driver *, const char *, enum outp_font); /* Imported from som-frnt.c. */ void som_destroy_driver (struct outp_driver *); -#endif /* output.h */ +/* Common drivers. */ +extern const struct outp_class ascii_class; +#ifdef HAVE_CAIRO +extern const struct outp_class cairo_class; +#endif +extern const struct outp_class odt_class; + +#endif /* output/output.h */