/* * Item.h -- Header to access items' common state and functions. * * Authors : Patrick Lecoanet. * Creation date : * * $Id$ */ /* * Copyright (c) 1996 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 _Item_h #define _Item_h #include "PostScript.h" #include "Attrs.h" #include "List.h" #include #include #define DEFAULT_TRACK_PRIORITY 5 #define DEFAULT_WAY_POINT_PRIORITY 4 #define DEFAULT_TABULAR_PRIORITY 3 #define DEFAULT_RECTANGLE_PRIORITY 2 #define DEFAULT_CURVE_PRIORITY 2 #define DEFAULT_BEZIER_PRIORITY 2 #define DEFAULT_ARC_PRIORITY 2 #define DEFAULT_RETICLE_PRIORITY 2 #define DEFAULT_MAP_PRIORITY 1 #define DEFAULT_GROUP_PRIORITY 0 #define DEFAULT_ICON_PRIORITY 2 #define DEFAULT_TEXT_PRIORITY 2 #define DEFAULT_WINDOW_PRIORITY 0 /* N/A */ #define DEFAULT_MOSAIC_PRIORITY 0 #define DEFAULT_MARKER_SIZE 0 #define DEFAULT_VISIBLE_HISTORY_SIZE 6 #define DEFAULT_MANAGED_HISTORY_SIZE 6 #define DEFAULT_SPEED_VECTOR_LENGTH 3 #define DEFAULT_RETICLE_STEP_SIZE 80 #define DEFAULT_RETICLE_PERIOD 5 #define DEFAULT_LABEL_ANGLE 20 #define DEFAULT_LABEL_DISTANCE 50 #define DEFAULT_LINE_WIDTH 1 #define DEFAULT_TILE_SIZE 1 #define DEFAULT_ROW_COUNT 1 #define DEFAULT_COLUMN_COUNT 1 /* * Item flags values. */ #define VISIBLE_BIT 1 #define SENSITIVE_BIT 2 #define ATOMIC_BIT 4 #define UPDATE_DEPENDENT_BIT 16 #define COMPOSE_SCALE_BIT 32 #define COMPOSE_ROTATION_BIT 64 /* * Item record header -- */ typedef struct _ItemStruct { /* Private data */ int id; ZnList tags; struct _WidgetInfo *wi; /* The widget this item is on */ struct _ItemClassStruct *class; /* item class */ struct _ItemStruct *previous; /* previous item in group list */ struct _ItemStruct *next; /* next item in group list */ ZnBBox item_bounding_box; /* device item bounding box */ /* Common attributes */ unsigned char flags; unsigned char part_sensitive; /* Currently limited to 8 parts per item */ short inv_flags; struct _ItemStruct *parent; int priority; struct _ZnTransfo *transfo; struct _ItemStruct *connected_item; /* Item this item is connected to */ } ItemStruct, *Item; /* * Group item special record. */ typedef struct _GroupItemStruct { ItemStruct header; /* Public data */ Item clip; /* Private data */ Item head; /* Doubly linked list of all items. */ Item tail; ZnList dependents; /* List of dependent items. */ #ifdef OM /* Overlap manager variables. * These variables are valid *only* if the overlap * manager is active. */ ZnBool call_om; /* Tell if there is a need to call the */ /* overlap manager. */ #endif } GroupItemStruct, *GroupItem; /* * Field array management record. */ typedef struct _FieldSetStruct { struct _WidgetInfo *wi; ZnLabelFormat label_format; unsigned int num_fields; struct _FieldStruct *fields; ZnDim label_width; /* Describe the label size. Access these */ ZnDim label_height; /* 2 only with GetLabelBBox. -1 means * not up to date. */ ZnPoint label_pos; /* Describe the label origin. */ } FieldSetStruct, *FieldSet; /* * Item class record -- */ typedef int (*ItemInitMethod)(Item item, int *argc, Tcl_Obj *CONST *args[]); typedef int (*ItemConfigureMethod)(Item item, int argc, Tcl_Obj *CONST args[], int *flags); typedef int (*ItemQueryMethod)(Item item, int argc, Tcl_Obj *CONST args[]); typedef void (*ItemCloneMethod)(Item item); typedef void (*ItemDestroyMethod)(Item item); typedef void (*ItemDrawMethod)(Item item); typedef void (*ItemRenderMethod)(Item item); typedef void (*ItemComputeCoordinatesMethod)(Item item, ZnBool force); typedef int (*ItemToAreaMethod)(Item item, ZnBBox *area, Tk_Uid tag_uid, int enclosed, ZnBool report); typedef ZnBool (*ItemIsSensitiveMethod)(Item item, int part); typedef double (*ItemPickMethod)(Item item, ZnPoint *point, Item start_item, int aperture, Item *a_item, int *a_part); typedef FieldSet (*ItemGetFieldSetMethod)(Item item); typedef void (*ItemContourMethod)(Item item, int cmd, ZnPoly *poly); typedef void (*ItemPickVertexMethod)(Item item, ZnPoint *p, int *contour, int *vertex, int *o_vertex); typedef void (*ItemGetAnchorMethod)(Item item, ZnAnchor anchor, ZnPoint *p); typedef ZnBool (*ItemGetClipVerticesMethod)(Item item, ZnPoly *points); typedef int (*ItemCoordsMethod)(Item item, int contour, int index, int cmd, ZnPoint **points, int *num_points); typedef void (*ItemInsertCharsMethod)(Item item, int index, char *chars); typedef void (*ItemDeleteCharsMethod)(Item item, int first, int last); typedef void (*ItemCursorMethod)(Item item, int index); typedef int (*ItemIndexMethod)(Item item, Tcl_Obj *index_spec, int *index); typedef int (*ItemPartMethod)(Item item, Tcl_Obj **part_spec, int *part); typedef int (*ItemSelectionMethod)(Item item, int offset, char *chars, int max_chars); typedef void (*ItemPostScriptMethod)(Item item, PostScriptInfo ps_info); typedef struct _ItemClassStruct { int item_size; ZnBool has_fields; int num_parts; /* 0 if no special parts, else * gives how many parts exist. */ ZnBool has_anchors; char *name; ZnAttrConfig *attr_desc; ItemInitMethod Init; ItemCloneMethod Clone; ItemDestroyMethod Destroy; ItemConfigureMethod Configure; ItemQueryMethod Query; ItemGetFieldSetMethod GetFieldSet; ItemGetAnchorMethod GetAnchor; ItemGetClipVerticesMethod GetClipVertices; ItemCoordsMethod Coords; ItemInsertCharsMethod InsertChars; ItemDeleteCharsMethod DeleteChars; ItemCursorMethod Cursor; ItemIndexMethod Index; ItemPartMethod Part; ItemSelectionMethod Selection; ItemContourMethod Contour; ItemComputeCoordinatesMethod ComputeCoordinates; ItemToAreaMethod ToArea; ItemDrawMethod Draw; ItemRenderMethod Render; ItemIsSensitiveMethod IsSensitive; ItemPickMethod Pick; ItemPickVertexMethod PickVertex; ItemPostScriptMethod PostScript; } ItemClassStruct, *ItemClass; /* ********************************************************************************** * * Generic methods for all items. * ********************************************************************************** */ extern struct _ITEM { Item (*CloneItem)(Item model); void (*DestroyItem)(Item item); int (*ConfigureItem)(Item item, int field, int argc, Tcl_Obj *CONST args[], ZnBool init); int (*QueryItem)(Item item, int field, int argc, Tcl_Obj *CONST args[]); int (*AttributesInfo)(Item item, int field, int argc, Tcl_Obj *CONST args[]); void (*SetFieldsAutoAlign)(Item item, int alignment); void (*InsertItem)(Item item, Item group, Item mark_item, ZnBool before); void (*UpdateItemPriority)(Item item, Item mark_item, ZnBool before); void (*InsertDependentItem)(Item item); void (*UpdateItemDependency)(Item item, Item old_connection); void (*RemoveItem)(Item item); void (*SetId)(Item item); void (*FreeId)(Item item); void (*AddTag)(Item item, Tk_Uid tag); void (*RemoveTag)(Item item, Tk_Uid tag); void (*FreeTags)(Item item); void (*ResetTransfo)(Item item); void (*SetTransfo)(Item item, struct _ZnTransfo *t); void (*TranslateItem)(Item item, ZnReal tx, ZnReal ty); void (*ScaleItem)(Item item, ZnReal sx, ZnReal sy); void (*RotateItem)(Item item, ZnReal angle, ZnPoint *p); void (*Invalidate)(Item item, int reason); void (*InvalidateItems)(Item group, ItemClass item_class); void (*GetItemTransform)(Item item, struct _ZnTransfo *t); } ITEM; /* ********************************************************************************** * * Methods defined in item.c useful for writing items. * ********************************************************************************** */ extern struct _ITEM_P { void (*GlobalModuleInit)(); Item (*CreateItem)(struct _WidgetInfo *wi, ItemClass item_class, int *argc, Tcl_Obj *CONST *args[]); void (*AddItemClass)(ItemClass class); ItemClass (*LookupItemClass)(char *class_name); ZnList (*ItemClassList)(); void (*Damage)(struct _WidgetInfo *wi, ZnBBox *damage); void (*Repair)(struct _WidgetInfo *wi); void (*Update)(struct _WidgetInfo *wi); int (*ConfigureAttributes)(char *record, int field, int argc, Tcl_Obj *CONST args[], int *flags); int (*QueryAttribute)(char *record, int field, Tcl_Obj *attr_name); void (*InitFields)(FieldSet field_set); void (*CloneFields)(FieldSet field_set); void (*FreeFields)(FieldSet field_set); void (*DrawFields)(FieldSet field_set); void (*RenderFields)(FieldSet field_set); int (*FieldsToArea)(FieldSet field_set, ZnBBox *area); ZnBool (*IsFieldSensitive)(FieldSet field_set, int part); double (*FieldsPick)(FieldSet field_set, ZnPoint *p, int *part); void (*LeaderToLabel)(FieldSet field_set, ZnPoint *start, ZnPoint *end); void (*GetLabelBBox)(FieldSet field_set, ZnDim *w, ZnDim *h); void (*GetFieldBBox)(FieldSet field_set, unsigned int index, ZnBBox *field_bbox); void (*InitTransformStack)(struct _WidgetInfo *wi); void (*FreeTransformStack)(struct _WidgetInfo *wi); void (*ResetTransformStack)(struct _WidgetInfo *wi); void (*PushTransform)(struct _WidgetInfo *wi, struct _ZnTransfo *transfo, ZnBool compose_scale, ZnBool compose_rot); void (*PopTransform)(struct _WidgetInfo *wi); void (*InitClipStack)(struct _WidgetInfo *wi); void (*FreeClipStack)(struct _WidgetInfo *wi); void (*ResetClipStack)(struct _WidgetInfo *wi); void (*PushClip)(struct _WidgetInfo *wi, ZnPoly *poly, ZnBool simple, ZnBool set_gc); void (*PopClip)(struct _WidgetInfo *wi, ZnBool set_gc); ZnBool (*CurrentClip)(struct _WidgetInfo *wi, Region *reg, ZnBBox **clip_box, ZnBool *simple); void (*RenderSVP)(struct _WidgetInfo *wi, ArtSVP *svp, int r, int g, int b, int a, int tile_x, int tile_y, ArtPixBuf *tile); } ITEM_P; extern ZnItemClassId ZnArc; extern ZnItemClassId ZnMap; extern ZnItemClassId ZnTabular; extern ZnItemClassId ZnMosaic; extern ZnItemClassId ZnCurve; extern ZnItemClassId ZnBezier; extern ZnItemClassId ZnRectangle; extern ZnItemClassId ZnReticle; extern ZnItemClassId ZnTrack; extern ZnItemClassId ZnWayPoint; extern ZnItemClassId ZnGroup; extern ZnItemClassId ZnIcon; extern ZnItemClassId ZnText; extern ZnItemClassId ZnWind; #endif /* _Item_h */