From 3261805fee19e346b4d1f84b23816daa1628764a Mon Sep 17 00:00:00 2001 From: lecoanet Date: Wed, 16 Apr 2003 09:49:22 +0000 Subject: Update from the Windows port and general cleanup/restructure --- generic/Window.c | 187 +++++++++++++++++++++++++++---------------------------- 1 file changed, 93 insertions(+), 94 deletions(-) (limited to 'generic/Window.c') diff --git a/generic/Window.c b/generic/Window.c index c577ff6..ddc21a3 100644 --- a/generic/Window.c +++ b/generic/Window.c @@ -24,7 +24,6 @@ * */ -#include #include "Item.h" #include "Geo.h" @@ -43,15 +42,15 @@ static const char compile_id[] = "$Compile: " __FILE__ " " __DATE__ " " __TIME__ ********************************************************************************** */ typedef struct _WindowItemStruct { - ItemStruct header; + ZnItemStruct header; /* Public data */ ZnPoint pos; - ZnAnchor anchor; - ZnAnchor connection_anchor; - ZnWindow win; - ZnDim width; - ZnDim height; + Tk_Anchor anchor; + Tk_Anchor connection_anchor; + Tk_Window win; + int width; + int height; /* Private data */ ZnPoint pos_dev; @@ -64,20 +63,20 @@ static ZnAttrConfig wind_attrs[] = { { ZN_CONFIG_ANCHOR, "-anchor", NULL, Tk_Offset(WindowItemStruct, anchor), 0, ZN_COORDS_FLAG, False }, { ZN_CONFIG_BOOL, "-composealpha", NULL, - Tk_Offset(WindowItemStruct, header.flags), COMPOSE_ALPHA_BIT, + Tk_Offset(WindowItemStruct, header.flags), ZN_COMPOSE_ALPHA_BIT, ZN_DRAW_FLAG, False }, { ZN_CONFIG_BOOL, "-composerotation", NULL, - Tk_Offset(WindowItemStruct, header.flags), COMPOSE_ROTATION_BIT, + Tk_Offset(WindowItemStruct, header.flags), ZN_COMPOSE_ROTATION_BIT, ZN_COORDS_FLAG, False }, { ZN_CONFIG_BOOL, "-composescale", NULL, - Tk_Offset(WindowItemStruct, header.flags), COMPOSE_SCALE_BIT, + Tk_Offset(WindowItemStruct, header.flags), ZN_COMPOSE_SCALE_BIT, ZN_COORDS_FLAG, False }, { ZN_CONFIG_ITEM, "-connecteditem", NULL, Tk_Offset(WindowItemStruct, header.connected_item), 0, ZN_COORDS_FLAG|ZN_ITEM_FLAG, False }, { ZN_CONFIG_ANCHOR, "-connectionanchor", NULL, Tk_Offset(WindowItemStruct, connection_anchor), 0, ZN_COORDS_FLAG, False }, - { ZN_CONFIG_DIM, "-height", NULL, + { ZN_CONFIG_INT, "-height", NULL, Tk_Offset(WindowItemStruct, height), 0, ZN_COORDS_FLAG, False }, { ZN_CONFIG_POINT, "-position", NULL, Tk_Offset(WindowItemStruct, pos), 0, ZN_COORDS_FLAG, False}, @@ -85,20 +84,20 @@ static ZnAttrConfig wind_attrs[] = { Tk_Offset(WindowItemStruct, header.priority), 0, ZN_DRAW_FLAG|ZN_REPICK_FLAG, False }, { ZN_CONFIG_BOOL, "-sensitive", NULL, - Tk_Offset(WindowItemStruct, header.flags), SENSITIVE_BIT, + Tk_Offset(WindowItemStruct, header.flags), ZN_SENSITIVE_BIT, ZN_REPICK_FLAG, False }, { ZN_CONFIG_TAG_LIST, "-tags", NULL, Tk_Offset(WindowItemStruct, header.tags), 0, 0, False }, { ZN_CONFIG_BOOL, "-visible", NULL, - Tk_Offset(WindowItemStruct, header.flags), VISIBLE_BIT, + Tk_Offset(WindowItemStruct, header.flags), ZN_VISIBLE_BIT, ZN_DRAW_FLAG|ZN_REPICK_FLAG|ZN_VIS_FLAG, False }, - { ZN_CONFIG_DIM, "-width", NULL, + { ZN_CONFIG_INT, "-width", NULL, Tk_Offset(WindowItemStruct, width), 0, ZN_COORDS_FLAG, False }, { ZN_CONFIG_WINDOW, "-window", NULL, Tk_Offset(WindowItemStruct, win), 0, ZN_COORDS_FLAG|ZN_WINDOW_FLAG, False }, - { ZN_CONFIG_END, NULL, NULL, 0, 0, 0 } + { ZN_CONFIG_END, NULL, NULL, 0, 0, 0, False } }; @@ -136,11 +135,11 @@ WindowDeleted(ClientData client_data, */ static void WindowItemRequest(ClientData client_data, - ZnWindow win) + Tk_Window win __unused) { WindowItem wind = (WindowItem) client_data; - ITEM.Invalidate((Item) wind, ZN_COORDS_FLAG); + ZnITEM.Invalidate((ZnItem) wind, ZN_COORDS_FLAG); } /* @@ -149,10 +148,10 @@ WindowItemRequest(ClientData client_data, */ static void WindowItemLostSlave(ClientData client_data, - ZnWindow win) + Tk_Window win __unused) { WindowItem wind = (WindowItem) client_data; - WidgetInfo *wi = ((Item) wind)->wi; + ZnWInfo *wi = ((ZnItem) wind)->wi; Tk_DeleteEventHandler(wi->win, StructureNotifyMask, WindowDeleted, (ClientData) wind); @@ -178,27 +177,27 @@ static Tk_GeomMgr wind_geom_type = { ********************************************************************************** */ static int -Init(Item item, - int *argc, - Tcl_Obj *CONST *args[]) +Init(ZnItem item, + int *argc __unused, + Tcl_Obj *CONST *args[] __unused) { WindowItem wind = (WindowItem) item; /* Init attributes */ - SET(item->flags, VISIBLE_BIT); - SET(item->flags, SENSITIVE_BIT); - SET(item->flags, COMPOSE_ALPHA_BIT); /* N.A */ - SET(item->flags, COMPOSE_ROTATION_BIT); - SET(item->flags, COMPOSE_SCALE_BIT); - item->priority = DEFAULT_WINDOW_PRIORITY; /* N.A */ + SET(item->flags, ZN_VISIBLE_BIT); + SET(item->flags, ZN_SENSITIVE_BIT); + SET(item->flags, ZN_COMPOSE_ALPHA_BIT); /* N.A */ + SET(item->flags, ZN_COMPOSE_ROTATION_BIT); + SET(item->flags, ZN_COMPOSE_SCALE_BIT); + item->priority = 0; wind->pos.x = wind->pos.y = 0.0; wind->width = wind->height = 0; - wind->anchor = ZnAnchorNW; - wind->connection_anchor = ZnAnchorSW; + wind->anchor = TK_ANCHOR_NW; + wind->connection_anchor = TK_ANCHOR_SW; wind->win = NULL; - return ZN_OK; + return TCL_OK; } @@ -210,7 +209,7 @@ Init(Item item, ********************************************************************************** */ static void -Clone(Item item) +Clone(ZnItem item) { WindowItem wind = (WindowItem) item; @@ -229,9 +228,9 @@ Clone(Item item) ********************************************************************************** */ static void -Destroy(Item item) +Destroy(ZnItem item) { - WidgetInfo *wi = item->wi; + ZnWInfo *wi = item->wi; WindowItem wind = (WindowItem) item; /* @@ -257,20 +256,20 @@ Destroy(Item item) ********************************************************************************** */ static int -Configure(Item item, +Configure(ZnItem item, int argc, Tcl_Obj *CONST argv[], int *flags) { WindowItem wind = (WindowItem) item; - WidgetInfo *wi = item->wi; - Item old_connected; - ZnWindow old_win; + ZnWInfo *wi = item->wi; + ZnItem old_connected; + Tk_Window old_win; old_connected = item->connected_item; old_win = wind->win; - if (ZnConfigureAttributes(wi, item, wind_attrs, argc, argv, flags) == ZN_ERROR) { - return ZN_ERROR; + if (ZnConfigureAttributes(wi, item, wind_attrs, argc, argv, flags) == TCL_ERROR) { + return TCL_ERROR; } if (ISSET(*flags, ZN_ITEM_FLAG)) { @@ -281,7 +280,7 @@ Configure(Item item, if ((item->connected_item == ZN_NO_ITEM) || (item->connected_item->class->has_anchors && (item->parent == item->connected_item->parent))) { - ITEM.UpdateItemDependency(item, old_connected); + ZnITEM.UpdateItemDependency(item, old_connected); } else { item->connected_item = old_connected; @@ -305,11 +304,11 @@ Configure(Item item, if ((wind->win != NULL) && ISSET(*flags, ZN_VIS_FLAG) && - ISCLEAR(item->flags, VISIBLE_BIT)) { + ISCLEAR(item->flags, ZN_VISIBLE_BIT)) { Tk_UnmapWindow(wind->win); } - return ZN_OK; + return TCL_OK; } @@ -321,15 +320,15 @@ Configure(Item item, ********************************************************************************** */ static int -Query(Item item, - int argc, +Query(ZnItem item, + int argc __unused, Tcl_Obj *CONST argv[]) { - if (ZnQueryAttribute(item->wi, item, wind_attrs, argv[0]) == ZN_ERROR) { - return ZN_ERROR; + if (ZnQueryAttribute(item->wi, item, wind_attrs, argv[0]) == TCL_ERROR) { + return TCL_ERROR; } - return ZN_OK; + return TCL_OK; } @@ -341,13 +340,13 @@ Query(Item item, ********************************************************************************** */ static void -ComputeCoordinates(Item item, - ZnBool force) +ComputeCoordinates(ZnItem item, + ZnBool force __unused) { - WidgetInfo *wi = item->wi; + ZnWInfo *wi = item->wi; WindowItem wind = (WindowItem) item; - ResetBBox(&item->item_bounding_box); + ZnResetBBox(&item->item_bounding_box); if (wind->win == NULL) { return; @@ -381,17 +380,17 @@ ComputeCoordinates(Item item, ZnTransformPoint(wi->current_transfo, &wind->pos, &wind->pos_dev); } - Anchor2Origin(&wind->pos_dev, wind->real_width, wind->real_height, wind->anchor, - &wind->pos_dev); - wind->pos_dev.x = REAL_TO_INT(wind->pos_dev.x); - wind->pos_dev.y = REAL_TO_INT(wind->pos_dev.y); + ZnAnchor2Origin(&wind->pos_dev, (ZnReal) wind->real_width, (ZnReal) wind->real_height, + wind->anchor, &wind->pos_dev); + wind->pos_dev.x = ZnNearestInt(wind->pos_dev.x); + wind->pos_dev.y = ZnNearestInt(wind->pos_dev.y); /* * Compute the bounding box. */ - AddPointToBBox(&item->item_bounding_box, wind->pos_dev.x, wind->pos_dev.y); - AddPointToBBox(&item->item_bounding_box, wind->pos_dev.x+wind->real_width, - wind->pos_dev.y+wind->real_height); + ZnAddPointToBBox(&item->item_bounding_box, wind->pos_dev.x, wind->pos_dev.y); + ZnAddPointToBBox(&item->item_bounding_box, wind->pos_dev.x+wind->real_width, + wind->pos_dev.y+wind->real_height); item->item_bounding_box.orig.x -= 1.0; item->item_bounding_box.orig.y -= 1.0; item->item_bounding_box.corner.x += 1.0; @@ -400,7 +399,7 @@ ComputeCoordinates(Item item, /* * Update connected items. */ - SET(item->flags, UPDATE_DEPENDENT_BIT); + SET(item->flags, ZN_UPDATE_DEPENDENT_BIT); } @@ -414,7 +413,7 @@ ComputeCoordinates(Item item, ********************************************************************************** */ static int -ToArea(Item item, +ToArea(ZnItem item, ZnToArea ta) { WindowItem wind = (WindowItem) item; @@ -429,7 +428,7 @@ ToArea(Item item, box.corner.x = box.orig.x + w; box.corner.y = box.orig.y + h; - return BBoxInBBox(&box, ta->area); + return ZnBBoxInBBox(&box, ta->area); } /* @@ -440,9 +439,9 @@ ToArea(Item item, ********************************************************************************** */ static void -Draw(Item item) +Draw(ZnItem item) { - WidgetInfo *wi = item->wi; + ZnWInfo *wi = item->wi; WindowItem wind = (WindowItem) item; if (wind->win == NULL) { @@ -474,14 +473,14 @@ Draw(Item item) (wind->real_width != Tk_Width(wind->win)) || (wind->real_height != Tk_Height(wind->win))) { Tk_MoveResizeWindow(wind->win, - wind->pos_dev.x, wind->pos_dev.y, + (int) wind->pos_dev.x, (int) wind->pos_dev.y, wind->real_width, wind->real_height); } Tk_MapWindow(wind->win); } else { Tk_MaintainGeometry(wind->win, wi->win, - wind->pos_dev.x, wind->pos_dev.y, + (int) wind->pos_dev.x, (int) wind->pos_dev.y, wind->real_width, wind->real_height); } @@ -496,8 +495,8 @@ Draw(Item item) ********************************************************************************** */ static ZnBool -IsSensitive(Item item, - int item_part) +IsSensitive(ZnItem item __unused, + int item_part __unused) { /* * Sensitivity can't be controlled. @@ -514,7 +513,7 @@ IsSensitive(Item item, ********************************************************************************** */ static double -Pick(Item item, +Pick(ZnItem item, ZnPick ps) { WindowItem wind = (WindowItem) item; @@ -526,7 +525,7 @@ Pick(Item item, if (wind->win != NULL) { box.corner.x = box.orig.x + wind->real_width; box.corner.y = box.orig.y + wind->real_height; - dist = RectangleToPointDist(&box, p); + dist = ZnRectangleToPointDist(&box, p); if (dist <= 0.0) { dist = 0.0; } @@ -543,8 +542,8 @@ Pick(Item item, ********************************************************************************** */ static void -PostScript(Item item, - PostScriptInfo ps_info) +PostScript(ZnItem item __unused, + ZnPostScriptInfo ps_info __unused) { } @@ -557,15 +556,15 @@ PostScript(Item item, ********************************************************************************** */ static void -GetAnchor(Item item, - ZnAnchor anchor, +GetAnchor(ZnItem item, + Tk_Anchor anchor, ZnPoint *p) { WindowItem wind = (WindowItem) item; if (wind->win != NULL) { - Origin2Anchor(&wind->pos_dev, wind->real_width, - wind->real_height, anchor, p); + ZnOrigin2Anchor(&wind->pos_dev, (ZnReal) wind->real_width, + (ZnReal) wind->real_height, anchor, p); } else { p->x = p->y = 0.0; @@ -582,7 +581,7 @@ GetAnchor(Item item, ********************************************************************************** */ static ZnBool -GetClipVertices(Item item, +GetClipVertices(ZnItem item, ZnTriStrip *tristrip) { WindowItem wind = (WindowItem) item; @@ -595,7 +594,7 @@ GetClipVertices(Item item, h = wind->real_height; } points = ZnListArray(item->wi->work_pts); - TRI_STRIP1(tristrip, points, 2, False); + ZnTriStrip1(tristrip, points, 2, False); points[0] = wind->pos_dev; points[1].x = points[0].x + w; points[1].y = points[0].y + h; @@ -615,35 +614,35 @@ GetClipVertices(Item item, ********************************************************************************** */ static int -Coords(Item item, - int contour, - int index, - int cmd, - ZnPoint **pts, - char **controls, - int *num_pts) +Coords(ZnItem item, + int contour __unused, + int index __unused, + int cmd, + ZnPoint **pts, + char **controls __unused, + unsigned int *num_pts) { WindowItem wind = (WindowItem) item; - if ((cmd == COORDS_ADD) || (cmd == COORDS_ADD_LAST) || (cmd == COORDS_REMOVE)) { + if ((cmd == ZN_COORDS_ADD) || (cmd == ZN_COORDS_ADD_LAST) || (cmd == ZN_COORDS_REMOVE)) { Tcl_AppendResult(item->wi->interp, " windows can't add or remove vertices", NULL); - return ZN_ERROR; + return TCL_ERROR; } - else if ((cmd == COORDS_REPLACE) || (cmd == COORDS_REPLACE_ALL)) { + else if ((cmd == ZN_COORDS_REPLACE) || (cmd == ZN_COORDS_REPLACE_ALL)) { if (*num_pts == 0) { Tcl_AppendResult(item->wi->interp, " coords command need 1 point on windows", NULL); - return ZN_ERROR; + return TCL_ERROR; } wind->pos = (*pts)[0]; - ITEM.Invalidate(item, ZN_COORDS_FLAG); + ZnITEM.Invalidate(item, ZN_COORDS_FLAG); } - else if ((cmd == COORDS_READ) || (cmd == COORDS_READ_ALL)) { + else if ((cmd == ZN_COORDS_READ) || (cmd == ZN_COORDS_READ_ALL)) { *num_pts = 1; *pts = &wind->pos; } - return ZN_OK; + return TCL_OK; } @@ -654,7 +653,7 @@ Coords(Item item, * ********************************************************************************** */ -static ItemClassStruct WINDOW_ITEM_CLASS = { +static ZnItemClassStruct WINDOW_ITEM_CLASS = { sizeof(WindowItemStruct), 0, /* num_parts */ True, /* has_anchors */ @@ -687,4 +686,4 @@ static ItemClassStruct WINDOW_ITEM_CLASS = { PostScript }; -ZnItemClassId ZnWind = (ZnItemClassId) &WINDOW_ITEM_CLASS; +ZnItemClassId ZnWindow = (ZnItemClassId) &WINDOW_ITEM_CLASS; -- cgit v1.1