/* * Types.h -- Types used by the Zinc widget. * * Authors : Patrick Lecoanet. * Creation date : Mon Feb 1 12:13:24 1999 * * $Id$ */ /* * Copyright (c) 1993 - 1999 CENA, Patrick Lecoanet -- * * This code is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This code 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this code; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef _Types_h #define _Types_h #define NEED_REAL_STDIO #include #include #ifdef PTK #include #endif #include #ifdef __CPLUSPLUS__ extern "C" { #endif typedef void *ZnItemClassId; typedef void *ZnItemId; typedef double ZnReal; /* Keep it a double for GPC & libart. */ typedef int ZnBool; /* Keep it an int to keep Tk & GPC happy */ typedef ZnReal ZnPos; typedef ZnReal ZnDim; typedef XColor *ZnColor; typedef Tk_Font ZnFont; typedef Tk_Window ZnWindow; typedef void *ZnPtr; typedef Tk_Image ZnImage; typedef struct { ZnPos x, y; } ZnPoint; typedef struct { ZnPos x, y, w, h; } ZnRect; typedef struct { int num_points; ZnPoint *points; } ZnContour; /* * contour1/hole1 can be used to store a single contour * without having to alloc the holes & contours arrays. */ typedef struct { int num_contours; ZnBool *holes; ZnContour *contours; ZnBool *cw; ZnBool hole1; ZnContour contour1; ZnBool cw1; } ZnPoly; /* * ZnBBox: orig is into the area while corner is not. * Thus the test: ((bbox.orig.x == bbox.corner.x) || * (bbox.orig.y == bbox.corner.y)) * tells whether the bbox is empty or not. * When interpreting bboxes the X coordinate system is * the norm. x goes from left toward the right and y * goes from the top toward the bottom. Bboxes are * always axes aligned. */ typedef struct { ZnPoint orig, corner; } ZnBBox; /* * Operator constants for the coord method. */ #define COORDS_READ 0 #define COORDS_READ_ALL 1 #define COORDS_REPLACE 2 #define COORDS_REPLACE_ALL 3 #define COORDS_ADD 4 #define COORDS_ADD_LAST 5 #define COORDS_REMOVE 6 /* * Types and constants for attribute processing. */ typedef struct { int type; char *name; Tk_Uid uid; int offset; int bool_bit; int flags; ZnBool read_only; } ZnAttrConfig; /* * When adding new type in the following enum * do not forget to update attribute_type_strings * in Item.c. */ #define ZN_CONFIG_END 0 #define ZN_CONFIG_COLOR 1 #define ZN_CONFIG_BOOL 2 #define ZN_CONFIG_PATTERN 3 #define ZN_CONFIG_TEXT 4 #define ZN_CONFIG_FONT 5 #define ZN_CONFIG_BORDER 6 #define ZN_CONFIG_RELIEF 7 #define ZN_CONFIG_DIM 8 #define ZN_CONFIG_PRI 9 #define ZN_CONFIG_JUSTIFY 10 #define ZN_CONFIG_AUTO_JUSTIFY 11 #define ZN_CONFIG_LINE_END 12 #define ZN_CONFIG_LABEL_FORMAT 13 #define ZN_CONFIG_LINE_STYLE 14 #define ZN_CONFIG_LINE_SHAPE 15 #define ZN_CONFIG_ITEM 16 #define ZN_CONFIG_ANGLE 17 #define ZN_CONFIG_INT 18 #define ZN_CONFIG_UINT 19 #define ZN_CONFIG_POINT 20 #define ZN_CONFIG_RECT 21 #define ZN_CONFIG_PATTERNS 22 #define ZN_CONFIG_ANCHOR 23 #define ZN_CONFIG_TAGS 24 #define ZN_CONFIG_POINTS 25 #define ZN_CONFIG_MAP_INFO 26 #define ZN_CONFIG_IMAGE 27 #define ZN_CONFIG_LEADER_ANCHORS 28 #define ZN_CONFIG_JOIN_STYLE 29 #define ZN_CONFIG_CAP_STYLE 30 #define ZN_CONFIG_GRADIENT_GEOM 31 #define ZN_CONFIG_GRADIENT_COLOR 32 #define ZN_CONFIG_WINDOW 33 #define ZN_DRAW_FLAG 1 << 0 #define ZN_COORDS_FLAG 1 << 1 #define ZN_TRANSFO_FLAG 1 << 2 #define ZN_REPICK_FLAG 1 << 3 #define ZN_BORDER_FLAG 1 << 4 #define ZN_CLFC_FLAG 1 << 5 /* Clear Label Format Cache. */ #define ZN_IMAGE_FLAG 1 << 6 /* Update image pointer. */ #define ZN_VIS_FLAG 1 << 7 /* Visibility has changed. */ #define ZN_MOVED_FLAG 1 << 8 /* Item has moved. */ #define ZN_ITEM_FLAG 1 << 9 /* Signal a change in an item type attribute. */ #define ZN_MAP_INFO_FLAG 1 << 10 /* Update mapinfo pointer. */ #define ZN_LAYOUT_FLAG 1 << 10 /* A layout need update. */ #define ZN_POLAR_FLAG 1 << 11 /* Signal a cartesian to polar change. */ #define ZN_CARTESIAN_FLAG 1 << 12 /* Signal a polar to cartesian change. */ #define ZN_TILE_FLAG 1 << 13 /* Update tile pointer. */ #define ZN_WINDOW_FLAG 1 << 14 /* Signal a change in a window type attribute. */ /* * Type and constant values for alignments. */ typedef char ZnJustify; #define ZnJustifyLeft TK_JUSTIFY_LEFT #define ZnJustifyRight TK_JUSTIFY_RIGHT #define ZnJustifyCenter TK_JUSTIFY_CENTER /* * Type and constant values for anchors. */ typedef Tk_Anchor ZnAnchor; #define ZnAnchorN TK_ANCHOR_N #define ZnAnchorS TK_ANCHOR_S #define ZnAnchorE TK_ANCHOR_E #define ZnAnchorW TK_ANCHOR_W #define ZnAnchorNE TK_ANCHOR_NE #define ZnAnchorNW TK_ANCHOR_NW #define ZnAnchorSE TK_ANCHOR_SE #define ZnAnchorSW TK_ANCHOR_SW #define ZnAnchorCenter TK_ANCHOR_CENTER /* * Type and constant values for borders. */ typedef unsigned char Border; #define NO_BORDER 0 #define LEFT_BORDER 1 #define RIGHT_BORDER 2 #define TOP_BORDER 4 #define BOTTOM_BORDER 8 #define CONTOUR_BORDER (LEFT_BORDER|RIGHT_BORDER|TOP_BORDER|BOTTOM_BORDER) #define COUNTER_OBLIQUE 16 #define OBLIQUE 32 #define LEFT_SPEC "left" #define RIGHT_SPEC "right" #define TOP_SPEC "top" #define BOTTOM_SPEC "bottom" #define CONTOUR_SPEC "contour" #define COUNTER_OBLIQUE_SPEC "counteroblique" #define OBLIQUE_SPEC "oblique" #define NO_BORDER_SPEC "noborder" /* * Type and constant values for line styles, line shapes and line ends. */ typedef unsigned char LineStyle; typedef unsigned char LineEndStyle; typedef unsigned char LineShape; /* LineStyle */ #define LINE_SIMPLE 0 #define LINE_DASHED 1 #define LINE_MIXED 2 #define LINE_DOTTED 3 /* LineShape */ #define LINE_STRAIGHT 0 #define LINE_LEFT_LIGHTNING 1 #define LINE_LEFT_CORNER 2 #define LINE_DOUBLE_LEFT_CORNER 3 #define LINE_RIGHT_LIGHTNING 4 #define LINE_RIGHT_CORNER 5 #define LINE_DOUBLE_RIGHT_CORNER 6 #define SIMPLE_SPEC "simple" #define DASHED_SPEC "dashed" #define DOTTED_SPEC "dotted" #define MIXED_SPEC "mixed" #define STRAIGHT_SPEC "straight" #define RIGHT_LIGHTNING_SPEC "rightlightning" #define LEFT_LIGHTNING_SPEC "leftlightning" #define RIGHT_CORNER_SPEC "rightcorner" #define LEFT_CORNER_SPEC "leftcorner" #define DOUBLE_RIGHT_CORNER_SPEC "doublerightcorner" #define DOUBLE_LEFT_CORNER_SPEC "doubleleftcorner" /* * Type and constant values for relief styles. */ typedef int ReliefStyle; /* Keep it an int to keep Tk happy */ #define RELIEF_BEVEL_OUT TK_RELIEF_RAISED #define RELIEF_FLAT TK_RELIEF_FLAT #define RELIEF_BEVEL_IN TK_RELIEF_SUNKEN #define RELIEF_GROOVE TK_RELIEF_GROOVE #define RELIEF_RIDGE TK_RELIEF_RIDGE /* * Number of steps for relief drawing. This translate in * RELIEF_STEPS*2+1 color steps in the color gradient. */ #define RELIEF_STEPS 6 /* * Type and constant values for automatic alignments. */ typedef struct { ZnBool automatic; ZnJustify align[3]; } AutoAlign; #define AA_LEFT 0 #define AA_CENTER 1 #define AA_RIGHT 2 #define AA_LEFT_SPEC "l" #define AA_CENTER_SPEC "c" #define AA_RIGHT_SPEC "r" #define AA_AUTO_SPEC "-" /* * Type for leader anchors. */ typedef struct { int left_x; /* left leader anchor field or percent of bbox */ int right_x; /* right leader anchor field or percent of bbox */ short left_y; /* left leader percent of bbox or < 0 if field */ short right_y; /* right leader percent of bbox or < 0 if field */ } LeaderAnchorsStruct, *LeaderAnchors; #define ZnPixel(color) ((color)->pixel) #define ZnFontId(font) (Tk_FontId(font)) #define ZnWindowId(win) (Tk_WindowId(win)) #define ZnTextWidth(font, text, len) (Tk_TextWidth(font, text, len)) #define ZnMalloc(size) (ckalloc(size)) #define ZnFree(ptr) (ckfree((char *)(ptr))) #define ZnRealloc(ptr, size) (ckrealloc((void *)(ptr), size)) #define ZnWarning(msg) (fprintf(stderr, "%s\n", (msg))) #define ZnUnspecifiedPattern None #define ZnUnspecifiedImage None #define ZnUnspecifiedColor NULL #define ZN_OK TCL_OK #define ZN_ERROR TCL_ERROR #define ZN_NO_ITEM NULL /* * Various constants used by items. */ #define ZN_ANY_CIRCLES -1 /* * Constants for item parts. The fields or item indexable parts are coded * as positive or null integers. The item specific parts (not indexable) are * coded as negatives begining at -2 up to -9 which is the current limit. The * -1 value is reserved to indicate no part. */ #define PART_NUMBER_TO_BIT(part) (1 << (ABS(part)-2)) #define ZN_NO_PART -1 /* * Some flags macros. */ #define ISSET(var, mask) ((var) & (mask)) #define ISCLEAR(var, mask) (((var) & (mask)) == 0) #define SET(var,mask) ((var) |= (mask)) #define CLEAR(var, mask) ((var) &= ~(mask)) #define ASSIGN(var, mask, bool) ((bool) ? SET((var), (mask)) : CLEAR((var), (mask))) #ifdef __CPLUSPLUS__ } #endif #endif /* _Types_h */