aboutsummaryrefslogtreecommitdiff
path: root/generic/tkZinc.c
diff options
context:
space:
mode:
authorlecoanet2003-04-16 09:49:22 +0000
committerlecoanet2003-04-16 09:49:22 +0000
commit3261805fee19e346b4d1f84b23816daa1628764a (patch)
tree63ca1d7e4b0a3d9ae49cc0888e58033c3ef3fe22 /generic/tkZinc.c
parenteed2656db0adae2c234c3d74af0913746ed5c444 (diff)
downloadtkzinc-3261805fee19e346b4d1f84b23816daa1628764a.zip
tkzinc-3261805fee19e346b4d1f84b23816daa1628764a.tar.gz
tkzinc-3261805fee19e346b4d1f84b23816daa1628764a.tar.bz2
tkzinc-3261805fee19e346b4d1f84b23816daa1628764a.tar.xz
Update from the Windows port and general cleanup/restructure
Diffstat (limited to 'generic/tkZinc.c')
-rw-r--r--generic/tkZinc.c2313
1 files changed, 1433 insertions, 880 deletions
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index 1a8a3f0..4f5e7a3 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -27,16 +27,18 @@
*/
/*
- * Some functions in this file are derived from tkCanvas.c and thus
- * copyrighted:
+ * Some functions and code excerpts in this file are from tkCanvas.c
+ * and thus copyrighted:
*
* Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright (c) 1998-1999 by Scriptics Corporation.
*
*/
static const char rcs_id[]="$Id$";
static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " $";
+static const char * const zinc_version = "zinc-version-" VERSION;
#include "Types.h"
@@ -46,14 +48,15 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
#include "WidgetInfo.h"
#include "tkZinc.h"
#include "MapInfo.h"
-#include "patchlvl.h"
#include "OverlapMan.h"
#include "Track.h"
#include "Transfo.h"
#include "Image.h"
#include "Draw.h"
#include "Color.h"
+#ifndef _WIN32
#include "perfos.h"
+#endif
#include "libtess/glu.h"
#include <ctype.h>
@@ -62,9 +65,6 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
#include <string.h>
#include <math.h>
#include <X11/Xatom.h>
-#ifdef GLX
-#include <GL/glx.h>
-#endif
typedef struct _TagSearchExpr {
@@ -78,11 +78,9 @@ typedef struct _TagSearchExpr {
} TagSearchExpr;
-#define INTEGER_SPACE 30
-
#define SYMBOL_WIDTH 8
#define SYMBOL_HEIGHT 8
-static char SYMBOLS_BITS[][SYMBOL_WIDTH*SYMBOL_HEIGHT/8] = {
+static unsigned char SYMBOLS_BITS[][SYMBOL_WIDTH*SYMBOL_HEIGHT/8] = {
{ 0x18, 0x18, 0x24, 0x24, 0x5a, 0x5a, 0x81, 0xff },
{ 0xff, 0x81, 0x99, 0xbd, 0xbd, 0x99, 0x81, 0xff },
{ 0x18, 0x24, 0x42, 0x99, 0x99, 0x42, 0x24, 0x18 },
@@ -113,7 +111,8 @@ static unsigned char dither4x4[4][4] = {
{ 3, 11, 1, 9 },
{ 15, 7, 13, 5 }
};
-static unsigned char bitmaps[NUM_ALPHA_STEPS][32][4];
+
+static unsigned char bitmaps[ZN_NUM_ALPHA_STEPS][32][4];
static Tk_Uid all_uid;
static Tk_Uid current_uid;
@@ -175,77 +174,91 @@ static Tk_CustomOption bitmapOption = {
*/
static Tk_ConfigSpec config_specs[] = {
{TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- "2", Tk_Offset(WidgetInfo, border_width), 0},
+ "2", Tk_Offset(ZnWInfo, border_width), 0, NULL},
{TK_CONFIG_CUSTOM, "-backcolor", "backColor", "BackColor",
- "#c3c3c3", Tk_Offset(WidgetInfo, back_color), 0, &gradientOption},
+ "#c3c3c3", Tk_Offset(ZnWInfo, back_color), 0, &gradientOption},
+ {TK_CONFIG_BOOLEAN, "-confine", "confine", "Confine",
+ "1", Tk_Offset(ZnWInfo, confine), 0, NULL},
{TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- "", Tk_Offset(WidgetInfo, cursor), TK_CONFIG_NULL_OK},
+ "", Tk_Offset(ZnWInfo, cursor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_FONT, "-font", "font", "Font",
"-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-*",
- Tk_Offset(WidgetInfo, font), 0},
+ Tk_Offset(ZnWInfo, font), 0, NULL},
{TK_CONFIG_CUSTOM, "-forecolor", "foreColor", "Foreground",
- "Black", Tk_Offset(WidgetInfo, fore_color), 0, &gradientOption},
+ "Black", Tk_Offset(ZnWInfo, fore_color), 0, &gradientOption},
+#ifndef _WIN32
{TK_CONFIG_BOOLEAN, "-fullreshape", "fullReshape", "FullReshape",
- "1", Tk_Offset(WidgetInfo, full_reshape), 0},
+ "1", Tk_Offset(ZnWInfo, full_reshape), 0, NULL},
+#endif
{TK_CONFIG_PIXELS, "-height", "height", "Height",
- "7c", Tk_Offset(WidgetInfo, opt_height), 0},
+ "7c", Tk_Offset(ZnWInfo, opt_height), 0, NULL},
{TK_CONFIG_CUSTOM, "-highlightbackground", "highlightBackground", "HighlightBackground",
- "#c3c3c3", Tk_Offset(WidgetInfo, highlight_bg_color), 0, &gradientOption},
+ "#c3c3c3", Tk_Offset(ZnWInfo, highlight_bg_color), 0, &gradientOption},
{TK_CONFIG_CUSTOM, "-highlightcolor", "highlightColor", "HighlightColor",
- "Black", Tk_Offset(WidgetInfo, highlight_color), 0, &gradientOption},
+ "Black", Tk_Offset(ZnWInfo, highlight_color), 0, &gradientOption},
{TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness",
- "2", Tk_Offset(WidgetInfo, highlight_width), 0},
+ "2", Tk_Offset(ZnWInfo, highlight_width), 0, NULL},
{TK_CONFIG_CUSTOM, "-insertbackground", "insertBackground", "Foreground",
- "Black", Tk_Offset(WidgetInfo, text_info.insert_color), 0, &gradientOption},
+ "Black", Tk_Offset(ZnWInfo, text_info.insert_color), 0, &gradientOption},
{TK_CONFIG_INT, "-insertofftime", "insertOffTime", "OffTime",
- "300", Tk_Offset(WidgetInfo, insert_off_time), 0},
+ "300", Tk_Offset(ZnWInfo, insert_off_time), 0, NULL},
{TK_CONFIG_INT, "-insertontime", "insertOnTime", "OnTime",
- "600", Tk_Offset(WidgetInfo, insert_on_time), 0},
+ "600", Tk_Offset(ZnWInfo, insert_on_time), 0, NULL},
{TK_CONFIG_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- "2", Tk_Offset(WidgetInfo, text_info.insert_width), 0},
+ "2", Tk_Offset(ZnWInfo, text_info.insert_width), 0, NULL},
{TK_CONFIG_CUSTOM, "-mapdistancesymbol", "mapDistanceSymbol", "MapDistanceSymbol",
- "AtcSymbol19", Tk_Offset(WidgetInfo, map_distance_symbol),
+ "AtcSymbol19", Tk_Offset(ZnWInfo, map_distance_symbol),
TK_CONFIG_NULL_OK, &bitmapOption},
{TK_CONFIG_FONT, "-maptextfont", "mapTextFont", "MapTextFont",
"-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-*",
- Tk_Offset(WidgetInfo, map_text_font), 0},
+ Tk_Offset(ZnWInfo, map_text_font), 0, NULL},
#ifdef OM
{TK_CONFIG_INT, "-overlapmanager", "overlapManager", "OverlapManager", "1",
- Tk_Offset(WidgetInfo, om_group_id), 0},
+ Tk_Offset(ZnWInfo, om_group_id), 0, NULL},
#endif
{TK_CONFIG_INT, "-pickaperture", "pickAperture", "PickAperture",
- "1", Tk_Offset(WidgetInfo, pick_aperture), 0},
+ "1", Tk_Offset(ZnWInfo, pick_aperture), 0, NULL},
{TK_CONFIG_CUSTOM, "-relief", "relief", "Relief",
- "flat", Tk_Offset(WidgetInfo, relief), 0, &reliefOption},
+ "flat", Tk_Offset(ZnWInfo, relief), 0, &reliefOption},
{TK_CONFIG_INT, "-render", "render", "Render",
- "0", Tk_Offset(WidgetInfo, render), 0},
+ "0", Tk_Offset(ZnWInfo, render), 0, NULL},
{TK_CONFIG_BOOLEAN, "-reshape", "reshape", "Reshape",
- "1", Tk_Offset(WidgetInfo, reshape), 0},
+ "1", Tk_Offset(ZnWInfo, reshape), 0, NULL},
+ {TK_CONFIG_STRING, "-scrollregion", "scrollRegion", "ScrollRegion",
+ "", Tk_Offset(ZnWInfo, region), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-selectbackground", "selectBackground", "Foreground",
- "#a0a0a0", Tk_Offset(WidgetInfo, text_info.sel_color), 0, &gradientOption},
+ "#a0a0a0", Tk_Offset(ZnWInfo, text_info.sel_color), 0, &gradientOption},
{TK_CONFIG_DOUBLE, "-speedvectorlength", "speedVectorLength",
- "SpeedVectorLength", "3", Tk_Offset(WidgetInfo, speed_vector_length), 0},
+ "SpeedVectorLength", "3", Tk_Offset(ZnWInfo, speed_vector_length), 0, NULL},
{TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- NULL, Tk_Offset(WidgetInfo, take_focus), TK_CONFIG_NULL_OK},
+ NULL, Tk_Offset(ZnWInfo, take_focus), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-tile", "tile", "Tile",
- "", Tk_Offset(WidgetInfo, tile), 0, &imageOption},
+ "", Tk_Offset(ZnWInfo, tile), 0, &imageOption},
{TK_CONFIG_BOOLEAN, "-trackmanagehistory", "trackManageHistory", "TrackManageHistory",
- "1", Tk_Offset(WidgetInfo, track_manage_history), 0},
+ "1", Tk_Offset(ZnWInfo, track_manage_history), 0, NULL},
{TK_CONFIG_INT, "-trackmanagedhistorysize", "trackManagedHistorySize",
- "TrackManagedHistorySize", "6", Tk_Offset(WidgetInfo, track_managed_history_size), 0},
+ "TrackManagedHistorySize", "6", Tk_Offset(ZnWInfo, track_managed_history_size), 0, NULL},
{TK_CONFIG_PIXELS, "-width", "width", "Width",
- "10c", Tk_Offset(WidgetInfo, opt_width), 0},
+ "10c", Tk_Offset(ZnWInfo, opt_width), 0, NULL},
+ {TK_CONFIG_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
+ "", Tk_Offset(ZnWInfo, x_scroll_cmd), TK_CONFIG_NULL_OK, NULL},
+ {TK_CONFIG_PIXELS, "-xscrollincrement", "xScrollIncrement", "ScrollIncrement",
+ "0", Tk_Offset(ZnWInfo, x_scroll_incr), 0, NULL},
+ {TK_CONFIG_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
+ "", Tk_Offset(ZnWInfo, y_scroll_cmd), TK_CONFIG_NULL_OK, NULL},
+ {TK_CONFIG_PIXELS, "-yscrollincrement", "yScrollIncrement", "ScrollIncrement",
+ "0", Tk_Offset(ZnWInfo, y_scroll_incr), 0, NULL},
/*
* Debug options.
*/
{TK_CONFIG_BOOLEAN, "-drawbboxes", "drawBBoxes",
- "DrawBBoxes", "0", Tk_Offset(WidgetInfo, draw_bboxes), 0},
+ "DrawBBoxes", "0", Tk_Offset(ZnWInfo, draw_bboxes), 0, NULL},
{TK_CONFIG_CUSTOM, "-bboxcolor", "bboxColor", "BBoxColor",
- "Pink", Tk_Offset(WidgetInfo, bbox_color), 0, &gradientOption},
+ "Pink", Tk_Offset(ZnWInfo, bbox_color), 0, &gradientOption},
{TK_CONFIG_INT, "-lightangle", "lightAngle", "LightAngle",
- "120", Tk_Offset(WidgetInfo, light_angle), 0},
+ "120", Tk_Offset(ZnWInfo, light_angle), 0, NULL},
- {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0}
+ {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
/*
@@ -253,35 +266,41 @@ static Tk_ConfigSpec config_specs[] = {
*/
#define BORDER_WIDTH_SPEC 0
#define BACK_COLOR_SPEC 1
-#define CURSOR_SPEC 2
-#define FONT_SPEC 3
-#define FORE_COLOR_SPEC 4
-#define FULL_RESHAPE_SPEC 5
-#define HEIGHT_SPEC 6
-#define HIGHLIGHT_BACK_COLOR_SPEC 7
-#define HIGHLIGHT_COLOR_SPEC 8
-#define HIGHLIGHT_THICKNESS_SPEC 9
-#define INSERT_COLOR_SPEC 10
-#define INSERT_OFF_TIME_SPEC 11
-#define INSERT_ON_TIME_SPEC 12
-#define INSERT_WIDTH_SPEC 13
-#define MAP_DISTANCE_SYMBOL_SPEC 14
-#define MAP_TEXT_FONT_SPEC 15
-#define OVERLAP_MANAGER_SPEC 16
-#define PICK_APERTURE_SPEC 17
-#define RELIEF_SPEC 18
-#define RENDER_SPEC 19
-#define RESHAPE_SPEC 20
-#define SELECT_COLOR_SPEC 21
-#define SPEED_VECTOR_LENGTH_SPEC 22
-#define TAKE_FOCUS_SPEC 23
-#define TILE_SPEC 24
-#define MANAGE_HISTORY_SPEC 25
-#define MANAGED_HISTORY_SIZE_SPEC 26
-#define WIDTH_SPEC 27
-#define BBOXES_SPEC 28
-#define BBOXES_COLOR_SPEC 29
-#define LIGHT_ANGLE_SPEC 30
+#define CONFINE_SPEC 2
+#define CURSOR_SPEC 3
+#define FONT_SPEC 4
+#define FORE_COLOR_SPEC 5
+#define FULL_RESHAPE_SPEC 6
+#define HEIGHT_SPEC 7
+#define HIGHLIGHT_BACK_COLOR_SPEC 8
+#define HIGHLIGHT_COLOR_SPEC 9
+#define HIGHLIGHT_THICKNESS_SPEC 10
+#define INSERT_COLOR_SPEC 11
+#define INSERT_OFF_TIME_SPEC 12
+#define INSERT_ON_TIME_SPEC 13
+#define INSERT_WIDTH_SPEC 14
+#define MAP_DISTANCE_SYMBOL_SPEC 15
+#define MAP_TEXT_FONT_SPEC 16
+#define OVERLAP_MANAGER_SPEC 17
+#define PICK_APERTURE_SPEC 18
+#define RELIEF_SPEC 19
+#define RENDER_SPEC 20
+#define RESHAPE_SPEC 21
+#define SCROLL_REGION_SPEC 22
+#define SELECT_COLOR_SPEC 23
+#define SPEED_VECTOR_LENGTH_SPEC 24
+#define TAKE_FOCUS_SPEC 25
+#define TILE_SPEC 26
+#define MANAGE_HISTORY_SPEC 27
+#define MANAGED_HISTORY_SIZE_SPEC 28
+#define WIDTH_SPEC 29
+#define X_SCROLL_CMD_SPEC 30
+#define X_SCROLL_INCREMENT_SPEC 31
+#define Y_SCROLL_CMD_SPEC 32
+#define Y_SCROLL_INCREMENT_SPEC 33
+#define BBOXES_SPEC 34
+#define BBOXES_COLOR_SPEC 35
+#define LIGHT_ANGLE_SPEC 36
static void CmdDeleted _ANSI_ARGS_((ClientData client_data));
@@ -289,30 +308,19 @@ static void Event _ANSI_ARGS_((ClientData client_data, XEvent *eventPtr));
static void Bind _ANSI_ARGS_((ClientData client_data, XEvent *eventPtr));
static int FetchSelection _ANSI_ARGS_((ClientData clientData, int offset,
char *buffer, int maxBytes));
-static void SelectTo _ANSI_ARGS_((Item item, int field, int index));
+static void SelectTo _ANSI_ARGS_((ZnItem item, int field, int index));
static int WidgetObjCmd _ANSI_ARGS_((ClientData client_data,
Tcl_Interp *, int argc, Tcl_Obj *CONST args[]));
-static int Configure _ANSI_ARGS_((Tcl_Interp *interp, WidgetInfo *wi,
+static int Configure _ANSI_ARGS_((Tcl_Interp *interp, ZnWInfo *wi,
int argc, Tcl_Obj *CONST args[], int flags));
static void Redisplay _ANSI_ARGS_((ClientData client_data));
static void Destroy _ANSI_ARGS_((char *mem_ptr));
static void InitZinc _ANSI_ARGS_((Tcl_Interp *interp));
-static void Focus _ANSI_ARGS_((WidgetInfo *wi, ZnBool got_focus));
-static void Update _ANSI_ARGS_((WidgetInfo *wi));
-static void Repair _ANSI_ARGS_((WidgetInfo *wi));
+static void Focus _ANSI_ARGS_((ZnWInfo *wi, ZnBool got_focus));
+static void Update _ANSI_ARGS_((ZnWInfo *wi));
+static void Repair _ANSI_ARGS_((ZnWInfo *wi));
-Tcl_Obj *
-NewStringObj(CONST char *str) {
- return Tcl_NewStringObj(str, strlen(str));
-}
-
-void
-SetStringObj(Tcl_Obj *o,
- char *str) {
- return Tcl_SetStringObj(o, str, strlen(str));
-}
-
/*
*----------------------------------------------------------------------
@@ -324,25 +332,25 @@ SetStringObj(Tcl_Obj *o,
*----------------------------------------------------------------------
*/
static int
-ZnReliefParse(ClientData client_data,
- Tcl_Interp *interp,
- Tk_Window tkwin,
+ZnReliefParse(ClientData client_data __unused,
+ Tcl_Interp *interp __unused,
+ Tk_Window tkwin __unused,
Tcl_Obj *ovalue,
char *widget_rec,
int offset)
{
- ReliefStyle *relief_ptr = (ReliefStyle *) (widget_rec + offset);
- ReliefStyle relief;
+ ZnReliefStyle *relief_ptr = (ZnReliefStyle *) (widget_rec + offset);
+ ZnReliefStyle relief;
#ifdef PTK
char *value = Tcl_GetString(ovalue);
#else
char *value = (char *) ovalue;
#endif
- int result = ZN_OK;
+ int result = TCL_OK;
if (value != NULL) {
- result = ZnGetRelief((WidgetInfo *) widget_rec, value, &relief);
- if (result == ZN_OK) {
+ result = ZnGetRelief((ZnWInfo *) widget_rec, value, &relief);
+ if (result == TCL_OK) {
*relief_ptr = relief;
}
}
@@ -350,15 +358,15 @@ ZnReliefParse(ClientData client_data,
}
static Tcl_Obj *
-ZnReliefPrint(ClientData client_data,
- Tk_Window tkwin,
+ZnReliefPrint(ClientData client_data __unused,
+ Tk_Window tkwin __unused,
char *widget_rec,
int offset,
- Tcl_FreeProc **free_proc)
+ Tcl_FreeProc **free_proc __unused)
{
- ReliefStyle relief = *(ReliefStyle *) (widget_rec + offset);
+ ZnReliefStyle relief = *(ZnReliefStyle *) (widget_rec + offset);
#ifdef PTK
- return NewStringObj(ZnNameOfRelief(relief));
+ return Tcl_NewStringObj(ZnNameOfRelief(relief), -1);
#else
return (Tcl_Obj *) ZnNameOfRelief(relief);
#endif
@@ -375,7 +383,7 @@ ZnReliefPrint(ClientData client_data,
*----------------------------------------------------------------------
*/
static int
-ZnGradientParse(ClientData client_data,
+ZnGradientParse(ClientData client_data __unused,
Tcl_Interp *interp,
Tk_Window tkwin,
Tcl_Obj *ovalue,
@@ -394,26 +402,26 @@ ZnGradientParse(ClientData client_data,
if ((value != NULL) && (*value != '\0')) {
grad = ZnGetGradient(interp, tkwin, value);
if (grad == NULL) {
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (prev_grad != NULL) {
ZnFreeGradient(prev_grad);
}
*grad_ptr = grad;
}
- return ZN_OK;
+ return TCL_OK;
}
static Tcl_Obj *
-ZnGradientPrint(ClientData client_data,
- Tk_Window tkwin,
+ZnGradientPrint(ClientData client_data __unused,
+ Tk_Window tkwin __unused,
char *widget_rec,
int offset,
- Tcl_FreeProc **free_proc)
+ Tcl_FreeProc **free_proc __unused)
{
ZnGradient *gradient = *(ZnGradient **) (widget_rec + offset);
#ifdef PTK
- return NewStringObj(ZnNameOfGradient(gradient));
+ return Tcl_NewStringObj(ZnNameOfGradient(gradient), -1);
#else
return (Tcl_Obj *) ZnNameOfGradient(gradient);
#endif
@@ -426,14 +434,14 @@ ZnGradientPrint(ClientData client_data,
* ZnBitmapParse
* ZnImageParse
* ZnImagePrint --
- * Converter for the -*color* options.
+ * Converter for the -*image* options.
*
*----------------------------------------------------------------------
*/
static int
-ZnBitmapParse(ClientData client_data,
- Tcl_Interp *interp,
- Tk_Window tkwin,
+ZnBitmapParse(ClientData client_data __unused,
+ Tcl_Interp *interp __unused,
+ Tk_Window tkwin __unused,
Tcl_Obj *ovalue,
char *widget_rec,
int offset)
@@ -445,13 +453,13 @@ ZnBitmapParse(ClientData client_data,
#else
char *value = (char *) ovalue;
#endif
- WidgetInfo *wi = (WidgetInfo*) widget_rec;
+ ZnWInfo *wi = (ZnWInfo*) widget_rec;
prev_image = *image_ptr;
if ((value != NULL) && (*value != '\0')) {
image = ZnGetBitmap(wi, value);
if (image == NULL) {
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (prev_image != NULL) {
ZnFreeImage(prev_image);
@@ -462,13 +470,13 @@ ZnBitmapParse(ClientData client_data,
ZnFreeImage(prev_image);
*image_ptr = NULL;
}
- return ZN_OK;
+ return TCL_OK;
}
static int
-ZnImageParse(ClientData client_data,
- Tcl_Interp *interp,
- Tk_Window tkwin,
+ZnImageParse(ClientData client_data __unused,
+ Tcl_Interp *interp __unused,
+ Tk_Window tkwin __unused,
Tcl_Obj *ovalue,
char *widget_rec,
int offset)
@@ -480,13 +488,13 @@ ZnImageParse(ClientData client_data,
#else
char *value = (char *) ovalue;
#endif
- WidgetInfo *wi = (WidgetInfo*) widget_rec;
+ ZnWInfo *wi = (ZnWInfo*) widget_rec;
prev_image = *image_ptr;
if ((value != NULL) && (*value != '\0')) {
image = ZnGetImage(wi, value);
if (image == NULL) {
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (prev_image != NULL) {
ZnFreeImage(prev_image);
@@ -497,19 +505,19 @@ ZnImageParse(ClientData client_data,
ZnFreeImage(prev_image);
*image_ptr = NULL;
}
- return ZN_OK;
+ return TCL_OK;
}
static Tcl_Obj *
-ZnImagePrint(ClientData client_data,
- Tk_Window tkwin,
+ZnImagePrint(ClientData client_data __unused,
+ Tk_Window tkwin __unused,
char *widget_rec,
int offset,
- Tcl_FreeProc **free_proc)
+ Tcl_FreeProc **free_proc __unused)
{
ZnImage image = *(ZnImage *) (widget_rec + offset);
#ifdef PTK
- return NewStringObj(image?ZnNameOfImage(image):"");
+ return Tcl_NewStringObj(image?ZnNameOfImage(image):"", -1);
#else
return (Tcl_Obj *) (image?ZnNameOfImage(image):"");
#endif
@@ -525,9 +533,9 @@ ZnImagePrint(ClientData client_data,
*
*----------------------------------------------------------------------
*/
-Pixmap
-ZnGetAlphaStipple(WidgetInfo *wi,
- unsigned char val)
+static Pixmap
+ZnGetAlphaStipple(ZnWInfo *wi,
+ unsigned int val)
{
if (val >= 255)
return None;
@@ -543,7 +551,7 @@ ZnGetAlphaStipple(WidgetInfo *wi,
*----------------------------------------------------------------------
*/
Pixmap
-ZnGetInactiveStipple(WidgetInfo *wi)
+ZnGetInactiveStipple(ZnWInfo *wi)
{
return ZnGetAlphaStipple(wi, 128);
}
@@ -557,12 +565,12 @@ ZnGetInactiveStipple(WidgetInfo *wi)
*----------------------------------------------------------------------
*/
void
-ZnNeedRedisplay(WidgetInfo *wi)
+ZnNeedRedisplay(ZnWInfo *wi)
{
- if (!wi->update_pending) {
+ if (ISCLEAR(wi->flags, ZN_UPDATE_PENDING) && ISSET(wi->flags, ZN_REALIZED)) {
/*printf("scheduling an update\n");*/
Tcl_DoWhenIdle(Redisplay, (ClientData) wi);
- wi->update_pending = 1;
+ SET(wi->flags, ZN_UPDATE_PENDING);
}
}
@@ -585,12 +593,15 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
Tcl_Obj *CONST args[]) /* Argument strings. */
{
Tk_Window top_w = (Tk_Window) client_data;
- WidgetInfo *wi;
+ ZnWInfo *wi;
Tk_Window tkwin;
unsigned int num;
+ ZnBool has_gl = False;
+#ifndef _WIN32
+# if defined(GL) || defined(SHAPE)
int major_op, first_err, first_evt;
- ZnBool has_glx = False;
-#ifdef GLX
+# endif
+# ifdef GL
int major_glx, minor_glx;
Display *dpy = Tk_Display(top_w);
Screen *screen = Tk_Screen(top_w);
@@ -603,59 +614,68 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
/*GLX_ALPHA_SIZE, 8,*/
None
};
+# endif
#endif
InitZinc(interp);
-#ifdef GLX
+#ifdef GL
+# ifdef _WIN32
+ has_gl = True;
+# else
if (XQueryExtension(dpy, "GLX", &major_op, &first_evt, &first_err)) {
if (glXQueryExtension(dpy, &first_err, &first_evt)) {
if (glXQueryVersion(dpy, &major_glx, &minor_glx)) {
if ((major_glx == 1) && (minor_glx >= 1)) {
- has_glx = True;
+ has_gl = True;
}
}
}
}
+# endif
#endif
+
if (argc == 1) {
- Tcl_AppendResult(interp, ZINCVERSION, NULL);
+ Tcl_AppendResult(interp, VERSION, NULL);
Tcl_AppendResult(interp, " X11", NULL);
-#ifdef GLX
- if (has_glx && glXChooseVisual(dpy,
- XScreenNumberOfScreen(screen),
- attribs)) {
+#ifdef GL
+# ifdef _WIN32
+ Tcl_AppendResult(interp, " GL", NULL);
+# else
+ if (has_gl && glXChooseVisual(dpy,
+ XScreenNumberOfScreen(screen),
+ attribs)) {
Tcl_AppendResult(interp, " GL", NULL);
}
+# endif
#endif
return TCL_OK;
}
tkwin = Tk_CreateWindowFromPath(interp, top_w, Tcl_GetString(args[1]), NULL);
if (tkwin == NULL) {
- return ZN_ERROR;
+ return TCL_ERROR;
}
Tk_SetClass(tkwin, "Zinc");
/*
* Allocate and initialize the widget record.
*/
- wi = (WidgetInfo *) ZnMalloc(sizeof(WidgetInfo));
+ wi = (ZnWInfo *) ZnMalloc(sizeof(ZnWInfo));
wi->win = tkwin;
wi->interp = interp;
wi->dpy = Tk_Display(tkwin);
wi->screen = Tk_Screen(tkwin);
- wi->has_glx = has_glx;;
+ ASSIGN(wi->flags, ZN_HAS_GL, has_gl);
-#ifdef SHAPE
- wi->has_x_shape = XQueryExtension(wi->dpy, "SHAPE",
- &major_op, &first_evt, &first_err);
+#if defined(SHAPE) && !defined(_WIN32)
+ ASSIGN(wi->flags, ZN_HAS_X_SHAPE,
+ XQueryExtension(wi->dpy, "SHAPE", &major_op, &first_evt, &first_err));
+ wi->reshape = wi->full_reshape = True;
#else
- wi->has_x_shape = False;
+ CLEAR(wi->flags, ZN_HAS_X_SHAPE);
+ wi->reshape = wi->full_reshape = False;
#endif
- wi->has_x_input = XQueryExtension(wi->dpy, "XInputExtension",
- &major_op, &first_evt, &first_err);
- wi->reshape = wi->full_reshape = True;
wi->render = 0;
wi->real_top = None;
@@ -667,9 +687,8 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
wi->cmd = Tcl_CreateObjCommand(interp, Tk_PathName(tkwin), WidgetObjCmd,
(ClientData) wi, CmdDeleted);
#endif
+ wi->flags = 0;
wi->binding_table = 0;
- wi->realized = False;
- wi->update_pending = 0;
wi->fore_color = NULL;
wi->back_color = NULL;
wi->relief_grad = NULL;
@@ -677,14 +696,18 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
wi->draw_bboxes = 0;
wi->light_angle = 120;
wi->border_width = 0;
- wi->relief = TK_RELIEF_FLAT;
+ wi->relief = ZN_RELIEF_FLAT;
wi->opt_width = None;
wi->opt_height = None;
wi->font = 0;
wi->map_text_font = 0;
-#ifdef GLX
+#ifdef GL
wi->font_tfi = NULL;
wi->map_font_tfi = NULL;
+ wi->gl_context = NULL;
+# ifndef _WIN32
+ wi->gl_visual = NULL;
+# endif
#endif
wi->map_distance_symbol = None;
wi->cursor = None;
@@ -694,6 +717,13 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
wi->track_managed_history_size = 0;
wi->speed_vector_length = 0;
wi->tile = ZnUnspecifiedImage;
+ wi->confine = 0;
+ wi->origin.x = wi->origin.y = 0;
+ wi->scroll_xo = wi->scroll_yo = 0;
+ wi->scroll_xc = wi->scroll_yc = 0;
+ wi->x_scroll_incr = wi->y_scroll_incr = 0;
+ wi->x_scroll_cmd = wi->y_scroll_cmd = NULL;
+ wi->region = NULL;
wi->id_table = (Tcl_HashTable *) ZnMalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(wi->id_table, TCL_ONE_WORD_KEYS);
@@ -708,26 +738,26 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
#ifdef OM
wi->om_group_id = 0;
wi->om_group = wi->top_group;
- OmRegister((void *) wi, SendTrackToOm, SetLabelAngleFromOm, QueryLabelPosition);
+ OmRegister((void *) wi, ZnSendTrackToOm, ZnSetLabelAngleFromOm, ZnQueryLabelPosition);
#endif
wi->gc = 0;
wi->draw_buffer = 0;
- wi->events_flags = 0;
wi->pick_aperture = 0;
wi->new_item = wi->current_item = ZN_NO_ITEM;
wi->new_part = wi->current_part = ZN_NO_PART;
wi->focus_item = ZN_NO_ITEM;
wi->focus_field = ZN_NO_PART;
- wi->got_focus = False;
- wi->monitoring = False;
- wi->total_draw_chrono = NewChrono("Total draw time");
- wi->this_draw_chrono = NewChrono("Last draw time");
+ CLEAR(wi->flags, ZN_MONITORING);
+#ifndef _WIN32
+ wi->total_draw_chrono = ZnNewChrono("Total draw time");
+ wi->this_draw_chrono = ZnNewChrono("Last draw time");
+#endif
wi->damaged_area_w = wi->damaged_area_h = 0;
wi->work_item_list = NULL;
wi->work_pts = ZnListNew(8, sizeof(ZnPoint));
-#ifdef GLX
+#ifdef GL
wi->work_doubles = ZnListNew(8, sizeof(double));
#endif
wi->work_xpts = ZnListNew(8, sizeof(XPoint));
@@ -758,8 +788,8 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
ZnInitClipStack(wi);
ZnInitTransformStack(wi);
- for (num = 0; num < NUM_ALPHA_STEPS; num++) {
- char name[INTEGER_SPACE+12];
+ for (num = 0; num < ZN_NUM_ALPHA_STEPS; num++) {
+ char name[TCL_INTEGER_SPACE+12];
sprintf(name, "AlphaStipple%d", num);
wi->alpha_stipples[num] = Tk_GetBitmap(interp, tkwin, Tk_GetUid(name));
@@ -777,10 +807,10 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
if (Configure(interp, wi, argc-2, args+2, 0) != TCL_OK) {
Tk_DestroyWindow(tkwin);
- return ZN_ERROR;
+ return TCL_ERROR;
}
- ResetBBox(&wi->exposed_area);
+ ZnResetBBox(&wi->exposed_area);
wi->damaged_area.orig.x = wi->damaged_area.orig.y = 0;
wi->damaged_area.corner.x = wi->width = wi->opt_width;
wi->damaged_area.corner.y = wi->height = wi->opt_height;
@@ -795,19 +825,63 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
* Allocate double buffer pixmap/image.
*/
if (wi->render) {
-#ifdef GLX
+#ifdef GL
wi->gl_context = 0;
-
- if (wi->has_glx) {
-#ifdef GLX_PRINT_CONFIG
+ ASSIGN(wi->flags, ZN_PRINT_CONFIG, (getenv("ZINC_GLX_INFO") != NULL));
+
+ if (ISSET(wi->flags, ZN_HAS_GL)) {
+# ifdef _WIN32
+ PIXELFORMATDESCRIPTOR pfd = {
+ sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
+ 1, // version number
+ PFD_DRAW_TO_WINDOW |
+ PFD_SUPPORT_OPENGL | // support OpenGL
+ PFD_DOUBLEBUFFER, // double buffered
+ PFD_TYPE_RGBA, // RGBA type
+ 0, // Color bits ignored
+ 8, 0, 8, 0, 8, 0, 8, 0, // R, G, B, A (color shifts ignored )
+ 0, // accum bits ignored
+ 0, 0, 0, 0, // accum R, G, B, A ignored
+ 0, // no depth buffer
+ 8, // 8 bits stencil buffer
+ 0, // no auxiliary buffer
+ PFD_MAIN_PLANE, // main layer
+ 0, // reserved
+ 0, 0, 0 // layer masks ignored
+ };
+ int ipixel;
+
+ Tk_MakeWindowExist(wi->win);
+ wi->hwnd = Tk_GetHWND(Tk_WindowId(wi->win));
+ wi->hdc = GetDC(wi->hwnd);
+ if (!wi->hdc) {
+ OutputDebugString("Unable to get the hdc\n");
+ }
+ ipixel = ChoosePixelFormat(wi->hdc, &pfd);
+ /* sprintf(msg, "ipixel=%d dwFlags=0x%x req=0x%x iPixelType=%d\n",
+ ipixel,
+ pfd.dwFlags,
+ PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
+ pfd.iPixelType==PFD_TYPE_RGBA);
+ OutputDebugString(msg);*/
+ if (!ipixel) {
+ OutputDebugString("ChoosePixelFormat failed\n");
+ }
+ wi->render = (SetPixelFormat(wi->hdc, ipixel, &pfd) == TRUE);
+ if (wi->render) {
+ wi->gl_context = wglCreateContext(wi->hdc);
+ if (!wi->gl_context) {
+ OutputDebugString("wglCreateContext failed\n");
+ }
+ }
+ ZnGLRelease(wi);
+# else /* _WIN32 */
int val;
-#endif
-
-#if GLX_PRINT_CONFIG
- if (getenv("ZINC_GLX_INFO")) {
+
+ if (ISSET(wi->flags, ZN_PRINT_CONFIG)) {
fprintf(stderr, "GLX version %d.%d\n", major_glx, minor_glx);
}
-#endif
+
wi->gl_visual = glXChooseVisual(wi->dpy,
XScreenNumberOfScreen(wi->screen),
attribs);
@@ -823,8 +897,7 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
wi->render = 0;
}
else {
-#ifdef GLX_PRINT_CONFIG
- if (getenv("ZINC_GLX_INFO")) {
+ if (ISSET(wi->flags, ZN_PRINT_CONFIG)) {
fprintf(stderr, " Visual : 0x%x, ",
(int) wi->gl_visual->visualid);
glXGetConfig(wi->dpy, wi->gl_visual, GLX_RGBA, &val);
@@ -846,29 +919,31 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
fprintf(stderr, " Direct Rendering: %d\n",
glXIsDirect(wi->dpy, wi->gl_context));
}
-#endif
Tk_SetWindowVisual(wi->win, wi->gl_visual->visual,
24,
XCreateColormap(wi->dpy, RootWindowOfScreen(wi->screen),
wi->gl_visual->visual, AllocNone));
}
}
+# endif /* _WIN32 */
}
else {
- fprintf(stderr, "glx not available\n");
+ fprintf(stderr, "GL not available\n");
wi->render = 0;
}
-#endif
+#else /* GL */
+ wi->render = 0;
+#endif /* GL */
}
if (!wi->render) {
- wi->draw_buffer = XCreatePixmap(wi->dpy, RootWindowOfScreen(wi->screen),
- wi->width, wi->height, Tk_Depth(wi->win));
+ wi->draw_buffer = Tk_GetPixmap(wi->dpy, RootWindowOfScreen(wi->screen),
+ wi->width, wi->height, Tk_Depth(wi->win));
}
#ifdef PTK
Tcl_SetObjResult(interp, LangWidgetObj(interp, tkwin));
#else
- Tcl_SetObjResult(interp, NewStringObj(Tk_PathName(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(tkwin), -1));
#endif
return TCL_OK;
@@ -886,16 +961,16 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
*----------------------------------------------------------------------
*/
ClientData
-EncodeItemPart(Item item,
+EncodeItemPart(ZnItem item,
int part)
{
if (part >= 0) {
- FieldSet fs;
+ ZnFieldSet fs;
if (!item->class->GetFieldSet) {
return item;
}
fs = item->class->GetFieldSet(item);
- return (ClientData) (FIELD.GetFieldStruct(fs, part%FIELD.NumFields(fs)));
+ return (ClientData) (ZnFIELD.GetFieldStruct(fs, part % (int) ZnFIELD.NumFields(fs)));
}
else if (part == ZN_NO_PART) {
return item;
@@ -984,7 +1059,7 @@ TagSearchExprDestroy(TagSearchExpr *expr)
*/
static int
TagSearchScanExpr(Tcl_Interp *interp, /* Current interpreter. */
- TagSearch *search, /* Search data */
+ ZnTagSearch *search, /* Search data */
TagSearchExpr *expr) /* Compiled expression result */
{
int looking_for_tag; /* When true, scanner expects next char(s)
@@ -1023,7 +1098,7 @@ TagSearchScanExpr(Tcl_Interp *interp, /* Current interpreter. */
if (looking_for_tag > 1) {
Tcl_AppendResult(interp, "Too many '!' in tag search expression",
(char *) NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
looking_for_tag++;
negate_result = 1;
@@ -1039,7 +1114,7 @@ TagSearchScanExpr(Tcl_Interp *interp, /* Current interpreter. */
if (TagSearchScanExpr(interp, search, expr) != TCL_OK) {
/* Result string should be already set
* by nested call to tag_expr_scan() */
- return ZN_ERROR;
+ return TCL_ERROR;
}
looking_for_tag = 0;
found_tag = 1;
@@ -1068,13 +1143,13 @@ TagSearchScanExpr(Tcl_Interp *interp, /* Current interpreter. */
if (! found_endquote) {
Tcl_AppendResult(interp, "Missing endquote in tag search expression",
(char *) NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (! (tag - search->rewrite_buf)) {
Tcl_AppendResult(interp,
"Null quoted tag string in tag search expression",
(char *) NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
*tag++ = '\0';
expr->uids[expr->index++] = Tk_GetUid(search->rewrite_buf);
@@ -1087,7 +1162,7 @@ TagSearchScanExpr(Tcl_Interp *interp, /* Current interpreter. */
case ')':
Tcl_AppendResult(interp, "Unexpected operator in tag search expression",
(char *) NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
default: /* unquoted tag string */
if (negate_result) {
expr->uids[expr->index++] = neg_tag_val_uid;
@@ -1136,7 +1211,7 @@ TagSearchScanExpr(Tcl_Interp *interp, /* Current interpreter. */
if (c != '&') {
Tcl_AppendResult(interp, "Singleton '&' in tag search expression",
(char *) NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
expr->uids[expr->index++] = and_uid;
looking_for_tag = 1;
@@ -1146,7 +1221,7 @@ TagSearchScanExpr(Tcl_Interp *interp, /* Current interpreter. */
if (c != '|') {
Tcl_AppendResult(interp, "Singleton '|' in tag search expression",
(char *) NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
expr->uids[expr->index++] = or_uid;
looking_for_tag = 1;
@@ -1162,17 +1237,17 @@ TagSearchScanExpr(Tcl_Interp *interp, /* Current interpreter. */
Tcl_AppendResult(interp,
"Invalid boolean operator in tag search expression",
(char *) NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
}
}
breakwhile:
if (found_tag && ! looking_for_tag) {
- return ZN_OK;
+ return TCL_OK;
}
Tcl_AppendResult(interp, "Missing tag in tag search expression",
(char *) NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
@@ -1193,7 +1268,7 @@ TagSearchScanExpr(Tcl_Interp *interp, /* Current interpreter. */
*/
static int
TagSearchEvalExpr(TagSearchExpr *expr, /* Search expression */
- Item item) /* Item being test for match */
+ ZnItem item) /* Item being test for match */
{
int looking_for_tag; /* When true, scanner expects next char(s)
* to be a tag, else operand expected */
@@ -1215,7 +1290,7 @@ TagSearchEvalExpr(TagSearchExpr *expr, /* Search expression */
/*
* set result 1 if tag is found in item's tags
*/
- result = ITEM.HasTag(item, uid) ? 1 : 0;
+ result = ZnITEM.HasTag(item, uid) ? 1 : 0;
}
else if (uid == neg_tag_val_uid) {
negate_result = ! negate_result;
@@ -1226,7 +1301,7 @@ TagSearchEvalExpr(TagSearchExpr *expr, /* Search expression */
/*
* set result 1 if tag is found in item's tags
*/
- result = ITEM.HasTag(item, uid) ? 1 : 0;
+ result = ZnITEM.HasTag(item, uid) ? 1 : 0;
}
else if (uid == paren_uid) {
/*
@@ -1303,15 +1378,15 @@ TagSearchEvalExpr(TagSearchExpr *expr, /* Search expression */
}
-static Item
-LookupGroupFromPath(Item start,
- Tk_Uid *names,
- int num_names)
+static ZnItem
+LookupGroupFromPath(ZnItem start,
+ Tk_Uid *names,
+ unsigned int num_names)
{
Tk_Uid name, *tags;
- int count;
+ unsigned int count;
ZnBool recursive;
- Item result, current = ZnGroupHead(start);
+ ZnItem result, current = ZnGroupHead(start);
if (num_names == 0) {
return start;
@@ -1377,16 +1452,16 @@ LookupGroupFromPath(Item start,
*--------------------------------------------------------------
*/
static int
-ZnTagSearchScan(WidgetInfo *wi,
- Tcl_Obj *tag_obj, /* Object giving tag value, NULL
- * is the same as 'all'. */
- TagSearch **search_var) /* Record describing tag search;
- * will be initialized here. */
+ZnTagSearchScan(ZnWInfo *wi,
+ Tcl_Obj *tag_obj, /* Object giving tag value, NULL
+ * is the same as 'all'. */
+ ZnTagSearch **search_var) /* Record describing tag search;
+ * will be initialized here. */
{
Tk_Uid tag;
int i;
- TagSearch *search;
- Item group = wi->top_group;
+ ZnTagSearch *search;
+ ZnItem group = wi->top_group;
ZnBool recursive = True;
if (tag_obj) {
@@ -1404,13 +1479,13 @@ ZnTagSearchScan(WidgetInfo *wi,
}
else {
/* Allocate primary search struct on first call */
- *search_var = search = (TagSearch *) ZnMalloc(sizeof(TagSearch));
+ *search_var = search = (ZnTagSearch *) ZnMalloc(sizeof(ZnTagSearch));
search->expr = NULL;
/* Allocate buffer for rewritten tags (after de-escaping) */
search->rewrite_buf_alloc = 100;
search->rewrite_buf = ZnMalloc(search->rewrite_buf_alloc);
- search->item_stack = ZnListNew(16, sizeof(Item));
+ search->item_stack = ZnListNew(16, sizeof(ZnItem));
}
TagSearchExprInit(&(search->expr));
@@ -1427,7 +1502,7 @@ ZnTagSearchScan(WidgetInfo *wi,
*/
if (search->tag_len == 0) {
search->over = True;
- return ZN_OK;
+ return TCL_OK;
}
/*
@@ -1435,9 +1510,9 @@ ZnTagSearchScan(WidgetInfo *wi,
* tag and search for a matching group.
*/
if (strpbrk(tag, ".*")) {
- Tk_Uid path;
- char c, *next;
- unsigned long id;
+ Tk_Uid path;
+ char c, *next;
+ long id;
Tcl_HashEntry *entry;
ZnListEmpty(wi->work_strs);
@@ -1458,33 +1533,35 @@ ZnTagSearchScan(WidgetInfo *wi,
if ((group == ZN_NO_ITEM) || (group->id != id)) {
entry = Tcl_FindHashEntry(wi->id_table, (char *) id);
if (entry != NULL) {
- group = (Item) Tcl_GetHashValue(entry);
+ group = (ZnItem) Tcl_GetHashValue(entry);
}
else {
Tcl_AppendResult(wi->interp, "unknown group in path \"",
tag, "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
}
if (group->class != ZnGroup) {
Tcl_AppendResult(wi->interp, "item is not a group in path \"",
tag, "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
}
else {
Tcl_AppendResult(wi->interp, "misplaced group id in path \"",
tag, "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
}
else {
- ZnListAdd(wi->work_strs, recursive ? &star_uid : &dot_uid, ZnListTail);
+ ZnListAdd(wi->work_strs,
+ (void *) (recursive ? &star_uid : &dot_uid),
+ ZnListTail);
c = *next;
*next = '\0';
path = Tk_GetUid(path);
*next = c;
- ZnListAdd(wi->work_strs, &path, ZnListTail);
+ ZnListAdd(wi->work_strs, (void *) &path, ZnListTail);
}
recursive = (*next == '*');
path = next+1;
@@ -1496,7 +1573,7 @@ ZnTagSearchScan(WidgetInfo *wi,
if (group == ZN_NO_ITEM) {
Tcl_AppendResult(wi->interp, "path does not lead to a valid group\"",
tag, "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
/*
@@ -1517,8 +1594,8 @@ ZnTagSearchScan(WidgetInfo *wi,
/*
* Make sure there is enough buffer to hold rewritten tags (30%).
*/
- if ((unsigned int)search->tag_len*1.3 >= search->rewrite_buf_alloc) {
- search->rewrite_buf_alloc = (unsigned int)search->tag_len*1.3;
+ if ((unsigned int)(search->tag_len*1.3) >= search->rewrite_buf_alloc) {
+ search->rewrite_buf_alloc = (unsigned int) (search->tag_len*1.3);
search->rewrite_buf = ZnRealloc(search->rewrite_buf,
search->rewrite_buf_alloc);
}
@@ -1542,7 +1619,7 @@ ZnTagSearchScan(WidgetInfo *wi,
search->id = strtoul(tag, &end, 0);
if (*end == 0) {
search->type = 1;
- return ZN_OK;
+ return TCL_OK;
}
}
@@ -1581,10 +1658,10 @@ ZnTagSearchScan(WidgetInfo *wi,
* now compile the tag expression into array of Tk_Uid
* flagging any syntax errors found
*/
- if (TagSearchScanExpr(wi->interp, search, search->expr) != ZN_OK) {
+ if (TagSearchScanExpr(wi->interp, search, search->expr) != TCL_OK) {
/* Syntax error in tag expression */
/* Result message set by TagSearchScanExpr */
- return ZN_ERROR;
+ return TCL_ERROR;
}
search->expr->length = search->expr->index;
}
@@ -1607,7 +1684,7 @@ ZnTagSearchScan(WidgetInfo *wi,
search->type = 3;
}
}
- return ZN_OK;
+ return TCL_OK;
}
@@ -1633,10 +1710,10 @@ ZnTagSearchScan(WidgetInfo *wi,
*
*--------------------------------------------------------------
*/
-static Item
-ZnTagSearchFirst(TagSearch *search) /* Record describing tag search */
+static ZnItem
+ZnTagSearchFirst(ZnTagSearch *search) /* Record describing tag search */
{
- Item item, previous;
+ ZnItem item, previous;
/* short circuit impossible searches for null tags */
if (search->over == True) {
@@ -1658,7 +1735,7 @@ ZnTagSearchFirst(TagSearch *search) /* Record describing tag search */
(previous == ZN_NO_ITEM) || (previous->next != item)) {
entry = Tcl_FindHashEntry(search->wi->id_table, (char *) search->id);
if (entry != NULL) {
- item = (Item) Tcl_GetHashValue(entry);
+ item = (ZnItem) Tcl_GetHashValue(entry);
previous = item->previous;
}
else {
@@ -1689,7 +1766,7 @@ ZnTagSearchFirst(TagSearch *search) /* Record describing tag search */
/*
* Optimized single-tag search
*/
- if (ITEM.HasTag(item, search->expr->uid)) {
+ if (ZnITEM.HasTag(item, search->expr->uid)) {
search->previous = previous;
search->current = item;
return item;
@@ -1708,7 +1785,7 @@ ZnTagSearchFirst(TagSearch *search) /* Record describing tag search */
}
}
if ((item->class == ZnGroup) && (search->recursive)) {
- Item prev_group = (Item) search->group;
+ ZnItem prev_group = (ZnItem) search->group;
/*
* Explore the hierarchy depth first using the item stack
* to save the current node.
@@ -1739,9 +1816,9 @@ ZnTagSearchFirst(TagSearch *search) /* Record describing tag search */
/*printf("ZnTagSearchFirst backup for tag, detph %d\n",
ZnListSize(search->item_stack)/2);*/
while ((item == ZN_NO_ITEM) && ZnListSize(search->item_stack)) {
- item = *(Item *) ZnListAt(search->item_stack, ZnListTail);
+ item = *(ZnItem *) ZnListAt(search->item_stack, ZnListTail);
ZnListDelete(search->item_stack, ZnListTail);
- previous = *(Item *) ZnListAt(search->item_stack, ZnListTail);
+ previous = *(ZnItem *) ZnListAt(search->item_stack, ZnListTail);
ZnListDelete(search->item_stack, ZnListTail);
}
if (item != ZN_NO_ITEM) {
@@ -1776,10 +1853,10 @@ ZnTagSearchFirst(TagSearch *search) /* Record describing tag search */
*
*--------------------------------------------------------------
*/
-static Item
-ZnTagSearchNext(TagSearch *search) /* Record describing search in progress. */
+static ZnItem
+ZnTagSearchNext(ZnTagSearch *search) /* Record describing search in progress. */
{
- Item item, previous;
+ ZnItem item, previous;
if (search->over) {
return ZN_NO_ITEM;
@@ -1829,9 +1906,9 @@ ZnTagSearchNext(TagSearch *search) /* Record describing search in progress. */
/*
* End of list at this level, back up one level.
*/
- item = *(Item *) ZnListAt(search->item_stack, ZnListTail);
+ item = *(ZnItem *) ZnListAt(search->item_stack, ZnListTail);
ZnListDelete(search->item_stack, ZnListTail);
- previous = *(Item *) ZnListAt(search->item_stack, ZnListTail);
+ previous = *(ZnItem *) ZnListAt(search->item_stack, ZnListTail);
ZnListDelete(search->item_stack, ZnListTail);
}
if (item != ZN_NO_ITEM) {
@@ -1864,7 +1941,7 @@ ZnTagSearchNext(TagSearch *search) /* Record describing search in progress. */
/*
* Optimized single-tag search
*/
- if (ITEM.HasTag(item, search->expr->uid)) {
+ if (ZnITEM.HasTag(item, search->expr->uid)) {
search->previous = previous;
search->current = item;
return item;
@@ -1904,9 +1981,9 @@ ZnTagSearchNext(TagSearch *search) /* Record describing search in progress. */
/*printf("ZnTagSearchNext backup for tag, depth %d\n",
ZnListSize(search->item_stack)/2);*/
while ((item == ZN_NO_ITEM) && ZnListSize(search->item_stack)) {
- item = *(Item *) ZnListAt(search->item_stack, ZnListTail);
+ item = *(ZnItem *) ZnListAt(search->item_stack, ZnListTail);
ZnListDelete(search->item_stack, ZnListTail);
- previous = *(Item *) ZnListAt(search->item_stack, ZnListTail);
+ previous = *(ZnItem *) ZnListAt(search->item_stack, ZnListTail);
ZnListDelete(search->item_stack, ZnListTail);
}
if (item != ZN_NO_ITEM) {
@@ -1935,7 +2012,7 @@ ZnTagSearchNext(TagSearch *search) /* Record describing search in progress. */
*--------------------------------------------------------------
*/
void
-ZnTagSearchDestroy(TagSearch *search) /* Record describing tag search */
+ZnTagSearchDestroy(ZnTagSearch *search) /* Record describing tag search */
{
if (search) {
TagSearchExprDestroy(search->expr);
@@ -1958,16 +2035,16 @@ ZnTagSearchDestroy(TagSearch *search) /* Record describing tag search */
*----------------------------------------------------------------------
*/
int
-ZnItemWithTagOrId(WidgetInfo *wi,
+ZnItemWithTagOrId(ZnWInfo *wi,
Tcl_Obj *tag_or_id,
- Item *item,
- TagSearch **search_var)
+ ZnItem *item,
+ ZnTagSearch **search_var)
{
- if (ZnTagSearchScan(wi, tag_or_id, search_var) != ZN_OK) {
- return ZN_ERROR;
+ if (ZnTagSearchScan(wi, tag_or_id, search_var) != TCL_OK) {
+ return TCL_ERROR;
}
*item = ZnTagSearchFirst(*search_var);
- return ZN_OK;
+ return TCL_OK;
}
@@ -1984,13 +2061,17 @@ ZnItemWithTagOrId(WidgetInfo *wi,
*----------------------------------------------------------------------
*/
static int
-LayoutItems(WidgetInfo *wi,
- int argc,
+LayoutItems(ZnWInfo *wi,
+ int argc __unused,
Tcl_Obj *CONST args[])
{
- int index, result;
- Item item;
+ int index/*, result*/;
+ /*ZnItem item;*/
+#ifdef PTK
+ static char *layout_cmd_strings[] = {
+#else
static CONST char *layout_cmd_strings[] = {
+#endif
"align", "grid", "position", "scale", "space", NULL
};
enum layout_cmds {
@@ -1998,8 +2079,8 @@ LayoutItems(WidgetInfo *wi,
};
if (Tcl_GetIndexFromObj(wi->interp, args[0], layout_cmd_strings,
- "layout command", 0, &index) != ZN_OK) {
- return ZN_ERROR;
+ "layout command", 0, &index) != TCL_OK) {
+ return TCL_ERROR;
}
switch((enum layout_cmds) index) {
/*
@@ -2029,7 +2110,243 @@ LayoutItems(WidgetInfo *wi,
break;
}
- return ZN_OK;
+ return TCL_OK;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SetOrigin --
+ *
+ * This procedure is invoked to translate the viewed area so
+ * that the given point is displayed in the top left corner.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Zinc will be redisplayed to reflect the change in ciew.
+ * The scrollbars will be updated if there are any.
+ * The top group transform is modified to achieve the effect,
+ * it is not a good idea to mix view control and application
+ * control of the top group transform.
+ *
+ *----------------------------------------------------------------------
+ */
+static void
+SetOrigin(ZnWInfo *wi,
+ ZnReal x_origin,
+ ZnReal y_origin)
+{
+ int left, right, top, bottom, delta;
+
+ /*
+ * If scroll increments have been set, round the window origin
+ * to the nearest multiple of the increments.
+ */
+ if (wi->x_scroll_incr > 0) {
+ if (x_origin >= 0) {
+ x_origin += wi->x_scroll_incr/2;
+ }
+ else {
+ x_origin = (-x_origin) + wi->x_scroll_incr/2;
+ }
+ }
+ if (wi->y_scroll_incr > 0) {
+ if (y_origin >= 0) {
+ y_origin += wi->y_scroll_incr/2;
+ }
+ else {
+ y_origin = (-y_origin) + wi->y_scroll_incr/2;
+ }
+ }
+
+ /*
+ * Adjust the origin if necessary to keep as much as possible of the
+ * canvas in the view. The variables left, right, etc. keep track of
+ * how much extra space there is on each side of the view before it
+ * will stick out past the scroll region. If one side sticks out past
+ * the edge of the scroll region, adjust the view to bring that side
+ * back to the edge of the scrollregion (but don't move it so much that
+ * the other side sticks out now). If scroll increments are in effect,
+ * be sure to adjust only by full increments.
+ */
+ if (wi->confine && (wi->region != NULL)) {
+ left = x_origin - wi->scroll_xo;
+ right = wi->scroll_xc - (x_origin + Tk_Width(wi->win));
+ top = y_origin - wi->scroll_yo;
+ bottom = wi->scroll_yc - (y_origin + Tk_Height(wi->win));
+ if ((left < 0) && (right > 0)) {
+ delta = (right > -left) ? -left : right;
+ if (wi->x_scroll_incr > 0) {
+ delta -= delta % wi->x_scroll_incr;
+ }
+ x_origin += delta;
+ }
+ else if ((right < 0) && (left > 0)) {
+ delta = (left > -right) ? -right : left;
+ if (wi->x_scroll_incr > 0) {
+ delta -= delta % wi->x_scroll_incr;
+ }
+ x_origin -= delta;
+ }
+ if ((top < 0) && (bottom > 0)) {
+ delta = (bottom > -top) ? -top : bottom;
+ if (wi->y_scroll_incr > 0) {
+ delta -= delta % wi->y_scroll_incr;
+ }
+ y_origin += delta;
+ }
+ else if ((bottom < 0) && (top > 0)) {
+ delta = (top > -bottom) ? -bottom : top;
+ if (wi->y_scroll_incr > 0) {
+ delta -= delta % wi->y_scroll_incr;
+ }
+ y_origin -= delta;
+ }
+ }
+
+ /*
+ * If the requested origin is not already set, translate the
+ * top group and update the scrollbars.
+ */
+ if ((wi->origin.x != x_origin) || (wi->origin.y != y_origin)) {
+ wi->origin.x = x_origin;
+ wi->origin.y = y_origin;
+ ZnITEM.ResetTransfo(wi->top_group);
+ ZnITEM.TranslateItem(wi->top_group, -x_origin, -y_origin);
+ SET(wi->flags, ZN_UPDATE_SCROLLBARS);
+ }
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ScrollFractions --
+ *
+ * Given the range that's visible in the window and the "100%
+ * range", return a list of two real representing the scroll
+ * fractions. This procedure is used for both x and y scrolling.
+ *
+ * Results:
+ * Return a string as a Tcl_Obj holding two real numbers
+ * describing the scroll fraction (between 0 and 1) corresponding
+ * to the arguments.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+static Tcl_Obj *
+ScrollFractions(ZnReal view1, /* Lowest coordinate visible in the window. */
+ ZnReal view2, /* Highest coordinate visible in the window. */
+ ZnReal region1,/* Lowest coordinate in the object. */
+ ZnReal region2)/* Highest coordinate in the object. */
+{
+ ZnReal range, f1, f2;
+ char buffer[2*TCL_DOUBLE_SPACE+2];
+
+ range = region2 - region1;
+ if (range <= 0) {
+ f1 = 0;
+ f2 = 1.0;
+ }
+ else {
+ f1 = (view1 - region1)/range;
+ if (f1 < 0) {
+ f1 = 0.0;
+ }
+ f2 = (view2 - region1)/range;
+ if (f2 > 1.0) {
+ f2 = 1.0;
+ }
+ if (f2 < f1) {
+ f2 = f1;
+ }
+ }
+ sprintf(buffer, "%g %g", f1, f2);
+ return Tcl_NewStringObj(buffer, -1);
+}
+
+
+/*
+ *--------------------------------------------------------------
+ *
+ * UpdateScrollbars --
+ *
+ * This procedure is invoked whenever zinc has changed in
+ * a way that requires scrollbars to be redisplayed (e.g.
+ * the view has changed).
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * If there are scrollbars associated with zinc, then
+ * their scrolling commands are invoked to cause them to
+ * redisplay. If errors occur, additional Tcl commands may
+ * be invoked to process the errors.
+ *
+ *--------------------------------------------------------------
+ */
+static void
+UpdateScrollbars(ZnWInfo *wi)
+{
+ int result;
+ Tcl_Interp *interp;
+ int x_origin, y_origin, width, height;
+ int scroll_xo, scroll_xc, scroll_yo, scroll_yc;
+ char *x_scroll_cmd, *y_scroll_cmd;
+ Tcl_Obj *fractions;
+
+ /*
+ * Save all the relevant values from wi, because it might be
+ * deleted as part of either of the two calls to Tcl_VarEval below.
+ */
+ interp = wi->interp;
+ Tcl_Preserve((ClientData) interp);
+ x_scroll_cmd = wi->x_scroll_cmd;
+ if (x_scroll_cmd != NULL) {
+ Tcl_Preserve((ClientData) x_scroll_cmd);
+ }
+ y_scroll_cmd = wi->y_scroll_cmd;
+ if (y_scroll_cmd != NULL) {
+ Tcl_Preserve((ClientData) y_scroll_cmd);
+ }
+ x_origin = wi->origin.x;
+ y_origin = wi->origin.y;
+ width = Tk_Width(wi->win);
+ height = Tk_Height(wi->win);
+ scroll_xo = wi->scroll_xo;
+ scroll_xc = wi->scroll_xc;
+ scroll_yo = wi->scroll_yo;
+ scroll_yc = wi->scroll_yc;
+ CLEAR(wi->flags, ZN_UPDATE_SCROLLBARS);
+ if (wi->x_scroll_cmd != NULL) {
+ fractions = ScrollFractions(x_origin, x_origin + width, scroll_xo, scroll_xc);
+ result = Tcl_VarEval(interp, x_scroll_cmd, " ", Tcl_GetString(fractions), NULL);
+ Tcl_DecrRefCount(fractions);
+ if (result != TCL_OK) {
+ Tcl_BackgroundError(interp);
+ }
+ Tcl_ResetResult(interp);
+ Tcl_Release((ClientData) x_scroll_cmd);
+ }
+
+ if (y_scroll_cmd != NULL) {
+ fractions = ScrollFractions(y_origin, y_origin + height, scroll_yo, scroll_yc);
+ result = Tcl_VarEval(interp, y_scroll_cmd, " ", Tcl_GetString(fractions), NULL);
+ Tcl_DecrRefCount(fractions);
+ if (result != TCL_OK) {
+ Tcl_BackgroundError(interp);
+ }
+ Tcl_ResetResult(interp);
+ Tcl_Release((ClientData) y_scroll_cmd);
+ }
+ Tcl_Release((ClientData) interp);
}
@@ -2047,21 +2364,21 @@ LayoutItems(WidgetInfo *wi,
*/
void
ZnDoItem(Tcl_Interp *interp,
- Item item,
+ ZnItem item,
int part,
Tk_Uid tag_uid)
{
if (tag_uid == NULL) {
Tcl_Obj *l;
l = Tcl_GetObjResult(interp);
- Tcl_ListObjAppendElement(interp, l, NewLongObj(item->id));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewLongObj(item->id));
if (part != ZN_NO_PART) {
Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(part));
}
}
else {
/*printf("Adding tag %s to item %d\n", tag_uid, item->id);*/
- ITEM.AddTag(item, tag_uid);
+ ZnITEM.AddTag(item, tag_uid);
}
}
@@ -2078,33 +2395,33 @@ ZnDoItem(Tcl_Interp *interp,
* items enclosed in the area. If enclosed is 0, it looks
* for overlapping and enclosed items.
* If an error occurs, a message is left in the interp result
- * and ZN_ERROR is returned.
+ * and TCL_ERROR is returned.
*
*----------------------------------------------------------------------
*/
static int
-FindArea(WidgetInfo *wi,
+FindArea(ZnWInfo *wi,
Tcl_Obj *CONST args[],
Tk_Uid tag_uid,
ZnBool enclosed,
ZnBool recursive,
- Item group)
+ ZnItem group)
{
ZnPos pos;
ZnBBox area;
ZnToAreaStruct ta;
- if (Tcl_GetDoubleFromObj(wi->interp, args[0], &area.orig.x) == ZN_ERROR) {
- return ZN_ERROR;
+ if (Tcl_GetDoubleFromObj(wi->interp, args[0], &area.orig.x) == TCL_ERROR) {
+ return TCL_ERROR;
}
- if (Tcl_GetDoubleFromObj(wi->interp, args[1], &area.orig.y) == ZN_ERROR) {
- return ZN_ERROR;
+ if (Tcl_GetDoubleFromObj(wi->interp, args[1], &area.orig.y) == TCL_ERROR) {
+ return TCL_ERROR;
}
- if (Tcl_GetDoubleFromObj(wi->interp, args[2], &area.corner.x) == ZN_ERROR) {
- return ZN_ERROR;
+ if (Tcl_GetDoubleFromObj(wi->interp, args[2], &area.corner.x) == TCL_ERROR) {
+ return TCL_ERROR;
}
- if (Tcl_GetDoubleFromObj(wi->interp, args[3], &area.corner.y) == ZN_ERROR) {
- return ZN_ERROR;
+ if (Tcl_GetDoubleFromObj(wi->interp, args[3], &area.corner.y) == TCL_ERROR) {
+ return TCL_ERROR;
}
if (area.corner.x < area.orig.x) {
pos = area.orig.x;
@@ -2127,7 +2444,7 @@ FindArea(WidgetInfo *wi,
ta.area = &area;
wi->top_group->class->ToArea(wi->top_group, &ta);
- return ZN_OK;
+ return TCL_OK;
}
@@ -2147,19 +2464,23 @@ FindArea(WidgetInfo *wi,
*----------------------------------------------------------------------
*/
static int
-FindItems(WidgetInfo *wi,
+FindItems(ZnWInfo *wi,
int argc,
Tcl_Obj *CONST args[],
Tcl_Obj *tag, /* NULL to search or tag to add tag. */
int first, /* First arg to process in args */
- TagSearch **search_var)
+ ZnTagSearch **search_var)
{
Tk_Uid tag_uid = NULL;
int index, result;
- Item item;
+ ZnItem item;
ZnBool recursive = True;
ZnPickStruct ps;
+#ifdef PTK
+ static char *search_cmd_strings[] = {
+#else
static CONST char *search_cmd_strings[] = {
+#endif
"above", "ancestors", "atpriority", "below", "closest", "enclosed",
"overlapping", "withtag", "withtype", NULL
};
@@ -2169,8 +2490,8 @@ FindItems(WidgetInfo *wi,
};
if (Tcl_GetIndexFromObj(wi->interp, args[first], search_cmd_strings,
- "search command", 0, &index) != ZN_OK) {
- return ZN_ERROR;
+ "search command", 0, &index) != TCL_OK) {
+ return TCL_ERROR;
}
if (tag) {
@@ -2185,16 +2506,16 @@ FindItems(WidgetInfo *wi,
{
if (argc != first+2) {
Tcl_WrongNumArgs(wi->interp, first+1, args, "tagOrId");
- return ZN_ERROR;
+ return TCL_ERROR;
}
result = ZnItemWithTagOrId(wi, args[first+1], &item, search_var);
- if (result == ZN_OK) {
+ if (result == TCL_OK) {
if ((item != ZN_NO_ITEM) && (item->previous != ZN_NO_ITEM)) {
ZnDoItem(wi->interp, item->previous, ZN_NO_PART, tag_uid);
}
}
else {
- return ZN_ERROR;
+ return TCL_ERROR;
}
}
break;
@@ -2206,18 +2527,18 @@ FindItems(WidgetInfo *wi,
Tk_Uid uid = NULL;
if ((argc != first+2) && (argc != first+3)) {
Tcl_WrongNumArgs(wi->interp, first+1, args, "tagOrId ?withTag?");
- return ZN_ERROR;
+ return TCL_ERROR;
}
result = ZnItemWithTagOrId(wi, args[first+1], &item, search_var);
- if (result == ZN_ERROR) {
- return ZN_ERROR;
+ if (result == TCL_ERROR) {
+ return TCL_ERROR;
}
item = item->parent;
if (argc == first+3) {
uid = Tk_GetUid(Tcl_GetString(args[first+2]));
}
while (item != ZN_NO_ITEM) {
- if (!uid || ITEM.HasTag(item, uid)) {
+ if (!uid || ZnITEM.HasTag(item, uid)) {
ZnDoItem(wi->interp, item, ZN_NO_PART, tag_uid);
}
item = item->parent;
@@ -2233,10 +2554,10 @@ FindItems(WidgetInfo *wi,
if ((argc != first+2) && (argc != first+3)) {
Tcl_WrongNumArgs(wi->interp, first+1, args, "pri ?tagOrId?");
- return ZN_ERROR;
+ return TCL_ERROR;
}
- if (Tcl_GetIntFromObj(wi->interp, args[first+1], &pri) == ZN_ERROR) {
- return ZN_ERROR;
+ if (Tcl_GetIntFromObj(wi->interp, args[first+1], &pri) == TCL_ERROR) {
+ return TCL_ERROR;
}
/*
@@ -2244,8 +2565,8 @@ FindItems(WidgetInfo *wi,
* the given priority.
*/
if (ZnTagSearchScan(wi, (argc == first+3) ? args[first+2] : NULL,
- search_var) == ZN_ERROR) {
- return ZN_ERROR;
+ search_var) == TCL_ERROR) {
+ return TCL_ERROR;
}
for (item = ZnTagSearchFirst(*search_var);
item != ZN_NO_ITEM; item = ZnTagSearchNext(*search_var)) {
@@ -2260,15 +2581,15 @@ FindItems(WidgetInfo *wi,
*/
case ZN_S_BELOW:
{
- Item next;
+ ZnItem next;
if (argc != first+2) {
Tcl_WrongNumArgs(wi->interp, first+1, args, "tagOrId");
- return ZN_ERROR;
+ return TCL_ERROR;
}
item = ZN_NO_ITEM;
- if (ZnTagSearchScan(wi, args[first+1], search_var) == ZN_ERROR) {
- return ZN_ERROR;
+ if (ZnTagSearchScan(wi, args[first+1], search_var) == TCL_ERROR) {
+ return TCL_ERROR;
}
for (next = ZnTagSearchFirst(*search_var);
next != ZN_NO_ITEM; next = ZnTagSearchNext(*search_var)) {
@@ -2289,17 +2610,17 @@ FindItems(WidgetInfo *wi,
if ((argc < first+3) || (argc > first+6)) {
Tcl_WrongNumArgs(wi->interp, first+1, args, "x y ?halo? ?start?, ?recursive?");
- return ZN_ERROR;
+ return TCL_ERROR;
}
- if (Tcl_GetDoubleFromObj(wi->interp, args[first+1], &p.x) == ZN_ERROR) {
- return ZN_ERROR;
+ if (Tcl_GetDoubleFromObj(wi->interp, args[first+1], &p.x) == TCL_ERROR) {
+ return TCL_ERROR;
}
- if (Tcl_GetDoubleFromObj(wi->interp, args[first+2], &p.y) == ZN_ERROR) {
- return ZN_ERROR;
+ if (Tcl_GetDoubleFromObj(wi->interp, args[first+2], &p.y) == TCL_ERROR) {
+ return TCL_ERROR;
}
if (argc > first+3) {
- if (Tcl_GetIntFromObj(wi->interp, args[first+3], &halo) == ZN_ERROR) {
- return ZN_ERROR;
+ if (Tcl_GetIntFromObj(wi->interp, args[first+3], &halo) == TCL_ERROR) {
+ return TCL_ERROR;
}
if (halo < 0) {
halo = 0;
@@ -2311,7 +2632,7 @@ FindItems(WidgetInfo *wi,
item = ZN_NO_ITEM;
if (argc > (first+4)) {
result = ZnItemWithTagOrId(wi, args[first+4], &item, search_var);
- if ((result == ZN_OK) && (item != ZN_NO_ITEM)) {
+ if ((result == TCL_OK) && (item != ZN_NO_ITEM)) {
if ((item->class == ZnGroup) && !ZnGroupAtomic) {
ps.in_group = item;
}
@@ -2322,8 +2643,8 @@ FindItems(WidgetInfo *wi,
}
}
if (argc > first+5) {
- if (Tcl_GetBooleanFromObj(wi->interp, args[first+5], &recursive) != ZN_OK) {
- return ZN_ERROR;
+ if (Tcl_GetBooleanFromObj(wi->interp, args[first+5], &recursive) != TCL_OK) {
+ return TCL_ERROR;
}
}
/*
@@ -2351,18 +2672,18 @@ FindItems(WidgetInfo *wi,
{
if ((argc < first+5) || (argc > first+7)) {
Tcl_WrongNumArgs(wi->interp, first+1, args, "x1 y1 x2 y2 ?inGroup? ?recursive?");
- return ZN_ERROR;
+ return TCL_ERROR;
}
item = wi->top_group;
if (argc > first+5) {
result = ZnItemWithTagOrId(wi, args[first+5], &item, search_var);
- if ((result != ZN_OK) || (item == ZN_NO_ITEM) || (item->class != ZnGroup)) {
- return ZN_ERROR;
+ if ((result != TCL_OK) || (item == ZN_NO_ITEM) || (item->class != ZnGroup)) {
+ return TCL_ERROR;
}
}
if (argc > first+6) {
- if (Tcl_GetBooleanFromObj(wi->interp, args[first+6], &recursive) != ZN_OK) {
- return ZN_ERROR;
+ if (Tcl_GetBooleanFromObj(wi->interp, args[first+6], &recursive) != TCL_OK) {
+ return TCL_ERROR;
}
}
return FindArea(wi, args+first+1, tag_uid, True, recursive, item);
@@ -2375,18 +2696,18 @@ FindItems(WidgetInfo *wi,
{
if ((argc < first+5) || (argc > first+7)) {
Tcl_WrongNumArgs(wi->interp, first+1, args, "x1 y1 x2 y2 ?inGroup? ?recursive?");
- return ZN_ERROR;
+ return TCL_ERROR;
}
item = wi->top_group;
if (argc > first+5) {
result = ZnItemWithTagOrId(wi, args[first+5], &item, search_var);
- if ((result != ZN_OK) || (item == ZN_NO_ITEM) || (item->class != ZnGroup)) {
- return ZN_ERROR;
+ if ((result != TCL_OK) || (item == ZN_NO_ITEM) || (item->class != ZnGroup)) {
+ return TCL_ERROR;
}
}
if (argc > first+6) {
- if (Tcl_GetBooleanFromObj(wi->interp, args[first+6], &recursive) != ZN_OK) {
- return ZN_ERROR;
+ if (Tcl_GetBooleanFromObj(wi->interp, args[first+6], &recursive) != TCL_OK) {
+ return TCL_ERROR;
}
}
return FindArea(wi, args+first+1, tag_uid, False, recursive, item);
@@ -2399,10 +2720,10 @@ FindItems(WidgetInfo *wi,
{
if (argc != first+2) {
Tcl_WrongNumArgs(wi->interp, first+1, args, "tagOrId");
- return ZN_ERROR;
+ return TCL_ERROR;
}
- if (ZnTagSearchScan(wi, args[first+1], search_var) == ZN_ERROR) {
- return ZN_ERROR;
+ if (ZnTagSearchScan(wi, args[first+1], search_var) == TCL_ERROR) {
+ return TCL_ERROR;
}
for (item = ZnTagSearchFirst(*search_var);
item != ZN_NO_ITEM; item = ZnTagSearchNext(*search_var)) {
@@ -2415,17 +2736,17 @@ FindItems(WidgetInfo *wi,
*/
case ZN_S_WITHTYPE:
{
- ItemClass cls;
+ ZnItemClass cls;
if ((argc != first+2) && (argc != first+3)) {
Tcl_WrongNumArgs(wi->interp, first+1, args, "itemType ?tagOrId?");
- return ZN_ERROR;
+ return TCL_ERROR;
}
cls = ZnLookupItemClass(Tcl_GetString(args[first+1]));
if (!cls) {
Tcl_AppendResult(wi->interp, "unknown item type \"",
Tcl_GetString(args[first+1]), "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
/*
@@ -2433,8 +2754,8 @@ FindItems(WidgetInfo *wi,
* the given item type.
*/
if (ZnTagSearchScan(wi, (argc == first+3) ? args[first+2] : NULL,
- search_var) == ZN_ERROR) {
- return ZN_ERROR;
+ search_var) == TCL_ERROR) {
+ return TCL_ERROR;
}
for (item = ZnTagSearchFirst(*search_var);
item != ZN_NO_ITEM; item = ZnTagSearchNext(*search_var)) {
@@ -2458,11 +2779,11 @@ FindItems(WidgetInfo *wi,
*----------------------------------------------------------------------
*/
int
-ZnParseCoordList(WidgetInfo *wi,
+ZnParseCoordList(ZnWInfo *wi,
Tcl_Obj *arg,
ZnPoint **pts,
char **controls,
- int *num_pts,
+ unsigned int *num_pts,
ZnBool *old_format)
{
Tcl_Obj **elems, **selems;
@@ -2479,15 +2800,15 @@ ZnParseCoordList(WidgetInfo *wi,
*old_format = True;
}
result = Tcl_ListObjGetElements(wi->interp, arg, &num_elems, &elems);
- if (result == ZN_ERROR) {
+ if (result == TCL_ERROR) {
coord_error:
Tcl_AppendResult(wi->interp, " malformed coord list", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (num_elems == 0) {
*num_pts = 0;
*pts = NULL;
- return ZN_OK;
+ return TCL_OK;
}
/*
@@ -2498,7 +2819,7 @@ ZnParseCoordList(WidgetInfo *wi,
* with its control flag.
*/
result = Tcl_GetDoubleFromObj(wi->interp, elems[0], &r);
- old_style = (result == ZN_OK);
+ old_style = (result == TCL_OK);
if (old_style) {
if ((num_elems%2) == 0) {
@@ -2506,10 +2827,10 @@ ZnParseCoordList(WidgetInfo *wi,
ZnListAssertSize(wi->work_pts, *num_pts);
*pts = p = (ZnPoint *) ZnListArray(wi->work_pts);
for (i = 0; i < num_elems; i += 2, p++) {
- if (Tcl_GetDoubleFromObj(wi->interp, elems[i], &p->x) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(wi->interp, elems[i], &p->x) == TCL_ERROR) {
goto coord_error;
}
- if (Tcl_GetDoubleFromObj(wi->interp, elems[i+1], &p->y) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(wi->interp, elems[i+1], &p->y) == TCL_ERROR) {
goto coord_error;
}
/*printf("Parsed a point: %g@%g, ", p->x, p->y);*/
@@ -2520,10 +2841,10 @@ ZnParseCoordList(WidgetInfo *wi,
*num_pts = 1;
ZnListAssertSize(wi->work_pts, *num_pts);
*pts = p = (ZnPoint *) ZnListArray(wi->work_pts);
- if (Tcl_GetDoubleFromObj(wi->interp, elems[0], &p->x) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(wi->interp, elems[0], &p->x) == TCL_ERROR) {
goto coord_error;
}
- if (Tcl_GetDoubleFromObj(wi->interp, elems[1], &p->y) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(wi->interp, elems[1], &p->y) == TCL_ERROR) {
goto coord_error;
}
if (controls) {
@@ -2548,13 +2869,13 @@ ZnParseCoordList(WidgetInfo *wi,
*pts = p = (ZnPoint *) ZnListArray(wi->work_pts);
for (i = 0; i < num_elems; i++, p++) {
result = Tcl_ListObjGetElements(wi->interp, elems[i], &num_selems, &selems);
- if ((result == ZN_ERROR) || (num_selems < 2) || (num_selems > 3)) {
+ if ((result == TCL_ERROR) || (num_selems < 2) || (num_selems > 3)) {
goto coord_error;
}
- if (Tcl_GetDoubleFromObj(wi->interp, selems[0], &p->x) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(wi->interp, selems[0], &p->x) == TCL_ERROR) {
goto coord_error;
}
- if (Tcl_GetDoubleFromObj(wi->interp, selems[1], &p->y) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(wi->interp, selems[1], &p->y) == TCL_ERROR) {
goto coord_error;
}
if (controls) {
@@ -2575,7 +2896,7 @@ ZnParseCoordList(WidgetInfo *wi,
if (old_format) {
*old_format = old_style;
}
- return ZN_OK;
+ return TCL_OK;
}
@@ -2587,14 +2908,15 @@ ZnParseCoordList(WidgetInfo *wi,
*----------------------------------------------------------------------
*/
static int
-Contour(WidgetInfo *wi,
+Contour(ZnWInfo *wi,
int argc,
Tcl_Obj *CONST args[],
- TagSearch **search_var)
+ ZnTagSearch **search_var)
{
ZnPoint *points;
- Item item, shape;
- int cmd, num_points, cw, result, i, j, k;
+ ZnItem item, shape;
+ unsigned int i, j, k,num_points;
+ int cmd, cw, result;
int winding_flag, revert = False;
long index;
char *controls;
@@ -2604,15 +2926,19 @@ Contour(WidgetInfo *wi,
ZnContour *contours;
/* Keep this array in sync with ZnContourCmd in Types.h */
+#ifdef PTK
+ static char *op_strings[] = {
+#else
static CONST char *op_strings[] = {
+#endif
"add", "remove", NULL
};
result = ZnItemWithTagOrId(wi, args[2], &item, search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)){
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)){
Tcl_AppendResult(wi->interp, "unknown item \"", Tcl_GetString(args[2]),
"\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (!item->class->Contour) {
if (item->class->GetClipVertices ||
@@ -2622,38 +2948,38 @@ Contour(WidgetInfo *wi,
else {
Tcl_SetObjResult(wi->interp, Tcl_NewIntObj(0));
}
- return ZN_OK;
+ return TCL_OK;
}
if (argc == 3) {
/*
* Requesting the number of contours.
*/
Tcl_SetObjResult(wi->interp, Tcl_NewIntObj(item->class->Contour(item, -1, 0, NULL)));
- return ZN_OK;
+ return TCL_OK;
}
/*
* Get the sub-command
*/
if (Tcl_GetIndexFromObj(wi->interp, args[3], op_strings,
- "contour operation", 0, &cmd) != ZN_OK) {
- return ZN_ERROR;
+ "contour operation", 0, &cmd) != TCL_OK) {
+ return TCL_ERROR;
}
/*
* Get the winding flag.
*/
- if ((Tcl_GetIntFromObj(wi->interp, args[4], &winding_flag) != ZN_OK) ||
+ if ((Tcl_GetIntFromObj(wi->interp, args[4], &winding_flag) != TCL_OK) ||
(winding_flag < -1) || (winding_flag > 1)) {
Tcl_AppendResult(wi->interp, " incorrect winding flag, should be -1, 0, 1, \"",
Tcl_GetString(args[4]), "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
index = ZnListTail;
if (((argc == 6) && (cmd == ZN_CONTOUR_REMOVE)) || (argc == 7)) {
/* Look for an index value. */
- if (Tcl_GetLongFromObj(wi->interp, args[5], &index) != ZN_OK) {
+ if (Tcl_GetLongFromObj(wi->interp, args[5], &index) != TCL_OK) {
Tcl_AppendResult(wi->interp, " incorrect contour index \"",
Tcl_GetString(args[5]), "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
argc--;
args++;
@@ -2664,19 +2990,19 @@ Contour(WidgetInfo *wi,
}
else {
result = ZnItemWithTagOrId(wi, args[5], &shape, search_var);
- if ((result == ZN_ERROR) || (shape == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (shape == ZN_NO_ITEM)) {
Tcl_ResetResult(wi->interp);
if (ZnParseCoordList(wi, args[5], &points,
- &controls, &num_points, NULL) == ZN_ERROR) {
- return ZN_ERROR;
+ &controls, &num_points, NULL) == TCL_ERROR) {
+ return TCL_ERROR;
}
- POLY_CONTOUR1(&poly, NULL, num_points, False);
+ ZnPolyContour1(&poly, NULL, num_points, False);
/*
* Allocate a fresh point array, ZnParseCoordList returns a shared
* array. The control array is not shared and can be passed along.
*/
poly.contours[0].points = ZnMalloc(num_points*sizeof(ZnPoint));
- cw = poly.contours[0].cw = !TestCCW(points, num_points);
+ cw = poly.contours[0].cw = !ZnTestCCW(points, num_points);
if (winding_flag != 0) {
revert = cw ^ (winding_flag == -1);
}
@@ -2704,7 +3030,7 @@ Contour(WidgetInfo *wi,
Tcl_AppendResult(wi->interp,
"Must supply an explicit winding direction (-1, 1)\nwhen adding a contour from an item",
NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
/*
* If something has changed in the geometry we need to
@@ -2716,7 +3042,7 @@ Contour(WidgetInfo *wi,
noshape:
Tcl_AppendResult(wi->interp, "class: \"", shape->class->name,
"\" can't give a polygonal shape", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (!shape->class->GetContours) {
ZnTriStrip tristrip;
@@ -2730,7 +3056,7 @@ Contour(WidgetInfo *wi,
if (!simple) {
goto noshape;
}
- POLY_CONTOUR1(&poly, tristrip.strip1.points, tristrip.strip1.num_points, False);
+ ZnPolyContour1(&poly, tristrip.strip1.points, tristrip.strip1.num_points, False);
poly.contours[0].controls = NULL;
}
else {
@@ -2738,13 +3064,13 @@ Contour(WidgetInfo *wi,
simple = shape->class->GetContours(shape, &poly);
}
if (poly.num_contours == 0) {
- return ZN_OK;
+ return TCL_OK;
}
/*
* Compute the tranform to map the device points
* into the coordinate space of item.
*/
- ITEM.GetItemTransform(item, &t);
+ ZnITEM.GetItemTransform(item, &t);
ZnTransfoInvert(&t, &inv);
/*
* Make a new transformed poly and unshare
@@ -2838,14 +3164,14 @@ Contour(WidgetInfo *wi,
if (poly.contours != &poly.contour1) {
/*
- * Must not use POLY_FREE: the point and controls arrays
+ * Must not use ZnPolyFree: the point and controls arrays
* are passed along to the item and no longer ours.
*/
ZnFree(poly.contours);
}
}
- return ZN_OK;
+ return TCL_OK;
}
@@ -2857,52 +3183,52 @@ Contour(WidgetInfo *wi,
*----------------------------------------------------------------------
*/
static int
-Coords(WidgetInfo *wi,
+Coords(ZnWInfo *wi,
int argc,
Tcl_Obj *CONST args[],
- TagSearch **search_var)
+ ZnTagSearch **search_var)
{
ZnPoint *points;
- Item item;
- int num_points, result, i;
- int cmd = COORDS_READ;
+ ZnItem item;
+ unsigned int num_points, i;
+ int result, cmd = ZN_COORDS_READ;
long index, contour = 0;
char *str, *controls = NULL;
char c[2] = " ";
Tcl_Obj *l, *entries[3];
result = ZnItemWithTagOrId(wi, args[2], &item, search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)) {
Tcl_AppendResult(wi->interp, " unknown item \"",
Tcl_GetString(args[2]), "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
num_points = 0;
/*printf(" coords: argc=%d, item %d class: %s\n",
argc, item->id, item->class->name);*/
if (argc == 3) {
/* Get all coords of default contour (0). */
- if (item->class->Coords(item, 0, 0, COORDS_READ_ALL,
- &points, &controls, &num_points) == ZN_ERROR) {
- return ZN_ERROR;
+ if (item->class->Coords(item, 0, 0, ZN_COORDS_READ_ALL,
+ &points, &controls, &num_points) == TCL_ERROR) {
+ return TCL_ERROR;
}
coords_read:
/*printf(" coords: read %d points, first is %g@%g\n",
num_points, points->x, points->y);*/
l = Tcl_GetObjResult(wi->interp);
for (i = 0; i < num_points; i++, points++) {
- entries[0] = NewDoubleObj(points->x);
- entries[1] = NewDoubleObj(points->y);
+ entries[0] = Tcl_NewDoubleObj(points->x);
+ entries[1] = Tcl_NewDoubleObj(points->y);
if (controls && controls[i]) {
c[0] = controls[i];
- entries[2] = NewStringObj(c);
+ entries[2] = Tcl_NewStringObj(c, -1);
Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewListObj(3, entries));
}
else {
Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewListObj(2, entries));
}
}
- return ZN_OK;
+ return TCL_OK;
}
/*
@@ -2914,18 +3240,18 @@ Coords(WidgetInfo *wi,
if ((argc < 5) || (argc > 7)) {
Tcl_WrongNumArgs(wi->interp, 1, args,
"coords tagOrId add ?contour? ?index? coordList");
- return ZN_ERROR;
+ return TCL_ERROR;
}
- cmd = COORDS_ADD;
+ cmd = ZN_COORDS_ADD;
i++;
}
else if ((str[0] == 'r') && (strcmp(str, "remove") == 0)) {
if ((argc != 5) && (argc != 6)) {
Tcl_WrongNumArgs(wi->interp, 1, args,
"coords tagOrId remove ?contour? index");
- return ZN_ERROR;
+ return TCL_ERROR;
}
- cmd = COORDS_REMOVE;
+ cmd = ZN_COORDS_REMOVE;
i++;
}
@@ -2934,140 +3260,140 @@ Coords(WidgetInfo *wi,
* a contour index or a coord list.
*/
/* printf(" coords: arg %d is %s\n", i, Tcl_GetString(args[i])); */
- if (Tcl_GetLongFromObj(wi->interp, args[i], &index) != ZN_OK) {
+ if (Tcl_GetLongFromObj(wi->interp, args[i], &index) != TCL_OK) {
Tcl_ResetResult(wi->interp);
- if (((argc == 5) && (cmd != COORDS_ADD) && (cmd != COORDS_REMOVE)) ||
+ if (((argc == 5) && (cmd != ZN_COORDS_ADD) && (cmd != ZN_COORDS_REMOVE)) ||
(argc == 6) || (argc == 7)) {
Tcl_AppendResult(wi->interp, " incorrect contour index \"",
Tcl_GetString(args[i]), "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
- else if ((argc == 5) && (cmd != COORDS_ADD)) {
+ else if ((argc == 5) && (cmd != ZN_COORDS_ADD)) {
Tcl_AppendResult(wi->interp, " incorrect coord index \"",
Tcl_GetString(args[i]), "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
else if (ZnParseCoordList(wi, args[argc-1], &points,
- &controls, &num_points, NULL) == ZN_ERROR) {
- return ZN_ERROR;
+ &controls, &num_points, NULL) == TCL_ERROR) {
+ return TCL_ERROR;
}
- if (cmd == COORDS_ADD) {
+ if (cmd == ZN_COORDS_ADD) {
/* Append coords at end of default contour (0). */
- if (item->class->Coords(item, 0, 0, COORDS_ADD_LAST,
- &points, &controls, &num_points) == ZN_ERROR) {
- return ZN_ERROR;
+ if (item->class->Coords(item, 0, 0, ZN_COORDS_ADD_LAST,
+ &points, &controls, &num_points) == TCL_ERROR) {
+ return TCL_ERROR;
}
}
else {
/* Set all coords of default contour (0). */
- if (item->class->Coords(item, 0, 0, COORDS_REPLACE_ALL,
- &points, &controls, &num_points) == ZN_ERROR) {
- return ZN_ERROR;
+ if (item->class->Coords(item, 0, 0, ZN_COORDS_REPLACE_ALL,
+ &points, &controls, &num_points) == TCL_ERROR) {
+ return TCL_ERROR;
}
}
if (controls) {
ZnFree(controls);
}
- return ZN_OK;
+ return TCL_OK;
}
contour = index;
if (argc == 4) {
/* Get all coords of contour. */
- if (item->class->Coords(item, contour, 0, COORDS_READ_ALL,
- &points, &controls, &num_points) == ZN_ERROR) {
- return ZN_ERROR;
+ if (item->class->Coords(item, contour, 0, ZN_COORDS_READ_ALL,
+ &points, &controls, &num_points) == TCL_ERROR) {
+ return TCL_ERROR;
}
goto coords_read;
}
- else if ((argc == 5) && (cmd == COORDS_REMOVE)) {
+ else if ((argc == 5) && (cmd == ZN_COORDS_REMOVE)) {
/* Remove coord at index in default contour (0). */
- if (item->class->Coords(item, 0, index, COORDS_REMOVE,
- &points, &controls, &num_points) == ZN_ERROR) {
- return ZN_ERROR;
+ if (item->class->Coords(item, 0, index, ZN_COORDS_REMOVE,
+ &points, &controls, &num_points) == TCL_ERROR) {
+ return TCL_ERROR;
}
- return ZN_OK;
+ return TCL_OK;
}
/*
* Try to see if the next param is a vertex index or a coord list.
*/
i++;
/*printf(" coords: arg %d is %s\n", i, Tcl_GetString(args[i]));*/
- if (Tcl_GetLongFromObj(wi->interp, args[i], &index) != ZN_OK) {
+ if (Tcl_GetLongFromObj(wi->interp, args[i], &index) != TCL_OK) {
Tcl_ResetResult(wi->interp);
- if ((argc == 7) || ((argc == 6) && (cmd != COORDS_ADD))) {
+ if ((argc == 7) || ((argc == 6) && (cmd != ZN_COORDS_ADD))) {
Tcl_AppendResult(wi->interp, " incorrect coord index \"",
Tcl_GetString(args[i]), "\"", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
else if (ZnParseCoordList(wi, args[argc-1], &points,
- &controls, &num_points, NULL) == ZN_ERROR) {
- return ZN_ERROR;
+ &controls, &num_points, NULL) == TCL_ERROR) {
+ return TCL_ERROR;
}
- if (cmd == COORDS_ADD) {
+ if (cmd == ZN_COORDS_ADD) {
/* Append coords at end of contour. */
- if (item->class->Coords(item, contour, 0, COORDS_ADD_LAST,
- &points, &controls, &num_points) == ZN_ERROR) {
- return ZN_ERROR;
+ if (item->class->Coords(item, contour, 0, ZN_COORDS_ADD_LAST,
+ &points, &controls, &num_points) == TCL_ERROR) {
+ return TCL_ERROR;
}
}
else {
/* Set all coords of contour. */
- if (item->class->Coords(item, contour, 0, COORDS_REPLACE_ALL,
- &points, &controls, &num_points) == ZN_ERROR) {
- return ZN_ERROR;
+ if (item->class->Coords(item, contour, 0, ZN_COORDS_REPLACE_ALL,
+ &points, &controls, &num_points) == TCL_ERROR) {
+ return TCL_ERROR;
}
}
if (controls) {
ZnFree(controls);
}
- return ZN_OK;
+ return TCL_OK;
}
if (argc == 5) {
/* Get coord of contour at index. */
- if (item->class->Coords(item, contour, index, COORDS_READ,
- &points, &controls, &num_points) == ZN_ERROR) {
- return ZN_ERROR;
+ if (item->class->Coords(item, contour, index, ZN_COORDS_READ,
+ &points, &controls, &num_points) == TCL_ERROR) {
+ return TCL_ERROR;
}
if (num_points) {
/*printf(" coords: read contour:%d, index:%d, point is %g@%g\n",
contour, index, points->x, points->y); */
l = Tcl_GetObjResult(wi->interp);
- Tcl_ListObjAppendElement(wi->interp, l, NewDoubleObj(points->x));
- Tcl_ListObjAppendElement(wi->interp, l, NewDoubleObj(points->y));
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewDoubleObj(points->x));
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewDoubleObj(points->y));
if (controls && controls[0]) {
c[0] = controls[0];
- Tcl_ListObjAppendElement(wi->interp, l, NewStringObj(c));
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewStringObj(c, -1));
}
}
- return ZN_OK;
+ return TCL_OK;
}
- else if ((argc == 6) && (cmd == COORDS_REMOVE)) {
+ else if ((argc == 6) && (cmd == ZN_COORDS_REMOVE)) {
/* Remove coord of contour at index. */
- if (item->class->Coords(item, contour, index, COORDS_REMOVE,
- &points, &controls, &num_points) == ZN_ERROR) {
- return ZN_ERROR;
+ if (item->class->Coords(item, contour, index, ZN_COORDS_REMOVE,
+ &points, &controls, &num_points) == TCL_ERROR) {
+ return TCL_ERROR;
}
- return ZN_OK;
+ return TCL_OK;
}
/* Set a single coord or add coords at index in contour. */
if (ZnParseCoordList(wi, args[argc-1], &points,
- &controls, &num_points, NULL) == ZN_ERROR) {
- return ZN_ERROR;
+ &controls, &num_points, NULL) == TCL_ERROR) {
+ return TCL_ERROR;
}
if (argc == 6) {
num_points = 1;
- cmd = COORDS_REPLACE;
+ cmd = ZN_COORDS_REPLACE;
}
if (item->class->Coords(item, contour, index, cmd,
- &points, &controls, &num_points) == ZN_ERROR) {
- return ZN_ERROR;
+ &points, &controls, &num_points) == TCL_ERROR) {
+ return TCL_ERROR;
}
if (controls) {
ZnFree(controls);
}
- return ZN_OK;
+ return TCL_OK;
}
@@ -3092,25 +3418,29 @@ static int
WidgetObjCmd(ClientData client_data, /* Information about the widget. */
Tcl_Interp *interp, /* Current interpreter. */
int argc, /* Number of arguments. */
- Tcl_Obj *CONST args[]) /* Argument strings. */
+ Tcl_Obj *CONST args[]) /* Arguments. */
{
- WidgetInfo *wi = (WidgetInfo *) client_data;
+ ZnWInfo *wi = (ZnWInfo *) client_data;
int result, cmd_index, index;
- Item item, item2;
+ ZnItem item, item2;
int field = ZN_NO_PART;
- int num = 0, i, j;
+ unsigned int num = 0, i, j;
char *end, *str;
ZnTransfo *t = NULL;
Tcl_Obj *l;
- TagSearch *search_var = NULL;
+ ZnTagSearch *search_var = NULL;
Tcl_HashEntry *entry;
ZnPoint *points;
- int num_points;
+ unsigned int num_points;
ZnList to_points;
Tcl_Obj *entries[3];
char c[] = "c";
+#ifdef PTK
+ static char *sub_cmd_strings[] = {
+#else
static CONST char *sub_cmd_strings[] = {
+#endif
"add", "addtag", "anchorxy", "bbox", "becomes", "bind",
"cget", "chggroup", "clone", "configure", "contour",
"coords", "currentpart", "cursor", "dchars",
@@ -3120,7 +3450,8 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
"lower", "monitor", "numparts", "postscript", "raise",
"remove", "rotate", "scale", "select", "smooth",
"tapply", "tdelete", "transform", "translate", "treset",
- "trestore", "tsave", "type", "vertexat", NULL
+ "trestore", "tsave", "type", "vertexat", "xview", "yview",
+ NULL
};
enum sub_cmds {
ZN_W_ADD, ZN_W_ADDTAG, ZN_W_ANCHORXY, ZN_W_BBOX, ZN_W_BECOMES, ZN_W_BIND,
@@ -3132,9 +3463,13 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
ZN_W_LOWER, ZN_W_MONITOR, ZN_W_NUMPARTS, ZN_W_POSTSCRIPT, ZN_W_RAISE,
ZN_W_REMOVE, ZN_W_ROTATE, ZN_W_SCALE, ZN_W_SELECT, ZN_W_SMOOTH,
ZN_W_TAPPLY, ZN_W_TDELETE, ZN_W_TRANSFORM, ZN_W_TRANSLATE, ZN_W_TRESET,
- ZN_W_TRESTORE, ZN_W_TSAVE, ZN_W_TYPE, ZN_W_VERTEX_AT,
+ ZN_W_TRESTORE, ZN_W_TSAVE, ZN_W_TYPE, ZN_W_VERTEX_AT, ZN_W_XVIEW, ZN_W_YVIEW
};
+#ifdef PTK
+ static char *sel_cmd_strings[] = {
+#else
static CONST char *sel_cmd_strings[] = {
+#endif
"adjust", "clear", "from", "item", "to", NULL
};
enum sel_cmds {
@@ -3144,16 +3479,16 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
if (argc < 2) {
Tcl_WrongNumArgs(interp, 1, args, "subcommand ?args?");
- return ZN_ERROR;
+ return TCL_ERROR;
}
Tcl_Preserve((ClientData) wi);
if (Tcl_GetIndexFromObj(interp, args[1], sub_cmd_strings,
- "subcommand", 0, &cmd_index) != ZN_OK) {
+ "subcommand", 0, &cmd_index) != TCL_OK) {
goto error;
}
- result = ZN_OK;
+ result = TCL_OK;
/*printf("executing command \"%s\", argc=%d\n",
Tcl_GetString(args[1]), argc);*/
@@ -3163,17 +3498,17 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
case ZN_W_ADD:
{
- Item group;
- ItemClass cls;
+ ZnItem group;
+ ZnItemClass cls;
if (argc == 2) { /* create subcommand alone, return the list of known
* object types. */
- ItemClass *classes = ZnListArray(ZnItemClassList());
+ ZnItemClass *classes = ZnListArray(ZnItemClassList());
num = ZnListSize(ZnItemClassList());
l = Tcl_GetObjResult(interp);
for (i = 0; i < num; i++) {
- Tcl_ListObjAppendElement(interp, l, NewStringObj(classes[i]->name));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewStringObj(classes[i]->name, -1));
}
goto done;
}
@@ -3192,7 +3527,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[3], &group, &search_var);
- if ((result == ZN_ERROR) || (group == ZN_NO_ITEM) ||
+ if ((result == TCL_ERROR) || (group == ZN_NO_ITEM) ||
(group->class != ZnGroup)) {
Tcl_AppendResult(interp, ", group item expected, got \"",
Tcl_GetString(args[3]), "\"", NULL);
@@ -3205,13 +3540,13 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
if (item == ZN_NO_ITEM) {
goto error;
}
- ITEM.InsertItem(item, group, ZN_NO_ITEM, True);
- if (ITEM.ConfigureItem(item, ZN_NO_PART, argc, args, True) == ZN_ERROR) {
+ ZnITEM.InsertItem(item, group, ZN_NO_ITEM, True);
+ if (ZnITEM.ConfigureItem(item, ZN_NO_PART, argc, args, True) == TCL_ERROR) {
goto error;
}
wi->hot_item = item;
wi->hot_prev = item->previous;
- l = NewLongObj(item->id);
+ l = Tcl_NewLongObj(item->id);
Tcl_SetObjResult(interp, l);
}
break;
@@ -3240,7 +3575,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM) ||
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM) ||
!item->class->has_anchors) {
Tcl_AppendResult(interp, "unknown item or doesn't support anchors \"",
Tcl_GetString(args[2]), NULL);
@@ -3256,8 +3591,8 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
Update(wi);
item->class->GetAnchor(item, anchor, &p);
l = Tcl_GetObjResult(wi->interp);
- Tcl_ListObjAppendElement(wi->interp, l, NewDoubleObj(p.x));
- Tcl_ListObjAppendElement(wi->interp, l, NewDoubleObj(p.y));
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewDoubleObj(p.x));
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewDoubleObj(p.y));
}
break;
/*
@@ -3285,22 +3620,22 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
args += 2;
Update(wi);
- ResetBBox(&bbox);
+ ZnResetBBox(&bbox);
for (i = 0; i < argc; i++) {
- if (ZnTagSearchScan(wi, args[i], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[i], &search_var) == TCL_ERROR) {
goto error;
}
for (item = ZnTagSearchFirst(search_var);
item != ZN_NO_ITEM; item = ZnTagSearchNext(search_var)) {
- AddBBoxToBBox(&bbox, &item->item_bounding_box);
+ ZnAddBBoxToBBox(&bbox, &item->item_bounding_box);
}
}
- if (!IsEmptyBBox(&bbox)) {
+ if (!ZnIsEmptyBBox(&bbox)) {
l = Tcl_GetObjResult(interp);
- Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.orig.x));
- Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.orig.y));
- Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.corner.x));
- Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.corner.y));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(bbox.orig.x));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(bbox.orig.y));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(bbox.corner.x));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(bbox.corner.y));
}
}
break;
@@ -3338,8 +3673,8 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
}
if (*end == ':') {
if (item->class->Part) {
- l = NewStringObj(end+1);
- if (item->class->Part(item, &l, &part) == ZN_ERROR) {
+ l = Tcl_NewStringObj(end+1, -1);
+ if (item->class->Part(item, &l, &part) == TCL_ERROR) {
goto error;
}
elem = EncodeItemPart(item, part);
@@ -3431,7 +3766,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
if (command == NULL) {
goto error;
}
- Tcl_SetObjResult(interp, NewStringObj(command));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(command, -1));
#endif
}
else {
@@ -3457,7 +3792,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
case ZN_W_CHGGROUP:
{
- Item grp, scan;
+ ZnItem grp, scan;
int adjust=0;
ZnTransfo inv, t, t2, *this_one=NULL;
@@ -3466,11 +3801,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)) {
goto error;
}
result = ZnItemWithTagOrId(wi, args[3], &grp, &search_var);
- if ((result == ZN_ERROR) || (grp == ZN_NO_ITEM)|| (grp->class != ZnGroup)) {
+ if ((result == TCL_ERROR) || (grp == ZN_NO_ITEM)|| (grp->class != ZnGroup)) {
goto error;
}
if (item->parent == grp) {
@@ -3493,7 +3828,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
if (argc == 5) {
- if (Tcl_GetBooleanFromObj(interp, args[4], &adjust) != ZN_OK) {
+ if (Tcl_GetBooleanFromObj(interp, args[4], &adjust) != TCL_OK) {
goto error;
}
}
@@ -3501,9 +3836,9 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto done;
}
if (adjust) {
- ITEM.GetItemTransform(grp, &t);
+ ZnITEM.GetItemTransform(grp, &t);
ZnTransfoInvert(&t, &inv);
- ITEM.GetItemTransform(item->parent, &t);
+ ZnITEM.GetItemTransform(item->parent, &t);
ZnTransfoCompose(&t2, &t, &inv);
this_one = &t2;
if (item->transfo) {
@@ -3511,18 +3846,18 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
this_one = &t;
}
}
- ITEM.ExtractItem(item);
- ITEM.InsertItem(item, grp, ZN_NO_ITEM, True);
+ ZnITEM.ExtractItem(item);
+ ZnITEM.InsertItem(item, grp, ZN_NO_ITEM, True);
/*
* The item can be a group in which case we must
* use the ZN_TRANSFO_FLAG to force an update of
* the children. In all other case ZN_COORDS_FLAG
* is enough.
*/
- ITEM.Invalidate(item,
+ ZnITEM.Invalidate(item,
item->class==ZnGroup?ZN_TRANSFO_FLAG:ZN_COORDS_FLAG);
if (adjust) {
- ITEM.SetTransfo(item, this_one);
+ ZnITEM.SetTransfo(item, this_one);
}
}
break;
@@ -3536,18 +3871,18 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) ||
+ if ((result == TCL_ERROR) ||
(item == ZN_NO_ITEM) || (item == wi->top_group)) {
goto error;
}
argc -= 3;
args += 3;
- item2 = ITEM.CloneItem(item);
- ITEM.InsertItem(item2, item->parent, ZN_NO_ITEM, True);
- if (ITEM.ConfigureItem(item2, ZN_NO_PART, argc, args, False) == ZN_ERROR) {
+ item2 = ZnITEM.CloneItem(item);
+ ZnITEM.InsertItem(item2, item->parent, ZN_NO_ITEM, True);
+ if (ZnITEM.ConfigureItem(item2, ZN_NO_PART, argc, args, False) == TCL_ERROR) {
goto error;
}
- l = NewLongObj(item2->id);
+ l = Tcl_NewLongObj(item2->id);
Tcl_SetObjResult(interp, l);
}
break;
@@ -3579,7 +3914,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
"contour tagOrId ?operator windingFlag? ?index? ?coordListOrTagOrId?");
goto error;
}
- if (Contour(wi, argc, args, &search_var) == ZN_ERROR) {
+ if (Contour(wi, argc, args, &search_var) == TCL_ERROR) {
goto error;
}
break;
@@ -3594,7 +3929,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
"coords tagOrId ?add/remove? ?contour? ?index? ?coordList?");
goto error;
}
- if (Coords(wi, argc, args, &search_var) == ZN_ERROR) {
+ if (Coords(wi, argc, args, &search_var) == TCL_ERROR) {
goto error;
}
}
@@ -3610,7 +3945,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
if (argc == 3) {
- if (Tcl_GetBooleanFromObj(interp, args[2], &only_fields) != ZN_OK) {
+ if (Tcl_GetBooleanFromObj(interp, args[2], &only_fields) != TCL_OK) {
goto error;
}
}
@@ -3632,11 +3967,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
Tcl_WrongNumArgs(interp, 1, args, "cursor tagOrId ?field? index");
goto error;
}
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
if (argc == 5) {
- if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) {
+ if (Tcl_GetIntFromObj(interp, args[3], &field) != TCL_OK) {
field = ZN_NO_PART;
if (Tcl_GetString(args[3])[0] != 0) {
Tcl_AppendResult(interp, "invalid field index \"",
@@ -3655,14 +3990,14 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
continue;
}
result = (*item->class->Index)(item, field, args[3], &index);
- if (result != ZN_OK) {
+ if (result != TCL_OK) {
goto error;
}
(*item->class->Cursor)(item, field, index);
if ((item == wi->focus_item) && (field == wi->focus_field) &&
wi->text_info.cursor_on) {
- ITEM.Invalidate(item, ZN_DRAW_FLAG);
+ ZnITEM.Invalidate(item, ZN_DRAW_FLAG);
}
}
}
@@ -3672,18 +4007,18 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
case ZN_W_DCHARS:
{
- int first, last;
- TextInfo *ti = &wi->text_info;
+ int first, last;
+ ZnTextInfo *ti = &wi->text_info;
if ((argc < 4) || (argc > 6)) {
Tcl_WrongNumArgs(interp, 1, args, "dchars tagOrId ?field? first ?last?");
goto error;
}
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
if (argc == 6) {
- if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) {
+ if (Tcl_GetIntFromObj(interp, args[3], &field) != TCL_OK) {
field = ZN_NO_PART;
if (Tcl_GetString(args[3])[0] != 0) {
Tcl_AppendResult(interp, "invalid field index \"",
@@ -3702,12 +4037,12 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
continue;
}
result = (*item->class->Index)(item, field, args[3], &first);
- if (result != ZN_OK) {
+ if (result != TCL_OK) {
goto error;
}
if (argc == 5) {
result = (*item->class->Index)(item, field, args[4], &last);
- if (result != ZN_OK) {
+ if (result != TCL_OK) {
goto error;
}
}
@@ -3766,12 +4101,12 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
else {
tag = Tk_GetUid(Tcl_GetString(args[2]));
}
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
for (item = ZnTagSearchFirst(search_var);
item != ZN_NO_ITEM; item = ZnTagSearchNext(search_var)) {
- ITEM.RemoveTag(item, (char *) tag);
+ ZnITEM.RemoveTag(item, (char *) tag);
}
}
break;
@@ -3799,22 +4134,22 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
if (ZnParseCoordList(wi, args[2], &points,
- NULL, &num_points, NULL) == ZN_ERROR) {
- return ZN_ERROR;
+ NULL, &num_points, NULL) == TCL_ERROR) {
+ return TCL_ERROR;
}
- if (Tcl_GetDoubleFromObj(interp, args[3], &error) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(interp, args[3], &error) == TCL_ERROR) {
goto error;
}
to_points = ZnListNew(32, sizeof(ZnPoint));
- FitBezier(points, num_points, error, to_points);
+ ZnFitBezier(points, num_points, error, to_points);
points = (ZnPoint *) ZnListArray(to_points);
num_points = ZnListSize(to_points);
l = Tcl_GetObjResult(interp);
for (i = 0; i < num_points; i++, points++) {
- entries[0] = NewDoubleObj(points->x);
- entries[1] = NewDoubleObj(points->y);
+ entries[0] = Tcl_NewDoubleObj(points->x);
+ entries[1] = Tcl_NewDoubleObj(points->y);
if (i % 3) {
- entries[2] = NewStringObj(c);
+ entries[2] = Tcl_NewStringObj(c, -1);
Tcl_ListObjAppendElement(interp, l, Tcl_NewListObj(3, entries));
}
else {
@@ -3838,30 +4173,30 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
field = wi->focus_field;
if (item != ZN_NO_ITEM) {
l = Tcl_GetObjResult(interp);
- Tcl_ListObjAppendElement(interp, l, NewLongObj(item->id));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewLongObj(item->id));
if (field != ZN_NO_PART) {
Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(field));
}
else {
- Tcl_ListObjAppendElement(interp, l, NewStringObj(""));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewStringObj("", -1));
}
}
break;
}
if ((item != ZN_NO_ITEM) && (item->class->Cursor != NULL) &&
- (wi->got_focus)) {
- ITEM.Invalidate(item, ZN_COORDS_FLAG);
+ ISSET(wi->flags, ZN_GOT_FOCUS)) {
+ ZnITEM.Invalidate(item, ZN_COORDS_FLAG);
}
if (Tcl_GetString(args[2])[0] == 0) {
wi->focus_item = ZN_NO_ITEM;
wi->focus_field = ZN_NO_PART;
break;
}
- if (ZnItemWithTagOrId(wi, args[2], &item, &search_var) == ZN_ERROR) {
+ if (ZnItemWithTagOrId(wi, args[2], &item, &search_var) == TCL_ERROR) {
goto error;
}
if (argc == 4) {
- if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) {
+ if (Tcl_GetIntFromObj(interp, args[3], &field) != TCL_OK) {
field = ZN_NO_PART;
if (Tcl_GetString(args[3])[0] != 0) {
Tcl_AppendResult(interp, "invalid field index \"",
@@ -3873,8 +4208,8 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
}
wi->focus_item = item;
wi->focus_field = field;
- if (wi->got_focus && (item->class->Cursor != NULL)) {
- ITEM.Invalidate(wi->focus_item, ZN_COORDS_FLAG);
+ if (ISSET(wi->flags, ZN_GOT_FOCUS) && (item->class->Cursor != NULL)) {
+ ZnITEM.Invalidate(wi->focus_item, ZN_COORDS_FLAG);
}
}
break;
@@ -3902,7 +4237,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)) {
goto error;
}
if (!item->tags || !ZnListSize(item->tags)) {
@@ -3913,7 +4248,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
tags = (Tk_Uid *) ZnListArray(item->tags);
l = Tcl_GetObjResult(interp);
for (i = 0; i < num; i++) {
- Tcl_ListObjAppendElement(interp, l, NewStringObj(tags[i]));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewStringObj(tags[i], -1));
}
}
}
@@ -3930,7 +4265,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
if (argc == 3) {
- l = NewBooleanObj(ZnGradientNameExists(Tcl_GetString(args[2])));
+ l = Tcl_NewBooleanObj(ZnGradientNameExists(Tcl_GetString(args[2])));
Tcl_SetObjResult(interp, l);
}
else {
@@ -3952,18 +4287,18 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)) {
goto error;
}
if (item->parent != ZN_NO_ITEM) {
- l = NewLongObj(item->parent->id);
+ l = Tcl_NewLongObj(item->parent->id);
Tcl_SetObjResult(interp, l);
}
else {
/*
* Top group is its own parent.
*/
- l = NewLongObj(item->id);
+ l = Tcl_NewLongObj(item->id);
Tcl_SetObjResult(interp, l);
}
}
@@ -3978,10 +4313,10 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)) {
goto error;
}
- l = NewBooleanObj(item->class->has_anchors?1:0);
+ l = Tcl_NewBooleanObj(item->class->has_anchors?1:0);
Tcl_SetObjResult(interp, l);
}
break;
@@ -3995,10 +4330,10 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)) {
goto error;
}
- l = NewBooleanObj(item->class->GetFieldSet?1:0);
+ l = Tcl_NewBooleanObj(item->class->GetFieldSet?1:0);
Tcl_SetObjResult(interp, l);
}
break;
@@ -4012,11 +4347,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)) {
goto error;
}
- l = NewBooleanObj(ITEM.HasTag(item,
- Tk_GetUid(Tcl_GetString(args[3]))));
+ l = Tcl_NewBooleanObj(ZnITEM.HasTag(item,
+ Tk_GetUid(Tcl_GetString(args[3]))));
Tcl_SetObjResult(interp, l);
}
break;
@@ -4029,11 +4364,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
Tcl_WrongNumArgs(interp, 1, args, "index tagOrId ?field? string");
goto error;
}
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
if (argc == 5) {
- if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) {
+ if (Tcl_GetIntFromObj(interp, args[3], &field) != TCL_OK) {
field = ZN_NO_PART;
if (Tcl_GetString(args[3])[0] != 0) {
Tcl_AppendResult(interp, "invalid field index \"",
@@ -4049,7 +4384,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
item != ZN_NO_ITEM; item = ZnTagSearchNext(search_var)) {
if (item->class->Index != NULL) {
result = (*item->class->Index)(item, field, args[3], &index);
- if (result != ZN_OK) {
+ if (result != TCL_OK) {
goto error;
}
l = Tcl_NewIntObj(index);
@@ -4067,18 +4402,18 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
case ZN_W_INSERT:
{
- TextInfo *ti = &wi->text_info;
- char *chars;
+ ZnTextInfo *ti = &wi->text_info;
+ char *chars;
if ((argc != 5) && (argc != 6)) {
Tcl_WrongNumArgs(interp, 1, args, "insert tagOrId ?field? before string");
goto error;
}
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
if (argc == 6) {
- if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) {
+ if (Tcl_GetIntFromObj(interp, args[3], &field) != TCL_OK) {
field = ZN_NO_PART;
if (Tcl_GetString(args[3])[0] != 0) {
Tcl_AppendResult(interp, "invalid field index \"",
@@ -4097,7 +4432,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
continue;
}
result = (*item->class->Index)(item, field, args[3], &index);
- if (result != ZN_OK) {
+ if (result != TCL_OK) {
goto error;
}
chars = Tcl_GetString(args[4]);
@@ -4132,11 +4467,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)) {
goto error;
}
if (argc == 5) {
- if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) {
+ if (Tcl_GetIntFromObj(interp, args[3], &field) != TCL_OK) {
field = ZN_NO_PART;
if (Tcl_GetString(args[3])[0] != 0) {
Tcl_AppendResult(interp, "invalid field index \"",
@@ -4151,7 +4486,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
if (argc != 4) {
goto itemcget_syntax;
}
- if (ITEM.QueryItem(item, field, 1, &args[3]) != ZN_OK) {
+ if (ZnITEM.QueryItem(item, field, 1, &args[3]) != TCL_OK) {
goto error;
}
}
@@ -4166,11 +4501,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
"itemconfigure tagOrId ?field? option value ?option value? ...");
goto error;
}
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
if ((argc > 3) && (Tcl_GetString(args[3])[0] != '-')) {
- if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) {
+ if (Tcl_GetIntFromObj(interp, args[3], &field) != TCL_OK) {
field = ZN_NO_PART;
if (Tcl_GetString(args[3])[0] != 0) {
Tcl_AppendResult(interp, "invalid field index \"",
@@ -4191,10 +4526,10 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
result = ZnAttributesInfo(wi, item, item->class->attr_desc, argc, args);
}
else if (item->class->GetFieldSet) {
- FieldSet fs = item->class->GetFieldSet(item);
- if (field < FIELD.NumFields(fs)) {
- result = ZnAttributesInfo(wi, FIELD.GetFieldStruct(fs, field),
- FIELD.attr_desc, argc, args);
+ ZnFieldSet fs = item->class->GetFieldSet(item);
+ if (field < (int) ZnFIELD.NumFields(fs)) {
+ result = ZnAttributesInfo(wi, ZnFIELD.GetFieldStruct(fs, field),
+ ZnFIELD.attr_desc, argc, args);
}
else {
Tcl_AppendResult(interp, "field index out of bound", NULL);
@@ -4208,9 +4543,9 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto done;
}
else {
- result = ITEM.ConfigureItem(item, field, argc, args, False);
+ result = ZnITEM.ConfigureItem(item, field, argc, args, False);
}
- if (result == ZN_ERROR) {
+ if (result == TCL_ERROR) {
goto error;
}
}
@@ -4226,7 +4561,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
"layout operator ?args...? tagOrId ?tagOrId...?");
goto error;
}
- if (LayoutItems(wi, argc-2, args+2) == ZN_ERROR) {
+ if (LayoutItems(wi, argc-2, args+2) == TCL_ERROR) {
goto error;
}
}
@@ -4236,14 +4571,14 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
case ZN_W_LOWER:
{
- Item first, group, mark = ZN_NO_ITEM;
+ ZnItem first, group, mark = ZN_NO_ITEM;
if (argc < 3) {
Tcl_WrongNumArgs(interp, 1, args, "lower tagOrId ?belowThis?");
goto error;
}
if (argc == 4) {
- if (ZnTagSearchScan(wi, args[3], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[3], &search_var) == TCL_ERROR) {
goto error;
}
for (item = ZnTagSearchFirst(search_var);
@@ -4256,11 +4591,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
}
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
item = ZnTagSearchFirst(search_var);
- if (item == ZN_NO_ITEM) {
+ if ((item == ZN_NO_ITEM) || (item == wi->top_group)) {
goto done;
}
first = item;
@@ -4270,7 +4605,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
group = mark->parent;
do {
if ((item->parent == group) && (item != mark)) {
- ITEM.UpdateItemPriority(item, mark, False);
+ ZnITEM.UpdateItemPriority(item, mark, False);
mark = item;
}
item = ZnTagSearchNext(search_var);
@@ -4283,6 +4618,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
case ZN_W_MONITOR:
{
+#ifndef _WIN32
ZnBool on_off;
if ((argc != 2) && (argc != 3)) {
@@ -4290,20 +4626,20 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
if (argc == 3) {
- if (Tcl_GetBooleanFromObj(interp, args[2], &on_off) != ZN_OK) {
+ if (Tcl_GetBooleanFromObj(interp, args[2], &on_off) != TCL_OK) {
goto error;
}
- wi->monitoring = on_off;
+ ASSIGN(wi->flags, ZN_MONITORING, on_off);
if (on_off == True) {
- ResetChronos(wi->total_draw_chrono);
- ResetChronos(wi->this_draw_chrono);
+ ZnResetChronos(wi->total_draw_chrono);
+ ZnResetChronos(wi->this_draw_chrono);
}
}
if ((argc == 2) || (on_off == False)) {
long ttime, ltime;
int num_actions;
- GetChrono(wi->total_draw_chrono, &ttime, &num_actions);
- GetChrono(wi->this_draw_chrono, &ltime, NULL);
+ ZnGetChrono(wi->total_draw_chrono, &ttime, &num_actions);
+ ZnGetChrono(wi->this_draw_chrono, &ltime, NULL);
l = Tcl_GetObjResult(interp);
Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(num_actions));
Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(ltime));
@@ -4312,6 +4648,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(wi->damaged_area_h));
Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(ttime));*/
}
+#endif
}
break;
/*
@@ -4324,10 +4661,10 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)) {
goto error;
}
- l = Tcl_NewIntObj(item->class->num_parts);
+ l = Tcl_NewIntObj((int) item->class->num_parts);
Tcl_SetObjResult(interp, l);
}
break;
@@ -4345,7 +4682,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
case ZN_W_RAISE:
{
- Item group, mark = ZN_NO_ITEM;
+ ZnItem group, mark = ZN_NO_ITEM;
if (argc < 3) {
Tcl_WrongNumArgs(interp, 1, args, "raise tagOrId ?aboveThis?");
@@ -4355,7 +4692,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
/*
* Find the topmost item with the tag.
*/
- if (ZnTagSearchScan(wi, args[3], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[3], &search_var) == TCL_ERROR) {
goto error;
}
mark = ZnTagSearchFirst(search_var);
@@ -4365,11 +4702,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
}
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
item = ZnTagSearchFirst(search_var);
- if (item == ZN_NO_ITEM) {
+ if ((item == ZN_NO_ITEM) || (item == wi->top_group)) {
goto done;
}
if (mark == ZN_NO_ITEM) {
@@ -4381,7 +4718,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
continue;
}
if (item != mark) {
- ITEM.UpdateItemPriority(item, mark, True);
+ ZnITEM.UpdateItemPriority(item, mark, True);
}
}
}
@@ -4391,7 +4728,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
case ZN_W_REMOVE:
{
- int num_fields;
+ unsigned int num_fields;
if (argc < 3) {
Tcl_WrongNumArgs(interp, 1, args, "remove tagOrId ?tagOrId ...?");
@@ -4399,8 +4736,8 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
}
argc -= 2;
args += 2;
- for (i = 0; i < argc; i++) {
- if (ZnTagSearchScan(wi, args[i], &search_var) == ZN_ERROR) {
+ for (i = 0; i < (unsigned int) argc; i++) {
+ if (ZnTagSearchScan(wi, args[i], &search_var) == TCL_ERROR) {
goto error;
}
for (item = ZnTagSearchFirst(search_var);
@@ -4411,7 +4748,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
if (wi->binding_table != NULL) {
Tk_DeleteAllBindings(wi->binding_table, (ClientData) item);
if (item->class->GetFieldSet) {
- num_fields = FIELD.NumFields(item->class->GetFieldSet(item));
+ num_fields = ZnFIELD.NumFields(item->class->GetFieldSet(item));
for (j = 0; j < num_fields; j++) {
Tk_DeleteAllBindings(wi->binding_table,
(ClientData) EncodeItemPart(item, j));
@@ -4422,7 +4759,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
(ClientData) EncodeItemPart(item, -(j+2)));
}
}
- ITEM.DestroyItem(item);
+ ZnITEM.DestroyItem(item);
}
}
}
@@ -4441,10 +4778,10 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
}
if (argc == 6) {
- if (Tcl_GetDoubleFromObj(interp, args[4], &p.x) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(interp, args[4], &p.x) == TCL_ERROR) {
goto error;
}
- if (Tcl_GetDoubleFromObj(interp, args[5], &p.y) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(interp, args[5], &p.y) == TCL_ERROR) {
goto error;
}
}
@@ -4453,11 +4790,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
t = (ZnTransfo *) Tcl_GetHashValue(entry);
}
else {
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
}
- if (Tcl_GetDoubleFromObj(interp, args[3], &angle) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(interp, args[3], &angle) == TCL_ERROR) {
goto error;
}
@@ -4473,7 +4810,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
else {
for (item = ZnTagSearchFirst(search_var);
item != ZN_NO_ITEM; item = ZnTagSearchNext(search_var)) {
- ITEM.RotateItem(item, angle, (argc == 6) ? &p : NULL);
+ ZnITEM.RotateItem(item, angle, (argc == 6) ? &p : NULL);
}
}
}
@@ -4494,14 +4831,14 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
t = (ZnTransfo *) Tcl_GetHashValue(entry);
}
else {
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
}
- if (Tcl_GetDoubleFromObj(interp, args[3], &scale.x) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(interp, args[3], &scale.x) == TCL_ERROR) {
goto error;
}
- if (Tcl_GetDoubleFromObj(interp, args[4], &scale.y) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(interp, args[4], &scale.y) == TCL_ERROR) {
goto error;
}
@@ -4511,7 +4848,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
else {
for (item = ZnTagSearchFirst(search_var);
item != ZN_NO_ITEM; item = ZnTagSearchNext(search_var)) {
- ITEM.ScaleItem(item, scale.x, scale.y);
+ ZnITEM.ScaleItem(item, scale.x, scale.y);
}
}
}
@@ -4521,14 +4858,14 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
case ZN_W_SELECT:
{
- TextInfo *ti = &wi->text_info;
+ ZnTextInfo *ti = &wi->text_info;
if (argc < 3) {
Tcl_WrongNumArgs(interp, 1, args, "select option ?tagOrId? ?arg?");
goto error;
}
if (argc >= 4) {
- if (ZnTagSearchScan(wi, args[3], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[3], &search_var) == TCL_ERROR) {
goto error;
}
for (item = ZnTagSearchFirst(search_var);
@@ -4545,12 +4882,12 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
}
}
if (Tcl_GetIndexFromObj(interp, args[2], sel_cmd_strings,
- "selection option", 0, &cmd_index) != ZN_OK) {
+ "selection option", 0, &cmd_index) != TCL_OK) {
goto error;
}
if ((argc == 5) || (argc == 6)) {
if (argc == 6) {
- if (Tcl_GetIntFromObj(interp, args[4], &field) != ZN_OK) {
+ if (Tcl_GetIntFromObj(interp, args[4], &field) != TCL_OK) {
field = ZN_NO_PART;
if (Tcl_GetString(args[4])[0] != 0) {
Tcl_AppendResult(interp, "invalid field index \"",
@@ -4563,7 +4900,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
args++;
}
result = item->class->Index(item, field, args[4], &index);
- if (result != ZN_OK) {
+ if (result != TCL_OK) {
goto error;
}
}
@@ -4589,7 +4926,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
if (ti->sel_item != ZN_NO_ITEM) {
- ITEM.Invalidate(ti->sel_item, ZN_DRAW_FLAG);
+ ZnITEM.Invalidate(ti->sel_item, ZN_DRAW_FLAG);
ti->sel_item = ZN_NO_ITEM;
ti->sel_field = ZN_NO_PART;
}
@@ -4610,12 +4947,12 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
}
if (ti->sel_item != ZN_NO_ITEM) {
l = Tcl_GetObjResult(interp);
- Tcl_ListObjAppendElement(interp, l, NewLongObj(ti->sel_item->id));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewLongObj(ti->sel_item->id));
if (ti->sel_field != ZN_NO_PART) {
Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(ti->sel_field));
}
else {
- Tcl_ListObjAppendElement(interp, l, NewStringObj(""));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewStringObj("", -1));
}
}
break;
@@ -4639,19 +4976,19 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
if (ZnParseCoordList(wi, args[2], &points,
- NULL, &num_points, NULL) == ZN_ERROR) {
- return ZN_ERROR;
+ NULL, &num_points, NULL) == TCL_ERROR) {
+ return TCL_ERROR;
}
to_points = ZnListNew(32, sizeof(ZnPoint));
- SmoothPathWithBezier(points, num_points, to_points);
+ ZnSmoothPathWithBezier(points, num_points, to_points);
points = (ZnPoint *) ZnListArray(to_points);
num_points = ZnListSize(to_points);
l = Tcl_GetObjResult(interp);
for (i = 0; i < num_points; i++, points++) {
- entries[0] = NewDoubleObj(points->x);
- entries[1] = NewDoubleObj(points->y);
+ entries[0] = Tcl_NewDoubleObj(points->x);
+ entries[1] = Tcl_NewDoubleObj(points->y);
if (i % 3) {
- entries[2] = NewStringObj(c);
+ entries[2] = Tcl_NewStringObj(c, -1);
Tcl_ListObjAppendElement(interp, l, Tcl_NewListObj(3, entries));
}
else {
@@ -4699,7 +5036,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
char *controls;
ZnPoint *p, xp;
ZnTransfo t, t2, inv, *this_one;
- Item from, to;
+ ZnItem from, to;
ZnBool old_format;
if ((argc != 4) && (argc != 5)) {
@@ -4709,12 +5046,12 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
if (argc == 5) {
result = ZnItemWithTagOrId(wi, args[2], &from, &search_var);
- if ((result == ZN_ERROR) || (from == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (from == ZN_NO_ITEM)) {
goto error;
}
}
result = ZnItemWithTagOrId(wi, args[argc-2], &to, &search_var);
- if ((result == ZN_ERROR) || (to == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (to == ZN_NO_ITEM)) {
Tcl_HashEntry *e;
/*
* Try to find a named transform.
@@ -4730,12 +5067,12 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
inv = *((ZnTransfo *) Tcl_GetHashValue(e));
}
else {
- ITEM.GetItemTransform(to, &t);
+ ZnITEM.GetItemTransform(to, &t);
ZnTransfoInvert(&t, &inv);
}
this_one = &inv;
if (argc == 5) {
- ITEM.GetItemTransform(from, &t);
+ ZnITEM.GetItemTransform(from, &t);
ZnTransfoCompose(&t2, &t, &inv);
this_one = &t2;
}
@@ -4743,7 +5080,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
ZnPrintTransfo(&inv);*/
if (ZnParseCoordList(wi, args[argc-1], &p,
- &controls, &num_points, &old_format) == ZN_ERROR) {
+ &controls, &num_points, &old_format) == TCL_ERROR) {
Tcl_AppendResult(interp, " invalid coord list \"",
Tcl_GetString(args[argc-1]), "\"", NULL);
goto error;
@@ -4753,14 +5090,14 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
for (i = 0; i < num_points; i++, p++) {
ZnTransformPoint(this_one, p, &xp);
/*printf("p->x=%g, p->y=%g, xp.x=%g, xp.y=%g\n", p->x, p->y, xp.x, xp.y);*/
- Tcl_ListObjAppendElement(interp, l, NewDoubleObj(xp.x));
- Tcl_ListObjAppendElement(interp, l, NewDoubleObj(xp.y));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(xp.x));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(xp.y));
/* The next case only applies for a one point
* list with a control flag.
*/
if (controls && controls[i]) {
c[0] = controls[i];
- Tcl_ListObjAppendElement(interp, l, NewStringObj(c));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewStringObj(c, -1));
}
}
}
@@ -4768,11 +5105,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
for (i = 0; i < num_points; i++, p++) {
ZnTransformPoint(this_one, p, &xp);
/*printf("p->x=%g, p->y=%g, xp.x=%g, xp.y=%g\n", p->x, p->y, xp.x, xp.y);*/
- entries[0] = NewDoubleObj(xp.x);
- entries[1] = NewDoubleObj(xp.y);
+ entries[0] = Tcl_NewDoubleObj(xp.x);
+ entries[1] = Tcl_NewDoubleObj(xp.y);
if (controls && controls[i]) {
c[0] = controls[i];
- entries[2] = NewStringObj(c);
+ entries[2] = Tcl_NewStringObj(c, -1);
Tcl_ListObjAppendElement(interp, l, Tcl_NewListObj(3, entries));
}
else {
@@ -4798,14 +5135,14 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
t = (ZnTransfo *) Tcl_GetHashValue(entry);
}
else {
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
}
- if (Tcl_GetDoubleFromObj(interp, args[3], &trans.x) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(interp, args[3], &trans.x) == TCL_ERROR) {
goto error;
}
- if (Tcl_GetDoubleFromObj(interp, args[4], &trans.y) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(interp, args[4], &trans.y) == TCL_ERROR) {
goto error;
}
@@ -4815,7 +5152,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
else {
for (item = ZnTagSearchFirst(search_var);
item != ZN_NO_ITEM; item =ZnTagSearchNext(search_var)) {
- ITEM.TranslateItem(item, trans.x, trans.y);
+ ZnITEM.TranslateItem(item, trans.x, trans.y);
}
}
}
@@ -4834,7 +5171,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
t = (ZnTransfo *) Tcl_GetHashValue(entry);
}
else {
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
}
@@ -4845,7 +5182,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
else {
for (item = ZnTagSearchFirst(search_var);
item != ZN_NO_ITEM; item = ZnTagSearchNext(search_var)) {
- ITEM.ResetTransfo(item);
+ ZnITEM.ResetTransfo(item);
}
}
}
@@ -4866,12 +5203,12 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
t = (ZnTransfo *) Tcl_GetHashValue(entry);
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
for (item = ZnTagSearchFirst(search_var);
item != ZN_NO_ITEM; item = ZnTagSearchNext(search_var)) {
- ITEM.SetTransfo(item, t);
+ ZnITEM.SetTransfo(item, t);
}
}
break;
@@ -4889,16 +5226,16 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
}
if (argc == 3) {
entry = Tcl_FindHashEntry(wi->t_table, Tcl_GetString(args[2]));
- l = NewBooleanObj(entry != NULL);
+ l = Tcl_NewBooleanObj(entry != NULL);
Tcl_SetObjResult(interp, l);
goto done;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM)) {
goto error;
}
if (argc == 5) {
- if (Tcl_GetBooleanFromObj(interp, args[4], &invert) != ZN_OK) {
+ if (Tcl_GetBooleanFromObj(interp, args[4], &invert) != TCL_OK) {
goto error;
}
argc--;
@@ -4928,11 +5265,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
goto error;
}
result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if (result == ZN_ERROR) {
+ if (result == TCL_ERROR) {
goto error;
}
if (item != ZN_NO_ITEM) {
- l = NewStringObj(item->class->name);
+ l = Tcl_NewStringObj(item->class->name, -1);
Tcl_SetObjResult(interp, l);
}
}
@@ -4949,7 +5286,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
Tcl_WrongNumArgs(interp, 1, args, " vertexat tagOrId x y");
goto error;
}
- if (ZnTagSearchScan(wi, args[2], &search_var) == ZN_ERROR) {
+ if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
goto error;
}
for (item = ZnTagSearchFirst(search_var);
@@ -4963,10 +5300,10 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
Tcl_GetString(args[2]), "\"", NULL);
goto error;
}
- if (Tcl_GetDoubleFromObj(interp, args[3], &p.x) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(interp, args[3], &p.x) == TCL_ERROR) {
goto error;
}
- if (Tcl_GetDoubleFromObj(interp, args[4], &p.y) == ZN_ERROR) {
+ if (Tcl_GetDoubleFromObj(interp, args[4], &p.y) == TCL_ERROR) {
goto error;
}
item->class->PickVertex(item, &p, &contour, &vertex, &o_vertex);
@@ -4975,6 +5312,80 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(vertex));
Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(o_vertex));
}
+
+ /* xview */
+ case ZN_W_XVIEW:
+ {
+ int count, type;
+ ZnReal new_x=0.0, fraction;
+
+ if (argc == 2) {
+ Tcl_SetObjResult(interp,
+ ScrollFractions(wi->origin.x, wi->origin.x + Tk_Width(wi->win),
+ wi->scroll_xo, wi->scroll_xc));
+ }
+ else {
+ type = Tk_GetScrollInfoObj(interp, argc, args, &fraction, &count);
+ switch (type) {
+ case TK_SCROLL_ERROR:
+ result = TCL_ERROR;
+ goto done;
+ case TK_SCROLL_MOVETO:
+ new_x = (wi->scroll_xo + (int) (fraction * (wi->scroll_xc - wi->scroll_xo) + 0.5));
+ break;
+ case TK_SCROLL_PAGES:
+ new_x = (int) (wi->origin.x + count * 0.9 * Tk_Width(wi->win));
+ break;
+ case TK_SCROLL_UNITS:
+ if (wi->x_scroll_incr > 0) {
+ new_x = wi->origin.x + count * wi->x_scroll_incr;
+ }
+ else {
+ new_x = (int) (wi->origin.x + count * 0.1 * Tk_Width(wi->win));
+ }
+ break;
+ }
+ SetOrigin(wi, new_x, wi->origin.y);
+ }
+ break;
+ }
+
+ /*yview */
+ case ZN_W_YVIEW:
+ {
+ int count, type;
+ ZnReal new_y = 0.0, fraction;
+
+ if (argc == 2) {
+ Tcl_SetObjResult(interp,
+ ScrollFractions(wi->origin.y, wi->origin.y + Tk_Height(wi->win),
+ wi->scroll_yo, wi->scroll_yc));
+ }
+ else {
+ type = Tk_GetScrollInfoObj(interp, argc, args, &fraction, &count);
+ switch (type) {
+ case TK_SCROLL_ERROR:
+ result = TCL_ERROR;
+ goto done;
+ case TK_SCROLL_MOVETO:
+ new_y = (wi->scroll_yo + (int) (fraction * (wi->scroll_yc - wi->scroll_yo) + 0.5));
+ break;
+ case TK_SCROLL_PAGES:
+ new_y = (int) (wi->origin.y + count * 0.9 * Tk_Height(wi->win));
+ break;
+ case TK_SCROLL_UNITS:
+ if (wi->y_scroll_incr > 0) {
+ new_y = wi->origin.y + count * wi->y_scroll_incr;
+ }
+ else {
+ new_y = (int) (wi->origin.y + count * 0.1 * Tk_Height(wi->win));
+ }
+ break;
+ }
+ SetOrigin(wi, wi->origin.x, new_y);
+ }
+ break;
+ }
}
done:
@@ -4993,7 +5404,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
wi->work_item_list = NULL;
}
Tcl_Release((ClientData) wi);
- return ZN_ERROR;
+ return TCL_ERROR;
}
@@ -5007,7 +5418,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
* reconfigure) a Zinc widget.
*
* Results:
- * The return value is a standard Tcl result. If ZN_ERROR is
+ * The return value is a standard Tcl result. If TCL_ERROR is
* returned, then interp->result contains an error message.
*
* Side effects:
@@ -5019,7 +5430,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
*/
static int
Configure(Tcl_Interp *interp,/* Used for error reporting. */
- WidgetInfo *wi, /* Information about widget. */
+ ZnWInfo *wi, /* Information about widget. */
int argc, /* Number of valid entries in args. */
Tcl_Obj *CONST args[], /* Arguments. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
@@ -5047,7 +5458,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
wi->render = render;
}
-#ifdef GLX
+#ifdef GL
if (CONFIG_PROBE(FONT_SPEC) || !wi->font_tfi) {
if (wi->font_tfi) {
ZnFreeTexFont(wi->font_tfi);
@@ -5075,16 +5486,18 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
wi->pick_aperture = 0;
}
if (CONFIG_PROBE(BACK_COLOR_SPEC) || !wi->relief_grad) {
- XColor *color;
- int alpha;
- color = ZnGetGradientColor(wi->back_color, 0, &alpha);
+ XColor *color;
+ unsigned short alpha;
+
+ color = ZnGetGradientColor(wi->back_color, 0.0, &alpha);
Tk_SetWindowBackground(wi->win, ZnPixel(color));
if (wi->relief_grad) {
ZnFreeGradient(wi->relief_grad);
+ wi->relief_grad = NULL;
}
- if (wi->relief != RELIEF_FLAT) {
+ if (wi->relief != ZN_RELIEF_FLAT) {
wi->relief_grad = ZnGetReliefGradient(interp, wi->win,
- ZnNameOfColor(color), alpha);
+ Tk_NameOfColor(color), alpha);
}
}
if (CONFIG_PROBE(BACK_COLOR_SPEC) || CONFIG_PROBE(LIGHT_ANGLE_SPEC)) {
@@ -5108,10 +5521,10 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
if (CONFIG_PROBE(SPEED_VECTOR_LENGTH_SPEC) ||
CONFIG_PROBE(MANAGE_HISTORY_SPEC) ||
CONFIG_PROBE(MANAGED_HISTORY_SIZE_SPEC)) {
- ITEM.InvalidateItems(wi->top_group, ZnTrack);
+ ZnITEM.InvalidateItems(wi->top_group, ZnTrack);
}
if (CONFIG_PROBE(MAP_DISTANCE_SYMBOL_SPEC)) {
- ITEM.InvalidateItems(wi->top_group, ZnMap);
+ ZnITEM.InvalidateItems(wi->top_group, ZnMap);
}
/*
@@ -5119,7 +5532,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
*/
if (CONFIG_PROBE(WIDTH_SPEC) || CONFIG_PROBE(HEIGHT_SPEC) ||
CONFIG_PROBE(BORDER_WIDTH_SPEC) ||
- CONFIG_PROBE(HIGHLIGHT_THICKNESS_SPEC) || !wi->realized) {
+ CONFIG_PROBE(HIGHLIGHT_THICKNESS_SPEC) || ISCLEAR(wi->flags, ZN_REALIZED)) {
Tk_GeometryRequest(wi->win, wi->opt_width, wi->opt_height);
}
@@ -5136,7 +5549,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
#ifdef OM
if (CONFIG_PROBE(OVERLAP_MANAGER_SPEC)) {
Tcl_HashEntry *entry;
- Item grp;
+ ZnItem grp;
if (wi->om_group != ZN_NO_ITEM) {
OmUnregister((void *) wi);
@@ -5145,10 +5558,10 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
if (wi->om_group_id != 0) {
entry = Tcl_FindHashEntry(wi->id_table, (char *) wi->om_group_id);
if (entry != NULL) {
- grp = (Item) Tcl_GetHashValue(entry);
+ grp = (ZnItem) Tcl_GetHashValue(entry);
if (grp->class == ZnGroup) {
- OmRegister((void *) wi, SendTrackToOm,
- SetLabelAngleFromOm, QueryLabelPosition);
+ OmRegister((void *) wi, ZnSendTrackToOm,
+ ZnSetLabelAngleFromOm, ZnQueryLabelPosition);
wi->om_group = grp;
}
}
@@ -5157,17 +5570,59 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
#endif
if (CONFIG_PROBE(INSERT_WIDTH_SPEC) && wi->focus_item) {
- ITEM.Invalidate(wi->focus_item, ZN_COORDS_FLAG);
+ ZnITEM.Invalidate(wi->focus_item, ZN_COORDS_FLAG);
}
/*
* Update the blinking cursor timing if on/off time has changed.
*/
- if (wi->got_focus &&
+ if (ISSET(wi->flags, ZN_GOT_FOCUS) &&
(CONFIG_PROBE(INSERT_ON_TIME_SPEC) ||
CONFIG_PROBE(INSERT_OFF_TIME_SPEC))) {
Focus(wi, True);
}
-
+
+ if (CONFIG_PROBE(SCROLL_REGION_SPEC)) {
+ /*
+ * Compute the scroll region
+ */
+ wi->scroll_xo = wi->scroll_yo = 0;
+ wi->scroll_xc = wi->scroll_yc = 0;
+ if (wi->region != NULL) {
+ int argc2;
+#ifdef PTK
+ char **args2;
+#else
+ CONST char **args2;
+#endif
+
+ if (Tcl_SplitList(interp, wi->region, &argc2, &args2) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (argc2 != 4) {
+ Tcl_AppendResult(interp, "bad scrollRegion \"",
+ wi->region, "\"", (char *) NULL);
+ badRegion:
+ ZnFree(wi->region);
+ ZnFree(args2);
+ wi->region = NULL;
+ return TCL_ERROR;
+ }
+ if ((Tk_GetPixels(interp, wi->win, args2[0], &wi->scroll_xo) != TCL_OK) ||
+ (Tk_GetPixels(interp, wi->win, args2[1], &wi->scroll_yo) != TCL_OK) ||
+ (Tk_GetPixels(interp, wi->win, args2[2], &wi->scroll_xc) != TCL_OK) ||
+ (Tk_GetPixels(interp, wi->win, args2[3], &wi->scroll_yc) != TCL_OK)) {
+ goto badRegion;
+ }
+ ZnFree(args2);
+ }
+ }
+
+ if (CONFIG_PROBE(SCROLL_REGION_SPEC) ||
+ CONFIG_PROBE(CONFINE_SPEC)) {
+ SetOrigin(wi, wi->origin.x, wi->origin.y);
+ SET(wi->flags, ZN_UPDATE_SCROLLBARS);
+ }
+
return TCL_OK;
}
@@ -5192,9 +5647,9 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
static void
Blink(ClientData client_data)
{
- WidgetInfo *wi = (WidgetInfo *) client_data;
+ ZnWInfo *wi = (ZnWInfo *) client_data;
- if (!wi->got_focus || (wi->insert_off_time == 0)) {
+ if (ISCLEAR(wi->flags, ZN_GOT_FOCUS) || (wi->insert_off_time == 0)) {
return;
}
if (wi->text_info.cursor_on) {
@@ -5209,17 +5664,17 @@ Blink(ClientData client_data)
}
if ((wi->focus_item != ZN_NO_ITEM) &&
(wi->focus_item->class->Cursor != NULL)) {
- ITEM.Invalidate(wi->focus_item, ZN_DRAW_FLAG);
+ ZnITEM.Invalidate(wi->focus_item, ZN_DRAW_FLAG);
}
}
static void
-Focus(WidgetInfo *wi,
+Focus(ZnWInfo *wi,
ZnBool got_focus)
{
Tcl_DeleteTimerHandler(wi->blink_handler);
if (got_focus) {
- wi->got_focus = 1;
+ SET(wi->flags, ZN_GOT_FOCUS);
wi->text_info.cursor_on = 1;
if (wi->insert_off_time != 0) {
wi->blink_handler = Tcl_CreateTimerHandler(wi->insert_off_time,
@@ -5227,19 +5682,19 @@ Focus(WidgetInfo *wi,
}
}
else {
- wi->got_focus = 0;
+ CLEAR(wi->flags, ZN_GOT_FOCUS);
wi->text_info.cursor_on = 0;
wi->blink_handler = (Tcl_TimerToken) NULL;
}
if ((wi->focus_item != ZN_NO_ITEM) &&
(wi->focus_item->class->Cursor != NULL)){
- ITEM.Invalidate(wi->focus_item, ZN_COORDS_FLAG);
+ ZnITEM.Invalidate(wi->focus_item, ZN_COORDS_FLAG);
}
/*printf("focus %s\n", got_focus ? "in" : "out");*/
if (wi->highlight_width > 0) {
ZnNeedRedisplay(wi);
}
-#ifdef GLX_DAMAGE
+#ifdef GL_DAMAGE
if (wi->render) {
ZnBBox bbox;
@@ -5273,7 +5728,8 @@ static void
Event(ClientData client_data, /* Information about widget. */
XEvent *event) /* Information about event. */
{
- WidgetInfo *wi = (WidgetInfo *) client_data;
+ ZnWInfo *wi = (ZnWInfo *) client_data;
+ XGCValues values;
/*printf("=============== DEBUT %s %d EVENT ==================\n",
event->type == MapNotify ? "MAP":
@@ -5283,20 +5739,18 @@ Event(ClientData client_data, /* Information about widget. */
"??", event->type);*/
if (event->type == MapNotify) {
if (!wi->gc) {
- wi->realized = True;
+ SET(wi->flags, ZN_REALIZED);
if (wi->render) {
-#ifdef GLX
+#ifdef GL
GLfloat r[2];
- glXMakeCurrent(wi->dpy, ZnWindowId(wi->win), wi->gl_context);
- /*glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, r);*/
- glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, r);
+ ZnGLMakeCurrent(wi);
+ glGetFloatv(ZN_GL_LINE_WIDTH_RANGE, r);
wi->max_line_width = r[1];
- /*glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, r);*/
- glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, r);
+ glGetFloatv(ZN_GL_POINT_SIZE_RANGE, r);
wi->max_point_width = r[1];
-#ifdef GLX_PRINT_CONFIG
- if (getenv("ZINC_GLX_INFO")) {
+
+ if (ISSET(wi->flags, ZN_PRINT_CONFIG)) {
fprintf(stderr, "OpenGL version %s\n",
(char *) glGetString(GL_VERSION));
fprintf(stderr, " Rendering engine: %s, ",
@@ -5310,7 +5764,8 @@ Event(ClientData client_data, /* Information about widget. */
fprintf(stderr, "Max antialiased point size: %g\n",
wi->max_point_width);
}
-#endif
+
+ ZnGLRelease(wi);
#endif
}
@@ -5318,8 +5773,10 @@ Event(ClientData client_data, /* Information about widget. */
* Get the work GC and suppress GraphicExpose
* and NoExpose events reception.
*/
- wi->gc = XCreateGC(wi->dpy, ZnWindowId(wi->win), 0, NULL);
- XSetGraphicsExposures(wi->dpy, wi->gc, False);
+ wi->gc = XCreateGC(wi->dpy, Tk_WindowId(wi->win), 0, NULL);
+ values.graphics_exposures = False;
+ XChangeGC(wi->dpy, wi->gc, GCGraphicsExposures, &values);
+
/*
* Set the real top window above us.
*/
@@ -5332,16 +5789,19 @@ Event(ClientData client_data, /* Information about widget. */
while (!Tk_IsTopLevel(top_level)) {
top_level = Tk_Parent(top_level);
}
- XQueryTree(wi->dpy, ZnWindowId(top_level), &root, &parent,
+ XQueryTree(wi->dpy, Tk_WindowId(top_level), &root, &parent,
&children, &num_children);
if (root == parent) {
- wi->real_top = ZnWindowId(top_level);
+ wi->real_top = Tk_WindowId(top_level);
}
else {
wi->real_top = parent;
}
- XFree((char *) children);
+ if (children) {
+ XFree(children);
+ }
}
+ ZnNeedRedisplay(wi);
}
}
else if (event->type == Expose) {
@@ -5371,9 +5831,9 @@ Event(ClientData client_data, /* Information about widget. */
* schedule an asynchronous redisplay of the window
* if we are done adding exposed parts.
*/
- AddBBoxToBBox(&wi->exposed_area, &bbox);
+ ZnAddBBoxToBBox(&wi->exposed_area, &bbox);
if (/*(((XExposeEvent*) event)->count == 0) &&*/
- !IsEmptyBBox(&wi->exposed_area)) {
+ !ZnIsEmptyBBox(&wi->exposed_area)) {
ZnNeedRedisplay(wi);
}
}
@@ -5384,7 +5844,7 @@ Event(ClientData client_data, /* Information about widget. */
* need such change, it can bind a handler on <Configure>.
*/
else if (event->type == ConfigureNotify) {
- ZnDim int_width, int_height;
+ int int_width, int_height;
ZnBBox bbox;
int_width = Tk_Width(wi->win);
@@ -5398,18 +5858,27 @@ Event(ClientData client_data, /* Information about widget. */
wi->opt_height = wi->height = int_height;
ZnResetTransformStack(wi);
+
+ SET(wi->flags, ZN_UPDATE_SCROLLBARS);
+ /*
+ * The call below is needed in order to recenter the view if
+ * it's confined and the scroll region is smaller than the
+ * window.
+ */
+ SetOrigin(wi, wi->origin.x, wi->origin.y);
+
ZnDamage(wi, &bbox);
- ITEM.Invalidate(wi->top_group, ZN_TRANSFO_FLAG);
+ ZnITEM.Invalidate(wi->top_group, ZN_TRANSFO_FLAG);
/*
* Reallocate the double buffer pixmap/image.
*/
if (!wi->render) {
/*printf("reallocating double buffer\n");*/
- XFreePixmap(wi->dpy, wi->draw_buffer);
- wi->draw_buffer = XCreatePixmap(wi->dpy, RootWindowOfScreen(wi->screen),
- int_width, int_height,
- DefaultDepthOfScreen(wi->screen));
+ Tk_FreePixmap(wi->dpy, wi->draw_buffer);
+ wi->draw_buffer = Tk_GetPixmap(wi->dpy, RootWindowOfScreen(wi->screen),
+ int_width, int_height,
+ DefaultDepthOfScreen(wi->screen));
}
}
else {
@@ -5421,7 +5890,7 @@ Event(ClientData client_data, /* Information about widget. */
bbox.orig.x = bbox.orig.y = 0;
bbox.corner.x = Tk_Width(wi->win);
bbox.corner.y = Tk_Height(wi->win);
- AddBBoxToBBox(&wi->exposed_area, &bbox);
+ ZnAddBBoxToBBox(&wi->exposed_area, &bbox);
}
ZnNeedRedisplay(wi);
}
@@ -5433,10 +5902,10 @@ Event(ClientData client_data, /* Information about widget. */
else if (event->type == DestroyNotify) {
if (wi->win != NULL) {
wi->win = NULL;
- wi->realized = False;
+ CLEAR(wi->flags, ZN_REALIZED);
Tcl_DeleteCommandFromToken(wi->interp, wi->cmd);
}
- if (wi->update_pending) {
+ if (ISSET(wi->flags, ZN_UPDATE_PENDING)) {
Tcl_CancelIdleCall(Redisplay, (ClientData) wi);
}
Tcl_EventuallyFree((ClientData) wi, Destroy);
@@ -5471,18 +5940,18 @@ Event(ClientData client_data, /* Information about widget. */
*----------------------------------------------------------------------
*/
static void
-DoEvent(WidgetInfo *wi,
- XEvent *event)
+DoEvent(ZnWInfo *wi,
+ XEvent *event)
{
#define NUM_STATIC 4
- ClientData items[NUM_STATIC], *its;
- static int worksize = 128;
- static char *workspace = NULL;
- int num, num_tags, i, len, ptr;
- ClientData *tag_list = NULL;
- Item item;
- int part;
- ZnBool bind_part, bind_item;
+ ClientData items[NUM_STATIC], *its;
+ static unsigned int worksize = 128, len, num, num_tags;
+ static char *workspace = NULL;
+ unsigned int i, ptr;
+ ClientData *tag_list = NULL;
+ ZnItem item;
+ int part;
+ ZnBool bind_part, bind_item;
#define BIND_ITEM(test) \
if (bind_item && (test)) { \
@@ -5574,7 +6043,7 @@ DoEvent(WidgetInfo *wi,
* Add here a binding for each tag suffixed by :part
*/
for (i = 0; i < num_tags; i++) {
- len = strlen(tag_list[i])+ INTEGER_SPACE;
+ len = strlen(tag_list[i])+ TCL_INTEGER_SPACE;
if (worksize < len) {
worksize = len + 10;
workspace = ZnRealloc(workspace, len);
@@ -5596,7 +6065,7 @@ DoEvent(WidgetInfo *wi,
* Invoke the binding system.
*/
if (wi->win != NULL) {
- Tk_BindEvent(wi->binding_table, event, wi->win, num, its);
+ Tk_BindEvent(wi->binding_table, event, wi->win, (int) num, its);
}
if (its != items) {
ZnFree(its);
@@ -5631,7 +6100,7 @@ DoEvent(WidgetInfo *wi,
*----------------------------------------------------------------------
*/
static void
-PickCurrentItem(WidgetInfo *wi,
+PickCurrentItem(ZnWInfo *wi,
XEvent *event)
{
int button_down;
@@ -5645,7 +6114,7 @@ PickCurrentItem(WidgetInfo *wi,
button_down = wi->state
& (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask);
if (!button_down) {
- wi->events_flags &= ~LEFT_GRABBED_ITEM;
+ wi->flags &= ~ZN_LEFT_GRABBED_ITEM;
}
/*
@@ -5690,7 +6159,7 @@ PickCurrentItem(WidgetInfo *wi,
* Leave event handler for the old current item) then just return;
* the pending call will do everything that's needed.
*/
- if (wi->events_flags & REPICK_IN_PROGRESS) {
+ if (wi->flags & ZN_REPICK_IN_PROGRESS) {
fprintf(stderr, "PickCurrentItem recursive\n");
return;
}
@@ -5731,7 +6200,7 @@ PickCurrentItem(WidgetInfo *wi,
wi->new_item==ZN_NO_ITEM?0:wi->new_item->id, wi->new_part);*/
if ((wi->new_item == wi->current_item) && (wi->new_part == wi->current_part) &&
- !(wi->events_flags & LEFT_GRABBED_ITEM)) {
+ !(wi->flags & ZN_LEFT_GRABBED_ITEM)) {
/*
* Nothing to do: the current item/part hasn't changed.
*/
@@ -5743,13 +6212,11 @@ PickCurrentItem(WidgetInfo *wi,
* an EnterNotify event on the new current item. Remove the "current"
* tag from the previous current item and place it on the new current
* item.
- * Note that the test for prev_left_grabbed_item is needed to prevent
- * calling leave when the grab is released.
*/
if (((wi->new_item != wi->current_item) || (wi->new_part != wi->current_part)) &&
- (wi->current_item != ZN_NO_ITEM) && !(wi->events_flags & LEFT_GRABBED_ITEM)) {
+ (wi->current_item != ZN_NO_ITEM) && !(wi->flags & ZN_LEFT_GRABBED_ITEM)) {
XEvent event;
- Item item = wi->current_item;
+ ZnItem item = wi->current_item;
event = wi->pick_event;
event.type = LeaveNotify;
@@ -5761,9 +6228,9 @@ PickCurrentItem(WidgetInfo *wi,
* always use NotifyAncestor.
*/
event.xcrossing.detail = NotifyAncestor;
- wi->events_flags |= REPICK_IN_PROGRESS;
+ wi->flags |= ZN_REPICK_IN_PROGRESS;
DoEvent(wi, &event);
- wi->events_flags &= ~REPICK_IN_PROGRESS;
+ wi->flags &= ~ZN_REPICK_IN_PROGRESS;
/*
* The check on item below is needed because there could be an
@@ -5771,7 +6238,7 @@ PickCurrentItem(WidgetInfo *wi,
*/
if ((item == wi->current_item) && !button_down) {
/*printf("^^^ Removing 'current' from %d\n", wi->current_item->id);*/
- ITEM.RemoveTag(item, current_uid);
+ ZnITEM.RemoveTag(item, current_uid);
}
/*
* Note: during DoEvent above, it's possible that
@@ -5781,16 +6248,16 @@ PickCurrentItem(WidgetInfo *wi,
}
if (((wi->new_item != wi->current_item) ||
(wi->new_part != wi->current_part)) && button_down) {
- wi->events_flags |= LEFT_GRABBED_ITEM;
+ wi->flags |= ZN_LEFT_GRABBED_ITEM;
return;
}
/*
* Special note: it's possible that wi->new_item == wi->current_item
- * here. This can happen, for example, if LEFT_GRABBED_ITEM was set or
+ * here. This can happen, for example, if ZN_LEFT_GRABBED_ITEM was set or
* if there is only a change in the part number.
*/
- wi->events_flags &= ~LEFT_GRABBED_ITEM;
+ wi->flags &= ~ZN_LEFT_GRABBED_ITEM;
/*
* Tentative pour éviter d'enlever puis de remettre
@@ -5799,18 +6266,18 @@ PickCurrentItem(WidgetInfo *wi,
if (wi->current_item != wi->new_item) {
if (wi->current_item != ZN_NO_ITEM) {
printf("vvv Removing 'current' from %d\n", wi->current_item->id);
- ITEM.RemoveTag(wi->current_item, current_uid);
+ ZnITEM.RemoveTag(wi->current_item, current_uid);
}
}*/
{
- Item it = wi->current_item;
+ ZnItem it = wi->current_item;
wi->current_item = wi->new_item;
wi->current_part = wi->new_part;
/*
* Added to enable DoEvent to make a special case for enter/leaves
* between fields in the same item. It may interact with
- * LEFT_GRABBED_ITEM.
+ * ZN_LEFT_GRABBED_ITEM.
*/
wi->new_item = it;
}
@@ -5861,7 +6328,7 @@ static void
Bind(ClientData client_data, /* Information about widget. */
XEvent *event) /* Information about event. */
{
- WidgetInfo *wi = (WidgetInfo *) client_data;
+ ZnWInfo *wi = (ZnWInfo *) client_data;
Tcl_Preserve((ClientData) wi);
@@ -5931,7 +6398,7 @@ Bind(ClientData client_data, /* Information about widget. */
}
else if ((event->type == EnterNotify) || (event->type == LeaveNotify)) {
-#ifdef GLX_DAMAGE
+#ifdef GL_DAMAGE
/*
* Kludge to prevent incorrect redrawing after
* a move window when using GL. This code force
@@ -5986,11 +6453,11 @@ done:
static void
LostSelection(ClientData client_data)
{
- WidgetInfo *wi = (WidgetInfo *) client_data;
- TextInfo *ti = &wi->text_info;
+ ZnWInfo *wi = (ZnWInfo *) client_data;
+ ZnTextInfo *ti = &wi->text_info;
if (ti->sel_item != ZN_NO_ITEM) {
- ITEM.Invalidate(ti->sel_item, ZN_DRAW_FLAG);
+ ZnITEM.Invalidate(ti->sel_item, ZN_DRAW_FLAG);
}
ti->sel_item = ZN_NO_ITEM;
ti->sel_field = ZN_NO_PART;
@@ -6014,14 +6481,14 @@ LostSelection(ClientData client_data)
*----------------------------------------------------------------------
*/
static void
-SelectTo(Item item,
+SelectTo(ZnItem item,
int field,
int index)
{
- WidgetInfo *wi = item->wi;
- TextInfo *ti = &wi->text_info;
+ ZnWInfo *wi = item->wi;
+ ZnTextInfo *ti = &wi->text_info;
int old_first, old_last, old_field;
- Item old_sel_item;
+ ZnItem old_sel_item;
old_first = ti->sel_first;
old_last = ti->sel_last;
@@ -6035,7 +6502,7 @@ SelectTo(Item item,
Tk_OwnSelection(wi->win, XA_PRIMARY, LostSelection, (ClientData) wi);
}
else if ((ti->sel_item != item) || (ti->sel_field != field)) {
- ITEM.Invalidate(ti->sel_item, ZN_DRAW_FLAG);
+ ZnITEM.Invalidate(ti->sel_item, ZN_DRAW_FLAG);
}
ti->sel_item = item;
ti->sel_field = field;
@@ -6056,7 +6523,7 @@ SelectTo(Item item,
if ((ti->sel_first != old_first) ||
(ti->sel_last != old_last) ||
(item != old_sel_item)) {
- ITEM.Invalidate(item, ZN_DRAW_FLAG);
+ ZnITEM.Invalidate(item, ZN_DRAW_FLAG);
}
}
@@ -6091,8 +6558,8 @@ FetchSelection( ClientData client_data,
* at buffer, not including terminating
* NULL character. */
{
- WidgetInfo *wi = (WidgetInfo *) client_data;
- TextInfo *ti = &wi->text_info;
+ ZnWInfo *wi = (ZnWInfo *) client_data;
+ ZnTextInfo *ti = &wi->text_info;
if (ti->sel_item == ZN_NO_ITEM) {
return -1;
@@ -6125,7 +6592,7 @@ FetchSelection( ClientData client_data,
static void
CmdDeleted(ClientData client_data) /* Pointer to widget record for widget. */
{
- WidgetInfo *wi = (WidgetInfo *) client_data;
+ ZnWInfo *wi = (ZnWInfo *) client_data;
if (wi->win != NULL) {
Tk_DestroyWindow(wi->win);
@@ -6154,7 +6621,7 @@ CmdDeleted(ClientData client_data) /* Pointer to widget record for widget. */
static void
Destroy(char *mem_ptr) /* Info about the widget. */
{
- WidgetInfo *wi = (WidgetInfo *) mem_ptr;
+ ZnWInfo *wi = (ZnWInfo *) mem_ptr;
unsigned int num;
Tcl_HashSearch search;
Tcl_HashEntry *entry;
@@ -6180,19 +6647,19 @@ Destroy(char *mem_ptr) /* Info about the widget. */
*/
/* Free all items. */
- fprintf(stderr, "Item count before cleanup: %d\n", wi->num_items);
- ITEM.DestroyItem(wi->top_group);
- fprintf(stderr, "Remaining item count: %d\n", wi->num_items);
+ /*fprintf(stderr, "Item count before cleanup: %d\n", wi->num_items);*/
+ ZnITEM.DestroyItem(wi->top_group);
+ /*fprintf(stderr, "Remaining item count: %d\n", wi->num_items);*/
/*
* Remove the redisplay scheduled by the cleanup.
* It will fire when the widget will be gone and
* will corrupt memory.
*/
- if (wi->update_pending) {
+ if (ISSET(wi->flags, ZN_UPDATE_PENDING)) {
Tcl_CancelIdleCall(Redisplay, (ClientData) wi);
}
-#ifdef GLX
+#ifdef GL
if (wi->font_tfi) {
ZnFreeTexFont(wi->font_tfi);
}
@@ -6208,7 +6675,7 @@ Destroy(char *mem_ptr) /* Info about the widget. */
Tk_FreeFont(wi->map_text_font);
}*/
- for (num = 0; num < NUM_ALPHA_STEPS; num++) {
+ for (num = 0; num < ZN_NUM_ALPHA_STEPS; num++) {
if (wi->alpha_stipples[num] != None) {
Tk_FreeBitmap(wi->dpy, wi->alpha_stipples[num]);
}
@@ -6240,7 +6707,7 @@ Destroy(char *mem_ptr) /* Info about the widget. */
/* Free the double buffer pixmap/image */
if (wi->draw_buffer) {
- XFreePixmap(wi->dpy, wi->draw_buffer);
+ Tk_FreePixmap(wi->dpy, wi->draw_buffer);
}
if (wi->fore_color) {
@@ -6264,28 +6731,30 @@ Destroy(char *mem_ptr) /* Info about the widget. */
ZnFreeClipStack(wi);
ZnListFree(wi->work_pts);
-#ifdef GLX
+#ifdef GL
ZnListFree(wi->work_doubles);
#endif
ZnListFree(wi->work_xpts);
ZnListFree(wi->work_strs);
- FreeChrono(wi->total_draw_chrono);
- FreeChrono(wi->this_draw_chrono);
+#ifndef _WIN32
+ ZnFreeChrono(wi->total_draw_chrono);
+ ZnFreeChrono(wi->this_draw_chrono);
+#endif
-#ifdef GLX
- if (wi->render) {
- if (wi->gl_context) {
- glXDestroyContext(wi->dpy, wi->gl_context);
- }
- if (wi->gl_visual) {
- XFree(wi->gl_visual);
- }
+#ifdef GL
+ if (wi->gl_context) {
+ ZnGLDestroyContext(wi);
}
+# ifndef _WIN32
+ if (wi->gl_visual) {
+ XFree(wi->gl_visual);
+ }
+# endif
+#endif
if (wi->tess) {
gluDeleteTess(wi->tess);
}
-#endif
ZnFree(wi);
/*printf("Destroy ending\n");*/
@@ -6300,17 +6769,17 @@ Destroy(char *mem_ptr) /* Info about the widget. */
**********************************************************************************
*/
void
-ZnDamage(WidgetInfo *wi,
+ZnDamage(ZnWInfo *wi,
ZnBBox *damage)
{
- if ((damage == NULL) || IsEmptyBBox(damage)) {
+ if ((damage == NULL) || ZnIsEmptyBBox(damage)) {
return;
}
/*printf("damaging area: %g %g %g %g\n", damage->orig.x,
damage->orig.y, damage->corner.x, damage->corner.y);*/
- if (IsEmptyBBox(&wi->damaged_area)) {
+ if (ZnIsEmptyBBox(&wi->damaged_area)) {
wi->damaged_area.orig.x = damage->orig.x;
wi->damaged_area.orig.y = damage->orig.y;
wi->damaged_area.corner.x = damage->corner.x;
@@ -6329,7 +6798,7 @@ ZnDamage(WidgetInfo *wi,
}
static void
-ClampDamageArea(WidgetInfo *wi)
+ClampDamageArea(ZnWInfo *wi)
{
int width, height;
@@ -6370,7 +6839,7 @@ ClampDamageArea(WidgetInfo *wi)
**********************************************************************************
*/
static void
-Update(WidgetInfo *wi)
+Update(ZnWInfo *wi)
{
/*
* Give the overlap manager a chance to do its work.
@@ -6402,31 +6871,31 @@ Update(WidgetInfo *wi)
**********************************************************************************
*/
static void
-Repair(WidgetInfo *wi)
+Repair(ZnWInfo *wi)
{
XGCValues values;
- ZnPoint pts[2];
+ ZnPoint p[5];
ZnTriStrip tristrip;
-#ifdef GLX
+#ifdef GL
XColor *color;
#endif
- ZnReal int_width = Tk_Width(wi->win);
- ZnReal int_height = Tk_Height(wi->win);
+ int int_width = Tk_Width(wi->win);
+ int int_height = Tk_Height(wi->win);
if (wi->render) {
-#ifdef GLX
-#ifdef GLX_DAMAGE
+#ifdef GL
+#ifdef GL_DAMAGE
ClampDamageArea(wi);
/*
* Merge the exposed area.
*/
- AddBBoxToBBox(&wi->damaged_area, &wi->exposed_area);
- if (IsEmptyBBox(&wi->damaged_area)) {
+ ZnAddBBoxToBBox(&wi->damaged_area, &wi->exposed_area);
+ if (ZnIsEmptyBBox(&wi->damaged_area)) {
return;
}
#endif
- glXMakeCurrent(wi->dpy, ZnWindowId(wi->win), wi->gl_context);
+ ZnGLMakeCurrent(wi);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
#if 0
@@ -6438,9 +6907,9 @@ Repair(WidgetInfo *wi)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearStencil(0);
- color = ZnGetGradientColor(wi->back_color, 0, NULL);
- glClearColor(color->red/65536.0, color->green/65536.0,
- color->blue/65536.0, 0.0);
+ color = ZnGetGradientColor(wi->back_color, 0.0, NULL);
+ glClearColor((GLfloat) color->red/65536, (GLfloat) color->green/65536,
+ (GLfloat) color->blue/65536, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
@@ -6452,23 +6921,23 @@ Repair(WidgetInfo *wi)
glViewport(0, 0, (GLsizei) int_width, int_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0.0, int_width, int_height, 0.0, -1.0, 1.0);
+ glOrtho(0.0, (GLfloat) int_width, (GLfloat) int_height, 0.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
-#ifdef GLX_DAMAGE
+#ifdef GL_DAMAGE
glEnable(GL_SCISSOR_TEST);
/*
* Set the damaged area as the scissor area.
*/
- wi->damaged_area.orig.x = REAL_TO_INT(wi->damaged_area.orig.x);
- wi->damaged_area.orig.y = REAL_TO_INT(wi->damaged_area.orig.y);
- wi->damaged_area.corner.x = REAL_TO_INT(wi->damaged_area.corner.x);
- wi->damaged_area.corner.y = REAL_TO_INT(wi->damaged_area.corner.y);
- glScissor(wi->damaged_area.orig.x,
- int_height - wi->damaged_area.corner.y,
- wi->damaged_area.corner.x - wi->damaged_area.orig.x,
- wi->damaged_area.corner.y - wi->damaged_area.orig.y);
+ wi->damaged_area.orig.x = ZnNearestInt(wi->damaged_area.orig.x);
+ wi->damaged_area.orig.y = ZnNearestInt(wi->damaged_area.orig.y);
+ wi->damaged_area.corner.x = ZnNearestInt(wi->damaged_area.corner.x);
+ wi->damaged_area.corner.y = ZnNearestInt(wi->damaged_area.corner.y);
+ glScissor((int) wi->damaged_area.orig.x,
+ int_height - (int) wi->damaged_area.corner.y,
+ (int) (wi->damaged_area.corner.x - wi->damaged_area.orig.x),
+ (int) (wi->damaged_area.corner.y - wi->damaged_area.orig.y));
#else
/*
* We do not use the damaged area for GL rendering,
@@ -6500,91 +6969,111 @@ Repair(WidgetInfo *wi)
wi->top_group->class->Render(wi->top_group);
if ((wi->border_width > 0) || (wi->highlight_width > 0)) {
- int alpha;
+ unsigned short alpha;
-#ifdef GLX_DAMAGE
+#ifdef GL_DAMAGE
glDisable(GL_SCISSOR_TEST);
#endif
if (wi->highlight_width > 0) {
- color = ZnGetGradientColor(wi->got_focus?wi->highlight_color:
- wi->highlight_bg_color, 0, &alpha);
+ color = ZnGetGradientColor(ISSET(wi->flags, ZN_GOT_FOCUS)?wi->highlight_color:
+ wi->highlight_bg_color, 0.0, &alpha);
alpha = ZnComposeAlpha(alpha, 100);
glColor4us(color->red, color->green, color->blue, alpha);
glBegin(GL_QUAD_STRIP);
- glVertex2f(0.0, 0.0);
- glVertex2f(wi->highlight_width, wi->highlight_width);
- glVertex2f(int_width, 0);
- glVertex2f(int_width - wi->highlight_width, wi->highlight_width);
- glVertex2f(int_width, int_height);
- glVertex2f(int_width - wi->highlight_width, int_height - wi->highlight_width);
- glVertex2f(0, int_height);
- glVertex2f(wi->highlight_width, int_height - wi->highlight_width);
- glVertex2f(0, 0);
- glVertex2f(wi->highlight_width, wi->highlight_width);
+ glVertex2d(0.0, 0.0);
+ glVertex2i(wi->highlight_width, wi->highlight_width);
+ glVertex2i(int_width, 0);
+ glVertex2i(int_width - wi->highlight_width, wi->highlight_width);
+ glVertex2i(int_width, int_height);
+ glVertex2i(int_width - wi->highlight_width, int_height - wi->highlight_width);
+ glVertex2i(0, int_height);
+ glVertex2i(wi->highlight_width, int_height - wi->highlight_width);
+ glVertex2i(0, 0);
+ glVertex2i(wi->highlight_width, wi->highlight_width);
glEnd();
}
- if ((wi->border_width > 0) && (wi->relief != RELIEF_FLAT)) {
- ZnPoint p[5];
-
- p[4].x = p[4].y = p[3].y = p[1].x = wi->highlight_width;
- p[0] = p[4];
- p[3].x = p[2].x = int_width - wi->highlight_width;
- p[2].y = p[1].y = int_height - wi->highlight_width;
- ZnRenderPolygonRelief(wi, wi->relief, wi->relief_grad,
- False, p, 5, wi->border_width);
- }
-#ifdef GLX_DAMAGE
+ if (wi->border_width > 0) {
+ if (wi->relief != ZN_RELIEF_FLAT) {
+ p[4].x = p[4].y = p[3].y = p[1].x = wi->highlight_width;
+ p[0] = p[4];
+ p[3].x = p[2].x = int_width - wi->highlight_width;
+ p[2].y = p[1].y = int_height - wi->highlight_width;
+ ZnRenderPolygonRelief(wi, wi->relief, wi->relief_grad,
+ False, p, 5, (ZnReal) wi->border_width);
+ }
+ else {
+ color = ZnGetGradientColor(wi->back_color, 0.0, &alpha);
+ alpha = ZnComposeAlpha(alpha, 100);
+ glColor4us(color->red, color->green, color->blue, alpha);
+
+ glBegin(GL_QUAD_STRIP);
+ glVertex2d(0.0, 0.0);
+ glVertex2i(wi->highlight_width, wi->highlight_width);
+ glVertex2i(int_width, 0);
+ glVertex2i(int_width - wi->highlight_width, wi->highlight_width);
+ glVertex2i(int_width, int_height);
+ glVertex2i(int_width - wi->highlight_width, int_height - wi->highlight_width);
+ glVertex2i(0, int_height);
+ glVertex2i(wi->highlight_width, int_height - wi->highlight_width);
+ glVertex2i(0, 0);
+ glVertex2i(wi->highlight_width, wi->highlight_width);
+ glEnd();
+ }
+ }
+#ifdef GL_DAMAGE
glEnable(GL_SCISSOR_TEST);
#endif
}
- /* Switch the GL buffers. */
- glXSwapBuffers(wi->dpy, ZnWindowId(wi->win));
+
glFlush();
+ /* Switch the GL buffers. */
+ ZnGLSwapBuffers(wi);
+ ZnGLRelease(wi);
/*
* Wait the end of GL update if we need to synchronize
* to monitor perfs.
*/
- if (wi->monitoring) {
- glXWaitGL();
+ if (ISSET(wi->flags, ZN_MONITORING)) {
+ ZnGLWaitGL();
}
#endif
}
else {
- XRectangle r;
+ XRectangle r, rs[4];
ZnBBox merge;
ClampDamageArea(wi);
/*
* Merge the damaged area with the exposed area.
*/
- ResetBBox(&merge);
- CopyBBox(&wi->damaged_area, &merge);
- AddBBoxToBBox(&merge, &wi->exposed_area);
- if (!IsEmptyBBox(&merge)) {
+ ZnResetBBox(&merge);
+ ZnCopyBBox(&wi->damaged_area, &merge);
+ ZnAddBBoxToBBox(&merge, &wi->exposed_area);
+ if (!ZnIsEmptyBBox(&merge)) {
/* Set the whole damaged area as clip rect. */
- wi->damaged_area.orig.x = r.x = REAL_TO_INT(wi->damaged_area.orig.x);
- wi->damaged_area.orig.y = r.y = REAL_TO_INT(wi->damaged_area.orig.y);
- wi->damaged_area.corner.x = REAL_TO_INT(wi->damaged_area.corner.x);
- wi->damaged_area.corner.y = REAL_TO_INT(wi->damaged_area.corner.y);
- r.width = wi->damaged_area.corner.x - wi->damaged_area.orig.x;
- r.height = wi->damaged_area.corner.y - wi->damaged_area.orig.y;
- pts[0] = wi->damaged_area.orig;
- pts[1] = wi->damaged_area.corner;
- TRI_STRIP1(&tristrip, pts, 2, False);
+ wi->damaged_area.orig.x = r.x = ZnNearestInt(wi->damaged_area.orig.x);
+ wi->damaged_area.orig.y = r.y = ZnNearestInt(wi->damaged_area.orig.y);
+ wi->damaged_area.corner.x = ZnNearestInt(wi->damaged_area.corner.x);
+ wi->damaged_area.corner.y = ZnNearestInt(wi->damaged_area.corner.y);
+ r.width = (unsigned short) (wi->damaged_area.corner.x - wi->damaged_area.orig.x);
+ r.height = (unsigned short) (wi->damaged_area.corner.y - wi->damaged_area.orig.y);
+ p[0] = wi->damaged_area.orig;
+ p[1] = wi->damaged_area.corner;
+ ZnTriStrip1(&tristrip, p, 2, False);
ZnPushClip(wi, &tristrip, True, True);
/* Fill the background of the double buffer pixmap. */
if (wi->tile == ZnUnspecifiedImage) {
- values.foreground = ZnPixel(ZnGetGradientColor(wi->back_color, 0, NULL));
+ values.foreground = ZnPixel(ZnGetGradientColor(wi->back_color, 0.0, NULL));
values.fill_style = FillSolid;
XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCForeground, &values);
}
else {
values.fill_style = FillTiled;
- values.tile = ZnImagePixmap(wi->tile, NULL);
+ values.tile = ZnImagePixmap(wi->tile);
values.ts_x_origin = values.ts_y_origin = 0;
XChangeGC(wi->dpy, wi->gc,
GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin,
@@ -6606,49 +7095,69 @@ Repair(WidgetInfo *wi)
merge.orig.y = MAX(merge.orig.y, wi->inset);
merge.corner.x = MIN(merge.corner.x, int_width-wi->inset);
merge.corner.y = MIN(merge.corner.y, int_height-wi->inset);
- BBox2XRect(&merge, &r);
+ ZnBBox2XRect(&merge, &r);
XCopyArea(wi->dpy,
- wi->draw_buffer, ZnWindowId(wi->win), wi->gc,
+ wi->draw_buffer, Tk_WindowId(wi->win), wi->gc,
r.x, r.y, r.width, r.height, r.x, r.y);
}
/*
* Redraw the borders.
*/
- if ((wi->border_width > 0) && (wi->relief != RELIEF_FLAT)) {
+ if (wi->border_width > 0) {
Pixmap save;
- XRectangle r;
save = wi->draw_buffer;
- wi->draw_buffer = ZnWindowId(wi->win);
- r.x = r.y = wi->highlight_width;
- r.width = int_width - 2*wi->highlight_width;
- r.height = int_height - 2*wi->highlight_width;
- ZnDrawRectangleRelief(wi, wi->relief, wi->relief_grad, &r, wi->border_width);
+ wi->draw_buffer = Tk_WindowId(wi->win);
+ if (wi->relief_grad != ZN_RELIEF_FLAT) {
+ r.x = r.y = wi->highlight_width;
+ r.width = int_width - 2*wi->highlight_width;
+ r.height = int_height - 2*wi->highlight_width;
+ ZnDrawRectangleRelief(wi, wi->relief, wi->relief_grad, &r,
+ (ZnDim) wi->border_width);
+ }
+ else {
+ XSetForeground(wi->dpy, wi->gc,
+ ZnPixel(ZnGetGradientColor(wi->back_color, 0.0, NULL)));
+ XSetFillStyle(wi->dpy, wi->gc, FillSolid);
+ rs[0].x = rs[0].y = wi->highlight_width;
+ rs[0].width = int_width - 2*wi->highlight_width;
+ rs[0].height = wi->border_width;
+ rs[1].x = int_width - wi->highlight_width - wi->border_width;
+ rs[1].y = 0;
+ rs[1].width = wi->border_width;
+ rs[1].height = int_height - 2*wi->highlight_width;
+ rs[2].x = 0;
+ rs[2].y = int_height - wi->highlight_width - wi->border_width;
+ rs[2].width = rs[0].width;
+ rs[2].height = wi->border_width;
+ rs[3].x = rs[3].y = wi->highlight_width;
+ rs[3].width = wi->border_width;
+ rs[3].height = rs[1].height;
+ XFillRectangles(wi->dpy, Tk_WindowId(wi->win), wi->gc, rs, 4);
+ }
wi->draw_buffer = save;
}
if (wi->highlight_width > 0) {
- XRectangle r[4];
-
XSetForeground(wi->dpy, wi->gc,
- ZnPixel(ZnGetGradientColor(wi->got_focus?wi->highlight_color:
- wi->highlight_bg_color, 0, NULL)));
+ ZnPixel(ZnGetGradientColor(ISSET(wi->flags, ZN_GOT_FOCUS)?wi->highlight_color:
+ wi->highlight_bg_color, 0.0, NULL)));
XSetFillStyle(wi->dpy, wi->gc, FillSolid);
- r[0].x = r[0].y = 0;
- r[0].width = int_width;
- r[0].height = wi->highlight_width;
- r[1].x = int_width - wi->highlight_width;
- r[1].y = 0;
- r[1].width = wi->highlight_width;
- r[1].height = int_height;
- r[2].x = 0;
- r[2].y = int_height - wi->highlight_width;
- r[2].width = int_width;
- r[2].height = wi->highlight_width;
- r[3].x = r[3].y = 0;
- r[3].width = wi->highlight_width;
- r[3].height = int_height;
- XFillRectangles(wi->dpy, ZnWindowId(wi->win), wi->gc, r, 4);
+ rs[0].x = rs[0].y = 0;
+ rs[0].width = int_width;
+ rs[0].height = wi->highlight_width;
+ rs[1].x = int_width - wi->highlight_width;
+ rs[1].y = 0;
+ rs[1].width = wi->highlight_width;
+ rs[1].height = int_height;
+ rs[2].x = 0;
+ rs[2].y = int_height - wi->highlight_width;
+ rs[2].width = int_width;
+ rs[2].height = wi->highlight_width;
+ rs[3].x = rs[3].y = 0;
+ rs[3].width = wi->highlight_width;
+ rs[3].height = int_height;
+ XFillRectangles(wi->dpy, Tk_WindowId(wi->win), wi->gc, rs, 4);
}
}
}
@@ -6675,17 +7184,19 @@ Repair(WidgetInfo *wi)
static void
Redisplay(ClientData client_data) /* Information about the widget. */
{
- WidgetInfo *wi = (WidgetInfo *) client_data;
+ ZnWInfo *wi = (ZnWInfo *) client_data;
- wi->update_pending = 0;
- if (!wi->realized || !Tk_IsMapped(wi->win)) {
+ CLEAR(wi->flags, ZN_UPDATE_PENDING);
+ if (ISCLEAR(wi->flags, ZN_REALIZED) || !Tk_IsMapped(wi->win)) {
return;
}
- if (wi->monitoring) {
- XStartChrono(wi->total_draw_chrono, wi->dpy, ZnWindowId(wi->win));
- ResetChronos(wi->this_draw_chrono);
- XStartChrono(wi->this_draw_chrono, wi->dpy, ZnWindowId(wi->win));
+ if (ISSET(wi->flags, ZN_MONITORING)) {
+#ifndef _WIN32
+ ZnXStartChrono(wi->total_draw_chrono, wi->dpy, Tk_WindowId(wi->win));
+ ZnResetChronos(wi->this_draw_chrono);
+ ZnXStartChrono(wi->this_draw_chrono, wi->dpy, Tk_WindowId(wi->win));
+#endif
}
do {
@@ -6703,11 +7214,11 @@ Redisplay(ClientData client_data) /* Information about the widget. */
* lead to the widget destruction, this is the reason
* for Tcl_Preserve/Tcl_Release.
*/
- if (ISSET(wi->events_flags, INTERNAL_NEED_REPICK)) {
+ if (ISSET(wi->flags, ZN_INTERNAL_NEED_REPICK)) {
Tk_Window tkwin;
Tcl_Preserve((ClientData) wi);
- CLEAR(wi->events_flags, INTERNAL_NEED_REPICK);
+ CLEAR(wi->flags, ZN_INTERNAL_NEED_REPICK);
PickCurrentItem(wi, &wi->pick_event);
tkwin = wi->win;
Tcl_Release((ClientData) wi);
@@ -6718,7 +7229,7 @@ Redisplay(ClientData client_data) /* Information about the widget. */
}
while (ISSET(wi->top_group->inv_flags, ZN_COORDS_FLAG) ||
ISSET(wi->top_group->inv_flags, ZN_TRANSFO_FLAG) ||
- ISSET(wi->events_flags, INTERNAL_NEED_REPICK));
+ ISSET(wi->flags, ZN_INTERNAL_NEED_REPICK));
/*
* Repair the scene where it is no longer up to date,
@@ -6729,12 +7240,18 @@ Redisplay(ClientData client_data) /* Information about the widget. */
/*
* Reset the exposed & damaged areas.
*/
- ResetBBox(&wi->exposed_area);
- ResetBBox(&wi->damaged_area);
+ ZnResetBBox(&wi->exposed_area);
+ ZnResetBBox(&wi->damaged_area);
- if (wi->monitoring) {
- XStopChrono(wi->total_draw_chrono, wi->dpy, ZnWindowId(wi->win));
- XStopChrono(wi->this_draw_chrono, wi->dpy, ZnWindowId(wi->win));
+ if (ISSET(wi->flags, ZN_MONITORING)) {
+#ifndef _WIN32
+ ZnXStopChrono(wi->total_draw_chrono, wi->dpy, Tk_WindowId(wi->win));
+ ZnXStopChrono(wi->this_draw_chrono, wi->dpy, Tk_WindowId(wi->win));
+#endif
+ }
+
+ if (ISSET(wi->flags, ZN_UPDATE_SCROLLBARS)) {
+ UpdateScrollbars(wi);
}
}
@@ -6743,7 +7260,7 @@ static void
InitZinc(Tcl_Interp *interp) {
static ZnBool inited = False;
unsigned int i, x, y, bit;
- char name[INTEGER_SPACE + 20];
+ char name[TCL_INTEGER_SPACE + 20];
if (inited) {
return;
@@ -6758,7 +7275,7 @@ InitZinc(Tcl_Interp *interp) {
SYMBOLS_BITS[i], SYMBOL_WIDTH, SYMBOL_HEIGHT);
}
- for (i = 0; i < NUM_ALPHA_STEPS; i++) {
+ for (i = 0; i < ZN_NUM_ALPHA_STEPS; i++) {
for (y = 0; y < 4; y++) {
bitmaps[i][y][0] = 0;
for (x = 0; x < 4; x++) {
@@ -6816,6 +7333,10 @@ InitZinc(Tcl_Interp *interp) {
inited = True;
}
+#ifdef BUILD_Tkzinc
+# undef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLEXPORT
+#endif
/*
*----------------------------------------------------------------------
@@ -6827,41 +7348,39 @@ InitZinc(Tcl_Interp *interp) {
*
*----------------------------------------------------------------------
*/
-int
+EXTERN int
Tkzinc_Init(Tcl_Interp *interp) /* Used for error reporting. */
{
+#ifndef PTK
if (
-#ifdef USE_TCL_STUBS
- Tcl_InitStubs(interp, "8.2", 0)
-#else
- Tcl_PkgRequire(interp, "Tcl", "8.2", 0)
-#endif
- == NULL) {
+# ifdef USE_TCL_STUBS
+ Tcl_InitStubs(interp, "8.4", 0)
+# else
+ Tcl_PkgRequire(interp, "Tcl", "8.4", 0)
+# endif
+ == NULL) {
return TCL_ERROR;
}
+
if (
-#ifdef USE_TK_STUBS
- Tk_InitStubs(interp, "8.2", 0)
-#else
- Tcl_PkgRequire(interp, "Tk", "8.2", 0)
-#endif
- == NULL) {
+# ifdef USE_TK_STUBS
+ Tk_InitStubs(interp, "8.4", 0)
+# else
+ Tcl_PkgRequire(interp, "Tk", "8.4", 0)
+# endif
+ == NULL) {
return TCL_ERROR;
}
-
+#endif
/*
* Create additional commands
*/
- if (Tcl_PkgProvide(interp, "Tkzinc", "3.2") == ZN_ERROR) {
- return ZN_ERROR;
- }
-
Tcl_CreateObjCommand(interp, "zinc", ZincObjCmd,
(ClientData) Tk_MainWindow(interp),
(Tcl_CmdDeleteProc *) NULL);
- Tcl_CreateObjCommand(interp, "mapinfo", MapInfoObjCmd,
+ Tcl_CreateObjCommand(interp, "mapinfo", ZnMapInfoObjCmd,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
- Tcl_CreateObjCommand(interp, "videomap", VideomapObjCmd,
+ Tcl_CreateObjCommand(interp, "videomap", ZnVideomapObjCmd,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
/*
@@ -6869,11 +7388,45 @@ Tkzinc_Init(Tcl_Interp *interp) /* Used for error reporting. */
*/
OmInit();
+#ifndef PTK
+ if (Tcl_PkgProvide(interp, "Tkzinc", VERSION) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+#endif
+
return TCL_OK;
}
-int
+EXTERN int
Tkzinc_debug_Init(Tcl_Interp *interp) /* Used for error reporting. */
{
return Tkzinc_Init(interp);
}
+
+#ifdef _WIN32
+/*
+ *----------------------------------------------------------------------
+ *
+ * DllEntryPoint --
+ *
+ * This wrapper function is used by Windows to invoke the
+ * initialization code for the DLL. If we are compiling
+ * with Visual C++, this routine will be renamed to DllMain.
+ * routine.
+ *
+ * Results:
+ * Returns TRUE;
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+BOOL APIENTRY
+DllEntryPoint(HINSTANCE hInst __unused, /* Library instance handle. */
+ DWORD reason __unused, /* Reason this function is being called. */
+ LPVOID reserved __unused) /* Not used. */
+{
+ return TRUE;
+}
+#endif