/* * 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 #define DEFAULT_TRACK_PRIORITY 5 #define DEFAULT_WAY_POINT_PRIORITY 4 #define DEFAULT_TABULAR_PRIORITY 3 #define DEFAULT_RECTANGLE_PRIORITY 2 #define DEFAULT_MULTI_POINT_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_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; RadarList tags; struct _WidgetInfo *wi; /* The radar 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 */ RadarBBox 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 _RadarTransfo *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; RadarList dependents; /* List of dependent items. */ #ifdef OM /* Overlap manager variables. * These variables are valid *only* if the overlap * manager is active. */ RadarBool 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; LabelFormat label_format; unsigned int num_fields; struct _FieldStruct *fields; RadarDim label_width; /* Describe the label size. Access these */ RadarDim label_height; /* 2 only with GetLabelBBox. -1 means * not up to date. */ RadarPoint label_pos; /* Describe the label origin. */ } FieldSetStruct, *FieldSet; /* * Item class record -- */ typedef int (*ItemInitMethod)(Item item, int *argc, Arg **args); typedef int (*ItemConfigureMethod)(Item item, int argc, RadarAttrList args, int *flags); typedef int (*ItemQueryMethod)(Item item, int argc, RadarAttrList args); typedef void (*ItemCloneMethod)(Item item); typedef void (*ItemDestroyMethod)(Item item); typedef void (*ItemDrawMethod)(Item item); typedef void (*ItemComputeCoordinatesMethod)(Item item, RadarBool force); typedef int (*ItemToAreaMethod)(Item item, RadarBBox *area, Tk_Uid tag_uid, int enclosed, RadarBool report); typedef RadarBool (*ItemIsSensitiveMethod)(Item item, int part); typedef double (*ItemPickMethod)(Item item, RadarPoint *point, Item start_item, int aperture, Item *a_item, int *a_part); typedef FieldSet (*ItemGetFieldSetMethod)(Item item); typedef void (*ItemGetAnchorMethod)(Item item, RadarAnchor anchor, RadarPoint *p); typedef RadarBool (*ItemGetClipVerticesMethod)(Item item, RadarPoint **points, int *num_points); typedef int (*ItemCoordsMethod)(Item item, int index, int cmd, RadarPoint **points, int *num_points); typedef void (*ItemPostScriptMethod)(Item item, PostScriptInfo ps_info); typedef struct _ItemClassStruct { int item_size; RadarBool has_fields; RadarBool has_parts; /* True for items with parts * other than fields. */ RadarBool has_anchors; char *name; RadarAttrConfig *attr_desc; ItemInitMethod Init; ItemCloneMethod Clone; ItemDestroyMethod Destroy; ItemConfigureMethod Configure; ItemQueryMethod Query; ItemGetFieldSetMethod GetFieldSet; ItemGetAnchorMethod GetAnchor; ItemGetClipVerticesMethod GetClipVertices; ItemCoordsMethod Coords; ItemComputeCoordinatesMethod ComputeCoordinates; ItemToAreaMethod ToArea; ItemDrawMethod Draw; ItemIsSensitiveMethod IsSensitive; ItemPickMethod Pick; 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, RadarAttrList args, RadarBool init); int (*QueryItem)(Item item, int field, int argc, RadarAttrList args); int (*AttributesInfo)(Item item, int field, int argc, Arg *args); void (*SetFieldsAutoAlign)(Item item, int alignment); void (*InsertItem)(Item item, Item group, Item mark_item, RadarBool before); void (*UpdateItemPriority)(Item item, Item mark_item, RadarBool 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 _RadarTransfo *t); void (*TranslateItem)(Item item, RadarReal tx, RadarReal ty); void (*ScaleItem)(Item item, RadarReal sx, RadarReal sy); void (*RotateItem)(Item item, RadarReal angle, RadarPoint *p); void (*Invalidate)(Item item, int reason); void (*InvalidateItems)(Item group, ItemClass item_class); void (*ComposeItemTransform)(Item item, struct _RadarTransfo *current_t, struct _RadarTransfo *new_t); void (*GetTransform)(Item item, struct _RadarTransfo *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, Arg **args); void (*AddItemClass)(ItemClass class); ItemClass (*LookupItemClass)(char *class_name); RadarList (*ItemClassList)(); void (*Damage)(struct _WidgetInfo *wi, RadarBBox *damage); void (*Repair)(struct _WidgetInfo *wi); void (*Update)(struct _WidgetInfo *wi); int (*ConfigureAttributes)(char *record, int field, int argc, Arg *args, int *flags); int (*QueryAttribute)(char *record, int field, Arg attr_name); void (*InitFields)(FieldSet field_set); void (*CloneFields)(FieldSet field_set); void (*FreeFields)(FieldSet field_set); void (*DrawFields)(FieldSet field_set); int (*FieldsToArea)(FieldSet field_set, RadarBBox *area); RadarBool (*IsFieldSensitive)(FieldSet field_set, int part); double (*FieldsPick)(FieldSet field_set, RadarPoint *p, int *part); void (*LeaderToLabel)(FieldSet field_set, RadarPoint *start, RadarPoint *end); void (*GetLabelBBox)(FieldSet field_set, RadarDim *w, RadarDim *h); void (*GetFieldBBox)(FieldSet field_set, unsigned int index, RadarBBox *field_bbox); void (*ResetTransformStack)(struct _WidgetInfo *wi); void (*ResetClipStack)(struct _WidgetInfo *wi); } ITEM_P; extern RadarItemClassId RadarArc; extern RadarItemClassId RadarMap; extern RadarItemClassId RadarTabular; extern RadarItemClassId RadarMosaic; extern RadarItemClassId RadarCurve; extern RadarItemClassId RadarRectangle; extern RadarItemClassId RadarReticle; extern RadarItemClassId RadarTrack; extern RadarItemClassId RadarWayPoint; extern RadarItemClassId RadarGroup; extern RadarItemClassId RadarIcon; extern RadarItemClassId RadarText; #endif /* _Item_h */